11609: Add another case to the syntax fixup code r=flodiebold a=flodiebold



Co-authored-by: Florian Diebold <flodiebold@gmail.com>
This commit is contained in:
bors[bot] 2022-03-03 17:34:00 +00:00 committed by GitHub
commit f470f35abf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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] #[test]
fn field_expr_before_call() { fn field_expr_before_call() {
// another case that easily happens while typing // another case that easily happens while typing