From 19e45799a5e3b3b9137cad4a1db94d64dce9ae76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Medzi=C5=84ski?= Date: Fri, 5 Aug 2016 14:29:09 +0200 Subject: [PATCH] Updated error message E0282 --- src/librustc/traits/error_reporting.rs | 10 ++++++---- src/test/compile-fail/issue-12187-1.rs | 4 +++- src/test/compile-fail/issue-12187-2.rs | 4 +++- src/test/compile-fail/issue-23041.rs | 2 ++ src/test/compile-fail/issue-5062.rs | 2 +- src/test/compile-fail/issue-6458-2.rs | 2 +- src/test/compile-fail/issue-6458-3.rs | 4 +++- src/test/compile-fail/issue-6458-4.rs | 4 +++- src/test/compile-fail/issue-6458.rs | 4 +++- src/test/compile-fail/issue-7813.rs | 4 +++- .../method-ambig-one-trait-unknown-int-type.rs | 2 +- .../traits-multidispatch-convert-ambig-dest.rs | 4 +++- src/test/compile-fail/unconstrained-none.rs | 4 +++- src/test/compile-fail/unconstrained-ref.rs | 4 +++- src/test/compile-fail/vector-no-ann.rs | 4 +++- 15 files changed, 41 insertions(+), 17 deletions(-) diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 67ad887530eb3..9950560b13a5a 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 5322966ae2ea0..001e4b51bebc4 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 dabc0acba370e..7cbee402b3682 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 1a9bb4c29f3e0..1be082ba9bbba 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 392d38a6144f1..f5aa4fadbed88 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 acf1d766b6a11..71f2805457915 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 3f81e51efe2ef..e397805565bbd 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 7f408be9c02d4..c3f3a718ad0e2 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 c1f9dd6a4b893..a64522a0e5b75 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 327fb6adf1d54..e3cb1d0c7daaf 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 59d75c5a787a6..4f86909765ef1 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 c77494912bc75..e6545063dbd44 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 c14de98e03f14..380cdd266cd6e 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 02a3f2b9ab8d2..ba94bf613d217 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 419b8c4e1b015..25709f35246e3 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 }