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 for map_entry when two different maps used #4219

Closed
madadam opened this issue Jun 19, 2019 · 0 comments · Fixed by #4495
Closed

false positive for map_entry when two different maps used #4219

madadam opened this issue Jun 19, 2019 · 0 comments · Fixed by #4495
Labels
C-bug Category: Clippy is not doing the correct thing good-first-issue These issues are a good way to get started with Clippy L-suggestion Lint: Improving, adding or fixing lint suggestions

Comments

@madadam
Copy link

madadam commented Jun 19, 2019

Clippy wrongly triggers the map_entry lint in the following case (note the map used with contains_key is different from the one used with insert):

    let a: HashMap<String, String> = HashMap::new();
    let mut b: HashMap<String, String> = HashMap::new();

    let key = "foo".to_string();
    
    if !a.contains_key(&key) {
        b.insert(key, "baz".to_string());
    }

Link to the playground (click Tools -> Clippy): https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=b230b4300359f8ddaa4e2610d2e0dd1c

> cargo clippy -V
clippy 0.0.212 (265318d 2019-05-17)
@flip1995 flip1995 added L-suggestion Lint: Improving, adding or fixing lint suggestions good-first-issue These issues are a good way to get started with Clippy C-bug Category: Clippy is not doing the correct thing labels Jun 19, 2019
@bors bors closed this as completed in e3ae76a Sep 4, 2019
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 good-first-issue These issues are a good way to get started with Clippy L-suggestion Lint: Improving, adding or fixing lint suggestions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants