-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 Uneeded Return #13467
Labels
C-bug
Category: Clippy is not doing the correct thing
Comments
Can reproduce: Note it's on 2024 edition. |
Duplicates #13458 |
flip1995
pushed a commit
to flip1995/rust-clippy
that referenced
this issue
Oct 18, 2024
Don't warn on proc macro generated code in `needless_return` Fixes rust-lang#13458 Fixes rust-lang#13457 Fixes rust-lang#13467 Fixes rust-lang#13479 Fixes rust-lang#13481 Fixes rust-lang#13526 Fixes rust-lang#13486 The fix is unfortunately a little more convoluted than just simply adding a `is_from_proc_macro`. That check *does* fix the issue, however it also introduces a bunch of false negatives in the tests, specifically when the returned expression is in a different syntax context, e.g. `return format!(..)`. The proc macro check builds up a start and end pattern based on the HIR nodes and compares it to a snippet of the span, however that would currently fail for `return format!(..)` because we would have the patterns `("return", <something inside of the format macro>)`, which doesn't compare equal. So we now return an empty string pattern for when it's in a different syntax context. "Hide whitespace" helps a bit for reviewing the proc macro detection change changelog: none
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Summary
⋊> lothrop@archimedes ⋊> ~/s/c/v0.3.14 on v0.3.14 ↑ cargo clippy --fix --bin "crack-voting" (base) 07:58:15
Checking crack-voting v0.3.14 (/home/lothrop/src/cracktunes.worktrees/v0.3.14/crack-voting)
warning: failed to automatically apply fixes suggested by rustc to crate
crack_voting
after fixes were automatically applied the compiler reported errors within these files:
This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/rust-clippy/issues
quoting the full output of this command we'd be very appreciative!
Note that you may be able to make some more progress in the near-term
fixing code with the
--broken-code
flagThe following errors were reported:
error[E0599]: no method named
awaitrun
found for opaque typeimpl std::future::Future<Output = ()>
in the current scope--> crack-voting/src/main.rs:7:11
|
7 | run().awaitrun().await;
| ^^^^^^^^ method not found in
impl Future<Output = ()>
error: aborting due to 1 previous error
For more information about this error, try
rustc --explain E0599
.Original diagnostics will follow.
warning: unneeded
return
statement--> crack-voting/src/main.rs:7:16
|
7 | run().await;
| ^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
= note:
#[warn(clippy::needless_return)]
on by defaulthelp: remove
return
|
7 | run().awaitrun().await;
| ~~~~~~~~~~~~
warning:
crack-voting
(bin "crack-voting") generated 1 warning (runcargo clippy --fix --bin "crack-voting"
to apply 1 suggestion)Finished
dev
profile [unoptimized + debuginfo] target(s) in 2.87sReproducer
I tried this code:
<code>
I expected to see this happen:
Instead, this happened:
Version
No response
Additional Labels
No response
The text was updated successfully, but these errors were encountered: