diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3d5ef2161..bac5ab447 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.89 -c rust-docs - rustup default 1.89 + rustup toolchain install 1.90 -c rust-docs + rustup default 1.90 - name: Install mdbook run: | mkdir bin @@ -47,8 +47,8 @@ jobs: - name: Install Rust run: | rustup set profile minimal - rustup toolchain install 1.89 -c rust-docs - rustup default 1.89 + rustup toolchain install 1.90 -c rust-docs + rustup default 1.90 - name: Run `tools` package tests run: | cargo test 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 f75aa7f42..ba310bad2 100644 --- a/listings/ch02-guessing-game-tutorial/listing-02-04/output.txt +++ b/listings/ch02-guessing-game-tutorial/listing-02-04/output.txt @@ -18,7 +18,7 @@ error[E0308]: mismatched types = note: expected reference `&String` found reference `&{integer}` note: method defined here - --> /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/core/src/cmp.rs:976:8 + --> /rustc/1159e78c4747b02ef996e55082b704c09b970588/library/core/src/cmp.rs:979:8 For more information about this error, try `rustc --explain E0308`. error: could not compile `guessing_game` (bin "guessing_game") due to 1 previous error diff --git a/listings/ch05-using-structs-to-structure-related-data/output-only-01-debug/output.txt b/listings/ch05-using-structs-to-structure-related-data/output-only-01-debug/output.txt index b4e7adf74..25e0661fb 100644 --- a/listings/ch05-using-structs-to-structure-related-data/output-only-01-debug/output.txt +++ b/listings/ch05-using-structs-to-structure-related-data/output-only-01-debug/output.txt @@ -13,8 +13,8 @@ error[E0277]: `Rectangle` doesn't implement `Debug` = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Rectangle` with `#[derive(Debug)]` | -1 + #[derive(Debug)] -2 | struct Rectangle { + 1 + #[derive(Debug)] + 2 | struct Rectangle { | For more information about this error, try `rustc --explain E0277`. 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 98fb8ffef..3d06cff21 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 @@ -7,8 +7,8 @@ error[E0004]: non-exhaustive patterns: `None` not covered | ^ pattern `None` not covered | note: `Option` defined here - --> /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/core/src/option.rs:591:1 - ::: /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/core/src/option.rs:595:5 + --> /rustc/1159e78c4747b02ef996e55082b704c09b970588/library/core/src/option.rs:593:1 + ::: /rustc/1159e78c4747b02ef996e55082b704c09b970588/library/core/src/option.rs:597:5 | = note: not covered = note: the matched value is of type `Option` diff --git a/listings/ch07-managing-growing-projects/listing-07-03/output.txt b/listings/ch07-managing-growing-projects/listing-07-03/output.txt index 2d06c7fd1..aeaf0e699 100644 --- a/listings/ch07-managing-growing-projects/listing-07-03/output.txt +++ b/listings/ch07-managing-growing-projects/listing-07-03/output.txt @@ -25,7 +25,7 @@ error[E0603]: module `hosting` is private note: the module `hosting` is defined here --> src/lib.rs:2:5 | -2 | mod hosting { + 2 | mod hosting { | ^^^^^^^^^^^ For more information about this error, try `rustc --explain E0603`. diff --git a/listings/ch07-managing-growing-projects/listing-07-05/output.txt b/listings/ch07-managing-growing-projects/listing-07-05/output.txt index 199e8a9ed..1283eb539 100644 --- a/listings/ch07-managing-growing-projects/listing-07-05/output.txt +++ b/listings/ch07-managing-growing-projects/listing-07-05/output.txt @@ -9,7 +9,7 @@ error[E0603]: function `add_to_waitlist` is private note: the function `add_to_waitlist` is defined here --> src/lib.rs:3:9 | -3 | fn add_to_waitlist() {} + 3 | fn add_to_waitlist() {} | ^^^^^^^^^^^^^^^^^^^^ error[E0603]: function `add_to_waitlist` is private @@ -21,7 +21,7 @@ error[E0603]: function `add_to_waitlist` is private note: the function `add_to_waitlist` is defined here --> src/lib.rs:3:9 | -3 | fn add_to_waitlist() {} + 3 | fn add_to_waitlist() {} | ^^^^^^^^^^^^^^^^^^^^ For more information about this error, try `rustc --explain E0603`. diff --git a/listings/ch13-functional-features/listing-13-03/output.txt b/listings/ch13-functional-features/listing-13-03/output.txt index 16716c3ac..8d3bebc97 100644 --- a/listings/ch13-functional-features/listing-13-03/output.txt +++ b/listings/ch13-functional-features/listing-13-03/output.txt @@ -4,9 +4,8 @@ error[E0308]: mismatched types --> src/main.rs:5:29 | 5 | let n = example_closure(5); - | --------------- ^- help: try using a conversion method: `.to_string()` - | | | - | | expected `String`, found integer + | --------------- ^ expected `String`, found integer + | | | arguments to this function are incorrect | note: expected because the closure was earlier called with an argument of type `String` @@ -21,6 +20,10 @@ note: closure parameter defined here | 2 | let example_closure = |x| x; | ^ +help: try using a conversion method + | +5 | let n = example_closure(5.to_string()); + | ++++++++++++ For more information about this error, try `rustc --explain E0308`. error: could not compile `closure-example` (bin "closure-example") due to 1 previous error diff --git a/listings/ch13-functional-features/listing-13-08/output.txt b/listings/ch13-functional-features/listing-13-08/output.txt index 979868dc3..000f7f9e7 100644 --- a/listings/ch13-functional-features/listing-13-08/output.txt +++ b/listings/ch13-functional-features/listing-13-08/output.txt @@ -4,12 +4,14 @@ error[E0507]: cannot move out of `value`, a captured variable in an `FnMut` clos --> src/main.rs:18:30 | 15 | let value = String::from("closure called"); - | ----- captured outer variable + | ----- ------------------------------ move occurs because `value` has type `String`, which does not implement the `Copy` trait + | | + | captured outer variable 16 | 17 | list.sort_by_key(|r| { | --- captured by this `FnMut` closure 18 | sort_operations.push(value); - | ^^^^^ move occurs because `value` has type `String`, which does not implement the `Copy` trait + | ^^^^^ `value` is moved here | help: consider cloning the value if the performance cost is acceptable | diff --git a/listings/ch15-smart-pointers/listing-15-17/output.txt b/listings/ch15-smart-pointers/listing-15-17/output.txt index 757a65fb5..13bc17847 100644 --- a/listings/ch15-smart-pointers/listing-15-17/output.txt +++ b/listings/ch15-smart-pointers/listing-15-17/output.txt @@ -3,12 +3,21 @@ $ cargo run error[E0382]: use of moved value: `a` --> src/main.rs:11:30 | -9 | let a = Cons(5, Box::new(Cons(10, Box::new(Nil)))); + 9 | let a = Cons(5, Box::new(Cons(10, Box::new(Nil)))); | - move occurs because `a` has type `List`, which does not implement the `Copy` trait 10 | let b = Cons(3, Box::new(a)); | - value moved here 11 | let c = Cons(4, Box::new(a)); | ^ value used here after move + | +note: if `List` implemented `Clone`, you could clone the value + --> src/main.rs:1:1 + | + 1 | enum List { + | ^^^^^^^^^ consider implementing `Clone` for this type +... +10 | let b = Cons(3, Box::new(a)); + | - you could clone this value For more information about this error, try `rustc --explain E0382`. error: could not compile `cons-list` (bin "cons-list") due to 1 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 8501007f0..2af416752 100644 --- a/listings/ch15-smart-pointers/listing-15-21/output.txt +++ b/listings/ch15-smart-pointers/listing-15-21/output.txt @@ -8,8 +8,8 @@ error[E0596]: cannot borrow `self.sent_messages` as mutable, as it is behind a ` | help: consider changing this to be a mutable reference in the `impl` method and the `trait` definition | -2 ~ fn send(&mut self, msg: &str); -3 | } + 2 ~ fn send(&mut self, msg: &str); + 3 | } ... 56 | impl Messenger for MockMessenger { 57 ~ fn send(&mut self, message: &str) { diff --git a/listings/ch16-fearless-concurrency/listing-16-09/output.txt b/listings/ch16-fearless-concurrency/listing-16-09/output.txt index 4af5d4539..f6d3ee7d6 100644 --- a/listings/ch16-fearless-concurrency/listing-16-09/output.txt +++ b/listings/ch16-fearless-concurrency/listing-16-09/output.txt @@ -3,9 +3,9 @@ $ cargo run error[E0382]: borrow of moved value: `val` --> src/main.rs:10:27 | -8 | let val = String::from("hi"); + 8 | let val = String::from("hi"); | --- move occurs because `val` has type `String`, which does not implement the `Copy` trait -9 | tx.send(val).unwrap(); + 9 | tx.send(val).unwrap(); | --- value moved here 10 | println!("val is {val}"); | ^^^ value borrowed here after move diff --git a/listings/ch16-fearless-concurrency/listing-16-13/output.txt b/listings/ch16-fearless-concurrency/listing-16-13/output.txt index a4db0dcc3..598e0ad7c 100644 --- a/listings/ch16-fearless-concurrency/listing-16-13/output.txt +++ b/listings/ch16-fearless-concurrency/listing-16-13/output.txt @@ -3,12 +3,12 @@ $ cargo run error[E0382]: borrow of moved value: `counter` --> src/main.rs:21:29 | -5 | let counter = Mutex::new(0); - | ------- move occurs because `counter` has type `Mutex`, which does not implement the `Copy` trait + 5 | let counter = Mutex::new(0); + | ------- move occurs because `counter` has type `std::sync::Mutex`, which does not implement the `Copy` trait ... -8 | for _ in 0..10 { + 8 | for _ in 0..10 { | -------------- inside of this loop -9 | let handle = thread::spawn(move || { + 9 | let handle = thread::spawn(move || { | ------- value moved into closure here, in previous iteration of loop ... 21 | println!("Result: {}", *counter.lock().unwrap()); @@ -16,8 +16,8 @@ error[E0382]: borrow of moved value: `counter` | help: consider moving the expression out of the loop so it is only moved once | -8 ~ let mut value = counter.lock(); -9 ~ for _ in 0..10 { + 8 ~ let mut value = counter.lock(); + 9 ~ for _ in 0..10 { 10 | let handle = thread::spawn(move || { 11 ~ let mut num = value.unwrap(); | diff --git a/listings/ch16-fearless-concurrency/listing-16-14/output.txt b/listings/ch16-fearless-concurrency/listing-16-14/output.txt index 56798af09..7b856e2e8 100644 --- a/listings/ch16-fearless-concurrency/listing-16-14/output.txt +++ b/listings/ch16-fearless-concurrency/listing-16-14/output.txt @@ -1,6 +1,6 @@ $ cargo run Compiling shared-state v0.1.0 (file:///projects/shared-state) -error[E0277]: `Rc>` cannot be sent between threads safely +error[E0277]: `Rc>` cannot be sent between threads safely --> src/main.rs:11:36 | 11 | let handle = thread::spawn(move || { @@ -13,16 +13,16 @@ error[E0277]: `Rc>` cannot be sent between threads safely 13 | | 14 | | *num += 1; 15 | | }); - | |_________^ `Rc>` cannot be sent between threads safely + | |_________^ `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>` + = 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 || { | ^^^^^^^ note: required by a bound in `spawn` - --> /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/thread/mod.rs:723:1 + --> /rustc/1159e78c4747b02ef996e55082b704c09b970588/library/std/src/thread/mod.rs:723:1 For more information about this error, try `rustc --explain E0277`. error: could not compile `shared-state` (bin "shared-state") due to 1 previous error diff --git a/listings/ch16-fearless-concurrency/output-only-01-move-drop/output.txt b/listings/ch16-fearless-concurrency/output-only-01-move-drop/output.txt index 929354c13..6a8d57f84 100644 --- a/listings/ch16-fearless-concurrency/output-only-01-move-drop/output.txt +++ b/listings/ch16-fearless-concurrency/output-only-01-move-drop/output.txt @@ -3,16 +3,23 @@ $ cargo run error[E0382]: use of moved value: `v` --> src/main.rs:10:10 | -4 | let v = vec![1, 2, 3]; + 4 | let v = vec![1, 2, 3]; | - move occurs because `v` has type `Vec`, which does not implement the `Copy` trait -5 | -6 | let handle = thread::spawn(move || { + 5 | + 6 | let handle = thread::spawn(move || { | ------- value moved into closure here -7 | println!("Here's a vector: {v:?}"); + 7 | println!("Here's a vector: {v:?}"); | - variable moved due to use in closure ... 10 | drop(v); // oh no! | ^ value used here after move + | +help: consider cloning the value before moving it into the closure + | + 6 ~ let value = v.clone(); + 7 ~ let handle = thread::spawn(move || { + 8 ~ println!("Here's a vector: {value:?}"); + | For more information about this error, try `rustc --explain E0382`. error: could not compile `threads` (bin "threads") due to 1 previous error diff --git a/listings/ch20-advanced-features/listing-20-21/output.txt b/listings/ch20-advanced-features/listing-20-21/output.txt index 0e78ae2d9..b62a1fc9c 100644 --- a/listings/ch20-advanced-features/listing-20-21/output.txt +++ b/listings/ch20-advanced-features/listing-20-21/output.txt @@ -3,7 +3,7 @@ $ cargo run error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type --> src/main.rs:20:43 | -2 | fn baby_name() -> String; + 2 | fn baby_name() -> String; | ------------------------- `Animal::baby_name` defined here ... 20 | println!("A baby dog is called a {}", Animal::baby_name()); diff --git a/listings/ch20-advanced-features/listing-20-33/output.txt b/listings/ch20-advanced-features/listing-20-33/output.txt index acef33111..267366128 100644 --- a/listings/ch20-advanced-features/listing-20-33/output.txt +++ b/listings/ch20-advanced-features/listing-20-33/output.txt @@ -3,10 +3,10 @@ $ cargo build error[E0308]: mismatched types --> src/main.rs:2:44 | -2 | let handlers = vec![returns_closure(), returns_initialized_closure(123)]; + 2 | let handlers = vec![returns_closure(), returns_initialized_closure(123)]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected opaque type, found a different opaque type ... -9 | fn returns_closure() -> impl Fn(i32) -> i32 { + 9 | fn returns_closure() -> impl Fn(i32) -> i32 { | ------------------- the expected opaque type ... 13 | fn returns_initialized_closure(init: i32) -> impl Fn(i32) -> i32 { diff --git a/listings/ch20-advanced-features/no-listing-02-impl-outlineprint-for-point/output.txt b/listings/ch20-advanced-features/no-listing-02-impl-outlineprint-for-point/output.txt index 97a5d00be..2d45a218b 100644 --- a/listings/ch20-advanced-features/no-listing-02-impl-outlineprint-for-point/output.txt +++ b/listings/ch20-advanced-features/no-listing-02-impl-outlineprint-for-point/output.txt @@ -9,7 +9,7 @@ error[E0277]: `Point` doesn't implement `std::fmt::Display` note: required by a bound in `OutlinePrint` --> src/main.rs:3:21 | -3 | trait OutlinePrint: fmt::Display { + 3 | trait OutlinePrint: fmt::Display { | ^^^^^^^^^^^^ required by this bound in `OutlinePrint` error[E0277]: `Point` doesn't implement `std::fmt::Display` @@ -21,9 +21,9 @@ error[E0277]: `Point` doesn't implement `std::fmt::Display` note: required by a bound in `OutlinePrint::outline_print` --> src/main.rs:3:21 | -3 | trait OutlinePrint: fmt::Display { + 3 | trait OutlinePrint: fmt::Display { | ^^^^^^^^^^^^ required by this bound in `OutlinePrint::outline_print` -4 | fn outline_print(&self) { + 4 | fn outline_print(&self) { | ------------- required by a bound in this associated function For more information about this error, try `rustc --explain E0277`. diff --git a/listings/ch21-web-server/listing-21-22/output.txt b/listings/ch21-web-server/listing-21-22/output.txt index a012e6277..6e6b2e639 100644 --- a/listings/ch21-web-server/listing-21-22/output.txt +++ b/listings/ch21-web-server/listing-21-22/output.txt @@ -9,7 +9,7 @@ error[E0507]: cannot move out of `worker.thread` which is behind a mutable refer | 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` - --> /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/thread/mod.rs:1896:17 + --> /rustc/1159e78c4747b02ef996e55082b704c09b970588/library/std/src/thread/mod.rs:1921:17 For more information about this error, try `rustc --explain E0507`. error: could not compile `hello` (lib) due to 1 previous error diff --git a/rust-toolchain b/rust-toolchain index 93132999c..e87fb34ea 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.89 +1.90 diff --git a/src/title-page.md b/src/title-page.md index 8c5404aad..099ab8d64 100644 --- a/src/title-page.md +++ b/src/title-page.md @@ -3,7 +3,7 @@ _by Steve Klabnik, Carol Nichols, and Chris Krycho, with contributions from the Rust Community_ -This version of the text assumes you’re using Rust 1.89.0 (released 2025-08-07) +This version of the text assumes you’re using Rust 1.90.0 (released 2025-09-18) or later with `edition = "2024"` in the *Cargo.toml* file of all projects to configure them to use Rust 2024 Edition idioms. See the [“Installation” section of Chapter 1][install] for instructions on installing or