diff --git a/compiler/rustc_middle/src/thir.rs b/compiler/rustc_middle/src/thir.rs index b3ed250a16e8..8e9951dd9621 100644 --- a/compiler/rustc_middle/src/thir.rs +++ b/compiler/rustc_middle/src/thir.rs @@ -979,6 +979,9 @@ impl<'tcx> PatRangeBoundary<'tcx> { ) -> Option { 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), diff --git a/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs index cb903c1b6a65..330ed5d8f3d7 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs @@ -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<_> =