From 1c4603e3b036b3f1292feb1a073fc7f3221a4321 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sat, 11 Mar 2023 23:16:46 +0000 Subject: [PATCH] Commit some tests for the new solver + lazy norm --- .../cast-checks-handling-projections.rs | 0 .../equating-projection-cyclically.rs | 0 .../equating-projection-cyclically.stderr | 0 .../new-solver/lazy-nested-obligations-1.rs | 13 ++++++ .../new-solver/lazy-nested-obligations-2.rs | 23 +++++++++++ .../new-solver/lazy-nested-obligations-3.rs | 38 ++++++++++++++++++ .../new-solver/normalize-param-env-1.rs | 40 +++++++++++++++++++ .../new-solver/normalize-param-env-2.rs | 26 ++++++++++++ .../new-solver/normalize-param-env-3.rs | 32 +++++++++++++++ 9 files changed, 172 insertions(+) rename tests/ui/{typeck/lazy-norm => traits/new-solver}/cast-checks-handling-projections.rs (100%) rename tests/ui/{typeck/lazy-norm => traits/new-solver}/equating-projection-cyclically.rs (100%) rename tests/ui/{typeck/lazy-norm => traits/new-solver}/equating-projection-cyclically.stderr (100%) create mode 100644 tests/ui/traits/new-solver/lazy-nested-obligations-1.rs create mode 100644 tests/ui/traits/new-solver/lazy-nested-obligations-2.rs create mode 100644 tests/ui/traits/new-solver/lazy-nested-obligations-3.rs create mode 100644 tests/ui/traits/new-solver/normalize-param-env-1.rs create mode 100644 tests/ui/traits/new-solver/normalize-param-env-2.rs create mode 100644 tests/ui/traits/new-solver/normalize-param-env-3.rs diff --git a/tests/ui/typeck/lazy-norm/cast-checks-handling-projections.rs b/tests/ui/traits/new-solver/cast-checks-handling-projections.rs similarity index 100% rename from tests/ui/typeck/lazy-norm/cast-checks-handling-projections.rs rename to tests/ui/traits/new-solver/cast-checks-handling-projections.rs diff --git a/tests/ui/typeck/lazy-norm/equating-projection-cyclically.rs b/tests/ui/traits/new-solver/equating-projection-cyclically.rs similarity index 100% rename from tests/ui/typeck/lazy-norm/equating-projection-cyclically.rs rename to tests/ui/traits/new-solver/equating-projection-cyclically.rs diff --git a/tests/ui/typeck/lazy-norm/equating-projection-cyclically.stderr b/tests/ui/traits/new-solver/equating-projection-cyclically.stderr similarity index 100% rename from tests/ui/typeck/lazy-norm/equating-projection-cyclically.stderr rename to tests/ui/traits/new-solver/equating-projection-cyclically.stderr diff --git a/tests/ui/traits/new-solver/lazy-nested-obligations-1.rs b/tests/ui/traits/new-solver/lazy-nested-obligations-1.rs new file mode 100644 index 0000000000000..af00cbb3ba827 --- /dev/null +++ b/tests/ui/traits/new-solver/lazy-nested-obligations-1.rs @@ -0,0 +1,13 @@ +// check-pass +// compile-flags: -Ztrait-solver=next +// Issue 94358 + +fn foo(_: C) +where + for <'a> &'a C: IntoIterator, + for <'a> <&'a C as IntoIterator>::IntoIter: ExactSizeIterator, +{} + +fn main() { + foo::<_>(vec![true, false]); +} diff --git a/tests/ui/traits/new-solver/lazy-nested-obligations-2.rs b/tests/ui/traits/new-solver/lazy-nested-obligations-2.rs new file mode 100644 index 0000000000000..32addd829dcfd --- /dev/null +++ b/tests/ui/traits/new-solver/lazy-nested-obligations-2.rs @@ -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 = V(f); + pub struct V(::F); + + pub enum E3 { + Var(::F), + } + let _: E3 = E3::Var(f); +} diff --git a/tests/ui/traits/new-solver/lazy-nested-obligations-3.rs b/tests/ui/traits/new-solver/lazy-nested-obligations-3.rs new file mode 100644 index 0000000000000..baf3995724023 --- /dev/null +++ b/tests/ui/traits/new-solver/lazy-nested-obligations-3.rs @@ -0,0 +1,38 @@ +// check-pass +// compile-flags: -Ztrait-solver=next +// Issue 96750 + +use std::marker::PhantomData; + +trait AsyncFn { + type Output; +} +trait RequestFamily { + type Type<'a>; +} +trait Service {} + +struct MyFn; +impl AsyncFn for MyFn { + type Output = (); +} + +impl RequestFamily for String { + type Type<'a> = String; +} + +struct ServiceFromAsyncFn(F, PhantomData); + +impl Service for ServiceFromAsyncFn +where + Req: RequestFamily, + F: AsyncFn, + F: for<'a> AsyncFn, Output = O>, +{ +} + +fn assert_service() -> impl Service { + ServiceFromAsyncFn(MyFn, PhantomData) +} + +fn main() {} diff --git a/tests/ui/traits/new-solver/normalize-param-env-1.rs b/tests/ui/traits/new-solver/normalize-param-env-1.rs new file mode 100644 index 0000000000000..b02a5d623307a --- /dev/null +++ b/tests/ui/traits/new-solver/normalize-param-env-1.rs @@ -0,0 +1,40 @@ +// check-pass +// compile-flags: -Ztrait-solver=next +// Issue 108933 + +trait Add { + type Sum; +} + +impl Add<()> for () { + type Sum = (); +} + +type Unit = <() as Add<()>>::Sum; + +trait Trait { + type Output; +} + +fn f() +where + T: Trait<()>, + >::Output: Sized, +{ +} + +fn g() +where + T: Trait, + >::Output: Sized, +{ +} + +fn h() +where + T: Trait<()>, + >::Output: Sized, +{ +} + +fn main() {} diff --git a/tests/ui/traits/new-solver/normalize-param-env-2.rs b/tests/ui/traits/new-solver/normalize-param-env-2.rs new file mode 100644 index 0000000000000..7c2cebdd2002f --- /dev/null +++ b/tests/ui/traits/new-solver/normalize-param-env-2.rs @@ -0,0 +1,26 @@ +// check-pass +// compile-flags: -Ztrait-solver=next +// Issue 92505 + +trait A { + type I; + + fn f() + where + Self::I: A, + { + } +} + +impl A for () { + type I = (); + + fn f() + where + Self::I: A, + { + <() as A>::f(); + } +} + +fn main() {} diff --git a/tests/ui/traits/new-solver/normalize-param-env-3.rs b/tests/ui/traits/new-solver/normalize-param-env-3.rs new file mode 100644 index 0000000000000..ce2974b2a16f4 --- /dev/null +++ b/tests/ui/traits/new-solver/normalize-param-env-3.rs @@ -0,0 +1,32 @@ +// check-pass +// compile-flags: -Ztrait-solver=next +// Issue 100177 + +trait GenericTrait {} + +trait Channel: GenericTrait { + type T; +} + +trait Sender { + type Msg; + + fn send() + where + C: Channel; +} + +impl Sender for T { + type Msg = (); + + fn send() + where + C: Channel, + { + } +} + +// This works +fn foo(ch: C) where C: Channel {} + +fn main() {}