Skip to content

Commit ea129e9

Browse files
committed
improve error message when default components are unavailable on a new toolchain
fix clippy fmt
1 parent 79766cf commit ea129e9

2 files changed

Lines changed: 34 additions & 1 deletion

File tree

src/dist/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ fn components_missing_msg(cs: &[Component], manifest: &ManifestV2, toolchain: &s
8484
}
8585
}
8686

87+
let from_complete_profile = manifest
88+
.profiles
89+
.get(&Profile::Complete)
90+
.map(|profile| cs.iter().all(|c| profile.contains(&c.pkg)))
91+
.unwrap_or(false);
92+
8793
if toolchain.starts_with("nightly") {
8894
let _ = write!(
8995
buf,
@@ -97,6 +103,13 @@ fn components_missing_msg(cs: &[Component], manifest: &ManifestV2, toolchain: &s
97103
help: then you can use the toolchain with commands such as:\n\
98104
help: cargo +nightly-2018-12-27 build"
99105
);
106+
} else if from_complete_profile {
107+
let _ = write!(
108+
buf,
109+
"\
110+
note: these were added as default components on another toolchain
111+
help: run `rustup set profile minimal` to stop new toolchains from inheriting extra components"
112+
);
100113
} else if ["beta", "stable"].iter().any(|&p| toolchain.starts_with(p)) {
101114
let _ = write!(
102115
buf,

src/errors.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use url::Url;
1212

1313
use crate::{
1414
dist::{
15-
Channel, TargetTuple, ToolchainDesc,
15+
Channel, Profile, TargetTuple, ToolchainDesc,
1616
manifest::{Component, Manifest},
1717
},
1818
toolchain::{PathBasedToolchainName, ToolchainName},
@@ -217,6 +217,8 @@ fn component_unavailable_msg(cs: &[Component], manifest: &Manifest, toolchain: &
217217

218218
if toolchain.starts_with("nightly") {
219219
let _ = write!(buf, "{NIGHTLY_COMPONENT_NOTE}");
220+
} else {
221+
write_nightly_profile_hint(&mut buf, cs, manifest);
220222
}
221223
}
222224
cs => {
@@ -244,13 +246,31 @@ fn component_unavailable_msg(cs: &[Component], manifest: &Manifest, toolchain: &
244246

245247
if toolchain.starts_with("nightly") {
246248
let _ = write!(buf, "{NIGHTLY_COMPONENT_NOTE}");
249+
} else {
250+
write_nightly_profile_hint(&mut buf, cs, manifest);
247251
}
248252
}
249253
}
250254

251255
String::from_utf8(buf).unwrap()
252256
}
253257

258+
fn write_nightly_profile_hint(buf: &mut Vec<u8>, cs: &[Component], manifest: &Manifest) {
259+
let from_complete_profile = manifest
260+
.profiles
261+
.get(&Profile::Complete)
262+
.map(|profile| cs.iter().all(|c| profile.contains(&c.pkg)))
263+
.unwrap_or(false);
264+
if from_complete_profile {
265+
let _ = write!(
266+
buf,
267+
"\
268+
note: these were added as default components on another toolchain
269+
help: run `rustup set profile minimal` to stop new toolchains from inheriting extra components"
270+
);
271+
}
272+
}
273+
254274
fn unknown_components_msg(desc: &ToolchainDesc, components: &[UnknownComponentInfo]) -> String {
255275
let mut buf = String::new();
256276

0 commit comments

Comments
 (0)