mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-28 05:53:45 +00:00
fix: Fix proc-macro paths using incorrect CrateId's for rust-project.json workspaces
This commit is contained in:
parent
c04a13cb19
commit
b03a218b57
1 changed files with 32 additions and 34 deletions
|
@ -704,15 +704,7 @@ fn project_json_to_crate_graph(
|
||||||
})
|
})
|
||||||
.map(|(crate_id, krate, file_id)| {
|
.map(|(crate_id, krate, file_id)| {
|
||||||
let env = krate.env.clone().into_iter().collect();
|
let env = krate.env.clone().into_iter().collect();
|
||||||
if let Some(path) = krate.proc_macro_dylib_path.clone() {
|
|
||||||
proc_macros.insert(
|
|
||||||
crate_id,
|
|
||||||
Some((
|
|
||||||
krate.display_name.as_ref().map(|it| it.canonical_name().to_owned()),
|
|
||||||
path,
|
|
||||||
)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
let target_cfgs = match krate.target.as_deref() {
|
let target_cfgs = match krate.target.as_deref() {
|
||||||
Some(target) => cfg_cache
|
Some(target) => cfg_cache
|
||||||
.entry(target)
|
.entry(target)
|
||||||
|
@ -722,9 +714,7 @@ fn project_json_to_crate_graph(
|
||||||
|
|
||||||
let mut cfg_options = CfgOptions::default();
|
let mut cfg_options = CfgOptions::default();
|
||||||
cfg_options.extend(target_cfgs.iter().chain(krate.cfg.iter()).cloned());
|
cfg_options.extend(target_cfgs.iter().chain(krate.cfg.iter()).cloned());
|
||||||
(
|
let crate_graph_crate_id = crate_graph.add_crate_root(
|
||||||
crate_id,
|
|
||||||
crate_graph.add_crate_root(
|
|
||||||
file_id,
|
file_id,
|
||||||
krate.edition,
|
krate.edition,
|
||||||
krate.display_name.clone(),
|
krate.display_name.clone(),
|
||||||
|
@ -736,17 +726,25 @@ fn project_json_to_crate_graph(
|
||||||
if krate.display_name.is_some() {
|
if krate.display_name.is_some() {
|
||||||
CrateOrigin::CratesIo {
|
CrateOrigin::CratesIo {
|
||||||
repo: krate.repository.clone(),
|
repo: krate.repository.clone(),
|
||||||
name: krate
|
name: krate.display_name.clone().map(|n| n.canonical_name().to_string()),
|
||||||
.display_name
|
|
||||||
.clone()
|
|
||||||
.map(|n| n.canonical_name().to_string()),
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
CrateOrigin::CratesIo { repo: None, name: None }
|
CrateOrigin::CratesIo { repo: None, name: None }
|
||||||
},
|
},
|
||||||
target_layout.clone(),
|
target_layout.clone(),
|
||||||
),
|
);
|
||||||
)
|
if krate.is_proc_macro {
|
||||||
|
if let Some(path) = krate.proc_macro_dylib_path.clone() {
|
||||||
|
proc_macros.insert(
|
||||||
|
crate_graph_crate_id,
|
||||||
|
Some((
|
||||||
|
krate.display_name.as_ref().map(|it| it.canonical_name().to_owned()),
|
||||||
|
path,
|
||||||
|
)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
(crate_id, crate_graph_crate_id)
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue