summaryrefslogtreecommitdiffstats
path: root/src/test/ui/const-generics/generic_const_exprs/fn_call.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/const-generics/generic_const_exprs/fn_call.rs')
-rw-r--r--src/test/ui/const-generics/generic_const_exprs/fn_call.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/generic_const_exprs/fn_call.rs b/src/test/ui/const-generics/generic_const_exprs/fn_call.rs
new file mode 100644
index 000000000..cbe4277df
--- /dev/null
+++ b/src/test/ui/const-generics/generic_const_exprs/fn_call.rs
@@ -0,0 +1,30 @@
+// run-pass
+#![feature(generic_const_exprs)]
+#![allow(incomplete_features)]
+
+const fn test_me<T>(a: usize, b: usize) -> usize {
+ if a < b {
+ std::mem::size_of::<T>()
+ } else {
+ usize::MAX
+ }
+}
+
+fn test_simple<T>() -> [u8; std::mem::size_of::<T>()]
+where
+ [u8; std::mem::size_of::<T>()]: Sized,
+{
+ [0; std::mem::size_of::<T>()]
+}
+
+fn test_with_args<T, const N: usize>() -> [u8; test_me::<T>(N, N + 1) + N]
+where
+ [u8; test_me::<T>(N, N + 1) + N]: Sized,
+{
+ [0; test_me::<T>(N, N + 1) + N]
+}
+
+fn main() {
+ assert_eq!([0; 8], test_simple::<u64>());
+ assert_eq!([0; 12], test_with_args::<u64, 4>());
+}