From 8fe83813ba03dd95b855155bbd8ff889d90d142d Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Tue, 1 Jan 2019 13:50:44 -0500 Subject: [PATCH] Extract error message updates to send to nostarch --- nostarch/chapter-04-error-message-updates.md | 49 ++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 nostarch/chapter-04-error-message-updates.md diff --git a/nostarch/chapter-04-error-message-updates.md b/nostarch/chapter-04-error-message-updates.md new file mode 100644 index 000000000..9b6292cb0 --- /dev/null +++ b/nostarch/chapter-04-error-message-updates.md @@ -0,0 +1,49 @@ +Please view this file in monospace to see how the error messages should line up vertically. + +Here is the new error message for page 70, I've included the whole message for clarity: + +``` +error[E0499]: cannot borrow `s` as mutable more than once at a time + --> src/main.rs:5:14 + | +4 | let r1 = &mut s; + | ------ first mutable borrow occurs here +5 | let r2 = &mut s; + | ^^^^^^ second mutable borrow occurs here +6 | +7 | println!("{}, {}", r1, r2); + | -- first borrow later used here +``` + +For page 71: + +``` +error[E0502]: cannot borrow `s` as mutable because it is also borrowed as immutable + --> src/main.rs:6:14 + | +4 | let r1 = &s; // no problem + | -- immutable borrow occurs here +5 | let r2 = &s; // no problem +6 | let r3 = &mut s; // BIG PROBLEM + | ^^^^^^ mutable borrow occurs here +7 | +8 | println!("{}, {}, and {}", r1, r2, r3); + | -- immutable borrow later used here +``` + +For page 77: + +``` +error[E0502]: cannot borrow `s` as mutable because it is also borrowed as immutable + --> src/main.rs:18:5 + | +16 | let word = first_word(&s); + | -- immutable borrow occurs here +17 | +18 | s.clear(); // error! + | ^^^^^^^^^ mutable borrow occurs here +19 | +20 | println!("the first word is: {}", word); + | ---- immutable borrow later used here +``` +