@@ -9,6 +9,15 @@ use crate::ty;
9
9
10
10
use self :: Namespace :: * ;
11
11
12
+ /// Encodes if a `Def::Ctor` is the constructor of an enum variant or a struct.
13
+ #[ derive( Clone , Copy , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug , HashStable ) ]
14
+ pub enum CtorOf {
15
+ /// This `Def::Ctor` is a synthesized constructor of a tuple or unit struct.
16
+ Struct ,
17
+ /// This `Def::Ctor` is a synthesized constructor of a tuple or unit variant.
18
+ Variant ,
19
+ }
20
+
12
21
#[ derive( Clone , Copy , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug , HashStable ) ]
13
22
pub enum CtorKind {
14
23
/// Constructor function automatically created by a tuple struct/variant.
@@ -64,7 +73,7 @@ pub enum Def {
64
73
ConstParam ( DefId ) ,
65
74
Static ( DefId , bool /* is_mutbl */ ) ,
66
75
/// `DefId` refers to the struct or enum variant's constructor.
67
- Ctor ( hir :: CtorOf , DefId , CtorKind ) ,
76
+ Ctor ( CtorOf , DefId , CtorKind ) ,
68
77
SelfCtor ( DefId /* impl */ ) , // `DefId` refers to the impl
69
78
Method ( DefId ) ,
70
79
AssociatedConst ( DefId ) ,
@@ -306,13 +315,13 @@ impl Def {
306
315
Def :: Static ( ..) => "static" ,
307
316
Def :: Enum ( ..) => "enum" ,
308
317
Def :: Variant ( ..) => "variant" ,
309
- Def :: Ctor ( hir :: CtorOf :: Variant , _, CtorKind :: Fn ) => "tuple variant" ,
310
- Def :: Ctor ( hir :: CtorOf :: Variant , _, CtorKind :: Const ) => "unit variant" ,
311
- Def :: Ctor ( hir :: CtorOf :: Variant , _, CtorKind :: Fictive ) => "struct variant" ,
318
+ Def :: Ctor ( CtorOf :: Variant , _, CtorKind :: Fn ) => "tuple variant" ,
319
+ Def :: Ctor ( CtorOf :: Variant , _, CtorKind :: Const ) => "unit variant" ,
320
+ Def :: Ctor ( CtorOf :: Variant , _, CtorKind :: Fictive ) => "struct variant" ,
312
321
Def :: Struct ( ..) => "struct" ,
313
- Def :: Ctor ( hir :: CtorOf :: Struct , _, CtorKind :: Fn ) => "tuple struct" ,
314
- Def :: Ctor ( hir :: CtorOf :: Struct , _, CtorKind :: Const ) => "unit struct" ,
315
- Def :: Ctor ( hir :: CtorOf :: Struct , _, CtorKind :: Fictive ) =>
322
+ Def :: Ctor ( CtorOf :: Struct , _, CtorKind :: Fn ) => "tuple struct" ,
323
+ Def :: Ctor ( CtorOf :: Struct , _, CtorKind :: Const ) => "unit struct" ,
324
+ Def :: Ctor ( CtorOf :: Struct , _, CtorKind :: Fictive ) =>
316
325
bug ! ( "impossible struct constructor" ) ,
317
326
Def :: Existential ( ..) => "existential type" ,
318
327
Def :: TyAlias ( ..) => "type alias" ,
0 commit comments