Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 4869e20

Browse files
committed
Split get_opt_name hashing use into hashed_symbol
1 parent d16daf5 commit 4869e20

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

compiler/rustc_hir/src/definitions.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ impl DefKey {
145145
let DisambiguatedDefPathData { ref data, disambiguator } = self.disambiguated_data;
146146

147147
std::mem::discriminant(data).hash(&mut hasher);
148-
if let Some(name) = data.get_opt_name() {
148+
if let Some(name) = data.hashed_symbol() {
149149
// Get a stable hash by considering the symbol chars rather than
150150
// the symbol index.
151151
name.as_str().hash(&mut hasher);
@@ -443,6 +443,26 @@ pub enum DefPathDataName {
443443

444444
impl DefPathData {
445445
pub fn get_opt_name(&self) -> Option<Symbol> {
446+
use self::DefPathData::*;
447+
match *self {
448+
TypeNs(name) | ValueNs(name) | MacroNs(name) | LifetimeNs(name) => Some(name),
449+
450+
Impl
451+
| ForeignMod
452+
| CrateRoot
453+
| Use
454+
| GlobalAsm
455+
| Closure
456+
| Ctor
457+
| AnonConst
458+
| OpaqueTy
459+
| AnonAssocTy(..)
460+
| SyntheticCoroutineBody
461+
| NestedStatic => None,
462+
}
463+
}
464+
465+
fn hashed_symbol(&self) -> Option<Symbol> {
446466
use self::DefPathData::*;
447467
match *self {
448468
TypeNs(name) | ValueNs(name) | MacroNs(name) | LifetimeNs(name) | AnonAssocTy(name) => {

compiler/rustc_middle/src/ty/print/pretty.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,10 +391,6 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
391391
let visible_parent_map = self.tcx().visible_parent_map(());
392392
let kind = self.tcx().def_kind(def_id);
393393

394-
if let DefPathData::AnonAssocTy(..) = key.disambiguated_data.data {
395-
return Ok(false);
396-
}
397-
398394
let get_local_name = |this: &Self, name, def_id, key: DefKey| {
399395
if let Some(visible_parent) = visible_parent_map.get(&def_id)
400396
&& let actual_parent = this.tcx().opt_parent(def_id)

0 commit comments

Comments
 (0)