Skip to content

Commit a5b926d

Browse files
committed
---
yaml --- r: 12778 b: refs/heads/master c: a6b9fa0 h: refs/heads/master v: v3
1 parent 14cfa04 commit a5b926d

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
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 63eb8e0e8784ad8cc126bf80a9267c30b4a3a82a
2+
refs/heads/master: a6b9fa0cd1a6eb29a127e05d10910d8b8f194f59
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf
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)