Go through `layout` to get doc dir output directories
authorAlex Crichton <alex@alexcrichton.com>
Fri, 19 Feb 2016 22:14:23 +0000 (14:14 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Fri, 19 Feb 2016 22:14:40 +0000 (14:14 -0800)
src/cargo/ops/cargo_rustc/layout.rs
src/cargo/ops/cargo_rustc/mod.rs

index 1be8ed4df7ca9e9b0552fc77f37832fcc7dff8a1..d25a8199d1a47c9918e640bf8aa3f5afc267cb53 100644 (file)
@@ -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))
index 593f86870a15a7d9be482f972b2265d52e3d9e13..7f2deb917f67bf42e411e0d4fd2f8ad59de75806 100644 (file)
@@ -370,12 +370,14 @@ fn rustdoc(cx: &mut Context, unit: &Unit) -> CargoResult<Work> {
            .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