X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustc%2Fhir%2Fdef.rs;h=4e0c6479abf141c1e3fff1dfc8e3648389be1622;hb=efa3ec67e28ab8a4c3377a039095cd464713cdfd;hp=feded417ce17fb7910d62a4e671c7ea0a48575be;hpb=0c4fb24a077b17da1de5b77ad6b9d2c868a7b342;p=rust.git diff --git a/src/librustc/hir/def.rs b/src/librustc/hir/def.rs index feded417ce1..4e0c6479abf 100644 --- a/src/librustc/hir/def.rs +++ b/src/librustc/hir/def.rs @@ -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; @@ -17,11 +17,11 @@ #[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; -// This is the replacement export map. It maps a module to all of the exports -// within. -pub type ExportMap = NodeMap>; + +/// This is the replacement export map. It maps a module to all of the exports +/// within. +pub type ExportMap = DefIdMap>; #[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",