]> git.lizzy.rs Git - rust.git/commitdiff
Add regression test for #26681
authorJonas Schievink <jonasschievink@gmail.com>
Sat, 14 Sep 2019 23:15:22 +0000 (01:15 +0200)
committerJonas Schievink <jonasschievink@gmail.com>
Fri, 21 Feb 2020 18:41:22 +0000 (19:41 +0100)
src/test/ui/associated-types/issue-26681.rs [new file with mode: 0644]
src/test/ui/associated-types/issue-26681.stderr [new file with mode: 0644]

diff --git a/src/test/ui/associated-types/issue-26681.rs b/src/test/ui/associated-types/issue-26681.rs
new file mode 100644 (file)
index 0000000..a0a8c86
--- /dev/null
@@ -0,0 +1,20 @@
+#![feature(associated_type_defaults)]
+
+// This is a partial regression test for #26681, which used to fail to resolve
+// `Self` in the assoc. constant, and now fails with a type mismatch because
+// `Self::Fv` cannot be assumed to equal `u8` inside the trait.
+
+trait Foo {
+    type Bar;
+}
+
+impl Foo for u8 {
+    type Bar = ();
+}
+
+trait Baz {
+    type Fv: Foo = u8;
+    const C: <Self::Fv as Foo>::Bar = 6665;  //~ error: mismatched types
+}
+
+fn main() {}
diff --git a/src/test/ui/associated-types/issue-26681.stderr b/src/test/ui/associated-types/issue-26681.stderr
new file mode 100644 (file)
index 0000000..27175a2
--- /dev/null
@@ -0,0 +1,12 @@
+error[E0308]: mismatched types
+  --> $DIR/issue-26681.rs:17:39
+   |
+LL |     const C: <Self::Fv as Foo>::Bar = 6665;
+   |                                       ^^^^ expected associated type, found integer
+   |
+   = note: expected type `<<Self as Baz>::Fv as Foo>::Bar`
+              found type `{integer}`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.