Skip to content

Commit e92b85e

Browse files
committed
refactor(cli): remove deprecated()
1 parent 319f931 commit e92b85e

File tree

3 files changed

+3
-51
lines changed

3 files changed

+3
-51
lines changed

src/cli/rustup_mode.rs

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use crate::{
4646
toolchain::Toolchain,
4747
},
4848
utils::utils,
49-
Cfg, Notification,
49+
Cfg,
5050
};
5151

5252
const TOOLCHAIN_OVERRIDE_ERROR: &str =
@@ -68,25 +68,6 @@ fn handle_epipe(res: Result<utils::ExitCode>) -> Result<utils::ExitCode> {
6868
}
6969
}
7070

71-
fn deprecated<F, B, R>(instead: &str, cfg: &mut Cfg, matches: B, callee: F) -> R
72-
where
73-
F: FnOnce(&mut Cfg, B) -> R,
74-
{
75-
(cfg.notify_handler)(Notification::PlainVerboseMessage(
76-
"Use of (currently) unmaintained command line interface.",
77-
));
78-
(cfg.notify_handler)(Notification::PlainVerboseMessage(
79-
"The exact API of this command may change without warning",
80-
));
81-
(cfg.notify_handler)(Notification::PlainVerboseMessage(
82-
"Eventually this command will be a true alias. Until then:",
83-
));
84-
(cfg.notify_handler)(Notification::PlainVerboseMessage(&format!(
85-
" Please use `rustup {instead}` instead"
86-
)));
87-
callee(cfg, matches)
88-
}
89-
9071
#[derive(Debug, Parser)]
9172
#[command(
9273
name = "rustup",
@@ -217,10 +198,10 @@ pub fn main() -> Result<utils::ExitCode> {
217198
Some(s) => match s {
218199
("dump-testament", _) => common::dump_testament()?,
219200
("show", _) => Rustup::from_arg_matches(&matches)?.dispatch(cfg)?,
220-
("install", m) => deprecated("toolchain install", cfg, m, update)?,
201+
("install", m) => update(cfg, m)?,
221202
("update", m) => update(cfg, m)?,
222203
("check", _) => check_updates(cfg)?,
223-
("uninstall", m) => deprecated("toolchain uninstall", cfg, m, toolchain_remove)?,
204+
("uninstall", m) => toolchain_remove(cfg, m)?,
224205
("default", m) => default_(cfg, m)?,
225206
("toolchain", c) => match c.subcommand() {
226207
Some(s) => match s {

src/notifications.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ pub(crate) enum Notification<'a> {
3131
ReadMetadataVersion(&'a str),
3232
NonFatalError(&'a anyhow::Error),
3333
UpgradeRemovesToolchains,
34-
PlainVerboseMessage(&'a str),
3534
/// Both `rust-toolchain` and `rust-toolchain.toml` exist within a directory
3635
DuplicateToolchainFile {
3736
rust_toolchain: &'a Path,
@@ -68,7 +67,6 @@ impl<'a> Notification<'a> {
6867
| UpdatingToolchain(_)
6968
| ReadMetadataVersion(_)
7069
| InstalledToolchain(_)
71-
| PlainVerboseMessage(_)
7270
| UpdateHashMatches => NotificationLevel::Verbose,
7371
SetDefaultToolchain(_)
7472
| SetOverrideToolchain(_, _)
@@ -124,7 +122,6 @@ impl<'a> Display for Notification<'a> {
124122
f,
125123
"this upgrade will remove all existing toolchains. you will need to reinstall them"
126124
),
127-
PlainVerboseMessage(r) => write!(f, "{r}"),
128125
DuplicateToolchainFile {
129126
rust_toolchain,
130127
rust_toolchain_toml,

tests/suite/cli_misc.rs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,29 +1021,3 @@ fn toolchain_link_then_list_verbose() {
10211021
config.expect_stdout_ok(&["rustup", "toolchain", "list", "-v"], "/custom-1");
10221022
});
10231023
}
1024-
1025-
#[test]
1026-
fn deprecated_interfaces() {
1027-
setup(&|config| {
1028-
// In verbose mode we want the deprecated interfaces to complain
1029-
config.expect_ok_contains(
1030-
&["rustup", "--verbose", "install", "nightly"],
1031-
"",
1032-
"Please use `rustup toolchain install` instead",
1033-
);
1034-
config.expect_ok_contains(
1035-
&["rustup", "--verbose", "uninstall", "nightly"],
1036-
"",
1037-
"Please use `rustup toolchain uninstall` instead",
1038-
);
1039-
// But if not verbose then they should *NOT* complain
1040-
config.expect_not_stderr_ok(
1041-
&["rustup", "install", "nightly"],
1042-
"Please use `rustup toolchain install` instead",
1043-
);
1044-
config.expect_not_stderr_ok(
1045-
&["rustup", "uninstall", "nightly"],
1046-
"Please use `rustup toolchain uninstall` instead",
1047-
);
1048-
})
1049-
}

0 commit comments

Comments
 (0)