File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
crates/proc_macro_srv/src Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -188,7 +188,9 @@ impl Expander {
188
188
/// Copy the dylib to temp directory to prevent locking in Windows
189
189
#[ cfg( windows) ]
190
190
fn ensure_file_with_lock_free_access ( path : & Path ) -> io:: Result < PathBuf > {
191
- use std:: { ffi:: OsString , time:: SystemTime } ;
191
+ use std:: collections:: hash_map:: RandomState ;
192
+ use std:: ffi:: OsString ;
193
+ use std:: hash:: { BuildHasher , Hasher } ;
192
194
193
195
let mut to = std:: env:: temp_dir ( ) ;
194
196
@@ -199,10 +201,11 @@ fn ensure_file_with_lock_free_access(path: &Path) -> io::Result<PathBuf> {
199
201
)
200
202
} ) ?;
201
203
202
- // generate a time deps unique number
203
- let t = SystemTime :: now ( ) . duration_since ( std:: time:: UNIX_EPOCH ) . expect ( "Time went backwards" ) ;
204
+ // Generate a unique number by abusing `HashMap`'s hasher.
205
+ // Maybe this will also "inspire" a libs team member to finally put `rand` in libstd.
206
+ let t = RandomState :: new ( ) . build_hasher ( ) . finish ( ) ;
204
207
205
- let mut unique_name = OsString :: from ( t. as_millis ( ) . to_string ( ) ) ;
208
+ let mut unique_name = OsString :: from ( t. to_string ( ) ) ;
206
209
unique_name. push ( file_name) ;
207
210
208
211
to. push ( unique_name) ;
You can’t perform that action at this time.
0 commit comments