Skip to content

Commit 650f8fd

Browse files
authored
Rollup merge of #110932 - sameer:master, r=michaelwoerister
include source error for LoadLibraryExW In #107595, we added retry behavior for LoadLibraryExW on Windows. If it fails we do not print the underlying error that Windows returned. This made #110889 a little harder to debug. In this PR I am adding the source error in the message if it is available.
2 parents 55df5c8 + 24adb1f commit 650f8fd

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

compiler/rustc_metadata/src/creader.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use rustc_span::{Span, DUMMY_SP};
2727
use rustc_target::spec::{PanicStrategy, TargetTriple};
2828

2929
use proc_macro::bridge::client::ProcMacro;
30+
use std::error::Error;
3031
use std::ops::Fn;
3132
use std::path::Path;
3233
use std::time::Duration;
@@ -1094,5 +1095,12 @@ fn load_dylib(path: &Path, max_attempts: usize) -> Result<libloading::Library, S
10941095
}
10951096

10961097
debug!("Failed to load proc-macro `{}` even after {} attempts.", path.display(), max_attempts);
1097-
Err(format!("{} (retried {} times)", last_error.unwrap(), max_attempts))
1098+
1099+
let last_error = last_error.unwrap();
1100+
let message = if let Some(src) = last_error.source() {
1101+
format!("{last_error} ({src}) (retried {max_attempts} times)")
1102+
} else {
1103+
format!("{last_error} (retried {max_attempts} times)")
1104+
};
1105+
Err(message)
10981106
}

0 commit comments

Comments
 (0)