Skip to content

Commit

Permalink
Auto merge of #14739 - weihanglo:cmd, r=epage
Browse files Browse the repository at this point in the history
fix: clean up for deprecated and removed commands

### What does this PR try to resolve?

This PR is a follow-up of <#14679>.

* A new doc page for deprecated and removed commands
* Remove shell completions for deprecated commands
* Remove `verify-project` and `read-manifest` from `cargo --list` output.

### How should we test and review this PR?

`mdbook serve src/doc` and read the doc.

I've set up redirections for all removed/deprecated commands to maintain consistency,
though only `verify-project` really need it I believe.
  • Loading branch information
bors committed Oct 28, 2024
2 parents eb2be13 + 886e55b commit f95eeb6
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 20 deletions.
4 changes: 3 additions & 1 deletion src/bin/cargo/commands/git_checkout.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
//! Removed.
use crate::command_prelude::*;

const REMOVED: &str = "The `git-checkout` command has been removed.";

pub fn cli() -> Command {
subcommand("git-checkout")
.about("This command has been removed")
.about("REMOVED: This command has been removed")
.hide(true)
.override_help(REMOVED)
}
Expand Down
7 changes: 5 additions & 2 deletions src/bin/cargo/commands/read_manifest.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
//! Deprecated.
use crate::command_prelude::*;

pub fn cli() -> Command {
subcommand("read-manifest")
.hide(true)
.about(color_print::cstr!(
"\
Print a JSON representation of a Cargo.toml manifest.
DEPRECATED: Print a JSON representation of a Cargo.toml manifest.
Deprecated, use `<cyan,bold>cargo metadata --no-deps</>` instead.\
Use `<cyan,bold>cargo metadata --no-deps</>` instead.\
"
))
.arg_silent_suggestion()
Expand Down
7 changes: 5 additions & 2 deletions src/bin/cargo/commands/verify_project.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
//! Deprecated.
use crate::command_prelude::*;

use std::collections::HashMap;
use std::process;

pub fn cli() -> Command {
subcommand("verify-project")
.hide(true)
.about(
"\
Check correctness of crate manifest.
DEPRECATED: Check correctness of crate manifest.
Deprecated, see https://github.com/rust-lang/cargo/issues/14679.",
See https://github.com/rust-lang/cargo/issues/14679.",
)
.arg_silent_suggestion()
.arg_manifest_path()
Expand Down
3 changes: 3 additions & 0 deletions src/doc/book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ search.use-boolean-and = true

[output.html.redirect]
"/guide/build-cache.html" = "../reference/build-cache.html"
"/commands/cargo-git-checkout.html" = "./deprecated-and-removed.html"
"/commands/cargo-read-manifest.html" = "./deprecated-and-removed.html"
"/commands/cargo-verify-project.html" = "./deprecated-and-removed.html"
1 change: 1 addition & 0 deletions src/doc/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
* [cargo package](commands/cargo-package.md)
* [cargo publish](commands/cargo-publish.md)
* [cargo yank](commands/cargo-yank.md)
* [Deprecated and Removed](commands/deprecated-and-removed.md)

* [FAQ](faq.md)
* [Appendix: Glossary](appendix/glossary.md)
Expand Down
10 changes: 10 additions & 0 deletions src/doc/src/commands/deprecated-and-removed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## Deprecated and Removed Commands

These commands have been deprecated or removed in early Rust releases.
Deprecated commands receive only critical bug fixes,
and may be removed in future versions.
Removed commands are no longer functional and are unsupported.

* `read-manifest` --- deprecated since Rust 1.13
* `git-checkout` --- removed since Rust 1.44
* `verify-project` --- deprecated since Rust 1.84
1 change: 1 addition & 0 deletions src/doc/src/commands/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
* [Manifest Commands](manifest-commands.md)
* [Package Commands](package-commands.md)
* [Publishing Commands](publishing-commands.md)
* [Deprecated and Removed](deprecated-and-removed.md)
8 changes: 0 additions & 8 deletions src/etc/_cargo
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,6 @@ _cargo() {
'--dry-run[perform all checks without uploading]'
;;

read-manifest)
_arguments -s -S $common $manifest
;;

remove | rm)
_arguments -s -A "^--" $common $manifest \
"--dev[remove as a dev dependency]" \
Expand Down Expand Up @@ -356,10 +352,6 @@ _cargo() {
'*:package:_cargo_package_names'
;;

verify-project)
_arguments -s -S $common $manifest
;;

version)
_arguments -s -S $common
;;
Expand Down
2 changes: 0 additions & 2 deletions src/etc/cargo.bashcomp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ _cargo()
local opt__package="$opt_common $opt_mani $opt_feat $opt_lock $opt_parallel --allow-dirty -l --list --no-verify --no-metadata --index --registry --target --target-dir"
local opt__pkgid="$opt_common $opt_mani $opt_lock $opt_pkg"
local opt__publish="$opt_common $opt_mani $opt_feat $opt_lock $opt_parallel --allow-dirty --dry-run --token --no-verify --index --registry --target --target-dir"
local opt__read_manifest="$opt_help $opt_quiet $opt_verbose $opt_mani $opt_color $opt_lock --no-deps"
local opt__remove="$opt_common $opt_pkg $opt_lock $opt_mani --dry-run --dev --build --target"
local opt__rm="$opt__remove"
local opt__report="$opt_help $opt_verbose $opt_color future-incompat future-incompatibilities"
Expand All @@ -90,7 +89,6 @@ _cargo()
local opt__uninstall="$opt_common $opt_lock $opt_pkg --bin --root"
local opt__update="$opt_common $opt_mani $opt_lock $opt_pkg --aggressive --recursive --precise --dry-run"
local opt__vendor="$opt_common $opt_mani $opt_lock $opt_sync --no-delete --respect-source-config --versioned-dirs"
local opt__verify_project="$opt_common $opt_mani $opt_lock"
local opt__version="$opt_common $opt_lock"
local opt__yank="$opt_common $opt_lock --version --undo --index --token --registry"
local opt__libtest="--help --include-ignored --ignored --test --bench --list --logfile --nocapture --test-threads --skip -q --quiet --exact --color --format"
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn list_commands_with_descriptions() {
...
r alias: run
...
read-manifest Print a JSON representation of a Cargo.toml manifest.
read-manifest DEPRECATED: Print a JSON representation of a Cargo.toml manifest.
...
t alias: test
...
Expand Down
4 changes: 2 additions & 2 deletions tests/testsuite/cargo_read_manifest/help/stdout.term.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions tests/testsuite/cargo_verify_project/help/stdout.term.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f95eeb6

Please sign in to comment.