Skip to content

Commit

Permalink
Expand error message to explain that a string was found
Browse files Browse the repository at this point in the history
With `opt-level = "3"` this previously said:

    must be an integer, `z`, or `s`, but found: 3 for ...

The error message doesn't make that super clear.
This should now be a bit more clear.

Fixes #8234
  • Loading branch information
badboy committed May 12, 2020
1 parent 22c091c commit 09084a3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ impl<'de> de::Deserialize<'de> for TomlOptLevel {
} else {
Err(E::custom(format!(
"must be an integer, `z`, or `s`, \
but found: {}",
but found the string: \"{}\"",
value
)))
}
Expand Down
4 changes: 2 additions & 2 deletions tests/testsuite/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ opt-level = 'foo'
error in [..]/.cargo/config: could not load config key `profile.dev.opt-level`
Caused by:
must be an integer, `z`, or `s`, but found: foo",
must be an integer, `z`, or `s`, but found the string: \"foo\"",
);

let config = ConfigBuilder::new()
Expand All @@ -587,7 +587,7 @@ Caused by:
error in environment variable `CARGO_PROFILE_DEV_OPT_LEVEL`: could not load config key `profile.dev.opt-level`
Caused by:
must be an integer, `z`, or `s`, but found: asdf",
must be an integer, `z`, or `s`, but found the string: \"asdf\"",
);
}

Expand Down

0 comments on commit 09084a3

Please sign in to comment.