From 6e34e651a64260b99ea95d568d94daf7e4022f6a Mon Sep 17 00:00:00 2001 From: yukang Date: Tue, 21 Feb 2023 15:32:06 +0000 Subject: [PATCH] Fix compiletest crash when test file path does not exist --- src/tools/compiletest/src/main.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index c648b2f12f101..1760c29ec66b7 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, String> { let full_paths = { let mut full_paths: Vec = 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();