Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanly report when rust-docs isn't installed #2116

Merged
merged 1 commit into from
Nov 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1277,6 +1277,19 @@ const DOCS_DATA: &[(&str, &str, &str,)] = &[

fn doc(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<()> {
let toolchain = explicit_or_dir_toolchain(cfg, m)?;
for cstatus in &toolchain.list_components()? {
if cstatus.component.short_name_in_manifest() == "rust-docs" && !cstatus.installed {
info!(
"`rust-docs` not installed in toolchain `{}`",
toolchain.name()
);
info!(
"To install, try `rustup component add --toolchain {} rust-docs`",
toolchain.name()
);
return Err("unable to view documentation which is not installed".into());
}
}
let topical_path: PathBuf;

let doc_url = if let Some(topic) = m.value_of("topic") {
Expand Down
13 changes: 13 additions & 0 deletions tests/cli-rustup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1616,6 +1616,19 @@ fn docs_topical_with_path() {
});
}

#[test]
fn docs_missing() {
setup(&|config| {
expect_ok(config, &["rustup", "set", "profile", "minimal"]);
expect_ok(config, &["rustup", "default", "nightly"]);
expect_err(
config,
&["rustup", "doc"],
"error: unable to view documentation which is not installed",
);
});
}

#[cfg(unix)]
#[test]
fn non_utf8_arg() {
Expand Down