Skip to content

Commit

Permalink
Respect request_kind
Browse files Browse the repository at this point in the history
  • Loading branch information
Rustin170506 committed Mar 8, 2023
1 parent 1adb8c1 commit 181c726
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/cargo/ops/cargo_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,19 @@ pub fn doc(ws: &Workspace<'_>, options: &DocOptions) -> CargoResult<()> {
let compilation = ops::compile(ws, &options.compile_opts)?;

if options.open_result {
// The open behavior is as follows:
// cargo doc --open:
// - Pick the first root unit that was built for host.
// - If none found, pick the first one(whatever it's target is).
// cargo doc --target TARGET --open:
// - Pick the first root unit for the given target.
// - If none found, pick the first one(whatever it's target is).
let request_kind = options.compile_opts.build_config.single_requested_kind()?;
let (name, kind) = &compilation
.root_crate_names
.get(0)
.iter()
.find(|(_, kind)| *kind == request_kind)
.or_else(|| compilation.root_crate_names.get(0))
.ok_or_else(|| anyhow::anyhow!("no crates with documentation"))?;

let path = compilation.root_output[&kind]
Expand Down

0 comments on commit 181c726

Please sign in to comment.