mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 08:44:35 +00:00
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:
commit
3166b4a245
13
tests/ui/traits/new-solver/lazy-nested-obligations-1.rs
Normal file
13
tests/ui/traits/new-solver/lazy-nested-obligations-1.rs
Normal 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]);
|
||||
}
|
23
tests/ui/traits/new-solver/lazy-nested-obligations-2.rs
Normal file
23
tests/ui/traits/new-solver/lazy-nested-obligations-2.rs
Normal 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);
|
||||
}
|
38
tests/ui/traits/new-solver/lazy-nested-obligations-3.rs
Normal file
38
tests/ui/traits/new-solver/lazy-nested-obligations-3.rs
Normal 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() {}
|
40
tests/ui/traits/new-solver/normalize-param-env-1.rs
Normal file
40
tests/ui/traits/new-solver/normalize-param-env-1.rs
Normal 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() {}
|
26
tests/ui/traits/new-solver/normalize-param-env-2.rs
Normal file
26
tests/ui/traits/new-solver/normalize-param-env-2.rs
Normal 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() {}
|
32
tests/ui/traits/new-solver/normalize-param-env-3.rs
Normal file
32
tests/ui/traits/new-solver/normalize-param-env-3.rs
Normal 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() {}
|
Loading…
Reference in New Issue
Block a user