diff --git a/src/bin/cargo/commands/generate_lockfile.rs b/src/bin/cargo/commands/generate_lockfile.rs index d1a95fda0..a2ddac61d 100644 --- a/src/bin/cargo/commands/generate_lockfile.rs +++ b/src/bin/cargo/commands/generate_lockfile.rs @@ -7,12 +7,23 @@ pub fn cli() -> Command { .about("Generate the lockfile for a package") .arg_silent_suggestion() .arg_manifest_path() + .arg_ignore_rust_version_with_help( + "Ignore `rust-version` specification in packages (unstable)", + ) .after_help(color_print::cstr!( "Run `cargo help generate-lockfile` for more detailed information.\n" )) } pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult { + if args.honor_rust_version().is_some() { + gctx.cli_unstable().fail_if_stable_opt_custom_z( + "--ignore-rust-version", + 9930, + "msrv-policy", + gctx.cli_unstable().msrv_policy, + )?; + } let ws = args.workspace(gctx)?; ops::generate_lockfile(&ws)?; Ok(()) diff --git a/src/bin/cargo/commands/update.rs b/src/bin/cargo/commands/update.rs index 43bd32926..fb394e4aa 100644 --- a/src/bin/cargo/commands/update.rs +++ b/src/bin/cargo/commands/update.rs @@ -42,12 +42,23 @@ pub fn cli() -> Command { .help_heading(heading::PACKAGE_SELECTION), ) .arg_manifest_path() + .arg_ignore_rust_version_with_help( + "Ignore `rust-version` specification in packages (unstable)", + ) .after_help(color_print::cstr!( "Run `cargo help update` for more detailed information.\n" )) } pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult { + if args.honor_rust_version().is_some() { + gctx.cli_unstable().fail_if_stable_opt_custom_z( + "--ignore-rust-version", + 9930, + "msrv-policy", + gctx.cli_unstable().msrv_policy, + )?; + } let ws = args.workspace(gctx)?; if args.is_present_with_zero_values("package") { diff --git a/src/cargo/util/command_prelude.rs b/src/cargo/util/command_prelude.rs index c269e65ba..0f3d3dc43 100644 --- a/src/cargo/util/command_prelude.rs +++ b/src/cargo/util/command_prelude.rs @@ -352,13 +352,11 @@ pub trait CommandExt: Sized { } fn arg_ignore_rust_version(self) -> Self { - self._arg( - flag( - "ignore-rust-version", - "Ignore `rust-version` specification in packages", - ) - .help_heading(heading::MANIFEST_OPTIONS), - ) + self.arg_ignore_rust_version_with_help("Ignore `rust-version` specification in packages") + } + + fn arg_ignore_rust_version_with_help(self, help: &'static str) -> Self { + self._arg(flag("ignore-rust-version", help).help_heading(heading::MANIFEST_OPTIONS)) } fn arg_future_incompat_report(self) -> Self { diff --git a/src/doc/man/cargo-generate-lockfile.md b/src/doc/man/cargo-generate-lockfile.md index 3a2f52b39..956cc58dc 100644 --- a/src/doc/man/cargo-generate-lockfile.md +++ b/src/doc/man/cargo-generate-lockfile.md @@ -30,6 +30,8 @@ lockfile and has more options for controlling update behavior. {{#options}} {{> options-manifest-path }} +{{> options-ignore-rust-version }} + {{> options-locked }} {{/options}} diff --git a/src/doc/man/cargo-update.md b/src/doc/man/cargo-update.md index 0e9ca371a..ce62269f9 100644 --- a/src/doc/man/cargo-update.md +++ b/src/doc/man/cargo-update.md @@ -75,6 +75,8 @@ Displays what would be updated, but doesn't actually write the lockfile. {{> options-manifest-path }} +{{> options-ignore-rust-version }} + {{> options-locked }} {{/options}} diff --git a/src/doc/man/generated_txt/cargo-generate-lockfile.txt b/src/doc/man/generated_txt/cargo-generate-lockfile.txt index d1951275e..7c925d384 100644 --- a/src/doc/man/generated_txt/cargo-generate-lockfile.txt +++ b/src/doc/man/generated_txt/cargo-generate-lockfile.txt @@ -46,6 +46,9 @@ OPTIONS Path to the Cargo.toml file. By default, Cargo searches for the Cargo.toml file in the current directory or any parent directory. + --ignore-rust-version + Ignore rust-version specification in packages. + --locked Asserts that the exact same dependencies and versions are used as when the existing Cargo.lock file was originally generated. Cargo diff --git a/src/doc/man/generated_txt/cargo-update.txt b/src/doc/man/generated_txt/cargo-update.txt index e6765c680..1d5541042 100644 --- a/src/doc/man/generated_txt/cargo-update.txt +++ b/src/doc/man/generated_txt/cargo-update.txt @@ -85,6 +85,9 @@ OPTIONS Path to the Cargo.toml file. By default, Cargo searches for the Cargo.toml file in the current directory or any parent directory. + --ignore-rust-version + Ignore rust-version specification in packages. + --locked Asserts that the exact same dependencies and versions are used as when the existing Cargo.lock file was originally generated. Cargo diff --git a/src/doc/src/commands/cargo-generate-lockfile.md b/src/doc/src/commands/cargo-generate-lockfile.md index ee52d544c..a87e86a62 100644 --- a/src/doc/src/commands/cargo-generate-lockfile.md +++ b/src/doc/src/commands/cargo-generate-lockfile.md @@ -58,6 +58,10 @@ terminal. Cargo.toml file in the current directory or any parent directory. +
--ignore-rust-version
+
Ignore rust-version specification in packages.
+ +
--locked
Asserts that the exact same dependencies and versions are used as when the existing Cargo.lock file was originally generated. Cargo will exit with an diff --git a/src/doc/src/commands/cargo-update.md b/src/doc/src/commands/cargo-update.md index 3738c7418..27a9f815d 100644 --- a/src/doc/src/commands/cargo-update.md +++ b/src/doc/src/commands/cargo-update.md @@ -100,6 +100,10 @@ terminal. Cargo.toml file in the current directory or any parent directory.
+
--ignore-rust-version
+
Ignore rust-version specification in packages.
+ +
--locked
Asserts that the exact same dependencies and versions are used as when the existing Cargo.lock file was originally generated. Cargo will exit with an diff --git a/src/etc/man/cargo-generate-lockfile.1 b/src/etc/man/cargo-generate-lockfile.1 index a436909f8..732c805a7 100644 --- a/src/etc/man/cargo-generate-lockfile.1 +++ b/src/etc/man/cargo-generate-lockfile.1 @@ -62,6 +62,11 @@ Path to the \fBCargo.toml\fR file. By default, Cargo searches for the \fBCargo.toml\fR file in the current directory or any parent directory. .RE .sp +\fB\-\-ignore\-rust\-version\fR +.RS 4 +Ignore \fBrust\-version\fR specification in packages. +.RE +.sp \fB\-\-locked\fR .RS 4 Asserts that the exact same dependencies and versions are used as when the diff --git a/src/etc/man/cargo-update.1 b/src/etc/man/cargo-update.1 index 921575fec..56407d023 100644 --- a/src/etc/man/cargo-update.1 +++ b/src/etc/man/cargo-update.1 @@ -107,6 +107,11 @@ Path to the \fBCargo.toml\fR file. By default, Cargo searches for the \fBCargo.toml\fR file in the current directory or any parent directory. .RE .sp +\fB\-\-ignore\-rust\-version\fR +.RS 4 +Ignore \fBrust\-version\fR specification in packages. +.RE +.sp \fB\-\-locked\fR .RS 4 Asserts that the exact same dependencies and versions are used as when the diff --git a/tests/testsuite/cargo_generate_lockfile/help/stdout.term.svg b/tests/testsuite/cargo_generate_lockfile/help/stdout.term.svg index 80de855fa..d116fb6d5 100644 --- a/tests/testsuite/cargo_generate_lockfile/help/stdout.term.svg +++ b/tests/testsuite/cargo_generate_lockfile/help/stdout.term.svg @@ -1,4 +1,4 @@ - +