Skip to content

Commit

Permalink
Rollup merge of #117034 - Nadrieril:fix-117033, r=cjgillot
Browse files Browse the repository at this point in the history
Don't crash on empty match in the `nonexhaustive_omitted_patterns` lint

Oops

Fixes #117033
  • Loading branch information
matthiaskrgr authored Oct 22, 2023
2 parents 4d80740 + a134f16 commit 4681eb6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions compiler/rustc_mir_build/src/thir/pattern/usefulness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,9 @@ fn collect_nonexhaustive_missing_variants<'p, 'tcx>(
cx: &MatchCheckCtxt<'p, 'tcx>,
column: &[&DeconstructedPat<'p, 'tcx>],
) -> Vec<WitnessPat<'tcx>> {
if column.is_empty() {
return Vec::new();
}
let ty = column[0].ty();
let pcx = &PatCtxt { cx, ty, span: DUMMY_SP, is_top_level: false };

Expand Down
7 changes: 7 additions & 0 deletions tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
}

0 comments on commit 4681eb6

Please sign in to comment.