summary refs log tree commit diff
path: root/src/test/run-pass/issue-54462-mutable-noalias-correctness.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-10-05 22:17:57 +0000
committerbors <bors@rust-lang.org>2018-10-05 22:17:57 +0000
commit17a9dc7513b9fea883dc9505f09f97c63d1d601b (patch)
tree34be1935d6ac0448637d6c95f751dbe7a33a83e7 /src/test/run-pass/issue-54462-mutable-noalias-correctness.rs
parentb801ae66425cf7c3c71052b19ef8f145b0d0513d (diff)
parenta154257c85fc109c19610b2c5fe25499e77ea9a7 (diff)
downloadrust-1.29.2.tar.gz
rust-1.29.2.zip
Auto merge of #54808 - pietroalbini:stable-1.29.2, r=alexcrichton 1.29.2
1.29.2 stable point release

This point release includes a backport of #54639 (a miscompilation) and the fix for #54206 (rls missing on windows-gnu). It also backports a release notes fix (#54150).

The target date for the release is Thursday 11th.

r? @Mark-Simulacrum
cc @rust-lang/core @rust-lang/release
Diffstat (limited to 'src/test/run-pass/issue-54462-mutable-noalias-correctness.rs')
-rw-r--r--src/test/run-pass/issue-54462-mutable-noalias-correctness.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/test/run-pass/issue-54462-mutable-noalias-correctness.rs b/src/test/run-pass/issue-54462-mutable-noalias-correctness.rs
new file mode 100644
index 00000000000..f0e52b29287
--- /dev/null
+++ b/src/test/run-pass/issue-54462-mutable-noalias-correctness.rs
@@ -0,0 +1,33 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+//
+// 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);
+}