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> {
14951495 err
14961496 } ,
14971497 )
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 )
15001500 } else if this. may_recover ( ) && this. is_do_catch_block ( ) {
15011501 this. recover_do_catch ( )
15021502 } else if this. is_try_block ( ) {
Original file line number Diff line number Diff line change @@ -1281,8 +1281,9 @@ impl<'a> Parser<'a> {
12811281 }
12821282 }
12831283
1284- /// Parses inline const expressions. The `const` keyword was already eaten.
1284+ /// Parses inline const expressions.
12851285 fn parse_const_block ( & mut self , span : Span , pat : bool ) -> PResult < ' a , P < Expr > > {
1286+ self . expect_keyword ( exp ! ( Const ) ) ?;
12861287 let ( attrs, blk) = self . parse_inner_attrs_and_block ( None ) ?;
12871288 let anon_const = AnonConst {
12881289 id : DUMMY_NODE_ID ,
Original file line number Diff line number Diff line change @@ -779,9 +779,9 @@ impl<'a> Parser<'a> {
779779 self . parse_pat_ident ( BindingMode ( ByRef :: Yes ( mutbl) , Mutability :: Not ) , syntax_loc) ?
780780 } else if self . eat_keyword ( exp ! ( Box ) ) {
781781 self . parse_pat_box ( ) ?
782- } else if self . eat_keyword ( exp ! ( Const ) ) {
782+ } else if self . check_keyword ( exp ! ( Const ) ) {
783783 // 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 ) ?;
785785
786786 if let Some ( re) = self . parse_range_end ( ) {
787787 self . parse_pat_range_begin_with ( const_expr, re) ?
@@ -1268,9 +1268,7 @@ impl<'a> Parser<'a> {
12681268 . then_some ( self . prev_token . span ) ;
12691269
12701270 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 )
12741272 } else if self . check_path ( ) {
12751273 let lo = self . token . span ;
12761274 let ( qself, path) = if self . eat_lt ( ) {
You can’t perform that action at this time.
0 commit comments