about summary refs log tree commit diff
path: root/tests/ui/codegen
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/codegen')
-rw-r--r--tests/ui/codegen/indirect-nocapture.rs15
-rw-r--r--tests/ui/codegen/matrix-row-swap-54462.rs26
-rw-r--r--tests/ui/codegen/static-array-comparison-7012.rs23
3 files changed, 64 insertions, 0 deletions
diff --git a/tests/ui/codegen/indirect-nocapture.rs b/tests/ui/codegen/indirect-nocapture.rs
new file mode 100644
index 00000000000..78024a94c0d
--- /dev/null
+++ b/tests/ui/codegen/indirect-nocapture.rs
@@ -0,0 +1,15 @@
+// Regression test for issue #137668 where an indirect argument have been marked as nocapture
+// despite the fact that callee did in fact capture the address.
+//
+//@ run-pass
+//@ compile-flags: -Copt-level=2
+
+#[inline(never)]
+pub fn f(a: [u32; 64], b: [u32; 64]) -> bool {
+    &a as *const _ as usize != &b as *const _ as usize
+}
+
+fn main() {
+    static S: [u32; 64] = [0; 64];
+    assert!(f(S, S));
+}
diff --git a/tests/ui/codegen/matrix-row-swap-54462.rs b/tests/ui/codegen/matrix-row-swap-54462.rs
new file mode 100644
index 00000000000..6bfc600399a
--- /dev/null
+++ b/tests/ui/codegen/matrix-row-swap-54462.rs
@@ -0,0 +1,26 @@
+// https://github.com/rust-lang/rust/issues/54462
+//@ run-pass
+//
+//@ compile-flags: -Ccodegen-units=1 -O
+
+fn linidx(row: usize, col: usize) -> usize {
+    row * 1 + col * 3
+}
+
+fn main() {
+    let mut mat = [1.0f32, 5.0, 9.0, 2.0, 6.0, 10.0, 3.0, 7.0, 11.0, 4.0, 8.0, 12.0];
+
+    for i in 0..2 {
+        for j in i+1..3 {
+            if mat[linidx(j, 3)] > mat[linidx(i, 3)] {
+                    for k in 0..4 {
+                            let (x, rest) = mat.split_at_mut(linidx(i, k) + 1);
+                            let a = x.last_mut().unwrap();
+                            let b = rest.get_mut(linidx(j, k) - linidx(i, k) - 1).unwrap();
+                            ::std::mem::swap(a, b);
+                    }
+            }
+        }
+    }
+    assert_eq!([9.0, 5.0, 1.0, 10.0, 6.0, 2.0, 11.0, 7.0, 3.0, 12.0, 8.0, 4.0], mat);
+}
diff --git a/tests/ui/codegen/static-array-comparison-7012.rs b/tests/ui/codegen/static-array-comparison-7012.rs
new file mode 100644
index 00000000000..c08b1c0059b
--- /dev/null
+++ b/tests/ui/codegen/static-array-comparison-7012.rs
@@ -0,0 +1,23 @@
+// https://github.com/rust-lang/rust/issues/7012
+//@ run-pass
+#![allow(non_camel_case_types)]
+#![allow(non_upper_case_globals)]
+
+/*
+# Comparison of static arrays
+
+The expected behaviour would be that `test == test1`, therefore 'true'
+would be printed, however the below prints false.
+*/
+
+struct signature<'a> { pattern : &'a [u32] }
+
+static test1: signature<'static> =  signature {
+  pattern: &[0x243f6a88,0x85a308d3,0x13198a2e,0x03707344,0xa4093822,0x299f31d0]
+};
+
+pub fn main() {
+  let test: &[u32] = &[0x243f6a88,0x85a308d3,0x13198a2e,
+                       0x03707344,0xa4093822,0x299f31d0];
+  println!("{}",test==test1.pattern);
+}