@@ -315,7 +315,13 @@ impl<'a> Parser<'a> {
315
315
PatKind :: Box ( pat)
316
316
} else if self . check_inline_const ( ) {
317
317
// 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
+ }
319
325
} else if self . can_be_ident_pat ( ) {
320
326
// Parse `ident @ pat`
321
327
// This can give false positives and parse nullary enums,
@@ -716,17 +722,20 @@ impl<'a> Parser<'a> {
716
722
}
717
723
718
724
/// 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`;
722
729
|| t. kind == token:: Dot // e.g. `.5` for recovery;
723
730
|| t. can_begin_literal_maybe_minus ( ) // e.g. `42`.
724
731
|| t. is_whole_expr ( )
725
- } )
732
+ } )
726
733
}
727
734
728
735
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 ( ) {
730
739
let lo = self . token . span ;
731
740
let ( qself, path) = if self . eat_lt ( ) {
732
741
// Parse a qualified path
0 commit comments