Skip to content

Commit 90c4355

Browse files
bors[bot]jhgg
andauthored
Merge #10870
10870: ide: fix macro expansion for 'as _' r=Veykril a=jhgg fixes: #10862 Co-authored-by: Jake Heinz <[email protected]>
2 parents 9f447ad + dca8f61 commit 90c4355

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

crates/ide/src/expand_macro.rs

+21
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ fn insert_whitespaces(syn: SyntaxNode) -> String {
176176
res.push_str(token.text());
177177
res.push(' ');
178178
}
179+
AS_KW => {
180+
res.push_str(token.text());
181+
res.push(' ');
182+
}
179183
T![;] => {
180184
res.push_str(";\n");
181185
res.extend(iter::repeat(" ").take(2 * indent));
@@ -210,6 +214,23 @@ mod tests {
210214
expect.assert_eq(&actual);
211215
}
212216

217+
#[test]
218+
fn macro_expand_as_keyword() {
219+
check(
220+
r#"
221+
macro_rules! bar {
222+
($i:tt) => { $i as _ }
223+
}
224+
fn main() {
225+
let x: u64 = ba$0r!(5i64);
226+
}
227+
"#,
228+
expect![[r#"
229+
bar
230+
5i64 as _"#]],
231+
);
232+
}
233+
213234
#[test]
214235
fn macro_expand_recursive_expansion() {
215236
check(

0 commit comments

Comments
 (0)