Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 3 additions & 2 deletions
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
Lines changed: 7 additions & 29 deletions
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

0 commit comments

Comments
 (0)