-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Audit accesses to the source_map #97417
Copy link
Copy link
Open
Labels
A-HIRArea: The high-level intermediate representation (HIR)Area: The high-level intermediate representation (HIR)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-incr-compArea: Incremental compilationArea: Incremental compilationE-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-HIRArea: The high-level intermediate representation (HIR)Area: The high-level intermediate representation (HIR)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-incr-compArea: Incremental compilationArea: Incremental compilationE-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
The exact source code text in the
SourceMapis not tracked for incremental compilation. Accessing it and changing behaviour depending on this text is bound to cause issues with incremental compilation. Accesses to thesource_mapshould therefore be audited, to remove access to such untracked information.As the main use for these is diagnostics (accessing the exact source code, adjusting a span...). As a consequence, we don't expect ICEs or miscompilations. The worse that could happen is weird diagnostics.
Are fine:
impl HashStable for Span: filename, line number, column number...Steps:
source_map: () -> &'tcx SourceMap, markedeval_alwaysandno_hash;tcx.sess.source_map()(there are many), determine if it looks at the source code text;2.2 if it does, see below;
2.1. if it does not: leave it as it, wrap this access in a method on
TyCtxtinrustc_middle::ty::contextand document why this access is fine.When an untracked access to the source code is found, there are three options, in order:
tcx.sess.source_map()bytcx.source_map(()), which will force the query system to recompute everything properly.Note: there are many of such accesses. A quick grep counted ~300.
We do not expect a single contributor to audit all of them at once.
Do not hesitate to contact @cjgillot on zulip if necessary.