File tree Expand file tree Collapse file tree 3 files changed +7
-8
lines changed
compiler/rustc_parse/src/parser Expand file tree Collapse file tree 3 files changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -1495,8 +1495,8 @@ impl<'a> Parser<'a> {
1495
1495
err
1496
1496
} ,
1497
1497
)
1498
- } else if this. eat_keyword ( exp ! ( Const ) ) {
1499
- this. parse_const_block ( lo. to ( this. prev_token . span ) , false )
1498
+ } else if this. check_keyword ( exp ! ( Const ) ) {
1499
+ this. parse_const_block ( lo. to ( this. token . span ) , false )
1500
1500
} else if this. may_recover ( ) && this. is_do_catch_block ( ) {
1501
1501
this. recover_do_catch ( )
1502
1502
} else if this. is_try_block ( ) {
Original file line number Diff line number Diff line change @@ -1281,8 +1281,9 @@ impl<'a> Parser<'a> {
1281
1281
}
1282
1282
}
1283
1283
1284
- /// Parses inline const expressions. The `const` keyword was already eaten.
1284
+ /// Parses inline const expressions.
1285
1285
fn parse_const_block ( & mut self , span : Span , pat : bool ) -> PResult < ' a , P < Expr > > {
1286
+ self . expect_keyword ( exp ! ( Const ) ) ?;
1286
1287
let ( attrs, blk) = self . parse_inner_attrs_and_block ( None ) ?;
1287
1288
let anon_const = AnonConst {
1288
1289
id : DUMMY_NODE_ID ,
Original file line number Diff line number Diff line change @@ -779,9 +779,9 @@ impl<'a> Parser<'a> {
779
779
self . parse_pat_ident ( BindingMode ( ByRef :: Yes ( mutbl) , Mutability :: Not ) , syntax_loc) ?
780
780
} else if self . eat_keyword ( exp ! ( Box ) ) {
781
781
self . parse_pat_box ( ) ?
782
- } else if self . eat_keyword ( exp ! ( Const ) ) {
782
+ } else if self . check_keyword ( exp ! ( Const ) ) {
783
783
// Parse `const { pat }`
784
- let const_expr = self . parse_const_block ( lo. to ( self . prev_token . span ) , true ) ?;
784
+ let const_expr = self . parse_const_block ( lo. to ( self . token . span ) , true ) ?;
785
785
786
786
if let Some ( re) = self . parse_range_end ( ) {
787
787
self . parse_pat_range_begin_with ( const_expr, re) ?
@@ -1268,9 +1268,7 @@ impl<'a> Parser<'a> {
1268
1268
. then_some ( self . prev_token . span ) ;
1269
1269
1270
1270
let bound = if self . check_inline_const ( 0 ) {
1271
- let _eaten = self . eat_keyword ( exp ! ( Const ) ) ;
1272
- debug_assert ! ( _eaten) ;
1273
- self . parse_const_block ( self . prev_token . span , true )
1271
+ self . parse_const_block ( self . token . span , true )
1274
1272
} else if self . check_path ( ) {
1275
1273
let lo = self . token . span ;
1276
1274
let ( qself, path) = if self . eat_lt ( ) {
You can’t perform that action at this time.
0 commit comments