Skip to content

Commit 5b22d2b

Browse files
author
Jonathan Turner
authored
Rollup merge of rust-lang#35366 - medzin:E0282, r=jonathandturner
Updated error message E0282 Fixes rust-lang#35312 as part of rust-lang#35233. r? @GuillaumeGomez
2 parents 262c91f + 19e4579 commit 5b22d2b

15 files changed

+41
-17
lines changed

src/librustc/traits/error_reporting.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -870,10 +870,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
870870

871871

872872
fn need_type_info(&self, span: Span, ty: Ty<'tcx>) {
873-
span_err!(self.tcx.sess, span, E0282,
874-
"unable to infer enough type information about `{}`; \
875-
type annotations or generic parameter binding required",
876-
ty);
873+
let mut err = struct_span_err!(self.tcx.sess, span, E0282,
874+
"unable to infer enough type information about `{}`",
875+
ty);
876+
err.note("type annotations or generic parameter binding required");
877+
err.span_label(span, &format!("cannot infer type for `{}`", ty));
878+
err.emit()
877879
}
878880

879881
fn note_obligation_cause<T>(&self,

src/test/compile-fail/issue-12187-1.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,7 @@ fn new<T>() -> &'static T {
1414

1515
fn main() {
1616
let &v = new();
17-
//~^ ERROR type annotations or generic parameter binding required
17+
//~^ ERROR unable to infer enough type information about `_` [E0282]
18+
//~| NOTE cannot infer type for `_`
19+
//~| NOTE type annotations or generic parameter binding
1820
}

src/test/compile-fail/issue-12187-2.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,7 @@ fn new<'r, T>() -> &'r T {
1414

1515
fn main() {
1616
let &v = new();
17-
//~^ ERROR type annotations or generic parameter binding required
17+
//~^ ERROR unable to infer enough type information about `_` [E0282]
18+
//~| NOTE cannot infer type for `_`
19+
//~| NOTE type annotations or generic parameter binding
1820
}

src/test/compile-fail/issue-23041.rs

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

src/test/compile-fail/issue-5062.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
// except according to those terms.
1010

1111
fn main() { format!("{:?}", None); }
12-
//~^ ERROR type annotations or generic parameter binding required
12+
//~^ ERROR unable to infer enough type information about `_` [E0282]

src/test/compile-fail/issue-6458-2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
fn main() {
1212
// Unconstrained type:
1313
format!("{:?}", None);
14-
//~^ ERROR type annotations or generic parameter binding required
14+
//~^ ERROR unable to infer enough type information about `_` [E0282]
1515
}

src/test/compile-fail/issue-6458-3.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,7 @@ use std::mem;
1212

1313
fn main() {
1414
mem::transmute(0);
15-
//~^ ERROR type annotations or generic parameter binding required
15+
//~^ ERROR unable to infer enough type information about `_` [E0282]
16+
//~| NOTE cannot infer type for `_`
17+
//~| NOTE type annotations or generic parameter binding
1618
}

src/test/compile-fail/issue-6458-4.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010

1111
fn foo(b: bool) -> Result<bool,String> {
1212
Err("bar".to_string());
13-
//~^ ERROR type annotations or generic parameter binding required
13+
//~^ ERROR unable to infer enough type information about `_` [E0282]
14+
//~| NOTE cannot infer type for `_`
15+
//~| NOTE type annotations or generic parameter binding
1416
}
1517

1618
fn main() {

src/test/compile-fail/issue-6458.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ pub fn foo<State>(_: TypeWithState<State>) {}
1717

1818
pub fn bar() {
1919
foo(TypeWithState(marker::PhantomData));
20-
//~^ ERROR type annotations or generic parameter binding required
20+
//~^ ERROR unable to infer enough type information about `_` [E0282]
21+
//~| NOTE cannot infer type for `_`
22+
//~| NOTE type annotations or generic parameter binding
2123
}
2224

2325
fn main() {

src/test/compile-fail/issue-7813.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,7 @@
1010

1111
fn main() {
1212
let v = &[];
13-
let it = v.iter(); //~ ERROR type annotations or generic parameter binding required
13+
let it = v.iter(); //~ ERROR unable to infer enough type information about `_` [E0282]
14+
//~| NOTE cannot infer type for `_`
15+
//~| NOTE type annotations or generic parameter binding
1416
}

src/test/compile-fail/method-ambig-one-trait-unknown-int-type.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl foo for Vec<isize> {
3232
fn m1() {
3333
// we couldn't infer the type of the vector just based on calling foo()...
3434
let mut x = Vec::new();
35-
//~^ ERROR type annotations or generic parameter binding required
35+
//~^ ERROR unable to infer enough type information about `_` [E0282]
3636
x.foo();
3737
}
3838

src/test/compile-fail/traits-multidispatch-convert-ambig-dest.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ where T : Convert<U>
3434

3535
fn a() {
3636
test(22, std::default::Default::default());
37-
//~^ ERROR type annotations or generic parameter binding required
37+
//~^ ERROR unable to infer enough type information about `_` [E0282]
38+
//~| NOTE cannot infer type for `_`
39+
//~| NOTE type annotations or generic parameter binding
3840
}
3941

4042
fn main() {}

src/test/compile-fail/unconstrained-none.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@
1111
// Issue #5062
1212

1313
fn main() {
14-
None; //~ ERROR type annotations or generic parameter binding required
14+
None; //~ ERROR unable to infer enough type information about `_` [E0282]
15+
//~| NOTE cannot infer type for `_`
16+
//~| NOTE type annotations or generic parameter binding
1517
}

src/test/compile-fail/unconstrained-ref.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,7 @@ struct S<'a, T:'a> {
1313
}
1414

1515
fn main() {
16-
S { o: &None }; //~ ERROR type annotations or generic parameter binding required
16+
S { o: &None }; //~ ERROR unable to infer enough type information about `_` [E0282]
17+
//~| NOTE cannot infer type for `_`
18+
//~| NOTE type annotations or generic parameter binding
1719
}

src/test/compile-fail/vector-no-ann.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@
1111

1212
fn main() {
1313
let _foo = Vec::new();
14-
//~^ ERROR type annotations or generic parameter binding required
14+
//~^ ERROR unable to infer enough type information about `_` [E0282]
15+
//~| NOTE cannot infer type for `_`
16+
//~| NOTE type annotations or generic parameter binding
1517
}

0 commit comments

Comments
 (0)