let describe_path = |pkgid: &PackageId| -> String {
let dep_path = resolve.path_to_top(pkgid);
if dep_path.is_empty() {
- String::from("(This is the root-package)")
+ String::from("The root-package ")
} else {
- let mut pkg_path_desc = String::from("(Dependency via ");
- let mut dep_path_iter = dep_path.into_iter().peekable();
- while let Some(dep) = dep_path_iter.next() {
- write!(pkg_path_desc, "{}", dep).unwrap();
- if dep_path_iter.peek().is_some() {
- pkg_path_desc.push_str(" => ");
- }
+ let mut dep_path_desc = format!("Package `{}`\n", pkgid);
+ for dep in dep_path {
+ write!(dep_path_desc,
+ " ... which is depended on by `{}`\n",
+ dep).unwrap();
}
- pkg_path_desc.push(')');
- pkg_path_desc
+ dep_path_desc
}
};
- bail!("More than one package links to native library `{}`, \
- which can only be linked once.\n\n\
- Package {} links to native library `{}`.\n\
- {}\n\
+ bail!("Multiple packages link to native library `{}`. \
+ A native library can be linked only once.\n\
\n\
- Package {} also links to native library `{}`.\n\
- {}\n\
+ {}links to native library `{}`.\n\
\n\
- Try updating or pinning your dependencies to ensure that \
- native library `{}` is only linked once.",
+ {}also links to native library `{}`.",
lib,
- prev, lib,
- describe_path(prev),
- pkg, lib,
- describe_path(pkg),
- lib)
+ describe_path(prev), lib,
+ describe_path(pkg), lib)
}
if !unit.pkg.manifest().targets().iter().any(|t| t.is_custom_build()) {
bail!("package `{}` specifies that it links to `{}` but does not \
assert_that(p.cargo_process("build"),
execs().with_status(101)
.with_stderr("\
-error: More than one package links to native library `a`, which can only be \
-linked once.
+[ERROR] Multiple packages link to native library `a`. A native library can be \
+linked only once.
-Package foo v0.5.0 (file://[..]) links to native library `a`.
-(This is the root-package)
+The root-package links to native library `a`.
-Package a-sys v0.5.0 (file://[..]) also links to native library `a`.
-(Dependency via foo v0.5.0 (file://[..]))
-
-Try updating[..]
+Package `a-sys v0.5.0 (file://[..])`
+ ... which is depended on by `foo v0.5.0 (file://[..])`
+also links to native library `a`.
"));
}
assert_that(p.cargo_process("build"),
execs().with_status(101)
.with_stderr("\
-error: More than one package links to native library `a`, which can only be \
-linked once.
-
-Package foo v0.5.0 (file://[..]) links to native library `a`.
-(This is the root-package)
+[ERROR] Multiple packages link to native library `a`. A native library can be \
+linked only once.
-Package a-sys v0.5.0 (file://[..]) also links to native library `a`.
-(Dependency via a v0.5.0 (file://[..]) => foo v0.5.0 (file://[..]))
+The root-package links to native library `a`.
-Try updating[..]
+Package `a-sys v0.5.0 (file://[..])`
+ ... which is depended on by `a v0.5.0 (file://[..])`
+ ... which is depended on by `foo v0.5.0 (file://[..])`
+also links to native library `a`.
"));
}