@@ -54,11 +54,11 @@ impl LateLintPass<'_> for BorrowDerefRef {
5454 fn check_expr ( & mut self , cx : & LateContext < ' tcx > , e : & ' tcx rustc_hir:: Expr < ' _ > ) {
5555 if_chain ! {
5656 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 ) ;
6262 if let ty:: Ref ( _, inner_ty, Mutability :: Not ) = ref_ty. kind( ) ;
6363 then{
6464
@@ -68,7 +68,7 @@ impl LateLintPass<'_> for BorrowDerefRef {
6868 if span. from_expansion( ) {
6969 return ;
7070 }
71- if matches!( deref_expr . kind, ExprKind :: Path ( ..) | ExprKind :: Field ( ..) ) {
71+ if matches!( deref_target . kind, ExprKind :: Path ( ..) | ExprKind :: Field ( ..) ) {
7272 if let Some ( rustc_hir:: Node :: Expr ( parent_expr) ) = map. find( parent_hir_id) {
7373 if matches!( parent_expr. kind, ExprKind :: AddrOf ( _, Mutability :: Mut , _) ) {
7474 return ;
@@ -90,7 +90,7 @@ impl LateLintPass<'_> for BorrowDerefRef {
9090 diag. help(
9191 & format!(
9292 "consider using `{}` if you would like to reborrow" ,
93- & snippet_opt( cx, deref_expr . span) . unwrap( ) ,
93+ & snippet_opt( cx, deref_target . span) . unwrap( ) ,
9494 )
9595 ) ;
9696
@@ -105,7 +105,7 @@ impl LateLintPass<'_> for BorrowDerefRef {
105105 diag. help(
106106 & format!(
107107 "consider using `&**{}` if you would like to deref" ,
108- & snippet_opt( cx, deref_expr . span) . unwrap( ) ,
108+ & snippet_opt( cx, deref_target . span) . unwrap( ) ,
109109 )
110110 ) ;
111111
0 commit comments