Expand description
Puts the input’s own attribute groups back into an expansion that went through syn.
syn writes every delimiter group with one span, so an attribute that survives a parse and a
quote! reaches the compiler with its [..] and (..) delimiters collapsed, and an editor can
no longer map the attribute’s path to the source it was written at. restore_attrs replaces
each surviving #[..] group with the group the input carried, which is the same tokens with
their original spans.
A group is matched by its contents with spacing ignored and by its span, which syn keeps
from the input as the span of the whole group: an attribute the macro removed, rewrote or
generated has no counterpart and is left as built, even where its text equals another
attribute’s. Among groups equal in both, which only an input that repeats one source position
can carry, source order decides.
Functions§
- restore_
attrs outputwith every#[..]or#![..]group that also appears ininputreplaced by the input’s group.- restore_
item itemwritten back as tokens, with the attribute groupsinputcarried restored.inputis the tokens the macro was given anditemwhat it parsed from them and may have changed; only the item is restored, so an attribute the macro generates around it is not matched.