perf(cli): compile out advanced help and share layout code - #1402
Conversation
Keep flatten and recursive help behind help-advanced so slim CLIs do not link those pages. Share section layout and unexpected-flag diagnostics through one inline(never) implementation each, matching the sort sharing from #1400, and skip help_structure work on plain pages.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Central YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 4 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe change centralizes unexpected-flag diagnostics and updates help rendering with advanced-feature gates, generalized grouping callbacks, reduced monomorphization, and feature-specific tests. ChangesDiagnostic rendering
Help rendering
Estimated code review effort: 3 (Moderate) | ~25 minutes Merge Risk: ⚪ Minimal · up to The help and diagnostic changes preserve expected behavior across supported feature configurations, with no actionable merge risk identified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Instruction counts
No instruction-count regression above 1%. Only instruction counts gate. Wall clock is shown for context — on identical hardware it moves 4-20% run to run. Measured by tak — instruction-counted CLI benchmarks, stored in this repository's git notes. Shadow comparisonParsing
|
Follow-up to #1396, #1399, and #1400 for the oxc migration binary-size work.
CLIs that omit
help-advanced(oxlint/oxfmt) no longer compile flatten or recursive help. Fat LTO was still cloning section layout and unexpected-flag diagnostics; those now share one#[inline(never)]implementation each, the same pattern as the shared sorts. Plain help skipshelp_structure, which only exists to recognize colored spans.Help text is intended to stay identical. Flattened and
HelpAllpages still panic without the feature.Validation: argv lib tests with and without
help-advanced;usage-rsfacade tests with completions; reduced-featurestatic_endpointtests including the existing panic coverage. Clippy-D warningsonusage-argv --all-features.Implemented with AI assistance.
Note
Low Risk
Changes are compile-time gating and internal refactors aimed at binary size and LTO; behaviour is covered by existing tests with and without
help-advanced.Overview
This PR shrinks binaries for CLIs built without
help-advanced(e.g. oxlint/oxfmt) and reduces fat-LTO duplication in help and diagnostics.Advanced help — Flattened help, recursive
HelpAllrendering, and related helpers (flat_help_*,flat_commands_*,recursive_help, multi-line usage for flatten) are now behind#[cfg(feature = "help-advanced")]. Publicrender_all_*entry points returnNonewhen the feature is off instead of linking that code.Plain help path — When output is not coloured, rendering skips
help_structureentirely (it only collects spellings for styled span matching), usingHelpStructure::default()instead.Shared cold paths — Unknown-flag diagnostics for
UnknownFlagand dash-prefixedUnexpectedArgshare one#[inline(never)]unexpected_flag.split_groups_sectiontakes slice + trait-object callbacks so LTO does not monomorphize a copy per args/flags section; several layout helpers (entry,wrap, etc.) are also#[inline(never)].Behaviour — Intended help/error text stays the same; advanced pages still require
help-advanced(and panic when invoked without it where documented).Reviewed by Cursor Bugbot for commit 00a9b93. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit
Bug Fixes
Refactor
Tests