Problem
Specifying opt-level = s or opt-level = z for a profile fails with the following error:
$ cargo build
error: failed to parse manifest at `/xoxo/stuff/cargo-opt-level-size-bug/Cargo.toml`
Caused by:
could not parse input as TOML
Caused by:
invalid number at line 10
Steps
cargo new reprotoml
[profile.dev]
opt-level = s
Cargo.toml.cargo buildPossible Solution(s)
Fix the Cargo.toml parser?
Notes
Output of cargo version:
cargo 1.36.0 (c4fcfb725 2019-05-15)
cargo 1.38.0-nightly (26092da33 2019-07-31)
They need to be specified as a string, like:
[profile.dev]
opt-level = 's'
The TOML language does not allow bare words as values.
Ah, interesting! Considers this a bug report about an unhelpful error message then :)
Looks like the error message is coming from https://github.com/alexcrichton/toml-rs
cc @alexcrichton
@aleksator I recently opened https://github.com/alexcrichton/toml-rs/issues/379 regarding the confusing error message here (it has cropped up in a few other places). I left some very rough guidance there, where number_or_date needs to check if the "keylike" value looks like it starts like a number or date, and if not should provide a better error message.
Fixed in toml-rs 0.5.7 (thank you @ehuss and @alexcrichton!).
We can rename this issue and close it next time we update dependencies.
Yep, just updated via #8772.
Most helpful comment
@aleksator I recently opened https://github.com/alexcrichton/toml-rs/issues/379 regarding the confusing error message here (it has cropped up in a few other places). I left some very rough guidance there, where
number_or_dateneeds to check if the "keylike" value looks like it starts like a number or date, and if not should provide a better error message.