Skip to content

Commit 2139a0a

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 431eeb0 + ff96b56 commit 2139a0a

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/librustc/traits/error_reporting.rs

Lines changed: 6 additions & 4 deletions
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-23041.rs

Lines changed: 2 additions & 0 deletions
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
}

0 commit comments

Comments
 (0)