Edit GATs tests to apply lint

This commit is contained in:
jackh726 2021-10-16 18:53:41 -04:00
parent e391796d47
commit c2da21063f
16 changed files with 35 additions and 53 deletions

View File

@ -8,7 +8,7 @@
// 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> =

View File

@ -8,7 +8,7 @@
// 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> =

View File

@ -3,7 +3,7 @@
#![feature(generic_associated_types)]
pub trait X {
type Y<'a>;
type Y<'a> where Self: 'a;
fn m(&self) -> Self::Y<'_>;
}

View File

@ -3,7 +3,7 @@
#![feature(generic_associated_types)]
trait Document {
type Cursor<'a>: DocCursor<'a>;
type Cursor<'a>: DocCursor<'a> where Self: 'a;
fn cursor(&self) -> Self::Cursor<'_>;
}

View File

@ -3,7 +3,7 @@
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>;
}

View File

@ -7,7 +7,7 @@ LL | let sub: Box<dyn SuperTrait<SubType = SubStruct>> = Box::new(SuperStruc
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
|
@ -25,7 +25,7 @@ note: for a trait to be "object safe" it needs to allow building a vtable to all
|
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
@ -40,7 +40,7 @@ note: for a trait to be "object safe" it needs to allow building a vtable to all
|
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>`

View File

@ -17,12 +17,12 @@ impl<'a, T> RefCont<'a, T> for Box<T> {
}
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)
}

View File

@ -7,7 +7,7 @@ LL | as Box<dyn MapLike<u8, u8, VRefCont = dyn RefCont<'_, u8>>>;
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
|
@ -25,7 +25,7 @@ note: for a trait to be "object safe" it needs to allow building a vtable to all
|
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
@ -40,7 +40,7 @@ note: for a trait to be "object safe" it needs to allow building a vtable to all
|
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>>`

View File

@ -9,6 +9,7 @@ enum Either<L, R> {
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>;
@ -20,9 +21,9 @@ where
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

View File

@ -1,32 +1,10 @@
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

View File

@ -13,7 +13,8 @@ trait SearchableResource<Criteria> {
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>;
}
@ -29,6 +30,7 @@ where
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> {

View File

@ -1,13 +1,14 @@
#![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 {

View File

@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/issue-88360.rs:14:9
--> $DIR/issue-88360.rs:15:9
|
LL | trait SuperTrait<T>
| - this type parameter

View File

@ -1,7 +1,7 @@
#![feature(generic_associated_types)]
pub trait X {
type Y<'a>;
type Y<'a> where Self: 'a;
fn m(&self) -> Self::Y<'_>;
}

View File

@ -5,12 +5,12 @@
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>,
}
@ -30,7 +30,7 @@ struct StreamEnumerate<I> {
}
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,
@ -44,7 +44,7 @@ impl<I: StreamingIterator> StreamingIterator for StreamEnumerate<I> {
}
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)
}

View File

@ -3,7 +3,7 @@
#![feature(generic_associated_types)]
trait A {
type B<'a>;
type B<'a> where Self: 'a;
fn make_b<'a>(&'a self) -> Self::B<'a>;
}