aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_hir_def/Cargo.toml2
-rw-r--r--crates/ra_hir_def/src/nameres.rs5
-rw-r--r--crates/ra_hir_ty/Cargo.toml2
-rw-r--r--crates/ra_hir_ty/src/test_db.rs3
-rw-r--r--crates/ra_syntax/Cargo.toml2
-rw-r--r--crates/ra_syntax/src/ast/make.rs15
-rw-r--r--crates/ra_syntax/src/lib.rs7
-rw-r--r--crates/rust-analyzer/Cargo.toml2
-rw-r--r--crates/rust-analyzer/src/world.rs15
-rw-r--r--crates/stdx/src/lib.rs2
10 files changed, 34 insertions, 21 deletions
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"
15anymap = "0.12.1" 15anymap = "0.12.1"
16drop_bomb = "0.1.4" 16drop_bomb = "0.1.4"
17 17
18stdx = { path = "../stdx" }
19
18ra_arena = { path = "../ra_arena" } 20ra_arena = { path = "../ra_arena" }
19ra_db = { path = "../ra_db" } 21ra_db = { path = "../ra_db" }
20ra_syntax = { path = "../ra_syntax" } 22ra_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};
63use ra_prof::profile; 63use ra_prof::profile;
64use ra_syntax::ast; 64use ra_syntax::ast;
65use rustc_hash::FxHashMap; 65use rustc_hash::FxHashMap;
66use stdx::format_to;
66 67
67use crate::{ 68use crate::{
68 db::DefDatabase, 69 db::DefDatabase,
@@ -246,7 +247,7 @@ impl CrateDefMap {
246 entries.sort_by_key(|(name, _)| name.clone()); 247 entries.sort_by_key(|(name, _)| name.clone());
247 248
248 for (name, def) in entries { 249 for (name, def) in entries {
249 *buf += &format!("{}:", name); 250 format_to!(buf, "{}:", name);
250 251
251 if def.types.is_some() { 252 if def.types.is_some() {
252 *buf += " t"; 253 *buf += " t";
@@ -265,7 +266,7 @@ impl CrateDefMap {
265 } 266 }
266 267
267 for (name, child) in map.modules[module].children.iter() { 268 for (name, child) in map.modules[module].children.iter() {
268 let path = path.to_string() + &format!("::{}", name); 269 let path = &format!("{}::{}", path, name);
269 go(buf, map, &path, *child); 270 go(buf, map, &path, *child);
270 } 271 }
271 } 272 }
diff --git a/crates/ra_hir_ty/Cargo.toml b/crates/ra_hir_ty/Cargo.toml
index 9962112db..5a58d70cf 100644
--- a/crates/ra_hir_ty/Cargo.toml
+++ b/crates/ra_hir_ty/Cargo.toml
@@ -13,6 +13,8 @@ ena = "0.13.1"
13log = "0.4.8" 13log = "0.4.8"
14rustc-hash = "1.1.0" 14rustc-hash = "1.1.0"
15 15
16stdx = { path = "../stdx" }
17
16hir_def = { path = "../ra_hir_def", package = "ra_hir_def" } 18hir_def = { path = "../ra_hir_def", package = "ra_hir_def" }
17hir_expand = { path = "../ra_hir_expand", package = "ra_hir_expand" } 19hir_expand = { path = "../ra_hir_expand", package = "ra_hir_expand" }
18ra_arena = { path = "../ra_arena" } 20ra_arena = { path = "../ra_arena" }
diff --git a/crates/ra_hir_ty/src/test_db.rs b/crates/ra_hir_ty/src/test_db.rs
index 5bbeabf51..208096aab 100644
--- a/crates/ra_hir_ty/src/test_db.rs
+++ b/crates/ra_hir_ty/src/test_db.rs
@@ -10,6 +10,7 @@ use hir_expand::{db::AstDatabase, diagnostics::DiagnosticSink};
10use ra_db::{ 10use ra_db::{
11 salsa, CrateId, FileId, FileLoader, FileLoaderDelegate, RelativePath, SourceDatabase, Upcast, 11 salsa, CrateId, FileId, FileLoader, FileLoaderDelegate, RelativePath, SourceDatabase, Upcast,
12}; 12};
13use stdx::format_to;
13 14
14use crate::{db::HirDatabase, expr::ExprValidator}; 15use crate::{db::HirDatabase, expr::ExprValidator};
15 16
@@ -131,7 +132,7 @@ impl TestDB {
131 for f in fns { 132 for f in fns {
132 let infer = self.infer(f.into()); 133 let infer = self.infer(f.into());
133 let mut sink = DiagnosticSink::new(|d| { 134 let mut sink = DiagnosticSink::new(|d| {
134 buf += &format!("{:?}: {}\n", d.syntax_node(self).text(), d.message()); 135 format_to!(buf, "{:?}: {}\n", d.syntax_node(self).text(), d.message());
135 }); 136 });
136 infer.add_diagnostics(self, f, &mut sink); 137 infer.add_diagnostics(self, f, &mut sink);
137 let mut validator = ExprValidator::new(f, infer, &mut sink); 138 let mut validator = ExprValidator::new(f, infer, &mut sink);
diff --git a/crates/ra_syntax/Cargo.toml b/crates/ra_syntax/Cargo.toml
index 6fccc2303..3c6ae77e4 100644
--- a/crates/ra_syntax/Cargo.toml
+++ b/crates/ra_syntax/Cargo.toml
@@ -18,6 +18,8 @@ rustc-hash = "1.1.0"
18arrayvec = "0.5.1" 18arrayvec = "0.5.1"
19once_cell = "1.3.1" 19once_cell = "1.3.1"
20 20
21stdx = { path = "../stdx" }
22
21ra_text_edit = { path = "../ra_text_edit" } 23ra_text_edit = { path = "../ra_text_edit" }
22ra_parser = { path = "../ra_parser" } 24ra_parser = { path = "../ra_parser" }
23 25
diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs
index dbf8e6370..0c908573d 100644
--- a/crates/ra_syntax/src/ast/make.rs
+++ b/crates/ra_syntax/src/ast/make.rs
@@ -1,6 +1,7 @@
1//! This module contains free-standing functions for creating AST fragments out 1//! This module contains free-standing functions for creating AST fragments out
2//! of smaller pieces. 2//! of smaller pieces.
3use itertools::Itertools; 3use itertools::Itertools;
4use stdx::format_to;
4 5
5use crate::{ast, AstNode, SourceFile, SyntaxKind, SyntaxNode, SyntaxToken}; 6use crate::{ast, AstNode, SourceFile, SyntaxKind, SyntaxNode, SyntaxToken};
6 7
@@ -34,14 +35,14 @@ pub fn use_tree(
34 let mut buf = "use ".to_string(); 35 let mut buf = "use ".to_string();
35 buf += &path.syntax().to_string(); 36 buf += &path.syntax().to_string();
36 if let Some(use_tree_list) = use_tree_list { 37 if let Some(use_tree_list) = use_tree_list {
37 buf += &format!("::{}", use_tree_list); 38 format_to!(buf, "::{}", use_tree_list);
38 } 39 }
39 if add_star { 40 if add_star {
40 buf += "::*"; 41 buf += "::*";
41 } 42 }
42 43
43 if let Some(alias) = alias { 44 if let Some(alias) = alias {
44 buf += &format!(" {}", alias); 45 format_to!(buf, " {}", alias);
45 } 46 }
46 ast_from_text(&buf) 47 ast_from_text(&buf)
47} 48}
@@ -70,15 +71,15 @@ pub fn block_expr(
70 stmts: impl IntoIterator<Item = ast::Stmt>, 71 stmts: impl IntoIterator<Item = ast::Stmt>,
71 tail_expr: Option<ast::Expr>, 72 tail_expr: Option<ast::Expr>,
72) -> ast::BlockExpr { 73) -> ast::BlockExpr {
73 let mut text = "{\n".to_string(); 74 let mut buf = "{\n".to_string();
74 for stmt in stmts.into_iter() { 75 for stmt in stmts.into_iter() {
75 text += &format!(" {}\n", stmt); 76 format_to!(buf, " {}\n", stmt);
76 } 77 }
77 if let Some(tail_expr) = tail_expr { 78 if let Some(tail_expr) = tail_expr {
78 text += &format!(" {}\n", tail_expr) 79 format_to!(buf, " {}\n", tail_expr)
79 } 80 }
80 text += "}"; 81 buf += "}";
81 ast_from_text(&format!("fn f() {}", text)) 82 ast_from_text(&format!("fn f() {}", buf))
82} 83}
83 84
84pub fn block_from_expr(e: ast::Expr) -> ast::Block { 85pub fn block_from_expr(e: ast::Expr) -> ast::Block {
diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs
index cef926ed3..f0e16dc2b 100644
--- a/crates/ra_syntax/src/lib.rs
+++ b/crates/ra_syntax/src/lib.rs
@@ -32,9 +32,10 @@ pub mod ast;
32#[doc(hidden)] 32#[doc(hidden)]
33pub mod fuzz; 33pub mod fuzz;
34 34
35use std::{fmt::Write, marker::PhantomData, sync::Arc}; 35use std::{marker::PhantomData, sync::Arc};
36 36
37use ra_text_edit::AtomTextEdit; 37use ra_text_edit::AtomTextEdit;
38use stdx::format_to;
38 39
39use crate::syntax_node::GreenNode; 40use crate::syntax_node::GreenNode;
40 41
@@ -115,7 +116,7 @@ impl Parse<SourceFile> {
115 pub fn debug_dump(&self) -> String { 116 pub fn debug_dump(&self) -> String {
116 let mut buf = format!("{:#?}", self.tree().syntax()); 117 let mut buf = format!("{:#?}", self.tree().syntax());
117 for err in self.errors.iter() { 118 for err in self.errors.iter() {
118 writeln!(buf, "error {:?}: {}", err.range(), err).unwrap(); 119 format_to!(buf, "error {:?}: {}\n", err.range(), err);
119 } 120 }
120 buf 121 buf
121 } 122 }
@@ -296,7 +297,7 @@ fn api_walkthrough() {
296 NodeOrToken::Node(it) => it.text().to_string(), 297 NodeOrToken::Node(it) => it.text().to_string(),
297 NodeOrToken::Token(it) => it.text().to_string(), 298 NodeOrToken::Token(it) => it.text().to_string(),
298 }; 299 };
299 buf += &format!("{:indent$}{:?} {:?}\n", " ", text, node.kind(), indent = indent); 300 format_to!(buf, "{:indent$}{:?} {:?}\n", " ", text, node.kind(), indent = indent);
300 indent += 2; 301 indent += 2;
301 } 302 }
302 WalkEvent::Leave(_) => indent -= 2, 303 WalkEvent::Leave(_) => indent -= 2,
diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml
index e071e9b8d..8fe6799d2 100644
--- a/crates/rust-analyzer/Cargo.toml
+++ b/crates/rust-analyzer/Cargo.toml
@@ -30,6 +30,8 @@ serde = { version = "1.0.104", features = ["derive"] }
30serde_json = "1.0.48" 30serde_json = "1.0.48"
31threadpool = "1.7.1" 31threadpool = "1.7.1"
32 32
33stdx = { path = "../stdx" }
34
33lsp-server = "0.3.1" 35lsp-server = "0.3.1"
34ra_cargo_watch = { path = "../ra_cargo_watch" } 36ra_cargo_watch = { path = "../ra_cargo_watch" }
35ra_ide = { path = "../ra_ide" } 37ra_ide = { path = "../ra_ide" }
diff --git a/crates/rust-analyzer/src/world.rs b/crates/rust-analyzer/src/world.rs
index de85bb017..64a7b907e 100644
--- a/crates/rust-analyzer/src/world.rs
+++ b/crates/rust-analyzer/src/world.rs
@@ -19,6 +19,7 @@ use ra_ide::{
19use ra_project_model::{get_rustc_cfg_options, ProcMacroClient, ProjectWorkspace}; 19use ra_project_model::{get_rustc_cfg_options, ProcMacroClient, ProjectWorkspace};
20use ra_vfs::{LineEndings, RootEntry, Vfs, VfsChange, VfsFile, VfsRoot, VfsTask, Watch}; 20use ra_vfs::{LineEndings, RootEntry, Vfs, VfsChange, VfsFile, VfsRoot, VfsTask, Watch};
21use relative_path::RelativePathBuf; 21use relative_path::RelativePathBuf;
22use stdx::format_to;
22 23
23use crate::{ 24use crate::{
24 diagnostics::{CheckFixes, DiagnosticCollection}, 25 diagnostics::{CheckFixes, DiagnosticCollection},
@@ -319,23 +320,23 @@ impl WorldSnapshot {
319 } 320 }
320 321
321 pub fn status(&self) -> String { 322 pub fn status(&self) -> String {
322 let mut res = String::new(); 323 let mut buf = String::new();
323 if self.workspaces.is_empty() { 324 if self.workspaces.is_empty() {
324 res.push_str("no workspaces\n") 325 buf.push_str("no workspaces\n")
325 } else { 326 } else {
326 res.push_str("workspaces:\n"); 327 buf.push_str("workspaces:\n");
327 for w in self.workspaces.iter() { 328 for w in self.workspaces.iter() {
328 res += &format!("{} packages loaded\n", w.n_packages()); 329 format_to!(buf, "{} packages loaded\n", w.n_packages());
329 } 330 }
330 } 331 }
331 res.push_str("\nanalysis:\n"); 332 buf.push_str("\nanalysis:\n");
332 res.push_str( 333 buf.push_str(
333 &self 334 &self
334 .analysis 335 .analysis
335 .status() 336 .status()
336 .unwrap_or_else(|_| "Analysis retrieval was cancelled".to_owned()), 337 .unwrap_or_else(|_| "Analysis retrieval was cancelled".to_owned()),
337 ); 338 );
338 res 339 buf
339 } 340 }
340 341
341 pub fn workspace_root_for(&self, file_id: FileId) -> Option<&Path> { 342 pub fn workspace_root_for(&self, file_id: FileId) -> Option<&Path> {
diff --git a/crates/stdx/src/lib.rs b/crates/stdx/src/lib.rs
index a01ca6d4d..8492c17af 100644
--- a/crates/stdx/src/lib.rs
+++ b/crates/stdx/src/lib.rs
@@ -21,7 +21,7 @@ where
21 I: Iterator, 21 I: Iterator,
22 I::Item: fmt::Display, 22 I::Item: fmt::Display,
23{ 23{
24 fn sep_by<'a>(self, sep: &'a std::primitive::str) -> SepByBuilder<'a, Self> { 24 fn sep_by<'a>(self, sep: &'a str) -> SepByBuilder<'a, Self> {
25 SepByBuilder::new(sep, self) 25 SepByBuilder::new(sep, self)
26 } 26 }
27} 27}