tests: move coherence-subtyping from run-pass to compile-fail

This is the pattern we no longer accept.
This commit is contained in:
Niko Matsakis 2018-10-30 16:39:29 -04:00
parent 652fd2efdf
commit 78705b5ec7
2 changed files with 33 additions and 1 deletions

View File

@ -1,4 +1,3 @@
// run-pass
// Test that two distinct impls which match subtypes of one another
// yield coherence errors (or not) depending on the variance.
@ -10,6 +9,7 @@ impl Contravariant for for<'a,'b> fn(&'a u8, &'b u8) -> &'a u8 {
}
impl Contravariant for for<'a> fn(&'a u8, &'a u8) -> &'a u8 {
//~^ ERROR
}
///////////////////////////////////////////////////////////////////////////
@ -22,6 +22,7 @@ impl Covariant for for<'a,'b> fn(&'a u8, &'b u8) -> &'a u8 {
}
impl Covariant for for<'a> fn(&'a u8, &'a u8) -> &'a u8 {
//~^ ERROR
}
///////////////////////////////////////////////////////////////////////////
@ -34,6 +35,7 @@ impl Invariant for for<'a,'b> fn(&'a u8, &'b u8) -> &'a u8 {
}
impl Invariant for for<'a> fn(&'a u8, &'a u8) -> &'a u8 {
//~^ ERROR
}
fn main() { }

View File

@ -0,0 +1,30 @@
error[E0119]: conflicting implementations of trait `Contravariant` for type `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8`:
--> $DIR/coherence-subtyping.rs:21:1
|
LL | impl Contravariant for for<'a,'b> fn(&'a u8, &'b u8) -> &'a u8 {
| -------------------------------------------------------------- first implementation here
...
LL | impl Contravariant for for<'a> fn(&'a u8, &'a u8) -> &'a u8 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8`
error[E0119]: conflicting implementations of trait `Covariant` for type `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8`:
--> $DIR/coherence-subtyping.rs:34:1
|
LL | impl Covariant for for<'a,'b> fn(&'a u8, &'b u8) -> &'a u8 {
| ---------------------------------------------------------- first implementation here
...
LL | impl Covariant for for<'a> fn(&'a u8, &'a u8) -> &'a u8 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8`
error[E0119]: conflicting implementations of trait `Invariant` for type `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8`:
--> $DIR/coherence-subtyping.rs:47:1
|
LL | impl Invariant for for<'a,'b> fn(&'a u8, &'b u8) -> &'a u8 {
| ---------------------------------------------------------- first implementation here
...
LL | impl Invariant for for<'a> fn(&'a u8, &'a u8) -> &'a u8 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8`
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0119`.