Skip to content

false negative unused_mut: if let x .. = &mut #69701

@matthiaskrgr

Description

@matthiaskrgr
fn main() {
   let mut word = "hello".to_string();
   if let Some(_) = &mut word.chars().last() { // here
       word.push_str(" word");
   }
   
   println!("{}", word);
}

In this example, the mut in if let Some(char) = &mut word.chars().last() { is redundant but the compiler issued no warning.

rustc 1.43.0-nightly (4ad624882 2020-03-03)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-borrow-checkerArea: The borrow checkerA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions