File tree Expand file tree Collapse file tree 12 files changed +317
-0
lines changed Expand file tree Collapse file tree 12 files changed +317
-0
lines changed Original file line number Diff line number Diff line change 1+ // check-pass
2+
3+ #![ allow( incomplete_features) ]
4+ #![ feature( associated_type_bounds) ]
5+ #![ feature( generic_associated_types) ]
6+
7+ trait MP {
8+ type T < ' a > ;
9+ }
10+ struct S ( String ) ;
11+ impl MP for S {
12+ type T < ' a > = & ' a str ;
13+ }
14+
15+ trait SR : MP {
16+ fn sr < IM > ( & self ) -> i32
17+ where
18+ for < ' a > IM : T < T : U < <Self as MP >:: T < ' a > > > ;
19+ }
20+
21+ trait T {
22+ type T ;
23+ }
24+ trait U < X > { }
25+
26+ fn main ( ) { }
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+ }
Original file line number Diff line number Diff line change 1+ #![ allow( incomplete_features) ]
2+ #![ feature( generic_associated_types) ]
3+
4+ trait Document {
5+ type Cursor < ' a > : DocCursor < ' a > ;
6+
7+ fn cursor ( & self ) -> Self :: Cursor < ' _ > ;
8+ }
9+
10+ struct DocumentImpl { }
11+
12+ impl Document for DocumentImpl {
13+ type Cursor < ' a > = DocCursorImpl < ' a > ;
14+
15+ fn cursor ( & self ) -> Self :: Cursor < ' _ > {
16+ DocCursorImpl {
17+ document : & self ,
18+ }
19+ }
20+ }
21+
22+
23+ trait DocCursor < ' a > { }
24+
25+ struct DocCursorImpl < ' a > {
26+ document : & ' a DocumentImpl ,
27+ }
28+
29+ impl < ' a > DocCursor < ' a > for DocCursorImpl < ' a > { }
30+
31+ struct Lexer < ' d , Cursor >
32+ where
33+ Cursor : DocCursor < ' d > ,
34+ {
35+ cursor : Cursor ,
36+ _phantom : std:: marker:: PhantomData < & ' d ( ) > ,
37+ }
38+
39+
40+ impl < ' d , Cursor > Lexer < ' d , Cursor >
41+ where
42+ Cursor : DocCursor < ' d > ,
43+ {
44+ pub fn from < Doc > ( document : & ' d Doc ) -> Lexer < ' d , Cursor >
45+ where
46+ Doc : Document < Cursor < ' d > = Cursor > ,
47+ {
48+ Lexer {
49+ cursor : document. cursor ( ) ,
50+ _phantom : std:: marker:: PhantomData ,
51+ }
52+ }
53+ }
54+
55+ fn create_doc ( ) -> impl Document < Cursor < ' _ > = DocCursorImpl < ' _ > > {
56+ //~^ ERROR: missing lifetime specifier
57+ DocumentImpl { }
58+ }
59+
60+ pub fn main ( ) {
61+ let doc = create_doc ( ) ;
62+ let lexer: Lexer < ' _ , DocCursorImpl < ' _ > > = Lexer :: from ( & doc) ;
63+ }
Original file line number Diff line number Diff line change 1+ error[E0106]: missing lifetime specifier
2+ --> $DIR/issue-70304.rs:55:41
3+ |
4+ LL | fn create_doc() -> impl Document<Cursor<'_> = DocCursorImpl<'_>> {
5+ | ^^ expected named lifetime parameter
6+ |
7+ = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
8+ help: consider using the `'static` lifetime
9+ |
10+ LL | fn create_doc() -> impl Document<Cursor<'static> = DocCursorImpl<'_>> {
11+ | ^^^^^^^
12+
13+ error: aborting due to previous error
14+
15+ For more information about this error, try `rustc --explain E0106`.
Original file line number Diff line number Diff line change 1+ #![ allow( incomplete_features) ]
2+ #![ feature( generic_associated_types) ]
3+
4+ trait Provider {
5+ type A < ' a > ;
6+ //~^ ERROR: missing generics for associated type
7+ }
8+
9+ impl Provider for ( ) {
10+ type A < ' a > = ( ) ;
11+ }
12+
13+ struct Holder < B > {
14+ inner : Box < dyn Provider < A = B > > ,
15+ }
16+
17+ fn main ( ) {
18+ Holder {
19+ inner : Box :: new ( ( ) ) ,
20+ } ;
21+ }
Original file line number Diff line number Diff line change 1+ error[E0107]: missing generics for associated type `Provider::A`
2+ --> $DIR/issue-71176.rs:5:10
3+ |
4+ LL | type A<'a>;
5+ | ^ expected 1 lifetime argument
6+ |
7+ note: associated type defined here, with 1 lifetime parameter: `'a`
8+ --> $DIR/issue-71176.rs:5:10
9+ |
10+ LL | type A<'a>;
11+ | ^ --
12+ help: use angle brackets to add missing lifetime argument
13+ |
14+ LL | type A<'a><'a>;
15+ | ^^^^
16+
17+ error: aborting due to previous error
18+
19+ For more information about this error, try `rustc --explain E0107`.
Original file line number Diff line number Diff line change 1+ #![ allow( incomplete_features) ]
2+ #![ feature( generic_associated_types) ]
3+
4+ trait CollectionFamily {
5+ type Member < T > ;
6+ //~^ ERROR: missing generics for associated type
7+ }
8+ fn floatify ( ) {
9+ Box :: new ( Family ) as & dyn CollectionFamily < Member =usize >
10+ }
11+
12+ struct Family ;
13+
14+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error[E0107]: missing generics for associated type `CollectionFamily::Member`
2+ --> $DIR/issue-78671.rs:5:10
3+ |
4+ LL | type Member<T>;
5+ | ^^^^^^ expected 1 type argument
6+ |
7+ note: associated type defined here, with 1 type parameter: `T`
8+ --> $DIR/issue-78671.rs:5:10
9+ |
10+ LL | type Member<T>;
11+ | ^^^^^^ -
12+ help: use angle brackets to add missing type argument
13+ |
14+ LL | type Member<T><T>;
15+ | ^^^
16+
17+ error: aborting due to previous error
18+
19+ For more information about this error, try `rustc --explain E0107`.
Original file line number Diff line number Diff line change 1+ #![ allow( incomplete_features) ]
2+ #![ feature( generic_associated_types) ]
3+
4+ trait Monad {
5+ type Unwrapped ;
6+ type Wrapped < B > ;
7+ //~^ ERROR: missing generics for associated type `Monad::Wrapped`
8+
9+ fn bind < B , F > ( self , f : F ) -> Self :: Wrapped < B > {
10+ todo ! ( )
11+ }
12+ }
13+
14+ fn join < MOuter , MInner , A > ( outer : MOuter ) -> MOuter :: Wrapped < A >
15+ where
16+ MOuter : Monad < Unwrapped = MInner > ,
17+ MInner : Monad < Unwrapped = A , Wrapped = MOuter :: Wrapped < A > > ,
18+ {
19+ outer. bind ( |inner| inner)
20+ }
21+
22+ fn main ( ) {
23+ assert_eq ! ( join( Some ( Some ( true ) ) ) , Some ( true ) ) ;
24+ }
Original file line number Diff line number Diff line change 1+ error[E0107]: missing generics for associated type `Monad::Wrapped`
2+ --> $DIR/issue-79636-1.rs:6:10
3+ |
4+ LL | type Wrapped<B>;
5+ | ^^^^^^^ expected 1 type argument
6+ |
7+ note: associated type defined here, with 1 type parameter: `B`
8+ --> $DIR/issue-79636-1.rs:6:10
9+ |
10+ LL | type Wrapped<B>;
11+ | ^^^^^^^ -
12+ help: use angle brackets to add missing type argument
13+ |
14+ LL | type Wrapped<B><B>;
15+ | ^^^
16+
17+ error: aborting due to previous error
18+
19+ For more information about this error, try `rustc --explain E0107`.
You can’t perform that action at this time.
0 commit comments