about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJake Heinz <jh@discordapp.com>2021-11-27 02:22:21 +0000
committerJake Heinz <jh@discordapp.com>2021-11-27 02:22:21 +0000
commitdca8f612d0522aecad27f0f5053987b3e5c6b3e2 (patch)
tree5300b8e008b7d5d0bf4c9422d8a10004b28dd427
parent9f447ad522a2e7464d827d5b51cdeb53a90c91f5 (diff)
downloadrust-dca8f612d0522aecad27f0f5053987b3e5c6b3e2.tar.gz
rust-dca8f612d0522aecad27f0f5053987b3e5c6b3e2.zip
ide: fix expansion for 'as _'
-rw-r--r--crates/ide/src/expand_macro.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/crates/ide/src/expand_macro.rs b/crates/ide/src/expand_macro.rs
index 57c078ef57d..ee49732240e 100644
--- a/crates/ide/src/expand_macro.rs
+++ b/crates/ide/src/expand_macro.rs
@@ -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));
@@ -211,6 +215,23 @@ mod tests {
     }
 
     #[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(
             r#"