about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2019-01-11 19:31:45 -0800
committerEsteban Küber <esteban@kuber.com.ar>2019-01-11 19:31:45 -0800
commit5c67ba615c299d47aef592f62f1c7540e824e87f (patch)
treee57849a58dc8d74bee6aa2fc82b23a6a40a6ad22
parentc2d381d39d282c0586d50ea7d7a431ffd5ddb3fb (diff)
downloadrust-5c67ba615c299d47aef592f62f1c7540e824e87f.tar.gz
rust-5c67ba615c299d47aef592f62f1c7540e824e87f.zip
Continue parser after trailing type argument attribute
-rw-r--r--src/libsyntax/parse/parser.rs8
-rw-r--r--src/test/ui/attrs-with-no-formal-in-generics/attrs-with-no-formal-in-generics-1.stderr2
-rw-r--r--src/test/ui/attrs-with-no-formal-in-generics/attrs-with-no-formal-in-generics-2.stderr2
-rw-r--r--src/test/ui/attrs-with-no-formal-in-generics/attrs-with-no-formal-in-generics-3.rs3
-rw-r--r--src/test/ui/attrs-with-no-formal-in-generics/attrs-with-no-formal-in-generics-3.stderr13
5 files changed, 20 insertions, 8 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 1e4a26b3537..ae0296f839c 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -5255,8 +5255,12 @@ impl<'a> Parser<'a> {
                 // Check for trailing attributes and stop parsing.
                 if !attrs.is_empty() {
                     let param_kind = if seen_ty_param.is_some() { "type" } else { "lifetime" };
-                    self.span_err(attrs[0].span,
-                        &format!("trailing attribute after {} parameters", param_kind));
+                    self.struct_span_err(
+                        attrs[0].span,
+                        &format!("trailing attribute after {} parameters", param_kind),
+                    )
+                    .span_label(attrs[0].span, "attributes must go before parameters")
+                    .emit();
                 }
                 break
             }
diff --git a/src/test/ui/attrs-with-no-formal-in-generics/attrs-with-no-formal-in-generics-1.stderr b/src/test/ui/attrs-with-no-formal-in-generics/attrs-with-no-formal-in-generics-1.stderr
index 75c0d91ee17..c4c0cee5ccc 100644
--- a/src/test/ui/attrs-with-no-formal-in-generics/attrs-with-no-formal-in-generics-1.stderr
+++ b/src/test/ui/attrs-with-no-formal-in-generics/attrs-with-no-formal-in-generics-1.stderr
@@ -2,7 +2,7 @@ error: trailing attribute after lifetime parameters
   --> $DIR/attrs-with-no-formal-in-generics-1.rs:9:25
    |
 LL | impl<#[rustc_1] 'a, 'b, #[oops]> RefIntPair<'a, 'b> {
-   |                         ^^^^^^^
+   |                         ^^^^^^^ attributes must go before parameters
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/attrs-with-no-formal-in-generics/attrs-with-no-formal-in-generics-2.stderr b/src/test/ui/attrs-with-no-formal-in-generics/attrs-with-no-formal-in-generics-2.stderr
index 7585c6dd738..9099d74ce1b 100644
--- a/src/test/ui/attrs-with-no-formal-in-generics/attrs-with-no-formal-in-generics-2.stderr
+++ b/src/test/ui/attrs-with-no-formal-in-generics/attrs-with-no-formal-in-generics-2.stderr
@@ -2,7 +2,7 @@ error: trailing attribute after type parameters
   --> $DIR/attrs-with-no-formal-in-generics-2.rs:9:35
    |
 LL | impl<#[rustc_1] 'a, #[rustc_2] T, #[oops]> RefAny<'a, T> {}
-   |                                   ^^^^^^^
+   |                                   ^^^^^^^ attributes must go before parameters
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/attrs-with-no-formal-in-generics/attrs-with-no-formal-in-generics-3.rs b/src/test/ui/attrs-with-no-formal-in-generics/attrs-with-no-formal-in-generics-3.rs
index 343a2d7a563..84e242f322c 100644
--- a/src/test/ui/attrs-with-no-formal-in-generics/attrs-with-no-formal-in-generics-3.rs
+++ b/src/test/ui/attrs-with-no-formal-in-generics/attrs-with-no-formal-in-generics-3.rs
@@ -7,10 +7,9 @@ struct RefIntPair<'a, 'b>(&'a u32, &'b u32);
 fn hof_lt<Q>(_: Q)
     where Q: for <#[rustc_1] 'a, 'b, #[oops]> Fn(RefIntPair<'a,'b>) -> &'b u32
     //~^ ERROR trailing attribute after lifetime parameters
+    //~| ERROR unless otherwise specified, attributes with the prefix `rustc_` are reserved for
 {
-
 }
 
 fn main() {
-
 }
diff --git a/src/test/ui/attrs-with-no-formal-in-generics/attrs-with-no-formal-in-generics-3.stderr b/src/test/ui/attrs-with-no-formal-in-generics/attrs-with-no-formal-in-generics-3.stderr
index 91960510de4..a918a5a8d99 100644
--- a/src/test/ui/attrs-with-no-formal-in-generics/attrs-with-no-formal-in-generics-3.stderr
+++ b/src/test/ui/attrs-with-no-formal-in-generics/attrs-with-no-formal-in-generics-3.stderr
@@ -2,7 +2,16 @@ error: trailing attribute after lifetime parameters
   --> $DIR/attrs-with-no-formal-in-generics-3.rs:8:38
    |
 LL |     where Q: for <#[rustc_1] 'a, 'b, #[oops]> Fn(RefIntPair<'a,'b>) -> &'b u32
-   |                                      ^^^^^^^
+   |                                      ^^^^^^^ attributes must go before parameters
 
-error: aborting due to previous error
+error[E0658]: unless otherwise specified, attributes with the prefix `rustc_` are reserved for internal compiler diagnostics (see issue #29642)
+  --> $DIR/attrs-with-no-formal-in-generics-3.rs:8:19
+   |
+LL |     where Q: for <#[rustc_1] 'a, 'b, #[oops]> Fn(RefIntPair<'a,'b>) -> &'b u32
+   |                   ^^^^^^^^^^
+   |
+   = help: add #![feature(rustc_attrs)] to the crate attributes to enable
+
+error: aborting due to 2 previous errors
 
+For more information about this error, try `rustc --explain E0658`.