about summary refs log tree commit diff
path: root/src/tools
diff options
context:
space:
mode:
authorLukas Wirth <lukastw97@gmail.com>2025-02-27 11:55:22 +0100
committerLukas Wirth <lukastw97@gmail.com>2025-02-27 13:20:19 +0100
commitcabb08ded5a8ac6d06f8f0803939d31e274da799 (patch)
tree808065555a17130106f4b5c23b013fcefb8e2329 /src/tools
parentd4b92f4b682eb7d856f09a3f58adc6338b5f5e9c (diff)
downloadrust-cabb08ded5a8ac6d06f8f0803939d31e274da799.tar.gz
rust-cabb08ded5a8ac6d06f8f0803939d31e274da799.zip
Fix sysroot crate-graph construction not mapping crate-ids for proc-macros
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/rust-analyzer/crates/project-model/src/workspace.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/tools/rust-analyzer/crates/project-model/src/workspace.rs b/src/tools/rust-analyzer/crates/project-model/src/workspace.rs
index 6b6fb5f9ec1..2c9f41e828e 100644
--- a/src/tools/rust-analyzer/crates/project-model/src/workspace.rs
+++ b/src/tools/rust-analyzer/crates/project-model/src/workspace.rs
@@ -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.