about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Forral <intrepion@gmail.com>2016-08-06 07:51:53 -0700
committerOliver Forral <intrepion@gmail.com>2016-08-06 07:51:53 -0700
commit6eba89e194f6b2990239d7010ab47bfa5a7bd266 (patch)
treeb58215fdea82d9aeec3eade751724ad65bd7e050
parentb30eff7ba72a78e31acd61a2b6931919a0ad62e8 (diff)
Fixing compiler error E0121
-rw-r--r--src/librustc_typeck/collect.rs9
-rw-r--r--src/test/compile-fail/typeck_type_placeholder_item.rs34
2 files changed, 41 insertions, 2 deletions
diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs
index cb9c0496246..7d9cbb2ad41 100644
--- a/src/librustc_typeck/collect.rs
+++ b/src/librustc_typeck/collect.rs
@@ -367,8 +367,13 @@ impl<'a, 'tcx> AstConv<'tcx, 'tcx> for ItemCtxt<'a, 'tcx> {
                 _substs: Option<&mut Substs<'tcx>>,
                 _space: Option<ParamSpace>,
                 span: Span) -> Ty<'tcx> {
-        span_err!(self.tcx().sess, span, E0121,
-                  "the type placeholder `_` is not allowed within types on item signatures");
+        struct_span_err!(
+            self.tcx().sess,
+            span,
+            E0121,
+            "the type placeholder `_` is not allowed within types on item signatures"
+        ).span_label(span, &format!("not allowed in type signatures"))
+        .emit();
         self.tcx().types.err
     }
 
diff --git a/src/test/compile-fail/typeck_type_placeholder_item.rs b/src/test/compile-fail/typeck_type_placeholder_item.rs
index d4f3cdfd8b7..42db3b47a04 100644
--- a/src/test/compile-fail/typeck_type_placeholder_item.rs
+++ b/src/test/compile-fail/typeck_type_placeholder_item.rs
@@ -13,107 +13,141 @@
 
 fn test() -> _ { 5 }
 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+//~| NOTE not allowed in type signatures
 
 fn test2() -> (_, _) { (5, 5) }
 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
 //~^^ ERROR the type placeholder `_` is not allowed within types on item signatures
+//~| NOTE not allowed in type signatures
+//~| NOTE not allowed in type signatures
 
 static TEST3: _ = "test";
 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+//~| NOTE not allowed in type signatures
 
 static TEST4: _ = 145;
 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+//~| NOTE not allowed in type signatures
 
 static TEST5: (_, _) = (1, 2);
 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
 //~^^ ERROR the type placeholder `_` is not allowed within types on item signatures
+//~| NOTE not allowed in type signatures
+//~| NOTE not allowed in type signatures
 
 fn test6(_: _) { }
 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+//~| NOTE not allowed in type signatures
 
 fn test7(x: _) { let _x: usize = x; }
 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+//~| NOTE not allowed in type signatures
 
 fn test8(_f: fn() -> _) { }
 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+//~| NOTE not allowed in type signatures
 
 struct Test9;
 
 impl Test9 {
     fn test9(&self) -> _ { () }
     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+    //~| NOTE not allowed in type signatures
 
     fn test10(&self, _x : _) { }
     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+    //~| NOTE not allowed in type signatures
 }
 
 impl Clone for Test9 {
     fn clone(&self) -> _ { Test9 }
     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+    //~| NOTE not allowed in type signatures
 
     fn clone_from(&mut self, other: _) { *self = Test9; }
     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+    //~| NOTE not allowed in type signatures
 }
 
 struct Test10 {
     a: _,
     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+    //~| NOTE not allowed in type signatures
     b: (_, _),
     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
     //~^^ ERROR the type placeholder `_` is not allowed within types on item signatures
+    //~| NOTE not allowed in type signatures
+    //~| NOTE not allowed in type signatures
 }
 
 pub fn main() {
     fn fn_test() -> _ { 5 }
     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+    //~| NOTE not allowed in type signatures
 
     fn fn_test2() -> (_, _) { (5, 5) }
     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
     //~^^ ERROR the type placeholder `_` is not allowed within types on item signatures
+    //~| NOTE not allowed in type signatures
+    //~| NOTE not allowed in type signatures
 
     static FN_TEST3: _ = "test";
     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+    //~| NOTE not allowed in type signatures
 
     static FN_TEST4: _ = 145;
     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+    //~| NOTE not allowed in type signatures
 
     static FN_TEST5: (_, _) = (1, 2);
     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
     //~^^ ERROR the type placeholder `_` is not allowed within types on item signatures
+    //~| NOTE not allowed in type signatures
+    //~| NOTE not allowed in type signatures
 
     fn fn_test6(_: _) { }
     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+    //~| NOTE not allowed in type signatures
 
     fn fn_test7(x: _) { let _x: usize = x; }
     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+    //~| NOTE not allowed in type signatures
 
     fn fn_test8(_f: fn() -> _) { }
     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+    //~| NOTE not allowed in type signatures
 
     struct FnTest9;
 
     impl FnTest9 {
         fn fn_test9(&self) -> _ { () }
         //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+        //~| NOTE not allowed in type signatures
 
         fn fn_test10(&self, _x : _) { }
         //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+        //~| NOTE not allowed in type signatures
     }
 
     impl Clone for FnTest9 {
         fn clone(&self) -> _ { FnTest9 }
         //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+        //~| NOTE not allowed in type signatures
 
         fn clone_from(&mut self, other: _) { *self = FnTest9; }
         //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+        //~| NOTE not allowed in type signatures
     }
 
     struct FnTest10 {
         a: _,
         //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+        //~| NOTE not allowed in type signatures
         b: (_, _),
         //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
         //~^^ ERROR the type placeholder `_` is not allowed within types on item signatures
+        //~| NOTE not allowed in type signatures
+        //~| NOTE not allowed in type signatures
     }
 
 }