Open
Description
Motivation
As of 2023-04-10, the compiler permits impl Foo<Output = impl Bar>
but not impl Fn() -> impl Bar
. There have been proposals to permit impl Trait in the latter position -- but what should it mean?
Details
This issue exists to catalog the various options.
- In argument position:
fn something(f: impl Fn() -> impl Debug)
could be equivalent tofn something<A,E>(f: A) where A: Fn() -> E, E: Debug
, but this cannot accommodate higher-ranked signatures likeimpl Fn(&u32) -> impl Debug + '_
.fn something(f: impl Fn() -> impl Debug)
could also be equivalent tofn something<A>(f: A) where A: Fn() -> _, A::Output: Debug
(this is not legal syntax today, the-> _
is meant to mean "returns some type not specified). This would accommodate said signatures.- The same is relevant to
impl Foo<Output = impl Bar>
; for example to permit writing something likeimpl for<'a> Foo<Output<'a> = impl Bar + 'a>
(not currently possible). Can we transition from current behavior to this? Not entirely backwards compatible, perhaps, but likely achievable. (Today,impl for<'a> Foo<Output<'a> = impl Bar>
would assert thatOutput
value is not dependent on'a
because theimpl Bar
desugars to a generic parameter outside the scope of thefor
.)
cannot.
- In return position:
fn something() -> impl Fn() -> impl Debug
could be equivalent totype A: Fn() -> B; type B: Debug; fn something() -> A
Metadata
Metadata
Assignees
Labels
No labels