forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#84379 - marmeladema:test-for-issue-79949, r…
…=jackh726 Add GAT related tests Closes rust-lang#79949 Closes rust-lang#79636 Closes rust-lang#78671 Closes rust-lang#70303 Closes rust-lang#70304 Closes rust-lang#71176
- Loading branch information
Showing
12 changed files
with
317 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// check-pass | ||
|
||
#![allow(incomplete_features)] | ||
#![feature(associated_type_bounds)] | ||
#![feature(generic_associated_types)] | ||
|
||
trait MP { | ||
type T<'a>; | ||
} | ||
struct S(String); | ||
impl MP for S { | ||
type T<'a> = &'a str; | ||
} | ||
|
||
trait SR: MP { | ||
fn sr<IM>(&self) -> i32 | ||
where | ||
for<'a> IM: T<T: U<<Self as MP>::T<'a>>>; | ||
} | ||
|
||
trait T { | ||
type T; | ||
} | ||
trait U<X> {} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// check-pass | ||
|
||
#![allow(incomplete_features)] | ||
#![feature(generic_associated_types)] | ||
|
||
trait Document { | ||
type Cursor<'a>: DocCursor<'a>; | ||
|
||
fn cursor(&self) -> Self::Cursor<'_>; | ||
} | ||
|
||
struct DocumentImpl {} | ||
|
||
impl Document for DocumentImpl { | ||
type Cursor<'a> = DocCursorImpl<'a>; | ||
|
||
fn cursor(&self) -> Self::Cursor<'_> { | ||
DocCursorImpl { | ||
document: &self, | ||
} | ||
} | ||
} | ||
|
||
|
||
trait DocCursor<'a> {} | ||
|
||
struct DocCursorImpl<'a> { | ||
document: &'a DocumentImpl, | ||
} | ||
|
||
impl<'a> DocCursor<'a> for DocCursorImpl<'a> {} | ||
|
||
struct Lexer<'d, Cursor> | ||
where | ||
Cursor: DocCursor<'d>, | ||
{ | ||
cursor: Cursor, | ||
_phantom: std::marker::PhantomData<&'d ()>, | ||
} | ||
|
||
|
||
impl<'d, Cursor> Lexer<'d, Cursor> | ||
where | ||
Cursor: DocCursor<'d>, | ||
{ | ||
pub fn from<Doc>(document: &'d Doc) -> Lexer<'d, Cursor> | ||
where | ||
Doc: Document<Cursor<'d> = Cursor>, | ||
{ | ||
Lexer { | ||
cursor: document.cursor(), | ||
_phantom: std::marker::PhantomData, | ||
} | ||
} | ||
} | ||
|
||
pub fn main() { | ||
let doc = DocumentImpl {}; | ||
let lexer: Lexer<'_, DocCursorImpl<'_>> = Lexer::from(&doc); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#![allow(incomplete_features)] | ||
#![feature(generic_associated_types)] | ||
|
||
trait Document { | ||
type Cursor<'a>: DocCursor<'a>; | ||
|
||
fn cursor(&self) -> Self::Cursor<'_>; | ||
} | ||
|
||
struct DocumentImpl {} | ||
|
||
impl Document for DocumentImpl { | ||
type Cursor<'a> = DocCursorImpl<'a>; | ||
|
||
fn cursor(&self) -> Self::Cursor<'_> { | ||
DocCursorImpl { | ||
document: &self, | ||
} | ||
} | ||
} | ||
|
||
|
||
trait DocCursor<'a> {} | ||
|
||
struct DocCursorImpl<'a> { | ||
document: &'a DocumentImpl, | ||
} | ||
|
||
impl<'a> DocCursor<'a> for DocCursorImpl<'a> {} | ||
|
||
struct Lexer<'d, Cursor> | ||
where | ||
Cursor: DocCursor<'d>, | ||
{ | ||
cursor: Cursor, | ||
_phantom: std::marker::PhantomData<&'d ()>, | ||
} | ||
|
||
|
||
impl<'d, Cursor> Lexer<'d, Cursor> | ||
where | ||
Cursor: DocCursor<'d>, | ||
{ | ||
pub fn from<Doc>(document: &'d Doc) -> Lexer<'d, Cursor> | ||
where | ||
Doc: Document<Cursor<'d> = Cursor>, | ||
{ | ||
Lexer { | ||
cursor: document.cursor(), | ||
_phantom: std::marker::PhantomData, | ||
} | ||
} | ||
} | ||
|
||
fn create_doc() -> impl Document<Cursor<'_> = DocCursorImpl<'_>> { | ||
//~^ ERROR: missing lifetime specifier | ||
DocumentImpl {} | ||
} | ||
|
||
pub fn main() { | ||
let doc = create_doc(); | ||
let lexer: Lexer<'_, DocCursorImpl<'_>> = Lexer::from(&doc); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
error[E0106]: missing lifetime specifier | ||
--> $DIR/issue-70304.rs:55:41 | ||
| | ||
LL | fn create_doc() -> impl Document<Cursor<'_> = DocCursorImpl<'_>> { | ||
| ^^ expected named lifetime parameter | ||
| | ||
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from | ||
help: consider using the `'static` lifetime | ||
| | ||
LL | fn create_doc() -> impl Document<Cursor<'static> = DocCursorImpl<'_>> { | ||
| ^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0106`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#![allow(incomplete_features)] | ||
#![feature(generic_associated_types)] | ||
|
||
trait Provider { | ||
type A<'a>; | ||
//~^ ERROR: missing generics for associated type | ||
} | ||
|
||
impl Provider for () { | ||
type A<'a> = (); | ||
} | ||
|
||
struct Holder<B> { | ||
inner: Box<dyn Provider<A = B>>, | ||
} | ||
|
||
fn main() { | ||
Holder { | ||
inner: Box::new(()), | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
error[E0107]: missing generics for associated type `Provider::A` | ||
--> $DIR/issue-71176.rs:5:10 | ||
| | ||
LL | type A<'a>; | ||
| ^ expected 1 lifetime argument | ||
| | ||
note: associated type defined here, with 1 lifetime parameter: `'a` | ||
--> $DIR/issue-71176.rs:5:10 | ||
| | ||
LL | type A<'a>; | ||
| ^ -- | ||
help: use angle brackets to add missing lifetime argument | ||
| | ||
LL | type A<'a><'a>; | ||
| ^^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0107`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#![allow(incomplete_features)] | ||
#![feature(generic_associated_types)] | ||
|
||
trait CollectionFamily { | ||
type Member<T>; | ||
//~^ ERROR: missing generics for associated type | ||
} | ||
fn floatify() { | ||
Box::new(Family) as &dyn CollectionFamily<Member=usize> | ||
} | ||
|
||
struct Family; | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
error[E0107]: missing generics for associated type `CollectionFamily::Member` | ||
--> $DIR/issue-78671.rs:5:10 | ||
| | ||
LL | type Member<T>; | ||
| ^^^^^^ expected 1 type argument | ||
| | ||
note: associated type defined here, with 1 type parameter: `T` | ||
--> $DIR/issue-78671.rs:5:10 | ||
| | ||
LL | type Member<T>; | ||
| ^^^^^^ - | ||
help: use angle brackets to add missing type argument | ||
| | ||
LL | type Member<T><T>; | ||
| ^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0107`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#![allow(incomplete_features)] | ||
#![feature(generic_associated_types)] | ||
|
||
trait Monad { | ||
type Unwrapped; | ||
type Wrapped<B>; | ||
//~^ ERROR: missing generics for associated type `Monad::Wrapped` | ||
|
||
fn bind<B, F>(self, f: F) -> Self::Wrapped<B> { | ||
todo!() | ||
} | ||
} | ||
|
||
fn join<MOuter, MInner, A>(outer: MOuter) -> MOuter::Wrapped<A> | ||
where | ||
MOuter: Monad<Unwrapped = MInner>, | ||
MInner: Monad<Unwrapped = A, Wrapped = MOuter::Wrapped<A>>, | ||
{ | ||
outer.bind(|inner| inner) | ||
} | ||
|
||
fn main() { | ||
assert_eq!(join(Some(Some(true))), Some(true)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
error[E0107]: missing generics for associated type `Monad::Wrapped` | ||
--> $DIR/issue-79636-1.rs:6:10 | ||
| | ||
LL | type Wrapped<B>; | ||
| ^^^^^^^ expected 1 type argument | ||
| | ||
note: associated type defined here, with 1 type parameter: `B` | ||
--> $DIR/issue-79636-1.rs:6:10 | ||
| | ||
LL | type Wrapped<B>; | ||
| ^^^^^^^ - | ||
help: use angle brackets to add missing type argument | ||
| | ||
LL | type Wrapped<B><B>; | ||
| ^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0107`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#![allow(incomplete_features)] | ||
#![feature(generic_associated_types)] | ||
|
||
trait SomeTrait { | ||
type Wrapped<A>: SomeTrait; | ||
//~^ ERROR: missing generics for associated type `SomeTrait::Wrapped` | ||
|
||
fn f() -> (); | ||
} | ||
|
||
fn program<W>() -> () | ||
where | ||
W: SomeTrait<Wrapped = W>, | ||
{ | ||
return W::f(); | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
error[E0107]: missing generics for associated type `SomeTrait::Wrapped` | ||
--> $DIR/issue-79636-2.rs:5:10 | ||
| | ||
LL | type Wrapped<A>: SomeTrait; | ||
| ^^^^^^^ expected 1 type argument | ||
| | ||
note: associated type defined here, with 1 type parameter: `A` | ||
--> $DIR/issue-79636-2.rs:5:10 | ||
| | ||
LL | type Wrapped<A>: SomeTrait; | ||
| ^^^^^^^ - | ||
help: use angle brackets to add missing type argument | ||
| | ||
LL | type Wrapped<A><A>: SomeTrait; | ||
| ^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0107`. |