From 80124ada8fb5f6329748caeef023d4161ed9b753 Mon Sep 17 00:00:00 2001
From: Ed Page
Date: Wed, 20 Mar 2024 11:19:00 -0500
Subject: [PATCH 1/2] feat(cli): Add shell completions for 'cargo add
-ignore-rust-version'
---
src/etc/_cargo | 1 +
src/etc/cargo.bashcomp.sh | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/etc/_cargo b/src/etc/_cargo
index 7fb3352523d..aab5c98d958 100644
--- a/src/etc/_cargo
+++ b/src/etc/_cargo
@@ -87,6 +87,7 @@ _cargo() {
'--path=[local filesystem path to crate to add]: :_directories' \
'--rev=[specific commit to use when adding from git]:commit' \
'--tag=[tag to use when adding from git]:tag' \
+ '--ignore-rust-version[Ignore rust-version specification in packages]' \
'1: :_guard "^-*" "crate name"' \
'*:args:_default'
;;
diff --git a/src/etc/cargo.bashcomp.sh b/src/etc/cargo.bashcomp.sh
index dad16dd99e3..398fc6f9fad 100644
--- a/src/etc/cargo.bashcomp.sh
+++ b/src/etc/cargo.bashcomp.sh
@@ -49,7 +49,7 @@ _cargo()
local opt_targets="--lib --bin --bins --example --examples --test --tests --bench --benches --all-targets"
local opt___nocmd="$opt_common -V --version --list --explain"
- local opt__add="$opt_common -p --package --features --default-features --no-default-features $opt_mani --optional --no-optional --rename --dry-run --path --git --branch --tag --rev --registry --dev --build --target"
+ local opt__add="$opt_common -p --package --features --default-features --no-default-features $opt_mani --optional --no-optional --rename --dry-run --path --git --branch --tag --rev --registry --dev --build --target --ignore-rust-version"
local opt__bench="$opt_common $opt_pkg_spec $opt_feat $opt_mani $opt_lock $opt_jobs $opt_targets --message-format --target --no-run --no-fail-fast --target-dir --ignore-rust-version"
local opt__build="$opt_common $opt_pkg_spec $opt_feat $opt_mani $opt_lock $opt_parallel $opt_targets --message-format --target --release --profile --target-dir --ignore-rust-version"
local opt__b="$opt__build"
From 6e4e31bec05bf707f0e4123caa748174ba5d957f Mon Sep 17 00:00:00 2001
From: Ed Page
Date: Wed, 20 Mar 2024 10:42:08 -0500
Subject: [PATCH 2/2] feat(add): Stabilize MSRV-aware version req selection
This is part of #9930 for rust-lang/rfcs#3537
This will make it easier to maintain an MSRV-compliant `Cargo.toml` but
leaves validation up to the user as the resolver will pick newer
versions.
This helps the MSRV-aware workflows enumerated in
rust-lang/rfcs#3537 though it could be confusing to the workflow with an
MSRV-compatible lockfile.
PR #13561 at least raises awareness of that discrepancy.
There is an unresolved question on differences in the resolver vs
`cargo add` for dealing with an unset `rust-version`.
However, we are only stabilizing the `cargo add` side which is a very
light two-way door as this is a UX-focused command and not a
programmatic command.
This hasn't gotten much end-user testing but, as its UX focused, that
seems fine.
As such, this seems like it is ready to stabilize.
---
src/bin/cargo/commands/add.rs | 10 +---------
src/cargo/ops/cargo_add/mod.rs | 2 +-
src/doc/man/cargo-add.md | 5 -----
src/doc/man/generated_txt/cargo-add.txt | 6 ------
src/doc/src/commands/cargo-add.md | 6 +-----
src/doc/src/reference/unstable.md | 2 --
src/etc/man/cargo-add.1 | 5 -----
tests/testsuite/cargo_add/help/stdout.term.svg | 2 +-
8 files changed, 4 insertions(+), 34 deletions(-)
diff --git a/src/bin/cargo/commands/add.rs b/src/bin/cargo/commands/add.rs
index ca75e734622..b1bde446bfe 100644
--- a/src/bin/cargo/commands/add.rs
+++ b/src/bin/cargo/commands/add.rs
@@ -87,7 +87,7 @@ Example uses:
- Depend on crates with the same name from different registries"),
flag(
"ignore-rust-version",
- "Ignore `rust-version` specification in packages (unstable)"
+ "Ignore `rust-version` specification in packages"
),
])
.arg_manifest_path_without_unsupported_path_tip()
@@ -206,14 +206,6 @@ pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult {
let dependencies = parse_dependencies(gctx, args)?;
let ignore_rust_version = args.flag("ignore-rust-version");
- if ignore_rust_version && !gctx.cli_unstable().msrv_policy {
- return Err(CliError::new(
- anyhow::format_err!(
- "`--ignore-rust-version` is unstable; pass `-Zmsrv-policy` to enable support for it"
- ),
- 101,
- ));
- }
let honor_rust_version = !ignore_rust_version;
let options = AddOptions {
diff --git a/src/cargo/ops/cargo_add/mod.rs b/src/cargo/ops/cargo_add/mod.rs
index 0902b552815..a0232bda8ac 100644
--- a/src/cargo/ops/cargo_add/mod.rs
+++ b/src/cargo/ops/cargo_add/mod.rs
@@ -608,7 +608,7 @@ fn get_latest_dependency(
)
})?;
- if gctx.cli_unstable().msrv_policy && honor_rust_version {
+ if honor_rust_version {
let (req_msrv, is_msrv) = spec
.rust_version()
.cloned()
diff --git a/src/doc/man/cargo-add.md b/src/doc/man/cargo-add.md
index 3c7adec4e04..d773004a7d2 100644
--- a/src/doc/man/cargo-add.md
+++ b/src/doc/man/cargo-add.md
@@ -141,11 +141,6 @@ which enables all specified features.
{{#option "`--ignore-rust-version`" }}
Ignore `rust-version` specification in packages.
-
-This option is unstable and available only 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 for more information.
{{/option}}
{{/options}}
diff --git a/src/doc/man/generated_txt/cargo-add.txt b/src/doc/man/generated_txt/cargo-add.txt
index 83e1dda7de2..b3ea38207f3 100644
--- a/src/doc/man/generated_txt/cargo-add.txt
+++ b/src/doc/man/generated_txt/cargo-add.txt
@@ -131,12 +131,6 @@ OPTIONS
--ignore-rust-version
Ignore rust-version specification in packages.
- This option is unstable and available only on the nightly channel
- and
- requires the -Z unstable-options flag to enable. See
- for more
- information.
-
Display Options
-v, --verbose
Use verbose output. May be specified twice for “very verbose”
diff --git a/src/doc/src/commands/cargo-add.md b/src/doc/src/commands/cargo-add.md
index 80fb05615ac..43b7998723d 100644
--- a/src/doc/src/commands/cargo-add.md
+++ b/src/doc/src/commands/cargo-add.md
@@ -137,11 +137,7 @@ which enables all specified features.
--ignore-rust-version
-Ignore rust-version
specification in packages.
-This option is unstable and available only on the
-nightly channel
-and requires the -Z unstable-options
flag to enable.
-See https://github.com/rust-lang/cargo/issues/5579 for more information.
+
Ignore rust-version
specification in packages.
diff --git a/src/doc/src/reference/unstable.md b/src/doc/src/reference/unstable.md
index 5ead28787da..bacd2bccb91 100644
--- a/src/doc/src/reference/unstable.md
+++ b/src/doc/src/reference/unstable.md
@@ -326,8 +326,6 @@ Documentation updates:
## msrv-policy
- [#9930](https://github.com/rust-lang/cargo/issues/9930) (MSRV-aware resolver)
-- [#10653](https://github.com/rust-lang/cargo/issues/10653) (MSRV-aware cargo-add)
-- [#10903](https://github.com/rust-lang/cargo/issues/10903) (MSRV-aware cargo-install)
The `msrv-policy` feature enables experiments in MSRV-aware policy for cargo in
preparation for an upcoming RFC.
diff --git a/src/etc/man/cargo-add.1 b/src/etc/man/cargo-add.1
index 49cd2fba9b5..0cd2ebda278 100644
--- a/src/etc/man/cargo-add.1
+++ b/src/etc/man/cargo-add.1
@@ -162,11 +162,6 @@ which enables all specified features.
\fB\-\-ignore\-rust\-version\fR
.RS 4
Ignore \fBrust\-version\fR specification in packages.
-.sp
-This option is unstable and available only on the
-\fInightly channel\fR
-and requires the \fB\-Z unstable\-options\fR flag to enable.
-See for more information.
.RE
.SS "Display Options"
.sp
diff --git a/tests/testsuite/cargo_add/help/stdout.term.svg b/tests/testsuite/cargo_add/help/stdout.term.svg
index 729a83c6c52..59cc01542aa 100644
--- a/tests/testsuite/cargo_add/help/stdout.term.svg
+++ b/tests/testsuite/cargo_add/help/stdout.term.svg
@@ -125,7 +125,7 @@
--ignore-rust-version
- Ignore `rust-version` specification in packages (unstable)
+ Ignore `rust-version` specification in packages