Skip to content

Commit b90e9c9

Browse files
committed
Added test to make sure we can refer to the declared traits of a generic associated type
1 parent 4f90eac commit b90e9c9

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

src/test/ui/rfc1598-generic-associated-types/iterable.rs

+7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
#![feature(generic_associated_types)]
1212

13+
use std::ops::Deref;
14+
1315
//FIXME(#44265): "lifetime parameters are not allowed on this type" errors will be addressed in a
1416
//follow-up PR
1517

@@ -18,6 +20,11 @@ trait Iterable {
1820
type Iter<'a>: Iterator<Item = Self::Item<'a>>;
1921
//~^ ERROR lifetime parameters are not allowed on this type [E0110]
2022

23+
// This weird type tests that we can use universal function call syntax to access the Item on
24+
// Self::Iter which we have declared to be an Iterator
25+
type Iter2<'a>: Deref<Target = <Self::Iter<'a> as Iterator>::Item>;
26+
//~^ ERROR lifetime parameters are not allowed on this type [E0110]
27+
2128
fn iter<'a>(&'a self) -> Self::Iter<'a>;
2229
//~^ ERROR lifetime parameters are not allowed on this type [E0110]
2330
}
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
error[E0110]: lifetime parameters are not allowed on this type
2-
--> $DIR/iterable.rs:18:47
2+
--> $DIR/iterable.rs:20:47
33
|
4-
18 | type Iter<'a>: Iterator<Item = Self::Item<'a>>;
4+
20 | type Iter<'a>: Iterator<Item = Self::Item<'a>>;
55
| ^^ lifetime parameter not allowed on this type
66

77
error[E0110]: lifetime parameters are not allowed on this type
8-
--> $DIR/iterable.rs:21:41
8+
--> $DIR/iterable.rs:25:48
99
|
10-
21 | fn iter<'a>(&'a self) -> Self::Iter<'a>;
10+
25 | type Iter2<'a>: Deref<Target = <Self::Iter<'a> as Iterator>::Item>;
11+
| ^^ lifetime parameter not allowed on this type
12+
13+
error[E0110]: lifetime parameters are not allowed on this type
14+
--> $DIR/iterable.rs:28:41
15+
|
16+
28 | fn iter<'a>(&'a self) -> Self::Iter<'a>;
1117
| ^^ lifetime parameter not allowed on this type
1218

13-
error: aborting due to 2 previous errors
19+
error: aborting due to 3 previous errors
1420

0 commit comments

Comments
 (0)