summaryrefslogtreecommitdiffstats
path: root/tests/rust/const_generics_thru.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/rust/const_generics_thru.rs')
-rw-r--r--tests/rust/const_generics_thru.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/rust/const_generics_thru.rs b/tests/rust/const_generics_thru.rs
new file mode 100644
index 0000000..51b279c
--- /dev/null
+++ b/tests/rust/const_generics_thru.rs
@@ -0,0 +1,22 @@
+// Propagating const arguments through generics that use generics.
+
+#[repr(C)]
+pub struct Inner<const N: usize> {
+ pub bytes: [u8; N],
+}
+
+#[repr(C)]
+pub struct Outer<const N: usize> {
+ pub inner: Inner<N>, // don't declare two different structs named `Inner_N`
+}
+
+#[no_mangle]
+pub extern "C" fn one() -> Outer<1> {
+ Outer { inner: Inner { bytes: [0] } }
+}
+
+#[no_mangle]
+pub extern "C" fn two() -> Outer<2> {
+ Outer { inner: Inner { bytes: [0, 0] } }
+}
+