Unnamed repository; edit this file 'description' to name the repository.
Merge #11609
11609: Add another case to the syntax fixup code r=flodiebold a=flodiebold Co-authored-by: Florian Diebold <[email protected]>
bors[bot] 2022-03-04
parent a55dd29 · parent ac51eea · commit f470f35
-rw-r--r--crates/hir_expand/src/fixup.rs40
1 files changed, 40 insertions, 0 deletions
diff --git a/crates/hir_expand/src/fixup.rs b/crates/hir_expand/src/fixup.rs
index 2eb3da79dc..63ab5e9b4a 100644
--- a/crates/hir_expand/src/fixup.rs
+++ b/crates/hir_expand/src/fixup.rs
@@ -97,6 +97,18 @@ pub(crate) fn fixup_syntax(node: &SyntaxNode) -> SyntaxFixups {
]);
}
},
+ ast::LetStmt(it) => {
+ if it.semicolon_token().is_none() {
+ append.insert(node.clone(), vec![
+ SyntheticToken {
+ kind: SyntaxKind::SEMICOLON,
+ text: ";".into(),
+ range: end_range,
+ id: EMPTY_ID,
+ },
+ ]);
+ }
+ },
_ => (),
}
}
@@ -230,6 +242,34 @@ fn foo () {a . __ra_fixup ; bar () ;}
}
#[test]
+ fn incomplete_let() {
+ check(
+ r#"
+fn foo() {
+ let x = a
+}
+"#,
+ expect![[r#"
+fn foo () {let x = a ;}
+"#]],
+ )
+ }
+
+ #[test]
+ fn incomplete_field_expr_in_let() {
+ check(
+ r#"
+fn foo() {
+ let x = a.
+}
+"#,
+ expect![[r#"
+fn foo () {let x = a . __ra_fixup ;}
+"#]],
+ )
+ }
+
+ #[test]
fn field_expr_before_call() {
// another case that easily happens while typing
check(