aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_project_model/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_project_model/src/lib.rs')
-rw-r--r--crates/ra_project_model/src/lib.rs50
1 files changed, 25 insertions, 25 deletions
diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs
index 081b1fec2..b500a74fb 100644
--- a/crates/ra_project_model/src/lib.rs
+++ b/crates/ra_project_model/src/lib.rs
@@ -138,12 +138,12 @@ impl ProjectWorkspace {
138 ProjectWorkspace::Cargo { cargo, sysroot } => { 138 ProjectWorkspace::Cargo { cargo, sysroot } => {
139 let mut roots = Vec::with_capacity(cargo.packages().len() + sysroot.crates().len()); 139 let mut roots = Vec::with_capacity(cargo.packages().len() + sysroot.crates().len());
140 for pkg in cargo.packages() { 140 for pkg in cargo.packages() {
141 let root = pkg.root(&cargo).to_path_buf(); 141 let root = cargo[pkg].root().to_path_buf();
142 let member = pkg.is_member(&cargo); 142 let member = cargo[pkg].is_member;
143 roots.push(PackageRoot::new(root, member)); 143 roots.push(PackageRoot::new(root, member));
144 } 144 }
145 for krate in sysroot.crates() { 145 for krate in sysroot.crates() {
146 roots.push(PackageRoot::new(krate.root_dir(&sysroot).to_path_buf(), false)) 146 roots.push(PackageRoot::new(sysroot[krate].root_dir().to_path_buf(), false))
147 } 147 }
148 roots 148 roots
149 } 149 }
@@ -164,7 +164,7 @@ impl ProjectWorkspace {
164 ProjectWorkspace::Cargo { cargo, sysroot: _sysroot } => { 164 ProjectWorkspace::Cargo { cargo, sysroot: _sysroot } => {
165 let mut out_dirs = Vec::with_capacity(cargo.packages().len()); 165 let mut out_dirs = Vec::with_capacity(cargo.packages().len());
166 for pkg in cargo.packages() { 166 for pkg in cargo.packages() {
167 if let Some(out_dir) = pkg.out_dir(&cargo) { 167 if let Some(out_dir) = &cargo[pkg].out_dir {
168 out_dirs.push(out_dir.to_path_buf()); 168 out_dirs.push(out_dir.to_path_buf());
169 } 169 }
170 } 170 }
@@ -260,7 +260,7 @@ impl ProjectWorkspace {
260 ProjectWorkspace::Cargo { cargo, sysroot } => { 260 ProjectWorkspace::Cargo { cargo, sysroot } => {
261 let mut sysroot_crates = FxHashMap::default(); 261 let mut sysroot_crates = FxHashMap::default();
262 for krate in sysroot.crates() { 262 for krate in sysroot.crates() {
263 if let Some(file_id) = load(krate.root(&sysroot)) { 263 if let Some(file_id) = load(&sysroot[krate].root) {
264 // Crates from sysroot have `cfg(test)` disabled 264 // Crates from sysroot have `cfg(test)` disabled
265 let cfg_options = { 265 let cfg_options = {
266 let mut opts = default_cfg_options.clone(); 266 let mut opts = default_cfg_options.clone();
@@ -274,7 +274,7 @@ impl ProjectWorkspace {
274 file_id, 274 file_id,
275 Edition::Edition2018, 275 Edition::Edition2018,
276 Some( 276 Some(
277 CrateName::new(krate.name(&sysroot)) 277 CrateName::new(&sysroot[krate].name)
278 .expect("Sysroot crate names should not contain dashes"), 278 .expect("Sysroot crate names should not contain dashes"),
279 ), 279 ),
280 cfg_options, 280 cfg_options,
@@ -285,8 +285,8 @@ impl ProjectWorkspace {
285 } 285 }
286 } 286 }
287 for from in sysroot.crates() { 287 for from in sysroot.crates() {
288 for to in from.deps(&sysroot) { 288 for &to in sysroot[from].deps.iter() {
289 let name = to.name(&sysroot); 289 let name = &sysroot[to].name;
290 if let (Some(&from), Some(&to)) = 290 if let (Some(&from), Some(&to)) =
291 (sysroot_crates.get(&from), sysroot_crates.get(&to)) 291 (sysroot_crates.get(&from), sysroot_crates.get(&to))
292 { 292 {
@@ -309,18 +309,18 @@ impl ProjectWorkspace {
309 // Next, create crates for each package, target pair 309 // Next, create crates for each package, target pair
310 for pkg in cargo.packages() { 310 for pkg in cargo.packages() {
311 let mut lib_tgt = None; 311 let mut lib_tgt = None;
312 for tgt in pkg.targets(&cargo) { 312 for &tgt in cargo[pkg].targets.iter() {
313 let root = tgt.root(&cargo); 313 let root = cargo[tgt].root.as_path();
314 if let Some(file_id) = load(root) { 314 if let Some(file_id) = load(root) {
315 let edition = pkg.edition(&cargo); 315 let edition = cargo[pkg].edition;
316 let cfg_options = { 316 let cfg_options = {
317 let mut opts = default_cfg_options.clone(); 317 let mut opts = default_cfg_options.clone();
318 opts.insert_features(pkg.features(&cargo).iter().map(Into::into)); 318 opts.insert_features(cargo[pkg].features.iter().map(Into::into));
319 opts 319 opts
320 }; 320 };
321 let mut env = Env::default(); 321 let mut env = Env::default();
322 let mut extern_source = ExternSource::default(); 322 let mut extern_source = ExternSource::default();
323 if let Some(out_dir) = pkg.out_dir(cargo) { 323 if let Some(out_dir) = &cargo[pkg].out_dir {
324 // FIXME: We probably mangle non UTF-8 paths here, figure out a better solution 324 // FIXME: We probably mangle non UTF-8 paths here, figure out a better solution
325 env.set("OUT_DIR", out_dir.to_string_lossy().to_string()); 325 env.set("OUT_DIR", out_dir.to_string_lossy().to_string());
326 if let Some(&extern_source_id) = extern_source_roots.get(out_dir) { 326 if let Some(&extern_source_id) = extern_source_roots.get(out_dir) {
@@ -330,16 +330,16 @@ impl ProjectWorkspace {
330 let crate_id = crate_graph.add_crate_root( 330 let crate_id = crate_graph.add_crate_root(
331 file_id, 331 file_id,
332 edition, 332 edition,
333 Some(CrateName::normalize_dashes(pkg.name(&cargo))), 333 Some(CrateName::normalize_dashes(&cargo[pkg].name)),
334 cfg_options, 334 cfg_options,
335 env, 335 env,
336 extern_source, 336 extern_source,
337 ); 337 );
338 if tgt.kind(&cargo) == TargetKind::Lib { 338 if cargo[tgt].kind == TargetKind::Lib {
339 lib_tgt = Some(crate_id); 339 lib_tgt = Some(crate_id);
340 pkg_to_lib_crate.insert(pkg, crate_id); 340 pkg_to_lib_crate.insert(pkg, crate_id);
341 } 341 }
342 if tgt.is_proc_macro(&cargo) { 342 if cargo[tgt].is_proc_macro {
343 if let Some(proc_macro) = libproc_macro { 343 if let Some(proc_macro) = libproc_macro {
344 if crate_graph 344 if crate_graph
345 .add_dep( 345 .add_dep(
@@ -351,7 +351,7 @@ impl ProjectWorkspace {
351 { 351 {
352 log::error!( 352 log::error!(
353 "cyclic dependency on proc_macro for {}", 353 "cyclic dependency on proc_macro for {}",
354 pkg.name(&cargo) 354 &cargo[pkg].name
355 ) 355 )
356 } 356 }
357 } 357 }
@@ -371,7 +371,7 @@ impl ProjectWorkspace {
371 // For root projects with dashes in their name, 371 // For root projects with dashes in their name,
372 // cargo metadata does not do any normalization, 372 // cargo metadata does not do any normalization,
373 // so we do it ourselves currently 373 // so we do it ourselves currently
374 CrateName::normalize_dashes(pkg.name(&cargo)), 374 CrateName::normalize_dashes(&cargo[pkg].name),
375 to, 375 to,
376 ) 376 )
377 .is_err() 377 .is_err()
@@ -379,7 +379,7 @@ impl ProjectWorkspace {
379 { 379 {
380 log::error!( 380 log::error!(
381 "cyclic dependency between targets of {}", 381 "cyclic dependency between targets of {}",
382 pkg.name(&cargo) 382 &cargo[pkg].name
383 ) 383 )
384 } 384 }
385 } 385 }
@@ -391,7 +391,7 @@ impl ProjectWorkspace {
391 .add_dep(from, CrateName::new("core").unwrap(), core) 391 .add_dep(from, CrateName::new("core").unwrap(), core)
392 .is_err() 392 .is_err()
393 { 393 {
394 log::error!("cyclic dependency on core for {}", pkg.name(&cargo)) 394 log::error!("cyclic dependency on core for {}", &cargo[pkg].name)
395 } 395 }
396 } 396 }
397 if let Some(alloc) = liballoc { 397 if let Some(alloc) = liballoc {
@@ -399,7 +399,7 @@ impl ProjectWorkspace {
399 .add_dep(from, CrateName::new("alloc").unwrap(), alloc) 399 .add_dep(from, CrateName::new("alloc").unwrap(), alloc)
400 .is_err() 400 .is_err()
401 { 401 {
402 log::error!("cyclic dependency on alloc for {}", pkg.name(&cargo)) 402 log::error!("cyclic dependency on alloc for {}", &cargo[pkg].name)
403 } 403 }
404 } 404 }
405 if let Some(std) = libstd { 405 if let Some(std) = libstd {
@@ -407,7 +407,7 @@ impl ProjectWorkspace {
407 .add_dep(from, CrateName::new("std").unwrap(), std) 407 .add_dep(from, CrateName::new("std").unwrap(), std)
408 .is_err() 408 .is_err()
409 { 409 {
410 log::error!("cyclic dependency on std for {}", pkg.name(&cargo)) 410 log::error!("cyclic dependency on std for {}", &cargo[pkg].name)
411 } 411 }
412 } 412 }
413 } 413 }
@@ -416,7 +416,7 @@ impl ProjectWorkspace {
416 // Now add a dep edge from all targets of upstream to the lib 416 // Now add a dep edge from all targets of upstream to the lib
417 // target of downstream. 417 // target of downstream.
418 for pkg in cargo.packages() { 418 for pkg in cargo.packages() {
419 for dep in pkg.dependencies(&cargo) { 419 for dep in cargo[pkg].dependencies.iter() {
420 if let Some(&to) = pkg_to_lib_crate.get(&dep.pkg) { 420 if let Some(&to) = pkg_to_lib_crate.get(&dep.pkg) {
421 for &from in pkg_crates.get(&pkg).into_iter().flatten() { 421 for &from in pkg_crates.get(&pkg).into_iter().flatten() {
422 if crate_graph 422 if crate_graph
@@ -425,8 +425,8 @@ impl ProjectWorkspace {
425 { 425 {
426 log::error!( 426 log::error!(
427 "cyclic dependency {} -> {}", 427 "cyclic dependency {} -> {}",
428 pkg.name(&cargo), 428 &cargo[pkg].name,
429 dep.pkg.name(&cargo) 429 &cargo[dep.pkg].name
430 ) 430 )
431 } 431 }
432 } 432 }