From 24838a4ac9d06469ef9e5bd6365ec1454cb0e7c2 Mon Sep 17 00:00:00 2001 From: rami3l Date: Tue, 2 Jul 2024 21:21:00 +0800 Subject: [PATCH 1/6] fix: fix typo in several places Co-authored-by: Robert Collins --- src/dist/mod.rs | 4 ++-- src/errors.rs | 4 ++-- src/test/mock/clitools.rs | 2 +- tests/suite/cli_v2.rs | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/dist/mod.rs b/src/dist/mod.rs index f9623d8e06..8274890019 100644 --- a/src/dist/mod.rs +++ b/src/dist/mod.rs @@ -47,7 +47,7 @@ pub(crate) use triple::*; pub static DEFAULT_DIST_SERVER: &str = "https://static.rust-lang.org"; const TOOLSTATE_MSG: &str = - "If you require these components, please install and use the latest successful build version,\n\ + "If you require these components, please install and use the latest successfully built version,\n\ which you can find at .\n\nAfter determining \ the correct date, install it with a command such as:\n\n \ rustup toolchain install nightly-2018-12-27\n\n\ @@ -93,7 +93,7 @@ fn components_missing_msg(cs: &[Component], manifest: &ManifestV2, toolchain: &s .join(", "); let _ = write!( buf, - "some components unavailable for download for channel '{toolchain}': {cs_str}" + "some components are unavailable for download for channel '{toolchain}': {cs_str}" ); if toolchain.starts_with("nightly") { diff --git a/src/errors.rs b/src/errors.rs index 035ef7fea6..0d13334839 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -148,7 +148,7 @@ fn suggest_message(suggestion: &Option) -> String { /// Returns a error message indicating that certain [`Component`]s are unavailable. /// -/// See also [`component_missing_msg`](../dist/dist/fn.components_missing_msg.html) +/// See also [`components_missing_msg`](../dist/dist/fn.components_missing_msg.html) /// which generates error messages for component unavailability toolchain-wide operations. /// /// # Panics @@ -192,7 +192,7 @@ fn component_unavailable_msg(cs: &[Component], manifest: &Manifest, toolchain: & let _ = write!( buf, - "some components unavailable for download for channel '{toolchain}': {cs_str}" + "some components are unavailable for download for channel '{toolchain}': {cs_str}" ); if toolchain.starts_with("nightly") { diff --git a/src/test/mock/clitools.rs b/src/test/mock/clitools.rs index 1b2ed29859..aa041bd4a5 100644 --- a/src/test/mock/clitools.rs +++ b/src/test/mock/clitools.rs @@ -93,7 +93,7 @@ pub enum Scenario { Unavailable, /// Two dates, v2 manifests, RLS unavailable in first date, restored on second. UnavailableRls, - /// Three dates, v2 manifests, RLS available in first and last, not middle + /// Three dates, v2 manifests, RLS available in first and second, not last MissingComponent, /// Three dates, v2 manifests, RLS available in first, middle missing nightly MissingNightly, diff --git a/tests/suite/cli_v2.rs b/tests/suite/cli_v2.rs index 995094d298..ba599d6828 100644 --- a/tests/suite/cli_v2.rs +++ b/tests/suite/cli_v2.rs @@ -1363,7 +1363,7 @@ Sometimes not all components are available in any given nightly. If you don't ne rustup toolchain add nightly --profile minimal -If you require these components, please install and use the latest successful build version, +If you require these components, please install and use the latest successfully built version, which you can find at . After determining the correct date, install it with a command such as: From dbaa02bf4f5194cd26d123455df6c35289224869 Mon Sep 17 00:00:00 2001 From: rami3l Date: Tue, 2 Jul 2024 21:59:44 +0800 Subject: [PATCH 2/6] refactor(dist): extract "nightly tips" out of the match block in `components_missing_msg()` --- src/dist/mod.rs | 26 ++++++++------------------ tests/suite/cli_v2.rs | 3 ++- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/src/dist/mod.rs b/src/dist/mod.rs index 8274890019..75ef9c4137 100644 --- a/src/dist/mod.rs +++ b/src/dist/mod.rs @@ -75,15 +75,6 @@ fn components_missing_msg(cs: &[Component], manifest: &ManifestV2, toolchain: &s c.description(manifest), toolchain, ); - - if toolchain.starts_with("nightly") { - let _ = write!(buf, "{nightly_tips}"); - } - - let _ = write!( - buf, - "If you don't need the component, you could try a minimal installation with:\n\n{suggestion}\n\n{TOOLSTATE_MSG}" - ); } cs => { let cs_str = cs @@ -95,18 +86,17 @@ fn components_missing_msg(cs: &[Component], manifest: &ManifestV2, toolchain: &s buf, "some components are unavailable for download for channel '{toolchain}': {cs_str}" ); - - if toolchain.starts_with("nightly") { - let _ = write!(buf, "{nightly_tips}"); - } - - let _ = write!( - buf, - "If you don't need the components, you could try a minimal installation with:\n\n{suggestion}\n\n{TOOLSTATE_MSG}" - ); } } + if toolchain.starts_with("nightly") { + let _ = write!(buf, "{nightly_tips}"); + + let _ = write!( + buf, + "If you don't need these components, you could try a minimal installation with:\n\n{suggestion}\n\n{TOOLSTATE_MSG}" + ); + } String::from_utf8(buf).unwrap() } diff --git a/tests/suite/cli_v2.rs b/tests/suite/cli_v2.rs index ba599d6828..f99b2044b2 100644 --- a/tests/suite/cli_v2.rs +++ b/tests/suite/cli_v2.rs @@ -1359,7 +1359,8 @@ async fn add_missing_component_toolchain() { &["rustup", "toolchain", "add", "nightly"], for_host!( r"component 'rust-std' for target '{0}' is unavailable for download for channel 'nightly' -Sometimes not all components are available in any given nightly. If you don't need the component, you could try a minimal installation with: +Sometimes not all components are available in any given nightly. +If you don't need these components, you could try a minimal installation with: rustup toolchain add nightly --profile minimal From f41217ebc88141ca1c9a2acd4e6f9de2cc4d7886 Mon Sep 17 00:00:00 2001 From: rami3l Date: Tue, 2 Jul 2024 22:12:36 +0800 Subject: [PATCH 3/6] refactor(dist): inline some const strings in `components_missing_msg()` --- src/dist/mod.rs | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/dist/mod.rs b/src/dist/mod.rs index 75ef9c4137..177dbbef65 100644 --- a/src/dist/mod.rs +++ b/src/dist/mod.rs @@ -46,14 +46,6 @@ pub(crate) use triple::*; pub static DEFAULT_DIST_SERVER: &str = "https://static.rust-lang.org"; -const TOOLSTATE_MSG: &str = - "If you require these components, please install and use the latest successfully built version,\n\ - which you can find at .\n\nAfter determining \ - the correct date, install it with a command such as:\n\n \ - rustup toolchain install nightly-2018-12-27\n\n\ - Then you can use the toolchain with commands such as:\n\n \ - cargo +nightly-2018-12-27 build"; - /// Returns a error message indicating that certain [`Component`]s are missing in a toolchain distribution. /// /// This message is currently used exclusively in toolchain-wide operations, @@ -63,8 +55,6 @@ const TOOLSTATE_MSG: &str = /// This function will panic when the collection of unavailable components `cs` is empty. fn components_missing_msg(cs: &[Component], manifest: &ManifestV2, toolchain: &str) -> String { let mut buf = vec![]; - let suggestion = format!(" rustup toolchain add {toolchain} --profile minimal"); - let nightly_tips = "Sometimes not all components are available in any given nightly. "; match cs { [] => panic!("`components_missing_msg` should not be called with an empty collection of unavailable components"), @@ -90,13 +80,27 @@ fn components_missing_msg(cs: &[Component], manifest: &ManifestV2, toolchain: &s } if toolchain.starts_with("nightly") { - let _ = write!(buf, "{nightly_tips}"); - let _ = write!( buf, - "If you don't need these components, you could try a minimal installation with:\n\n{suggestion}\n\n{TOOLSTATE_MSG}" + "\ +Sometimes not all components are available in any given nightly. +If you don't need these components, you could try a minimal installation with: + + rustup toolchain add {toolchain} --profile minimal + +If you require these components, please install and use the latest successfully built version, +which you can find at . + +After determining the correct date, install it with a command such as: + + rustup toolchain install nightly-2018-12-27 + +Then you can use the toolchain with commands such as: + + cargo +nightly-2018-12-27 build" ); } + String::from_utf8(buf).unwrap() } From 419bb2e0393c3d664c794b245be047219c37a4f8 Mon Sep 17 00:00:00 2001 From: rami3l Date: Tue, 2 Jul 2024 22:47:45 +0800 Subject: [PATCH 4/6] feat(dist): add notes for `stable` and `beta` in `components_missing_msg()` --- src/dist/mod.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/dist/mod.rs b/src/dist/mod.rs index 177dbbef65..5fe3651767 100644 --- a/src/dist/mod.rs +++ b/src/dist/mod.rs @@ -99,6 +99,23 @@ Then you can use the toolchain with commands such as: cargo +nightly-2018-12-27 build" ); + } else if ["beta", "stable"].iter().any(|&p| toolchain.starts_with(p)) { + let _ = write!( + buf, + "\ +One or many components listed above might have been permanently removed from newer versions +of the official Rust distribution due to deprecation. + +You can find the list of removed components at +. + +If you are updating an existing toolchain, after determining the deprecated component(s) +in question, please remove them with a command such as: + + rustup component remove --toolchain {toolchain} ... + +After that, you should be able to continue with the update as usual.", + ); } String::from_utf8(buf).unwrap() From 58b7dba1c38561186792b695a96ce43836b78cf0 Mon Sep 17 00:00:00 2001 From: rami3l Date: Tue, 2 Jul 2024 22:19:30 +0800 Subject: [PATCH 5/6] test(cli_v2): introduce `update_removed_component_toolchain()` --- src/test/mock/clitools.rs | 8 ++++++++ tests/suite/cli_v2.rs | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/src/test/mock/clitools.rs b/src/test/mock/clitools.rs index aa041bd4a5..d81eb0374b 100644 --- a/src/test/mock/clitools.rs +++ b/src/test/mock/clitools.rs @@ -93,6 +93,8 @@ pub enum Scenario { Unavailable, /// Two dates, v2 manifests, RLS unavailable in first date, restored on second. UnavailableRls, + /// Two dates, v2 manifests, RLS available in first stable, removed on second. + RemovedRls, /// Three dates, v2 manifests, RLS available in first and second, not last MissingComponent, /// Three dates, v2 manifests, RLS available in first, middle missing nightly @@ -152,6 +154,7 @@ impl ConstState { Scenario::MissingNightly => RwLock::new(None), Scenario::MultiHost => RwLock::new(None), Scenario::None => RwLock::new(None), + Scenario::RemovedRls => RwLock::new(None), Scenario::SimpleV1 => RwLock::new(None), Scenario::SimpleV2 => RwLock::new(None), Scenario::Unavailable => RwLock::new(None), @@ -1152,6 +1155,10 @@ fn create_mock_dist_server(path: &Path, s: Scenario) { Release::stable("1.1.0", "2015-01-02"), ] } + Scenario::RemovedRls => vec![ + Release::stable("1.78.0", "2024-05-01"), + Release::stable("1.79.0", "2024-06-15").with_rls(RlsStatus::Unavailable), + ], Scenario::SimpleV1 | Scenario::SimpleV2 => vec![ Release::new("nightly", "1.3.0", "2015-01-02", "2").with_rls(RlsStatus::Renamed), Release::beta("1.2.0", "2015-01-02"), @@ -1199,6 +1206,7 @@ fn create_mock_dist_server(path: &Path, s: Scenario) { | Scenario::MultiHost | Scenario::Unavailable | Scenario::UnavailableRls + | Scenario::RemovedRls | Scenario::MissingNightly | Scenario::HostGoesMissingBefore | Scenario::HostGoesMissingAfter diff --git a/tests/suite/cli_v2.rs b/tests/suite/cli_v2.rs index f99b2044b2..7d678fd790 100644 --- a/tests/suite/cli_v2.rs +++ b/tests/suite/cli_v2.rs @@ -1378,6 +1378,43 @@ Then you can use the toolchain with commands such as: ).await; } +#[tokio::test] +async fn update_removed_component_toolchain() { + let mut cx = CliTestContext::new(Scenario::RemovedRls).await; + set_current_dist_date(&cx.config, "2024-05-01"); + cx.config.expect_ok(&["rustup", "default", "stable"]).await; + + // Install `rls` on the first day. + cx.config + .expect_stdout_ok(&["rustc", "--version"], "1.78.0") + .await; + cx.config + .expect_ok(&["rustup", "component", "add", "rls"]) + .await; + cx.config.expect_component_executable("rls").await; + + // `rls` is missing on the second day. + set_current_dist_date(&cx.config, "2024-06-15"); + + // An update at this time should inform the user of an unavailable component. + cx.config + .expect_err( + &["rustup", "update", "stable"], + for_host!( + r"component 'rls' for target '{0}' is unavailable for download for channel 'stable' +One or many components listed above might have been permanently removed from newer versions +of the official Rust distribution due to deprecation." + ), + ) + .await; + + // We're still stuck with the old version. + cx.config + .expect_stdout_ok(&["rustc", "--version"], "1.78.0") + .await; + cx.config.expect_component_executable("rls").await; +} + #[tokio::test] async fn update_unavailable_force() { let mut cx = CliTestContext::new(Scenario::SimpleV2).await; From cb82025796034d57f02c6dc3ada49db88bba8ee3 Mon Sep 17 00:00:00 2001 From: rami3l Date: Mon, 12 Aug 2024 18:56:45 +0800 Subject: [PATCH 6/6] docs(user-guide): add a link to the latest "Previous components" section --- doc/user-guide/src/concepts/components.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/user-guide/src/concepts/components.md b/doc/user-guide/src/concepts/components.md index 59978298b2..f6f35a04ef 100644 --- a/doc/user-guide/src/concepts/components.md +++ b/doc/user-guide/src/concepts/components.md @@ -63,6 +63,9 @@ toolchains. The following is an overview of the different components: ### Previous components +> See [here](https://rust-lang.github.io/rustup/devel/concepts/components.html#previous-components) +> for the latest version of this section. + These components have been deprecated and are not published in new Rust releases. * `rls` --- [RLS] is a language server that is deprecated and has been replaced