From a5294b6486ea4930e0d16518851dffa51917a8e5 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Mon, 13 Apr 2020 16:23:39 +0100 Subject: [PATCH] We already handle arrays of unknown length correctly --- src/librustc_mir_build/hair/pattern/_match.rs | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/librustc_mir_build/hair/pattern/_match.rs b/src/librustc_mir_build/hair/pattern/_match.rs index 4bc6166041e..56e9c5d1188 100644 --- a/src/librustc_mir_build/hair/pattern/_match.rs +++ b/src/librustc_mir_build/hair/pattern/_match.rs @@ -885,22 +885,10 @@ impl<'tcx> Constructor<'tcx> { // in any other pattern from this match (because they are // private), so their type does not matter - but we don't want // to know they are uninhabited. - let allowed_to_inspect = is_visible - && match (is_non_exhaustive, is_uninhabited) { - // Treat all uninhabited types in non-exhaustive variants as - // `TyErr`. - (true, true) => false, - (_, _) => { - match ty.kind { - // If the field type returned is an array of an unknown - // size return an TyErr. - ty::Array(_, len) => len - .try_eval_usize(cx.tcx, cx.param_env) - .is_some(), - _ => true, - } - } - }; + // Also treat all uninhabited types in non-exhaustive variants as + // `TyErr`. + let allowed_to_inspect = + is_visible && !(is_non_exhaustive && is_uninhabited); if allowed_to_inspect { Pat::wildcard_from_ty(ty)