diff options
author | Aleksey Kladov <[email protected]> | 2019-01-31 18:09:43 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-31 20:23:30 +0000 |
commit | 40feacdeb90786b49ea9e0510ba22ff7af79e020 (patch) | |
tree | 294162ffb99480a5f150b9718675a954a4ac0f0a /crates | |
parent | ad80a0c551458de7d27a98d182d7f559de04f291 (diff) |
split macros across crates
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_hir/Cargo.toml | 3 | ||||
-rw-r--r-- | crates/ra_hir/src/macros.rs | 1 | ||||
-rw-r--r-- | crates/ra_macros/src/lib.rs | 17 | ||||
-rw-r--r-- | crates/ra_mbe/Cargo.toml | 10 | ||||
-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" | |||
16 | ra_syntax = { path = "../ra_syntax" } | 16 | ra_syntax = { path = "../ra_syntax" } |
17 | ra_arena = { path = "../ra_arena" } | 17 | ra_arena = { path = "../ra_arena" } |
18 | ra_db = { path = "../ra_db" } | 18 | ra_db = { path = "../ra_db" } |
19 | ra_macros = { path = "../ra_macros" } | 19 | mbe = { path = "../ra_mbe", package = "ra_mbe" } |
20 | tt = { path = "../ra_tt", package = "ra_tt" } | ||
20 | test_utils = { path = "../test_utils" } | 21 | test_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 | }; |
17 | use ra_macros::{tt, mbe}; | ||
18 | 17 | ||
19 | use crate::{HirDatabase, MacroCallId}; | 18 | use 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 @@ | |||
1 | macro_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 | |||
13 | pub mod tt; | ||
14 | pub mod mbe; | ||
15 | mod tt_cursor; | ||
16 | mod mbe_parser; | ||
17 | mod 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] | ||
2 | edition = "2018" | ||
3 | name = "ra_mbe" | ||
4 | version = "0.1.0" | ||
5 | authors = ["Aleksey Kladov <[email protected]>"] | ||
6 | |||
7 | [dependencies] | ||
8 | tt = { path = "../ra_tt", package = "ra_tt" } | ||
9 | rustc-hash = "1.0.0" | ||
10 | smol_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 @@ | |||
1 | macro_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 | |||
13 | mod tt_cursor; | ||
14 | mod mbe_parser; | ||
15 | mod mbe_expander; | ||
16 | |||
1 | use smol_str::SmolStr; | 17 | use smol_str::SmolStr; |
2 | 18 | ||
3 | pub(crate) use crate::tt::{Delimiter, Punct}; | 19 | pub use tt::{Delimiter, Punct}; |
4 | 20 | ||
5 | pub use crate::{ | 21 | pub 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 @@ | |||
1 | use rustc_hash::FxHashMap; | 1 | use rustc_hash::FxHashMap; |
2 | use smol_str::SmolStr; | 2 | use smol_str::SmolStr; |
3 | 3 | ||
4 | use crate::{mbe, tt, tt_cursor::TtCursor}; | 4 | use crate::{self as mbe, tt_cursor::TtCursor}; |
5 | 5 | ||
6 | pub fn exapnd(rules: &mbe::MacroRules, input: &tt::Subtree) -> Option<tt::Subtree> { | 6 | pub 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 @@ | |||
1 | use crate::{tt, mbe}; | 1 | use crate::{self as mbe, tt_cursor::TtCursor}; |
2 | use 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 @@ | |||
1 | use crate::tt; | ||
2 | |||
3 | #[derive(Clone)] | 1 | #[derive(Clone)] |
4 | pub(crate) struct TtCursor<'a> { | 2 | pub(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] |
2 | edition = "2018" | 2 | edition = "2018" |
3 | name = "ra_macros" | 3 | name = "ra_tt" |
4 | version = "0.1.0" | 4 | version = "0.1.0" |
5 | authors = ["Aleksey Kladov <[email protected]>"] | 5 | authors = ["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 @@ | |||
1 | macro_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 | |||
1 | use std::fmt; | 13 | use std::fmt; |
2 | 14 | ||
3 | use smol_str::SmolStr; | 15 | use smol_str::SmolStr; |