diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 1fa31181fd5..6a889d27793 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -1146,11 +1146,9 @@ fn expand_variables(mut value: String, config: &Config) -> String { } if value.contains(RUST_SRC_BASE) { - let src_base = config - .sysroot_base - .join("lib/rustlib/src/rust") - .read_link() - .expect("lib/rustlib/src/rust in target is a symlink to checkout root"); + let src_base = config.sysroot_base.join("lib/rustlib/src/rust"); + src_base.try_exists().expect(&*format!("{} should exists", src_base.display())); + let src_base = src_base.read_link().unwrap_or(src_base); value = value.replace(RUST_SRC_BASE, &src_base.to_string_lossy()); } diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 1a1cc86e2de..922492e451f 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2311,12 +2311,9 @@ fn normalize_output(&self, output: &str, custom_rules: &[(String, String)]) -> S normalize_path(parent_build_dir, "$BUILD_DIR"); // Real paths into the libstd/libcore - let rust_src_dir = &self - .config - .sysroot_base - .join("lib/rustlib/src/rust") - .read_link() - .expect("lib/rustlib/src/rust in target is a symlink to checkout root"); + let rust_src_dir = &self.config.sysroot_base.join("lib/rustlib/src/rust"); + rust_src_dir.try_exists().expect(&*format!("{} should exists", rust_src_dir.display())); + let rust_src_dir = rust_src_dir.read_link().unwrap_or(rust_src_dir.to_path_buf()); normalize_path(&rust_src_dir.join("library"), "$SRC_DIR_REAL"); if json {