Skip to content

Commit 3d16d65

Browse files
committed
Auto merge of #13608 - epage:msrv-add, r=weihanglo
feat(add): Stabilize MSRV-aware version req selection ### What does this PR try to resolve? 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 ### How should we test and review this PR? As for determining if this is ready for stabilization: By stabilizing this without the MSRV-aware resolver, this could be confusing to the workflow with an MSRV-compatible lockfile. PR #13561 at least raises awareness of that discrepancy. In general there was interest in the RFC discussions to stabilize this ASAP, regardless of what resolver direction we went. There is an unresolved question on differences in the resolver vs `cargo add` for dealing with an unset `rust-version` (noted in the tracking issue). 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 acceptance testing but, as its UX focused, that seems fine (light, two way door) As such, this seems like it is ready to stabilize. ### Additional information
2 parents 5da2858 + 6e4e31b commit 3d16d65

File tree

10 files changed

+6
-35
lines changed

10 files changed

+6
-35
lines changed

src/bin/cargo/commands/add.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Example uses:
8787
- Depend on crates with the same name from different registries"),
8888
flag(
8989
"ignore-rust-version",
90-
"Ignore `rust-version` specification in packages (unstable)"
90+
"Ignore `rust-version` specification in packages"
9191
),
9292
])
9393
.arg_manifest_path_without_unsupported_path_tip()
@@ -206,14 +206,6 @@ pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult {
206206
let dependencies = parse_dependencies(gctx, args)?;
207207

208208
let ignore_rust_version = args.flag("ignore-rust-version");
209-
if ignore_rust_version && !gctx.cli_unstable().msrv_policy {
210-
return Err(CliError::new(
211-
anyhow::format_err!(
212-
"`--ignore-rust-version` is unstable; pass `-Zmsrv-policy` to enable support for it"
213-
),
214-
101,
215-
));
216-
}
217209
let honor_rust_version = !ignore_rust_version;
218210

219211
let options = AddOptions {

src/cargo/ops/cargo_add/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ fn get_latest_dependency(
608608
)
609609
})?;
610610

611-
if gctx.cli_unstable().msrv_policy && honor_rust_version {
611+
if honor_rust_version {
612612
let (req_msrv, is_msrv) = spec
613613
.rust_version()
614614
.cloned()

src/doc/man/cargo-add.md

-5
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,6 @@ which enables all specified features.
141141

142142
{{#option "`--ignore-rust-version`" }}
143143
Ignore `rust-version` specification in packages.
144-
145-
This option is unstable and available only on the
146-
[nightly channel](https://doc.rust-lang.org/book/appendix-07-nightly-rust.html)
147-
and requires the `-Z unstable-options` flag to enable.
148-
See <https://github.com/rust-lang/cargo/issues/5579> for more information.
149144
{{/option}}
150145

151146
{{/options}}

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

-6
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,6 @@ OPTIONS
131131
--ignore-rust-version
132132
Ignore rust-version specification in packages.
133133

134-
This option is unstable and available only on the nightly channel
135-
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
136-
requires the -Z unstable-options flag to enable. See
137-
<https://github.com/rust-lang/cargo/issues/5579> for more
138-
information.
139-
140134
Display Options
141135
-v, --verbose
142136
Use verbose output. May be specified twice for “very verbose”

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

+1-5
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,7 @@ which enables all specified features.</dd>
137137

138138

139139
<dt class="option-term" id="option-cargo-add---ignore-rust-version"><a class="option-anchor" href="#option-cargo-add---ignore-rust-version"></a><code>--ignore-rust-version</code></dt>
140-
<dd class="option-desc">Ignore <code>rust-version</code> specification in packages.</p>
141-
<p>This option is unstable and available only on the
142-
<a href="https://doc.rust-lang.org/book/appendix-07-nightly-rust.html">nightly channel</a>
143-
and requires the <code>-Z unstable-options</code> flag to enable.
144-
See <a href="https://github.com/rust-lang/cargo/issues/5579">https://github.com/rust-lang/cargo/issues/5579</a> for more information.</dd>
140+
<dd class="option-desc">Ignore <code>rust-version</code> specification in packages.</dd>
145141

146142

147143
</dl>

src/doc/src/reference/unstable.md

-2
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,6 @@ Documentation updates:
326326

327327
## msrv-policy
328328
- [#9930](https://github.com/rust-lang/cargo/issues/9930) (MSRV-aware resolver)
329-
- [#10653](https://github.com/rust-lang/cargo/issues/10653) (MSRV-aware cargo-add)
330-
- [#10903](https://github.com/rust-lang/cargo/issues/10903) (MSRV-aware cargo-install)
331329

332330
The `msrv-policy` feature enables experiments in MSRV-aware policy for cargo in
333331
preparation for an upcoming RFC.

src/etc/_cargo

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ _cargo() {
8787
'--path=[local filesystem path to crate to add]: :_directories' \
8888
'--rev=[specific commit to use when adding from git]:commit' \
8989
'--tag=[tag to use when adding from git]:tag' \
90+
'--ignore-rust-version[Ignore rust-version specification in packages]' \
9091
'1: :_guard "^-*" "crate name"' \
9192
'*:args:_default'
9293
;;

src/etc/cargo.bashcomp.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ _cargo()
4949
local opt_targets="--lib --bin --bins --example --examples --test --tests --bench --benches --all-targets"
5050

5151
local opt___nocmd="$opt_common -V --version --list --explain"
52-
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"
52+
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"
5353
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"
5454
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"
5555
local opt__b="$opt__build"

src/etc/man/cargo-add.1

-5
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,6 @@ which enables all specified features.
162162
\fB\-\-ignore\-rust\-version\fR
163163
.RS 4
164164
Ignore \fBrust\-version\fR specification in packages.
165-
.sp
166-
This option is unstable and available only on the
167-
\fInightly channel\fR <https://doc.rust\-lang.org/book/appendix\-07\-nightly\-rust.html>
168-
and requires the \fB\-Z unstable\-options\fR flag to enable.
169-
See <https://github.com/rust\-lang/cargo/issues/5579> for more information.
170165
.RE
171166
.SS "Display Options"
172167
.sp

tests/testsuite/cargo_add/help/stdout.term.svg

+1-1
Loading

0 commit comments

Comments
 (0)