Repository: rust-analyzer/rust-analyzer
Pull request #5725 (2020-08-12 14:49:32)

Rename ra_tt -> tt

bors r+
🤖


Patch:
diff --git a/Cargo.lock b/Cargo.lock
index c2a0457c76..598b739c7e 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -939,8 +939,8 @@ version = "0.1.0"
 dependencies = [
  "ra_mbe",
  "ra_syntax",
- "ra_tt",
  "rustc-hash",
+ "tt",
 ]
 
 [[package]]
@@ -950,11 +950,11 @@ dependencies = [
  "profile",
  "ra_cfg",
  "ra_syntax",
- "ra_tt",
  "rustc-hash",
  "salsa",
  "stdx",
  "test_utils",
+ "tt",
  "vfs",
 ]
 
@@ -1004,11 +1004,11 @@ dependencies = [
  "ra_hir_expand",
  "ra_mbe",
  "ra_syntax",
- "ra_tt",
  "rustc-hash",
  "smallvec",
  "stdx",
  "test_utils",
+ "tt",
 ]
 
 [[package]]
@@ -1023,9 +1023,9 @@ dependencies = [
  "ra_mbe",
  "ra_parser",
  "ra_syntax",
- "ra_tt",
  "rustc-hash",
  "test_utils",
+ "tt",
 ]
 
 [[package]]
@@ -1107,10 +1107,10 @@ dependencies = [
  "log",
  "ra_parser",
  "ra_syntax",
- "ra_tt",
  "rustc-hash",
  "smallvec",
  "test_utils",
+ "tt",
 ]
 
 [[package]]
@@ -1127,9 +1127,9 @@ dependencies = [
  "crossbeam-channel",
  "jod-thread",
  "log",
- "ra_tt",
  "serde",
  "serde_json",
+ "tt",
 ]
 
 [[package]]
@@ -1144,9 +1144,9 @@ dependencies = [
  "ra_mbe",
  "ra_proc_macro",
  "ra_toolchain",
- "ra_tt",
  "serde_derive",
  "test_utils",
+ "tt",
 ]
 
 [[package]]
@@ -1217,14 +1217,6 @@ dependencies = [
  "home",
 ]
 
-[[package]]
-name = "ra_tt"
-version = "0.1.0"
-dependencies = [
- "smol_str",
- "stdx",
-]
-
 [[package]]
 name = "rayon"
 version = "1.3.1"
