GAT: Self: 'a
bound cannot be added for types which store a generic T that is further constrained by the impl
#92280
Labels
A-GATs
Area: Generic associated types (GATs)
C-bug
Category: This is a bug.
F-generic_associated_types
`#![feature(generic_associated_types)]` a.k.a. GATs
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Within an
impl<T: Trait1> Trait2 for Struct<T::Foo>
, a GAT bound ofSelf: 'a
does not compile, asking me to add an explicitT::Foo: 'a
bound.Playground
This code results in two errors:
I believe that the
E0309
error is a bug, as sincekey
is known in thisimpl
to beS::String
,S::String
must outliveSelf
and the suggested bound should thus already be implied bySelf: 'a
. Applying the suggested fix removes this error, but obviously cannot compile (as the GAT impl now has a stricterwhere
than in thetrait
declaration). The first error seems incorrect too, as there is no visible difference between the highlighted lines other than= ()
:Adding the type bound on the
struct
declaration avoids these errors, but is less generic.Meta
rustc --version --verbose
:I have also encountered this bug on
1.59.0-nightly (e100ec5bc 2021-12-21)
.The text was updated successfully, but these errors were encountered: