about summary refs log tree commit diff
path: root/src/test/ui/const-generics/mut-ref-const-param-array.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/const-generics/mut-ref-const-param-array.rs')
-rw-r--r--src/test/ui/const-generics/mut-ref-const-param-array.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/mut-ref-const-param-array.rs b/src/test/ui/const-generics/mut-ref-const-param-array.rs
new file mode 100644
index 00000000000..f930fb87963
--- /dev/null
+++ b/src/test/ui/const-generics/mut-ref-const-param-array.rs
@@ -0,0 +1,19 @@
+// run-pass
+
+#![feature(const_generics)]
+//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
+
+use std::ops::AddAssign;
+
+fn inc<T: AddAssign + Clone, const N: usize>(v: &mut [T; N]) -> &mut [T; N] {
+    for x in v.iter_mut() {
+        *x += x.clone();
+    }
+    v
+}
+
+fn main() {
+    let mut v = [1, 2, 3];
+    inc(&mut v);
+    assert_eq!(v, [2, 4, 6]);
+}