Skip to content
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

False positive for needless_return (there is no return!) #13535

Closed
nicoburns opened this issue Oct 10, 2024 · 2 comments
Closed

False positive for needless_return (there is no return!) #13535

nicoburns opened this issue Oct 10, 2024 · 2 comments
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@nicoburns
Copy link

nicoburns commented Oct 10, 2024

Summary

The following file is generating what I believe to be a false positive needless_return lint when there is no return statement at all:

https://github.com/DioxusLabs/taffy/blob/b66bd6bfaa3368aa105ad01e697ea2ff3da6b11a/scripts/gentest/src/main.rs

Lint Name

needless_return

Reproducer

I tried this code:

(Sorry, I don't have to time to reduce this right now)

I saw this happen:

warning: unneeded `return` statement
   --> scripts/gentest/src/main.rs:158:78
    |
158 |     Command::new("cargo").arg("fmt").current_dir(repo_root).status().unwrap();
    |                                                                              ^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
    = note: `#[warn(clippy::needless_return)]` on by default
help: remove `return`
    |
158 |     Command::new("cargo").arg("fmt").current_dir(repo_root).status().unwrap()Command::new("cargo").arg("fmt").current_dir(repo_root).status().unwrap();
    |                                                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

There is also a second unrelated warning (but I believe this is legitimate).

I expected to see this happen:

No warning as there is no return statement.

Version

rustc 1.83.0-nightly (eb4e23467 2024-10-09)
binary: rustc
commit-hash: eb4e2346748e1760f74fcaa27b42431e0b95f8f3
commit-date: 2024-10-09
host: aarch64-apple-darwin
release: 1.83.0-nightly
LLVM version: 19.1.1

Also reproduced with slightly older nightly from 2024-10-04. Bug is not present in 1.81.0 stable.

Additional Labels

No response

@nicoburns nicoburns added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Oct 10, 2024
@y21
Copy link
Member

y21 commented Oct 10, 2024

The fix for this should be in the next nightly (rust-lang/rust#131492).

@y21
Copy link
Member

y21 commented Oct 11, 2024

Closing as the fix is in today's nightly. Feel free to reopen if you're still seeing this.

@y21 y21 closed this as completed Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

No branches or pull requests

2 participants