diff options
Diffstat (limited to 'crates/ra_mbe')
-rw-r--r-- | crates/ra_mbe/src/lib.rs | 10 | ||||
-rw-r--r-- | crates/ra_mbe/src/mbe_expander.rs | 4 | ||||
-rw-r--r-- | crates/ra_mbe/src/mbe_parser.rs | 2 | ||||
-rw-r--r-- | crates/ra_mbe/src/subtree_parser.rs | 4 | ||||
-rw-r--r-- | crates/ra_mbe/src/subtree_source.rs | 6 | ||||
-rw-r--r-- | crates/ra_mbe/src/syntax_bridge.rs | 14 | ||||
-rw-r--r-- | crates/ra_mbe/src/tt_cursor.rs | 4 |
7 files changed, 19 insertions, 25 deletions
diff --git a/crates/ra_mbe/src/lib.rs b/crates/ra_mbe/src/lib.rs index c146252a4..52c3d03b5 100644 --- a/crates/ra_mbe/src/lib.rs +++ b/crates/ra_mbe/src/lib.rs | |||
@@ -41,14 +41,8 @@ pub enum ExpandError { | |||
41 | } | 41 | } |
42 | 42 | ||
43 | pub use crate::syntax_bridge::{ | 43 | pub use crate::syntax_bridge::{ |
44 | ast_to_token_tree, | 44 | ast_to_token_tree, syntax_node_to_token_tree, token_tree_to_ast_item_list, token_tree_to_expr, |
45 | token_tree_to_ast_item_list, | 45 | token_tree_to_macro_items, token_tree_to_macro_stmts, token_tree_to_pat, token_tree_to_ty, |
46 | syntax_node_to_token_tree, | ||
47 | token_tree_to_expr, | ||
48 | token_tree_to_pat, | ||
49 | token_tree_to_ty, | ||
50 | token_tree_to_macro_items, | ||
51 | token_tree_to_macro_stmts, | ||
52 | }; | 46 | }; |
53 | 47 | ||
54 | /// This struct contains AST for a single `macro_rules` definition. What might | 48 | /// This struct contains AST for a single `macro_rules` definition. What might |
diff --git a/crates/ra_mbe/src/mbe_expander.rs b/crates/ra_mbe/src/mbe_expander.rs index 55a6ecf58..fbad8ebe2 100644 --- a/crates/ra_mbe/src/mbe_expander.rs +++ b/crates/ra_mbe/src/mbe_expander.rs | |||
@@ -1,12 +1,12 @@ | |||
1 | use ra_syntax::SmolStr; | ||
1 | /// This module takes a (parsed) definition of `macro_rules` invocation, a | 2 | /// This module takes a (parsed) definition of `macro_rules` invocation, a |
2 | /// `tt::TokenTree` representing an argument of macro invocation, and produces a | 3 | /// `tt::TokenTree` representing an argument of macro invocation, and produces a |
3 | /// `tt::TokenTree` for the result of the expansion. | 4 | /// `tt::TokenTree` for the result of the expansion. |
4 | use rustc_hash::FxHashMap; | 5 | use rustc_hash::FxHashMap; |
5 | use ra_syntax::SmolStr; | ||
6 | use tt::TokenId; | 6 | use tt::TokenId; |
7 | 7 | ||
8 | use crate::ExpandError; | ||
9 | use crate::tt_cursor::TtCursor; | 8 | use crate::tt_cursor::TtCursor; |
9 | use crate::ExpandError; | ||
10 | 10 | ||
11 | pub(crate) fn expand( | 11 | pub(crate) fn expand( |
12 | rules: &crate::MacroRules, | 12 | rules: &crate::MacroRules, |
diff --git a/crates/ra_mbe/src/mbe_parser.rs b/crates/ra_mbe/src/mbe_parser.rs index dca16b537..a29885852 100644 --- a/crates/ra_mbe/src/mbe_parser.rs +++ b/crates/ra_mbe/src/mbe_parser.rs | |||
@@ -1,8 +1,8 @@ | |||
1 | use crate::tt_cursor::TtCursor; | ||
1 | /// This module parses a raw `tt::TokenStream` into macro-by-example token | 2 | /// This module parses a raw `tt::TokenStream` into macro-by-example token |
2 | /// stream. This is a *mostly* identify function, expect for handling of | 3 | /// stream. This is a *mostly* identify function, expect for handling of |
3 | /// `$var:tt_kind` and `$(repeat),*` constructs. | 4 | /// `$var:tt_kind` and `$(repeat),*` constructs. |
4 | use crate::ParseError; | 5 | use crate::ParseError; |
5 | use crate::tt_cursor::TtCursor; | ||
6 | 6 | ||
7 | pub(crate) fn parse(tt: &tt::Subtree) -> Result<crate::MacroRules, ParseError> { | 7 | pub(crate) fn parse(tt: &tt::Subtree) -> Result<crate::MacroRules, ParseError> { |
8 | let mut parser = TtCursor::new(tt); | 8 | let mut parser = TtCursor::new(tt); |
diff --git a/crates/ra_mbe/src/subtree_parser.rs b/crates/ra_mbe/src/subtree_parser.rs index 4a6f6aa45..5688e7f7f 100644 --- a/crates/ra_mbe/src/subtree_parser.rs +++ b/crates/ra_mbe/src/subtree_parser.rs | |||
@@ -1,8 +1,8 @@ | |||
1 | use crate::subtree_source::SubtreeTokenSource; | 1 | use crate::subtree_source::SubtreeTokenSource; |
2 | 2 | ||
3 | use ra_parser::{TokenSource, TreeSink}; | 3 | use ra_parser::{TokenSource, TreeSink}; |
4 | use ra_syntax::{SyntaxKind}; | 4 | use ra_syntax::SyntaxKind; |
5 | use tt::buffer::{TokenBuffer, Cursor}; | 5 | use tt::buffer::{Cursor, TokenBuffer}; |
6 | 6 | ||
7 | struct OffsetTokenSink<'a> { | 7 | struct OffsetTokenSink<'a> { |
8 | cursor: Cursor<'a>, | 8 | cursor: Cursor<'a>, |
diff --git a/crates/ra_mbe/src/subtree_source.rs b/crates/ra_mbe/src/subtree_source.rs index 7647e16d8..2489c996b 100644 --- a/crates/ra_mbe/src/subtree_source.rs +++ b/crates/ra_mbe/src/subtree_source.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | use ra_parser::{TokenSource, Token}; | 1 | use ra_parser::{Token, TokenSource}; |
2 | use ra_syntax::{classify_literal, SmolStr, SyntaxKind, SyntaxKind::*, T}; | 2 | use ra_syntax::{classify_literal, SmolStr, SyntaxKind, SyntaxKind::*, T}; |
3 | use std::cell::{RefCell, Cell}; | 3 | use std::cell::{Cell, RefCell}; |
4 | use tt::buffer::{TokenBuffer, Cursor}; | 4 | use tt::buffer::{Cursor, TokenBuffer}; |
5 | 5 | ||
6 | #[derive(Debug, Clone, Eq, PartialEq)] | 6 | #[derive(Debug, Clone, Eq, PartialEq)] |
7 | struct TtToken { | 7 | struct TtToken { |
diff --git a/crates/ra_mbe/src/syntax_bridge.rs b/crates/ra_mbe/src/syntax_bridge.rs index cb039ca37..b91b0e7a5 100644 --- a/crates/ra_mbe/src/syntax_bridge.rs +++ b/crates/ra_mbe/src/syntax_bridge.rs | |||
@@ -1,11 +1,11 @@ | |||
1 | use ra_parser::{TreeSink, ParseError}; | 1 | use crate::subtree_source::SubtreeTokenSource; |
2 | use crate::ExpandError; | ||
3 | use ra_parser::{ParseError, TreeSink}; | ||
2 | use ra_syntax::{ | 4 | use ra_syntax::{ |
3 | AstNode, SyntaxNode, TextRange, SyntaxKind, SmolStr, SyntaxTreeBuilder, TreeArc, SyntaxElement, | 5 | ast, AstNode, SmolStr, SyntaxElement, SyntaxKind, SyntaxKind::*, SyntaxNode, SyntaxTreeBuilder, |
4 | ast, SyntaxKind::*, TextUnit, T | 6 | TextRange, TextUnit, TreeArc, T, |
5 | }; | 7 | }; |
6 | use tt::buffer::{TokenBuffer, Cursor}; | 8 | use tt::buffer::{Cursor, TokenBuffer}; |
7 | use crate::subtree_source::{SubtreeTokenSource}; | ||
8 | use crate::ExpandError; | ||
9 | 9 | ||
10 | /// Maps `tt::TokenId` to the relative range of the original token. | 10 | /// Maps `tt::TokenId` to the relative range of the original token. |
11 | #[derive(Default)] | 11 | #[derive(Default)] |
@@ -367,7 +367,7 @@ impl<'a> TreeSink for TtTreeSink<'a> { | |||
367 | #[cfg(test)] | 367 | #[cfg(test)] |
368 | mod tests { | 368 | mod tests { |
369 | use super::*; | 369 | use super::*; |
370 | use crate::tests::{expand, create_rules}; | 370 | use crate::tests::{create_rules, expand}; |
371 | use ra_parser::TokenSource; | 371 | use ra_parser::TokenSource; |
372 | 372 | ||
373 | #[test] | 373 | #[test] |
diff --git a/crates/ra_mbe/src/tt_cursor.rs b/crates/ra_mbe/src/tt_cursor.rs index d85ab43e4..503c77ef3 100644 --- a/crates/ra_mbe/src/tt_cursor.rs +++ b/crates/ra_mbe/src/tt_cursor.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use crate::ParseError; | ||
2 | use crate::subtree_parser::Parser; | 1 | use crate::subtree_parser::Parser; |
3 | use smallvec::{SmallVec, smallvec}; | 2 | use crate::ParseError; |
3 | use smallvec::{smallvec, SmallVec}; | ||
4 | 4 | ||
5 | #[derive(Debug, Clone)] | 5 | #[derive(Debug, Clone)] |
6 | pub(crate) struct TtCursor<'a> { | 6 | pub(crate) struct TtCursor<'a> { |