Skip to content

Commit

Permalink
Auto merge of #10204 - hi-rustin:rustin-patch-doc, r=alexcrichton
Browse files Browse the repository at this point in the history
Error about not having any crates with documentation

close #10194

Error about not having any crates with documentation.
  • Loading branch information
bors committed Dec 16, 2021
2 parents 99627cd + 07843ed commit b9bc3d1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/cargo/ops/cargo_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ pub fn doc(ws: &Workspace<'_>, options: &DocOptions) -> CargoResult<()> {
let compilation = ops::compile(ws, &options.compile_opts)?;

if options.open_result {
let name = &compilation.root_crate_names[0];
let name = &compilation
.root_crate_names
.get(0)
.ok_or_else(|| anyhow::anyhow!("no crates with documentation"))?;
let kind = options.compile_opts.build_config.single_requested_kind()?;
let path = compilation.root_output[&kind]
.with_file_name("doc")
Expand Down
25 changes: 25 additions & 0 deletions tests/testsuite/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1344,6 +1344,31 @@ fn doc_extern_map_local() {
.run();
}

#[cargo_test]
fn open_no_doc_crate() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "a"
version = "0.0.1"
authors = []
[lib]
doc = false
"#,
)
.file("src/lib.rs", "#[cfg(feature)] pub fn f();")
.build();

p.cargo("doc --open")
.env("BROWSER", "do_not_run_me")
.with_status(101)
.with_stderr_contains("error: no crates with documentation")
.run();
}

#[cargo_test]
fn doc_workspace_open_different_library_and_package_names() {
let p = project()
Expand Down

0 comments on commit b9bc3d1

Please sign in to comment.