rust/compiler/rustc_session/src
bors fb9dfa8cef Auto merge of #84762 - cjgillot:resolve-span-opt, r=petrochenkov
Encode spans relative to the enclosing item -- enable on nightly

Follow-up to #84373 with the flag `-Zincremental-relative-spans` set by default.

This PR seeks to remove one of the main shortcomings of incremental: the handling of spans.
Changing the contents of a function may require redoing part of the compilation process for another function in another file because of span information is changed.
Within one file: all the spans in HIR change, so typechecking had to be re-done.
Between files: spans of associated types/consts/functions change, so type-based resolution needs to be re-done (hygiene information is stored in the span).

The flag `-Zincremental-relative-spans` encodes local spans relative to the span of an item, stored inside the `source_span` query.

Trap: stashed diagnostics are referenced by the "raw" span, so stealing them requires to remove the span's parent.

In order to avoid too much traffic in the span interner, span encoding uses the `ctxt_or_tag` field to encode:
- the parent when the `SyntaxContext` is 0;
- the `SyntaxContext` when the parent is `None`.
Even with this, the PR creates a lot of traffic to the Span interner, when a Span has both a LocalDefId parent and a non-root SyntaxContext. They appear in lowering, when we add a parent to all spans, including those which come from macros, and during inlining when we mark inlined spans.

The last commit changes how queries of `LocalDefId` manage their cache. I can put this in a separate PR if required.

Possible future directions:
- validate that all spans are marked in HIR validation;
- mark macro-expanded spans relative to the def-site and not the use-site.
2023-01-02 13:10:16 +00:00
..
config Change process spawning to inherit the parent's signal mask by default 2022-10-20 14:53:38 -07:00
cgu_reuse_tracker.rs Remove useless borrows and derefs 2022-12-01 17:34:43 +00:00
code_stats.rs Properly print generator interior type sizes 2022-12-07 18:33:26 +00:00
config.rs Only enable relative span hashing on nightly. 2022-12-25 18:48:36 +00:00
cstore.rs Fold Definitions into the untracked data 2022-12-09 14:59:39 +00:00
errors.rs Auto merge of #105421 - jacobbramley:jb/branch-prot-check, r=nagisa 2022-12-17 12:10:27 +00:00
filesearch.rs clippy::complexity fixes 2022-12-19 00:04:28 +01:00
lib.rs remove cfg(bootstrap) 2022-09-26 10:14:45 +02:00
options.rs Auto merge of #84762 - cjgillot:resolve-span-opt, r=petrochenkov 2023-01-02 13:10:16 +00:00
output.rs Use Symbol for the crate name instead of String/str 2022-12-07 20:30:02 +00:00
parse.rs rustc: Remove needless lifetimes 2022-12-20 22:10:40 +01:00
search_paths.rs incr. comp.: Don't export impl_stable_hash_via_hash!() and warn about using it. 2022-04-19 10:43:20 +02:00
session.rs Remove wrapper functions for some unstable options 2022-12-20 15:02:15 +01:00
utils.rs rustc: Remove needless lifetimes 2022-12-20 22:10:40 +01:00