about summary refs log tree commit diff
path: root/clippy_lints/src/inconsistent_struct_constructor.rs
diff options
context:
space:
mode:
authorrzvxa <rzvxa@protonmail.com>2024-08-03 22:52:22 +0330
committerrzvxa <rzvxa@protonmail.com>2024-08-03 22:52:22 +0330
commit5364cbea80f0e9b251151f40aa67592b0827759e (patch)
tree86ce7fc95a6e723f46128f3c3152f5c869455770 /clippy_lints/src/inconsistent_struct_constructor.rs
parent8dd459d4c750dbf200bbd48a10f129b1401e7bf3 (diff)
Respect allow inconsistent_struct_constructor on the type definition
Diffstat (limited to 'clippy_lints/src/inconsistent_struct_constructor.rs')
-rw-r--r--clippy_lints/src/inconsistent_struct_constructor.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/clippy_lints/src/inconsistent_struct_constructor.rs b/clippy_lints/src/inconsistent_struct_constructor.rs
index 5b0aadf35c6..da289225509 100644
--- a/clippy_lints/src/inconsistent_struct_constructor.rs
+++ b/clippy_lints/src/inconsistent_struct_constructor.rs
@@ -1,4 +1,5 @@
 use clippy_utils::diagnostics::span_lint_and_sugg;
+use clippy_utils::is_lint_allowed;
 use clippy_utils::source::snippet;
 use rustc_data_structures::fx::FxHashMap;
 use rustc_errors::Applicability;
@@ -71,6 +72,9 @@ impl<'tcx> LateLintPass<'tcx> for InconsistentStructConstructor {
             && let ty = cx.typeck_results().expr_ty(expr)
             && let Some(adt_def) = ty.ty_adt_def()
             && adt_def.is_struct()
+            && let Some(local_def_id) = adt_def.did().as_local()
+            && let ty_hir_id = cx.tcx.local_def_id_to_hir_id(local_def_id)
+            && !is_lint_allowed(cx, INCONSISTENT_STRUCT_CONSTRUCTOR, ty_hir_id)
             && let Some(variant) = adt_def.variants().iter().next()
         {
             let mut def_order_map = FxHashMap::default();