File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
compiler/rustc_middle/src Expand file tree Collapse file tree 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> {
10061006
10071007 // This code is hot when compiling matches with many ranges. So we
10081008 // 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
10101010 // many ranges such as '\u{037A}'..='\u{037F}', and chars can be compared
10111011 // 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 ) => {
10131013 if let ( Some ( a) , Some ( b) ) = ( a. try_to_scalar_int ( ) , b. try_to_scalar_int ( ) ) {
10141014 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) ;
10181021 }
10191022 }
10201023 _ => { }
You can’t perform that action at this time.
0 commit comments