Skip to content

Commit

Permalink
Auto merge of #12515 - Veykril:rustc-proc-macros, r=Veykril
Browse files Browse the repository at this point in the history
fix: Pass the build data to rustc_private crates

With this all proc-macros should resolve in rustc now when setting up the build script running command properly.
  • Loading branch information
bors committed Jun 12, 2022
2 parents 6c65edf + 10e9f47 commit 366bd72
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion crates/project-model/src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@ fn cargo_to_crate_graph(
&public_deps,
cargo,
&pkg_crates,
build_scripts,
);
}
}
Expand Down Expand Up @@ -728,6 +729,7 @@ fn handle_rustc_crates(
public_deps: &SysrootPublicDeps,
cargo: &CargoWorkspace,
pkg_crates: &FxHashMap<la_arena::Idx<crate::PackageData>, Vec<(CrateId, TargetKind)>>,
build_scripts: &WorkspaceBuildScripts,
) {
let mut rustc_pkg_crates = FxHashMap::default();
// The root package of the rustc-dev component is rustc_driver, so we match that
Expand Down Expand Up @@ -781,7 +783,7 @@ fn handle_rustc_crates(
let crate_id = add_target_crate_root(
crate_graph,
&rustc_workspace[pkg],
None,
build_scripts.get_output(pkg),
cfg_options,
&mut |path| load_proc_macro(&rustc_workspace[tgt].name, path),
file_id,
Expand Down
8 changes: 7 additions & 1 deletion crates/rust-analyzer/src/reload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ pub(crate) fn load_proc_macro(
}
};

return client
let proc_macros: Vec<_> = client
.map(|it| it.load_dylib(dylib))
.into_iter()
.flat_map(|it| match it {
Expand All @@ -568,6 +568,12 @@ pub(crate) fn load_proc_macro(
})
.map(|expander| expander_to_proc_macro(expander, dummy_replace))
.collect();
tracing::info!(
"Loaded proc-macros for {}: {:?}",
path.display(),
proc_macros.iter().map(|it| it.name.clone()).collect::<Vec<_>>()
);
return proc_macros;

fn expander_to_proc_macro(
expander: proc_macro_api::ProcMacro,
Expand Down

0 comments on commit 366bd72

Please sign in to comment.