Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 88f0fe7

Browse files
committed
fix: Fix rustc proc-macro handling being broken on the rustc workspace itself
1 parent aaf08bd commit 88f0fe7

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

crates/project-model/src/build_scripts.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,9 @@ impl WorkspaceBuildScripts {
428428
for p in rustc.packages() {
429429
let package = &rustc[p];
430430
if package.targets.iter().any(|&it| rustc[it].is_proc_macro) {
431-
if let Some((_, path)) =
432-
proc_macro_dylibs.iter().find(|(name, _)| *name == package.name)
431+
if let Some((_, path)) = proc_macro_dylibs
432+
.iter()
433+
.find(|(name, _)| *name.trim_start_matches("lib") == package.name)
433434
{
434435
bs.outputs[p].proc_macro_dylib_path = Some(path.clone());
435436
}

crates/project-model/src/workspace.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,7 @@ fn cargo_to_crate_graph(
932932
if has_private {
933933
// If the user provided a path to rustc sources, we add all the rustc_private crates
934934
// and create dependencies on them for the crates which opt-in to that
935-
if let Some((rustc_workspace, build_scripts)) = rustc {
935+
if let Some((rustc_workspace, rustc_build_scripts)) = rustc {
936936
handle_rustc_crates(
937937
&mut crate_graph,
938938
&mut pkg_to_lib_crate,
@@ -945,7 +945,13 @@ fn cargo_to_crate_graph(
945945
&pkg_crates,
946946
&cfg_options,
947947
override_cfg,
948-
build_scripts,
948+
if rustc_workspace.workspace_root() == cargo.workspace_root() {
949+
// the rustc workspace does not use the installed toolchain's proc-macro server
950+
// so we need to make sure we don't use the pre compiled proc-macros there either
951+
build_scripts
952+
} else {
953+
rustc_build_scripts
954+
},
949955
target_layout,
950956
);
951957
}

0 commit comments

Comments
 (0)