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};
88use libloading:: Library ;
99use memmap:: Mmap ;
1010use ra_proc_macro:: ProcMacroKind ;
11-
1211use std:: io;
1312
1413const NEW_REGISTRAR_SYMBOL : & str = "_rustc_proc_macro_decls_" ;
@@ -197,16 +196,25 @@ impl Expander {
197196/// Copy the dylib to temp directory to prevent locking in Windows
198197#[ cfg( windows) ]
199198fn ensure_file_with_lock_free_access ( path : & Path ) -> io:: Result < PathBuf > {
199+ use std:: { ffi:: OsString , time:: SystemTime } ;
200+
200201 let mut to = std:: env:: temp_dir ( ) ;
202+
201203 let file_name = path. file_name ( ) . ok_or_else ( || {
202204 io:: Error :: new (
203205 io:: ErrorKind :: InvalidInput ,
204206 format ! ( "File path is invalid: {}" , path. display( ) ) ,
205207 )
206208 } ) ?;
207209
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 ( ) ;
210218 Ok ( to)
211219}
212220
You can’t perform that action at this time.
0 commit comments