about summary refs log tree commit diff
diff options
context:
space:
mode:
authorwhtahy <whtahy@users.noreply.github.com>2023-04-26 21:47:31 -0400
committerwhtahy <whtahy@users.noreply.github.com>2023-04-26 22:34:39 -0400
commitfcf8468efc7cab2f66372baf9bb28131de444f86 (patch)
tree36f346c72162a17d122d90a9dd4dd264c30f6308
parent21b9f5c3bb55a8be44fe277891dd1c77fd6ca782 (diff)
downloadrust-fcf8468efc7cab2f66372baf9bb28131de444f86.tar.gz
rust-fcf8468efc7cab2f66372baf9bb28131de444f86.zip
add known-bug test for unsound issue 105782
-rw-r--r--tests/ui/specialization/specialization-default-items-drop-coherence.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/ui/specialization/specialization-default-items-drop-coherence.rs b/tests/ui/specialization/specialization-default-items-drop-coherence.rs
new file mode 100644
index 00000000000..16ad942d5ab
--- /dev/null
+++ b/tests/ui/specialization/specialization-default-items-drop-coherence.rs
@@ -0,0 +1,30 @@
+// check-pass
+// known-bug: #105782
+
+// Should fail. Default items completely drop candidates instead of ambiguity,
+// which is unsound during coherence, since coherence requires completeness.
+
+#![feature(specialization)]
+#![allow(incomplete_features)]
+
+trait Default {
+   type Id;
+}
+
+impl<T> Default for T {
+   default type Id = T;
+}
+
+trait Overlap {
+   type Assoc;
+}
+
+impl Overlap for u32 {
+   type Assoc = usize;
+}
+
+impl Overlap for <u32 as Default>::Id {
+   type Assoc = Box<usize>;
+}
+
+fn main() {}