Skip to content

Commit

Permalink
Auto merge of #10755 - jonhoo:stabilize-config-cli, r=ehuss
Browse files Browse the repository at this point in the history
Stabilize config-cli

This stabilizes the `--config` CLI argument as per [this FCP](#7722 (comment)).

It also makes the adjustment [suggested by `@ehuss](#7722 (comment) 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`.
  • Loading branch information
bors committed Jun 22, 2022
2 parents c9d8c28 + 7eefb42 commit ed549d8
Show file tree
Hide file tree
Showing 101 changed files with 455 additions and 102 deletions.
9 changes: 1 addition & 8 deletions src/bin/cargo/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,14 +476,7 @@ See 'cargo help <command>' for more information on a specific command.\n",
.arg(flag("frozen", "Require Cargo.lock and cache are up to date").global(true))
.arg(flag("locked", "Require Cargo.lock is up to date").global(true))
.arg(flag("offline", "Run without accessing the network").global(true))
.arg(
multi_opt(
"config",
"KEY=VALUE",
"Override a configuration value (unstable)",
)
.global(true),
)
.arg(multi_opt("config", "KEY=VALUE", "Override a configuration value").global(true))
.arg(
Arg::new("unstable-features")
.help("Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details")
Expand Down
7 changes: 3 additions & 4 deletions src/cargo/util/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,6 @@ impl Config {
self.unstable_flags_cli = Some(unstable_flags.to_vec());
}
if !cli_config.is_empty() {
self.unstable_flags.fail_if_stable_opt("--config", 6699)?;
self.cli_config = Some(cli_config.iter().map(|s| s.to_string()).collect());
self.merge_cli_args()?;
}
Expand Down Expand Up @@ -1165,6 +1164,7 @@ impl Config {
Some(cli_args) => cli_args,
None => return Ok(loaded_args),
};
let mut seen = HashSet::new();
for arg in cli_args {
let arg_as_path = self.cwd.join(arg);
let tmp_table = if !arg.is_empty() && arg_as_path.exists() {
Expand All @@ -1175,9 +1175,8 @@ impl Config {
anyhow::format_err!("config path {:?} is not utf-8", arg_as_path)
})?
.to_string();
let value = CV::String(str_path, Definition::Cli);
let map = HashMap::from([("include".to_string(), value)]);
CV::Table(map, Definition::Cli)
self._load_file(&self.cwd().join(&str_path), &mut seen, true)
.with_context(|| format!("failed to load config from `{}`", str_path))?
} else {
// We only want to allow "dotted key" (see https://toml.io/en/v1.0.0#keys)
// expressions followed by a value that's not an "inline table"
Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-add.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-bench.txt
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-build.txt
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-check.txt
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-clean.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-fetch.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-fix.txt
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-generate-lockfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-init.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-install.txt
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-locate-project.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-login.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-new.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-owner.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-package.txt
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-pkgid.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-publish.txt
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-run.txt
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-rustc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-rustdoc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-search.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-tree.txt
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-uninstall.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-update.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-vendor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-verify-project.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo-yank.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ OPTIONS
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE
Overrides a Cargo configuration value.

-h, --help
Prints help information.

Expand Down
4 changes: 4 additions & 0 deletions src/doc/man/includes/section-options-common.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ See the [rustup documentation](https://rust-lang.github.io/rustup/overrides.html
for more information about how toolchain overrides work.
{{/option}}

{{#option "`--config` KEY=VALUE"}}
Overrides a Cargo configuration value.
{{/option}}

{{#option "`-h`" "`--help`"}}
Prints help information.
{{/option}}
Expand Down
4 changes: 4 additions & 0 deletions src/doc/src/commands/cargo-add.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ See the <a href="https://rust-lang.github.io/rustup/overrides.html">rustup docum
for more information about how toolchain overrides work.</dd>


<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>
<dd class="option-desc">Overrides a Cargo configuration value.</dd>


<dt class="option-term" id="option-cargo-add--h"><a class="option-anchor" href="#option-cargo-add--h"></a><code>-h</code></dt>
<dt class="option-term" id="option-cargo-add---help"><a class="option-anchor" href="#option-cargo-add---help"></a><code>--help</code></dt>
<dd class="option-desc">Prints help information.</dd>
Expand Down
4 changes: 4 additions & 0 deletions src/doc/src/commands/cargo-bench.md
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,10 @@ See the <a href="https://rust-lang.github.io/rustup/overrides.html">rustup docum
for more information about how toolchain overrides work.</dd>


<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>
<dd class="option-desc">Overrides a Cargo configuration value.</dd>


<dt class="option-term" id="option-cargo-bench--h"><a class="option-anchor" href="#option-cargo-bench--h"></a><code>-h</code></dt>
<dt class="option-term" id="option-cargo-bench---help"><a class="option-anchor" href="#option-cargo-bench---help"></a><code>--help</code></dt>
<dd class="option-desc">Prints help information.</dd>
Expand Down
4 changes: 4 additions & 0 deletions src/doc/src/commands/cargo-build.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,10 @@ See the <a href="https://rust-lang.github.io/rustup/overrides.html">rustup docum
for more information about how toolchain overrides work.</dd>


<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>
<dd class="option-desc">Overrides a Cargo configuration value.</dd>


<dt class="option-term" id="option-cargo-build--h"><a class="option-anchor" href="#option-cargo-build--h"></a><code>-h</code></dt>
<dt class="option-term" id="option-cargo-build---help"><a class="option-anchor" href="#option-cargo-build---help"></a><code>--help</code></dt>
<dd class="option-desc">Prints help information.</dd>
Expand Down

0 comments on commit ed549d8

Please sign in to comment.