Use more slice patterns inside the compiler
This commit is contained in:
parent
60d146580c
commit
c4c518d2d4
40 changed files with 191 additions and 221 deletions
|
@ -483,9 +483,11 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> {
|
|||
// Check if the match is exhaustive.
|
||||
let witnesses = report.non_exhaustiveness_witnesses;
|
||||
if !witnesses.is_empty() {
|
||||
if source == hir::MatchSource::ForLoopDesugar && arms.len() == 2 {
|
||||
if source == hir::MatchSource::ForLoopDesugar
|
||||
&& let [_, snd_arm] = *arms
|
||||
{
|
||||
// the for loop pattern is not irrefutable
|
||||
let pat = &self.thir[arms[1]].pattern;
|
||||
let pat = &self.thir[snd_arm].pattern;
|
||||
// `pat` should be `Some(<pat_field>)` from a desugared for loop.
|
||||
debug_assert_eq!(pat.span.desugaring_kind(), Some(DesugaringKind::ForLoop));
|
||||
let PatKind::Variant { ref subpatterns, .. } = pat.kind else { bug!() };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue