Skip to content

Commit c16e4f2

Browse files
committed
Add syntax fixup for loop
1 parent a969481 commit c16e4f2

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

crates/hir-expand/src/fixup.rs

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,26 @@ pub(crate) fn fixup_syntax(node: &SyntaxNode) -> SyntaxFixups {
175175
]);
176176
}
177177
},
178+
ast::LoopExpr(it) => {
179+
if it.loop_body().is_none() {
180+
append.insert(node.clone().into(), vec![
181+
SyntheticToken {
182+
kind: SyntaxKind::L_CURLY,
183+
text: "{".into(),
184+
range: end_range,
185+
id: EMPTY_ID,
186+
},
187+
SyntheticToken {
188+
kind: SyntaxKind::R_CURLY,
189+
text: "}".into(),
190+
range: end_range,
191+
id: EMPTY_ID,
192+
},
193+
]);
194+
}
195+
},
178196
// FIXME: foo::
179-
// FIXME: for, loop, match etc.
197+
// FIXME: for, match etc.
180198
_ => (),
181199
}
182200
}
@@ -450,6 +468,20 @@ fn foo() {
450468
"#,
451469
expect![[r#"
452470
fn foo () {while __ra_fixup {}}
471+
"#]],
472+
)
473+
}
474+
475+
#[test]
476+
fn fixup_loop() {
477+
check(
478+
r#"
479+
fn foo() {
480+
loop
481+
}
482+
"#,
483+
expect![[r#"
484+
fn foo () {loop {}}
453485
"#]],
454486
)
455487
}

0 commit comments

Comments
 (0)