Skip to content

Commit fdc9f47

Browse files
committed
refactor(dist): extract "nightly tips" out of the match block in components_missing_msg()
1 parent 080e97e commit fdc9f47

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

src/dist/mod.rs

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub static DEFAULT_DIST_SERVER: &str = "https://static.rust-lang.org";
4545
pub(crate) static DEFAULT_DIST_ROOT: &str = "https://static.rust-lang.org/dist";
4646

4747
const TOOLSTATE_MSG: &str =
48-
"If you require these components, please install and use the latest successful build version,\n\
48+
"If you require the component(s), please install and use the latest successful build version,\n\
4949
which you can find at <https://rust-lang.github.io/rustup-components-history>.\n\nAfter determining \
5050
the correct date, install it with a command such as:\n\n \
5151
rustup toolchain install nightly-2018-12-27\n\n\
@@ -73,15 +73,6 @@ fn components_missing_msg(cs: &[Component], manifest: &ManifestV2, toolchain: &s
7373
c.description(manifest),
7474
toolchain,
7575
);
76-
77-
if toolchain.starts_with("nightly") {
78-
let _ = write!(buf, "{nightly_tips}");
79-
}
80-
81-
let _ = write!(
82-
buf,
83-
"If you don't need the component, you could try a minimal installation with:\n\n{suggestion}\n\n{TOOLSTATE_MSG}"
84-
);
8576
}
8677
cs => {
8778
let cs_str = cs
@@ -93,18 +84,17 @@ fn components_missing_msg(cs: &[Component], manifest: &ManifestV2, toolchain: &s
9384
buf,
9485
"some components are unavailable for download for channel '{toolchain}': {cs_str}"
9586
);
96-
97-
if toolchain.starts_with("nightly") {
98-
let _ = write!(buf, "{nightly_tips}");
99-
}
100-
101-
let _ = write!(
102-
buf,
103-
"If you don't need the components, you could try a minimal installation with:\n\n{suggestion}\n\n{TOOLSTATE_MSG}"
104-
);
10587
}
10688
}
10789

90+
if toolchain.starts_with("nightly") {
91+
let _ = write!(buf, "{nightly_tips}");
92+
93+
let _ = write!(
94+
buf,
95+
"If you don't need the component(s), you could try a minimal installation with:\n\n{suggestion}\n\n{TOOLSTATE_MSG}"
96+
);
97+
}
10898
String::from_utf8(buf).unwrap()
10999
}
110100

0 commit comments

Comments
 (0)