Replace DefPathData::Misc by two appropriately-named variants.
This commit is contained in:
parent
3a08bd7873
commit
dde7bff574
3 changed files with 14 additions and 11 deletions
|
@ -261,14 +261,16 @@ pub enum DefPathData {
|
||||||
// they are treated specially by the `def_path` function.
|
// they are treated specially by the `def_path` function.
|
||||||
/// The crate root (marker).
|
/// The crate root (marker).
|
||||||
CrateRoot,
|
CrateRoot,
|
||||||
// Catch-all for random `DefId` things like `DUMMY_NODE_ID`.
|
|
||||||
Misc,
|
|
||||||
|
|
||||||
// Different kinds of items and item-like things:
|
// Different kinds of items and item-like things:
|
||||||
/// An impl.
|
/// An impl.
|
||||||
Impl,
|
Impl,
|
||||||
/// An `extern` block.
|
/// An `extern` block.
|
||||||
ForeignMod,
|
ForeignMod,
|
||||||
|
/// A `use` item.
|
||||||
|
Use,
|
||||||
|
/// A global asm item.
|
||||||
|
GlobalAsm,
|
||||||
/// Something in the type namespace.
|
/// Something in the type namespace.
|
||||||
TypeNs(Symbol),
|
TypeNs(Symbol),
|
||||||
/// Something in the value namespace.
|
/// Something in the value namespace.
|
||||||
|
@ -443,9 +445,8 @@ impl DefPathData {
|
||||||
match *self {
|
match *self {
|
||||||
TypeNs(name) | ValueNs(name) | MacroNs(name) | LifetimeNs(name) => Some(name),
|
TypeNs(name) | ValueNs(name) | MacroNs(name) | LifetimeNs(name) => Some(name),
|
||||||
|
|
||||||
Impl | ForeignMod | CrateRoot | Misc | ClosureExpr | Ctor | AnonConst | ImplTrait => {
|
Impl | ForeignMod | CrateRoot | Use | GlobalAsm | ClosureExpr | Ctor | AnonConst
|
||||||
None
|
| ImplTrait => None,
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -459,7 +460,8 @@ impl DefPathData {
|
||||||
CrateRoot => DefPathDataName::Anon { namespace: kw::Crate },
|
CrateRoot => DefPathDataName::Anon { namespace: kw::Crate },
|
||||||
Impl => DefPathDataName::Anon { namespace: kw::Impl },
|
Impl => DefPathDataName::Anon { namespace: kw::Impl },
|
||||||
ForeignMod => DefPathDataName::Anon { namespace: kw::Extern },
|
ForeignMod => DefPathDataName::Anon { namespace: kw::Extern },
|
||||||
Misc => DefPathDataName::Anon { namespace: sym::misc },
|
Use => DefPathDataName::Anon { namespace: kw::Use },
|
||||||
|
GlobalAsm => DefPathDataName::Anon { namespace: sym::global_asm },
|
||||||
ClosureExpr => DefPathDataName::Anon { namespace: sym::closure },
|
ClosureExpr => DefPathDataName::Anon { namespace: sym::closure },
|
||||||
Ctor => DefPathDataName::Anon { namespace: sym::constructor },
|
Ctor => DefPathDataName::Anon { namespace: sym::constructor },
|
||||||
AnonConst => DefPathDataName::Anon { namespace: sym::constant },
|
AnonConst => DefPathDataName::Anon { namespace: sym::constant },
|
||||||
|
|
|
@ -109,7 +109,7 @@ impl<'a, 'b> visit::Visitor<'a> for DefCollector<'a, 'b> {
|
||||||
visit::walk_item(self, i);
|
visit::walk_item(self, i);
|
||||||
return self.visit_macro_invoc(i.id);
|
return self.visit_macro_invoc(i.id);
|
||||||
}
|
}
|
||||||
ItemKind::GlobalAsm(..) => DefPathData::Misc,
|
ItemKind::GlobalAsm(..) => DefPathData::GlobalAsm,
|
||||||
ItemKind::Use(..) => {
|
ItemKind::Use(..) => {
|
||||||
return visit::walk_item(self, i);
|
return visit::walk_item(self, i);
|
||||||
}
|
}
|
||||||
|
@ -160,11 +160,11 @@ impl<'a, 'b> visit::Visitor<'a> for DefCollector<'a, 'b> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_use_tree(&mut self, use_tree: &'a UseTree, id: NodeId, _nested: bool) {
|
fn visit_use_tree(&mut self, use_tree: &'a UseTree, id: NodeId, _nested: bool) {
|
||||||
self.create_def(id, DefPathData::Misc, use_tree.span);
|
self.create_def(id, DefPathData::Use, use_tree.span);
|
||||||
match use_tree.kind {
|
match use_tree.kind {
|
||||||
UseTreeKind::Simple(_, id1, id2) => {
|
UseTreeKind::Simple(_, id1, id2) => {
|
||||||
self.create_def(id1, DefPathData::Misc, use_tree.prefix.span);
|
self.create_def(id1, DefPathData::Use, use_tree.prefix.span);
|
||||||
self.create_def(id2, DefPathData::Misc, use_tree.prefix.span);
|
self.create_def(id2, DefPathData::Use, use_tree.prefix.span);
|
||||||
}
|
}
|
||||||
UseTreeKind::Glob => (),
|
UseTreeKind::Glob => (),
|
||||||
UseTreeKind::Nested(..) => {}
|
UseTreeKind::Nested(..) => {}
|
||||||
|
|
|
@ -788,7 +788,8 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> {
|
||||||
|
|
||||||
// These should never show up as `path_append` arguments.
|
// These should never show up as `path_append` arguments.
|
||||||
DefPathData::CrateRoot
|
DefPathData::CrateRoot
|
||||||
| DefPathData::Misc
|
| DefPathData::Use
|
||||||
|
| DefPathData::GlobalAsm
|
||||||
| DefPathData::Impl
|
| DefPathData::Impl
|
||||||
| DefPathData::MacroNs(_)
|
| DefPathData::MacroNs(_)
|
||||||
| DefPathData::LifetimeNs(_) => {
|
| DefPathData::LifetimeNs(_) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue