From 871e281cff34d9dba177c6e59077a8886f454b29 Mon Sep 17 00:00:00 2001 From: Bilal Khan Date: Fri, 20 Dec 2024 03:46:16 +0500 Subject: [PATCH] fixed the error message for a user to open the crate --- src/cargo/ops/cargo_doc.rs | 9 +++++---- tests/testsuite/doc.rs | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/cargo/ops/cargo_doc.rs b/src/cargo/ops/cargo_doc.rs index 5f7e9ad131a..efca9861d31 100644 --- a/src/cargo/ops/cargo_doc.rs +++ b/src/cargo/ops/cargo_doc.rs @@ -56,10 +56,11 @@ 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 - .get(0) - .ok_or_else(|| anyhow::anyhow!("no crates with documentation"))?; + let name = &compilation.root_crate_names.get(0).ok_or_else(|| { + anyhow::anyhow!( + "cannot open specified crate's documentation: no documentation generated" + ) + })?; let kind = options.compile_opts.build_config.single_requested_kind()?; let path = path_by_output_format(&compilation, &kind, &name, &options.output_format); diff --git a/tests/testsuite/doc.rs b/tests/testsuite/doc.rs index ede038b0e7e..fcaa553f027 100644 --- a/tests/testsuite/doc.rs +++ b/tests/testsuite/doc.rs @@ -1501,7 +1501,7 @@ fn open_no_doc_crate() { .with_status(101) .with_stderr_data(str![[r#" [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s -[ERROR] no crates with documentation +[ERROR] cannot open specified crate's documentation: no documentation generated "#]]) .run();