File tree 1 file changed +60
-0
lines changed
src/test/ui/generic-associated-types
1 file changed +60
-0
lines changed Original file line number Diff line number Diff line change
1
+ // check-pass
2
+
3
+ #![ allow( incomplete_features) ]
4
+ #![ feature( generic_associated_types) ]
5
+
6
+ trait Document {
7
+ type Cursor < ' a > : DocCursor < ' a > ;
8
+
9
+ fn cursor ( & self ) -> Self :: Cursor < ' _ > ;
10
+ }
11
+
12
+ struct DocumentImpl { }
13
+
14
+ impl Document for DocumentImpl {
15
+ type Cursor < ' a > = DocCursorImpl < ' a > ;
16
+
17
+ fn cursor ( & self ) -> Self :: Cursor < ' _ > {
18
+ DocCursorImpl {
19
+ document : & self ,
20
+ }
21
+ }
22
+ }
23
+
24
+
25
+ trait DocCursor < ' a > { }
26
+
27
+ struct DocCursorImpl < ' a > {
28
+ document : & ' a DocumentImpl ,
29
+ }
30
+
31
+ impl < ' a > DocCursor < ' a > for DocCursorImpl < ' a > { }
32
+
33
+ struct Lexer < ' d , Cursor >
34
+ where
35
+ Cursor : DocCursor < ' d > ,
36
+ {
37
+ cursor : Cursor ,
38
+ _phantom : std:: marker:: PhantomData < & ' d ( ) > ,
39
+ }
40
+
41
+
42
+ impl < ' d , Cursor > Lexer < ' d , Cursor >
43
+ where
44
+ Cursor : DocCursor < ' d > ,
45
+ {
46
+ pub fn from < Doc > ( document : & ' d Doc ) -> Lexer < ' d , Cursor >
47
+ where
48
+ Doc : Document < Cursor < ' d > = Cursor > ,
49
+ {
50
+ Lexer {
51
+ cursor : document. cursor ( ) ,
52
+ _phantom : std:: marker:: PhantomData ,
53
+ }
54
+ }
55
+ }
56
+
57
+ pub fn main ( ) {
58
+ let doc = DocumentImpl { } ;
59
+ let lexer: Lexer < ' _ , DocCursorImpl < ' _ > > = Lexer :: from ( & doc) ;
60
+ }
You can’t perform that action at this time.
0 commit comments