Skip to content

Commit dde7bff

Browse files
committed
Replace DefPathData::Misc by two appropriately-named variants.
1 parent 3a08bd7 commit dde7bff

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

compiler/rustc_hir/src/definitions.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -261,14 +261,16 @@ pub enum DefPathData {
261261
// they are treated specially by the `def_path` function.
262262
/// The crate root (marker).
263263
CrateRoot,
264-
// Catch-all for random `DefId` things like `DUMMY_NODE_ID`.
265-
Misc,
266264

267265
// Different kinds of items and item-like things:
268266
/// An impl.
269267
Impl,
270268
/// An `extern` block.
271269
ForeignMod,
270+
/// A `use` item.
271+
Use,
272+
/// A global asm item.
273+
GlobalAsm,
272274
/// Something in the type namespace.
273275
TypeNs(Symbol),
274276
/// Something in the value namespace.
@@ -443,9 +445,8 @@ impl DefPathData {
443445
match *self {
444446
TypeNs(name) | ValueNs(name) | MacroNs(name) | LifetimeNs(name) => Some(name),
445447

446-
Impl | ForeignMod | CrateRoot | Misc | ClosureExpr | Ctor | AnonConst | ImplTrait => {
447-
None
448-
}
448+
Impl | ForeignMod | CrateRoot | Use | GlobalAsm | ClosureExpr | Ctor | AnonConst
449+
| ImplTrait => None,
449450
}
450451
}
451452

@@ -459,7 +460,8 @@ impl DefPathData {
459460
CrateRoot => DefPathDataName::Anon { namespace: kw::Crate },
460461
Impl => DefPathDataName::Anon { namespace: kw::Impl },
461462
ForeignMod => DefPathDataName::Anon { namespace: kw::Extern },
462-
Misc => DefPathDataName::Anon { namespace: sym::misc },
463+
Use => DefPathDataName::Anon { namespace: kw::Use },
464+
GlobalAsm => DefPathDataName::Anon { namespace: sym::global_asm },
463465
ClosureExpr => DefPathDataName::Anon { namespace: sym::closure },
464466
Ctor => DefPathDataName::Anon { namespace: sym::constructor },
465467
AnonConst => DefPathDataName::Anon { namespace: sym::constant },

compiler/rustc_resolve/src/def_collector.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ impl<'a, 'b> visit::Visitor<'a> for DefCollector<'a, 'b> {
109109
visit::walk_item(self, i);
110110
return self.visit_macro_invoc(i.id);
111111
}
112-
ItemKind::GlobalAsm(..) => DefPathData::Misc,
112+
ItemKind::GlobalAsm(..) => DefPathData::GlobalAsm,
113113
ItemKind::Use(..) => {
114114
return visit::walk_item(self, i);
115115
}
@@ -160,11 +160,11 @@ impl<'a, 'b> visit::Visitor<'a> for DefCollector<'a, 'b> {
160160
}
161161

162162
fn visit_use_tree(&mut self, use_tree: &'a UseTree, id: NodeId, _nested: bool) {
163-
self.create_def(id, DefPathData::Misc, use_tree.span);
163+
self.create_def(id, DefPathData::Use, use_tree.span);
164164
match use_tree.kind {
165165
UseTreeKind::Simple(_, id1, id2) => {
166-
self.create_def(id1, DefPathData::Misc, use_tree.prefix.span);
167-
self.create_def(id2, DefPathData::Misc, use_tree.prefix.span);
166+
self.create_def(id1, DefPathData::Use, use_tree.prefix.span);
167+
self.create_def(id2, DefPathData::Use, use_tree.prefix.span);
168168
}
169169
UseTreeKind::Glob => (),
170170
UseTreeKind::Nested(..) => {}

compiler/rustc_symbol_mangling/src/v0.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,8 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> {
788788

789789
// These should never show up as `path_append` arguments.
790790
DefPathData::CrateRoot
791-
| DefPathData::Misc
791+
| DefPathData::Use
792+
| DefPathData::GlobalAsm
792793
| DefPathData::Impl
793794
| DefPathData::MacroNs(_)
794795
| DefPathData::LifetimeNs(_) => {

0 commit comments

Comments
 (0)