Skip to content

Comments

refactor(oxfmt): Use Box<FormatOptions> for ResolvedOptions#17772

Merged
graphite-app[bot] merged 1 commit intomainfrom
01-08-refactor_oxfmt_box_formatoptions_for_resolvedoptions
Jan 8, 2026
Merged

refactor(oxfmt): Use Box<FormatOptions> for ResolvedOptions#17772
graphite-app[bot] merged 1 commit intomainfrom
01-08-refactor_oxfmt_box_formatoptions_for_resolvedoptions

Conversation

@leaysgur
Copy link
Member

@leaysgur leaysgur commented Jan 8, 2026

Preparation for #17576

error: large size difference between variants
  --> apps/oxfmt/src/core/config.rs:51:1
   |
51 | /   pub enum ResolvedOptions {
52 | |       /// For JS/TS files formatted by oxc_formatter.
53 | | /     OxcFormatter {
54 | | |         format_options: FormatOptions,
55 | | |         /// For embedded language formatting (e.g., CSS in template literals)
56 | | |         external_options: Value,
57 | | |         insert_final_newline: bool,
58 | | |     },
   | | |_____- the largest variant contains at least 281 bytes
...  |
66 | | /     ExternalFormatterPackageJson {
67 | | |         external_options: Value,
68 | | |         sort_package_json: Option<sort_package_json::SortOptions>,
69 | | |         insert_final_newline: bool,
70 | | |     },
   | | |_____- the second-largest variant contains at least 75 bytes
71 | |   }
   | |___^ the entire enum is at least 288 bytes
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#large_enum_variant
   = note: `-D clippy::large-enum-variant` implied by `-D warnings`
   = help: to override `-D warnings` add `#[allow(clippy::large_enum_variant)]`
help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
   |
54 -         format_options: FormatOptions,
54 +         format_options: Box<FormatOptions>,
   |

Copilot AI review requested due to automatic review settings January 8, 2026 01:29
@github-actions github-actions bot added A-cli Area - CLI A-formatter Area - Formatter C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels Jan 8, 2026
Copy link
Member Author

leaysgur commented Jan 8, 2026


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@leaysgur leaysgur changed the title refactor(oxfmt): Box<FormatOptions> for ResolvedOptions refactor(oxfmt): Use Box<FormatOptions> for ResolvedOptions Jan 8, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the ResolvedOptions enum by boxing the FormatOptions field to reduce the overall size of the enum. This is a standard Rust optimization to prevent one large variant from inflating the size of all enum variants.

Key Changes:

  • Changed format_options: FormatOptions to format_options: Box<FormatOptions> in the ResolvedOptions::OxcFormatter variant
  • Updated creation site to wrap FormatOptions in a Box
  • Updated usage site to dereference the boxed value when passing to the formatter

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
apps/oxfmt/src/core/config.rs Changed field type to Box<FormatOptions> and wrapped the value in Box::new() when constructing the enum variant
apps/oxfmt/src/core/format.rs Dereferenced the boxed FormatOptions when passing it to format_by_oxc_formatter

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@leaysgur leaysgur added the 0-merge Merge with Graphite Merge Queue label Jan 8, 2026
Copy link
Member Author

leaysgur commented Jan 8, 2026

Merge activity

Preparation for #17576

```
error: large size difference between variants
  --> apps/oxfmt/src/core/config.rs:51:1
   |
51 | /   pub enum ResolvedOptions {
52 | |       /// For JS/TS files formatted by oxc_formatter.
53 | | /     OxcFormatter {
54 | | |         format_options: FormatOptions,
55 | | |         /// For embedded language formatting (e.g., CSS in template literals)
56 | | |         external_options: Value,
57 | | |         insert_final_newline: bool,
58 | | |     },
   | | |_____- the largest variant contains at least 281 bytes
...  |
66 | | /     ExternalFormatterPackageJson {
67 | | |         external_options: Value,
68 | | |         sort_package_json: Option<sort_package_json::SortOptions>,
69 | | |         insert_final_newline: bool,
70 | | |     },
   | | |_____- the second-largest variant contains at least 75 bytes
71 | |   }
   | |___^ the entire enum is at least 288 bytes
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#large_enum_variant
   = note: `-D clippy::large-enum-variant` implied by `-D warnings`
   = help: to override `-D warnings` add `#[allow(clippy::large_enum_variant)]`
help: consider boxing the large fields or introducing indirection in some other way to reduce the total size of the enum
   |
54 -         format_options: FormatOptions,
54 +         format_options: Box<FormatOptions>,
   |

```
@graphite-app graphite-app bot force-pushed the 01-08-refactor_oxfmt_box_formatoptions_for_resolvedoptions branch from 35cbfd9 to e9f1a43 Compare January 8, 2026 01:55
@graphite-app graphite-app bot merged commit e9f1a43 into main Jan 8, 2026
18 checks passed
@graphite-app graphite-app bot deleted the 01-08-refactor_oxfmt_box_formatoptions_for_resolvedoptions branch January 8, 2026 02:01
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Jan 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Area - CLI A-formatter Area - Formatter C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants