Skip to content

needless borrow does not trigger on block trailing expression #1726

Closed
@oli-obk

Description

@oli-obk
    let x = 5;
    let foo = match 42 {
        44 => &x,
        45 => {
            println!("foo");
            &&x // does not trigger needless_borrow
        },
        46 => &&x, // triggers needless_borrow
        _ => panic!(),
    };

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingC-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.I-false-negativeIssue: The lint should have been triggered on code, but wasn'tT-middleType: Probably requires verifiying types

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions