Skip to content

Commit

Permalink
Remove client side proc-macro version check
Browse files Browse the repository at this point in the history
  • Loading branch information
Veykril committed Mar 25, 2023
1 parent 39e86e7 commit 3ae9bfe
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
14 changes: 2 additions & 12 deletions crates/proc-macro-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,8 @@ pub struct MacroDylib {
}

impl MacroDylib {
// FIXME: this is buggy due to TOCTOU, we should check the version in the
// macro process instead.
pub fn new(path: AbsPathBuf) -> io::Result<MacroDylib> {
let _p = profile::span("MacroDylib::new");

let info = version::read_dylib_info(&path)?;
if info.version.0 < 1 || info.version.1 < 47 {
let msg = format!("proc-macro {} built by {info:#?} is not supported by rust-analyzer, please update your Rust version.", path.display());
return Err(io::Error::new(io::ErrorKind::InvalidData, msg));
}

Ok(MacroDylib { path })
pub fn new(path: AbsPathBuf) -> MacroDylib {
MacroDylib { path }
}
}

Expand Down
3 changes: 1 addition & 2 deletions crates/rust-analyzer/src/reload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,8 +648,7 @@ pub(crate) fn load_proc_macro(
) -> ProcMacroLoadResult {
let server = server.map_err(ToOwned::to_owned)?;
let res: Result<Vec<_>, String> = (|| {
let dylib = MacroDylib::new(path.to_path_buf())
.map_err(|io| format!("Proc-macro dylib loading failed: {io}"))?;
let dylib = MacroDylib::new(path.to_path_buf());
let vec = server.load_dylib(dylib).map_err(|e| format!("{e}"))?;
if vec.is_empty() {
return Err("proc macro library returned no proc macros".to_string());
Expand Down

0 comments on commit 3ae9bfe

Please sign in to comment.