-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
False positive wrong_self_convention inside trait impls #6983
Comments
rust-lang/rust-clippy#6983 warning: methods with the following characteristics: (`to_*` and `self` type is `Copy`) usually take `self` by value --> src/to_tokens.rs:80:18 | 80 | fn to_tokens(&self, tokens: &mut TokenStream) { | ^^^^^ | = note: `#[warn(clippy::wrong_self_convention)]` on by default = help: consider choosing a less ambiguous name = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#wrong_self_convention
rust-lang/rust-clippy#6983 error: methods with the following characteristics: (`to_*` and `self` type is `Copy`) usually take `self` by value --> src/token.rs:563:18 | 563 | fn to_tokens(&self, tokens: &mut TokenStream) { | ^^^^^ | = note: `-D clippy::wrong-self-convention` implied by `-D clippy::all` = help: consider choosing a less ambiguous name = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#wrong_self_convention
rust-lang/rust-clippy#6983 warning: methods with the following characteristics: (`to_*` and `self` type is `Copy`) usually take `self` by value --> macro/src/syntax/discriminant.rs:194:18 | 194 | fn to_tokens(&self, tokens: &mut TokenStream) { | ^^^^^ | = note: `#[warn(clippy::wrong_self_convention)]` on by default = help: consider choosing a less ambiguous name = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#wrong_self_convention
Mentioning @matthiaskrgr too since I am surprised this was not caught by b9a7a2a -- all three of the above affected crates (quote, syn, cxx) are in lintcheck_crates.
|
Oops. I was under the impression that methods taking |
this is even more problematic because the trait |
Beginning with the most recent nightly (clippy 0.1.53 5e65467 2021-03-26, rustc 1.53.0-nightly 5e65467 2021-03-26) the following code incorrectly triggers
wrong_self_convention
. The trait method signature is controlled by the trait; it doesn't matter that the impl is for a type implementingCopy
, that doesn't mean that the trait can or should take self by value. In particular there are likely other impls which are not Copy.Mentioning @mgacek8 @llogiq who touched this lint recently in #6924.
The text was updated successfully, but these errors were encountered: