Skip to content

Commit 02e071c

Browse files
author
Jon Gjengset
committed
Use implicit captured format args
1 parent 51917b4 commit 02e071c

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

src/cargo/util/config/mod.rs

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,7 +1182,7 @@ impl Config {
11821182
// parse the value as a toml_edit::Document, and check that the (single)
11831183
// inner-most table is set via dotted keys.
11841184
let doc: toml_edit::Document = arg.parse().with_context(|| {
1185-
format!("failed to parse value from --config argument `{}` as a dotted key expression", arg)
1185+
format!("failed to parse value from --config argument `{arg}` as a dotted key expression")
11861186
})?;
11871187
fn non_empty_decor(d: &toml_edit::Decor) -> bool {
11881188
d.prefix().map_or(false, |p| !p.trim().is_empty())
@@ -1204,67 +1204,62 @@ impl Config {
12041204
|| non_empty_decor(nt.decor())
12051205
{
12061206
bail!(
1207-
"--config argument `{}` \
1208-
includes non-whitespace decoration",
1209-
arg
1207+
"--config argument `{arg}` \
1208+
includes non-whitespace decoration"
12101209
)
12111210
}
12121211
table = nt;
12131212
}
12141213
Item::Value(v) if v.is_inline_table() => {
12151214
bail!(
1216-
"--config argument `{}` \
1217-
sets a value to an inline table, which is not accepted",
1218-
arg,
1215+
"--config argument `{arg}` \
1216+
sets a value to an inline table, which is not accepted"
12191217
);
12201218
}
12211219
Item::Value(v) => {
12221220
if non_empty_decor(v.decor()) {
12231221
bail!(
1224-
"--config argument `{}` \
1225-
includes non-whitespace decoration",
1226-
arg
1222+
"--config argument `{arg}` \
1223+
includes non-whitespace decoration"
12271224
)
12281225
}
12291226
got_to_value = true;
12301227
break;
12311228
}
12321229
Item::ArrayOfTables(_) => {
12331230
bail!(
1234-
"--config argument `{}` \
1235-
sets a value to an array of tables, which is not accepted",
1236-
arg,
1231+
"--config argument `{arg}` \
1232+
sets a value to an array of tables, which is not accepted"
12371233
);
12381234
}
12391235

12401236
Item::None => {
1241-
bail!("--config argument `{}` doesn't provide a value", arg)
1237+
bail!("--config argument `{arg}` doesn't provide a value")
12421238
}
12431239
}
12441240
}
12451241
got_to_value
12461242
};
12471243
if !ok {
12481244
bail!(
1249-
"--config argument `{}` was not a TOML dotted key expression (such as `build.jobs = 2`)",
1250-
arg
1245+
"--config argument `{arg}` was not a TOML dotted key expression (such as `build.jobs = 2`)"
12511246
);
12521247
}
12531248

12541249
let toml_v = toml::from_document(doc).with_context(|| {
1255-
format!("failed to parse value from --config argument `{}`", arg)
1250+
format!("failed to parse value from --config argument `{arg}`")
12561251
})?;
12571252

12581253
CV::from_toml(Definition::Cli, toml_v)
1259-
.with_context(|| format!("failed to convert --config argument `{}`", arg))?
1254+
.with_context(|| format!("failed to convert --config argument `{arg}`"))?
12601255
};
12611256
let mut seen = HashSet::new();
12621257
let tmp_table = self
12631258
.load_includes(tmp_table, &mut seen)
12641259
.with_context(|| "failed to load --config include".to_string())?;
12651260
loaded_args
12661261
.merge(tmp_table, true)
1267-
.with_context(|| format!("failed to merge --config argument `{}`", arg))?;
1262+
.with_context(|| format!("failed to merge --config argument `{arg}`"))?;
12681263
}
12691264
Ok(loaded_args)
12701265
}

0 commit comments

Comments
 (0)