Skip to content

Commit 2017214

Browse files
committed
add winnowing tests
1 parent 9ba3d31 commit 2017214

6 files changed

+127
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// A regression test for an edge case of candidate selection
2+
// in the old trait solver, see #124592 for more details.
3+
4+
//@ revisions: current next
5+
//@ ignore-compare-mode-next-solver (explicit revisions)
6+
//@[next] compile-flags: -Znext-solver
7+
//@ check-pass
8+
9+
trait Trait<T> {}
10+
impl<T> Trait<T> for () {}
11+
12+
fn impls_trait<T: Trait<U>, U>(_: T) -> U { todo!() }
13+
fn foo<T>() -> u32
14+
where
15+
(): Trait<u32>,
16+
(): Trait<T>,
17+
{
18+
impls_trait(())
19+
}
20+
21+
fn main() {}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/global-non-global-env-2.rs:20:5
3+
|
4+
LL | fn foo<T>() -> u32
5+
| - --- expected `u32` because of return type
6+
| |
7+
| found this type parameter
8+
...
9+
LL | impls_trait(())
10+
| ^^^^^^^^^^^^^^^ expected `u32`, found type parameter `T`
11+
|
12+
= note: expected type `u32`
13+
found type parameter `T`
14+
15+
error: aborting due to 1 previous error
16+
17+
For more information about this error, try `rustc --explain E0308`.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// A regression test for an edge case of candidate selection
2+
// in the old trait solver, see #124592 for more details. Unlike
3+
// the first test, this one has two impl candidates.
4+
5+
//@ revisions: current next
6+
//@ ignore-compare-mode-next-solver (explicit revisions)
7+
//@[next] compile-flags: -Znext-solver
8+
//@[next] check-pass
9+
10+
trait Trait<T> {}
11+
impl Trait<u32> for () {}
12+
impl Trait<u64> for () {}
13+
14+
fn impls_trait<T: Trait<U>, U>(_: T) -> U { todo!() }
15+
fn foo<T>() -> u32
16+
where
17+
(): Trait<u32>,
18+
(): Trait<T>,
19+
{
20+
impls_trait(())
21+
//[current]~^ ERROR mismatched types
22+
}
23+
24+
fn main() {}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// A regression test for an edge case of candidate selection
2+
// in the old trait solver, see #124592 for more details. Unlike
3+
// the second test, the where-bounds are in a different order.
4+
5+
//@ revisions: current next
6+
//@ ignore-compare-mode-next-solver (explicit revisions)
7+
//@[next] compile-flags: -Znext-solver
8+
//@ check-pass
9+
10+
trait Trait<T> {}
11+
impl Trait<u32> for () {}
12+
impl Trait<u64> for () {}
13+
14+
fn impls_trait<T: Trait<U>, U>(_: T) -> U { todo!() }
15+
fn foo<T>() -> u32
16+
where
17+
(): Trait<T>,
18+
(): Trait<u32>,
19+
{
20+
impls_trait(())
21+
}
22+
23+
fn main() {}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/global-non-global-env-4.rs:21:5
3+
|
4+
LL | fn foo<T>() -> u32
5+
| - --- expected `u32` because of return type
6+
| |
7+
| found this type parameter
8+
...
9+
LL | impls_trait(())
10+
| ^^^^^^^^^^^^^^^ expected `u32`, found type parameter `T`
11+
|
12+
= note: expected type `u32`
13+
found type parameter `T`
14+
15+
error: aborting due to 1 previous error
16+
17+
For more information about this error, try `rustc --explain E0308`.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// A regression test for an edge case of candidate selection
2+
// in the old trait solver, see #124592 for more details. Unlike
3+
// the third test, this one has 3 impl candidates.
4+
5+
//@ revisions: current next
6+
//@ ignore-compare-mode-next-solver (explicit revisions)
7+
//@[next] compile-flags: -Znext-solver
8+
//@[next] check-pass
9+
10+
trait Trait<T> {}
11+
impl Trait<u32> for () {}
12+
impl Trait<u64> for () {}
13+
impl Trait<u128> for () {}
14+
15+
fn impls_trait<T: Trait<U>, U>(_: T) -> U { todo!() }
16+
fn foo<T>() -> u32
17+
where
18+
(): Trait<T>,
19+
(): Trait<u32>,
20+
{
21+
impls_trait(())
22+
//[current]~^ ERROR mismatched types
23+
}
24+
25+
fn main() {}

0 commit comments

Comments
 (0)