Skip to content

Commit f41217e

Browse files
committed
refactor(dist): inline some const strings in components_missing_msg()
1 parent dbaa02b commit f41217e

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

src/dist/mod.rs

+17-13
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,6 @@ pub(crate) use triple::*;
4646

4747
pub static DEFAULT_DIST_SERVER: &str = "https://static.rust-lang.org";
4848

49-
const TOOLSTATE_MSG: &str =
50-
"If you require these components, please install and use the latest successfully built version,\n\
51-
which you can find at <https://rust-lang.github.io/rustup-components-history>.\n\nAfter determining \
52-
the correct date, install it with a command such as:\n\n \
53-
rustup toolchain install nightly-2018-12-27\n\n\
54-
Then you can use the toolchain with commands such as:\n\n \
55-
cargo +nightly-2018-12-27 build";
56-
5749
/// Returns a error message indicating that certain [`Component`]s are missing in a toolchain distribution.
5850
///
5951
/// This message is currently used exclusively in toolchain-wide operations,
@@ -63,8 +55,6 @@ const TOOLSTATE_MSG: &str =
6355
/// This function will panic when the collection of unavailable components `cs` is empty.
6456
fn components_missing_msg(cs: &[Component], manifest: &ManifestV2, toolchain: &str) -> String {
6557
let mut buf = vec![];
66-
let suggestion = format!(" rustup toolchain add {toolchain} --profile minimal");
67-
let nightly_tips = "Sometimes not all components are available in any given nightly. ";
6858

6959
match cs {
7060
[] => 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
9080
}
9181

9282
if toolchain.starts_with("nightly") {
93-
let _ = write!(buf, "{nightly_tips}");
94-
9583
let _ = write!(
9684
buf,
97-
"If you don't need these components, you could try a minimal installation with:\n\n{suggestion}\n\n{TOOLSTATE_MSG}"
85+
"\
86+
Sometimes not all components are available in any given nightly.
87+
If you don't need these components, you could try a minimal installation with:
88+
89+
rustup toolchain add {toolchain} --profile minimal
90+
91+
If you require these components, please install and use the latest successfully built version,
92+
which you can find at <https://rust-lang.github.io/rustup-components-history>.
93+
94+
After determining the correct date, install it with a command such as:
95+
96+
rustup toolchain install nightly-2018-12-27
97+
98+
Then you can use the toolchain with commands such as:
99+
100+
cargo +nightly-2018-12-27 build"
98101
);
99102
}
103+
100104
String::from_utf8(buf).unwrap()
101105
}
102106

0 commit comments

Comments
 (0)