Skip to content

No warning for forward-declared variable with unused mutability #26332

Closed

Description

The compiler gives no warning for a forward-declared variable which need not be mutable.

This code:

let mut x = 5;
let y = x + 10;
println!("{}", y);

yields a warning:

<anon>:2:9: 2:14 warning: variable does not need to be mutable, #[warn(unused_mut)] on by default
<anon>:2     let mut x = 5;
                 ^~~~~

While this code does not:

let mut x;
x = 5;
let y = x + 10;
println!("{}", y);

Meta

rustc --version --verbose:
rustc 1.0.0 (a59de37 2015-05-13) (built 2015-05-14)
binary: rustc
commit-hash: a59de37
commit-date: 2015-05-13
build-date: 2015-05-14
host: x86_64-unknown-linux-gnu
release: 1.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions