Commit 2254991d authored by Tamir Duberstein's avatar Tamir Duberstein Committed by Miguel Ojeda
Browse files

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: default avatarTamir 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: default avatarMiguel Ojeda <ojeda@kernel.org>
parent 8b097b5a
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -92,13 +92,15 @@ fn find_candidates(
        ),
        [valid_path] => valid_path.to_str().unwrap(),
        valid_paths => {
            eprintln!("Several path candidates found:");
            use std::fmt::Write;

            let mut candidates = String::new();
            for path in valid_paths {
                eprintln!("    {path:?}");
                writeln!(&mut candidates, "    {path:?}").unwrap();
            }
            panic!(
                "Several path candidates found for `{file}`, please resolve the ambiguity by \
                renaming a file or folder."
                renaming a file or folder. Candidates:\n{candidates}",
            );
        }
    }