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 @@ -1472,8 +1472,8 @@ impl<'a> Parser<'a> {
1472
1472
err
1473
1473
} ,
1474
1474
)
1475
- } else if this. eat_keyword ( kw:: Const ) {
1476
- this. parse_const_block ( lo. to ( this. prev_token . span ) , false )
1475
+ } else if this. check_keyword ( kw:: Const ) {
1476
+ this. parse_const_block ( lo. to ( this. token . span ) , false )
1477
1477
} else if this. may_recover ( ) && this. is_do_catch_block ( ) {
1478
1478
this. recover_do_catch ( )
1479
1479
} else if this. is_try_block ( ) {
Original file line number Diff line number Diff line change @@ -1302,11 +1302,12 @@ impl<'a> Parser<'a> {
1302
1302
}
1303
1303
}
1304
1304
1305
- /// Parses inline const expressions. The `const` keyword was already eaten.
1305
+ /// Parses inline const expressions.
1306
1306
fn parse_const_block ( & mut self , span : Span , pat : bool ) -> PResult < ' a , P < Expr > > {
1307
1307
if pat {
1308
1308
self . psess . gated_spans . gate ( sym:: inline_const_pat, span) ;
1309
1309
}
1310
+ self . expect_keyword ( kw:: Const ) ?;
1310
1311
let ( attrs, blk) = self . parse_inner_attrs_and_block ( ) ?;
1311
1312
let anon_const = AnonConst {
1312
1313
id : DUMMY_NODE_ID ,
Original file line number Diff line number Diff line change @@ -730,9 +730,9 @@ impl<'a> Parser<'a> {
730
730
self . parse_pat_ident ( BindingMode ( ByRef :: Yes ( mutbl) , Mutability :: Not ) , syntax_loc) ?
731
731
} else if self . eat_keyword ( kw:: Box ) {
732
732
self . parse_pat_box ( ) ?
733
- } else if self . eat_keyword ( kw:: Const ) {
733
+ } else if self . check_keyword ( kw:: Const ) {
734
734
// Parse `const { pat }`
735
- let const_expr = self . parse_const_block ( lo. to ( self . prev_token . span ) , true ) ?;
735
+ let const_expr = self . parse_const_block ( lo. to ( self . token . span ) , true ) ?;
736
736
737
737
if let Some ( re) = self . parse_range_end ( ) {
738
738
self . parse_pat_range_begin_with ( const_expr, re) ?
@@ -1220,9 +1220,7 @@ impl<'a> Parser<'a> {
1220
1220
. then_some ( self . prev_token . span ) ;
1221
1221
1222
1222
let bound = if self . check_inline_const ( 0 ) {
1223
- let _eaten = self . eat_keyword ( kw:: Const ) ;
1224
- debug_assert ! ( _eaten) ;
1225
- self . parse_const_block ( self . prev_token . span , true )
1223
+ self . parse_const_block ( self . token . span , true )
1226
1224
} else if self . check_path ( ) {
1227
1225
let lo = self . token . span ;
1228
1226
let ( qself, path) = if self . eat_lt ( ) {
You can’t perform that action at this time.
0 commit comments