mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-29 05:14:18 +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: foo::
|
||||||
// FIXME: for, loop, match etc.
|
// FIXME: for, match etc.
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -450,6 +468,20 @@ fn foo() {
|
||||||
"#,
|
"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
fn foo () {while __ra_fixup {}}
|
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