|
1 | 1 | use clippy_utils::diagnostics::span_lint_and_sugg; |
2 | | -use clippy_utils::is_lint_allowed; |
| 2 | +use clippy_utils::fulfill_or_allowed; |
3 | 3 | use clippy_utils::source::snippet; |
4 | 4 | use rustc_data_structures::fx::FxHashMap; |
5 | 5 | use rustc_errors::Applicability; |
@@ -74,7 +74,6 @@ impl<'tcx> LateLintPass<'tcx> for InconsistentStructConstructor { |
74 | 74 | && adt_def.is_struct() |
75 | 75 | && let Some(local_def_id) = adt_def.did().as_local() |
76 | 76 | && 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) |
78 | 77 | && let Some(variant) = adt_def.variants().iter().next() |
79 | 78 | { |
80 | 79 | let mut def_order_map = FxHashMap::default(); |
@@ -107,15 +106,17 @@ impl<'tcx> LateLintPass<'tcx> for InconsistentStructConstructor { |
107 | 106 | snippet(cx, qpath.span(), ".."), |
108 | 107 | ); |
109 | 108 |
|
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 | + } |
119 | 120 | } |
120 | 121 | } |
121 | 122 | } |
|
0 commit comments