File tree 2 files changed +21
-3
lines changed
ide-db/src/syntax_helpers
2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ pub fn insert_ws_into(syn: SyntaxNode) -> SyntaxNode {
57
57
|f : fn ( SyntaxKind ) -> bool , default| -> bool { last. map ( f) . unwrap_or ( default) } ;
58
58
59
59
match tok. kind ( ) {
60
- k if is_text ( k) && is_next ( |it| !it. is_punct ( ) , true ) => {
60
+ k if is_text ( k) && is_next ( |it| !it. is_punct ( ) || it == UNDERSCORE , false ) => {
61
61
mods. push ( do_ws ( after, tok) ) ;
62
62
}
63
63
L_CURLY if is_next ( |it| it != R_CURLY , true ) => {
@@ -118,5 +118,5 @@ pub fn insert_ws_into(syn: SyntaxNode) -> SyntaxNode {
118
118
}
119
119
120
120
fn is_text ( k : SyntaxKind ) -> bool {
121
- k. is_keyword ( ) || k. is_literal ( ) || k == IDENT
121
+ k. is_keyword ( ) || k. is_literal ( ) || k == IDENT || k == UNDERSCORE
122
122
}
Original file line number Diff line number Diff line change @@ -237,6 +237,24 @@ fn main() {
237
237
) ;
238
238
}
239
239
240
+ #[ test]
241
+ fn macro_expand_underscore ( ) {
242
+ check (
243
+ r#"
244
+ macro_rules! bar {
245
+ ($i:tt) => { for _ in 0..$i {} }
246
+ }
247
+ fn main() {
248
+ ba$0r!(42);
249
+ }
250
+ "# ,
251
+ expect ! [ [ r#"
252
+ bar
253
+ for _ in 0..42{}
254
+ "# ] ] ,
255
+ ) ;
256
+ }
257
+
240
258
#[ test]
241
259
fn macro_expand_recursive_expansion ( ) {
242
260
check (
@@ -385,7 +403,7 @@ fn main() {
385
403
"# ,
386
404
expect ! [ [ r#"
387
405
foo
388
- 0 "# ] ] ,
406
+ 0"# ] ] ,
389
407
) ;
390
408
}
391
409
You can’t perform that action at this time.
0 commit comments