Skip to content

Commit 2254991

Browse files
tamirdojeda
authored andcommitted
scripts: rust: emit path candidates in panic message
Include all information in the panic message rather than emit fragments to stderr to avoid possible interleaving with other output. Signed-off-by: Tamir Duberstein <tamird@gmail.com> Link: https://lore.kernel.org/r/20250529-idiomatic-match-slice-v2-2-4925ca2f1550@gmail.com [ Kept newlines using `writeln!`. Used new message from Tamir. Reworded title. - Miguel ] Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent 8b097b5 commit 2254991

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

scripts/rustdoc_test_gen.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,15 @@ fn find_real_path<'a>(srctree: &Path, valid_paths: &'a mut Vec<PathBuf>, file: &
9292
),
9393
[valid_path] => valid_path.to_str().unwrap(),
9494
valid_paths => {
95-
eprintln!("Several path candidates found:");
95+
use std::fmt::Write;
96+
97+
let mut candidates = String::new();
9698
for path in valid_paths {
97-
eprintln!(" {path:?}");
99+
writeln!(&mut candidates, " {path:?}").unwrap();
98100
}
99101
panic!(
100102
"Several path candidates found for `{file}`, please resolve the ambiguity by \
101-
renaming a file or folder."
103+
renaming a file or folder. Candidates:\n{candidates}",
102104
);
103105
}
104106
}

0 commit comments

Comments
 (0)