mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 13:13:34 +00:00
Add a test for a shadow
corner case
This commit is contained in:
parent
9a3f53dee6
commit
e50cfa7e77
2 changed files with 4 additions and 1 deletions
|
@ -262,7 +262,7 @@ fn lint_shadow<T>(cx: &LateContext, name: Name, span: Span, pattern_span: Span,
|
|||
span_lint_and_then(cx,
|
||||
SHADOW_UNRELATED,
|
||||
span,
|
||||
&format!("{} shadows a previous declaration", snippet(cx, pattern_span, "_")),
|
||||
&format!("`{}` shadows a previous declaration", snippet(cx, pattern_span, "_")),
|
||||
|db| { db.span_note(prev_span, "previous binding is here"); });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,9 @@ fn main() {
|
|||
let y = 1;
|
||||
let x = y; //~ERROR `x` is shadowed by `y`
|
||||
|
||||
let x; //~ERROR `x` shadows a previous declaration
|
||||
x = 42;
|
||||
|
||||
let o = Some(1_u8);
|
||||
|
||||
if let Some(p) = o { assert_eq!(1, p); }
|
||||
|
|
Loading…
Reference in a new issue