Skip to content

Commit 93fe285

Browse files
committed
---
yaml --- r: 58331 b: refs/heads/auto c: d43d3e5 h: refs/heads/master i: 58329: ebcc812 58327: 62bf04d v: v3
1 parent 4f62af9 commit 93fe285

File tree

3 files changed

+63
-1
lines changed

3 files changed

+63
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: 842e304ab505f6c0d8f6b29ec3c0dfa8dc9e1aac
17+
refs/heads/auto: d43d3e538c42798db0706983ba7696b44f6764eb
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1919
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// error-pattern:borrowed
2+
3+
// Issue #6272. Tests that freezing correctly accounts for all the
4+
// implicit derefs that can occur and freezes the innermost box. See
5+
// the companion test
6+
//
7+
// run-pass/borrowck-wg-autoderef-and-autoborrowvec-combined-issue-6272.rs
8+
//
9+
// for a detailed explanation of what is going on here.
10+
11+
fn main() {
12+
let a = @mut [3i];
13+
let b = @mut [a];
14+
let c = @mut b;
15+
16+
// this should freeze `a` only
17+
let x: &mut [int] = c[0];
18+
19+
// hence this should fail
20+
a[0] = a[0];
21+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Issue #6272. Tests that freezing correctly accounts for all the
2+
// implicit derefs that can occur.
3+
//
4+
// In this particular case, the expression:
5+
//
6+
// let x: &mut [int] = c[0];
7+
//
8+
// is seen by borrowck as this sequence of derefs
9+
// and pointer offsets:
10+
//
11+
// &*((**c)[0])
12+
//
13+
// or, written using `x.*` for `*x` (so that everything
14+
// is a postfix operation):
15+
//
16+
// &c.*.*.[0].*
17+
// ^ ^
18+
// | |
19+
// b a
20+
//
21+
// Here I also indicated where the evaluation yields the boxes `a` and
22+
// `b`. It is important then that we only freeze the innermost box
23+
// (`a`), and not the other ones (`b`, `c`).
24+
//
25+
// Also see the companion test:
26+
//
27+
// run-fail/borrowck-wg-autoderef-and-autoborrowvec-combined-fail-issue-6272.rs
28+
29+
30+
fn main() {
31+
let a = @mut [3i];
32+
let b = @mut [a];
33+
let c = @mut b;
34+
35+
// this should freeze `a` only
36+
let _x: &mut [int] = c[0];
37+
38+
// hence these writes should not fail:
39+
b[0] = b[0];
40+
c[0] = c[0];
41+
}

0 commit comments

Comments
 (0)