Unnamed repository; edit this file 'description' to name the repository.
Remove unwraps from `destructure_tuple_binding`
DropDemBits 2023-11-14
parent 4aaa592 · commit 6f68cd3
-rw-r--r--crates/ide-assists/src/handlers/destructure_tuple_binding.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/crates/ide-assists/src/handlers/destructure_tuple_binding.rs b/crates/ide-assists/src/handlers/destructure_tuple_binding.rs
index 6a012d30bf..2dc30e685a 100644
--- a/crates/ide-assists/src/handlers/destructure_tuple_binding.rs
+++ b/crates/ide-assists/src/handlers/destructure_tuple_binding.rs
@@ -177,10 +177,12 @@ fn edit_tuple_assignment(
if let Some(cap) = ctx.config.snippet_cap {
// place cursor on first tuple name
- let ast::Pat::IdentPat(first_pat) = tuple_pat.fields().next().unwrap() else {
- unreachable!()
- };
- edit.add_tabstop_before(cap, first_pat.name().unwrap())
+ if let Some(ast::Pat::IdentPat(first_pat)) = tuple_pat.fields().next() {
+ edit.add_tabstop_before(
+ cap,
+ first_pat.name().expect("first ident pattern should have a name"),
+ )
+ }
}
AssignmentEdit { ident_pat, tuple_pat, in_sub_pattern }