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
No known key found for this signature in database
GPG key ID: 5E427C794CBA45E8
2 changed files with 4 additions and 1 deletions

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"); });
}
}

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); }