@@ -19,7 +19,7 @@ use rustc_front::hir;
1919
2020#[ derive( Clone , Copy , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
2121pub enum Def {
22- DefFn ( DefId , bool /* is_ctor */ ) ,
22+ DefFn ( DefId ) ,
2323 DefSelfTy ( Option < DefId > , // trait id
2424 Option < ( ast:: NodeId , ast:: NodeId ) > ) , // (impl id, self type id)
2525 DefMod ( DefId ) ,
@@ -29,8 +29,9 @@ pub enum Def {
2929 DefAssociatedConst ( DefId ) ,
3030 DefLocal ( DefId , // def id of variable
3131 ast:: NodeId ) , // node id of variable
32- DefVariant ( DefId /* enum */ , DefId /* variant */ , bool /* is_structure */ ) ,
33- DefTy ( DefId , bool /* is_enum */ ) ,
32+ DefVariant ( DefId /* enum */ , DefId /* variant */ ) ,
33+ DefEnum ( DefId ) ,
34+ DefTyAlias ( DefId ) ,
3435 DefAssociatedTy ( DefId /* trait */ , DefId ) ,
3536 DefTrait ( DefId ) ,
3637 DefPrimTy ( hir:: PrimTy ) ,
@@ -40,14 +41,10 @@ pub enum Def {
4041 usize , // index in the freevars list of the closure
4142 ast:: NodeId ) , // expr node that creates the closure
4243
43- /// Note that if it's a tuple struct's definition, the node id of the DefId
44- /// may either refer to the item definition's id or the VariantData.ctor_id.
45- ///
46- /// The cases that I have encountered so far are (this is not exhaustive):
47- /// - If it's a ty_path referring to some tuple struct, then DefMap maps
48- /// it to a def whose id is the item definition's id.
49- /// - If it's an ExprPath referring to some tuple struct, then DefMap maps
50- /// it to a def whose id is the VariantData.ctor_id.
44+ // If DefStruct lives in type namespace it denotes a struct item and its DefId refers
45+ // to NodeId of the struct itself.
46+ // If DefStruct lives in value namespace (e.g. tuple struct, unit struct expressions)
47+ // it denotes a constructor and its DefId refers to NodeId of the struct's constructor.
5148 DefStruct ( DefId ) ,
5249 DefLabel ( ast:: NodeId ) ,
5350 DefMethod ( DefId ) ,
@@ -121,7 +118,7 @@ impl Def {
121118 }
122119
123120 DefFn ( ..) | DefMod ( ..) | DefForeignMod ( ..) | DefStatic ( ..) |
124- DefVariant ( ..) | DefTy ( ..) | DefAssociatedTy ( ..) |
121+ DefVariant ( ..) | DefEnum ( .. ) | DefTyAlias ( ..) | DefAssociatedTy ( ..) |
125122 DefTyParam ( ..) | DefStruct ( ..) | DefTrait ( ..) |
126123 DefMethod ( ..) | DefConst ( ..) | DefAssociatedConst ( ..) |
127124 DefPrimTy ( ..) | DefLabel ( ..) | DefSelfTy ( ..) | DefErr => {
@@ -132,8 +129,8 @@ impl Def {
132129
133130 pub fn def_id ( & self ) -> DefId {
134131 match * self {
135- DefFn ( id, _ ) | DefMod ( id) | DefForeignMod ( id) | DefStatic ( id, _) |
136- DefVariant ( _, id, _ ) | DefTy ( id, _ ) | DefAssociatedTy ( _, id) |
132+ DefFn ( id) | DefMod ( id) | DefForeignMod ( id) | DefStatic ( id, _) |
133+ DefVariant ( _, id) | DefEnum ( id) | DefTyAlias ( id ) | DefAssociatedTy ( _, id) |
137134 DefTyParam ( _, _, id, _) | DefStruct ( id) | DefTrait ( id) |
138135 DefMethod ( id) | DefConst ( id) | DefAssociatedConst ( id) |
139136 DefLocal ( id, _) | DefUpvar ( id, _, _, _) => {
@@ -151,7 +148,7 @@ impl Def {
151148
152149 pub fn variant_def_ids ( & self ) -> Option < ( DefId , DefId ) > {
153150 match * self {
154- DefVariant ( enum_id, var_id, _ ) => {
151+ DefVariant ( enum_id, var_id) => {
155152 Some ( ( enum_id, var_id) )
156153 }
157154 _ => None
0 commit comments