diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 65574a070..5f3638cc3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,8 +12,8 @@ jobs: - name: Install Rust run: | rustup set profile minimal - rustup toolchain install 1.67 -c rust-docs - rustup default 1.67 + rustup toolchain install 1.68 -c rust-docs + rustup default 1.68 - name: Install mdbook run: | mkdir bin diff --git a/listings/ch02-guessing-game-tutorial/listing-02-04/output.txt b/listings/ch02-guessing-game-tutorial/listing-02-04/output.txt index 3640c0694..d784a3dca 100644 --- a/listings/ch02-guessing-game-tutorial/listing-02-04/output.txt +++ b/listings/ch02-guessing-game-tutorial/listing-02-04/output.txt @@ -8,17 +8,20 @@ $ cargo build Compiling rand v0.8.5 Compiling guessing_game v0.1.0 (file:///projects/guessing_game) error[E0308]: mismatched types - --> src/main.rs:22:21 - | -22 | match guess.cmp(&secret_number) { - | --- ^^^^^^^^^^^^^^ expected struct `String`, found integer - | | - | arguments to this function are incorrect - | - = note: expected reference `&String` - found reference `&{integer}` + --> src/main.rs:22:21 + | +22 | match guess.cmp(&secret_number) { + | --- ^^^^^^^^^^^^^^ expected struct `String`, found integer + | | + | arguments to this method are incorrect + | + = note: expected reference `&String` + found reference `&{integer}` note: associated function defined here - --> /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/cmp.rs:783:8 + --> /Users/carolnichols/.rustup/toolchains/1.68-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/cmp.rs:781:8 + | +781 | fn cmp(&self, other: &Self) -> Ordering; + | ^^^ For more information about this error, try `rustc --explain E0308`. error: could not compile `guessing_game` due to previous error diff --git a/listings/ch03-common-programming-concepts/no-listing-05-mut-cant-change-types/output.txt b/listings/ch03-common-programming-concepts/no-listing-05-mut-cant-change-types/output.txt index 31a07efc4..c954fa78a 100644 --- a/listings/ch03-common-programming-concepts/no-listing-05-mut-cant-change-types/output.txt +++ b/listings/ch03-common-programming-concepts/no-listing-05-mut-cant-change-types/output.txt @@ -7,6 +7,12 @@ error[E0308]: mismatched types | ----- expected due to this value 3 | spaces = spaces.len(); | ^^^^^^^^^^^^ expected `&str`, found `usize` + | +help: try removing the method call + | +3 - spaces = spaces.len(); +3 + spaces = spaces; + | For more information about this error, try `rustc --explain E0308`. error: could not compile `variables` due to previous error diff --git a/listings/ch03-common-programming-concepts/output-only-01-no-type-annotations/output.txt b/listings/ch03-common-programming-concepts/output-only-01-no-type-annotations/output.txt index 8a11cccd5..973308c53 100644 --- a/listings/ch03-common-programming-concepts/output-only-01-no-type-annotations/output.txt +++ b/listings/ch03-common-programming-concepts/output-only-01-no-type-annotations/output.txt @@ -8,8 +8,8 @@ error[E0282]: type annotations needed | help: consider giving `guess` an explicit type | -2 | let guess: _ = "42".parse().expect("Not a number!"); - | +++ +2 | let guess: /* Type */ = "42".parse().expect("Not a number!"); + | ++++++++++++ For more information about this error, try `rustc --explain E0282`. error: could not compile `no_type_annotations` due to previous error diff --git a/listings/ch04-understanding-ownership/listing-04-06/output.txt b/listings/ch04-understanding-ownership/listing-04-06/output.txt index 1176f4e3a..5fd57c96d 100644 --- a/listings/ch04-understanding-ownership/listing-04-06/output.txt +++ b/listings/ch04-understanding-ownership/listing-04-06/output.txt @@ -3,10 +3,13 @@ $ cargo run error[E0596]: cannot borrow `*some_string` as mutable, as it is behind a `&` reference --> src/main.rs:8:5 | -7 | fn change(some_string: &String) { - | ------- help: consider changing this to be a mutable reference: `&mut String` 8 | some_string.push_str(", world"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `some_string` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | +help: consider changing this to be a mutable reference + | +7 | fn change(some_string: &mut String) { + | ~~~~~~~~~~~ For more information about this error, try `rustc --explain E0596`. error: could not compile `ownership` due to previous error diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-10-non-exhaustive-match/output.txt b/listings/ch06-enums-and-pattern-matching/no-listing-10-non-exhaustive-match/output.txt index 75d056f84..a0a046ec6 100644 --- a/listings/ch06-enums-and-pattern-matching/no-listing-10-non-exhaustive-match/output.txt +++ b/listings/ch06-enums-and-pattern-matching/no-listing-10-non-exhaustive-match/output.txt @@ -1,22 +1,25 @@ $ cargo run Compiling enums v0.1.0 (file:///projects/enums) error[E0004]: non-exhaustive patterns: `None` not covered - --> src/main.rs:3:15 - | -3 | match x { - | ^ pattern `None` not covered - | + --> src/main.rs:3:15 + | +3 | match x { + | ^ pattern `None` not covered + | note: `Option` defined here - --> /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/option.rs:518:1 - | - = note: -/rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/option.rs:522:5: not covered - = note: the matched value is of type `Option` + --> /Users/carolnichols/.rustup/toolchains/1.68-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/option.rs:566:5 + | +562 | pub enum Option { + | ------------------ +... +566 | None, + | ^^^^ not covered + = note: the matched value is of type `Option` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown - | -4 ~ Some(i) => Some(i + 1), -5 ~ None => todo!(), - | + | +4 ~ Some(i) => Some(i + 1), +5 ~ None => todo!(), + | For more information about this error, try `rustc --explain E0004`. error: could not compile `enums` due to previous error diff --git a/listings/ch15-smart-pointers/listing-15-21/output.txt b/listings/ch15-smart-pointers/listing-15-21/output.txt index 6b07b66ea..0c9ef8eb2 100644 --- a/listings/ch15-smart-pointers/listing-15-21/output.txt +++ b/listings/ch15-smart-pointers/listing-15-21/output.txt @@ -3,11 +3,13 @@ $ cargo test error[E0596]: cannot borrow `self.sent_messages` as mutable, as it is behind a `&` reference --> src/lib.rs:58:13 | -2 | fn send(&self, msg: &str); - | ----- help: consider changing that to be a mutable reference: `&mut self` -... 58 | self.sent_messages.push(String::from(message)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | +help: consider changing that to be a mutable reference + | +2 | fn send(&mut self, msg: &str); + | ~~~~~~~~~ For more information about this error, try `rustc --explain E0596`. error: could not compile `limit-tracker` due to previous error diff --git a/listings/ch15-smart-pointers/no-listing-01-cant-borrow-immutable-as-mutable/output.txt b/listings/ch15-smart-pointers/no-listing-01-cant-borrow-immutable-as-mutable/output.txt index 8e84746ee..d9684a6e0 100644 --- a/listings/ch15-smart-pointers/no-listing-01-cant-borrow-immutable-as-mutable/output.txt +++ b/listings/ch15-smart-pointers/no-listing-01-cant-borrow-immutable-as-mutable/output.txt @@ -3,10 +3,13 @@ $ cargo run error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable --> src/main.rs:3:13 | -2 | let x = 5; - | - help: consider changing this to be mutable: `mut x` 3 | let y = &mut x; | ^^^^^^ cannot borrow as mutable + | +help: consider changing this to be mutable + | +2 | let mut x = 5; + | +++ For more information about this error, try `rustc --explain E0596`. error: could not compile `borrowing` due to previous error diff --git a/listings/ch16-fearless-concurrency/listing-16-14/output.txt b/listings/ch16-fearless-concurrency/listing-16-14/output.txt index e8cf21a73..93e6bd322 100644 --- a/listings/ch16-fearless-concurrency/listing-16-14/output.txt +++ b/listings/ch16-fearless-concurrency/listing-16-14/output.txt @@ -1,30 +1,31 @@ $ cargo run Compiling shared-state v0.1.0 (file:///projects/shared-state) error[E0277]: `Rc>` cannot be sent between threads safely - --> src/main.rs:11:36 - | -11 | let handle = thread::spawn(move || { - | ------------- ^------ - | | | - | ______________________|_____________within this `[closure@src/main.rs:11:36: 11:43]` - | | | - | | required by a bound introduced by this call -12 | | let mut num = counter.lock().unwrap(); -13 | | -14 | | *num += 1; -15 | | }); - | |_________^ `Rc>` cannot be sent between threads safely - | - = help: within `[closure@src/main.rs:11:36: 11:43]`, the trait `Send` is not implemented for `Rc>` + --> src/main.rs:11:36 + | +11 | let handle = thread::spawn(move || { + | ------------- ^------ + | | | + | ______________________|_____________within this `[closure@src/main.rs:11:36: 11:43]` + | | | + | | required by a bound introduced by this call +12 | | let mut num = counter.lock().unwrap(); +13 | | +14 | | *num += 1; +15 | | }); + | |_________^ `Rc>` cannot be sent between threads safely + | + = help: within `[closure@src/main.rs:11:36: 11:43]`, the trait `Send` is not implemented for `Rc>` note: required because it's used within this closure - --> src/main.rs:11:36 - | -11 | let handle = thread::spawn(move || { - | ^^^^^^^ + --> src/main.rs:11:36 + | +11 | let handle = thread::spawn(move || { + | ^^^^^^^ note: required by a bound in `spawn` - --> /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/thread/mod.rs:704:8 - | - = note: required by this bound in `spawn` + --> /Users/carolnichols/.rustup/toolchains/1.68-aarch64-apple-darwin/lib/rustlib/src/rust/library/std/src/thread/mod.rs:712:8 + | +712 | F: Send + 'static, + | ^^^^ required by this bound in `spawn` For more information about this error, try `rustc --explain E0277`. error: could not compile `shared-state` due to previous error diff --git a/listings/ch18-patterns-and-matching/listing-18-08/output.txt b/listings/ch18-patterns-and-matching/listing-18-08/output.txt index 52efabb5c..8e74696a0 100644 --- a/listings/ch18-patterns-and-matching/listing-18-08/output.txt +++ b/listings/ch18-patterns-and-matching/listing-18-08/output.txt @@ -1,6 +1,6 @@ $ cargo run Compiling patterns v0.1.0 (file:///projects/patterns) -error[E0005]: refutable pattern in local binding: `None` not covered +error[E0005]: refutable pattern in local binding --> src/main.rs:3:9 | 3 | let Some(x) = some_option_value; @@ -8,17 +8,8 @@ error[E0005]: refutable pattern in local binding: `None` not covered | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html -note: `Option` defined here - --> /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/option.rs:518:1 - | - = note: -/rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/option.rs:522:5: not covered = note: the matched value is of type `Option` -help: you might want to use `if let` to ignore the variant that isn't matched - | -3 | let x = if let Some(x) = some_option_value { x } else { todo!() }; - | ++++++++++ ++++++++++++++++++++++ -help: alternatively, you might want to use let else to handle the variant that isn't matched +help: you might want to use `let else` to handle the variant that isn't matched | 3 | let Some(x) = some_option_value else { todo!() }; | ++++++++++++++++ diff --git a/listings/ch19-advanced-features/no-listing-02-impl-outlineprint-for-point/output.txt b/listings/ch19-advanced-features/no-listing-02-impl-outlineprint-for-point/output.txt index 0991f10fa..f6965badd 100644 --- a/listings/ch19-advanced-features/no-listing-02-impl-outlineprint-for-point/output.txt +++ b/listings/ch19-advanced-features/no-listing-02-impl-outlineprint-for-point/output.txt @@ -1,10 +1,10 @@ $ cargo run Compiling traits-example v0.1.0 (file:///projects/traits-example) error[E0277]: `Point` doesn't implement `std::fmt::Display` - --> src/main.rs:20:6 + --> src/main.rs:20:23 | 20 | impl OutlinePrint for Point {} - | ^^^^^^^^^^^^ `Point` cannot be formatted with the default formatter + | ^^^^^ `Point` cannot be formatted with the default formatter | = help: the trait `std::fmt::Display` is not implemented for `Point` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead diff --git a/listings/ch20-web-server/listing-20-22/output.txt b/listings/ch20-web-server/listing-20-22/output.txt index 342bf9a16..99b6ef62a 100644 --- a/listings/ch20-web-server/listing-20-22/output.txt +++ b/listings/ch20-web-server/listing-20-22/output.txt @@ -1,15 +1,18 @@ $ cargo check Checking hello v0.1.0 (file:///projects/hello) error[E0507]: cannot move out of `worker.thread` which is behind a mutable reference - --> src/lib.rs:52:13 - | -52 | worker.thread.join().unwrap(); - | ^^^^^^^^^^^^^ ------ `worker.thread` moved due to this method call - | | - | move occurs because `worker.thread` has type `JoinHandle<()>`, which does not implement the `Copy` trait - | -note: this function takes ownership of the receiver `self`, which moves `worker.thread` - --> /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/thread/mod.rs:1581:17 + --> src/lib.rs:52:13 + | +52 | worker.thread.join().unwrap(); + | ^^^^^^^^^^^^^ ------ `worker.thread` moved due to this method call + | | + | move occurs because `worker.thread` has type `JoinHandle<()>`, which does not implement the `Copy` trait + | +note: `JoinHandle::::join` takes ownership of the receiver `self`, which moves `worker.thread` + --> /Users/carolnichols/.rustup/toolchains/1.68-aarch64-apple-darwin/lib/rustlib/src/rust/library/std/src/thread/mod.rs:1589:17 + | +1589 | pub fn join(self) -> Result { + | ^^^^ For more information about this error, try `rustc --explain E0507`. error: could not compile `hello` due to previous error diff --git a/listings/ch20-web-server/no-listing-04-update-worker-definition/output.txt b/listings/ch20-web-server/no-listing-04-update-worker-definition/output.txt index fec2377dc..6e0132e0a 100644 --- a/listings/ch20-web-server/no-listing-04-update-worker-definition/output.txt +++ b/listings/ch20-web-server/no-listing-04-update-worker-definition/output.txt @@ -1,17 +1,20 @@ $ cargo check Checking hello v0.1.0 (file:///projects/hello) error[E0599]: no method named `join` found for enum `Option` in the current scope - --> src/lib.rs:52:27 - | -52 | worker.thread.join().unwrap(); - | ^^^^ method not found in `Option>` - | + --> src/lib.rs:52:27 + | +52 | worker.thread.join().unwrap(); + | ^^^^ method not found in `Option>` + | note: the method `join` exists on the type `JoinHandle<()>` - --> /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/thread/mod.rs:1581:5 + --> /Users/carolnichols/.rustup/toolchains/1.68-aarch64-apple-darwin/lib/rustlib/src/rust/library/std/src/thread/mod.rs:1589:5 + | +1589 | pub fn join(self) -> Result { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `Option::expect` to unwrap the `JoinHandle<()>` value, panicking if the value is an `Option::None` - | -52 | worker.thread.expect("REASON").join().unwrap(); - | +++++++++++++++++ + | +52 | worker.thread.expect("REASON").join().unwrap(); + | +++++++++++++++++ error[E0308]: mismatched types --> src/lib.rs:72:22 diff --git a/rust-toolchain b/rust-toolchain index 9ebd7af32..083b97b96 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.67 +1.68 diff --git a/src/title-page.md b/src/title-page.md index 5f7a7a680..2f1c72d96 100644 --- a/src/title-page.md +++ b/src/title-page.md @@ -2,7 +2,7 @@ *by Steve Klabnik and Carol Nichols, with contributions from the Rust Community* -This version of the text assumes you’re using Rust 1.67.1 (released 2023-02-09) +This version of the text assumes you’re using Rust 1.68.2 (released 2023-03-28) or later. See the [“Installation” section of Chapter 1][install] to install or update Rust.