rust-lang / types-team

Home of the "types team", affiliated with the compiler and lang teams.
https://rust-lang.github.io/types-team/
Apache License 2.0
96 stars 19 forks source link

Avoid bounding impl trait return type by all input type parameters using existential lifetimes #121

Open nikomatsakis opened 1 year ago

nikomatsakis commented 1 year ago

Impl trait return types are currently bounded by all type parameters and will eventually be bounded by all lifetime parameters too. But sometimes the trait bounds imply they cannot capture generic parameters, e.g., fn foo<T>() -> impl 'static cannot capture T, since T is not known to be 'static. We mostly recognize this but do not always take advantage of it correctly.

cc https://github.com/rust-lang/rust/issues/42940