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

mismatching_type_param_order false positive when preceded by nontrivial generic argument #8962

Closed
dtolnay opened this issue Jun 7, 2022 · 3 comments · Fixed by #9146
Closed
Assignees
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@dtolnay
Copy link
Member

dtolnay commented Jun 7, 2022

Lint Name

mismatching_type_param_order

Reproducer

pub trait Trait {}

pub struct Collection<T, R>(T, R);

impl<K, V, R> Trait for Collection<(K, V), R> {}
error: `Collection` has a similarly named generic type parameter `R` in its declaration, but in a different order
 --> src/main.rs:5:44
  |
5 | impl<K, V, R> Trait for Collection<(K, V), R> {}
  |                                            ^
  |
  = note: `-D clippy::mismatching-type-param-order` implied by `-D clippy::pedantic`
  = help: try `T`, or a name that does not conflict with `Collection`'s generic params
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mismatching_type_param_order

The R is in the correct position though. I think this code is correct as written.

Version

rustc 1.63.0-nightly (50b00252a 2022-06-06)
binary: rustc
commit-hash: 50b00252aeb77b10db04d65dc9e12ce758def4b5
commit-date: 2022-06-06
host: x86_64-unknown-linux-gnu
release: 1.63.0-nightly
LLVM version: 14.0.5

Additional Labels

No response

@dtolnay dtolnay added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Jun 7, 2022
@dtolnay
Copy link
Member Author

dtolnay commented Jun 7, 2022

Mentioning @arieluy @dswij since this lint was recently added in #8831.

dtolnay added a commit to dtolnay/cargo-tally that referenced this issue Jun 7, 2022
rust-lang/rust-clippy#8962

    error: `Collection` has a similarly named generic type parameter `R` in its declaration, but in a different order
      --> src/max.rs:22:65
       |
    22 | impl<G, K, V, R> MaxByKey<G, K, V, R> for Collection<G, (K, V), R>
       |                                                                 ^
       |
       = note: `-D clippy::mismatching-type-param-order` implied by `-D clippy::pedantic`
       = help: try `D`, or a name that does not conflict with `Collection`'s generic params
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mismatching_type_param_order
@dswij
Copy link
Member

dswij commented Jun 7, 2022

Thanks for the report

@arieluy would you be interested in taking a look at this?

@arieluy
Copy link
Contributor

arieluy commented Jun 7, 2022

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants