-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Audit accesses to the source_map #97417
Comments
@rustbot claim |
In addition: the compiler uses We could add a |
…-and-impl-item, r=cjgillot Replace some `guess_head_span` with `def_span` This patch fixes a part of rust-lang#97417. r? `@cjgillot`
…-and-impl-item, r=cjgillot Replace some `guess_head_span` with `def_span` This patch fixes a part of rust-lang#97417. r? `@cjgillot`
…gillot Keep track of the start of the argument block of a closure This removes a call to `tcx.sess.source_map()` from [compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs](https://github.com/rust-lang/rust/compare/master...SarthakSingh31:issue-97417-1?expand=1#diff-8406bbc0d0b43d84c91b1933305df896ecdba0d1f9269e6744f13d87a2ab268a) as required by rust-lang#97417. VsCode automatically applied `rustfmt` to the files I edited under `src/tools`. I can undo that if its a problem. r? `@cjgillot`
…gillot Keep track of the start of the argument block of a closure This removes a call to `tcx.sess.source_map()` from [compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs](https://github.com/rust-lang/rust/compare/master...SarthakSingh31:issue-97417-1?expand=1#diff-8406bbc0d0b43d84c91b1933305df896ecdba0d1f9269e6744f13d87a2ab268a) as required by rust-lang#97417. VsCode automatically applied `rustfmt` to the files I edited under `src/tools`. I can undo that if its a problem. r? `@cjgillot`
…gillot Keep track of the start of the argument block of a closure This removes a call to `tcx.sess.source_map()` from [compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs](https://github.com/rust-lang/rust/compare/master...SarthakSingh31:issue-97417-1?expand=1#diff-8406bbc0d0b43d84c91b1933305df896ecdba0d1f9269e6744f13d87a2ab268a) as required by rust-lang#97417. VsCode automatically applied `rustfmt` to the files I edited under `src/tools`. I can undo that if its a problem. r? `@cjgillot`
The exact source code text in the
SourceMap
is 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_map
should 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_always
andno_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
TyCtxt
inrustc_middle::ty::context
and 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.
The text was updated successfully, but these errors were encountered: