@@ -126,6 +126,7 @@ use rustc_span::{InnerSpan, Span};
126
126
use source:: { SpanRangeExt , walk_span_to_context} ;
127
127
use visitors:: { Visitable , for_each_unconsumed_temporary} ;
128
128
129
+ use crate :: ast_utils:: unordered_over;
129
130
use crate :: consts:: { ConstEvalCtxt , Constant , mir_to_const} ;
130
131
use crate :: higher:: Range ;
131
132
use crate :: ty:: { adt_and_variant_of_res, can_partially_move_ty, expr_sig, is_copy, is_recursively_primitive_type} ;
@@ -1992,7 +1993,7 @@ pub fn is_expr_identity_of_pat(cx: &LateContext<'_>, pat: &Pat<'_>, expr: &Expr<
1992
1993
( PatKind :: Tuple ( pats, dotdot) , ExprKind :: Tup ( tup) )
1993
1994
if dotdot. as_opt_usize ( ) . is_none ( ) && pats. len ( ) == tup. len ( ) =>
1994
1995
{
1995
- zip ( pats, tup) . all ( | ( pat, expr) | is_expr_identity_of_pat ( cx, pat, expr, by_hir) )
1996
+ over ( pats, tup, | pat, expr| is_expr_identity_of_pat ( cx, pat, expr, by_hir) )
1996
1997
} ,
1997
1998
( PatKind :: Slice ( before, None , after) , ExprKind :: Array ( arr) ) if before. len ( ) + after. len ( ) == arr. len ( ) => {
1998
1999
zip ( before. iter ( ) . chain ( after) , arr) . all ( |( pat, expr) | is_expr_identity_of_pat ( cx, pat, expr, by_hir) )
@@ -2004,7 +2005,7 @@ pub fn is_expr_identity_of_pat(cx: &LateContext<'_>, pat: &Pat<'_>, expr: &Expr<
2004
2005
if let ExprKind :: Path ( ident) = & ident. kind
2005
2006
&& qpath_res ( & pat_ident, pat. hir_id ) == qpath_res ( ident, expr. hir_id )
2006
2007
// check fields
2007
- && zip ( field_pats, fields) . all ( | ( pat, expr) | is_expr_identity_of_pat ( cx, pat, expr, by_hir) )
2008
+ && over ( field_pats, fields, | pat, expr| is_expr_identity_of_pat ( cx, pat, expr, by_hir) )
2008
2009
{
2009
2010
true
2010
2011
} else {
@@ -2017,10 +2018,8 @@ pub fn is_expr_identity_of_pat(cx: &LateContext<'_>, pat: &Pat<'_>, expr: &Expr<
2017
2018
// check ident
2018
2019
qpath_res ( & pat_ident, pat. hir_id ) == qpath_res ( ident, expr. hir_id )
2019
2020
// check fields
2020
- && field_pats. iter ( ) . all ( |field_pat| {
2021
- fields. iter ( ) . any ( |field| {
2022
- field_pat. ident == field. ident && is_expr_identity_of_pat ( cx, field_pat. pat , field. expr , by_hir)
2023
- } )
2021
+ && unordered_over ( field_pats, fields, |field_pat, field| {
2022
+ field_pat. ident == field. ident && is_expr_identity_of_pat ( cx, field_pat. pat , field. expr , by_hir)
2024
2023
} )
2025
2024
} ,
2026
2025
_ => false ,
0 commit comments