added a test case for reporting mismatched traits
This commit is contained in:
parent
bae1e03109
commit
b75ed4f61c
12
src/test/ui/error-codes/E0308-2.rs
Normal file
12
src/test/ui/error-codes/E0308-2.rs
Normal 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() {
|
||||
}
|
18
src/test/ui/error-codes/E0308-2.stderr
Normal file
18
src/test/ui/error-codes/E0308-2.stderr
Normal 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`.
|
Loading…
Reference in New Issue
Block a user