File tree 4 files changed +101
-0
lines changed
src/test/ui/generic-associated-types
4 files changed +101
-0
lines changed Original file line number Diff line number Diff line change
1
+ #![ feature( generic_associated_types) ]
2
+ #![ feature( type_alias_impl_trait) ]
3
+
4
+ fn main ( ) { }
5
+
6
+ trait A < ' a > {
7
+ type B < ' b > : Clone
8
+ // FIXME(generic_associated_types): Remove one of the below bounds
9
+ // https://github.com/rust-lang/rust/pull/90678#discussion_r744976085
10
+ where
11
+ ' a : ' b , Self : ' a , Self : ' b ;
12
+
13
+ fn a ( & ' a self ) -> Self :: B < ' a > ;
14
+ }
15
+
16
+ struct C ;
17
+
18
+ impl < ' a > A < ' a > for C {
19
+ type B < ' b > = impl Clone ;
20
+ //~^ ERROR: lifetime bound not satisfied
21
+ //~| ERROR: could not find defining uses
22
+
23
+ fn a ( & ' a self ) -> Self :: B < ' a > { } //~ ERROR: non-defining opaque type use in defining scope
24
+ }
Original file line number Diff line number Diff line change
1
+ error[E0478]: lifetime bound not satisfied
2
+ --> $DIR/issue-88595.rs:19:5
3
+ |
4
+ LL | type B<'b> = impl Clone;
5
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
6
+ |
7
+ note: lifetime parameter instantiated with the lifetime `'a` as defined here
8
+ --> $DIR/issue-88595.rs:18:6
9
+ |
10
+ LL | impl<'a> A<'a> for C {
11
+ | ^^
12
+ note: but lifetime parameter must outlive the lifetime `'b` as defined here
13
+ --> $DIR/issue-88595.rs:19:12
14
+ |
15
+ LL | type B<'b> = impl Clone;
16
+ | ^^
17
+
18
+ error: non-defining opaque type use in defining scope
19
+ --> $DIR/issue-88595.rs:23:23
20
+ |
21
+ LL | fn a(&'a self) -> Self::B<'a> {}
22
+ | ^^^^^^^^^^^
23
+ |
24
+ note: lifetime used multiple times
25
+ --> $DIR/issue-88595.rs:18:6
26
+ |
27
+ LL | impl<'a> A<'a> for C {
28
+ | ^^
29
+ LL | type B<'b> = impl Clone;
30
+ | ^^
31
+
32
+ error: could not find defining uses
33
+ --> $DIR/issue-88595.rs:19:18
34
+ |
35
+ LL | type B<'b> = impl Clone;
36
+ | ^^^^^^^^^^
37
+
38
+ error: aborting due to 3 previous errors
39
+
40
+ For more information about this error, try `rustc --explain E0478`.
Original file line number Diff line number Diff line change
1
+ // edition:2018
2
+
3
+ #![ feature( generic_associated_types) ]
4
+ #![ feature( type_alias_impl_trait) ]
5
+
6
+ use std:: future:: Future ;
7
+
8
+ trait MakeFut {
9
+ type Fut < ' a > where Self : ' a ;
10
+ fn make_fut < ' a > ( & ' a self ) -> Self :: Fut < ' a > ;
11
+ }
12
+
13
+ impl MakeFut for & ' _ mut ( ) {
14
+ type Fut < ' a > = impl Future < Output = ( ) > ;
15
+ //~^ ERROR: the type `&mut ()` does not fulfill the required lifetime
16
+
17
+ fn make_fut < ' a > ( & ' a self ) -> Self :: Fut < ' a > {
18
+ async { ( ) }
19
+ }
20
+ }
21
+
22
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error[E0477]: the type `&mut ()` does not fulfill the required lifetime
2
+ --> $DIR/issue-90014.rs:14:5
3
+ |
4
+ LL | type Fut<'a> = impl Future<Output = ()>;
5
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6
+ |
7
+ note: type must outlive the lifetime `'a` as defined here
8
+ --> $DIR/issue-90014.rs:14:14
9
+ |
10
+ LL | type Fut<'a> = impl Future<Output = ()>;
11
+ | ^^
12
+
13
+ error: aborting due to previous error
14
+
15
+ For more information about this error, try `rustc --explain E0477`.
You can’t perform that action at this time.
0 commit comments