Skip to content

Commit f3b3eef

Browse files
committed
Fix proc-macro-test build script
1 parent 4c62359 commit f3b3eef

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

src/tools/rust-analyzer/crates/proc-macro-srv/proc-macro-test/build.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ fn main() {
3030

3131
if !has_features {
3232
println!("proc-macro-test testing only works on nightly toolchains");
33-
let info_path = out_dir.join("proc_macro_test_location.txt");
34-
fs::File::create(info_path).unwrap();
33+
println!("cargo::rustc-env=PROC_MACRO_TEST_LOCATION=\"\"");
3534
return;
3635
}
3736

src/tools/rust-analyzer/crates/proc-macro-srv/src/dylib.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,24 +133,32 @@ impl ProcMacroLibraryLibloading {
133133
}
134134
}
135135

136-
pub struct Expander {
136+
pub(crate) struct Expander {
137137
inner: ProcMacroLibraryLibloading,
138+
path: Utf8PathBuf,
139+
}
140+
141+
impl Drop for Expander {
142+
fn drop(&mut self) {
143+
#[cfg(windows)]
144+
std::fs::remove_file(&self.path).ok();
145+
}
138146
}
139147

140148
impl Expander {
141-
pub fn new(lib: &Utf8Path) -> Result<Expander, LoadProcMacroDylibError> {
149+
pub(crate) fn new(lib: &Utf8Path) -> Result<Expander, LoadProcMacroDylibError> {
142150
// Some libraries for dynamic loading require canonicalized path even when it is
143151
// already absolute
144152
let lib = lib.canonicalize_utf8()?;
145153

146-
let lib = ensure_file_with_lock_free_access(&lib)?;
154+
let path = ensure_file_with_lock_free_access(&lib)?;
147155

148-
let library = ProcMacroLibraryLibloading::open(lib.as_ref())?;
156+
let library = ProcMacroLibraryLibloading::open(path.as_ref())?;
149157

150-
Ok(Expander { inner: library })
158+
Ok(Expander { inner: library, path })
151159
}
152160

153-
pub fn expand<S: ProcMacroSrvSpan>(
161+
pub(crate) fn expand<S: ProcMacroSrvSpan>(
154162
&self,
155163
macro_name: &str,
156164
macro_body: tt::Subtree<S>,
@@ -169,7 +177,7 @@ impl Expander {
169177
result.map_err(|e| e.into_string().unwrap_or_default())
170178
}
171179

172-
pub fn list_macros(&self) -> Vec<(String, ProcMacroKind)> {
180+
pub(crate) fn list_macros(&self) -> Vec<(String, ProcMacroKind)> {
173181
self.inner.proc_macros.list_macros()
174182
}
175183
}
@@ -198,7 +206,7 @@ fn ensure_file_with_lock_free_access(path: &Utf8Path) -> io::Result<Utf8PathBuf>
198206
unique_name.push_str(file_name);
199207

200208
to.push(unique_name);
201-
std::fs::copy(path, &to).unwrap();
209+
std::fs::copy(path, &to)?;
202210
Ok(to)
203211
}
204212

0 commit comments

Comments
 (0)