// check that we don't normalize with trait defaults.
trait Collection<T> {
- type Iter<'iter>: Iterator<Item=&'iter T> where T: 'iter;
+ type Iter<'iter>: Iterator<Item=&'iter T> where T: 'iter, Self: 'iter;
type Family: CollectionFamily;
// Test associated type defaults with parameters
type Sibling<U>: Collection<U> =
// run-pass
trait Collection<T> {
- type Iter<'iter>: Iterator<Item=&'iter T> where T: 'iter;
+ type Iter<'iter>: Iterator<Item=&'iter T> where T: 'iter, Self: 'iter;
type Family: CollectionFamily;
// Test associated type defaults with parameters
type Sibling<U>: Collection<U> =
#![feature(generic_associated_types)]
pub trait X {
- type Y<'a>;
+ type Y<'a> where Self: 'a;
fn m(&self) -> Self::Y<'_>;
}
#![feature(generic_associated_types)]
trait Document {
- type Cursor<'a>: DocCursor<'a>;
+ type Cursor<'a>: DocCursor<'a> where Self: 'a;
fn cursor(&self) -> Self::Cursor<'_>;
}
pub trait SubTrait {}
pub trait SuperTrait {
- type SubType<'a>: SubTrait;
+ type SubType<'a>: SubTrait where Self: 'a;
fn get_sub<'a>(&'a mut self) -> Self::SubType<'a>;
}
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-76535.rs:6:10
|
-LL | type SubType<'a>: SubTrait;
+LL | type SubType<'a>: SubTrait where Self: 'a;
| ^^^^^^^ --
help: add missing lifetime argument
|
|
LL | pub trait SuperTrait {
| ---------- this trait cannot be made into an object...
-LL | type SubType<'a>: SubTrait;
+LL | type SubType<'a>: SubTrait where Self: 'a;
| ^^^^^^^ ...because it contains the generic associated type `SubType`
= help: consider moving `SubType` to another trait
|
LL | pub trait SuperTrait {
| ---------- this trait cannot be made into an object...
-LL | type SubType<'a>: SubTrait;
+LL | type SubType<'a>: SubTrait where Self: 'a;
| ^^^^^^^ ...because it contains the generic associated type `SubType`
= help: consider moving `SubType` to another trait
= note: required because of the requirements on the impl of `CoerceUnsized<Box<dyn SuperTrait<SubType = SubStruct<'_>>>>` for `Box<SuperStruct>`
}
trait MapLike<K, V> {
- type VRefCont<'a>: RefCont<'a, V>;
+ type VRefCont<'a>: RefCont<'a, V> where Self: 'a;
fn get<'a>(&'a self, key: &K) -> Option<Self::VRefCont<'a>>;
}
impl<K: Ord, V: 'static> MapLike<K, V> for std::collections::BTreeMap<K, V> {
- type VRefCont<'a> = &'a V;
+ type VRefCont<'a> where Self: 'a = &'a V;
fn get<'a>(&'a self, key: &K) -> Option<&'a V> {
std::collections::BTreeMap::get(self, key)
}
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-79422.rs:20:10
|
-LL | type VRefCont<'a>: RefCont<'a, V>;
+LL | type VRefCont<'a>: RefCont<'a, V> where Self: 'a;
| ^^^^^^^^ --
help: add missing lifetime argument
|
|
LL | trait MapLike<K, V> {
| ------- this trait cannot be made into an object...
-LL | type VRefCont<'a>: RefCont<'a, V>;
+LL | type VRefCont<'a>: RefCont<'a, V> where Self: 'a;
| ^^^^^^^^ ...because it contains the generic associated type `VRefCont`
= help: consider moving `VRefCont` to another trait
|
LL | trait MapLike<K, V> {
| ------- this trait cannot be made into an object...
-LL | type VRefCont<'a>: RefCont<'a, V>;
+LL | type VRefCont<'a>: RefCont<'a, V> where Self: 'a;
| ^^^^^^^^ ...because it contains the generic associated type `VRefCont`
= help: consider moving `VRefCont` to another trait
= note: required because of the requirements on the impl of `CoerceUnsized<Box<dyn MapLike<u8, u8, VRefCont = (dyn RefCont<'_, u8> + 'static)>>>` for `Box<BTreeMap<u8, u8>>`
pub trait HasChildrenOf {
type T;
type TRef<'a>;
+ //~^ Missing required bounds
fn ref_children<'a>(&'a self) -> Vec<Self::TRef<'a>>;
fn take_children(self) -> Vec<Self::T>;
Right: HasChildrenOf,
{
type T = Either<Left::T, Right::T>;
+ // We used to error below because the where clause doesn't match the trait.
+ // Now, we error early on the trait itself.
type TRef<'a>
- //~^ `impl` associated type signature
- //~^^ `impl` associated type signature
where
<Left as HasChildrenOf>::T: 'a,
<Right as HasChildrenOf>::T: 'a
-error: `impl` associated type signature for `TRef` doesn't match `trait` associated type signature
- --> $DIR/issue-86787.rs:23:5
+error: Missing required bounds on TRef
+ --> $DIR/issue-86787.rs:11:5
|
-LL | type TRef<'a>;
- | -------------- expected
-...
-LL | / type TRef<'a>
-LL | |
-LL | |
-LL | | where
-LL | | <Left as HasChildrenOf>::T: 'a,
-LL | | <Right as HasChildrenOf>::T: 'a
-LL | | = Either<&'a Left::T, &'a Right::T>;
- | |________________________________________^ found
+LL | type TRef<'a>;
+ | ^^^^^^^^^^^^^-
+ | |
+ | help: add the required where clauses: `where Self: 'a`
-error: `impl` associated type signature for `TRef` doesn't match `trait` associated type signature
- --> $DIR/issue-86787.rs:23:5
- |
-LL | type TRef<'a>;
- | -------------- expected
-...
-LL | / type TRef<'a>
-LL | |
-LL | |
-LL | | where
-LL | | <Left as HasChildrenOf>::T: 'a,
-LL | | <Right as HasChildrenOf>::T: 'a
-LL | | = Either<&'a Left::T, &'a Right::T>;
- | |________________________________________^ found
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
trait SearchableResourceExt<Criteria>: SearchableResource<Criteria> {
type Future<'f, A: 'f + ?Sized, B: 'f>: Future<Output = Result<Vec<A::SearchResult>, ()>> + 'f
where
- A: SearchableResource<B>;
+ A: SearchableResource<B>,
+ Self: 'f;
fn search<'c>(&'c self, client: &'c ()) -> Self::Future<'c, Self, Criteria>;
}
type Future<'f, A, B: 'f>
where
A: SearchableResource<B> + ?Sized + 'f,
+ Self: 'f,
= SearchFutureTy<'f, A, B>;
fn search<'c>(&'c self, _client: &'c ()) -> Self::Future<'c, Self, Criteria> {
#![feature(generic_associated_types)]
trait GatTrait {
- type Gat<'a>;
+ type Gat<'a> where Self: 'a;
fn test(&self) -> Self::Gat<'_>;
}
trait SuperTrait<T>
where
+ Self: 'static,
for<'a> Self: GatTrait<Gat<'a> = &'a T>,
{
fn copy(&self) -> Self::Gat<'_> where T: Copy {
error[E0308]: mismatched types
- --> $DIR/issue-88360.rs:14:9
+ --> $DIR/issue-88360.rs:15:9
|
LL | trait SuperTrait<T>
| - this type parameter
#![feature(generic_associated_types)]
pub trait X {
- type Y<'a>;
+ type Y<'a> where Self: 'a;
fn m(&self) -> Self::Y<'_>;
}
use std::fmt::Display;
trait StreamingIterator {
- type Item<'a>;
+ type Item<'a> where Self: 'a;
// Applying the lifetime parameter `'a` to `Self::Item` inside the trait.
fn next<'a>(&'a mut self) -> Option<Self::Item<'a>>;
}
-struct Foo<T: StreamingIterator> {
+struct Foo<T: StreamingIterator + 'static> {
// Applying a concrete lifetime to the constructor outside the trait.
bar: <T as StreamingIterator>::Item<'static>,
}
}
impl<I: StreamingIterator> StreamingIterator for StreamEnumerate<I> {
- type Item<'a> = (usize, I::Item<'a>);
+ type Item<'a> where Self: 'a = (usize, I::Item<'a>);
fn next<'a>(&'a mut self) -> Option<Self::Item<'a>> {
match self.iter.next() {
None => None,
}
impl<I: Iterator> StreamingIterator for I {
- type Item<'a> = <I as Iterator>::Item;
+ type Item<'a> where Self: 'a = <I as Iterator>::Item;
fn next(&mut self) -> Option<<I as StreamingIterator>::Item<'_>> {
Iterator::next(self)
}
#![feature(generic_associated_types)]
trait A {
- type B<'a>;
+ type B<'a> where Self: 'a;
fn make_b<'a>(&'a self) -> Self::B<'a>;
}