Skip to content

Commit 1cef6d7

Browse files
committed
refactor: reuse error_missing_print_output on similar errors
1 parent 036ed3a commit 1cef6d7

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

src/cargo/core/compiler/build_context/target_info.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,8 @@ impl TargetInfo {
219219
map.insert(crate_type.clone(), out);
220220
}
221221

222-
let line = match lines.next() {
223-
Some(line) => line,
224-
None => anyhow::bail!(
225-
"output of --print=sysroot missing when learning about \
226-
target-specific information from rustc\n{}",
227-
output_err_info(&process, &output, &error)
228-
),
222+
let Some(line) = lines.next() else {
223+
return error_missing_print_output("sysroot", &process, &output, &error);
229224
};
230225
let sysroot = PathBuf::from(line);
231226
let sysroot_host_libdir = if cfg!(windows) {
@@ -601,12 +596,8 @@ fn parse_crate_type(
601596
};
602597
let mut parts = line.trim().split("___");
603598
let prefix = parts.next().unwrap();
604-
let suffix = match parts.next() {
605-
Some(part) => part,
606-
None => anyhow::bail!(
607-
"output of --print=file-names has changed in the compiler, cannot parse\n{}",
608-
output_err_info(cmd, output, error)
609-
),
599+
let Some(suffix) = parts.next() else {
600+
return error_missing_print_output("file-names", cmd, output, error);
610601
};
611602

612603
Ok(Some((prefix.to_string(), suffix.to_string())))

0 commit comments

Comments
 (0)