Skip to content

Commit 02eb09e

Browse files
committed
!! (WIP) strip off AscribedUserType
1 parent 49194eb commit 02eb09e

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

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

+7-11
Original file line numberDiff line numberDiff line change
@@ -677,12 +677,12 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> {
677677
let mut interpreted_as_const = None;
678678
let mut interpreted_as_const_sugg = None;
679679

680-
if let PatKind::ExpandedConstant { def_id, is_inline: false, .. }
681-
| PatKind::AscribeUserType {
682-
subpattern:
683-
box Pat { kind: PatKind::ExpandedConstant { def_id, is_inline: false, .. }, .. },
684-
..
685-
} = pat.kind
680+
let mut subpat = pat;
681+
while let PatKind::AscribeUserType { ref subpattern, .. } = subpat.kind {
682+
subpat = subpattern;
683+
}
684+
685+
if let PatKind::ExpandedConstant { def_id, is_inline: false, .. } = subpat.kind
686686
&& let DefKind::Const = self.tcx.def_kind(def_id)
687687
&& let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(pat.span)
688688
// We filter out paths with multiple path::segments.
@@ -693,11 +693,7 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> {
693693
// When we encounter a constant as the binding name, point at the `const` definition.
694694
interpreted_as_const = Some(span);
695695
interpreted_as_const_sugg = Some(InterpretedAsConst { span: pat.span, variable });
696-
} else if let PatKind::Constant { .. }
697-
| PatKind::AscribeUserType {
698-
subpattern: box Pat { kind: PatKind::Constant { .. }, .. },
699-
..
700-
} = pat.kind
696+
} else if let PatKind::Constant { .. } = subpat.kind
701697
&& let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(pat.span)
702698
{
703699
// If the pattern to match is an integer literal:

0 commit comments

Comments
 (0)