2595: Fix parsing of interpolated expressions r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot]
2019-12-19 13:45:10 +00:00
committed by GitHub
2 changed files with 19 additions and 0 deletions
+18
View File
@@ -1450,6 +1450,24 @@ fn $method_name(self $(: $self_selftype)* $(,$marg: $marg_ty)*) -> $mret {
);
}
#[test]
fn expr_interpolation() {
let rules = create_rules(
r#"
macro_rules! id {
($expr:expr) => {
map($expr)
}
}
"#,
);
let expanded = expand(&rules, "id!(x + foo);");
let expanded =
token_tree_to_syntax_node(&expanded, FragmentKind::Expr).unwrap().0.syntax_node();
assert_eq!(expanded.to_string(), "map(x+foo)");
}
pub(crate) fn create_rules(macro_definition: &str) -> MacroRules {
let source_file = ast::SourceFile::parse(macro_definition).ok().unwrap();
let macro_definition =
@@ -43,6 +43,7 @@ pub(crate) fn literal(p: &mut Parser) -> Option<CompletedMarker> {
T!['('],
T!['{'],
T!['['],
L_DOLLAR,
T![|],
T![move],
T![box],