From 2d7edf908d5767567d20bec2440099b317169d8d Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Wed, 19 Sep 2018 01:09:36 +0100 Subject: Use full name to identify a macro in a `FileName`. Before this two macros with same name would be indistinguishable inside a `FileName`. This caused a bug in incremental compilation (see #53097) since two different macros would map out to the same `StableFilemapId`. Fixes #53097. --- src/librustc/hir/map/definitions.rs | 25 +++++++++++++++++++++++++ src/librustc/ty/query/on_disk_cache.rs | 1 + 2 files changed, 26 insertions(+) (limited to 'src/librustc') diff --git a/src/librustc/hir/map/definitions.rs b/src/librustc/hir/map/definitions.rs index c85cee73660..fa4bf1511b8 100644 --- a/src/librustc/hir/map/definitions.rs +++ b/src/librustc/hir/map/definitions.rs @@ -287,6 +287,31 @@ impl DefPath { s } + /// Return filename friendly string of the DefPah with the + /// crate-prefix. + pub fn to_string_friendly(&self, crate_imported_name: F) -> String + where F: FnOnce(CrateNum) -> Symbol + { + let crate_name_str = crate_imported_name(self.krate).as_str(); + let mut s = String::with_capacity(crate_name_str.len() + self.data.len() * 16); + + write!(s, "::{}", crate_name_str).unwrap(); + + for component in &self.data { + if component.disambiguator == 0 { + write!(s, "::{}", component.data.as_interned_str()).unwrap(); + } else { + write!(s, + "{}[{}]", + component.data.as_interned_str(), + component.disambiguator) + .unwrap(); + } + } + + s + } + /// Return filename friendly string of the DefPah without /// the crate-prefix. This method is useful if you don't have /// a TyCtxt available. diff --git a/src/librustc/ty/query/on_disk_cache.rs b/src/librustc/ty/query/on_disk_cache.rs index 0e4d2f1f647..296602e21ba 100644 --- a/src/librustc/ty/query/on_disk_cache.rs +++ b/src/librustc/ty/query/on_disk_cache.rs @@ -606,6 +606,7 @@ impl<'a, 'tcx, 'x> SpecializedDecoder for CacheDecoder<'a, ' alloc_decoding_session.decode_alloc_id(self) } } + impl<'a, 'tcx, 'x> SpecializedDecoder for CacheDecoder<'a, 'tcx, 'x> { fn specialized_decode(&mut self) -> Result { let tag: u8 = Decodable::decode(self)?; -- cgit 1.4.1-3-g733a5