mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
return None instead of assert
This commit is contained in:
parent
ed0cf1c5fa
commit
c2dc32c48e
@ -44,10 +44,14 @@ pub(crate) fn unwrap_tuple(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option
|
|||||||
_ => return None,
|
_ => return None,
|
||||||
};
|
};
|
||||||
|
|
||||||
stdx::always!(
|
if tuple_pat.fields().count() != tuple_init.fields().count() {
|
||||||
tuple_pat.fields().count() == tuple_init.fields().count(),
|
return None;
|
||||||
"Length of tuples in pattern and initializer do not match"
|
}
|
||||||
);
|
if let Some(tys) = &tuple_ty {
|
||||||
|
if tuple_pat.fields().count() != tys.fields().count() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let parent = let_kw.parent()?;
|
let parent = let_kw.parent()?;
|
||||||
|
|
||||||
@ -61,11 +65,6 @@ pub(crate) fn unwrap_tuple(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option
|
|||||||
// If there is an ascribed type, insert that type for each declaration,
|
// If there is an ascribed type, insert that type for each declaration,
|
||||||
// otherwise, omit that type.
|
// otherwise, omit that type.
|
||||||
if let Some(tys) = tuple_ty {
|
if let Some(tys) = tuple_ty {
|
||||||
stdx::always!(
|
|
||||||
tuple_pat.fields().count() == tys.fields().count(),
|
|
||||||
"Length of tuples in patterns and type do not match"
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut zipped_decls = String::new();
|
let mut zipped_decls = String::new();
|
||||||
for (pat, ty, expr) in
|
for (pat, ty, expr) in
|
||||||
itertools::izip!(tuple_pat.fields(), tys.fields(), tuple_init.fields())
|
itertools::izip!(tuple_pat.fields(), tys.fields(), tuple_init.fields())
|
||||||
|
Loading…
Reference in New Issue
Block a user