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 @@ -1472,8 +1472,8 @@ impl<'a> Parser<'a> {
14721472 err
14731473 } ,
14741474 )
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 )
14771477 } else if this. may_recover ( ) && this. is_do_catch_block ( ) {
14781478 this. recover_do_catch ( )
14791479 } else if this. is_try_block ( ) {
Original file line number Diff line number Diff line change @@ -1299,11 +1299,12 @@ impl<'a> Parser<'a> {
12991299 }
13001300 }
13011301
1302- /// Parses inline const expressions. The `const` keyword was already eaten.
1302+ /// Parses inline const expressions.
13031303 fn parse_const_block ( & mut self , span : Span , pat : bool ) -> PResult < ' a , P < Expr > > {
13041304 if pat {
13051305 self . psess . gated_spans . gate ( sym:: inline_const_pat, span) ;
13061306 }
1307+ self . expect_keyword ( kw:: Const ) ?;
13071308 let ( attrs, blk) = self . parse_inner_attrs_and_block ( ) ?;
13081309 let anon_const = AnonConst {
13091310 id : DUMMY_NODE_ID ,
Original file line number Diff line number Diff line change @@ -730,9 +730,9 @@ impl<'a> Parser<'a> {
730730 self . parse_pat_ident ( BindingMode ( ByRef :: Yes ( mutbl) , Mutability :: Not ) , syntax_loc) ?
731731 } else if self . eat_keyword ( kw:: Box ) {
732732 self . parse_pat_box ( ) ?
733- } else if self . eat_keyword ( kw:: Const ) {
733+ } else if self . check_keyword ( kw:: Const ) {
734734 // 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 ) ?;
736736
737737 if let Some ( re) = self . parse_range_end ( ) {
738738 self . parse_pat_range_begin_with ( const_expr, re) ?
@@ -1220,9 +1220,7 @@ impl<'a> Parser<'a> {
12201220 . then_some ( self . prev_token . span ) ;
12211221
12221222 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 )
12261224 } else if self . check_path ( ) {
12271225 let lo = self . token . span ;
12281226 let ( qself, path) = if self . eat_lt ( ) {
You can’t perform that action at this time.
0 commit comments