From ac51eea3094561253a84a90a8af1683eb64d43f0 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Thu, 3 Mar 2022 18:29:40 +0100 Subject: [PATCH] Add another case to the syntax fixup code --- crates/hir_expand/src/fixup.rs | 40 ++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/crates/hir_expand/src/fixup.rs b/crates/hir_expand/src/fixup.rs index 2eb3da79dc6..63ab5e9b4a0 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, + }, + ]); + } + }, _ => (), } } @@ -229,6 +241,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