File tree 1 file changed +8
-5
lines changed
compiler/rustc_middle/src
1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -1006,15 +1006,18 @@ impl<'tcx> PatRangeBoundary<'tcx> {
1006
1006
1007
1007
// This code is hot when compiling matches with many ranges. So we
1008
1008
// special-case extraction of evaluated scalars for speed, for types where
1009
- // unsigned int comparisons are appropriate . E.g. `unicode-normalization` has
1009
+ // we can do scalar comparisons . E.g. `unicode-normalization` has
1010
1010
// many ranges such as '\u{037A}'..='\u{037F}', and chars can be compared
1011
1011
// in this way.
1012
- ( Finite ( a) , Finite ( b) ) if matches ! ( ty. kind( ) , ty:: Uint ( _) | ty:: Char ) => {
1012
+ ( Finite ( a) , Finite ( b) ) if matches ! ( ty. kind( ) , ty:: Int ( _ ) | ty :: Uint ( _) | ty:: Char ) => {
1013
1013
if let ( Some ( a) , Some ( b) ) = ( a. try_to_scalar_int ( ) , b. try_to_scalar_int ( ) ) {
1014
1014
let sz = ty. primitive_size ( tcx) ;
1015
- let a = a. assert_uint ( sz) ;
1016
- let b = b. assert_uint ( sz) ;
1017
- return Some ( a. cmp ( & b) ) ;
1015
+ let cmp = match ty. kind ( ) {
1016
+ ty:: Uint ( _) | ty:: Char => a. assert_uint ( sz) . cmp ( & b. assert_uint ( sz) ) ,
1017
+ ty:: Int ( _) => a. assert_int ( sz) . cmp ( & b. assert_int ( sz) ) ,
1018
+ _ => unreachable ! ( ) ,
1019
+ } ;
1020
+ return Some ( cmp) ;
1018
1021
}
1019
1022
}
1020
1023
_ => { }
You can’t perform that action at this time.
0 commit comments