File tree 5 files changed +36
-5
lines changed
compiler/rustc_parse/src/parser
5 files changed +36
-5
lines changed Original file line number Diff line number Diff line change @@ -273,16 +273,23 @@ impl<'a> Parser<'a> {
273
273
let cursor_snapshot_next_calls = cursor_snapshot. num_next_calls ;
274
274
let mut end_pos = self . token_cursor . num_next_calls ;
275
275
276
+ let mut captured_trailing = false ;
277
+
276
278
// Capture a trailing token if requested by the callback 'f'
277
279
match trailing {
278
280
TrailingToken :: None => { }
281
+ TrailingToken :: Gt => {
282
+ assert_eq ! ( self . token. kind, token:: Gt ) ;
283
+ }
279
284
TrailingToken :: Semi => {
280
285
assert_eq ! ( self . token. kind, token:: Semi ) ;
281
286
end_pos += 1 ;
287
+ captured_trailing = true ;
282
288
}
283
289
TrailingToken :: MaybeComma => {
284
290
if self . token . kind == token:: Comma {
285
291
end_pos += 1 ;
292
+ captured_trailing = true ;
286
293
}
287
294
}
288
295
}
@@ -292,11 +299,7 @@ impl<'a> Parser<'a> {
292
299
// was not actually bumped past it. When the `LazyAttrTokenStream` gets converted
293
300
// into an `AttrTokenStream`, we will create the proper token.
294
301
if self . token_cursor . break_last_token {
295
- assert_eq ! (
296
- trailing,
297
- TrailingToken :: None ,
298
- "Cannot set `break_last_token` and have trailing token"
299
- ) ;
302
+ assert ! ( !captured_trailing, "Cannot set break_last_token and have trailing token" ) ;
300
303
end_pos += 1 ;
301
304
}
302
305
Original file line number Diff line number Diff line change @@ -3142,6 +3142,8 @@ impl<'a> Parser<'a> {
3142
3142
&& this. token . kind == token:: Semi
3143
3143
{
3144
3144
TrailingToken :: Semi
3145
+ } else if this. token . kind == token:: Gt {
3146
+ TrailingToken :: Gt
3145
3147
} else {
3146
3148
// FIXME - pass this through from the place where we know
3147
3149
// we need a comma, rather than assuming that `#[attr] expr,`
Original file line number Diff line number Diff line change @@ -79,6 +79,7 @@ pub enum ForceCollect {
79
79
pub enum TrailingToken {
80
80
None ,
81
81
Semi ,
82
+ Gt ,
82
83
/// If the trailing token is a comma, then capture it
83
84
/// Otherwise, ignore the trailing token
84
85
MaybeComma ,
Original file line number Diff line number Diff line change
1
+ fn main ( ) {
2
+ x:: <#[ a] y :: < z > >
3
+ //~^ ERROR invalid const generic expression
4
+ //~| ERROR cannot find value `x` in this scope
5
+ }
Original file line number Diff line number Diff line change
1
+ error: invalid const generic expression
2
+ --> $DIR/issue-103143.rs:2:13
3
+ |
4
+ LL | x::<#[a]y::<z>>
5
+ | ^^^^^^
6
+ |
7
+ help: expressions must be enclosed in braces to be used as const generic arguments
8
+ |
9
+ LL | x::<#[a]{ y::<z> }>
10
+ | + +
11
+
12
+ error[E0425]: cannot find value `x` in this scope
13
+ --> $DIR/issue-103143.rs:2:5
14
+ |
15
+ LL | x::<#[a]y::<z>>
16
+ | ^ not found in this scope
17
+
18
+ error: aborting due to 2 previous errors
19
+
20
+ For more information about this error, try `rustc --explain E0425`.
You can’t perform that action at this time.
0 commit comments