Skip to content

Commit 6e9a833

Browse files
committed
Auto merge of #11961 - ehuss:chdir-beta, r=weihanglo
[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
2 parents 713164a + 9474349 commit 6e9a833

File tree

104 files changed

+540
-35
lines changed

Some content is hidden

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

104 files changed

+540
-35
lines changed

src/bin/cargo/cli.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,23 @@ pub fn main(config: &mut LazyConfig) -> CliResult {
3131
// This must be completed before config is initialized
3232
assert_eq!(config.is_init(), false);
3333
if let Some(new_cwd) = args.get_one::<std::path::PathBuf>("directory") {
34+
// This is a temporary hack. This cannot access `Config`, so this is a bit messy.
35+
// This does not properly parse `-Z` flags that appear after the subcommand.
36+
// The error message is not as helpful as the standard one.
37+
let nightly_features_allowed = matches!(&*features::channel(), "nightly" | "dev");
38+
if !nightly_features_allowed
39+
|| (nightly_features_allowed
40+
&& !args
41+
.get_many("unstable-features")
42+
.map(|mut z| z.any(|value: &String| value == "unstable-options"))
43+
.unwrap_or(false))
44+
{
45+
return Err(anyhow::format_err!(
46+
"the `-C` flag is unstable, \
47+
pass `-Z unstable-options` on the nightly channel to enable it"
48+
)
49+
.into());
50+
}
3451
std::env::set_current_dir(&new_cwd).context("could not change to requested directory")?;
3552
}
3653

@@ -476,7 +493,7 @@ See 'cargo help <command>' for more information on a specific command.\n",
476493
)
477494
.arg(
478495
Arg::new("directory")
479-
.help("Change to DIRECTORY before doing anything")
496+
.help("Change to DIRECTORY before doing anything (nightly-only)")
480497
.short('C')
481498
.value_name("DIRECTORY")
482499
.value_hint(clap::ValueHint::DirPath)

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,11 @@ OPTIONS
192192
for the project manifest (Cargo.toml), as well as the directories
193193
searched for discovering .cargo/config.toml, for example.
194194

195+
This option is only available on the nightly channel
196+
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
197+
requires the -Z unstable-options flag to enable (see #10098
198+
<https://github.com/rust-lang/cargo/issues/10098>).
199+
195200
-h, --help
196201
Prints help information.
197202

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,11 @@ OPTIONS
371371
for the project manifest (Cargo.toml), as well as the directories
372372
searched for discovering .cargo/config.toml, for example.
373373

374+
This option is only available on the nightly channel
375+
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
376+
requires the -Z unstable-options flag to enable (see #10098
377+
<https://github.com/rust-lang/cargo/issues/10098>).
378+
374379
-h, --help
375380
Prints help information.
376381

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,11 @@ OPTIONS
320320
for the project manifest (Cargo.toml), as well as the directories
321321
searched for discovering .cargo/config.toml, for example.
322322

323+
This option is only available on the nightly channel
324+
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
325+
requires the -Z unstable-options flag to enable (see #10098
326+
<https://github.com/rust-lang/cargo/issues/10098>).
327+
323328
-h, --help
324329
Prints help information.
325330

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,11 @@ OPTIONS
305305
for the project manifest (Cargo.toml), as well as the directories
306306
searched for discovering .cargo/config.toml, for example.
307307

308+
This option is only available on the nightly channel
309+
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
310+
requires the -Z unstable-options flag to enable (see #10098
311+
<https://github.com/rust-lang/cargo/issues/10098>).
312+
308313
-h, --help
309314
Prints help information.
310315

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ OPTIONS
134134
for the project manifest (Cargo.toml), as well as the directories
135135
searched for discovering .cargo/config.toml, for example.
136136

137+
This option is only available on the nightly channel
138+
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
139+
requires the -Z unstable-options flag to enable (see #10098
140+
<https://github.com/rust-lang/cargo/issues/10098>).
141+
137142
-h, --help
138143
Prints help information.
139144

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,11 @@ OPTIONS
276276
for the project manifest (Cargo.toml), as well as the directories
277277
searched for discovering .cargo/config.toml, for example.
278278

279+
This option is only available on the nightly channel
280+
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
281+
requires the -Z unstable-options flag to enable (see #10098
282+
<https://github.com/rust-lang/cargo/issues/10098>).
283+
279284
-h, --help
280285
Prints help information.
281286

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ OPTIONS
119119
for the project manifest (Cargo.toml), as well as the directories
120120
searched for discovering .cargo/config.toml, for example.
121121

122+
This option is only available on the nightly channel
123+
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
124+
requires the -Z unstable-options flag to enable (see #10098
125+
<https://github.com/rust-lang/cargo/issues/10098>).
126+
122127
-h, --help
123128
Prints help information.
124129

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,11 @@ OPTIONS
378378
for the project manifest (Cargo.toml), as well as the directories
379379
searched for discovering .cargo/config.toml, for example.
380380

381+
This option is only available on the nightly channel
382+
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
383+
requires the -Z unstable-options flag to enable (see #10098
384+
<https://github.com/rust-lang/cargo/issues/10098>).
385+
381386
-h, --help
382387
Prints help information.
383388

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ OPTIONS
9494
for the project manifest (Cargo.toml), as well as the directories
9595
searched for discovering .cargo/config.toml, for example.
9696

97+
This option is only available on the nightly channel
98+
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
99+
requires the -Z unstable-options flag to enable (see #10098
100+
<https://github.com/rust-lang/cargo/issues/10098>).
101+
97102
-h, --help
98103
Prints help information.
99104

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ OPTIONS
102102
for the project manifest (Cargo.toml), as well as the directories
103103
searched for discovering .cargo/config.toml, for example.
104104

105+
This option is only available on the nightly channel
106+
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
107+
requires the -Z unstable-options flag to enable (see #10098
108+
<https://github.com/rust-lang/cargo/issues/10098>).
109+
105110
-h, --help
106111
Prints help information.
107112

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,11 @@ OPTIONS
352352
for the project manifest (Cargo.toml), as well as the directories
353353
searched for discovering .cargo/config.toml, for example.
354354

355+
This option is only available on the nightly channel
356+
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
357+
requires the -Z unstable-options flag to enable (see #10098
358+
<https://github.com/rust-lang/cargo/issues/10098>).
359+
355360
-h, --help
356361
Prints help information.
357362

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ OPTIONS
8585
for the project manifest (Cargo.toml), as well as the directories
8686
searched for discovering .cargo/config.toml, for example.
8787

88+
This option is only available on the nightly channel
89+
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
90+
requires the -Z unstable-options flag to enable (see #10098
91+
<https://github.com/rust-lang/cargo/issues/10098>).
92+
8893
-h, --help
8994
Prints help information.
9095

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ OPTIONS
7777
for the project manifest (Cargo.toml), as well as the directories
7878
searched for discovering .cargo/config.toml, for example.
7979

80+
This option is only available on the nightly channel
81+
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
82+
requires the -Z unstable-options flag to enable (see #10098
83+
<https://github.com/rust-lang/cargo/issues/10098>).
84+
8085
-h, --help
8186
Prints help information.
8287

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,11 @@ OPTIONS
407407
for the project manifest (Cargo.toml), as well as the directories
408408
searched for discovering .cargo/config.toml, for example.
409409

410+
This option is only available on the nightly channel
411+
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
412+
requires the -Z unstable-options flag to enable (see #10098
413+
<https://github.com/rust-lang/cargo/issues/10098>).
414+
410415
-h, --help
411416
Prints help information.
412417

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ OPTIONS
9797
for the project manifest (Cargo.toml), as well as the directories
9898
searched for discovering .cargo/config.toml, for example.
9999

100+
This option is only available on the nightly channel
101+
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
102+
requires the -Z unstable-options flag to enable (see #10098
103+
<https://github.com/rust-lang/cargo/issues/10098>).
104+
100105
-h, --help
101106
Prints help information.
102107

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ OPTIONS
104104
for the project manifest (Cargo.toml), as well as the directories
105105
searched for discovering .cargo/config.toml, for example.
106106

107+
This option is only available on the nightly channel
108+
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
109+
requires the -Z unstable-options flag to enable (see #10098
110+
<https://github.com/rust-lang/cargo/issues/10098>).
111+
107112
-h, --help
108113
Prints help information.
109114

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,11 @@ OPTIONS
246246
for the project manifest (Cargo.toml), as well as the directories
247247
searched for discovering .cargo/config.toml, for example.
248248

249+
This option is only available on the nightly channel
250+
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
251+
requires the -Z unstable-options flag to enable (see #10098
252+
<https://github.com/rust-lang/cargo/issues/10098>).
253+
249254
-h, --help
250255
Prints help information.
251256

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ OPTIONS
124124
for the project manifest (Cargo.toml), as well as the directories
125125
searched for discovering .cargo/config.toml, for example.
126126

127+
This option is only available on the nightly channel
128+
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
129+
requires the -Z unstable-options flag to enable (see #10098
130+
<https://github.com/rust-lang/cargo/issues/10098>).
131+
127132
-h, --help
128133
Prints help information.
129134

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@ OPTIONS
212212
for the project manifest (Cargo.toml), as well as the directories
213213
searched for discovering .cargo/config.toml, for example.
214214

215+
This option is only available on the nightly channel
216+
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
217+
requires the -Z unstable-options flag to enable (see #10098
218+
<https://github.com/rust-lang/cargo/issues/10098>).
219+
215220
-h, --help
216221
Prints help information.
217222

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ OPTIONS
110110
for the project manifest (Cargo.toml), as well as the directories
111111
searched for discovering .cargo/config.toml, for example.
112112

113+
This option is only available on the nightly channel
114+
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
115+
requires the -Z unstable-options flag to enable (see #10098
116+
<https://github.com/rust-lang/cargo/issues/10098>).
117+
113118
-h, --help
114119
Prints help information.
115120

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,11 @@ OPTIONS
220220
for the project manifest (Cargo.toml), as well as the directories
221221
searched for discovering .cargo/config.toml, for example.
222222

223+
This option is only available on the nightly channel
224+
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
225+
requires the -Z unstable-options flag to enable (see #10098
226+
<https://github.com/rust-lang/cargo/issues/10098>).
227+
223228
-h, --help
224229
Prints help information.
225230

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,11 @@ OPTIONS
322322
for the project manifest (Cargo.toml), as well as the directories
323323
searched for discovering .cargo/config.toml, for example.
324324

325+
This option is only available on the nightly channel
326+
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
327+
requires the -Z unstable-options flag to enable (see #10098
328+
<https://github.com/rust-lang/cargo/issues/10098>).
329+
325330
-h, --help
326331
Prints help information.
327332

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,11 @@ OPTIONS
292292
for the project manifest (Cargo.toml), as well as the directories
293293
searched for discovering .cargo/config.toml, for example.
294294

295+
This option is only available on the nightly channel
296+
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
297+
requires the -Z unstable-options flag to enable (see #10098
298+
<https://github.com/rust-lang/cargo/issues/10098>).
299+
295300
-h, --help
296301
Prints help information.
297302

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ OPTIONS
7474
for the project manifest (Cargo.toml), as well as the directories
7575
searched for discovering .cargo/config.toml, for example.
7676

77+
This option is only available on the nightly channel
78+
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
79+
requires the -Z unstable-options flag to enable (see #10098
80+
<https://github.com/rust-lang/cargo/issues/10098>).
81+
7782
-h, --help
7883
Prints help information.
7984

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,11 @@ OPTIONS
389389
for the project manifest (Cargo.toml), as well as the directories
390390
searched for discovering .cargo/config.toml, for example.
391391

392+
This option is only available on the nightly channel
393+
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
394+
requires the -Z unstable-options flag to enable (see #10098
395+
<https://github.com/rust-lang/cargo/issues/10098>).
396+
392397
-h, --help
393398
Prints help information.
394399

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,11 @@ OPTIONS
305305
for the project manifest (Cargo.toml), as well as the directories
306306
searched for discovering .cargo/config.toml, for example.
307307

308+
This option is only available on the nightly channel
309+
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
310+
requires the -Z unstable-options flag to enable (see #10098
311+
<https://github.com/rust-lang/cargo/issues/10098>).
312+
308313
-h, --help
309314
Prints help information.
310315

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ OPTIONS
8686
for the project manifest (Cargo.toml), as well as the directories
8787
searched for discovering .cargo/config.toml, for example.
8888

89+
This option is only available on the nightly channel
90+
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
91+
requires the -Z unstable-options flag to enable (see #10098
92+
<https://github.com/rust-lang/cargo/issues/10098>).
93+
8994
-h, --help
9095
Prints help information.
9196

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ OPTIONS
124124
for the project manifest (Cargo.toml), as well as the directories
125125
searched for discovering .cargo/config.toml, for example.
126126

127+
This option is only available on the nightly channel
128+
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
129+
requires the -Z unstable-options flag to enable (see #10098
130+
<https://github.com/rust-lang/cargo/issues/10098>).
131+
127132
-h, --help
128133
Prints help information.
129134

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ OPTIONS
120120
for the project manifest (Cargo.toml), as well as the directories
121121
searched for discovering .cargo/config.toml, for example.
122122

123+
This option is only available on the nightly channel
124+
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
125+
requires the -Z unstable-options flag to enable (see #10098
126+
<https://github.com/rust-lang/cargo/issues/10098>).
127+
123128
-h, --help
124129
Prints help information.
125130

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ OPTIONS
9797
for the project manifest (Cargo.toml), as well as the directories
9898
searched for discovering .cargo/config.toml, for example.
9999

100+
This option is only available on the nightly channel
101+
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
102+
requires the -Z unstable-options flag to enable (see #10098
103+
<https://github.com/rust-lang/cargo/issues/10098>).
104+
100105
-h, --help
101106
Prints help information.
102107

0 commit comments

Comments
 (0)