rust/compiler/rustc_expand/src
bors 547d9374d2 Auto merge of #84373 - cjgillot:resolve-span, r=michaelwoerister,petrochenkov
Encode spans relative to the enclosing item

The aim of this PR is to avoid recomputing queries when code is moved without modification.

MCP at https://github.com/rust-lang/compiler-team/issues/443

This is achieved by :
1. storing the HIR owner LocalDefId information inside the span;
2. encoding and decoding spans relative to the enclosing item in the incremental on-disk cache;
3. marking a dependency to the `source_span(LocalDefId)` query when we translate a span from the short (`Span`) representation to its explicit (`SpanData`) representation.

Since all client code uses `Span`, step 3 ensures that all manipulations
of span byte positions actually create the dependency edge between
the caller and the `source_span(LocalDefId)`.
This query return the actual absolute span of the parent item.
As a consequence, any source code motion that changes the absolute byte position of a node will either:
- modify the distance to the parent's beginning, so change the relative span's hash;
- dirty `source_span`, and trigger the incremental recomputation of all code that
  depends on the span's absolute byte position.

With this scheme, I believe the dependency tracking to be accurate.

For the moment, the spans are marked during lowering.
I'd rather do this during def-collection,
but the AST MutVisitor is not practical enough just yet.
The only difference is that we attach macro-expanded spans
to their expansion point instead of the macro itself.
2021-09-11 23:35:28 +00:00
..
mbe Auto merge of #88262 - klensy:pprust-cow, r=nagisa 2021-08-29 17:46:29 +00:00
mut_visit Rework SESSION_GLOBALS API to prevent overwriting it 2021-07-08 16:16:28 +02:00
parse Rework SESSION_GLOBALS API to prevent overwriting it 2021-07-08 16:16:28 +02:00
tokenstream Rework SESSION_GLOBALS API to prevent overwriting it 2021-07-08 16:16:28 +02:00
base.rs Auto merge of #84373 - cjgillot:resolve-span, r=michaelwoerister,petrochenkov 2021-09-11 23:35:28 +00:00
build.rs Detect bare blocks with type ascription that were meant to be a struct literal 2021-09-03 14:43:04 +00:00
config.rs Use if-let guards in the codebase 2021-08-25 20:24:35 +02:00
expand.rs Record call_site parent for macros. 2021-09-10 20:19:25 +02:00
lib.rs Bump stage0 compiler to 1.56 2021-09-08 20:51:05 -04:00
mbe.rs fix few typos 2021-04-19 15:57:08 +03:00
module.rs Use if-let guards in the codebase 2021-08-25 20:24:35 +02:00
placeholders.rs expand: Treat more macro calls as statement macro calls 2021-09-02 14:14:38 +03:00
proc_macro_server.rs Auto merge of #84373 - cjgillot:resolve-span, r=michaelwoerister,petrochenkov 2021-09-11 23:35:28 +00:00
proc_macro.rs rustc_expand: Remove redundant field from proc macro expander structures 2021-07-10 23:22:27 +03:00
tests.rs Rework SESSION_GLOBALS API to prevent overwriting it 2021-07-08 16:16:28 +02:00