Skip to content

Commit 671ba3f

Browse files
committed
Spot the typo easily
1 parent cc80b40 commit 671ba3f

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/cargo/core/resolver/errors.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,7 @@ pub(super) fn activation_error(
285285
.collect();
286286
candidates.sort_by_key(|o| o.0);
287287
let mut msg = format!(
288-
"no matching package named `{}` found\n\
289-
location searched: {}\n",
290-
dep.package_name(),
291-
dep.source_id()
292-
);
288+
"no matching package named `{}` found\n", dep.package_name());
293289
if !candidates.is_empty() {
294290
// If dependency package name is equal to the name of the candidate here
295291
// it may be a prerelease package which hasn't been specified correctly
@@ -312,8 +308,9 @@ pub(super) fn activation_error(
312308
if candidates.len() > 3 {
313309
names.push("...");
314310
}
315-
316-
msg.push_str("perhaps you meant: ");
311+
// Vertically align first suggestion with missing crate name
312+
// so the silly typo you probably made jumps out at you.
313+
msg.push_str("perhaps you meant: ");
317314
msg.push_str(&names.iter().enumerate().fold(
318315
String::default(),
319316
|acc, (i, el)| match i {
@@ -323,9 +320,9 @@ pub(super) fn activation_error(
323320
},
324321
));
325322
}
326-
327323
msg.push('\n');
328324
}
325+
msg.push_str(&format!("location searched: {}\n", dep.source_id()));
329326
msg.push_str("required by ");
330327
msg.push_str(&describe_path(
331328
&cx.parents.path_to_bottom(&parent.package_id()),

0 commit comments

Comments
 (0)