Skip to content

Commit 55869de

Browse files
committed
Auto merge of #8235 - badboy:8234-numbers-in-strings-are-numbers, r=alexcrichton
Expand error message to explain that a string was found 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 --- We could even include a bit more saying that `"3"` should become 3 (either unconditionally or after trying to parse `"3"` into an integer? cc @steveklabnik
2 parents 058baec + 09084a3 commit 55869de

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/cargo/util/toml/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ impl<'de> de::Deserialize<'de> for TomlOptLevel {
321321
} else {
322322
Err(E::custom(format!(
323323
"must be an integer, `z`, or `s`, \
324-
but found: {}",
324+
but found the string: \"{}\"",
325325
value
326326
)))
327327
}

tests/testsuite/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ opt-level = 'foo'
574574
error in [..]/.cargo/config: could not load config key `profile.dev.opt-level`
575575
576576
Caused by:
577-
must be an integer, `z`, or `s`, but found: foo",
577+
must be an integer, `z`, or `s`, but found the string: \"foo\"",
578578
);
579579

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

0 commit comments

Comments
 (0)