File tree 3 files changed +7
-8
lines changed
compiler/rustc_parse/src/parser
3 files changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -1473,8 +1473,8 @@ impl<'a> Parser<'a> {
1473
1473
err
1474
1474
} ,
1475
1475
)
1476
- } else if this. eat_keyword ( kw:: Const ) {
1477
- this. parse_const_block ( lo. to ( this. prev_token . span ) , false )
1476
+ } else if this. check_keyword ( kw:: Const ) {
1477
+ this. parse_const_block ( lo. to ( this. token . span ) , false )
1478
1478
} else if this. may_recover ( ) && this. is_do_catch_block ( ) {
1479
1479
this. recover_do_catch ( )
1480
1480
} else if this. is_try_block ( ) {
Original file line number Diff line number Diff line change @@ -1314,11 +1314,12 @@ impl<'a> Parser<'a> {
1314
1314
}
1315
1315
}
1316
1316
1317
- /// Parses inline const expressions. The `const` keyword was already eaten.
1317
+ /// Parses inline const expressions.
1318
1318
fn parse_const_block ( & mut self , span : Span , pat : bool ) -> PResult < ' a , P < Expr > > {
1319
1319
if pat {
1320
1320
self . psess . gated_spans . gate ( sym:: inline_const_pat, span) ;
1321
1321
}
1322
+ self . expect_keyword ( kw:: Const ) ?;
1322
1323
let ( attrs, blk) = self . parse_inner_attrs_and_block ( ) ?;
1323
1324
let anon_const = AnonConst {
1324
1325
id : DUMMY_NODE_ID ,
Original file line number Diff line number Diff line change @@ -733,9 +733,9 @@ impl<'a> Parser<'a> {
733
733
self . parse_pat_ident ( BindingMode ( ByRef :: Yes ( mutbl) , Mutability :: Not ) , syntax_loc) ?
734
734
} else if self . eat_keyword ( kw:: Box ) {
735
735
self . parse_pat_box ( ) ?
736
- } else if self . eat_keyword ( kw:: Const ) {
736
+ } else if self . check_keyword ( kw:: Const ) {
737
737
// Parse `const { pat }`
738
- let const_expr = self . parse_const_block ( lo. to ( self . prev_token . span ) , true ) ?;
738
+ let const_expr = self . parse_const_block ( lo. to ( self . token . span ) , true ) ?;
739
739
740
740
if let Some ( re) = self . parse_range_end ( ) {
741
741
self . parse_pat_range_begin_with ( const_expr, re) ?
@@ -1225,9 +1225,7 @@ impl<'a> Parser<'a> {
1225
1225
. then_some ( self . prev_token . span ) ;
1226
1226
1227
1227
let bound = if self . check_inline_const ( 0 ) {
1228
- let _eaten = self . eat_keyword ( kw:: Const ) ;
1229
- debug_assert ! ( _eaten) ;
1230
- self . parse_const_block ( self . prev_token . span , true )
1228
+ self . parse_const_block ( self . token . span , true )
1231
1229
} else if self . check_path ( ) {
1232
1230
let lo = self . token . span ;
1233
1231
let ( qself, path) = if self . eat_lt ( ) {
You can’t perform that action at this time.
0 commit comments