diff options
| author | Guillaume Gomez <guillaume.gomez@huawei.com> | 2024-03-04 14:30:46 +0100 |
|---|---|---|
| committer | Guillaume Gomez <guillaume.gomez@huawei.com> | 2024-03-04 16:19:17 +0100 |
| commit | 640e99ccc982586352b1ad94c350af3cbeff3c2e (patch) | |
| tree | 2bed21b44d682eb85ae6fbd30671b772c162cf30 | |
| parent | f04c5c51120eabf969c75381ee6151b4539313f4 (diff) | |
| download | rust-640e99ccc982586352b1ad94c350af3cbeff3c2e.tar.gz rust-640e99ccc982586352b1ad94c350af3cbeff3c2e.zip | |
Fix duplicated path in the "not found dylib" error
| -rw-r--r-- | compiler/rustc_metadata/src/creader.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/compiler/rustc_metadata/src/creader.rs b/compiler/rustc_metadata/src/creader.rs index f65fe1a29c7..564c35f881d 100644 --- a/compiler/rustc_metadata/src/creader.rs +++ b/compiler/rustc_metadata/src/creader.rs @@ -1132,7 +1132,13 @@ fn load_dylib(path: &Path, max_attempts: usize) -> Result<libloading::Library, S Err(err) => { // Only try to recover from this specific error. if !matches!(err, libloading::Error::LoadLibraryExW { .. }) { - return Err(err.to_string()); + let err = format_dlopen_err(&err); + // We include the path of the dylib in the error ourselves, so + // if it's in the error, we strip it. + if let Some(err) = err.strip_prefix(&format!(": {}", path.display())) { + return Err(err.to_string()); + } + return Err(err); } last_error = Some(err); |
