Skip to content

Commit

Permalink
Add failing test that should pass
Browse files Browse the repository at this point in the history
  • Loading branch information
spastorino committed Feb 14, 2022
1 parent f4bb450 commit ff11dfd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/test/ui/coherence/coherence-negative-outlives-lifetimes.rs
@@ -0,0 +1,12 @@
#![feature(negative_impls)]

// FIXME: this should compile

trait MyPredicate<'a> {}
impl<'a, T> !MyPredicate<'a> for &T where T: 'a {}
trait MyTrait<'a> {}
impl<'a, T: MyPredicate<'a>> MyTrait<'a> for T {}
impl<'a, T> MyTrait<'a> for &'a T {}
//~^ ERROR: conflicting implementations of trait `MyTrait<'_>` for type `&_`

fn main() {}
11 changes: 11 additions & 0 deletions src/test/ui/coherence/coherence-negative-outlives-lifetimes.stderr
@@ -0,0 +1,11 @@
error[E0119]: conflicting implementations of trait `MyTrait<'_>` for type `&_`
--> $DIR/coherence-negative-outlives-lifetimes.rs:9:1
|
LL | impl<'a, T: MyPredicate<'a>> MyTrait<'a> for T {}
| ---------------------------------------------- first implementation here
LL | impl<'a, T> MyTrait<'a> for &'a T {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&_`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0119`.

0 comments on commit ff11dfd

Please sign in to comment.