diff options
author | JasperDeSutter <[email protected]> | 2019-11-24 10:33:12 +0000 |
---|---|---|
committer | JasperDeSutter <[email protected]> | 2019-11-24 15:55:56 +0000 |
commit | 6a8b4f873aa42f3522d3a92384019272b6ccefd2 (patch) | |
tree | 23235e959e23796bb05c811742375aeaf8143953 /crates/ra_project_model/src/lib.rs | |
parent | ea3124c12a52f28163a6375b6a5e3c79fc14312d (diff) |
add proc-macro crate type handling
Diffstat (limited to 'crates/ra_project_model/src/lib.rs')
-rw-r--r-- | crates/ra_project_model/src/lib.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs index d04a8cbe2..77f729a25 100644 --- a/crates/ra_project_model/src/lib.rs +++ b/crates/ra_project_model/src/lib.rs | |||
@@ -210,6 +210,8 @@ impl ProjectWorkspace { | |||
210 | 210 | ||
211 | let libcore = sysroot.core().and_then(|it| sysroot_crates.get(&it).copied()); | 211 | let libcore = sysroot.core().and_then(|it| sysroot_crates.get(&it).copied()); |
212 | let libstd = sysroot.std().and_then(|it| sysroot_crates.get(&it).copied()); | 212 | let libstd = sysroot.std().and_then(|it| sysroot_crates.get(&it).copied()); |
213 | let libproc_macro = | ||
214 | sysroot.proc_macro().and_then(|it| sysroot_crates.get(&it).copied()); | ||
213 | 215 | ||
214 | let mut pkg_to_lib_crate = FxHashMap::default(); | 216 | let mut pkg_to_lib_crate = FxHashMap::default(); |
215 | let mut pkg_crates = FxHashMap::default(); | 217 | let mut pkg_crates = FxHashMap::default(); |
@@ -236,6 +238,21 @@ impl ProjectWorkspace { | |||
236 | lib_tgt = Some(crate_id); | 238 | lib_tgt = Some(crate_id); |
237 | pkg_to_lib_crate.insert(pkg, crate_id); | 239 | pkg_to_lib_crate.insert(pkg, crate_id); |
238 | } | 240 | } |
241 | if tgt.is_proc_macro(&cargo) { | ||
242 | if let Some(proc_macro) = libproc_macro { | ||
243 | if let Err(_) = crate_graph.add_dep( | ||
244 | crate_id, | ||
245 | "proc_macro".into(), | ||
246 | proc_macro, | ||
247 | ) { | ||
248 | log::error!( | ||
249 | "cyclic dependency on proc_macro for {}", | ||
250 | pkg.name(&cargo) | ||
251 | ) | ||
252 | } | ||
253 | } | ||
254 | } | ||
255 | |||
239 | pkg_crates.entry(pkg).or_insert_with(Vec::new).push(crate_id); | 256 | pkg_crates.entry(pkg).or_insert_with(Vec::new).push(crate_id); |
240 | } | 257 | } |
241 | } | 258 | } |