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

False Positive? Mutable key type lint is emitted on HashSets containing associated types #5020

Closed
TimoFreiberg opened this issue Jan 8, 2020 · 0 comments · Fixed by #5056
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@TimoFreiberg
Copy link

TimoFreiberg commented Jan 8, 2020

$ cargo clippy -V                                                                     
clippy 0.0.212 (e8642c7 2020-01-06)                                                   

Minimal example:

trait Trait {
    type AssociatedType;
    
    fn trait_fn(&self, set: std::collections::HashSet<Self::AssociatedType>);
}

A mutable key type lint is emitted on std::collections::HashSet<Self::AssociatedType> in the trait definition, but not in impls of that trait (interestingly not even in trait impls where Trait::AssociatedType is AtomicUsize).
While Trait::AssociatedType could be an internally mutable type, I think the correct place to lint this would be in impls that actually set Trait::AssociatedType to an internally mutable type.

Reproducible on the playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=094f6136a26c9911ee8dae0dcf94f150

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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants