@@ -16,7 +16,7 @@ use rustc_hir::{BindingAnnotation, ByRef, HirId, MatchSource, RangeEnd};
16
16
use rustc_index:: newtype_index;
17
17
use rustc_index:: IndexVec ;
18
18
use rustc_middle:: middle:: region;
19
- use rustc_middle:: mir:: interpret:: { AllocId , Scalar } ;
19
+ use rustc_middle:: mir:: interpret:: AllocId ;
20
20
use rustc_middle:: mir:: { self , BinOp , BorrowKind , FakeReadCause , UnOp } ;
21
21
use rustc_middle:: ty:: adjustment:: PointerCoercion ;
22
22
use rustc_middle:: ty:: layout:: IntegerExt ;
@@ -1012,15 +1012,14 @@ impl<'tcx> PatRangeBoundary<'tcx> {
1012
1012
// raw data comparisons are appropriate. E.g. `unicode-normalization` has
1013
1013
// many ranges such as '\u{037A}'..='\u{037F}', and chars can be compared
1014
1014
// in this way.
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 ( ) ) ) ;
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
+ }
1019
1022
}
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) ) ,
1024
1023
_ => { }
1025
1024
}
1026
1025
0 commit comments