File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
crates/ra_proc_macro_srv/src Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,6 @@ use goblin::{mach::Mach, Object};
8
8
use libloading:: Library ;
9
9
use memmap:: Mmap ;
10
10
use ra_proc_macro:: ProcMacroKind ;
11
-
12
11
use std:: io;
13
12
14
13
const NEW_REGISTRAR_SYMBOL : & str = "_rustc_proc_macro_decls_" ;
@@ -197,16 +196,25 @@ impl Expander {
197
196
/// Copy the dylib to temp directory to prevent locking in Windows
198
197
#[ cfg( windows) ]
199
198
fn ensure_file_with_lock_free_access ( path : & Path ) -> io:: Result < PathBuf > {
199
+ use std:: { ffi:: OsString , time:: SystemTime } ;
200
+
200
201
let mut to = std:: env:: temp_dir ( ) ;
202
+
201
203
let file_name = path. file_name ( ) . ok_or_else ( || {
202
204
io:: Error :: new (
203
205
io:: ErrorKind :: InvalidInput ,
204
206
format ! ( "File path is invalid: {}" , path. display( ) ) ,
205
207
)
206
208
} ) ?;
207
209
208
- to. push ( file_name) ;
209
- std:: fs:: copy ( path, & to) ?;
210
+ // generate a time deps unique number
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
218
Ok ( to)
211
219
}
212
220
You can’t perform that action at this time.
0 commit comments