aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock14
-rw-r--r--crates/ra_hir/Cargo.toml3
-rw-r--r--crates/ra_hir/src/macros.rs1
-rw-r--r--crates/ra_macros/src/lib.rs17
-rw-r--r--crates/ra_mbe/Cargo.toml10
-rw-r--r--crates/ra_mbe/src/lib.rs (renamed from crates/ra_macros/src/mbe.rs)18
-rw-r--r--crates/ra_mbe/src/mbe_expander.rs (renamed from crates/ra_macros/src/mbe_expander.rs)2
-rw-r--r--crates/ra_mbe/src/mbe_parser.rs (renamed from crates/ra_macros/src/mbe_parser.rs)5
-rw-r--r--crates/ra_mbe/src/tt_cursor.rs (renamed from crates/ra_macros/src/tt_cursor.rs)2
-rw-r--r--crates/ra_tt/Cargo.toml (renamed from crates/ra_macros/Cargo.toml)2
-rw-r--r--crates/ra_tt/src/lib.rs (renamed from crates/ra_macros/src/tt.rs)12
11 files changed, 57 insertions, 29 deletions
diff --git a/Cargo.lock b/Cargo.lock
index b48721622..426f4af27 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -940,8 +940,9 @@ dependencies = [
940 "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", 940 "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
941 "ra_arena 0.1.0", 941 "ra_arena 0.1.0",
942 "ra_db 0.1.0", 942 "ra_db 0.1.0",
943 "ra_macros 0.1.0", 943 "ra_mbe 0.1.0",
944 "ra_syntax 0.1.0", 944 "ra_syntax 0.1.0",
945 "ra_tt 0.1.0",
945 "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 946 "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
946 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", 947 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
947 "test_utils 0.1.0", 948 "test_utils 0.1.0",
@@ -1019,9 +1020,10 @@ dependencies = [
1019] 1020]
1020 1021
1021[[package]] 1022[[package]]
1022name = "ra_macros" 1023name = "ra_mbe"
1023version = "0.1.0" 1024version = "0.1.0"
1024dependencies = [ 1025dependencies = [
1026 "ra_tt 0.1.0",
1025 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", 1027 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
1026 "smol_str 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", 1028 "smol_str 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
1027] 1029]
@@ -1053,6 +1055,14 @@ dependencies = [
1053] 1055]
1054 1056
1055[[package]] 1057[[package]]
1058name = "ra_tt"
1059version = "0.1.0"
1060dependencies = [
1061 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
1062 "smol_str 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
1063]
1064
1065[[package]]
1056name = "ra_vfs" 1066name = "ra_vfs"
1057version = "0.1.0" 1067version = "0.1.0"
1058dependencies = [ 1068dependencies = [
diff --git a/crates/ra_hir/Cargo.toml b/crates/ra_hir/Cargo.toml
index f0988acc8..4309a05d6 100644
--- a/crates/ra_hir/Cargo.toml
+++ b/crates/ra_hir/Cargo.toml
@@ -16,7 +16,8 @@ join_to_string = "0.1.3"
16ra_syntax = { path = "../ra_syntax" } 16ra_syntax = { path = "../ra_syntax" }
17ra_arena = { path = "../ra_arena" } 17ra_arena = { path = "../ra_arena" }
18ra_db = { path = "../ra_db" } 18ra_db = { path = "../ra_db" }
19ra_macros = { path = "../ra_macros" } 19mbe = { path = "../ra_mbe", package = "ra_mbe" }
20tt = { path = "../ra_tt", package = "ra_tt" }
20test_utils = { path = "../test_utils" } 21test_utils = { path = "../test_utils" }
21 22
22[dev-dependencies] 23[dev-dependencies]
diff --git a/crates/ra_hir/src/macros.rs b/crates/ra_hir/src/macros.rs
index e6ba8c08f..ffcf1c3f9 100644
--- a/crates/ra_hir/src/macros.rs
+++ b/crates/ra_hir/src/macros.rs
@@ -14,7 +14,6 @@ use ra_syntax::{
14 SyntaxKind::*, 14 SyntaxKind::*,
15 ast::{self, NameOwner}, 15 ast::{self, NameOwner},
16}; 16};
17use ra_macros::{tt, mbe};
18 17
19use crate::{HirDatabase, MacroCallId}; 18use crate::{HirDatabase, MacroCallId};
20 19
diff --git a/crates/ra_macros/src/lib.rs b/crates/ra_macros/src/lib.rs
deleted file mode 100644
index e35a056cc..000000000
--- a/crates/ra_macros/src/lib.rs
+++ /dev/null
@@ -1,17 +0,0 @@
1macro_rules! impl_froms {
2 ($e:ident: $($v:ident), *) => {
3 $(
4 impl From<$v> for $e {
5 fn from(it: $v) -> $e {
6 $e::$v(it)
7 }
8 }
9 )*
10 }
11}
12
13pub mod tt;
14pub mod mbe;
15mod tt_cursor;
16mod mbe_parser;
17mod mbe_expander;
diff --git a/crates/ra_mbe/Cargo.toml b/crates/ra_mbe/Cargo.toml
new file mode 100644
index 000000000..b7f03cd38
--- /dev/null
+++ b/crates/ra_mbe/Cargo.toml
@@ -0,0 +1,10 @@
1[package]
2edition = "2018"
3name = "ra_mbe"
4version = "0.1.0"
5authors = ["Aleksey Kladov <[email protected]>"]
6
7[dependencies]
8tt = { path = "../ra_tt", package = "ra_tt" }
9rustc-hash = "1.0.0"
10smol_str = "0.1.9"
diff --git a/crates/ra_macros/src/mbe.rs b/crates/ra_mbe/src/lib.rs
index d4106a41c..38bf3431a 100644
--- a/crates/ra_macros/src/mbe.rs
+++ b/crates/ra_mbe/src/lib.rs
@@ -1,6 +1,22 @@
1macro_rules! impl_froms {
2 ($e:ident: $($v:ident), *) => {
3 $(
4 impl From<$v> for $e {
5 fn from(it: $v) -> $e {
6 $e::$v(it)
7 }
8 }
9 )*
10 }
11}
12
13mod tt_cursor;
14mod mbe_parser;
15mod mbe_expander;
16
1use smol_str::SmolStr; 17use smol_str::SmolStr;
2 18
3pub(crate) use crate::tt::{Delimiter, Punct}; 19pub use tt::{Delimiter, Punct};
4 20
5pub use crate::{ 21pub use crate::{
6 mbe_parser::parse, 22 mbe_parser::parse,
diff --git a/crates/ra_macros/src/mbe_expander.rs b/crates/ra_mbe/src/mbe_expander.rs
index 5d5363261..92ad26889 100644
--- a/crates/ra_macros/src/mbe_expander.rs
+++ b/crates/ra_mbe/src/mbe_expander.rs
@@ -1,7 +1,7 @@
1use rustc_hash::FxHashMap; 1use rustc_hash::FxHashMap;
2use smol_str::SmolStr; 2use smol_str::SmolStr;
3 3
4use crate::{mbe, tt, tt_cursor::TtCursor}; 4use crate::{self as mbe, tt_cursor::TtCursor};
5 5
6pub fn exapnd(rules: &mbe::MacroRules, input: &tt::Subtree) -> Option<tt::Subtree> { 6pub fn exapnd(rules: &mbe::MacroRules, input: &tt::Subtree) -> Option<tt::Subtree> {
7 rules.rules.iter().find_map(|it| expand_rule(it, input)) 7 rules.rules.iter().find_map(|it| expand_rule(it, input))
diff --git a/crates/ra_macros/src/mbe_parser.rs b/crates/ra_mbe/src/mbe_parser.rs
index 483594590..a70ed1d52 100644
--- a/crates/ra_macros/src/mbe_parser.rs
+++ b/crates/ra_mbe/src/mbe_parser.rs
@@ -1,5 +1,4 @@
1use crate::{tt, mbe}; 1use crate::{self as mbe, tt_cursor::TtCursor};
2use crate::tt_cursor::TtCursor;
3 2
4/// This module parses a raw `tt::TokenStream` into macro-by-example token 3/// This module parses a raw `tt::TokenStream` into macro-by-example token
5/// stream. This is a *mostly* identify function, expect for handling of 4/// stream. This is a *mostly* identify function, expect for handling of
@@ -43,7 +42,7 @@ fn parse_subtree(tt: &tt::Subtree) -> Option<mbe::Subtree> {
43 mbe::Leaf::from(mbe::Literal { text: text.clone() }).into() 42 mbe::Leaf::from(mbe::Literal { text: text.clone() }).into()
44 } 43 }
45 }, 44 },
46 tt::TokenTree::Subtree(subtree) => parse_subtree(subtree)?.into(), 45 tt::TokenTree::Subtree(subtree) => parse_subtree(&subtree)?.into(),
47 }; 46 };
48 token_trees.push(child); 47 token_trees.push(child);
49 } 48 }
diff --git a/crates/ra_macros/src/tt_cursor.rs b/crates/ra_mbe/src/tt_cursor.rs
index 046770a0f..30c8eda67 100644
--- a/crates/ra_macros/src/tt_cursor.rs
+++ b/crates/ra_mbe/src/tt_cursor.rs
@@ -1,5 +1,3 @@
1use crate::tt;
2
3#[derive(Clone)] 1#[derive(Clone)]
4pub(crate) struct TtCursor<'a> { 2pub(crate) struct TtCursor<'a> {
5 subtree: &'a tt::Subtree, 3 subtree: &'a tt::Subtree,
diff --git a/crates/ra_macros/Cargo.toml b/crates/ra_tt/Cargo.toml
index 7d3cb055c..357a5c5a3 100644
--- a/crates/ra_macros/Cargo.toml
+++ b/crates/ra_tt/Cargo.toml
@@ -1,6 +1,6 @@
1[package] 1[package]
2edition = "2018" 2edition = "2018"
3name = "ra_macros" 3name = "ra_tt"
4version = "0.1.0" 4version = "0.1.0"
5authors = ["Aleksey Kladov <[email protected]>"] 5authors = ["Aleksey Kladov <[email protected]>"]
6 6
diff --git a/crates/ra_macros/src/tt.rs b/crates/ra_tt/src/lib.rs
index 2855bae51..d7c3c62bf 100644
--- a/crates/ra_macros/src/tt.rs
+++ b/crates/ra_tt/src/lib.rs
@@ -1,3 +1,15 @@
1macro_rules! impl_froms {
2 ($e:ident: $($v:ident), *) => {
3 $(
4 impl From<$v> for $e {
5 fn from(it: $v) -> $e {
6 $e::$v(it)
7 }
8 }
9 )*
10 }
11}
12
1use std::fmt; 13use std::fmt;
2 14
3use smol_str::SmolStr; 15use smol_str::SmolStr;