let db = span_lint(cx,
SHADOW_SAME,
span,
- &format!("{} is shadowed by itself in {}",
+ &format!("`{}` is shadowed by itself in `{}`",
snippet(cx, pattern_span, "_"),
snippet(cx, expr.span, "..")));
+
note_orig(cx, db, SHADOW_SAME, prev_span);
} else if contains_self(name, expr) {
let db = span_note_and_lint(cx,
SHADOW_REUSE,
pattern_span,
- &format!("{} is shadowed by {} which reuses the original value",
+ &format!("`{}` is shadowed by `{}` which reuses the original value",
snippet(cx, pattern_span, "_"),
snippet(cx, expr.span, "..")),
expr.span,
let db = span_note_and_lint(cx,
SHADOW_UNRELATED,
pattern_span,
- &format!("{} is shadowed by {}",
+ &format!("`{}` is shadowed by `{}`",
snippet(cx, pattern_span, "_"),
snippet(cx, expr.span, "..")),
expr.span,
fn temporary_cstring() {
use std::ffi::CString;
- ( // extra parenthesis to better test spans
+ CString::new("foo").unwrap().as_ptr();
//~^ ERROR you are getting the inner pointer of a temporary `CString`
//~| NOTE that pointer will be invalid outside this expression
- CString::new("foo").unwrap()
- //~^ HELP assign the `CString` to a variable to extend its lifetime
- ).as_ptr();
+ //~| HELP assign the `CString` to a variable to extend its lifetime
}
fn main() {
let mut x = 1;
- let x = &mut x; //~ERROR x is shadowed by itself in &mut x
- let x = { x }; //~ERROR x is shadowed by itself in { x }
- let x = (&*x); //~ERROR x is shadowed by itself in &*x
- let x = { *x + 1 }; //~ERROR x is shadowed by { *x + 1 } which reuses
- let x = id(x); //~ERROR x is shadowed by id(x) which reuses
- let x = (1, x); //~ERROR x is shadowed by (1, x) which reuses
- let x = first(x); //~ERROR x is shadowed by first(x) which reuses
+ let x = &mut x; //~ERROR `x` is shadowed by itself in `&mut x`
+ let x = { x }; //~ERROR `x` is shadowed by itself in `{ x }`
+ let x = (&*x); //~ERROR `x` is shadowed by itself in `(&*x)`
+ let x = { *x + 1 }; //~ERROR `x` is shadowed by `{ *x + 1 }` which reuses
+ let x = id(x); //~ERROR `x` is shadowed by `id(x)` which reuses
+ let x = (1, x); //~ERROR `x` is shadowed by `(1, x)` which reuses
+ let x = first(x); //~ERROR `x` is shadowed by `first(x)` which reuses
let y = 1;
- let x = y; //~ERROR x is shadowed by y
+ let x = y; //~ERROR `x` is shadowed by `y`
let o = Some(1u8);