@@ -16,9 +16,12 @@ use rustc_span::source_map::{ExpnKind, Span};
1616
1717use clippy_utils:: sugg:: Sugg ;
1818use clippy_utils:: {
19- get_parent_expr, in_constant, is_integer_literal, is_no_std_crate, iter_input_pats, last_path_segment, SpanlessEq ,
19+ get_parent_expr, in_constant, is_integer_literal, is_lint_allowed, is_no_std_crate, iter_input_pats,
20+ last_path_segment, SpanlessEq ,
2021} ;
2122
23+ use crate :: ref_patterns:: REF_PATTERNS ;
24+
2225declare_clippy_lint ! {
2326 /// ### What it does
2427 /// Checks for function arguments and let bindings denoted as
@@ -162,6 +165,10 @@ impl<'tcx> LateLintPass<'tcx> for LintPass {
162165 return ;
163166 }
164167 for arg in iter_input_pats ( decl, body) {
168+ // Do not emit if clippy::ref_patterns is not allowed to avoid having two lints for the same issue.
169+ if !is_lint_allowed ( cx, REF_PATTERNS , arg. pat . hir_id ) {
170+ return ;
171+ }
165172 if let PatKind :: Binding ( BindingAnnotation ( ByRef :: Yes , _) , ..) = arg. pat . kind {
166173 span_lint (
167174 cx,
@@ -180,6 +187,8 @@ impl<'tcx> LateLintPass<'tcx> for LintPass {
180187 if let StmtKind :: Local ( local) = stmt. kind;
181188 if let PatKind :: Binding ( BindingAnnotation ( ByRef :: Yes , mutabl) , .., name, None ) = local. pat. kind;
182189 if let Some ( init) = local. init;
190+ // Do not emit if clippy::ref_patterns is not allowed to avoid having two lints for the same issue.
191+ if is_lint_allowed( cx, REF_PATTERNS , local. pat. hir_id) ;
183192 then {
184193 let ctxt = local. span. ctxt( ) ;
185194 let mut app = Applicability :: MachineApplicable ;
0 commit comments