Skip to content

"variable does not need to be mutable" not detected #61424

Closed
@ghost

Description

(sorry if this is an duplicate or the wrong repo 😇 )

fn main() {
    let mut name;
    name = format!("foo{}", "bar");
    dbg!(name);
}

(Playground)

Current behavior:
no warning

Expected behavior:

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

The variable clearly doesn't need to be mutable, still, nothing is detected and no warning is emitted.

Rust 1.35.0
(Using the playground, also in 1.37.0-nightly (2019-05-31 7840a0b753a065a41999))

Metadata

Metadata

Assignees

Labels

A-NLLArea: Non-lexical lifetimes (NLL)A-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

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions