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

Commit a23b8ca

Browse files
committed
rustc: don't hash the --extern crate name, but the original one, in DefPath.
1 parent 221d1a9 commit a23b8ca

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/librustc/hir/map/definitions.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,7 @@ impl DefPath {
115115
pub fn to_string(&self, tcx: TyCtxt) -> String {
116116
let mut s = String::with_capacity(self.data.len() * 16);
117117

118-
if self.krate == LOCAL_CRATE {
119-
s.push_str(&tcx.crate_name(self.krate));
120-
} else {
121-
s.push_str(&tcx.sess.cstore.original_crate_name(self.krate));
122-
}
118+
s.push_str(&tcx.original_crate_name(self.krate));
123119
s.push_str("/");
124120
s.push_str(&tcx.crate_disambiguator(self.krate));
125121

@@ -141,7 +137,7 @@ impl DefPath {
141137
}
142138

143139
pub fn deterministic_hash_to<H: Hasher>(&self, tcx: TyCtxt, state: &mut H) {
144-
tcx.crate_name(self.krate).hash(state);
140+
tcx.original_crate_name(self.krate).hash(state);
145141
tcx.crate_disambiguator(self.krate).hash(state);
146142
self.data.hash(state);
147143
}

src/librustc/ty/context.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,14 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
513513
}
514514
}
515515

516+
pub fn original_crate_name(self, cnum: CrateNum) -> token::InternedString {
517+
if cnum == LOCAL_CRATE {
518+
self.crate_name.clone()
519+
} else {
520+
self.sess.cstore.original_crate_name(cnum)
521+
}
522+
}
523+
516524
pub fn crate_disambiguator(self, cnum: CrateNum) -> token::InternedString {
517525
if cnum == LOCAL_CRATE {
518526
self.sess.local_crate_disambiguator()

src/librustc/ty/item_path.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
101101
RootMode::Absolute => {
102102
// In absolute mode, just write the crate name
103103
// unconditionally.
104-
if cnum == LOCAL_CRATE {
105-
buffer.push(&self.crate_name(cnum));
106-
} else {
107-
buffer.push(&self.sess.cstore.original_crate_name(cnum));
108-
}
104+
buffer.push(&self.original_crate_name(cnum));
109105
}
110106
}
111107
}

0 commit comments

Comments
 (0)