Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress clippy's too many arguments from the generated ctor #13

Open
Arnavion opened this issue Jan 28, 2017 · 2 comments
Open

Suppress clippy's too many arguments from the generated ctor #13

Arnavion opened this issue Jan 28, 2017 · 2 comments

Comments

@Arnavion
Copy link
Contributor

If a struct has too many members, cargo clippy will complain that the ctor has too many parameters:

warning: this function has too many arguments (16/7), #[warn(too_many_arguments)] on by default
  --> src\search.rs:10:37
   |
10 | #[derive(Clone, Debug, Deserialize, new, getters)]
   |                                     ^^^
   |
   = help: for further information visit https://github.com/Manishearth/rust-clippy/wiki#too_many_arguments

Emitting a #[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))] on the ctor should do it, I think.

@dtolnay
Copy link
Contributor

dtolnay commented Jan 28, 2017

I don't agree with this. A function can have too many arguments whether it is handwritten or generated code. (Of course if it is only called from generated code, that is a different story.)

The lint is saying maybe you shouldn't put #[derive(new)] on a struct with that many members. If the user wants to ignore that lint, the allow(too_many_arguments) should go in their code not in derive-new.

@Arnavion
Copy link
Contributor Author

Arnavion commented Jan 28, 2017

That's fine, then the codegen will need to inherit the #[allow] from the original struct (which core Rust attributes do as well).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants