Skip to content

Commit

Permalink
Auto merge of #11961 - ehuss:chdir-beta, r=weihanglo
Browse files Browse the repository at this point in the history
[beta 1.69] Change -C to be unstable

Beta backport of #11960.

This also includes some other changes to get CI passing:

#11916 — Disable test_profile test on windows-gnu
Ignored some tests due to a change in clap output
  • Loading branch information
bors committed Apr 12, 2023
2 parents 713164a + 9474349 commit 6e9a833
Show file tree
Hide file tree
Showing 104 changed files with 540 additions and 35 deletions.
19 changes: 18 additions & 1 deletion src/bin/cargo/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@ pub fn main(config: &mut LazyConfig) -> CliResult {
// This must be completed before config is initialized
assert_eq!(config.is_init(), false);
if let Some(new_cwd) = args.get_one::<std::path::PathBuf>("directory") {
// This is a temporary hack. This cannot access `Config`, so this is a bit messy.
// This does not properly parse `-Z` flags that appear after the subcommand.
// The error message is not as helpful as the standard one.
let nightly_features_allowed = matches!(&*features::channel(), "nightly" | "dev");
if !nightly_features_allowed
|| (nightly_features_allowed
&& !args
.get_many("unstable-features")
.map(|mut z| z.any(|value: &String| value == "unstable-options"))
.unwrap_or(false))
{
return Err(anyhow::format_err!(
"the `-C` flag is unstable, \
pass `-Z unstable-options` on the nightly channel to enable it"
)
.into());
}
std::env::set_current_dir(&new_cwd).context("could not change to requested directory")?;
}

Expand Down Expand Up @@ -476,7 +493,7 @@ See 'cargo help <command>' for more information on a specific command.\n",
)
.arg(
Arg::new("directory")
.help("Change to DIRECTORY before doing anything")
.help("Change to DIRECTORY before doing anything (nightly-only)")
.short('C')
.value_name("DIRECTORY")
.value_hint(clap::ValueHint::DirPath)
Expand Down
5 changes: 5 additions & 0 deletions src/doc/man/generated_txt/cargo-add.txt
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ OPTIONS
for the project manifest (Cargo.toml), as well as the directories
searched for discovering .cargo/config.toml, for example.

This option is only available on the nightly channel
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
requires the -Z unstable-options flag to enable (see #10098
<https://github.com/rust-lang/cargo/issues/10098>).

-h, --help
Prints help information.

Expand Down
5 changes: 5 additions & 0 deletions src/doc/man/generated_txt/cargo-bench.txt
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,11 @@ OPTIONS
for the project manifest (Cargo.toml), as well as the directories
searched for discovering .cargo/config.toml, for example.

This option is only available on the nightly channel
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
requires the -Z unstable-options flag to enable (see #10098
<https://github.com/rust-lang/cargo/issues/10098>).

-h, --help
Prints help information.

Expand Down
5 changes: 5 additions & 0 deletions src/doc/man/generated_txt/cargo-build.txt
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,11 @@ OPTIONS
for the project manifest (Cargo.toml), as well as the directories
searched for discovering .cargo/config.toml, for example.

This option is only available on the nightly channel
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
requires the -Z unstable-options flag to enable (see #10098
<https://github.com/rust-lang/cargo/issues/10098>).

-h, --help
Prints help information.

Expand Down
5 changes: 5 additions & 0 deletions src/doc/man/generated_txt/cargo-check.txt
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,11 @@ OPTIONS
for the project manifest (Cargo.toml), as well as the directories
searched for discovering .cargo/config.toml, for example.

This option is only available on the nightly channel
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
requires the -Z unstable-options flag to enable (see #10098
<https://github.com/rust-lang/cargo/issues/10098>).

-h, --help
Prints help information.

Expand Down
5 changes: 5 additions & 0 deletions src/doc/man/generated_txt/cargo-clean.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ OPTIONS
for the project manifest (Cargo.toml), as well as the directories
searched for discovering .cargo/config.toml, for example.

This option is only available on the nightly channel
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
requires the -Z unstable-options flag to enable (see #10098
<https://github.com/rust-lang/cargo/issues/10098>).

-h, --help
Prints help information.

Expand Down
5 changes: 5 additions & 0 deletions src/doc/man/generated_txt/cargo-doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@ OPTIONS
for the project manifest (Cargo.toml), as well as the directories
searched for discovering .cargo/config.toml, for example.

This option is only available on the nightly channel
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
requires the -Z unstable-options flag to enable (see #10098
<https://github.com/rust-lang/cargo/issues/10098>).

-h, --help
Prints help information.

Expand Down
5 changes: 5 additions & 0 deletions src/doc/man/generated_txt/cargo-fetch.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ OPTIONS
for the project manifest (Cargo.toml), as well as the directories
searched for discovering .cargo/config.toml, for example.

This option is only available on the nightly channel
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
requires the -Z unstable-options flag to enable (see #10098
<https://github.com/rust-lang/cargo/issues/10098>).

-h, --help
Prints help information.

Expand Down
5 changes: 5 additions & 0 deletions src/doc/man/generated_txt/cargo-fix.txt
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,11 @@ OPTIONS
for the project manifest (Cargo.toml), as well as the directories
searched for discovering .cargo/config.toml, for example.

This option is only available on the nightly channel
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
requires the -Z unstable-options flag to enable (see #10098
<https://github.com/rust-lang/cargo/issues/10098>).

-h, --help
Prints help information.

Expand Down
5 changes: 5 additions & 0 deletions src/doc/man/generated_txt/cargo-generate-lockfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ OPTIONS
for the project manifest (Cargo.toml), as well as the directories
searched for discovering .cargo/config.toml, for example.

This option is only available on the nightly channel
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
requires the -Z unstable-options flag to enable (see #10098
<https://github.com/rust-lang/cargo/issues/10098>).

-h, --help
Prints help information.

Expand Down
5 changes: 5 additions & 0 deletions src/doc/man/generated_txt/cargo-init.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ OPTIONS
for the project manifest (Cargo.toml), as well as the directories
searched for discovering .cargo/config.toml, for example.

This option is only available on the nightly channel
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
requires the -Z unstable-options flag to enable (see #10098
<https://github.com/rust-lang/cargo/issues/10098>).

-h, --help
Prints help information.

Expand Down
5 changes: 5 additions & 0 deletions src/doc/man/generated_txt/cargo-install.txt
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,11 @@ OPTIONS
for the project manifest (Cargo.toml), as well as the directories
searched for discovering .cargo/config.toml, for example.

This option is only available on the nightly channel
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
requires the -Z unstable-options flag to enable (see #10098
<https://github.com/rust-lang/cargo/issues/10098>).

-h, --help
Prints help information.

Expand Down
5 changes: 5 additions & 0 deletions src/doc/man/generated_txt/cargo-locate-project.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ OPTIONS
for the project manifest (Cargo.toml), as well as the directories
searched for discovering .cargo/config.toml, for example.

This option is only available on the nightly channel
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
requires the -Z unstable-options flag to enable (see #10098
<https://github.com/rust-lang/cargo/issues/10098>).

-h, --help
Prints help information.

Expand Down
5 changes: 5 additions & 0 deletions src/doc/man/generated_txt/cargo-login.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ OPTIONS
for the project manifest (Cargo.toml), as well as the directories
searched for discovering .cargo/config.toml, for example.

This option is only available on the nightly channel
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
requires the -Z unstable-options flag to enable (see #10098
<https://github.com/rust-lang/cargo/issues/10098>).

-h, --help
Prints help information.

Expand Down
5 changes: 5 additions & 0 deletions src/doc/man/generated_txt/cargo-metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,11 @@ OPTIONS
for the project manifest (Cargo.toml), as well as the directories
searched for discovering .cargo/config.toml, for example.

This option is only available on the nightly channel
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
requires the -Z unstable-options flag to enable (see #10098
<https://github.com/rust-lang/cargo/issues/10098>).

-h, --help
Prints help information.

Expand Down
5 changes: 5 additions & 0 deletions src/doc/man/generated_txt/cargo-new.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ OPTIONS
for the project manifest (Cargo.toml), as well as the directories
searched for discovering .cargo/config.toml, for example.

This option is only available on the nightly channel
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
requires the -Z unstable-options flag to enable (see #10098
<https://github.com/rust-lang/cargo/issues/10098>).

-h, --help
Prints help information.

Expand Down
5 changes: 5 additions & 0 deletions src/doc/man/generated_txt/cargo-owner.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ OPTIONS
for the project manifest (Cargo.toml), as well as the directories
searched for discovering .cargo/config.toml, for example.

This option is only available on the nightly channel
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
requires the -Z unstable-options flag to enable (see #10098
<https://github.com/rust-lang/cargo/issues/10098>).

-h, --help
Prints help information.

Expand Down
5 changes: 5 additions & 0 deletions src/doc/man/generated_txt/cargo-package.txt
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@ OPTIONS
for the project manifest (Cargo.toml), as well as the directories
searched for discovering .cargo/config.toml, for example.

This option is only available on the nightly channel
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
requires the -Z unstable-options flag to enable (see #10098
<https://github.com/rust-lang/cargo/issues/10098>).

-h, --help
Prints help information.

Expand Down
5 changes: 5 additions & 0 deletions src/doc/man/generated_txt/cargo-pkgid.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ OPTIONS
for the project manifest (Cargo.toml), as well as the directories
searched for discovering .cargo/config.toml, for example.

This option is only available on the nightly channel
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
requires the -Z unstable-options flag to enable (see #10098
<https://github.com/rust-lang/cargo/issues/10098>).

-h, --help
Prints help information.

Expand Down
5 changes: 5 additions & 0 deletions src/doc/man/generated_txt/cargo-publish.txt
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ OPTIONS
for the project manifest (Cargo.toml), as well as the directories
searched for discovering .cargo/config.toml, for example.

This option is only available on the nightly channel
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
requires the -Z unstable-options flag to enable (see #10098
<https://github.com/rust-lang/cargo/issues/10098>).

-h, --help
Prints help information.

Expand Down
5 changes: 5 additions & 0 deletions src/doc/man/generated_txt/cargo-remove.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ OPTIONS
for the project manifest (Cargo.toml), as well as the directories
searched for discovering .cargo/config.toml, for example.

This option is only available on the nightly channel
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
requires the -Z unstable-options flag to enable (see #10098
<https://github.com/rust-lang/cargo/issues/10098>).

-h, --help
Prints help information.

Expand Down
5 changes: 5 additions & 0 deletions src/doc/man/generated_txt/cargo-run.txt
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@ OPTIONS
for the project manifest (Cargo.toml), as well as the directories
searched for discovering .cargo/config.toml, for example.

This option is only available on the nightly channel
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
requires the -Z unstable-options flag to enable (see #10098
<https://github.com/rust-lang/cargo/issues/10098>).

-h, --help
Prints help information.

Expand Down
5 changes: 5 additions & 0 deletions src/doc/man/generated_txt/cargo-rustc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,11 @@ OPTIONS
for the project manifest (Cargo.toml), as well as the directories
searched for discovering .cargo/config.toml, for example.

This option is only available on the nightly channel
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
requires the -Z unstable-options flag to enable (see #10098
<https://github.com/rust-lang/cargo/issues/10098>).

-h, --help
Prints help information.

Expand Down
5 changes: 5 additions & 0 deletions src/doc/man/generated_txt/cargo-rustdoc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,11 @@ OPTIONS
for the project manifest (Cargo.toml), as well as the directories
searched for discovering .cargo/config.toml, for example.

This option is only available on the nightly channel
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
requires the -Z unstable-options flag to enable (see #10098
<https://github.com/rust-lang/cargo/issues/10098>).

-h, --help
Prints help information.

Expand Down
5 changes: 5 additions & 0 deletions src/doc/man/generated_txt/cargo-search.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ OPTIONS
for the project manifest (Cargo.toml), as well as the directories
searched for discovering .cargo/config.toml, for example.

This option is only available on the nightly channel
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
requires the -Z unstable-options flag to enable (see #10098
<https://github.com/rust-lang/cargo/issues/10098>).

-h, --help
Prints help information.

Expand Down
5 changes: 5 additions & 0 deletions src/doc/man/generated_txt/cargo-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,11 @@ OPTIONS
for the project manifest (Cargo.toml), as well as the directories
searched for discovering .cargo/config.toml, for example.

This option is only available on the nightly channel
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
requires the -Z unstable-options flag to enable (see #10098
<https://github.com/rust-lang/cargo/issues/10098>).

-h, --help
Prints help information.

Expand Down
5 changes: 5 additions & 0 deletions src/doc/man/generated_txt/cargo-tree.txt
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,11 @@ OPTIONS
for the project manifest (Cargo.toml), as well as the directories
searched for discovering .cargo/config.toml, for example.

This option is only available on the nightly channel
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
requires the -Z unstable-options flag to enable (see #10098
<https://github.com/rust-lang/cargo/issues/10098>).

-h, --help
Prints help information.

Expand Down
5 changes: 5 additions & 0 deletions src/doc/man/generated_txt/cargo-uninstall.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ OPTIONS
for the project manifest (Cargo.toml), as well as the directories
searched for discovering .cargo/config.toml, for example.

This option is only available on the nightly channel
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
requires the -Z unstable-options flag to enable (see #10098
<https://github.com/rust-lang/cargo/issues/10098>).

-h, --help
Prints help information.

Expand Down
5 changes: 5 additions & 0 deletions src/doc/man/generated_txt/cargo-update.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ OPTIONS
for the project manifest (Cargo.toml), as well as the directories
searched for discovering .cargo/config.toml, for example.

This option is only available on the nightly channel
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
requires the -Z unstable-options flag to enable (see #10098
<https://github.com/rust-lang/cargo/issues/10098>).

-h, --help
Prints help information.

Expand Down
5 changes: 5 additions & 0 deletions src/doc/man/generated_txt/cargo-vendor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ OPTIONS
for the project manifest (Cargo.toml), as well as the directories
searched for discovering .cargo/config.toml, for example.

This option is only available on the nightly channel
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
requires the -Z unstable-options flag to enable (see #10098
<https://github.com/rust-lang/cargo/issues/10098>).

-h, --help
Prints help information.

Expand Down
5 changes: 5 additions & 0 deletions src/doc/man/generated_txt/cargo-verify-project.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ OPTIONS
for the project manifest (Cargo.toml), as well as the directories
searched for discovering .cargo/config.toml, for example.

This option is only available on the nightly channel
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
requires the -Z unstable-options flag to enable (see #10098
<https://github.com/rust-lang/cargo/issues/10098>).

-h, --help
Prints help information.

Expand Down
Loading

0 comments on commit 6e9a833

Please sign in to comment.