diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 3b2bca4ab3912..5550287c2933c 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -310,8 +310,12 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o { None => match rscope.anon_regions(default_span, 1) { Ok(rs) => rs[0], Err(params) => { - let mut err = struct_span_err!(self.tcx().sess, default_span, E0106, - "missing lifetime specifier"); + let ampersand_span = Span { hi: default_span.lo, ..default_span}; + + let mut err = struct_span_err!(self.tcx().sess, ampersand_span, E0106, + "missing lifetime specifier"); + err.span_label(ampersand_span, &format!("expected lifetime parameter")); + if let Some(params) = params { report_elision_failure(&mut err, params); } diff --git a/src/test/compile-fail/E0106.rs b/src/test/compile-fail/E0106.rs index f1cd530863d34..dab03f0bccfd0 100644 --- a/src/test/compile-fail/E0106.rs +++ b/src/test/compile-fail/E0106.rs @@ -9,13 +9,19 @@ // except according to those terms. struct Foo { - x: &bool, //~ ERROR E0106 + x: &bool, + //~^ ERROR E0106 + //~| NOTE expected lifetime parameter } enum Bar { A(u8), - B(&bool), //~ ERROR E0106 + B(&bool), + //~^ ERROR E0106 + //~| NOTE expected lifetime parameter } -type MyStr = &str; //~ ERROR E0106 +type MyStr = &str; + //~^ ERROR E0106 + //~| NOTE expected lifetime parameter fn main() { }