Skip to content

Commit dbaa02b

Browse files
committed
refactor(dist): extract "nightly tips" out of the match block in components_missing_msg()
1 parent 24838a4 commit dbaa02b

File tree

2 files changed

+10
-19
lines changed

2 files changed

+10
-19
lines changed

src/dist/mod.rs

+8-18
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,6 @@ fn components_missing_msg(cs: &[Component], manifest: &ManifestV2, toolchain: &s
7575
c.description(manifest),
7676
toolchain,
7777
);
78-
79-
if toolchain.starts_with("nightly") {
80-
let _ = write!(buf, "{nightly_tips}");
81-
}
82-
83-
let _ = write!(
84-
buf,
85-
"If you don't need the component, you could try a minimal installation with:\n\n{suggestion}\n\n{TOOLSTATE_MSG}"
86-
);
8778
}
8879
cs => {
8980
let cs_str = cs
@@ -95,18 +86,17 @@ fn components_missing_msg(cs: &[Component], manifest: &ManifestV2, toolchain: &s
9586
buf,
9687
"some components are unavailable for download for channel '{toolchain}': {cs_str}"
9788
);
98-
99-
if toolchain.starts_with("nightly") {
100-
let _ = write!(buf, "{nightly_tips}");
101-
}
102-
103-
let _ = write!(
104-
buf,
105-
"If you don't need the components, you could try a minimal installation with:\n\n{suggestion}\n\n{TOOLSTATE_MSG}"
106-
);
10789
}
10890
}
10991

92+
if toolchain.starts_with("nightly") {
93+
let _ = write!(buf, "{nightly_tips}");
94+
95+
let _ = write!(
96+
buf,
97+
"If you don't need these components, you could try a minimal installation with:\n\n{suggestion}\n\n{TOOLSTATE_MSG}"
98+
);
99+
}
110100
String::from_utf8(buf).unwrap()
111101
}
112102

tests/suite/cli_v2.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1359,7 +1359,8 @@ async fn add_missing_component_toolchain() {
13591359
&["rustup", "toolchain", "add", "nightly"],
13601360
for_host!(
13611361
r"component 'rust-std' for target '{0}' is unavailable for download for channel 'nightly'
1362-
Sometimes not all components are available in any given nightly. If you don't need the component, you could try a minimal installation with:
1362+
Sometimes not all components are available in any given nightly.
1363+
If you don't need these components, you could try a minimal installation with:
13631364
13641365
rustup toolchain add nightly --profile minimal
13651366

0 commit comments

Comments
 (0)