Skip to content

Commit

Permalink
Update to Rust 1.68
Browse files Browse the repository at this point in the history
  • Loading branch information
carols10cents committed Feb 19, 2024
1 parent 71352de commit 667e928
Show file tree
Hide file tree
Showing 15 changed files with 108 additions and 90 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 13 additions & 10 deletions listings/ch02-guessing-game-tutorial/listing-02-04/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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<i32>` 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<i32>`
--> /Users/carolnichols/.rustup/toolchains/1.68-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/option.rs:566:5
|
562 | pub enum Option<T> {
| ------------------
...
566 | None,
| ^^^^ not covered
= note: the matched value is of type `Option<i32>`
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
8 changes: 5 additions & 3 deletions listings/ch15-smart-pointers/listing-15-21/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
45 changes: 23 additions & 22 deletions listings/ch16-fearless-concurrency/listing-16-14/output.txt
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
$ cargo run
Compiling shared-state v0.1.0 (file:///projects/shared-state)
error[E0277]: `Rc<Mutex<i32>>` 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<Mutex<i32>>` cannot be sent between threads safely
|
= help: within `[closure@src/main.rs:11:36: 11:43]`, the trait `Send` is not implemented for `Rc<Mutex<i32>>`
--> 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<Mutex<i32>>` cannot be sent between threads safely
|
= help: within `[closure@src/main.rs:11:36: 11:43]`, the trait `Send` is not implemented for `Rc<Mutex<i32>>`
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
13 changes: 2 additions & 11 deletions listings/ch18-patterns-and-matching/listing-18-08/output.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
$ 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;
| ^^^^^^^ pattern `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<i32>` 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<i32>`
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!() };
| ++++++++++++++++
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
21 changes: 12 additions & 9 deletions listings/ch20-web-server/listing-20-22/output.txt
Original file line number Diff line number Diff line change
@@ -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::<T>::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<T> {
| ^^^^

For more information about this error, try `rustc --explain E0507`.
error: could not compile `hello` due to previous error
Original file line number Diff line number Diff line change
@@ -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<JoinHandle<()>>`
|
--> src/lib.rs:52:27
|
52 | worker.thread.join().unwrap();
| ^^^^ method not found in `Option<JoinHandle<()>>`
|
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<T> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.67
1.68
2 changes: 1 addition & 1 deletion src/title-page.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]<!-- ignore -->
to install or update Rust.

Expand Down

0 comments on commit 667e928

Please sign in to comment.