@@ -255,7 +255,7 @@ pub fn in_macro(span: Span) -> bool {
255255}
256256
257257/// 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 {
259259 matches ! ( pat. kind, PatKind :: Wild )
260260}
261261
@@ -1019,8 +1019,8 @@ pub fn is_refutable(cx: &LateContext<'_>, pat: &Pat<'_>) -> bool {
10191019 )
10201020 }
10211021
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) )
10241024 }
10251025
10261026 match pat. kind {
@@ -1031,24 +1031,20 @@ pub fn is_refutable(cx: &LateContext<'_>, pat: &Pat<'_>) -> bool {
10311031 PatKind :: Path ( ref qpath) => is_enum_variant ( cx, qpath, pat. hir_id ) ,
10321032 PatKind :: Or ( pats) => {
10331033 // 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)
10351035 } ,
1036- PatKind :: Tuple ( pats, _) => are_refutable ( cx, pats. iter ( ) . map ( |pat| & * * pat ) ) ,
1036+ PatKind :: Tuple ( pats, _) => are_refutable ( cx, pats) ,
10371037 PatKind :: Struct ( ref qpath, fields, _) => {
10381038 is_enum_variant ( cx, qpath, pat. hir_id ) || are_refutable ( cx, fields. iter ( ) . map ( |field| & * field. pat ) )
10391039 } ,
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) => {
10441042 match & cx. typeck_results ( ) . node_type ( pat. hir_id ) . kind ( ) {
10451043 rustc_ty:: Slice ( ..) => {
10461044 // [..] is the only irrefutable slice pattern.
10471045 !head. is_empty ( ) || middle. is_none ( ) || !tail. is_empty ( )
10481046 } ,
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 ( ) ) ) ,
10521048 _ => {
10531049 // unreachable!()
10541050 true
@@ -1062,7 +1058,7 @@ pub fn is_refutable(cx: &LateContext<'_>, pat: &Pat<'_>) -> bool {
10621058/// the function once on the given pattern.
10631059pub fn recurse_or_patterns < ' tcx , F : FnMut ( & ' tcx Pat < ' tcx > ) > ( pat : & ' tcx Pat < ' tcx > , mut f : F ) {
10641060 if let PatKind :: Or ( pats) = pat. kind {
1065- pats. iter ( ) . copied ( ) . for_each ( f) ;
1061+ pats. iter ( ) . for_each ( f) ;
10661062 } else {
10671063 f ( pat) ;
10681064 }
0 commit comments