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

Clippy warning for same_name_method on generated file #204

Open
Zacho2 opened this issue Feb 5, 2023 · 2 comments
Open

Clippy warning for same_name_method on generated file #204

Zacho2 opened this issue Feb 5, 2023 · 2 comments

Comments

@Zacho2
Copy link

Zacho2 commented Feb 5, 2023

Clippy warns on same_name_method because the generated code has two methods with the same name: one from a trait, another not from trait (get()/iter()).

I made a simple example to reproduce the issue: https://github.com/Zacho2/rustembed-clippy. This is basically the same as rust-embed/examples/basic.rs.

Example output from clippy:

$ cargo clippy -- -W clippy::same_name_method
    Checking rustembed-clippy v0.1.0 (/home/Documents/src/rustembed-clippy)
warning: method's name is the same as an existing method in a trait
 --> src/main.rs:3:10
  |
3 | #[derive(RustEmbed)]
  |          ^^^^^^^^^
  |
note: existing `get` defined here
 --> src/main.rs:3:10
  |
3 | #[derive(RustEmbed)]
  |          ^^^^^^^^^
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#same_name_method
  = note: requested on the command line with `-W clippy::same-name-method`
  = note: this warning originates in the derive macro `RustEmbed` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: `rustembed-clippy` (bin "rustembed-clippy") generated 1 warning
    Finished dev [unoptimized + debuginfo] target(s) in 0.17s

It seems like one option is to add #[allow(clippy::same_name_method)] to the generated code. Maybe there's another option where we can fold the generated code into one get/iter method.

@AzureMarker
Copy link
Collaborator

Unless we make a breaking change / major version, we can't remove the non-trait methods. I'd accept a PR that adds the allow attribute to the generated code.

@Zacho2
Copy link
Author

Zacho2 commented Feb 10, 2023

Alright, I plan to submit a PR for the allow attribute shortly.

@pyrossh pyrossh closed this as completed Apr 19, 2024
@pyrossh pyrossh reopened this Apr 19, 2024
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