Skip to content

Commit d3f53e6

Browse files
committed
not lint when DEREF_ADDROF is triggered
1 parent 3372515 commit d3f53e6

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

clippy_lints/src/borrow_deref_ref.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,18 @@ impl LateLintPass<'_> for BorrowDerefRef {
6363
then{
6464

6565
if let Some(parent_expr) = get_parent_expr(cx, e){
66+
if matches!(parent_expr.kind, ExprKind::Unary(UnOp::Deref, ..)) &&
67+
!is_lint_allowed(cx, DEREF_ADDROF, parent_expr.hir_id) {
68+
return;
69+
}
70+
6671
// modification to `&mut &*x` is different from `&mut x`
6772
if matches!(deref_target.kind, ExprKind::Path(..)
68-
| ExprKind::Field(..)
69-
| ExprKind::Index(..)
70-
| ExprKind::Unary(UnOp::Deref, ..)) {
71-
if matches!(parent_expr.kind, ExprKind::AddrOf(_, Mutability::Mut, _)) {
72-
return;
73-
}
74-
if matches!(parent_expr.kind, ExprKind::Unary(UnOp::Deref, ..)) &&
75-
!is_lint_allowed(cx, DEREF_ADDROF, parent_expr.hir_id) {
76-
return;
77-
}
73+
| ExprKind::Field(..)
74+
| ExprKind::Index(..)
75+
| ExprKind::Unary(UnOp::Deref, ..))
76+
&& matches!(parent_expr.kind, ExprKind::AddrOf(_, Mutability::Mut, _)) {
77+
return;
7878
}
7979
}
8080

0 commit comments

Comments
 (0)