mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 10:13:54 +00:00
Fix parsing of interpolated expressions
This commit is contained in:
parent
8dd0e0086f
commit
5c3c2b8690
@ -1450,6 +1450,24 @@ macro_rules! delegate_impl {
|
||||
);
|
||||
}
|
||||
|
||||
#[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(super) const ATOM_EXPR_FIRST: TokenSet =
|
||||
T!['('],
|
||||
T!['{'],
|
||||
T!['['],
|
||||
L_DOLLAR,
|
||||
T![|],
|
||||
T![move],
|
||||
T![box],
|
||||
|
Loading…
Reference in New Issue
Block a user