rust/compiler/rustc_middle/src
bors 80926fc409 Auto merge of #86368 - michaelwoerister:lexing-ice, r=davidtwco
Disambiguate between SourceFiles from different crates even if they have the same path

This PR fixes an ICE that can occur when the compiler encounters a source file that is part of both the local crate and an upstream crate:

1. While importing source files from an upstream crate the compiler creates a `SourceFile` entry for `foo.rs` in the `SourceMap`. Since this is an imported source file its `src` field is `None`.
2. At a later point the parser encounters `foo.rs` again. It tells the `SourceMap` to load the file but because we already have an entry for `foo.rs` the `SourceMap` will return the existing version with `src == None`.
3. The parser proceeds under the assumption that `src.is_some()` and panics when actually trying to use the file's contents.

This PR fixes the issue by adding the source file's associated `CrateNum` to the `SourceMap`'s interning key. As a consequence the two instances of the file will each have a separate entry in the `SourceMap`. They just happen to share the same file path. This approach seemed less problematic to me than trying to mutate the `SourceFile` after it had already been created.

Another, more involved, approach might be to merge the `src` and the `external_src` field.

Fixes #85955
2021-06-22 14:53:58 +00:00
..
dep_graph Remove projection_ty_from_predicates 2021-06-16 16:33:03 +09:00
hir Revert "Merge CrateDisambiguator into StableCrateId" 2021-06-07 10:37:45 +02:00
ich Hash DefId in rustc_span. 2021-06-11 12:25:02 +02:00
infer Miscellaneous inlining improvements 2021-06-02 08:49:58 +02:00
middle Auto merge of #85910 - cjgillot:no-meta-version, r=Aaron1011 2021-06-10 00:39:25 +00:00
mir Fix unused_unsafe with compiler-generated unsafe 2021-06-21 17:25:45 -05:00
query Rollup merge of #86353 - JohnTitor:remove-projection_ty_from_predicates, r=oli-obk 2021-06-17 05:54:59 +09:00
traits Make traits with GATs not object safe 2021-04-27 14:34:23 -04:00
ty Encode SourceFile source crate as StableCrateId in incr. comp. OnDiskCache. 2021-06-21 15:30:16 +02:00
util
arena.rs Make THIR building a stealable query 2021-05-22 14:36:22 +02:00
lib.rs stabilize int_error_matching 2021-06-14 09:58:32 +01:00
lint.rs Add a page on force-warns in unstable book 2021-06-02 18:07:39 +02:00
macros.rs
tests.rs
thir.rs Fix unused_unsafe with compiler-generated unsafe 2021-06-21 17:25:45 -05:00