-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lints stop firing if macro reports with Span::call_site
?
#124145
Comments
honestly the main reason this issue was opened is because it seems like the only reason that this would vary so much is a serious bug in the linting framework. |
wait, am I supposed to be writing |
IIRC, many lints don't try to handle macro-generated code (or code with mixed soures) because it's a lot of complexity. The lints typically use |
for note, just using |
Apply a simple change to -sql-entity-graph and -macros: Use `format_ident!` for every case we format... an identifier... and we don't change the identifier, and reuse the existing span or worse, drop the span on the floor by calling `Span::call_site`. This will, in general, improve the error-reporting of spans so that errors refer back to the original input that provoked the expansion. It is possible we should by relocating synthesized spans, see rust-lang/rust#124145 for more details. This change is still preferred because it makes it easier to refactor these again.
I was trying to apply this diff:
Code
Current output
Desired output
None?
Rationale and extra context
This takes in an enum's name, so of course it formats out to using
__pgrx_internals_enum_SomeEnum
or whatever. Butformat_ident
is basically just constructing an Ident but with theSpan
of the original ident it is based on. Apparently the expanded code triggers lints only if it has that span, butSpan::call_site
does not! It seems odd/annoying for the lint to ignore irrational spans like this but punish me for trying to forward the correct span so that errors get reported more clearly from the macro.This is slightly different from #24580 because it's about the lint firing being inconsistent but I don't mind if it's closed for technically duplication I guess.
Other cases
No response
Rust Version
Anything else?
No response
The text was updated successfully, but these errors were encountered: