@@ -347,6 +347,7 @@ impl PatternFolder<'tcx> for LiteralExpander<'tcx> {
347347 ) => bug ! ( "cannot deref {:#?}, {} -> {}" , val, crty, rty) ,
348348
349349 ( _, & PatKind :: Binding { subpattern : Some ( ref s) , .. } ) => s. fold_with ( self ) ,
350+ ( _, & PatKind :: AscribeUserType { subpattern : ref s, .. } ) => s. fold_with ( self ) ,
350351 _ => pat. super_fold_with ( self ) ,
351352 }
352353 }
@@ -1759,9 +1760,7 @@ fn pat_constructor<'tcx>(
17591760 pat : & Pat < ' tcx > ,
17601761) -> Option < Constructor < ' tcx > > {
17611762 match * pat. kind {
1762- PatKind :: AscribeUserType { ref subpattern, .. } => {
1763- pat_constructor ( tcx, param_env, subpattern)
1764- }
1763+ PatKind :: AscribeUserType { .. } => bug ! ( ) , // Handled by `expand_pattern`
17651764 PatKind :: Binding { .. } | PatKind :: Wild => None ,
17661765 PatKind :: Leaf { .. } | PatKind :: Deref { .. } => Some ( Single ) ,
17671766 PatKind :: Variant { adt_def, variant_index, .. } => {
@@ -2262,21 +2261,17 @@ fn patterns_for_variant<'p, 'a: 'p, 'tcx>(
22622261/// fields filled with wild patterns.
22632262fn specialize_one_pattern < ' p , ' a : ' p , ' q : ' p , ' tcx > (
22642263 cx : & mut MatchCheckCtxt < ' a , ' tcx > ,
2265- mut pat : & ' q Pat < ' tcx > ,
2264+ pat : & ' q Pat < ' tcx > ,
22662265 constructor : & Constructor < ' tcx > ,
22672266 ctor_wild_subpatterns : & [ & ' p Pat < ' tcx > ] ,
22682267) -> Option < PatStack < ' p , ' tcx > > {
2269- while let PatKind :: AscribeUserType { ref subpattern, .. } = * pat. kind {
2270- pat = subpattern;
2271- }
2272-
22732268 if let NonExhaustive = constructor {
22742269 // Only a wildcard pattern can match the special extra constructor
22752270 return if pat. is_wildcard ( ) { Some ( PatStack :: default ( ) ) } else { None } ;
22762271 }
22772272
22782273 let result = match * pat. kind {
2279- PatKind :: AscribeUserType { .. } => bug ! ( ) , // Handled above
2274+ PatKind :: AscribeUserType { .. } => bug ! ( ) , // Handled by `expand_pattern`
22802275
22812276 PatKind :: Binding { .. } | PatKind :: Wild => {
22822277 Some ( PatStack :: from_slice ( ctor_wild_subpatterns) )
0 commit comments