Skip to content

Commit f2f4496

Browse files
committed
Auto merge of #11859 - chaitanyav:master, r=weihanglo
Add --ignore-rust-version flag to cargo install `@weihanglo` Added the flag to cargo install fixes #11718
2 parents c9faf70 + f5c699e commit f2f4496

File tree

7 files changed

+41
-11
lines changed

7 files changed

+41
-11
lines changed

src/bin/cargo/commands/install.rs

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ pub fn cli() -> Command {
8080
.requires("crate")
8181
.conflicts_with_all(&["git", "path", "index"]),
8282
)
83+
.arg_ignore_rust_version()
8384
.arg_message_format()
8485
.arg_timings()
8586
.after_help("Run `cargo help install` for more detailed information.\n")

src/doc/man/cargo-install.md

+2
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ See also the `--profile` option for choosing a specific profile by name.
179179

180180
{{> options-profile }}
181181

182+
{{> options-ignore-rust-version }}
183+
182184
{{> options-timings }}
183185

184186
{{/options}}

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

+5
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,11 @@ OPTIONS
215215
<https://doc.rust-lang.org/cargo/reference/profiles.html> for more
216216
details on profiles.
217217

218+
--ignore-rust-version
219+
Install the target even if the selected Rust compiler is older than
220+
the required Rust version as configured in the project’s
221+
rust-version field.
222+
218223
--timings=fmts
219224
Output information how long each compilation takes, and track
220225
concurrency information over time. Accepts an optional

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

+6
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,12 @@ See the <a href="../reference/profiles.html">the reference</a> for more details
248248

249249

250250

251+
<dt class="option-term" id="option-cargo-install---ignore-rust-version"><a class="option-anchor" href="#option-cargo-install---ignore-rust-version"></a><code>--ignore-rust-version</code></dt>
252+
<dd class="option-desc">Install the target even if the selected Rust compiler is older than the
253+
required Rust version as configured in the project’s <code>rust-version</code> field.</dd>
254+
255+
256+
251257
<dt class="option-term" id="option-cargo-install---timings=fmts"><a class="option-anchor" href="#option-cargo-install---timings=fmts"></a><code>--timings=</code><em>fmts</em></dt>
252258
<dd class="option-desc">Output information how long each compilation takes, and track concurrency
253259
information over time. Accepts an optional comma-separated list of output

src/etc/_cargo

+11-1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ _cargo() {
9494
'(-p --package)'{-p+,--package=}'[specify package to run benchmarks for]:package:_cargo_package_names' \
9595
'--exclude=[exclude packages from the benchmark]:spec' \
9696
'--no-fail-fast[run all benchmarks regardless of failure]' \
97+
'--ignore-rust-version[Ignore rust-version specification in packages]' \
9798
'1: :_guard "^-*" "bench name"' \
9899
'*:args:_default'
99100
;;
@@ -105,6 +106,7 @@ _cargo() {
105106
'(-p --package)'{-p+,--package=}'[specify package to build]:package:_cargo_package_names' \
106107
'--release[build in release mode]' \
107108
'--build-plan[output the build plan in JSON]' \
109+
'--ignore-rust-version[Ignore rust-version specification in packages]'
108110
;;
109111

110112
check | c)
@@ -113,6 +115,7 @@ _cargo() {
113115
"${command_scope_spec[@]}" \
114116
'(-p --package)'{-p+,--package=}'[specify package to check]:package:_cargo_package_names' \
115117
'--release[check in release mode]' \
118+
'--ignore-rust-version[Ignore rust-version specification in packages]'
116119
;;
117120

118121
clean)
@@ -129,6 +132,7 @@ _cargo() {
129132
'--open[open docs in browser after the build]' \
130133
'(-p --package)'{-p+,--package=}'[specify package to document]:package:_cargo_package_names' \
131134
'--release[build artifacts in release mode, with optimizations]' \
135+
'--ignore-rust-version[Ignore rust-version specification in packages]'
132136
;;
133137

134138
fetch)
@@ -143,7 +147,8 @@ _cargo() {
143147
'--edition-idioms[fix warnings to migrate to the idioms of an edition]' \
144148
'--allow-no-vcs[fix code even if a VCS was not detected]' \
145149
'--allow-dirty[fix code even if the working directory is dirty]' \
146-
'--allow-staged[fix code even if the working directory has staged changes]'
150+
'--allow-staged[fix code even if the working directory has staged changes]' \
151+
'--ignore-rust-version[Ignore rust-version specification in packages]'
147152
;;
148153

149154
generate-lockfile)
@@ -177,6 +182,7 @@ _cargo() {
177182
'--tag=[tag to use when installing from git]:tag' \
178183
'--version=[version to install from crates.io]:version' \
179184
'--list[list all installed packages and their versions]' \
185+
'--ignore-rust-version[Ignore rust-version specification in packages]' \
180186
'*: :_guard "^-*" "crate"'
181187
;;
182188

@@ -258,6 +264,7 @@ _cargo() {
258264
'--bin=[name of the bin target]:name' \
259265
'(-p --package)'{-p+,--package=}'[specify package with the target to run]:package:_cargo_package_names' \
260266
'--release[build in release mode]' \
267+
'--ignore-rust-version[Ignore rust-version specification in packages]' \
261268
'*: :_default'
262269
;;
263270

@@ -267,6 +274,7 @@ _cargo() {
267274
'--profile=[specify profile to build the selected target for]:profile' \
268275
'--release[build artifacts in release mode, with optimizations]' \
269276
"${command_scope_spec[@]}" \
277+
'--ignore-rust-version[Ignore rust-version specification in packages]' \
270278
'*: : _dispatch rustc rustc -default-'
271279
;;
272280

@@ -277,6 +285,7 @@ _cargo() {
277285
'(-p --package)'{-p+,--package=}'[specify package to document]:package:_cargo_package_names' \
278286
'--release[build artifacts in release mode, with optimizations]' \
279287
"${command_scope_spec[@]}" \
288+
'--ignore-rust-version[Ignore rust-version specification in packages]' \
280289
'*: : _dispatch rustdoc rustdoc -default-'
281290
;;
282291

@@ -302,6 +311,7 @@ _cargo() {
302311
'(--lib --doc --bin --test --bench)--example=[example name]:_cargo_example_names' \
303312
'(--lib --doc --bin --example --bench)--test=[test name]' \
304313
'(--lib --doc --bin --example --test)--bench=[benchmark name]' \
314+
'--ignore-rust-version[Ignore rust-version specification in packages]' \
305315
'*: :_default'
306316
;;
307317

src/etc/cargo.bashcomp.sh

+10-10
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,21 @@ _cargo()
4949

5050
local opt___nocmd="$opt_common -V --version --list --explain"
5151
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__bench="$opt_common $opt_pkg_spec $opt_feat $opt_mani $opt_lock $opt_parallel $opt_targets --message-format --target --no-run --no-fail-fast --target-dir"
53-
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"
52+
local opt__bench="$opt_common $opt_pkg_spec $opt_feat $opt_mani $opt_lock $opt_parallel $opt_targets --message-format --target --no-run --no-fail-fast --target-dir --ignore-rust-version"
53+
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"
5454
local opt__b="$opt__build"
55-
local opt__check="$opt_common $opt_pkg_spec $opt_feat $opt_mani $opt_lock $opt_parallel $opt_targets --message-format --target --release --profile --target-dir"
55+
local opt__check="$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"
5656
local opt__c="$opt__check"
5757
local opt__clean="$opt_common $opt_pkg $opt_mani $opt_lock --target --release --doc --target-dir --profile"
5858
local opt__clippy="$opt_common $opt_pkg_spec $opt_feat $opt_mani $opt_lock $opt_parallel $opt_targets --message-format --target --release --profile --target-dir --no-deps --fix"
59-
local opt__doc="$opt_common $opt_pkg_spec $opt_feat $opt_mani $opt_lock $opt_parallel --message-format --bin --bins --lib --target --open --no-deps --release --document-private-items --target-dir --profile"
59+
local opt__doc="$opt_common $opt_pkg_spec $opt_feat $opt_mani $opt_lock $opt_parallel --message-format --bin --bins --lib --target --open --no-deps --release --document-private-items --target-dir --profile --ignore-rust-version"
6060
local opt__d="$opt__doc"
6161
local opt__fetch="$opt_common $opt_mani $opt_lock --target"
62-
local opt__fix="$opt_common $opt_pkg_spec $opt_feat $opt_mani $opt_parallel $opt_targets $opt_lock --release --target --message-format --broken-code --edition --edition-idioms --allow-no-vcs --allow-dirty --allow-staged --profile --target-dir"
62+
local opt__fix="$opt_common $opt_pkg_spec $opt_feat $opt_mani $opt_parallel $opt_targets $opt_lock --release --target --message-format --broken-code --edition --edition-idioms --allow-no-vcs --allow-dirty --allow-staged --profile --target-dir --ignore-rust-version"
6363
local opt__generate_lockfile="$opt_common $opt_mani $opt_lock"
6464
local opt__help="$opt_help"
6565
local opt__init="$opt_common $opt_lock --bin --lib --name --vcs --edition --registry"
66-
local opt__install="$opt_common $opt_feat $opt_parallel $opt_lock $opt_force --bin --bins --branch --debug --example --examples --git --list --path --rev --root --tag --version --registry --target --profile --no-track"
66+
local opt__install="$opt_common $opt_feat $opt_parallel $opt_lock $opt_force --bin --bins --branch --debug --example --examples --git --list --path --rev --root --tag --version --registry --target --profile --no-track --ignore-rust-version"
6767
local opt__locate_project="$opt_common $opt_mani $opt_lock --message-format --workspace"
6868
local opt__login="$opt_common $opt_lock --registry"
6969
local opt__metadata="$opt_common $opt_feat $opt_mani $opt_lock --format-version=1 --no-deps --filter-platform"
@@ -77,12 +77,12 @@ _cargo()
7777
local opt__rm="$opt__remove"
7878
local opt__report="$opt_help $opt_verbose $opt_color future-incompat future-incompatibilities"
7979
local opt__report__future_incompat="$opt_help $opt_verbose $opt_color $opt_pkg --id"
80-
local opt__run="$opt_common $opt_pkg $opt_feat $opt_mani $opt_lock $opt_parallel --message-format --target --bin --example --release --target-dir --profile"
80+
local opt__run="$opt_common $opt_pkg $opt_feat $opt_mani $opt_lock $opt_parallel --message-format --target --bin --example --release --target-dir --profile --ignore-rust-version"
8181
local opt__r="$opt__run"
82-
local opt__rustc="$opt_common $opt_pkg $opt_feat $opt_mani $opt_lock $opt_parallel $opt_targets -L --crate-type --extern --message-format --profile --target --release --target-dir"
83-
local opt__rustdoc="$opt_common $opt_pkg $opt_feat $opt_mani $opt_lock $opt_parallel $opt_targets --message-format --target --release --open --target-dir --profile"
82+
local opt__rustc="$opt_common $opt_pkg $opt_feat $opt_mani $opt_lock $opt_parallel $opt_targets -L --crate-type --extern --message-format --profile --target --release --target-dir --ignore-rust-version"
83+
local opt__rustdoc="$opt_common $opt_pkg $opt_feat $opt_mani $opt_lock $opt_parallel $opt_targets --message-format --target --release --open --target-dir --profile --ignore-rust-version"
8484
local opt__search="$opt_common $opt_lock --limit --index --registry"
85-
local opt__test="$opt_common $opt_pkg_spec $opt_feat $opt_mani $opt_lock $opt_parallel $opt_targets --message-format --doc --target --no-run --release --no-fail-fast --target-dir --profile"
85+
local opt__test="$opt_common $opt_pkg_spec $opt_feat $opt_mani $opt_lock $opt_parallel $opt_targets --message-format --doc --target --no-run --release --no-fail-fast --target-dir --profile --ignore-rust-version"
8686
local opt__t="$opt__test"
8787
local opt__tree="$opt_common $opt_pkg_spec $opt_feat $opt_mani $opt_lock --target -i --invert --prefix --no-dedupe --duplicates -d --charset -f --format -e --edges"
8888
local opt__uninstall="$opt_common $opt_lock $opt_pkg --bin --root"

src/etc/man/cargo-install.1

+6
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,12 @@ Install with the given profile.
273273
See the \fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/profiles.html> for more details on profiles.
274274
.RE
275275
.sp
276+
\fB\-\-ignore\-rust\-version\fR
277+
.RS 4
278+
Install the target even if the selected Rust compiler is older than the
279+
required Rust version as configured in the project\[cq]s \fBrust\-version\fR field.
280+
.RE
281+
.sp
276282
\fB\-\-timings=\fR\fIfmts\fR
277283
.RS 4
278284
Output information how long each compilation takes, and track concurrency

0 commit comments

Comments
 (0)