aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_project_model/src/lib.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-11-24 15:59:47 +0000
committerGitHub <[email protected]>2019-11-24 15:59:47 +0000
commitb0581c2403f49c68738c039065fa2cfc41345738 (patch)
tree2a977c54f7203f3f11784b7ee7ece20fd3b7ef9e /crates/ra_project_model/src/lib.rs
parent775bd98e5cf7918acf0dd72009ac14cf758ed0ca (diff)
parent6a8b4f873aa42f3522d3a92384019272b6ccefd2 (diff)
Merge #2381
2381: Add proc-macro crate type handling r=JasperDeSutter a=JasperDeSutter Resolves the libproc_macro crate in crates that are the proc-macro type. This doesn't seem the ideal implementation though, since the compiler still requires you to write `extern crate proc_macro;` (even in 2018 edition). Co-authored-by: JasperDeSutter <[email protected]>
Diffstat (limited to 'crates/ra_project_model/src/lib.rs')
-rw-r--r--crates/ra_project_model/src/lib.rs17
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 638ca2f8b..55ff4d6ef 100644
--- a/crates/ra_project_model/src/lib.rs
+++ b/crates/ra_project_model/src/lib.rs
@@ -211,6 +211,8 @@ impl ProjectWorkspace {
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 liballoc = sysroot.alloc().and_then(|it| sysroot_crates.get(&it).copied()); 212 let liballoc = sysroot.alloc().and_then(|it| sysroot_crates.get(&it).copied());
213 let libstd = sysroot.std().and_then(|it| sysroot_crates.get(&it).copied()); 213 let libstd = sysroot.std().and_then(|it| sysroot_crates.get(&it).copied());
214 let libproc_macro =
215 sysroot.proc_macro().and_then(|it| sysroot_crates.get(&it).copied());
214 216
215 let mut pkg_to_lib_crate = FxHashMap::default(); 217 let mut pkg_to_lib_crate = FxHashMap::default();
216 let mut pkg_crates = FxHashMap::default(); 218 let mut pkg_crates = FxHashMap::default();
@@ -237,6 +239,21 @@ impl ProjectWorkspace {
237 lib_tgt = Some(crate_id); 239 lib_tgt = Some(crate_id);
238 pkg_to_lib_crate.insert(pkg, crate_id); 240 pkg_to_lib_crate.insert(pkg, crate_id);
239 } 241 }
242 if tgt.is_proc_macro(&cargo) {
243 if let Some(proc_macro) = libproc_macro {
244 if let Err(_) = crate_graph.add_dep(
245 crate_id,
246 "proc_macro".into(),
247 proc_macro,
248 ) {
249 log::error!(
250 "cyclic dependency on proc_macro for {}",
251 pkg.name(&cargo)
252 )
253 }
254 }
255 }
256
240 pkg_crates.entry(pkg).or_insert_with(Vec::new).push(crate_id); 257 pkg_crates.entry(pkg).or_insert_with(Vec::new).push(crate_id);
241 } 258 }
242 } 259 }