aboutsummaryrefslogtreecommitdiff
path: root/crates/project_model
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2021-05-11 22:34:56 +0100
committerJonas Schievink <[email protected]>2021-05-11 22:34:56 +0100
commit32560839d9d4dba8d08e0da19af557178cf5c0b3 (patch)
tree58664a16bb6ae8300004ab71777942d11667f3c2 /crates/project_model
parentda80dfc0226af546244dacf3fbfdbb2b7136539a (diff)
Use Cargo target name as crate name
Diffstat (limited to 'crates/project_model')
-rw-r--r--crates/project_model/src/workspace.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/crates/project_model/src/workspace.rs b/crates/project_model/src/workspace.rs
index 84c702fdf..761fbb3ab 100644
--- a/crates/project_model/src/workspace.rs
+++ b/crates/project_model/src/workspace.rs
@@ -390,6 +390,7 @@ fn cargo_to_crate_graph(
390 &cfg_options, 390 &cfg_options,
391 proc_macro_loader, 391 proc_macro_loader,
392 file_id, 392 file_id,
393 &cargo[tgt].name,
393 ); 394 );
394 if cargo[tgt].kind == TargetKind::Lib { 395 if cargo[tgt].kind == TargetKind::Lib {
395 lib_tgt = Some((crate_id, cargo[tgt].name.clone())); 396 lib_tgt = Some((crate_id, cargo[tgt].name.clone()));
@@ -505,6 +506,7 @@ fn handle_rustc_crates(
505 &cfg_options, 506 &cfg_options,
506 proc_macro_loader, 507 proc_macro_loader,
507 file_id, 508 file_id,
509 &rustc_workspace[tgt].name,
508 ); 510 );
509 pkg_to_lib_crate.insert(pkg, crate_id); 511 pkg_to_lib_crate.insert(pkg, crate_id);
510 // Add dependencies on core / std / alloc for this crate 512 // Add dependencies on core / std / alloc for this crate
@@ -560,6 +562,7 @@ fn add_target_crate_root(
560 cfg_options: &CfgOptions, 562 cfg_options: &CfgOptions,
561 proc_macro_loader: &dyn Fn(&Path) -> Vec<ProcMacro>, 563 proc_macro_loader: &dyn Fn(&Path) -> Vec<ProcMacro>,
562 file_id: FileId, 564 file_id: FileId,
565 cargo_name: &str,
563) -> CrateId { 566) -> CrateId {
564 let edition = pkg.edition; 567 let edition = pkg.edition;
565 let cfg_options = { 568 let cfg_options = {
@@ -586,7 +589,7 @@ fn add_target_crate_root(
586 .map(|it| proc_macro_loader(&it)) 589 .map(|it| proc_macro_loader(&it))
587 .unwrap_or_default(); 590 .unwrap_or_default();
588 591
589 let display_name = CrateDisplayName::from_canonical_name(pkg.name.clone()); 592 let display_name = CrateDisplayName::from_canonical_name(cargo_name.to_string());
590 let crate_id = crate_graph.add_crate_root( 593 let crate_id = crate_graph.add_crate_root(
591 file_id, 594 file_id,
592 edition, 595 edition,