File tree 4 files changed +95
-0
lines changed
src/test/ui/associated-types
4 files changed +95
-0
lines changed Original file line number Diff line number Diff line change
1
+ // check-pass
2
+
3
+ #![ allow( unused) ]
4
+
5
+ trait Bar < T > {
6
+ fn dummy ( & self ) ;
7
+ }
8
+
9
+ trait Foo {
10
+ type A ;
11
+ type B : Bar < Self :: A > ;
12
+
13
+ fn get_b ( & self ) -> & Self :: B ;
14
+ }
15
+
16
+ fn test_bar < A , B : Bar < A > > ( _: & B ) { }
17
+
18
+ fn test < A , F : Foo < A = A > > ( f : & F ) {
19
+ test_bar ( f. get_b ( ) ) ;
20
+ }
21
+
22
+ trait Bar1 < T > { }
23
+ trait Caz1 {
24
+ type A ;
25
+ type B : Bar1 < Self :: A > ;
26
+ }
27
+
28
+ fn test1 < T , U > ( ) where T : Caz1 , U : Caz1 < A = T :: A > { }
29
+
30
+ trait Bar2 < T > { }
31
+ trait Caz2 {
32
+ type A ;
33
+ type B : Bar2 < Self :: A > ;
34
+ }
35
+ fn test2 < T : Caz2 < A = ( ) > > ( ) { }
36
+
37
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ // check-pass
2
+
3
+ trait Parent {
4
+ type Ty ;
5
+ type Assoc : Child < Self :: Ty > ;
6
+ }
7
+
8
+ trait Child < T > { }
9
+
10
+ struct ChildWrapper < T > ( T ) ;
11
+ impl < A , T > Child < A > for ChildWrapper < T > where T : Child < A > { }
12
+
13
+ struct ParentWrapper < T > ( T ) ;
14
+ impl < A , T : Parent < Ty = A > > Parent for ParentWrapper < T > {
15
+ type Ty = A ;
16
+ type Assoc = ChildWrapper < T :: Assoc > ;
17
+ }
18
+
19
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ // check-pass
2
+
3
+ use std:: ops:: Mul ;
4
+
5
+ fn main ( ) { }
6
+
7
+ trait Ring { }
8
+ trait Real : Ring { }
9
+
10
+ trait Module : Sized + Mul < <Self as Module >:: Ring , Output = Self > {
11
+ type Ring : Ring ;
12
+ }
13
+
14
+ trait EuclideanSpace {
15
+ type Coordinates : Module < Ring = Self :: Real > ;
16
+ type Real : Real ;
17
+ }
18
+
19
+ trait Translation < E : EuclideanSpace > {
20
+ fn to_vector ( & self ) -> E :: Coordinates ;
21
+
22
+ fn powf ( & self , n : <E :: Coordinates as Module >:: Ring ) -> E :: Coordinates {
23
+ self . to_vector ( ) * n
24
+ }
25
+ }
Original file line number Diff line number Diff line change
1
+ // check-pass
2
+
3
+ #![ allow( unused) ]
4
+
5
+ trait Foo {
6
+ type Bar ;
7
+ type Baz : Bar < Self :: Bar > ;
8
+ }
9
+
10
+ trait Bar < T > { }
11
+
12
+ fn x < T : Foo < Bar = U > , U > ( t : & T ) { }
13
+
14
+ fn main ( ) { }
You can’t perform that action at this time.
0 commit comments