@@ -347,6 +347,7 @@ impl PatternFolder<'tcx> for LiteralExpander<'tcx> {
347
347
) => bug ! ( "cannot deref {:#?}, {} -> {}" , val, crty, rty) ,
348
348
349
349
( _, & PatKind :: Binding { subpattern : Some ( ref s) , .. } ) => s. fold_with ( self ) ,
350
+ ( _, & PatKind :: AscribeUserType { subpattern : ref s, .. } ) => s. fold_with ( self ) ,
350
351
_ => pat. super_fold_with ( self ) ,
351
352
}
352
353
}
@@ -1759,9 +1760,7 @@ fn pat_constructor<'tcx>(
1759
1760
pat : & Pat < ' tcx > ,
1760
1761
) -> Option < Constructor < ' tcx > > {
1761
1762
match * pat. kind {
1762
- PatKind :: AscribeUserType { ref subpattern, .. } => {
1763
- pat_constructor ( tcx, param_env, subpattern)
1764
- }
1763
+ PatKind :: AscribeUserType { .. } => bug ! ( ) , // Handled by `expand_pattern`
1765
1764
PatKind :: Binding { .. } | PatKind :: Wild => None ,
1766
1765
PatKind :: Leaf { .. } | PatKind :: Deref { .. } => Some ( Single ) ,
1767
1766
PatKind :: Variant { adt_def, variant_index, .. } => {
@@ -2262,21 +2261,17 @@ fn patterns_for_variant<'p, 'a: 'p, 'tcx>(
2262
2261
/// fields filled with wild patterns.
2263
2262
fn specialize_one_pattern < ' p , ' a : ' p , ' q : ' p , ' tcx > (
2264
2263
cx : & mut MatchCheckCtxt < ' a , ' tcx > ,
2265
- mut pat : & ' q Pat < ' tcx > ,
2264
+ pat : & ' q Pat < ' tcx > ,
2266
2265
constructor : & Constructor < ' tcx > ,
2267
2266
ctor_wild_subpatterns : & [ & ' p Pat < ' tcx > ] ,
2268
2267
) -> Option < PatStack < ' p , ' tcx > > {
2269
- while let PatKind :: AscribeUserType { ref subpattern, .. } = * pat. kind {
2270
- pat = subpattern;
2271
- }
2272
-
2273
2268
if let NonExhaustive = constructor {
2274
2269
// Only a wildcard pattern can match the special extra constructor
2275
2270
return if pat. is_wildcard ( ) { Some ( PatStack :: default ( ) ) } else { None } ;
2276
2271
}
2277
2272
2278
2273
let result = match * pat. kind {
2279
- PatKind :: AscribeUserType { .. } => bug ! ( ) , // Handled above
2274
+ PatKind :: AscribeUserType { .. } => bug ! ( ) , // Handled by `expand_pattern`
2280
2275
2281
2276
PatKind :: Binding { .. } | PatKind :: Wild => {
2282
2277
Some ( PatStack :: from_slice ( ctor_wild_subpatterns) )
0 commit comments