Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sysroot crate-graph construction not mapping crate-ids for proc-macros #19241

Merged
merged 1 commit into from
Feb 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions crates/project-model/src/workspace.rs
Original file line number Diff line number Diff line change
@@ -1094,8 +1094,7 @@ fn cargo_to_crate_graph(
) -> (CrateGraph, ProcMacroPaths) {
let _p = tracing::info_span!("cargo_to_crate_graph").entered();
let mut res = (CrateGraph::default(), ProcMacroPaths::default());
let crate_graph = &mut res.0;
let proc_macros = &mut res.1;
let (crate_graph, proc_macros) = &mut res;
let (public_deps, libproc_macro) =
sysroot_to_crate_graph(crate_graph, sysroot, rustc_cfg.clone(), load);

@@ -1560,6 +1559,10 @@ fn extend_crate_graph_with_sysroot(

// Remove all crates except the ones we are interested in to keep the sysroot graph small.
let removed_mapping = sysroot_crate_graph.remove_crates_except(&marker_set);
sysroot_proc_macros = sysroot_proc_macros
.into_iter()
.filter_map(|(k, v)| Some((removed_mapping[k.into_raw().into_u32() as usize]?, v)))
.collect();
let mapping = crate_graph.extend(sysroot_crate_graph, &mut sysroot_proc_macros);

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