Skip to content

Commit 94d0767

Browse files
committed
Error when the absence of any crates with files
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
1 parent 99627cd commit 94d0767

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/cargo/ops/cargo_doc.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ pub fn doc(ws: &Workspace<'_>, options: &DocOptions) -> CargoResult<()> {
2020
let compilation = ops::compile(ws, &options.compile_opts)?;
2121

2222
if options.open_result {
23-
let name = &compilation.root_crate_names[0];
23+
let name = &compilation
24+
.root_crate_names
25+
.get(0)
26+
.ok_or_else(|| anyhow::anyhow!("no crates with documentation"))?;
2427
let kind = options.compile_opts.build_config.single_requested_kind()?;
2528
let path = compilation.root_output[&kind]
2629
.with_file_name("doc")

0 commit comments

Comments
 (0)