From a134f1624cd011703378f5f7597854375d74e135 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sat, 21 Oct 2023 23:04:17 +0200 Subject: [PATCH] Fix #117033 --- compiler/rustc_mir_build/src/thir/pattern/usefulness.rs | 3 +++ tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.rs | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs b/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs index a8cee5a61edb5..5218f772484fd 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs @@ -884,6 +884,9 @@ fn collect_nonexhaustive_missing_variants<'p, 'tcx>( cx: &MatchCheckCtxt<'p, 'tcx>, column: &[&DeconstructedPat<'p, 'tcx>], ) -> Vec> { + if column.is_empty() { + return Vec::new(); + } let ty = column[0].ty(); let pcx = &PatCtxt { cx, ty, span: DUMMY_SP, is_top_level: false }; diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.rs index ecfeb3f9b98b0..e0a6051a81fab 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.rs +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.rs @@ -251,3 +251,10 @@ fn main() { pub fn takes_non_exhaustive(_: NonExhaustiveEnum) { let _closure = |_: NonExhaustiveEnum| {}; } + +// ICE #117033 +enum Void {} +#[deny(non_exhaustive_omitted_patterns)] +pub fn void(v: Void) -> ! { + match v {} +}