Skip to content

Commit 4681eb6

Browse files
authored
Rollup merge of rust-lang#117034 - Nadrieril:fix-117033, r=cjgillot
Don't crash on empty match in the `nonexhaustive_omitted_patterns` lint Oops Fixes rust-lang#117033
2 parents 4d80740 + a134f16 commit 4681eb6

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

compiler/rustc_mir_build/src/thir/pattern/usefulness.rs

+3
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,9 @@ fn collect_nonexhaustive_missing_variants<'p, 'tcx>(
884884
cx: &MatchCheckCtxt<'p, 'tcx>,
885885
column: &[&DeconstructedPat<'p, 'tcx>],
886886
) -> Vec<WitnessPat<'tcx>> {
887+
if column.is_empty() {
888+
return Vec::new();
889+
}
887890
let ty = column[0].ty();
888891
let pcx = &PatCtxt { cx, ty, span: DUMMY_SP, is_top_level: false };
889892

tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.rs

+7
Original file line numberDiff line numberDiff line change
@@ -251,3 +251,10 @@ fn main() {
251251
pub fn takes_non_exhaustive(_: NonExhaustiveEnum) {
252252
let _closure = |_: NonExhaustiveEnum| {};
253253
}
254+
255+
// ICE #117033
256+
enum Void {}
257+
#[deny(non_exhaustive_omitted_patterns)]
258+
pub fn void(v: Void) -> ! {
259+
match v {}
260+
}

0 commit comments

Comments
 (0)