Skip to content

Commit 6f297b9

Browse files
committed
Auto merge of rust-lang#14348 - Veykril:rustc-proc, r=Veykril
fix: Fix rustc proc-macro handling being broken on the rustc workspace itself Also addresses rust-lang/rust-analyzer#13591 (comment)
2 parents 6a98e96 + 88f0fe7 commit 6f297b9

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
@@ -429,8 +429,9 @@ impl WorkspaceBuildScripts {
429429
for p in rustc.packages() {
430430
let package = &rustc[p];
431431
if package.targets.iter().any(|&it| rustc[it].is_proc_macro) {
432-
if let Some((_, path)) =
433-
proc_macro_dylibs.iter().find(|(name, _)| *name == package.name)
432+
if let Some((_, path)) = proc_macro_dylibs
433+
.iter()
434+
.find(|(name, _)| *name.trim_start_matches("lib") == package.name)
434435
{
435436
bs.outputs[p].proc_macro_dylib_path = Some(path.clone());
436437
}

crates/project-model/src/workspace.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ fn cargo_to_crate_graph(
940940
if has_private {
941941
// If the user provided a path to rustc sources, we add all the rustc_private crates
942942
// and create dependencies on them for the crates which opt-in to that
943-
if let Some((rustc_workspace, build_scripts)) = rustc {
943+
if let Some((rustc_workspace, rustc_build_scripts)) = rustc {
944944
handle_rustc_crates(
945945
&mut crate_graph,
946946
&mut pkg_to_lib_crate,
@@ -953,7 +953,13 @@ fn cargo_to_crate_graph(
953953
&pkg_crates,
954954
&cfg_options,
955955
override_cfg,
956-
build_scripts,
956+
if rustc_workspace.workspace_root() == cargo.workspace_root() {
957+
// the rustc workspace does not use the installed toolchain's proc-macro server
958+
// so we need to make sure we don't use the pre compiled proc-macros there either
959+
build_scripts
960+
} else {
961+
rustc_build_scripts
962+
},
957963
target_layout,
958964
);
959965
}

0 commit comments

Comments
 (0)