From c7ccfb072c0f8b8e7a47424c341103f48d4648e1 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 20 Jul 2020 17:44:44 +0200 Subject: [PATCH] Simplify --- crates/ra_hir_def/src/nameres.rs | 20 ++++++++++---------- 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 b279bdeef6..5a9de3d3ec 100644 --- a/crates/ra_hir_def/src/nameres.rs +++ b/crates/ra_hir_def/src/nameres.rs @@ -229,12 +229,11 @@ impl CrateDefMap { // even), as this should be a great debugging aid. pub fn dump(&self) -> String { let mut buf = String::new(); - go(&mut buf, self, "\ncrate", self.root); - return buf.trim().to_string(); + go(&mut buf, self, "crate", self.root); + return buf; fn go(buf: &mut String, map: &CrateDefMap, path: &str, module: LocalModuleId) { - *buf += path; - *buf += "\n"; + format_to!(buf, "{}\n", path); let mut entries: Vec<_> = map.modules[module].scope.resolutions().collect(); entries.sort_by_key(|(name, _)| name.clone()); @@ -243,23 +242,24 @@ impl CrateDefMap { format_to!(buf, "{}:", name); if def.types.is_some() { - *buf += " t"; + buf.push_str(" t"); } if def.values.is_some() { - *buf += " v"; + buf.push_str(" v"); } if def.macros.is_some() { - *buf += " m"; + buf.push_str(" m"); } if def.is_none() { - *buf += " _"; + buf.push_str(" _"); } - *buf += "\n"; + buf.push_str("\n"); } for (name, child) in map.modules[module].children.iter() { - let path = &format!("{}::{}", path, name); + let path = format!("{}::{}", path, name); + buf.push('\n'); go(buf, map, &path, *child); } } diff --git a/crates/ra_hir_def/src/nameres/tests.rs b/crates/ra_hir_def/src/nameres/tests.rs index 02dca80c25..205d3528be 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 { fn check(ra_fixture: &str, expect: Expect) { let db = TestDB::with_files(ra_fixture); let krate = db.crate_graph().iter().next().unwrap(); - let actual = db.crate_def_map(krate).dump() + "\n"; + let actual = db.crate_def_map(krate).dump(); expect.assert_eq(&actual); }