Skip to content

internal: Add version info to unsupported proc macro abi error #13607

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/proc-macro-srv/src/abis/mod.rs
Original file line number Diff line number Diff line change
@@ -117,7 +117,7 @@ impl Abi {
let inner = unsafe { Abi_1_63::from_lib(lib, symbol_name) }?;
Ok(Abi::Abi1_63(inner))
}
_ => Err(LoadProcMacroDylibError::UnsupportedABI),
_ => Err(LoadProcMacroDylibError::UnsupportedABI(info.version_string.clone())),
}
}

4 changes: 2 additions & 2 deletions crates/proc-macro-srv/src/dylib.rs
Original file line number Diff line number Diff line change
@@ -80,14 +80,14 @@ fn load_library(file: &Path) -> Result<Library, libloading::Error> {
pub enum LoadProcMacroDylibError {
Io(io::Error),
LibLoading(libloading::Error),
UnsupportedABI,
UnsupportedABI(String),
}

impl fmt::Display for LoadProcMacroDylibError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Io(e) => e.fmt(f),
Self::UnsupportedABI => write!(f, "unsupported ABI version"),
Self::UnsupportedABI(v) => write!(f, "unsupported ABI `{v}`"),
Self::LibLoading(e) => e.fmt(f),
}
}
4 changes: 2 additions & 2 deletions crates/proc-macro-srv/src/lib.rs
Original file line number Diff line number Diff line change
@@ -113,12 +113,12 @@ impl ProcMacroSrv {

fn expander(&mut self, path: &Path) -> Result<&dylib::Expander, String> {
let time = fs::metadata(path).and_then(|it| it.modified()).map_err(|err| {
format!("Failed to get file metadata for {}: {:?}", path.display(), err)
format!("Failed to get file metadata for {}: {}", path.display(), err)
})?;

Ok(match self.expanders.entry((path.to_path_buf(), time)) {
Entry::Vacant(v) => v.insert(dylib::Expander::new(path).map_err(|err| {
format!("Cannot create expander for {}: {:?}", path.display(), err)
format!("Cannot create expander for {}: {}", path.display(), err)
})?),
Entry::Occupied(e) => e.into_mut(),
})