]> git.lizzy.rs Git - rust.git/commitdiff
added a test case for reporting mismatched traits
authorAyrton <a.munoz3327@gmail.com>
Fri, 24 Jul 2020 00:21:28 +0000 (20:21 -0400)
committerAyrton <a.munoz3327@gmail.com>
Fri, 24 Jul 2020 00:21:28 +0000 (20:21 -0400)
src/test/ui/error-codes/E0308-2.rs [new file with mode: 0644]
src/test/ui/error-codes/E0308-2.stderr [new file with mode: 0644]

diff --git a/src/test/ui/error-codes/E0308-2.rs b/src/test/ui/error-codes/E0308-2.rs
new file mode 100644 (file)
index 0000000..157f992
--- /dev/null
@@ -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 (file)
index 0000000..e7c5e4b
--- /dev/null
@@ -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`.