about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAyrton <a.munoz3327@gmail.com>2020-07-23 20:21:28 -0400
committerAyrton <a.munoz3327@gmail.com>2020-07-23 20:21:28 -0400
commitb75ed4f61cb867388eb17280f3acd933fe933f26 (patch)
tree3da2afcd2e460c8345f34bb2882e4f05d894f3c2
parentbae1e03109bc6594763be26cfa78270917c0199a (diff)
downloadrust-b75ed4f61cb867388eb17280f3acd933fe933f26.tar.gz
rust-b75ed4f61cb867388eb17280f3acd933fe933f26.zip
added a test case for reporting mismatched traits
-rw-r--r--src/test/ui/error-codes/E0308-2.rs12
-rw-r--r--src/test/ui/error-codes/E0308-2.stderr18
2 files changed, 30 insertions, 0 deletions
diff --git a/src/test/ui/error-codes/E0308-2.rs b/src/test/ui/error-codes/E0308-2.rs
new file mode 100644
index 00000000000..157f992da99
--- /dev/null
+++ b/src/test/ui/error-codes/E0308-2.rs
@@ -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() {
+}
diff --git a/src/test/ui/error-codes/E0308-2.stderr b/src/test/ui/error-codes/E0308-2.stderr
new file mode 100644
index 00000000000..e7c5e4b4240
--- /dev/null
+++ b/src/test/ui/error-codes/E0308-2.stderr
@@ -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`.