From 6596e7cddfc00281362c3640781f6cd6bc0b5614 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 28 Mar 2020 11:08:19 +0100 Subject: Nice string formatting --- crates/ra_hir_def/Cargo.toml | 2 ++ crates/ra_hir_def/src/nameres.rs | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'crates/ra_hir_def') diff --git a/crates/ra_hir_def/Cargo.toml b/crates/ra_hir_def/Cargo.toml index 30a12337e..56e791e3e 100644 --- a/crates/ra_hir_def/Cargo.toml +++ b/crates/ra_hir_def/Cargo.toml @@ -15,6 +15,8 @@ either = "1.5.3" anymap = "0.12.1" drop_bomb = "0.1.4" +stdx = { path = "../stdx" } + ra_arena = { path = "../ra_arena" } ra_db = { path = "../ra_db" } ra_syntax = { path = "../ra_syntax" } diff --git a/crates/ra_hir_def/src/nameres.rs b/crates/ra_hir_def/src/nameres.rs index 40bdc34f5..f279c2ad4 100644 --- a/crates/ra_hir_def/src/nameres.rs +++ b/crates/ra_hir_def/src/nameres.rs @@ -63,6 +63,7 @@ use ra_db::{CrateId, Edition, FileId}; use ra_prof::profile; use ra_syntax::ast; use rustc_hash::FxHashMap; +use stdx::format_to; use crate::{ db::DefDatabase, @@ -246,7 +247,7 @@ impl CrateDefMap { entries.sort_by_key(|(name, _)| name.clone()); for (name, def) in entries { - *buf += &format!("{}:", name); + format_to!(buf, "{}:", name); if def.types.is_some() { *buf += " t"; @@ -265,7 +266,7 @@ impl CrateDefMap { } for (name, child) in map.modules[module].children.iter() { - let path = path.to_string() + &format!("::{}", name); + let path = &format!("{}::{}", path, name); go(buf, map, &path, *child); } } -- cgit v1.2.3