Using wasm-bindgen with clippy results in warnings like those reported in https://github.com/rustwasm/wasm-bindgen/issues/1112 and like:
error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing.
--> src/change_list.rs:9:5
|
9 | #[wasm_bindgen]
| ^^^^^^^^^^^^^^^
|
= note: #[deny(clippy::drop_ref)] on by default
= note: argument has type &wasm_bindgen::JsValue
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#drop_ref
You can test it out by installing clippy:
rustup self update
rustup component add clippy
and then running clippy on wasm-bindgen/examples/request-animation-frame:
cd wasm-bindgen/examples/request-animation-frame/
cargo clippy
This should print out warnings like
warning: this function has too many arguments (8/7)
--> crates/js-sys/src/lib.rs:3798:15
|
3798 | #[wasm_bindgen]
| ^
|
= note: #[warn(clippy::too_many_arguments)] on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments
We would ideally like there to be zero clippy warnings in code generated by the #[wasm-bindgen] macro. (Note that tehre are unrelated clippy warnings in wasm-bindgen's general code base, which we are less interested in. The goal is to support folks using clippy on projects that use wasm-bindgen.)
In all the top-level items we create with the quote! { ... } macro in wasm-bindgen/crates/backend/src/codegen.rs, we need to add #[allow(clippy::*)] to the top-level item (function or static, etc...).
I鈥檇 like to pick this issue up!
Let me know if you have any questions!
Thank you so much!
I tried to fix but I have a problem.
Please read my PR.
Fixed in https://github.com/rustwasm/wasm-bindgen/pull/1207 -- thanks @T5uku5hi