Skip to content

Commit 3f05b1f

Browse files
committed
don't return a Result from symlink_dir_force
this gives a more helpful backtrace if it fails before: ``` thread 'main' panicked at 'symlink_dir_force(&builder.config, &out, &out_dir) failed with No such file or directory (os error 2)', doc.rs:697:9 ``` after: ``` thread 'main' panicked at 'symlink_dir(config, original, link) failed with No such file or directory (os error 2) ("failed to create link from /home/jyn/src/rust2/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/doc -> /home/jyn/src/rust2/build/x86_64-unknown-linux-gnu/compiler-doc")', doc.rs:975:5 ```
1 parent c57eb1b commit 3f05b1f

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/bootstrap/doc.rs

+11-9
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
//! `rustdoc`.
99
1010
use std::fs;
11-
use std::io;
1211
use std::path::{Path, PathBuf};
1312

1413
use crate::builder::crate_description;
@@ -694,11 +693,11 @@ impl Step for Rustc {
694693
// rustc. rustdoc needs to be able to see everything, for example when
695694
// merging the search index, or generating local (relative) links.
696695
let out_dir = builder.stage_out(compiler, Mode::Rustc).join(target.triple).join("doc");
697-
t!(symlink_dir_force(&builder.config, &out, &out_dir));
696+
symlink_dir_force(&builder.config, &out, &out_dir);
698697
// Cargo puts proc macros in `target/doc` even if you pass `--target`
699698
// explicitly (https://github.com/rust-lang/cargo/issues/7677).
700699
let proc_macro_out_dir = builder.stage_out(compiler, Mode::Rustc).join("doc");
701-
t!(symlink_dir_force(&builder.config, &out, &proc_macro_out_dir));
700+
symlink_dir_force(&builder.config, &out, &proc_macro_out_dir);
702701

703702
// Build cargo command.
704703
let mut cargo = builder.cargo(compiler, Mode::Rustc, SourceType::InTree, target, "doc");
@@ -816,7 +815,7 @@ macro_rules! tool_doc {
816815
];
817816
for out_dir in out_dirs {
818817
t!(fs::create_dir_all(&out_dir));
819-
t!(symlink_dir_force(&builder.config, &out, &out_dir));
818+
symlink_dir_force(&builder.config, &out, &out_dir);
820819
}
821820

822821
// Build cargo command.
@@ -959,21 +958,24 @@ impl Step for UnstableBookGen {
959958
}
960959
}
961960

962-
fn symlink_dir_force(config: &Config, original: &Path, link: &Path) -> io::Result<()> {
961+
fn symlink_dir_force(config: &Config, original: &Path, link: &Path) {
963962
if config.dry_run() {
964-
return Ok(());
963+
return;
965964
}
966965
if let Ok(m) = fs::symlink_metadata(link) {
967966
if m.file_type().is_dir() {
968-
fs::remove_dir_all(link)?;
967+
t!(fs::remove_dir_all(link));
969968
} else {
970969
// handle directory junctions on windows by falling back to
971970
// `remove_dir`.
972-
fs::remove_file(link).or_else(|_| fs::remove_dir(link))?;
971+
t!(fs::remove_file(link).or_else(|_| fs::remove_dir(link)));
973972
}
974973
}
975974

976-
symlink_dir(config, original, link)
975+
t!(
976+
symlink_dir(config, original, link),
977+
format!("failed to create link from {} -> {}", link.display(), original.display())
978+
);
977979
}
978980

979981
#[derive(Ord, PartialOrd, Debug, Copy, Clone, Hash, PartialEq, Eq)]

0 commit comments

Comments
 (0)