about summary refs log tree commit diff
diff options
context:
space:
mode:
authoryukang <moorekang@gmail.com>2023-02-21 15:32:06 +0000
committeryukang <moorekang@gmail.com>2023-02-21 15:32:45 +0000
commit6e34e651a64260b99ea95d568d94daf7e4022f6a (patch)
tree4ea8edbf7706efcc28d8c62daa4abf4c265bddb8
parentbda32a4023b1d3f96e56e1b2fc7510324f430316 (diff)
downloadrust-6e34e651a64260b99ea95d568d94daf7e4022f6a.tar.gz
rust-6e34e651a64260b99ea95d568d94daf7e4022f6a.zip
Fix compiletest crash when test file path does not exist
-rw-r--r--src/tools/compiletest/src/main.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs
index c648b2f12f1..1760c29ec66 100644
--- a/src/tools/compiletest/src/main.rs
+++ b/src/tools/compiletest/src/main.rs
@@ -588,7 +588,8 @@ fn modified_tests(config: &Config, dir: &Path) -> Result<Vec<PathBuf>, String> {
     let full_paths = {
         let mut full_paths: Vec<PathBuf> = all_paths
             .into_iter()
-            .map(|f| fs::canonicalize(&f).unwrap().with_extension("").with_extension("rs"))
+            .map(|f| PathBuf::from(f).with_extension("").with_extension("rs"))
+            .filter_map(|f| if Path::new(&f).exists() { f.canonicalize().ok() } else { None })
             .collect();
         full_paths.dedup();
         full_paths.sort_unstable();