Unnamed repository; edit this file 'description' to name the repository.
| -rw-r--r-- | crates/ide/src/expand_macro.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/crates/ide/src/expand_macro.rs b/crates/ide/src/expand_macro.rs index 57c078ef57..ee49732240 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#" |