about summary refs log tree commit diff
path: root/tests/ui/traits/const-traits/overlap-const-with-nonconst.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/traits/const-traits/overlap-const-with-nonconst.rs')
-rw-r--r--tests/ui/traits/const-traits/overlap-const-with-nonconst.rs38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/ui/traits/const-traits/overlap-const-with-nonconst.rs b/tests/ui/traits/const-traits/overlap-const-with-nonconst.rs
new file mode 100644
index 00000000000..eb66d03faa6
--- /dev/null
+++ b/tests/ui/traits/const-traits/overlap-const-with-nonconst.rs
@@ -0,0 +1,38 @@
+//@ revisions: spec min_spec
+
+#![feature(const_trait_impl)]
+#![cfg_attr(spec, feature(specialization))]
+//[spec]~^ WARN the feature `specialization` is incomplete
+#![cfg_attr(min_spec, feature(min_specialization))]
+
+#[const_trait]
+trait Bar {}
+impl<T> const Bar for T {}
+
+#[const_trait]
+trait Foo {
+    fn method(&self);
+}
+impl<T> const Foo for T
+where
+    T: ~const Bar,
+{
+    default fn method(&self) {}
+}
+// specializing impl:
+impl<T> Foo for (T,) {
+//~^ ERROR conflicting implementations
+    fn method(&self) {
+        println!("hi");
+    }
+}
+
+const fn dispatch<T: ~const Bar + Copy>(t: T) {
+    t.method();
+}
+
+fn main() {
+    const {
+        dispatch(((),));
+    }
+}