Skip to content

Commit

Permalink
ast: Reduce size of ExprKind by boxing fields of ExprKind::Struct
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Mar 16, 2021
1 parent 35e8be7 commit e72d283
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions clippy_lints/src/redundant_field_names.rs
Expand Up @@ -58,8 +58,8 @@ impl EarlyLintPass for RedundantFieldNames {
if in_external_macro(cx.sess, expr.span) {
return;
}
if let ExprKind::Struct(_, ref fields, _) = expr.kind {
for field in fields {
if let ExprKind::Struct(ref se) = expr.kind {
for field in &se.fields {
if field.is_shorthand {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/suspicious_operation_groupings.rs
Expand Up @@ -564,7 +564,7 @@ fn ident_difference_expr_with_base_location(
| (Try(_), Try(_))
| (Paren(_), Paren(_))
| (Repeat(_, _), Repeat(_, _))
| (Struct(_, _, _), Struct(_, _, _))
| (Struct(_), Struct(_))
| (MacCall(_), MacCall(_))
| (LlvmInlineAsm(_), LlvmInlineAsm(_))
| (InlineAsm(_), InlineAsm(_))
Expand Down
6 changes: 4 additions & 2 deletions clippy_utils/src/ast_utils.rs
Expand Up @@ -168,8 +168,10 @@ pub fn eq_expr(l: &Expr, r: &Expr) -> bool {
(AddrOf(lbk, lm, le), AddrOf(rbk, rm, re)) => lbk == rbk && lm == rm && eq_expr(le, re),
(Path(lq, lp), Path(rq, rp)) => both(lq, rq, |l, r| eq_qself(l, r)) && eq_path(lp, rp),
(MacCall(l), MacCall(r)) => eq_mac_call(l, r),
(Struct(lp, lfs, lb), Struct(rp, rfs, rb)) => {
eq_path(lp, rp) && eq_struct_rest(lb, rb) && unordered_over(lfs, rfs, |l, r| eq_field(l, r))
(Struct(lse), Struct(rse)) => {
eq_path(&lse.path, &rse.path) &&
eq_struct_rest(&lse.rest, &rse.rest) &&
unordered_over(&lse.fields, &rse.fields, |l, r| eq_field(l, r))
},
_ => false,
}
Expand Down

0 comments on commit e72d283

Please sign in to comment.