@@ -16,9 +16,12 @@ use rustc_span::source_map::{ExpnKind, Span};
16
16
17
17
use clippy_utils:: sugg:: Sugg ;
18
18
use 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 ,
20
21
} ;
21
22
23
+ use crate :: ref_pattern:: REF_PATTERN ;
24
+
22
25
declare_clippy_lint ! {
23
26
/// ### What it does
24
27
/// Checks for function arguments and let bindings denoted as
@@ -162,6 +165,10 @@ impl<'tcx> LateLintPass<'tcx> for LintPass {
162
165
return ;
163
166
}
164
167
for arg in iter_input_pats ( decl, body) {
168
+ // Do not emit if clippy::ref_pattern is not allowed to avoid having two lints for the same issue.
169
+ if !is_lint_allowed ( cx, REF_PATTERN , arg. pat . hir_id ) {
170
+ return ;
171
+ }
165
172
if let PatKind :: Binding ( BindingAnnotation ( ByRef :: Yes , _) , ..) = arg. pat . kind {
166
173
span_lint (
167
174
cx,
@@ -180,6 +187,8 @@ impl<'tcx> LateLintPass<'tcx> for LintPass {
180
187
if let StmtKind :: Local ( local) = stmt. kind;
181
188
if let PatKind :: Binding ( BindingAnnotation ( ByRef :: Yes , mutabl) , .., name, None ) = local. pat. kind;
182
189
if let Some ( init) = local. init;
190
+ // Do not emit if clippy::ref_pattern is not allowed to avoid having two lints for the same issue.
191
+ if is_lint_allowed( cx, REF_PATTERN , local. pat. hir_id) ;
183
192
then {
184
193
let ctxt = local. span. ctxt( ) ;
185
194
let mut app = Applicability :: MachineApplicable ;
@@ -220,6 +229,8 @@ impl<'tcx> LateLintPass<'tcx> for LintPass {
220
229
if let ExprKind :: Binary ( ref binop, a, b) = expr. kind;
221
230
if binop. node == BinOpKind :: And || binop. node == BinOpKind :: Or ;
222
231
if let Some ( sugg) = Sugg :: hir_opt( cx, a) ;
232
+ // Do not emit if clippy::ref_pattern is not allowed to avoid having two lints for the same issue.
233
+ if is_lint_allowed( cx, REF_PATTERN , expr. hir_id) ;
223
234
then {
224
235
span_lint_hir_and_then(
225
236
cx,
@@ -252,6 +263,10 @@ impl<'tcx> LateLintPass<'tcx> for LintPass {
252
263
// Don't lint things expanded by #[derive(...)], etc or `await` desugaring
253
264
return ;
254
265
}
266
+ // Do not emit if clippy::ref_pattern is not allowed to avoid having two lints for the same issue.
267
+ if !is_lint_allowed ( cx, REF_PATTERN , expr. hir_id ) {
268
+ return ;
269
+ }
255
270
let sym;
256
271
let binding = match expr. kind {
257
272
ExprKind :: Path ( ref qpath) if !matches ! ( qpath, hir:: QPath :: LangItem ( ..) ) => {
0 commit comments