Skip to content

Commit 7dc84a2

Browse files
committed
Auto merge of #13742 - epage:msrv-update, r=Muscraft
feat(cli): Add --ignore-rust-version to update/generate-lockfile ### What does this PR try to resolve? This is part of #9930 and extends `--ignore-rust-version` to `cargo update` and `cargo generate-lockfile` ### How should we test and review this PR? First commit sets up tests ### Additional information
2 parents 7ac5d58 + c7d89c6 commit 7dc84a2

File tree

14 files changed

+195
-21
lines changed

14 files changed

+195
-21
lines changed

src/bin/cargo/commands/generate_lockfile.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,23 @@ pub fn cli() -> Command {
77
.about("Generate the lockfile for a package")
88
.arg_silent_suggestion()
99
.arg_manifest_path()
10+
.arg_ignore_rust_version_with_help(
11+
"Ignore `rust-version` specification in packages (unstable)",
12+
)
1013
.after_help(color_print::cstr!(
1114
"Run `<cyan,bold>cargo help generate-lockfile</>` for more detailed information.\n"
1215
))
1316
}
1417

1518
pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult {
19+
if args.honor_rust_version().is_some() {
20+
gctx.cli_unstable().fail_if_stable_opt_custom_z(
21+
"--ignore-rust-version",
22+
9930,
23+
"msrv-policy",
24+
gctx.cli_unstable().msrv_policy,
25+
)?;
26+
}
1627
let ws = args.workspace(gctx)?;
1728
ops::generate_lockfile(&ws)?;
1829
Ok(())

src/bin/cargo/commands/update.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,23 @@ pub fn cli() -> Command {
4242
.help_heading(heading::PACKAGE_SELECTION),
4343
)
4444
.arg_manifest_path()
45+
.arg_ignore_rust_version_with_help(
46+
"Ignore `rust-version` specification in packages (unstable)",
47+
)
4548
.after_help(color_print::cstr!(
4649
"Run `<cyan,bold>cargo help update</>` for more detailed information.\n"
4750
))
4851
}
4952

5053
pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult {
54+
if args.honor_rust_version().is_some() {
55+
gctx.cli_unstable().fail_if_stable_opt_custom_z(
56+
"--ignore-rust-version",
57+
9930,
58+
"msrv-policy",
59+
gctx.cli_unstable().msrv_policy,
60+
)?;
61+
}
5162
let ws = args.workspace(gctx)?;
5263

5364
if args.is_present_with_zero_values("package") {

src/cargo/util/command_prelude.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -352,13 +352,11 @@ pub trait CommandExt: Sized {
352352
}
353353

354354
fn arg_ignore_rust_version(self) -> Self {
355-
self._arg(
356-
flag(
357-
"ignore-rust-version",
358-
"Ignore `rust-version` specification in packages",
359-
)
360-
.help_heading(heading::MANIFEST_OPTIONS),
361-
)
355+
self.arg_ignore_rust_version_with_help("Ignore `rust-version` specification in packages")
356+
}
357+
358+
fn arg_ignore_rust_version_with_help(self, help: &'static str) -> Self {
359+
self._arg(flag("ignore-rust-version", help).help_heading(heading::MANIFEST_OPTIONS))
362360
}
363361

364362
fn arg_future_incompat_report(self) -> Self {

src/doc/man/cargo-generate-lockfile.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ lockfile and has more options for controlling update behavior.
3030
{{#options}}
3131
{{> options-manifest-path }}
3232

33+
{{> options-ignore-rust-version }}
34+
3335
{{> options-locked }}
3436
{{/options}}
3537

src/doc/man/cargo-update.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ Displays what would be updated, but doesn't actually write the lockfile.
7575

7676
{{> options-manifest-path }}
7777

78+
{{> options-ignore-rust-version }}
79+
7880
{{> options-locked }}
7981

8082
{{/options}}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ OPTIONS
4646
Path to the Cargo.toml file. By default, Cargo searches for the
4747
Cargo.toml file in the current directory or any parent directory.
4848

49+
--ignore-rust-version
50+
Ignore rust-version specification in packages.
51+
4952
--locked
5053
Asserts that the exact same dependencies and versions are used as
5154
when the existing Cargo.lock file was originally generated. Cargo

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ OPTIONS
8585
Path to the Cargo.toml file. By default, Cargo searches for the
8686
Cargo.toml file in the current directory or any parent directory.
8787

88+
--ignore-rust-version
89+
Ignore rust-version specification in packages.
90+
8891
--locked
8992
Asserts that the exact same dependencies and versions are used as
9093
when the existing Cargo.lock file was originally generated. Cargo

src/doc/src/commands/cargo-generate-lockfile.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ terminal.</li>
5858
<code>Cargo.toml</code> file in the current directory or any parent directory.</dd>
5959

6060

61+
<dt class="option-term" id="option-cargo-generate-lockfile---ignore-rust-version"><a class="option-anchor" href="#option-cargo-generate-lockfile---ignore-rust-version"></a><code>--ignore-rust-version</code></dt>
62+
<dd class="option-desc">Ignore <code>rust-version</code> specification in packages.</dd>
63+
64+
6165
<dt class="option-term" id="option-cargo-generate-lockfile---locked"><a class="option-anchor" href="#option-cargo-generate-lockfile---locked"></a><code>--locked</code></dt>
6266
<dd class="option-desc">Asserts that the exact same dependencies and versions are used as when the
6367
existing <code>Cargo.lock</code> file was originally generated. Cargo will exit with an

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ terminal.</li>
100100
<code>Cargo.toml</code> file in the current directory or any parent directory.</dd>
101101

102102

103+
<dt class="option-term" id="option-cargo-update---ignore-rust-version"><a class="option-anchor" href="#option-cargo-update---ignore-rust-version"></a><code>--ignore-rust-version</code></dt>
104+
<dd class="option-desc">Ignore <code>rust-version</code> specification in packages.</dd>
105+
106+
103107
<dt class="option-term" id="option-cargo-update---locked"><a class="option-anchor" href="#option-cargo-update---locked"></a><code>--locked</code></dt>
104108
<dd class="option-desc">Asserts that the exact same dependencies and versions are used as when the
105109
existing <code>Cargo.lock</code> file was originally generated. Cargo will exit with an

src/etc/man/cargo-generate-lockfile.1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ Path to the \fBCargo.toml\fR file. By default, Cargo searches for the
6262
\fBCargo.toml\fR file in the current directory or any parent directory.
6363
.RE
6464
.sp
65+
\fB\-\-ignore\-rust\-version\fR
66+
.RS 4
67+
Ignore \fBrust\-version\fR specification in packages.
68+
.RE
69+
.sp
6570
\fB\-\-locked\fR
6671
.RS 4
6772
Asserts that the exact same dependencies and versions are used as when the

0 commit comments

Comments
 (0)