Skip to content

Compiler incorrectly warns that a variable "does not need to be mutable" #18769

Closed
@canndrew

Description

@canndrew

The following code:

#![feature(unboxed_closures)]

fn main() {
  let mut zarp: Vec<int> = Vec::new();
  let cls = move |&mut:| {
    zarp.push(3);
  };
}

Generates the following warning:

warning: variable does not need to be mutable, #[warn(unused_mut)] on by default
let mut zarp: Vec<int> = Vec::new();

However if I remove the mut from zarp it fails to compile (as it should).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions