Skip to content

Commit

Permalink
Auto merge of #11859 - chaitanyav:master, r=weihanglo
Browse files Browse the repository at this point in the history
Add --ignore-rust-version flag to cargo install

`@weihanglo` Added the flag to cargo install
fixes #11718
  • Loading branch information
bors committed Mar 17, 2023
2 parents c9faf70 + f5c699e commit f2f4496
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/bin/cargo/commands/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ pub fn cli() -> Command {
.requires("crate")
.conflicts_with_all(&["git", "path", "index"]),
)
.arg_ignore_rust_version()
.arg_message_format()
.arg_timings()
.after_help("Run `cargo help install` for more detailed information.\n")
Expand Down
2 changes: 2 additions & 0 deletions src/doc/man/cargo-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ See also the `--profile` option for choosing a specific profile by name.

{{> options-profile }}

{{> options-ignore-rust-version }}

{{> options-timings }}

{{/options}}
Expand Down
5 changes: 5 additions & 0 deletions src/doc/man/generated_txt/cargo-install.txt
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ OPTIONS
<https://doc.rust-lang.org/cargo/reference/profiles.html> for more
details on profiles.

--ignore-rust-version
Install the target even if the selected Rust compiler is older than
the required Rust version as configured in the project’s
rust-version field.

--timings=fmts
Output information how long each compilation takes, and track
concurrency information over time. Accepts an optional
Expand Down
6 changes: 6 additions & 0 deletions src/doc/src/commands/cargo-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,12 @@ See the <a href="../reference/profiles.html">the reference</a> for more details



<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>
<dd class="option-desc">Install the target even if the selected Rust compiler is older than the
required Rust version as configured in the project’s <code>rust-version</code> field.</dd>



<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>
<dd class="option-desc">Output information how long each compilation takes, and track concurrency
information over time. Accepts an optional comma-separated list of output
Expand Down
12 changes: 11 additions & 1 deletion src/etc/_cargo
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ _cargo() {
'(-p --package)'{-p+,--package=}'[specify package to run benchmarks for]:package:_cargo_package_names' \
'--exclude=[exclude packages from the benchmark]:spec' \
'--no-fail-fast[run all benchmarks regardless of failure]' \
'--ignore-rust-version[Ignore rust-version specification in packages]' \
'1: :_guard "^-*" "bench name"' \
'*:args:_default'
;;
Expand All @@ -105,6 +106,7 @@ _cargo() {
'(-p --package)'{-p+,--package=}'[specify package to build]:package:_cargo_package_names' \
'--release[build in release mode]' \
'--build-plan[output the build plan in JSON]' \
'--ignore-rust-version[Ignore rust-version specification in packages]'
;;

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

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

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

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

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

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

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

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

Expand Down
20 changes: 10 additions & 10 deletions src/etc/cargo.bashcomp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,21 @@ _cargo()

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__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"
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"
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"
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"
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"
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"
local opt__c="$opt__check"
local opt__clean="$opt_common $opt_pkg $opt_mani $opt_lock --target --release --doc --target-dir --profile"
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"
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"
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"
local opt__d="$opt__doc"
local opt__fetch="$opt_common $opt_mani $opt_lock --target"
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"
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"
local opt__generate_lockfile="$opt_common $opt_mani $opt_lock"
local opt__help="$opt_help"
local opt__init="$opt_common $opt_lock --bin --lib --name --vcs --edition --registry"
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"
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"
local opt__locate_project="$opt_common $opt_mani $opt_lock --message-format --workspace"
local opt__login="$opt_common $opt_lock --registry"
local opt__metadata="$opt_common $opt_feat $opt_mani $opt_lock --format-version=1 --no-deps --filter-platform"
Expand All @@ -77,12 +77,12 @@ _cargo()
local opt__rm="$opt__remove"
local opt__report="$opt_help $opt_verbose $opt_color future-incompat future-incompatibilities"
local opt__report__future_incompat="$opt_help $opt_verbose $opt_color $opt_pkg --id"
local opt__run="$opt_common $opt_pkg $opt_feat $opt_mani $opt_lock $opt_parallel --message-format --target --bin --example --release --target-dir --profile"
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"
local opt__r="$opt__run"
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"
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"
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"
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"
local opt__search="$opt_common $opt_lock --limit --index --registry"
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"
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"
local opt__t="$opt__test"
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"
local opt__uninstall="$opt_common $opt_lock $opt_pkg --bin --root"
Expand Down
6 changes: 6 additions & 0 deletions src/etc/man/cargo-install.1
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,12 @@ Install with the given profile.
See the \fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/profiles.html> for more details on profiles.
.RE
.sp
\fB\-\-ignore\-rust\-version\fR
.RS 4
Install the target even if the selected Rust compiler is older than the
required Rust version as configured in the project\[cq]s \fBrust\-version\fR field.
.RE
.sp
\fB\-\-timings=\fR\fIfmts\fR
.RS 4
Output information how long each compilation takes, and track concurrency
Expand Down

0 comments on commit f2f4496

Please sign in to comment.