Skip to content

guess_head_span depends on untracked state when used with an imported file #86480

@Aaron1011

Description

@Aaron1011

guess_head_span ends up calling ensure_source_file_source_present, which calls add_external_src. If the source file of the span is an imported file, then whether or not this method succeeds depends on the current file on disk:

if self.src_hash.matches(&src) {
normalize_src(&mut src, BytePos::from_usize(0));
*src_kind = ExternalSourceKind::Present(Lrc::new(src));
return true;
}

However, the hash of the external crate depends on the hash of the file at the time the external crate was compiled, not the time the current crate is compiled. If the external crate is a Cargo dependency (in ~/.cargo/registry), then changing a file in the dependency will not cause it to be re-built, allowing a new compilation session to read in a different file than the one used to originally compile the external crate.

Since guess_head_span falls back to the passed-in span if reading the source file fails, the span that we end up using depends on global untracked state (the current contents of an external crate's file on disk).

Metadata

Metadata

Assignees

Labels

A-incr-compArea: Incremental compilationC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions