Skip to content

Commit b03a218

Browse files
committed
fix: Fix proc-macro paths using incorrect CrateId's for rust-project.json workspaces
1 parent c04a13c commit b03a218

File tree

1 file changed

+32
-34
lines changed

1 file changed

+32
-34
lines changed

crates/project-model/src/workspace.rs

+32-34
Original file line numberDiff line numberDiff line change
@@ -704,15 +704,7 @@ fn project_json_to_crate_graph(
704704
})
705705
.map(|(crate_id, krate, file_id)| {
706706
let env = krate.env.clone().into_iter().collect();
707-
if let Some(path) = krate.proc_macro_dylib_path.clone() {
708-
proc_macros.insert(
709-
crate_id,
710-
Some((
711-
krate.display_name.as_ref().map(|it| it.canonical_name().to_owned()),
712-
path,
713-
)),
714-
);
715-
}
707+
716708
let target_cfgs = match krate.target.as_deref() {
717709
Some(target) => cfg_cache
718710
.entry(target)
@@ -722,31 +714,37 @@ fn project_json_to_crate_graph(
722714

723715
let mut cfg_options = CfgOptions::default();
724716
cfg_options.extend(target_cfgs.iter().chain(krate.cfg.iter()).cloned());
725-
(
726-
crate_id,
727-
crate_graph.add_crate_root(
728-
file_id,
729-
krate.edition,
730-
krate.display_name.clone(),
731-
krate.version.clone(),
732-
cfg_options.clone(),
733-
cfg_options,
734-
env,
735-
krate.is_proc_macro,
736-
if krate.display_name.is_some() {
737-
CrateOrigin::CratesIo {
738-
repo: krate.repository.clone(),
739-
name: krate
740-
.display_name
741-
.clone()
742-
.map(|n| n.canonical_name().to_string()),
743-
}
744-
} else {
745-
CrateOrigin::CratesIo { repo: None, name: None }
746-
},
747-
target_layout.clone(),
748-
),
749-
)
717+
let crate_graph_crate_id = crate_graph.add_crate_root(
718+
file_id,
719+
krate.edition,
720+
krate.display_name.clone(),
721+
krate.version.clone(),
722+
cfg_options.clone(),
723+
cfg_options,
724+
env,
725+
krate.is_proc_macro,
726+
if krate.display_name.is_some() {
727+
CrateOrigin::CratesIo {
728+
repo: krate.repository.clone(),
729+
name: krate.display_name.clone().map(|n| n.canonical_name().to_string()),
730+
}
731+
} else {
732+
CrateOrigin::CratesIo { repo: None, name: None }
733+
},
734+
target_layout.clone(),
735+
);
736+
if krate.is_proc_macro {
737+
if let Some(path) = krate.proc_macro_dylib_path.clone() {
738+
proc_macros.insert(
739+
crate_graph_crate_id,
740+
Some((
741+
krate.display_name.as_ref().map(|it| it.canonical_name().to_owned()),
742+
path,
743+
)),
744+
);
745+
}
746+
}
747+
(crate_id, crate_graph_crate_id)
750748
})
751749
.collect();
752750

0 commit comments

Comments
 (0)