Wasm-bindgen: Add #[allow(clippy::*)] to all our macro-generated Rust code

Created on 23 Jan 2019  路  4Comments  路  Source: rustwasm/wasm-bindgen

What

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.)

How to fix

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...).

assigned codegen good first issue help wanted

All 4 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alexcrichton picture alexcrichton  路  3Comments

expobrain picture expobrain  路  4Comments

MarcAntoine-Arnaud picture MarcAntoine-Arnaud  路  3Comments

gitmko0 picture gitmko0  路  3Comments

d3lm picture d3lm  路  3Comments