Skip to content

Commit

Permalink
refactor: clean some duplicate code.
Browse files Browse the repository at this point in the history
  • Loading branch information
linyihai committed Feb 21, 2025
1 parent 6e93991 commit 7735088
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/cargo/ops/cargo_compile/unit_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,8 @@ impl<'a> UnitGenerator<'a, '_> {
}
};

let mut msg = String::new();
if !suggestion.is_empty() {
let mut msg = String::new();
writeln!(
msg,
"no {} target {} `{}`{}",
Expand All @@ -297,10 +297,7 @@ impl<'a> UnitGenerator<'a, '_> {
suggestion
)?;
append_targets_elsewhere(&mut msg)?;

anyhow::bail!(msg);
} else {
let mut msg = String::new();
writeln!(
msg,
"no {} target {} `{}`.",
Expand All @@ -315,8 +312,8 @@ impl<'a> UnitGenerator<'a, '_> {
writeln!(msg, " {}", target.name())?;
}
}
anyhow::bail!(msg);
}
anyhow::bail!(msg);
}
Ok(proposals)
}
Expand Down

0 comments on commit 7735088

Please sign in to comment.