mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 01:17:27 +00:00
fix: Fix server panicking on project loading when proc-macros are disabled
This commit is contained in:
parent
1c752841e2
commit
c8ff70e924
2 changed files with 8 additions and 3 deletions
|
@ -66,7 +66,9 @@ pub fn load_workspace(
|
|||
};
|
||||
|
||||
let crate_graph = ws.to_crate_graph(
|
||||
&mut |_, path: &AbsPath| load_proc_macro(proc_macro_client.as_ref(), path, &[]),
|
||||
&mut |_, path: &AbsPath| {
|
||||
load_proc_macro(proc_macro_client.as_ref().map_err(|e| &**e), path, &[])
|
||||
},
|
||||
&mut |path: &AbsPath| {
|
||||
let contents = loader.load_sync(path);
|
||||
let path = vfs::VfsPath::from(path.to_path_buf());
|
||||
|
|
|
@ -390,7 +390,10 @@ impl GlobalState {
|
|||
|
||||
let mut crate_graph = CrateGraph::default();
|
||||
for (idx, ws) in self.workspaces.iter().enumerate() {
|
||||
let proc_macro_client = self.proc_macro_clients[idx].as_ref();
|
||||
let proc_macro_client = match self.proc_macro_clients.get(idx) {
|
||||
Some(res) => res.as_ref().map_err(|e| &**e),
|
||||
None => Err("Proc macros are disabled"),
|
||||
};
|
||||
let mut load_proc_macro = move |crate_name: &str, path: &AbsPath| {
|
||||
load_proc_macro(
|
||||
proc_macro_client,
|
||||
|
@ -574,7 +577,7 @@ impl SourceRootConfig {
|
|||
/// Load the proc-macros for the given lib path, replacing all expanders whose names are in `dummy_replace`
|
||||
/// with an identity dummy expander.
|
||||
pub(crate) fn load_proc_macro(
|
||||
server: Result<&ProcMacroServer, &String>,
|
||||
server: Result<&ProcMacroServer, &str>,
|
||||
path: &AbsPath,
|
||||
dummy_replace: &[Box<str>],
|
||||
) -> ProcMacroLoadResult {
|
||||
|
|
Loading…
Reference in a new issue