Skip to content

Commit 7ec32d0

Browse files
committed
Remove letelse control flow snippets
1 parent 51d57b9 commit 7ec32d0

File tree

1 file changed

+3
-43
lines changed

1 file changed

+3
-43
lines changed

crates/ide-completion/src/completions/postfix.rs

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,6 @@ pub(crate) fn complete_postfix(
7575

7676
let try_enum = TryEnum::from_ty(&ctx.sema, &receiver_ty.strip_references());
7777
if let Some(try_enum) = &try_enum {
78-
let in_loop = dot_receiver
79-
.syntax()
80-
.ancestors()
81-
.any(|n| matches!(n.kind(), WHILE_EXPR | LOOP_EXPR | FOR_EXPR));
82-
8378
match try_enum {
8479
TryEnum::Result => {
8580
postfix_snippet(
@@ -92,11 +87,7 @@ pub(crate) fn complete_postfix(
9287
postfix_snippet(
9388
"lete",
9489
"let Ok else {}",
95-
&if in_loop {
96-
format!("let Ok($1) = {receiver_text} else {{\n ${{2|continue,break,return|}};\n}};\n$0")
97-
} else {
98-
format!("let Ok($1) = {receiver_text} else {{\n ${{2:return}};\n}};\n$0")
99-
},
90+
&format!("let Ok($1) = {receiver_text} else {{\n $2\n}};\n$0"),
10091
)
10192
.add_to(acc, ctx.db);
10293

@@ -118,11 +109,7 @@ pub(crate) fn complete_postfix(
118109
postfix_snippet(
119110
"lete",
120111
"let Some else {}",
121-
&if in_loop {
122-
format!("let Some($1) = {receiver_text} else {{\n ${{2|continue,break,return|}};\n}};\n$0")
123-
} else {
124-
format!("let Some($1) = {receiver_text} else {{\n ${{2:return}};\n}};\n$0")
125-
},
112+
&format!("let Some($1) = {receiver_text} else {{\n $2\n}};\n$0"),
126113
)
127114
.add_to(acc, ctx.db);
128115

@@ -511,36 +498,9 @@ fn main() {
511498
fn main() {
512499
let bar = Some(true);
513500
let Some($1) = bar else {
514-
${2:return};
515-
};
516-
$0
517-
}
518-
"#,
519-
);
520-
}
521-
522-
#[test]
523-
fn option_letelse_loop() {
524-
check_edit(
525-
"lete",
526-
r#"
527-
//- minicore: option
528-
fn main() {
529-
let bar = Some(true);
530-
loop {
531-
bar.$0
532-
}
533-
}
534-
"#,
535-
r#"
536-
fn main() {
537-
let bar = Some(true);
538-
loop {
539-
let Some($1) = bar else {
540-
${2|continue,break,return|};
501+
$2
541502
};
542503
$0
543-
}
544504
}
545505
"#,
546506
);

0 commit comments

Comments
 (0)