-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.T-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.
Description
Code
fn main() {
let mut x = 1;
x = 2;
x = 3;
println!("{x}");
}
Current output
warning: value assigned to `x` is never read
--> src/main.rs:2:13
|
2 | let mut x = 1;
| ^
|
= help: maybe it is overwritten before being read?
= note: `#[warn(unused_assignments)]` on by default
warning: value assigned to `x` is never read
--> src/main.rs:3:5
|
3 | x = 2;
| ^
|
= help: maybe it is overwritten before being read?
Desired output
warning: value assigned to `x` is never read
--> src/main.rs:2:13
|
2 | let mut x = 1;
| ^
3 | x = 2;
| - overwritten here before being read
= note: `#[warn(unused_assignments)]` on by default
warning: value assigned to `x` is never read
--> src/main.rs:3:5
|
3 | x = 2;
| ^
4 | x = 3;
| - overwritten here before being read
Rationale and extra context
No response
Other cases
Rust Version
1.88 + 1.90-nightly as of today
Anything else?
No response
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.T-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.