aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_proc_macro_srv/src/dylib.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/crates/ra_proc_macro_srv/src/dylib.rs b/crates/ra_proc_macro_srv/src/dylib.rs
index 209f61493..aa84e951c 100644
--- a/crates/ra_proc_macro_srv/src/dylib.rs
+++ b/crates/ra_proc_macro_srv/src/dylib.rs
@@ -8,7 +8,6 @@ use goblin::{mach::Mach, Object};
8use libloading::Library; 8use libloading::Library;
9use memmap::Mmap; 9use memmap::Mmap;
10use ra_proc_macro::ProcMacroKind; 10use ra_proc_macro::ProcMacroKind;
11
12use std::io; 11use std::io;
13 12
14const NEW_REGISTRAR_SYMBOL: &str = "_rustc_proc_macro_decls_"; 13const NEW_REGISTRAR_SYMBOL: &str = "_rustc_proc_macro_decls_";
@@ -197,7 +196,10 @@ impl Expander {
197/// Copy the dylib to temp directory to prevent locking in Windows 196/// Copy the dylib to temp directory to prevent locking in Windows
198#[cfg(windows)] 197#[cfg(windows)]
199fn ensure_file_with_lock_free_access(path: &Path) -> io::Result<PathBuf> { 198fn ensure_file_with_lock_free_access(path: &Path) -> io::Result<PathBuf> {
199 use std::{ffi::OsString, time::SystemTime};
200
200 let mut to = std::env::temp_dir(); 201 let mut to = std::env::temp_dir();
202
201 let file_name = path.file_name().ok_or_else(|| { 203 let file_name = path.file_name().ok_or_else(|| {
202 io::Error::new( 204 io::Error::new(
203 io::ErrorKind::InvalidInput, 205 io::ErrorKind::InvalidInput,
@@ -205,8 +207,14 @@ fn ensure_file_with_lock_free_access(path: &Path) -> io::Result<PathBuf> {
205 ) 207 )
206 })?; 208 })?;
207 209
208 to.push(file_name); 210 // generate a time deps unique number
209 std::fs::copy(path, &to)?; 211 let t = SystemTime::now().duration_since(std::time::UNIX_EPOCH).expect("Time went backwards");
212
213 let mut unique_name = OsString::from(t.as_millis().to_string());
214 unique_name.push(file_name);
215
216 to.push(unique_name);
217 std::fs::copy(path, &to).unwrap();
210 Ok(to) 218 Ok(to)
211} 219}
212 220