From cae2e859ffbf2b435c8675838e450b66d4c6153e Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Fri, 2 Oct 2020 20:59:32 +0300 Subject: Add a dash test --- crates/base_db/src/fixture.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/base_db') diff --git a/crates/base_db/src/fixture.rs b/crates/base_db/src/fixture.rs index b7286fc7d..31560bc09 100644 --- a/crates/base_db/src/fixture.rs +++ b/crates/base_db/src/fixture.rs @@ -162,11 +162,11 @@ impl ChangeFixture { meta.env, Default::default(), ); - let crate_name = CrateName::new(&krate).unwrap(); + let crate_name = CrateName::normalize_dashes(&krate); let prev = crates.insert(crate_name.clone(), crate_id); assert!(prev.is_none()); for dep in meta.deps { - let dep = CrateName::new(&dep).unwrap(); + let dep = CrateName::normalize_dashes(&dep); crate_deps.push((crate_name.clone(), dep)) } } else if meta.path == "/main.rs" || meta.path == "/lib.rs" { -- cgit v1.2.3 From 99952f3be254394a5c70ce8fb8436d76c779ed71 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Fri, 2 Oct 2020 21:16:22 +0300 Subject: Fix the hover dash issues --- crates/base_db/src/fixture.rs | 6 +++--- crates/base_db/src/input.rs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'crates/base_db') diff --git a/crates/base_db/src/fixture.rs b/crates/base_db/src/fixture.rs index 31560bc09..72f1fd667 100644 --- a/crates/base_db/src/fixture.rs +++ b/crates/base_db/src/fixture.rs @@ -154,15 +154,15 @@ impl ChangeFixture { assert!(meta.path.starts_with(&source_root_prefix)); if let Some(krate) = meta.krate { + let crate_name = CrateName::normalize_dashes(&krate); let crate_id = crate_graph.add_crate_root( file_id, meta.edition, - Some(krate.clone()), + Some(crate_name.clone()), meta.cfg, meta.env, Default::default(), ); - let crate_name = CrateName::normalize_dashes(&krate); let prev = crates.insert(crate_name.clone(), crate_id); assert!(prev.is_none()); for dep in meta.deps { @@ -187,7 +187,7 @@ impl ChangeFixture { crate_graph.add_crate_root( crate_root, Edition::Edition2018, - Some("test".to_string()), + Some(CrateName::new("test").unwrap()), default_cfg, Env::default(), Default::default(), diff --git a/crates/base_db/src/input.rs b/crates/base_db/src/input.rs index 9a61f1d56..251a7b245 100644 --- a/crates/base_db/src/input.rs +++ b/crates/base_db/src/input.rs @@ -130,7 +130,7 @@ pub struct CrateData { /// The name to display to the end user. /// This actual crate name can be different in a particular dependent crate /// or may even be missing for some cases, such as a dummy crate for the code snippet. - pub display_name: Option, + pub display_name: Option, pub cfg_options: CfgOptions, pub env: Env, pub dependencies: Vec, @@ -159,7 +159,7 @@ impl CrateGraph { &mut self, file_id: FileId, edition: Edition, - display_name: Option, + display_name: Option, cfg_options: CfgOptions, env: Env, proc_macro: Vec<(SmolStr, Arc)>, -- cgit v1.2.3 From 9d19e5b962f77259dd1334b9edb4da4de54f0987 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Fri, 2 Oct 2020 21:38:22 +0300 Subject: Properly name the field --- crates/base_db/src/input.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'crates/base_db') diff --git a/crates/base_db/src/input.rs b/crates/base_db/src/input.rs index 251a7b245..c330314d4 100644 --- a/crates/base_db/src/input.rs +++ b/crates/base_db/src/input.rs @@ -127,10 +127,11 @@ impl PartialEq for ProcMacro { pub struct CrateData { pub root_file_id: FileId, pub edition: Edition, - /// The name to display to the end user. - /// This actual crate name can be different in a particular dependent crate - /// or may even be missing for some cases, such as a dummy crate for the code snippet. - pub display_name: Option, + /// A name used in the package's project declaration: for Cargo projects, it's [package].name, + /// can be different for other project types or even absent (a dummy crate for the code snippet, for example). + /// NOTE: The crate can be referenced as a dependency under a different name, + /// this one should be used when working with crate hierarchies. + pub declaration_name: Option, pub cfg_options: CfgOptions, pub env: Env, pub dependencies: Vec, @@ -159,7 +160,7 @@ impl CrateGraph { &mut self, file_id: FileId, edition: Edition, - display_name: Option, + declaration_name: Option, cfg_options: CfgOptions, env: Env, proc_macro: Vec<(SmolStr, Arc)>, @@ -170,7 +171,7 @@ impl CrateGraph { let data = CrateData { root_file_id: file_id, edition, - display_name, + declaration_name, cfg_options, env, proc_macro, -- cgit v1.2.3