aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_db/src/input.rs7
-rw-r--r--crates/ra_hir_def/src/nameres.rs2
-rw-r--r--crates/ra_ide/src/hover.rs27
3 files changed, 17 insertions, 19 deletions
diff --git a/crates/ra_db/src/input.rs b/crates/ra_db/src/input.rs
index a6a831afa..bde843001 100644
--- a/crates/ra_db/src/input.rs
+++ b/crates/ra_db/src/input.rs
@@ -14,6 +14,7 @@ use rustc_hash::FxHashMap;
14use rustc_hash::FxHashSet; 14use rustc_hash::FxHashSet;
15 15
16use crate::{RelativePath, RelativePathBuf}; 16use crate::{RelativePath, RelativePathBuf};
17use fmt::Display;
17 18
18/// `FileId` is an integer which uniquely identifies a file. File paths are 19/// `FileId` is an integer which uniquely identifies a file. File paths are
19/// messy and system-dependent, so most of the code should work directly with 20/// messy and system-dependent, so most of the code should work directly with
@@ -102,9 +103,11 @@ impl CrateName {
102 pub fn normalize_dashes(name: &str) -> CrateName { 103 pub fn normalize_dashes(name: &str) -> CrateName {
103 Self(SmolStr::new(name.replace('-', "_"))) 104 Self(SmolStr::new(name.replace('-', "_")))
104 } 105 }
106}
105 107
106 pub fn get_name(&self) -> String { 108impl Display for CrateName {
107 self.0.to_string() 109 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
110 write!(f, "{}", self.0)
108 } 111 }
109} 112}
110 113
diff --git a/crates/ra_hir_def/src/nameres.rs b/crates/ra_hir_def/src/nameres.rs
index 87992854a..03515309e 100644
--- a/crates/ra_hir_def/src/nameres.rs
+++ b/crates/ra_hir_def/src/nameres.rs
@@ -181,7 +181,7 @@ impl CrateDefMap {
181 db.crate_graph()[krate] 181 db.crate_graph()[krate]
182 .display_name 182 .display_name
183 .as_ref() 183 .as_ref()
184 .map(|name| name.get_name()) 184 .map(ToString::to_string)
185 .unwrap_or_default() 185 .unwrap_or_default()
186 }); 186 });
187 let def_map = { 187 let def_map = {
diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs
index d1deca96b..5b3760c18 100644
--- a/crates/ra_ide/src/hover.rs
+++ b/crates/ra_ide/src/hover.rs
@@ -94,22 +94,17 @@ fn definition_owner_name(db: &RootDatabase, def: &Definition) -> Option<String>
94 94
95fn determine_mod_path(db: &RootDatabase, def: &Definition) -> Option<String> { 95fn determine_mod_path(db: &RootDatabase, def: &Definition) -> Option<String> {
96 let mod_path = def.module(db).map(|module| { 96 let mod_path = def.module(db).map(|module| {
97 once( 97 once(db.crate_graph()[module.krate().into()].display_name.as_ref().map(ToString::to_string))
98 db.crate_graph()[module.krate().into()] 98 .chain(
99 .display_name 99 module
100 .as_ref() 100 .path_to_root(db)
101 .map(|name| name.get_name()), 101 .into_iter()
102 ) 102 .rev()
103 .chain( 103 .map(|it| it.name(db).map(|name| name.to_string())),
104 module 104 )
105 .path_to_root(db) 105 .chain(once(definition_owner_name(db, def)))
106 .into_iter() 106 .flatten()
107 .rev() 107 .join("::")
108 .map(|it| it.name(db).map(|name| name.to_string())),
109 )
110 .chain(once(definition_owner_name(db, def)))
111 .flatten()
112 .join("::")
113 }); 108 });
114 mod_path // FIXME: replace dashes with underscores in crate display name 109 mod_path // FIXME: replace dashes with underscores in crate display name
115} 110}