rust/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
..
bootstrap Run cargo test on tidy itself. 2022-12-31 12:34:23 -08:00
ci Run cargo test on tidy itself. 2022-12-31 12:34:23 -08:00
doc Added link from Targets to Platform Support in the book 2022-12-30 18:06:13 -05:00
etc Make the pre-push script work on directories with spaces 2022-12-17 17:18:53 -06:00
librustdoc Auto merge of #106301 - notriddle:notriddle/dir-entry, r=GuillaumeGomez 2023-01-02 10:21:53 +00:00
llvm-project@3dfd4d93fa Update LLVM submodule 2022-12-07 08:40:49 +01:00
rustdoc-json-types Rollup merge of #103065 - aDotInTheVoid:rdj-arg-pattern, r=GuillaumeGomez 2022-11-30 19:53:17 +01:00
test Auto merge of #84762 - cjgillot:resolve-span-opt, r=petrochenkov 2023-01-02 13:10:16 +00:00
tools Implement fix for #67535 2023-01-01 18:26:28 -08:00
README.md
stage0.json bump stage0 2022-12-28 09:18:43 -05:00
version bump version to 1.68 2022-12-09 17:49:45 +01:00

This directory contains the source code of the rust project, including:

  • The test suite
  • The bootstrapping build system
  • Various submodules for tools, like cargo, etc.

For more information on how various parts of the compiler work, see the rustc dev guide.