Skip to content
Permalink
Browse files

rustc: rename DefPathData::{MacroDef,LifetimeParam} to {Macro,Lifetim…

…e}Ns.
  • Loading branch information...
eddyb committed May 3, 2019
1 parent 2efeb48 commit 60f1944ebf29d738d870df86ee46c92cb3f09448
@@ -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,
@@ -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,
@@ -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(..) => {
@@ -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),
};
@@ -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).
@@ -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 |
@@ -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
}
@@ -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,
}
@@ -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);

0 comments on commit 60f1944

Please sign in to comment.
You can’t perform that action at this time.