Skip to content

Commit

Permalink
rustc: rename DefPathData::{MacroDef,LifetimeParam} to {Macro,Lifetim…
Browse files Browse the repository at this point in the history
…e}Ns.
  • Loading branch information
eddyb committed May 4, 2019
1 parent 2efeb48 commit 60f1944
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ impl<'a> LoweringContext<'a> {
self.resolver.definitions().create_def_with_parent(
parent_index,
node_id,
DefPathData::LifetimeParam(str_name),
DefPathData::LifetimeNs(str_name),
DefIndexAddressSpace::High,
Mark::root(),
span,
Expand Down Expand Up @@ -1749,7 +1749,7 @@ impl<'a> LoweringContext<'a> {
self.context.resolver.definitions().create_def_with_parent(
self.parent,
def_node_id,
DefPathData::LifetimeParam(name.ident().as_interned_str()),
DefPathData::LifetimeNs(name.ident().as_interned_str()),
DefIndexAddressSpace::High,
Mark::root(),
lifetime.span,
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/hir/map/def_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
}
ItemKind::Static(..) | ItemKind::Const(..) | ItemKind::Fn(..) =>
DefPathData::ValueNs(i.ident.as_interned_str()),
ItemKind::MacroDef(..) => DefPathData::MacroDef(i.ident.as_interned_str()),
ItemKind::MacroDef(..) => DefPathData::MacroNs(i.ident.as_interned_str()),
ItemKind::Mac(..) => return self.visit_macro_invoc(i.id),
ItemKind::GlobalAsm(..) => DefPathData::Misc,
ItemKind::Use(..) => {
Expand Down Expand Up @@ -236,7 +236,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
fn visit_generic_param(&mut self, param: &'a GenericParam) {
let name = param.ident.as_interned_str();
let def_path_data = match param.kind {
GenericParamKind::Lifetime { .. } => DefPathData::LifetimeParam(name),
GenericParamKind::Lifetime { .. } => DefPathData::LifetimeNs(name),
GenericParamKind::Type { .. } => DefPathData::TypeNs(name),
GenericParamKind::Const { .. } => DefPathData::ValueNs(name),
};
Expand Down
16 changes: 8 additions & 8 deletions src/librustc/hir/map/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,13 @@ pub enum DefPathData {
TypeNs(InternedString),
/// Something in the value NS
ValueNs(InternedString),
/// A macro rule
MacroDef(InternedString),
/// Something in the macro NS
MacroNs(InternedString),
/// Something in the lifetime NS
LifetimeNs(InternedString),
/// A closure expression
ClosureExpr,
// Subportions of items
/// A lifetime (generic) parameter
LifetimeParam(InternedString),
/// Implicit ctor for a unit or tuple-like struct or enum variant.
Ctor,
/// A constant expression (see {ast,hir}::AnonConst).
Expand Down Expand Up @@ -614,8 +614,8 @@ impl DefPathData {
match *self {
TypeNs(name) |
ValueNs(name) |
MacroDef(name) |
LifetimeParam(name) |
MacroNs(name) |
LifetimeNs(name) |
GlobalMetaData(name) => Some(name),

Impl |
Expand All @@ -633,8 +633,8 @@ impl DefPathData {
let s = match *self {
TypeNs(name) |
ValueNs(name) |
MacroDef(name) |
LifetimeParam(name) |
MacroNs(name) |
LifetimeNs(name) |
GlobalMetaData(name) => {
return name
}
Expand Down
14 changes: 9 additions & 5 deletions src/librustc/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -858,12 +858,16 @@ impl TyCtxt<'_, '_, '_> {
// (but also some things just print a `DefId` generally so maybe we need this?)
fn guess_def_namespace(self, def_id: DefId) -> Namespace {
match self.def_key(def_id).disambiguated_data.data {
DefPathData::ValueNs(..) |
DefPathData::AnonConst |
DefPathData::ClosureExpr |
DefPathData::Ctor => Namespace::ValueNS,
DefPathData::TypeNs(..)
| DefPathData::CrateRoot
| DefPathData::ImplTrait => Namespace::TypeNS,

DefPathData::MacroDef(..) => Namespace::MacroNS,
DefPathData::ValueNs(..)
| DefPathData::AnonConst
| DefPathData::ClosureExpr
| DefPathData::Ctor => Namespace::ValueNS,

DefPathData::MacroNs(..) => Namespace::MacroNS,

_ => Namespace::TypeNS,
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_metadata/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ crate fn proc_macro_def_path_table(crate_root: &CrateRoot,
let def_index = definitions.create_def_with_parent(
crate_root,
ast::DUMMY_NODE_ID,
DefPathData::MacroDef(name.as_interned_str()),
DefPathData::MacroNs(name.as_interned_str()),
DefIndexAddressSpace::High,
Mark::root(),
DUMMY_SP);
Expand Down

0 comments on commit 60f1944

Please sign in to comment.