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 ++-- crates/ide/src/hover.rs | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) (limited to 'crates') 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" { diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs index 9cf02f0a3..acdb51f26 100644 --- a/crates/ide/src/hover.rs +++ b/crates/ide/src/hover.rs @@ -3163,4 +3163,34 @@ fn main() { let s<|>t = test().get(); } "#]], ); } + + #[test] + fn hover_displays_normalized_crate_names() { + check( + r#" +//- /lib.rs crate:name-with-dashes +pub mod wrapper { + pub struct Thing { x: u32 } + + impl Thing { + pub fn new() -> Thing { Thing { x: 0 } } + } +} + +//- /main.rs crate:main deps:name-with-dashes +fn main() { let foo_test = name_with_dashes::wrapper::Thing::new<|>(); } +"#, + expect![[r#" + *new* + + ```rust + name_with_dashes::wrapper::Thing + ``` + + ```rust + pub fn new() -> Thing + ``` + "#]], + ) + } } -- cgit v1.2.3