Skip to content

Commit 6f68cd3

Browse files
committed
Remove unwraps from destructure_tuple_binding
1 parent 4aaa592 commit 6f68cd3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

crates/ide-assists/src/handlers/destructure_tuple_binding.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,12 @@ fn edit_tuple_assignment(
177177

178178
if let Some(cap) = ctx.config.snippet_cap {
179179
// place cursor on first tuple name
180-
let ast::Pat::IdentPat(first_pat) = tuple_pat.fields().next().unwrap() else {
181-
unreachable!()
182-
};
183-
edit.add_tabstop_before(cap, first_pat.name().unwrap())
180+
if let Some(ast::Pat::IdentPat(first_pat)) = tuple_pat.fields().next() {
181+
edit.add_tabstop_before(
182+
cap,
183+
first_pat.name().expect("first ident pattern should have a name"),
184+
)
185+
}
184186
}
185187

186188
AssignmentEdit { ident_pat, tuple_pat, in_sub_pattern }

0 commit comments

Comments
 (0)