rust/compiler
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
..
rustc
rustc_abi Auto merge of #105446 - erikdesjardins:vt-size, r=nikic 2022-12-18 22:01:39 +00:00
rustc_apfloat
rustc_arena
rustc_ast Rename Rptr to Ref in AST and HIR 2022-12-28 18:52:36 +01:00
rustc_ast_lowering Auto merge of #84762 - cjgillot:resolve-span-opt, r=petrochenkov 2023-01-02 13:10:16 +00:00
rustc_ast_passes
rustc_ast_pretty Rename Rptr to Ref in AST and HIR 2022-12-28 18:52:36 +01:00
rustc_attr
rustc_baked_icu_data
rustc_borrowck Verbose suggestions 2023-01-01 21:33:23 -08:00
rustc_builtin_macros Rename Rptr to Ref in AST and HIR 2022-12-28 18:52:36 +01:00
rustc_codegen_cranelift Auto merge of #105613 - Nilstrieb:rename-assert_uninit_valid, r=RalfJung 2022-12-21 23:20:04 +00:00
rustc_codegen_gcc Add missing anonymous lifetime 2022-12-20 22:34:42 +01:00
rustc_codegen_llvm Rollup merge of #105955 - Nilstrieb:no-trivial-opt-wrappers-we-have-field-accesses-for-that, r=cjgillot 2022-12-25 22:15:00 +01:00
rustc_codegen_ssa Auto merge of #105605 - inquisitivecrystal:attr-validation, r=cjgillot 2022-12-26 09:06:51 +00:00
rustc_const_eval Auto merge of #105085 - oli-obk:stop_promoting_all_the_things, r=RalfJung 2022-12-24 14:00:37 +00:00
rustc_data_structures fix some typos 2022-12-25 00:43:50 +01:00
rustc_driver Only deduplicate stack traces for good path bugs 2022-12-31 02:14:26 +00:00
rustc_error_codes refactor: merge E0465 into E0464 2022-12-31 20:44:54 +13:00
rustc_error_messages refactor: merge E0465 into E0464 2022-12-31 20:44:54 +13:00
rustc_errors Auto merge of #84762 - cjgillot:resolve-span-opt, r=petrochenkov 2023-01-02 13:10:16 +00:00
rustc_expand Auto merge of #84762 - cjgillot:resolve-span-opt, r=petrochenkov 2023-01-02 13:10:16 +00:00
rustc_feature Use the correct tracking issue for dyn_star 2023-01-01 19:56:10 +01:00
rustc_fs_util
rustc_graphviz Indicate anonymous lifetime 2022-12-23 15:59:53 +01:00
rustc_hir Rollup merge of #106221 - Nilstrieb:rptr-more-like-ref-actually, r=compiler-errors 2022-12-29 13:16:04 +01:00
rustc_hir_analysis Implement fix for #67535 2023-01-01 18:26:28 -08:00
rustc_hir_pretty Rename Rptr to Ref in AST and HIR 2022-12-28 18:52:36 +01:00
rustc_hir_typeck Auto merge of #84762 - cjgillot:resolve-span-opt, r=petrochenkov 2023-01-02 13:10:16 +00:00
rustc_incremental rustc: Remove needless lifetimes 2022-12-20 22:10:40 +01:00
rustc_index A few small cleanups for newtype_index 2022-12-18 21:47:28 +01:00
rustc_infer Rollup merge of #106221 - Nilstrieb:rptr-more-like-ref-actually, r=compiler-errors 2022-12-29 13:16:04 +01:00
rustc_interface Ignore span references from diagnostics. 2022-12-25 18:48:42 +00:00
rustc_lexer Recover fn keyword as Fn trait in bounds 2022-12-27 06:14:46 +00:00
rustc_lint Rollup merge of #106248 - dtolnay:revertupcastlint, r=jackh726 2022-12-30 21:26:34 -08:00
rustc_lint_defs fix some typos 2022-12-25 00:43:50 +01:00
rustc_llvm
rustc_log
rustc_macros rustc: Remove needless lifetimes 2022-12-20 22:10:40 +01:00
rustc_metadata refactor: merge E0465 into E0464 2022-12-31 20:44:54 +13:00
rustc_middle Auto merge of #84762 - cjgillot:resolve-span-opt, r=petrochenkov 2023-01-02 13:10:16 +00:00
rustc_mir_build Rollup merge of #105975 - jeremystucki:rustc-remove-needless-lifetimes, r=eholk 2022-12-24 00:31:41 +01:00
rustc_mir_dataflow rustc: Remove needless lifetimes 2022-12-20 22:10:40 +01:00
rustc_mir_transform Give the correct track-caller location with MIR inlining. 2022-12-25 18:48:13 +00:00
rustc_monomorphize Auto merge of #106143 - matthiaskrgr:rollup-3kpy1dc, r=matthiaskrgr 2022-12-25 23:47:11 +00:00
rustc_parse Auto merge of #106268 - kraktus:patch-2, r=Nilstrieb 2022-12-30 06:59:13 +00:00
rustc_parse_format Add enum for find_width_map_from_snippet 2022-12-28 17:43:35 +01:00
rustc_passes Rename Rptr to Ref in AST and HIR 2022-12-28 18:52:36 +01:00
rustc_plugin_impl
rustc_privacy
rustc_query_impl Rollup merge of #105975 - jeremystucki:rustc-remove-needless-lifetimes, r=eholk 2022-12-24 00:31:41 +01:00
rustc_query_system Ignore span references from diagnostics. 2022-12-25 18:48:42 +00:00
rustc_resolve Rollup merge of #106221 - Nilstrieb:rptr-more-like-ref-actually, r=compiler-errors 2022-12-29 13:16:04 +01:00
rustc_save_analysis Rename Rptr to Ref in AST and HIR 2022-12-28 18:52:36 +01:00
rustc_serialize
rustc_session Auto merge of #84762 - cjgillot:resolve-span-opt, r=petrochenkov 2023-01-02 13:10:16 +00:00
rustc_smir
rustc_span Auto merge of #84762 - cjgillot:resolve-span-opt, r=petrochenkov 2023-01-02 13:10:16 +00:00
rustc_symbol_mangling CFI: Monomorphize transparent ADTs before typeid 2022-12-29 10:21:07 -08:00
rustc_target fix some typos 2022-12-25 00:43:50 +01:00
rustc_trait_selection Merge multiple mutable borrows of immutable binding errors 2023-01-01 10:09:26 -08:00
rustc_traits rustc: Remove needless lifetimes 2022-12-20 22:10:40 +01:00
rustc_transmute Rollup merge of #105864 - matthiaskrgr:compl, r=Nilstrieb 2022-12-19 14:41:35 +05:30
rustc_ty_utils Rename some compare_method functions 2022-12-24 21:36:58 +00:00
rustc_type_ir A few small cleanups for newtype_index 2022-12-18 21:47:28 +01:00