Skip to content

Commit a5294b6

Browse files
committed
We already handle arrays of unknown length correctly
1 parent 4a1772e commit a5294b6

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

src/librustc_mir_build/hair/pattern/_match.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -885,22 +885,10 @@ impl<'tcx> Constructor<'tcx> {
885885
// in any other pattern from this match (because they are
886886
// private), so their type does not matter - but we don't want
887887
// to know they are uninhabited.
888-
let allowed_to_inspect = is_visible
889-
&& match (is_non_exhaustive, is_uninhabited) {
890-
// Treat all uninhabited types in non-exhaustive variants as
891-
// `TyErr`.
892-
(true, true) => false,
893-
(_, _) => {
894-
match ty.kind {
895-
// If the field type returned is an array of an unknown
896-
// size return an TyErr.
897-
ty::Array(_, len) => len
898-
.try_eval_usize(cx.tcx, cx.param_env)
899-
.is_some(),
900-
_ => true,
901-
}
902-
}
903-
};
888+
// Also treat all uninhabited types in non-exhaustive variants as
889+
// `TyErr`.
890+
let allowed_to_inspect =
891+
is_visible && !(is_non_exhaustive && is_uninhabited);
904892

905893
if allowed_to_inspect {
906894
Pat::wildcard_from_ty(ty)

0 commit comments

Comments
 (0)