diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2022-05-12 20:12:35 +0200 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2022-05-12 20:12:35 +0200 |
| commit | dde7bff5740134c98edfa38090dab1e7cbdc29a6 (patch) | |
| tree | 5df1e3dc93f9888ef971072aabf17c499d1759d5 | |
| parent | 3a08bd7873ac755f93286f087fdc398380c69e21 (diff) | |
| download | rust-dde7bff5740134c98edfa38090dab1e7cbdc29a6.tar.gz rust-dde7bff5740134c98edfa38090dab1e7cbdc29a6.zip | |
Replace DefPathData::Misc by two appropriately-named variants.
| -rw-r--r-- | compiler/rustc_hir/src/definitions.rs | 14 | ||||
| -rw-r--r-- | compiler/rustc_resolve/src/def_collector.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_symbol_mangling/src/v0.rs | 3 |
3 files changed, 14 insertions, 11 deletions
diff --git a/compiler/rustc_hir/src/definitions.rs b/compiler/rustc_hir/src/definitions.rs index bce9ba12ac0..5c32dd372dd 100644 --- a/compiler/rustc_hir/src/definitions.rs +++ b/compiler/rustc_hir/src/definitions.rs @@ -261,14 +261,16 @@ pub enum DefPathData { // they are treated specially by the `def_path` function. /// The crate root (marker). CrateRoot, - // Catch-all for random `DefId` things like `DUMMY_NODE_ID`. - Misc, // Different kinds of items and item-like things: /// An impl. Impl, /// An `extern` block. ForeignMod, + /// A `use` item. + Use, + /// A global asm item. + GlobalAsm, /// Something in the type namespace. TypeNs(Symbol), /// Something in the value namespace. @@ -443,9 +445,8 @@ impl DefPathData { match *self { TypeNs(name) | ValueNs(name) | MacroNs(name) | LifetimeNs(name) => Some(name), - Impl | ForeignMod | CrateRoot | Misc | ClosureExpr | Ctor | AnonConst | ImplTrait => { - None - } + Impl | ForeignMod | CrateRoot | Use | GlobalAsm | ClosureExpr | Ctor | AnonConst + | ImplTrait => None, } } @@ -459,7 +460,8 @@ impl DefPathData { CrateRoot => DefPathDataName::Anon { namespace: kw::Crate }, Impl => DefPathDataName::Anon { namespace: kw::Impl }, 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 }, Ctor => DefPathDataName::Anon { namespace: sym::constructor }, AnonConst => DefPathDataName::Anon { namespace: sym::constant }, diff --git a/compiler/rustc_resolve/src/def_collector.rs b/compiler/rustc_resolve/src/def_collector.rs index 1e8cca6122c..f0861103098 100644 --- a/compiler/rustc_resolve/src/def_collector.rs +++ b/compiler/rustc_resolve/src/def_collector.rs @@ -109,7 +109,7 @@ impl<'a, 'b> visit::Visitor<'a> for DefCollector<'a, 'b> { visit::walk_item(self, i); return self.visit_macro_invoc(i.id); } - ItemKind::GlobalAsm(..) => DefPathData::Misc, + ItemKind::GlobalAsm(..) => DefPathData::GlobalAsm, ItemKind::Use(..) => { 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) { - self.create_def(id, DefPathData::Misc, use_tree.span); + self.create_def(id, DefPathData::Use, use_tree.span); match use_tree.kind { UseTreeKind::Simple(_, id1, id2) => { - self.create_def(id1, DefPathData::Misc, use_tree.prefix.span); - self.create_def(id2, DefPathData::Misc, use_tree.prefix.span); + self.create_def(id1, DefPathData::Use, use_tree.prefix.span); + self.create_def(id2, DefPathData::Use, use_tree.prefix.span); } UseTreeKind::Glob => (), UseTreeKind::Nested(..) => {} diff --git a/compiler/rustc_symbol_mangling/src/v0.rs b/compiler/rustc_symbol_mangling/src/v0.rs index c8fdf363f05..e1e14011e52 100644 --- a/compiler/rustc_symbol_mangling/src/v0.rs +++ b/compiler/rustc_symbol_mangling/src/v0.rs @@ -788,7 +788,8 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> { // These should never show up as `path_append` arguments. DefPathData::CrateRoot - | DefPathData::Misc + | DefPathData::Use + | DefPathData::GlobalAsm | DefPathData::Impl | DefPathData::MacroNs(_) | DefPathData::LifetimeNs(_) => { |
