From 6a86a0c89c932b971bc4e5846abcf54769d3b6b4 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Fri, 31 Jul 2015 09:32:53 +0200 Subject: [PATCH] fix code and error to match the surronding text --- src/doc/tarpl/borrow-splitting.md | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/doc/tarpl/borrow-splitting.md b/src/doc/tarpl/borrow-splitting.md index 123e2baf8fa..a394d8f9647 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 -:3:18: 3:22 error: cannot borrow immutable indexed content `x[..]` as mutable -:3 let a = &mut x[0]; - ^~~~ -:4:18: 4:22 error: cannot borrow immutable indexed content `x[..]` as mutable -:4 let b = &mut x[1]; - ^~~~ +:4:14: 4:18 error: cannot borrow `x[..]` as mutable more than once at a time +:4 let b = &mut x[1]; + ^~~~ +: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 +:3 let a = &mut x[0]; + ^~~~ +:6:2: 6:2 note: previous borrow ends here +:1 fn main() { +:2 let mut x = [1, 2, 3]; +:3 let a = &mut x[0]; +:4 let b = &mut x[1]; +:5 println!("{} {}", a, b); +:6 } + ^ error: aborting due to 2 previous errors ``` -- 2.44.0