Skip to content

Commit

Permalink
Revert a hack that only ever worked on level deep
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Jul 15, 2022
1 parent 6b33d5b commit ea68ce7
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions compiler/rustc_mir_build/src/thir/pattern/usefulness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -967,11 +967,7 @@ pub(crate) fn compute_match_usefulness<'p, 'tcx>(
})
.collect();

// In case we're matching on an opaque type in its defining scope, the patterns define the hidden type.
// The wildcard pattern needs to have the same type, otherwise it will always be deemed useful, even if the
// match is exhaustive for the pattern type.
let wild_ty = arms.first().map_or(scrut_ty, |arm| arm.pat.ty());
let wild_pattern = cx.pattern_arena.alloc(DeconstructedPat::wildcard(wild_ty));
let wild_pattern = cx.pattern_arena.alloc(DeconstructedPat::wildcard(scrut_ty));
let v = PatStack::from_pattern(wild_pattern);
let usefulness = is_useful(cx, &matrix, &v, FakeExtraWildcard, scrut_hir_id, false, true);
let non_exhaustiveness_witnesses = match usefulness {
Expand Down

0 comments on commit ea68ce7

Please sign in to comment.