@@ -54,11 +54,11 @@ impl LateLintPass<'_> for BorrowDerefRef {
54
54
fn check_expr ( & mut self , cx : & LateContext < ' tcx > , e : & ' tcx rustc_hir:: Expr < ' _ > ) {
55
55
if_chain ! {
56
56
if !e. span. from_expansion( ) ;
57
- if let ExprKind :: AddrOf ( _, Mutability :: Not , addrof_expr ) = e. kind;
58
- if let ExprKind :: Unary ( UnOp :: Deref , deref_expr ) = addrof_expr . kind;
59
- if !deref_expr . span. from_expansion( ) ;
60
- if !matches!( deref_expr . kind, ExprKind :: Unary ( UnOp :: Deref , ..) ) ;
61
- let ref_ty = cx. typeck_results( ) . expr_ty( deref_expr ) ;
57
+ if let ExprKind :: AddrOf ( _, Mutability :: Not , addrof_target ) = e. kind;
58
+ if let ExprKind :: Unary ( UnOp :: Deref , deref_target ) = addrof_target . kind;
59
+ if !deref_target . span. from_expansion( ) ;
60
+ if !matches!( deref_target . kind, ExprKind :: Unary ( UnOp :: Deref , ..) ) ;
61
+ let ref_ty = cx. typeck_results( ) . expr_ty( deref_target ) ;
62
62
if let ty:: Ref ( _, inner_ty, Mutability :: Not ) = ref_ty. kind( ) ;
63
63
then{
64
64
@@ -68,7 +68,7 @@ impl LateLintPass<'_> for BorrowDerefRef {
68
68
if span. from_expansion( ) {
69
69
return ;
70
70
}
71
- if matches!( deref_expr . kind, ExprKind :: Path ( ..) | ExprKind :: Field ( ..) ) {
71
+ if matches!( deref_target . kind, ExprKind :: Path ( ..) | ExprKind :: Field ( ..) ) {
72
72
if let Some ( rustc_hir:: Node :: Expr ( parent_expr) ) = map. find( parent_hir_id) {
73
73
if matches!( parent_expr. kind, ExprKind :: AddrOf ( _, Mutability :: Mut , _) ) {
74
74
return ;
@@ -90,7 +90,7 @@ impl LateLintPass<'_> for BorrowDerefRef {
90
90
diag. help(
91
91
& format!(
92
92
"consider using `{}` if you would like to reborrow" ,
93
- & snippet_opt( cx, deref_expr . span) . unwrap( ) ,
93
+ & snippet_opt( cx, deref_target . span) . unwrap( ) ,
94
94
)
95
95
) ;
96
96
@@ -105,7 +105,7 @@ impl LateLintPass<'_> for BorrowDerefRef {
105
105
diag. help(
106
106
& format!(
107
107
"consider using `&**{}` if you would like to deref" ,
108
- & snippet_opt( cx, deref_expr . span) . unwrap( ) ,
108
+ & snippet_opt( cx, deref_target . span) . unwrap( ) ,
109
109
)
110
110
) ;
111
111
0 commit comments