aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-11-24 13:26:54 +0000
committerGitHub <[email protected]>2019-11-24 13:26:54 +0000
commit5cc634fa6018b60c7bac5ada2038ca341a91f410 (patch)
tree23eab70222d83610b5a9c90b6767524255d644fc /crates
parent450b820b7069f6ed5306ef6896263e2620314b73 (diff)
parente3f8e7d13d01fcdd1bb0f31887d1f72fc44c4d4e (diff)
Merge #2383
2383: Add alloc to the crate graph r=matklad a=marcogroppo `alloc` has been added to the crate graph. Completions work, but they are available even when the user has **not** declared an `extern crate alloc`. Is this the correct approach? Fixes #2376. Co-authored-by: Marco Groppo <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_project_model/src/lib.rs6
-rw-r--r--crates/ra_project_model/src/sysroot.rs4
2 files changed, 10 insertions, 0 deletions
diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs
index d04a8cbe2..638ca2f8b 100644
--- a/crates/ra_project_model/src/lib.rs
+++ b/crates/ra_project_model/src/lib.rs
@@ -209,6 +209,7 @@ impl ProjectWorkspace {
209 } 209 }
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 liballoc = sysroot.alloc().and_then(|it| sysroot_crates.get(&it).copied());
212 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());
213 214
214 let mut pkg_to_lib_crate = FxHashMap::default(); 215 let mut pkg_to_lib_crate = FxHashMap::default();
@@ -261,6 +262,11 @@ impl ProjectWorkspace {
261 log::error!("cyclic dependency on core for {}", pkg.name(&cargo)) 262 log::error!("cyclic dependency on core for {}", pkg.name(&cargo))
262 } 263 }
263 } 264 }
265 if let Some(alloc) = liballoc {
266 if let Err(_) = crate_graph.add_dep(from, "alloc".into(), alloc) {
267 log::error!("cyclic dependency on alloc for {}", pkg.name(&cargo))
268 }
269 }
264 if let Some(std) = libstd { 270 if let Some(std) = libstd {
265 if let Err(_) = crate_graph.add_dep(from, "std".into(), std) { 271 if let Err(_) = crate_graph.add_dep(from, "std".into(), std) {
266 log::error!("cyclic dependency on std for {}", pkg.name(&cargo)) 272 log::error!("cyclic dependency on std for {}", pkg.name(&cargo))
diff --git a/crates/ra_project_model/src/sysroot.rs b/crates/ra_project_model/src/sysroot.rs
index 3d827809e..bec9439d7 100644
--- a/crates/ra_project_model/src/sysroot.rs
+++ b/crates/ra_project_model/src/sysroot.rs
@@ -31,6 +31,10 @@ impl Sysroot {
31 self.by_name("core") 31 self.by_name("core")
32 } 32 }
33 33
34 pub fn alloc(&self) -> Option<SysrootCrate> {
35 self.by_name("alloc")
36 }
37
34 pub fn std(&self) -> Option<SysrootCrate> { 38 pub fn std(&self) -> Option<SysrootCrate> {
35 self.by_name("std") 39 self.by_name("std")
36 } 40 }