Skip to content

Commit d4e3da3

Browse files
committed
unified nightly disclaimer wording/styling; preserved distinct messages per scenario
1 parent 8031de4 commit d4e3da3

File tree

3 files changed

+36
-42
lines changed

3 files changed

+36
-42
lines changed

src/dist/mod.rs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use tracing::{debug, info, warn};
2121

2222
use crate::{
2323
config::Cfg,
24-
errors::RustupError,
24+
errors::{RustupError, nightly_component_unavailable_help_toolchain},
2525
process::Process,
2626
toolchain::{DistributableToolchain, ToolchainName},
2727
utils,
@@ -87,22 +87,8 @@ fn components_missing_msg(cs: &[Component], manifest: &ManifestV2, toolchain: &s
8787
if toolchain.starts_with("nightly") {
8888
let _ = write!(
8989
buf,
90-
"\
91-
Sometimes not all components are available in any given nightly.
92-
If you don't need these components, you could try a minimal installation with:
93-
94-
rustup toolchain add {toolchain} --profile minimal
95-
96-
If you require these components, please install and use the latest successfully built version,
97-
which you can find at <https://rust-lang.github.io/rustup-components-history>.
98-
99-
After determining the correct date, install it with a command such as:
100-
101-
rustup toolchain install nightly-2018-12-27
102-
103-
Then you can use the toolchain with commands such as:
104-
105-
cargo +nightly-2018-12-27 build"
90+
"{}",
91+
nightly_component_unavailable_help_toolchain(toolchain)
10692
);
10793
} else if ["beta", "stable"].iter().any(|&p| toolchain.starts_with(p)) {
10894
let _ = write!(

src/errors.rs

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,25 @@ fn suggest_message(suggestion: &Option<String>) -> String {
181181
}
182182
}
183183

184+
const NIGHTLY_COMPONENT_NOTE: &str =
185+
"note: sometimes not all components are available in any given nightly";
186+
187+
/// Returns extended note/help for toolchain-wide nightly failures (includes pinned-nightly guidance).
188+
pub(crate) fn nightly_component_unavailable_help_toolchain(toolchain: &str) -> String {
189+
format!(
190+
"\n{NIGHTLY_COMPONENT_NOTE}\n\
191+
help: if you don't need these components, you could try a minimal installation with:\n\
192+
help: rustup toolchain add {toolchain} --profile minimal\n\
193+
help: if you require these components, please install and use the latest successfully built version,\n\
194+
help: which you can find at <https://rust-lang.github.io/rustup-components-history>\n\
195+
help: after determining the correct date, install it with a command such as:\n\
196+
help: rustup toolchain install nightly-2018-12-27\n\
197+
help: then you can use the toolchain with commands such as:\n\
198+
help: cargo +nightly-2018-12-27 build\n",
199+
toolchain = toolchain
200+
)
201+
}
202+
184203
/// Returns a error message indicating that certain [`Component`]s are unavailable.
185204
///
186205
/// See also [`components_missing_msg`](../dist/dist/fn.components_missing_msg.html)
@@ -203,10 +222,7 @@ fn component_unavailable_msg(cs: &[Component], manifest: &Manifest, toolchain: &
203222
);
204223

205224
if toolchain.starts_with("nightly") {
206-
let _ = write!(
207-
buf,
208-
"(sometimes not all components are available in any given nightly)"
209-
);
225+
let _ = writeln!(buf, "{NIGHTLY_COMPONENT_NOTE}");
210226
}
211227
}
212228
cs => {
@@ -227,16 +243,13 @@ fn component_unavailable_msg(cs: &[Component], manifest: &Manifest, toolchain: &
227243
.join(", ")
228244
};
229245

230-
let _ = write!(
246+
let _ = writeln!(
231247
buf,
232-
"some components are unavailable for download for channel '{toolchain}': {cs_str}"
248+
"some components are unavailable for download for channel '{toolchain}': {cs_str}",
233249
);
234250

235251
if toolchain.starts_with("nightly") {
236-
let _ = write!(
237-
buf,
238-
"(sometimes not all components are available in any given nightly)"
239-
);
252+
let _ = writeln!(buf, "{NIGHTLY_COMPONENT_NOTE}");
240253
}
241254
}
242255
}

tests/suite/cli_v2.rs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1972,7 +1972,7 @@ async fn add_missing_component() {
19721972
.with_stderr(snapbox::str![[r#"
19731973
...
19741974
error: component 'rls' for target '[HOST_TRIPLE]' is unavailable for download for channel 'nightly'
1975-
(sometimes not all components are available in any given nightly)
1975+
note: sometimes not all components are available in any given nightly
19761976
...
19771977
"#]])
19781978
.is_err();
@@ -1995,21 +1995,16 @@ async fn add_missing_component_toolchain() {
19951995
.with_stderr(snapbox::str![[r#"
19961996
...
19971997
error: component 'rust-std' for target '[HOST_TRIPLE]' is unavailable for download for channel 'nightly'
1998-
Sometimes not all components are available in any given nightly.
1999-
If you don't need these components, you could try a minimal installation with:
20001998
2001-
rustup toolchain add nightly --profile minimal
2002-
2003-
If you require these components, please install and use the latest successfully built version,
2004-
which you can find at <https://rust-lang.github.io/rustup-components-history>.
2005-
2006-
After determining the correct date, install it with a command such as:
2007-
2008-
rustup toolchain install nightly-2018-12-27
2009-
2010-
Then you can use the toolchain with commands such as:
2011-
2012-
cargo +nightly-2018-12-27 build
1999+
note: sometimes not all components are available in any given nightly
2000+
help: if you don't need these components, you could try a minimal installation with:
2001+
help: rustup toolchain add nightly --profile minimal
2002+
help: if you require these components, please install and use the latest successfully built version,
2003+
help: which you can find at <https://rust-lang.github.io/rustup-components-history>
2004+
help: after determining the correct date, install it with a command such as:
2005+
help: rustup toolchain install nightly-2018-12-27
2006+
help: then you can use the toolchain with commands such as:
2007+
help: cargo +nightly-2018-12-27 build
20132008
...
20142009
"#]])
20152010
.is_err();

0 commit comments

Comments
 (0)