about summary refs log tree commit diff
path: root/src/librustc
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-09-28 06:40:32 +0000
committerbors <bors@rust-lang.org>2018-09-28 06:40:32 +0000
commitbd8d030d014a4aa13b9b02b0ce98e2de2a2c54be (patch)
treef9073c5d1269b2c8c372857159d5e59b9e5808c1 /src/librustc
parentc222479c6feb036e5e5198e068aa9824d855ffa4 (diff)
parent2d7edf908d5767567d20bec2440099b317169d8d (diff)
downloadrust-bd8d030d014a4aa13b9b02b0ce98e2de2a2c54be.tar.gz
rust-bd8d030d014a4aa13b9b02b0ce98e2de2a2c54be.zip
Auto merge of #54338 - orium:fix-macro-inc-comp, r=nrc
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.

r? @nrc
Diffstat (limited to 'src/librustc')
-rw-r--r--src/librustc/hir/map/definitions.rs25
-rw-r--r--src/librustc/ty/query/on_disk_cache.rs1
2 files changed, 26 insertions, 0 deletions
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<F>(&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<interpret::AllocId> for CacheDecoder<'a, '
         alloc_decoding_session.decode_alloc_id(self)
     }
 }
+
 impl<'a, 'tcx, 'x> SpecializedDecoder<Span> for CacheDecoder<'a, 'tcx, 'x> {
     fn specialized_decode(&mut self) -> Result<Span, Self::Error> {
         let tag: u8 = Decodable::decode(self)?;