diff --git a/src/librustc_mir/build/matches/simplify.rs b/src/librustc_mir/build/matches/simplify.rs index 7125eb6850bb6..d9b748f71f011 100644 --- a/src/librustc_mir/build/matches/simplify.rs +++ b/src/librustc_mir/build/matches/simplify.rs @@ -161,7 +161,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { PatternKind::Variant { adt_def, substs, variant_index, ref subpatterns } => { let irrefutable = adt_def.variants.iter_enumerated().all(|(i, v)| { i == variant_index || { - self.hir.tcx().features().never_type && self.hir.tcx().features().exhaustive_patterns && !v.uninhabited_from(self.hir.tcx(), substs, adt_def.adt_kind()).is_empty() } diff --git a/src/test/ui/uninhabited/exhaustive-wo-nevertype-issue-51221.rs b/src/test/ui/uninhabited/exhaustive-wo-nevertype-issue-51221.rs new file mode 100644 index 0000000000000..b59432078350e --- /dev/null +++ b/src/test/ui/uninhabited/exhaustive-wo-nevertype-issue-51221.rs @@ -0,0 +1,9 @@ +// check-pass + +#![feature(exhaustive_patterns)] + +enum Void {} +fn main() { + let a: Option = None; + let None = a; +}