Skip to content

Commit 3d78767

Browse files
committed
refactor: clean some duplicate code.
1 parent 5f360fb commit 3d78767

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/cargo/ops/cargo_compile/unit_generator.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,8 @@ impl<'a> UnitGenerator<'a, '_> {
286286
}
287287
};
288288

289+
let mut msg = String::new();
289290
if !suggestion.is_empty() {
290-
let mut msg = String::new();
291291
writeln!(
292292
msg,
293293
"no {} target {} `{}`{}",
@@ -297,10 +297,7 @@ impl<'a> UnitGenerator<'a, '_> {
297297
suggestion
298298
)?;
299299
append_targets_elsewhere(&mut msg)?;
300-
301-
anyhow::bail!(msg);
302300
} else {
303-
let mut msg = String::new();
304301
writeln!(
305302
msg,
306303
"no {} target {} `{}`.",
@@ -315,8 +312,8 @@ impl<'a> UnitGenerator<'a, '_> {
315312
writeln!(msg, " {}", target.name())?;
316313
}
317314
}
318-
anyhow::bail!(msg);
319315
}
316+
anyhow::bail!(msg);
320317
}
321318
Ok(proposals)
322319
}

0 commit comments

Comments
 (0)