Skip to content

Commit 78705b5

Browse files
committed
tests: move coherence-subtyping from run-pass to compile-fail
This is the pattern we no longer accept.
1 parent 652fd2e commit 78705b5

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

src/test/run-pass/coherence/coherence-subtyping.rs renamed to src/test/ui/coherence/coherence-subtyping.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// run-pass
21
// Test that two distinct impls which match subtypes of one another
32
// yield coherence errors (or not) depending on the variance.
43

@@ -10,6 +9,7 @@ impl Contravariant for for<'a,'b> fn(&'a u8, &'b u8) -> &'a u8 {
109
}
1110

1211
impl Contravariant for for<'a> fn(&'a u8, &'a u8) -> &'a u8 {
12+
//~^ ERROR
1313
}
1414

1515
///////////////////////////////////////////////////////////////////////////
@@ -22,6 +22,7 @@ impl Covariant for for<'a,'b> fn(&'a u8, &'b u8) -> &'a u8 {
2222
}
2323

2424
impl Covariant for for<'a> fn(&'a u8, &'a u8) -> &'a u8 {
25+
//~^ ERROR
2526
}
2627

2728
///////////////////////////////////////////////////////////////////////////
@@ -34,6 +35,7 @@ impl Invariant for for<'a,'b> fn(&'a u8, &'b u8) -> &'a u8 {
3435
}
3536

3637
impl Invariant for for<'a> fn(&'a u8, &'a u8) -> &'a u8 {
38+
//~^ ERROR
3739
}
3840

3941
fn main() { }
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
error[E0119]: conflicting implementations of trait `Contravariant` for type `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8`:
2+
--> $DIR/coherence-subtyping.rs:21:1
3+
|
4+
LL | impl Contravariant for for<'a,'b> fn(&'a u8, &'b u8) -> &'a u8 {
5+
| -------------------------------------------------------------- first implementation here
6+
...
7+
LL | impl Contravariant for for<'a> fn(&'a u8, &'a u8) -> &'a u8 {
8+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8`
9+
10+
error[E0119]: conflicting implementations of trait `Covariant` for type `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8`:
11+
--> $DIR/coherence-subtyping.rs:34:1
12+
|
13+
LL | impl Covariant for for<'a,'b> fn(&'a u8, &'b u8) -> &'a u8 {
14+
| ---------------------------------------------------------- first implementation here
15+
...
16+
LL | impl Covariant for for<'a> fn(&'a u8, &'a u8) -> &'a u8 {
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8`
18+
19+
error[E0119]: conflicting implementations of trait `Invariant` for type `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8`:
20+
--> $DIR/coherence-subtyping.rs:47:1
21+
|
22+
LL | impl Invariant for for<'a,'b> fn(&'a u8, &'b u8) -> &'a u8 {
23+
| ---------------------------------------------------------- first implementation here
24+
...
25+
LL | impl Invariant for for<'a> fn(&'a u8, &'a u8) -> &'a u8 {
26+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8`
27+
28+
error: aborting due to 3 previous errors
29+
30+
For more information about this error, try `rustc --explain E0119`.

0 commit comments

Comments
 (0)