Auto merge of #12314 - jonas-schievink:proc-macro-load, r=jonas-schievink
minor: simplify
This commit is contained in:
commit
eba26af9f1
@ -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;
|
||||
|
@ -389,14 +389,10 @@ pub fn n_packages(&self) -> usize {
|
||||
|
||||
pub fn to_crate_graph(
|
||||
&self,
|
||||
dummy_replace: &FxHashMap<Box<str>, Box<[Box<str>]>>,
|
||||
load_proc_macro: &mut dyn FnMut(&AbsPath, &[Box<str>]) -> Vec<ProcMacro>,
|
||||
load_proc_macro: &mut dyn FnMut(&str, &AbsPath) -> Vec<ProcMacro>,
|
||||
load: &mut dyn FnMut(&AbsPath) -> Option<FileId>,
|
||||
) -> 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(
|
||||
|
@ -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());
|
||||
|
@ -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
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user