10870: ide: fix macro expansion for 'as _' r=Veykril a=jhgg

fixes: #10862

Co-authored-by: Jake Heinz <jh@discordapp.com>
This commit is contained in:
bors[bot] 2021-11-27 02:29:54 +00:00 committed by GitHub
commit 90c435519d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -176,6 +176,10 @@ fn insert_whitespaces(syn: SyntaxNode) -> String {
res.push_str(token.text());
res.push(' ');
}
AS_KW => {
res.push_str(token.text());
res.push(' ');
}
T![;] => {
res.push_str(";\n");
res.extend(iter::repeat(" ").take(2 * indent));
@ -210,6 +214,23 @@ mod tests {
expect.assert_eq(&actual);
}
#[test]
fn macro_expand_as_keyword() {
check(
r#"
macro_rules! bar {
($i:tt) => { $i as _ }
}
fn main() {
let x: u64 = ba$0r!(5i64);
}
"#,
expect![[r#"
bar
5i64 as _"#]],
);
}
#[test]
fn macro_expand_recursive_expansion() {
check(