rust/compiler/rustc_session/src
bors 984a6bf9c1 Auto merge of #92175 - Aaron1011:fix-missing-source-file, r=cjgillot
Import `SourceFile`s from crate before decoding foreign `Span`

Fixes #92163
Fixes #92014

When writing to the incremental cache, we encode all `Span`s
we encounter, regardless of whether or not their `SourceFile`
comes from the local crate, or from a foreign crate.

When we decode a `Span`, we use the `StableSourceFileId` we encoded
to locate the matching `SourceFile` in the current session. If this
id corresponds to a `SourceFile` from another crate, then we need to
have already imported that `SourceFile` into our current session.

This usually happens automatically during resolution / macro expansion,
when we try to resolve definitions from other crates. In certain cases,
however, we may try to load a `Span` from a transitive dependency
without having ever imported the `SourceFile`s from that crate, leading
to an ICE.

This PR fixes the issue by enconding the `SourceFile`'s `CrateNum`
when we encode a `Span`. During decoding, we call `imported_source_files()`
when we encounter a foreign `CrateNum`, which ensure that all
`SourceFile`s from that crate are imported into the current session.
2021-12-31 16:38:23 +00:00
..
cgu_reuse_tracker.rs Make Diagnostic::span_fatal unconditionally raise an error 2021-05-08 23:12:04 -04:00
code_stats.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
config.rs Auto merge of #88354 - Jmc18134:hint-space-pauth-opt, r=nagisa 2021-12-29 22:35:11 +00:00
cstore.rs Import SourceFiles from crate before decoding foreign Span 2021-12-23 12:56:12 -05:00
filesearch.rs Use IntoIterator for array impl everywhere. 2021-12-04 19:40:33 +01:00
lib.rs Use derive_default_enum in the compiler 2021-11-22 20:17:53 -05:00
options.rs Auto merge of #88354 - Jmc18134:hint-space-pauth-opt, r=nagisa 2021-12-29 22:35:11 +00:00
output.rs Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obk 2021-12-19 09:31:37 +00:00
parse.rs review comment: plural of emoji is emoji 2021-11-23 20:36:19 +00:00
search_paths.rs Doc comments 2021-09-08 18:25:46 +02:00
session.rs Auto merge of #91555 - matthiaskrgr:rollup-pq0iaq7, r=matthiaskrgr 2021-12-05 15:33:44 +00:00
utils.rs Implement RFC 2951: Native link modifiers 2021-05-05 16:04:25 -07:00