Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ewenmcneill opened this issue Jan 10, 2023 · 2 comments
Closed

Comments

@ewenmcneill
Copy link

ewenmcneill commented Jan 10, 2023

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$ 
@ewenmcneill
Copy link
Author

It turns out that this is fixed in PR #91, which (a) hasn't been merged, and (b) had too generate a subject line to find it easily (I found it by accident today, looking for something else). PR #91 claims to fix issue #77, but AFAICT it only fixes part of #77; however AFAICT PR #91 would fix this issue.

Ewen

@ewenmcneill
Copy link
Author

Closing issue to clean up my GitHub "issues created" list, since after 18 months it seems clear nothing will happen in this Rust book related repo with the open issues.

Pull request #91 is still open, and unmerged, if someone needs to find this fix.

Ewen

@ewenmcneill ewenmcneill closed this as not planned Won't fix, can't repro, duplicate, stale Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant