Continue parser after trailing type argument attribute

This commit is contained in:
Esteban Küber 2019-01-11 19:31:45 -08:00
parent c2d381d39d
commit 5c67ba615c
5 changed files with 20 additions and 8 deletions

View file

@ -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
}

View file

@ -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

View file

@ -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

View file

@ -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() {
}

View file

@ -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`.