Open oddcoder opened 2 months ago
This is something that could be fixed on the clippy side, but FWIW, it would be better to just use the proper span APIs to begin with, i.e. use Span::call_site().located_at(field.span())
here:
https://github.com/oddcoder/clippy-macros-bug/blob/main/marshalable-derive/src/lib.rs#L40
That should also get clippy to stop emitting warnings there already, because the lint already does have macro checks.
When passing an input span directly to quote_spanned!
, the spans have no indication that they're from a macro, so detecting these kinds of things require an additional check in the lint.
It works as expected with quote!
because that uses Span::call_site()
for the let statement, which preserves the macro information
Summary
Cargo clippy captures warnings from inside macros when using
quote_spanned!
. Attempting--fix
results in: warning: failed to automatically apply fixes suggested by rustc to crate.....
after fixes were automatically applied the compiler reported errors within these files ....Replacing
quote_spanned
withquote
here made the bug disappear.Reproducer
The code does not fit in a snippet, unfortunately multiple crates are required But a small reproducer may be found here
I expected to see no warnings when running cargo clippy.
Instead, this happened:
Futhermore attempting
`--fix
causes clippy error:But this might be a side effect.
Version
Additional Labels
No response