@@ -255,7 +255,7 @@ pub fn in_macro(span: Span) -> bool {
255
255
}
256
256
257
257
/// Checks if given pattern is a wildcard (`_`)
258
- pub fn is_wild < ' tcx > ( pat : & impl std :: ops :: Deref < Target = Pat < ' tcx > > ) -> bool {
258
+ pub fn is_wild ( pat : & Pat < ' _ > ) -> bool {
259
259
matches ! ( pat. kind, PatKind :: Wild )
260
260
}
261
261
@@ -1019,8 +1019,8 @@ pub fn is_refutable(cx: &LateContext<'_>, pat: &Pat<'_>) -> bool {
1019
1019
)
1020
1020
}
1021
1021
1022
- fn are_refutable < ' a , I : Iterator < Item = & ' a Pat < ' a > > > ( cx : & LateContext < ' _ > , mut i : I ) -> bool {
1023
- i. any ( |pat| is_refutable ( cx, pat) )
1022
+ fn are_refutable < ' a , I : IntoIterator < Item = & ' a Pat < ' a > > > ( cx : & LateContext < ' _ > , i : I ) -> bool {
1023
+ i. into_iter ( ) . any ( |pat| is_refutable ( cx, pat) )
1024
1024
}
1025
1025
1026
1026
match pat. kind {
@@ -1031,24 +1031,20 @@ pub fn is_refutable(cx: &LateContext<'_>, pat: &Pat<'_>) -> bool {
1031
1031
PatKind :: Path ( ref qpath) => is_enum_variant ( cx, qpath, pat. hir_id ) ,
1032
1032
PatKind :: Or ( pats) => {
1033
1033
// TODO: should be the honest check, that pats is exhaustive set
1034
- are_refutable ( cx, pats. iter ( ) . map ( |pat| & * * pat ) )
1034
+ are_refutable ( cx, pats)
1035
1035
} ,
1036
- PatKind :: Tuple ( pats, _) => are_refutable ( cx, pats. iter ( ) . map ( |pat| & * * pat ) ) ,
1036
+ PatKind :: Tuple ( pats, _) => are_refutable ( cx, pats) ,
1037
1037
PatKind :: Struct ( ref qpath, fields, _) => {
1038
1038
is_enum_variant ( cx, qpath, pat. hir_id ) || are_refutable ( cx, fields. iter ( ) . map ( |field| & * field. pat ) )
1039
1039
} ,
1040
- PatKind :: TupleStruct ( ref qpath, pats, _) => {
1041
- is_enum_variant ( cx, qpath, pat. hir_id ) || are_refutable ( cx, pats. iter ( ) . map ( |pat| & * * pat) )
1042
- } ,
1043
- PatKind :: Slice ( head, ref middle, tail) => {
1040
+ PatKind :: TupleStruct ( ref qpath, pats, _) => is_enum_variant ( cx, qpath, pat. hir_id ) || are_refutable ( cx, pats) ,
1041
+ PatKind :: Slice ( head, middle, tail) => {
1044
1042
match & cx. typeck_results ( ) . node_type ( pat. hir_id ) . kind ( ) {
1045
1043
rustc_ty:: Slice ( ..) => {
1046
1044
// [..] is the only irrefutable slice pattern.
1047
1045
!head. is_empty ( ) || middle. is_none ( ) || !tail. is_empty ( )
1048
1046
} ,
1049
- rustc_ty:: Array ( ..) => {
1050
- are_refutable ( cx, head. iter ( ) . chain ( middle) . chain ( tail. iter ( ) ) . map ( |pat| & * * pat) )
1051
- } ,
1047
+ rustc_ty:: Array ( ..) => are_refutable ( cx, head. iter ( ) . chain ( middle) . chain ( tail. iter ( ) ) ) ,
1052
1048
_ => {
1053
1049
// unreachable!()
1054
1050
true
@@ -1062,7 +1058,7 @@ pub fn is_refutable(cx: &LateContext<'_>, pat: &Pat<'_>) -> bool {
1062
1058
/// the function once on the given pattern.
1063
1059
pub fn recurse_or_patterns < ' tcx , F : FnMut ( & ' tcx Pat < ' tcx > ) > ( pat : & ' tcx Pat < ' tcx > , mut f : F ) {
1064
1060
if let PatKind :: Or ( pats) = pat. kind {
1065
- pats. iter ( ) . copied ( ) . for_each ( f) ;
1061
+ pats. iter ( ) . for_each ( f) ;
1066
1062
} else {
1067
1063
f ( pat) ;
1068
1064
}
0 commit comments