mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
refactor: clean some duplicate code.
This commit is contained in:
parent
5ad084c3b0
commit
bac98aaa9f
@ -287,8 +287,9 @@ impl<'a> UnitGenerator<'a, '_> {
|
||||
}
|
||||
CargoResult::Ok(())
|
||||
};
|
||||
|
||||
let mut msg = String::new();
|
||||
if !suggestion.is_empty() {
|
||||
let mut msg = String::new();
|
||||
write!(
|
||||
msg,
|
||||
"no {} target {} `{}`{}",
|
||||
@ -298,9 +299,7 @@ impl<'a> UnitGenerator<'a, '_> {
|
||||
suggestion,
|
||||
)?;
|
||||
append_targets_elsewhere(&mut msg, "\n")?;
|
||||
anyhow::bail!(msg);
|
||||
} else {
|
||||
let mut msg = String::new();
|
||||
writeln!(
|
||||
msg,
|
||||
"no {} target {} `{}`.",
|
||||
@ -316,8 +315,8 @@ impl<'a> UnitGenerator<'a, '_> {
|
||||
writeln!(msg, " {}", target.name())?;
|
||||
}
|
||||
}
|
||||
anyhow::bail!(msg);
|
||||
}
|
||||
anyhow::bail!(msg);
|
||||
}
|
||||
Ok(proposals)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user