diff --git a/crates/project-model/src/tests.rs b/crates/project-model/src/tests.rs index 3d089b61b5a..e72903e55fe 100644 --- a/crates/project-model/src/tests.rs +++ b/crates/project-model/src/tests.rs @@ -88,7 +88,7 @@ fn rooted_project_json(data: ProjectJsonData) -> ProjectJson { } fn to_crate_graph(project_workspace: ProjectWorkspace) -> CrateGraph { - project_workspace.to_crate_graph(&Default::default(), &mut |_, _| Vec::new(), &mut { + project_workspace.to_crate_graph(&mut |_, _| Vec::new(), &mut { let mut counter = 0; move |_path| { counter += 1; diff --git a/crates/project-model/src/workspace.rs b/crates/project-model/src/workspace.rs index 93255705be4..ace1d455c46 100644 --- a/crates/project-model/src/workspace.rs +++ b/crates/project-model/src/workspace.rs @@ -389,14 +389,10 @@ pub fn n_packages(&self) -> usize { pub fn to_crate_graph( &self, - dummy_replace: &FxHashMap, Box<[Box]>>, - load_proc_macro: &mut dyn FnMut(&AbsPath, &[Box]) -> Vec, + load_proc_macro: &mut dyn FnMut(&str, &AbsPath) -> Vec, load: &mut dyn FnMut(&AbsPath) -> Option, ) -> CrateGraph { let _p = profile::span("ProjectWorkspace::to_crate_graph"); - let load_proc_macro = &mut |crate_name: &_, path: &_| { - load_proc_macro(path, dummy_replace.get(crate_name).map(|it| &**it).unwrap_or_default()) - }; let mut crate_graph = match self { ProjectWorkspace::Json { project, sysroot, rustc_cfg } => project_json_to_crate_graph( diff --git a/crates/rust-analyzer/src/cli/load_cargo.rs b/crates/rust-analyzer/src/cli/load_cargo.rs index 490aef50f3e..4243af25ff1 100644 --- a/crates/rust-analyzer/src/cli/load_cargo.rs +++ b/crates/rust-analyzer/src/cli/load_cargo.rs @@ -66,8 +66,7 @@ pub fn load_workspace( }; let crate_graph = ws.to_crate_graph( - &Default::default(), - &mut |path: &AbsPath, _| load_proc_macro(proc_macro_client.as_ref(), path, &[]), + &mut |_, path: &AbsPath| load_proc_macro(proc_macro_client.as_ref(), path, &[]), &mut |path: &AbsPath| { let contents = loader.load_sync(path); let path = vfs::VfsPath::from(path.to_path_buf()); diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs index c2a521bbf54..ed8c24acd1c 100644 --- a/crates/rust-analyzer/src/reload.rs +++ b/crates/rust-analyzer/src/reload.rs @@ -319,8 +319,13 @@ fn eq_ignore_build_data<'a>( // Create crate graph from all the workspaces let crate_graph = { let proc_macro_client = self.proc_macro_client.as_ref(); - let mut load_proc_macro = move |path: &AbsPath, dummy_replace: &_| { - load_proc_macro(proc_macro_client, path, dummy_replace) + let dummy_replacements = self.config.dummy_replacements(); + let mut load_proc_macro = move |crate_name: &str, path: &AbsPath| { + load_proc_macro( + proc_macro_client, + path, + dummy_replacements.get(crate_name).map(|v| &**v).unwrap_or_default(), + ) }; let vfs = &mut self.vfs.write().0; @@ -342,11 +347,7 @@ fn eq_ignore_build_data<'a>( let mut crate_graph = CrateGraph::default(); for ws in self.workspaces.iter() { - crate_graph.extend(ws.to_crate_graph( - self.config.dummy_replacements(), - &mut load_proc_macro, - &mut load, - )); + crate_graph.extend(ws.to_crate_graph(&mut load_proc_macro, &mut load)); } crate_graph };