mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
add proc-macro crate type handling
This commit is contained in:
parent
ea3124c12a
commit
6a8b4f873a
3 changed files with 30 additions and 1 deletions
|
@ -210,6 +210,8 @@ impl ProjectWorkspace {
|
|||
|
||||
let libcore = sysroot.core().and_then(|it| sysroot_crates.get(&it).copied());
|
||||
let libstd = sysroot.std().and_then(|it| sysroot_crates.get(&it).copied());
|
||||
let libproc_macro =
|
||||
sysroot.proc_macro().and_then(|it| sysroot_crates.get(&it).copied());
|
||||
|
||||
let mut pkg_to_lib_crate = FxHashMap::default();
|
||||
let mut pkg_crates = FxHashMap::default();
|
||||
|
@ -236,6 +238,21 @@ impl ProjectWorkspace {
|
|||
lib_tgt = Some(crate_id);
|
||||
pkg_to_lib_crate.insert(pkg, crate_id);
|
||||
}
|
||||
if tgt.is_proc_macro(&cargo) {
|
||||
if let Some(proc_macro) = libproc_macro {
|
||||
if let Err(_) = crate_graph.add_dep(
|
||||
crate_id,
|
||||
"proc_macro".into(),
|
||||
proc_macro,
|
||||
) {
|
||||
log::error!(
|
||||
"cyclic dependency on proc_macro for {}",
|
||||
pkg.name(&cargo)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pkg_crates.entry(pkg).or_insert_with(Vec::new).push(crate_id);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue