mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Generate uniq name
This commit is contained in:
parent
183673655f
commit
bfce657377
1 changed files with 11 additions and 3 deletions
|
@ -8,7 +8,6 @@ use goblin::{mach::Mach, Object};
|
||||||
use libloading::Library;
|
use libloading::Library;
|
||||||
use memmap::Mmap;
|
use memmap::Mmap;
|
||||||
use ra_proc_macro::ProcMacroKind;
|
use ra_proc_macro::ProcMacroKind;
|
||||||
|
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
const NEW_REGISTRAR_SYMBOL: &str = "_rustc_proc_macro_decls_";
|
const NEW_REGISTRAR_SYMBOL: &str = "_rustc_proc_macro_decls_";
|
||||||
|
@ -197,7 +196,10 @@ impl Expander {
|
||||||
/// Copy the dylib to temp directory to prevent locking in Windows
|
/// Copy the dylib to temp directory to prevent locking in Windows
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
fn ensure_file_with_lock_free_access(path: &Path) -> io::Result<PathBuf> {
|
fn ensure_file_with_lock_free_access(path: &Path) -> io::Result<PathBuf> {
|
||||||
|
use std::{ffi::OsString, time::SystemTime};
|
||||||
|
|
||||||
let mut to = std::env::temp_dir();
|
let mut to = std::env::temp_dir();
|
||||||
|
|
||||||
let file_name = path.file_name().ok_or_else(|| {
|
let file_name = path.file_name().ok_or_else(|| {
|
||||||
io::Error::new(
|
io::Error::new(
|
||||||
io::ErrorKind::InvalidInput,
|
io::ErrorKind::InvalidInput,
|
||||||
|
@ -205,8 +207,14 @@ fn ensure_file_with_lock_free_access(path: &Path) -> io::Result<PathBuf> {
|
||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
to.push(file_name);
|
// generate a time deps unique number
|
||||||
std::fs::copy(path, &to)?;
|
let t = SystemTime::now().duration_since(std::time::UNIX_EPOCH).expect("Time went backwards");
|
||||||
|
|
||||||
|
let mut unique_name = OsString::from(t.as_millis().to_string());
|
||||||
|
unique_name.push(file_name);
|
||||||
|
|
||||||
|
to.push(unique_name);
|
||||||
|
std::fs::copy(path, &to).unwrap();
|
||||||
Ok(to)
|
Ok(to)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue