rust/compiler/rustc_span/src
bors 2bf78d12d3 Auto merge of #119673 - petrochenkov:dialoc5, r=compiler-errors,cjgillot
macro_rules: Preserve all metavariable spans in a global side table

This PR preserves spans of `tt` metavariables used to pass tokens to declarative macros.
Such metavariable spans can then be used in span combination operations like `Span::to` to improve all kinds of diagnostics.

Spans of non-`tt` metavariables are currently kept in nonterminal tokens, but the long term plan is remove all nonterminal tokens from rustc parser and rely on the proc macro model with invisible delimiters (#114647, #67062).
In particular, `NtIdent` nonterminal (corresponding to `ident` metavariables) becomes easy to remove when this PR lands (#119412 does it).

The metavariable spans are kept in a global side table keyed by `Span`s of original tokens.
The alternative to the side table is keeping them in `SpanData` instead, but the performance regressions would be large because any spans from tokens passed to declarative macros would stop being inline and would work through span interner instead, and the penalty would be paid even if we never use the metavar span for the given original span.
(But also see the comment on `fn maybe_use_metavar_location` describing the map collision issues with the side table approach.)

There are also other alternatives - keeping the metavar span in `Token` or `TokenTree`, but associating it with `Span` itsel is the most natural choice because metavar spans are used in span combining operations, and those operations are not necessarily tied to tokens.
2024-02-18 20:51:16 +00:00
..
analyze_source_file Use relative positions inside a SourceFile. 2023-09-03 12:56:10 +00:00
edit_distance Add test for precise algorithm used 2023-02-19 22:59:22 +00:00
source_map By tracking import use types to check whether it is scope uses or the other situations like module-relative uses, we can do more accurate redundant import checking. 2024-02-18 16:38:11 +08:00
symbol Use FxIndexSet in the symbol interner. 2023-11-03 07:19:41 +11:00
analyze_source_file.rs Initiate the inner usage of cfg_match 2023-10-19 20:18:51 -03:00
caching_source_map_view.rs Add better ICE messages for some undescriptive panics 2023-12-15 00:50:55 -05:00
def_id.rs Auto merge of #119478 - bjorn3:no_serialize_specialization, r=wesleywiser 2024-01-06 09:56:00 +00:00
edit_distance.rs check rust lints when an unknown lint is detected 2024-01-12 18:50:36 +08:00
edition.rs Remove edition umbrella features. 2023-12-10 13:03:28 -08:00
fatal_error.rs Auto merge of #117557 - Zoxc:panic-prio, r=petrochenkov 2023-11-09 00:39:02 +00:00
hygiene.rs Add async bound modifier to enable async Fn bounds 2024-01-31 16:59:19 +00:00
lib.rs macro_rules: Preserve all metavariable spans in a global side table 2024-02-18 11:19:24 +03:00
profiling.rs Remove an unnecessary use of with_session_globals. 2023-03-31 15:34:00 +11:00
source_map.rs Use UnhashMap for a few more maps 2024-01-17 17:09:55 -05:00
span_encoding.rs rustc_span: Optimize syntax context comparisons 2024-01-06 01:25:20 +03:00
symbol.rs Auto merge of #120500 - oli-obk:intrinsics2.0, r=WaffleLapkin 2024-02-16 09:53:01 +00:00
tests.rs Use Freeze for SourceFile.lines 2023-09-07 13:05:05 +02:00