-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
clippy::let_and_return false positive #4555
Comments
That's strange. Gotta look into the code that structopt generates. Sometimes the expr spans aren't the same as their stmt spans. |
Yes, structopt propagates source span info to the generated code. This particular piece of generated code has a span that points to |
Relevant piece of expansion: let app = <B>::augment_clap(app);
let app = if <B>::is_subcommand() {
app.setting(::structopt::clap::AppSettings::SubcommandRequiredElseHelp)
} else {
app
};
app These let statements get a span pointing to The warning:
|
I think checking |
@llogiq Yes, you're right. Perhaps this will be more appropriate: if !in_external_macro(cx.sess(), retexpr.span);
if !in_external_macro(cx.sess(), local.span); |
Summary
The
clippy::let_and_return
lint triggers from code generated by a macro-derive.Reproducer
structopt v0.3.2
does generate let_and_return in this case but I don't think this lint makes much sense when originated from a macro expansion.The text was updated successfully, but these errors were encountered: