Skip to content

Commit 640e99c

Browse files
Fix duplicated path in the "not found dylib" error
1 parent f04c5c5 commit 640e99c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

compiler/rustc_metadata/src/creader.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,13 @@ fn load_dylib(path: &Path, max_attempts: usize) -> Result<libloading::Library, S
11321132
Err(err) => {
11331133
// Only try to recover from this specific error.
11341134
if !matches!(err, libloading::Error::LoadLibraryExW { .. }) {
1135-
return Err(err.to_string());
1135+
let err = format_dlopen_err(&err);
1136+
// We include the path of the dylib in the error ourselves, so
1137+
// if it's in the error, we strip it.
1138+
if let Some(err) = err.strip_prefix(&format!(": {}", path.display())) {
1139+
return Err(err.to_string());
1140+
}
1141+
return Err(err);
11361142
}
11371143

11381144
last_error = Some(err);

0 commit comments

Comments
 (0)