Open
Description
Given the following code:
fn foo(x: u32) -> u32 {
let a = 100;
let b = 200;
let c = 300;
match x {
c => 3,
b => 2,
a => 1,
_ => 0
}
}
we currently emit:
warning: unreachable pattern
--> <source>:8:7
|
7 | c => 3,
| - matches any value
8 | b => 2,
| ^ unreachable pattern
|
= note: `#[warn(unreachable_patterns)]` on by default
However, in this case, the developer was likely confused and thought they were matching on the value of c
, not creating a binding of with name c
. We should emit something more similar to:
warning: match arm binding shadows local binding
--> <source>:8:7
|
7 | c => 3,
| ^
= note: shadows local binding `c` declared at <source>:4:7
= note: `#[warn(arm_binding_shadows_local)]` on by default
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Category: An issue proposing an enhancement or a PR with one.Diagnostics: Confusing error or lint; hard to understand for new users.Relevant to the compiler team, which will review and decide on the PR/issue.