mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
Move dylib version stuff to proc-macro-srv
This commit is contained in:
parent
5374ebbf36
commit
db15273d4d
8 changed files with 36 additions and 33 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
use libloading::Library;
|
||||
use proc_macro::bridge;
|
||||
use proc_macro_api::{ProcMacroKind, RustCInfo};
|
||||
use proc_macro_api::ProcMacroKind;
|
||||
|
||||
use crate::{dylib::LoadProcMacroDylibError, ProcMacroSrvSpan};
|
||||
|
||||
|
@ -29,15 +29,15 @@ impl ProcMacros {
|
|||
pub(crate) fn from_lib(
|
||||
lib: &Library,
|
||||
symbol_name: String,
|
||||
info: RustCInfo,
|
||||
version_string: &str,
|
||||
) -> Result<ProcMacros, LoadProcMacroDylibError> {
|
||||
if info.version_string == crate::RUSTC_VERSION_STRING {
|
||||
if version_string == crate::RUSTC_VERSION_STRING {
|
||||
let macros =
|
||||
unsafe { lib.get::<&&[bridge::client::ProcMacro]>(symbol_name.as_bytes()) }?;
|
||||
|
||||
return Ok(Self { exported_macros: macros.to_vec() });
|
||||
}
|
||||
Err(LoadProcMacroDylibError::AbiMismatch(info.version_string))
|
||||
Err(LoadProcMacroDylibError::AbiMismatch(version_string.to_owned()))
|
||||
}
|
||||
|
||||
pub(crate) fn expand<S: ProcMacroSrvSpan>(
|
||||
|
@ -117,16 +117,3 @@ impl ProcMacros {
|
|||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_version_check() {
|
||||
let path = paths::AbsPathBuf::assert(crate::proc_macro_test_dylib_path());
|
||||
let info = proc_macro_api::read_dylib_info(&path).unwrap();
|
||||
assert_eq!(
|
||||
info.version_string,
|
||||
crate::RUSTC_VERSION_STRING,
|
||||
"sysroot ABI mismatch: dylib rustc version (read from .rustc section): {:?} != proc-macro-srv version (read from 'rustc --version'): {:?}",
|
||||
info.version_string,
|
||||
crate::RUSTC_VERSION_STRING,
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue