Skip to content

Commit d31b4c3

Browse files
committed
Remove fishy condition
That condition was leftover from a refactor, and was probably not intended. In fact it can't trigger: it would require a ConstantValue of an integral type for which `try_eval_bits` fails. But since we only apply `subtract_ctors` to the output of `all_ctors`, this won't happen.
1 parent e47d631 commit d31b4c3

File tree

1 file changed

+2
-24
lines changed

1 file changed

+2
-24
lines changed

src/librustc_mir/hair/pattern/_match.rs

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -611,13 +611,6 @@ impl<'tcx> Constructor<'tcx> {
611611
}
612612
}
613613

614-
fn is_integral_range(&self) -> bool {
615-
match self {
616-
IntRange(_) => return true,
617-
_ => return false,
618-
};
619-
}
620-
621614
fn variant_index_for_adt<'a>(
622615
&self,
623616
cx: &MatchCheckCtxt<'a, 'tcx>,
@@ -639,12 +632,8 @@ impl<'tcx> Constructor<'tcx> {
639632
fn subtract_ctors(&self, other_ctors: &Vec<Constructor<'tcx>>) -> Vec<Constructor<'tcx>> {
640633
match self {
641634
// Those constructors can only match themselves.
642-
Single | Variant(_) => {
643-
if other_ctors.iter().any(|c| c == self) {
644-
vec![]
645-
} else {
646-
vec![self.clone()]
647-
}
635+
Single | Variant(_) | ConstantValue(..) | ConstantRange(..) => {
636+
if other_ctors.iter().any(|c| c == self) { vec![] } else { vec![self.clone()] }
648637
}
649638
&FixedLenSlice(self_len) => {
650639
let overlaps = |c: &Constructor<'_>| match *c {
@@ -741,17 +730,6 @@ impl<'tcx> Constructor<'tcx> {
741730
// Convert the ranges back into constructors
742731
remaining_ranges.into_iter().map(IntRange).collect()
743732
}
744-
ConstantRange(..) | ConstantValue(..) => {
745-
if other_ctors.iter().any(|c| {
746-
c == self
747-
// FIXME(Nadrieril): This condition looks fishy
748-
|| c.is_integral_range()
749-
}) {
750-
vec![]
751-
} else {
752-
vec![self.clone()]
753-
}
754-
}
755733
// This constructor is never covered by anything else
756734
NonExhaustive => vec![NonExhaustive],
757735
}

0 commit comments

Comments
 (0)