From 451ee889b2c6969406ac5956c9713aa852019aae Mon Sep 17 00:00:00 2001 From: LucaCappelletti94 Date: Thu, 1 Oct 2026 15:21:04 +0200 Subject: [PATCH] Enforce the Wasm consumer lint policy --- smoke/src/exchange.rs | 13 +++++++++---- wasm/Cargo.toml | 15 +++++++++++++++ wasm/build.rs | 8 +++++++- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/smoke/src/exchange.rs b/smoke/src/exchange.rs index d10d787..7dd9afb 100644 --- a/smoke/src/exchange.rs +++ b/smoke/src/exchange.rs @@ -43,9 +43,14 @@ impl Db { let c_name = CString::new(name).unwrap(); let mut handle = std::ptr::null_mut(); let flags = ffi::SQLITE_OPEN_READWRITE | ffi::SQLITE_OPEN_CREATE; - // `c_name` outlives the call, and SQLite copies it. + // SAFETY: `c_name` is live and NUL-terminated, and `handle` is writable for the call. let rc = unsafe { - ffi::sqlite3_open_v2(c_name.as_ptr(), &raw mut handle, flags, std::ptr::null()) + ffi::sqlite3_open_v2( + c_name.as_ptr(), + std::ptr::addr_of_mut!(handle), + flags, + std::ptr::null(), + ) }; let db = Self(handle, name.to_owned()); assert_eq!(rc, ffi::SQLITE_OK, "{name}: {}", db.error()); @@ -79,13 +84,13 @@ impl Db { pub fn text(&self, sql: &str) -> String { let c_sql = CString::new(sql).unwrap(); let mut stmt = std::ptr::null_mut(); - // `c_sql` outlives the call, which reads it up to its NUL. + // SAFETY: The connection is live, `c_sql` is NUL-terminated, and `stmt` is writable for the call. let rc = unsafe { ffi::sqlite3_prepare_v2( self.0, c_sql.as_ptr(), -1, - &raw mut stmt, + std::ptr::addr_of_mut!(stmt), std::ptr::null_mut(), ) }; diff --git a/wasm/Cargo.toml b/wasm/Cargo.toml index 964a7ee..cc9f1d2 100644 --- a/wasm/Cargo.toml +++ b/wasm/Cargo.toml @@ -14,5 +14,20 @@ sqlite-wasm-vfs = { version = "0.3", features = ["sahpool"] } sqlite3mc-src = { path = ".." } wasm-bindgen-test = "0.3" +[lints.rust] +missing_docs = "forbid" +rust_2018_idioms = { level = "warn", priority = -1 } +unreachable_pub = "warn" +unsafe_op_in_unsafe_fn = "deny" +unused_unsafe = "warn" + +[lints.clippy] +all = { level = "deny", priority = -1 } +pedantic = { level = "warn", priority = -1 } +nursery = { level = "warn", priority = -1 } +cargo = { level = "warn", priority = -1 } +allow_attributes = "deny" +allow_attributes_without_reason = "deny" + # Standalone, so the root crate never adopts it as a member. [workspace] diff --git a/wasm/build.rs b/wasm/build.rs index 4ac4e13..d351b38 100644 --- a/wasm/build.rs +++ b/wasm/build.rs @@ -19,9 +19,15 @@ fn main() { }) .collect(); files.sort(); - let mut table = String::from("pub const NATIVE_FILES: &[(&str, &[u8])] = &[\n"); + let mut table = String::from( + "/// Native encrypted fixtures embedded for interop.\npub const NATIVE_FILES: &[(&str, &[u8])] = &[\n", + ); for path in files { let name = path.file_name().unwrap().to_string_lossy().into_owned(); + #[expect( + clippy::unnecessary_debug_formatting, + reason = "Debug formatting emits a quoted and escaped Rust path literal" + )] writeln!( table, "({name:?}, include_bytes!({:?})),",