@@ -1329,7 +1321,6 @@ dependencies = [
  "ra_syntax",
  "ra_text_edit",
  "ra_toolchain",
- "ra_tt",
  "rayon",
  "rustc-hash",
  "serde",
@@ -1337,6 +1328,7 @@ dependencies = [
  "stdx",
  "test_utils",
  "threadpool",
+ "tt",
  "vfs",
  "vfs-notify",
  "winapi 0.3.9",
@@ -1706,6 +1698,14 @@ dependencies = [
  "tracing-subscriber",
 ]
 
+[[package]]
+name = "tt"
+version = "0.0.0"
+dependencies = [
+ "smol_str",
+ "stdx",
+]
+
 [[package]]
 name = "ungrammar"
 version = "1.1.1"
diff --git a/crates/ra_cfg/Cargo.toml b/crates/ra_cfg/Cargo.toml
index 6425cd6d6f..770a407428 100644
--- a/crates/ra_cfg/Cargo.toml
+++ b/crates/ra_cfg/Cargo.toml
@@ -12,7 +12,7 @@ doctest = false
 rustc-hash = "1.1.0"
 
 ra_syntax = { path = "../ra_syntax" }
-tt = { path = "../ra_tt", package = "ra_tt" }
+tt = { path = "../tt" }
 
 [dev-dependencies]
 mbe = { path = "../ra_mbe", package = "ra_mbe" }
diff --git a/crates/ra_db/Cargo.toml b/crates/ra_db/Cargo.toml
index 9cb9ba11c7..47a0f6248f 100644
--- a/crates/ra_db/Cargo.toml
+++ b/crates/ra_db/Cargo.toml
@@ -15,7 +15,7 @@ rustc-hash = "1.1.0"
 ra_syntax = { path = "../ra_syntax" }
 ra_cfg = { path = "../ra_cfg" }
 profile = { path = "../profile" }
-ra_tt = { path = "../ra_tt" }
+tt = { path = "../tt" }
 test_utils = { path = "../test_utils" }
 vfs = { path = "../vfs" }
 stdx = { path = "../stdx" }
diff --git a/crates/ra_db/src/input.rs b/crates/ra_db/src/input.rs
index 6f2e5cfc76..02a1abee0f 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};
 
 use ra_cfg::CfgOptions;
 use ra_syntax::SmolStr;
-use ra_tt::TokenExpander;
 use rustc_hash::{FxHashMap, FxHashSet};
+use tt::TokenExpander;
 use vfs::file_set::FileSet;
 
 pub use vfs::FileId;
@@ -156,7 +156,7 @@ impl CrateGraph {
         display_name: Option<String>,
         cfg_options: CfgOptions,
         env: Env,
-        proc_macro: Vec<(SmolStr, Arc<dyn ra_tt::TokenExpander>)>,
+        proc_macro: Vec<(SmolStr, Arc<dyn tt::TokenExpander>)>,
     ) -> CrateId {
         let proc_macro =
             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 adfd8c7b71..1a080a8b4b 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" }
 test_utils = { path = "../test_utils" }
 mbe = { path = "../ra_mbe", package = "ra_mbe" }
 ra_cfg = { path = "../ra_cfg" }
-tt = { path = "../ra_tt", package = "ra_tt" }
+tt = { path = "../tt" }
 
 [dev-dependencies]
 expect = { path = "../expect" }
diff --git a/crates/ra_hir_expand/Cargo.toml b/crates/ra_hir_expand/Cargo.toml
index 711a93c56b..7d8ccd56fc 100644
--- a/crates/ra_hir_expand/Cargo.toml
+++ b/crates/ra_hir_expand/Cargo.toml
@@ -18,6 +18,6 @@ ra_db = { path = "../ra_db" }
 ra_syntax = { path = "../ra_syntax" }
 ra_parser = { path = "../ra_parser" }
 profile = { path = "../profile" }
-tt = { path = "../ra_tt", package = "ra_tt" }
+tt = { path = "../tt" }
 mbe = { path = "../ra_mbe", package = "ra_mbe" }
 test_utils = { path = "../test_utils"}
diff --git a/crates/ra_mbe/Cargo.toml b/crates/ra_mbe/Cargo.toml
index a26746a194..23315910c4 100644
--- a/crates/ra_mbe/Cargo.toml
+++ b/crates/ra_mbe/Cargo.toml
@@ -11,7 +11,7 @@ doctest = false
 [dependencies]
 ra_syntax = { path = "../ra_syntax" }
 ra_parser = { path = "../ra_parser" }
-tt = { path = "../ra_tt", package = "ra_tt" }
+tt = { path = "../tt" }
 rustc-hash = "1.1.0"
 smallvec = "1.2.0"
 log = "0.4.8"
diff --git a/crates/ra_mbe/src/lib.rs b/crates/ra_mbe/src/lib.rs
index dec7ba22ea..f854ca09ab 100644
--- a/crates/ra_mbe/src/lib.rs
+++ b/crates/ra_mbe/src/lib.rs
@@ -1,5 +1,5 @@
 //! `mbe` (short for Macro By Example) crate contains code for handling
-//! `macro_rules` macros. It uses `TokenTree` (from `ra_tt` package) as the
+//! `macro_rules` macros. It uses `TokenTree` (from `tt` package) as the
 //! interface, although it contains some code to bridge `SyntaxNode`s and
 //! `TokenTree`s as well!
 
diff --git a/crates/ra_proc_macro/Cargo.toml b/crates/ra_proc_macro/Cargo.toml
index c4b6e9e7ba..d2d1bc228d 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"
 doctest = false
 
 [dependencies]
-ra_tt = { path = "../ra_tt" }
+tt = { path = "../tt" }
 serde = { version = "1.0", features = ["derive"] }
 serde_json = "1.0"
 log = "0.4.8"
diff --git a/crates/ra_proc_macro/src/lib.rs b/crates/ra_proc_macro/src/lib.rs
index 004943b9e0..15db57eb28 100644
--- a/crates/ra_proc_macro/src/lib.rs
+++ b/crates/ra_proc_macro/src/lib.rs
@@ -9,8 +9,6 @@ mod rpc;
 mod process;
 pub mod msg;
 
-use process::{ProcMacroProcessSrv, ProcMacroProcessThread};
-use ra_tt::{SmolStr, Subtree};
 use std::{
     ffi::OsStr,
     io,
@@ -18,6 +16,10 @@ use std::{
     sync::Arc,
 };
 
+use tt::{SmolStr, Subtree};
+
+use crate::process::{ProcMacroProcessSrv, ProcMacroProcessThread};
+
 pub use rpc::{ExpansionResult, ExpansionTask, ListMacrosResult, ListMacrosTask, ProcMacroKind};
 
 #[derive(Debug, Clone)]
@@ -36,12 +38,12 @@ impl PartialEq for ProcMacroProcessExpander {
     }
 }
 
-impl ra_tt::TokenExpander for ProcMacroProcessExpander {
+impl tt::TokenExpander for ProcMacroProcessExpander {
     fn expand(
         &self,
         subtree: &Subtree,
         _attr: Option<&Subtree>,
-    ) -> Result<Subtree, ra_tt::ExpansionError> {
+    ) -> Result<Subtree, tt::ExpansionError> {
         self.process.custom_derive(&self.dylib_path, subtree, &self.name)
     }
 }
@@ -72,10 +74,7 @@ impl ProcMacroClient {
         ProcMacroClient { kind: ProcMacroClientKind::Dummy }
     }
 
-    pub fn by_dylib_path(
-        &self,
-        dylib_path: &Path,
-    ) -> Vec<(SmolStr, Arc<dyn ra_tt::TokenExpander>)> {
+    pub fn by_dylib_path(&self, dylib_path: &Path) -> Vec<(SmolStr, Arc<dyn tt::TokenExpander>)> {
         match &self.kind {
             ProcMacroClientKind::Dummy => vec![],
             ProcMacroClientKind::Process { process, .. } => {
@@ -94,7 +93,7 @@ impl ProcMacroClient {
                         match kind {
                             ProcMacroKind::CustomDerive => {
                                 let name = SmolStr::new(&name);
-                                let expander: Arc<dyn ra_tt::TokenExpander> =
+                                let expander: Arc<dyn tt::TokenExpander> =
                                     Arc::new(ProcMacroProcessExpander {
                                         process: process.clone(),
                                         name: name.clone(),
diff --git a/crates/ra_proc_macro/src/msg.rs b/crates/ra_proc_macro/src/msg.rs
index 95d9b8804e..f84ebdbc57 100644
--- a/crates/ra_proc_macro/src/msg.rs
+++ b/crates/ra_proc_macro/src/msg.rs
@@ -5,11 +5,12 @@ use std::{
     io::{self, BufRead, Write},
 };
 
+use serde::{de::DeserializeOwned, Deserialize, Serialize};
+
 use crate::{
     rpc::{ListMacrosResult, ListMacrosTask},
     ExpansionResult, ExpansionTask,
 };
-use serde::{de::DeserializeOwned, Deserialize, Serialize};
 
 #[derive(Debug, Serialize, Deserialize, Clone)]
 pub enum Request {
diff --git a/crates/ra_proc_macro/src/process.rs b/crates/ra_proc_macro/src/process.rs
index 37dd3f4965..51ffcaa786 100644
--- a/crates/ra_proc_macro/src/process.rs
+++ b/crates/ra_proc_macro/src/process.rs
@@ -1,21 +1,22 @@
 //! Handle process life-time and message passing for proc-macro client
 
-use crossbeam_channel::{bounded, Receiver, Sender};
-use ra_tt::Subtree;
-
-use crate::msg::{ErrorCode, Message, Request, Response, ResponseError};
-use crate::rpc::{ExpansionResult, ExpansionTask, ListMacrosResult, ListMacrosTask, ProcMacroKind};
-
-use io::{BufRead, BufReader};
 use std::{
     convert::{TryFrom, TryInto},
     ffi::{OsStr, OsString},
-    io::{self, Write},
+    io::{self, BufRead, BufReader, Write},
     path::{Path, PathBuf},
     process::{Child, Command, Stdio},
     sync::{Arc, Weak},
 };
 
+use crossbeam_channel::{bounded, Receiver, Sender};
+use tt::Subtree;
+
+use crate::{
+    msg::{ErrorCode, Message, Request, Response, ResponseError},
+    rpc::{ExpansionResult, ExpansionTask, ListMacrosResult, ListMacrosTask, ProcMacroKind},
+};
+
 #[derive(Debug, Default)]
 pub(crate) struct ProcMacroProcessSrv {
     inner: Option<Weak<Sender<Task>>>,
@@ -50,7 +51,7 @@ impl ProcMacroProcessSrv {
     pub fn find_proc_macros(
         &self,
         dylib_path: &Path,
-    ) -> Result<Vec<(String, ProcMacroKind)>, ra_tt::ExpansionError> {
+    ) -> Result<Vec<(String, ProcMacroKind)>, tt::ExpansionError> {
         let task = ListMacrosTask { lib: dylib_path.to_path_buf() };
 
         let result: ListMacrosResult = self.send_task(Request::ListMacro(task))?;
@@ -62,7 +63,7 @@ impl ProcMacroProcessSrv {
         dylib_path: &Path,
         subtree: &Subtree,
         derive_name: &str,
-    ) -> Result<Subtree, ra_tt::ExpansionError> {
+    ) -> Result<Subtree, tt::ExpansionError> {
         let task = ExpansionTask {
             macro_body: subtree.clone(),
             macro_name: derive_name.to_string(),
@@ -74,38 +75,35 @@ impl ProcMacroProcessSrv {
         Ok(result.expansion)
     }
 
-    pub fn send_task<R>(&self, req: Request) -> Result<R, ra_tt::ExpansionError>
+    pub fn send_task<R>(&self, req: Request) -> Result<R, tt::ExpansionError>
     where
         R: TryFrom<Response, Error = &'static str>,
     {
         let sender = match &self.inner {
-            None => return Err(ra_tt::ExpansionError::Unknown("No sender is found.".to_string())),
+            None => return Err(tt::ExpansionError::Unknown("No sender is found.".to_string())),
             Some(it) => it,
         };
 
         let (result_tx, result_rx) = bounded(0);
         let sender = match sender.upgrade() {
             None => {
-                return Err(ra_tt::ExpansionError::Unknown("Proc macro process is closed.".into()))
+                return Err(tt::ExpansionError::Unknown("Proc macro process is closed.".into()))
             }
             Some(it) => it,
         };
         sender.send(Task { req, result_tx }).unwrap();
         let res = result_rx
             .recv()
-            .map_err(|_| ra_tt::ExpansionError::Unknown("Proc macro thread is closed.".into()))?;
+            .map_err(|_| tt::ExpansionError::Unknown("Proc macro thread is closed.".into()))?;
 
         match res {
             Some(Response::Error(err)) => {
-                return Err(ra_tt::ExpansionError::ExpansionError(err.message));
+                return Err(tt::ExpansionError::ExpansionError(err.message));
             }
             Some(res) => Ok(res.try_into().map_err(|err| {
-                ra_tt::ExpansionError::Unknown(format!(
-                    "Fail to get response, reason : {:#?} ",
-                    err
-                ))
+                tt::ExpansionError::Unknown(format!("Fail to get response, reason : {:#?} ", err))
             })?),
-            None => Err(ra_tt::ExpansionError::Unknown("Empty result".into())),
+            None => Err(tt::ExpansionError::Unknown("Empty result".into())),
         }
     }
 }
diff --git a/crates/ra_proc_macro/src/rpc.rs b/crates/ra_proc_macro/src/rpc.rs
index 4ce4859263..5e5d78d067 100644
--- a/crates/ra_proc_macro/src/rpc.rs
+++ b/crates/ra_proc_macro/src/rpc.rs
@@ -1,17 +1,18 @@
 //! Data struture serialization related stuff for RPC
 //!
 //! Defines all necessary rpc serialization data structures,
-//! which includes `ra_tt` related data and some task messages.
-//! Although adding `Serialize` and `Deserialize` traits to `ra_tt` directly seems
-//! to be much easier, we deliberately duplicate `ra_tt` structs with `#[serde(with = "XXDef")]`
+//! which includes `tt` related data and some task messages.
+//! Although adding `Serialize` and `Deserialize` traits to `tt` directly seems
+//! to be much easier, we deliberately duplicate `tt` structs with `#[serde(with = "XXDef")]`
 //! for separation of code responsibility.
 
-use ra_tt::{
+use std::path::PathBuf;
+
+use serde::{Deserialize, Serialize};
+use tt::{
     Delimiter, DelimiterKind, Ident, Leaf, Literal, Punct, SmolStr, Spacing, Subtree, TokenId,
     TokenTree,
 };
-use serde::{Deserialize, Serialize};
-use std::path::PathBuf;
 
 #[derive(Clone, Eq, PartialEq, Debug, Serialize, Deserialize)]
 pub struct ListMacrosTask {
diff --git a/crates/ra_proc_macro_srv/Cargo.toml b/crates/ra_proc_macro_srv/Cargo.toml
index bc119a6c71..a690cc0443 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"
 doctest = false
 
 [dependencies]
-ra_tt = { path = "../ra_tt" }
+tt = { path = "../tt" }
 ra_mbe = { path = "../ra_mbe" }
 ra_proc_macro = { path = "../ra_proc_macro" }
 goblin = "0.2.1"
diff --git a/crates/ra_proc_macro_srv/src/dylib.rs b/crates/ra_proc_macro_srv/src/dylib.rs
index 1addbbd54f..9b6cc91ef9 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 {
     pub fn expand(
         &self,
         macro_name: &str,
-        macro_body: &ra_tt::Subtree,
-        attributes: Option<&ra_tt::Subtree>,
-    ) -> Result<ra_tt::Subtree, bridge::PanicMessage> {
+        macro_body: &tt::Subtree,
+        attributes: Option<&tt::Subtree>,
+    ) -> Result<tt::Subtree, bridge::PanicMessage> {
         let parsed_body = TokenStream::with_subtree(macro_body.clone());
 
         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 922bb84bbf..1fc2eef82e 100644
--- a/crates/ra_proc_macro_srv/src/lib.rs
+++ b/crates/ra_proc_macro_srv/src/lib.rs
@@ -5,7 +5,7 @@
 //!
 //! But we adapt it to better fit RA needs:
 //!
-//! * We use `ra_tt` for proc-macro `TokenStream` server, it is easier to manipulate and interact with
+//! * We use `tt` for proc-macro `TokenStream` server, it is easier to manipulate and interact with
 //!   RA than `proc-macro2` token stream.
 //! * By **copying** the whole rustc `lib_proc_macro` code, we are able to build this with `stable`
 //!   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 cc32d5a6dd..d534d1337f 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 @@
-//! Rustc proc-macro server implementation with ra_tt
+//! Rustc proc-macro server implementation with tt
 //!
 //! Based on idea from https://github.com/fedochet/rust-proc-macro-expander
 //! The lib-proc-macro server backend is `TokenStream`-agnostic, such that
 //! we could provide any TokenStream implementation.
 //! The original idea from fedochet is using proc-macro2 as backend,
-//! we use ra_tt instead for better intergation with RA.
+//! we use tt instead for better intergation with RA.
 //!
 //! FIXME: No span and source file information is implemented yet
 
 use crate::proc_macro::bridge::{self, server};
-use ra_tt as tt;
 
 use std::collections::{Bound, HashMap};
 use std::hash::Hash;
@@ -153,9 +152,10 @@ pub struct TokenStreamBuilder {
 
 /// Public implementation details for the `TokenStream` type, such as iterators.
 pub mod token_stream {
-    use super::{tt, TokenStream, TokenTree};
     use std::str::FromStr;
 
+    use super::{TokenStream, TokenTree};
+
     /// An iterator over `TokenStream`'s `TokenTree`s.
     /// The iteration is "shallow", e.g., the iterator doesn't recurse into delimited groups,
     /// and returns whole groups as token trees.
diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml
index 6cbf43bb2e..9bc5cc6314 100644
--- a/crates/rust-analyzer/Cargo.toml
+++ b/crates/rust-analyzer/Cargo.toml
@@ -61,4 +61,4 @@ winapi = "0.3.8"
 expect = { path = "../expect" }
 test_utils = { path = "../test_utils" }
 mbe = { path = "../ra_mbe", package = "ra_mbe" }
-tt = { path = "../ra_tt", package = "ra_tt" }
+tt = { path = "../tt" }
diff --git a/crates/ra_tt/Cargo.toml b/crates/tt/Cargo.toml
similarity index 90%
rename from crates/ra_tt/Cargo.toml
rename to crates/tt/Cargo.toml
index 3c45248c3e..dfcdcf03e8 100644
--- a/crates/ra_tt/Cargo.toml
+++ b/crates/tt/Cargo.toml
@@ -1,15 +1,16 @@
 [package]
-edition = "2018"
-name = "ra_tt"
-version = "0.1.0"
-authors = ["rust-analyzer developers"]
+name = "tt"
+version = "0.0.0"
 license = "MIT OR Apache-2.0"
+authors = ["rust-analyzer developers"]
+edition = "2018"
 
 [lib]
 doctest = false
 
 [dependencies]
-stdx = { path = "../stdx" }
 # ideally, `serde` should be enabled by `rust-analyzer`, but we enable it here
 # to reduce number of compilations
 smol_str = { version = "0.1.15", features = ["serde"] }
+
+stdx = { path = "../stdx" }


Test patch:
diff --git a/crates/ra_tt/src/buffer.rs b/crates/tt/src/buffer.rs
similarity index 100%
rename from crates/ra_tt/src/buffer.rs
rename to crates/tt/src/buffer.rs
diff --git a/crates/ra_tt/src/lib.rs b/crates/tt/src/lib.rs
similarity index 100%
rename from crates/ra_tt/src/lib.rs
rename to crates/tt/src/lib.rs
diff --git a/xtask/tests/tidy.rs b/xtask/tests/tidy.rs
index 7384205db4..ddaab93ab7 100644
--- a/xtask/tests/tidy.rs
+++ b/xtask/tests/tidy.rs
@@ -200,7 +200,7 @@ impl TidyDocs {
             "profile",
             "ra_project_model",
             "ra_syntax",
-            "ra_tt",
+            "tt",
             "ra_hir_ty",
         ];