Unnamed repository; edit this file 'description' to name the repository.
Fixed up for loops, added fixme with problem
https://github.com/rust-lang/rust-analyzer/pull/12937#discussion_r937633695
fprasx 2022-08-04
parent d6d8a1c · commit ab44a81
-rw-r--r--crates/hir-expand/src/fixup.rs26
1 files changed, 15 insertions, 11 deletions
diff --git a/crates/hir-expand/src/fixup.rs b/crates/hir-expand/src/fixup.rs
index 58d73f2d6c..46257b6bc4 100644
--- a/crates/hir-expand/src/fixup.rs
+++ b/crates/hir-expand/src/fixup.rs
@@ -240,10 +240,9 @@ pub(crate) fn fixup_syntax(node: &SyntaxNode) -> SyntaxFixups {
if it.pat().is_none() && it.in_token().is_none() && it.iterable().is_none() {
append.insert(for_token.into(), vec![pat, in_token, iter]);
+ // does something funky -- see test case for_no_pat
} else if it.pat().is_none() {
append.insert(for_token.into(), vec![pat]);
- } else if it.pat().is_none() && it.in_token().is_none() {
- append.insert(for_token.into(), vec![pat, in_token]);
}
if it.loop_body().is_none() {
@@ -356,7 +355,7 @@ mod tests {
}
#[test]
- fn for_no_iter_no_body() {
+ fn just_for_token() {
check(
r#"
fn foo() {
@@ -369,11 +368,12 @@ fn foo () {for _ in __ra_fixup {}}
)
}
- fn for_no_iter_no_in() {
+ #[test]
+ fn for_no_iter_pattern() {
check(
r#"
fn foo() {
- for _ {}
+ for {}
}
"#,
expect![[r#"
@@ -381,30 +381,34 @@ fn foo () {for _ in __ra_fixup {}}
"#]],
)
}
+
#[test]
- fn for_no_iter() {
+ fn for_no_body() {
check(
r#"
fn foo() {
- for {}
+ for bar in qux
}
"#,
expect![[r#"
-fn foo () {for _ in __ra_fixup {}}
+fn foo () {for bar in qux {}}
"#]],
)
}
+ // FIXME: https://github.com/rust-lang/rust-analyzer/pull/12937#discussion_r937633695
#[test]
- fn for_no_body() {
+ fn for_no_pat() {
check(
r#"
fn foo() {
- for bar in qux
+ for in qux {
+
+ }
}
"#,
expect![[r#"
-fn foo () {for bar in qux {}}
+fn foo () {__ra_fixup}
"#]],
)
}