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

unused_unit false positive on macro input #7055

Closed
trinity-1686a opened this issue Apr 9, 2021 · 2 comments · Fixed by #7167
Closed

unused_unit false positive on macro input #7055

trinity-1686a opened this issue Apr 9, 2021 · 2 comments · Fixed by #7167
Assignees
Labels
C-bug Category: Clippy is not doing the correct thing E-medium Call for participation: Medium difficulty level problem and requires some initial experience. I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@trinity-1686a
Copy link

Lint name: clippy::unused_unit

I tried this code:

use futures::{future::ok, select}

pub async fn func() {
    let mut a = ok::<i32, i32>(1)
    select! { 
        _ = a => (),
    }
}

I expected to see this happen: no linting about the unit being unneeded

Instead, this happened: lint says unit expression is unneeded, but macro won't accept removing it

This looks related to #4076, except select! depends on a proc macro internally

Meta

  • cargo clippy -V: clippy 0.1.52 (07e0e2e 2021-03-24)
  • rustc -Vv:
rustc 1.53.0-nightly (07e0e2ec2 2021-03-24)
binary: rustc
commit-hash: 07e0e2ec268c140e607e1ac7f49f145612d0f597
commit-date: 2021-03-24
host: x86_64-unknown-linux-gnu
release: 1.53.0-nightly
LLVM version: 12.0.0

(reproducible on latest stable too)

@trinity-1686a trinity-1686a 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 Apr 9, 2021
@alex-700
Copy link
Contributor

alex-700 commented Apr 9, 2021

I don't sure, but using {} instead of () here should be a solution. So I think that it might be not FP, but "bad hint description". And this hint can be improved.

@trinity-1686a
Copy link
Author

I confirm {} works fine

@camsteffen camsteffen added the E-medium Call for participation: Medium difficulty level problem and requires some initial experience. label May 3, 2021
@camsteffen camsteffen self-assigned this May 4, 2021
@bors bors closed this as completed in 7e538e3 May 5, 2021
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 E-medium Call for participation: Medium difficulty level problem and requires some initial experience. I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants