Skip to content
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

Commit some tests for the new solver + lazy norm #109034

Merged
merged 1 commit into from
Mar 12, 2023
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/ui/traits/new-solver/lazy-nested-obligations-1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// check-pass
// compile-flags: -Ztrait-solver=next
// Issue 94358

fn foo<C>(_: C)
where
for <'a> &'a C: IntoIterator,
for <'a> <&'a C as IntoIterator>::IntoIter: ExactSizeIterator,
{}

fn main() {
foo::<_>(vec![true, false]);
}
23 changes: 23 additions & 0 deletions tests/ui/traits/new-solver/lazy-nested-obligations-2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// check-pass
// compile-flags: -Ztrait-solver=next
// Issue 95863

pub trait With {
type F;
}

impl With for i32 {
type F = fn(&str);
}

fn f(_: &str) {}

fn main() {
let _: V<i32> = V(f);
pub struct V<T: With>(<T as With>::F);

pub enum E3<T: With> {
Var(<T as With>::F),
}
let _: E3<i32> = E3::Var(f);
}
38 changes: 38 additions & 0 deletions tests/ui/traits/new-solver/lazy-nested-obligations-3.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// check-pass
// compile-flags: -Ztrait-solver=next
// Issue 96750

use std::marker::PhantomData;

trait AsyncFn<Arg> {
type Output;
}
trait RequestFamily {
type Type<'a>;
}
trait Service {}

struct MyFn;
impl AsyncFn<String> for MyFn {
type Output = ();
}

impl RequestFamily for String {
type Type<'a> = String;
}

struct ServiceFromAsyncFn<F, Req>(F, PhantomData<Req>);

impl<F, Req, O> Service for ServiceFromAsyncFn<F, Req>
where
Req: RequestFamily,
F: AsyncFn<Req>,
F: for<'a> AsyncFn<Req::Type<'a>, Output = O>,
{
}

fn assert_service() -> impl Service {
ServiceFromAsyncFn(MyFn, PhantomData)
}

fn main() {}
40 changes: 40 additions & 0 deletions tests/ui/traits/new-solver/normalize-param-env-1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// check-pass
// compile-flags: -Ztrait-solver=next
// Issue 108933

trait Add<Rhs> {
type Sum;
}

impl Add<()> for () {
type Sum = ();
}

type Unit = <() as Add<()>>::Sum;

trait Trait<C> {
type Output;
}

fn f<T>()
where
T: Trait<()>,
<T as Trait<()>>::Output: Sized,
{
}

fn g<T>()
where
T: Trait<Unit>,
<T as Trait<()>>::Output: Sized,
{
}

fn h<T>()
where
T: Trait<()>,
<T as Trait<Unit>>::Output: Sized,
{
}

fn main() {}
26 changes: 26 additions & 0 deletions tests/ui/traits/new-solver/normalize-param-env-2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// check-pass
// compile-flags: -Ztrait-solver=next
// Issue 92505

trait A<T> {
type I;

fn f()
where
Self::I: A<T>,
{
}
}

impl<T> A<T> for () {
type I = ();

fn f()
where
Self::I: A<T>,
{
<() as A<T>>::f();
}
}

fn main() {}
32 changes: 32 additions & 0 deletions tests/ui/traits/new-solver/normalize-param-env-3.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// check-pass
// compile-flags: -Ztrait-solver=next
// Issue 100177

trait GenericTrait<T> {}

trait Channel<I>: GenericTrait<Self::T> {
type T;
}

trait Sender {
type Msg;

fn send<C>()
where
C: Channel<Self::Msg>;
}

impl<T> Sender for T {
type Msg = ();

fn send<C>()
where
C: Channel<Self::Msg>,
{
}
}

// This works
fn foo<I, C>(ch: C) where C: Channel<I> {}

fn main() {}