Skip to content

Commit 167822c

Browse files
committed
Review
1 parent 2e766c0 commit 167822c

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

Diff for: compiler/rustc_middle/src/thir.rs

+3
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,9 @@ impl<'tcx> PatRangeBoundary<'tcx> {
979979
) -> Option<Ordering> {
980980
use PatRangeBoundary::*;
981981
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.
982985
(PosInfinity, PosInfinity) => return Some(Ordering::Equal),
983986
(NegInfinity, NegInfinity) => return Some(Ordering::Equal),
984987

Diff for: compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs

+15-7
Original file line numberDiff line numberDiff line change
@@ -1192,17 +1192,25 @@ impl ConstructorSet {
11921192
}
11931193
}
11941194
ConstructorSet::Bool => {
1195-
let mut seen_bools = [false, false];
1195+
let mut seen_false = false;
1196+
let mut seen_true = false;
11961197
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;
12021200
} else {
1203-
missing.push(Bool(b));
1201+
seen_false = true;
12041202
}
12051203
}
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+
}
12061214
}
12071215
ConstructorSet::Integers { range_1, range_2 } => {
12081216
let seen_ranges: Vec<_> =

0 commit comments

Comments
 (0)