diff options
-rw-r--r-- | Cargo.lock | 14 | ||||
-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 |
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]] |
1022 | name = "ra_macros" | 1023 | name = "ra_mbe" |
1023 | version = "0.1.0" | 1024 | version = "0.1.0" |
1024 | dependencies = [ | 1025 | dependencies = [ |
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]] |
1058 | name = "ra_tt" | ||
1059 | version = "0.1.0" | ||
1060 | dependencies = [ | ||
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]] | ||
1056 | name = "ra_vfs" | 1066 | name = "ra_vfs" |
1057 | version = "0.1.0" | 1067 | version = "0.1.0" |
1058 | dependencies = [ | 1068 | dependencies = [ |
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; |