diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-03-03 17:34:00 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-03 17:34:00 +0000 |
| commit | f470f35abf0f3a33310114a64231871ba7e51f82 (patch) | |
| tree | 18e38046bcb17c59458f42522620a84a4091265d | |
| parent | a55dd29e88c6f2aa37c39b790ab7036596e74686 (diff) | |
| parent | ac51eea3094561253a84a90a8af1683eb64d43f0 (diff) | |
| download | rust-f470f35abf0f3a33310114a64231871ba7e51f82.tar.gz rust-f470f35abf0f3a33310114a64231871ba7e51f82.zip | |
Merge #11609
11609: Add another case to the syntax fixup code r=flodiebold a=flodiebold Co-authored-by: Florian Diebold <flodiebold@gmail.com>
| -rw-r--r-- | crates/hir_expand/src/fixup.rs | 40 |
1 files changed, 40 insertions, 0 deletions
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, + }, + ]); + } + }, _ => (), } } @@ -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( |
