Skip to content

[regression - rust2018]: unused_mut lint false positives on nightly #55344

Closed
@gnzlbg

Description

@gnzlbg

I believe this is a regression in rust2018 nightly (it wasn't triggering in earlier rust2018 builds).


Playground

#![deny(warnings)]  

#[allow(unreachable_code)]
pub fn sum_nan() {
    // return;

    let mut v = 0;
    assert_eq!(v, 0);
    v = 1;
    assert_eq!(v, 1);
}

fn main() {}

works correctly, but uncommenting the return; (play) errors with:

error: variable does not need to be mutable
 --> src/main.rs:7:9
  |
7 |     let mut v = 0;
  |         ----^
  |         |
  |         help: remove this `mut`

This only happens with Rust2018 on nightly (Rust2015 works fine).

Metadata

Metadata

Labels

A-NLLArea: Non-lexical lifetimes (NLL)A-edition-2018Area: The 2018 editionA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.NLL-diagnosticsWorking towards the "diagnostic parity" goalP-mediumMedium priorityT-langRelevant to the language 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