2024-04-17 20:30:41 -05:00
|
|
|
trait Tr {
|
|
|
|
type Assoc;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct W<'a>(&'a ());
|
|
|
|
|
|
|
|
impl Tr for W<'_> {
|
|
|
|
type Assoc = ();
|
|
|
|
}
|
|
|
|
|
|
|
|
// The normal way of capturing `'a`...
|
|
|
|
impl<'a> W<'a> {
|
2024-06-05 15:18:52 -05:00
|
|
|
fn good1() -> impl Into<<W<'a> as Tr>::Assoc> + use<'a> {}
|
2024-04-17 20:30:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// This ensures that we don't error when we capture the *parent* copy of `'a`,
|
|
|
|
// since the opaque captures that rather than the duplicated `'a` lifetime
|
|
|
|
// synthesized from mentioning `'a` directly in the bounds.
|
|
|
|
impl<'a> W<'a> {
|
2024-06-05 15:18:52 -05:00
|
|
|
fn good2() -> impl Into<<Self as Tr>::Assoc> + use<'a> {}
|
2024-04-17 20:30:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// The normal way of capturing `'a`... but not mentioned in the bounds.
|
|
|
|
impl<'a> W<'a> {
|
2024-06-05 15:18:52 -05:00
|
|
|
fn bad1() -> impl Into<<W<'a> as Tr>::Assoc> + use<> {}
|
2024-04-17 20:30:41 -05:00
|
|
|
//~^ ERROR `impl Trait` captures lifetime parameter, but it is not mentioned in `use<...>` precise captures list
|
|
|
|
}
|
|
|
|
|
|
|
|
// But also make sure that we error here...
|
|
|
|
impl<'a> W<'a> {
|
2024-06-05 15:18:52 -05:00
|
|
|
fn bad2() -> impl Into<<Self as Tr>::Assoc> + use<> {}
|
2024-04-19 14:18:00 -05:00
|
|
|
//~^ ERROR `impl Trait` captures lifetime parameter, but it is not mentioned in `use<...>` precise captures list
|
2024-04-17 20:30:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|