Skip to content

Commit 606efbc

Browse files
committed
Fix sysroot crate-graph construction not mapping crate-ids for proc-macros
1 parent 2f5e8d7 commit 606efbc

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

crates/project-model/src/workspace.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,8 +1069,7 @@ fn cargo_to_crate_graph(
10691069
) -> (CrateGraph, ProcMacroPaths) {
10701070
let _p = tracing::info_span!("cargo_to_crate_graph").entered();
10711071
let mut res = (CrateGraph::default(), ProcMacroPaths::default());
1072-
let crate_graph = &mut res.0;
1073-
let proc_macros = &mut res.1;
1072+
let (crate_graph, proc_macros) = &mut res;
10741073
let (public_deps, libproc_macro) =
10751074
sysroot_to_crate_graph(crate_graph, sysroot, rustc_cfg.clone(), load);
10761075

@@ -1499,7 +1498,7 @@ fn sysroot_to_crate_graph(
14991498
let _p = tracing::info_span!("sysroot_to_crate_graph").entered();
15001499
match sysroot.workspace() {
15011500
RustLibSrcWorkspace::Workspace(cargo) => {
1502-
let (mut cg, mut pm) = cargo_to_crate_graph(
1501+
let (mut cg, pm) = cargo_to_crate_graph(
15031502
load,
15041503
None,
15051504
cargo,
@@ -1519,7 +1518,6 @@ fn sysroot_to_crate_graph(
15191518
&WorkspaceBuildScripts::default(),
15201519
false,
15211520
);
1522-
15231521
let mut pub_deps = vec![];
15241522
let mut libproc_macro = None;
15251523
let diff = CfgDiff::new(vec![], vec![CfgAtom::Flag(sym::test.clone())]).unwrap();
@@ -1560,6 +1558,10 @@ fn sysroot_to_crate_graph(
15601558

15611559
// Remove all crates except the ones we are interested in to keep the sysroot graph small.
15621560
let removed_mapping = cg.remove_crates_except(&marker_set);
1561+
let mut pm = pm
1562+
.into_iter()
1563+
.filter_map(|(k, v)| Some((removed_mapping[k.into_raw().into_u32() as usize]?, v)))
1564+
.collect();
15631565
let mapping = crate_graph.extend(cg, &mut pm);
15641566

15651567
// Map the id through the removal mapping first, then through the crate graph extension mapping.

0 commit comments

Comments
 (0)