Skip to content

Add GAT related tests #4970

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions tests/source/issue_4257.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#![feature(generic_associated_types)]
#![allow(incomplete_features)]

trait Trait<T> {
type Type<'a> where T: 'a;
fn foo(x: &T) -> Self::Type<'_>;
}
impl<T> Trait<T> for () {
type Type<'a> where T: 'a = &'a T;
fn foo(x: &T) -> Self::Type<'_> {
x
}
}
3 changes: 3 additions & 0 deletions tests/source/issue_4322.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
trait Bar {
type X<'a> where Self: 'a;
}
9 changes: 9 additions & 0 deletions tests/source/issue_4943.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#![feature(generic_associated_types)]

impl SomeStruct {
fn process<T>(v: T) -> <Self as GAT>::R<T>
where Self: GAT<R<T> = T>
{
SomeStruct::do_something(v)
}
}
5 changes: 5 additions & 0 deletions tests/source/issue_4954.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
trait Foo {
type Arg<'a>;
}

struct Bar<T>(T) where for<'a> T: Foo<Arg<'a> = ()>;
18 changes: 18 additions & 0 deletions tests/target/issue_4257.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#![feature(generic_associated_types)]
#![allow(incomplete_features)]

trait Trait<T> {
type Type<'a>
where
T: 'a;
fn foo(x: &T) -> Self::Type<'_>;
}
impl<T> Trait<T> for () {
type Type<'a>
where
T: 'a,
= &'a T;
fn foo(x: &T) -> Self::Type<'_> {
x
}
}
5 changes: 5 additions & 0 deletions tests/target/issue_4322.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
trait Bar {
type X<'a>
where
Self: 'a;
}
2 changes: 2 additions & 0 deletions tests/target/issue_4943.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![feature(generic_associated_types)]

impl SomeStruct {
fn process<T>(v: T) -> <Self as GAT>::R<T>
where
Expand Down
7 changes: 7 additions & 0 deletions tests/target/issue_4954.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
trait Foo {
type Arg<'a>;
}

struct Bar<T>(T)
where
for<'a> T: Foo<Arg<'a> = ()>;