diff options
| author | rzvxa <rzvxa@protonmail.com> | 2024-08-03 22:52:22 +0330 |
|---|---|---|
| committer | rzvxa <rzvxa@protonmail.com> | 2024-08-03 22:52:22 +0330 |
| commit | 5364cbea80f0e9b251151f40aa67592b0827759e (patch) | |
| tree | 86ce7fc95a6e723f46128f3c3152f5c869455770 /clippy_lints/src/inconsistent_struct_constructor.rs | |
| parent | 8dd459d4c750dbf200bbd48a10f129b1401e7bf3 (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.rs | 4 |
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(); |
