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

opt-level = s and opt-level = z don't seem to work #7240

Closed
michaelwoerister opened this issue Aug 12, 2019 · 6 comments
Closed

opt-level = s and opt-level = z don't seem to work #7240

michaelwoerister opened this issue Aug 12, 2019 · 6 comments
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. A-toml Area: TOML parsing and handling C-bug Category: bug

Comments

@michaelwoerister
Copy link
Member

michaelwoerister commented Aug 12, 2019

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

  1. Create a new project with cargo new repro
  2. Add
    [profile.dev]
    opt-level = s
    to Cargo.toml.
  3. Run cargo build

Possible 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)
@michaelwoerister michaelwoerister added the C-bug Category: bug label Aug 12, 2019
@ehuss
Copy link
Contributor

ehuss commented Aug 12, 2019

They need to be specified as a string, like:

[profile.dev]
opt-level = 's'

The TOML language does not allow bare words as values.

@michaelwoerister
Copy link
Member Author

Ah, interesting! Considers this a bug report about an unhelpful error message then :)

@ehuss ehuss added A-diagnostics Area: Error and warning messages generated by Cargo itself. A-toml Area: TOML parsing and handling labels Sep 21, 2019
@aleksator
Copy link
Contributor

Looks like the error message is coming from https://github.com/alexcrichton/toml-rs
cc @alexcrichton

@ehuss
Copy link
Contributor

ehuss commented Feb 29, 2020

@aleksator I recently opened toml-rs/toml-rs#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.

@aleksator
Copy link
Contributor

aleksator commented Oct 12, 2020

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.

@ehuss
Copy link
Contributor

ehuss commented Oct 12, 2020

Yep, just updated via #8772.

@ehuss ehuss closed this as completed Oct 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. A-toml Area: TOML parsing and handling C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

3 participants