2bf78d12d3
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. |
||
---|---|---|
.. | ||
auxiliary | ||
uniform-paths | ||
async-ident-allowed.rs | ||
async-ident-allowed.stderr | ||
async-ident.fixed | ||
async-ident.rs | ||
async-ident.stderr | ||
dyn-keyword.fixed | ||
dyn-keyword.rs | ||
dyn-keyword.stderr | ||
dyn-trait-compatibility.rs | ||
dyn-trait-compatibility.stderr | ||
edition-lint-fully-qualified-paths.fixed | ||
edition-lint-fully-qualified-paths.rs | ||
edition-lint-fully-qualified-paths.stderr | ||
edition-lint-infer-outlives-macro.fixed | ||
edition-lint-infer-outlives-macro.rs | ||
edition-lint-infer-outlives-macro.stderr | ||
edition-lint-infer-outlives-multispan.rs | ||
edition-lint-infer-outlives-multispan.stderr | ||
edition-lint-infer-outlives.fixed | ||
edition-lint-infer-outlives.rs | ||
edition-lint-infer-outlives.stderr | ||
edition-lint-nested-empty-paths.fixed | ||
edition-lint-nested-empty-paths.rs | ||
edition-lint-nested-empty-paths.stderr | ||
edition-lint-nested-paths.fixed | ||
edition-lint-nested-paths.rs | ||
edition-lint-nested-paths.stderr | ||
edition-lint-paths-2018.rs | ||
edition-lint-paths.fixed | ||
edition-lint-paths.rs | ||
edition-lint-paths.stderr | ||
edition-lint-uninferable-outlives.rs | ||
extern-crate-idiomatic-in-2018.fixed | ||
extern-crate-idiomatic-in-2018.rs | ||
extern-crate-idiomatic-in-2018.stderr | ||
extern-crate-idiomatic.fixed | ||
extern-crate-idiomatic.rs | ||
extern-crate-referenced-by-self-path.fixed | ||
extern-crate-referenced-by-self-path.rs | ||
extern-crate-rename.fixed | ||
extern-crate-rename.rs | ||
extern-crate-rename.stderr | ||
extern-crate-submod.fixed | ||
extern-crate-submod.rs | ||
extern-crate-submod.stderr | ||
future-proofing-locals.rs | ||
future-proofing-locals.stderr | ||
issue-51008-1.rs | ||
issue-51008.rs | ||
issue-52202-use-suggestions.rs | ||
issue-52202-use-suggestions.stderr | ||
issue-54006.rs | ||
issue-54006.stderr | ||
issue-54400-unused-extern-crate-attr-span.fixed | ||
issue-54400-unused-extern-crate-attr-span.rs | ||
issue-54400-unused-extern-crate-attr-span.stderr | ||
local-path-suggestions-2015.rs | ||
local-path-suggestions-2015.stderr | ||
local-path-suggestions-2018.rs | ||
local-path-suggestions-2018.stderr | ||
macro-use-warned-against.rs | ||
macro-use-warned-against.stderr | ||
proc-macro-crate-in-paths.rs | ||
remove-extern-crate.fixed | ||
remove-extern-crate.rs | ||
remove-extern-crate.stderr | ||
suggestions-not-always-applicable.fixed | ||
suggestions-not-always-applicable.rs | ||
trait-import-suggestions.rs | ||
trait-import-suggestions.stderr | ||
try-ident.fixed | ||
try-ident.rs | ||
try-ident.stderr | ||
try-macro.fixed | ||
try-macro.rs | ||
try-macro.stderr | ||
unresolved-asterisk-imports.rs | ||
unresolved-asterisk-imports.stderr |