-
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
function "in_external_macro” judgment is incorrect #131993
Comments
Can you please provide a complete reproducer, including how your lint is setup? It doesn't need to be minimal, I just need something that's more complete instead of having to figure out how to reproduce the issue you are observing. Is this in the context of clippy lints, or rustc lints, or some other custom lint framework? |
My lint context is custom, but the logic is similar to clippy, which should have no effect on the function return value. |
I can't test your changes because I don't have a complete example, but, if you point your code to use a local clap checkout such that all the code with the code pattern matching quote_spanned! { ty.span()=>
#arg_matches.#get_many(#id)
.map(|v| v.collect::<Vec<_>>())
.unwrap_or_else(Vec::new)
} becomes quote! { #arg_matches.#get_many(#id)
.map(|v| v.collect::<Vec<_>>())
.unwrap_or_else(Vec::new)
} or maybe quote_spanned! { Span::call_site().located_at(ty.span()) =>
#arg_matches.#get_many(#id)
.map(|v| v.collect::<Vec<_>>())
.unwrap_or_else(Vec::new)
} Does making any of the two changes cause |
I change quote_spam! to quote but not change the result |
I use the derive macro provided by the clap crate in my code, and then call the in_external_macro function in the context of a custom lint diagnostic code. The function determines that the code derived from the derive macro is local code.
I tried this code:
dependency is clap = { version = "=4.2.0", features = ["derive"] }
My lint code is:
I expected to see this happen: I think all code generated by derived macros should belong to external macros derived from external crates.
Instead, this happened: Some of the code generated by the derived macro is considered to be local code
The error macro code is expanded as follows.
The blocks inside the .arg function are considered native code.
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: