diff options
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_hir/src/definitions.rs | 22 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/print/pretty.rs | 4 |
2 files changed, 21 insertions, 5 deletions
diff --git a/compiler/rustc_hir/src/definitions.rs b/compiler/rustc_hir/src/definitions.rs index 1a0af38517a..98b41187f11 100644 --- a/compiler/rustc_hir/src/definitions.rs +++ b/compiler/rustc_hir/src/definitions.rs @@ -145,7 +145,7 @@ impl DefKey { let DisambiguatedDefPathData { ref data, disambiguator } = self.disambiguated_data; std::mem::discriminant(data).hash(&mut hasher); - if let Some(name) = data.get_opt_name() { + if let Some(name) = data.hashed_symbol() { // Get a stable hash by considering the symbol chars rather than // the symbol index. name.as_str().hash(&mut hasher); @@ -445,6 +445,26 @@ impl DefPathData { pub fn get_opt_name(&self) -> Option<Symbol> { use self::DefPathData::*; match *self { + TypeNs(name) | ValueNs(name) | MacroNs(name) | LifetimeNs(name) => Some(name), + + Impl + | ForeignMod + | CrateRoot + | Use + | GlobalAsm + | Closure + | Ctor + | AnonConst + | OpaqueTy + | AnonAssocTy(..) + | SyntheticCoroutineBody + | NestedStatic => None, + } + } + + fn hashed_symbol(&self) -> Option<Symbol> { + use self::DefPathData::*; + match *self { TypeNs(name) | ValueNs(name) | MacroNs(name) | LifetimeNs(name) | AnonAssocTy(name) => { Some(name) } diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index f589c7df628..1df3bff5244 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -391,10 +391,6 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { let visible_parent_map = self.tcx().visible_parent_map(()); let kind = self.tcx().def_kind(def_id); - if let DefPathData::AnonAssocTy(..) = key.disambiguated_data.data { - return Ok(false); - } - let get_local_name = |this: &Self, name, def_id, key: DefKey| { if let Some(visible_parent) = visible_parent_map.get(&def_id) && let actual_parent = this.tcx().opt_parent(def_id) |
