diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 67ad887530e..9950560b13a 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -870,10 +870,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { fn need_type_info(&self, span: Span, ty: Ty<'tcx>) { - span_err!(self.tcx.sess, span, E0282, - "unable to infer enough type information about `{}`; \ - type annotations or generic parameter binding required", - ty); + let mut err = struct_span_err!(self.tcx.sess, span, E0282, + "unable to infer enough type information about `{}`", + ty); + err.note("type annotations or generic parameter binding required"); + err.span_label(span, &format!("cannot infer type for `{}`", ty)); + err.emit() } fn note_obligation_cause(&self, diff --git a/src/test/compile-fail/issue-12187-1.rs b/src/test/compile-fail/issue-12187-1.rs index 5322966ae2e..001e4b51beb 100644 --- a/src/test/compile-fail/issue-12187-1.rs +++ b/src/test/compile-fail/issue-12187-1.rs @@ -14,5 +14,7 @@ fn new() -> &'static T { fn main() { let &v = new(); - //~^ ERROR type annotations or generic parameter binding required + //~^ ERROR unable to infer enough type information about `_` [E0282] + //~| NOTE cannot infer type for `_` + //~| NOTE type annotations or generic parameter binding } diff --git a/src/test/compile-fail/issue-12187-2.rs b/src/test/compile-fail/issue-12187-2.rs index dabc0acba37..7cbee402b36 100644 --- a/src/test/compile-fail/issue-12187-2.rs +++ b/src/test/compile-fail/issue-12187-2.rs @@ -14,5 +14,7 @@ fn new<'r, T>() -> &'r T { fn main() { let &v = new(); - //~^ ERROR type annotations or generic parameter binding required + //~^ ERROR unable to infer enough type information about `_` [E0282] + //~| NOTE cannot infer type for `_` + //~| NOTE type annotations or generic parameter binding } diff --git a/src/test/compile-fail/issue-23041.rs b/src/test/compile-fail/issue-23041.rs index 1a9bb4c29f3..1be082ba9bb 100644 --- a/src/test/compile-fail/issue-23041.rs +++ b/src/test/compile-fail/issue-23041.rs @@ -14,4 +14,6 @@ fn main() fn bar(x:i32) ->i32 { 3*x }; let b:Box = Box::new(bar as fn(_)->_); b.downcast_ref::_>(); //~ ERROR E0282 + //~| NOTE cannot infer type for `_` + //~| NOTE type annotations or generic parameter binding required } diff --git a/src/test/compile-fail/issue-5062.rs b/src/test/compile-fail/issue-5062.rs index 392d38a6144..f5aa4fadbed 100644 --- a/src/test/compile-fail/issue-5062.rs +++ b/src/test/compile-fail/issue-5062.rs @@ -9,4 +9,4 @@ // except according to those terms. fn main() { format!("{:?}", None); } - //~^ ERROR type annotations or generic parameter binding required + //~^ ERROR unable to infer enough type information about `_` [E0282] diff --git a/src/test/compile-fail/issue-6458-2.rs b/src/test/compile-fail/issue-6458-2.rs index acf1d766b6a..71f28054579 100644 --- a/src/test/compile-fail/issue-6458-2.rs +++ b/src/test/compile-fail/issue-6458-2.rs @@ -11,5 +11,5 @@ fn main() { // Unconstrained type: format!("{:?}", None); - //~^ ERROR type annotations or generic parameter binding required + //~^ ERROR unable to infer enough type information about `_` [E0282] } diff --git a/src/test/compile-fail/issue-6458-3.rs b/src/test/compile-fail/issue-6458-3.rs index 3f81e51efe2..e397805565b 100644 --- a/src/test/compile-fail/issue-6458-3.rs +++ b/src/test/compile-fail/issue-6458-3.rs @@ -12,5 +12,7 @@ use std::mem; fn main() { mem::transmute(0); - //~^ ERROR type annotations or generic parameter binding required + //~^ ERROR unable to infer enough type information about `_` [E0282] + //~| NOTE cannot infer type for `_` + //~| NOTE type annotations or generic parameter binding } diff --git a/src/test/compile-fail/issue-6458-4.rs b/src/test/compile-fail/issue-6458-4.rs index 7f408be9c02..c3f3a718ad0 100644 --- a/src/test/compile-fail/issue-6458-4.rs +++ b/src/test/compile-fail/issue-6458-4.rs @@ -10,7 +10,9 @@ fn foo(b: bool) -> Result { Err("bar".to_string()); - //~^ ERROR type annotations or generic parameter binding required + //~^ ERROR unable to infer enough type information about `_` [E0282] + //~| NOTE cannot infer type for `_` + //~| NOTE type annotations or generic parameter binding } fn main() { diff --git a/src/test/compile-fail/issue-6458.rs b/src/test/compile-fail/issue-6458.rs index c1f9dd6a4b8..a64522a0e5b 100644 --- a/src/test/compile-fail/issue-6458.rs +++ b/src/test/compile-fail/issue-6458.rs @@ -17,7 +17,9 @@ pub fn foo(_: TypeWithState) {} pub fn bar() { foo(TypeWithState(marker::PhantomData)); - //~^ ERROR type annotations or generic parameter binding required + //~^ ERROR unable to infer enough type information about `_` [E0282] + //~| NOTE cannot infer type for `_` + //~| NOTE type annotations or generic parameter binding } fn main() { diff --git a/src/test/compile-fail/issue-7813.rs b/src/test/compile-fail/issue-7813.rs index 327fb6adf1d..e3cb1d0c7da 100644 --- a/src/test/compile-fail/issue-7813.rs +++ b/src/test/compile-fail/issue-7813.rs @@ -10,5 +10,7 @@ fn main() { let v = &[]; - let it = v.iter(); //~ ERROR type annotations or generic parameter binding required + let it = v.iter(); //~ ERROR unable to infer enough type information about `_` [E0282] + //~| NOTE cannot infer type for `_` + //~| NOTE type annotations or generic parameter binding } diff --git a/src/test/compile-fail/method-ambig-one-trait-unknown-int-type.rs b/src/test/compile-fail/method-ambig-one-trait-unknown-int-type.rs index 59d75c5a787..4f86909765e 100644 --- a/src/test/compile-fail/method-ambig-one-trait-unknown-int-type.rs +++ b/src/test/compile-fail/method-ambig-one-trait-unknown-int-type.rs @@ -32,7 +32,7 @@ impl foo for Vec { fn m1() { // we couldn't infer the type of the vector just based on calling foo()... let mut x = Vec::new(); - //~^ ERROR type annotations or generic parameter binding required + //~^ ERROR unable to infer enough type information about `_` [E0282] x.foo(); } diff --git a/src/test/compile-fail/traits-multidispatch-convert-ambig-dest.rs b/src/test/compile-fail/traits-multidispatch-convert-ambig-dest.rs index c77494912bc..e6545063dbd 100644 --- a/src/test/compile-fail/traits-multidispatch-convert-ambig-dest.rs +++ b/src/test/compile-fail/traits-multidispatch-convert-ambig-dest.rs @@ -34,7 +34,9 @@ where T : Convert fn a() { test(22, std::default::Default::default()); - //~^ ERROR type annotations or generic parameter binding required + //~^ ERROR unable to infer enough type information about `_` [E0282] + //~| NOTE cannot infer type for `_` + //~| NOTE type annotations or generic parameter binding } fn main() {} diff --git a/src/test/compile-fail/unconstrained-none.rs b/src/test/compile-fail/unconstrained-none.rs index c14de98e03f..380cdd266cd 100644 --- a/src/test/compile-fail/unconstrained-none.rs +++ b/src/test/compile-fail/unconstrained-none.rs @@ -11,5 +11,7 @@ // Issue #5062 fn main() { - None; //~ ERROR type annotations or generic parameter binding required + None; //~ ERROR unable to infer enough type information about `_` [E0282] + //~| NOTE cannot infer type for `_` + //~| NOTE type annotations or generic parameter binding } diff --git a/src/test/compile-fail/unconstrained-ref.rs b/src/test/compile-fail/unconstrained-ref.rs index 02a3f2b9ab8..ba94bf613d2 100644 --- a/src/test/compile-fail/unconstrained-ref.rs +++ b/src/test/compile-fail/unconstrained-ref.rs @@ -13,5 +13,7 @@ struct S<'a, T:'a> { } fn main() { - S { o: &None }; //~ ERROR type annotations or generic parameter binding required + S { o: &None }; //~ ERROR unable to infer enough type information about `_` [E0282] + //~| NOTE cannot infer type for `_` + //~| NOTE type annotations or generic parameter binding } diff --git a/src/test/compile-fail/vector-no-ann.rs b/src/test/compile-fail/vector-no-ann.rs index 419b8c4e1b0..25709f35246 100644 --- a/src/test/compile-fail/vector-no-ann.rs +++ b/src/test/compile-fail/vector-no-ann.rs @@ -11,5 +11,7 @@ fn main() { let _foo = Vec::new(); - //~^ ERROR type annotations or generic parameter binding required + //~^ ERROR unable to infer enough type information about `_` [E0282] + //~| NOTE cannot infer type for `_` + //~| NOTE type annotations or generic parameter binding }