Auto merge of #119139 - michaelwoerister:cleanup-stable-source-file-id, r=cjgillot
Unify SourceFile::name_hash and StableSourceFileId This PR adapts the existing `StableSourceFileId` type so that it can be used instead of the `name_hash` field of `SourceFile`. This simplifies a few things that were kind of duplicated before. The PR should also fix issues https://github.com/rust-lang/rust/issues/112700 and https://github.com/rust-lang/rust/issues/115835, but I was not able to reproduce these issues in a regression test. As far as I can tell, the root cause of these issues is that the id of the originating crate is not hashed in the `HashStable` impl of `Span` and thus cache entries that should have been considered invalidated were loaded. After this PR, the `stable_id` field of `SourceFile` includes information about the originating crate, so that ICE should not occur anymore.
This commit is contained in:
commit
bf8716f1cd
10 changed files with 131 additions and 118 deletions
|
@ -60,8 +60,8 @@ impl<'ctx> rustc_ast::HashStableContext for StableHashingContext<'ctx> {
|
|||
impl<'a> HashStable<StableHashingContext<'a>> for SourceFile {
|
||||
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
|
||||
let SourceFile {
|
||||
name: _, // We hash the smaller name_hash instead of this
|
||||
name_hash,
|
||||
name: _, // We hash the smaller stable_id instead of this
|
||||
stable_id,
|
||||
cnum,
|
||||
// Do not hash the source as it is not encoded
|
||||
src: _,
|
||||
|
@ -75,7 +75,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for SourceFile {
|
|||
ref normalized_pos,
|
||||
} = *self;
|
||||
|
||||
name_hash.hash_stable(hcx, hasher);
|
||||
stable_id.hash_stable(hcx, hasher);
|
||||
|
||||
src_hash.hash_stable(hcx, hasher);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue