summaryrefslogtreecommitdiff
path: root/scripts/rustdoc_test_gen.rs
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/rustdoc_test_gen.rs')
-rw-r--r--scripts/rustdoc_test_gen.rs33
1 files changed, 17 insertions, 16 deletions
diff --git a/scripts/rustdoc_test_gen.rs b/scripts/rustdoc_test_gen.rs
index 1ca253594d38..abb34ada2508 100644
--- a/scripts/rustdoc_test_gen.rs
+++ b/scripts/rustdoc_test_gen.rs
@@ -85,24 +85,25 @@ fn find_real_path<'a>(srctree: &Path, valid_paths: &'a mut Vec<PathBuf>, file: &
}
}
- assert!(
- valid_paths.len() > 0,
- "No path candidates found for `{file}`. This is likely a bug in the build system, or some \
- files went away while compiling."
- );
-
- if valid_paths.len() > 1 {
- eprintln!("Several path candidates found:");
- for path in valid_paths {
- eprintln!(" {path:?}");
+ match valid_paths.as_slice() {
+ [] => panic!(
+ "No path candidates found for `{file}`. This is likely a bug in the build system, or \
+ some files went away while compiling."
+ ),
+ [valid_path] => valid_path.to_str().unwrap(),
+ valid_paths => {
+ use std::fmt::Write;
+
+ let mut candidates = String::new();
+ for path in valid_paths {
+ writeln!(&mut candidates, " {path:?}").unwrap();
+ }
+ panic!(
+ "Several path candidates found for `{file}`, please resolve the ambiguity by \
+ renaming a file or folder. Candidates:\n{candidates}",
+ );
}
- panic!(
- "Several path candidates found for `{file}`, please resolve the ambiguity by renaming \
- a file or folder."
- );
}
-
- valid_paths[0].to_str().unwrap()
}
fn main() {