File tree Expand file tree Collapse file tree 2 files changed +37
-1
lines changed
trunk/src/test/compile-fail Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: 63eb8e0e8784ad8cc126bf80a9267c30b4a3a82a
2
+ refs/heads/master: a6b9fa0cd1a6eb29a127e05d10910d8b8f194f59
3
3
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4
4
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5
5
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments