aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_mbe
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-07-04 21:09:32 +0100
committerbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-07-04 21:09:32 +0100
commitcacdb0eab8131bfb945eb7ed0150c92ec56eefe2 (patch)
treef762de90ce813591bc640ae0bce36493a3dcafa9 /crates/ra_mbe
parent4e8664d9d37021e85d72b6228fa45e7edf4a1a74 (diff)
parent1834bae5b86c54ed9dece26e82436919d59e6cb7 (diff)
Merge #1486
1486: allow rustfmt to reorder imports r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_mbe')
-rw-r--r--crates/ra_mbe/src/lib.rs10
-rw-r--r--crates/ra_mbe/src/mbe_expander.rs4
-rw-r--r--crates/ra_mbe/src/mbe_parser.rs2
-rw-r--r--crates/ra_mbe/src/subtree_parser.rs4
-rw-r--r--crates/ra_mbe/src/subtree_source.rs6
-rw-r--r--crates/ra_mbe/src/syntax_bridge.rs14
-rw-r--r--crates/ra_mbe/src/tt_cursor.rs4
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
43pub use crate::syntax_bridge::{ 43pub 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 @@
1use 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.
4use rustc_hash::FxHashMap; 5use rustc_hash::FxHashMap;
5use ra_syntax::SmolStr;
6use tt::TokenId; 6use tt::TokenId;
7 7
8use crate::ExpandError;
9use crate::tt_cursor::TtCursor; 8use crate::tt_cursor::TtCursor;
9use crate::ExpandError;
10 10
11pub(crate) fn expand( 11pub(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 @@
1use 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.
4use crate::ParseError; 5use crate::ParseError;
5use crate::tt_cursor::TtCursor;
6 6
7pub(crate) fn parse(tt: &tt::Subtree) -> Result<crate::MacroRules, ParseError> { 7pub(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 @@
1use crate::subtree_source::SubtreeTokenSource; 1use crate::subtree_source::SubtreeTokenSource;
2 2
3use ra_parser::{TokenSource, TreeSink}; 3use ra_parser::{TokenSource, TreeSink};
4use ra_syntax::{SyntaxKind}; 4use ra_syntax::SyntaxKind;
5use tt::buffer::{TokenBuffer, Cursor}; 5use tt::buffer::{Cursor, TokenBuffer};
6 6
7struct OffsetTokenSink<'a> { 7struct 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 @@
1use ra_parser::{TokenSource, Token}; 1use ra_parser::{Token, TokenSource};
2use ra_syntax::{classify_literal, SmolStr, SyntaxKind, SyntaxKind::*, T}; 2use ra_syntax::{classify_literal, SmolStr, SyntaxKind, SyntaxKind::*, T};
3use std::cell::{RefCell, Cell}; 3use std::cell::{Cell, RefCell};
4use tt::buffer::{TokenBuffer, Cursor}; 4use tt::buffer::{Cursor, TokenBuffer};
5 5
6#[derive(Debug, Clone, Eq, PartialEq)] 6#[derive(Debug, Clone, Eq, PartialEq)]
7struct TtToken { 7struct 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 @@
1use ra_parser::{TreeSink, ParseError}; 1use crate::subtree_source::SubtreeTokenSource;
2use crate::ExpandError;
3use ra_parser::{ParseError, TreeSink};
2use ra_syntax::{ 4use 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};
6use tt::buffer::{TokenBuffer, Cursor}; 8use tt::buffer::{Cursor, TokenBuffer};
7use crate::subtree_source::{SubtreeTokenSource};
8use 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)]
368mod tests { 368mod 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 @@
1use crate::ParseError;
2use crate::subtree_parser::Parser; 1use crate::subtree_parser::Parser;
3use smallvec::{SmallVec, smallvec}; 2use crate::ParseError;
3use smallvec::{smallvec, SmallVec};
4 4
5#[derive(Debug, Clone)] 5#[derive(Debug, Clone)]
6pub(crate) struct TtCursor<'a> { 6pub(crate) struct TtCursor<'a> {