@@ -1202,35 +1202,32 @@ impl<'p, 'tcx> Fields<'p, 'tcx> {
12021202
12031203 /// Creates a new list of wildcard fields for a given constructor. The result must have a
12041204 /// length of `constructor.arity()`.
1205- pub ( super ) fn wildcards (
1206- cx : & MatchCheckCtxt < ' p , ' tcx > ,
1207- ty : Ty < ' tcx > ,
1208- constructor : & Constructor < ' tcx > ,
1209- ) -> Self {
1205+ #[ instrument( level = "trace" ) ]
1206+ pub ( super ) fn wildcards ( pcx : PatCtxt < ' _ , ' p , ' tcx > , constructor : & Constructor < ' tcx > ) -> Self {
12101207 let ret = match constructor {
1211- Single | Variant ( _) => match ty. kind ( ) {
1212- ty:: Tuple ( fs) => Fields :: wildcards_from_tys ( cx, fs. iter ( ) ) ,
1213- ty:: Ref ( _, rty, _) => Fields :: wildcards_from_tys ( cx, once ( * rty) ) ,
1208+ Single | Variant ( _) => match pcx . ty . kind ( ) {
1209+ ty:: Tuple ( fs) => Fields :: wildcards_from_tys ( pcx . cx , fs. iter ( ) ) ,
1210+ ty:: Ref ( _, rty, _) => Fields :: wildcards_from_tys ( pcx . cx , once ( * rty) ) ,
12141211 ty:: Adt ( adt, substs) => {
12151212 if adt. is_box ( ) {
12161213 // The only legal patterns of type `Box` (outside `std`) are `_` and box
12171214 // patterns. If we're here we can assume this is a box pattern.
1218- Fields :: wildcards_from_tys ( cx, once ( substs. type_at ( 0 ) ) )
1215+ Fields :: wildcards_from_tys ( pcx . cx , once ( substs. type_at ( 0 ) ) )
12191216 } else {
12201217 let variant = & adt. variant ( constructor. variant_index_for_adt ( * adt) ) ;
1221- let tys = Fields :: list_variant_nonhidden_fields ( cx, ty, variant)
1218+ let tys = Fields :: list_variant_nonhidden_fields ( pcx . cx , pcx . ty , variant)
12221219 . map ( |( _, ty) | ty) ;
1223- Fields :: wildcards_from_tys ( cx, tys)
1220+ Fields :: wildcards_from_tys ( pcx . cx , tys)
12241221 }
12251222 }
1226- _ => bug ! ( "Unexpected type for `Single` constructor: {:?}" , ty ) ,
1223+ _ => bug ! ( "Unexpected type for `Single` constructor: {:?}" , pcx ) ,
12271224 } ,
1228- Slice ( slice) => match * ty. kind ( ) {
1225+ Slice ( slice) => match * pcx . ty . kind ( ) {
12291226 ty:: Slice ( ty) | ty:: Array ( ty, _) => {
12301227 let arity = slice. arity ( ) ;
1231- Fields :: wildcards_from_tys ( cx, ( 0 ..arity) . map ( |_| ty) )
1228+ Fields :: wildcards_from_tys ( pcx . cx , ( 0 ..arity) . map ( |_| ty) )
12321229 }
1233- _ => bug ! ( "bad slice pattern {:?} {:?}" , constructor, ty ) ,
1230+ _ => bug ! ( "bad slice pattern {:?} {:?}" , constructor, pcx ) ,
12341231 } ,
12351232 Str ( ..)
12361233 | FloatRange ( ..)
@@ -1243,7 +1240,7 @@ impl<'p, 'tcx> Fields<'p, 'tcx> {
12431240 bug ! ( "called `Fields::wildcards` on an `Or` ctor" )
12441241 }
12451242 } ;
1246- debug ! ( "Fields::wildcards({:?}, {:?}) = {:#?}" , constructor , ty , ret) ;
1243+ debug ! ( ? ret) ;
12471244 ret
12481245 }
12491246
@@ -1286,7 +1283,7 @@ impl<'p, 'tcx> DeconstructedPat<'p, 'tcx> {
12861283 /// For example, if `ctor` is a `Constructor::Variant` for `Option::Some`, we get the pattern
12871284 /// `Some(_)`.
12881285 pub ( super ) fn wild_from_ctor ( pcx : PatCtxt < ' _ , ' p , ' tcx > , ctor : Constructor < ' tcx > ) -> Self {
1289- let fields = Fields :: wildcards ( pcx. cx , pcx . ty , & ctor) ;
1286+ let fields = Fields :: wildcards ( pcx, & ctor) ;
12901287 DeconstructedPat :: new ( ctor, fields, pcx. ty , DUMMY_SP )
12911288 }
12921289
@@ -1553,13 +1550,13 @@ impl<'p, 'tcx> DeconstructedPat<'p, 'tcx> {
15531550 /// `other_ctor` can be different from `self.ctor`, but must be covered by it.
15541551 pub ( super ) fn specialize < ' a > (
15551552 & ' a self ,
1556- cx : & MatchCheckCtxt < ' p , ' tcx > ,
1553+ pcx : PatCtxt < ' _ , ' p , ' tcx > ,
15571554 other_ctor : & Constructor < ' tcx > ,
15581555 ) -> SmallVec < [ & ' p DeconstructedPat < ' p , ' tcx > ; 2 ] > {
15591556 match ( & self . ctor , other_ctor) {
15601557 ( Wildcard , _) => {
15611558 // We return a wildcard for each field of `other_ctor`.
1562- Fields :: wildcards ( cx , self . ty , other_ctor) . iter_patterns ( ) . collect ( )
1559+ Fields :: wildcards ( pcx , other_ctor) . iter_patterns ( ) . collect ( )
15631560 }
15641561 ( Slice ( self_slice) , Slice ( other_slice) )
15651562 if self_slice. arity ( ) != other_slice. arity ( ) =>
@@ -1578,7 +1575,7 @@ impl<'p, 'tcx> DeconstructedPat<'p, 'tcx> {
15781575 let prefix = & self . fields . fields [ ..prefix] ;
15791576 let suffix = & self . fields . fields [ self_slice. arity ( ) - suffix..] ;
15801577 let wildcard: & _ =
1581- cx. pattern_arena . alloc ( DeconstructedPat :: wildcard ( inner_ty) ) ;
1578+ pcx . cx . pattern_arena . alloc ( DeconstructedPat :: wildcard ( inner_ty) ) ;
15821579 let extra_wildcards = other_slice. arity ( ) - self_slice. arity ( ) ;
15831580 let extra_wildcards = ( 0 ..extra_wildcards) . map ( |_| wildcard) ;
15841581 prefix. iter ( ) . chain ( extra_wildcards) . chain ( suffix) . collect ( )
0 commit comments