]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_metadata/encoder.rs
Rollup merge of #65792 - Centril:split-syntax-2, r=petrochenkov
[rust.git] / src / librustc_metadata / encoder.rs
index fa961fe04dcc4d11b7233d771c5d27fd9b4ac785..f6498f4eaa8919011a212465d0c3c971fb58acc2 100644 (file)
@@ -197,6 +197,13 @@ fn specialized_encode(&mut self, span: &Span) -> Result<(), Self::Error> {
             return TAG_INVALID_SPAN.encode(self)
         }
 
+        // HACK(eddyb) there's no way to indicate which crate a Span is coming
+        // from right now, so decoding would fail to find the SourceFile if
+        // it's not local to the crate the Span is found in.
+        if self.source_file_cache.is_imported() {
+            return TAG_INVALID_SPAN.encode(self)
+        }
+
         TAG_VALID_SPAN.encode(self)?;
         span.lo.encode(self)?;
 
@@ -379,6 +386,7 @@ fn encode_source_map(&mut self) -> Lazy<[syntax_pos::SourceFile]> {
             .filter(|source_file| {
                 // No need to re-export imported source_files, as any downstream
                 // crate will import them from their original source.
+                // FIXME(eddyb) the `Span` encoding should take that into account.
                 !source_file.is_imported()
             })
             .map(|source_file| {