Skip to content

Commit

Permalink
added a test case for reporting mismatched traits
Browse files Browse the repository at this point in the history
  • Loading branch information
ayrtonm committed Jul 24, 2020
1 parent bae1e03 commit b75ed4f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/test/ui/error-codes/E0308-2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
trait DynEq {}

impl<'a> PartialEq for &'a (dyn DynEq + 'static) {
fn eq(&self, _other: &Self) -> bool {
true
}
}

impl Eq for &dyn DynEq {} //~ ERROR E0308

fn main() {
}
18 changes: 18 additions & 0 deletions src/test/ui/error-codes/E0308-2.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
error[E0308]: mismatched types
--> $DIR/E0308-2.rs:9:6
|
LL | impl Eq for &dyn DynEq {}
| ^^ lifetime mismatch
|
= note: expected trait `std::cmp::PartialEq`
found trait `std::cmp::PartialEq`
note: the lifetime `'_` as defined on the impl at 9:13...
--> $DIR/E0308-2.rs:9:13
|
LL | impl Eq for &dyn DynEq {}
| ^
= note: ...does not necessarily outlive the static lifetime

error: aborting due to previous error

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

0 comments on commit b75ed4f

Please sign in to comment.