Skip to content

Commit a42729a

Browse files
committed
Simplify crate graph creation
1 parent 9970dd3 commit a42729a

File tree

1 file changed

+16
-22
lines changed

1 file changed

+16
-22
lines changed

crates/rust-analyzer/src/world.rs

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,6 @@ impl WorldState {
137137
opts
138138
};
139139

140-
// Create crate graph from all the workspaces
141-
let mut crate_graph = CrateGraph::default();
142-
let mut load = |path: &std::path::Path| {
143-
// Some path from metadata will be non canonicalized, e.g. /foo/../bar/lib.rs
144-
let path = path.canonicalize().ok()?;
145-
let vfs_file = vfs.load(&path);
146-
vfs_file.map(|f| FileId(f.0))
147-
};
148-
149140
let proc_macro_client = match &config.proc_macro_srv {
150141
None => ProcMacroClient::dummy(),
151142
Some((path, args)) => match ProcMacroClient::extern_process(path.into(), args) {
@@ -161,19 +152,22 @@ impl WorldState {
161152
},
162153
};
163154

164-
workspaces
165-
.iter()
166-
.map(|ws| {
167-
ws.to_crate_graph(
168-
&default_cfg_options,
169-
&extern_source_roots,
170-
&proc_macro_client,
171-
&mut load,
172-
)
173-
})
174-
.for_each(|graph| {
175-
crate_graph.extend(graph);
176-
});
155+
// Create crate graph from all the workspaces
156+
let mut crate_graph = CrateGraph::default();
157+
let mut load = |path: &Path| {
158+
// Some path from metadata will be non canonicalized, e.g. /foo/../bar/lib.rs
159+
let path = path.canonicalize().ok()?;
160+
let vfs_file = vfs.load(&path);
161+
vfs_file.map(|f| FileId(f.0))
162+
};
163+
for ws in workspaces.iter() {
164+
crate_graph.extend(ws.to_crate_graph(
165+
&default_cfg_options,
166+
&extern_source_roots,
167+
&proc_macro_client,
168+
&mut load,
169+
));
170+
}
177171
change.set_crate_graph(crate_graph);
178172

179173
let flycheck = config.check.as_ref().and_then(|c| create_flycheck(&workspaces, c));

0 commit comments

Comments
 (0)