Skip to content

Commit b75ed4f

Browse files
committed
added a test case for reporting mismatched traits
1 parent bae1e03 commit b75ed4f

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/test/ui/error-codes/E0308-2.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
trait DynEq {}
2+
3+
impl<'a> PartialEq for &'a (dyn DynEq + 'static) {
4+
fn eq(&self, _other: &Self) -> bool {
5+
true
6+
}
7+
}
8+
9+
impl Eq for &dyn DynEq {} //~ ERROR E0308
10+
11+
fn main() {
12+
}
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/E0308-2.rs:9:6
3+
|
4+
LL | impl Eq for &dyn DynEq {}
5+
| ^^ lifetime mismatch
6+
|
7+
= note: expected trait `std::cmp::PartialEq`
8+
found trait `std::cmp::PartialEq`
9+
note: the lifetime `'_` as defined on the impl at 9:13...
10+
--> $DIR/E0308-2.rs:9:13
11+
|
12+
LL | impl Eq for &dyn DynEq {}
13+
| ^
14+
= note: ...does not necessarily outlive the static lifetime
15+
16+
error: aborting due to previous error
17+
18+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)