File tree 12 files changed +97
-35
lines changed
run-pass/rfc1598-generic-associated-types
ui/rfc1598-generic-associated-types
12 files changed +97
-35
lines changed Original file line number Diff line number Diff line change @@ -12,13 +12,17 @@ use std::ops::Deref;
12
12
13
13
trait PointerFamily < U > {
14
14
type Pointer < T > : Deref < Target = T > ;
15
+ //~^ ERROR generic associated types are unstable
15
16
type Pointer2 < T > : Deref < Target = T > where T : Clone , U : Clone ;
17
+ //~^ ERROR generic associated types are unstable
16
18
}
17
19
18
20
struct Foo ;
19
21
impl PointerFamily < u32 > for Foo {
20
22
type Pointer < usize > = Box < usize > ;
23
+ //~^ ERROR generic associated types are unstable
21
24
type Pointer2 < u32 > = Box < u32 > ;
25
+ //~^ ERROR generic associated types are unstable
22
26
}
23
27
24
28
fn main ( ) { }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 10
10
11
11
#![ feature( generic_associated_types) ]
12
12
13
+ //FIXME(#44265): "undeclared lifetime" errors will be addressed in a follow-up PR
14
+
13
15
trait Foo {
14
16
type Bar < ' a , ' b > ;
15
17
}
@@ -20,6 +22,7 @@ trait Baz {
20
22
21
23
impl < T > Baz for T where T : Foo {
22
24
type Quux < ' a > = <T as Foo >:: Bar < ' a , ' static > ;
25
+ //~^ ERROR undeclared lifetime
23
26
}
24
27
25
28
fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error[E0261]: use of undeclared lifetime name `'a`
2
+ --> $DIR/construct_with_other_type.rs:24:37
3
+ |
4
+ 24 | type Quux<'a> = <T as Foo>::Bar<'a, 'static>;
5
+ | ^^ undeclared lifetime
6
+
7
+ error: aborting due to previous error
8
+
Original file line number Diff line number Diff line change 13
13
// Checking the interaction with this other feature
14
14
#![ feature( associated_type_defaults) ]
15
15
16
+ //FIXME(#44265): "undeclared lifetime" errors will be addressed in a follow-up PR
17
+
16
18
use std:: fmt:: { Display , Debug } ;
17
19
18
20
trait Foo {
19
21
type Assoc where Self : Sized ;
20
22
type Assoc2 < T > where T : Display ;
21
23
type WithDefault < T > where T : Debug = Iterator < Item =T > ;
24
+ type NoGenerics ;
22
25
}
23
26
24
27
struct Bar ;
@@ -27,6 +30,8 @@ impl Foo for Bar {
27
30
type Assoc = usize ;
28
31
type Assoc2 < T > = Vec < T > ;
29
32
type WithDefault < ' a , T > = & ' a Iterator < T > ;
33
+ //~^ ERROR undeclared lifetime
34
+ type NoGenerics = :: std:: cell:: Cell < i32 > ;
30
35
}
31
36
32
37
fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error[E0261]: use of undeclared lifetime name `'a`
2
+ --> $DIR/generic-associated-types-where.rs:32:32
3
+ |
4
+ 32 | type WithDefault<'a, T> = &'a Iterator<T>;
5
+ | ^^ undeclared lifetime
6
+
7
+ error: aborting due to previous error
8
+
Original file line number Diff line number Diff line change 10
10
11
11
#![ feature( generic_associated_types) ]
12
12
13
+ //FIXME(#44265): "undeclared lifetime" errors will be addressed in a follow-up PR
14
+
13
15
trait Iterable {
14
16
type Item < ' a > ;
15
17
type Iter < ' a > : Iterator < Item = Self :: Item < ' a > > ;
18
+ //~^ ERROR undeclared lifetime
16
19
17
20
fn iter < ' a > ( & ' a self ) -> Self :: Iter < ' a > ;
18
21
}
Original file line number Diff line number Diff line change
1
+ error[E0261]: use of undeclared lifetime name `'a`
2
+ --> $DIR/iterable.rs:17:47
3
+ |
4
+ 17 | type Iter<'a>: Iterator<Item = Self::Item<'a>>;
5
+ | ^^ undeclared lifetime
6
+
7
+ error: aborting due to previous error
8
+
Original file line number Diff line number Diff line change 10
10
11
11
#![ feature( generic_associated_types) ]
12
12
13
+ //FIXME(#44265): "type parameter not allowed" errors will be addressed in a follow-up PR
14
+
13
15
use std:: rc:: Rc ;
14
16
use std:: sync:: Arc ;
15
17
use std:: ops:: Deref ;
16
18
17
19
trait PointerFamily {
18
20
type Pointer < T > : Deref < Target = T > ;
19
21
fn new < T > ( value : T ) -> Self :: Pointer < T > ;
22
+ //~^ ERROR type parameters are not allowed on this type [E0109]
20
23
}
21
24
22
25
struct ArcFamily ;
23
26
24
27
impl PointerFamily for ArcFamily {
25
28
type Pointer < T > = Arc < T > ;
26
29
fn new < T > ( value : T ) -> Self :: Pointer < T > {
30
+ //~^ ERROR type parameters are not allowed on this type [E0109]
27
31
Arc :: new ( value)
28
32
}
29
33
}
@@ -33,12 +37,14 @@ struct RcFamily;
33
37
impl PointerFamily for RcFamily {
34
38
type Pointer < T > = Rc < T > ;
35
39
fn new < T > ( value : T ) -> Self :: Pointer < T > {
40
+ //~^ ERROR type parameters are not allowed on this type [E0109]
36
41
Rc :: new ( value)
37
42
}
38
43
}
39
44
40
45
struct Foo < P : PointerFamily > {
41
46
bar : P :: Pointer < String > ,
47
+ //~^ ERROR type parameters are not allowed on this type [E0109]
42
48
}
43
49
44
50
fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error[E0109]: type parameters are not allowed on this type
2
+ --> $DIR/pointer_family.rs:46:21
3
+ |
4
+ 46 | bar: P::Pointer<String>,
5
+ | ^^^^^^ type parameter not allowed
6
+
7
+ error[E0109]: type parameters are not allowed on this type
8
+ --> $DIR/pointer_family.rs:21:42
9
+ |
10
+ 21 | fn new<T>(value: T) -> Self::Pointer<T>;
11
+ | ^ type parameter not allowed
12
+
13
+ error[E0109]: type parameters are not allowed on this type
14
+ --> $DIR/pointer_family.rs:29:42
15
+ |
16
+ 29 | fn new<T>(value: T) -> Self::Pointer<T> {
17
+ | ^ type parameter not allowed
18
+
19
+ error[E0109]: type parameters are not allowed on this type
20
+ --> $DIR/pointer_family.rs:39:42
21
+ |
22
+ 39 | fn new<T>(value: T) -> Self::Pointer<T> {
23
+ | ^ type parameter not allowed
24
+
25
+ error: aborting due to 4 previous errors
26
+
Original file line number Diff line number Diff line change 10
10
11
11
#![ feature( generic_associated_types) ]
12
12
13
+ //FIXME(#44265): "lifetime parameter not allowed on this type" errors will be addressed in a
14
+ // follow-up PR
15
+
13
16
use std:: fmt:: Display ;
14
17
15
18
trait StreamingIterator {
16
19
type Item < ' a > ;
17
20
// Applying the lifetime parameter `'a` to `Self::Item` inside the trait.
18
21
fn next < ' a > ( & ' a self ) -> Option < Self :: Item < ' a > > ;
22
+ //~^ ERROR lifetime parameters are not allowed on this type [E0110]
19
23
}
20
24
21
25
struct Foo < T : StreamingIterator > {
22
26
// Applying a concrete lifetime to the constructor outside the trait.
23
27
bar : <T as StreamingIterator >:: Item < ' static > ,
28
+ //~^ ERROR lifetime parameters are not allowed on this type [E0110]
24
29
}
25
30
26
31
// Users can bound parameters by the type constructed by that trait's associated type constructor
27
32
// of a trait using HRTB. Both type equality bounds and trait bounds of this kind are valid:
28
33
//FIXME(sunjay): This next line should parse and be valid
29
34
//fn foo<T: for<'a> StreamingIterator<Item<'a>=&'a [i32]>>(iter: T) { /* ... */ }
30
35
fn foo < T > ( iter : T ) where T : StreamingIterator , for < ' a > T :: Item < ' a > : Display { /* ... */ }
36
+ //~^ ERROR lifetime parameters are not allowed on this type [E0110]
31
37
32
38
fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error[E0110]: lifetime parameters are not allowed on this type
2
+ --> $DIR/streaming_iterator.rs:27:41
3
+ |
4
+ 27 | bar: <T as StreamingIterator>::Item<'static>,
5
+ | ^^^^^^^ lifetime parameter not allowed on this type
6
+
7
+ error[E0110]: lifetime parameters are not allowed on this type
8
+ --> $DIR/streaming_iterator.rs:35:64
9
+ |
10
+ 35 | fn foo<T>(iter: T) where T: StreamingIterator, for<'a> T::Item<'a>: Display { /* ... */ }
11
+ | ^^ lifetime parameter not allowed on this type
12
+
13
+ error[E0110]: lifetime parameters are not allowed on this type
14
+ --> $DIR/streaming_iterator.rs:21:48
15
+ |
16
+ 21 | fn next<'a>(&'a self) -> Option<Self::Item<'a>>;
17
+ | ^^ lifetime parameter not allowed on this type
18
+
19
+ error: aborting due to 3 previous errors
20
+
You can’t perform that action at this time.
0 commit comments