aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_proc_macro_srv
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_proc_macro_srv')
-rw-r--r--crates/ra_proc_macro_srv/src/lib.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/crates/ra_proc_macro_srv/src/lib.rs b/crates/ra_proc_macro_srv/src/lib.rs
index 0954bd6b5..121f531fd 100644
--- a/crates/ra_proc_macro_srv/src/lib.rs
+++ b/crates/ra_proc_macro_srv/src/lib.rs
@@ -23,12 +23,14 @@ use proc_macro::bridge::client::TokenStream;
23use ra_proc_macro::{ExpansionResult, ExpansionTask, ListMacrosResult, ListMacrosTask}; 23use ra_proc_macro::{ExpansionResult, ExpansionTask, ListMacrosResult, ListMacrosTask};
24use std::{ 24use std::{
25 collections::{hash_map::Entry, HashMap}, 25 collections::{hash_map::Entry, HashMap},
26 fs::metadata,
26 path::{Path, PathBuf}, 27 path::{Path, PathBuf},
28 time::SystemTime,
27}; 29};
28 30
29#[derive(Default)] 31#[derive(Default)]
30pub(crate) struct ProcMacroSrv { 32pub(crate) struct ProcMacroSrv {
31 expanders: HashMap<PathBuf, dylib::Expander>, 33 expanders: HashMap<(PathBuf, SystemTime), dylib::Expander>,
32} 34}
33 35
34impl ProcMacroSrv { 36impl ProcMacroSrv {
@@ -48,7 +50,11 @@ impl ProcMacroSrv {
48 } 50 }
49 51
50 fn expander(&mut self, path: &Path) -> Result<&dylib::Expander, String> { 52 fn expander(&mut self, path: &Path) -> Result<&dylib::Expander, String> {
51 Ok(match self.expanders.entry(path.to_path_buf()) { 53 let time = metadata(path)
54 .and_then(|it| it.modified())
55 .map_err(|err| format!("Failed to file metadata for {}: {:?}", path.display(), err))?;
56
57 Ok(match self.expanders.entry((path.to_path_buf(), time)) {
52 Entry::Vacant(v) => v.insert(dylib::Expander::new(path).map_err(|err| { 58 Entry::Vacant(v) => v.insert(dylib::Expander::new(path).map_err(|err| {
53 format!("Cannot create expander for {}: {:?}", path.display(), err) 59 format!("Cannot create expander for {}: {:?}", path.display(), err)
54 })?), 60 })?),