RFC 1951 disallowed uses of impl Trait within Fn trait sugar or higher-ranked bounds. For example, the following is disallowed:
fn foo(f: impl Fn(impl SomeTrait) -> impl OtherTrait)
fn bar() -> (impl Fn(impl SomeTrait) -> impl OtherTrait)
This tracking issue exists to discuss -- if we were to allow them -- what semantics they ought to have. Some known concerns around the syntax are:
- Should the
() switch from existential to universal quantification and back?
- I think the general feeling here is now "no", basically because "too complex".
- If HRTB were introduced, where would we (e.g.) want
impl OtherTrait to be bound?
For consistency, we are disallow fn(impl SomeTrait) -> impl OtherTrait and dyn Fn(impl SomeTrait) -> impl OtherTrait as well. When considering the questions, one should also consider what the meaning would be in those contexts.
RFC 1951 disallowed uses of impl Trait within Fn trait sugar or higher-ranked bounds. For example, the following is disallowed:
This tracking issue exists to discuss -- if we were to allow them -- what semantics they ought to have. Some known concerns around the syntax are:
()switch from existential to universal quantification and back?impl OtherTraitto be bound?For consistency, we are disallow
fn(impl SomeTrait) -> impl OtherTraitanddyn Fn(impl SomeTrait) -> impl OtherTraitas well. When considering the questions, one should also consider what the meaning would be in those contexts.