mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-16 07:03:57 +00:00
Add syntax fixup for loop
This commit is contained in:
parent
a969481952
commit
c16e4f260f
1 changed files with 33 additions and 1 deletions
|
@ -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.
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
@ -450,6 +468,20 @@ fn foo() {
|
|||
"#,
|
||||
expect![[r#"
|
||||
fn foo () {while __ra_fixup {}}
|
||||
"#]],
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fixup_loop() {
|
||||
check(
|
||||
r#"
|
||||
fn foo() {
|
||||
loop
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
fn foo () {loop {}}
|
||||
"#]],
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue