You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add ClosestAstOrMacro to allow detecting macro expansions
Following PR rust-lang#72389, we create many more spans with
`ExpnKind::Desugaring`. This exposed a latent bug in Clippy - only the
top-most `ExpnData` is considered when checking if code is the result of
a macro expansion. If code emitted by a macro expansion gets annotated
with an `ExpnKind::Desugaring` (e.g. an operator or a for loop), Clippy
will incorrectly act as though this code is not the result of a macro
expansion.
This PR introduces the `ClosestAstOrMacro` enum, which allows linting
code to quickly determine if a given `Span` is the result of a macro
expansion. For any `ExpnId`, we keep track of closest `ExpnKind::Macro`
or `ExpnKind::AstPass` in the `call_site` chain. This is determined when
the `ExpnData` is set for an `ExpnId`, which allows us to avoid walking
the entire chain in Clippy.
0 commit comments