Skip to content

Commit

Permalink
Commit some tests for the new solver + lazy norm
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Mar 11, 2023
1 parent 8a73f50 commit 1c4603e
Show file tree
Hide file tree
Showing 9 changed files with 172 additions and 0 deletions.
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() {}

0 comments on commit 1c4603e

Please sign in to comment.