forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added a test case for reporting mismatched traits
- Loading branch information
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`. |