diff options
author | Aleksey Kladov <[email protected]> | 2020-07-01 08:53:53 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-07-01 08:53:53 +0100 |
commit | 307c6fec618d5e509c754362687253ef44bb5f3f (patch) | |
tree | 09715ea291087ed1fffa4dc597c02a5541564bd0 /crates/ra_db/src | |
parent | e336a96998710c94685d42435acccff15dc8cd4f (diff) |
Use CrateName for semantic names
Diffstat (limited to 'crates/ra_db/src')
-rw-r--r-- | crates/ra_db/src/input.rs | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/crates/ra_db/src/input.rs b/crates/ra_db/src/input.rs index 7f3660118..a8cc588f9 100644 --- a/crates/ra_db/src/input.rs +++ b/crates/ra_db/src/input.rs | |||
@@ -94,6 +94,13 @@ impl fmt::Display for CrateName { | |||
94 | } | 94 | } |
95 | } | 95 | } |
96 | 96 | ||
97 | impl ops::Deref for CrateName { | ||
98 | type Target = str; | ||
99 | fn deref(&self) -> &Self::Target { | ||
100 | &*self.0 | ||
101 | } | ||
102 | } | ||
103 | |||
97 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | 104 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] |
98 | pub struct ProcMacroId(pub u32); | 105 | pub struct ProcMacroId(pub u32); |
99 | 106 | ||
@@ -138,7 +145,7 @@ pub struct Env { | |||
138 | #[derive(Debug, Clone, PartialEq, Eq)] | 145 | #[derive(Debug, Clone, PartialEq, Eq)] |
139 | pub struct Dependency { | 146 | pub struct Dependency { |
140 | pub crate_id: CrateId, | 147 | pub crate_id: CrateId, |
141 | pub name: SmolStr, | 148 | pub name: CrateName, |
142 | } | 149 | } |
143 | 150 | ||
144 | impl CrateGraph { | 151 | impl CrateGraph { |
@@ -178,7 +185,7 @@ impl CrateGraph { | |||
178 | if self.dfs_find(from, to, &mut FxHashSet::default()) { | 185 | if self.dfs_find(from, to, &mut FxHashSet::default()) { |
179 | return Err(CyclicDependenciesError); | 186 | return Err(CyclicDependenciesError); |
180 | } | 187 | } |
181 | self.arena.get_mut(&from).unwrap().add_dep(name.0, to); | 188 | self.arena.get_mut(&from).unwrap().add_dep(name, to); |
182 | Ok(()) | 189 | Ok(()) |
183 | } | 190 | } |
184 | 191 | ||
@@ -247,7 +254,7 @@ impl CrateId { | |||
247 | } | 254 | } |
248 | 255 | ||
249 | impl CrateData { | 256 | impl CrateData { |
250 | fn add_dep(&mut self, name: SmolStr, crate_id: CrateId) { | 257 | fn add_dep(&mut self, name: CrateName, crate_id: CrateId) { |
251 | self.dependencies.push(Dependency { name, crate_id }) | 258 | self.dependencies.push(Dependency { name, crate_id }) |
252 | } | 259 | } |
253 | } | 260 | } |
@@ -429,7 +436,10 @@ mod tests { | |||
429 | .is_ok()); | 436 | .is_ok()); |
430 | assert_eq!( | 437 | assert_eq!( |
431 | graph[crate1].dependencies, | 438 | graph[crate1].dependencies, |
432 | vec![Dependency { crate_id: crate2, name: "crate_name_with_dashes".into() }] | 439 | vec![Dependency { |
440 | crate_id: crate2, | ||
441 | name: CrateName::new("crate_name_with_dashes").unwrap() | ||
442 | }] | ||
433 | ); | 443 | ); |
434 | } | 444 | } |
435 | } | 445 | } |