diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-11-21 19:31:19 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-11-21 19:31:19 +0000 |
commit | c9273828b3c44fba62d1b989480c287d923839d2 (patch) | |
tree | c222eabbd7fafcf9d491ba77d34238fe587449ce /crates/ra_hir_expand/src | |
parent | 3f1a0c3c5f4e52505ca83cb217201b116453c896 (diff) | |
parent | 144dc6652c1bdb0a8a522d86d5bb4be612968675 (diff) |
Merge #2342
2342: Use proper MacroFileKind in `SourceAnalyzer` r=matklad a=edwin0cheng
* Add `MacroFileKind::Statements`
* Add `to_macro_file_kind` in `source_binding.rs` to set a proper `MacroFileKind` when expanding a macro.
* Add a test for trying expanding `match_ast` which is not correct before this PR.
* Fix some spacing issues in `insert_whitespaces`
Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_hir_expand/src')
-rw-r--r-- | crates/ra_hir_expand/src/db.rs | 1 | ||||
-rw-r--r-- | crates/ra_hir_expand/src/lib.rs | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/crates/ra_hir_expand/src/db.rs b/crates/ra_hir_expand/src/db.rs index 3c11c8a22..e1d93a8ef 100644 --- a/crates/ra_hir_expand/src/db.rs +++ b/crates/ra_hir_expand/src/db.rs | |||
@@ -151,6 +151,7 @@ pub(crate) fn parse_macro( | |||
151 | let fragment_kind = match macro_file.macro_file_kind { | 151 | let fragment_kind = match macro_file.macro_file_kind { |
152 | MacroFileKind::Items => FragmentKind::Items, | 152 | MacroFileKind::Items => FragmentKind::Items, |
153 | MacroFileKind::Expr => FragmentKind::Expr, | 153 | MacroFileKind::Expr => FragmentKind::Expr, |
154 | MacroFileKind::Statements => FragmentKind::Statements, | ||
154 | }; | 155 | }; |
155 | let (parse, rev_token_map) = mbe::token_tree_to_syntax_node(&tt, fragment_kind).ok()?; | 156 | let (parse, rev_token_map) = mbe::token_tree_to_syntax_node(&tt, fragment_kind).ok()?; |
156 | Some((parse, Arc::new(rev_token_map))) | 157 | Some((parse, Arc::new(rev_token_map))) |
diff --git a/crates/ra_hir_expand/src/lib.rs b/crates/ra_hir_expand/src/lib.rs index 1389f64ce..126d12fbb 100644 --- a/crates/ra_hir_expand/src/lib.rs +++ b/crates/ra_hir_expand/src/lib.rs | |||
@@ -109,6 +109,7 @@ pub struct MacroFile { | |||
109 | pub enum MacroFileKind { | 109 | pub enum MacroFileKind { |
110 | Items, | 110 | Items, |
111 | Expr, | 111 | Expr, |
112 | Statements, | ||
112 | } | 113 | } |
113 | 114 | ||
114 | /// `MacroCallId` identifies a particular macro invocation, like | 115 | /// `MacroCallId` identifies a particular macro invocation, like |