Skip to content

Commit ef7071d

Browse files
committed
add tests for pyella regression
1 parent d361fb6 commit ef7071d

7 files changed

+121
-0
lines changed
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Added in #124532. While `(): Super` is knowable, `(): Sub<?t>` is not.
2+
//
3+
// We therefore elaborate super trait bounds in the implicit negative
4+
// overlap check.
5+
6+
trait Super {}
7+
trait Sub<T>: Super {}
8+
9+
trait Overlap<T> {}
10+
impl<T, U: Sub<T>> Overlap<T> for U {}
11+
impl<T> Overlap<T> for () {}
12+
//~^ ERROR conflicting implementations of trait `Overlap<_>` for type `()`
13+
14+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error[E0119]: conflicting implementations of trait `Overlap<_>` for type `()`
2+
--> $DIR/super-trait-knowable-1.rs:11:1
3+
|
4+
LL | impl<T, U: Sub<T>> Overlap<T> for U {}
5+
| ----------------------------------- first implementation here
6+
LL | impl<T> Overlap<T> for () {}
7+
| ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `()`
8+
|
9+
= note: downstream crates may implement trait `Sub<_>` for type `()`
10+
11+
error: aborting due to 1 previous error
12+
13+
For more information about this error, try `rustc --explain E0119`.
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// A regression test for pyella-0.1.5 which broke when
2+
// enabling the new solver in coherence.
3+
//
4+
// `Tensor: TensorValue` is knowable while `Tensor: TensorOp<?t2>`
5+
// may be implemented downstream. We previously didn't check the
6+
// super trait bound in coherence, causing these impls to overlap.
7+
//
8+
// However, we did fail to normalize `<Tensor as TensorValue::Unmasked`
9+
// which caused the old solver to emit a `Tensor: TensorValue` goal in
10+
// `fn normalize_to_error` which then failed, causing this test to pass.
11+
12+
pub trait TensorValue {
13+
type Unmasked;
14+
}
15+
16+
trait TensorCompare<T> {}
17+
pub trait TensorOp<T>: TensorValue {}
18+
19+
pub struct Tensor;
20+
impl<T2> TensorCompare<T2> for Tensor {}
21+
impl<T1, T2> TensorCompare<T2> for T1
22+
//~^ ERROR conflicting implementations
23+
where
24+
T1: TensorOp<T2>,
25+
T1::Unmasked: Sized,
26+
{}
27+
28+
29+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0119]: conflicting implementations of trait `TensorCompare<_>` for type `Tensor`
2+
--> $DIR/super-trait-knowable-2.rs:21:1
3+
|
4+
LL | impl<T2> TensorCompare<T2> for Tensor {}
5+
| ------------------------------------- first implementation here
6+
LL | / impl<T1, T2> TensorCompare<T2> for T1
7+
LL | |
8+
LL | | where
9+
LL | | T1: TensorOp<T2>,
10+
LL | | T1::Unmasked: Sized,
11+
| |________________________^ conflicting implementation for `Tensor`
12+
|
13+
= note: downstream crates may implement trait `TensorOp<_>` for type `Tensor`
14+
15+
error: aborting due to 1 previous error
16+
17+
For more information about this error, try `rustc --explain E0119`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error[E0119]: conflicting implementations of trait `Overlap<_>` for type `()`
2+
--> $DIR/super-trait-knowable-nested.rs:19:1
3+
|
4+
LL | impl<T, U: Bound<T>> Overlap<T> for U {}
5+
| ------------------------------------- first implementation here
6+
LL | impl<T> Overlap<T> for () {}
7+
| ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `()`
8+
|
9+
= note: downstream crates may implement trait `Bound<_>` for type `()`
10+
11+
error: aborting due to 1 previous error
12+
13+
For more information about this error, try `rustc --explain E0119`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error[E0119]: conflicting implementations of trait `Overlap<_>` for type `()`
2+
--> $DIR/super-trait-knowable-nested.rs:19:1
3+
|
4+
LL | impl<T, U: Bound<T>> Overlap<T> for U {}
5+
| ------------------------------------- first implementation here
6+
LL | impl<T> Overlap<T> for () {}
7+
| ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `()`
8+
|
9+
= note: downstream crates may implement trait `Bound<_>` for type `()`
10+
11+
error: aborting due to 1 previous error
12+
13+
For more information about this error, try `rustc --explain E0119`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Unlike in `super-trait-knowable-1.rs`, the knowable
2+
// super trait bound is in a nested goal and we currently
3+
// only elaborate in the root. This can, and should, be#
4+
// changed in the future.
5+
6+
//@ revisions: current next
7+
//@ ignore-compare-mode-next-solver (explicit revisions)
8+
//@[next] compile-flags: -Znext-solver
9+
10+
trait Super {}
11+
trait Sub<T>: Super {}
12+
13+
trait Bound<T> {}
14+
15+
impl<T: Sub<T>, U> Bound<U> for T {}
16+
17+
trait Overlap<T> {}
18+
impl<T, U: Bound<T>> Overlap<T> for U {}
19+
impl<T> Overlap<T> for () {}
20+
//~^ ERROR conflicting implementations of trait `Overlap<_>` for type `()`
21+
22+
fn main() {}

0 commit comments

Comments
 (0)