Confusing error message when returning impl Trait with multiple lifetimes #49431
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-impl-trait
Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.
A-lifetimes
Area: Lifetimes / regions
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Given
you currently (
rustc 1.26.0-nightly (188e693b3 2018-03-26)
) get the errorsThis not being an allowed syntax was briefly mentioned by @nikomatsakis in #34511, quoting the relevant part of the comment:
As far as I recall/can discover this limitation was never followed up on in that thread.
After some RFC spelunking I cannot find anything restricting a type bound to having at most a single lifetime bound, RFC 192 Appendix B may be relevant, but I don't believe that the
Trait
part ofimpl Trait
is an "object type", it seems to me to be a "type parameter bound". Re-reading theimpl Trait
RFC series doesn't appear to clear this up, exactly what sort of syntaxTrait
is is never explicitly named, the original RFC simply saysIt seems to me that supporting multiple lifetime bounds on
impl Trait
should be fine, conceptually it seems to be the equivalent of:Whether or not
impl Trait
can be extended to support multiple lifetimes, it seems like there should be an error message that the formimpl Foo + 'a + 'b
is not valid currently, rather than some weird lifetime mismatch errors.The text was updated successfully, but these errors were encountered: