From eaa2697be2135ba883b2dd6e13abd325628fc2e0 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 1/2] Updated error message E0282 --- src/librustc/traits/error_reporting.rs | 11 +++++++---- src/test/compile-fail/issue-23041.rs | 2 ++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 67ad887530eb3..9f6e9ee3f005e 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -870,10 +870,13 @@ 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 `{}`; \ + type annotations or generic parameter binding required", + ty); + err.note("type annotations or generic parameter binding required"); + err.span_label(span, &format!("cannot infer type about `{}`", ty)); + err.emit() } fn note_obligation_cause(&self, diff --git a/src/test/compile-fail/issue-23041.rs b/src/test/compile-fail/issue-23041.rs index 1a9bb4c29f3e0..0dffd0fbee5ea 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 about `_` + //~| NOTE type annotations or generic parameter binding required } From ff96b561fbde8f2d431e6d5c9644f74ece280588 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Medzi=C5=84ski?= Date: Fri, 5 Aug 2016 23:16:54 +0200 Subject: [PATCH 2/2] Updated E0282 to new requirements --- src/librustc/traits/error_reporting.rs | 5 ++--- src/test/compile-fail/issue-23041.rs | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 9f6e9ee3f005e..9950560b13a5a 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -871,11 +871,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { fn need_type_info(&self, span: Span, ty: Ty<'tcx>) { let mut err = struct_span_err!(self.tcx.sess, span, E0282, - "unable to infer enough type information about `{}`; \ - type annotations or generic parameter binding required", + "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 about `{}`", ty)); + err.span_label(span, &format!("cannot infer type for `{}`", ty)); err.emit() } diff --git a/src/test/compile-fail/issue-23041.rs b/src/test/compile-fail/issue-23041.rs index 0dffd0fbee5ea..1be082ba9bbba 100644 --- a/src/test/compile-fail/issue-23041.rs +++ b/src/test/compile-fail/issue-23041.rs @@ -14,6 +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 about `_` + //~| NOTE cannot infer type for `_` //~| NOTE type annotations or generic parameter binding required }