Skip to content

Commit

Permalink
Merge #11365
Browse files Browse the repository at this point in the history
11365: Add a way to disable dll copying for users of proc_macro_srv library r=lnicola a=vlad20012

We use `ra_ap_proc_macro_srv` library in IntelliJ Rust in order to expand proc macros. We need a way to disable [DLL copying to a temp dir on Windows](https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/proc_macro_srv/src/dylib.rs#L166) behavior because it causes issues like intellij-rust/intellij-rust#7709. Unlike RA, file locking is not an issue for IntelliJ Rust because we copy DLLs to a temp dir before calling the expander.

Co-authored-by: vlad20012 <beskvlad@gmail.com>
  • Loading branch information
bors[bot] and vlad20012 authored Jan 28, 2022
2 parents cd6521e + e277d5d commit 4aadabc
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crates/proc_macro_srv/src/dylib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ fn ensure_file_with_lock_free_access(path: &Path) -> io::Result<PathBuf> {
use std::ffi::OsString;
use std::hash::{BuildHasher, Hasher};

if std::env::var("RA_DONT_COPY_PROC_MACRO_DLL").is_ok() {
return Ok(path.to_path_buf());
}

let mut to = std::env::temp_dir();

let file_name = path.file_name().ok_or_else(|| {
Expand Down

0 comments on commit 4aadabc

Please sign in to comment.