]> git.lizzy.rs Git - rust.git/commitdiff
Add a test
authorJonas Schievink <jonasschievink@gmail.com>
Sun, 29 Mar 2020 00:01:32 +0000 (01:01 +0100)
committerJonas Schievink <jonasschievink@gmail.com>
Mon, 30 Mar 2020 17:44:21 +0000 (19:44 +0200)
src/test/ui/specialization/issue-70442.rs [new file with mode: 0644]

diff --git a/src/test/ui/specialization/issue-70442.rs b/src/test/ui/specialization/issue-70442.rs
new file mode 100644 (file)
index 0000000..4371dd2
--- /dev/null
@@ -0,0 +1,23 @@
+#![feature(specialization)]
+
+// check-pass
+
+trait Trait {
+    type Assoc;
+}
+
+impl<T> Trait for T {
+    default type Assoc = bool;
+}
+
+// This impl inherits the `Assoc` definition from above and "locks it in", or finalizes it, making
+// child impls unable to further specialize it. However, since the specialization graph didn't
+// correctly track this, we would refuse to project `Assoc` from this impl, even though that should
+// happen for items that are final.
+impl Trait for () {}
+
+fn foo<X: Trait<Assoc=bool>>() {}
+
+fn main() {
+    foo::<()>();  // `<() as Trait>::Assoc` is normalized to `bool` correctly
+}