@@ -5,7 +5,7 @@ use std::fmt;
5
5
use smallvec:: { smallvec, SmallVec } ;
6
6
7
7
use crate :: constructor:: { Constructor , Slice , SliceKind } ;
8
- use crate :: { PrivateUninhabitedField , TypeCx } ;
8
+ use crate :: { PatCx , PrivateUninhabitedField } ;
9
9
10
10
use self :: Constructor :: * ;
11
11
@@ -21,15 +21,15 @@ impl PatId {
21
21
}
22
22
23
23
/// A pattern with an index denoting which field it corresponds to.
24
- pub struct IndexedPat < Cx : TypeCx > {
24
+ pub struct IndexedPat < Cx : PatCx > {
25
25
pub idx : usize ,
26
26
pub pat : DeconstructedPat < Cx > ,
27
27
}
28
28
29
29
/// Values and patterns can be represented as a constructor applied to some fields. This represents
30
30
/// a pattern in this form. A `DeconstructedPat` will almost always come from user input; the only
31
31
/// exception are some `Wildcard`s introduced during pattern lowering.
32
- pub struct DeconstructedPat < Cx : TypeCx > {
32
+ pub struct DeconstructedPat < Cx : PatCx > {
33
33
ctor : Constructor < Cx > ,
34
34
fields : Vec < IndexedPat < Cx > > ,
35
35
/// The number of fields in this pattern. E.g. if the pattern is `SomeStruct { field12: true, ..
@@ -43,7 +43,7 @@ pub struct DeconstructedPat<Cx: TypeCx> {
43
43
pub ( crate ) uid : PatId ,
44
44
}
45
45
46
- impl < Cx : TypeCx > DeconstructedPat < Cx > {
46
+ impl < Cx : PatCx > DeconstructedPat < Cx > {
47
47
pub fn new (
48
48
ctor : Constructor < Cx > ,
49
49
fields : Vec < IndexedPat < Cx > > ,
@@ -136,7 +136,7 @@ impl<Cx: TypeCx> DeconstructedPat<Cx> {
136
136
}
137
137
138
138
/// This is best effort and not good enough for a `Display` impl.
139
- impl < Cx : TypeCx > fmt:: Debug for DeconstructedPat < Cx > {
139
+ impl < Cx : PatCx > fmt:: Debug for DeconstructedPat < Cx > {
140
140
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
141
141
let pat = self ;
142
142
let mut first = true ;
@@ -219,14 +219,14 @@ impl<Cx: TypeCx> fmt::Debug for DeconstructedPat<Cx> {
219
219
/// algorithm. Do not use `Wild` to represent a wildcard pattern comping from user input.
220
220
///
221
221
/// This is morally `Option<&'p DeconstructedPat>` where `None` is interpreted as a wildcard.
222
- pub ( crate ) enum PatOrWild < ' p , Cx : TypeCx > {
222
+ pub ( crate ) enum PatOrWild < ' p , Cx : PatCx > {
223
223
/// A non-user-provided wildcard, created during specialization.
224
224
Wild ,
225
225
/// A user-provided pattern.
226
226
Pat ( & ' p DeconstructedPat < Cx > ) ,
227
227
}
228
228
229
- impl < ' p , Cx : TypeCx > Clone for PatOrWild < ' p , Cx > {
229
+ impl < ' p , Cx : PatCx > Clone for PatOrWild < ' p , Cx > {
230
230
fn clone ( & self ) -> Self {
231
231
match self {
232
232
PatOrWild :: Wild => PatOrWild :: Wild ,
@@ -235,9 +235,9 @@ impl<'p, Cx: TypeCx> Clone for PatOrWild<'p, Cx> {
235
235
}
236
236
}
237
237
238
- impl < ' p , Cx : TypeCx > Copy for PatOrWild < ' p , Cx > { }
238
+ impl < ' p , Cx : PatCx > Copy for PatOrWild < ' p , Cx > { }
239
239
240
- impl < ' p , Cx : TypeCx > PatOrWild < ' p , Cx > {
240
+ impl < ' p , Cx : PatCx > PatOrWild < ' p , Cx > {
241
241
pub ( crate ) fn as_pat ( & self ) -> Option < & ' p DeconstructedPat < Cx > > {
242
242
match self {
243
243
PatOrWild :: Wild => None ,
@@ -283,7 +283,7 @@ impl<'p, Cx: TypeCx> PatOrWild<'p, Cx> {
283
283
}
284
284
}
285
285
286
- impl < ' p , Cx : TypeCx > fmt:: Debug for PatOrWild < ' p , Cx > {
286
+ impl < ' p , Cx : PatCx > fmt:: Debug for PatOrWild < ' p , Cx > {
287
287
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
288
288
match self {
289
289
PatOrWild :: Wild => write ! ( f, "_" ) ,
@@ -295,19 +295,19 @@ impl<'p, Cx: TypeCx> fmt::Debug for PatOrWild<'p, Cx> {
295
295
/// Same idea as `DeconstructedPat`, except this is a fictitious pattern built up for diagnostics
296
296
/// purposes. As such they don't use interning and can be cloned.
297
297
#[ derive( Debug ) ]
298
- pub struct WitnessPat < Cx : TypeCx > {
298
+ pub struct WitnessPat < Cx : PatCx > {
299
299
ctor : Constructor < Cx > ,
300
300
pub ( crate ) fields : Vec < WitnessPat < Cx > > ,
301
301
ty : Cx :: Ty ,
302
302
}
303
303
304
- impl < Cx : TypeCx > Clone for WitnessPat < Cx > {
304
+ impl < Cx : PatCx > Clone for WitnessPat < Cx > {
305
305
fn clone ( & self ) -> Self {
306
306
Self { ctor : self . ctor . clone ( ) , fields : self . fields . clone ( ) , ty : self . ty . clone ( ) }
307
307
}
308
308
}
309
309
310
- impl < Cx : TypeCx > WitnessPat < Cx > {
310
+ impl < Cx : PatCx > WitnessPat < Cx > {
311
311
pub ( crate ) fn new ( ctor : Constructor < Cx > , fields : Vec < Self > , ty : Cx :: Ty ) -> Self {
312
312
Self { ctor, fields, ty }
313
313
}
0 commit comments