aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_project_model/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_project_model/src')
-rw-r--r--crates/ra_project_model/src/lib.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs
index bcf12460d..37845ca56 100644
--- a/crates/ra_project_model/src/lib.rs
+++ b/crates/ra_project_model/src/lib.rs
@@ -14,7 +14,7 @@ use std::{
14 14
15use anyhow::{bail, Context, Result}; 15use anyhow::{bail, Context, Result};
16use ra_cfg::CfgOptions; 16use ra_cfg::CfgOptions;
17use ra_db::{CrateGraph, CrateId, CrateName, Edition, Env, FileId}; 17use ra_db::{CrateGraph, CrateName, Edition, Env, FileId};
18use rustc_hash::FxHashMap; 18use rustc_hash::FxHashMap;
19use serde_json::from_reader; 19use serde_json::from_reader;
20 20
@@ -163,9 +163,8 @@ impl ProjectWorkspace {
163 &self, 163 &self,
164 default_cfg_options: &CfgOptions, 164 default_cfg_options: &CfgOptions,
165 load: &mut dyn FnMut(&Path) -> Option<FileId>, 165 load: &mut dyn FnMut(&Path) -> Option<FileId>,
166 ) -> (CrateGraph, FxHashMap<CrateId, String>) { 166 ) -> CrateGraph {
167 let mut crate_graph = CrateGraph::default(); 167 let mut crate_graph = CrateGraph::default();
168 let mut names = FxHashMap::default();
169 match self { 168 match self {
170 ProjectWorkspace::Json { project } => { 169 ProjectWorkspace::Json { project } => {
171 let mut crates = FxHashMap::default(); 170 let mut crates = FxHashMap::default();
@@ -191,6 +190,8 @@ impl ProjectWorkspace {
191 crate_graph.add_crate_root( 190 crate_graph.add_crate_root(
192 file_id, 191 file_id,
193 edition, 192 edition,
193 // FIXME json definitions can store the crate name
194 None,
194 cfg_options, 195 cfg_options,
195 Env::default(), 196 Env::default(),
196 ), 197 ),
@@ -233,11 +234,11 @@ impl ProjectWorkspace {
233 let crate_id = crate_graph.add_crate_root( 234 let crate_id = crate_graph.add_crate_root(
234 file_id, 235 file_id,
235 Edition::Edition2018, 236 Edition::Edition2018,
237 Some(krate.name(&sysroot).to_string()),
236 cfg_options, 238 cfg_options,
237 Env::default(), 239 Env::default(),
238 ); 240 );
239 sysroot_crates.insert(krate, crate_id); 241 sysroot_crates.insert(krate, crate_id);
240 names.insert(crate_id, krate.name(&sysroot).to_string());
241 } 242 }
242 } 243 }
243 for from in sysroot.crates() { 244 for from in sysroot.crates() {
@@ -277,10 +278,10 @@ impl ProjectWorkspace {
277 let crate_id = crate_graph.add_crate_root( 278 let crate_id = crate_graph.add_crate_root(
278 file_id, 279 file_id,
279 edition, 280 edition,
281 Some(pkg.name(&cargo).to_string()),
280 cfg_options, 282 cfg_options,
281 Env::default(), 283 Env::default(),
282 ); 284 );
283 names.insert(crate_id, pkg.name(&cargo).to_string());
284 if tgt.kind(&cargo) == TargetKind::Lib { 285 if tgt.kind(&cargo) == TargetKind::Lib {
285 lib_tgt = Some(crate_id); 286 lib_tgt = Some(crate_id);
286 pkg_to_lib_crate.insert(pkg, crate_id); 287 pkg_to_lib_crate.insert(pkg, crate_id);
@@ -381,7 +382,7 @@ impl ProjectWorkspace {
381 } 382 }
382 } 383 }
383 } 384 }
384 (crate_graph, names) 385 crate_graph
385 } 386 }
386 387
387 pub fn workspace_root_for(&self, path: &Path) -> Option<&Path> { 388 pub fn workspace_root_for(&self, path: &Path) -> Option<&Path> {