mirror of https://github.com/rust-lang/book
Merge `main` into `nyurik:inlinefmt2`
This commit is contained in:
commit
6196a0ab45
|
@ -12,8 +12,8 @@ jobs:
|
|||
- name: Install Rust
|
||||
run: |
|
||||
rustup set profile minimal
|
||||
rustup toolchain install 1.67 -c rust-docs
|
||||
rustup default 1.67
|
||||
rustup toolchain install 1.76 -c rust-docs
|
||||
rustup default 1.76
|
||||
- name: Install mdbook
|
||||
run: |
|
||||
mkdir bin
|
||||
|
|
|
@ -70,4 +70,4 @@ a new language! We're waiting on [mdbook support] for multiple languages
|
|||
before we merge any in, but feel free to start!
|
||||
|
||||
[Translations]: https://github.com/rust-lang/book/issues?q=is%3Aopen+is%3Aissue+label%3ATranslations
|
||||
[mdbook support]: https://github.com/rust-lang-nursery/mdBook/issues/5
|
||||
[mdbook support]: https://github.com/rust-lang/mdBook/issues/5
|
||||
|
|
|
@ -101,18 +101,18 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.39"
|
||||
version = "1.0.80"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f"
|
||||
checksum = "a56dea16b0a29e94408b9aa5e2940a4eedbd128a1ba20e8f7ae60fd3d465af0e"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.18"
|
||||
version = "1.0.36"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1"
|
||||
checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
@ -167,18 +167,18 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.137"
|
||||
version = "1.0.197"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1"
|
||||
checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.137"
|
||||
version = "1.0.197"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be"
|
||||
checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -193,9 +193,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
|||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.96"
|
||||
version = "2.0.59"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0748dd251e24453cb8717f0354206b91557e4ec8703673a4b30208f2abaf1ebf"
|
||||
checksum = "4a6531ffc7b071655e4ce2e04bd464c4830bb585a61cabb96cf808f05172615a"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
|
|
@ -26,11 +26,11 @@ See the [releases] to download just the code of all the code listings that appea
|
|||
Building the book requires [mdBook], ideally the same version that
|
||||
rust-lang/rust uses in [this file][rust-mdbook]. To get it:
|
||||
|
||||
[mdBook]: https://github.com/rust-lang-nursery/mdBook
|
||||
[mdBook]: https://github.com/rust-lang/mdBook
|
||||
[rust-mdbook]: https://github.com/rust-lang/rust/blob/master/src/tools/rustbook/Cargo.toml
|
||||
|
||||
```bash
|
||||
$ cargo install mdbook --version <version_num>
|
||||
$ cargo install mdbook --locked --version <version_num>
|
||||
```
|
||||
|
||||
## Building
|
||||
|
@ -93,13 +93,13 @@ a new language! We're waiting on [mdbook support] for multiple languages
|
|||
before we merge any in, but feel free to start!
|
||||
|
||||
[Translations]: https://github.com/rust-lang/book/issues?q=is%3Aopen+is%3Aissue+label%3ATranslations
|
||||
[mdbook support]: https://github.com/rust-lang-nursery/mdBook/issues/5
|
||||
[mdbook support]: https://github.com/rust-lang/mdBook/issues/5
|
||||
|
||||
## Spellchecking
|
||||
|
||||
To scan source files for spelling errors, you can use the `spellcheck.sh`
|
||||
script available in the `ci` directory. It needs a dictionary of valid words,
|
||||
which is provided in `ci/dictionary.txt`. If the script produces a false
|
||||
positive (say, you used word `BTreeMap` which the script considers invalid),
|
||||
positive (say, you used the word `BTreeMap` which the script considers invalid),
|
||||
you need to add this word to `ci/dictionary.txt` (keep the sorted order for
|
||||
consistency).
|
||||
|
|
|
@ -35,6 +35,7 @@ backtraces
|
|||
BACKTRACE
|
||||
Backtraces
|
||||
Baz's
|
||||
beefeb
|
||||
benchmarking
|
||||
bioinformatics
|
||||
bitand
|
||||
|
|
|
@ -10,9 +10,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
|||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.7"
|
||||
version = "0.2.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6"
|
||||
checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
|
@ -28,15 +28,15 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.127"
|
||||
version = "0.2.153"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "505e71a4706fa491e9b1b55f51b95d4037d0821ee40131190475f692b35b009b"
|
||||
checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.16"
|
||||
version = "0.2.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872"
|
||||
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
|
@ -61,9 +61,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.6.3"
|
||||
version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
|
||||
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
]
|
||||
|
|
|
@ -11,14 +11,14 @@ error[E0308]: mismatched types
|
|||
--> src/main.rs:22:21
|
||||
|
|
||||
22 | match guess.cmp(&secret_number) {
|
||||
| --- ^^^^^^^^^^^^^^ expected struct `String`, found integer
|
||||
| --- ^^^^^^^^^^^^^^ expected `&String`, found `&{integer}`
|
||||
| |
|
||||
| arguments to this function are incorrect
|
||||
| arguments to this method are incorrect
|
||||
|
|
||||
= note: expected reference `&String`
|
||||
found reference `&{integer}`
|
||||
note: associated function defined here
|
||||
--> /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/cmp.rs:783:8
|
||||
note: method defined here
|
||||
--> /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/cmp.rs:814:8
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
error: could not compile `guessing_game` due to previous error
|
||||
error: could not compile `guessing_game` (bin "guessing_game") due to 1 previous error
|
||||
|
|
|
@ -8,6 +8,10 @@ warning: unused `Result` that must be used
|
|||
|
|
||||
= note: this `Result` may be an `Err` variant, which should be handled
|
||||
= note: `#[warn(unused_must_use)]` on by default
|
||||
help: use `let _ = ...` to ignore the resulting value
|
||||
|
|
||||
10 | let _ = io::stdin().read_line(&mut guess);
|
||||
| +++++++
|
||||
|
||||
warning: `guessing_game` (bin "guessing_game") generated 1 warning
|
||||
Finished dev [unoptimized + debuginfo] target(s) in 0.59s
|
||||
|
|
|
@ -13,4 +13,4 @@ error[E0384]: cannot assign twice to immutable variable `x`
|
|||
| ^^^^^ cannot assign twice to immutable variable
|
||||
|
||||
For more information about this error, try `rustc --explain E0384`.
|
||||
error: could not compile `variables` due to previous error
|
||||
error: could not compile `variables` (bin "variables") due to 1 previous error
|
||||
|
|
|
@ -7,6 +7,12 @@ error[E0308]: mismatched types
|
|||
| ----- expected due to this value
|
||||
3 | spaces = spaces.len();
|
||||
| ^^^^^^^^^^^^ expected `&str`, found `usize`
|
||||
|
|
||||
help: try removing the method call
|
||||
|
|
||||
3 - spaces = spaces.len();
|
||||
3 + spaces = spaces;
|
||||
|
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
error: could not compile `variables` due to previous error
|
||||
error: could not compile `variables` (bin "variables") due to 1 previous error
|
||||
|
|
|
@ -5,22 +5,8 @@ error: expected expression, found `let` statement
|
|||
|
|
||||
2 | let x = (let y = 6);
|
||||
| ^^^
|
||||
|
||||
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
|
||||
|
||||
error[E0658]: `let` expressions in this position are unstable
|
||||
--> src/main.rs:2:14
|
||||
|
|
||||
2 | let x = (let y = 6);
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
warning: unnecessary parentheses around assigned value
|
||||
--> src/main.rs:2:13
|
||||
|
@ -35,6 +21,5 @@ help: remove these parentheses
|
|||
2 + let x = let y = 6;
|
||||
|
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
warning: `functions` (bin "functions") generated 1 warning
|
||||
error: could not compile `functions` due to 3 previous errors; 1 warning emitted
|
||||
error: could not compile `functions` (bin "functions") due to 1 previous error; 1 warning emitted
|
||||
|
|
|
@ -11,4 +11,4 @@ error[E0308]: mismatched types
|
|||
| - help: remove this semicolon to return this value
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
error: could not compile `functions` due to previous error
|
||||
error: could not compile `functions` (bin "functions") due to 1 previous error
|
||||
|
|
|
@ -7,4 +7,4 @@ error[E0308]: mismatched types
|
|||
| ^^^^^^ expected `bool`, found integer
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
error: could not compile `branches` due to previous error
|
||||
error: could not compile `branches` (bin "branches") due to 1 previous error
|
||||
|
|
|
@ -9,4 +9,4 @@ error[E0308]: `if` and `else` have incompatible types
|
|||
| expected because of this
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
error: could not compile `branches` due to previous error
|
||||
error: could not compile `branches` (bin "branches") due to 1 previous error
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
$ cargo build
|
||||
Compiling no_type_annotations v0.1.0 (file:///projects/no_type_annotations)
|
||||
error[E0282]: type annotations needed
|
||||
error[E0284]: type annotations needed
|
||||
--> src/main.rs:2:9
|
||||
|
|
||||
2 | let guess = "42".parse().expect("Not a number!");
|
||||
| ^^^^^
|
||||
| ^^^^^ ----- type must be known at this point
|
||||
|
|
||||
= note: cannot satisfy `<_ as FromStr>::Err == _`
|
||||
help: consider giving `guess` an explicit type
|
||||
|
|
||||
2 | let guess: _ = "42".parse().expect("Not a number!");
|
||||
| +++
|
||||
2 | let guess: /* Type */ = "42".parse().expect("Not a number!");
|
||||
| ++++++++++++
|
||||
|
||||
For more information about this error, try `rustc --explain E0282`.
|
||||
error: could not compile `no_type_annotations` due to previous error
|
||||
For more information about this error, try `rustc --explain E0284`.
|
||||
error: could not compile `no_type_annotations` (bin "no_type_annotations") due to 1 previous error
|
||||
|
|
|
@ -3,10 +3,13 @@ $ cargo run
|
|||
error[E0596]: cannot borrow `*some_string` as mutable, as it is behind a `&` reference
|
||||
--> src/main.rs:8:5
|
||||
|
|
||||
7 | fn change(some_string: &String) {
|
||||
| ------- help: consider changing this to be a mutable reference: `&mut String`
|
||||
8 | some_string.push_str(", world");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `some_string` is a `&` reference, so the data it refers to cannot be borrowed as mutable
|
||||
| ^^^^^^^^^^^ `some_string` is a `&` reference, so the data it refers to cannot be borrowed as mutable
|
||||
|
|
||||
help: consider changing this to be a mutable reference
|
||||
|
|
||||
7 | fn change(some_string: &mut String) {
|
||||
| +++
|
||||
|
||||
For more information about this error, try `rustc --explain E0596`.
|
||||
error: could not compile `ownership` due to previous error
|
||||
error: could not compile `ownership` (bin "ownership") due to 1 previous error
|
||||
|
|
|
@ -18,4 +18,4 @@ help: consider cloning the value if the performance cost is acceptable
|
|||
| ++++++++
|
||||
|
||||
For more information about this error, try `rustc --explain E0382`.
|
||||
error: could not compile `ownership` due to previous error
|
||||
error: could not compile `ownership` (bin "ownership") due to 1 previous error
|
||||
|
|
|
@ -12,4 +12,4 @@ error[E0499]: cannot borrow `s` as mutable more than once at a time
|
|||
| -- first borrow later used here
|
||||
|
||||
For more information about this error, try `rustc --explain E0499`.
|
||||
error: could not compile `ownership` due to previous error
|
||||
error: could not compile `ownership` (bin "ownership") due to 1 previous error
|
||||
|
|
|
@ -13,4 +13,4 @@ error[E0502]: cannot borrow `s` as mutable because it is also borrowed as immuta
|
|||
| -- immutable borrow later used here
|
||||
|
||||
For more information about this error, try `rustc --explain E0502`.
|
||||
error: could not compile `ownership` due to previous error
|
||||
error: could not compile `ownership` (bin "ownership") due to 1 previous error
|
||||
|
|
|
@ -7,10 +7,15 @@ error[E0106]: missing lifetime specifier
|
|||
| ^ expected named lifetime parameter
|
||||
|
|
||||
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
|
||||
help: consider using the `'static` lifetime
|
||||
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
|
||||
|
|
||||
5 | fn dangle() -> &'static String {
|
||||
| +++++++
|
||||
help: instead, you are more likely to want to return an owned value
|
||||
|
|
||||
5 - fn dangle() -> &String {
|
||||
5 + fn dangle() -> String {
|
||||
|
|
||||
|
||||
For more information about this error, try `rustc --explain E0106`.
|
||||
error: could not compile `ownership` due to previous error
|
||||
error: could not compile `ownership` (bin "ownership") due to 1 previous error
|
||||
|
|
|
@ -13,4 +13,4 @@ error[E0502]: cannot borrow `s` as mutable because it is also borrowed as immuta
|
|||
| ---- immutable borrow later used here
|
||||
|
||||
For more information about this error, try `rustc --explain E0502`.
|
||||
error: could not compile `ownership` due to previous error
|
||||
error: could not compile `ownership` (bin "ownership") due to 1 previous error
|
||||
|
|
|
@ -11,4 +11,4 @@ error[E0277]: `Rectangle` doesn't implement `std::fmt::Display`
|
|||
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
error: could not compile `rectangles` due to previous error
|
||||
error: could not compile `rectangles` (bin "rectangles") due to 1 previous error
|
||||
|
|
|
@ -28,4 +28,4 @@ help: consider introducing a named lifetime parameter
|
|||
|
|
||||
|
||||
For more information about this error, try `rustc --explain E0106`.
|
||||
error: could not compile `structs` due to 2 previous errors
|
||||
error: could not compile `structs` (bin "structs") due to 2 previous errors
|
||||
|
|
|
@ -2,8 +2,8 @@ $ cargo run
|
|||
Compiling rectangles v0.1.0 (file:///projects/rectangles)
|
||||
Finished dev [unoptimized + debuginfo] target(s) in 0.61s
|
||||
Running `target/debug/rectangles`
|
||||
[src/main.rs:10] 30 * scale = 60
|
||||
[src/main.rs:14] &rect1 = Rectangle {
|
||||
[src/main.rs:10:16] 30 * scale = 60
|
||||
[src/main.rs:14:5] &rect1 = Rectangle {
|
||||
width: 60,
|
||||
height: 50,
|
||||
}
|
||||
|
|
|
@ -11,8 +11,9 @@ error[E0277]: `Rectangle` doesn't implement `Debug`
|
|||
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
help: consider annotating `Rectangle` with `#[derive(Debug)]`
|
||||
|
|
||||
1 | #[derive(Debug)]
|
||||
1 + #[derive(Debug)]
|
||||
2 | struct Rectangle {
|
||||
|
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
error: could not compile `rectangles` due to previous error
|
||||
error: could not compile `rectangles` (bin "rectangles") due to 1 previous error
|
||||
|
|
|
@ -8,10 +8,10 @@ error[E0277]: cannot add `Option<i8>` to `i8`
|
|||
|
|
||||
= help: the trait `Add<Option<i8>>` is not implemented for `i8`
|
||||
= help: the following other types implement trait `Add<Rhs>`:
|
||||
<i8 as Add>
|
||||
<i8 as Add<&i8>>
|
||||
<&'a i8 as Add<i8>>
|
||||
<&i8 as Add<&i8>>
|
||||
<i8 as Add<&i8>>
|
||||
<i8 as Add>
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
error: could not compile `enums` due to previous error
|
||||
error: could not compile `enums` (bin "enums") due to 1 previous error
|
||||
|
|
|
@ -7,10 +7,10 @@ error[E0004]: non-exhaustive patterns: `None` not covered
|
|||
| ^ pattern `None` not covered
|
||||
|
|
||||
note: `Option<i32>` defined here
|
||||
--> /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/option.rs:518:1
|
||||
--> /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/option.rs:570:1
|
||||
::: /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/option.rs:574:5
|
||||
|
|
||||
= note:
|
||||
/rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/option.rs:522:5: not covered
|
||||
= note: not covered
|
||||
= note: the matched value is of type `Option<i32>`
|
||||
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
||||
|
|
||||
|
@ -19,4 +19,4 @@ help: ensure that all possible cases are being handled by adding a match arm wit
|
|||
|
|
||||
|
||||
For more information about this error, try `rustc --explain E0004`.
|
||||
error: could not compile `enums` due to previous error
|
||||
error: could not compile `enums` (bin "enums") due to 1 previous error
|
||||
|
|
|
@ -4,7 +4,9 @@ error[E0603]: module `hosting` is private
|
|||
--> src/lib.rs:9:28
|
||||
|
|
||||
9 | crate::front_of_house::hosting::add_to_waitlist();
|
||||
| ^^^^^^^ private module
|
||||
| ^^^^^^^ --------------- function `add_to_waitlist` is not publicly re-exported
|
||||
| |
|
||||
| private module
|
||||
|
|
||||
note: the module `hosting` is defined here
|
||||
--> src/lib.rs:2:5
|
||||
|
@ -16,7 +18,9 @@ error[E0603]: module `hosting` is private
|
|||
--> src/lib.rs:12:21
|
||||
|
|
||||
12 | front_of_house::hosting::add_to_waitlist();
|
||||
| ^^^^^^^ private module
|
||||
| ^^^^^^^ --------------- function `add_to_waitlist` is not publicly re-exported
|
||||
| |
|
||||
| private module
|
||||
|
|
||||
note: the module `hosting` is defined here
|
||||
--> src/lib.rs:2:5
|
||||
|
@ -25,4 +29,4 @@ note: the module `hosting` is defined here
|
|||
| ^^^^^^^^^^^
|
||||
|
||||
For more information about this error, try `rustc --explain E0603`.
|
||||
error: could not compile `restaurant` due to 2 previous errors
|
||||
error: could not compile `restaurant` (lib) due to 2 previous errors
|
||||
|
|
|
@ -25,4 +25,4 @@ note: the function `add_to_waitlist` is defined here
|
|||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
For more information about this error, try `rustc --explain E0603`.
|
||||
error: could not compile `restaurant` due to 2 previous errors
|
||||
error: could not compile `restaurant` (lib) due to 2 previous errors
|
||||
|
|
|
@ -1,5 +1,16 @@
|
|||
$ cargo build
|
||||
Compiling restaurant v0.1.0 (file:///projects/restaurant)
|
||||
error[E0433]: failed to resolve: use of undeclared crate or module `hosting`
|
||||
--> src/lib.rs:11:9
|
||||
|
|
||||
11 | hosting::add_to_waitlist();
|
||||
| ^^^^^^^ use of undeclared crate or module `hosting`
|
||||
|
|
||||
help: consider importing this module through its public re-export
|
||||
|
|
||||
10 + use crate::hosting;
|
||||
|
|
||||
|
||||
warning: unused import: `crate::front_of_house::hosting`
|
||||
--> src/lib.rs:7:5
|
||||
|
|
||||
|
@ -8,12 +19,6 @@ warning: unused import: `crate::front_of_house::hosting`
|
|||
|
|
||||
= note: `#[warn(unused_imports)]` on by default
|
||||
|
||||
error[E0433]: failed to resolve: use of undeclared crate or module `hosting`
|
||||
--> src/lib.rs:11:9
|
||||
|
|
||||
11 | hosting::add_to_waitlist();
|
||||
| ^^^^^^^ use of undeclared crate or module `hosting`
|
||||
|
||||
For more information about this error, try `rustc --explain E0433`.
|
||||
warning: `restaurant` (lib) generated 1 warning
|
||||
error: could not compile `restaurant` due to previous error; 1 warning emitted
|
||||
error: could not compile `restaurant` (lib) due to 1 previous error; 1 warning emitted
|
||||
|
|
|
@ -10,7 +10,7 @@ error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immuta
|
|||
| ^^^^^^^^^ mutable borrow occurs here
|
||||
7 |
|
||||
8 | println!("The first element is: {first}");
|
||||
| ----- immutable borrow later used here
|
||||
| ------- immutable borrow later used here
|
||||
|
||||
For more information about this error, try `rustc --explain E0502`.
|
||||
error: could not compile `collections` due to previous error
|
||||
error: could not compile `collections` (bin "collections") due to 1 previous error
|
||||
|
|
|
@ -3,7 +3,7 @@ fn main() {
|
|||
let hello = String::from("السلام عليكم");
|
||||
let hello = String::from("Dobrý den");
|
||||
let hello = String::from("Hello");
|
||||
let hello = String::from("שָׁלוֹם");
|
||||
let hello = String::from("שלום");
|
||||
let hello = String::from("नमस्ते");
|
||||
let hello = String::from("こんにちは");
|
||||
let hello = String::from("안녕하세요");
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
$ cargo run
|
||||
Compiling collections v0.1.0 (file:///projects/collections)
|
||||
error[E0277]: the type `String` cannot be indexed by `{integer}`
|
||||
--> src/main.rs:3:13
|
||||
--> src/main.rs:3:16
|
||||
|
|
||||
3 | let h = s1[0];
|
||||
| ^^^^^ `String` cannot be indexed by `{integer}`
|
||||
| ^ `String` cannot be indexed by `{integer}`
|
||||
|
|
||||
= help: the trait `Index<{integer}>` is not implemented for `String`
|
||||
= help: the following other types implement trait `Index<Idx>`:
|
||||
<String as Index<RangeFrom<usize>>>
|
||||
<String as Index<RangeFull>>
|
||||
<String as Index<RangeInclusive<usize>>>
|
||||
<String as Index<RangeTo<usize>>>
|
||||
<String as Index<RangeToInclusive<usize>>>
|
||||
<String as Index<std::ops::Range<usize>>>
|
||||
<String as Index<RangeFrom<usize>>>
|
||||
<String as Index<RangeTo<usize>>>
|
||||
<String as Index<RangeInclusive<usize>>>
|
||||
<String as Index<RangeToInclusive<usize>>>
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
error: could not compile `collections` due to previous error
|
||||
error: could not compile `collections` (bin "collections") due to 1 previous error
|
||||
|
|
|
@ -2,5 +2,6 @@ $ 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/main.rs:4:14
|
||||
thread 'main' panicked at src/main.rs:4:19:
|
||||
byte index 1 is not a char boundary; it is inside 'З' (bytes 0..2) of `Здравствуйте`
|
||||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
|
||||
|
|
|
@ -2,5 +2,6 @@ $ 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', src/main.rs:4:5
|
||||
thread 'main' panicked at src/main.rs:4:6:
|
||||
index out of bounds: the len is 3 but the index is 99
|
||||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
|
||||
|
|
|
@ -2,5 +2,6 @@ $ cargo run
|
|||
Compiling error-handling v0.1.0 (file:///projects/error-handling)
|
||||
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
|
||||
thread 'main' panicked at src/main.rs:8:23:
|
||||
Problem opening the file: Os { code: 2, kind: NotFound, message: "No such file or directory" }
|
||||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
|
||||
|
|
|
@ -11,4 +11,4 @@ error[E0277]: the `?` operator can only be used in a function that returns `Resu
|
|||
= help: the trait `FromResidual<Result<Infallible, std::io::Error>>` is not implemented for `()`
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
error: could not compile `error-handling` due to previous error
|
||||
error: could not compile `error-handling` (bin "error-handling") due to 1 previous error
|
||||
|
|
|
@ -2,5 +2,6 @@ $ cargo run
|
|||
Compiling panic v0.1.0 (file:///projects/panic)
|
||||
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
|
||||
thread 'main' panicked at src/main.rs:2:5:
|
||||
crash and burn
|
||||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
|
||||
|
|
|
@ -14,4 +14,4 @@ help: consider restricting type parameter `T`
|
|||
| ++++++++++++++++++++++
|
||||
|
||||
For more information about this error, try `rustc --explain E0369`.
|
||||
error: could not compile `chapter10` due to previous error
|
||||
error: could not compile `chapter10` (bin "chapter10") due to 1 previous error
|
||||
|
|
|
@ -7,4 +7,4 @@ error[E0308]: mismatched types
|
|||
| ^^^ expected integer, found floating-point number
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
error: could not compile `chapter10` due to previous error
|
||||
error: could not compile `chapter10` (bin "chapter10") due to 1 previous error
|
||||
|
|
|
@ -3,6 +3,8 @@ $ cargo run
|
|||
error[E0597]: `x` does not live long enough
|
||||
--> src/main.rs:6:13
|
||||
|
|
||||
5 | let x = 5;
|
||||
| - binding `x` declared here
|
||||
6 | r = &x;
|
||||
| ^^ borrowed value does not live long enough
|
||||
7 | }
|
||||
|
@ -12,4 +14,4 @@ error[E0597]: `x` does not live long enough
|
|||
| - borrow later used here
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
error: could not compile `chapter10` due to previous error
|
||||
error: could not compile `chapter10` (bin "chapter10") due to 1 previous error
|
||||
|
|
|
@ -13,4 +13,4 @@ help: consider introducing a named lifetime parameter
|
|||
| ++++ ++ ++ ++
|
||||
|
||||
For more information about this error, try `rustc --explain E0106`.
|
||||
error: could not compile `chapter10` due to previous error
|
||||
error: could not compile `chapter10` (bin "chapter10") due to 1 previous error
|
||||
|
|
|
@ -3,12 +3,14 @@ $ cargo run
|
|||
error[E0597]: `string2` does not live long enough
|
||||
--> src/main.rs:6:44
|
||||
|
|
||||
5 | let string2 = String::from("xyz");
|
||||
| ------- binding `string2` declared here
|
||||
6 | result = longest(string1.as_str(), string2.as_str());
|
||||
| ^^^^^^^^^^^^^^^^ borrowed value does not live long enough
|
||||
| ^^^^^^^ borrowed value does not live long enough
|
||||
7 | }
|
||||
| - `string2` dropped here while still borrowed
|
||||
8 | println!("The longest string is {result}");
|
||||
| ------ borrow later used here
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
error: could not compile `chapter10` due to previous error
|
||||
error: could not compile `chapter10` (bin "chapter10") due to 1 previous error
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
$ cargo run
|
||||
Compiling chapter10 v0.1.0 (file:///projects/chapter10)
|
||||
error[E0515]: cannot return reference to local variable `result`
|
||||
error[E0515]: cannot return value referencing local variable `result`
|
||||
--> src/main.rs:11:5
|
||||
|
|
||||
11 | result.as_str()
|
||||
| ^^^^^^^^^^^^^^^ returns a reference to data owned by the current function
|
||||
| ------^^^^^^^^^
|
||||
| |
|
||||
| returns a value referencing data owned by the current function
|
||||
| `result` is borrowed here
|
||||
|
||||
For more information about this error, try `rustc --explain E0515`.
|
||||
error: could not compile `chapter10` due to previous error
|
||||
error: could not compile `chapter10` (bin "chapter10") due to 1 previous error
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
pub fn add(left: usize, right: usize) -> usize {
|
||||
left + right
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn it_works() {
|
||||
let result = 2 + 2;
|
||||
let result = add(2, 2);
|
||||
assert_eq!(result, 4);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,8 @@ test tests::exploration ... ok
|
|||
failures:
|
||||
|
||||
---- tests::another stdout ----
|
||||
thread 'tests::another' panicked at 'Make this test fail', src/lib.rs:10:9
|
||||
thread 'tests::another' panicked at src/lib.rs:10:9:
|
||||
Make this test fail
|
||||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
|
||||
|
||||
|
||||
|
|
|
@ -1,11 +1,18 @@
|
|||
// ANCHOR: here
|
||||
pub fn add(left: usize, right: usize) -> usize {
|
||||
left + right
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn exploration() {
|
||||
assert_eq!(2 + 2, 4);
|
||||
let result = add(2, 2);
|
||||
assert_eq!(result, 4);
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn another() {
|
||||
panic!("Make this test fail");
|
||||
|
|
|
@ -9,13 +9,11 @@ impl Guess {
|
|||
pub fn new(value: i32) -> Guess {
|
||||
if value < 1 {
|
||||
panic!(
|
||||
"Guess value must be greater than or equal to 1, got {}.",
|
||||
value
|
||||
"Guess value must be greater than or equal to 1, got {value}."
|
||||
);
|
||||
} else if value > 100 {
|
||||
panic!(
|
||||
"Guess value must be less than or equal to 100, got {}.",
|
||||
value
|
||||
"Guess value must be less than or equal to 100, got {value}."
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,9 +11,10 @@ failures:
|
|||
|
||||
---- tests::this_test_will_fail stdout ----
|
||||
I got the value 8
|
||||
thread 'tests::this_test_will_fail' panicked at 'assertion failed: `(left == right)`
|
||||
left: `5`,
|
||||
right: `10`', src/lib.rs:19:9
|
||||
thread 'tests::this_test_will_fail' panicked at src/lib.rs:19:9:
|
||||
assertion `left == right` failed
|
||||
left: 5
|
||||
right: 10
|
||||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use adder;
|
||||
use adder::add_two;
|
||||
|
||||
#[test]
|
||||
fn it_adds_two() {
|
||||
assert_eq!(4, adder::add_two(2));
|
||||
assert_eq!(4, add_two(2));
|
||||
}
|
||||
|
|
|
@ -1,7 +1,14 @@
|
|||
pub fn add(left: usize, right: usize) -> usize {
|
||||
left + right
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn exploration() {
|
||||
assert_eq!(2 + 2, 4);
|
||||
let result = add(2, 2);
|
||||
assert_eq!(result, 4);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,8 @@ test tests::smaller_cannot_hold_larger ... ok
|
|||
failures:
|
||||
|
||||
---- tests::larger_can_hold_smaller stdout ----
|
||||
thread 'tests::larger_can_hold_smaller' panicked at 'assertion failed: larger.can_hold(&smaller)', src/lib.rs:28:9
|
||||
thread 'tests::larger_can_hold_smaller' panicked at src/lib.rs:28:9:
|
||||
assertion failed: larger.can_hold(&smaller)
|
||||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
|
||||
|
||||
|
||||
|
|
|
@ -9,9 +9,10 @@ test tests::it_adds_two ... FAILED
|
|||
failures:
|
||||
|
||||
---- tests::it_adds_two stdout ----
|
||||
thread 'tests::it_adds_two' panicked at 'assertion failed: `(left == right)`
|
||||
left: `4`,
|
||||
right: `5`', src/lib.rs:11:9
|
||||
thread 'tests::it_adds_two' panicked at src/lib.rs:11:9:
|
||||
assertion `left == right` failed
|
||||
left: 4
|
||||
right: 5
|
||||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
|
||||
|
||||
|
||||
|
|
|
@ -9,7 +9,8 @@ test tests::greeting_contains_name ... FAILED
|
|||
failures:
|
||||
|
||||
---- tests::greeting_contains_name stdout ----
|
||||
thread 'tests::greeting_contains_name' panicked at 'assertion failed: result.contains(\"Carol\")', src/lib.rs:12:9
|
||||
thread 'tests::greeting_contains_name' panicked at src/lib.rs:12:9:
|
||||
assertion failed: result.contains("Carol")
|
||||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
|
||||
|
||||
|
||||
|
|
|
@ -9,7 +9,8 @@ test tests::greeting_contains_name ... FAILED
|
|||
failures:
|
||||
|
||||
---- tests::greeting_contains_name stdout ----
|
||||
thread 'tests::greeting_contains_name' panicked at 'Greeting did not contain name, value was `Hello!`', src/lib.rs:12:9
|
||||
thread 'tests::greeting_contains_name' panicked at src/lib.rs:12:9:
|
||||
Greeting did not contain name, value was `Hello!`
|
||||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
|
||||
|
||||
|
||||
|
|
|
@ -9,7 +9,8 @@ test tests::greater_than_100 - should panic ... FAILED
|
|||
failures:
|
||||
|
||||
---- tests::greater_than_100 stdout ----
|
||||
thread 'tests::greater_than_100' panicked at 'Guess value must be greater than or equal to 1, got 200.', src/lib.rs:13:13
|
||||
thread 'tests::greater_than_100' panicked at src/lib.rs:13:13:
|
||||
Guess value must be greater than or equal to 1, got 200.
|
||||
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."`,
|
||||
|
|
|
@ -7,13 +7,11 @@ impl Guess {
|
|||
// ANCHOR: here
|
||||
if value < 1 {
|
||||
panic!(
|
||||
"Guess value must be less than or equal to 100, got {}.",
|
||||
value
|
||||
"Guess value must be less than or equal to 100, got {value}."
|
||||
);
|
||||
} else if value > 100 {
|
||||
panic!(
|
||||
"Guess value must be greater than or equal to 1, got {}.",
|
||||
value
|
||||
"Guess value must be greater than or equal to 1, got {value}."
|
||||
);
|
||||
}
|
||||
// ANCHOR_END: here
|
||||
|
|
|
@ -20,9 +20,10 @@ failures:
|
|||
|
||||
---- tests::this_test_will_fail stdout ----
|
||||
I got the value 8
|
||||
thread 'tests::this_test_will_fail' panicked at 'assertion failed: `(left == right)`
|
||||
left: `5`,
|
||||
right: `10`', src/lib.rs:19:9
|
||||
thread 'tests::this_test_will_fail' panicked at src/lib.rs:19:9:
|
||||
assertion `left == right` failed
|
||||
left: 5
|
||||
right: 10
|
||||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,6 @@ $ cargo run
|
|||
Compiling minigrep v0.1.0 (file:///projects/minigrep)
|
||||
Finished dev [unoptimized + debuginfo] target(s) in 0.61s
|
||||
Running `target/debug/minigrep`
|
||||
[src/main.rs:5] args = [
|
||||
[src/main.rs:5:5] args = [
|
||||
"target/debug/minigrep",
|
||||
]
|
||||
|
|
|
@ -2,5 +2,6 @@ $ cargo run
|
|||
Compiling minigrep v0.1.0 (file:///projects/minigrep)
|
||||
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
|
||||
thread 'main' panicked at src/main.rs:27:21:
|
||||
index out of bounds: the len is 1 but the index is 1
|
||||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
|
||||
|
|
|
@ -2,5 +2,6 @@ $ cargo run
|
|||
Compiling minigrep v0.1.0 (file:///projects/minigrep)
|
||||
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
|
||||
thread 'main' panicked at src/main.rs:26:13:
|
||||
not enough arguments
|
||||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$ cargo run the poem.txt
|
||||
$ cargo run -- the poem.txt
|
||||
Compiling minigrep v0.1.0 (file:///projects/minigrep)
|
||||
warning: unused `Result` that must be used
|
||||
--> src/main.rs:19:5
|
||||
|
@ -8,6 +8,10 @@ warning: unused `Result` that must be used
|
|||
|
|
||||
= note: this `Result` may be an `Err` variant, which should be handled
|
||||
= note: `#[warn(unused_must_use)]` on by default
|
||||
help: use `let _ = ...` to ignore the resulting value
|
||||
|
|
||||
19 | let _ = run(config);
|
||||
| +++++++
|
||||
|
||||
warning: `minigrep` (bin "minigrep") generated 1 warning
|
||||
Finished dev [unoptimized + debuginfo] target(s) in 0.71s
|
||||
|
|
|
@ -9,9 +9,10 @@ test tests::one_result ... FAILED
|
|||
failures:
|
||||
|
||||
---- tests::one_result stdout ----
|
||||
thread 'tests::one_result' panicked at 'assertion failed: `(left == right)`
|
||||
left: `["safe, fast, productive."]`,
|
||||
right: `[]`', src/lib.rs:44:9
|
||||
thread 'tests::one_result' panicked at src/lib.rs:44:9:
|
||||
assertion `left == right` failed
|
||||
left: ["safe, fast, productive."]
|
||||
right: []
|
||||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ $ cargo run -- needle haystack
|
|||
Compiling minigrep v0.1.0 (file:///projects/minigrep)
|
||||
Finished dev [unoptimized + debuginfo] target(s) in 1.57s
|
||||
Running `target/debug/minigrep needle haystack`
|
||||
[src/main.rs:5] args = [
|
||||
[src/main.rs:5:5] args = [
|
||||
"target/debug/minigrep",
|
||||
"needle",
|
||||
"haystack",
|
||||
|
|
|
@ -13,4 +13,4 @@ help: consider introducing a named lifetime parameter
|
|||
| ++++ ++ ++ ++
|
||||
|
||||
For more information about this error, try `rustc --explain E0106`.
|
||||
error: could not compile `minigrep` due to previous error
|
||||
error: could not compile `minigrep` (lib) due to 1 previous error
|
||||
|
|
|
@ -6,9 +6,16 @@ error[E0308]: mismatched types
|
|||
5 | let n = example_closure(5);
|
||||
| --------------- ^- help: try using a conversion method: `.to_string()`
|
||||
| | |
|
||||
| | expected struct `String`, found integer
|
||||
| | expected `String`, found integer
|
||||
| arguments to this function are incorrect
|
||||
|
|
||||
note: expected because the closure was earlier called with an argument of type `String`
|
||||
--> src/main.rs:4:29
|
||||
|
|
||||
4 | let s = example_closure(String::from("hello"));
|
||||
| --------------- ^^^^^^^^^^^^^^^^^^^^^ expected because this argument is of type `String`
|
||||
| |
|
||||
| in this closure call
|
||||
note: closure parameter defined here
|
||||
--> src/main.rs:2:28
|
||||
|
|
||||
|
@ -16,4 +23,4 @@ note: closure parameter defined here
|
|||
| ^
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
error: could not compile `closure-example` due to previous error
|
||||
error: could not compile `closure-example` (bin "closure-example") due to 1 previous error
|
||||
|
|
|
@ -3,7 +3,7 @@ $ cargo run
|
|||
error[E0507]: cannot move out of `value`, a captured variable in an `FnMut` closure
|
||||
--> src/main.rs:18:30
|
||||
|
|
||||
15 | let value = String::from("by key called");
|
||||
15 | let value = String::from("closure called");
|
||||
| ----- captured outer variable
|
||||
16 |
|
||||
17 | list.sort_by_key(|r| {
|
||||
|
@ -12,4 +12,4 @@ error[E0507]: cannot move out of `value`, a captured variable in an `FnMut` clos
|
|||
| ^^^^^ move occurs because `value` has type `String`, which does not implement the `Copy` trait
|
||||
|
||||
For more information about this error, try `rustc --explain E0507`.
|
||||
error: could not compile `rectangles` due to previous error
|
||||
error: could not compile `rectangles` (bin "rectangles") due to 1 previous error
|
||||
|
|
|
@ -12,7 +12,7 @@ fn main() {
|
|||
];
|
||||
|
||||
let mut sort_operations = vec![];
|
||||
let value = String::from("by key called");
|
||||
let value = String::from("closure called");
|
||||
|
||||
list.sort_by_key(|r| {
|
||||
sort_operations.push(value);
|
||||
|
|
|
@ -8,6 +8,10 @@ warning: unused `Map` that must be used
|
|||
|
|
||||
= note: iterators are lazy and do nothing unless consumed
|
||||
= note: `#[warn(unused_must_use)]` on by default
|
||||
help: use `let _ = ...` to ignore the resulting value
|
||||
|
|
||||
4 | let _ = v1.iter().map(|x| x + 1);
|
||||
| +++++++
|
||||
|
||||
warning: `iterators` (bin "iterators") generated 1 warning
|
||||
Finished dev [unoptimized + debuginfo] target(s) in 0.47s
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
pub fn add(left: usize, right: usize) -> usize {
|
||||
left + right
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn it_works() {
|
||||
let result = 2 + 2;
|
||||
let result = add(2, 2);
|
||||
assert_eq!(result, 4);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,4 +14,4 @@ help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle
|
|||
| ++++ +
|
||||
|
||||
For more information about this error, try `rustc --explain E0072`.
|
||||
error: could not compile `cons-list` due to previous error
|
||||
error: could not compile `cons-list` (bin "cons-list") due to 1 previous error
|
||||
|
|
|
@ -7,4 +7,4 @@ error[E0614]: type `MyBox<{integer}>` cannot be dereferenced
|
|||
| ^^
|
||||
|
||||
For more information about this error, try `rustc --explain E0614`.
|
||||
error: could not compile `deref-example` due to previous error
|
||||
error: could not compile `deref-example` (bin "deref-example") due to 1 previous error
|
||||
|
|
|
@ -4,10 +4,12 @@ error[E0040]: explicit use of destructor method
|
|||
--> src/main.rs:16:7
|
||||
|
|
||||
16 | c.drop();
|
||||
| --^^^^--
|
||||
| | |
|
||||
| | explicit destructor calls not allowed
|
||||
| help: consider using `drop` function: `drop(c)`
|
||||
| ^^^^ explicit destructor calls not allowed
|
||||
|
|
||||
help: consider using `drop` function
|
||||
|
|
||||
16 | drop(c);
|
||||
| +++++ ~
|
||||
|
||||
For more information about this error, try `rustc --explain E0040`.
|
||||
error: could not compile `drop-example` due to previous error
|
||||
error: could not compile `drop-example` (bin "drop-example") due to 1 previous error
|
||||
|
|
|
@ -11,4 +11,4 @@ error[E0382]: use of moved value: `a`
|
|||
| ^ value used here after move
|
||||
|
||||
For more information about this error, try `rustc --explain E0382`.
|
||||
error: could not compile `cons-list` due to previous error
|
||||
error: could not compile `cons-list` (bin "cons-list") due to 1 previous error
|
||||
|
|
|
@ -3,12 +3,13 @@ $ cargo test
|
|||
error[E0596]: cannot borrow `self.sent_messages` as mutable, as it is behind a `&` reference
|
||||
--> src/lib.rs:58:13
|
||||
|
|
||||
2 | fn send(&self, msg: &str);
|
||||
| ----- help: consider changing that to be a mutable reference: `&mut self`
|
||||
...
|
||||
58 | self.sent_messages.push(String::from(message));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable
|
||||
| ^^^^^^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable
|
||||
|
|
||||
help: consider changing this to be a mutable reference
|
||||
|
|
||||
2 | fn send(&mut self, msg: &str);
|
||||
| ~~~~~~~~~
|
||||
|
||||
For more information about this error, try `rustc --explain E0596`.
|
||||
error: could not compile `limit-tracker` due to previous error
|
||||
warning: build failed, waiting for other jobs to finish...
|
||||
error: could not compile `limit-tracker` (lib test) due to 1 previous error
|
||||
|
|
|
@ -9,7 +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 'tests::it_sends_an_over_75_percent_warning_message' panicked at 'already borrowed: BorrowMutError', src/lib.rs:60:53
|
||||
thread 'tests::it_sends_an_over_75_percent_warning_message' panicked at src/lib.rs:60:53:
|
||||
already borrowed: BorrowMutError
|
||||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
|
||||
|
||||
|
||||
|
|
|
@ -3,10 +3,13 @@ $ cargo run
|
|||
error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
|
||||
--> src/main.rs:3:13
|
||||
|
|
||||
2 | let x = 5;
|
||||
| - help: consider changing this to be mutable: `mut x`
|
||||
3 | let y = &mut x;
|
||||
| ^^^^^^ cannot borrow as mutable
|
||||
|
|
||||
help: consider changing this to be mutable
|
||||
|
|
||||
2 | let mut x = 5;
|
||||
| +++
|
||||
|
||||
For more information about this error, try `rustc --explain E0596`.
|
||||
error: could not compile `borrowing` due to previous error
|
||||
error: could not compile `borrowing` (bin "borrowing") due to 1 previous error
|
||||
|
|
|
@ -8,16 +8,16 @@ error[E0277]: can't compare `{integer}` with `&{integer}`
|
|||
|
|
||||
= help: the trait `PartialEq<&{integer}>` is not implemented for `{integer}`
|
||||
= help: the following other types implement trait `PartialEq<Rhs>`:
|
||||
f32
|
||||
f64
|
||||
i128
|
||||
isize
|
||||
i8
|
||||
i16
|
||||
i32
|
||||
i64
|
||||
i8
|
||||
isize
|
||||
i128
|
||||
usize
|
||||
u8
|
||||
and 6 others
|
||||
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
error: could not compile `deref-example` due to previous error
|
||||
error: could not compile `deref-example` (bin "deref-example") due to 1 previous error
|
||||
|
|
|
@ -22,4 +22,4 @@ help: to force the closure to take ownership of `v` (and any other referenced va
|
|||
| ++++
|
||||
|
||||
For more information about this error, try `rustc --explain E0373`.
|
||||
error: could not compile `threads` due to previous error
|
||||
error: could not compile `threads` (bin "threads") due to 1 previous error
|
||||
|
|
|
@ -11,6 +11,10 @@ error[E0382]: borrow of moved value: `val`
|
|||
| ^^^ value borrowed here after move
|
||||
|
|
||||
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
help: consider cloning the value if the performance cost is acceptable
|
||||
|
|
||||
9 | tx.send(val.clone()).unwrap();
|
||||
| ++++++++
|
||||
|
||||
For more information about this error, try `rustc --explain E0382`.
|
||||
error: could not compile `message-passing` due to previous error
|
||||
error: could not compile `message-passing` (bin "message-passing") due to 1 previous error
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
$ cargo run
|
||||
Compiling shared-state v0.1.0 (file:///projects/shared-state)
|
||||
error[E0382]: use of moved value: `counter`
|
||||
--> src/main.rs:9:36
|
||||
error[E0382]: borrow of moved value: `counter`
|
||||
--> src/main.rs:21:29
|
||||
|
|
||||
5 | let counter = Mutex::new(0);
|
||||
| ------- move occurs because `counter` has type `Mutex<i32>`, which does not implement the `Copy` trait
|
||||
...
|
||||
9 | let handle = thread::spawn(move || {
|
||||
| ^^^^^^^ value moved into closure here, in previous iteration of loop
|
||||
10 | let mut num = counter.lock().unwrap();
|
||||
| ------- use occurs due to use in closure
|
||||
| ------- value moved into closure here, in previous iteration of loop
|
||||
...
|
||||
21 | println!("Result: {}", *counter.lock().unwrap());
|
||||
| ^^^^^^^ value borrowed here after move
|
||||
|
||||
For more information about this error, try `rustc --explain E0382`.
|
||||
error: could not compile `shared-state` due to previous error
|
||||
error: could not compile `shared-state` (bin "shared-state") due to 1 previous error
|
||||
|
|
|
@ -6,7 +6,7 @@ error[E0277]: `Rc<Mutex<i32>>` cannot be sent between threads safely
|
|||
11 | let handle = thread::spawn(move || {
|
||||
| ------------- ^------
|
||||
| | |
|
||||
| ______________________|_____________within this `[closure@src/main.rs:11:36: 11:43]`
|
||||
| ______________________|_____________within this `{closure@src/main.rs:11:36: 11:43}`
|
||||
| | |
|
||||
| | required by a bound introduced by this call
|
||||
12 | | let mut num = counter.lock().unwrap();
|
||||
|
@ -15,16 +15,14 @@ error[E0277]: `Rc<Mutex<i32>>` cannot be sent between threads safely
|
|||
15 | | });
|
||||
| |_________^ `Rc<Mutex<i32>>` cannot be sent between threads safely
|
||||
|
|
||||
= help: within `[closure@src/main.rs:11:36: 11:43]`, the trait `Send` is not implemented for `Rc<Mutex<i32>>`
|
||||
= help: within `{closure@src/main.rs:11:36: 11:43}`, the trait `Send` is not implemented for `Rc<Mutex<i32>>`
|
||||
note: required because it's used within this closure
|
||||
--> src/main.rs:11:36
|
||||
|
|
||||
11 | let handle = thread::spawn(move || {
|
||||
| ^^^^^^^
|
||||
note: required by a bound in `spawn`
|
||||
--> /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/thread/mod.rs:704:8
|
||||
|
|
||||
= note: required by this bound in `spawn`
|
||||
--> /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/thread/mod.rs:678:1
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
error: could not compile `shared-state` due to previous error
|
||||
error: could not compile `shared-state` (bin "shared-state") due to 1 previous error
|
||||
|
|
|
@ -15,4 +15,4 @@ error[E0382]: use of moved value: `v`
|
|||
| ^ value used here after move
|
||||
|
||||
For more information about this error, try `rustc --explain E0382`.
|
||||
error: could not compile `threads` due to previous error
|
||||
error: could not compile `threads` (bin "threads") due to 1 previous error
|
||||
|
|
|
@ -7,7 +7,7 @@ error[E0277]: the trait bound `String: Draw` is not satisfied
|
|||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Draw` is not implemented for `String`
|
||||
|
|
||||
= help: the trait `Draw` is implemented for `Button`
|
||||
= note: required for the cast from `String` to the object type `dyn Draw`
|
||||
= note: required for the cast from `Box<String>` to `Box<dyn Draw>`
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
error: could not compile `gui` due to previous error
|
||||
error: could not compile `gui` (bin "gui") due to 1 previous error
|
||||
|
|
|
@ -12,4 +12,4 @@ error[E0308]: mismatched types
|
|||
found tuple `(_, _)`
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
error: could not compile `patterns` due to previous error
|
||||
error: could not compile `patterns` (bin "patterns") due to 1 previous error
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
$ cargo run
|
||||
Compiling patterns v0.1.0 (file:///projects/patterns)
|
||||
error[E0005]: refutable pattern in local binding: `None` not covered
|
||||
error[E0005]: refutable pattern in local binding
|
||||
--> src/main.rs:3:9
|
||||
|
|
||||
3 | let Some(x) = some_option_value;
|
||||
|
@ -8,20 +8,11 @@ error[E0005]: refutable pattern in local binding: `None` not covered
|
|||
|
|
||||
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
|
||||
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
|
||||
note: `Option<i32>` defined here
|
||||
--> /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/option.rs:518:1
|
||||
|
|
||||
= note:
|
||||
/rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/option.rs:522:5: not covered
|
||||
= note: the matched value is of type `Option<i32>`
|
||||
help: you might want to use `if let` to ignore the variant that isn't matched
|
||||
|
|
||||
3 | let x = if let Some(x) = some_option_value { x } else { todo!() };
|
||||
| ++++++++++ ++++++++++++++++++++++
|
||||
help: alternatively, you might want to use let else to handle the variant that isn't matched
|
||||
help: you might want to use `let else` to handle the variant that isn't matched
|
||||
|
|
||||
3 | let Some(x) = some_option_value else { todo!() };
|
||||
| ++++++++++++++++
|
||||
|
||||
For more information about this error, try `rustc --explain E0005`.
|
||||
error: could not compile `patterns` due to previous error
|
||||
error: could not compile `patterns` (bin "patterns") due to 1 previous error
|
||||
|
|
|
@ -8,4 +8,4 @@ error: `..` can only be used once per tuple pattern
|
|||
| |
|
||||
| previously used here
|
||||
|
||||
error: could not compile `patterns` due to previous error
|
||||
error: could not compile `patterns` (bin "patterns") due to 1 previous error
|
||||
|
|
|
@ -14,4 +14,4 @@ error[E0499]: cannot borrow `*values` as mutable more than once at a time
|
|||
| returning this value requires that `*values` is borrowed for `'1`
|
||||
|
||||
For more information about this error, try `rustc --explain E0499`.
|
||||
error: could not compile `unsafe-example` due to previous error
|
||||
error: could not compile `unsafe-example` (bin "unsafe-example") due to 1 previous error
|
||||
|
|
|
@ -15,4 +15,4 @@ help: use the fully-qualified path to the only available implementation
|
|||
| +++++++ +
|
||||
|
||||
For more information about this error, try `rustc --explain E0790`.
|
||||
error: could not compile `traits-example` due to previous error
|
||||
error: could not compile `traits-example` (bin "traits-example") due to 1 previous error
|
||||
|
|
|
@ -1,46 +1,46 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "hello_macro_derive"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.8"
|
||||
version = "1.0.80"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a56dea16b0a29e94408b9aa5e2940a4eedbd128a1ba20e8f7ae60fd3d465af0e"
|
||||
dependencies = [
|
||||
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.2"
|
||||
version = "1.0.36"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.14"
|
||||
version = "2.0.59"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4a6531ffc7b071655e4ce2e04bd464c4830bb585a61cabb96cf808f05172615a"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.2.0"
|
||||
name = "unicode-ident"
|
||||
version = "1.0.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[metadata]
|
||||
"checksum proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3acb317c6ff86a4e579dfa00fc5e6cca91ecbb4e7eb2df0468805b674eb88548"
|
||||
"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe"
|
||||
"checksum syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "af6f3550d8dff9ef7dc34d384ac6f107e5d31c8f57d9f28e0081503f547ac8f5"
|
||||
"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
|
||||
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||
|
|
|
@ -7,5 +7,5 @@ edition = "2021"
|
|||
proc-macro = true
|
||||
|
||||
[dependencies]
|
||||
syn = "1.0"
|
||||
syn = "2.0"
|
||||
quote = "1.0"
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use proc_macro::TokenStream;
|
||||
use quote::quote;
|
||||
use syn;
|
||||
|
||||
#[proc_macro_derive(HelloMacro)]
|
||||
pub fn hello_macro_derive(input: TokenStream) -> TokenStream {
|
||||
|
|
|
@ -1,46 +1,46 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "hello_macro_derive"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.8"
|
||||
version = "1.0.80"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a56dea16b0a29e94408b9aa5e2940a4eedbd128a1ba20e8f7ae60fd3d465af0e"
|
||||
dependencies = [
|
||||
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.2"
|
||||
version = "1.0.36"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.14"
|
||||
version = "2.0.59"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4a6531ffc7b071655e4ce2e04bd464c4830bb585a61cabb96cf808f05172615a"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.2.0"
|
||||
name = "unicode-ident"
|
||||
version = "1.0.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[metadata]
|
||||
"checksum proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3acb317c6ff86a4e579dfa00fc5e6cca91ecbb4e7eb2df0468805b674eb88548"
|
||||
"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe"
|
||||
"checksum syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "af6f3550d8dff9ef7dc34d384ac6f107e5d31c8f57d9f28e0081503f547ac8f5"
|
||||
"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
|
||||
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||
|
|
|
@ -7,5 +7,5 @@ edition = "2021"
|
|||
proc-macro = true
|
||||
|
||||
[dependencies]
|
||||
syn = "1.0"
|
||||
syn = "2.0"
|
||||
quote = "1.0"
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use proc_macro::TokenStream;
|
||||
use quote::quote;
|
||||
use syn;
|
||||
|
||||
#[proc_macro_derive(HelloMacro)]
|
||||
pub fn hello_macro_derive(input: TokenStream) -> TokenStream {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
$ cargo run
|
||||
Compiling traits-example v0.1.0 (file:///projects/traits-example)
|
||||
error[E0277]: `Point` doesn't implement `std::fmt::Display`
|
||||
--> src/main.rs:20:6
|
||||
--> src/main.rs:20:23
|
||||
|
|
||||
20 | impl OutlinePrint for Point {}
|
||||
| ^^^^^^^^^^^^ `Point` cannot be formatted with the default formatter
|
||||
| ^^^^^ `Point` cannot be formatted with the default formatter
|
||||
|
|
||||
= help: the trait `std::fmt::Display` is not implemented for `Point`
|
||||
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
|
||||
|
@ -15,4 +15,4 @@ note: required by a bound in `OutlinePrint`
|
|||
| ^^^^^^^^^^^^ required by this bound in `OutlinePrint`
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
error: could not compile `traits-example` due to previous error
|
||||
error: could not compile `traits-example` (bin "traits-example") due to 1 previous error
|
||||
|
|
|
@ -6,11 +6,15 @@ error[E0746]: return type cannot have an unboxed trait object
|
|||
1 | fn returns_closure() -> dyn Fn(i32) -> i32 {
|
||||
| ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
||||
|
|
||||
= note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
|
||||
help: use `impl Fn(i32) -> i32` as the return type, as all return paths are of type `[closure@src/lib.rs:2:5: 2:8]`, which implements `Fn(i32) -> i32`
|
||||
help: return an `impl Trait` instead of a `dyn Trait`, if all returned values are the same type
|
||||
|
|
||||
1 | fn returns_closure() -> impl Fn(i32) -> i32 {
|
||||
| ~~~~~~~~~~~~~~~~~~~
|
||||
| ~~~~
|
||||
help: box the return type, and wrap all of the returned values in `Box::new`
|
||||
|
|
||||
1 ~ fn returns_closure() -> Box<dyn Fn(i32) -> i32> {
|
||||
2 ~ Box::new(|x| x + 1)
|
||||
|
|
||||
|
||||
For more information about this error, try `rustc --explain E0746`.
|
||||
error: could not compile `functions-example` due to previous error
|
||||
error: could not compile `functions-example` (lib) due to 1 previous error
|
||||
|
|
|
@ -1,46 +1,46 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "hello_macro_derive"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.8"
|
||||
version = "1.0.80"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a56dea16b0a29e94408b9aa5e2940a4eedbd128a1ba20e8f7ae60fd3d465af0e"
|
||||
dependencies = [
|
||||
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.2"
|
||||
version = "1.0.36"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.14"
|
||||
version = "2.0.59"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4a6531ffc7b071655e4ce2e04bd464c4830bb585a61cabb96cf808f05172615a"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.2.0"
|
||||
name = "unicode-ident"
|
||||
version = "1.0.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[metadata]
|
||||
"checksum proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3acb317c6ff86a4e579dfa00fc5e6cca91ecbb4e7eb2df0468805b674eb88548"
|
||||
"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe"
|
||||
"checksum syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "af6f3550d8dff9ef7dc34d384ac6f107e5d31c8f57d9f28e0081503f547ac8f5"
|
||||
"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
|
||||
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||
|
|
|
@ -7,5 +7,5 @@ edition = "2021"
|
|||
proc-macro = true
|
||||
|
||||
[dependencies]
|
||||
syn = "1.0"
|
||||
syn = "2.0"
|
||||
quote = "1.0"
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use proc_macro::TokenStream;
|
||||
use quote::quote;
|
||||
use syn;
|
||||
|
||||
#[proc_macro_derive(HelloMacro)]
|
||||
pub fn hello_macro_derive(input: TokenStream) -> TokenStream {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue