rustc: rename DefPathData::{MacroDef,LifetimeParam} to {Macro,Lifetime}Ns.

This commit is contained in:
Eduard-Mihai Burtescu 2019-05-03 22:45:36 +03:00
parent 2efeb485a9
commit 60f1944ebf
5 changed files with 22 additions and 18 deletions

View file

@ -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,

View file

@ -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),
};

View file

@ -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
}

View file

@ -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,
}

View file

@ -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);