Open
Description
I tried this code:
#![feature(type_alias_impl_trait)]
type Tait = impl Sized + 'static;
fn capture<T>() -> Tait {
|| 0u8
}
I expected to see this happen:
Successful compilation, since the generic parameter T
is not used in the returned closure.
Instead, this happened:
Compiling playground v0.0.1 (/playground)
error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias
--> src/lib.rs:6:5
|
6 | || 0u8
| ^^^^^^
This error also happens when returning async blocks:
// same error
fn capture_async<T>() -> Tait {
async {
0u8
}
}
Also, this appears to only affect generic type parameters, as lifetimes aren't captured if the closure doesn't use them:
// compiles
fn capture_lt<'a>(_: &'a ()) -> Tait {
|| 0u8
}
Meta
Version
:
rustc 1.76.0-nightly (2023-11-19 9a66e4471f71283fd54d)