Skip to content

Commit

Permalink
Review
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadrieril committed Oct 20, 2023
1 parent 8504900 commit 0d0da35
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
3 changes: 3 additions & 0 deletions compiler/rustc_middle/src/thir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,9 @@ impl<'tcx> PatRangeBoundary<'tcx> {
) -> Option<Ordering> {
use PatRangeBoundary::*;
match (self, other) {
// When comparing with infinities, we must remember that `0u8..` and `0u8..=255`
// describe the same range. These two shortcuts are ok, but for the rest we must check
// bit values.
(PosInfinity, PosInfinity) => return Some(Ordering::Equal),
(NegInfinity, NegInfinity) => return Some(Ordering::Equal),

Expand Down
22 changes: 15 additions & 7 deletions compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1192,17 +1192,25 @@ impl ConstructorSet {
}
}
ConstructorSet::Bool => {
let mut seen_bools = [false, false];
let mut seen_false = false;
let mut seen_true = false;
for b in seen.map(|ctor| ctor.as_bool().unwrap()) {
seen_bools[b as usize] = true;
}
for b in [true, false] {
if seen_bools[b as usize] {
present.push(Bool(b));
if b {
seen_true = true;
} else {
missing.push(Bool(b));
seen_false = true;
}
}
if seen_false {
present.push(Bool(false));
} else {
missing.push(Bool(false));
}
if seen_true {
present.push(Bool(true));
} else {
missing.push(Bool(true));
}
}
ConstructorSet::Integers { range_1, range_2 } => {
let seen_ranges: Vec<_> =
Expand Down

0 comments on commit 0d0da35

Please sign in to comment.