added a test case for reporting mismatched traits

This commit is contained in:
Ayrton 2020-07-23 20:21:28 -04:00
parent bae1e03109
commit b75ed4f61c
2 changed files with 30 additions and 0 deletions

View File

@ -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() {
}

View File

@ -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`.