@@ -315,7 +315,13 @@ impl<'a> Parser<'a> {
315315 PatKind :: Box ( pat)
316316 } else if self . check_inline_const ( ) {
317317 // Parse `const pat`
318- PatKind :: Lit ( self . parse_const_block ( lo. to ( self . token . span ) ) ?)
318+ let const_expr = self . parse_const_block ( lo. to ( self . token . span ) ) ?;
319+
320+ if let Some ( re) = self . parse_range_end ( ) {
321+ self . parse_pat_range_begin_with ( const_expr, re) ?
322+ } else {
323+ PatKind :: Lit ( const_expr)
324+ }
319325 } else if self . can_be_ident_pat ( ) {
320326 // Parse `ident @ pat`
321327 // This can give false positives and parse nullary enums,
@@ -716,17 +722,20 @@ impl<'a> Parser<'a> {
716722 }
717723
718724 /// Is the token `dist` away from the current suitable as the start of a range patterns end?
719- fn is_pat_range_end_start ( & self , dist : usize ) -> bool {
720- self . look_ahead ( dist, |t| {
721- t. is_path_start ( ) // e.g. `MY_CONST`;
725+ fn is_pat_range_end_start ( & mut self , dist : usize ) -> bool {
726+ self . check_inline_const ( )
727+ || self . look_ahead ( dist, |t| {
728+ t. is_path_start ( ) // e.g. `MY_CONST`;
722729 || t. kind == token:: Dot // e.g. `.5` for recovery;
723730 || t. can_begin_literal_maybe_minus ( ) // e.g. `42`.
724731 || t. is_whole_expr ( )
725- } )
732+ } )
726733 }
727734
728735 fn parse_pat_range_end ( & mut self ) -> PResult < ' a , P < Expr > > {
729- if self . check_path ( ) {
736+ if self . check_inline_const ( ) {
737+ self . parse_const_block ( self . token . span )
738+ } else if self . check_path ( ) {
730739 let lo = self . token . span ;
731740 let ( qself, path) = if self . eat_lt ( ) {
732741 // Parse a qualified path
0 commit comments