Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

False positive "variable does not need to be mutable" with two closures #59620

Copy link
Copy link
@Riateche

Description

@Riateche
Issue body actions

Code:

fn main() {
    let mut i = 0;
    [].iter().for_each(|_: &i32| {
        [].iter().for_each(move |_: &i32| {
            i += 1;
        });
    });
}

Output:

warning: variable does not need to be mutable
 --> src/main.rs:3:9
  |
3 |     let mut i = 0;
  |         ----^
  |         |
  |         help: remove this `mut`
  |
  = note: #[warn(unused_mut)] on by default

    Finished dev [unoptimized + debuginfo] target(s) in 1.26s
     Running `target/debug/playground`

Removing mut breaks the code.

Stargateur

Metadata

Metadata

Assignees

Labels

A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.NLL-diagnosticsWorking towards the "diagnostic parity" goalWorking towards the "diagnostic parity" goalT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant 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

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.