diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-04-25 19:59:34 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-04-25 19:59:34 +0100 |
commit | 42c4e0f378faeabd425392d4a7a7839bd7e8ac2f (patch) | |
tree | f48081403383b7a00a3c297b2ff24a7c11ddd07e /crates/ra_hir/src | |
parent | 5bbd9f43cc217a44445fde91b4b53ca85d78cd92 (diff) | |
parent | 1908819bf6432016527f4bd3b0f22500b85cab5f (diff) |
Merge #1209
1209: Bugs fixes And Improvements of MBE r=matklad a=edwin0cheng
This PR fixed / improve followings things:
* Add `token` `$repeat` separator support: Previously $repeat only support single punct separator.
* Fixed a bug which expand infinite pattern, see `test_match_group_in_group`
* Correctly handle +,*,? case of $repeat patterns
* Increase the limit of $repeat patterns (128 => 65536), personally i think we could remove this limit as we seem to fix all major loop bugs
* **Re-enable tt matcher**
* Better meta item parsing.
* Add related tests and add some real world test cases.
* Add more debug information.
Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r-- | crates/ra_hir/src/ids.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs index c7849c995..b0e9b1f9a 100644 --- a/crates/ra_hir/src/ids.rs +++ b/crates/ra_hir/src/ids.rs | |||
@@ -128,8 +128,14 @@ pub struct MacroDefId(pub(crate) AstId<ast::MacroCall>); | |||
128 | pub(crate) fn macro_def_query(db: &impl DefDatabase, id: MacroDefId) -> Option<Arc<MacroRules>> { | 128 | pub(crate) fn macro_def_query(db: &impl DefDatabase, id: MacroDefId) -> Option<Arc<MacroRules>> { |
129 | let macro_call = id.0.to_node(db); | 129 | let macro_call = id.0.to_node(db); |
130 | let arg = macro_call.token_tree()?; | 130 | let arg = macro_call.token_tree()?; |
131 | let (tt, _) = mbe::ast_to_token_tree(arg)?; | 131 | let (tt, _) = mbe::ast_to_token_tree(arg).or_else(|| { |
132 | let rules = MacroRules::parse(&tt).ok()?; | 132 | log::warn!("fail on macro_def to token tree: {:#?}", arg); |
133 | None | ||
134 | })?; | ||
135 | let rules = MacroRules::parse(&tt).ok().or_else(|| { | ||
136 | log::warn!("fail on macro_def parse: {:#?}", tt); | ||
137 | None | ||
138 | })?; | ||
133 | Some(Arc::new(rules)) | 139 | Some(Arc::new(rules)) |
134 | } | 140 | } |
135 | 141 | ||