@@ -365,23 +365,9 @@ struct LiteralExpander;
365365impl < ' tcx > PatternFolder < ' tcx > for LiteralExpander {
366366 fn fold_pattern ( & mut self , pat : & Pat < ' tcx > ) -> Pat < ' tcx > {
367367 debug ! ( "fold_pattern {:?} {:?} {:?}" , pat, pat. ty. kind( ) , pat. kind) ;
368- match ( pat. ty . kind ( ) , pat. kind . as_ref ( ) ) {
369- ( _, PatKind :: Binding { subpattern : Some ( s) , .. } ) => s. fold_with ( self ) ,
370- ( _, PatKind :: AscribeUserType { subpattern : s, .. } ) => s. fold_with ( self ) ,
371- ( ty:: Ref ( _, t, _) , PatKind :: Constant { .. } ) if t. is_str ( ) => {
372- // Treat string literal patterns as deref patterns to a `str` constant, i.e.
373- // `&CONST`. This expands them like other const patterns. This could have been done
374- // in `const_to_pat`, but that causes issues with the rest of the matching code.
375- let mut new_pat = pat. super_fold_with ( self ) ;
376- // Make a fake const pattern of type `str` (instead of `&str`). That the carried
377- // constant value still knows it is of type `&str`.
378- new_pat. ty = t;
379- Pat {
380- kind : Box :: new ( PatKind :: Deref { subpattern : new_pat } ) ,
381- span : pat. span ,
382- ty : pat. ty ,
383- }
384- }
368+ match pat. kind . as_ref ( ) {
369+ PatKind :: Binding { subpattern : Some ( s) , .. } => s. fold_with ( self ) ,
370+ PatKind :: AscribeUserType { subpattern : s, .. } => s. fold_with ( self ) ,
385371 _ => pat. super_fold_with ( self ) ,
386372 }
387373 }
@@ -1183,7 +1169,7 @@ fn is_useful<'p, 'tcx>(
11831169 let ctor_wild_subpatterns = Fields :: wildcards ( pcx. cx , pcx. ty , & ctor) ;
11841170 let spec_matrix =
11851171 start_matrix. specialize_constructor ( pcx, & ctor, & ctor_wild_subpatterns) ;
1186- let v = v. pop_head_constructor ( pcx . cx , & ctor_wild_subpatterns) ;
1172+ let v = v. pop_head_constructor ( cx, & ctor_wild_subpatterns) ;
11871173 let usefulness =
11881174 is_useful ( cx, & spec_matrix, & v, witness_preference, hir_id, is_under_guard, false ) ;
11891175 let usefulness =
0 commit comments