@@ -9,6 +9,15 @@ use crate::ty;
99
1010use self :: Namespace :: * ;
1111
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+
1221#[ derive( Clone , Copy , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug , HashStable ) ]
1322pub enum CtorKind {
1423 /// Constructor function automatically created by a tuple struct/variant.
@@ -64,7 +73,7 @@ pub enum Def {
6473 ConstParam ( DefId ) ,
6574 Static ( DefId , bool /* is_mutbl */ ) ,
6675 /// `DefId` refers to the struct or enum variant's constructor.
67- Ctor ( hir :: CtorOf , DefId , CtorKind ) ,
76+ Ctor ( CtorOf , DefId , CtorKind ) ,
6877 SelfCtor ( DefId /* impl */ ) , // `DefId` refers to the impl
6978 Method ( DefId ) ,
7079 AssociatedConst ( DefId ) ,
@@ -306,13 +315,13 @@ impl Def {
306315 Def :: Static ( ..) => "static" ,
307316 Def :: Enum ( ..) => "enum" ,
308317 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" ,
312321 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 ) =>
316325 bug ! ( "impossible struct constructor" ) ,
317326 Def :: Existential ( ..) => "existential type" ,
318327 Def :: TyAlias ( ..) => "type alias" ,
0 commit comments