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
Summary
The
closure_lifetime_binderfeature allows usingfor<...>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:
I saw this happen:
I expected to see this happen:
No warning
Version
Additional Labels
@rustbot label +I-suggestion-causes-error