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 in combination with #![feature(closure_lifetime_binder)] #9748

Closed
Jules-Bertholet opened this issue Oct 29, 2022 · 1 comment · Fixed by #9849
Closed
Assignees
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 I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied

Comments

@Jules-Bertholet
Copy link
Contributor

Jules-Bertholet commented Oct 29, 2022

Summary

The closure_lifetime_binder feature allows using for<...> to specify the lifetimes of closure arguments and return values, but this requires the types of the closure argument and return to be fully specified, including return types of (). Therefore, suggesting removing an -> () from the closure causes an error.

Lint Name

unused_unit

Reproducer

I tried this code:

#![feature(closure_lifetime_binder)]

fn main() {
    let _ = for<'a> |_: &'a u32| -> () {};
}

I saw this happen:

warning: unneeded unit return type
 --> src/main.rs:4:33
  |
4 |     let _ = for<'a> |_: &'a u32| -> () {};
  |                                 ^^^^^^ help: remove the `-> ()`
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_unit
  = note: `#[warn(clippy::unused_unit)]` on by default

I expected to see this happen:
No warning

Version

rustc 1.66.0-nightly (9565dfeb4 2022-10-28)
binary: rustc
commit-hash: 9565dfeb4e6225177bbe78f18cd48a7982f34401
commit-date: 2022-10-28
host: x86_64-unknown-linux-gnu
release: 1.66.0-nightly
LLVM version: 15.0.2

Additional Labels

@rustbot label +I-suggestion-causes-error

@Jules-Bertholet Jules-Bertholet 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 29, 2022
@rustbot rustbot added the I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied label Oct 29, 2022
@Jules-Bertholet Jules-Bertholet changed the title unused_unit false positive in combination with #![feature(closure_lifetime_binder}] unused_unit false positive in combination with #![feature(closure_lifetime_binder)] Nov 1, 2022
@koka831
Copy link
Contributor

koka831 commented Nov 15, 2022

@rustbot claim

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 I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants