diff options
author | Kirill Bulatov <[email protected]> | 2020-03-16 09:47:52 +0000 |
---|---|---|
committer | Kirill Bulatov <[email protected]> | 2020-03-16 09:47:52 +0000 |
commit | 059ed25a3eea97f370c190803318d5cb7885e1a9 (patch) | |
tree | 7c4b36fc3623683380caf5bd6487e3f8aa57774a /crates/ra_db/src/input.rs | |
parent | 6bc226fa1918b8025b19cdf9d1f972f029e6a899 (diff) |
Fix crate display name dashes
Diffstat (limited to 'crates/ra_db/src/input.rs')
-rw-r--r-- | crates/ra_db/src/input.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/crates/ra_db/src/input.rs b/crates/ra_db/src/input.rs index 06d40db96..a6a831afa 100644 --- a/crates/ra_db/src/input.rs +++ b/crates/ra_db/src/input.rs | |||
@@ -83,6 +83,7 @@ pub struct CrateGraph { | |||
83 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] | 83 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] |
84 | pub struct CrateId(pub u32); | 84 | pub struct CrateId(pub u32); |
85 | 85 | ||
86 | #[derive(Debug, Clone, PartialEq, Eq)] | ||
86 | pub struct CrateName(SmolStr); | 87 | pub struct CrateName(SmolStr); |
87 | 88 | ||
88 | impl CrateName { | 89 | impl CrateName { |
@@ -101,6 +102,10 @@ impl CrateName { | |||
101 | pub fn normalize_dashes(name: &str) -> CrateName { | 102 | pub fn normalize_dashes(name: &str) -> CrateName { |
102 | Self(SmolStr::new(name.replace('-', "_"))) | 103 | Self(SmolStr::new(name.replace('-', "_"))) |
103 | } | 104 | } |
105 | |||
106 | pub fn get_name(&self) -> String { | ||
107 | self.0.to_string() | ||
108 | } | ||
104 | } | 109 | } |
105 | 110 | ||
106 | #[derive(Debug, Clone, PartialEq, Eq)] | 111 | #[derive(Debug, Clone, PartialEq, Eq)] |
@@ -110,7 +115,7 @@ pub struct CrateData { | |||
110 | /// The name to display to the end user. | 115 | /// The name to display to the end user. |
111 | /// This actual crate name can be different in a particular dependent crate | 116 | /// This actual crate name can be different in a particular dependent crate |
112 | /// or may even be missing for some cases, such as a dummy crate for the code snippet. | 117 | /// or may even be missing for some cases, such as a dummy crate for the code snippet. |
113 | pub display_name: Option<String>, | 118 | pub display_name: Option<CrateName>, |
114 | pub cfg_options: CfgOptions, | 119 | pub cfg_options: CfgOptions, |
115 | pub env: Env, | 120 | pub env: Env, |
116 | pub extern_source: ExternSource, | 121 | pub extern_source: ExternSource, |
@@ -150,7 +155,7 @@ impl CrateGraph { | |||
150 | &mut self, | 155 | &mut self, |
151 | file_id: FileId, | 156 | file_id: FileId, |
152 | edition: Edition, | 157 | edition: Edition, |
153 | display_name: Option<String>, | 158 | display_name: Option<CrateName>, |
154 | cfg_options: CfgOptions, | 159 | cfg_options: CfgOptions, |
155 | env: Env, | 160 | env: Env, |
156 | extern_source: ExternSource, | 161 | extern_source: ExternSource, |