Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--crates/rust-analyzer/src/config.rs47
-rw-r--r--crates/rust-analyzer/src/reload.rs5
2 files changed, 46 insertions, 6 deletions
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs
index 89ca8e6356..c24bdab78a 100644
--- a/crates/rust-analyzer/src/config.rs
+++ b/crates/rust-analyzer/src/config.rs
@@ -1102,12 +1102,8 @@ impl Config {
}
pub fn proc_macro_srv(&self) -> Option<AbsPathBuf> {
- self.data
- .procMacro_server
- .clone()
- .map(AbsPathBuf::try_from)?
- .ok()
- .map(|path| self.root_path.join(path))
+ let path = self.data.procMacro_server.clone()?;
+ Some(AbsPathBuf::try_from(path).unwrap_or_else(|path| self.root_path.join(&path)))
}
pub fn dummy_replacements(&self) -> &FxHashMap<Box<str>, Box<[Box<str>]>> {
@@ -2424,4 +2420,43 @@ mod tests {
fn remove_ws(text: &str) -> String {
text.replace(char::is_whitespace, "")
}
+
+ #[test]
+ fn proc_macro_srv_null() {
+ let mut config =
+ Config::new(AbsPathBuf::try_from(project_root()).unwrap(), Default::default(), vec![]);
+ config
+ .update(serde_json::json!({
+ "procMacro_server": null,
+ }))
+ .unwrap();
+ assert_eq!(config.proc_macro_srv(), None);
+ }
+
+ #[test]
+ fn proc_macro_srv_abs() {
+ let mut config =
+ Config::new(AbsPathBuf::try_from(project_root()).unwrap(), Default::default(), vec![]);
+ config
+ .update(serde_json::json!({
+ "procMacro": {"server": project_root().display().to_string()}
+ }))
+ .unwrap();
+ assert_eq!(config.proc_macro_srv(), Some(AbsPathBuf::try_from(project_root()).unwrap()));
+ }
+
+ #[test]
+ fn proc_macro_srv_rel() {
+ let mut config =
+ Config::new(AbsPathBuf::try_from(project_root()).unwrap(), Default::default(), vec![]);
+ config
+ .update(serde_json::json!({
+ "procMacro": {"server": "./server"}
+ }))
+ .unwrap();
+ assert_eq!(
+ config.proc_macro_srv(),
+ Some(AbsPathBuf::try_from(project_root().join("./server")).unwrap())
+ );
+ }
}
diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs
index 4d840e11df..87ec040d7b 100644
--- a/crates/rust-analyzer/src/reload.rs
+++ b/crates/rust-analyzer/src/reload.rs
@@ -426,6 +426,11 @@ impl GlobalState {
tracing::info!("Using proc-macro server at {}", path.display(),);
ProcMacroServer::spawn(path.clone()).map_err(|err| {
+ tracing::error!(
+ "Failed to run proc-macro server from path {}, error: {:?}",
+ path.display(),
+ err
+ );
anyhow::anyhow!(
"Failed to run proc-macro server from path {}, error: {:?}",
path.display(),