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

single_match_else false positive #4952

Closed
Razican opened this issue Dec 24, 2019 · 0 comments · Fixed by #8667
Closed

single_match_else false positive #4952

Razican opened this issue Dec 24, 2019 · 0 comments · Fixed by #8667
Labels
C-bug Category: Clippy is not doing the correct thing I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied T-async-await Type: Issues related to async/await

Comments

@Razican
Copy link

Razican commented Dec 24, 2019

Hi!
I'm getting a false positive with the single_match_else lint in an async function declaration. I'm not 100% sure where this is happening, since the function has some Rocket procedural attributes in it.

First things first, cargo clippy -V:

clippy 0.0.212 (69f99e7 2019-12-14)

The code that is causing the issue is the following:

#[get("/endpoint/?<meta>")] 
async fn get_sth(
    meta: Option<bool>,
) -> &'static str {
    if meta == Some(true) {
        "meta is true!"
    } else {
        "meta is false :("
    }
}

I get this error:

warning: you seem to be trying to use match for destructuring a single pattern. Consider using `if let`
   --> src/lib.rs:176:5
    |
176 |     meta: Option<bool>,
    |     ^^^^^^^^^^^^^^^^^^ help: try this: `if let meta: Option<bool> = meta: Option<bool> { meta: Option<bool> } else meta: Option<bool>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match_else

But this is a function header, so I cannot implement the proposed solution.

@JohnTitor JohnTitor added C-bug Category: Clippy is not doing the correct thing I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied labels Dec 25, 2019
@flip1995 flip1995 added T-async-await Type: Issues related to async/await A-musing labels Dec 28, 2019
@flip1995 flip1995 removed the A-musing label Feb 6, 2021
@bors bors closed this as completed in 89ee6aa Apr 11, 2022
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-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied T-async-await Type: Issues related to async/await
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants