summaryrefslogtreecommitdiffstats
path: root/tests/ui/generic-const-items/unsatisfied-bounds.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/generic-const-items/unsatisfied-bounds.rs')
-rw-r--r--tests/ui/generic-const-items/unsatisfied-bounds.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/ui/generic-const-items/unsatisfied-bounds.rs b/tests/ui/generic-const-items/unsatisfied-bounds.rs
new file mode 100644
index 000000000..058799001
--- /dev/null
+++ b/tests/ui/generic-const-items/unsatisfied-bounds.rs
@@ -0,0 +1,34 @@
+#![feature(generic_const_items)]
+#![allow(incomplete_features)]
+
+// Ensure that we check if bounds on const items hold or not.
+
+use std::convert::Infallible;
+
+const C<T: Copy>: () = ();
+
+const K<T>: () = ()
+where
+ Infallible: From<T>;
+
+trait Trait<P> {
+ const A: u32
+ where
+ P: Copy;
+
+ const B<T>: u32
+ where
+ Infallible: From<T>;
+}
+
+impl<P> Trait<P> for () {
+ const A: u32 = 0;
+ const B<T>: u32 = 1;
+}
+
+fn main() {
+ let () = C::<String>; //~ ERROR the trait bound `String: Copy` is not satisfied
+ let () = K::<()>; //~ ERROR the trait bound `Infallible: From<()>` is not satisfied
+ let _ = <() as Trait<Vec<u8>>>::A; //~ ERROR the trait bound `Vec<u8>: Copy` is not satisfied
+ let _ = <() as Trait<&'static str>>::B::<()>; //~ ERROR the trait bound `Infallible: From<()>` is not satisfied
+}