aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_mbe/src/tests.rs18
-rw-r--r--crates/ra_parser/src/grammar/expressions/atom.rs1
2 files changed, 19 insertions, 0 deletions
diff --git a/crates/ra_mbe/src/tests.rs b/crates/ra_mbe/src/tests.rs
index ff225f0db..b5a10a9d2 100644
--- a/crates/ra_mbe/src/tests.rs
+++ b/crates/ra_mbe/src/tests.rs
@@ -1450,6 +1450,24 @@ macro_rules! delegate_impl {
1450 ); 1450 );
1451} 1451}
1452 1452
1453#[test]
1454fn expr_interpolation() {
1455 let rules = create_rules(
1456 r#"
1457 macro_rules! id {
1458 ($expr:expr) => {
1459 map($expr)
1460 }
1461 }
1462 "#,
1463 );
1464
1465 let expanded = expand(&rules, "id!(x + foo);");
1466 let expanded =
1467 token_tree_to_syntax_node(&expanded, FragmentKind::Expr).unwrap().0.syntax_node();
1468 assert_eq!(expanded.to_string(), "map(x+foo)");
1469}
1470
1453pub(crate) fn create_rules(macro_definition: &str) -> MacroRules { 1471pub(crate) fn create_rules(macro_definition: &str) -> MacroRules {
1454 let source_file = ast::SourceFile::parse(macro_definition).ok().unwrap(); 1472 let source_file = ast::SourceFile::parse(macro_definition).ok().unwrap();
1455 let macro_definition = 1473 let macro_definition =
diff --git a/crates/ra_parser/src/grammar/expressions/atom.rs b/crates/ra_parser/src/grammar/expressions/atom.rs
index 09f0a2d98..6f5545a83 100644
--- a/crates/ra_parser/src/grammar/expressions/atom.rs
+++ b/crates/ra_parser/src/grammar/expressions/atom.rs
@@ -43,6 +43,7 @@ pub(super) const ATOM_EXPR_FIRST: TokenSet =
43 T!['('], 43 T!['('],
44 T!['{'], 44 T!['{'],
45 T!['['], 45 T!['['],
46 L_DOLLAR,
46 T![|], 47 T![|],
47 T![move], 48 T![move],
48 T![box], 49 T![box],