diff options
-rw-r--r-- | crates/ra_hir_def/src/nameres.rs | 20 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/tests.rs | 2 |
2 files changed, 11 insertions, 11 deletions
diff --git a/crates/ra_hir_def/src/nameres.rs b/crates/ra_hir_def/src/nameres.rs index b279bdeef..5a9de3d3e 100644 --- a/crates/ra_hir_def/src/nameres.rs +++ b/crates/ra_hir_def/src/nameres.rs | |||
@@ -229,12 +229,11 @@ impl CrateDefMap { | |||
229 | // even), as this should be a great debugging aid. | 229 | // even), as this should be a great debugging aid. |
230 | pub fn dump(&self) -> String { | 230 | pub fn dump(&self) -> String { |
231 | let mut buf = String::new(); | 231 | let mut buf = String::new(); |
232 | go(&mut buf, self, "\ncrate", self.root); | 232 | go(&mut buf, self, "crate", self.root); |
233 | return buf.trim().to_string(); | 233 | return buf; |
234 | 234 | ||
235 | fn go(buf: &mut String, map: &CrateDefMap, path: &str, module: LocalModuleId) { | 235 | fn go(buf: &mut String, map: &CrateDefMap, path: &str, module: LocalModuleId) { |
236 | *buf += path; | 236 | format_to!(buf, "{}\n", path); |
237 | *buf += "\n"; | ||
238 | 237 | ||
239 | let mut entries: Vec<_> = map.modules[module].scope.resolutions().collect(); | 238 | let mut entries: Vec<_> = map.modules[module].scope.resolutions().collect(); |
240 | entries.sort_by_key(|(name, _)| name.clone()); | 239 | entries.sort_by_key(|(name, _)| name.clone()); |
@@ -243,23 +242,24 @@ impl CrateDefMap { | |||
243 | format_to!(buf, "{}:", name); | 242 | format_to!(buf, "{}:", name); |
244 | 243 | ||
245 | if def.types.is_some() { | 244 | if def.types.is_some() { |
246 | *buf += " t"; | 245 | buf.push_str(" t"); |
247 | } | 246 | } |
248 | if def.values.is_some() { | 247 | if def.values.is_some() { |
249 | *buf += " v"; | 248 | buf.push_str(" v"); |
250 | } | 249 | } |
251 | if def.macros.is_some() { | 250 | if def.macros.is_some() { |
252 | *buf += " m"; | 251 | buf.push_str(" m"); |
253 | } | 252 | } |
254 | if def.is_none() { | 253 | if def.is_none() { |
255 | *buf += " _"; | 254 | buf.push_str(" _"); |
256 | } | 255 | } |
257 | 256 | ||
258 | *buf += "\n"; | 257 | buf.push_str("\n"); |
259 | } | 258 | } |
260 | 259 | ||
261 | for (name, child) in map.modules[module].children.iter() { | 260 | for (name, child) in map.modules[module].children.iter() { |
262 | let path = &format!("{}::{}", path, name); | 261 | let path = format!("{}::{}", path, name); |
262 | buf.push('\n'); | ||
263 | go(buf, map, &path, *child); | 263 | go(buf, map, &path, *child); |
264 | } | 264 | } |
265 | } | 265 | } |
diff --git a/crates/ra_hir_def/src/nameres/tests.rs b/crates/ra_hir_def/src/nameres/tests.rs index 02dca80c2..205d3528b 100644 --- a/crates/ra_hir_def/src/nameres/tests.rs +++ b/crates/ra_hir_def/src/nameres/tests.rs | |||
@@ -21,7 +21,7 @@ fn compute_crate_def_map(fixture: &str) -> Arc<CrateDefMap> { | |||
21 | fn check(ra_fixture: &str, expect: Expect) { | 21 | fn check(ra_fixture: &str, expect: Expect) { |
22 | let db = TestDB::with_files(ra_fixture); | 22 | let db = TestDB::with_files(ra_fixture); |
23 | let krate = db.crate_graph().iter().next().unwrap(); | 23 | let krate = db.crate_graph().iter().next().unwrap(); |
24 | let actual = db.crate_def_map(krate).dump() + "\n"; | 24 | let actual = db.crate_def_map(krate).dump(); |
25 | expect.assert_eq(&actual); | 25 | expect.assert_eq(&actual); |
26 | } | 26 | } |
27 | 27 | ||