]> git.lizzy.rs Git - rust.git/commitdiff
Add a test for wrong assoc type diagnostics
authorXIAO Tian <tian@example.com>
Sat, 30 May 2020 03:28:33 +0000 (11:28 +0800)
committerXIAO Tian <tian@example.com>
Sun, 31 May 2020 04:13:30 +0000 (12:13 +0800)
src/test/ui/associated-types/issue-72806.rs [new file with mode: 0644]
src/test/ui/associated-types/issue-72806.stderr [new file with mode: 0644]

diff --git a/src/test/ui/associated-types/issue-72806.rs b/src/test/ui/associated-types/issue-72806.rs
new file mode 100644 (file)
index 0000000..ae63781
--- /dev/null
@@ -0,0 +1,20 @@
+trait Bar {
+    type Ok;
+    type Sibling: Bar2<Ok=char>;
+}
+trait Bar2 {
+    type Ok;
+}
+
+struct Foo;
+struct Foo2;
+
+impl Bar for Foo {  //~ ERROR type mismatch resolving `<Foo2 as Bar2>::Ok == char`
+    type Ok = ();
+    type Sibling = Foo2;
+}
+impl Bar2 for Foo2 {
+    type Ok = u32;
+}
+
+fn main() {}
diff --git a/src/test/ui/associated-types/issue-72806.stderr b/src/test/ui/associated-types/issue-72806.stderr
new file mode 100644 (file)
index 0000000..03a6565
--- /dev/null
@@ -0,0 +1,9 @@
+error[E0271]: type mismatch resolving `<Foo2 as Bar2>::Ok == char`
+  --> $DIR/issue-72806.rs:12:6
+   |
+LL | impl Bar for Foo {
+   |      ^^^ expected `u32`, found `char`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0271`.