about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2015-08-01 12:31:24 +0530
committerManish Goregaokar <manishsmail@gmail.com>2015-08-01 14:05:52 +0530
commit548d552c7e7617711a3b71611e010ffe7d0d9fef (patch)
tree471817ed0de4e6eafbb94ee0647ae74175c1eb69 /src
parentae9abdf705f457edc1cd0a4a01e089dbfed0007d (diff)
parent6a86a0c89c932b971bc4e5846abcf54769d3b6b4 (diff)
Rollup merge of #27423 - oli-obk:patch-1, r=Gankro
Diffstat (limited to 'src')
-rw-r--r--src/doc/tarpl/borrow-splitting.md22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/doc/tarpl/borrow-splitting.md b/src/doc/tarpl/borrow-splitting.md
index da484385788..cc5bc8a602d 100644
--- a/src/doc/tarpl/borrow-splitting.md
+++ b/src/doc/tarpl/borrow-splitting.md
@@ -27,19 +27,27 @@ However borrowck doesn't understand arrays or slices in any way, so this doesn't
 work:
 
 ```rust,ignore
-let x = [1, 2, 3];
+let mut x = [1, 2, 3];
 let a = &mut x[0];
 let b = &mut x[1];
 println!("{} {}", a, b);
 ```
 
 ```text
-<anon>:3:18: 3:22 error: cannot borrow immutable indexed content `x[..]` as mutable
-<anon>:3     let a = &mut x[0];
-                          ^~~~
-<anon>:4:18: 4:22 error: cannot borrow immutable indexed content `x[..]` as mutable
-<anon>:4     let b = &mut x[1];
-                          ^~~~
+<anon>:4:14: 4:18 error: cannot borrow `x[..]` as mutable more than once at a time
+<anon>:4 let b = &mut x[1];
+                      ^~~~
+<anon>:3:14: 3:18 note: previous borrow of `x[..]` occurs here; the mutable borrow prevents subsequent moves, borrows, or modification of `x[..]` until the borrow ends
+<anon>:3 let a = &mut x[0];
+                      ^~~~
+<anon>:6:2: 6:2 note: previous borrow ends here
+<anon>:1 fn main() {
+<anon>:2 let mut x = [1, 2, 3];
+<anon>:3 let a = &mut x[0];
+<anon>:4 let b = &mut x[1];
+<anon>:5 println!("{} {}", a, b);
+<anon>:6 }
+         ^
 error: aborting due to 2 previous errors
 ```