diff options
Diffstat (limited to 'crates/ra_mbe/src')
-rw-r--r-- | crates/ra_mbe/src/lib.rs | 24 | ||||
-rw-r--r-- | crates/ra_mbe/src/mbe_expander.rs | 5 |
2 files changed, 29 insertions, 0 deletions
diff --git a/crates/ra_mbe/src/lib.rs b/crates/ra_mbe/src/lib.rs index 6b648e7af..6f719acbf 100644 --- a/crates/ra_mbe/src/lib.rs +++ b/crates/ra_mbe/src/lib.rs | |||
@@ -232,4 +232,28 @@ impl_froms!(TokenTree: Leaf, Subtree); | |||
232 | assert_expansion(&rules, "foo! { bar = }", "fn bar () {}"); | 232 | assert_expansion(&rules, "foo! { bar = }", "fn bar () {}"); |
233 | assert_expansion(&rules, "foo! { Baz + }", "struct Baz ;"); | 233 | assert_expansion(&rules, "foo! { Baz + }", "struct Baz ;"); |
234 | } | 234 | } |
235 | |||
236 | #[test] | ||
237 | fn test_fail_match_pattern_by_word_token() { | ||
238 | let rules = create_rules( | ||
239 | r#" | ||
240 | macro_rules! foo { | ||
241 | ($ i:ident) => ( | ||
242 | mod $ i {} | ||
243 | ); | ||
244 | (spam $ i:ident) => ( | ||
245 | fn $ i() {} | ||
246 | ); | ||
247 | (eggs $ i:ident) => ( | ||
248 | struct $ i; | ||
249 | ) | ||
250 | } | ||
251 | "#, | ||
252 | ); | ||
253 | |||
254 | assert_expansion(&rules, "foo! { foo }", "mod foo {}"); | ||
255 | assert_expansion(&rules, "foo! { spam bar }", "fn bar () {}"); | ||
256 | assert_expansion(&rules, "foo! { eggs Baz }", "struct Baz ;"); | ||
257 | } | ||
258 | |||
235 | } | 259 | } |
diff --git a/crates/ra_mbe/src/mbe_expander.rs b/crates/ra_mbe/src/mbe_expander.rs index 2945e7359..212e2ea92 100644 --- a/crates/ra_mbe/src/mbe_expander.rs +++ b/crates/ra_mbe/src/mbe_expander.rs | |||
@@ -126,6 +126,11 @@ fn match_lhs(pattern: &crate::Subtree, input: &mut TtCursor) -> Option<Bindings> | |||
126 | return None; | 126 | return None; |
127 | } | 127 | } |
128 | } | 128 | } |
129 | crate::Leaf::Ident(ident) => { | ||
130 | if input.eat_ident()?.text != ident.text { | ||
131 | return None; | ||
132 | } | ||
133 | } | ||
129 | _ => return None, | 134 | _ => return None, |
130 | }, | 135 | }, |
131 | crate::TokenTree::Repeat(crate::Repeat { | 136 | crate::TokenTree::Repeat(crate::Repeat { |