mirror of
https://github.com/rust-lang/book.git
synced 2026-04-03 13:35:12 -04:00
Update to Rust 1.76
This commit is contained in:
committed by
Carol (Nichols || Goulding)
parent
57516ea03b
commit
940fb140f5
4
.github/workflows/main.yml
vendored
4
.github/workflows/main.yml
vendored
@@ -12,8 +12,8 @@ jobs:
|
||||
- name: Install Rust
|
||||
run: |
|
||||
rustup set profile minimal
|
||||
rustup toolchain install 1.75 -c rust-docs
|
||||
rustup default 1.75
|
||||
rustup toolchain install 1.76 -c rust-docs
|
||||
rustup default 1.76
|
||||
- name: Install mdbook
|
||||
run: |
|
||||
mkdir bin
|
||||
|
||||
@@ -10,9 +10,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.7"
|
||||
version = "0.2.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6"
|
||||
checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
@@ -28,15 +28,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.127"
|
||||
version = "0.2.153"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "505e71a4706fa491e9b1b55f51b95d4037d0821ee40131190475f692b35b009b"
|
||||
checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.16"
|
||||
version = "0.2.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872"
|
||||
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
@@ -61,9 +61,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.6.3"
|
||||
version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
|
||||
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
]
|
||||
|
||||
@@ -18,7 +18,7 @@ error[E0308]: mismatched types
|
||||
= note: expected reference `&String`
|
||||
found reference `&{integer}`
|
||||
note: method defined here
|
||||
--> /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/cmp.rs:811:8
|
||||
--> /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/cmp.rs:814:8
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
error: could not compile `guessing_game` (bin "guessing_game") due to previous error
|
||||
error: could not compile `guessing_game` (bin "guessing_game") due to 1 previous error
|
||||
|
||||
@@ -13,4 +13,4 @@ error[E0384]: cannot assign twice to immutable variable `x`
|
||||
| ^^^^^ cannot assign twice to immutable variable
|
||||
|
||||
For more information about this error, try `rustc --explain E0384`.
|
||||
error: could not compile `variables` (bin "variables") due to previous error
|
||||
error: could not compile `variables` (bin "variables") due to 1 previous error
|
||||
|
||||
@@ -15,4 +15,4 @@ help: try removing the method call
|
||||
|
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
error: could not compile `variables` (bin "variables") due to previous error
|
||||
error: could not compile `variables` (bin "variables") due to 1 previous error
|
||||
|
||||
@@ -22,4 +22,4 @@ help: remove these parentheses
|
||||
|
|
||||
|
||||
warning: `functions` (bin "functions") generated 1 warning
|
||||
error: could not compile `functions` (bin "functions") due to previous error; 1 warning emitted
|
||||
error: could not compile `functions` (bin "functions") due to 1 previous error; 1 warning emitted
|
||||
|
||||
@@ -11,4 +11,4 @@ error[E0308]: mismatched types
|
||||
| - help: remove this semicolon to return this value
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
error: could not compile `functions` (bin "functions") due to previous error
|
||||
error: could not compile `functions` (bin "functions") due to 1 previous error
|
||||
|
||||
@@ -7,4 +7,4 @@ error[E0308]: mismatched types
|
||||
| ^^^^^^ expected `bool`, found integer
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
error: could not compile `branches` (bin "branches") due to previous error
|
||||
error: could not compile `branches` (bin "branches") due to 1 previous error
|
||||
|
||||
@@ -9,4 +9,4 @@ error[E0308]: `if` and `else` have incompatible types
|
||||
| expected because of this
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
error: could not compile `branches` (bin "branches") due to previous error
|
||||
error: could not compile `branches` (bin "branches") due to 1 previous error
|
||||
|
||||
@@ -13,4 +13,4 @@ help: consider giving `guess` an explicit type
|
||||
| ++++++++++++
|
||||
|
||||
For more information about this error, try `rustc --explain E0284`.
|
||||
error: could not compile `no_type_annotations` (bin "no_type_annotations") due to previous error
|
||||
error: could not compile `no_type_annotations` (bin "no_type_annotations") due to 1 previous error
|
||||
|
||||
@@ -12,4 +12,4 @@ help: consider changing this to be a mutable reference
|
||||
| +++
|
||||
|
||||
For more information about this error, try `rustc --explain E0596`.
|
||||
error: could not compile `ownership` (bin "ownership") due to previous error
|
||||
error: could not compile `ownership` (bin "ownership") due to 1 previous error
|
||||
|
||||
@@ -18,4 +18,4 @@ help: consider cloning the value if the performance cost is acceptable
|
||||
| ++++++++
|
||||
|
||||
For more information about this error, try `rustc --explain E0382`.
|
||||
error: could not compile `ownership` (bin "ownership") due to previous error
|
||||
error: could not compile `ownership` (bin "ownership") due to 1 previous error
|
||||
|
||||
@@ -12,4 +12,4 @@ error[E0499]: cannot borrow `s` as mutable more than once at a time
|
||||
| -- first borrow later used here
|
||||
|
||||
For more information about this error, try `rustc --explain E0499`.
|
||||
error: could not compile `ownership` (bin "ownership") due to previous error
|
||||
error: could not compile `ownership` (bin "ownership") due to 1 previous error
|
||||
|
||||
@@ -13,4 +13,4 @@ error[E0502]: cannot borrow `s` as mutable because it is also borrowed as immuta
|
||||
| -- immutable borrow later used here
|
||||
|
||||
For more information about this error, try `rustc --explain E0502`.
|
||||
error: could not compile `ownership` (bin "ownership") due to previous error
|
||||
error: could not compile `ownership` (bin "ownership") due to 1 previous error
|
||||
|
||||
@@ -7,10 +7,15 @@ error[E0106]: missing lifetime specifier
|
||||
| ^ expected named lifetime parameter
|
||||
|
|
||||
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
|
||||
help: consider using the `'static` lifetime
|
||||
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
|
||||
|
|
||||
5 | fn dangle() -> &'static String {
|
||||
| +++++++
|
||||
help: instead, you are more likely to want to return an owned value
|
||||
|
|
||||
5 - fn dangle() -> &String {
|
||||
5 + fn dangle() -> String {
|
||||
|
|
||||
|
||||
For more information about this error, try `rustc --explain E0106`.
|
||||
error: could not compile `ownership` (bin "ownership") due to previous error
|
||||
error: could not compile `ownership` (bin "ownership") due to 1 previous error
|
||||
|
||||
@@ -13,4 +13,4 @@ error[E0502]: cannot borrow `s` as mutable because it is also borrowed as immuta
|
||||
| ---- immutable borrow later used here
|
||||
|
||||
For more information about this error, try `rustc --explain E0502`.
|
||||
error: could not compile `ownership` (bin "ownership") due to previous error
|
||||
error: could not compile `ownership` (bin "ownership") due to 1 previous error
|
||||
|
||||
@@ -11,4 +11,4 @@ error[E0277]: `Rectangle` doesn't implement `std::fmt::Display`
|
||||
= 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)
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
error: could not compile `rectangles` (bin "rectangles") due to previous error
|
||||
error: could not compile `rectangles` (bin "rectangles") due to 1 previous error
|
||||
|
||||
@@ -2,8 +2,8 @@ $ cargo run
|
||||
Compiling rectangles v0.1.0 (file:///projects/rectangles)
|
||||
Finished dev [unoptimized + debuginfo] target(s) in 0.61s
|
||||
Running `target/debug/rectangles`
|
||||
[src/main.rs:10] 30 * scale = 60
|
||||
[src/main.rs:14] &rect1 = Rectangle {
|
||||
[src/main.rs:10:16] 30 * scale = 60
|
||||
[src/main.rs:14:5] &rect1 = Rectangle {
|
||||
width: 60,
|
||||
height: 50,
|
||||
}
|
||||
|
||||
@@ -16,4 +16,4 @@ help: consider annotating `Rectangle` with `#[derive(Debug)]`
|
||||
|
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
error: could not compile `rectangles` (bin "rectangles") due to previous error
|
||||
error: could not compile `rectangles` (bin "rectangles") due to 1 previous error
|
||||
|
||||
@@ -14,4 +14,4 @@ error[E0277]: cannot add `Option<i8>` to `i8`
|
||||
<&i8 as Add<&i8>>
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
error: could not compile `enums` (bin "enums") due to previous error
|
||||
error: could not compile `enums` (bin "enums") due to 1 previous error
|
||||
|
||||
@@ -7,8 +7,8 @@ error[E0004]: non-exhaustive patterns: `None` not covered
|
||||
| ^ pattern `None` not covered
|
||||
|
|
||||
note: `Option<i32>` defined here
|
||||
--> /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/option.rs:569:1
|
||||
::: /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/option.rs:573:5
|
||||
--> /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/option.rs:570:1
|
||||
::: /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/option.rs:574:5
|
||||
|
|
||||
= note: not covered
|
||||
= note: the matched value is of type `Option<i32>`
|
||||
@@ -19,4 +19,4 @@ help: ensure that all possible cases are being handled by adding a match arm wit
|
||||
|
|
||||
|
||||
For more information about this error, try `rustc --explain E0004`.
|
||||
error: could not compile `enums` (bin "enums") due to previous error
|
||||
error: could not compile `enums` (bin "enums") due to 1 previous error
|
||||
|
||||
@@ -21,4 +21,4 @@ warning: unused import: `crate::front_of_house::hosting`
|
||||
|
||||
For more information about this error, try `rustc --explain E0433`.
|
||||
warning: `restaurant` (lib) generated 1 warning
|
||||
error: could not compile `restaurant` (lib) due to previous error; 1 warning emitted
|
||||
error: could not compile `restaurant` (lib) due to 1 previous error; 1 warning emitted
|
||||
|
||||
@@ -13,4 +13,4 @@ error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immuta
|
||||
| ------- immutable borrow later used here
|
||||
|
||||
For more information about this error, try `rustc --explain E0502`.
|
||||
error: could not compile `collections` (bin "collections") due to previous error
|
||||
error: could not compile `collections` (bin "collections") due to 1 previous error
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
$ cargo run
|
||||
Compiling collections v0.1.0 (file:///projects/collections)
|
||||
error[E0277]: the type `String` cannot be indexed by `{integer}`
|
||||
--> src/main.rs:3:13
|
||||
--> src/main.rs:3:16
|
||||
|
|
||||
3 | let h = s1[0];
|
||||
| ^^^^^ `String` cannot be indexed by `{integer}`
|
||||
| ^ `String` cannot be indexed by `{integer}`
|
||||
|
|
||||
= help: the trait `Index<{integer}>` is not implemented for `String`
|
||||
= help: the following other types implement trait `Index<Idx>`:
|
||||
@@ -16,4 +16,4 @@ error[E0277]: the type `String` cannot be indexed by `{integer}`
|
||||
<String as Index<RangeToInclusive<usize>>>
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
error: could not compile `collections` (bin "collections") due to previous error
|
||||
error: could not compile `collections` (bin "collections") due to 1 previous error
|
||||
|
||||
@@ -11,4 +11,4 @@ error[E0277]: the `?` operator can only be used in a function that returns `Resu
|
||||
= help: the trait `FromResidual<Result<Infallible, std::io::Error>>` is not implemented for `()`
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
error: could not compile `error-handling` (bin "error-handling") due to previous error
|
||||
error: could not compile `error-handling` (bin "error-handling") due to 1 previous error
|
||||
|
||||
@@ -14,4 +14,4 @@ help: consider restricting type parameter `T`
|
||||
| ++++++++++++++++++++++
|
||||
|
||||
For more information about this error, try `rustc --explain E0369`.
|
||||
error: could not compile `chapter10` (bin "chapter10") due to previous error
|
||||
error: could not compile `chapter10` (bin "chapter10") due to 1 previous error
|
||||
|
||||
@@ -7,4 +7,4 @@ error[E0308]: mismatched types
|
||||
| ^^^ expected integer, found floating-point number
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
error: could not compile `chapter10` (bin "chapter10") due to previous error
|
||||
error: could not compile `chapter10` (bin "chapter10") due to 1 previous error
|
||||
|
||||
@@ -14,4 +14,4 @@ error[E0597]: `x` does not live long enough
|
||||
| - borrow later used here
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
error: could not compile `chapter10` (bin "chapter10") due to previous error
|
||||
error: could not compile `chapter10` (bin "chapter10") due to 1 previous error
|
||||
|
||||
@@ -13,4 +13,4 @@ help: consider introducing a named lifetime parameter
|
||||
| ++++ ++ ++ ++
|
||||
|
||||
For more information about this error, try `rustc --explain E0106`.
|
||||
error: could not compile `chapter10` (bin "chapter10") due to previous error
|
||||
error: could not compile `chapter10` (bin "chapter10") due to 1 previous error
|
||||
|
||||
@@ -13,4 +13,4 @@ error[E0597]: `string2` does not live long enough
|
||||
| ------ borrow later used here
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
error: could not compile `chapter10` (bin "chapter10") due to previous error
|
||||
error: could not compile `chapter10` (bin "chapter10") due to 1 previous error
|
||||
|
||||
@@ -10,4 +10,4 @@ error[E0515]: cannot return value referencing local variable `result`
|
||||
| `result` is borrowed here
|
||||
|
||||
For more information about this error, try `rustc --explain E0515`.
|
||||
error: could not compile `chapter10` (bin "chapter10") due to previous error
|
||||
error: could not compile `chapter10` (bin "chapter10") due to 1 previous error
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
pub fn add(left: usize, right: usize) -> usize {
|
||||
left + right
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn it_works() {
|
||||
let result = 2 + 2;
|
||||
let result = add(2, 2);
|
||||
assert_eq!(result, 4);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@ $ cargo run
|
||||
Compiling minigrep v0.1.0 (file:///projects/minigrep)
|
||||
Finished dev [unoptimized + debuginfo] target(s) in 0.61s
|
||||
Running `target/debug/minigrep`
|
||||
[src/main.rs:5] args = [
|
||||
[src/main.rs:5:5] args = [
|
||||
"target/debug/minigrep",
|
||||
]
|
||||
|
||||
@@ -2,7 +2,7 @@ $ cargo run -- needle haystack
|
||||
Compiling minigrep v0.1.0 (file:///projects/minigrep)
|
||||
Finished dev [unoptimized + debuginfo] target(s) in 1.57s
|
||||
Running `target/debug/minigrep needle haystack`
|
||||
[src/main.rs:5] args = [
|
||||
[src/main.rs:5:5] args = [
|
||||
"target/debug/minigrep",
|
||||
"needle",
|
||||
"haystack",
|
||||
|
||||
@@ -13,4 +13,4 @@ help: consider introducing a named lifetime parameter
|
||||
| ++++ ++ ++ ++
|
||||
|
||||
For more information about this error, try `rustc --explain E0106`.
|
||||
error: could not compile `minigrep` (lib) due to previous error
|
||||
error: could not compile `minigrep` (lib) due to 1 previous error
|
||||
|
||||
@@ -23,4 +23,4 @@ note: closure parameter defined here
|
||||
| ^
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
error: could not compile `closure-example` (bin "closure-example") due to previous error
|
||||
error: could not compile `closure-example` (bin "closure-example") due to 1 previous error
|
||||
|
||||
@@ -12,4 +12,4 @@ error[E0507]: cannot move out of `value`, a captured variable in an `FnMut` clos
|
||||
| ^^^^^ move occurs because `value` has type `String`, which does not implement the `Copy` trait
|
||||
|
||||
For more information about this error, try `rustc --explain E0507`.
|
||||
error: could not compile `rectangles` (bin "rectangles") due to previous error
|
||||
error: could not compile `rectangles` (bin "rectangles") due to 1 previous error
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
pub fn add(left: usize, right: usize) -> usize {
|
||||
left + right
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn it_works() {
|
||||
let result = 2 + 2;
|
||||
let result = add(2, 2);
|
||||
assert_eq!(result, 4);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,4 +14,4 @@ help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle
|
||||
| ++++ +
|
||||
|
||||
For more information about this error, try `rustc --explain E0072`.
|
||||
error: could not compile `cons-list` (bin "cons-list") due to previous error
|
||||
error: could not compile `cons-list` (bin "cons-list") due to 1 previous error
|
||||
|
||||
@@ -7,4 +7,4 @@ error[E0614]: type `MyBox<{integer}>` cannot be dereferenced
|
||||
| ^^
|
||||
|
||||
For more information about this error, try `rustc --explain E0614`.
|
||||
error: could not compile `deref-example` (bin "deref-example") due to previous error
|
||||
error: could not compile `deref-example` (bin "deref-example") due to 1 previous error
|
||||
|
||||
@@ -12,4 +12,4 @@ help: consider using `drop` function
|
||||
| +++++ ~
|
||||
|
||||
For more information about this error, try `rustc --explain E0040`.
|
||||
error: could not compile `drop-example` (bin "drop-example") due to previous error
|
||||
error: could not compile `drop-example` (bin "drop-example") due to 1 previous error
|
||||
|
||||
@@ -11,4 +11,4 @@ error[E0382]: use of moved value: `a`
|
||||
| ^ value used here after move
|
||||
|
||||
For more information about this error, try `rustc --explain E0382`.
|
||||
error: could not compile `cons-list` (bin "cons-list") due to previous error
|
||||
error: could not compile `cons-list` (bin "cons-list") due to 1 previous error
|
||||
|
||||
@@ -12,4 +12,4 @@ help: consider changing this to be a mutable reference
|
||||
| ~~~~~~~~~
|
||||
|
||||
For more information about this error, try `rustc --explain E0596`.
|
||||
error: could not compile `limit-tracker` (lib test) due to previous error
|
||||
error: could not compile `limit-tracker` (lib test) due to 1 previous error
|
||||
|
||||
@@ -12,4 +12,4 @@ help: consider changing this to be mutable
|
||||
| +++
|
||||
|
||||
For more information about this error, try `rustc --explain E0596`.
|
||||
error: could not compile `borrowing` (bin "borrowing") due to previous error
|
||||
error: could not compile `borrowing` (bin "borrowing") due to 1 previous error
|
||||
|
||||
@@ -20,4 +20,4 @@ error[E0277]: can't compare `{integer}` with `&{integer}`
|
||||
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
error: could not compile `deref-example` (bin "deref-example") due to previous error
|
||||
error: could not compile `deref-example` (bin "deref-example") due to 1 previous error
|
||||
|
||||
@@ -22,4 +22,4 @@ help: to force the closure to take ownership of `v` (and any other referenced va
|
||||
| ++++
|
||||
|
||||
For more information about this error, try `rustc --explain E0373`.
|
||||
error: could not compile `threads` (bin "threads") due to previous error
|
||||
error: could not compile `threads` (bin "threads") due to 1 previous error
|
||||
|
||||
@@ -17,4 +17,4 @@ help: consider cloning the value if the performance cost is acceptable
|
||||
| ++++++++
|
||||
|
||||
For more information about this error, try `rustc --explain E0382`.
|
||||
error: could not compile `message-passing` (bin "message-passing") due to previous error
|
||||
error: could not compile `message-passing` (bin "message-passing") due to 1 previous error
|
||||
|
||||
@@ -13,4 +13,4 @@ error[E0382]: borrow of moved value: `counter`
|
||||
| ^^^^^^^ value borrowed here after move
|
||||
|
||||
For more information about this error, try `rustc --explain E0382`.
|
||||
error: could not compile `shared-state` (bin "shared-state") due to previous error
|
||||
error: could not compile `shared-state` (bin "shared-state") due to 1 previous error
|
||||
|
||||
@@ -22,7 +22,7 @@ note: required because it's used within this closure
|
||||
11 | let handle = thread::spawn(move || {
|
||||
| ^^^^^^^
|
||||
note: required by a bound in `spawn`
|
||||
--> /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/mod.rs:682:1
|
||||
--> /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/thread/mod.rs:678:1
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
error: could not compile `shared-state` (bin "shared-state") due to previous error
|
||||
error: could not compile `shared-state` (bin "shared-state") due to 1 previous error
|
||||
|
||||
@@ -15,4 +15,4 @@ error[E0382]: use of moved value: `v`
|
||||
| ^ value used here after move
|
||||
|
||||
For more information about this error, try `rustc --explain E0382`.
|
||||
error: could not compile `threads` (bin "threads") due to previous error
|
||||
error: could not compile `threads` (bin "threads") due to 1 previous error
|
||||
|
||||
@@ -10,4 +10,4 @@ error[E0277]: the trait bound `String: Draw` is not satisfied
|
||||
= note: required for the cast from `Box<String>` to `Box<dyn Draw>`
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
error: could not compile `gui` (bin "gui") due to previous error
|
||||
error: could not compile `gui` (bin "gui") due to 1 previous error
|
||||
|
||||
@@ -12,4 +12,4 @@ error[E0308]: mismatched types
|
||||
found tuple `(_, _)`
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
error: could not compile `patterns` (bin "patterns") due to previous error
|
||||
error: could not compile `patterns` (bin "patterns") due to 1 previous error
|
||||
|
||||
@@ -15,4 +15,4 @@ help: you might want to use `let else` to handle the variant that isn't matched
|
||||
| ++++++++++++++++
|
||||
|
||||
For more information about this error, try `rustc --explain E0005`.
|
||||
error: could not compile `patterns` (bin "patterns") due to previous error
|
||||
error: could not compile `patterns` (bin "patterns") due to 1 previous error
|
||||
|
||||
@@ -8,4 +8,4 @@ error: `..` can only be used once per tuple pattern
|
||||
| |
|
||||
| previously used here
|
||||
|
||||
error: could not compile `patterns` (bin "patterns") due to previous error
|
||||
error: could not compile `patterns` (bin "patterns") due to 1 previous error
|
||||
|
||||
@@ -14,4 +14,4 @@ error[E0499]: cannot borrow `*values` as mutable more than once at a time
|
||||
| returning this value requires that `*values` is borrowed for `'1`
|
||||
|
||||
For more information about this error, try `rustc --explain E0499`.
|
||||
error: could not compile `unsafe-example` (bin "unsafe-example") due to previous error
|
||||
error: could not compile `unsafe-example` (bin "unsafe-example") due to 1 previous error
|
||||
|
||||
@@ -15,4 +15,4 @@ help: use the fully-qualified path to the only available implementation
|
||||
| +++++++ +
|
||||
|
||||
For more information about this error, try `rustc --explain E0790`.
|
||||
error: could not compile `traits-example` (bin "traits-example") due to previous error
|
||||
error: could not compile `traits-example` (bin "traits-example") due to 1 previous error
|
||||
|
||||
@@ -15,4 +15,4 @@ note: required by a bound in `OutlinePrint`
|
||||
| ^^^^^^^^^^^^ required by this bound in `OutlinePrint`
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
error: could not compile `traits-example` (bin "traits-example") due to previous error
|
||||
error: could not compile `traits-example` (bin "traits-example") due to 1 previous error
|
||||
|
||||
@@ -17,4 +17,4 @@ help: box the return type, and wrap all of the returned values in `Box::new`
|
||||
|
|
||||
|
||||
For more information about this error, try `rustc --explain E0746`.
|
||||
error: could not compile `functions-example` (lib) due to previous error
|
||||
error: could not compile `functions-example` (lib) due to 1 previous error
|
||||
|
||||
@@ -9,4 +9,4 @@ error[E0133]: call to unsafe function is unsafe and requires unsafe function or
|
||||
= note: consult the function's documentation for information on how to avoid undefined behavior
|
||||
|
||||
For more information about this error, try `rustc --explain E0133`.
|
||||
error: could not compile `unsafe-example` (bin "unsafe-example") due to previous error
|
||||
error: could not compile `unsafe-example` (bin "unsafe-example") due to 1 previous error
|
||||
|
||||
@@ -7,4 +7,4 @@ error[E0433]: failed to resolve: use of undeclared type `ThreadPool`
|
||||
| ^^^^^^^^^^ use of undeclared type `ThreadPool`
|
||||
|
||||
For more information about this error, try `rustc --explain E0433`.
|
||||
error: could not compile `hello` (bin "hello") due to previous error
|
||||
error: could not compile `hello` (bin "hello") due to 1 previous error
|
||||
|
||||
@@ -18,4 +18,4 @@ note: consider changing this parameter type in method `new` to borrow instead if
|
||||
| --- in this method ^^^^^^^^^^^^^^^^^^^ this parameter takes ownership of the value
|
||||
|
||||
For more information about this error, try `rustc --explain E0382`.
|
||||
error: could not compile `hello` (lib) due to previous error
|
||||
error: could not compile `hello` (lib) due to 1 previous error
|
||||
|
||||
@@ -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::<T>::join` takes ownership of the receiver `self`, which moves `worker.thread`
|
||||
--> /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/mod.rs:1652:17
|
||||
--> /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/thread/mod.rs:1649:17
|
||||
|
||||
For more information about this error, try `rustc --explain E0507`.
|
||||
error: could not compile `hello` (lib) due to previous error
|
||||
error: could not compile `hello` (lib) due to 1 previous error
|
||||
|
||||
@@ -7,4 +7,4 @@ error[E0599]: no function or associated item named `new` found for struct `Threa
|
||||
| ^^^ function or associated item not found in `ThreadPool`
|
||||
|
||||
For more information about this error, try `rustc --explain E0599`.
|
||||
error: could not compile `hello` (bin "hello") due to previous error
|
||||
error: could not compile `hello` (bin "hello") due to 1 previous error
|
||||
|
||||
@@ -7,4 +7,4 @@ error[E0599]: no method named `execute` found for struct `ThreadPool` in the cur
|
||||
| -----^^^^^^^ method not found in `ThreadPool`
|
||||
|
||||
For more information about this error, try `rustc --explain E0599`.
|
||||
error: could not compile `hello` (bin "hello") due to previous error
|
||||
error: could not compile `hello` (bin "hello") due to 1 previous error
|
||||
|
||||
@@ -7,7 +7,7 @@ error[E0599]: no method named `join` found for enum `Option` in the current scop
|
||||
| ^^^^ method not found in `Option<JoinHandle<()>>`
|
||||
|
|
||||
note: the method `join` exists on the type `JoinHandle<()>`
|
||||
--> /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/mod.rs:1652:5
|
||||
--> /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/thread/mod.rs:1649:5
|
||||
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();
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.75
|
||||
1.76
|
||||
|
||||
@@ -352,7 +352,8 @@ cargo run
|
||||
-->
|
||||
|
||||
```console
|
||||
thread 'main' panicked at 'index out of bounds: the len is 5 but the index is 10', src/main.rs:19:19
|
||||
thread 'main' panicked at src/main.rs:19:19:
|
||||
index out of bounds: the len is 5 but the index is 10
|
||||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
|
||||
```
|
||||
|
||||
|
||||
@@ -278,7 +278,7 @@ implement them on any type, including unit-like structs.
|
||||
> |
|
||||
>
|
||||
> For more information about this error, try `rustc --explain E0106`.
|
||||
> error: could not compile `structs` due to 2 previous errors
|
||||
> error: could not compile `structs` (bin "structs") due to 2 previous errors
|
||||
> ```
|
||||
>
|
||||
> In Chapter 10, we’ll discuss how to fix these errors so you can store
|
||||
|
||||
@@ -117,24 +117,25 @@ check the backtrace number mentioned in the text below the listing
|
||||
|
||||
```console
|
||||
$ RUST_BACKTRACE=1 cargo run
|
||||
thread 'main' panicked at 'index out of bounds: the len is 3 but the index is 99', src/main.rs:4:5
|
||||
thread 'main' panicked at src/main.rs:4:6:
|
||||
index out of bounds: the len is 3 but the index is 99
|
||||
stack backtrace:
|
||||
0: rust_begin_unwind
|
||||
at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/panicking.rs:584:5
|
||||
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:645:5
|
||||
1: core::panicking::panic_fmt
|
||||
at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/panicking.rs:142:14
|
||||
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:72:14
|
||||
2: core::panicking::panic_bounds_check
|
||||
at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/panicking.rs:84:5
|
||||
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:208:5
|
||||
3: <usize as core::slice::index::SliceIndex<[T]>>::index
|
||||
at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/slice/index.rs:242:10
|
||||
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/slice/index.rs:255:10
|
||||
4: core::slice::index::<impl core::ops::index::Index<I> for [T]>::index
|
||||
at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/slice/index.rs:18:9
|
||||
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/slice/index.rs:18:9
|
||||
5: <alloc::vec::Vec<T,A> as core::ops::index::Index<I>>::index
|
||||
at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/alloc/src/vec/mod.rs:2591:9
|
||||
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/alloc/src/vec/mod.rs:2770:9
|
||||
6: panic::main
|
||||
at ./src/main.rs:4:5
|
||||
at ./src/main.rs:4:6
|
||||
7: core::ops::function::FnOnce::call_once
|
||||
at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/ops/function.rs:248:5
|
||||
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:250:5
|
||||
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
|
||||
```
|
||||
|
||||
|
||||
@@ -188,9 +188,8 @@ copy and paste relevant text
|
||||
-->
|
||||
|
||||
```text
|
||||
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os {
|
||||
code: 2, kind: NotFound, message: "No such file or directory" }',
|
||||
src/main.rs:4:49
|
||||
thread 'main' panicked at src/main.rs:4:49:
|
||||
called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }
|
||||
```
|
||||
|
||||
Similarly, the `expect` method lets us also choose the `panic!` error message.
|
||||
@@ -216,9 +215,8 @@ copy and paste relevant text
|
||||
-->
|
||||
|
||||
```text
|
||||
thread 'main' panicked at 'hello.txt should be included in this project: Os {
|
||||
code: 2, kind: NotFound, message: "No such file or directory" }',
|
||||
src/main.rs:5:10
|
||||
thread 'main' panicked at src/main.rs:5:10:
|
||||
hello.txt should be included in this project: Os { code: 2, kind: NotFound, message: "No such file or directory" }
|
||||
```
|
||||
|
||||
In production-quality code, most Rustaceans choose `expect` rather than
|
||||
|
||||
@@ -193,7 +193,7 @@ after doing automatic regeneration, look at listings/ch15-smart-pointers/listing
|
||||
-->
|
||||
|
||||
```text
|
||||
help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `List` representable
|
||||
help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle
|
||||
|
|
||||
2 | Cons(i32, Box<List>),
|
||||
| ++++ +
|
||||
|
||||
@@ -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.75.0 (released 2023-12-28)
|
||||
This version of the text assumes you’re using Rust 1.76.0 (released 2024-02-08)
|
||||
or later. See the [“Installation” section of Chapter 1][install]<!-- ignore -->
|
||||
to install or update Rust.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user