about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJonas Schievink <jonasschievink@gmail.com>2019-09-15 01:15:22 +0200
committerJonas Schievink <jonasschievink@gmail.com>2020-02-21 19:41:22 +0100
commitfd28614cb799b762880b25b976760ddd0c530e92 (patch)
treef4c1dbcdc3162fe6abe8b6fb02669ed06b526e36
parent1f61f36849249b5333c74f63d54d2f8bfe30ad59 (diff)
downloadrust-fd28614cb799b762880b25b976760ddd0c530e92.tar.gz
rust-fd28614cb799b762880b25b976760ddd0c530e92.zip
Add regression test for #26681
-rw-r--r--src/test/ui/associated-types/issue-26681.rs20
-rw-r--r--src/test/ui/associated-types/issue-26681.stderr12
2 files changed, 32 insertions, 0 deletions
diff --git a/src/test/ui/associated-types/issue-26681.rs b/src/test/ui/associated-types/issue-26681.rs
new file mode 100644
index 00000000000..a0a8c86d949
--- /dev/null
+++ b/src/test/ui/associated-types/issue-26681.rs
@@ -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
index 00000000000..27175a247fa
--- /dev/null
+++ b/src/test/ui/associated-types/issue-26681.stderr
@@ -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`.