Skip to content

Commit 2f3afa5

Browse files
linyihaiYihai Lin
authored andcommitted
refactor: clean some duplicate code.
1 parent 5ec4f8e commit 2f3afa5

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/cargo/ops/cargo_compile/unit_generator.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,8 @@ impl<'a> UnitGenerator<'a, '_> {
282282
CargoResult::Ok(())
283283
};
284284

285+
let mut msg = String::new();
285286
if !suggestion.is_empty() {
286-
let mut msg = String::new();
287287
write!(
288288
msg,
289289
"no {} target {} `{}`{}{}",
@@ -298,9 +298,7 @@ impl<'a> UnitGenerator<'a, '_> {
298298
},
299299
)?;
300300
append_targets_elsewhere(&mut msg)?;
301-
anyhow::bail!(msg);
302301
} else {
303-
let mut msg = String::new();
304302
writeln!(
305303
msg,
306304
"no {} target {} `{}`.",
@@ -316,8 +314,8 @@ impl<'a> UnitGenerator<'a, '_> {
316314
writeln!(msg, " {}", target.name())?;
317315
}
318316
}
319-
anyhow::bail!(msg);
320317
}
318+
anyhow::bail!(msg);
321319
}
322320
Ok(proposals)
323321
}

0 commit comments

Comments
 (0)