Skip to content

ch8/ch8-mget: build fails immediately due to misformed TOML in Cargo.toml #102

@ewenmcneill

Description

@ewenmcneill

At least with Rust 1.66 / Cargo 1.66, embedded newlines are not permitted in inline tables in TOML. This is also noted in the TOML specification: "No newlines are allowed between the curly braces unless they are valid within a value." So it appears Cargo is simply enforcing the TOML specification.

The pre-book-release version of the Cargo.toml uses multiple TOML (non-inline) tables, which appears to be the recommended TOML formatting if you need to break the table over multiple lines.

For some (not documented in the commit) reason this was changed to a more "JSON-like" multiline inline structure with the release of the book. I'm unclear if there is any rust/cargo version where that multi-line structure of inline TOML tables ever worked, or if this is just another thing that was never tested prior to release.

It apears sufficient to simply join the whole {...} inline table in the TOML onto a single line, in each case.

Ewen

PS: Both the "smoltcp" and "trust-dns" dependency details got reformatted in the book release version of Cargo.toml; both will need fixing for cargo to accept the Cargo.toml file.

ewen@rustdev:~/misc/src/rust/rust-in-action/ch8/ch8-mget$ git status Cargo.toml
On branch 1st-edition
Your branch is up to date with 'origin/1st-edition'.

nothing to commit, working tree clean
ewen@rustdev:~/misc/src/rust/rust-in-action/ch8/ch8-mget$ grep -A 99 dependencies Cargo.toml 
[dependencies]
clap = "2"
rand = "0.7"
smoltcp = {
  version = "0.6",
  features = ["proto-igmp", "proto-ipv4", "verbose", "log"]
}
trust-dns = {
  version = "0.16",
  default-features = false
}
url = "2"
ewen@rustdev:~/misc/src/rust/rust-in-action/ch8/ch8-mget$ cargo build
error: failed to parse manifest at `/home/ewen/misc/src/rust/rust-in-action/ch8/ch8-mget/Cargo.toml`

Caused by:
  could not parse input as TOML

Caused by:
  TOML parse error at line 10, column 12
     |
  10 | smoltcp = {
     |            ^
  Unexpected `
  `
  Expected key
ewen@rustdev:~/misc/src/rust/rust-in-action/ch8/ch8-mget$ 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions