Skip to content

Commit e72d283

Browse files
committed
ast: Reduce size of ExprKind by boxing fields of ExprKind::Struct
1 parent 35e8be7 commit e72d283

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

clippy_lints/src/redundant_field_names.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ impl EarlyLintPass for RedundantFieldNames {
5858
if in_external_macro(cx.sess, expr.span) {
5959
return;
6060
}
61-
if let ExprKind::Struct(_, ref fields, _) = expr.kind {
62-
for field in fields {
61+
if let ExprKind::Struct(ref se) = expr.kind {
62+
for field in &se.fields {
6363
if field.is_shorthand {
6464
continue;
6565
}

clippy_lints/src/suspicious_operation_groupings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ fn ident_difference_expr_with_base_location(
564564
| (Try(_), Try(_))
565565
| (Paren(_), Paren(_))
566566
| (Repeat(_, _), Repeat(_, _))
567-
| (Struct(_, _, _), Struct(_, _, _))
567+
| (Struct(_), Struct(_))
568568
| (MacCall(_), MacCall(_))
569569
| (LlvmInlineAsm(_), LlvmInlineAsm(_))
570570
| (InlineAsm(_), InlineAsm(_))

clippy_utils/src/ast_utils.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,10 @@ pub fn eq_expr(l: &Expr, r: &Expr) -> bool {
168168
(AddrOf(lbk, lm, le), AddrOf(rbk, rm, re)) => lbk == rbk && lm == rm && eq_expr(le, re),
169169
(Path(lq, lp), Path(rq, rp)) => both(lq, rq, |l, r| eq_qself(l, r)) && eq_path(lp, rp),
170170
(MacCall(l), MacCall(r)) => eq_mac_call(l, r),
171-
(Struct(lp, lfs, lb), Struct(rp, rfs, rb)) => {
172-
eq_path(lp, rp) && eq_struct_rest(lb, rb) && unordered_over(lfs, rfs, |l, r| eq_field(l, r))
171+
(Struct(lse), Struct(rse)) => {
172+
eq_path(&lse.path, &rse.path) &&
173+
eq_struct_rest(&lse.rest, &rse.rest) &&
174+
unordered_over(&lse.fields, &rse.fields, |l, r| eq_field(l, r))
173175
},
174176
_ => false,
175177
}

0 commit comments

Comments
 (0)