summaryrefslogtreecommitdiffstats
path: root/src/test/ui/const-generics/generic_const_exprs/issue-72787.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/const-generics/generic_const_exprs/issue-72787.rs')
-rw-r--r--src/test/ui/const-generics/generic_const_exprs/issue-72787.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/generic_const_exprs/issue-72787.rs b/src/test/ui/const-generics/generic_const_exprs/issue-72787.rs
new file mode 100644
index 000000000..c651bf1c8
--- /dev/null
+++ b/src/test/ui/const-generics/generic_const_exprs/issue-72787.rs
@@ -0,0 +1,35 @@
+// [full] check-pass
+// revisions: full min
+#![cfg_attr(full, feature(generic_const_exprs))]
+#![cfg_attr(full, allow(incomplete_features))]
+
+pub struct IsLessOrEqual<const LHS: u32, const RHS: u32>;
+pub struct Condition<const CONDITION: bool>;
+pub trait True {}
+
+impl<const LHS: u32, const RHS: u32> True for IsLessOrEqual<LHS, RHS> where
+ Condition<{ LHS <= RHS }>: True
+//[min]~^ Error generic parameters may not be used in const operations
+//[min]~| Error generic parameters may not be used in const operations
+{
+}
+impl True for Condition<true> {}
+
+struct S<const I: u32, const J: u32>;
+impl<const I: u32, const J: u32> S<I, J>
+where
+ IsLessOrEqual<I, 8>: True,
+//[min]~^ Error type annotations needed
+//[min]~| Error type annotations needed
+ IsLessOrEqual<J, 8>: True,
+ IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
+//[min]~^ Error generic parameters may not be used in const operations
+//[min]~| Error generic parameters may not be used in const operations
+ // Condition<{ 8 - I <= 8 - J }>: True,
+{
+ fn print() {
+ println!("I {} J {}", I, J);
+ }
+}
+
+fn main() {}