@@ -142,8 +142,13 @@ impl MaybeInfiniteInt {
142142            PatRangeBoundary :: PosInfinity  => PosInfinity , 
143143        } 
144144    } 
145-     // This could change from finite to infinite if we got `usize::MAX+1` after range splitting. 
146-     fn  to_pat_range_bdy < ' tcx > ( self ,  ty :  Ty < ' tcx > ,  tcx :  TyCtxt < ' tcx > )  -> PatRangeBoundary < ' tcx >  { 
145+     /// Used only for diagnostics. 
146+ /// This could change from finite to infinite if we got `usize::MAX+1` after range splitting. 
147+ fn  to_diagnostic_pat_range_bdy < ' tcx > ( 
148+         self , 
149+         ty :  Ty < ' tcx > , 
150+         tcx :  TyCtxt < ' tcx > , 
151+     )  -> PatRangeBoundary < ' tcx >  { 
147152        match  self  { 
148153            NegInfinity  => PatRangeBoundary :: NegInfinity , 
149154            Finite ( x)  => { 
@@ -346,25 +351,25 @@ impl IntRange {
346351    /// Whether the range denotes the values before `isize::MIN` or the values after 
347352/// `usize::MAX`/`isize::MAX`. 
348353pub ( crate )  fn  is_beyond_boundaries < ' tcx > ( & self ,  ty :  Ty < ' tcx > ,  tcx :  TyCtxt < ' tcx > )  -> bool  { 
349-         // First check if we are usize/isize to avoid unnecessary `to_pat_range_bdy `. 
354+         // First check if we are usize/isize to avoid unnecessary `to_diagnostic_pat_range_bdy `. 
350355        ty. is_ptr_sized_integral ( )  && !tcx. features ( ) . precise_pointer_size_matching  && { 
351-             let  lo = self . lo . to_pat_range_bdy ( ty,  tcx) ; 
352-             let  hi = self . hi . to_pat_range_bdy ( ty,  tcx) ; 
356+             let  lo = self . lo . to_diagnostic_pat_range_bdy ( ty,  tcx) ; 
357+             let  hi = self . hi . to_diagnostic_pat_range_bdy ( ty,  tcx) ; 
353358            matches ! ( lo,  PatRangeBoundary :: PosInfinity ) 
354359                || matches ! ( hi,  PatRangeBoundary :: NegInfinity ) 
355360        } 
356361    } 
357362    /// Only used for displaying the range. 
358- fn  to_pat < ' tcx > ( & self ,  ty :  Ty < ' tcx > ,  tcx :  TyCtxt < ' tcx > )  -> Pat < ' tcx >  { 
363+ fn  to_diagnostic_pat < ' tcx > ( & self ,  ty :  Ty < ' tcx > ,  tcx :  TyCtxt < ' tcx > )  -> Pat < ' tcx >  { 
359364        let  kind = if  matches ! ( ( self . lo,  self . hi) ,  ( NegInfinity ,  PosInfinity ) )  { 
360365            PatKind :: Wild 
361366        }  else  if  self . is_singleton ( )  { 
362-             let  lo = self . lo . to_pat_range_bdy ( ty,  tcx) ; 
367+             let  lo = self . lo . to_diagnostic_pat_range_bdy ( ty,  tcx) ; 
363368            let  value = lo. as_finite ( ) . unwrap ( ) ; 
364369            PatKind :: Constant  {  value } 
365370        }  else  { 
366-             let  mut  lo = self . lo . to_pat_range_bdy ( ty,  tcx) ; 
367-             let  mut  hi = self . hi . to_pat_range_bdy ( ty,  tcx) ; 
371+             let  mut  lo = self . lo . to_diagnostic_pat_range_bdy ( ty,  tcx) ; 
372+             let  mut  hi = self . hi . to_diagnostic_pat_range_bdy ( ty,  tcx) ; 
368373            let  end = if  hi. is_finite ( )  { 
369374                RangeEnd :: Included 
370375            }  else  { 
@@ -421,7 +426,7 @@ impl IntRange {
421426            . filter_map ( |pat| Some ( ( pat. ctor ( ) . as_int_range ( ) ?,  pat. span ( ) ) ) ) 
422427            . filter ( |( range,  _) | self . suspicious_intersection ( range) ) 
423428            . map ( |( range,  span) | Overlap  { 
424-                 range :  self . intersection ( & range) . unwrap ( ) . to_pat ( pcx. ty ,  pcx. cx . tcx ) , 
429+                 range :  self . intersection ( & range) . unwrap ( ) . to_diagnostic_pat ( pcx. ty ,  pcx. cx . tcx ) , 
425430                span, 
426431            } ) 
427432            . collect ( ) ; 
@@ -1867,13 +1872,14 @@ impl<'tcx> WitnessPat<'tcx> {
18671872        self . ty 
18681873    } 
18691874
1870-     /// Convert back to a `thir::Pat` for diagnostic purposes. 
1871- pub ( crate )  fn  to_pat ( & self ,  cx :  & MatchCheckCtxt < ' _ ,  ' tcx > )  -> Pat < ' tcx >  { 
1875+     /// Convert back to a `thir::Pat` for diagnostic purposes. This panics for patterns that don't 
1876+ /// appear in diagnostics, like float ranges. 
1877+ pub ( crate )  fn  to_diagnostic_pat ( & self ,  cx :  & MatchCheckCtxt < ' _ ,  ' tcx > )  -> Pat < ' tcx >  { 
18721878        let  is_wildcard = |pat :  & Pat < ' _ > | matches ! ( pat. kind,  PatKind :: Wild ) ; 
1873-         let  mut  subpatterns = self . iter_fields ( ) . map ( |p| Box :: new ( p. to_pat ( cx) ) ) ; 
1879+         let  mut  subpatterns = self . iter_fields ( ) . map ( |p| Box :: new ( p. to_diagnostic_pat ( cx) ) ) ; 
18741880        let  kind = match  & self . ctor  { 
18751881            Bool ( b)  => PatKind :: Constant  {  value :  mir:: Const :: from_bool ( cx. tcx ,  * b)  } , 
1876-             IntRange ( range)  => return  range. to_pat ( self . ty ,  cx. tcx ) , 
1882+             IntRange ( range)  => return  range. to_diagnostic_pat ( self . ty ,  cx. tcx ) , 
18771883            Single  | Variant ( _)  => match  self . ty . kind ( )  { 
18781884                ty:: Tuple ( ..)  => PatKind :: Leaf  { 
18791885                    subpatterns :  subpatterns
0 commit comments