Skip to content

Commit

Permalink
fixed the error message for a user to open the crate
Browse files Browse the repository at this point in the history
  • Loading branch information
ibilalkayy committed Dec 19, 2024
1 parent c2b0d50 commit 871e281
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/cargo/ops/cargo_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 871e281

Please sign in to comment.