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

FN redundant_pattern_matching: reference to LHS op: &None #5396

Closed
matthiaskrgr opened this issue Mar 30, 2020 · 3 comments · Fixed by #6991
Closed

FN redundant_pattern_matching: reference to LHS op: &None #5396

matthiaskrgr opened this issue Mar 30, 2020 · 3 comments · Fixed by #6991
Assignees
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages good-first-issue These issues are a good way to get started with Clippy I-false-negative Issue: The lint should have been triggered on code, but wasn't L-style Lint: Belongs in the style lint group

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Mar 30, 2020

for some reason

fn use_enum(e: Option<i32>) -> bool {
    let x = if let None = &e { true } else { false };

    println!("{:?}", x);
    x
}

warns but

fn use_enum(e: Option<i32>) -> bool {
    let x = if let &None = &e { true } else { false };

    println!("{:?}", x);
    x
}

(&None) does not. :/

@matthiaskrgr matthiaskrgr added the L-style Lint: Belongs in the style lint group label Mar 30, 2020
@matthiaskrgr matthiaskrgr changed the title FN redundant_pattern_matching reference to LHS op: &None FN redundant_pattern_matching: reference to LHS op: &None Mar 30, 2020
@matthiaskrgr matthiaskrgr added the I-false-negative Issue: The lint should have been triggered on code, but wasn't label Dec 18, 2020
@camsteffen camsteffen added good-first-issue These issues are a good way to get started with Clippy C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages labels Jan 26, 2021
@besok
Copy link

besok commented Feb 23, 2021

Can i try to solve this?

@giraffate
Copy link
Contributor

Yes. FYI you can use @rustbot claim to assign the issue to yourself, https://github.com/rust-lang/rust-clippy/blob/master/CONTRIBUTING.md#finding-something-to-fiximprove.

@besok
Copy link

besok commented Feb 23, 2021

nice. @rustbot claim

bors added a commit that referenced this issue Mar 28, 2021
redundant_pattern_matching: look inside Refs

look inside refs and detect if let &None = ...

Fixes #5396

changelog:  redundant_pattern_matching: look inside Refs to fix FNs with "if let &None = .. "
@bors bors closed this as completed in e006c77 Mar 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages good-first-issue These issues are a good way to get started with Clippy I-false-negative Issue: The lint should have been triggered on code, but wasn't L-style Lint: Belongs in the style lint group
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants