Skip to content

Commit c2da210

Browse files
committed
Edit GATs tests to apply lint
1 parent e391796 commit c2da210

16 files changed

+35
-53
lines changed

src/test/ui/generic-associated-types/collections-project-default.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// check that we don't normalize with trait defaults.
99

1010
trait Collection<T> {
11-
type Iter<'iter>: Iterator<Item=&'iter T> where T: 'iter;
11+
type Iter<'iter>: Iterator<Item=&'iter T> where T: 'iter, Self: 'iter;
1212
type Family: CollectionFamily;
1313
// Test associated type defaults with parameters
1414
type Sibling<U>: Collection<U> =

src/test/ui/generic-associated-types/collections.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// run-pass
99

1010
trait Collection<T> {
11-
type Iter<'iter>: Iterator<Item=&'iter T> where T: 'iter;
11+
type Iter<'iter>: Iterator<Item=&'iter T> where T: 'iter, Self: 'iter;
1212
type Family: CollectionFamily;
1313
// Test associated type defaults with parameters
1414
type Sibling<U>: Collection<U> =

src/test/ui/generic-associated-types/generic-associated-type-bounds.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#![feature(generic_associated_types)]
44

55
pub trait X {
6-
type Y<'a>;
6+
type Y<'a> where Self: 'a;
77
fn m(&self) -> Self::Y<'_>;
88
}
99

src/test/ui/generic-associated-types/issue-70303.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#![feature(generic_associated_types)]
44

55
trait Document {
6-
type Cursor<'a>: DocCursor<'a>;
6+
type Cursor<'a>: DocCursor<'a> where Self: 'a;
77

88
fn cursor(&self) -> Self::Cursor<'_>;
99
}

src/test/ui/generic-associated-types/issue-76535.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
pub trait SubTrait {}
44

55
pub trait SuperTrait {
6-
type SubType<'a>: SubTrait;
6+
type SubType<'a>: SubTrait where Self: 'a;
77

88
fn get_sub<'a>(&'a mut self) -> Self::SubType<'a>;
99
}

src/test/ui/generic-associated-types/issue-76535.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | let sub: Box<dyn SuperTrait<SubType = SubStruct>> = Box::new(SuperStruc
77
note: associated type defined here, with 1 lifetime parameter: `'a`
88
--> $DIR/issue-76535.rs:6:10
99
|
10-
LL | type SubType<'a>: SubTrait;
10+
LL | type SubType<'a>: SubTrait where Self: 'a;
1111
| ^^^^^^^ --
1212
help: add missing lifetime argument
1313
|
@@ -25,7 +25,7 @@ note: for a trait to be "object safe" it needs to allow building a vtable to all
2525
|
2626
LL | pub trait SuperTrait {
2727
| ---------- this trait cannot be made into an object...
28-
LL | type SubType<'a>: SubTrait;
28+
LL | type SubType<'a>: SubTrait where Self: 'a;
2929
| ^^^^^^^ ...because it contains the generic associated type `SubType`
3030
= help: consider moving `SubType` to another trait
3131

@@ -40,7 +40,7 @@ note: for a trait to be "object safe" it needs to allow building a vtable to all
4040
|
4141
LL | pub trait SuperTrait {
4242
| ---------- this trait cannot be made into an object...
43-
LL | type SubType<'a>: SubTrait;
43+
LL | type SubType<'a>: SubTrait where Self: 'a;
4444
| ^^^^^^^ ...because it contains the generic associated type `SubType`
4545
= help: consider moving `SubType` to another trait
4646
= note: required because of the requirements on the impl of `CoerceUnsized<Box<dyn SuperTrait<SubType = SubStruct<'_>>>>` for `Box<SuperStruct>`

src/test/ui/generic-associated-types/issue-79422.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ impl<'a, T> RefCont<'a, T> for Box<T> {
1717
}
1818

1919
trait MapLike<K, V> {
20-
type VRefCont<'a>: RefCont<'a, V>;
20+
type VRefCont<'a>: RefCont<'a, V> where Self: 'a;
2121
fn get<'a>(&'a self, key: &K) -> Option<Self::VRefCont<'a>>;
2222
}
2323

2424
impl<K: Ord, V: 'static> MapLike<K, V> for std::collections::BTreeMap<K, V> {
25-
type VRefCont<'a> = &'a V;
25+
type VRefCont<'a> where Self: 'a = &'a V;
2626
fn get<'a>(&'a self, key: &K) -> Option<&'a V> {
2727
std::collections::BTreeMap::get(self, key)
2828
}

src/test/ui/generic-associated-types/issue-79422.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | as Box<dyn MapLike<u8, u8, VRefCont = dyn RefCont<'_, u8>>>;
77
note: associated type defined here, with 1 lifetime parameter: `'a`
88
--> $DIR/issue-79422.rs:20:10
99
|
10-
LL | type VRefCont<'a>: RefCont<'a, V>;
10+
LL | type VRefCont<'a>: RefCont<'a, V> where Self: 'a;
1111
| ^^^^^^^^ --
1212
help: add missing lifetime argument
1313
|
@@ -25,7 +25,7 @@ note: for a trait to be "object safe" it needs to allow building a vtable to all
2525
|
2626
LL | trait MapLike<K, V> {
2727
| ------- this trait cannot be made into an object...
28-
LL | type VRefCont<'a>: RefCont<'a, V>;
28+
LL | type VRefCont<'a>: RefCont<'a, V> where Self: 'a;
2929
| ^^^^^^^^ ...because it contains the generic associated type `VRefCont`
3030
= help: consider moving `VRefCont` to another trait
3131

@@ -40,7 +40,7 @@ note: for a trait to be "object safe" it needs to allow building a vtable to all
4040
|
4141
LL | trait MapLike<K, V> {
4242
| ------- this trait cannot be made into an object...
43-
LL | type VRefCont<'a>: RefCont<'a, V>;
43+
LL | type VRefCont<'a>: RefCont<'a, V> where Self: 'a;
4444
| ^^^^^^^^ ...because it contains the generic associated type `VRefCont`
4545
= help: consider moving `VRefCont` to another trait
4646
= 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>>`

src/test/ui/generic-associated-types/issue-86787.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ enum Either<L, R> {
99
pub trait HasChildrenOf {
1010
type T;
1111
type TRef<'a>;
12+
//~^ Missing required bounds
1213

1314
fn ref_children<'a>(&'a self) -> Vec<Self::TRef<'a>>;
1415
fn take_children(self) -> Vec<Self::T>;
@@ -20,9 +21,9 @@ where
2021
Right: HasChildrenOf,
2122
{
2223
type T = Either<Left::T, Right::T>;
24+
// We used to error below because the where clause doesn't match the trait.
25+
// Now, we error early on the trait itself.
2326
type TRef<'a>
24-
//~^ `impl` associated type signature
25-
//~^^ `impl` associated type signature
2627
where
2728
<Left as HasChildrenOf>::T: 'a,
2829
<Right as HasChildrenOf>::T: 'a
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,10 @@
1-
error: `impl` associated type signature for `TRef` doesn't match `trait` associated type signature
2-
--> $DIR/issue-86787.rs:23:5
1+
error: Missing required bounds on TRef
2+
--> $DIR/issue-86787.rs:11:5
33
|
4-
LL | type TRef<'a>;
5-
| -------------- expected
6-
...
7-
LL | / type TRef<'a>
8-
LL | |
9-
LL | |
10-
LL | | where
11-
LL | | <Left as HasChildrenOf>::T: 'a,
12-
LL | | <Right as HasChildrenOf>::T: 'a
13-
LL | | = Either<&'a Left::T, &'a Right::T>;
14-
| |________________________________________^ found
4+
LL | type TRef<'a>;
5+
| ^^^^^^^^^^^^^-
6+
| |
7+
| help: add the required where clauses: `where Self: 'a`
158

16-
error: `impl` associated type signature for `TRef` doesn't match `trait` associated type signature
17-
--> $DIR/issue-86787.rs:23:5
18-
|
19-
LL | type TRef<'a>;
20-
| -------------- expected
21-
...
22-
LL | / type TRef<'a>
23-
LL | |
24-
LL | |
25-
LL | | where
26-
LL | | <Left as HasChildrenOf>::T: 'a,
27-
LL | | <Right as HasChildrenOf>::T: 'a
28-
LL | | = Either<&'a Left::T, &'a Right::T>;
29-
| |________________________________________^ found
30-
31-
error: aborting due to 2 previous errors
9+
error: aborting due to previous error
3210

src/test/ui/generic-associated-types/issue-88287.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ trait SearchableResource<Criteria> {
1313
trait SearchableResourceExt<Criteria>: SearchableResource<Criteria> {
1414
type Future<'f, A: 'f + ?Sized, B: 'f>: Future<Output = Result<Vec<A::SearchResult>, ()>> + 'f
1515
where
16-
A: SearchableResource<B>;
16+
A: SearchableResource<B>,
17+
Self: 'f;
1718

1819
fn search<'c>(&'c self, client: &'c ()) -> Self::Future<'c, Self, Criteria>;
1920
}
@@ -29,6 +30,7 @@ where
2930
type Future<'f, A, B: 'f>
3031
where
3132
A: SearchableResource<B> + ?Sized + 'f,
33+
Self: 'f,
3234
= SearchFutureTy<'f, A, B>;
3335

3436
fn search<'c>(&'c self, _client: &'c ()) -> Self::Future<'c, Self, Criteria> {

src/test/ui/generic-associated-types/issue-88360.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
#![feature(generic_associated_types)]
22

33
trait GatTrait {
4-
type Gat<'a>;
4+
type Gat<'a> where Self: 'a;
55

66
fn test(&self) -> Self::Gat<'_>;
77
}
88

99
trait SuperTrait<T>
1010
where
11+
Self: 'static,
1112
for<'a> Self: GatTrait<Gat<'a> = &'a T>,
1213
{
1314
fn copy(&self) -> Self::Gat<'_> where T: Copy {

src/test/ui/generic-associated-types/issue-88360.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0308]: mismatched types
2-
--> $DIR/issue-88360.rs:14:9
2+
--> $DIR/issue-88360.rs:15:9
33
|
44
LL | trait SuperTrait<T>
55
| - this type parameter

src/test/ui/generic-associated-types/projection-type-lifetime-mismatch.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![feature(generic_associated_types)]
22

33
pub trait X {
4-
type Y<'a>;
4+
type Y<'a> where Self: 'a;
55
fn m(&self) -> Self::Y<'_>;
66
}
77

src/test/ui/generic-associated-types/streaming_iterator.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
use std::fmt::Display;
66

77
trait StreamingIterator {
8-
type Item<'a>;
8+
type Item<'a> where Self: 'a;
99
// Applying the lifetime parameter `'a` to `Self::Item` inside the trait.
1010
fn next<'a>(&'a mut self) -> Option<Self::Item<'a>>;
1111
}
1212

13-
struct Foo<T: StreamingIterator> {
13+
struct Foo<T: StreamingIterator + 'static> {
1414
// Applying a concrete lifetime to the constructor outside the trait.
1515
bar: <T as StreamingIterator>::Item<'static>,
1616
}
@@ -30,7 +30,7 @@ struct StreamEnumerate<I> {
3030
}
3131

3232
impl<I: StreamingIterator> StreamingIterator for StreamEnumerate<I> {
33-
type Item<'a> = (usize, I::Item<'a>);
33+
type Item<'a> where Self: 'a = (usize, I::Item<'a>);
3434
fn next<'a>(&'a mut self) -> Option<Self::Item<'a>> {
3535
match self.iter.next() {
3636
None => None,
@@ -44,7 +44,7 @@ impl<I: StreamingIterator> StreamingIterator for StreamEnumerate<I> {
4444
}
4545

4646
impl<I: Iterator> StreamingIterator for I {
47-
type Item<'a> = <I as Iterator>::Item;
47+
type Item<'a> where Self: 'a = <I as Iterator>::Item;
4848
fn next(&mut self) -> Option<<I as StreamingIterator>::Item<'_>> {
4949
Iterator::next(self)
5050
}

src/test/ui/generic-associated-types/variance_constraints.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#![feature(generic_associated_types)]
44

55
trait A {
6-
type B<'a>;
6+
type B<'a> where Self: 'a;
77

88
fn make_b<'a>(&'a self) -> Self::B<'a>;
99
}

0 commit comments

Comments
 (0)