@@ -22,7 +22,6 @@ pub(super) fn check<'tcx>(
22
22
let mut applicability = Applicability :: MachineApplicable ;
23
23
let expr_ty = cx. typeck_results ( ) . expr_ty ( recv) ;
24
24
let get_args_str = snippet_with_applicability ( cx, get_arg. span , ".." , & mut applicability) ;
25
- let mut needs_ref = true ;
26
25
let caller_type = if derefs_to_slice ( cx, recv, expr_ty) . is_some ( ) {
27
26
"slice"
28
27
} else if is_type_diagnostic_item ( cx, expr_ty, sym:: Vec ) {
@@ -42,8 +41,7 @@ pub(super) fn check<'tcx>(
42
41
// Handle the case where the result is immediately dereferenced,
43
42
// either directly be the user, or as a result of a method call or the like
44
43
// by not requiring an explicit reference
45
- if needs_ref
46
- && let Some ( parent) = get_parent_expr ( cx, expr)
44
+ let needs_ref = if let Some ( parent) = get_parent_expr ( cx, expr)
47
45
&& let hir:: ExprKind :: Unary ( hir:: UnOp :: Deref , _)
48
46
| hir:: ExprKind :: MethodCall ( ..)
49
47
| hir:: ExprKind :: Field ( ..)
@@ -54,8 +52,10 @@ pub(super) fn check<'tcx>(
54
52
// the span to also include the deref part
55
53
span = parent. span ;
56
54
}
57
- needs_ref = false ;
58
- }
55
+ false
56
+ } else {
57
+ true
58
+ } ;
59
59
60
60
let mut_str = if is_mut { "_mut" } else { "" } ;
61
61
let borrow_str = if !needs_ref {
0 commit comments