Skip to content

Commit c2dc32c

Browse files
committed
return None instead of assert
1 parent ed0cf1c commit c2dc32c

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,14 @@ pub(crate) fn unwrap_tuple(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option
4444
_ => return None,
4545
};
4646

47-
stdx::always!(
48-
tuple_pat.fields().count() == tuple_init.fields().count(),
49-
"Length of tuples in pattern and initializer do not match"
50-
);
47+
if tuple_pat.fields().count() != tuple_init.fields().count() {
48+
return None;
49+
}
50+
if let Some(tys) = &tuple_ty {
51+
if tuple_pat.fields().count() != tys.fields().count() {
52+
return None;
53+
}
54+
}
5155

5256
let parent = let_kw.parent()?;
5357

@@ -61,11 +65,6 @@ pub(crate) fn unwrap_tuple(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option
6165
// If there is an ascribed type, insert that type for each declaration,
6266
// otherwise, omit that type.
6367
if let Some(tys) = tuple_ty {
64-
stdx::always!(
65-
tuple_pat.fields().count() == tys.fields().count(),
66-
"Length of tuples in patterns and type do not match"
67-
);
68-
6968
let mut zipped_decls = String::new();
7069
for (pat, ty, expr) in
7170
itertools::izip!(tuple_pat.fields(), tys.fields(), tuple_init.fields())

0 commit comments

Comments
 (0)