aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_mbe
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-12-19 13:45:10 +0000
committerGitHub <[email protected]>2019-12-19 13:45:10 +0000
commite17dcc45a679c025e79639bd2d22c3b0f20953f9 (patch)
tree15bfa093d9decc4425d5763a4f912a5ecd07d482 /crates/ra_mbe
parent8dd0e0086fc07422c9b1044b1db021cff6563214 (diff)
parent5c3c2b869085a26187c0f7c7bcd4ee58bc1075a9 (diff)
Merge #2595
2595: Fix parsing of interpolated expressions r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_mbe')
-rw-r--r--crates/ra_mbe/src/tests.rs18
1 files changed, 18 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 =