Skip to content

unused_mut lint improvement: warn when variable only copied into closure #47128

Closed

Description

Minimal example of the lint failure to fire:

fn foo() -> bool {
    let mut res = false;
    
    let mut do_thing = move || res = true;
    do_thing();
    
    res
}

foo unconditionally returns false, but the top-level binding of res doesn't get an unused_mut warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: Lints (warnings about flaws in source code) such as unused_mut.C-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions