aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock32
-rw-r--r--crates/ra_cfg/Cargo.toml2
-rw-r--r--crates/ra_db/Cargo.toml2
-rw-r--r--crates/ra_db/src/input.rs4
-rw-r--r--crates/ra_hir_def/Cargo.toml2
-rw-r--r--crates/ra_hir_expand/Cargo.toml2
-rw-r--r--crates/ra_mbe/Cargo.toml2
-rw-r--r--crates/ra_mbe/src/lib.rs2
-rw-r--r--crates/ra_proc_macro/Cargo.toml2
-rw-r--r--crates/ra_proc_macro/src/lib.rs17
-rw-r--r--crates/ra_proc_macro/src/msg.rs3
-rw-r--r--crates/ra_proc_macro/src/process.rs38
-rw-r--r--crates/ra_proc_macro/src/rpc.rs13
-rw-r--r--crates/ra_proc_macro_srv/Cargo.toml2
-rw-r--r--crates/ra_proc_macro_srv/src/dylib.rs6
-rw-r--r--crates/ra_proc_macro_srv/src/lib.rs2
-rw-r--r--crates/ra_proc_macro_srv/src/rustc_server.rs8
-rw-r--r--crates/rust-analyzer/Cargo.toml2
-rw-r--r--crates/tt/Cargo.toml (renamed from crates/ra_tt/Cargo.toml)11
-rw-r--r--crates/tt/src/buffer.rs (renamed from crates/ra_tt/src/buffer.rs)0
-rw-r--r--crates/tt/src/lib.rs (renamed from crates/ra_tt/src/lib.rs)0
-rw-r--r--xtask/tests/tidy.rs2
22 files changed, 77 insertions, 77 deletions
diff --git a/Cargo.lock b/Cargo.lock
index c2a0457c7..598b739c7 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -939,8 +939,8 @@ version = "0.1.0"
939dependencies = [ 939dependencies = [
940 "ra_mbe", 940 "ra_mbe",
941 "ra_syntax", 941 "ra_syntax",
942 "ra_tt",
943 "rustc-hash", 942 "rustc-hash",
943 "tt",
944] 944]
945 945
946[[package]] 946[[package]]
@@ -950,11 +950,11 @@ dependencies = [
950 "profile", 950 "profile",
951 "ra_cfg", 951 "ra_cfg",
952 "ra_syntax", 952 "ra_syntax",
953 "ra_tt",
954 "rustc-hash", 953 "rustc-hash",
955 "salsa", 954 "salsa",
956 "stdx", 955 "stdx",
957 "test_utils", 956 "test_utils",
957 "tt",
958 "vfs", 958 "vfs",
959] 959]
960 960
@@ -1004,11 +1004,11 @@ dependencies = [
1004 "ra_hir_expand", 1004 "ra_hir_expand",
1005 "ra_mbe", 1005 "ra_mbe",
1006 "ra_syntax", 1006 "ra_syntax",
1007 "ra_tt",
1008 "rustc-hash", 1007 "rustc-hash",
1009 "smallvec", 1008 "smallvec",
1010 "stdx", 1009 "stdx",
1011 "test_utils", 1010 "test_utils",
1011 "tt",
1012] 1012]
1013 1013
1014[[package]] 1014[[package]]
@@ -1023,9 +1023,9 @@ dependencies = [
1023 "ra_mbe", 1023 "ra_mbe",
1024 "ra_parser", 1024 "ra_parser",
1025 "ra_syntax", 1025 "ra_syntax",
1026 "ra_tt",
1027 "rustc-hash", 1026 "rustc-hash",
1028 "test_utils", 1027 "test_utils",
1028 "tt",
1029] 1029]
1030 1030
1031[[package]] 1031[[package]]
@@ -1107,10 +1107,10 @@ dependencies = [
1107 "log", 1107 "log",
1108 "ra_parser", 1108 "ra_parser",
1109 "ra_syntax", 1109 "ra_syntax",
1110 "ra_tt",
1111 "rustc-hash", 1110 "rustc-hash",
1112 "smallvec", 1111 "smallvec",
1113 "test_utils", 1112 "test_utils",
1113 "tt",
1114] 1114]
1115 1115
1116[[package]] 1116[[package]]
@@ -1127,9 +1127,9 @@ dependencies = [
1127 "crossbeam-channel", 1127 "crossbeam-channel",
1128 "jod-thread", 1128 "jod-thread",
1129 "log", 1129 "log",
1130 "ra_tt",
1131 "serde", 1130 "serde",
1132 "serde_json", 1131 "serde_json",
1132 "tt",
1133] 1133]
1134 1134
1135[[package]] 1135[[package]]
@@ -1144,9 +1144,9 @@ dependencies = [
1144 "ra_mbe", 1144 "ra_mbe",
1145 "ra_proc_macro", 1145 "ra_proc_macro",
1146 "ra_toolchain", 1146 "ra_toolchain",
1147 "ra_tt",
1148 "serde_derive", 1147 "serde_derive",
1149 "test_utils", 1148 "test_utils",
1149 "tt",
1150] 1150]
1151 1151
1152[[package]] 1152[[package]]
@@ -1218,14 +1218,6 @@ dependencies = [
1218] 1218]
1219 1219
1220[[package]] 1220[[package]]
1221name = "ra_tt"
1222version = "0.1.0"
1223dependencies = [
1224 "smol_str",
1225 "stdx",
1226]
1227
1228[[package]]
1229name = "rayon" 1221name = "rayon"
1230version = "1.3.1" 1222version = "1.3.1"
1231source = "registry+https://github.com/rust-lang/crates.io-index" 1223source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1329,7 +1321,6 @@ dependencies = [
1329 "ra_syntax", 1321 "ra_syntax",
1330 "ra_text_edit", 1322 "ra_text_edit",
1331 "ra_toolchain", 1323 "ra_toolchain",
1332 "ra_tt",
1333 "rayon", 1324 "rayon",
1334 "rustc-hash", 1325 "rustc-hash",
1335 "serde", 1326 "serde",
@@ -1337,6 +1328,7 @@ dependencies = [
1337 "stdx", 1328 "stdx",
1338 "test_utils", 1329 "test_utils",
1339 "threadpool", 1330 "threadpool",
1331 "tt",
1340 "vfs", 1332 "vfs",
1341 "vfs-notify", 1333 "vfs-notify",
1342 "winapi 0.3.9", 1334 "winapi 0.3.9",
@@ -1707,6 +1699,14 @@ dependencies = [
1707] 1699]
1708 1700
1709[[package]] 1701[[package]]
1702name = "tt"
1703version = "0.0.0"
1704dependencies = [
1705 "smol_str",
1706 "stdx",
1707]
1708
1709[[package]]
1710name = "ungrammar" 1710name = "ungrammar"
1711version = "1.1.1" 1711version = "1.1.1"
1712source = "registry+https://github.com/rust-lang/crates.io-index" 1712source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/crates/ra_cfg/Cargo.toml b/crates/ra_cfg/Cargo.toml
index 6425cd6d6..770a40742 100644
--- a/crates/ra_cfg/Cargo.toml
+++ b/crates/ra_cfg/Cargo.toml
@@ -12,7 +12,7 @@ doctest = false
12rustc-hash = "1.1.0" 12rustc-hash = "1.1.0"
13 13
14ra_syntax = { path = "../ra_syntax" } 14ra_syntax = { path = "../ra_syntax" }
15tt = { path = "../ra_tt", package = "ra_tt" } 15tt = { path = "../tt" }
16 16
17[dev-dependencies] 17[dev-dependencies]
18mbe = { path = "../ra_mbe", package = "ra_mbe" } 18mbe = { path = "../ra_mbe", package = "ra_mbe" }
diff --git a/crates/ra_db/Cargo.toml b/crates/ra_db/Cargo.toml
index 9cb9ba11c..47a0f6248 100644
--- a/crates/ra_db/Cargo.toml
+++ b/crates/ra_db/Cargo.toml
@@ -15,7 +15,7 @@ rustc-hash = "1.1.0"
15ra_syntax = { path = "../ra_syntax" } 15ra_syntax = { path = "../ra_syntax" }
16ra_cfg = { path = "../ra_cfg" } 16ra_cfg = { path = "../ra_cfg" }
17profile = { path = "../profile" } 17profile = { path = "../profile" }
18ra_tt = { path = "../ra_tt" } 18tt = { path = "../tt" }
19test_utils = { path = "../test_utils" } 19test_utils = { path = "../test_utils" }
20vfs = { path = "../vfs" } 20vfs = { path = "../vfs" }
21stdx = { path = "../stdx" } 21stdx = { path = "../stdx" }
diff --git a/crates/ra_db/src/input.rs b/crates/ra_db/src/input.rs
index 6f2e5cfc7..02a1abee0 100644
--- a/crates/ra_db/src/input.rs
+++ b/crates/ra_db/src/input.rs
@@ -10,8 +10,8 @@ use std::{fmt, iter::FromIterator, ops, str::FromStr, sync::Arc};
10 10
11use ra_cfg::CfgOptions; 11use ra_cfg::CfgOptions;
12use ra_syntax::SmolStr; 12use ra_syntax::SmolStr;
13use ra_tt::TokenExpander;
14use rustc_hash::{FxHashMap, FxHashSet}; 13use rustc_hash::{FxHashMap, FxHashSet};
14use tt::TokenExpander;
15use vfs::file_set::FileSet; 15use vfs::file_set::FileSet;
16 16
17pub use vfs::FileId; 17pub use vfs::FileId;
@@ -156,7 +156,7 @@ impl CrateGraph {
156 display_name: Option<String>, 156 display_name: Option<String>,
157 cfg_options: CfgOptions, 157 cfg_options: CfgOptions,
158 env: Env, 158 env: Env,
159 proc_macro: Vec<(SmolStr, Arc<dyn ra_tt::TokenExpander>)>, 159 proc_macro: Vec<(SmolStr, Arc<dyn tt::TokenExpander>)>,
160 ) -> CrateId { 160 ) -> CrateId {
161 let proc_macro = 161 let proc_macro =
162 proc_macro.into_iter().map(|(name, it)| ProcMacro { name, expander: it }).collect(); 162 proc_macro.into_iter().map(|(name, it)| ProcMacro { name, expander: it }).collect();
diff --git a/crates/ra_hir_def/Cargo.toml b/crates/ra_hir_def/Cargo.toml
index adfd8c7b7..1a080a8b4 100644
--- a/crates/ra_hir_def/Cargo.toml
+++ b/crates/ra_hir_def/Cargo.toml
@@ -30,7 +30,7 @@ hir_expand = { path = "../ra_hir_expand", package = "ra_hir_expand" }
30test_utils = { path = "../test_utils" } 30test_utils = { path = "../test_utils" }
31mbe = { path = "../ra_mbe", package = "ra_mbe" } 31mbe = { path = "../ra_mbe", package = "ra_mbe" }
32ra_cfg = { path = "../ra_cfg" } 32ra_cfg = { path = "../ra_cfg" }
33tt = { path = "../ra_tt", package = "ra_tt" } 33tt = { path = "../tt" }
34 34
35[dev-dependencies] 35[dev-dependencies]
36expect = { path = "../expect" } 36expect = { path = "../expect" }
diff --git a/crates/ra_hir_expand/Cargo.toml b/crates/ra_hir_expand/Cargo.toml
index 711a93c56..7d8ccd56f 100644
--- a/crates/ra_hir_expand/Cargo.toml
+++ b/crates/ra_hir_expand/Cargo.toml
@@ -18,6 +18,6 @@ ra_db = { path = "../ra_db" }
18ra_syntax = { path = "../ra_syntax" } 18ra_syntax = { path = "../ra_syntax" }
19ra_parser = { path = "../ra_parser" } 19ra_parser = { path = "../ra_parser" }
20profile = { path = "../profile" } 20profile = { path = "../profile" }
21tt = { path = "../ra_tt", package = "ra_tt" } 21tt = { path = "../tt" }
22mbe = { path = "../ra_mbe", package = "ra_mbe" } 22mbe = { path = "../ra_mbe", package = "ra_mbe" }
23test_utils = { path = "../test_utils"} 23test_utils = { path = "../test_utils"}
diff --git a/crates/ra_mbe/Cargo.toml b/crates/ra_mbe/Cargo.toml
index a26746a19..23315910c 100644
--- a/crates/ra_mbe/Cargo.toml
+++ b/crates/ra_mbe/Cargo.toml
@@ -11,7 +11,7 @@ doctest = false
11[dependencies] 11[dependencies]
12ra_syntax = { path = "../ra_syntax" } 12ra_syntax = { path = "../ra_syntax" }
13ra_parser = { path = "../ra_parser" } 13ra_parser = { path = "../ra_parser" }
14tt = { path = "../ra_tt", package = "ra_tt" } 14tt = { path = "../tt" }
15rustc-hash = "1.1.0" 15rustc-hash = "1.1.0"
16smallvec = "1.2.0" 16smallvec = "1.2.0"
17log = "0.4.8" 17log = "0.4.8"
diff --git a/crates/ra_mbe/src/lib.rs b/crates/ra_mbe/src/lib.rs
index dec7ba22e..f854ca09a 100644
--- a/crates/ra_mbe/src/lib.rs
+++ b/crates/ra_mbe/src/lib.rs
@@ -1,5 +1,5 @@
1//! `mbe` (short for Macro By Example) crate contains code for handling 1//! `mbe` (short for Macro By Example) crate contains code for handling
2//! `macro_rules` macros. It uses `TokenTree` (from `ra_tt` package) as the 2//! `macro_rules` macros. It uses `TokenTree` (from `tt` package) as the
3//! interface, although it contains some code to bridge `SyntaxNode`s and 3//! interface, although it contains some code to bridge `SyntaxNode`s and
4//! `TokenTree`s as well! 4//! `TokenTree`s as well!
5 5
diff --git a/crates/ra_proc_macro/Cargo.toml b/crates/ra_proc_macro/Cargo.toml
index c4b6e9e7b..d2d1bc228 100644
--- a/crates/ra_proc_macro/Cargo.toml
+++ b/crates/ra_proc_macro/Cargo.toml
@@ -10,7 +10,7 @@ license = "MIT OR Apache-2.0"
10doctest = false 10doctest = false
11 11
12[dependencies] 12[dependencies]
13ra_tt = { path = "../ra_tt" } 13tt = { path = "../tt" }
14serde = { version = "1.0", features = ["derive"] } 14serde = { version = "1.0", features = ["derive"] }
15serde_json = "1.0" 15serde_json = "1.0"
16log = "0.4.8" 16log = "0.4.8"
diff --git a/crates/ra_proc_macro/src/lib.rs b/crates/ra_proc_macro/src/lib.rs
index 004943b9e..15db57eb2 100644
--- a/crates/ra_proc_macro/src/lib.rs
+++ b/crates/ra_proc_macro/src/lib.rs
@@ -9,8 +9,6 @@ mod rpc;
9mod process; 9mod process;
10pub mod msg; 10pub mod msg;
11 11
12use process::{ProcMacroProcessSrv, ProcMacroProcessThread};
13use ra_tt::{SmolStr, Subtree};
14use std::{ 12use std::{
15 ffi::OsStr, 13 ffi::OsStr,
16 io, 14 io,
@@ -18,6 +16,10 @@ use std::{
18 sync::Arc, 16 sync::Arc,
19}; 17};
20 18
19use tt::{SmolStr, Subtree};
20
21use crate::process::{ProcMacroProcessSrv, ProcMacroProcessThread};
22
21pub use rpc::{ExpansionResult, ExpansionTask, ListMacrosResult, ListMacrosTask, ProcMacroKind}; 23pub use rpc::{ExpansionResult, ExpansionTask, ListMacrosResult, ListMacrosTask, ProcMacroKind};
22 24
23#[derive(Debug, Clone)] 25#[derive(Debug, Clone)]
@@ -36,12 +38,12 @@ impl PartialEq for ProcMacroProcessExpander {
36 } 38 }
37} 39}
38 40
39impl ra_tt::TokenExpander for ProcMacroProcessExpander { 41impl tt::TokenExpander for ProcMacroProcessExpander {
40 fn expand( 42 fn expand(
41 &self, 43 &self,
42 subtree: &Subtree, 44 subtree: &Subtree,
43 _attr: Option<&Subtree>, 45 _attr: Option<&Subtree>,
44 ) -> Result<Subtree, ra_tt::ExpansionError> { 46 ) -> Result<Subtree, tt::ExpansionError> {
45 self.process.custom_derive(&self.dylib_path, subtree, &self.name) 47 self.process.custom_derive(&self.dylib_path, subtree, &self.name)
46 } 48 }
47} 49}
@@ -72,10 +74,7 @@ impl ProcMacroClient {
72 ProcMacroClient { kind: ProcMacroClientKind::Dummy } 74 ProcMacroClient { kind: ProcMacroClientKind::Dummy }
73 } 75 }
74 76
75 pub fn by_dylib_path( 77 pub fn by_dylib_path(&self, dylib_path: &Path) -> Vec<(SmolStr, Arc<dyn tt::TokenExpander>)> {
76 &self,
77 dylib_path: &Path,
78 ) -> Vec<(SmolStr, Arc<dyn ra_tt::TokenExpander>)> {
79 match &self.kind { 78 match &self.kind {
80 ProcMacroClientKind::Dummy => vec![], 79 ProcMacroClientKind::Dummy => vec![],
81 ProcMacroClientKind::Process { process, .. } => { 80 ProcMacroClientKind::Process { process, .. } => {
@@ -94,7 +93,7 @@ impl ProcMacroClient {
94 match kind { 93 match kind {
95 ProcMacroKind::CustomDerive => { 94 ProcMacroKind::CustomDerive => {
96 let name = SmolStr::new(&name); 95 let name = SmolStr::new(&name);
97 let expander: Arc<dyn ra_tt::TokenExpander> = 96 let expander: Arc<dyn tt::TokenExpander> =
98 Arc::new(ProcMacroProcessExpander { 97 Arc::new(ProcMacroProcessExpander {
99 process: process.clone(), 98 process: process.clone(),
100 name: name.clone(), 99 name: name.clone(),
diff --git a/crates/ra_proc_macro/src/msg.rs b/crates/ra_proc_macro/src/msg.rs
index 95d9b8804..f84ebdbc5 100644
--- a/crates/ra_proc_macro/src/msg.rs
+++ b/crates/ra_proc_macro/src/msg.rs
@@ -5,11 +5,12 @@ use std::{
5 io::{self, BufRead, Write}, 5 io::{self, BufRead, Write},
6}; 6};
7 7
8use serde::{de::DeserializeOwned, Deserialize, Serialize};
9
8use crate::{ 10use crate::{
9 rpc::{ListMacrosResult, ListMacrosTask}, 11 rpc::{ListMacrosResult, ListMacrosTask},
10 ExpansionResult, ExpansionTask, 12 ExpansionResult, ExpansionTask,
11}; 13};
12use serde::{de::DeserializeOwned, Deserialize, Serialize};
13 14
14#[derive(Debug, Serialize, Deserialize, Clone)] 15#[derive(Debug, Serialize, Deserialize, Clone)]
15pub enum Request { 16pub enum Request {
diff --git a/crates/ra_proc_macro/src/process.rs b/crates/ra_proc_macro/src/process.rs
index 37dd3f496..51ffcaa78 100644
--- a/crates/ra_proc_macro/src/process.rs
+++ b/crates/ra_proc_macro/src/process.rs
@@ -1,21 +1,22 @@
1//! Handle process life-time and message passing for proc-macro client 1//! Handle process life-time and message passing for proc-macro client
2 2
3use crossbeam_channel::{bounded, Receiver, Sender};
4use ra_tt::Subtree;
5
6use crate::msg::{ErrorCode, Message, Request, Response, ResponseError};
7use crate::rpc::{ExpansionResult, ExpansionTask, ListMacrosResult, ListMacrosTask, ProcMacroKind};
8
9use io::{BufRead, BufReader};
10use std::{ 3use std::{
11 convert::{TryFrom, TryInto}, 4 convert::{TryFrom, TryInto},
12 ffi::{OsStr, OsString}, 5 ffi::{OsStr, OsString},
13 io::{self, Write}, 6 io::{self, BufRead, BufReader, Write},
14 path::{Path, PathBuf}, 7 path::{Path, PathBuf},
15 process::{Child, Command, Stdio}, 8 process::{Child, Command, Stdio},
16 sync::{Arc, Weak}, 9 sync::{Arc, Weak},
17}; 10};
18 11
12use crossbeam_channel::{bounded, Receiver, Sender};
13use tt::Subtree;
14
15use crate::{
16 msg::{ErrorCode, Message, Request, Response, ResponseError},
17 rpc::{ExpansionResult, ExpansionTask, ListMacrosResult, ListMacrosTask, ProcMacroKind},
18};
19
19#[derive(Debug, Default)] 20#[derive(Debug, Default)]
20pub(crate) struct ProcMacroProcessSrv { 21pub(crate) struct ProcMacroProcessSrv {
21 inner: Option<Weak<Sender<Task>>>, 22 inner: Option<Weak<Sender<Task>>>,
@@ -50,7 +51,7 @@ impl ProcMacroProcessSrv {
50 pub fn find_proc_macros( 51 pub fn find_proc_macros(
51 &self, 52 &self,
52 dylib_path: &Path, 53 dylib_path: &Path,
53 ) -> Result<Vec<(String, ProcMacroKind)>, ra_tt::ExpansionError> { 54 ) -> Result<Vec<(String, ProcMacroKind)>, tt::ExpansionError> {
54 let task = ListMacrosTask { lib: dylib_path.to_path_buf() }; 55 let task = ListMacrosTask { lib: dylib_path.to_path_buf() };
55 56
56 let result: ListMacrosResult = self.send_task(Request::ListMacro(task))?; 57 let result: ListMacrosResult = self.send_task(Request::ListMacro(task))?;
@@ -62,7 +63,7 @@ impl ProcMacroProcessSrv {
62 dylib_path: &Path, 63 dylib_path: &Path,
63 subtree: &Subtree, 64 subtree: &Subtree,
64 derive_name: &str, 65 derive_name: &str,
65 ) -> Result<Subtree, ra_tt::ExpansionError> { 66 ) -> Result<Subtree, tt::ExpansionError> {
66 let task = ExpansionTask { 67 let task = ExpansionTask {
67 macro_body: subtree.clone(), 68 macro_body: subtree.clone(),
68 macro_name: derive_name.to_string(), 69 macro_name: derive_name.to_string(),
@@ -74,38 +75,35 @@ impl ProcMacroProcessSrv {
74 Ok(result.expansion) 75 Ok(result.expansion)
75 } 76 }
76 77
77 pub fn send_task<R>(&self, req: Request) -> Result<R, ra_tt::ExpansionError> 78 pub fn send_task<R>(&self, req: Request) -> Result<R, tt::ExpansionError>
78 where 79 where
79 R: TryFrom<Response, Error = &'static str>, 80 R: TryFrom<Response, Error = &'static str>,
80 { 81 {
81 let sender = match &self.inner { 82 let sender = match &self.inner {
82 None => return Err(ra_tt::ExpansionError::Unknown("No sender is found.".to_string())), 83 None => return Err(tt::ExpansionError::Unknown("No sender is found.".to_string())),
83 Some(it) => it, 84 Some(it) => it,
84 }; 85 };
85 86
86 let (result_tx, result_rx) = bounded(0); 87 let (result_tx, result_rx) = bounded(0);
87 let sender = match sender.upgrade() { 88 let sender = match sender.upgrade() {
88 None => { 89 None => {
89 return Err(ra_tt::ExpansionError::Unknown("Proc macro process is closed.".into())) 90 return Err(tt::ExpansionError::Unknown("Proc macro process is closed.".into()))
90 } 91 }
91 Some(it) => it, 92 Some(it) => it,
92 }; 93 };
93 sender.send(Task { req, result_tx }).unwrap(); 94 sender.send(Task { req, result_tx }).unwrap();
94 let res = result_rx 95 let res = result_rx
95 .recv() 96 .recv()
96 .map_err(|_| ra_tt::ExpansionError::Unknown("Proc macro thread is closed.".into()))?; 97 .map_err(|_| tt::ExpansionError::Unknown("Proc macro thread is closed.".into()))?;
97 98
98 match res { 99 match res {
99 Some(Response::Error(err)) => { 100 Some(Response::Error(err)) => {
100 return Err(ra_tt::ExpansionError::ExpansionError(err.message)); 101 return Err(tt::ExpansionError::ExpansionError(err.message));
101 } 102 }
102 Some(res) => Ok(res.try_into().map_err(|err| { 103 Some(res) => Ok(res.try_into().map_err(|err| {
103 ra_tt::ExpansionError::Unknown(format!( 104 tt::ExpansionError::Unknown(format!("Fail to get response, reason : {:#?} ", err))
104 "Fail to get response, reason : {:#?} ",
105 err
106 ))
107 })?), 105 })?),
108 None => Err(ra_tt::ExpansionError::Unknown("Empty result".into())), 106 None => Err(tt::ExpansionError::Unknown("Empty result".into())),
109 } 107 }
110 } 108 }
111} 109}
diff --git a/crates/ra_proc_macro/src/rpc.rs b/crates/ra_proc_macro/src/rpc.rs
index 4ce485926..5e5d78d06 100644
--- a/crates/ra_proc_macro/src/rpc.rs
+++ b/crates/ra_proc_macro/src/rpc.rs
@@ -1,17 +1,18 @@
1//! Data struture serialization related stuff for RPC 1//! Data struture serialization related stuff for RPC
2//! 2//!
3//! Defines all necessary rpc serialization data structures, 3//! Defines all necessary rpc serialization data structures,
4//! which includes `ra_tt` related data and some task messages. 4//! which includes `tt` related data and some task messages.
5//! Although adding `Serialize` and `Deserialize` traits to `ra_tt` directly seems 5//! Although adding `Serialize` and `Deserialize` traits to `tt` directly seems
6//! to be much easier, we deliberately duplicate `ra_tt` structs with `#[serde(with = "XXDef")]` 6//! to be much easier, we deliberately duplicate `tt` structs with `#[serde(with = "XXDef")]`
7//! for separation of code responsibility. 7//! for separation of code responsibility.
8 8
9use ra_tt::{ 9use std::path::PathBuf;
10
11use serde::{Deserialize, Serialize};
12use tt::{
10 Delimiter, DelimiterKind, Ident, Leaf, Literal, Punct, SmolStr, Spacing, Subtree, TokenId, 13 Delimiter, DelimiterKind, Ident, Leaf, Literal, Punct, SmolStr, Spacing, Subtree, TokenId,
11 TokenTree, 14 TokenTree,
12}; 15};
13use serde::{Deserialize, Serialize};
14use std::path::PathBuf;
15 16
16#[derive(Clone, Eq, PartialEq, Debug, Serialize, Deserialize)] 17#[derive(Clone, Eq, PartialEq, Debug, Serialize, Deserialize)]
17pub struct ListMacrosTask { 18pub struct ListMacrosTask {
diff --git a/crates/ra_proc_macro_srv/Cargo.toml b/crates/ra_proc_macro_srv/Cargo.toml
index bc119a6c7..a690cc044 100644
--- a/crates/ra_proc_macro_srv/Cargo.toml
+++ b/crates/ra_proc_macro_srv/Cargo.toml
@@ -10,7 +10,7 @@ license = "MIT OR Apache-2.0"
10doctest = false 10doctest = false
11 11
12[dependencies] 12[dependencies]
13ra_tt = { path = "../ra_tt" } 13tt = { path = "../tt" }
14ra_mbe = { path = "../ra_mbe" } 14ra_mbe = { path = "../ra_mbe" }
15ra_proc_macro = { path = "../ra_proc_macro" } 15ra_proc_macro = { path = "../ra_proc_macro" }
16goblin = "0.2.1" 16goblin = "0.2.1"
diff --git a/crates/ra_proc_macro_srv/src/dylib.rs b/crates/ra_proc_macro_srv/src/dylib.rs
index 1addbbd54..9b6cc91ef 100644
--- a/crates/ra_proc_macro_srv/src/dylib.rs
+++ b/crates/ra_proc_macro_srv/src/dylib.rs
@@ -128,9 +128,9 @@ impl Expander {
128 pub fn expand( 128 pub fn expand(
129 &self, 129 &self,
130 macro_name: &str, 130 macro_name: &str,
131 macro_body: &ra_tt::Subtree, 131 macro_body: &tt::Subtree,
132 attributes: Option<&ra_tt::Subtree>, 132 attributes: Option<&tt::Subtree>,
133 ) -> Result<ra_tt::Subtree, bridge::PanicMessage> { 133 ) -> Result<tt::Subtree, bridge::PanicMessage> {
134 let parsed_body = TokenStream::with_subtree(macro_body.clone()); 134 let parsed_body = TokenStream::with_subtree(macro_body.clone());
135 135
136 let parsed_attributes = attributes 136 let parsed_attributes = attributes
diff --git a/crates/ra_proc_macro_srv/src/lib.rs b/crates/ra_proc_macro_srv/src/lib.rs
index 922bb84bb..1fc2eef82 100644
--- a/crates/ra_proc_macro_srv/src/lib.rs
+++ b/crates/ra_proc_macro_srv/src/lib.rs
@@ -5,7 +5,7 @@
5//! 5//!
6//! But we adapt it to better fit RA needs: 6//! But we adapt it to better fit RA needs:
7//! 7//!
8//! * We use `ra_tt` for proc-macro `TokenStream` server, it is easier to manipulate and interact with 8//! * We use `tt` for proc-macro `TokenStream` server, it is easier to manipulate and interact with
9//! RA than `proc-macro2` token stream. 9//! RA than `proc-macro2` token stream.
10//! * By **copying** the whole rustc `lib_proc_macro` code, we are able to build this with `stable` 10//! * By **copying** the whole rustc `lib_proc_macro` code, we are able to build this with `stable`
11//! rustc rather than `unstable`. (Although in gerenal ABI compatibility is still an issue) 11//! rustc rather than `unstable`. (Although in gerenal ABI compatibility is still an issue)
diff --git a/crates/ra_proc_macro_srv/src/rustc_server.rs b/crates/ra_proc_macro_srv/src/rustc_server.rs
index cc32d5a6d..d534d1337 100644
--- a/crates/ra_proc_macro_srv/src/rustc_server.rs
+++ b/crates/ra_proc_macro_srv/src/rustc_server.rs
@@ -1,15 +1,14 @@
1//! Rustc proc-macro server implementation with ra_tt 1//! Rustc proc-macro server implementation with tt
2//! 2//!
3//! Based on idea from https://github.com/fedochet/rust-proc-macro-expander 3//! Based on idea from https://github.com/fedochet/rust-proc-macro-expander
4//! The lib-proc-macro server backend is `TokenStream`-agnostic, such that 4//! The lib-proc-macro server backend is `TokenStream`-agnostic, such that
5//! we could provide any TokenStream implementation. 5//! we could provide any TokenStream implementation.
6//! The original idea from fedochet is using proc-macro2 as backend, 6//! The original idea from fedochet is using proc-macro2 as backend,
7//! we use ra_tt instead for better intergation with RA. 7//! we use tt instead for better intergation with RA.
8//! 8//!
9//! FIXME: No span and source file information is implemented yet 9//! FIXME: No span and source file information is implemented yet
10 10
11use crate::proc_macro::bridge::{self, server}; 11use crate::proc_macro::bridge::{self, server};
12use ra_tt as tt;
13 12
14use std::collections::{Bound, HashMap}; 13use std::collections::{Bound, HashMap};
15use std::hash::Hash; 14use std::hash::Hash;
@@ -153,9 +152,10 @@ pub struct TokenStreamBuilder {
153 152
154/// Public implementation details for the `TokenStream` type, such as iterators. 153/// Public implementation details for the `TokenStream` type, such as iterators.
155pub mod token_stream { 154pub mod token_stream {
156 use super::{tt, TokenStream, TokenTree};
157 use std::str::FromStr; 155 use std::str::FromStr;
158 156
157 use super::{TokenStream, TokenTree};
158
159 /// An iterator over `TokenStream`'s `TokenTree`s. 159 /// An iterator over `TokenStream`'s `TokenTree`s.
160 /// The iteration is "shallow", e.g., the iterator doesn't recurse into delimited groups, 160 /// The iteration is "shallow", e.g., the iterator doesn't recurse into delimited groups,
161 /// and returns whole groups as token trees. 161 /// and returns whole groups as token trees.
diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml
index 6cbf43bb2..9bc5cc631 100644
--- a/crates/rust-analyzer/Cargo.toml
+++ b/crates/rust-analyzer/Cargo.toml
@@ -61,4 +61,4 @@ winapi = "0.3.8"
61expect = { path = "../expect" } 61expect = { path = "../expect" }
62test_utils = { path = "../test_utils" } 62test_utils = { path = "../test_utils" }
63mbe = { path = "../ra_mbe", package = "ra_mbe" } 63mbe = { path = "../ra_mbe", package = "ra_mbe" }
64tt = { path = "../ra_tt", package = "ra_tt" } 64tt = { path = "../tt" }
diff --git a/crates/ra_tt/Cargo.toml b/crates/tt/Cargo.toml
index 3c45248c3..dfcdcf03e 100644
--- a/crates/ra_tt/Cargo.toml
+++ b/crates/tt/Cargo.toml
@@ -1,15 +1,16 @@
1[package] 1[package]
2edition = "2018" 2name = "tt"
3name = "ra_tt" 3version = "0.0.0"
4version = "0.1.0"
5authors = ["rust-analyzer developers"]
6license = "MIT OR Apache-2.0" 4license = "MIT OR Apache-2.0"
5authors = ["rust-analyzer developers"]
6edition = "2018"
7 7
8[lib] 8[lib]
9doctest = false 9doctest = false
10 10
11[dependencies] 11[dependencies]
12stdx = { path = "../stdx" }
13# ideally, `serde` should be enabled by `rust-analyzer`, but we enable it here 12# ideally, `serde` should be enabled by `rust-analyzer`, but we enable it here
14# to reduce number of compilations 13# to reduce number of compilations
15smol_str = { version = "0.1.15", features = ["serde"] } 14smol_str = { version = "0.1.15", features = ["serde"] }
15
16stdx = { path = "../stdx" }
diff --git a/crates/ra_tt/src/buffer.rs b/crates/tt/src/buffer.rs
index 02c771f70..02c771f70 100644
--- a/crates/ra_tt/src/buffer.rs
+++ b/crates/tt/src/buffer.rs
diff --git a/crates/ra_tt/src/lib.rs b/crates/tt/src/lib.rs
index 20c3f5eab..20c3f5eab 100644
--- a/crates/ra_tt/src/lib.rs
+++ b/crates/tt/src/lib.rs
diff --git a/xtask/tests/tidy.rs b/xtask/tests/tidy.rs
index 7384205db..ddaab93ab 100644
--- a/xtask/tests/tidy.rs
+++ b/xtask/tests/tidy.rs
@@ -200,7 +200,7 @@ impl TidyDocs {
200 "profile", 200 "profile",
201 "ra_project_model", 201 "ra_project_model",
202 "ra_syntax", 202 "ra_syntax",
203 "ra_tt", 203 "tt",
204 "ra_hir_ty", 204 "ra_hir_ty",
205 ]; 205 ];
206 206