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