File tree 1 file changed +45
-0
lines changed 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -142,6 +142,37 @@ pub(crate) fn fixup_syntax(node: &SyntaxNode) -> SyntaxFixups {
142
142
] ) ;
143
143
}
144
144
} ,
145
+ ast:: WhileExpr ( it) => {
146
+ if it. condition( ) . is_none( ) {
147
+ // insert placeholder token after the while token
148
+ let while_token = match it. while_token( ) {
149
+ Some ( t) => t,
150
+ None => continue ,
151
+ } ;
152
+ append. insert( while_token. into( ) , vec![
153
+ SyntheticToken {
154
+ kind: SyntaxKind :: IDENT ,
155
+ text: "__ra_fixup" . into( ) ,
156
+ range: end_range,
157
+ id: EMPTY_ID ,
158
+ } ,
159
+ ] ) ;
160
+ append. insert( node. clone( ) . into( ) , vec![
161
+ SyntheticToken {
162
+ kind: SyntaxKind :: L_CURLY ,
163
+ text: "{" . into( ) ,
164
+ range: end_range,
165
+ id: EMPTY_ID ,
166
+ } ,
167
+ SyntheticToken {
168
+ kind: SyntaxKind :: R_CURLY ,
169
+ text: "}" . into( ) ,
170
+ range: end_range,
171
+ id: EMPTY_ID ,
172
+ } ,
173
+ ] ) ;
174
+ }
175
+ } ,
145
176
// FIXME: foo::
146
177
// FIXME: for, loop, match etc.
147
178
_ => ( ) ,
@@ -376,6 +407,20 @@ fn foo() {
376
407
// the {} gets parsed as the condition, I think?
377
408
expect ! [ [ r#"
378
409
fn foo () {if {} {}}
410
+ "# ] ] ,
411
+ )
412
+ }
413
+
414
+ #[ test]
415
+ fn fixup_while_1 ( ) {
416
+ check (
417
+ r#"
418
+ fn foo() {
419
+ while
420
+ }
421
+ "# ,
422
+ expect ! [ [ r#"
423
+ fn foo () {while __ra_fixup {}}
379
424
"# ] ] ,
380
425
)
381
426
}
You can’t perform that action at this time.
0 commit comments