aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-01-31 18:09:43 +0000
committerAleksey Kladov <[email protected]>2019-01-31 20:23:30 +0000
commit40feacdeb90786b49ea9e0510ba22ff7af79e020 (patch)
tree294162ffb99480a5f150b9718675a954a4ac0f0a /crates
parentad80a0c551458de7d27a98d182d7f559de04f291 (diff)
split macros across crates
Diffstat (limited to 'crates')
-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
10 files changed, 45 insertions, 27 deletions
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;