Rollup merge of #35366 - medzin:E0282, r=jonathandturner

Updated error message E0282

Fixes #35312 as part of #35233.

r? @GuillaumeGomez
This commit is contained in:
Jonathan Turner 2016-08-07 09:59:41 -07:00 committed by GitHub
commit 94cb842887
15 changed files with 41 additions and 17 deletions

View File

@ -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<T>(&self,

View File

@ -14,5 +14,7 @@ fn new<T>() -> &'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
}

View File

@ -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
}

View File

@ -14,4 +14,6 @@ fn main()
fn bar(x:i32) ->i32 { 3*x };
let b:Box<Any> = Box::new(bar as fn(_)->_);
b.downcast_ref::<fn(_)->_>(); //~ ERROR E0282
//~| NOTE cannot infer type for `_`
//~| NOTE type annotations or generic parameter binding required
}

View File

@ -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]

View File

@ -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]
}

View File

@ -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
}

View File

@ -10,7 +10,9 @@
fn foo(b: bool) -> Result<bool,String> {
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() {

View File

@ -17,7 +17,9 @@ pub fn foo<State>(_: TypeWithState<State>) {}
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() {

View File

@ -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
}

View File

@ -32,7 +32,7 @@ impl foo for Vec<isize> {
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();
}

View File

@ -34,7 +34,9 @@ where T : Convert<U>
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() {}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}