]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/hir/def.rs
Auto merge of #44435 - alexcrichton:in-scope, r=michaelwoerister
[rust.git] / src / librustc / hir / def.rs
index feded417ce17fb7910d62a4e671c7ea0a48575be..4e0c6479abf141c1e3fff1dfc8e3648389be1622 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 use hir::def_id::DefId;
-use util::nodemap::NodeMap;
+use util::nodemap::{NodeMap, DefIdMap};
 use syntax::ast;
 use syntax::ext::base::MacroKind;
 use syntax_pos::Span;
 
 #[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
 pub enum CtorKind {
-    // Constructor function automatically created by a tuple struct/variant.
+    /// Constructor function automatically created by a tuple struct/variant.
     Fn,
-    // Constructor constant automatically created by a unit struct/variant.
+    /// Constructor constant automatically created by a unit struct/variant.
     Const,
-    // Unusable name in value namespace created by a struct variant.
+    /// Unusable name in value namespace created by a struct variant.
     Fictive,
 }
 
@@ -48,8 +48,9 @@ pub enum Def {
     VariantCtor(DefId, CtorKind),
     Method(DefId),
     AssociatedConst(DefId),
-    Local(DefId),
-    Upvar(DefId,        // def id of closed over local
+
+    Local(ast::NodeId),
+    Upvar(ast::NodeId,  // node id of closed over local
           usize,        // index in the freevars list of the closure
           ast::NodeId), // expr node that creates the closure
     Label(ast::NodeId),
@@ -109,17 +110,21 @@ pub fn kind_name(&self) -> &'static str {
     }
 }
 
-// Definition mapping
+/// Definition mapping
 pub type DefMap = NodeMap<PathResolution>;
-// This is the replacement export map. It maps a module to all of the exports
-// within.
-pub type ExportMap = NodeMap<Vec<Export>>;
+
+/// This is the replacement export map. It maps a module to all of the exports
+/// within.
+pub type ExportMap = DefIdMap<Vec<Export>>;
 
 #[derive(Copy, Clone, Debug, RustcEncodable, RustcDecodable)]
 pub struct Export {
-    pub ident: ast::Ident, // The name of the target.
-    pub def: Def, // The definition of the target.
-    pub span: Span, // The span of the target definition.
+    /// The name of the target.
+    pub ident: ast::Ident,
+    /// The definition of the target.
+    pub def: Def,
+    /// The span of the target definition.
+    pub span: Span,
 }
 
 impl CtorKind {
@@ -146,11 +151,13 @@ pub fn def_id(&self) -> DefId {
             Def::Variant(id) | Def::VariantCtor(id, ..) | Def::Enum(id) | Def::TyAlias(id) |
             Def::AssociatedTy(id) | Def::TyParam(id) | Def::Struct(id) | Def::StructCtor(id, ..) |
             Def::Union(id) | Def::Trait(id) | Def::Method(id) | Def::Const(id) |
-            Def::AssociatedConst(id) | Def::Local(id) | Def::Upvar(id, ..) | Def::Macro(id, ..) |
+            Def::AssociatedConst(id) | Def::Macro(id, ..) |
             Def::GlobalAsm(id) => {
                 id
             }
 
+            Def::Local(..) |
+            Def::Upvar(..) |
             Def::Label(..)  |
             Def::PrimTy(..) |
             Def::SelfTy(..) |
@@ -160,6 +167,7 @@ pub fn def_id(&self) -> DefId {
         }
     }
 
+    /// A human readable kind name
     pub fn kind_name(&self) -> &'static str {
         match *self {
             Def::Fn(..) => "function",