Skip to content

Commit ed549d8

Browse files
committed
Auto merge of #10755 - jonhoo:stabilize-config-cli, r=ehuss
Stabilize config-cli This stabilizes the `--config` CLI argument as per [this FCP](#7722 (comment)). It also makes the adjustment [suggested by `@ehuss](https://github.com/rust-lang/cargo/issues/7722#issuecomment-1098612205)` to allow stabilizing `--config path` without _also_ stabilizing [`config-include`](https://doc.rust-lang.org/cargo/reference/unstable.html#config-include). I took a guess that this would land in 1.63 and put that in the tombstone entry in the unstable docs, but let me know if that's likely to be wrong. Closes #7722. Also, I think this should probably be tagged `relnotes`.
2 parents c9d8c28 + 7eefb42 commit ed549d8

File tree

101 files changed

+455
-102
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+455
-102
lines changed

src/bin/cargo/cli.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -476,14 +476,7 @@ See 'cargo help <command>' for more information on a specific command.\n",
476476
.arg(flag("frozen", "Require Cargo.lock and cache are up to date").global(true))
477477
.arg(flag("locked", "Require Cargo.lock is up to date").global(true))
478478
.arg(flag("offline", "Run without accessing the network").global(true))
479-
.arg(
480-
multi_opt(
481-
"config",
482-
"KEY=VALUE",
483-
"Override a configuration value (unstable)",
484-
)
485-
.global(true),
486-
)
479+
.arg(multi_opt("config", "KEY=VALUE", "Override a configuration value").global(true))
487480
.arg(
488481
Arg::new("unstable-features")
489482
.help("Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details")

src/cargo/util/config/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,6 @@ impl Config {
892892
self.unstable_flags_cli = Some(unstable_flags.to_vec());
893893
}
894894
if !cli_config.is_empty() {
895-
self.unstable_flags.fail_if_stable_opt("--config", 6699)?;
896895
self.cli_config = Some(cli_config.iter().map(|s| s.to_string()).collect());
897896
self.merge_cli_args()?;
898897
}
@@ -1165,6 +1164,7 @@ impl Config {
11651164
Some(cli_args) => cli_args,
11661165
None => return Ok(loaded_args),
11671166
};
1167+
let mut seen = HashSet::new();
11681168
for arg in cli_args {
11691169
let arg_as_path = self.cwd.join(arg);
11701170
let tmp_table = if !arg.is_empty() && arg_as_path.exists() {
@@ -1175,9 +1175,8 @@ impl Config {
11751175
anyhow::format_err!("config path {:?} is not utf-8", arg_as_path)
11761176
})?
11771177
.to_string();
1178-
let value = CV::String(str_path, Definition::Cli);
1179-
let map = HashMap::from([("include".to_string(), value)]);
1180-
CV::Table(map, Definition::Cli)
1178+
self._load_file(&self.cwd().join(&str_path), &mut seen, true)
1179+
.with_context(|| format!("failed to load config from `{}`", str_path))?
11811180
} else {
11821181
// We only want to allow "dotted key" (see https://toml.io/en/v1.0.0#keys)
11831182
// expressions followed by a value that's not an "inline table"

src/doc/man/generated_txt/cargo-add.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ OPTIONS
141141
<https://rust-lang.github.io/rustup/overrides.html> for more
142142
information about how toolchain overrides work.
143143

144+
--config KEY=VALUE
145+
Overrides a Cargo configuration value.
146+
144147
-h, --help
145148
Prints help information.
146149

src/doc/man/generated_txt/cargo-bench.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,9 @@ OPTIONS
353353
<https://rust-lang.github.io/rustup/overrides.html> for more
354354
information about how toolchain overrides work.
355355

356+
--config KEY=VALUE
357+
Overrides a Cargo configuration value.
358+
356359
-h, --help
357360
Prints help information.
358361

src/doc/man/generated_txt/cargo-build.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,9 @@ OPTIONS
302302
<https://rust-lang.github.io/rustup/overrides.html> for more
303303
information about how toolchain overrides work.
304304

305+
--config KEY=VALUE
306+
Overrides a Cargo configuration value.
307+
305308
-h, --help
306309
Prints help information.
307310

src/doc/man/generated_txt/cargo-check.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,9 @@ OPTIONS
287287
<https://rust-lang.github.io/rustup/overrides.html> for more
288288
information about how toolchain overrides work.
289289

290+
--config KEY=VALUE
291+
Overrides a Cargo configuration value.
292+
290293
-h, --help
291294
Prints help information.
292295

src/doc/man/generated_txt/cargo-clean.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ OPTIONS
118118
<https://rust-lang.github.io/rustup/overrides.html> for more
119119
information about how toolchain overrides work.
120120

121+
--config KEY=VALUE
122+
Overrides a Cargo configuration value.
123+
121124
-h, --help
122125
Prints help information.
123126

src/doc/man/generated_txt/cargo-doc.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,9 @@ OPTIONS
258258
<https://rust-lang.github.io/rustup/overrides.html> for more
259259
information about how toolchain overrides work.
260260

261+
--config KEY=VALUE
262+
Overrides a Cargo configuration value.
263+
261264
-h, --help
262265
Prints help information.
263266

src/doc/man/generated_txt/cargo-fetch.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ OPTIONS
103103
<https://rust-lang.github.io/rustup/overrides.html> for more
104104
information about how toolchain overrides work.
105105

106+
--config KEY=VALUE
107+
Overrides a Cargo configuration value.
108+
106109
-h, --help
107110
Prints help information.
108111

src/doc/man/generated_txt/cargo-fix.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,9 @@ OPTIONS
360360
<https://rust-lang.github.io/rustup/overrides.html> for more
361361
information about how toolchain overrides work.
362362

363+
--config KEY=VALUE
364+
Overrides a Cargo configuration value.
365+
363366
-h, --help
364367
Prints help information.
365368

src/doc/man/generated_txt/cargo-generate-lockfile.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ OPTIONS
7979
<https://rust-lang.github.io/rustup/overrides.html> for more
8080
information about how toolchain overrides work.
8181

82+
--config KEY=VALUE
83+
Overrides a Cargo configuration value.
84+
8285
-h, --help
8386
Prints help information.
8487

src/doc/man/generated_txt/cargo-init.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ OPTIONS
8787
<https://rust-lang.github.io/rustup/overrides.html> for more
8888
information about how toolchain overrides work.
8989

90+
--config KEY=VALUE
91+
Overrides a Cargo configuration value.
92+
9093
-h, --help
9194
Prints help information.
9295

src/doc/man/generated_txt/cargo-install.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,9 @@ OPTIONS
323323
<https://rust-lang.github.io/rustup/overrides.html> for more
324324
information about how toolchain overrides work.
325325

326+
--config KEY=VALUE
327+
Overrides a Cargo configuration value.
328+
326329
-h, --help
327330
Prints help information.
328331

src/doc/man/generated_txt/cargo-locate-project.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ OPTIONS
6262
<https://rust-lang.github.io/rustup/overrides.html> for more
6363
information about how toolchain overrides work.
6464

65+
--config KEY=VALUE
66+
Overrides a Cargo configuration value.
67+
6568
-h, --help
6669
Prints help information.
6770

src/doc/man/generated_txt/cargo-login.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ OPTIONS
6262
<https://rust-lang.github.io/rustup/overrides.html> for more
6363
information about how toolchain overrides work.
6464

65+
--config KEY=VALUE
66+
Overrides a Cargo configuration value.
67+
6568
-h, --help
6669
Prints help information.
6770

src/doc/man/generated_txt/cargo-metadata.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,9 @@ OPTIONS
391391
<https://rust-lang.github.io/rustup/overrides.html> for more
392392
information about how toolchain overrides work.
393393

394+
--config KEY=VALUE
395+
Overrides a Cargo configuration value.
396+
394397
-h, --help
395398
Prints help information.
396399

src/doc/man/generated_txt/cargo-new.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ OPTIONS
8282
<https://rust-lang.github.io/rustup/overrides.html> for more
8383
information about how toolchain overrides work.
8484

85+
--config KEY=VALUE
86+
Overrides a Cargo configuration value.
87+
8588
-h, --help
8689
Prints help information.
8790

src/doc/man/generated_txt/cargo-owner.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ OPTIONS
8989
<https://rust-lang.github.io/rustup/overrides.html> for more
9090
information about how toolchain overrides work.
9191

92+
--config KEY=VALUE
93+
Overrides a Cargo configuration value.
94+
9295
-h, --help
9396
Prints help information.
9497

src/doc/man/generated_txt/cargo-package.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,9 @@ OPTIONS
227227
<https://rust-lang.github.io/rustup/overrides.html> for more
228228
information about how toolchain overrides work.
229229

230+
--config KEY=VALUE
231+
Overrides a Cargo configuration value.
232+
230233
-h, --help
231234
Prints help information.
232235

src/doc/man/generated_txt/cargo-pkgid.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ OPTIONS
109109
<https://rust-lang.github.io/rustup/overrides.html> for more
110110
information about how toolchain overrides work.
111111

112+
--config KEY=VALUE
113+
Overrides a Cargo configuration value.
114+
112115
-h, --help
113116
Prints help information.
114117

src/doc/man/generated_txt/cargo-publish.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ OPTIONS
194194
<https://rust-lang.github.io/rustup/overrides.html> for more
195195
information about how toolchain overrides work.
196196

197+
--config KEY=VALUE
198+
Overrides a Cargo configuration value.
199+
197200
-h, --help
198201
Prints help information.
199202

src/doc/man/generated_txt/cargo-run.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ OPTIONS
203203
<https://rust-lang.github.io/rustup/overrides.html> for more
204204
information about how toolchain overrides work.
205205

206+
--config KEY=VALUE
207+
Overrides a Cargo configuration value.
208+
206209
-h, --help
207210
Prints help information.
208211

src/doc/man/generated_txt/cargo-rustc.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,9 @@ OPTIONS
291291
<https://rust-lang.github.io/rustup/overrides.html> for more
292292
information about how toolchain overrides work.
293293

294+
--config KEY=VALUE
295+
Overrides a Cargo configuration value.
296+
294297
-h, --help
295298
Prints help information.
296299

src/doc/man/generated_txt/cargo-rustdoc.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,9 @@ OPTIONS
274274
<https://rust-lang.github.io/rustup/overrides.html> for more
275275
information about how toolchain overrides work.
276276

277+
--config KEY=VALUE
278+
Overrides a Cargo configuration value.
279+
277280
-h, --help
278281
Prints help information.
279282

src/doc/man/generated_txt/cargo-search.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ OPTIONS
5959
<https://rust-lang.github.io/rustup/overrides.html> for more
6060
information about how toolchain overrides work.
6161

62+
--config KEY=VALUE
63+
Overrides a Cargo configuration value.
64+
6265
-h, --help
6366
Prints help information.
6467

src/doc/man/generated_txt/cargo-test.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,9 @@ OPTIONS
371371
<https://rust-lang.github.io/rustup/overrides.html> for more
372372
information about how toolchain overrides work.
373373

374+
--config KEY=VALUE
375+
Overrides a Cargo configuration value.
376+
374377
-h, --help
375378
Prints help information.
376379

src/doc/man/generated_txt/cargo-tree.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,9 @@ OPTIONS
269269
<https://rust-lang.github.io/rustup/overrides.html> for more
270270
information about how toolchain overrides work.
271271

272+
--config KEY=VALUE
273+
Overrides a Cargo configuration value.
274+
272275
-h, --help
273276
Prints help information.
274277

src/doc/man/generated_txt/cargo-uninstall.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ OPTIONS
7171
<https://rust-lang.github.io/rustup/overrides.html> for more
7272
information about how toolchain overrides work.
7373

74+
--config KEY=VALUE
75+
Overrides a Cargo configuration value.
76+
7477
-h, --help
7578
Prints help information.
7679

src/doc/man/generated_txt/cargo-update.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ OPTIONS
109109
<https://rust-lang.github.io/rustup/overrides.html> for more
110110
information about how toolchain overrides work.
111111

112+
--config KEY=VALUE
113+
Overrides a Cargo configuration value.
114+
112115
-h, --help
113116
Prints help information.
114117

src/doc/man/generated_txt/cargo-vendor.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ OPTIONS
105105
<https://rust-lang.github.io/rustup/overrides.html> for more
106106
information about how toolchain overrides work.
107107

108+
--config KEY=VALUE
109+
Overrides a Cargo configuration value.
110+
108111
-h, --help
109112
Prints help information.
110113

src/doc/man/generated_txt/cargo-verify-project.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ OPTIONS
8282
<https://rust-lang.github.io/rustup/overrides.html> for more
8383
information about how toolchain overrides work.
8484

85+
--config KEY=VALUE
86+
Overrides a Cargo configuration value.
87+
8588
-h, --help
8689
Prints help information.
8790

src/doc/man/generated_txt/cargo-yank.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ OPTIONS
8585
<https://rust-lang.github.io/rustup/overrides.html> for more
8686
information about how toolchain overrides work.
8787

88+
--config KEY=VALUE
89+
Overrides a Cargo configuration value.
90+
8891
-h, --help
8992
Prints help information.
9093

src/doc/man/generated_txt/cargo.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ OPTIONS
188188
<https://rust-lang.github.io/rustup/overrides.html> for more
189189
information about how toolchain overrides work.
190190

191+
--config KEY=VALUE
192+
Overrides a Cargo configuration value.
193+
191194
-h, --help
192195
Prints help information.
193196

src/doc/man/includes/section-options-common.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ See the [rustup documentation](https://rust-lang.github.io/rustup/overrides.html
1010
for more information about how toolchain overrides work.
1111
{{/option}}
1212

13+
{{#option "`--config` KEY=VALUE"}}
14+
Overrides a Cargo configuration value.
15+
{{/option}}
16+
1317
{{#option "`-h`" "`--help`"}}
1418
Prints help information.
1519
{{/option}}

src/doc/src/commands/cargo-add.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,10 @@ See the <a href="https://rust-lang.github.io/rustup/overrides.html">rustup docum
177177
for more information about how toolchain overrides work.</dd>
178178

179179

180+
<dt class="option-term" id="option-cargo-add---config"><a class="option-anchor" href="#option-cargo-add---config"></a><code>--config</code> KEY=VALUE</dt>
181+
<dd class="option-desc">Overrides a Cargo configuration value.</dd>
182+
183+
180184
<dt class="option-term" id="option-cargo-add--h"><a class="option-anchor" href="#option-cargo-add--h"></a><code>-h</code></dt>
181185
<dt class="option-term" id="option-cargo-add---help"><a class="option-anchor" href="#option-cargo-add---help"></a><code>--help</code></dt>
182186
<dd class="option-desc">Prints help information.</dd>

src/doc/src/commands/cargo-bench.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,10 @@ See the <a href="https://rust-lang.github.io/rustup/overrides.html">rustup docum
420420
for more information about how toolchain overrides work.</dd>
421421

422422

423+
<dt class="option-term" id="option-cargo-bench---config"><a class="option-anchor" href="#option-cargo-bench---config"></a><code>--config</code> KEY=VALUE</dt>
424+
<dd class="option-desc">Overrides a Cargo configuration value.</dd>
425+
426+
423427
<dt class="option-term" id="option-cargo-bench--h"><a class="option-anchor" href="#option-cargo-bench--h"></a><code>-h</code></dt>
424428
<dt class="option-term" id="option-cargo-bench---help"><a class="option-anchor" href="#option-cargo-bench---help"></a><code>--help</code></dt>
425429
<dd class="option-desc">Prints help information.</dd>

src/doc/src/commands/cargo-build.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,10 @@ See the <a href="https://rust-lang.github.io/rustup/overrides.html">rustup docum
364364
for more information about how toolchain overrides work.</dd>
365365

366366

367+
<dt class="option-term" id="option-cargo-build---config"><a class="option-anchor" href="#option-cargo-build---config"></a><code>--config</code> KEY=VALUE</dt>
368+
<dd class="option-desc">Overrides a Cargo configuration value.</dd>
369+
370+
367371
<dt class="option-term" id="option-cargo-build--h"><a class="option-anchor" href="#option-cargo-build--h"></a><code>-h</code></dt>
368372
<dt class="option-term" id="option-cargo-build---help"><a class="option-anchor" href="#option-cargo-build---help"></a><code>--help</code></dt>
369373
<dd class="option-desc">Prints help information.</dd>

0 commit comments

Comments
 (0)