diff --git a/src/docbuilder/rustwide_builder.rs b/src/docbuilder/rustwide_builder.rs index 2f912de75..4c1aa3669 100644 --- a/src/docbuilder/rustwide_builder.rs +++ b/src/docbuilder/rustwide_builder.rs @@ -351,22 +351,23 @@ impl RustwideBuilder { if res.result.successful { if let Some(name) = res.cargo_metadata.root().library_name() { let host_target = build.host_target_dir(); - has_docs = if metadata.proc_macro { - host_target.join("doc").join(name).is_dir() - } else { - host_target - .join("doc") - .join(default_target) - .join(name) - .is_dir() - } + has_docs = host_target + .join(default_target) + .join("doc") + .join(name) + .is_dir(); } } let mut algs = HashSet::new(); if has_docs { debug!("adding documentation for the default target to the database"); - self.copy_docs(&build.host_target_dir(), local_storage.path(), "", true)?; + self.copy_docs( + &build.host_target_dir(), + local_storage.path(), + default_target, + true, + )?; successful_targets.push(res.target.clone()); @@ -607,11 +608,15 @@ impl RustwideBuilder { // However, if this is the default build, we don't want it there, // we want it in `target/doc`. // NOTE: don't rename this if the build failed, because `target//doc` won't exist. - if successful && target != HOST_TARGET && is_default_target { - // mv target/$target/doc target/doc + if successful && metadata.proc_macro { + assert!( + is_default_target && target == HOST_TARGET, + "can't handle cross-compiling macros" + ); + // mv target/doc target/$target/doc let target_dir = build.host_target_dir(); - let old_dir = target_dir.join(target).join("doc"); - let new_dir = target_dir.join("doc"); + let old_dir = target_dir.join("doc"); + let new_dir = target_dir.join(target).join("doc"); debug!("rename {} to {}", old_dir.display(), new_dir.display()); std::fs::rename(old_dir, new_dir)?; } @@ -853,11 +858,11 @@ mod tests { // doc archive exists let doc_archive = rustdoc_archive_path(crate_, version); - assert!(storage.exists(&doc_archive)?); + assert!(storage.exists(&doc_archive)?, "{}", doc_archive); // source archive exists let source_archive = source_archive_path(crate_, version); - assert!(storage.exists(&source_archive)?); + assert!(storage.exists(&source_archive)?, "{}", source_archive); // default target was built and is accessible assert!(storage.exists_in_archive(&doc_archive, &format!("{}/index.html", crate_path))?); @@ -990,11 +995,11 @@ mod tests { // doc archive exists let doc_archive = rustdoc_archive_path(crate_, version); - assert!(storage.exists(&doc_archive)?); + assert!(storage.exists(&doc_archive)?, "{}", doc_archive); // source archive exists let source_archive = source_archive_path(crate_, version); - assert!(storage.exists(&source_archive)?); + assert!(storage.exists(&source_archive)?, "{}", source_archive); let target = "x86_64-unknown-linux-gnu"; let crate_path = crate_.replace("-", "_");