@@ -10,7 +10,7 @@ use crate::utils::{
1010
1111use super :: { utils, REDUNDANT_ALLOCATION } ;
1212
13- pub ( super ) fn check ( cx : & LateContext < ' _ > , hir_ty : & hir:: Ty < ' _ > , qpath : & QPath < ' _ > , def_id : DefId ) {
13+ pub ( super ) fn check ( cx : & LateContext < ' _ > , hir_ty : & hir:: Ty < ' _ > , qpath : & QPath < ' _ > , def_id : DefId ) -> bool {
1414 if Some ( def_id) == cx. tcx . lang_items ( ) . owned_box ( ) {
1515 if let Some ( span) = utils:: match_borrows_parameter ( cx, qpath) {
1616 let mut applicability = Applicability :: MachineApplicable ;
@@ -23,7 +23,7 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_
2323 snippet_with_applicability ( cx, span, ".." , & mut applicability) . to_string ( ) ,
2424 applicability,
2525 ) ;
26- return ;
26+ return true ;
2727 }
2828 }
2929
@@ -39,14 +39,15 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_
3939 snippet_with_applicability ( cx, ty. span , ".." , & mut applicability) . to_string ( ) ,
4040 applicability,
4141 ) ;
42+ true
4243 } else if let Some ( ty) = is_ty_param_lang_item ( cx, qpath, LangItem :: OwnedBox ) {
4344 let qpath = match & ty. kind {
4445 TyKind :: Path ( qpath) => qpath,
45- _ => return ,
46+ _ => return false ,
4647 } ;
4748 let inner_span = match get_qpath_generic_tys ( qpath) . next ( ) {
4849 Some ( ty) => ty. span ,
49- None => return ,
50+ None => return false ,
5051 } ;
5152 let mut applicability = Applicability :: MachineApplicable ;
5253 span_lint_and_sugg (
@@ -61,6 +62,7 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_
6162 ) ,
6263 applicability,
6364 ) ;
65+ true
6466 } else if let Some ( span) = utils:: match_borrows_parameter ( cx, qpath) {
6567 let mut applicability = Applicability :: MachineApplicable ;
6668 span_lint_and_sugg (
@@ -72,7 +74,11 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_
7274 snippet_with_applicability ( cx, span, ".." , & mut applicability) . to_string ( ) ,
7375 applicability,
7476 ) ;
75- return ; // don't recurse into the type
77+ true
78+ } else {
79+ false
7680 }
81+ } else {
82+ false
7783 }
7884}
0 commit comments