Skip to content

Commit bac98aa

Browse files
linyihaiYihai Lin
authored and
Yihai Lin
committed
refactor: clean some duplicate code.
1 parent 5ad084c commit bac98aa

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/cargo/ops/cargo_compile/unit_generator.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,9 @@ impl<'a> UnitGenerator<'a, '_> {
287287
}
288288
CargoResult::Ok(())
289289
};
290+
291+
let mut msg = String::new();
290292
if !suggestion.is_empty() {
291-
let mut msg = String::new();
292293
write!(
293294
msg,
294295
"no {} target {} `{}`{}",
@@ -298,9 +299,7 @@ impl<'a> UnitGenerator<'a, '_> {
298299
suggestion,
299300
)?;
300301
append_targets_elsewhere(&mut msg, "\n")?;
301-
anyhow::bail!(msg);
302302
} else {
303-
let mut msg = String::new();
304303
writeln!(
305304
msg,
306305
"no {} target {} `{}`.",
@@ -316,8 +315,8 @@ impl<'a> UnitGenerator<'a, '_> {
316315
writeln!(msg, " {}", target.name())?;
317316
}
318317
}
319-
anyhow::bail!(msg);
320318
}
319+
anyhow::bail!(msg);
321320
}
322321
Ok(proposals)
323322
}

0 commit comments

Comments
 (0)