From 0b256d34a944ccc383df02183245a93710a52f26 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 19 Feb 2016 14:14:23 -0800 Subject: [PATCH] Go through `layout` to get doc dir output directories --- src/cargo/ops/cargo_rustc/layout.rs | 1 + src/cargo/ops/cargo_rustc/mod.rs | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/layout.rs b/src/cargo/ops/cargo_rustc/layout.rs index 1be8ed4df..d25a8199d 100644 --- a/src/cargo/ops/cargo_rustc/layout.rs +++ b/src/cargo/ops/cargo_rustc/layout.rs @@ -116,6 +116,7 @@ impl Layout { pub fn dest(&self) -> &Path { &self.root } pub fn deps(&self) -> &Path { &self.deps } pub fn examples(&self) -> &Path { &self.examples } + pub fn root(&self) -> &Path { &self.root } pub fn fingerprint(&self, package: &Package) -> PathBuf { self.fingerprint.join(&self.pkg_dir(package)) diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 593f86870..7f2deb917 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -370,12 +370,14 @@ fn rustdoc(cx: &mut Context, unit: &Unit) -> CargoResult { .cwd(cx.config.cwd()) .arg("--crate-name").arg(&unit.target.crate_name()); - let mut doc_dir = cx.config.target_dir(cx.get_package(cx.resolve.root())); if let Some(target) = cx.requested_target() { rustdoc.arg("--target").arg(target); - doc_dir.push(target); } - doc_dir.push("doc"); + + // the "root" directory ends in 'debug' or 'release', and we want it to end + // in 'doc' instead + let doc_dir = cx.layout(unit.pkg, unit.kind).proxy().root(); + let doc_dir = doc_dir.parent().unwrap().join("doc"); // Create the documentation directory ahead of time as rustdoc currently has // a bug where concurrent invocations will race to create this directory if -- 2.39.5