Skip to content

Remove client side proc-macro version check #14404

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
Mar 25, 2023
Merged
Show file tree
Hide file tree
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
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