mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-25 11:14:46 +00:00
fix(compile): Remove trailing newlines on errors
This commit is contained in:
parent
c2764576ac
commit
fde91dde66
@ -271,7 +271,7 @@ impl<'a> UnitGenerator<'a, '_> {
|
||||
let suggestion = closest_msg(target_name, targets.iter(), |t| t.name(), "target");
|
||||
let targets_elsewhere = self.get_targets_from_other_packages(filter)?;
|
||||
let need_append_targets_elsewhere = !targets_elsewhere.is_empty();
|
||||
let append_targets_elsewhere = |msg: &mut String, prefix: &str| {
|
||||
let append_targets_elsewhere = |msg: &mut String| {
|
||||
let mut available_msg = Vec::new();
|
||||
for (package, targets) in targets_elsewhere {
|
||||
if !targets.is_empty() {
|
||||
@ -284,7 +284,7 @@ impl<'a> UnitGenerator<'a, '_> {
|
||||
}
|
||||
}
|
||||
if !available_msg.is_empty() {
|
||||
write!(msg, "{prefix}{}", available_msg.join("\n"))?;
|
||||
write!(msg, "\n{}", available_msg.join("\n"))?;
|
||||
}
|
||||
CargoResult::Ok(())
|
||||
};
|
||||
@ -313,18 +313,18 @@ impl<'a> UnitGenerator<'a, '_> {
|
||||
msg,
|
||||
"no {target_desc} target {named} `{target_name}` in {unmatched_packages}{suggestion}",
|
||||
)?;
|
||||
append_targets_elsewhere(&mut msg, "\n")?;
|
||||
append_targets_elsewhere(&mut msg)?;
|
||||
} else {
|
||||
writeln!(
|
||||
write!(
|
||||
msg,
|
||||
"no {target_desc} target {named} `{target_name}` in {unmatched_packages}",
|
||||
)?;
|
||||
|
||||
append_targets_elsewhere(&mut msg, "")?;
|
||||
append_targets_elsewhere(&mut msg)?;
|
||||
if !targets.is_empty() && !need_append_targets_elsewhere {
|
||||
writeln!(msg, "Available {} targets:", target_desc)?;
|
||||
write!(msg, "\nAvailable {} targets:", target_desc)?;
|
||||
for target in targets {
|
||||
writeln!(msg, " {}", target.name())?;
|
||||
write!(msg, "\n {}", target.name())?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1341,7 +1341,6 @@ fn cargo_compile_with_filename() {
|
||||
Available bin targets:
|
||||
a
|
||||
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
|
||||
@ -1362,7 +1361,6 @@ Available bin targets:
|
||||
Available example targets:
|
||||
a
|
||||
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
|
||||
|
@ -627,7 +627,6 @@ https://github.com/rust-lang/cargo/issues/5330
|
||||
Available example targets:
|
||||
do_magic
|
||||
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
@ -659,7 +658,6 @@ fn run_example_autodiscover_2015_with_autoexamples_disabled() {
|
||||
Available example targets:
|
||||
do_magic
|
||||
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
@ -747,7 +745,6 @@ fn run_with_filename() {
|
||||
Available bin targets:
|
||||
a
|
||||
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
|
||||
@ -768,7 +765,6 @@ Available bin targets:
|
||||
Available example targets:
|
||||
a
|
||||
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
|
||||
@ -854,7 +850,6 @@ Available bin targets:
|
||||
ambiguous
|
||||
ambiguous
|
||||
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
@ -2449,7 +2449,6 @@ fn bad_example() {
|
||||
.with_stderr_data(str![[r#"
|
||||
[ERROR] no example target named `foo` in default-run packages
|
||||
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
p.cargo("run --bin foo")
|
||||
@ -2457,7 +2456,6 @@ fn bad_example() {
|
||||
.with_stderr_data(str![[r#"
|
||||
[ERROR] no bin target named `foo` in default-run packages
|
||||
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user