You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I expected it to compile. Instead I was greeted by E0207, lamenting that 'a is unconstrained. However, the following code works without issue (playground).
Note that introducing the supertrait allows referring to Bar0::Assoc without mentioning the lifetime 'a. However, unless I'm missing any subtleties, the compiler should be able to deduce (due to the bound on Bar::Assoc) that <T as Bar<'a>>::Assoc: 'static and that therefore it does not matter that the lifetime is unconstrained.
Meta
Affects all rustc versions, including 1.69.0-nightly (5b8f284 2023-02-12).
The text was updated successfully, but these errors were encountered:
I have yet to confirm that the workaround applies to my original problem. I'll leave this issue open regardless because I believe it's an unnecessary paper cut.
Edit: This workaround runs straight into #39959 when trying to implement the trait (playground).
The compiler fails to exploit a
'static
bound, requiring a verbose workaround via supertrait.I tried the following code (playground).
I expected it to compile. Instead I was greeted by E0207, lamenting that
'a
is unconstrained. However, the following code works without issue (playground).Note that introducing the supertrait allows referring to
Bar0::Assoc
without mentioning the lifetime'a
. However, unless I'm missing any subtleties, the compiler should be able to deduce (due to the bound onBar::Assoc
) that<T as Bar<'a>>::Assoc: 'static
and that therefore it does not matter that the lifetime is unconstrained.Meta
Affects all rustc versions, including 1.69.0-nightly (5b8f284 2023-02-12).
The text was updated successfully, but these errors were encountered: