File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change 1+ use crate :: reference:: DEREF_ADDROF ;
12use clippy_utils:: diagnostics:: { span_lint_and_help, span_lint_and_then} ;
3+ use clippy_utils:: is_lint_allowed;
24use clippy_utils:: source:: snippet_opt;
35use clippy_utils:: ty:: implements_trait;
46use rustc_hir:: { ExprKind , UnOp } ;
@@ -55,11 +57,14 @@ impl LateLintPass<'_> for NeedlessDeref {
5557 if span. from_expansion( ) {
5658 return ;
5759 }
58- if matches!( deref_expr. kind, ExprKind :: Path ( ..) ) {
60+ if matches!( deref_expr. kind, ExprKind :: Path ( ..) ) {
5961 let parent_node = map. find( parent_hir_id) ;
6062 if let Some ( rustc_hir:: Node :: Expr ( parent_expr) ) = parent_node {
61- if matches!( parent_expr. kind, ExprKind :: Unary ( UnOp :: Deref , ..) ) ||
62- matches!( parent_expr. kind, ExprKind :: AddrOf ( ..) ) {
63+ if matches!( parent_expr. kind, ExprKind :: AddrOf ( ..) ) {
64+ return ;
65+ }
66+ if matches!( parent_expr. kind, ExprKind :: Unary ( UnOp :: Deref , ..) ) &&
67+ !is_lint_allowed( cx, DEREF_ADDROF , parent_expr. hir_id) {
6368 return ;
6469 }
6570 }
You can’t perform that action at this time.
0 commit comments