aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-12-07 16:21:51 +0000
committerGitHub <[email protected]>2020-12-07 16:21:51 +0000
commitc1824b4933f7a30b4253116290a0a6b2935eedc3 (patch)
tree30b2e506e326af121a716c92d42fc90229179072
parent9a88332452d661d4afea10f0063c893142e08019 (diff)
parent577d5f1c337d5de8719bddcabd3d22a560a11b95 (diff)
Merge #6745
6745: Some more proc macro cleanups r=jonas-schievink a=jonas-schievink * Remove `ProcMacroClient::dummy` and just use `Option<ProcMacroClient>` instead * Remember the type of proc macros (later allows us to reject using an incorrect macro type) * Prepare a few internals for procedural attribute macros bors r+ Co-authored-by: Jonas Schievink <[email protected]>
-rw-r--r--Cargo.lock1
-rw-r--r--crates/base_db/src/input.rs13
-rw-r--r--crates/base_db/src/lib.rs2
-rw-r--r--crates/hir_expand/src/proc_macro.rs1
-rw-r--r--crates/proc_macro_api/Cargo.toml1
-rw-r--r--crates/proc_macro_api/src/lib.rs86
-rw-r--r--crates/proc_macro_api/src/process.rs20
-rw-r--r--crates/proc_macro_api/src/rpc.rs2
-rw-r--r--crates/project_model/src/workspace.rs39
-rw-r--r--crates/rust-analyzer/src/cli/load_cargo.rs6
-rw-r--r--crates/rust-analyzer/src/global_state.rs4
-rw-r--r--crates/rust-analyzer/src/reload.rs8
12 files changed, 84 insertions, 99 deletions
diff --git a/Cargo.lock b/Cargo.lock
index f1847e769..b73fb909c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1187,6 +1187,7 @@ dependencies = [
1187name = "proc_macro_api" 1187name = "proc_macro_api"
1188version = "0.0.0" 1188version = "0.0.0"
1189dependencies = [ 1189dependencies = [
1190 "base_db",
1190 "crossbeam-channel 0.5.0", 1191 "crossbeam-channel 0.5.0",
1191 "jod-thread", 1192 "jod-thread",
1192 "log", 1193 "log",
diff --git a/crates/base_db/src/input.rs b/crates/base_db/src/input.rs
index 98ba372ad..cda5e57dc 100644
--- a/crates/base_db/src/input.rs
+++ b/crates/base_db/src/input.rs
@@ -143,9 +143,17 @@ impl CrateDisplayName {
143#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] 143#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
144pub struct ProcMacroId(pub u32); 144pub struct ProcMacroId(pub u32);
145 145
146#[derive(Copy, Clone, Eq, PartialEq, Debug)]
147pub enum ProcMacroKind {
148 CustomDerive,
149 FuncLike,
150 Attr,
151}
152
146#[derive(Debug, Clone)] 153#[derive(Debug, Clone)]
147pub struct ProcMacro { 154pub struct ProcMacro {
148 pub name: SmolStr, 155 pub name: SmolStr,
156 pub kind: ProcMacroKind,
149 pub expander: Arc<dyn TokenExpander>, 157 pub expander: Arc<dyn TokenExpander>,
150} 158}
151 159
@@ -198,11 +206,8 @@ impl CrateGraph {
198 display_name: Option<CrateDisplayName>, 206 display_name: Option<CrateDisplayName>,
199 cfg_options: CfgOptions, 207 cfg_options: CfgOptions,
200 env: Env, 208 env: Env,
201 proc_macro: Vec<(SmolStr, Arc<dyn tt::TokenExpander>)>, 209 proc_macro: Vec<ProcMacro>,
202 ) -> CrateId { 210 ) -> CrateId {
203 let proc_macro =
204 proc_macro.into_iter().map(|(name, it)| ProcMacro { name, expander: it }).collect();
205
206 let data = CrateData { 211 let data = CrateData {
207 root_file_id: file_id, 212 root_file_id: file_id,
208 edition, 213 edition,
diff --git a/crates/base_db/src/lib.rs b/crates/base_db/src/lib.rs
index ce75a5337..5571af495 100644
--- a/crates/base_db/src/lib.rs
+++ b/crates/base_db/src/lib.rs
@@ -14,7 +14,7 @@ pub use crate::{
14 change::Change, 14 change::Change,
15 input::{ 15 input::{
16 CrateData, CrateDisplayName, CrateGraph, CrateId, CrateName, Dependency, Edition, Env, 16 CrateData, CrateDisplayName, CrateGraph, CrateId, CrateName, Dependency, Edition, Env,
17 ProcMacroId, SourceRoot, SourceRootId, 17 ProcMacro, ProcMacroId, ProcMacroKind, SourceRoot, SourceRootId,
18 }, 18 },
19}; 19};
20pub use salsa; 20pub use salsa;
diff --git a/crates/hir_expand/src/proc_macro.rs b/crates/hir_expand/src/proc_macro.rs
index 97edf0fb6..38882d2b6 100644
--- a/crates/hir_expand/src/proc_macro.rs
+++ b/crates/hir_expand/src/proc_macro.rs
@@ -26,7 +26,6 @@ impl ProcMacroExpander {
26 26
27 pub fn dummy(krate: CrateId) -> Self { 27 pub fn dummy(krate: CrateId) -> Self {
28 // FIXME: Should store the name for better errors 28 // FIXME: Should store the name for better errors
29 // FIXME: I think this is the second layer of "dummy" expansion, we should reduce that
30 Self { krate, proc_macro_id: None } 29 Self { krate, proc_macro_id: None }
31 } 30 }
32 31
diff --git a/crates/proc_macro_api/Cargo.toml b/crates/proc_macro_api/Cargo.toml
index 3863e5189..1af2bbca7 100644
--- a/crates/proc_macro_api/Cargo.toml
+++ b/crates/proc_macro_api/Cargo.toml
@@ -17,3 +17,4 @@ crossbeam-channel = "0.5.0"
17jod-thread = "0.1.1" 17jod-thread = "0.1.1"
18 18
19tt = { path = "../tt", version = "0.0.0" } 19tt = { path = "../tt", version = "0.0.0" }
20base_db = { path = "../base_db", version = "0.0.0" }
diff --git a/crates/proc_macro_api/src/lib.rs b/crates/proc_macro_api/src/lib.rs
index d5e87cf7d..0d061fd53 100644
--- a/crates/proc_macro_api/src/lib.rs
+++ b/crates/proc_macro_api/src/lib.rs
@@ -16,6 +16,7 @@ use std::{
16 sync::Arc, 16 sync::Arc,
17}; 17};
18 18
19use base_db::ProcMacro;
19use tt::{SmolStr, Subtree}; 20use tt::{SmolStr, Subtree};
20 21
21use crate::process::{ProcMacroProcessSrv, ProcMacroProcessThread}; 22use crate::process::{ProcMacroProcessSrv, ProcMacroProcessThread};
@@ -23,7 +24,7 @@ use crate::process::{ProcMacroProcessSrv, ProcMacroProcessThread};
23pub use rpc::{ExpansionResult, ExpansionTask, ListMacrosResult, ListMacrosTask, ProcMacroKind}; 24pub use rpc::{ExpansionResult, ExpansionTask, ListMacrosResult, ListMacrosTask, ProcMacroKind};
24 25
25#[derive(Debug, Clone)] 26#[derive(Debug, Clone)]
26pub struct ProcMacroProcessExpander { 27struct ProcMacroProcessExpander {
27 process: Arc<ProcMacroProcessSrv>, 28 process: Arc<ProcMacroProcessSrv>,
28 dylib_path: PathBuf, 29 dylib_path: PathBuf,
29 name: SmolStr, 30 name: SmolStr,
@@ -42,21 +43,24 @@ impl tt::TokenExpander for ProcMacroProcessExpander {
42 fn expand( 43 fn expand(
43 &self, 44 &self,
44 subtree: &Subtree, 45 subtree: &Subtree,
45 _attr: Option<&Subtree>, 46 attr: Option<&Subtree>,
46 ) -> Result<Subtree, tt::ExpansionError> { 47 ) -> Result<Subtree, tt::ExpansionError> {
47 self.process.custom_derive(&self.dylib_path, subtree, &self.name) 48 let task = ExpansionTask {
48 } 49 macro_body: subtree.clone(),
49} 50 macro_name: self.name.to_string(),
51 attributes: attr.cloned(),
52 lib: self.dylib_path.to_path_buf(),
53 };
50 54
51#[derive(Debug)] 55 let result: ExpansionResult = self.process.send_task(msg::Request::ExpansionMacro(task))?;
52enum ProcMacroClientKind { 56 Ok(result.expansion)
53 Process { process: Arc<ProcMacroProcessSrv>, thread: ProcMacroProcessThread }, 57 }
54 Dummy,
55} 58}
56 59
57#[derive(Debug)] 60#[derive(Debug)]
58pub struct ProcMacroClient { 61pub struct ProcMacroClient {
59 kind: ProcMacroClientKind, 62 process: Arc<ProcMacroProcessSrv>,
63 thread: ProcMacroProcessThread,
60} 64}
61 65
62impl ProcMacroClient { 66impl ProcMacroClient {
@@ -65,47 +69,35 @@ impl ProcMacroClient {
65 args: impl IntoIterator<Item = impl AsRef<OsStr>>, 69 args: impl IntoIterator<Item = impl AsRef<OsStr>>,
66 ) -> io::Result<ProcMacroClient> { 70 ) -> io::Result<ProcMacroClient> {
67 let (thread, process) = ProcMacroProcessSrv::run(process_path, args)?; 71 let (thread, process) = ProcMacroProcessSrv::run(process_path, args)?;
68 Ok(ProcMacroClient { 72 Ok(ProcMacroClient { process: Arc::new(process), thread })
69 kind: ProcMacroClientKind::Process { process: Arc::new(process), thread },
70 })
71 } 73 }
72 74
73 pub fn dummy() -> ProcMacroClient { 75 pub fn by_dylib_path(&self, dylib_path: &Path) -> Vec<ProcMacro> {
74 ProcMacroClient { kind: ProcMacroClientKind::Dummy } 76 let macros = match self.process.find_proc_macros(dylib_path) {
75 } 77 Err(err) => {
78 eprintln!("Failed to find proc macros. Error: {:#?}", err);
79 return vec![];
80 }
81 Ok(macros) => macros,
82 };
76 83
77 pub fn by_dylib_path(&self, dylib_path: &Path) -> Vec<(SmolStr, Arc<dyn tt::TokenExpander>)> { 84 macros
78 match &self.kind { 85 .into_iter()
79 ProcMacroClientKind::Dummy => vec![], 86 .map(|(name, kind)| {
80 ProcMacroClientKind::Process { process, .. } => { 87 let name = SmolStr::new(&name);
81 let macros = match process.find_proc_macros(dylib_path) { 88 let kind = match kind {
82 Err(err) => { 89 ProcMacroKind::CustomDerive => base_db::ProcMacroKind::CustomDerive,
83 eprintln!("Failed to find proc macros. Error: {:#?}", err); 90 ProcMacroKind::FuncLike => base_db::ProcMacroKind::FuncLike,
84 return vec![]; 91 ProcMacroKind::Attr => base_db::ProcMacroKind::Attr,
85 }
86 Ok(macros) => macros,
87 }; 92 };
93 let expander: Arc<dyn tt::TokenExpander> = Arc::new(ProcMacroProcessExpander {
94 process: self.process.clone(),
95 name: name.clone(),
96 dylib_path: dylib_path.into(),
97 });
88 98
89 macros 99 ProcMacro { name, kind, expander }
90 .into_iter() 100 })
91 .filter_map(|(name, kind)| { 101 .collect()
92 match kind {
93 ProcMacroKind::CustomDerive | ProcMacroKind::FuncLike => {
94 let name = SmolStr::new(&name);
95 let expander: Arc<dyn tt::TokenExpander> =
96 Arc::new(ProcMacroProcessExpander {
97 process: process.clone(),
98 name: name.clone(),
99 dylib_path: dylib_path.into(),
100 });
101 Some((name, expander))
102 }
103 // FIXME: Attribute macro are currently unsupported.
104 ProcMacroKind::Attr => None,
105 }
106 })
107 .collect()
108 }
109 }
110 } 102 }
111} 103}
diff --git a/crates/proc_macro_api/src/process.rs b/crates/proc_macro_api/src/process.rs
index 301888a0e..d68723ada 100644
--- a/crates/proc_macro_api/src/process.rs
+++ b/crates/proc_macro_api/src/process.rs
@@ -10,11 +10,10 @@ use std::{
10}; 10};
11 11
12use crossbeam_channel::{bounded, Receiver, Sender}; 12use crossbeam_channel::{bounded, Receiver, Sender};
13use tt::Subtree;
14 13
15use crate::{ 14use crate::{
16 msg::{ErrorCode, Message, Request, Response, ResponseError}, 15 msg::{ErrorCode, Message, Request, Response, ResponseError},
17 rpc::{ExpansionResult, ExpansionTask, ListMacrosResult, ListMacrosTask, ProcMacroKind}, 16 rpc::{ListMacrosResult, ListMacrosTask, ProcMacroKind},
18}; 17};
19 18
20#[derive(Debug, Default)] 19#[derive(Debug, Default)]
@@ -58,23 +57,6 @@ impl ProcMacroProcessSrv {
58 Ok(result.macros) 57 Ok(result.macros)
59 } 58 }
60 59
61 pub(crate) fn custom_derive(
62 &self,
63 dylib_path: &Path,
64 subtree: &Subtree,
65 derive_name: &str,
66 ) -> Result<Subtree, tt::ExpansionError> {
67 let task = ExpansionTask {
68 macro_body: subtree.clone(),
69 macro_name: derive_name.to_string(),
70 attributes: None,
71 lib: dylib_path.to_path_buf(),
72 };
73
74 let result: ExpansionResult = self.send_task(Request::ExpansionMacro(task))?;
75 Ok(result.expansion)
76 }
77
78 pub(crate) fn send_task<R>(&self, req: Request) -> Result<R, tt::ExpansionError> 60 pub(crate) fn send_task<R>(&self, req: Request) -> Result<R, tt::ExpansionError>
79 where 61 where
80 R: TryFrom<Response, Error = &'static str>, 62 R: TryFrom<Response, Error = &'static str>,
diff --git a/crates/proc_macro_api/src/rpc.rs b/crates/proc_macro_api/src/rpc.rs
index 203109ca4..b85f92eea 100644
--- a/crates/proc_macro_api/src/rpc.rs
+++ b/crates/proc_macro_api/src/rpc.rs
@@ -19,7 +19,7 @@ pub struct ListMacrosTask {
19 pub lib: PathBuf, 19 pub lib: PathBuf,
20} 20}
21 21
22#[derive(Clone, Eq, PartialEq, Debug, Serialize, Deserialize)] 22#[derive(Copy, Clone, Eq, PartialEq, Debug, Serialize, Deserialize)]
23pub enum ProcMacroKind { 23pub enum ProcMacroKind {
24 CustomDerive, 24 CustomDerive,
25 FuncLike, 25 FuncLike,
diff --git a/crates/project_model/src/workspace.rs b/crates/project_model/src/workspace.rs
index a71f96164..ab5cbae11 100644
--- a/crates/project_model/src/workspace.rs
+++ b/crates/project_model/src/workspace.rs
@@ -2,10 +2,14 @@
2//! metadata` or `rust-project.json`) into representation stored in the salsa 2//! metadata` or `rust-project.json`) into representation stored in the salsa
3//! database -- `CrateGraph`. 3//! database -- `CrateGraph`.
4 4
5use std::{fmt, fs, path::Component, process::Command}; 5use std::{
6 fmt, fs,
7 path::{Component, Path},
8 process::Command,
9};
6 10
7use anyhow::{Context, Result}; 11use anyhow::{Context, Result};
8use base_db::{CrateDisplayName, CrateGraph, CrateId, CrateName, Edition, Env, FileId}; 12use base_db::{CrateDisplayName, CrateGraph, CrateId, CrateName, Edition, Env, FileId, ProcMacro};
9use cfg::CfgOptions; 13use cfg::CfgOptions;
10use paths::{AbsPath, AbsPathBuf}; 14use paths::{AbsPath, AbsPathBuf};
11use proc_macro_api::ProcMacroClient; 15use proc_macro_api::ProcMacroClient;
@@ -194,15 +198,20 @@ impl ProjectWorkspace {
194 pub fn to_crate_graph( 198 pub fn to_crate_graph(
195 &self, 199 &self,
196 target: Option<&str>, 200 target: Option<&str>,
197 proc_macro_client: &ProcMacroClient, 201 proc_macro_client: Option<&ProcMacroClient>,
198 load: &mut dyn FnMut(&AbsPath) -> Option<FileId>, 202 load: &mut dyn FnMut(&AbsPath) -> Option<FileId>,
199 ) -> CrateGraph { 203 ) -> CrateGraph {
204 let proc_macro_loader = |path: &Path| match proc_macro_client {
205 Some(client) => client.by_dylib_path(path),
206 None => Vec::new(),
207 };
208
200 let mut crate_graph = match self { 209 let mut crate_graph = match self {
201 ProjectWorkspace::Json { project, sysroot } => { 210 ProjectWorkspace::Json { project, sysroot } => {
202 project_json_to_crate_graph(target, proc_macro_client, load, project, sysroot) 211 project_json_to_crate_graph(target, &proc_macro_loader, load, project, sysroot)
203 } 212 }
204 ProjectWorkspace::Cargo { cargo, sysroot, rustc } => { 213 ProjectWorkspace::Cargo { cargo, sysroot, rustc } => {
205 cargo_to_crate_graph(target, proc_macro_client, load, cargo, sysroot, rustc) 214 cargo_to_crate_graph(target, &proc_macro_loader, load, cargo, sysroot, rustc)
206 } 215 }
207 }; 216 };
208 if crate_graph.patch_cfg_if() { 217 if crate_graph.patch_cfg_if() {
@@ -216,7 +225,7 @@ impl ProjectWorkspace {
216 225
217fn project_json_to_crate_graph( 226fn project_json_to_crate_graph(
218 target: Option<&str>, 227 target: Option<&str>,
219 proc_macro_client: &ProcMacroClient, 228 proc_macro_loader: &dyn Fn(&Path) -> Vec<ProcMacro>,
220 load: &mut dyn FnMut(&AbsPath) -> Option<FileId>, 229 load: &mut dyn FnMut(&AbsPath) -> Option<FileId>,
221 project: &ProjectJson, 230 project: &ProjectJson,
222 sysroot: &Option<Sysroot>, 231 sysroot: &Option<Sysroot>,
@@ -236,8 +245,7 @@ fn project_json_to_crate_graph(
236 }) 245 })
237 .map(|(crate_id, krate, file_id)| { 246 .map(|(crate_id, krate, file_id)| {
238 let env = krate.env.clone().into_iter().collect(); 247 let env = krate.env.clone().into_iter().collect();
239 let proc_macro = 248 let proc_macro = krate.proc_macro_dylib_path.clone().map(|it| proc_macro_loader(&it));
240 krate.proc_macro_dylib_path.clone().map(|it| proc_macro_client.by_dylib_path(&it));
241 249
242 let target = krate.target.as_deref().or(target); 250 let target = krate.target.as_deref().or(target);
243 let target_cfgs = 251 let target_cfgs =
@@ -279,7 +287,7 @@ fn project_json_to_crate_graph(
279 287
280fn cargo_to_crate_graph( 288fn cargo_to_crate_graph(
281 target: Option<&str>, 289 target: Option<&str>,
282 proc_macro_client: &ProcMacroClient, 290 proc_macro_loader: &dyn Fn(&Path) -> Vec<ProcMacro>,
283 load: &mut dyn FnMut(&AbsPath) -> Option<FileId>, 291 load: &mut dyn FnMut(&AbsPath) -> Option<FileId>,
284 cargo: &CargoWorkspace, 292 cargo: &CargoWorkspace,
285 sysroot: &Sysroot, 293 sysroot: &Sysroot,
@@ -309,7 +317,7 @@ fn cargo_to_crate_graph(
309 &mut crate_graph, 317 &mut crate_graph,
310 &cargo[pkg], 318 &cargo[pkg],
311 &cfg_options, 319 &cfg_options,
312 proc_macro_client, 320 proc_macro_loader,
313 file_id, 321 file_id,
314 ); 322 );
315 if cargo[tgt].kind == TargetKind::Lib { 323 if cargo[tgt].kind == TargetKind::Lib {
@@ -385,7 +393,7 @@ fn cargo_to_crate_graph(
385 &mut crate_graph, 393 &mut crate_graph,
386 &rustc_workspace[pkg], 394 &rustc_workspace[pkg],
387 &cfg_options, 395 &cfg_options,
388 proc_macro_client, 396 proc_macro_loader,
389 file_id, 397 file_id,
390 ); 398 );
391 pkg_to_lib_crate.insert(pkg, crate_id); 399 pkg_to_lib_crate.insert(pkg, crate_id);
@@ -433,7 +441,7 @@ fn add_target_crate_root(
433 crate_graph: &mut CrateGraph, 441 crate_graph: &mut CrateGraph,
434 pkg: &cargo_workspace::PackageData, 442 pkg: &cargo_workspace::PackageData,
435 cfg_options: &CfgOptions, 443 cfg_options: &CfgOptions,
436 proc_macro_client: &ProcMacroClient, 444 proc_macro_loader: &dyn Fn(&Path) -> Vec<ProcMacro>,
437 file_id: FileId, 445 file_id: FileId,
438) -> CrateId { 446) -> CrateId {
439 let edition = pkg.edition; 447 let edition = pkg.edition;
@@ -452,11 +460,8 @@ fn add_target_crate_root(
452 env.set("OUT_DIR", out_dir); 460 env.set("OUT_DIR", out_dir);
453 } 461 }
454 } 462 }
455 let proc_macro = pkg 463 let proc_macro =
456 .proc_macro_dylib_path 464 pkg.proc_macro_dylib_path.as_ref().map(|it| proc_macro_loader(&it)).unwrap_or_default();
457 .as_ref()
458 .map(|it| proc_macro_client.by_dylib_path(&it))
459 .unwrap_or_default();
460 465
461 let display_name = CrateDisplayName::from_canonical_name(pkg.name.clone()); 466 let display_name = CrateDisplayName::from_canonical_name(pkg.name.clone());
462 let crate_id = crate_graph.add_crate_root( 467 let crate_id = crate_graph.add_crate_root(
diff --git a/crates/rust-analyzer/src/cli/load_cargo.rs b/crates/rust-analyzer/src/cli/load_cargo.rs
index 76526c66c..d51f4a93a 100644
--- a/crates/rust-analyzer/src/cli/load_cargo.rs
+++ b/crates/rust-analyzer/src/cli/load_cargo.rs
@@ -33,12 +33,12 @@ pub fn load_cargo(
33 33
34 let proc_macro_client = if with_proc_macro { 34 let proc_macro_client = if with_proc_macro {
35 let path = std::env::current_exe()?; 35 let path = std::env::current_exe()?;
36 ProcMacroClient::extern_process(path, &["proc-macro"]).unwrap() 36 Some(ProcMacroClient::extern_process(path, &["proc-macro"]).unwrap())
37 } else { 37 } else {
38 ProcMacroClient::dummy() 38 None
39 }; 39 };
40 40
41 let crate_graph = ws.to_crate_graph(None, &proc_macro_client, &mut |path: &AbsPath| { 41 let crate_graph = ws.to_crate_graph(None, proc_macro_client.as_ref(), &mut |path: &AbsPath| {
42 let contents = loader.load_sync(path); 42 let contents = loader.load_sync(path);
43 let path = vfs::VfsPath::from(path.to_path_buf()); 43 let path = vfs::VfsPath::from(path.to_path_buf());
44 vfs.set_file_contents(path.clone(), contents); 44 vfs.set_file_contents(path.clone(), contents);
diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs
index defe11c55..a27495d0d 100644
--- a/crates/rust-analyzer/src/global_state.rs
+++ b/crates/rust-analyzer/src/global_state.rs
@@ -75,7 +75,7 @@ pub(crate) struct GlobalState {
75 pub(crate) shutdown_requested: bool, 75 pub(crate) shutdown_requested: bool,
76 pub(crate) status: Status, 76 pub(crate) status: Status,
77 pub(crate) source_root_config: SourceRootConfig, 77 pub(crate) source_root_config: SourceRootConfig,
78 pub(crate) proc_macro_client: ProcMacroClient, 78 pub(crate) proc_macro_client: Option<ProcMacroClient>,
79 pub(crate) workspaces: Arc<Vec<ProjectWorkspace>>, 79 pub(crate) workspaces: Arc<Vec<ProjectWorkspace>>,
80 latest_requests: Arc<RwLock<LatestRequests>>, 80 latest_requests: Arc<RwLock<LatestRequests>>,
81} 81}
@@ -127,7 +127,7 @@ impl GlobalState {
127 shutdown_requested: false, 127 shutdown_requested: false,
128 status: Status::default(), 128 status: Status::default(),
129 source_root_config: SourceRootConfig::default(), 129 source_root_config: SourceRootConfig::default(),
130 proc_macro_client: ProcMacroClient::dummy(), 130 proc_macro_client: None,
131 workspaces: Arc::new(Vec::new()), 131 workspaces: Arc::new(Vec::new()),
132 latest_requests: Default::default(), 132 latest_requests: Default::default(),
133 } 133 }
diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs
index b2d35f535..79e39e3a5 100644
--- a/crates/rust-analyzer/src/reload.rs
+++ b/crates/rust-analyzer/src/reload.rs
@@ -171,16 +171,16 @@ impl GlobalState {
171 let project_folders = ProjectFolders::new(&workspaces); 171 let project_folders = ProjectFolders::new(&workspaces);
172 172
173 self.proc_macro_client = match &self.config.proc_macro_srv { 173 self.proc_macro_client = match &self.config.proc_macro_srv {
174 None => ProcMacroClient::dummy(), 174 None => None,
175 Some((path, args)) => match ProcMacroClient::extern_process(path.into(), args) { 175 Some((path, args)) => match ProcMacroClient::extern_process(path.into(), args) {
176 Ok(it) => it, 176 Ok(it) => Some(it),
177 Err(err) => { 177 Err(err) => {
178 log::error!( 178 log::error!(
179 "Failed to run proc_macro_srv from path {}, error: {:?}", 179 "Failed to run proc_macro_srv from path {}, error: {:?}",
180 path.display(), 180 path.display(),
181 err 181 err
182 ); 182 );
183 ProcMacroClient::dummy() 183 None
184 } 184 }
185 }, 185 },
186 }; 186 };
@@ -212,7 +212,7 @@ impl GlobalState {
212 for ws in workspaces.iter() { 212 for ws in workspaces.iter() {
213 crate_graph.extend(ws.to_crate_graph( 213 crate_graph.extend(ws.to_crate_graph(
214 self.config.cargo.target.as_deref(), 214 self.config.cargo.target.as_deref(),
215 &self.proc_macro_client, 215 self.proc_macro_client.as_ref(),
216 &mut load, 216 &mut load,
217 )); 217 ));
218 } 218 }