Rollup merge of #109034 - compiler-errors:lazy-norm-tests, r=jackh726

Commit some tests for the new solver + lazy norm

Also consolidate `typeck/lazy-norm` into `traits/new-solver`, since it's not really useful to maintain a distinction, like when a test really is due to "lazy norm" or "the new solver" (usually both!)
This commit is contained in:
Matthias Krüger 2023-03-12 08:13:29 +01:00 committed by GitHub
commit 3166b4a245
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 172 additions and 0 deletions

View File

@ -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]);
}

View File

@ -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);
}

View File

@ -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() {}

View File

@ -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() {}

View File

@ -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() {}

View File

@ -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() {}