File tree 2 files changed +18
-7
lines changed
rustc_mir_build/src/thir/pattern
2 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -979,6 +979,9 @@ impl<'tcx> PatRangeBoundary<'tcx> {
979
979
) -> Option < Ordering > {
980
980
use PatRangeBoundary :: * ;
981
981
match ( self , other) {
982
+ // When comparing with infinities, we must remember that `0u8..` and `0u8..=255`
983
+ // describe the same range. These two shortcuts are ok, but for the rest we must check
984
+ // bit values.
982
985
( PosInfinity , PosInfinity ) => return Some ( Ordering :: Equal ) ,
983
986
( NegInfinity , NegInfinity ) => return Some ( Ordering :: Equal ) ,
984
987
Original file line number Diff line number Diff line change @@ -1192,17 +1192,25 @@ impl ConstructorSet {
1192
1192
}
1193
1193
}
1194
1194
ConstructorSet :: Bool => {
1195
- let mut seen_bools = [ false , false ] ;
1195
+ let mut seen_false = false ;
1196
+ let mut seen_true = false ;
1196
1197
for b in seen. map ( |ctor| ctor. as_bool ( ) . unwrap ( ) ) {
1197
- seen_bools[ b as usize ] = true ;
1198
- }
1199
- for b in [ true , false ] {
1200
- if seen_bools[ b as usize ] {
1201
- present. push ( Bool ( b) ) ;
1198
+ if b {
1199
+ seen_true = true ;
1202
1200
} else {
1203
- missing . push ( Bool ( b ) ) ;
1201
+ seen_false = true ;
1204
1202
}
1205
1203
}
1204
+ if seen_false {
1205
+ present. push ( Bool ( false ) ) ;
1206
+ } else {
1207
+ missing. push ( Bool ( false ) ) ;
1208
+ }
1209
+ if seen_true {
1210
+ present. push ( Bool ( true ) ) ;
1211
+ } else {
1212
+ missing. push ( Bool ( true ) ) ;
1213
+ }
1206
1214
}
1207
1215
ConstructorSet :: Integers { range_1, range_2 } => {
1208
1216
let seen_ranges: Vec < _ > =
You can’t perform that action at this time.
0 commit comments