Add a test for a shadow
corner case
This commit is contained in:
parent
9a3f53dee6
commit
e50cfa7e77
@ -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 New Issue
Block a user