Skip to content

Commit 3166b4a

Browse files
authored
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!)
2 parents 54c95a8 + 1c4603e commit 3166b4a

9 files changed

+172
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// check-pass
2+
// compile-flags: -Ztrait-solver=next
3+
// Issue 94358
4+
5+
fn foo<C>(_: C)
6+
where
7+
for <'a> &'a C: IntoIterator,
8+
for <'a> <&'a C as IntoIterator>::IntoIter: ExactSizeIterator,
9+
{}
10+
11+
fn main() {
12+
foo::<_>(vec![true, false]);
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// check-pass
2+
// compile-flags: -Ztrait-solver=next
3+
// Issue 95863
4+
5+
pub trait With {
6+
type F;
7+
}
8+
9+
impl With for i32 {
10+
type F = fn(&str);
11+
}
12+
13+
fn f(_: &str) {}
14+
15+
fn main() {
16+
let _: V<i32> = V(f);
17+
pub struct V<T: With>(<T as With>::F);
18+
19+
pub enum E3<T: With> {
20+
Var(<T as With>::F),
21+
}
22+
let _: E3<i32> = E3::Var(f);
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// check-pass
2+
// compile-flags: -Ztrait-solver=next
3+
// Issue 96750
4+
5+
use std::marker::PhantomData;
6+
7+
trait AsyncFn<Arg> {
8+
type Output;
9+
}
10+
trait RequestFamily {
11+
type Type<'a>;
12+
}
13+
trait Service {}
14+
15+
struct MyFn;
16+
impl AsyncFn<String> for MyFn {
17+
type Output = ();
18+
}
19+
20+
impl RequestFamily for String {
21+
type Type<'a> = String;
22+
}
23+
24+
struct ServiceFromAsyncFn<F, Req>(F, PhantomData<Req>);
25+
26+
impl<F, Req, O> Service for ServiceFromAsyncFn<F, Req>
27+
where
28+
Req: RequestFamily,
29+
F: AsyncFn<Req>,
30+
F: for<'a> AsyncFn<Req::Type<'a>, Output = O>,
31+
{
32+
}
33+
34+
fn assert_service() -> impl Service {
35+
ServiceFromAsyncFn(MyFn, PhantomData)
36+
}
37+
38+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// check-pass
2+
// compile-flags: -Ztrait-solver=next
3+
// Issue 108933
4+
5+
trait Add<Rhs> {
6+
type Sum;
7+
}
8+
9+
impl Add<()> for () {
10+
type Sum = ();
11+
}
12+
13+
type Unit = <() as Add<()>>::Sum;
14+
15+
trait Trait<C> {
16+
type Output;
17+
}
18+
19+
fn f<T>()
20+
where
21+
T: Trait<()>,
22+
<T as Trait<()>>::Output: Sized,
23+
{
24+
}
25+
26+
fn g<T>()
27+
where
28+
T: Trait<Unit>,
29+
<T as Trait<()>>::Output: Sized,
30+
{
31+
}
32+
33+
fn h<T>()
34+
where
35+
T: Trait<()>,
36+
<T as Trait<Unit>>::Output: Sized,
37+
{
38+
}
39+
40+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// check-pass
2+
// compile-flags: -Ztrait-solver=next
3+
// Issue 92505
4+
5+
trait A<T> {
6+
type I;
7+
8+
fn f()
9+
where
10+
Self::I: A<T>,
11+
{
12+
}
13+
}
14+
15+
impl<T> A<T> for () {
16+
type I = ();
17+
18+
fn f()
19+
where
20+
Self::I: A<T>,
21+
{
22+
<() as A<T>>::f();
23+
}
24+
}
25+
26+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// check-pass
2+
// compile-flags: -Ztrait-solver=next
3+
// Issue 100177
4+
5+
trait GenericTrait<T> {}
6+
7+
trait Channel<I>: GenericTrait<Self::T> {
8+
type T;
9+
}
10+
11+
trait Sender {
12+
type Msg;
13+
14+
fn send<C>()
15+
where
16+
C: Channel<Self::Msg>;
17+
}
18+
19+
impl<T> Sender for T {
20+
type Msg = ();
21+
22+
fn send<C>()
23+
where
24+
C: Channel<Self::Msg>,
25+
{
26+
}
27+
}
28+
29+
// This works
30+
fn foo<I, C>(ch: C) where C: Channel<I> {}
31+
32+
fn main() {}

0 commit comments

Comments
 (0)