about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--crates/hir-expand/src/fixup.rs34
1 files changed, 33 insertions, 1 deletions
diff --git a/crates/hir-expand/src/fixup.rs b/crates/hir-expand/src/fixup.rs
index 6d0766020bd..e46f43a878f 100644
--- a/crates/hir-expand/src/fixup.rs
+++ b/crates/hir-expand/src/fixup.rs
@@ -175,8 +175,26 @@ pub(crate) fn fixup_syntax(node: &SyntaxNode) -> SyntaxFixups {
                         ]);
                     }
                 },
+                ast::LoopExpr(it) => {
+                    if it.loop_body().is_none() {
+                        append.insert(node.clone().into(), vec![
+                            SyntheticToken {
+                                kind: SyntaxKind::L_CURLY,
+                                text: "{".into(),
+                                range: end_range,
+                                id: EMPTY_ID,
+                            },
+                            SyntheticToken {
+                                kind: SyntaxKind::R_CURLY,
+                                text: "}".into(),
+                                range: end_range,
+                                id: EMPTY_ID,
+                            },
+                        ]);
+                    }
+                },
                 // FIXME: foo::
-                // FIXME: for, loop, match etc.
+                // FIXME: for, match etc.
                 _ => (),
             }
         }
@@ -453,4 +471,18 @@ fn foo () {while __ra_fixup {}}
 "#]],
         )
     }
+
+    #[test]
+    fn fixup_loop() {
+        check(
+            r#"
+fn foo() {
+    loop
+}
+"#,
+            expect![[r#"
+fn foo () {loop {}}
+"#]],
+        )
+    }
 }