Skip to content

Commit 5b37ab3

Browse files
committed
Auto merge of #9472 - r00ster91:bettererrors, r=alexcrichton
Improve two error messages The first error message saying "an integer" is confusing because if you give it `4` it's an integer but it will still complain that it must be an integer. So it's more specific now and tells you that it actually needs to be `1`, `2` or `3`. In the second error there was a space missing. It says `is not a valid setting,must be`.
2 parents 4592422 + b381fdb commit 5b37ab3

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/cargo/util/toml/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ impl<'de> de::Deserialize<'de> for TomlOptLevel {
395395
Ok(TomlOptLevel(value.to_string()))
396396
} else {
397397
Err(E::custom(format!(
398-
"must be an integer, `z`, or `s`, \
398+
"must be `0`, `1`, `2`, `3`, `s` or `z`, \
399399
but found the string: \"{}\"",
400400
value
401401
)))
@@ -553,7 +553,7 @@ impl TomlProfile {
553553
if let Some(panic) = &self.panic {
554554
if panic != "unwind" && panic != "abort" {
555555
bail!(
556-
"`panic` setting of `{}` is not a valid setting,\
556+
"`panic` setting of `{}` is not a valid setting, \
557557
must be `unwind` or `abort`",
558558
panic
559559
);

tests/testsuite/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ opt-level = 'foo'
583583
error in [..]/.cargo/config: could not load config key `profile.dev.opt-level`
584584
585585
Caused by:
586-
must be an integer, `z`, or `s`, but found the string: \"foo\"",
586+
must be `0`, `1`, `2`, `3`, `s` or `z`, but found the string: \"foo\"",
587587
);
588588

589589
let config = ConfigBuilder::new()
@@ -596,7 +596,7 @@ Caused by:
596596
error in environment variable `CARGO_PROFILE_DEV_OPT_LEVEL`: could not load config key `profile.dev.opt-level`
597597
598598
Caused by:
599-
must be an integer, `z`, or `s`, but found the string: \"asdf\"",
599+
must be `0`, `1`, `2`, `3`, `s` or `z`, but found the string: \"asdf\"",
600600
);
601601
}
602602

0 commit comments

Comments
 (0)