diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-05-20 20:27:05 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-05-20 20:27:05 +0100 |
commit | 11742e33716cd9fdce08bf5501afcb793fcc59ac (patch) | |
tree | 072112a8cd2061bf1acc31aad9cfa343191d0204 /crates/ra_mbe/src/mbe_expander.rs | |
parent | c8f93ff58cf4f63d48d2258e1a4c449e043987f3 (diff) | |
parent | ad9d2012ded90a33702efedabf8f8e2c8d992975 (diff) |
Merge #1287
1287: Add support of matching literal in mbe r=matklad a=edwin0cheng
This PR adds support of matching literal in mbe , which used in our `T` macro :
```rust
macro_rules! foo {
('(') => {
fn foo() {}
}
}
```
Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_mbe/src/mbe_expander.rs')
-rw-r--r-- | crates/ra_mbe/src/mbe_expander.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/crates/ra_mbe/src/mbe_expander.rs b/crates/ra_mbe/src/mbe_expander.rs index 3a4dbb5f5..7fff8deff 100644 --- a/crates/ra_mbe/src/mbe_expander.rs +++ b/crates/ra_mbe/src/mbe_expander.rs | |||
@@ -281,7 +281,11 @@ fn match_lhs(pattern: &crate::Subtree, input: &mut TtCursor) -> Result<Bindings, | |||
281 | return Err(ExpandError::UnexpectedToken); | 281 | return Err(ExpandError::UnexpectedToken); |
282 | } | 282 | } |
283 | } | 283 | } |
284 | _ => return Err(ExpandError::UnexpectedToken), | 284 | crate::Leaf::Literal(literal) => { |
285 | if input.eat_literal().map(|i| &i.text) != Some(&literal.text) { | ||
286 | return Err(ExpandError::UnexpectedToken); | ||
287 | } | ||
288 | } | ||
285 | }, | 289 | }, |
286 | crate::TokenTree::Repeat(crate::Repeat { subtree, kind, separator }) => { | 290 | crate::TokenTree::Repeat(crate::Repeat { subtree, kind, separator }) => { |
287 | // Dirty hack to make macro-expansion terminate. | 291 | // Dirty hack to make macro-expansion terminate. |