aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_mbe/src/lib.rs24
-rw-r--r--crates/ra_mbe/src/mbe_expander.rs4
2 files changed, 28 insertions, 0 deletions
diff --git a/crates/ra_mbe/src/lib.rs b/crates/ra_mbe/src/lib.rs
index d7462d09d..ae8a62036 100644
--- a/crates/ra_mbe/src/lib.rs
+++ b/crates/ra_mbe/src/lib.rs
@@ -762,4 +762,28 @@ MACRO_ITEMS@[0; 40)
762 r#"# [cfg (target_os = "windows")] fn bar () {}"#, 762 r#"# [cfg (target_os = "windows")] fn bar () {}"#,
763 ); 763 );
764 } 764 }
765
766 #[test]
767 fn test_tt_block() {
768 let rules = create_rules(
769 r#"
770 macro_rules! foo {
771 ($ i:tt) => { fn foo() $ i }
772 }
773"#,
774 );
775 assert_expansion(&rules, r#"foo! { { 1; } }"#, r#"fn foo () {1 ;}"#);
776 }
777
778 #[test]
779 fn test_tt_group() {
780 let rules = create_rules(
781 r#"
782 macro_rules! foo {
783 ($($ i:tt)*) => { $($ i)* }
784 }
785"#,
786 );
787 assert_expansion(&rules, r#"foo! { fn foo() {} }"#, r#"fn foo () {}"#);
788 }
765} 789}
diff --git a/crates/ra_mbe/src/mbe_expander.rs b/crates/ra_mbe/src/mbe_expander.rs
index 6ada580cc..4261dee8d 100644
--- a/crates/ra_mbe/src/mbe_expander.rs
+++ b/crates/ra_mbe/src/mbe_expander.rs
@@ -171,6 +171,10 @@ fn match_lhs(pattern: &crate::Subtree, input: &mut TtCursor) -> Result<Bindings,
171 input.eat_meta().ok_or(ExpandError::UnexpectedToken)?.clone(); 171 input.eat_meta().ok_or(ExpandError::UnexpectedToken)?.clone();
172 res.inner.insert(text.clone(), Binding::Simple(meta.into())); 172 res.inner.insert(text.clone(), Binding::Simple(meta.into()));
173 } 173 }
174 "tt" => {
175 let token = input.eat().ok_or(ExpandError::UnexpectedToken)?.clone();
176 res.inner.insert(text.clone(), Binding::Simple(token.into()));
177 }
174 "item" => { 178 "item" => {
175 let item = 179 let item =
176 input.eat_item().ok_or(ExpandError::UnexpectedToken)?.clone(); 180 input.eat_item().ok_or(ExpandError::UnexpectedToken)?.clone();