Skip to content

Commit 1adb8c1

Browse files
committed
cargo doc --open respect forced-target
1 parent 234d9f6 commit 1adb8c1

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/cargo/core/compiler/compilation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub struct Compilation<'cfg> {
5656
pub cdylibs: Vec<UnitOutput>,
5757

5858
/// The crate names of the root units specified on the command-line.
59-
pub root_crate_names: Vec<String>,
59+
pub root_crate_names: Vec<(String, CompileKind)>,
6060

6161
/// All directories for the output of native build commands.
6262
///

src/cargo/core/compiler/context/mod.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,12 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
321321
}
322322
self.primary_packages
323323
.extend(self.bcx.roots.iter().map(|u| u.pkg.package_id()));
324-
self.compilation
325-
.root_crate_names
326-
.extend(self.bcx.roots.iter().map(|u| u.target.crate_name()));
324+
self.compilation.root_crate_names.extend(
325+
self.bcx
326+
.roots
327+
.iter()
328+
.map(|u| (u.target.crate_name(), u.kind.clone())),
329+
);
327330

328331
self.record_units_requiring_metadata();
329332

src/cargo/ops/cargo_doc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ 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
23+
let (name, kind) = &compilation
2424
.root_crate_names
2525
.get(0)
2626
.ok_or_else(|| anyhow::anyhow!("no crates with documentation"))?;
27-
let kind = options.compile_opts.build_config.single_requested_kind()?;
27+
2828
let path = compilation.root_output[&kind]
2929
.with_file_name("doc")
3030
.join(&name)

0 commit comments

Comments
 (0)