Skip to content

Commit

Permalink
not lint when DEREF_ADDROF is triggered
Browse files Browse the repository at this point in the history
  • Loading branch information
lengyijun committed May 26, 2022
1 parent 3372515 commit d3f53e6
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions clippy_lints/src/borrow_deref_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,18 @@ impl LateLintPass<'_> for BorrowDerefRef {
then{

if let Some(parent_expr) = get_parent_expr(cx, e){
if matches!(parent_expr.kind, ExprKind::Unary(UnOp::Deref, ..)) &&
!is_lint_allowed(cx, DEREF_ADDROF, parent_expr.hir_id) {
return;
}

// modification to `&mut &*x` is different from `&mut x`
if matches!(deref_target.kind, ExprKind::Path(..)
| ExprKind::Field(..)
| ExprKind::Index(..)
| ExprKind::Unary(UnOp::Deref, ..)) {
if matches!(parent_expr.kind, ExprKind::AddrOf(_, Mutability::Mut, _)) {
return;
}
if matches!(parent_expr.kind, ExprKind::Unary(UnOp::Deref, ..)) &&
!is_lint_allowed(cx, DEREF_ADDROF, parent_expr.hir_id) {
return;
}
| ExprKind::Field(..)
| ExprKind::Index(..)
| ExprKind::Unary(UnOp::Deref, ..))
&& matches!(parent_expr.kind, ExprKind::AddrOf(_, Mutability::Mut, _)) {
return;
}
}

Expand Down

0 comments on commit d3f53e6

Please sign in to comment.