about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAntti Keränen <detegr@gmail.com>2016-08-07 10:40:38 +0300
committerAntti Keränen <detegr@gmail.com>2016-08-07 10:40:38 +0300
commite91f3f6d1296176b17042fcfba7ee5f77a847423 (patch)
tree45aecef3469e166aa1f480fdf33e46387a864726
parentac10b5f127f634a1d9a45ddf6d0f2904a2cabe42 (diff)
downloadrust-e91f3f6d1296176b17042fcfba7ee5f77a847423.tar.gz
rust-e91f3f6d1296176b17042fcfba7ee5f77a847423.zip
Update error E0118 to new format
Fixes #35251
Also changes the span of the error to the span of the type
as suggested in the bonus section of #35251
-rw-r--r--src/librustc_typeck/coherence/orphan.rs10
-rw-r--r--src/test/compile-fail/E0118.rs2
2 files changed, 7 insertions, 5 deletions
diff --git a/src/librustc_typeck/coherence/orphan.rs b/src/librustc_typeck/coherence/orphan.rs
index 49959a7a3b2..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;
                     }
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()
     }