diff options
| author | Jonathan Turner <jonathandturner@users.noreply.github.com> | 2016-08-07 09:59:44 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-08-07 09:59:44 -0700 |
| commit | fe7b3ae13bd90105ecb4692e5cc6b3aa142e9deb (patch) | |
| tree | 4fe331ecaa26abe87be3d498adc616b49ce84c7e /src | |
| parent | a6cf011334e48bff757406f396e631a8d11f01c9 (diff) | |
| parent | e91f3f6d1296176b17042fcfba7ee5f77a847423 (diff) | |
| download | rust-fe7b3ae13bd90105ecb4692e5cc6b3aa142e9deb.tar.gz rust-fe7b3ae13bd90105ecb4692e5cc6b3aa142e9deb.zip | |
Rollup merge of #35454 - Detegr:master, r=jonathandturner
New error message format for E0117 and E0118 Part of #35233 r? @jonathandturner
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_typeck/coherence/orphan.rs | 22 | ||||
| -rw-r--r-- | src/test/compile-fail/E0117.rs | 2 | ||||
| -rw-r--r-- | src/test/compile-fail/E0118.rs | 2 |
3 files changed, 16 insertions, 10 deletions
diff --git a/src/librustc_typeck/coherence/orphan.rs b/src/librustc_typeck/coherence/orphan.rs index 15d4026254f..2f2668e9645 100644 --- a/src/librustc_typeck/coherence/orphan.rs +++ b/src/librustc_typeck/coherence/orphan.rs @@ -66,7 +66,7 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> { fn check_item(&self, item: &hir::Item) { let def_id = self.tcx.map.local_def_id(item.id); match item.node { - hir::ItemImpl(_, _, _, None, _, _) => { + hir::ItemImpl(_, _, _, None, ref ty, _) => { // For inherent impls, self type must be a nominal type // defined in this crate. debug!("coherence2::orphan check: inherent impl {}", @@ -209,11 +209,11 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> { return; } _ => { - struct_span_err!(self.tcx.sess, item.span, E0118, + struct_span_err!(self.tcx.sess, ty.span, E0118, "no base type found for inherent implementation") - .span_help(item.span, - "either implement a trait on it or create a newtype to wrap it \ - instead") + .span_label(ty.span, &format!("impl requires a base type")) + .note(&format!("either implement a trait on it or create a newtype \ + to wrap it instead")) .emit(); return; } @@ -228,12 +228,14 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> { match traits::orphan_check(self.tcx, def_id) { Ok(()) => { } Err(traits::OrphanCheckErr::NoLocalInputType) => { - span_err!( + struct_span_err!( self.tcx.sess, item.span, E0117, - "the impl does not reference any \ - types defined in this crate; \ - only traits defined in the current crate can be \ - implemented for arbitrary types"); + "only traits defined in the current crate can be \ + implemented for arbitrary types") + .span_label(item.span, &format!("impl doesn't use types inside crate")) + .note(&format!("the impl does not reference any \ + types defined in this crate")) + .emit(); return; } Err(traits::OrphanCheckErr::UncoveredTy(param_ty)) => { diff --git a/src/test/compile-fail/E0117.rs b/src/test/compile-fail/E0117.rs index 16d713bba92..e9375e67325 100644 --- a/src/test/compile-fail/E0117.rs +++ b/src/test/compile-fail/E0117.rs @@ -9,6 +9,8 @@ // except according to those terms. impl Drop for u32 {} //~ ERROR E0117 +//~^ NOTE impl doesn't use types inside crate +//~| NOTE the impl does not reference any types defined in this crate fn main() { } diff --git a/src/test/compile-fail/E0118.rs b/src/test/compile-fail/E0118.rs index d37ff34b861..3fc478f1e40 100644 --- a/src/test/compile-fail/E0118.rs +++ b/src/test/compile-fail/E0118.rs @@ -9,6 +9,8 @@ // except according to those terms. impl (u8, u8) { //~ ERROR E0118 +//~^ NOTE impl requires a base type +//~| NOTE either implement a trait on it or create a newtype to wrap it instead fn get_state(&self) -> String { String::new() } |
