Skip to content

Commit d85cf0b

Browse files
committed
use fulfill_or_allowed over is_lint_allowed.
1 parent 5364cbe commit d85cf0b

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

clippy_lints/src/inconsistent_struct_constructor.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use clippy_utils::diagnostics::span_lint_and_sugg;
2-
use clippy_utils::is_lint_allowed;
2+
use clippy_utils::fulfill_or_allowed;
33
use clippy_utils::source::snippet;
44
use rustc_data_structures::fx::FxHashMap;
55
use rustc_errors::Applicability;
@@ -74,7 +74,6 @@ impl<'tcx> LateLintPass<'tcx> for InconsistentStructConstructor {
7474
&& adt_def.is_struct()
7575
&& let Some(local_def_id) = adt_def.did().as_local()
7676
&& let ty_hir_id = cx.tcx.local_def_id_to_hir_id(local_def_id)
77-
&& !is_lint_allowed(cx, INCONSISTENT_STRUCT_CONSTRUCTOR, ty_hir_id)
7877
&& let Some(variant) = adt_def.variants().iter().next()
7978
{
8079
let mut def_order_map = FxHashMap::default();
@@ -107,15 +106,17 @@ impl<'tcx> LateLintPass<'tcx> for InconsistentStructConstructor {
107106
snippet(cx, qpath.span(), ".."),
108107
);
109108

110-
span_lint_and_sugg(
111-
cx,
112-
INCONSISTENT_STRUCT_CONSTRUCTOR,
113-
expr.span,
114-
"struct constructor field order is inconsistent with struct definition field order",
115-
"try",
116-
sugg,
117-
Applicability::MachineApplicable,
118-
);
109+
if !fulfill_or_allowed(cx, INCONSISTENT_STRUCT_CONSTRUCTOR, Some(ty_hir_id)) {
110+
span_lint_and_sugg(
111+
cx,
112+
INCONSISTENT_STRUCT_CONSTRUCTOR,
113+
expr.span,
114+
"struct constructor field order is inconsistent with struct definition field order",
115+
"try",
116+
sugg,
117+
Applicability::MachineApplicable,
118+
);
119+
}
119120
}
120121
}
121122
}

0 commit comments

Comments
 (0)