Add a test for a shadow corner case

This commit is contained in:
mcarton
2016-10-02 02:38:26 +02:00
parent 9a3f53dee6
commit e50cfa7e77
2 changed files with 4 additions and 1 deletions
+1 -1
View File
@@ -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"); });
}
}
+3
View File
@@ -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); }