From 6e988056292ce5af6910412b8d220d314e836e6e Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Mon, 30 Nov 2020 15:14:06 -0500 Subject: [PATCH 01/13] Update to 1.42 --- .github/workflows/main.yml | 4 +-- .../output.txt | 27 +++++++++++++++++-- .../output.txt | 2 +- .../output.txt | 17 ++++++++++-- .../listing-07-03/output.txt | 16 +++++++++-- .../listing-07-05/output.txt | 16 +++++++++-- .../output.txt | 4 +-- .../listing-09-01/output.txt | 4 +-- .../listing-09-04/output.txt | 2 +- .../no-listing-01-panic/output.txt | 2 +- .../listing-10-05/output.txt | 8 +++--- .../listing-10-21/output.txt | 6 ++++- .../listing-11-03/output.txt | 2 +- .../listing-11-10/output.txt | 4 +-- .../output.txt | 2 +- .../no-listing-04-bug-in-add-two/output.txt | 2 +- .../no-listing-06-greeter-with-bug/output.txt | 2 +- .../output.txt | 2 +- .../output.txt | 2 +- .../output-only-01-show-output/output.txt | 2 +- .../listing-12-07/output.txt | 2 +- .../listing-12-08/output.txt | 2 +- .../listing-12-16/output.txt | 2 +- .../output.txt | 6 ++++- .../output.txt | 2 +- .../output-only-01-adder-crate/add/Cargo.lock | 5 ++++ .../listing-15-23/output.txt | 4 +-- .../listing-16-14/output.txt | 11 ++++++-- .../no-listing-18-returns-closure/output.txt | 16 ++--------- .../output.txt | 2 +- .../output.txt | 2 +- .../output.txt | 2 +- rust-toolchain | 2 +- src/ch05-01-defining-structs.md | 17 ++++++++++-- src/title-page.md | 2 +- 35 files changed, 142 insertions(+), 61 deletions(-) create mode 100644 listings/ch14-more-about-cargo/output-only-01-adder-crate/add/Cargo.lock diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 575853a837..763847329d 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.41.0 -c rust-docs - rustup default 1.41.0 + rustup toolchain install 1.42 -c rust-docs + rustup default 1.42 - name: Install mdbook run: | mkdir bin diff --git a/listings/ch03-common-programming-concepts/no-listing-19-statements-vs-expressions/output.txt b/listings/ch03-common-programming-concepts/no-listing-19-statements-vs-expressions/output.txt index 548ce3270b..0c4fd396e3 100644 --- a/listings/ch03-common-programming-concepts/no-listing-19-statements-vs-expressions/output.txt +++ b/listings/ch03-common-programming-concepts/no-listing-19-statements-vs-expressions/output.txt @@ -1,9 +1,32 @@ $ cargo run Compiling functions v0.1.0 (file:///projects/functions) +error[E0658]: `let` expressions in this position are experimental + --> src/main.rs:2:14 + | +2 | let x = (let y = 6); + | ^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/53667 + error: expected expression, found statement (`let`) --> src/main.rs:2:14 | 2 | let x = (let y = 6); - | ^^^ + | ^^^^^^^^^ + | + = note: variable declaration using `let` is a statement + +warning: unnecessary parentheses around assigned value + --> src/main.rs:2:13 + | +2 | let x = (let y = 6); + | ^^^^^^^^^^^ help: remove these parentheses | - = note: variable declaration using `let` is a statement \ No newline at end of file + = note: `#[warn(unused_parens)]` on by default + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. +error: could not compile `functions`. + +To learn more, run the command again with --verbose. diff --git a/listings/ch03-common-programming-concepts/no-listing-31-arms-must-return-same-type/output.txt b/listings/ch03-common-programming-concepts/no-listing-31-arms-must-return-same-type/output.txt index f47a2a8067..b576c972eb 100644 --- a/listings/ch03-common-programming-concepts/no-listing-31-arms-must-return-same-type/output.txt +++ b/listings/ch03-common-programming-concepts/no-listing-31-arms-must-return-same-type/output.txt @@ -1,6 +1,6 @@ $ cargo run Compiling branches v0.1.0 (file:///projects/branches) -error[E0308]: if and else have incompatible types +error[E0308]: `if` and `else` have incompatible types --> src/main.rs:4:44 | 4 | let number = if condition { 5 } else { "six" }; diff --git a/listings/ch05-using-structs-to-structure-related-data/no-listing-02-reference-in-struct/output.txt b/listings/ch05-using-structs-to-structure-related-data/no-listing-02-reference-in-struct/output.txt index 9a75534c3b..4d1b4beb25 100644 --- a/listings/ch05-using-structs-to-structure-related-data/no-listing-02-reference-in-struct/output.txt +++ b/listings/ch05-using-structs-to-structure-related-data/no-listing-02-reference-in-struct/output.txt @@ -4,13 +4,26 @@ error[E0106]: missing lifetime specifier --> src/main.rs:2:15 | 2 | username: &str, - | ^ expected lifetime parameter + | ^ expected named lifetime parameter + | +help: consider introducing a named lifetime parameter + | +1 | struct User<'lifetime> { +2 | username: &'lifetime str, + | error[E0106]: missing lifetime specifier --> src/main.rs:3:12 | 3 | email: &str, - | ^ expected lifetime parameter + | ^ expected named lifetime parameter + | +help: consider introducing a named lifetime parameter + | +1 | struct User<'lifetime> { +2 | username: &str, +3 | email: &'lifetime str, + | error: aborting due to 2 previous errors 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 2a494c29ea..e4030eb996 100644 --- a/listings/ch07-managing-growing-projects/listing-07-03/output.txt +++ b/listings/ch07-managing-growing-projects/listing-07-03/output.txt @@ -4,13 +4,25 @@ error[E0603]: module `hosting` is private --> src/lib.rs:9:28 | 9 | crate::front_of_house::hosting::add_to_waitlist(); - | ^^^^^^^ + | ^^^^^^^ this module is private + | +note: the module `hosting` is defined here + --> src/lib.rs:2:5 + | +2 | mod hosting { + | ^^^^^^^^^^^ error[E0603]: module `hosting` is private --> src/lib.rs:12:21 | 12 | front_of_house::hosting::add_to_waitlist(); - | ^^^^^^^ + | ^^^^^^^ this module is private + | +note: the module `hosting` is defined here + --> src/lib.rs:2:5 + | +2 | mod hosting { + | ^^^^^^^^^^^ error: aborting due to 2 previous errors 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 664c6a4800..a06f4dd3c7 100644 --- a/listings/ch07-managing-growing-projects/listing-07-05/output.txt +++ b/listings/ch07-managing-growing-projects/listing-07-05/output.txt @@ -4,13 +4,25 @@ error[E0603]: function `add_to_waitlist` is private --> src/lib.rs:9:37 | 9 | crate::front_of_house::hosting::add_to_waitlist(); - | ^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ this function is private + | +note: the function `add_to_waitlist` is defined here + --> src/lib.rs:3:9 + | +3 | fn add_to_waitlist() {} + | ^^^^^^^^^^^^^^^^^^^^ error[E0603]: function `add_to_waitlist` is private --> src/lib.rs:12:30 | 12 | front_of_house::hosting::add_to_waitlist(); - | ^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ this function is private + | +note: the function `add_to_waitlist` is defined here + --> src/lib.rs:3:9 + | +3 | fn add_to_waitlist() {} + | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/listings/ch08-common-collections/output-only-01-not-char-boundary/output.txt b/listings/ch08-common-collections/output-only-01-not-char-boundary/output.txt index e05d332339..621e16b431 100644 --- a/listings/ch08-common-collections/output-only-01-not-char-boundary/output.txt +++ b/listings/ch08-common-collections/output-only-01-not-char-boundary/output.txt @@ -2,5 +2,5 @@ $ cargo run Compiling collections v0.1.0 (file:///projects/collections) Finished dev [unoptimized + debuginfo] target(s) in 0.43s Running `target/debug/collections` -thread 'main' panicked at 'byte index 1 is not a char boundary; it is inside 'З' (bytes 0..2) of `Здравствуйте`', src/libcore/str/mod.rs:2069:5 -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. +thread 'main' panicked at 'byte index 1 is not a char boundary; it is inside 'З' (bytes 0..2) of `Здравствуйте`', src/libcore/str/mod.rs:2154:5 +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/listings/ch09-error-handling/listing-09-01/output.txt b/listings/ch09-error-handling/listing-09-01/output.txt index 36aef5049e..631390368b 100644 --- a/listings/ch09-error-handling/listing-09-01/output.txt +++ b/listings/ch09-error-handling/listing-09-01/output.txt @@ -2,5 +2,5 @@ $ cargo run Compiling panic v0.1.0 (file:///projects/panic) Finished dev [unoptimized + debuginfo] target(s) in 0.27s Running `target/debug/panic` -thread 'main' panicked at 'index out of bounds: the len is 3 but the index is 99', /rustc/5e1a799842ba6ed4a57e91f7ab9435947482f7d8/src/libcore/slice/mod.rs:2806:10 -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. +thread 'main' panicked at 'index out of bounds: the len is 3 but the index is 99', /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447/src/libcore/slice/mod.rs:2791:10 +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/listings/ch09-error-handling/listing-09-04/output.txt b/listings/ch09-error-handling/listing-09-04/output.txt index acc4f0c741..f776a591ce 100644 --- a/listings/ch09-error-handling/listing-09-04/output.txt +++ b/listings/ch09-error-handling/listing-09-04/output.txt @@ -3,4 +3,4 @@ $ cargo run Finished dev [unoptimized + debuginfo] target(s) in 0.73s Running `target/debug/error-handling` thread 'main' panicked at 'Problem opening the file: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/main.rs:8:23 -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/listings/ch09-error-handling/no-listing-01-panic/output.txt b/listings/ch09-error-handling/no-listing-01-panic/output.txt index 1bc3dc729a..b25ed85d7c 100644 --- a/listings/ch09-error-handling/no-listing-01-panic/output.txt +++ b/listings/ch09-error-handling/no-listing-01-panic/output.txt @@ -3,4 +3,4 @@ $ cargo run Finished dev [unoptimized + debuginfo] target(s) in 0.25s Running `target/debug/panic` thread 'main' panicked at 'crash and burn', src/main.rs:2:5 -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-05/output.txt b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-05/output.txt index 65498128db..8018aafed7 100644 --- a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-05/output.txt +++ b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-05/output.txt @@ -1,14 +1,14 @@ $ cargo run Compiling chapter10 v0.1.0 (file:///projects/chapter10) -error[E0369]: binary operation `>` cannot be applied to type `T` +error[E0369]: binary operation `>` cannot be applied to type `&T` --> src/main.rs:5:17 | 5 | if item > largest { - | ---- ^ ------- T + | ---- ^ ------- &T | | - | T + | &T | - = note: `T` might need a bound for `std::cmp::PartialOrd` + = note: an implementation of `std::cmp::PartialOrd` might be missing for `&T` error: aborting due to previous error diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-21/output.txt b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-21/output.txt index 21fb936145..9432339ff0 100644 --- a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-21/output.txt +++ b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-21/output.txt @@ -4,9 +4,13 @@ error[E0106]: missing lifetime specifier --> src/main.rs:9:33 | 9 | fn longest(x: &str, y: &str) -> &str { - | ^ expected lifetime parameter + | ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from `x` or `y` +help: consider introducing a named lifetime parameter + | +9 | fn longest<'lifetime>(x: &str, y: &str) -> &'lifetime str { + | ^^^^^^^^^^^ ^^^^^^^^^^ error: aborting due to previous error diff --git a/listings/ch11-writing-automated-tests/listing-11-03/output.txt b/listings/ch11-writing-automated-tests/listing-11-03/output.txt index c39456f818..bbe077e7e2 100644 --- a/listings/ch11-writing-automated-tests/listing-11-03/output.txt +++ b/listings/ch11-writing-automated-tests/listing-11-03/output.txt @@ -11,7 +11,7 @@ failures: ---- tests::another stdout ---- thread 'main' panicked at 'Make this test fail', src/lib.rs:10:9 -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace failures: diff --git a/listings/ch11-writing-automated-tests/listing-11-10/output.txt b/listings/ch11-writing-automated-tests/listing-11-10/output.txt index 1621d796b0..817543cd2b 100644 --- a/listings/ch11-writing-automated-tests/listing-11-10/output.txt +++ b/listings/ch11-writing-automated-tests/listing-11-10/output.txt @@ -13,8 +13,8 @@ failures: I got the value 8 thread 'main' panicked at 'assertion failed: `(left == right)` left: `5`, - right: `10`', src/lib.rs:19:9 -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. + right: `10`', src/lib.rs:20:9 +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace failures: diff --git a/listings/ch11-writing-automated-tests/no-listing-03-introducing-a-bug/output.txt b/listings/ch11-writing-automated-tests/no-listing-03-introducing-a-bug/output.txt index 8f050a252d..b01fab9062 100644 --- a/listings/ch11-writing-automated-tests/no-listing-03-introducing-a-bug/output.txt +++ b/listings/ch11-writing-automated-tests/no-listing-03-introducing-a-bug/output.txt @@ -11,7 +11,7 @@ failures: ---- tests::larger_can_hold_smaller stdout ---- thread 'main' panicked at 'assertion failed: larger.can_hold(&smaller)', src/lib.rs:28:9 -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace failures: diff --git a/listings/ch11-writing-automated-tests/no-listing-04-bug-in-add-two/output.txt b/listings/ch11-writing-automated-tests/no-listing-04-bug-in-add-two/output.txt index 7fb67743eb..3a9a82c3a7 100644 --- a/listings/ch11-writing-automated-tests/no-listing-04-bug-in-add-two/output.txt +++ b/listings/ch11-writing-automated-tests/no-listing-04-bug-in-add-two/output.txt @@ -12,7 +12,7 @@ failures: thread 'main' panicked at 'assertion failed: `(left == right)` left: `4`, right: `5`', src/lib.rs:11:9 -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace failures: diff --git a/listings/ch11-writing-automated-tests/no-listing-06-greeter-with-bug/output.txt b/listings/ch11-writing-automated-tests/no-listing-06-greeter-with-bug/output.txt index 8f832a7432..d8fab6a91c 100644 --- a/listings/ch11-writing-automated-tests/no-listing-06-greeter-with-bug/output.txt +++ b/listings/ch11-writing-automated-tests/no-listing-06-greeter-with-bug/output.txt @@ -10,7 +10,7 @@ failures: ---- tests::greeting_contains_name stdout ---- thread 'main' panicked at 'assertion failed: result.contains("Carol")', src/lib.rs:12:9 -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace failures: diff --git a/listings/ch11-writing-automated-tests/no-listing-07-custom-failure-message/output.txt b/listings/ch11-writing-automated-tests/no-listing-07-custom-failure-message/output.txt index c3a735e4d4..281e3746a1 100644 --- a/listings/ch11-writing-automated-tests/no-listing-07-custom-failure-message/output.txt +++ b/listings/ch11-writing-automated-tests/no-listing-07-custom-failure-message/output.txt @@ -10,7 +10,7 @@ failures: ---- tests::greeting_contains_name stdout ---- thread 'main' panicked at 'Greeting did not contain name, value was `Hello!`', src/lib.rs:12:9 -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace failures: diff --git a/listings/ch11-writing-automated-tests/no-listing-09-guess-with-panic-msg-bug/output.txt b/listings/ch11-writing-automated-tests/no-listing-09-guess-with-panic-msg-bug/output.txt index f2b8ffc7c3..0e8cf48861 100644 --- a/listings/ch11-writing-automated-tests/no-listing-09-guess-with-panic-msg-bug/output.txt +++ b/listings/ch11-writing-automated-tests/no-listing-09-guess-with-panic-msg-bug/output.txt @@ -10,7 +10,7 @@ failures: ---- tests::greater_than_100 stdout ---- thread 'main' panicked at 'Guess value must be greater than or equal to 1, got 200.', src/lib.rs:13:13 -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: panic did not contain expected string panic message: `"Guess value must be greater than or equal to 1, got 200."`, expected substring: `"Guess value must be less than or equal to 100"` diff --git a/listings/ch11-writing-automated-tests/output-only-01-show-output/output.txt b/listings/ch11-writing-automated-tests/output-only-01-show-output/output.txt index 901df6ae63..3bff4258ab 100644 --- a/listings/ch11-writing-automated-tests/output-only-01-show-output/output.txt +++ b/listings/ch11-writing-automated-tests/output-only-01-show-output/output.txt @@ -23,7 +23,7 @@ I got the value 8 thread 'main' panicked at 'assertion failed: `(left == right)` left: `5`, right: `10`', src/lib.rs:19:9 -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace failures: diff --git a/listings/ch12-an-io-project/listing-12-07/output.txt b/listings/ch12-an-io-project/listing-12-07/output.txt index 8c8d53aa8b..d3fa7777d5 100644 --- a/listings/ch12-an-io-project/listing-12-07/output.txt +++ b/listings/ch12-an-io-project/listing-12-07/output.txt @@ -3,4 +3,4 @@ $ cargo run Finished dev [unoptimized + debuginfo] target(s) in 0.0s Running `target/debug/minigrep` thread 'main' panicked at 'index out of bounds: the len is 1 but the index is 1', src/main.rs:27:21 -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/listings/ch12-an-io-project/listing-12-08/output.txt b/listings/ch12-an-io-project/listing-12-08/output.txt index fa5d235eb5..de2abd1afc 100644 --- a/listings/ch12-an-io-project/listing-12-08/output.txt +++ b/listings/ch12-an-io-project/listing-12-08/output.txt @@ -3,4 +3,4 @@ $ cargo run Finished dev [unoptimized + debuginfo] target(s) in 0.0s Running `target/debug/minigrep` thread 'main' panicked at 'not enough arguments', src/main.rs:26:13 -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/listings/ch12-an-io-project/listing-12-16/output.txt b/listings/ch12-an-io-project/listing-12-16/output.txt index a7a676ec3d..8c60f26576 100644 --- a/listings/ch12-an-io-project/listing-12-16/output.txt +++ b/listings/ch12-an-io-project/listing-12-16/output.txt @@ -12,7 +12,7 @@ failures: thread 'main' panicked at 'assertion failed: `(left == right)` left: `["safe, fast, productive."]`, right: `[]`', src/lib.rs:44:9 -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace failures: diff --git a/listings/ch12-an-io-project/output-only-02-missing-lifetimes/output.txt b/listings/ch12-an-io-project/output-only-02-missing-lifetimes/output.txt index b76084b0f1..a1a481cbb7 100644 --- a/listings/ch12-an-io-project/output-only-02-missing-lifetimes/output.txt +++ b/listings/ch12-an-io-project/output-only-02-missing-lifetimes/output.txt @@ -4,9 +4,13 @@ error[E0106]: missing lifetime specifier --> src/lib.rs:28:51 | 28 | pub fn search(query: &str, contents: &str) -> Vec<&str> { - | ^ expected lifetime parameter + | ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from `query` or `contents` +help: consider introducing a named lifetime parameter + | +28 | pub fn search<'lifetime>(query: &str, contents: &str) -> Vec<&'lifetime str> { + | ^^^^^^^^^^^ ^^^^^^^^^^ error: aborting due to previous error diff --git a/listings/ch13-functional-features/no-listing-01-failing-cacher-test/output.txt b/listings/ch13-functional-features/no-listing-01-failing-cacher-test/output.txt index 378a614d4e..66bff6b60a 100644 --- a/listings/ch13-functional-features/no-listing-01-failing-cacher-test/output.txt +++ b/listings/ch13-functional-features/no-listing-01-failing-cacher-test/output.txt @@ -12,7 +12,7 @@ failures: thread 'main' panicked at 'assertion failed: `(left == right)` left: `1`, right: `2`', src/lib.rs:43:9 -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace failures: diff --git a/listings/ch14-more-about-cargo/output-only-01-adder-crate/add/Cargo.lock b/listings/ch14-more-about-cargo/output-only-01-adder-crate/add/Cargo.lock new file mode 100644 index 0000000000..d98623d6e9 --- /dev/null +++ b/listings/ch14-more-about-cargo/output-only-01-adder-crate/add/Cargo.lock @@ -0,0 +1,5 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "adder" +version = "0.1.0" diff --git a/listings/ch15-smart-pointers/listing-15-23/output.txt b/listings/ch15-smart-pointers/listing-15-23/output.txt index 9d69d439c7..55f6208dd5 100644 --- a/listings/ch15-smart-pointers/listing-15-23/output.txt +++ b/listings/ch15-smart-pointers/listing-15-23/output.txt @@ -9,8 +9,8 @@ test tests::it_sends_an_over_75_percent_warning_message ... FAILED failures: ---- tests::it_sends_an_over_75_percent_warning_message stdout ---- -thread 'main' panicked at 'already borrowed: BorrowMutError', src/libcore/result.rs:1188:5 -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. +thread 'main' panicked at 'already borrowed: BorrowMutError', /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447/src/libcore/cell.rs:878:9 +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace failures: diff --git a/listings/ch16-fearless-concurrency/listing-16-14/output.txt b/listings/ch16-fearless-concurrency/listing-16-14/output.txt index 200c55e220..32225ef19e 100644 --- a/listings/ch16-fearless-concurrency/listing-16-14/output.txt +++ b/listings/ch16-fearless-concurrency/listing-16-14/output.txt @@ -3,8 +3,15 @@ $ cargo run error[E0277]: `std::rc::Rc>` cannot be sent between threads safely --> src/main.rs:11:22 | -11 | let handle = thread::spawn(move || { - | ^^^^^^^^^^^^^ `std::rc::Rc>` cannot be sent between threads safely +11 | let handle = thread::spawn(move || { + | ______________________^^^^^^^^^^^^^_- + | | | + | | `std::rc::Rc>` cannot be sent between threads safely +12 | | let mut num = counter.lock().unwrap(); +13 | | +14 | | *num += 1; +15 | | }); + | |_________- within this `[closure@src/main.rs:11:36: 15:10 counter:std::rc::Rc>]` | = help: within `[closure@src/main.rs:11:36: 15:10 counter:std::rc::Rc>]`, the trait `std::marker::Send` is not implemented for `std::rc::Rc>` = note: required because it appears within the type `[closure@src/main.rs:11:36: 15:10 counter:std::rc::Rc>]` diff --git a/listings/ch19-advanced-features/no-listing-18-returns-closure/output.txt b/listings/ch19-advanced-features/no-listing-18-returns-closure/output.txt index 2d4be9b0a3..9c030d1776 100644 --- a/listings/ch19-advanced-features/no-listing-18-returns-closure/output.txt +++ b/listings/ch19-advanced-features/no-listing-18-returns-closure/output.txt @@ -10,21 +10,9 @@ error[E0277]: the size for values of type `(dyn std::ops::Fn(i32) -> i32 + 'stat = note: to learn more, visit = note: the return type of a function must have a statically known size -error[E0308]: mismatched types - --> src/lib.rs:2:5 - | -1 | fn returns_closure() -> dyn Fn(i32) -> i32 { - | ------------------ expected `(dyn std::ops::Fn(i32) -> i32 + 'static)` because of return type -2 | |x| x + 1 - | ^^^^^^^^^ expected trait `std::ops::Fn`, found closure - | - = note: expected trait object `(dyn std::ops::Fn(i32) -> i32 + 'static)` - found closure `[closure@src/lib.rs:2:5: 2:14]` - -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0277, E0308. -For more information about an error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0277`. error: could not compile `functions-example`. To learn more, run the command again with --verbose. diff --git a/listings/ch20-web-server/no-listing-01-define-threadpool-struct/output.txt b/listings/ch20-web-server/no-listing-01-define-threadpool-struct/output.txt index 0161c7b2c7..1aeb2b9919 100644 --- a/listings/ch20-web-server/no-listing-01-define-threadpool-struct/output.txt +++ b/listings/ch20-web-server/no-listing-01-define-threadpool-struct/output.txt @@ -1,6 +1,6 @@ $ cargo check Checking hello v0.1.0 (file:///projects/hello) -error[E0599]: no function or associated item named `new` found for type `hello::ThreadPool` in the current scope +error[E0599]: no function or associated item named `new` found for struct `hello::ThreadPool` in the current scope --> src/bin/main.rs:11:28 | 11 | let pool = ThreadPool::new(4); diff --git a/listings/ch20-web-server/no-listing-02-impl-threadpool-new/output.txt b/listings/ch20-web-server/no-listing-02-impl-threadpool-new/output.txt index c808b8986b..0489965537 100644 --- a/listings/ch20-web-server/no-listing-02-impl-threadpool-new/output.txt +++ b/listings/ch20-web-server/no-listing-02-impl-threadpool-new/output.txt @@ -1,6 +1,6 @@ $ cargo check Checking hello v0.1.0 (file:///projects/hello) -error[E0599]: no method named `execute` found for type `hello::ThreadPool` in the current scope +error[E0599]: no method named `execute` found for struct `hello::ThreadPool` in the current scope --> src/bin/main.rs:16:14 | 16 | pool.execute(|| { 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 91907cf79a..4ce0cb1416 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,6 +1,6 @@ $ cargo check Checking hello v0.1.0 (file:///projects/hello) -error[E0599]: no method named `join` found for type `std::option::Option>` in the current scope +error[E0599]: no method named `join` found for enum `std::option::Option>` in the current scope --> src/lib.rs:52:27 | 52 | worker.thread.join().unwrap(); diff --git a/rust-toolchain b/rust-toolchain index 7d47e59980..1a6bf91137 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.41.0 +1.42 diff --git a/src/ch05-01-defining-structs.md b/src/ch05-01-defining-structs.md index 590941bb27..ea2cb296b0 100644 --- a/src/ch05-01-defining-structs.md +++ b/src/ch05-01-defining-structs.md @@ -200,13 +200,26 @@ itself. We’ll discuss traits in Chapter 10. > --> src/main.rs:2:15 > | > 2 | username: &str, -> | ^ expected lifetime parameter +> | ^ expected named lifetime parameter +> | +> help: consider introducing a named lifetime parameter +> | +> 1 | struct User<'lifetime> { +> 2 | username: &'lifetime str, +> | > > error[E0106]: missing lifetime specifier > --> src/main.rs:3:12 > | > 3 | email: &str, -> | ^ expected lifetime parameter +> | ^ expected named lifetime parameter +> | +> help: consider introducing a named lifetime parameter +> | +> 1 | struct User<'lifetime> { +> 2 | username: &str, +> 3 | email: &'lifetime str, +> | > > error: aborting due to 2 previous errors > diff --git a/src/title-page.md b/src/title-page.md index c1cb567109..89847e9ca9 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.41.0 or later with +This version of the text assumes you’re using Rust 1.42 or later with `edition="2018"` in *Cargo.toml* of all projects to use Rust 2018 Edition idioms. See the [“Installation” section of Chapter 1][install] to install or update Rust, and see the new [Appendix E][editions] src/main.rs:2:14 diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-11/output.txt b/listings/ch05-using-structs-to-structure-related-data/listing-05-11/output.txt index 1e03d06259..ea5510a8c5 100644 --- a/listings/ch05-using-structs-to-structure-related-data/listing-05-11/output.txt +++ b/listings/ch05-using-structs-to-structure-related-data/listing-05-11/output.txt @@ -9,6 +9,7 @@ error[E0277]: `Rectangle` doesn't implement `std::fmt::Display` = help: the trait `std::fmt::Display` is not implemented for `Rectangle` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead = note: required by `std::fmt::Display::fmt` + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/listings/ch05-using-structs-to-structure-related-data/no-listing-02-reference-in-struct/output.txt b/listings/ch05-using-structs-to-structure-related-data/no-listing-02-reference-in-struct/output.txt index 4d1b4beb25..f05c033eb5 100644 --- a/listings/ch05-using-structs-to-structure-related-data/no-listing-02-reference-in-struct/output.txt +++ b/listings/ch05-using-structs-to-structure-related-data/no-listing-02-reference-in-struct/output.txt @@ -8,8 +8,8 @@ error[E0106]: missing lifetime specifier | help: consider introducing a named lifetime parameter | -1 | struct User<'lifetime> { -2 | username: &'lifetime str, +1 | struct User<'a> { +2 | username: &'a str, | error[E0106]: missing lifetime specifier @@ -20,9 +20,9 @@ error[E0106]: missing lifetime specifier | help: consider introducing a named lifetime parameter | -1 | struct User<'lifetime> { +1 | struct User<'a> { 2 | username: &str, -3 | email: &'lifetime str, +3 | email: &'a str, | error: aborting due to 2 previous errors 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 c891d9342b..3ce9155889 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 @@ -9,6 +9,7 @@ error[E0277]: `Rectangle` doesn't implement `std::fmt::Debug` = help: the trait `std::fmt::Debug` is not implemented for `Rectangle` = note: add `#[derive(Debug)]` or manually implement `std::fmt::Debug` = note: required by `std::fmt::Debug::fmt` + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/listings/ch08-common-collections/output-only-01-not-char-boundary/output.txt b/listings/ch08-common-collections/output-only-01-not-char-boundary/output.txt index 621e16b431..85ba71bf11 100644 --- a/listings/ch08-common-collections/output-only-01-not-char-boundary/output.txt +++ b/listings/ch08-common-collections/output-only-01-not-char-boundary/output.txt @@ -2,5 +2,5 @@ $ cargo run Compiling collections v0.1.0 (file:///projects/collections) Finished dev [unoptimized + debuginfo] target(s) in 0.43s Running `target/debug/collections` -thread 'main' panicked at 'byte index 1 is not a char boundary; it is inside 'З' (bytes 0..2) of `Здравствуйте`', src/libcore/str/mod.rs:2154:5 +thread 'main' panicked at 'byte index 1 is not a char boundary; it is inside 'З' (bytes 0..2) of `Здравствуйте`', src/libcore/str/mod.rs:2219:5 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/listings/ch09-error-handling/listing-09-01/output.txt b/listings/ch09-error-handling/listing-09-01/output.txt index 631390368b..a4dfcae703 100644 --- a/listings/ch09-error-handling/listing-09-01/output.txt +++ b/listings/ch09-error-handling/listing-09-01/output.txt @@ -2,5 +2,5 @@ $ cargo run Compiling panic v0.1.0 (file:///projects/panic) Finished dev [unoptimized + debuginfo] target(s) in 0.27s Running `target/debug/panic` -thread 'main' panicked at 'index out of bounds: the len is 3 but the index is 99', /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447/src/libcore/slice/mod.rs:2791:10 +thread 'main' panicked at 'index out of bounds: the len is 3 but the index is 99', /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd/src/libcore/slice/mod.rs:2842:10 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-05/output.txt b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-05/output.txt index 8018aafed7..a6dd3d2c7e 100644 --- a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-05/output.txt +++ b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-05/output.txt @@ -7,8 +7,6 @@ error[E0369]: binary operation `>` cannot be applied to type `&T` | ---- ^ ------- &T | | | &T - | - = note: an implementation of `std::cmp::PartialOrd` might be missing for `&T` error: aborting due to previous error diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-21/output.txt b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-21/output.txt index 9432339ff0..d102d7123f 100644 --- a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-21/output.txt +++ b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-21/output.txt @@ -4,13 +4,13 @@ error[E0106]: missing lifetime specifier --> src/main.rs:9:33 | 9 | fn longest(x: &str, y: &str) -> &str { - | ^ expected named lifetime parameter + | ---- ---- ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from `x` or `y` help: consider introducing a named lifetime parameter | -9 | fn longest<'lifetime>(x: &str, y: &str) -> &'lifetime str { - | ^^^^^^^^^^^ ^^^^^^^^^^ +9 | fn longest<'a>(x: &'a str, y: &'a str) -> &'a str { + | ^^^^ ^^^^^^^ ^^^^^^^ ^^^ error: aborting due to previous error diff --git a/listings/ch12-an-io-project/output-only-02-missing-lifetimes/output.txt b/listings/ch12-an-io-project/output-only-02-missing-lifetimes/output.txt index a1a481cbb7..0fa63e3069 100644 --- a/listings/ch12-an-io-project/output-only-02-missing-lifetimes/output.txt +++ b/listings/ch12-an-io-project/output-only-02-missing-lifetimes/output.txt @@ -4,13 +4,13 @@ error[E0106]: missing lifetime specifier --> src/lib.rs:28:51 | 28 | pub fn search(query: &str, contents: &str) -> Vec<&str> { - | ^ expected named lifetime parameter + | ---- ---- ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from `query` or `contents` help: consider introducing a named lifetime parameter | -28 | pub fn search<'lifetime>(query: &str, contents: &str) -> Vec<&'lifetime str> { - | ^^^^^^^^^^^ ^^^^^^^^^^ +28 | pub fn search<'a>(query: &'a str, contents: &'a str) -> Vec<&'a str> { + | ^^^^ ^^^^^^^ ^^^^^^^ ^^^ error: aborting 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 851b5caf98..83377f3e02 100644 --- a/listings/ch15-smart-pointers/listing-15-21/output.txt +++ b/listings/ch15-smart-pointers/listing-15-21/output.txt @@ -14,3 +14,5 @@ For more information about this error, try `rustc --explain E0596`. error: could not compile `limit-tracker`. To learn more, run the command again with --verbose. +warning: build failed, waiting for other jobs to finish... +error: build failed diff --git a/listings/ch15-smart-pointers/listing-15-23/output.txt b/listings/ch15-smart-pointers/listing-15-23/output.txt index 55f6208dd5..1bac4003d2 100644 --- a/listings/ch15-smart-pointers/listing-15-23/output.txt +++ b/listings/ch15-smart-pointers/listing-15-23/output.txt @@ -9,7 +9,7 @@ test tests::it_sends_an_over_75_percent_warning_message ... FAILED failures: ---- tests::it_sends_an_over_75_percent_warning_message stdout ---- -thread 'main' panicked at 'already borrowed: BorrowMutError', /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447/src/libcore/cell.rs:878:9 +thread 'main' panicked at 'already borrowed: BorrowMutError', /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd/src/libcore/cell.rs:878:9 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/listings/ch15-smart-pointers/output-only-01-comparing-to-reference/output.txt b/listings/ch15-smart-pointers/output-only-01-comparing-to-reference/output.txt index 4368ee65f6..e4edda0500 100644 --- a/listings/ch15-smart-pointers/output-only-01-comparing-to-reference/output.txt +++ b/listings/ch15-smart-pointers/output-only-01-comparing-to-reference/output.txt @@ -7,7 +7,7 @@ error[E0277]: can't compare `{integer}` with `&{integer}` | ^^^^^^^^^^^^^^^^^ no implementation for `{integer} == &{integer}` | = help: the trait `std::cmp::PartialEq<&{integer}>` is not implemented for `{integer}` - = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/listings/ch17-oop/no-listing-01-trait-object-of-clone/output.txt b/listings/ch17-oop/no-listing-01-trait-object-of-clone/output.txt index 33a492556d..48e88dae63 100644 --- a/listings/ch17-oop/no-listing-01-trait-object-of-clone/output.txt +++ b/listings/ch17-oop/no-listing-01-trait-object-of-clone/output.txt @@ -6,7 +6,7 @@ error[E0038]: the trait `std::clone::Clone` cannot be made into an object 2 | pub components: Vec>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::clone::Clone` cannot be made into an object | - = note: the trait cannot require that `Self : Sized` + = note: the trait cannot be made into an object because it requires `Self: Sized` error: aborting due to previous error diff --git a/listings/ch18-patterns-and-matching/listing-18-05/output.txt b/listings/ch18-patterns-and-matching/listing-18-05/output.txt index eae835e37c..23a960f0fe 100644 --- a/listings/ch18-patterns-and-matching/listing-18-05/output.txt +++ b/listings/ch18-patterns-and-matching/listing-18-05/output.txt @@ -4,7 +4,9 @@ error[E0308]: mismatched types --> src/main.rs:2:9 | 2 | let (x, y) = (1, 2, 3); - | ^^^^^^ expected a tuple with 3 elements, found one with 2 elements + | ^^^^^^ --------- this expression has type `({integer}, {integer}, {integer})` + | | + | expected a tuple with 3 elements, found one with 2 elements | = note: expected tuple `({integer}, {integer}, {integer})` found tuple `(_, _)` diff --git a/rust-toolchain b/rust-toolchain index 1a6bf91137..d9d7ef5a4b 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.42 +1.43 diff --git a/src/title-page.md b/src/title-page.md index 89847e9ca9..ec1cee08f4 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.42 or later with +This version of the text assumes you’re using Rust 1.43 or later with `edition="2018"` in *Cargo.toml* of all projects to use Rust 2018 Edition idioms. See the [“Installation” section of Chapter 1][install] to install or update Rust, and see the new [Appendix E][editions] src/main.rs:5:19 - | -5 | let element = a[index]; - | ^^^^^^^^ index out of bounds: the len is 5 but the index is 10 - | - = note: `#[deny(unconditional_panic)]` on by default - -error: aborting due to previous error - -error: could not compile `arrays`. - -To learn more, run the command again with --verbose. + Finished dev [unoptimized + debuginfo] target(s) in 0.97s + Running `target/debug/arrays` +thread 'main' panicked at 'index out of bounds: the len is 5 but the index is 10', src/main.rs:5:19 +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/listings/ch03-common-programming-concepts/no-listing-19-statements-vs-expressions/output.txt b/listings/ch03-common-programming-concepts/no-listing-19-statements-vs-expressions/output.txt index 6b0844bc7c..879946f649 100644 --- a/listings/ch03-common-programming-concepts/no-listing-19-statements-vs-expressions/output.txt +++ b/listings/ch03-common-programming-concepts/no-listing-19-statements-vs-expressions/output.txt @@ -24,7 +24,7 @@ warning: unnecessary parentheses around assigned value | = note: `#[warn(unused_parens)]` on by default -error: aborting due to 2 previous errors +error: aborting due to 2 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0658`. error: could not compile `functions`. 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 da9e9d9bfe..6c9b69a119 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,12 +1,13 @@ $ 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 - | - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + --> src/main.rs:3:15 + | +3 | match x { + | ^ pattern `None` not covered + | + = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + = note: the matched value is of type `std::option::Option` error: aborting due to previous error 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 e4030eb996..088e092417 100644 --- a/listings/ch07-managing-growing-projects/listing-07-03/output.txt +++ b/listings/ch07-managing-growing-projects/listing-07-03/output.txt @@ -4,7 +4,7 @@ error[E0603]: module `hosting` is private --> src/lib.rs:9:28 | 9 | crate::front_of_house::hosting::add_to_waitlist(); - | ^^^^^^^ this module is private + | ^^^^^^^ private module | note: the module `hosting` is defined here --> src/lib.rs:2:5 @@ -16,7 +16,7 @@ error[E0603]: module `hosting` is private --> src/lib.rs:12:21 | 12 | front_of_house::hosting::add_to_waitlist(); - | ^^^^^^^ this module is private + | ^^^^^^^ private module | note: the module `hosting` is defined here --> src/lib.rs:2:5 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 a06f4dd3c7..552959b246 100644 --- a/listings/ch07-managing-growing-projects/listing-07-05/output.txt +++ b/listings/ch07-managing-growing-projects/listing-07-05/output.txt @@ -4,7 +4,7 @@ error[E0603]: function `add_to_waitlist` is private --> src/lib.rs:9:37 | 9 | crate::front_of_house::hosting::add_to_waitlist(); - | ^^^^^^^^^^^^^^^ this function is private + | ^^^^^^^^^^^^^^^ private function | note: the function `add_to_waitlist` is defined here --> src/lib.rs:3:9 @@ -16,7 +16,7 @@ error[E0603]: function `add_to_waitlist` is private --> src/lib.rs:12:30 | 12 | front_of_house::hosting::add_to_waitlist(); - | ^^^^^^^^^^^^^^^ this function is private + | ^^^^^^^^^^^^^^^ private function | note: the function `add_to_waitlist` is defined here --> src/lib.rs:3:9 diff --git a/listings/ch08-common-collections/output-only-01-not-char-boundary/output.txt b/listings/ch08-common-collections/output-only-01-not-char-boundary/output.txt index 85ba71bf11..54a42c8fa1 100644 --- a/listings/ch08-common-collections/output-only-01-not-char-boundary/output.txt +++ b/listings/ch08-common-collections/output-only-01-not-char-boundary/output.txt @@ -2,5 +2,5 @@ $ cargo run Compiling collections v0.1.0 (file:///projects/collections) Finished dev [unoptimized + debuginfo] target(s) in 0.43s Running `target/debug/collections` -thread 'main' panicked at 'byte index 1 is not a char boundary; it is inside 'З' (bytes 0..2) of `Здравствуйте`', src/libcore/str/mod.rs:2219:5 +thread 'main' panicked at 'byte index 1 is not a char boundary; it is inside 'З' (bytes 0..2) of `Здравствуйте`', /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7/src/libcore/str/mod.rs:1920:47 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/listings/ch09-error-handling/listing-09-01/output.txt b/listings/ch09-error-handling/listing-09-01/output.txt index a4dfcae703..89aebb952f 100644 --- a/listings/ch09-error-handling/listing-09-01/output.txt +++ b/listings/ch09-error-handling/listing-09-01/output.txt @@ -2,5 +2,5 @@ $ cargo run Compiling panic v0.1.0 (file:///projects/panic) Finished dev [unoptimized + debuginfo] target(s) in 0.27s Running `target/debug/panic` -thread 'main' panicked at 'index out of bounds: the len is 3 but the index is 99', /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd/src/libcore/slice/mod.rs:2842:10 +thread 'main' panicked at 'index out of bounds: the len is 3 but the index is 99', src/main.rs:4:5 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/listings/ch12-an-io-project/listing-12-12/output.txt b/listings/ch12-an-io-project/listing-12-12/output.txt index 565479d0c8..71562ed41c 100644 --- a/listings/ch12-an-io-project/listing-12-12/output.txt +++ b/listings/ch12-an-io-project/listing-12-12/output.txt @@ -9,6 +9,8 @@ warning: unused `std::result::Result` that must be used = note: `#[warn(unused_must_use)]` on by default = note: this `Result` may be an `Err` variant, which should be handled +warning: 1 warning emitted + Finished dev [unoptimized + debuginfo] target(s) in 0.71s Running `target/debug/minigrep the poem.txt` Searching for the diff --git a/listings/ch13-functional-features/listing-13-17/output.txt b/listings/ch13-functional-features/listing-13-17/output.txt index ff02254be7..970a315762 100644 --- a/listings/ch13-functional-features/listing-13-17/output.txt +++ b/listings/ch13-functional-features/listing-13-17/output.txt @@ -9,5 +9,7 @@ warning: unused `std::iter::Map` that must be used = note: `#[warn(unused_must_use)]` on by default = note: iterators are lazy and do nothing unless consumed +warning: 1 warning emitted + Finished dev [unoptimized + debuginfo] target(s) in 0.47s Running `target/debug/iterators` diff --git a/listings/ch15-smart-pointers/listing-15-21/output.txt b/listings/ch15-smart-pointers/listing-15-21/output.txt index 83377f3e02..851b5caf98 100644 --- a/listings/ch15-smart-pointers/listing-15-21/output.txt +++ b/listings/ch15-smart-pointers/listing-15-21/output.txt @@ -14,5 +14,3 @@ For more information about this error, try `rustc --explain E0596`. error: could not compile `limit-tracker`. To learn more, run the command again with --verbose. -warning: build failed, waiting for other jobs to finish... -error: build failed diff --git a/listings/ch15-smart-pointers/listing-15-23/output.txt b/listings/ch15-smart-pointers/listing-15-23/output.txt index 1bac4003d2..72450b8acc 100644 --- a/listings/ch15-smart-pointers/listing-15-23/output.txt +++ b/listings/ch15-smart-pointers/listing-15-23/output.txt @@ -9,7 +9,7 @@ test tests::it_sends_an_over_75_percent_warning_message ... FAILED failures: ---- tests::it_sends_an_over_75_percent_warning_message stdout ---- -thread 'main' panicked at 'already borrowed: BorrowMutError', /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd/src/libcore/cell.rs:878:9 +thread 'main' panicked at 'already borrowed: BorrowMutError', /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7/src/libcore/cell.rs:878:9 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace 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 551250ff87..d88dd08a88 100644 --- a/listings/ch18-patterns-and-matching/listing-18-08/output.txt +++ b/listings/ch18-patterns-and-matching/listing-18-08/output.txt @@ -1,17 +1,18 @@ $ cargo run Compiling patterns v0.1.0 (file:///projects/patterns) error[E0005]: refutable pattern in local binding: `None` not covered - --> 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 + --> 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: the matched value is of type `std::option::Option` help: you might want to use `if let` to ignore the variant that isn't matched - | -3 | if let Some(x) = some_option_value { /* */ } - | + | +3 | if let Some(x) = some_option_value { /* */ } + | error: aborting due to previous error diff --git a/listings/ch18-patterns-and-matching/listing-18-10/output.txt b/listings/ch18-patterns-and-matching/listing-18-10/output.txt index 8b72e18134..2fef90cec7 100644 --- a/listings/ch18-patterns-and-matching/listing-18-10/output.txt +++ b/listings/ch18-patterns-and-matching/listing-18-10/output.txt @@ -10,6 +10,8 @@ warning: irrefutable if-let pattern | = note: `#[warn(irrefutable_let_patterns)]` on by default +warning: 1 warning emitted + Finished dev [unoptimized + debuginfo] target(s) in 0.39s Running `target/debug/patterns` 5 diff --git a/listings/ch19-advanced-features/listing-19-20/output.txt b/listings/ch19-advanced-features/listing-19-20/output.txt index 46c7dafa0a..5cabbdb95c 100644 --- a/listings/ch19-advanced-features/listing-19-20/output.txt +++ b/listings/ch19-advanced-features/listing-19-20/output.txt @@ -9,7 +9,7 @@ error[E0283]: type annotations needed 20 | println!("A baby dog is called a {}", Animal::baby_name()); | ^^^^^^^^^^^^^^^^^ cannot infer type | - = note: cannot resolve `_: Animal` + = note: cannot satisfy `_: Animal` error: aborting due to previous error 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 e7a028e351..7d84c8f5d4 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 @@ -3,6 +3,9 @@ $ cargo run error[E0277]: `Point` doesn't implement `std::fmt::Display` --> src/main.rs:20:6 | +3 | trait OutlinePrint: fmt::Display { + | ------------ required by this bound in `OutlinePrint` +... 20 | impl OutlinePrint for Point {} | ^^^^^^^^^^^^ `Point` cannot be formatted with the default formatter | diff --git a/rust-toolchain b/rust-toolchain index d9d7ef5a4b..f42aadeec8 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.43 +1.44 diff --git a/src/title-page.md b/src/title-page.md index ec1cee08f4..9b2fd358d0 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.43 or later with +This version of the text assumes you’re using Rust 1.44 or later with `edition="2018"` in *Cargo.toml* of all projects to use Rust 2018 Edition idioms. See the [“Installation” section of Chapter 1][install] to install or update Rust, and see the new [Appendix E][editions] src/main.rs:5:19 + | +5 | let element = a[index]; + | ^^^^^^^^ index out of bounds: the len is 5 but the index is 10 + | + = note: `#[deny(unconditional_panic)]` on by default + +error: aborting due to previous error + +error: could not compile `arrays`. + +To learn more, run the command again with --verbose. diff --git a/listings/ch04-understanding-ownership/no-listing-14-dangling-reference/output.txt b/listings/ch04-understanding-ownership/no-listing-14-dangling-reference/output.txt index 6381d2a305..20f8d41a8c 100644 --- a/listings/ch04-understanding-ownership/no-listing-14-dangling-reference/output.txt +++ b/listings/ch04-understanding-ownership/no-listing-14-dangling-reference/output.txt @@ -4,9 +4,13 @@ error[E0106]: missing lifetime specifier --> src/main.rs:5:16 | 5 | fn dangle() -> &String { - | ^ help: consider giving it a 'static lifetime: `&'static` + | ^ 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 + | +5 | fn dangle() -> &'static String { + | ^^^^^^^^ error: aborting due to previous error diff --git a/listings/ch08-common-collections/output-only-01-not-char-boundary/output.txt b/listings/ch08-common-collections/output-only-01-not-char-boundary/output.txt index 54a42c8fa1..9677630294 100644 --- a/listings/ch08-common-collections/output-only-01-not-char-boundary/output.txt +++ b/listings/ch08-common-collections/output-only-01-not-char-boundary/output.txt @@ -2,5 +2,5 @@ $ cargo run Compiling collections v0.1.0 (file:///projects/collections) Finished dev [unoptimized + debuginfo] target(s) in 0.43s Running `target/debug/collections` -thread 'main' panicked at 'byte index 1 is not a char boundary; it is inside 'З' (bytes 0..2) of `Здравствуйте`', /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7/src/libcore/str/mod.rs:1920:47 +thread 'main' panicked at 'byte index 1 is not a char boundary; it is inside 'З' (bytes 0..2) of `Здравствуйте`', /rustc/d3fb005a39e62501b8b0b356166e515ae24e2e54/src/libcore/str/mod.rs:1920:47 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/listings/ch15-smart-pointers/listing-15-03/output.txt b/listings/ch15-smart-pointers/listing-15-03/output.txt index f15aaacb9a..0fa8fe47f9 100644 --- a/listings/ch15-smart-pointers/listing-15-03/output.txt +++ b/listings/ch15-smart-pointers/listing-15-03/output.txt @@ -10,13 +10,13 @@ error[E0072]: recursive type `List` has infinite size | = help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `List` representable -error[E0391]: cycle detected when processing `List` +error[E0391]: cycle detected when computing drop-check constraints for `List` --> src/main.rs:1:1 | 1 | enum List { | ^^^^^^^^^ | - = note: ...which again requires processing `List`, completing the cycle + = note: ...which again requires computing drop-check constraints for `List`, completing the cycle = note: cycle used when computing dropck types for `Canonical { max_universe: U0, variables: [], value: ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: UserFacing, def_id: None }, value: List } }` error: aborting due to 2 previous errors diff --git a/listings/ch15-smart-pointers/listing-15-15/output.txt b/listings/ch15-smart-pointers/listing-15-15/output.txt index 4af05876e1..a696a39a13 100644 --- a/listings/ch15-smart-pointers/listing-15-15/output.txt +++ b/listings/ch15-smart-pointers/listing-15-15/output.txt @@ -4,7 +4,10 @@ error[E0040]: explicit use of destructor method --> src/main.rs:16:7 | 16 | c.drop(); - | ^^^^ explicit destructor calls not allowed + | ^^^^ + | | + | explicit destructor calls not allowed + | help: consider using `drop` function: `drop(c)` error: aborting due to previous error diff --git a/listings/ch15-smart-pointers/listing-15-23/output.txt b/listings/ch15-smart-pointers/listing-15-23/output.txt index 72450b8acc..ffe399dd6c 100644 --- a/listings/ch15-smart-pointers/listing-15-23/output.txt +++ b/listings/ch15-smart-pointers/listing-15-23/output.txt @@ -9,7 +9,7 @@ test tests::it_sends_an_over_75_percent_warning_message ... FAILED failures: ---- tests::it_sends_an_over_75_percent_warning_message stdout ---- -thread 'main' panicked at 'already borrowed: BorrowMutError', /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7/src/libcore/cell.rs:878:9 +thread 'main' panicked at 'already borrowed: BorrowMutError', /rustc/d3fb005a39e62501b8b0b356166e515ae24e2e54/src/libcore/cell.rs:877:9 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/listings/ch19-advanced-features/no-listing-18-returns-closure/output.txt b/listings/ch19-advanced-features/no-listing-18-returns-closure/output.txt index 9c030d1776..89732a7342 100644 --- a/listings/ch19-advanced-features/no-listing-18-returns-closure/output.txt +++ b/listings/ch19-advanced-features/no-listing-18-returns-closure/output.txt @@ -1,18 +1,20 @@ $ cargo build Compiling functions-example v0.1.0 (file:///projects/functions-example) -error[E0277]: the size for values of type `(dyn std::ops::Fn(i32) -> i32 + 'static)` cannot be known at compilation time +error[E0746]: return type cannot have an unboxed trait object --> src/lib.rs:1:25 | 1 | fn returns_closure() -> dyn Fn(i32) -> i32 { | ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | - = help: the trait `std::marker::Sized` is not implemented for `(dyn std::ops::Fn(i32) -> i32 + 'static)` - = note: to learn more, visit - = note: the return type of a function must have a statically known size + = note: for information on `impl Trait`, see +help: use `impl Fn(i32) -> i32` as the return type, as all return paths are of type `[closure@src/lib.rs:2:5: 2:14]`, which implements `Fn(i32) -> i32` + | +1 | fn returns_closure() -> impl Fn(i32) -> i32 { + | ^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error -For more information about this error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0746`. error: could not compile `functions-example`. To learn more, run the command again with --verbose. diff --git a/rust-toolchain b/rust-toolchain index f42aadeec8..24c87c5127 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.44 +1.45 diff --git a/src/title-page.md b/src/title-page.md index 9b2fd358d0..6fc6409abe 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.44 or later with +This version of the text assumes you’re using Rust 1.45 or later with `edition="2018"` in *Cargo.toml* of all projects to use Rust 2018 Edition idioms. See the [“Installation” section of Chapter 1][install] to install or update Rust, and see the new [Appendix E][editions] src/main.rs:1:1 diff --git a/listings/ch15-smart-pointers/listing-15-23/output.txt b/listings/ch15-smart-pointers/listing-15-23/output.txt index ffe399dd6c..a413d916fe 100644 --- a/listings/ch15-smart-pointers/listing-15-23/output.txt +++ b/listings/ch15-smart-pointers/listing-15-23/output.txt @@ -9,7 +9,7 @@ test tests::it_sends_an_over_75_percent_warning_message ... FAILED failures: ---- tests::it_sends_an_over_75_percent_warning_message stdout ---- -thread 'main' panicked at 'already borrowed: BorrowMutError', /rustc/d3fb005a39e62501b8b0b356166e515ae24e2e54/src/libcore/cell.rs:877:9 +thread 'main' panicked at 'already borrowed: BorrowMutError', /rustc/04488afe34512aa4c33566eb16d8c912a3ae04f9/src/libcore/cell.rs:867:31 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/rust-toolchain b/rust-toolchain index 24c87c5127..7ab887e291 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.45 +1.46 diff --git a/src/title-page.md b/src/title-page.md index 6fc6409abe..a9396ce4a5 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.45 or later with +This version of the text assumes you’re using Rust 1.46 or later with `edition="2018"` in *Cargo.toml* of all projects to use Rust 2018 Edition idioms. See the [“Installation” section of Chapter 1][install] to install or update Rust, and see the new [Appendix E][editions] src/lib.rs:2:5 + --> src/lib.rs:2:21 | 2 | pub components: Vec>, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::clone::Clone` cannot be made into an object + | ^^^^^^^^^^^^^^^^^^^ the trait `std::clone::Clone` cannot be made into an object | = note: the trait cannot be made into an object because it requires `Self: Sized` diff --git a/rust-toolchain b/rust-toolchain index 7ab887e291..99dd716886 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.46 +1.47 diff --git a/src/title-page.md b/src/title-page.md index a9396ce4a5..9e975ec58b 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.46 or later with +This version of the text assumes you’re using Rust 1.47 or later with `edition="2018"` in *Cargo.toml* of all projects to use Rust 2018 Edition idioms. See the [“Installation” section of Chapter 1][install] to install or update Rust, and see the new [Appendix E][editions] src/main.rs:22:21 | 22 | match guess.cmp(&secret_number) { - | ^^^^^^^^^^^^^^ expected struct `std::string::String`, found integer + | ^^^^^^^^^^^^^^ expected struct `String`, found integer | - = note: expected reference `&std::string::String` + = note: expected reference `&String` found reference `&{integer}` error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. -error: could not compile `guessing_game`. +error: could not compile `guessing_game` To learn more, run the command again with --verbose. diff --git a/listings/ch03-common-programming-concepts/no-listing-01-variables-are-immutable/output.txt b/listings/ch03-common-programming-concepts/no-listing-01-variables-are-immutable/output.txt index 4693ca9da4..7c2ec5bf78 100644 --- a/listings/ch03-common-programming-concepts/no-listing-01-variables-are-immutable/output.txt +++ b/listings/ch03-common-programming-concepts/no-listing-01-variables-are-immutable/output.txt @@ -15,6 +15,6 @@ error[E0384]: cannot assign twice to immutable variable `x` error: aborting due to previous error For more information about this error, try `rustc --explain E0384`. -error: could not compile `variables`. +error: could not compile `variables` To learn more, run the command again with --verbose. 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 0f4a7d13a3..166b0798c2 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 @@ -9,6 +9,6 @@ error[E0308]: mismatched types error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. -error: could not compile `variables`. +error: could not compile `variables` To learn more, run the command again with --verbose. diff --git a/listings/ch03-common-programming-concepts/no-listing-15-invalid-array-access/output.txt b/listings/ch03-common-programming-concepts/no-listing-15-invalid-array-access/output.txt index 273b34711a..a4dd90c0bd 100644 --- a/listings/ch03-common-programming-concepts/no-listing-15-invalid-array-access/output.txt +++ b/listings/ch03-common-programming-concepts/no-listing-15-invalid-array-access/output.txt @@ -4,12 +4,12 @@ error: this operation will panic at runtime --> src/main.rs:5:19 | 5 | let element = a[index]; - | ^^^^^^^^ index out of bounds: the len is 5 but the index is 10 + | ^^^^^^^^ index out of bounds: the length is 5 but the index is 10 | = note: `#[deny(unconditional_panic)]` on by default error: aborting due to previous error -error: could not compile `arrays`. +error: could not compile `arrays` To learn more, run the command again with --verbose. diff --git a/listings/ch03-common-programming-concepts/no-listing-19-statements-vs-expressions/output.txt b/listings/ch03-common-programming-concepts/no-listing-19-statements-vs-expressions/output.txt index 879946f649..d4bb2b2ea3 100644 --- a/listings/ch03-common-programming-concepts/no-listing-19-statements-vs-expressions/output.txt +++ b/listings/ch03-common-programming-concepts/no-listing-19-statements-vs-expressions/output.txt @@ -27,6 +27,6 @@ warning: unnecessary parentheses around assigned value error: aborting due to 2 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0658`. -error: could not compile `functions`. +error: could not compile `functions` To learn more, run the command again with --verbose. diff --git a/listings/ch03-common-programming-concepts/no-listing-23-statements-dont-return-values/output.txt b/listings/ch03-common-programming-concepts/no-listing-23-statements-dont-return-values/output.txt index 1c80331541..6657c63d46 100644 --- a/listings/ch03-common-programming-concepts/no-listing-23-statements-dont-return-values/output.txt +++ b/listings/ch03-common-programming-concepts/no-listing-23-statements-dont-return-values/output.txt @@ -13,6 +13,6 @@ error[E0308]: mismatched types error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. -error: could not compile `functions`. +error: could not compile `functions` To learn more, run the command again with --verbose. diff --git a/listings/ch03-common-programming-concepts/no-listing-28-if-condition-must-be-bool/output.txt b/listings/ch03-common-programming-concepts/no-listing-28-if-condition-must-be-bool/output.txt index b3442affe0..5ddb737cfb 100644 --- a/listings/ch03-common-programming-concepts/no-listing-28-if-condition-must-be-bool/output.txt +++ b/listings/ch03-common-programming-concepts/no-listing-28-if-condition-must-be-bool/output.txt @@ -9,6 +9,6 @@ error[E0308]: mismatched types error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. -error: could not compile `branches`. +error: could not compile `branches` To learn more, run the command again with --verbose. diff --git a/listings/ch03-common-programming-concepts/no-listing-31-arms-must-return-same-type/output.txt b/listings/ch03-common-programming-concepts/no-listing-31-arms-must-return-same-type/output.txt index b576c972eb..90934b6be4 100644 --- a/listings/ch03-common-programming-concepts/no-listing-31-arms-must-return-same-type/output.txt +++ b/listings/ch03-common-programming-concepts/no-listing-31-arms-must-return-same-type/output.txt @@ -11,6 +11,6 @@ error[E0308]: `if` and `else` have incompatible types error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. -error: could not compile `branches`. +error: could not compile `branches` To learn more, run the command again with --verbose. 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 5b00236206..df0ed3515e 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 @@ -9,6 +9,6 @@ error[E0282]: type annotations needed error: aborting due to previous error For more information about this error, try `rustc --explain E0282`. -error: could not compile `no_type_annotations`. +error: could not compile `no_type_annotations` To learn more, run the command again with --verbose. diff --git a/listings/ch04-understanding-ownership/listing-04-06/output.txt b/listings/ch04-understanding-ownership/listing-04-06/output.txt index 98f438f614..b62dbd0a0d 100644 --- a/listings/ch04-understanding-ownership/listing-04-06/output.txt +++ b/listings/ch04-understanding-ownership/listing-04-06/output.txt @@ -4,13 +4,13 @@ error[E0596]: cannot borrow `*some_string` as mutable, as it is behind a `&` ref --> src/main.rs:8:5 | 7 | fn change(some_string: &String) { - | ------- help: consider changing this to be a mutable reference: `&mut std::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 error: aborting due to previous error For more information about this error, try `rustc --explain E0596`. -error: could not compile `ownership`. +error: could not compile `ownership` To learn more, run the command again with --verbose. diff --git a/listings/ch04-understanding-ownership/no-listing-04-cant-use-after-move/output.txt b/listings/ch04-understanding-ownership/no-listing-04-cant-use-after-move/output.txt index 910332ac13..b69c878131 100644 --- a/listings/ch04-understanding-ownership/no-listing-04-cant-use-after-move/output.txt +++ b/listings/ch04-understanding-ownership/no-listing-04-cant-use-after-move/output.txt @@ -4,7 +4,7 @@ error[E0382]: borrow of moved value: `s1` --> src/main.rs:5:28 | 2 | let s1 = String::from("hello"); - | -- move occurs because `s1` has type `std::string::String`, which does not implement the `Copy` trait + | -- move occurs because `s1` has type `String`, which does not implement the `Copy` trait 3 | let s2 = s1; | -- value moved here 4 | @@ -14,6 +14,6 @@ error[E0382]: borrow of moved value: `s1` error: aborting due to previous error For more information about this error, try `rustc --explain E0382`. -error: could not compile `ownership`. +error: could not compile `ownership` To learn more, run the command again with --verbose. diff --git a/listings/ch04-understanding-ownership/no-listing-10-multiple-mut-not-allowed/output.txt b/listings/ch04-understanding-ownership/no-listing-10-multiple-mut-not-allowed/output.txt index cb69a714b3..7e40a22fb2 100644 --- a/listings/ch04-understanding-ownership/no-listing-10-multiple-mut-not-allowed/output.txt +++ b/listings/ch04-understanding-ownership/no-listing-10-multiple-mut-not-allowed/output.txt @@ -14,6 +14,6 @@ error[E0499]: cannot borrow `s` as mutable more than once at a time error: aborting due to previous error For more information about this error, try `rustc --explain E0499`. -error: could not compile `ownership`. +error: could not compile `ownership` To learn more, run the command again with --verbose. diff --git a/listings/ch04-understanding-ownership/no-listing-12-immutable-and-mutable-not-allowed/output.txt b/listings/ch04-understanding-ownership/no-listing-12-immutable-and-mutable-not-allowed/output.txt index cd4168f8ce..25ca95494c 100644 --- a/listings/ch04-understanding-ownership/no-listing-12-immutable-and-mutable-not-allowed/output.txt +++ b/listings/ch04-understanding-ownership/no-listing-12-immutable-and-mutable-not-allowed/output.txt @@ -15,6 +15,6 @@ error[E0502]: cannot borrow `s` as mutable because it is also borrowed as immuta error: aborting due to previous error For more information about this error, try `rustc --explain E0502`. -error: could not compile `ownership`. +error: could not compile `ownership` To learn more, run the command again with --verbose. diff --git a/listings/ch04-understanding-ownership/no-listing-14-dangling-reference/output.txt b/listings/ch04-understanding-ownership/no-listing-14-dangling-reference/output.txt index 20f8d41a8c..dc23312387 100644 --- a/listings/ch04-understanding-ownership/no-listing-14-dangling-reference/output.txt +++ b/listings/ch04-understanding-ownership/no-listing-14-dangling-reference/output.txt @@ -15,6 +15,6 @@ help: consider using the `'static` lifetime error: aborting due to previous error For more information about this error, try `rustc --explain E0106`. -error: could not compile `ownership`. +error: could not compile `ownership` To learn more, run the command again with --verbose. diff --git a/listings/ch04-understanding-ownership/no-listing-19-slice-error/output.txt b/listings/ch04-understanding-ownership/no-listing-19-slice-error/output.txt index 0e95bb8cd6..503a503ca3 100644 --- a/listings/ch04-understanding-ownership/no-listing-19-slice-error/output.txt +++ b/listings/ch04-understanding-ownership/no-listing-19-slice-error/output.txt @@ -15,6 +15,6 @@ error[E0502]: cannot borrow `s` as mutable because it is also borrowed as immuta error: aborting due to previous error For more information about this error, try `rustc --explain E0502`. -error: could not compile `ownership`. +error: could not compile `ownership` To learn more, run the command again with --verbose. diff --git a/listings/ch05-using-structs-to-structure-related-data/listing-05-11/output.txt b/listings/ch05-using-structs-to-structure-related-data/listing-05-11/output.txt index ea5510a8c5..fbf73a6d84 100644 --- a/listings/ch05-using-structs-to-structure-related-data/listing-05-11/output.txt +++ b/listings/ch05-using-structs-to-structure-related-data/listing-05-11/output.txt @@ -14,6 +14,6 @@ error[E0277]: `Rectangle` doesn't implement `std::fmt::Display` error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. -error: could not compile `structs`. +error: could not compile `structs` To learn more, run the command again with --verbose. diff --git a/listings/ch05-using-structs-to-structure-related-data/no-listing-02-reference-in-struct/output.txt b/listings/ch05-using-structs-to-structure-related-data/no-listing-02-reference-in-struct/output.txt index f05c033eb5..9b54ddd8f2 100644 --- a/listings/ch05-using-structs-to-structure-related-data/no-listing-02-reference-in-struct/output.txt +++ b/listings/ch05-using-structs-to-structure-related-data/no-listing-02-reference-in-struct/output.txt @@ -28,6 +28,6 @@ help: consider introducing a named lifetime parameter error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0106`. -error: could not compile `structs`. +error: could not compile `structs` To learn more, run the command again with --verbose. 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 3ce9155889..bc7e5d8b70 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 @@ -1,19 +1,19 @@ $ cargo run Compiling structs v0.1.0 (file:///projects/structs) -error[E0277]: `Rectangle` doesn't implement `std::fmt::Debug` +error[E0277]: `Rectangle` doesn't implement `Debug` --> src/main.rs:12:31 | 12 | println!("rect1 is {:?}", rect1); | ^^^^^ `Rectangle` cannot be formatted using `{:?}` | - = help: the trait `std::fmt::Debug` is not implemented for `Rectangle` - = note: add `#[derive(Debug)]` or manually implement `std::fmt::Debug` + = help: the trait `Debug` is not implemented for `Rectangle` + = note: add `#[derive(Debug)]` or manually implement `Debug` = note: required by `std::fmt::Debug::fmt` = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. -error: could not compile `structs`. +error: could not compile `structs` To learn more, run the command again with --verbose. diff --git a/listings/ch06-enums-and-pattern-matching/no-listing-07-cant-use-option-directly/output.txt b/listings/ch06-enums-and-pattern-matching/no-listing-07-cant-use-option-directly/output.txt index d3092d9fb3..856826ca06 100644 --- a/listings/ch06-enums-and-pattern-matching/no-listing-07-cant-use-option-directly/output.txt +++ b/listings/ch06-enums-and-pattern-matching/no-listing-07-cant-use-option-directly/output.txt @@ -1,16 +1,16 @@ $ cargo run Compiling enums v0.1.0 (file:///projects/enums) -error[E0277]: cannot add `std::option::Option` to `i8` +error[E0277]: cannot add `Option` to `i8` --> src/main.rs:5:17 | 5 | let sum = x + y; - | ^ no implementation for `i8 + std::option::Option` + | ^ no implementation for `i8 + Option` | - = help: the trait `std::ops::Add>` is not implemented for `i8` + = help: the trait `Add>` is not implemented for `i8` error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. -error: could not compile `enums`. +error: could not compile `enums` To learn more, run the command again with --verbose. 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 6c9b69a119..0ab76cce95 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,11 +7,11 @@ error[E0004]: non-exhaustive patterns: `None` not covered | ^ pattern `None` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `std::option::Option` + = note: the matched value is of type `Option` error: aborting due to previous error For more information about this error, try `rustc --explain E0004`. -error: could not compile `enums`. +error: could not compile `enums` To learn more, run the command again with --verbose. 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 088e092417..4979d5f642 100644 --- a/listings/ch07-managing-growing-projects/listing-07-03/output.txt +++ b/listings/ch07-managing-growing-projects/listing-07-03/output.txt @@ -27,6 +27,6 @@ note: the module `hosting` is defined here error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0603`. -error: could not compile `restaurant`. +error: could not compile `restaurant` To learn more, run the command again with --verbose. 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 552959b246..22b4601958 100644 --- a/listings/ch07-managing-growing-projects/listing-07-05/output.txt +++ b/listings/ch07-managing-growing-projects/listing-07-05/output.txt @@ -27,6 +27,6 @@ note: the function `add_to_waitlist` is defined here error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0603`. -error: could not compile `restaurant`. +error: could not compile `restaurant` To learn more, run the command again with --verbose. diff --git a/listings/ch08-common-collections/listing-08-07/output.txt b/listings/ch08-common-collections/listing-08-07/output.txt index b50110bdba..d99310d25a 100644 --- a/listings/ch08-common-collections/listing-08-07/output.txt +++ b/listings/ch08-common-collections/listing-08-07/output.txt @@ -15,6 +15,6 @@ error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immuta error: aborting due to previous error For more information about this error, try `rustc --explain E0502`. -error: could not compile `collections`. +error: could not compile `collections` To learn more, run the command again with --verbose. diff --git a/listings/ch08-common-collections/listing-08-19/output.txt b/listings/ch08-common-collections/listing-08-19/output.txt index c239f71896..d6e45b2696 100644 --- a/listings/ch08-common-collections/listing-08-19/output.txt +++ b/listings/ch08-common-collections/listing-08-19/output.txt @@ -1,16 +1,16 @@ $ cargo run Compiling collections v0.1.0 (file:///projects/collections) -error[E0277]: the type `std::string::String` cannot be indexed by `{integer}` +error[E0277]: the type `String` cannot be indexed by `{integer}` --> src/main.rs:3:13 | 3 | let h = s1[0]; - | ^^^^^ `std::string::String` cannot be indexed by `{integer}` + | ^^^^^ `String` cannot be indexed by `{integer}` | - = help: the trait `std::ops::Index<{integer}>` is not implemented for `std::string::String` + = help: the trait `Index<{integer}>` is not implemented for `String` error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. -error: could not compile `collections`. +error: could not compile `collections` To learn more, run the command again with --verbose. diff --git a/listings/ch09-error-handling/no-listing-02-ask-compiler-for-type/output.txt b/listings/ch09-error-handling/no-listing-02-ask-compiler-for-type/output.txt index 18262cbc40..1b63b37cfd 100644 --- a/listings/ch09-error-handling/no-listing-02-ask-compiler-for-type/output.txt +++ b/listings/ch09-error-handling/no-listing-02-ask-compiler-for-type/output.txt @@ -9,11 +9,11 @@ error[E0308]: mismatched types | expected due to this | = note: expected type `u32` - found enum `std::result::Result` + found enum `std::result::Result` error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. -error: could not compile `error-handling`. +error: could not compile `error-handling` To learn more, run the command again with --verbose. diff --git a/listings/ch09-error-handling/no-listing-06-question-mark-in-main/output.txt b/listings/ch09-error-handling/no-listing-06-question-mark-in-main/output.txt index 17a8b2e476..76ff859884 100644 --- a/listings/ch09-error-handling/no-listing-06-question-mark-in-main/output.txt +++ b/listings/ch09-error-handling/no-listing-06-question-mark-in-main/output.txt @@ -1,6 +1,6 @@ $ cargo run Compiling error-handling v0.1.0 (file:///projects/error-handling) -error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `std::ops::Try`) +error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `Try`) --> src/main.rs:4:13 | 3 | / fn main() { @@ -9,12 +9,12 @@ error[E0277]: the `?` operator can only be used in a function that returns `Resu 5 | | } | |_- this function should return `Result` or `Option` to accept `?` | - = help: the trait `std::ops::Try` is not implemented for `()` - = note: required by `std::ops::Try::from_error` + = help: the trait `Try` is not implemented for `()` + = note: required by `from_error` error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. -error: could not compile `error-handling`. +error: could not compile `error-handling` To learn more, run the command again with --verbose. diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-05/output.txt b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-05/output.txt index b1ed1e326a..9604aac0e6 100644 --- a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-05/output.txt +++ b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-05/output.txt @@ -16,6 +16,6 @@ help: consider restricting type parameter `T` error: aborting due to previous error For more information about this error, try `rustc --explain E0369`. -error: could not compile `chapter10`. +error: could not compile `chapter10` To learn more, run the command again with --verbose. diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-07/output.txt b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-07/output.txt index 4a67e1b595..5f32bdc18d 100644 --- a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-07/output.txt +++ b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-07/output.txt @@ -9,6 +9,6 @@ error[E0308]: mismatched types error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. -error: could not compile `chapter10`. +error: could not compile `chapter10` To learn more, run the command again with --verbose. diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-17/output.txt b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-17/output.txt index 5f9b71b0bf..c79e59c26b 100644 --- a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-17/output.txt +++ b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-17/output.txt @@ -14,6 +14,6 @@ error[E0597]: `x` does not live long enough error: aborting due to previous error For more information about this error, try `rustc --explain E0597`. -error: could not compile `chapter10`. +error: could not compile `chapter10` To learn more, run the command again with --verbose. diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-21/output.txt b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-21/output.txt index d102d7123f..aa38ce00bc 100644 --- a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-21/output.txt +++ b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-21/output.txt @@ -15,6 +15,6 @@ help: consider introducing a named lifetime parameter error: aborting due to previous error For more information about this error, try `rustc --explain E0106`. -error: could not compile `chapter10`. +error: could not compile `chapter10` To learn more, run the command again with --verbose. diff --git a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-24/output.txt b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-24/output.txt index bcedda0f49..05ffdc7377 100644 --- a/listings/ch10-generic-types-traits-and-lifetimes/listing-10-24/output.txt +++ b/listings/ch10-generic-types-traits-and-lifetimes/listing-10-24/output.txt @@ -13,6 +13,6 @@ error[E0597]: `string2` does not live long enough error: aborting due to previous error For more information about this error, try `rustc --explain E0597`. -error: could not compile `chapter10`. +error: could not compile `chapter10` To learn more, run the command again with --verbose. diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-07-fixing-listing-10-05/output.txt b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-07-fixing-listing-10-05/output.txt index ca7023f1d1..0a3e7f5277 100644 --- a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-07-fixing-listing-10-05/output.txt +++ b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-07-fixing-listing-10-05/output.txt @@ -24,6 +24,6 @@ error: aborting due to 2 previous errors Some errors have detailed explanations: E0507, E0508. For more information about an error, try `rustc --explain E0507`. -error: could not compile `chapter10`. +error: could not compile `chapter10` To learn more, run the command again with --verbose. diff --git a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-09-unrelated-lifetime/output.txt b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-09-unrelated-lifetime/output.txt index cadd5fa32c..de29d4f43c 100644 --- a/listings/ch10-generic-types-traits-and-lifetimes/no-listing-09-unrelated-lifetime/output.txt +++ b/listings/ch10-generic-types-traits-and-lifetimes/no-listing-09-unrelated-lifetime/output.txt @@ -12,6 +12,6 @@ error[E0515]: cannot return value referencing local variable `result` error: aborting due to previous error For more information about this error, try `rustc --explain E0515`. -error: could not compile `chapter10`. +error: could not compile `chapter10` To learn more, run the command again with --verbose. diff --git a/listings/ch12-an-io-project/output-only-02-missing-lifetimes/output.txt b/listings/ch12-an-io-project/output-only-02-missing-lifetimes/output.txt index 0fa63e3069..8ba8fac52a 100644 --- a/listings/ch12-an-io-project/output-only-02-missing-lifetimes/output.txt +++ b/listings/ch12-an-io-project/output-only-02-missing-lifetimes/output.txt @@ -15,6 +15,6 @@ help: consider introducing a named lifetime parameter error: aborting due to previous error For more information about this error, try `rustc --explain E0106`. -error: could not compile `minigrep`. +error: could not compile `minigrep` To learn more, run the command again with --verbose. diff --git a/listings/ch13-functional-features/listing-13-08/output.txt b/listings/ch13-functional-features/listing-13-08/output.txt index d859957f21..a90814c347 100644 --- a/listings/ch13-functional-features/listing-13-08/output.txt +++ b/listings/ch13-functional-features/listing-13-08/output.txt @@ -6,12 +6,12 @@ error[E0308]: mismatched types 5 | let n = example_closure(5); | ^ | | - | expected struct `std::string::String`, found integer + | expected struct `String`, found integer | help: try using a conversion method: `5.to_string()` error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. -error: could not compile `closure-example`. +error: could not compile `closure-example` To learn more, run the command again with --verbose. diff --git a/listings/ch13-functional-features/listing-13-17/output.txt b/listings/ch13-functional-features/listing-13-17/output.txt index 970a315762..67f05573bd 100644 --- a/listings/ch13-functional-features/listing-13-17/output.txt +++ b/listings/ch13-functional-features/listing-13-17/output.txt @@ -1,6 +1,6 @@ $ cargo run Compiling iterators v0.1.0 (file:///projects/iterators) -warning: unused `std::iter::Map` that must be used +warning: unused `Map` that must be used --> src/main.rs:4:5 | 4 | v1.iter().map(|x| x + 1); diff --git a/listings/ch13-functional-features/no-listing-02-functions-cant-capture/output.txt b/listings/ch13-functional-features/no-listing-02-functions-cant-capture/output.txt index a8d9e16d38..8fa9df0f7c 100644 --- a/listings/ch13-functional-features/no-listing-02-functions-cant-capture/output.txt +++ b/listings/ch13-functional-features/no-listing-02-functions-cant-capture/output.txt @@ -11,6 +11,6 @@ error[E0434]: can't capture dynamic environment in a fn item error: aborting due to previous error For more information about this error, try `rustc --explain E0434`. -error: could not compile `equal-to-x`. +error: could not compile `equal-to-x` To learn more, run the command again with --verbose. diff --git a/listings/ch13-functional-features/no-listing-03-move-closures/output.txt b/listings/ch13-functional-features/no-listing-03-move-closures/output.txt index 43490332ed..3ca1901925 100644 --- a/listings/ch13-functional-features/no-listing-03-move-closures/output.txt +++ b/listings/ch13-functional-features/no-listing-03-move-closures/output.txt @@ -4,7 +4,7 @@ error[E0382]: borrow of moved value: `x` --> src/main.rs:6:40 | 2 | let x = vec![1, 2, 3]; - | - move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait + | - move occurs because `x` has type `Vec`, which does not implement the `Copy` trait 3 | 4 | let equal_to_x = move |z| z == x; | -------- - variable moved due to use in closure @@ -17,6 +17,6 @@ error[E0382]: borrow of moved value: `x` error: aborting due to previous error For more information about this error, try `rustc --explain E0382`. -error: could not compile `equal-to-x`. +error: could not compile `equal-to-x` To learn more, run the command again with --verbose. diff --git a/listings/ch15-smart-pointers/listing-15-03/output.txt b/listings/ch15-smart-pointers/listing-15-03/output.txt index 06817645b3..741e404963 100644 --- a/listings/ch15-smart-pointers/listing-15-03/output.txt +++ b/listings/ch15-smart-pointers/listing-15-03/output.txt @@ -20,12 +20,12 @@ error[E0391]: cycle detected when computing drop-check constraints for `List` | ^^^^^^^^^ | = note: ...which again requires computing drop-check constraints for `List`, completing the cycle - = note: cycle used when computing dropck types for `Canonical { max_universe: U0, variables: [], value: ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: UserFacing, def_id: None }, value: List } }` + = note: cycle used when computing dropck types for `Canonical { max_universe: U0, variables: [], value: ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: UserFacing }, value: List } }` error: aborting due to 2 previous errors Some errors have detailed explanations: E0072, E0391. For more information about an error, try `rustc --explain E0072`. -error: could not compile `cons-list`. +error: could not compile `cons-list` To learn more, run the command again with --verbose. diff --git a/listings/ch15-smart-pointers/listing-15-09/output.txt b/listings/ch15-smart-pointers/listing-15-09/output.txt index 8fbd56124b..a2b7995a25 100644 --- a/listings/ch15-smart-pointers/listing-15-09/output.txt +++ b/listings/ch15-smart-pointers/listing-15-09/output.txt @@ -9,6 +9,6 @@ error[E0614]: type `MyBox<{integer}>` cannot be dereferenced error: aborting due to previous error For more information about this error, try `rustc --explain E0614`. -error: could not compile `deref-example`. +error: could not compile `deref-example` To learn more, run the command again with --verbose. diff --git a/listings/ch15-smart-pointers/listing-15-15/output.txt b/listings/ch15-smart-pointers/listing-15-15/output.txt index a696a39a13..b7893963ee 100644 --- a/listings/ch15-smart-pointers/listing-15-15/output.txt +++ b/listings/ch15-smart-pointers/listing-15-15/output.txt @@ -12,6 +12,6 @@ error[E0040]: explicit use of destructor method error: aborting due to previous error For more information about this error, try `rustc --explain E0040`. -error: could not compile `drop-example`. +error: could not compile `drop-example` To learn more, run the command again with --verbose. diff --git a/listings/ch15-smart-pointers/listing-15-17/output.txt b/listings/ch15-smart-pointers/listing-15-17/output.txt index 5966a71ec2..a4aaeba5fb 100644 --- a/listings/ch15-smart-pointers/listing-15-17/output.txt +++ b/listings/ch15-smart-pointers/listing-15-17/output.txt @@ -13,6 +13,6 @@ error[E0382]: use of moved value: `a` error: aborting due to previous error For more information about this error, try `rustc --explain E0382`. -error: could not compile `cons-list`. +error: could not compile `cons-list` To learn more, run the command again with --verbose. diff --git a/listings/ch15-smart-pointers/listing-15-21/output.txt b/listings/ch15-smart-pointers/listing-15-21/output.txt index 83377f3e02..7cfa86b325 100644 --- a/listings/ch15-smart-pointers/listing-15-21/output.txt +++ b/listings/ch15-smart-pointers/listing-15-21/output.txt @@ -11,7 +11,7 @@ error[E0596]: cannot borrow `self.sent_messages` as mutable, as it is behind a ` error: aborting due to previous error For more information about this error, try `rustc --explain E0596`. -error: could not compile `limit-tracker`. +error: could not compile `limit-tracker` To learn more, run the command again with --verbose. warning: build failed, waiting for other jobs to finish... 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 c8e5592de7..28924261c8 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 @@ -11,6 +11,6 @@ error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable error: aborting due to previous error For more information about this error, try `rustc --explain E0596`. -error: could not compile `borrowing`. +error: could not compile `borrowing` To learn more, run the command again with --verbose. diff --git a/listings/ch15-smart-pointers/output-only-01-comparing-to-reference/output.txt b/listings/ch15-smart-pointers/output-only-01-comparing-to-reference/output.txt index e4edda0500..5eaa969925 100644 --- a/listings/ch15-smart-pointers/output-only-01-comparing-to-reference/output.txt +++ b/listings/ch15-smart-pointers/output-only-01-comparing-to-reference/output.txt @@ -6,12 +6,12 @@ error[E0277]: can't compare `{integer}` with `&{integer}` 6 | assert_eq!(5, y); | ^^^^^^^^^^^^^^^^^ no implementation for `{integer} == &{integer}` | - = help: the trait `std::cmp::PartialEq<&{integer}>` is not implemented for `{integer}` + = help: the trait `PartialEq<&{integer}>` is not implemented for `{integer}` = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. -error: could not compile `deref-example`. +error: could not compile `deref-example` To learn more, run the command again with --verbose. diff --git a/listings/ch16-fearless-concurrency/listing-16-03/output.txt b/listings/ch16-fearless-concurrency/listing-16-03/output.txt index 1dd4deeb2e..1223d38356 100644 --- a/listings/ch16-fearless-concurrency/listing-16-03/output.txt +++ b/listings/ch16-fearless-concurrency/listing-16-03/output.txt @@ -24,6 +24,6 @@ help: to force the closure to take ownership of `v` (and any other referenced va error: aborting due to previous error For more information about this error, try `rustc --explain E0373`. -error: could not compile `threads`. +error: could not compile `threads` To learn more, run the command again with --verbose. diff --git a/listings/ch16-fearless-concurrency/listing-16-09/output.txt b/listings/ch16-fearless-concurrency/listing-16-09/output.txt index 11bfc6fe32..deb47c97b4 100644 --- a/listings/ch16-fearless-concurrency/listing-16-09/output.txt +++ b/listings/ch16-fearless-concurrency/listing-16-09/output.txt @@ -4,7 +4,7 @@ error[E0382]: borrow of moved value: `val` --> src/main.rs:10:31 | 8 | let val = String::from("hi"); - | --- move occurs because `val` has type `std::string::String`, which does not implement the `Copy` trait + | --- move occurs because `val` has type `String`, which does not implement the `Copy` trait 9 | tx.send(val).unwrap(); | --- value moved here 10 | println!("val is {}", val); @@ -13,6 +13,6 @@ error[E0382]: borrow of moved value: `val` error: aborting due to previous error For more information about this error, try `rustc --explain E0382`. -error: could not compile `message-passing`. +error: could not compile `message-passing` To learn more, run the command again with --verbose. diff --git a/listings/ch16-fearless-concurrency/listing-16-13/output.txt b/listings/ch16-fearless-concurrency/listing-16-13/output.txt index 7369ec41b5..69e0b097d9 100644 --- a/listings/ch16-fearless-concurrency/listing-16-13/output.txt +++ b/listings/ch16-fearless-concurrency/listing-16-13/output.txt @@ -4,7 +4,7 @@ error[E0382]: use of moved value: `counter` --> src/main.rs:9:36 | 5 | let counter = Mutex::new(0); - | ------- move occurs because `counter` has type `std::sync::Mutex`, which does not implement the `Copy` trait + | ------- move occurs because `counter` has type `Mutex`, which does not implement the `Copy` trait ... 9 | let handle = thread::spawn(move || { | ^^^^^^^ value moved into closure here, in previous iteration of loop @@ -14,6 +14,6 @@ error[E0382]: use of moved value: `counter` error: aborting due to previous error For more information about this error, try `rustc --explain E0382`. -error: could not compile `shared-state`. +error: could not compile `shared-state` To learn more, run the command again with --verbose. diff --git a/listings/ch16-fearless-concurrency/listing-16-14/output.txt b/listings/ch16-fearless-concurrency/listing-16-14/output.txt index 32225ef19e..cd2d05b674 100644 --- a/listings/ch16-fearless-concurrency/listing-16-14/output.txt +++ b/listings/ch16-fearless-concurrency/listing-16-14/output.txt @@ -1,24 +1,24 @@ $ cargo run Compiling shared-state v0.1.0 (file:///projects/shared-state) -error[E0277]: `std::rc::Rc>` cannot be sent between threads safely +error[E0277]: `Rc>` cannot be sent between threads safely --> src/main.rs:11:22 | 11 | let handle = thread::spawn(move || { | ______________________^^^^^^^^^^^^^_- | | | - | | `std::rc::Rc>` cannot be sent between threads safely + | | `Rc>` cannot be sent between threads safely 12 | | let mut num = counter.lock().unwrap(); 13 | | 14 | | *num += 1; 15 | | }); - | |_________- within this `[closure@src/main.rs:11:36: 15:10 counter:std::rc::Rc>]` + | |_________- within this `[closure@src/main.rs:11:36: 15:10]` | - = help: within `[closure@src/main.rs:11:36: 15:10 counter:std::rc::Rc>]`, the trait `std::marker::Send` is not implemented for `std::rc::Rc>` - = note: required because it appears within the type `[closure@src/main.rs:11:36: 15:10 counter:std::rc::Rc>]` + = help: within `[closure@src/main.rs:11:36: 15:10]`, the trait `Send` is not implemented for `Rc>` + = note: required because it appears within the type `[closure@src/main.rs:11:36: 15:10]` error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. -error: could not compile `shared-state`. +error: could not compile `shared-state` To learn more, run the command again with --verbose. 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 2d1cb3c8b7..0a73128d50 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 @@ -4,7 +4,7 @@ error[E0382]: use of moved value: `v` --> src/main.rs:10:10 | 4 | let v = vec![1, 2, 3]; - | - move occurs because `v` has type `std::vec::Vec`, which does not implement the `Copy` trait + | - move occurs because `v` has type `Vec`, which does not implement the `Copy` trait 5 | 6 | let handle = thread::spawn(move || { | ------- value moved into closure here @@ -17,6 +17,6 @@ error[E0382]: use of moved value: `v` error: aborting due to previous error For more information about this error, try `rustc --explain E0382`. -error: could not compile `threads`. +error: could not compile `threads` To learn more, run the command again with --verbose. diff --git a/listings/ch17-oop/listing-17-10/output.txt b/listings/ch17-oop/listing-17-10/output.txt index b18e1e9b4e..893abd63ba 100644 --- a/listings/ch17-oop/listing-17-10/output.txt +++ b/listings/ch17-oop/listing-17-10/output.txt @@ -1,16 +1,16 @@ $ cargo run Compiling gui v0.1.0 (file:///projects/gui) -error[E0277]: the trait bound `std::string::String: gui::Draw` is not satisfied +error[E0277]: the trait bound `String: Draw` is not satisfied --> src/main.rs:5:26 | 5 | components: vec![Box::new(String::from("Hi"))], - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `gui::Draw` is not implemented for `std::string::String` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Draw` is not implemented for `String` | - = note: required for the cast to the object type `dyn gui::Draw` + = note: required for the cast to the object type `dyn Draw` error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. -error: could not compile `gui`. +error: could not compile `gui` To learn more, run the command again with --verbose. diff --git a/listings/ch17-oop/no-listing-01-trait-object-of-clone/output.txt b/listings/ch17-oop/no-listing-01-trait-object-of-clone/output.txt index fcf0b4133f..8c67a059d9 100644 --- a/listings/ch17-oop/no-listing-01-trait-object-of-clone/output.txt +++ b/listings/ch17-oop/no-listing-01-trait-object-of-clone/output.txt @@ -1,16 +1,16 @@ $ cargo build Compiling gui v0.1.0 (file:///projects/gui) -error[E0038]: the trait `std::clone::Clone` cannot be made into an object +error[E0038]: the trait `Clone` cannot be made into an object --> src/lib.rs:2:21 | 2 | pub components: Vec>, - | ^^^^^^^^^^^^^^^^^^^ the trait `std::clone::Clone` cannot be made into an object + | ^^^^^^^^^^^^^^^^^^^ the trait `Clone` cannot be made into an object | = note: the trait cannot be made into an object because it requires `Self: Sized` error: aborting due to previous error For more information about this error, try `rustc --explain E0038`. -error: could not compile `gui`. +error: could not compile `gui` To learn more, run the command again with --verbose. diff --git a/listings/ch18-patterns-and-matching/listing-18-05/output.txt b/listings/ch18-patterns-and-matching/listing-18-05/output.txt index 23a960f0fe..12eeda74e2 100644 --- a/listings/ch18-patterns-and-matching/listing-18-05/output.txt +++ b/listings/ch18-patterns-and-matching/listing-18-05/output.txt @@ -14,6 +14,6 @@ error[E0308]: mismatched types error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. -error: could not compile `patterns`. +error: could not compile `patterns` To learn more, run the command again with --verbose. 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 d88dd08a88..1843ece4b3 100644 --- a/listings/ch18-patterns-and-matching/listing-18-08/output.txt +++ b/listings/ch18-patterns-and-matching/listing-18-08/output.txt @@ -8,7 +8,7 @@ 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: the matched value is of type `std::option::Option` + = 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 | if let Some(x) = some_option_value { /* */ } @@ -17,6 +17,6 @@ help: you might want to use `if let` to ignore the variant that isn't matched error: aborting due to previous error For more information about this error, try `rustc --explain E0005`. -error: could not compile `patterns`. +error: could not compile `patterns` To learn more, run the command again with --verbose. diff --git a/listings/ch18-patterns-and-matching/listing-18-25/output.txt b/listings/ch18-patterns-and-matching/listing-18-25/output.txt index 3044c4b30c..9ba40fa1c1 100644 --- a/listings/ch18-patterns-and-matching/listing-18-25/output.txt +++ b/listings/ch18-patterns-and-matching/listing-18-25/output.txt @@ -10,6 +10,6 @@ error: `..` can only be used once per tuple pattern error: aborting due to previous error -error: could not compile `patterns`. +error: could not compile `patterns` To learn more, run the command again with --verbose. diff --git a/listings/ch19-advanced-features/listing-19-05/output.txt b/listings/ch19-advanced-features/listing-19-05/output.txt index 3df0e2b64c..559729f602 100644 --- a/listings/ch19-advanced-features/listing-19-05/output.txt +++ b/listings/ch19-advanced-features/listing-19-05/output.txt @@ -16,6 +16,6 @@ error[E0499]: cannot borrow `*slice` as mutable more than once at a time error: aborting due to previous error For more information about this error, try `rustc --explain E0499`. -error: could not compile `unsafe-example`. +error: could not compile `unsafe-example` To learn more, run the command again with --verbose. diff --git a/listings/ch19-advanced-features/listing-19-20/output.txt b/listings/ch19-advanced-features/listing-19-20/output.txt index 5cabbdb95c..b95dde7627 100644 --- a/listings/ch19-advanced-features/listing-19-20/output.txt +++ b/listings/ch19-advanced-features/listing-19-20/output.txt @@ -14,6 +14,6 @@ error[E0283]: type annotations needed error: aborting due to previous error For more information about this error, try `rustc --explain E0283`. -error: could not compile `traits-example`. +error: could not compile `traits-example` To learn more, run the command again with --verbose. 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 7d84c8f5d4..b9bb3f0921 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 @@ -15,6 +15,6 @@ error[E0277]: `Point` doesn't implement `std::fmt::Display` error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. -error: could not compile `traits-example`. +error: could not compile `traits-example` To learn more, run the command again with --verbose. diff --git a/listings/ch19-advanced-features/no-listing-18-returns-closure/output.txt b/listings/ch19-advanced-features/no-listing-18-returns-closure/output.txt index 89732a7342..be5584a247 100644 --- a/listings/ch19-advanced-features/no-listing-18-returns-closure/output.txt +++ b/listings/ch19-advanced-features/no-listing-18-returns-closure/output.txt @@ -15,6 +15,6 @@ help: use `impl Fn(i32) -> i32` as the return type, as all return paths are of t error: aborting due to previous error For more information about this error, try `rustc --explain E0746`. -error: could not compile `functions-example`. +error: could not compile `functions-example` To learn more, run the command again with --verbose. diff --git a/listings/ch19-advanced-features/output-only-01-missing-unsafe/output.txt b/listings/ch19-advanced-features/output-only-01-missing-unsafe/output.txt index bfe082a8b9..65e12009e3 100644 --- a/listings/ch19-advanced-features/output-only-01-missing-unsafe/output.txt +++ b/listings/ch19-advanced-features/output-only-01-missing-unsafe/output.txt @@ -11,6 +11,6 @@ error[E0133]: call to unsafe function is unsafe and requires unsafe function or error: aborting due to previous error For more information about this error, try `rustc --explain E0133`. -error: could not compile `unsafe-example`. +error: could not compile `unsafe-example` To learn more, run the command again with --verbose. diff --git a/listings/ch20-web-server/listing-20-12/output.txt b/listings/ch20-web-server/listing-20-12/output.txt index 3a798ef120..0bf6178713 100644 --- a/listings/ch20-web-server/listing-20-12/output.txt +++ b/listings/ch20-web-server/listing-20-12/output.txt @@ -1,14 +1,14 @@ $ cargo check Checking hello v0.1.0 (file:///projects/hello) -error[E0433]: failed to resolve: use of undeclared type or module `ThreadPool` +error[E0433]: failed to resolve: use of undeclared type `ThreadPool` --> src/main.rs:10:16 | 10 | let pool = ThreadPool::new(4); - | ^^^^^^^^^^ use of undeclared type or module `ThreadPool` + | ^^^^^^^^^^ use of undeclared type `ThreadPool` error: aborting due to previous error For more information about this error, try `rustc --explain E0433`. -error: could not compile `hello`. +error: could not compile `hello` To learn more, run the command again with --verbose. diff --git a/listings/ch20-web-server/listing-20-17/output.txt b/listings/ch20-web-server/listing-20-17/output.txt index f9749e1214..4715e23b93 100644 --- a/listings/ch20-web-server/listing-20-17/output.txt +++ b/listings/ch20-web-server/listing-20-17/output.txt @@ -12,6 +12,6 @@ error[E0382]: use of moved value: `receiver` error: aborting due to previous error For more information about this error, try `rustc --explain E0382`. -error: could not compile `hello`. +error: could not compile `hello` To learn more, run the command again with --verbose. diff --git a/listings/ch20-web-server/listing-20-22/output.txt b/listings/ch20-web-server/listing-20-22/output.txt index f5dd1ba13b..e810388ae0 100644 --- a/listings/ch20-web-server/listing-20-22/output.txt +++ b/listings/ch20-web-server/listing-20-22/output.txt @@ -4,11 +4,11 @@ error[E0507]: cannot move out of `worker.thread` which is behind a mutable refer --> src/lib.rs:52:13 | 52 | worker.thread.join().unwrap(); - | ^^^^^^^^^^^^^ move occurs because `worker.thread` has type `std::thread::JoinHandle<()>`, which does not implement the `Copy` trait + | ^^^^^^^^^^^^^ move occurs because `worker.thread` has type `JoinHandle<()>`, which does not implement the `Copy` trait error: aborting due to previous error For more information about this error, try `rustc --explain E0507`. -error: could not compile `hello`. +error: could not compile `hello` To learn more, run the command again with --verbose. diff --git a/listings/ch20-web-server/no-listing-01-define-threadpool-struct/output.txt b/listings/ch20-web-server/no-listing-01-define-threadpool-struct/output.txt index 1aeb2b9919..187274f046 100644 --- a/listings/ch20-web-server/no-listing-01-define-threadpool-struct/output.txt +++ b/listings/ch20-web-server/no-listing-01-define-threadpool-struct/output.txt @@ -1,14 +1,14 @@ $ cargo check Checking hello v0.1.0 (file:///projects/hello) -error[E0599]: no function or associated item named `new` found for struct `hello::ThreadPool` in the current scope +error[E0599]: no function or associated item named `new` found for struct `ThreadPool` in the current scope --> src/bin/main.rs:11:28 | 11 | let pool = ThreadPool::new(4); - | ^^^ function or associated item not found in `hello::ThreadPool` + | ^^^ function or associated item not found in `ThreadPool` error: aborting due to previous error For more information about this error, try `rustc --explain E0599`. -error: could not compile `hello`. +error: could not compile `hello` To learn more, run the command again with --verbose. diff --git a/listings/ch20-web-server/no-listing-02-impl-threadpool-new/output.txt b/listings/ch20-web-server/no-listing-02-impl-threadpool-new/output.txt index 0489965537..33c8a68c00 100644 --- a/listings/ch20-web-server/no-listing-02-impl-threadpool-new/output.txt +++ b/listings/ch20-web-server/no-listing-02-impl-threadpool-new/output.txt @@ -1,14 +1,14 @@ $ cargo check Checking hello v0.1.0 (file:///projects/hello) -error[E0599]: no method named `execute` found for struct `hello::ThreadPool` in the current scope +error[E0599]: no method named `execute` found for struct `ThreadPool` in the current scope --> src/bin/main.rs:16:14 | 16 | pool.execute(|| { - | ^^^^^^^ method not found in `hello::ThreadPool` + | ^^^^^^^ method not found in `ThreadPool` error: aborting due to previous error For more information about this error, try `rustc --explain E0599`. -error: could not compile `hello`. +error: could not compile `hello` To learn more, run the command again with --verbose. 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 4ce0cb1416..155e463a4d 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,10 +1,10 @@ $ cargo check Checking hello v0.1.0 (file:///projects/hello) -error[E0599]: no method named `join` found for enum `std::option::Option>` in the current scope +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 `std::option::Option>` + | ^^^^ method not found in `Option>` error[E0308]: mismatched types --> src/lib.rs:72:22 @@ -12,16 +12,16 @@ error[E0308]: mismatched types 72 | Worker { id, thread } | ^^^^^^ | | - | expected enum `std::option::Option`, found struct `std::thread::JoinHandle` + | expected enum `Option`, found struct `JoinHandle` | help: try using a variant of the expected enum: `Some(thread)` | - = note: expected enum `std::option::Option>` - found struct `std::thread::JoinHandle<_>` + = note: expected enum `Option>` + found struct `JoinHandle<_>` error: aborting due to 2 previous errors Some errors have detailed explanations: E0308, E0599. For more information about an error, try `rustc --explain E0308`. -error: could not compile `hello`. +error: could not compile `hello` To learn more, run the command again with --verbose. diff --git a/rust-toolchain b/rust-toolchain index 99dd716886..c05d9129f1 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.47 +1.48 diff --git a/src/title-page.md b/src/title-page.md index 9e975ec58b..2dfe5a102f 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.47 or later with +This version of the text assumes you’re using Rust 1.48 or later with `edition="2018"` in *Cargo.toml* of all projects to use Rust 2018 Edition idioms. See the [“Installation” section of Chapter 1][install] to install or update Rust, and see the new [Appendix E][editions] add-one/src/lib.rs:1:5 + | +1 | use rand; + | ^^^^ + | + = note: `#[warn(unused_imports)]` on by default + +warning: 1 warning emitted + Compiling adder v0.1.0 (file:///projects/add/adder) Finished dev [unoptimized + debuginfo] target(s) in 10.18s ``` @@ -255,7 +266,7 @@ error[E0432]: unresolved import `rand` --> adder/src/main.rs:2:5 | 2 | use rand; - | ^^^^ no `rand` external crate + | ^^^^ no external crate `rand` ``` To fix this, edit the *Cargo.toml* file for the `adder` package and indicate diff --git a/src/ch14-04-installing-binaries.md b/src/ch14-04-installing-binaries.md index 1a290b413e..753e3c61f9 100644 --- a/src/ch14-04-installing-binaries.md +++ b/src/ch14-04-installing-binaries.md @@ -33,7 +33,7 @@ $ cargo install ripgrep Installing ripgrep v11.0.2 --snip-- Compiling ripgrep v11.0.2 - Finished release [optimized] target(s) in 3m 10s + Finished release [optimized + debuginfo] target(s) in 3m 10s Installing ~/.cargo/bin/rg Installed package `ripgrep v11.0.2` (executable `rg`) ``` diff --git a/src/ch15-01-box.md b/src/ch15-01-box.md index acc3649fd7..394e4eb0d0 100644 --- a/src/ch15-01-box.md +++ b/src/ch15-01-box.md @@ -192,7 +192,10 @@ after doing automatic regeneration, look at listings/ch15-smart-pointers/listing --> ```text - = help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `List` representable +help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `List` representable + | +2 | Cons(i32, Box), + | ^^^^ ^ ``` In this suggestion, “indirection” means that instead of storing a value diff --git a/src/ch20-02-multithreaded.md b/src/ch20-02-multithreaded.md index d221cd475f..5b887d2c1c 100644 --- a/src/ch20-02-multithreaded.md +++ b/src/ch20-02-multithreaded.md @@ -616,6 +616,8 @@ warning: field is never read: `thread` 49 | thread: thread::JoinHandle<()>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +warning: 3 warnings emitted + Finished dev [unoptimized + debuginfo] target(s) in 1.40s Running `target/debug/main` Worker 0 got a job; executing. From eb60fedc9ccd72999f9aabd82f5936ca0143dd8f Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Fri, 4 Dec 2020 22:17:06 -0500 Subject: [PATCH 12/13] A solution for empty main in lib.rs, I think! The reasons we needed empty `fn main() {}`s were twofold: - Avoid confusing people when they click the "expand" button on the code listing and see the auto-main wrapping - Avoid failing doctests when running `mdbook test` that don't work when rustdoc wraps a code listing in main I think I have a solution that mostly solves these cases. I don't know why this didn't occur to me before. Here's my current thinking in case these assumptions turn out to be wrong: There are a [few things that tell mdbook to disable the main-wrapping][mdbook], and I hadn't noticed one of them until now: if you annotate a code block with `noplayground`, it won't add a `main` around it (and it also won't have the "play" button in the upper right that runs the block and inserts the result into the page). So instead of putting an empty `fn main() {}` at the bottom of src/lib.rs files that doesn't make sense, annotate those listings with `noplayground`. I don't think anyone will miss the play button anyway because: - The play button doesn't run tests, so there wasn't any output for these examples anyway - If an example doesn't compile, we have it marked `ignore` so that it doesn't make the tests fail, and `ignore` also disables the play button, so there isn't a way to see compiler errors either In most of these cases, `mdbook test` that runs these as doctests will still wrap these in main, but the tests still pass. There are some cases, mostly around modules and using `crate::` that won't pass as doctests when wrapped in main. For those, I've annotated them with the [undocumented][] [`test_harness`][] attribute that apparently I was using at some point and then [stopped using][] and now I've decided to use again, but maybe send in a PR to rust-lang/rust to change the name to `no_main` and document it or something. In any case, that shouldn't affect readers at all. [mdbook]: https://github.com/rust-lang/mdBook/blob/d0deee90b04068ed949f524bb682a47fa26f2218/src/renderer/html_handlebars/hbs_renderer.rs#L805-L808 [undocumented]: https://github.com/rust-lang/rust/issues/42288#issuecomment-309661382 [`test_harness`]: https://github.com/rust-lang/rust/blob/220352781c2585f0efb07ab0e758b136514de5b8/src/librustdoc/doctest.rs#L252 [stopped using]: https://github.com/rust-lang/book/pull/1233#discussion_r175515585 --- ci/dictionary.txt | 2 + .../listing-07-01/src/lib.rs | 4 -- .../listing-07-07/src/lib.rs | 4 -- .../listing-07-08/src/lib.rs | 4 -- .../listing-07-11/src/lib.rs | 4 -- .../listing-07-12/src/lib.rs | 4 -- .../listing-07-13/src/lib.rs | 4 -- .../listing-07-17/src/lib.rs | 4 -- .../listing-11-01/src/lib.rs | 4 -- .../listing-11-03/src/lib.rs | 2 - .../listing-11-05/src/lib.rs | 2 - .../listing-11-06/src/lib.rs | 2 - .../listing-11-07/src/lib.rs | 4 -- .../listing-11-08/src/lib.rs | 4 -- .../listing-11-09/src/lib.rs | 2 - .../listing-11-10/src/lib.rs | 4 -- .../listing-11-12/src/lib.rs | 4 -- .../src/lib.rs | 4 -- .../src/lib.rs | 2 - .../src/lib.rs | 2 - .../no-listing-04-bug-in-add-two/src/lib.rs | 2 - .../no-listing-05-greeter/src/lib.rs | 4 -- .../no-listing-06-greeter-with-bug/src/lib.rs | 2 - .../no-listing-08-guess-with-bug/src/lib.rs | 2 - .../no-listing-10-result-in-tests/src/lib.rs | 5 --- .../no-listing-11-ignore-a-test/src/lib.rs | 4 -- .../output-only-04-running-ignored/src/lib.rs | 2 - .../listing-12-15/src/lib.rs | 2 - .../listing-12-16/src/lib.rs | 2 - .../listing-12-20/src/lib.rs | 2 - .../listing-12-21/src/lib.rs | 2 - .../listing-12-22/src/lib.rs | 2 - .../listing-12-23/src/lib.rs | 2 - .../src/lib.rs | 2 - .../listing-12-23-reproduced/src/lib.rs | 2 - .../listing-13-15/src/lib.rs | 2 - .../listing-13-16/src/lib.rs | 2 - .../listing-13-19/src/lib.rs | 2 - .../listing-13-20/src/lib.rs | 2 - .../listing-13-21/src/lib.rs | 2 - .../listing-13-22/src/lib.rs | 2 - .../listing-13-23/src/lib.rs | 2 - .../listing-13-27/src/lib.rs | 2 - .../listing-14-03/src/lib.rs | 4 -- .../listing-15-22/src/lib.rs | 2 - listings/ch17-oop/listing-17-07/src/lib.rs | 2 - listings/ch17-oop/listing-17-13/src/lib.rs | 2 - listings/ch17-oop/listing-17-14/src/lib.rs | 2 - listings/ch17-oop/listing-17-15/src/lib.rs | 2 - .../listing-13-21-reproduced/src/lib.rs | 2 - .../no-listing-06-result-alias/src/lib.rs | 2 - .../no-listing-07-never-type/src/lib.rs | 2 - .../ch20-web-server/listing-20-13/src/lib.rs | 2 - .../ch20-web-server/listing-20-15/src/lib.rs | 2 - .../ch20-web-server/listing-20-16/src/lib.rs | 2 - .../ch20-web-server/listing-20-18/src/lib.rs | 2 - .../ch20-web-server/listing-20-19/src/lib.rs | 2 - .../ch20-web-server/listing-20-25/src/lib.rs | 4 -- .../src/lib.rs | 4 -- .../no-listing-03-define-execute/src/lib.rs | 2 - .../src/lib.rs | 2 - ...ng-modules-to-control-scope-and-privacy.md | 4 +- ...referring-to-an-item-in-the-module-tree.md | 8 ++-- ...g-paths-into-scope-with-the-use-keyword.md | 16 +++---- src/ch11-01-writing-tests.md | 42 +++++++++---------- src/ch11-02-running-tests.md | 8 ++-- src/ch11-03-test-organization.md | 4 +- ...2-04-testing-the-librarys-functionality.md | 2 +- ...2-05-working-with-environment-variables.md | 6 +-- src/ch13-02-iterators.md | 16 +++---- src/ch13-03-improving-our-io-project.md | 2 +- src/ch14-02-publishing-to-crates-io.md | 4 +- src/ch15-05-interior-mutability.md | 2 +- src/ch17-02-trait-objects.md | 2 +- src/ch17-03-oo-design-patterns.md | 6 +-- src/ch19-04-advanced-types.md | 6 +-- src/ch20-02-multithreaded.md | 16 +++---- src/ch20-03-graceful-shutdown-and-cleanup.md | 6 +-- 78 files changed, 77 insertions(+), 234 deletions(-) diff --git a/ci/dictionary.txt b/ci/dictionary.txt index d1ba6379d5..b4dbfa6312 100644 --- a/ci/dictionary.txt +++ b/ci/dictionary.txt @@ -318,6 +318,7 @@ nonadministrators nondeterministic nonequality nongeneric +noplayground NotFound nsprust null's @@ -470,6 +471,7 @@ supertraits TcpListener TcpStream templating +test_harness test's TextField That'd diff --git a/listings/ch07-managing-growing-projects/listing-07-01/src/lib.rs b/listings/ch07-managing-growing-projects/listing-07-01/src/lib.rs index 0e40be70d9..591e24557e 100644 --- a/listings/ch07-managing-growing-projects/listing-07-01/src/lib.rs +++ b/listings/ch07-managing-growing-projects/listing-07-01/src/lib.rs @@ -1,4 +1,3 @@ -// ANCHOR: here mod front_of_house { mod hosting { fn add_to_waitlist() {} @@ -14,6 +13,3 @@ mod front_of_house { fn take_payment() {} } } -// ANCHOR_END: here - -fn main() {} diff --git a/listings/ch07-managing-growing-projects/listing-07-07/src/lib.rs b/listings/ch07-managing-growing-projects/listing-07-07/src/lib.rs index 5a6edf9832..7b89ee7cd2 100644 --- a/listings/ch07-managing-growing-projects/listing-07-07/src/lib.rs +++ b/listings/ch07-managing-growing-projects/listing-07-07/src/lib.rs @@ -1,4 +1,3 @@ -// ANCHOR: here mod front_of_house { pub mod hosting { pub fn add_to_waitlist() {} @@ -12,6 +11,3 @@ pub fn eat_at_restaurant() { // Relative path front_of_house::hosting::add_to_waitlist(); } -// ANCHOR_END: here - -fn main() {} diff --git a/listings/ch07-managing-growing-projects/listing-07-08/src/lib.rs b/listings/ch07-managing-growing-projects/listing-07-08/src/lib.rs index a789379ae2..7d4b5972e6 100644 --- a/listings/ch07-managing-growing-projects/listing-07-08/src/lib.rs +++ b/listings/ch07-managing-growing-projects/listing-07-08/src/lib.rs @@ -1,4 +1,3 @@ -// ANCHOR: here fn serve_order() {} mod back_of_house { @@ -9,6 +8,3 @@ mod back_of_house { fn cook_order() {} } -// ANCHOR_END: here - -fn main() {} diff --git a/listings/ch07-managing-growing-projects/listing-07-11/src/lib.rs b/listings/ch07-managing-growing-projects/listing-07-11/src/lib.rs index 3a75683757..44defd0aa3 100644 --- a/listings/ch07-managing-growing-projects/listing-07-11/src/lib.rs +++ b/listings/ch07-managing-growing-projects/listing-07-11/src/lib.rs @@ -1,4 +1,3 @@ -// ANCHOR: here mod front_of_house { pub mod hosting { pub fn add_to_waitlist() {} @@ -12,6 +11,3 @@ pub fn eat_at_restaurant() { hosting::add_to_waitlist(); hosting::add_to_waitlist(); } -// ANCHOR_END: here - -fn main() {} diff --git a/listings/ch07-managing-growing-projects/listing-07-12/src/lib.rs b/listings/ch07-managing-growing-projects/listing-07-12/src/lib.rs index 6b0101b7d1..671bc10219 100644 --- a/listings/ch07-managing-growing-projects/listing-07-12/src/lib.rs +++ b/listings/ch07-managing-growing-projects/listing-07-12/src/lib.rs @@ -1,4 +1,3 @@ -// ANCHOR: here mod front_of_house { pub mod hosting { pub fn add_to_waitlist() {} @@ -12,6 +11,3 @@ pub fn eat_at_restaurant() { hosting::add_to_waitlist(); hosting::add_to_waitlist(); } -// ANCHOR_END: here - -fn main() {} diff --git a/listings/ch07-managing-growing-projects/listing-07-13/src/lib.rs b/listings/ch07-managing-growing-projects/listing-07-13/src/lib.rs index 98414aac91..e886c243e9 100644 --- a/listings/ch07-managing-growing-projects/listing-07-13/src/lib.rs +++ b/listings/ch07-managing-growing-projects/listing-07-13/src/lib.rs @@ -1,4 +1,3 @@ -// ANCHOR: here mod front_of_house { pub mod hosting { pub fn add_to_waitlist() {} @@ -12,6 +11,3 @@ pub fn eat_at_restaurant() { add_to_waitlist(); add_to_waitlist(); } -// ANCHOR_END: here - -fn main() {} diff --git a/listings/ch07-managing-growing-projects/listing-07-17/src/lib.rs b/listings/ch07-managing-growing-projects/listing-07-17/src/lib.rs index e948d7c38e..835e571ec9 100644 --- a/listings/ch07-managing-growing-projects/listing-07-17/src/lib.rs +++ b/listings/ch07-managing-growing-projects/listing-07-17/src/lib.rs @@ -1,4 +1,3 @@ -// ANCHOR: here mod front_of_house { pub mod hosting { pub fn add_to_waitlist() {} @@ -12,6 +11,3 @@ pub fn eat_at_restaurant() { hosting::add_to_waitlist(); hosting::add_to_waitlist(); } -// ANCHOR_END: here - -fn main() {} diff --git a/listings/ch11-writing-automated-tests/listing-11-01/src/lib.rs b/listings/ch11-writing-automated-tests/listing-11-01/src/lib.rs index 8e678421e9..31e1bb209f 100644 --- a/listings/ch11-writing-automated-tests/listing-11-01/src/lib.rs +++ b/listings/ch11-writing-automated-tests/listing-11-01/src/lib.rs @@ -1,4 +1,3 @@ -// ANCHOR: here #[cfg(test)] mod tests { #[test] @@ -6,6 +5,3 @@ mod tests { assert_eq!(2 + 2, 4); } } -// ANCHOR_END: here - -fn main() {} diff --git a/listings/ch11-writing-automated-tests/listing-11-03/src/lib.rs b/listings/ch11-writing-automated-tests/listing-11-03/src/lib.rs index 92f315ac85..a9ec008919 100644 --- a/listings/ch11-writing-automated-tests/listing-11-03/src/lib.rs +++ b/listings/ch11-writing-automated-tests/listing-11-03/src/lib.rs @@ -12,5 +12,3 @@ mod tests { } } // ANCHOR_END: here - -fn main() {} diff --git a/listings/ch11-writing-automated-tests/listing-11-05/src/lib.rs b/listings/ch11-writing-automated-tests/listing-11-05/src/lib.rs index aad33554b9..0f1bc4e084 100644 --- a/listings/ch11-writing-automated-tests/listing-11-05/src/lib.rs +++ b/listings/ch11-writing-automated-tests/listing-11-05/src/lib.rs @@ -11,5 +11,3 @@ impl Rectangle { } } // ANCHOR_END: here - -fn main() {} diff --git a/listings/ch11-writing-automated-tests/listing-11-06/src/lib.rs b/listings/ch11-writing-automated-tests/listing-11-06/src/lib.rs index a02395313d..6ad1512ed0 100644 --- a/listings/ch11-writing-automated-tests/listing-11-06/src/lib.rs +++ b/listings/ch11-writing-automated-tests/listing-11-06/src/lib.rs @@ -30,5 +30,3 @@ mod tests { } } // ANCHOR_END: here - -fn main() {} diff --git a/listings/ch11-writing-automated-tests/listing-11-07/src/lib.rs b/listings/ch11-writing-automated-tests/listing-11-07/src/lib.rs index 534073276d..3e5d66bfaf 100644 --- a/listings/ch11-writing-automated-tests/listing-11-07/src/lib.rs +++ b/listings/ch11-writing-automated-tests/listing-11-07/src/lib.rs @@ -1,4 +1,3 @@ -// ANCHOR: here pub fn add_two(a: i32) -> i32 { a + 2 } @@ -12,6 +11,3 @@ mod tests { assert_eq!(4, add_two(2)); } } -// ANCHOR_END: here - -fn main() {} diff --git a/listings/ch11-writing-automated-tests/listing-11-08/src/lib.rs b/listings/ch11-writing-automated-tests/listing-11-08/src/lib.rs index b417302131..9391be5b1f 100644 --- a/listings/ch11-writing-automated-tests/listing-11-08/src/lib.rs +++ b/listings/ch11-writing-automated-tests/listing-11-08/src/lib.rs @@ -1,4 +1,3 @@ -// ANCHOR: here pub struct Guess { value: i32, } @@ -23,6 +22,3 @@ mod tests { Guess::new(200); } } -// ANCHOR_END: here - -fn main() {} diff --git a/listings/ch11-writing-automated-tests/listing-11-09/src/lib.rs b/listings/ch11-writing-automated-tests/listing-11-09/src/lib.rs index ffa543bfb6..475d4b91cd 100644 --- a/listings/ch11-writing-automated-tests/listing-11-09/src/lib.rs +++ b/listings/ch11-writing-automated-tests/listing-11-09/src/lib.rs @@ -33,5 +33,3 @@ mod tests { } } // ANCHOR_END: here - -fn main() {} diff --git a/listings/ch11-writing-automated-tests/listing-11-10/src/lib.rs b/listings/ch11-writing-automated-tests/listing-11-10/src/lib.rs index 62d0fddbf1..6fd76ce006 100644 --- a/listings/ch11-writing-automated-tests/listing-11-10/src/lib.rs +++ b/listings/ch11-writing-automated-tests/listing-11-10/src/lib.rs @@ -1,6 +1,3 @@ -fn main() {} - -// ANCHOR: here fn prints_and_returns_10(a: i32) -> i32 { println!("I got the value {}", a); 10 @@ -22,4 +19,3 @@ mod tests { assert_eq!(5, value); } } -// ANCHOR_END: here diff --git a/listings/ch11-writing-automated-tests/listing-11-12/src/lib.rs b/listings/ch11-writing-automated-tests/listing-11-12/src/lib.rs index 800b84f53b..c3961b1f62 100644 --- a/listings/ch11-writing-automated-tests/listing-11-12/src/lib.rs +++ b/listings/ch11-writing-automated-tests/listing-11-12/src/lib.rs @@ -1,4 +1,3 @@ -// ANCHOR: here pub fn add_two(a: i32) -> i32 { internal_adder(a, 2) } @@ -16,6 +15,3 @@ mod tests { assert_eq!(4, internal_adder(2, 2)); } } -// ANCHOR_END: here - -fn main() {} diff --git a/listings/ch11-writing-automated-tests/no-listing-01-changing-test-name/src/lib.rs b/listings/ch11-writing-automated-tests/no-listing-01-changing-test-name/src/lib.rs index 2974d7273d..330bddf6ac 100644 --- a/listings/ch11-writing-automated-tests/no-listing-01-changing-test-name/src/lib.rs +++ b/listings/ch11-writing-automated-tests/no-listing-01-changing-test-name/src/lib.rs @@ -1,4 +1,3 @@ -// ANCHOR: here #[cfg(test)] mod tests { #[test] @@ -6,6 +5,3 @@ mod tests { assert_eq!(2 + 2, 4); } } -// ANCHOR_END: here - -fn main() {} diff --git a/listings/ch11-writing-automated-tests/no-listing-02-adding-another-rectangle-test/src/lib.rs b/listings/ch11-writing-automated-tests/no-listing-02-adding-another-rectangle-test/src/lib.rs index 338ad09364..ee4fc45b99 100644 --- a/listings/ch11-writing-automated-tests/no-listing-02-adding-another-rectangle-test/src/lib.rs +++ b/listings/ch11-writing-automated-tests/no-listing-02-adding-another-rectangle-test/src/lib.rs @@ -47,5 +47,3 @@ mod tests { } } // ANCHOR_END: here - -fn main() {} diff --git a/listings/ch11-writing-automated-tests/no-listing-03-introducing-a-bug/src/lib.rs b/listings/ch11-writing-automated-tests/no-listing-03-introducing-a-bug/src/lib.rs index 33a2dd0ac1..f5968fcafb 100644 --- a/listings/ch11-writing-automated-tests/no-listing-03-introducing-a-bug/src/lib.rs +++ b/listings/ch11-writing-automated-tests/no-listing-03-introducing-a-bug/src/lib.rs @@ -45,5 +45,3 @@ mod tests { assert!(!smaller.can_hold(&larger)); } } - -fn main() {} diff --git a/listings/ch11-writing-automated-tests/no-listing-04-bug-in-add-two/src/lib.rs b/listings/ch11-writing-automated-tests/no-listing-04-bug-in-add-two/src/lib.rs index 8b4534b4aa..f186625261 100644 --- a/listings/ch11-writing-automated-tests/no-listing-04-bug-in-add-two/src/lib.rs +++ b/listings/ch11-writing-automated-tests/no-listing-04-bug-in-add-two/src/lib.rs @@ -13,5 +13,3 @@ mod tests { assert_eq!(4, add_two(2)); } } - -fn main() {} diff --git a/listings/ch11-writing-automated-tests/no-listing-05-greeter/src/lib.rs b/listings/ch11-writing-automated-tests/no-listing-05-greeter/src/lib.rs index 4fcdbbf279..3ba3d8819e 100644 --- a/listings/ch11-writing-automated-tests/no-listing-05-greeter/src/lib.rs +++ b/listings/ch11-writing-automated-tests/no-listing-05-greeter/src/lib.rs @@ -1,4 +1,3 @@ -// ANCHOR: here pub fn greeting(name: &str) -> String { format!("Hello {}!", name) } @@ -13,6 +12,3 @@ mod tests { assert!(result.contains("Carol")); } } -// ANCHOR_END: here - -fn main() {} diff --git a/listings/ch11-writing-automated-tests/no-listing-06-greeter-with-bug/src/lib.rs b/listings/ch11-writing-automated-tests/no-listing-06-greeter-with-bug/src/lib.rs index d516534e59..6f28fc52a2 100644 --- a/listings/ch11-writing-automated-tests/no-listing-06-greeter-with-bug/src/lib.rs +++ b/listings/ch11-writing-automated-tests/no-listing-06-greeter-with-bug/src/lib.rs @@ -14,5 +14,3 @@ mod tests { assert!(result.contains("Carol")); } } - -fn main() {} diff --git a/listings/ch11-writing-automated-tests/no-listing-08-guess-with-bug/src/lib.rs b/listings/ch11-writing-automated-tests/no-listing-08-guess-with-bug/src/lib.rs index 269c73cefa..32540ba83c 100644 --- a/listings/ch11-writing-automated-tests/no-listing-08-guess-with-bug/src/lib.rs +++ b/listings/ch11-writing-automated-tests/no-listing-08-guess-with-bug/src/lib.rs @@ -25,5 +25,3 @@ mod tests { Guess::new(200); } } - -fn main() {} diff --git a/listings/ch11-writing-automated-tests/no-listing-10-result-in-tests/src/lib.rs b/listings/ch11-writing-automated-tests/no-listing-10-result-in-tests/src/lib.rs index becae97e07..6284f4f291 100644 --- a/listings/ch11-writing-automated-tests/no-listing-10-result-in-tests/src/lib.rs +++ b/listings/ch11-writing-automated-tests/no-listing-10-result-in-tests/src/lib.rs @@ -1,7 +1,3 @@ -#![allow(unused_variables)] -fn main() {} - -// ANCHOR: here #[cfg(test)] mod tests { #[test] @@ -13,4 +9,3 @@ mod tests { } } } -// ANCHOR_END: here diff --git a/listings/ch11-writing-automated-tests/no-listing-11-ignore-a-test/src/lib.rs b/listings/ch11-writing-automated-tests/no-listing-11-ignore-a-test/src/lib.rs index 9a75301e31..d54a6095d7 100644 --- a/listings/ch11-writing-automated-tests/no-listing-11-ignore-a-test/src/lib.rs +++ b/listings/ch11-writing-automated-tests/no-listing-11-ignore-a-test/src/lib.rs @@ -1,4 +1,3 @@ -// ANCHOR: here #[test] fn it_works() { assert_eq!(2 + 2, 4); @@ -9,6 +8,3 @@ fn it_works() { fn expensive_test() { // code that takes an hour to run } -// ANCHOR_END: here - -fn main() {} diff --git a/listings/ch11-writing-automated-tests/output-only-04-running-ignored/src/lib.rs b/listings/ch11-writing-automated-tests/output-only-04-running-ignored/src/lib.rs index 9a75301e31..2290c699d8 100644 --- a/listings/ch11-writing-automated-tests/output-only-04-running-ignored/src/lib.rs +++ b/listings/ch11-writing-automated-tests/output-only-04-running-ignored/src/lib.rs @@ -10,5 +10,3 @@ fn expensive_test() { // code that takes an hour to run } // ANCHOR_END: here - -fn main() {} diff --git a/listings/ch12-an-io-project/listing-12-15/src/lib.rs b/listings/ch12-an-io-project/listing-12-15/src/lib.rs index 22ec381783..c677188393 100644 --- a/listings/ch12-an-io-project/listing-12-15/src/lib.rs +++ b/listings/ch12-an-io-project/listing-12-15/src/lib.rs @@ -42,5 +42,3 @@ Pick three."; } } // ANCHOR_END: here - -fn main() {} diff --git a/listings/ch12-an-io-project/listing-12-16/src/lib.rs b/listings/ch12-an-io-project/listing-12-16/src/lib.rs index 2fc5b4f722..8729c32f4d 100644 --- a/listings/ch12-an-io-project/listing-12-16/src/lib.rs +++ b/listings/ch12-an-io-project/listing-12-16/src/lib.rs @@ -46,5 +46,3 @@ Pick three."; assert_eq!(vec!["safe, fast, productive."], search(query, contents)); } } - -fn main() {} diff --git a/listings/ch12-an-io-project/listing-12-20/src/lib.rs b/listings/ch12-an-io-project/listing-12-20/src/lib.rs index 52ba2bd51c..542d08874d 100644 --- a/listings/ch12-an-io-project/listing-12-20/src/lib.rs +++ b/listings/ch12-an-io-project/listing-12-20/src/lib.rs @@ -74,5 +74,3 @@ Trust me."; } } // ANCHOR_END: here - -fn main() {} diff --git a/listings/ch12-an-io-project/listing-12-21/src/lib.rs b/listings/ch12-an-io-project/listing-12-21/src/lib.rs index 873c8b53d0..10f6dea094 100644 --- a/listings/ch12-an-io-project/listing-12-21/src/lib.rs +++ b/listings/ch12-an-io-project/listing-12-21/src/lib.rs @@ -90,5 +90,3 @@ Trust me."; ); } } - -fn main() {} diff --git a/listings/ch12-an-io-project/listing-12-22/src/lib.rs b/listings/ch12-an-io-project/listing-12-22/src/lib.rs index 2df82b7e2f..3402a273f3 100644 --- a/listings/ch12-an-io-project/listing-12-22/src/lib.rs +++ b/listings/ch12-an-io-project/listing-12-22/src/lib.rs @@ -99,5 +99,3 @@ Trust me."; ); } } - -fn main() {} diff --git a/listings/ch12-an-io-project/listing-12-23/src/lib.rs b/listings/ch12-an-io-project/listing-12-23/src/lib.rs index e6dc51a0ed..fa63a8c7be 100644 --- a/listings/ch12-an-io-project/listing-12-23/src/lib.rs +++ b/listings/ch12-an-io-project/listing-12-23/src/lib.rs @@ -108,5 +108,3 @@ Trust me."; ); } } - -fn main() {} diff --git a/listings/ch12-an-io-project/output-only-02-missing-lifetimes/src/lib.rs b/listings/ch12-an-io-project/output-only-02-missing-lifetimes/src/lib.rs index c60405c219..65af968d95 100644 --- a/listings/ch12-an-io-project/output-only-02-missing-lifetimes/src/lib.rs +++ b/listings/ch12-an-io-project/output-only-02-missing-lifetimes/src/lib.rs @@ -46,5 +46,3 @@ Pick three."; assert_eq!(vec!["safe, fast, productive."], search(query, contents)); } } - -fn main() {} diff --git a/listings/ch13-functional-features/listing-12-23-reproduced/src/lib.rs b/listings/ch13-functional-features/listing-12-23-reproduced/src/lib.rs index 5397d7f617..7f0178dafc 100644 --- a/listings/ch13-functional-features/listing-12-23-reproduced/src/lib.rs +++ b/listings/ch13-functional-features/listing-12-23-reproduced/src/lib.rs @@ -104,5 +104,3 @@ Trust me."; ); } } - -fn main() {} diff --git a/listings/ch13-functional-features/listing-13-15/src/lib.rs b/listings/ch13-functional-features/listing-13-15/src/lib.rs index afea80d22e..758284044d 100644 --- a/listings/ch13-functional-features/listing-13-15/src/lib.rs +++ b/listings/ch13-functional-features/listing-13-15/src/lib.rs @@ -14,5 +14,3 @@ mod tests { } // ANCHOR_END: here } - -fn main() {} diff --git a/listings/ch13-functional-features/listing-13-16/src/lib.rs b/listings/ch13-functional-features/listing-13-16/src/lib.rs index 198b3c834b..d1cb54d0a1 100644 --- a/listings/ch13-functional-features/listing-13-16/src/lib.rs +++ b/listings/ch13-functional-features/listing-13-16/src/lib.rs @@ -13,5 +13,3 @@ mod tests { } // ANCHOR_END: here } - -fn main() {} diff --git a/listings/ch13-functional-features/listing-13-19/src/lib.rs b/listings/ch13-functional-features/listing-13-19/src/lib.rs index c7ca364c28..11c544f556 100644 --- a/listings/ch13-functional-features/listing-13-19/src/lib.rs +++ b/listings/ch13-functional-features/listing-13-19/src/lib.rs @@ -46,5 +46,3 @@ mod tests { ); } } - -fn main() {} diff --git a/listings/ch13-functional-features/listing-13-20/src/lib.rs b/listings/ch13-functional-features/listing-13-20/src/lib.rs index 897804c429..fb8a0cb2f8 100644 --- a/listings/ch13-functional-features/listing-13-20/src/lib.rs +++ b/listings/ch13-functional-features/listing-13-20/src/lib.rs @@ -7,5 +7,3 @@ impl Counter { Counter { count: 0 } } } - -fn main() {} diff --git a/listings/ch13-functional-features/listing-13-21/src/lib.rs b/listings/ch13-functional-features/listing-13-21/src/lib.rs index 97806be488..35ea8e5b6a 100644 --- a/listings/ch13-functional-features/listing-13-21/src/lib.rs +++ b/listings/ch13-functional-features/listing-13-21/src/lib.rs @@ -22,5 +22,3 @@ impl Iterator for Counter { } } // ANCHOR_END: here - -fn main() {} diff --git a/listings/ch13-functional-features/listing-13-22/src/lib.rs b/listings/ch13-functional-features/listing-13-22/src/lib.rs index f8faaca070..05afa41c88 100644 --- a/listings/ch13-functional-features/listing-13-22/src/lib.rs +++ b/listings/ch13-functional-features/listing-13-22/src/lib.rs @@ -39,5 +39,3 @@ mod tests { } // ANCHOR_END: here } - -fn main() {} diff --git a/listings/ch13-functional-features/listing-13-23/src/lib.rs b/listings/ch13-functional-features/listing-13-23/src/lib.rs index 351321ff97..f04d7304cd 100644 --- a/listings/ch13-functional-features/listing-13-23/src/lib.rs +++ b/listings/ch13-functional-features/listing-13-23/src/lib.rs @@ -49,5 +49,3 @@ mod tests { } // ANCHOR_END: here } - -fn main() {} diff --git a/listings/ch13-functional-features/listing-13-27/src/lib.rs b/listings/ch13-functional-features/listing-13-27/src/lib.rs index 61d828aab4..7a33565463 100644 --- a/listings/ch13-functional-features/listing-13-27/src/lib.rs +++ b/listings/ch13-functional-features/listing-13-27/src/lib.rs @@ -109,5 +109,3 @@ Trust me."; ); } } - -fn main() {} diff --git a/listings/ch14-more-about-cargo/listing-14-03/src/lib.rs b/listings/ch14-more-about-cargo/listing-14-03/src/lib.rs index 00a81c5082..09c043bad6 100644 --- a/listings/ch14-more-about-cargo/listing-14-03/src/lib.rs +++ b/listings/ch14-more-about-cargo/listing-14-03/src/lib.rs @@ -1,4 +1,3 @@ -// ANCHOR: here //! # Art //! //! A library for modeling artistic concepts. @@ -31,6 +30,3 @@ pub mod utils { // ANCHOR: here } } -// ANCHOR_END: here - -fn main() {} diff --git a/listings/ch15-smart-pointers/listing-15-22/src/lib.rs b/listings/ch15-smart-pointers/listing-15-22/src/lib.rs index dc259f7fca..539578ea2d 100644 --- a/listings/ch15-smart-pointers/listing-15-22/src/lib.rs +++ b/listings/ch15-smart-pointers/listing-15-22/src/lib.rs @@ -76,5 +76,3 @@ mod tests { } } // ANCHOR_END: here - -fn main() {} diff --git a/listings/ch17-oop/listing-17-07/src/lib.rs b/listings/ch17-oop/listing-17-07/src/lib.rs index 413dc6ff16..b16cd0155f 100644 --- a/listings/ch17-oop/listing-17-07/src/lib.rs +++ b/listings/ch17-oop/listing-17-07/src/lib.rs @@ -27,5 +27,3 @@ impl Draw for Button { } } // ANCHOR_END: here - -fn main() {} diff --git a/listings/ch17-oop/listing-17-13/src/lib.rs b/listings/ch17-oop/listing-17-13/src/lib.rs index 0ae3fa6e81..bd68557a01 100644 --- a/listings/ch17-oop/listing-17-13/src/lib.rs +++ b/listings/ch17-oop/listing-17-13/src/lib.rs @@ -26,5 +26,3 @@ trait State {} struct Draft {} impl State for Draft {} - -fn main() {} diff --git a/listings/ch17-oop/listing-17-14/src/lib.rs b/listings/ch17-oop/listing-17-14/src/lib.rs index 0d010f50c5..09cf0c4664 100644 --- a/listings/ch17-oop/listing-17-14/src/lib.rs +++ b/listings/ch17-oop/listing-17-14/src/lib.rs @@ -30,5 +30,3 @@ trait State {} struct Draft {} impl State for Draft {} - -fn main() {} diff --git a/listings/ch17-oop/listing-17-15/src/lib.rs b/listings/ch17-oop/listing-17-15/src/lib.rs index 806b4e49db..909dd5274b 100644 --- a/listings/ch17-oop/listing-17-15/src/lib.rs +++ b/listings/ch17-oop/listing-17-15/src/lib.rs @@ -50,5 +50,3 @@ impl State for PendingReview { } } // ANCHOR_END: here - -fn main() {} diff --git a/listings/ch19-advanced-features/listing-13-21-reproduced/src/lib.rs b/listings/ch19-advanced-features/listing-13-21-reproduced/src/lib.rs index b71b54fbce..04c7f38f5a 100644 --- a/listings/ch19-advanced-features/listing-13-21-reproduced/src/lib.rs +++ b/listings/ch19-advanced-features/listing-13-21-reproduced/src/lib.rs @@ -23,5 +23,3 @@ impl Iterator for Counter { } } } - -fn main() {} diff --git a/listings/ch19-advanced-features/no-listing-06-result-alias/src/lib.rs b/listings/ch19-advanced-features/no-listing-06-result-alias/src/lib.rs index c53a927e32..5735599348 100644 --- a/listings/ch19-advanced-features/no-listing-06-result-alias/src/lib.rs +++ b/listings/ch19-advanced-features/no-listing-06-result-alias/src/lib.rs @@ -13,5 +13,3 @@ pub trait Write { fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()>; } // ANCHOR_END: there - -fn main() {} diff --git a/listings/ch19-advanced-features/no-listing-07-never-type/src/lib.rs b/listings/ch19-advanced-features/no-listing-07-never-type/src/lib.rs index 236224186e..f0f7acac24 100644 --- a/listings/ch19-advanced-features/no-listing-07-never-type/src/lib.rs +++ b/listings/ch19-advanced-features/no-listing-07-never-type/src/lib.rs @@ -6,5 +6,3 @@ fn bar() -> ! { // ANCHOR: here } // ANCHOR_END: here - -fn main() {} diff --git a/listings/ch20-web-server/listing-20-13/src/lib.rs b/listings/ch20-web-server/listing-20-13/src/lib.rs index ffa3c6a254..e60c902472 100644 --- a/listings/ch20-web-server/listing-20-13/src/lib.rs +++ b/listings/ch20-web-server/listing-20-13/src/lib.rs @@ -26,5 +26,3 @@ impl ThreadPool { // ANCHOR: here } // ANCHOR_END: here - -fn main() {} diff --git a/listings/ch20-web-server/listing-20-15/src/lib.rs b/listings/ch20-web-server/listing-20-15/src/lib.rs index d2ad3ca176..80a6eeeb32 100644 --- a/listings/ch20-web-server/listing-20-15/src/lib.rs +++ b/listings/ch20-web-server/listing-20-15/src/lib.rs @@ -51,5 +51,3 @@ impl Worker { } } // ANCHOR_END: here - -fn main() {} diff --git a/listings/ch20-web-server/listing-20-16/src/lib.rs b/listings/ch20-web-server/listing-20-16/src/lib.rs index 28b374eed3..02d20cb000 100644 --- a/listings/ch20-web-server/listing-20-16/src/lib.rs +++ b/listings/ch20-web-server/listing-20-16/src/lib.rs @@ -58,5 +58,3 @@ impl Worker { Worker { id, thread } } } - -fn main() {} diff --git a/listings/ch20-web-server/listing-20-18/src/lib.rs b/listings/ch20-web-server/listing-20-18/src/lib.rs index d47eef869e..81973533a9 100644 --- a/listings/ch20-web-server/listing-20-18/src/lib.rs +++ b/listings/ch20-web-server/listing-20-18/src/lib.rs @@ -74,5 +74,3 @@ impl Worker { } } // ANCHOR_END: here - -fn main() {} diff --git a/listings/ch20-web-server/listing-20-19/src/lib.rs b/listings/ch20-web-server/listing-20-19/src/lib.rs index bf8127b8e5..734d4c2a9b 100644 --- a/listings/ch20-web-server/listing-20-19/src/lib.rs +++ b/listings/ch20-web-server/listing-20-19/src/lib.rs @@ -67,5 +67,3 @@ impl Worker { Worker { id, thread } } } - -fn main() {} diff --git a/listings/ch20-web-server/listing-20-25/src/lib.rs b/listings/ch20-web-server/listing-20-25/src/lib.rs index 424eac8e49..68f4263057 100644 --- a/listings/ch20-web-server/listing-20-25/src/lib.rs +++ b/listings/ch20-web-server/listing-20-25/src/lib.rs @@ -1,4 +1,3 @@ -// ANCHOR: here use std::sync::mpsc; use std::sync::Arc; use std::sync::Mutex; @@ -100,6 +99,3 @@ impl Worker { } } } -// ANCHOR_END: here - -fn main() {} diff --git a/listings/ch20-web-server/no-listing-02-impl-threadpool-new/src/lib.rs b/listings/ch20-web-server/no-listing-02-impl-threadpool-new/src/lib.rs index 3ff5ad4979..f0e1890bb6 100644 --- a/listings/ch20-web-server/no-listing-02-impl-threadpool-new/src/lib.rs +++ b/listings/ch20-web-server/no-listing-02-impl-threadpool-new/src/lib.rs @@ -1,4 +1,3 @@ -// ANCHOR: here pub struct ThreadPool; impl ThreadPool { @@ -6,6 +5,3 @@ impl ThreadPool { ThreadPool } } -// ANCHOR_END: here - -fn main() {} diff --git a/listings/ch20-web-server/no-listing-03-define-execute/src/lib.rs b/listings/ch20-web-server/no-listing-03-define-execute/src/lib.rs index 44e0ebd724..1321ab8738 100644 --- a/listings/ch20-web-server/no-listing-03-define-execute/src/lib.rs +++ b/listings/ch20-web-server/no-listing-03-define-execute/src/lib.rs @@ -16,5 +16,3 @@ impl ThreadPool { } } // ANCHOR_END: here - -fn main() {} diff --git a/listings/ch20-web-server/no-listing-07-define-message-enum/src/lib.rs b/listings/ch20-web-server/no-listing-07-define-message-enum/src/lib.rs index ed1913b293..46fb5f18d2 100644 --- a/listings/ch20-web-server/no-listing-07-define-message-enum/src/lib.rs +++ b/listings/ch20-web-server/no-listing-07-define-message-enum/src/lib.rs @@ -84,5 +84,3 @@ impl Worker { } } } - -fn main() {} diff --git a/src/ch07-02-defining-modules-to-control-scope-and-privacy.md b/src/ch07-02-defining-modules-to-control-scope-and-privacy.md index d46ef9b0c0..a215870bc5 100644 --- a/src/ch07-02-defining-modules-to-control-scope-and-privacy.md +++ b/src/ch07-02-defining-modules-to-control-scope-and-privacy.md @@ -29,8 +29,8 @@ Listing 7-1 into *src/lib.rs* to define some modules and function signatures. Filename: src/lib.rs -```rust -{{#rustdoc_include ../listings/ch07-managing-growing-projects/listing-07-01/src/lib.rs:here}} +```rust,noplayground +{{#rustdoc_include ../listings/ch07-managing-growing-projects/listing-07-01/src/lib.rs}} ``` Listing 7-1: A `front_of_house` module containing other diff --git a/src/ch07-03-paths-for-referring-to-an-item-in-the-module-tree.md b/src/ch07-03-paths-for-referring-to-an-item-in-the-module-tree.md index 9831ddc40a..20bb9b43df 100644 --- a/src/ch07-03-paths-for-referring-to-an-item-in-the-module-tree.md +++ b/src/ch07-03-paths-for-referring-to-an-item-in-the-module-tree.md @@ -141,8 +141,8 @@ keyword before its definition, as in Listing 7-7. Filename: src/lib.rs -```rust -{{#rustdoc_include ../listings/ch07-managing-growing-projects/listing-07-07/src/lib.rs:here}} +```rust,noplayground,test_harness +{{#rustdoc_include ../listings/ch07-managing-growing-projects/listing-07-07/src/lib.rs}} ``` Listing 7-7: Adding the `pub` keyword to `mod hosting` @@ -184,8 +184,8 @@ the path to `serve_order` starting with `super`: Filename: src/lib.rs -```rust -{{#rustdoc_include ../listings/ch07-managing-growing-projects/listing-07-08/src/lib.rs:here}} +```rust,noplayground,test_harness +{{#rustdoc_include ../listings/ch07-managing-growing-projects/listing-07-08/src/lib.rs}} ``` Listing 7-8: Calling a function using a relative path diff --git a/src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md b/src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md index 379ac4be35..01f2dfcaf1 100644 --- a/src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md +++ b/src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md @@ -15,8 +15,8 @@ scope of the `eat_at_restaurant` function so we only have to specify Filename: src/lib.rs -```rust -{{#rustdoc_include ../listings/ch07-managing-growing-projects/listing-07-11/src/lib.rs:here}} +```rust,noplayground,test_harness +{{#rustdoc_include ../listings/ch07-managing-growing-projects/listing-07-11/src/lib.rs}} ``` Listing 7-11: Bringing a module into scope with @@ -34,8 +34,8 @@ Listing 7-11. Filename: src/lib.rs -```rust -{{#rustdoc_include ../listings/ch07-managing-growing-projects/listing-07-12/src/lib.rs:here}} +```rust,noplayground,test_harness +{{#rustdoc_include ../listings/ch07-managing-growing-projects/listing-07-12/src/lib.rs}} ``` Listing 7-12: Bringing a module into scope with `use` and @@ -50,8 +50,8 @@ the `add_to_waitlist` function to achieve the same result, as in Listing 7-13. Filename: src/lib.rs -```rust -{{#rustdoc_include ../listings/ch07-managing-growing-projects/listing-07-13/src/lib.rs:here}} +```rust,noplayground,test_harness +{{#rustdoc_include ../listings/ch07-managing-growing-projects/listing-07-13/src/lib.rs}} ``` Listing 7-13: Bringing the `add_to_waitlist` function @@ -135,8 +135,8 @@ changed to `pub use`. Filename: src/lib.rs -```rust -{{#rustdoc_include ../listings/ch07-managing-growing-projects/listing-07-17/src/lib.rs:here}} +```rust,noplayground,test_harness +{{#rustdoc_include ../listings/ch07-managing-growing-projects/listing-07-17/src/lib.rs}} ``` Listing 7-17: Making a name available for any code to use diff --git a/src/ch11-01-writing-tests.md b/src/ch11-01-writing-tests.md index f486a5cdf8..9ff29d1949 100644 --- a/src/ch11-01-writing-tests.md +++ b/src/ch11-01-writing-tests.md @@ -46,8 +46,8 @@ Listing 11-1. Filename: src/lib.rs -```rust -{{#rustdoc_include ../listings/ch11-writing-automated-tests/listing-11-01/src/lib.rs:here}} +```rust,noplayground +{{#rustdoc_include ../listings/ch11-writing-automated-tests/listing-11-01/src/lib.rs}} ``` Listing 11-1: The test module and function generated @@ -107,8 +107,8 @@ so: Filename: src/lib.rs -```rust -{{#rustdoc_include ../listings/ch11-writing-automated-tests/no-listing-01-changing-test-name/src/lib.rs:here}} +```rust,noplayground +{{#rustdoc_include ../listings/ch11-writing-automated-tests/no-listing-01-changing-test-name/src/lib.rs}} ``` Then run `cargo test` again. The output now shows `exploration` instead of @@ -127,7 +127,7 @@ which is to call the `panic!` macro. Enter the new test, `another`, so your Filename: src/lib.rs -```rust,panics +```rust,panics,noplayground {{#rustdoc_include ../listings/ch11-writing-automated-tests/listing-11-03/src/lib.rs:here}} ``` @@ -177,7 +177,7 @@ method, which are repeated here in Listing 11-5. Let’s put this code in the Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch11-writing-automated-tests/listing-11-05/src/lib.rs:here}} ``` @@ -192,7 +192,7 @@ has a width of 5 and a height of 1. Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch11-writing-automated-tests/listing-11-06/src/lib.rs:here}} ``` @@ -222,7 +222,7 @@ rectangle cannot hold a larger rectangle: Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch11-writing-automated-tests/no-listing-02-adding-another-rectangle-test/src/lib.rs:here}} ``` @@ -239,7 +239,7 @@ introduce a bug in our code. Let’s change the implementation of the `can_hold` method by replacing the greater than sign with a less than sign when it compares the widths: -```rust,not_desired_behavior +```rust,not_desired_behavior,noplayground {{#rustdoc_include ../listings/ch11-writing-automated-tests/no-listing-03-introducing-a-bug/src/lib.rs:here}} ``` @@ -272,8 +272,8 @@ parameter and returns the result. Then we test this function using the Filename: src/lib.rs -```rust -{{#rustdoc_include ../listings/ch11-writing-automated-tests/listing-11-07/src/lib.rs:here}} +```rust,noplayground +{{#rustdoc_include ../listings/ch11-writing-automated-tests/listing-11-07/src/lib.rs}} ``` Listing 11-7: Testing the function `add_two` using the @@ -293,7 +293,7 @@ Let’s introduce a bug into our code to see what it looks like when a test that uses `assert_eq!` fails. Change the implementation of the `add_two` function to instead add `3`: -```rust,not_desired_behavior +```rust,not_desired_behavior,noplayground {{#rustdoc_include ../listings/ch11-writing-automated-tests/no-listing-04-bug-in-add-two/src/lib.rs:here}} ``` @@ -358,8 +358,8 @@ want to test that the name we pass into the function appears in the output: Filename: src/lib.rs -```rust -{{#rustdoc_include ../listings/ch11-writing-automated-tests/no-listing-05-greeter/src/lib.rs:here}} +```rust,noplayground +{{#rustdoc_include ../listings/ch11-writing-automated-tests/no-listing-05-greeter/src/lib.rs}} ``` The requirements for this program haven’t been agreed upon yet, and we’re @@ -372,7 +372,7 @@ input parameter. Let’s introduce a bug into this code by changing `greeting` to not include `name` to see what this test failure looks like: -```rust,not_desired_behavior +```rust,not_desired_behavior,noplayground {{#rustdoc_include ../listings/ch11-writing-automated-tests/no-listing-06-greeter-with-bug/src/lib.rs:here}} ``` @@ -420,8 +420,8 @@ happen when we expect them to. Filename: src/lib.rs -```rust -{{#rustdoc_include ../listings/ch11-writing-automated-tests/listing-11-08/src/lib.rs:here}} +```rust,noplayground +{{#rustdoc_include ../listings/ch11-writing-automated-tests/listing-11-08/src/lib.rs}} ``` Listing 11-8: Testing that a condition will cause a @@ -438,7 +438,7 @@ passes: Looks good! Now let’s introduce a bug in our code by removing the condition that the `new` function will panic if the value is greater than 100: -```rust,not_desired_behavior +```rust,not_desired_behavior,noplayground {{#rustdoc_include ../listings/ch11-writing-automated-tests/no-listing-08-guess-with-bug/src/lib.rs:here}} ``` @@ -463,7 +463,7 @@ different messages depending on whether the value is too small or too large. Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch11-writing-automated-tests/listing-11-09/src/lib.rs:here}} ``` @@ -506,8 +506,8 @@ So far, we’ve written tests that panic when they fail. We can also write tests that use `Result`! Here’s the test from Listing 11-1, rewritten to use `Result` and return an `Err` instead of panicking: -```rust -{{#rustdoc_include ../listings/ch11-writing-automated-tests/no-listing-10-result-in-tests/src/lib.rs:here}} +```rust,noplayground +{{#rustdoc_include ../listings/ch11-writing-automated-tests/no-listing-10-result-in-tests/src/lib.rs}} ``` The `it_works` function now has a return type, `Result<(), String>`. In the diff --git a/src/ch11-02-running-tests.md b/src/ch11-02-running-tests.md index 7941ce786c..880d1b38b2 100644 --- a/src/ch11-02-running-tests.md +++ b/src/ch11-02-running-tests.md @@ -61,8 +61,8 @@ parameter and returns 10, as well as a test that passes and a test that fails. Filename: src/lib.rs -```rust,panics -{{#rustdoc_include ../listings/ch11-writing-automated-tests/listing-11-10/src/lib.rs:here}} +```rust,panics,noplayground +{{#rustdoc_include ../listings/ch11-writing-automated-tests/listing-11-10/src/lib.rs}} ``` Listing 11-10: Tests for a function that calls @@ -159,8 +159,8 @@ here: Filename: src/lib.rs -```rust -{{#rustdoc_include ../listings/ch11-writing-automated-tests/no-listing-11-ignore-a-test/src/lib.rs:here}} +```rust,noplayground +{{#rustdoc_include ../listings/ch11-writing-automated-tests/no-listing-11-ignore-a-test/src/lib.rs}} ``` After `#[test]` we add the `#[ignore]` line to the test we want to exclude. Now diff --git a/src/ch11-03-test-organization.md b/src/ch11-03-test-organization.md index b36eb011cc..a6adb65a28 100644 --- a/src/ch11-03-test-organization.md +++ b/src/ch11-03-test-organization.md @@ -60,8 +60,8 @@ Consider the code in Listing 11-12 with the private function `internal_adder`. Filename: src/lib.rs -```rust -{{#rustdoc_include ../listings/ch11-writing-automated-tests/listing-11-12/src/lib.rs:here}} +```rust,noplayground +{{#rustdoc_include ../listings/ch11-writing-automated-tests/listing-11-12/src/lib.rs}} ``` Listing 11-12: Testing a private function diff --git a/src/ch12-04-testing-the-librarys-functionality.md b/src/ch12-04-testing-the-librarys-functionality.md index e9918ac5d1..514c2b716c 100644 --- a/src/ch12-04-testing-the-librarys-functionality.md +++ b/src/ch12-04-testing-the-librarys-functionality.md @@ -60,7 +60,7 @@ containing the line `"safe, fast, productive."` Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch12-an-io-project/listing-12-16/src/lib.rs:here}} ``` diff --git a/src/ch12-05-working-with-environment-variables.md b/src/ch12-05-working-with-environment-variables.md index d6ac076ebc..86457e8385 100644 --- a/src/ch12-05-working-with-environment-variables.md +++ b/src/ch12-05-working-with-environment-variables.md @@ -18,7 +18,7 @@ tests, as shown in Listing 12-20. Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch12-an-io-project/listing-12-20/src/lib.rs:here}} ``` @@ -50,7 +50,7 @@ they’ll be the same case when we check whether the line contains the query. Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch12-an-io-project/listing-12-21/src/lib.rs:here}} ``` @@ -120,7 +120,7 @@ in Listing 12-23. Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch12-an-io-project/listing-12-23/src/lib.rs:here}} ``` diff --git a/src/ch13-02-iterators.md b/src/ch13-02-iterators.md index 71587221a8..3d7f59946f 100644 --- a/src/ch13-02-iterators.md +++ b/src/ch13-02-iterators.md @@ -77,7 +77,7 @@ from the vector. Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch13-functional-features/listing-13-15/src/lib.rs:here}} ``` @@ -116,7 +116,7 @@ test illustrating a use of the `sum` method: Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch13-functional-features/listing-13-16/src/lib.rs:here}} ``` @@ -196,7 +196,7 @@ instances. It will return only shoes that are the specified size. Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch13-functional-features/listing-13-19/src/lib.rs}} ``` @@ -241,7 +241,7 @@ Listing 13-20 has the definition of the `Counter` struct and an associated Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch13-functional-features/listing-13-20/src/lib.rs}} ``` @@ -261,8 +261,8 @@ iterator is used, as shown in Listing 13-21: Filename: src/lib.rs -```rust -{{#rustdoc_include ../listings/ch13-functional-features/listing-13-21/src/lib.rs:here}} +```rust,noplayground +{{#rustdoc_include ../listings/ch13-functional-features/listing-13-21/src/lib.rs}} ``` Listing 13-21: Implementing the `Iterator` trait on our @@ -287,7 +287,7 @@ with the iterator created from a vector in Listing 13-15. Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch13-functional-features/listing-13-22/src/lib.rs:here}} ``` @@ -312,7 +312,7 @@ together, we could do so, as shown in the test in Listing 13-23: Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch13-functional-features/listing-13-23/src/lib.rs:here}} ``` diff --git a/src/ch13-03-improving-our-io-project.md b/src/ch13-03-improving-our-io-project.md index 0473b2cba8..f5efc4363d 100644 --- a/src/ch13-03-improving-our-io-project.md +++ b/src/ch13-03-improving-our-io-project.md @@ -98,7 +98,7 @@ Listing 12-23 to use the `next` method: Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch13-functional-features/listing-13-27/src/lib.rs:here}} ``` diff --git a/src/ch14-02-publishing-to-crates-io.md b/src/ch14-02-publishing-to-crates-io.md index 7f31dea836..dc10e2e965 100644 --- a/src/ch14-02-publishing-to-crates-io.md +++ b/src/ch14-02-publishing-to-crates-io.md @@ -176,8 +176,8 @@ function named `mix`, as shown in Listing 14-3: Filename: src/lib.rs -```rust -{{#rustdoc_include ../listings/ch14-more-about-cargo/listing-14-03/src/lib.rs:here}} +```rust,noplayground,test_harness +{{#rustdoc_include ../listings/ch14-more-about-cargo/listing-14-03/src/lib.rs}} ``` Listing 14-3: An `art` library with items organized into diff --git a/src/ch15-05-interior-mutability.md b/src/ch15-05-interior-mutability.md index 845a258e56..a1849025f5 100644 --- a/src/ch15-05-interior-mutability.md +++ b/src/ch15-05-interior-mutability.md @@ -195,7 +195,7 @@ shows what that looks like: Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch15-smart-pointers/listing-15-22/src/lib.rs:here}} ``` diff --git a/src/ch17-02-trait-objects.md b/src/ch17-02-trait-objects.md index 723aeec1fd..52a3371bd0 100644 --- a/src/ch17-02-trait-objects.md +++ b/src/ch17-02-trait-objects.md @@ -138,7 +138,7 @@ might have fields for `width`, `height`, and `label`, as shown in Listing 17-7: Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch17-oop/listing-17-07/src/lib.rs:here}} ``` diff --git a/src/ch17-03-oo-design-patterns.md b/src/ch17-03-oo-design-patterns.md index 8807541346..876f9c02b2 100644 --- a/src/ch17-03-oo-design-patterns.md +++ b/src/ch17-03-oo-design-patterns.md @@ -107,7 +107,7 @@ Post` block: Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch17-oop/listing-17-13/src/lib.rs:here}} ``` @@ -135,7 +135,7 @@ be empty. Listing 17-14 shows this placeholder implementation: Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch17-oop/listing-17-14/src/lib.rs:here}} ``` @@ -152,7 +152,7 @@ change its state from `Draft` to `PendingReview`. Listing 17-15 shows this code: Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch17-oop/listing-17-15/src/lib.rs:here}} ``` diff --git a/src/ch19-04-advanced-types.md b/src/ch19-04-advanced-types.md index f20d6b4dae..b10b4cbb41 100644 --- a/src/ch19-04-advanced-types.md +++ b/src/ch19-04-advanced-types.md @@ -108,7 +108,7 @@ the `Write` trait: The `Result<..., Error>` is repeated a lot. As such, `std::io` has this type of alias declaration: -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch19-advanced-features/no-listing-06-result-alias/src/lib.rs:here}} ``` @@ -117,7 +117,7 @@ qualified alias `std::io::Result`—that is, a `Result` with the `E` filled in as `std::io::Error`. The `Write` trait function signatures end up looking like this: -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch19-advanced-features/no-listing-06-result-alias/src/lib.rs:there}} ``` @@ -133,7 +133,7 @@ Rust has a special type named `!` that’s known in type theory lingo as the because it stands in the place of the return type when a function will never return. Here is an example: -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch19-advanced-features/no-listing-07-never-type/src/lib.rs:here}} ``` diff --git a/src/ch20-02-multithreaded.md b/src/ch20-02-multithreaded.md index 5b887d2c1c..95c3358196 100644 --- a/src/ch20-02-multithreaded.md +++ b/src/ch20-02-multithreaded.md @@ -189,8 +189,8 @@ characteristics: Filename: src/lib.rs -```rust -{{#rustdoc_include ../listings/ch20-web-server/no-listing-02-impl-threadpool-new/src/lib.rs:here}} +```rust,noplayground +{{#rustdoc_include ../listings/ch20-web-server/no-listing-02-impl-threadpool-new/src/lib.rs}} ``` We chose `usize` as the type of the `size` parameter, because we know that a @@ -246,7 +246,7 @@ the thread will take to execute. Let’s create an `execute` method on Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch20-web-server/no-listing-03-define-execute/src/lib.rs:here}} ``` @@ -287,7 +287,7 @@ zero by using the `assert!` macro, as shown in Listing 20-13. Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch20-web-server/listing-20-13/src/lib.rs:here}} ``` @@ -404,7 +404,7 @@ Ready? Here is Listing 20-15 with one way to make the preceding modifications. Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch20-web-server/listing-20-15/src/lib.rs:here}} ``` @@ -459,7 +459,7 @@ the channel. Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch20-web-server/listing-20-16/src/lib.rs:here}} ``` @@ -511,7 +511,7 @@ receiver at a time. Listing 20-18 shows the changes we need to make. Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch20-web-server/listing-20-18/src/lib.rs:here}} ``` @@ -535,7 +535,7 @@ at Listing 20-19. Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch20-web-server/listing-20-19/src/lib.rs:here}} ``` diff --git a/src/ch20-03-graceful-shutdown-and-cleanup.md b/src/ch20-03-graceful-shutdown-and-cleanup.md index 3c9cb67fea..872ed6353e 100644 --- a/src/ch20-03-graceful-shutdown-and-cleanup.md +++ b/src/ch20-03-graceful-shutdown-and-cleanup.md @@ -112,7 +112,7 @@ variants. Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch20-web-server/no-listing-07-define-message-enum/src/lib.rs:here}} ``` @@ -261,8 +261,8 @@ Here’s the full code for reference: Filename: src/lib.rs -```rust -{{#rustdoc_include ../listings/ch20-web-server/listing-20-25/src/lib.rs:here}} +```rust,noplayground +{{#rustdoc_include ../listings/ch20-web-server/listing-20-25/src/lib.rs}} ``` We could do more here! If you want to continue enhancing this project, here are From 322899b375d071e4d96aaf29ce25c1a4b4ec65da Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Sat, 5 Dec 2020 14:01:04 -0500 Subject: [PATCH 13/13] Re-fix #2516 - Make a new listing for final code of ch 20 I was trying to reuse too much; we don't want the `take(2)` to be part of the final code, but we do want it to be in the listing for the example where we shut down gracefully after 2 requests. --- .../listing-20-25/src/bin/main.rs | 4 +- .../no-listing-08-final-code/404.html | 11 ++ .../no-listing-08-final-code/Cargo.lock | 6 ++ .../no-listing-08-final-code/Cargo.toml | 7 ++ .../no-listing-08-final-code/hello.html | 11 ++ .../no-listing-08-final-code/src/bin/main.rs | 46 ++++++++ .../no-listing-08-final-code/src/lib.rs | 101 ++++++++++++++++++ src/ch20-03-graceful-shutdown-and-cleanup.md | 4 +- 8 files changed, 185 insertions(+), 5 deletions(-) create mode 100644 listings/ch20-web-server/no-listing-08-final-code/404.html create mode 100644 listings/ch20-web-server/no-listing-08-final-code/Cargo.lock create mode 100644 listings/ch20-web-server/no-listing-08-final-code/Cargo.toml create mode 100644 listings/ch20-web-server/no-listing-08-final-code/hello.html create mode 100644 listings/ch20-web-server/no-listing-08-final-code/src/bin/main.rs create mode 100644 listings/ch20-web-server/no-listing-08-final-code/src/lib.rs diff --git a/listings/ch20-web-server/listing-20-25/src/bin/main.rs b/listings/ch20-web-server/listing-20-25/src/bin/main.rs index 226423c22c..694df159ab 100644 --- a/listings/ch20-web-server/listing-20-25/src/bin/main.rs +++ b/listings/ch20-web-server/listing-20-25/src/bin/main.rs @@ -1,4 +1,3 @@ -// ANCHOR: all use hello::ThreadPool; use std::fs; use std::io::prelude::*; @@ -12,7 +11,7 @@ fn main() { let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); let pool = ThreadPool::new(4); - for stream in listener.incoming() { + for stream in listener.incoming().take(2) { let stream = stream.unwrap(); pool.execute(|| { @@ -47,4 +46,3 @@ fn handle_connection(mut stream: TcpStream) { stream.write(response.as_bytes()).unwrap(); stream.flush().unwrap(); } -// ANCHOR_END: all diff --git a/listings/ch20-web-server/no-listing-08-final-code/404.html b/listings/ch20-web-server/no-listing-08-final-code/404.html new file mode 100644 index 0000000000..88d8e9152d --- /dev/null +++ b/listings/ch20-web-server/no-listing-08-final-code/404.html @@ -0,0 +1,11 @@ + + + + + Hello! + + +

Oops!

+

Sorry, I don't know what you're asking for.

+ + diff --git a/listings/ch20-web-server/no-listing-08-final-code/Cargo.lock b/listings/ch20-web-server/no-listing-08-final-code/Cargo.lock new file mode 100644 index 0000000000..f2d069f462 --- /dev/null +++ b/listings/ch20-web-server/no-listing-08-final-code/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "hello" +version = "0.1.0" + diff --git a/listings/ch20-web-server/no-listing-08-final-code/Cargo.toml b/listings/ch20-web-server/no-listing-08-final-code/Cargo.toml new file mode 100644 index 0000000000..78dfe6ebc4 --- /dev/null +++ b/listings/ch20-web-server/no-listing-08-final-code/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "hello" +version = "0.1.0" +authors = ["Your Name "] +edition = "2018" + +[dependencies] diff --git a/listings/ch20-web-server/no-listing-08-final-code/hello.html b/listings/ch20-web-server/no-listing-08-final-code/hello.html new file mode 100644 index 0000000000..fe442d6b9b --- /dev/null +++ b/listings/ch20-web-server/no-listing-08-final-code/hello.html @@ -0,0 +1,11 @@ + + + + + Hello! + + +

Hello!

+

Hi from Rust

+ + diff --git a/listings/ch20-web-server/no-listing-08-final-code/src/bin/main.rs b/listings/ch20-web-server/no-listing-08-final-code/src/bin/main.rs new file mode 100644 index 0000000000..7e2508e2a5 --- /dev/null +++ b/listings/ch20-web-server/no-listing-08-final-code/src/bin/main.rs @@ -0,0 +1,46 @@ +use hello::ThreadPool; +use std::fs; +use std::io::prelude::*; +use std::net::TcpListener; +use std::net::TcpStream; +use std::thread; +use std::time::Duration; + +fn main() { + let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); + let pool = ThreadPool::new(4); + + for stream in listener.incoming() { + let stream = stream.unwrap(); + + pool.execute(|| { + handle_connection(stream); + }); + } + + println!("Shutting down."); +} + +fn handle_connection(mut stream: TcpStream) { + let mut buffer = [0; 1024]; + stream.read(&mut buffer).unwrap(); + + let get = b"GET / HTTP/1.1\r\n"; + let sleep = b"GET /sleep HTTP/1.1\r\n"; + + let (status_line, filename) = if buffer.starts_with(get) { + ("HTTP/1.1 200 OK\r\n\r\n", "hello.html") + } else if buffer.starts_with(sleep) { + thread::sleep(Duration::from_secs(5)); + ("HTTP/1.1 200 OK\r\n\r\n", "hello.html") + } else { + ("HTTP/1.1 404 NOT FOUND\r\n\r\n", "404.html") + }; + + let contents = fs::read_to_string(filename).unwrap(); + + let response = format!("{}{}", status_line, contents); + + stream.write(response.as_bytes()).unwrap(); + stream.flush().unwrap(); +} diff --git a/listings/ch20-web-server/no-listing-08-final-code/src/lib.rs b/listings/ch20-web-server/no-listing-08-final-code/src/lib.rs new file mode 100644 index 0000000000..68f4263057 --- /dev/null +++ b/listings/ch20-web-server/no-listing-08-final-code/src/lib.rs @@ -0,0 +1,101 @@ +use std::sync::mpsc; +use std::sync::Arc; +use std::sync::Mutex; +use std::thread; + +pub struct ThreadPool { + workers: Vec, + sender: mpsc::Sender, +} + +type Job = Box; + +enum Message { + NewJob(Job), + Terminate, +} + +impl ThreadPool { + /// Create a new ThreadPool. + /// + /// The size is the number of threads in the pool. + /// + /// # Panics + /// + /// The `new` function will panic if the size is zero. + pub fn new(size: usize) -> ThreadPool { + assert!(size > 0); + + let (sender, receiver) = mpsc::channel(); + + let receiver = Arc::new(Mutex::new(receiver)); + + let mut workers = Vec::with_capacity(size); + + for id in 0..size { + workers.push(Worker::new(id, Arc::clone(&receiver))); + } + + ThreadPool { workers, sender } + } + + pub fn execute(&self, f: F) + where + F: FnOnce() + Send + 'static, + { + let job = Box::new(f); + + self.sender.send(Message::NewJob(job)).unwrap(); + } +} + +impl Drop for ThreadPool { + fn drop(&mut self) { + println!("Sending terminate message to all workers."); + + for _ in &self.workers { + self.sender.send(Message::Terminate).unwrap(); + } + + println!("Shutting down all workers."); + + for worker in &mut self.workers { + println!("Shutting down worker {}", worker.id); + + if let Some(thread) = worker.thread.take() { + thread.join().unwrap(); + } + } + } +} + +struct Worker { + id: usize, + thread: Option>, +} + +impl Worker { + fn new(id: usize, receiver: Arc>>) -> Worker { + let thread = thread::spawn(move || loop { + let message = receiver.lock().unwrap().recv().unwrap(); + + match message { + Message::NewJob(job) => { + println!("Worker {} got a job; executing.", id); + + job(); + } + Message::Terminate => { + println!("Worker {} was told to terminate.", id); + + break; + } + } + }); + + Worker { + id, + thread: Some(thread), + } + } +} diff --git a/src/ch20-03-graceful-shutdown-and-cleanup.md b/src/ch20-03-graceful-shutdown-and-cleanup.md index 872ed6353e..6d4edbff68 100644 --- a/src/ch20-03-graceful-shutdown-and-cleanup.md +++ b/src/ch20-03-graceful-shutdown-and-cleanup.md @@ -256,13 +256,13 @@ Here’s the full code for reference: Filename: src/bin/main.rs ```rust,ignore -{{#rustdoc_include ../listings/ch20-web-server/listing-20-25/src/bin/main.rs:all}} +{{#rustdoc_include ../listings/ch20-web-server/no-listing-08-final-code/src/bin/main.rs}} ``` Filename: src/lib.rs ```rust,noplayground -{{#rustdoc_include ../listings/ch20-web-server/listing-20-25/src/lib.rs}} +{{#rustdoc_include ../listings/ch20-web-server/no-listing-08-final-code/src/lib.rs}} ``` We could do more here! If you want to continue enhancing this project, here are