@@ -16,7 +16,7 @@ use rustc_hir::{BindingAnnotation, ByRef, HirId, MatchSource, RangeEnd};
1616use rustc_index:: newtype_index;
1717use rustc_index:: IndexVec ;
1818use rustc_middle:: middle:: region;
19- use rustc_middle:: mir:: interpret:: AllocId ;
19+ use rustc_middle:: mir:: interpret:: { AllocId , Scalar } ;
2020use rustc_middle:: mir:: { self , BinOp , BorrowKind , FakeReadCause , UnOp } ;
2121use rustc_middle:: ty:: adjustment:: PointerCoercion ;
2222use rustc_middle:: ty:: layout:: IntegerExt ;
@@ -1012,14 +1012,15 @@ impl<'tcx> PatRangeBoundary<'tcx> {
10121012 // raw data comparisons are appropriate. E.g. `unicode-normalization` has
10131013 // many ranges such as '\u{037A}'..='\u{037F}', and chars can be compared
10141014 // in this way.
1015- ( Finite ( a) , Finite ( b) ) if matches ! ( ty. kind( ) , ty:: Uint ( _) | ty:: Char ) => {
1016- if let ( Some ( a) , Some ( b) ) = ( a. try_to_scalar_int ( ) , b. try_to_scalar_int ( ) ) {
1017- let sz = ty. primitive_size ( tcx) ;
1018- let a = a. assert_uint ( sz) ;
1019- let b = b. assert_uint ( sz) ;
1020- return Some ( a. cmp ( & b) ) ;
1021- }
1015+ ( Finite ( mir:: Const :: Ty ( a) ) , Finite ( mir:: Const :: Ty ( b) ) )
1016+ if matches ! ( ty. kind( ) , ty:: Uint ( _) | ty:: Char ) =>
1017+ {
1018+ return Some ( a. to_valtree ( ) . cmp ( & b. to_valtree ( ) ) ) ;
10221019 }
1020+ (
1021+ Finite ( mir:: Const :: Val ( mir:: ConstValue :: Scalar ( Scalar :: Int ( a) ) , _) ) ,
1022+ Finite ( mir:: Const :: Val ( mir:: ConstValue :: Scalar ( Scalar :: Int ( b) ) , _) ) ,
1023+ ) if matches ! ( ty. kind( ) , ty:: Uint ( _) | ty:: Char ) => return Some ( a. cmp ( & b) ) ,
10231024 _ => { }
10241025 }
10251026
0 commit comments