about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorGavin Baker <gavinb@antonym.org>2016-08-30 11:04:55 +1000
committerGavin Baker <gavinb@antonym.org>2016-09-05 23:07:50 +1000
commitd53ea97bfc149da4cdd0fb1fd1beab08295ae45d (patch)
treecd3232ce918b311f4e4bbb93af3ef47f90f3ef79 /src
parent2dbf600d159a5c65b53419f1669834d1f81496a7 (diff)
downloadrust-d53ea97bfc149da4cdd0fb1fd1beab08295ae45d.tar.gz
rust-d53ea97bfc149da4cdd0fb1fd1beab08295ae45d.zip
E0516 Update error format #36108
- fixes #36108
- part of #35233
Diffstat (limited to 'src')
-rw-r--r--src/librustc/hir/check_attr.rs18
-rw-r--r--src/librustc_typeck/astconv.rs7
-rw-r--r--src/test/compile-fail/E0516.rs1
3 files changed, 18 insertions, 8 deletions
diff --git a/src/librustc/hir/check_attr.rs b/src/librustc/hir/check_attr.rs
index a2d4239388a..6997b5d7702 100644
--- a/src/librustc/hir/check_attr.rs
+++ b/src/librustc/hir/check_attr.rs
@@ -56,18 +56,21 @@ impl<'a> CheckAttrVisitor<'a> {
 
         let mut conflicting_reprs = 0;
         for word in words {
+
             let name = match word.name() {
                 Some(word) => word,
                 None => continue,
             };
 
-            let message = match &*name {
+            let word: &str = &word.name();
+            let (message, label) = match word {
                 "C" => {
                     conflicting_reprs += 1;
                     if target != Target::Struct &&
                             target != Target::Union &&
                             target != Target::Enum {
-                        "attribute should be applied to struct, enum or union"
+                                ("attribute should be applied to struct, enum or union",
+                                 "a struct, enum or union")
                     } else {
                         continue
                     }
@@ -85,7 +88,8 @@ impl<'a> CheckAttrVisitor<'a> {
                 "simd" => {
                     conflicting_reprs += 1;
                     if target != Target::Struct {
-                        "attribute should be applied to struct"
+                        ("attribute should be applied to struct",
+                         "a struct")
                     } else {
                         continue
                     }
@@ -95,15 +99,17 @@ impl<'a> CheckAttrVisitor<'a> {
                 "isize" | "usize" => {
                     conflicting_reprs += 1;
                     if target != Target::Enum {
-                        "attribute should be applied to enum"
+                        ("attribute should be applied to enum",
+                         "an enum")
                     } else {
                         continue
                     }
                 }
                 _ => continue,
             };
-
-            span_err!(self.sess, attr.span, E0517, "{}", message);
+            struct_span_err!(self.sess, attr.span, E0517, "{}", message)
+                .span_label(attr.span, &format!("requires {}", label))
+                .emit();
         }
         if conflicting_reprs > 1 {
             span_warn!(self.sess, attr.span, E0566,
diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs
index 5925d222b44..334b7a5063a 100644
--- a/src/librustc_typeck/astconv.rs
+++ b/src/librustc_typeck/astconv.rs
@@ -1769,8 +1769,11 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
                 }
             }
             hir::TyTypeof(ref _e) => {
-                span_err!(tcx.sess, ast_ty.span, E0516,
-                      "`typeof` is a reserved keyword but unimplemented");
+                struct_span_err!(tcx.sess, ast_ty.span, E0516,
+                                 "`typeof` is a reserved keyword but unimplemented")
+                    .span_label(ast_ty.span, &format!("reserved keyword"))
+                    .emit();
+
                 tcx.types.err
             }
             hir::TyInfer => {
diff --git a/src/test/compile-fail/E0516.rs b/src/test/compile-fail/E0516.rs
index a5f609de849..be2b89c5f39 100644
--- a/src/test/compile-fail/E0516.rs
+++ b/src/test/compile-fail/E0516.rs
@@ -10,4 +10,5 @@
 
 fn main() {
     let x: typeof(92) = 92; //~ ERROR E0516
+                            //~| reserved keyword
 }