rust-lang / rust-lang/rust-clippy
False positive with unit_arg when returning Ok(function)
Open
Nobody has claimed this yet.
C-bug
I-false-positive
S-needs-discussion
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Lint name: unit_arg
I tried this code:
fn do_stuff() {
println!("stuff was done");
}
fn foo() -> Result<(), String> {
Ok(do_stuff())
}
I expected to see this happen: No error
Instead, this happened: It triggered the lint
In this case, I think the lint is overly strict and the code above is arguably better than the accepted fix:
fn foo() -> Result<(), String> {
do_stuff();
Ok(())
}
Meta
cargo clippy -V: clippy 0.0.212 (04488af 2020-08-24)rustc -Vv:
rustc 1.46.0 (04488afe3 2020-08-24)
binary: rustc
commit-hash: 04488afe34512aa4c33566eb16d8c912a3ae04f9
commit-date: 2020-08-24
host: x86_64-unknown-linux-gnu
release: 1.46.0
LLVM version: 10.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the report with cargo clippy using the Rust snippet and the unit_arg lint. Inspect the unit_arg lint implementation and its existing tests, if present; done means this pattern no longer triggers a false positive while other unit_arg warnings remain intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100