Skip to content

Commit c69dea9

Browse files
committed
add tests for issue 135671
1 parent 122a55b commit c69dea9

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// This is a regression test for issue #135671 where a MIR refactor about arrays and their lengths
2+
// unexpectedly caused borrowck errors for disjoint borrows of array elements, for which we had no
3+
// tests. This is a collection of a few code samples from that issue.
4+
5+
//@ check-pass
6+
7+
struct Test {
8+
a: i32,
9+
b: i32,
10+
}
11+
12+
fn one() {
13+
let inputs: &mut [_] = &mut [Test { a: 0, b: 0 }];
14+
let a = &mut inputs[0].a;
15+
let b = &mut inputs[0].b;
16+
17+
*a = 0;
18+
*b = 1;
19+
}
20+
21+
fn two() {
22+
let slice = &mut [(0, 0)][..];
23+
std::mem::swap(&mut slice[0].0, &mut slice[0].1);
24+
}
25+
26+
fn three(a: &mut [(i32, i32)], i: usize, j: usize) -> (&mut i32, &mut i32) {
27+
(&mut a[i].0, &mut a[j].1)
28+
}
29+
30+
fn main() {}

0 commit comments

Comments
 (0)