Skip to content

Commit d65e9de

Browse files
cuviperrbtcollins
authored andcommitted
Let docs pass through with custom toolchains
Following #2116, custom toolchains started to fail `rustup doc`, since they can't list components to check if `rust-docs` is installed. error: toolchain 'system' does not support components error: caused by: invalid toolchain name: 'system' Now custom toolchains just skip that component check, and it's up to the user to have installed the documentation in their own way.
1 parent 72bea7b commit d65e9de

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

src/cli/rustup_mode.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,17 +1312,19 @@ const DOCS_DATA: &[(&str, &str, &str,)] = &[
13121312

13131313
fn doc(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<()> {
13141314
let toolchain = explicit_or_dir_toolchain(cfg, m)?;
1315-
for cstatus in &toolchain.list_components()? {
1316-
if cstatus.component.short_name_in_manifest() == "rust-docs" && !cstatus.installed {
1317-
info!(
1318-
"`rust-docs` not installed in toolchain `{}`",
1319-
toolchain.name()
1320-
);
1321-
info!(
1322-
"To install, try `rustup component add --toolchain {} rust-docs`",
1323-
toolchain.name()
1324-
);
1325-
return Err("unable to view documentation which is not installed".into());
1315+
if !toolchain.is_custom() {
1316+
for cstatus in &toolchain.list_components()? {
1317+
if cstatus.component.short_name_in_manifest() == "rust-docs" && !cstatus.installed {
1318+
info!(
1319+
"`rust-docs` not installed in toolchain `{}`",
1320+
toolchain.name()
1321+
);
1322+
info!(
1323+
"To install, try `rustup component add --toolchain {} rust-docs`",
1324+
toolchain.name()
1325+
);
1326+
return Err("unable to view documentation which is not installed".into());
1327+
}
13261328
}
13271329
}
13281330
let topical_path: PathBuf;

tests/cli-rustup.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,6 +1654,17 @@ fn docs_missing() {
16541654
});
16551655
}
16561656

1657+
#[test]
1658+
fn docs_custom() {
1659+
setup(&|config| {
1660+
let path = config.customdir.join("custom-1");
1661+
let path = path.to_string_lossy();
1662+
expect_ok(config, &["rustup", "toolchain", "link", "custom", &path]);
1663+
expect_ok(config, &["rustup", "default", "custom"]);
1664+
expect_stdout_ok(config, &["rustup", "doc", "--path"], "custom");
1665+
});
1666+
}
1667+
16571668
#[cfg(unix)]
16581669
#[test]
16591670
fn non_utf8_arg() {

0 commit comments

Comments
 (0)