Skip to content

Commit 6b5cb9f

Browse files
committed
Delete suggestions of removing the relevant component from component_unavailable_msg
After digging into the codebase, I realized that the message generated by `component_unavailable_msg` is used only when: - Some components are missing from the toolchain so that the installation can no longer proceed; - We are not installing these components as a part of a toolchain-wide operation (e.g. updating the existing `nightly`), which is covered by `components_missing_msg` by catching the `RustupError::RequestedComponentsUnavailable` and re-throwing it as a `DistError::ToolchainComponentsMissing` (see <#3453 (comment)> for more info). Thus, I decided to remove the `rustup component remove` suggestion altogether.
1 parent dbb66ad commit 6b5cb9f

File tree

1 file changed

+4
-50
lines changed

1 file changed

+4
-50
lines changed

src/errors.rs

Lines changed: 4 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,6 @@ use crate::{
1919
toolchain::names::{PathBasedToolchainName, ToolchainName},
2020
};
2121

22-
const TOOLSTATE_MSG: &str =
23-
"If you require these components, please install and use the latest successful build version,\n\
24-
which you can find at <https://rust-lang.github.io/rustup-components-history>.\n\nAfter determining \
25-
the correct date, install it with a command such as:\n\n \
26-
rustup toolchain install nightly-2018-12-27\n\n\
27-
Then you can use the toolchain with commands such as:\n\n \
28-
cargo +nightly-2018-12-27 build";
29-
3022
/// A type erasing thunk for the retry crate to permit use with anyhow. See <https://github.com/dtolnay/anyhow/issues/149>
3123
#[derive(Debug, ThisError)]
3224
#[error(transparent)]
@@ -147,29 +139,6 @@ fn suggest_message(suggestion: &Option<String>) -> String {
147139
}
148140
}
149141

150-
fn remove_component_msg(cs: &Component, manifest: &Manifest, toolchain: &str) -> String {
151-
if cs.short_name_in_manifest() == "rust-std" {
152-
// We special-case rust-std as it's the stdlib so really you want to do
153-
// rustup target remove
154-
format!(
155-
" rustup target remove --toolchain {} {}",
156-
toolchain,
157-
cs.target.as_deref().unwrap_or(toolchain)
158-
)
159-
} else {
160-
format!(
161-
" rustup component remove --toolchain {}{} {}",
162-
toolchain,
163-
if let Some(target) = cs.target.as_ref() {
164-
format!(" --target {target}")
165-
} else {
166-
String::default()
167-
},
168-
cs.short_name(manifest)
169-
)
170-
}
171-
}
172-
173142
/// Returns a error message indicating that certain [`Component`]s are unavailable.
174143
///
175144
/// # Panics
@@ -179,24 +148,19 @@ fn component_unavailable_msg(cs: &[Component], manifest: &Manifest, toolchain: &
179148
match cs {
180149
[] => panic!("`component_unavailable_msg` should not be called with an empty collection of unavailable components"),
181150
[c] => {
182-
_ = writeln!(
151+
_ = writeln!(
183152
buf,
184153
"component {} is unavailable for download for channel '{}'",
185154
c.description(manifest),
186155
toolchain,
187156
);
157+
188158
if toolchain.starts_with("nightly") {
189-
_ = write!(
159+
_ = write!(
190160
buf,
191161
"Sometimes not all components are available in any given nightly. "
192162
);
193163
}
194-
_ = write!(
195-
buf,
196-
"If you are trying to update an existing toolchain and no longer need this component,\n\
197-
you might want to remove it first with:\n\n{}\n\n{TOOLSTATE_MSG}",
198-
remove_component_msg(c, manifest, toolchain)
199-
);
200164
}
201165
cs => {
202166
// More than one component
@@ -216,27 +180,17 @@ fn component_unavailable_msg(cs: &[Component], manifest: &Manifest, toolchain: &
216180
.join(", ")
217181
};
218182

219-
let remove_msg = cs
220-
.iter()
221-
.map(|c| remove_component_msg(c, manifest, toolchain))
222-
.collect::<Vec<_>>()
223-
.join("\n");
224-
225183
_ = write!(
226184
buf,
227185
"some components unavailable for download for channel '{toolchain}': {cs_str}"
228186
);
187+
229188
if toolchain.starts_with("nightly") {
230189
_ = write!(
231190
buf,
232191
"Sometimes not all components are available in any given nightly. "
233192
);
234193
}
235-
_ = write!(
236-
buf,
237-
"If you are trying to update an existing toolchain and no longer need these components,\n\
238-
you might want to remove them first with:\n\n{remove_msg}\n\n{TOOLSTATE_MSG}",
239-
);
240194
}
241195
}
242196

0 commit comments

Comments
 (0)