mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-14 00:47:16 +00:00
use fulfill_or_allowed
over is_lint_allowed
.
This commit is contained in:
parent
5364cbea80
commit
d85cf0bacd
1 changed files with 12 additions and 11 deletions
|
@ -1,5 +1,5 @@
|
||||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||||
use clippy_utils::is_lint_allowed;
|
use clippy_utils::fulfill_or_allowed;
|
||||||
use clippy_utils::source::snippet;
|
use clippy_utils::source::snippet;
|
||||||
use rustc_data_structures::fx::FxHashMap;
|
use rustc_data_structures::fx::FxHashMap;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
|
@ -74,7 +74,6 @@ impl<'tcx> LateLintPass<'tcx> for InconsistentStructConstructor {
|
||||||
&& adt_def.is_struct()
|
&& adt_def.is_struct()
|
||||||
&& let Some(local_def_id) = adt_def.did().as_local()
|
&& 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)
|
&& 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 Some(variant) = adt_def.variants().iter().next()
|
||||||
{
|
{
|
||||||
let mut def_order_map = FxHashMap::default();
|
let mut def_order_map = FxHashMap::default();
|
||||||
|
@ -107,15 +106,17 @@ impl<'tcx> LateLintPass<'tcx> for InconsistentStructConstructor {
|
||||||
snippet(cx, qpath.span(), ".."),
|
snippet(cx, qpath.span(), ".."),
|
||||||
);
|
);
|
||||||
|
|
||||||
span_lint_and_sugg(
|
if !fulfill_or_allowed(cx, INCONSISTENT_STRUCT_CONSTRUCTOR, Some(ty_hir_id)) {
|
||||||
cx,
|
span_lint_and_sugg(
|
||||||
INCONSISTENT_STRUCT_CONSTRUCTOR,
|
cx,
|
||||||
expr.span,
|
INCONSISTENT_STRUCT_CONSTRUCTOR,
|
||||||
"struct constructor field order is inconsistent with struct definition field order",
|
expr.span,
|
||||||
"try",
|
"struct constructor field order is inconsistent with struct definition field order",
|
||||||
sugg,
|
"try",
|
||||||
Applicability::MachineApplicable,
|
sugg,
|
||||||
);
|
Applicability::MachineApplicable,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue