Skip to content

Commit 62735cf

Browse files
bors[bot]matklad
andauthored
Merge #5456
5456: Simplify r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
2 parents c9c518e + c7ccfb0 commit 62735cf

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

crates/ra_hir_def/src/nameres.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,11 @@ impl CrateDefMap {
229229
// even), as this should be a great debugging aid.
230230
pub fn dump(&self) -> String {
231231
let mut buf = String::new();
232-
go(&mut buf, self, "\ncrate", self.root);
233-
return buf.trim().to_string();
232+
go(&mut buf, self, "crate", self.root);
233+
return buf;
234234

235235
fn go(buf: &mut String, map: &CrateDefMap, path: &str, module: LocalModuleId) {
236-
*buf += path;
237-
*buf += "\n";
236+
format_to!(buf, "{}\n", path);
238237

239238
let mut entries: Vec<_> = map.modules[module].scope.resolutions().collect();
240239
entries.sort_by_key(|(name, _)| name.clone());
@@ -243,23 +242,24 @@ impl CrateDefMap {
243242
format_to!(buf, "{}:", name);
244243

245244
if def.types.is_some() {
246-
*buf += " t";
245+
buf.push_str(" t");
247246
}
248247
if def.values.is_some() {
249-
*buf += " v";
248+
buf.push_str(" v");
250249
}
251250
if def.macros.is_some() {
252-
*buf += " m";
251+
buf.push_str(" m");
253252
}
254253
if def.is_none() {
255-
*buf += " _";
254+
buf.push_str(" _");
256255
}
257256

258-
*buf += "\n";
257+
buf.push_str("\n");
259258
}
260259

261260
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');
263263
go(buf, map, &path, *child);
264264
}
265265
}

crates/ra_hir_def/src/nameres/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn compute_crate_def_map(fixture: &str) -> Arc<CrateDefMap> {
2121
fn check(ra_fixture: &str, expect: Expect) {
2222
let db = TestDB::with_files(ra_fixture);
2323
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();
2525
expect.assert_eq(&actual);
2626
}
2727

0 commit comments

Comments
 (0)