Skip to content

Commit 5c67ba6

Browse files
committed
Continue parser after trailing type argument attribute
1 parent c2d381d commit 5c67ba6

File tree

5 files changed

+20
-8
lines changed

5 files changed

+20
-8
lines changed

src/libsyntax/parse/parser.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5255,8 +5255,12 @@ impl<'a> Parser<'a> {
52555255
// Check for trailing attributes and stop parsing.
52565256
if !attrs.is_empty() {
52575257
let param_kind = if seen_ty_param.is_some() { "type" } else { "lifetime" };
5258-
self.span_err(attrs[0].span,
5259-
&format!("trailing attribute after {} parameters", param_kind));
5258+
self.struct_span_err(
5259+
attrs[0].span,
5260+
&format!("trailing attribute after {} parameters", param_kind),
5261+
)
5262+
.span_label(attrs[0].span, "attributes must go before parameters")
5263+
.emit();
52605264
}
52615265
break
52625266
}

src/test/ui/attrs-with-no-formal-in-generics/attrs-with-no-formal-in-generics-1.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: trailing attribute after lifetime parameters
22
--> $DIR/attrs-with-no-formal-in-generics-1.rs:9:25
33
|
44
LL | impl<#[rustc_1] 'a, 'b, #[oops]> RefIntPair<'a, 'b> {
5-
| ^^^^^^^
5+
| ^^^^^^^ attributes must go before parameters
66

77
error: aborting due to previous error
88

src/test/ui/attrs-with-no-formal-in-generics/attrs-with-no-formal-in-generics-2.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: trailing attribute after type parameters
22
--> $DIR/attrs-with-no-formal-in-generics-2.rs:9:35
33
|
44
LL | impl<#[rustc_1] 'a, #[rustc_2] T, #[oops]> RefAny<'a, T> {}
5-
| ^^^^^^^
5+
| ^^^^^^^ attributes must go before parameters
66

77
error: aborting due to previous error
88

src/test/ui/attrs-with-no-formal-in-generics/attrs-with-no-formal-in-generics-3.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ struct RefIntPair<'a, 'b>(&'a u32, &'b u32);
77
fn hof_lt<Q>(_: Q)
88
where Q: for <#[rustc_1] 'a, 'b, #[oops]> Fn(RefIntPair<'a,'b>) -> &'b u32
99
//~^ ERROR trailing attribute after lifetime parameters
10+
//~| ERROR unless otherwise specified, attributes with the prefix `rustc_` are reserved for
1011
{
11-
1212
}
1313

1414
fn main() {
15-
1615
}

src/test/ui/attrs-with-no-formal-in-generics/attrs-with-no-formal-in-generics-3.stderr

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,16 @@ error: trailing attribute after lifetime parameters
22
--> $DIR/attrs-with-no-formal-in-generics-3.rs:8:38
33
|
44
LL | where Q: for <#[rustc_1] 'a, 'b, #[oops]> Fn(RefIntPair<'a,'b>) -> &'b u32
5-
| ^^^^^^^
5+
| ^^^^^^^ attributes must go before parameters
66

7-
error: aborting due to previous error
7+
error[E0658]: unless otherwise specified, attributes with the prefix `rustc_` are reserved for internal compiler diagnostics (see issue #29642)
8+
--> $DIR/attrs-with-no-formal-in-generics-3.rs:8:19
9+
|
10+
LL | where Q: for <#[rustc_1] 'a, 'b, #[oops]> Fn(RefIntPair<'a,'b>) -> &'b u32
11+
| ^^^^^^^^^^
12+
|
13+
= help: add #![feature(rustc_attrs)] to the crate attributes to enable
14+
15+
error: aborting due to 2 previous errors
816

17+
For more information about this error, try `rustc --explain E0658`.

0 commit comments

Comments
 (0)