Skip to content

Commit d3327bd

Browse files
committed
Auto merge of rust-lang#7380 - popzxc:compile-test-helper, r=flip1995
Improve panic message on "Found multiple rlibs" error in compile-test Related to rust-lang#7343 When I first met this error I was pretty much confused, so I thought it may be a good idea to: - Give a hint on what to do to users that don't want to dig into specifics and just want to quickly resolve the issue. - Give a link for those who are interested in details. ## Old appearance: <img width="1121" alt="Screenshot 2021-06-20 at 08 30 34" src="https://user-images.githubusercontent.com/12111581/122663361-df8ae780-d1aa-11eb-9236-775b4fd754d5.png"> ## New appearance: <img width="1121" alt="Screenshot 2021-06-20 at 08 32 18" src="https://user-images.githubusercontent.com/12111581/122663363-e4e83200-d1aa-11eb-9c46-f62d83eb79e2.png"> *Please write a short comment explaining your change (or "none" for internal only changes)* changelog: none
2 parents 3120b09 + 310a204 commit d3327bd

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

tests/compile-test.rs

+18-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,24 @@ fn third_party_crates() -> String {
4848
&& name.rsplit('.').next().map(|ext| ext.eq_ignore_ascii_case("rlib")) == Some(true)
4949
{
5050
if let Some(old) = crates.insert(dep, path.clone()) {
51-
panic!("Found multiple rlibs for crate `{}`: `{:?}` and `{:?}", dep, old, path);
51+
// Check which action should be done in order to remove compiled deps.
52+
// If pre-installed version of compiler is used, `cargo clean` will do.
53+
// Otherwise (for bootstrapped compiler), the dependencies directory
54+
// must be removed manually.
55+
let suggested_action = if std::env::var_os("RUSTC_BOOTSTRAP").is_some() {
56+
"remove the stageN-tools directory"
57+
} else {
58+
"run `cargo clean`"
59+
};
60+
61+
panic!(
62+
"\n---------------------------------------------------\n\n \
63+
Found multiple rlibs for crate `{}`: `{:?}` and `{:?}`.\n \
64+
Probably, you need to {} before running tests again.\n \
65+
\nFor details on that error see https://github.com/rust-lang/rust-clippy/issues/7343 \
66+
\n---------------------------------------------------\n",
67+
dep, old, path, suggested_action
68+
);
5269
}
5370
break;
5471
}

0 commit comments

Comments
 (0)