inconsistent_struct_constructor
: Check HIR tree first.
This commit is contained in:
parent
3869e93408
commit
b58b491d16
@ -65,13 +65,13 @@
|
||||
|
||||
impl<'tcx> LateLintPass<'tcx> for InconsistentStructConstructor {
|
||||
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) {
|
||||
if !expr.span.from_expansion()
|
||||
&& let ExprKind::Struct(qpath, fields, base) = expr.kind
|
||||
if let ExprKind::Struct(qpath, fields, base) = expr.kind
|
||||
&& fields.iter().all(|f| f.is_shorthand)
|
||||
&& !expr.span.from_expansion()
|
||||
&& let ty = cx.typeck_results().expr_ty(expr)
|
||||
&& let Some(adt_def) = ty.ty_adt_def()
|
||||
&& adt_def.is_struct()
|
||||
&& let Some(variant) = adt_def.variants().iter().next()
|
||||
&& fields.iter().all(|f| f.is_shorthand)
|
||||
{
|
||||
let mut def_order_map = FxHashMap::default();
|
||||
for (idx, field) in variant.fields.iter().enumerate() {
|
||||
|
Loading…
Reference in New Issue
Block a user