Skip to content

Commit 045ec58

Browse files
committed
---
yaml --- r: 15784 b: refs/heads/try c: a6b9fa0 h: refs/heads/master v: v3
1 parent f09eaf2 commit 045ec58

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: 63eb8e0e8784ad8cc126bf80a9267c30b4a3a82a
5+
refs/heads/try: a6b9fa0cd1a6eb29a127e05d10910d8b8f194f59
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// compile-flags:--borrowck=err
2+
3+
// Here we check that it is allowed to lend out an element of a
4+
// (locally rooted) mutable, unique vector, and that we then prevent
5+
// modifications to the contents.
6+
7+
fn takes_imm_elt(_v: &int, f: fn()) {
8+
f();
9+
}
10+
11+
fn has_mut_vec_and_does_not_try_to_change_it() {
12+
let v = [mut 1, 2, 3];
13+
takes_imm_elt(&v[0]) {||
14+
}
15+
}
16+
17+
fn has_mut_vec_but_tries_to_change_it() {
18+
let v = [mut 1, 2, 3];
19+
takes_imm_elt(&v[0]) {|| //! NOTE loan of mutable vec content granted here
20+
v[1] = 4; //! ERROR assigning to mutable vec content prohibited due to outstanding loan
21+
}
22+
}
23+
24+
fn takes_const_elt(_v: &const int, f: fn()) {
25+
f();
26+
}
27+
28+
fn has_mut_vec_and_tries_to_change_it() {
29+
let v = [mut 1, 2, 3];
30+
takes_const_elt(&const v[0]) {||
31+
v[1] = 4;
32+
}
33+
}
34+
35+
fn main() {
36+
}

0 commit comments

Comments
 (0)