Skip to content

Commit

Permalink
Unrolled build for rust-lang#117034
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rust-timer authored Oct 22, 2023
2 parents 3932c87 + a134f16 commit b824f1d
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 b824f1d

Please sign in to comment.