diff options
| author | Renato Lochetti <renato.lochetti@gmail.com> | 2023-05-07 12:35:17 +0100 |
|---|---|---|
| committer | Renato Lochetti <renato.lochetti@gmail.com> | 2023-05-07 12:35:17 +0100 |
| commit | 394b4c1906ed8eb0484f70a7697b452dbb8fa483 (patch) | |
| tree | fe8db74a3045ada0245dad3e42c4fd63633bd091 /clippy_lints/src | |
| parent | 371120bdbf58a331db5dcfb2d9cddc040f486de8 (diff) | |
| download | rust-394b4c1906ed8eb0484f70a7697b452dbb8fa483.tar.gz rust-394b4c1906ed8eb0484f70a7697b452dbb8fa483.zip | |
Ignore `borrow_deref_ref` warnings in code from procedural macros.
Diffstat (limited to 'clippy_lints/src')
| -rw-r--r-- | clippy_lints/src/borrow_deref_ref.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/clippy_lints/src/borrow_deref_ref.rs b/clippy_lints/src/borrow_deref_ref.rs index c4520d00392..814108ed8a7 100644 --- a/clippy_lints/src/borrow_deref_ref.rs +++ b/clippy_lints/src/borrow_deref_ref.rs @@ -1,5 +1,6 @@ use crate::reference::DEREF_ADDROF; use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::is_from_proc_macro; use clippy_utils::source::snippet_opt; use clippy_utils::ty::implements_trait; use clippy_utils::{get_parent_expr, is_lint_allowed}; @@ -47,8 +48,8 @@ declare_clippy_lint! { declare_lint_pass!(BorrowDerefRef => [BORROW_DEREF_REF]); -impl LateLintPass<'_> for BorrowDerefRef { - fn check_expr(&mut self, cx: &LateContext<'_>, e: &rustc_hir::Expr<'_>) { +impl<'tcx> LateLintPass<'tcx> for BorrowDerefRef { + fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &rustc_hir::Expr<'tcx>) { if_chain! { if !e.span.from_expansion(); if let ExprKind::AddrOf(_, Mutability::Not, addrof_target) = e.kind; @@ -58,6 +59,7 @@ impl LateLintPass<'_> for BorrowDerefRef { if !matches!(deref_target.kind, ExprKind::Unary(UnOp::Deref, ..) ); let ref_ty = cx.typeck_results().expr_ty(deref_target); if let ty::Ref(_, inner_ty, Mutability::Not) = ref_ty.kind(); + if !is_from_proc_macro(cx, e); then{ if let Some(parent_expr) = get_parent_expr(cx, e){ |
