Skip to content

single_match_else false positive #4952

Closed
@Razican

Description

@Razican

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedT-async-awaitType: Issues related to async/await

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions