wasm-bindgen
wasm-bindgen copied to clipboard
`wasm-bindgen` 0.2.92 triggers `clippy::mem_forget`
Summary
wasm-bindgen 0.2.92 triggers the Clippy rule mem_forget. Is it expected?
error: usage of `mem::forget` on `Drop` type
--> crates/biome_wasm/src/lib.rs:24:1
|
24 | #[wasm_bindgen]
| ^^^^^^^^^^^^^^^
|
= note: argument has type `wasm_bindgen::JsValue`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mem_forget
= note: this error originates in the attribute macro `wasm_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info)
I think this is the mem::forget
it's picking up on: https://github.com/rustwasm/wasm-bindgen/blob/e78db23553e70a48767a9bafaac3a4ffb4cba08d/crates/backend/src/codegen.rs#L369
There's an #[allow(clippy::all)]
right above it that's supposed to prevent issues like this, but I'm now realising that I've misunderstood how that works a bit: clippy::all
isn't actually all of clippy's lints, it's clippy's default set of lints, which doesn't include mem_forget
.
What we should really be using is #[automatically_derived]
, which does disable all lints - I'll make a PR switching it to use that.
What we should really be using is
#[automatically_derived]
, which does disable all lints - I'll make a PR switching it to use that.
Hm, seems like I was wrong: Clippy still throws a warning on this code even though it uses #[automatically_derived]
:
#![warn(clippy::mem_forget)]
struct Foo;
#[automatically_derived]
impl Foo {
fn test() {
std::mem::forget(String::new());
}
}
Searching for automatically_derived
in rustc/clippy's source code, and looking back at the original PR where we started using it (#2719), it seems like specific lints manually disable themselves if they see it, wherever it makes sense.
So I'm not really sure what the best solution is then, other than just spamming #[allow(clippy::all, clippy::nursery, clippy::pedantic, clippy::restriction)]
everywhere.