Skip to content

[codegen] Test and document codegen under different layouts#3085

Merged
jswrenn merged 3 commits intomainfrom
G39e297d5b891f5115ef9607b090c5fbe95427d68
Mar 9, 2026
Merged

[codegen] Test and document codegen under different layouts#3085
jswrenn merged 3 commits intomainfrom
G39e297d5b891f5115ef9607b090c5fbe95427d68

Conversation

@jswrenn
Copy link
Collaborator

@jswrenn jswrenn commented Mar 6, 2026

This improves the robustness of our suite to different code paths, and
illustrates in our documentation the relationship between type
complexity and codegen complexity.


Latest Update: v8 — Compare vs v7

📚 Full Patch History

Links show the diff between the row version and the column version.

Version v7 v6 v5 v4 v3 v2 v1 Base
v8 vs v7 vs v6 vs v5 vs v4 vs v3 vs v2 vs v1 vs Base
v7 vs v6 vs v5 vs v4 vs v3 vs v2 vs v1 vs Base
v6 vs v5 vs v4 vs v3 vs v2 vs v1 vs Base
v5 vs v4 vs v3 vs v2 vs v1 vs Base
v4 vs v3 vs v2 vs v1 vs Base
v3 vs v2 vs v1 vs Base
v2 vs v1 vs Base
v1 vs Base
⬇️ Download this PR

Branch

git fetch origin refs/heads/G39e297d5b891f5115ef9607b090c5fbe95427d68 && git checkout -b pr-G39e297d5b891f5115ef9607b090c5fbe95427d68 FETCH_HEAD

Checkout

git fetch origin refs/heads/G39e297d5b891f5115ef9607b090c5fbe95427d68 && git checkout FETCH_HEAD

Cherry Pick

git fetch origin refs/heads/G39e297d5b891f5115ef9607b090c5fbe95427d68 && git cherry-pick FETCH_HEAD

Pull

git pull origin refs/heads/G39e297d5b891f5115ef9607b090c5fbe95427d68

Stacked PRs enabled by GHerrit.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly improves the zerocopy library's code generation testing and documentation. By categorizing benchmarks based on type memory layouts (static, dynamic, and dynamically padded), it provides clearer insights into the performance characteristics and compiler optimizations for different zerocopy trait implementations. The new documentation structure, featuring interactive tabs, makes it easier to compare code generation outputs and understand the relationship between type complexity and codegen efficiency.

Highlights

  • Refactored Codegen Benchmarks: Existing codegen benchmarks were reorganized and new ones introduced to explicitly test zerocopy traits under various memory layouts: static size, dynamic size, and dynamically padded types. This provides a more granular view of performance characteristics.
  • Enhanced Codegen Documentation: The documentation system was significantly upgraded with new Rustdoc macros (codegen_section!, codegen_example_suite!, etc.). These macros generate interactive tabbed displays for benchmark results, allowing users to easily compare code generation outputs for different type layouts directly within the documentation.
  • Updated Rustdoc Styling: The rustdoc/style.css file was modified to support the new tabbed documentation layout. This includes using a CSS variable for dynamic grid column counts and adding specific styling for the interactive elements, improving the visual presentation and user experience.
  • Streamlined Documentation Generation: The --generate-macro-expansion flag was removed from the tools/doc.sh script, simplifying the rustdoc command and potentially speeding up documentation builds.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • benches/formats/coco.rs
    • Renamed to benches/formats/coco_dynamic_padding.rs.
  • benches/formats/coco_no_padding.rs
    • Renamed to benches/formats/coco_dynamic_size.rs.
  • benches/formats/coco_static_size.rs
    • Added a new format definition for static-sized types.
  • benches/read_from_bytes.rs
    • Added a new benchmark for read_from_bytes with static size.
  • benches/read_from_bytes.x86-64
    • Added x86-64 assembly output for read_from_bytes_static_size.
  • benches/read_from_bytes.x86-64.mca
    • Added machine code analysis for read_from_bytes_static_size.
  • benches/read_from_prefix.rs
    • Added a new benchmark for read_from_prefix with static size.
  • benches/read_from_prefix.x86-64
    • Added x86-64 assembly output for read_from_prefix_static_size.
  • benches/read_from_prefix.x86-64.mca
    • Added machine code analysis for read_from_prefix_static_size.
  • benches/read_from_suffix.rs
    • Added a new benchmark for read_from_suffix with static size.
  • benches/read_from_suffix.x86-64
    • Added x86-64 assembly output for read_from_suffix_static_size.
  • benches/read_from_suffix.x86-64.mca
    • Added machine code analysis for read_from_suffix_static_size.
  • benches/ref_from_bytes.rs
    • Removed the old ref_from_bytes benchmark.
  • benches/ref_from_bytes.x86-64
    • Renamed to benches/ref_from_bytes_dynamic_padding.x86-64.
  • benches/ref_from_bytes.x86-64.mca
    • Renamed to benches/ref_from_bytes_dynamic_padding.x86-64.mca.
  • benches/ref_from_bytes_dynamic_padding.rs
    • Added a new benchmark for ref_from_bytes with dynamic padding.
  • benches/ref_from_bytes_dynamic_size.rs
    • Added a new benchmark for ref_from_bytes with dynamic size.
  • benches/ref_from_bytes_dynamic_size.x86-64
    • Added x86-64 assembly output for ref_from_bytes_dynamic_size.
  • benches/ref_from_bytes_dynamic_size.x86-64.mca
    • Added machine code analysis for ref_from_bytes_dynamic_size.
  • benches/ref_from_bytes_static_size.rs
    • Added a new benchmark for ref_from_bytes with static size.
  • benches/ref_from_bytes_static_size.x86-64
    • Added x86-64 assembly output for ref_from_bytes_static_size.
  • benches/ref_from_bytes_static_size.x86-64.mca
    • Added machine code analysis for ref_from_bytes_static_size.
  • benches/ref_from_bytes_with_elems.rs
    • Removed the old ref_from_bytes_with_elems benchmark.
  • benches/ref_from_bytes_with_elems.x86-64
    • Renamed to benches/ref_from_bytes_with_elems_dynamic_padding.x86-64.
  • benches/ref_from_bytes_with_elems.x86-64.mca
    • Renamed to benches/ref_from_bytes_with_elems_dynamic_padding.x86-64.mca.
  • benches/ref_from_bytes_with_elems_dynamic_padding.rs
    • Added a new benchmark for ref_from_bytes_with_elems with dynamic padding.
  • benches/ref_from_bytes_with_elems_dynamic_size.rs
    • Added a new benchmark for ref_from_bytes_with_elems with dynamic size.
  • benches/ref_from_bytes_with_elems_dynamic_size.x86-64
    • Added x86-64 assembly output for ref_from_bytes_with_elems_dynamic_size.
  • benches/ref_from_bytes_with_elems_dynamic_size.x86-64.mca
    • Added machine code analysis for ref_from_bytes_with_elems_dynamic_size.
  • benches/ref_from_prefix.rs
    • Renamed to benches/ref_from_prefix_static_size.rs and updated its path.
  • benches/ref_from_prefix.x86-64
    • Renamed to benches/ref_from_prefix_dynamic_padding.x86-64.
  • benches/ref_from_prefix.x86-64.mca
    • Renamed to benches/ref_from_prefix_dynamic_padding.x86-64.mca.
  • benches/ref_from_prefix_dynamic_padding.rs
    • Added a new benchmark for ref_from_prefix with dynamic padding.
  • benches/ref_from_prefix_dynamic_size.rs
    • Added a new benchmark for ref_from_prefix with dynamic size.
  • benches/ref_from_prefix_dynamic_size.x86-64
    • Added x86-64 assembly output for ref_from_prefix_dynamic_size.
  • benches/ref_from_prefix_dynamic_size.x86-64.mca
    • Added machine code analysis for ref_from_prefix_dynamic_size.
  • benches/ref_from_prefix_static_size.x86-64
    • Added x86-64 assembly output for ref_from_prefix_static_size.
  • benches/ref_from_prefix_static_size.x86-64.mca
    • Added machine code analysis for ref_from_prefix_static_size.
  • benches/ref_from_prefix_with_elems.rs
    • Renamed to benches/ref_from_prefix_with_elems_dynamic_size.rs and updated its path.
  • benches/ref_from_prefix_with_elems.x86-64
    • Renamed to benches/ref_from_prefix_with_elems_dynamic_padding.x86-64.
  • benches/ref_from_prefix_with_elems.x86-64.mca
    • Renamed to benches/ref_from_prefix_with_elems_dynamic_padding.x86-64.mca.
  • benches/ref_from_prefix_with_elems_dynamic_padding.rs
    • Added a new benchmark for ref_from_prefix_with_elems with dynamic padding.
  • benches/ref_from_prefix_with_elems_dynamic_size.x86-64
    • Added x86-64 assembly output for ref_from_prefix_with_elems_dynamic_size.
  • benches/ref_from_prefix_with_elems_dynamic_size.x86-64.mca
    • Added machine code analysis for ref_from_prefix_with_elems_dynamic_size.
  • benches/ref_from_suffix.rs
    • Renamed to benches/ref_from_suffix_static_size.rs and updated its path.
  • benches/ref_from_suffix.x86-64
    • Renamed to benches/ref_from_suffix_dynamic_padding.x86-64.
  • benches/ref_from_suffix.x86-64.mca
    • Renamed to benches/ref_from_suffix_dynamic_padding.x86-64.mca.
  • benches/ref_from_suffix_dynamic_padding.rs
    • Added a new benchmark for ref_from_suffix with dynamic padding.
  • benches/ref_from_suffix_dynamic_size.rs
    • Added a new benchmark for ref_from_suffix with dynamic size.
  • benches/ref_from_suffix_dynamic_size.x86-64
    • Added x86-64 assembly output for ref_from_suffix_dynamic_size.
  • benches/ref_from_suffix_dynamic_size.x86-64.mca
    • Added machine code analysis for ref_from_suffix_dynamic_size.
  • benches/ref_from_suffix_static_size.x86-64
    • Added x86-64 assembly output for ref_from_suffix_static_size.
  • benches/ref_from_suffix_static_size.x86-64.mca
    • Added machine code analysis for ref_from_suffix_static_size.
  • benches/ref_from_suffix_with_elems.rs
    • Renamed to benches/ref_from_suffix_with_elems_dynamic_size.rs and updated its path.
  • benches/ref_from_suffix_with_elems.x86-64
    • Renamed to benches/ref_from_suffix_with_elems_dynamic_padding.x86-64.
  • benches/ref_from_suffix_with_elems.x86-64.mca
    • Renamed to benches/ref_from_suffix_with_elems_dynamic_padding.x86-64.mca.
  • benches/ref_from_suffix_with_elems_dynamic_padding.rs
    • Added a new benchmark for ref_from_suffix_with_elems with dynamic padding.
  • benches/ref_from_suffix_with_elems_dynamic_size.x86-64
    • Added x86-64 assembly output for ref_from_suffix_with_elems_dynamic_size.
  • benches/ref_from_suffix_with_elems_dynamic_size.x86-64.mca
    • Added machine code analysis for ref_from_suffix_with_elems_dynamic_size.
  • benches/transmute_ref.rs
    • Renamed to benches/transmute_ref_dynamic_size.rs and updated its path.
  • benches/transmute_ref.x86-64
    • Renamed to benches/transmute_ref_dynamic_size.x86-64.
  • benches/transmute_ref.x86-64.mca
    • Renamed to benches/transmute_ref_dynamic_size.x86-64.mca.
  • benches/transmute_ref_static_size.rs
    • Added a new benchmark for transmute_ref with static size.
  • benches/transmute_ref_static_size.x86-64
    • Added x86-64 assembly output for transmute_ref_static_size.
  • benches/transmute_ref_static_size.x86-64.mca
    • Added machine code analysis for transmute_ref_static_size.
  • benches/try_read_from_bytes.rs
    • Added a new benchmark for try_read_from_bytes with static size.
  • benches/try_read_from_bytes.x86-64
    • Added x86-64 assembly output for try_read_from_bytes_static_size.
  • benches/try_read_from_bytes.x86-64.mca
    • Added machine code analysis for try_read_from_bytes_static_size.
  • benches/try_read_from_prefix.rs
    • Added a new benchmark for try_read_from_prefix with static size.
  • benches/try_read_from_prefix.x86-64
    • Added x86-64 assembly output for try_read_from_prefix_static_size.
  • benches/try_read_from_prefix.x86-64.mca
    • Added machine code analysis for try_read_from_prefix_static_size.
  • benches/try_read_from_suffix.rs
    • Added a new benchmark for try_read_from_suffix with static size.
  • benches/try_read_from_suffix.x86-64
    • Added x86-64 assembly output for try_read_from_suffix_static_size.
  • benches/try_read_from_suffix.x86-64.mca
    • Added machine code analysis for try_read_from_suffix_static_size.
  • benches/try_ref_from_bytes.rs
    • Removed the old try_ref_from_bytes benchmark.
  • benches/try_ref_from_bytes.x86-64
    • Renamed to benches/try_ref_from_bytes_dynamic_padding.x86-64.
  • benches/try_ref_from_bytes.x86-64.mca
    • Renamed to benches/try_ref_from_bytes_dynamic_padding.x86-64.mca.
  • benches/try_ref_from_bytes_dynamic_padding.rs
    • Added a new benchmark for try_ref_from_bytes with dynamic padding.
  • benches/try_ref_from_bytes_dynamic_size.rs
    • Added a new benchmark for try_ref_from_bytes with dynamic size.
  • benches/try_ref_from_bytes_dynamic_size.x86-64
    • Added x86-64 assembly output for try_ref_from_bytes_dynamic_size.
  • benches/try_ref_from_bytes_dynamic_size.x86-64.mca
    • Added machine code analysis for try_ref_from_bytes_dynamic_size.
  • benches/try_ref_from_bytes_static_size.rs
    • Added a new benchmark for try_ref_from_bytes with static size.
  • benches/try_ref_from_bytes_static_size.x86-64
    • Added x86-64 assembly output for try_ref_from_bytes_static_size.
  • benches/try_ref_from_bytes_static_size.x86-64.mca
    • Added machine code analysis for try_ref_from_bytes_static_size.
  • benches/try_ref_from_bytes_with_elems.rs
    • Removed the old try_ref_from_bytes_with_elems benchmark.
  • benches/try_ref_from_bytes_with_elems.x86-64
    • Renamed to benches/try_ref_from_bytes_with_elems_dynamic_padding.x86-64.
  • benches/try_ref_from_bytes_with_elems.x86-64.mca
    • Renamed to benches/try_ref_from_bytes_with_elems_dynamic_padding.x86-64.mca.
  • benches/try_ref_from_bytes_with_elems_dynamic_padding.rs
    • Added a new benchmark for try_ref_from_bytes_with_elems with dynamic padding.
  • benches/try_ref_from_bytes_with_elems_dynamic_size.rs
    • Added a new benchmark for try_ref_from_bytes_with_elems with dynamic size.
  • benches/try_ref_from_bytes_with_elems_dynamic_size.x86-64
    • Added x86-64 assembly output for try_ref_from_bytes_with_elems_dynamic_size.
  • benches/try_ref_from_bytes_with_elems_dynamic_size.x86-64.mca
    • Added machine code analysis for try_ref_from_bytes_with_elems_dynamic_size.
  • benches/try_ref_from_prefix.rs
    • Renamed to benches/try_ref_from_prefix_static_size.rs and updated its path.
  • benches/try_ref_from_prefix.x86-64
    • Renamed to benches/try_ref_from_prefix_dynamic_padding.x86-64.
  • benches/try_ref_from_prefix.x86-64.mca
    • Renamed to benches/try_ref_from_prefix_dynamic_padding.x86-64.mca.
  • benches/try_ref_from_prefix_dynamic_padding.rs
    • Added a new benchmark for try_ref_from_prefix with dynamic padding.
  • benches/try_ref_from_prefix_dynamic_size.rs
    • Added a new benchmark for try_ref_from_prefix with dynamic size.
  • benches/try_ref_from_prefix_dynamic_size.x86-64
    • Added x86-64 assembly output for try_ref_from_prefix_dynamic_size.
  • benches/try_ref_from_prefix_dynamic_size.x86-64.mca
    • Added machine code analysis for try_ref_from_prefix_dynamic_size.
  • benches/try_ref_from_prefix_static_size.x86-64
    • Added x86-64 assembly output for try_ref_from_prefix_static_size.
  • benches/try_ref_from_prefix_static_size.x86-64.mca
    • Added machine code analysis for try_ref_from_prefix_static_size.
  • benches/try_ref_from_prefix_with_elems.rs
    • Renamed to benches/try_ref_from_prefix_with_elems_dynamic_size.rs and updated its path.
  • benches/try_ref_from_prefix_with_elems.x86-64
    • Renamed to benches/try_ref_from_prefix_with_elems_dynamic_padding.x86-64.
  • benches/try_ref_from_prefix_with_elems.x86-64.mca
    • Renamed to benches/try_ref_from_prefix_with_elems_dynamic_padding.x86-64.mca.
  • benches/try_ref_from_prefix_with_elems_dynamic_padding.rs
    • Added a new benchmark for try_ref_from_prefix_with_elems with dynamic padding.
  • benches/try_ref_from_prefix_with_elems_dynamic_size.x86-64
    • Added x86-64 assembly output for try_ref_from_prefix_with_elems_dynamic_size.
  • benches/try_ref_from_prefix_with_elems_dynamic_size.x86-64.mca
    • Added machine code analysis for try_ref_from_prefix_with_elems_dynamic_size.
  • benches/try_ref_from_suffix.rs
    • Renamed to benches/try_ref_from_suffix_static_size.rs and updated its path.
  • benches/try_ref_from_suffix.x86-64
    • Renamed to benches/try_ref_from_suffix_dynamic_padding.x86-64.
  • benches/try_ref_from_suffix.x86-64.mca
    • Renamed to benches/try_ref_from_suffix_dynamic_padding.x86-64.mca.
  • benches/try_ref_from_suffix_dynamic_padding.rs
    • Added a new benchmark for try_ref_from_suffix with dynamic padding.
  • benches/try_ref_from_suffix_dynamic_size.rs
    • Added a new benchmark for try_ref_from_suffix with dynamic size.
  • benches/try_ref_from_suffix_dynamic_size.x86-64
    • Added x86-64 assembly output for try_ref_from_suffix_dynamic_size.
  • benches/try_ref_from_suffix_dynamic_size.x86-64.mca
    • Added machine code analysis for try_ref_from_suffix_dynamic_size.
  • benches/try_ref_from_suffix_static_size.x86-64
    • Added x86-64 assembly output for try_ref_from_suffix_static_size.
  • benches/try_ref_from_suffix_static_size.x86-64.mca
    • Added machine code analysis for try_ref_from_suffix_static_size.
  • benches/try_ref_from_suffix_with_elems.rs
    • Renamed to benches/try_ref_from_suffix_with_elems_dynamic_size.rs and updated its path.
  • benches/try_ref_from_suffix_with_elems.x86-64
    • Renamed to benches/try_ref_from_suffix_with_elems_dynamic_padding.x86-64.
  • benches/try_ref_from_suffix_with_elems.x86-64.mca
    • Renamed to benches/try_ref_from_suffix_with_elems_dynamic_padding.x86-64.mca.
  • benches/try_ref_from_suffix_with_elems_dynamic_padding.rs
    • Added a new benchmark for try_ref_from_suffix_with_elems with dynamic padding.
  • benches/try_ref_from_suffix_with_elems_dynamic_size.x86-64
    • Added x86-64 assembly output for try_ref_from_suffix_with_elems_dynamic_size.
  • benches/try_ref_from_suffix_with_elems_dynamic_size.x86-64.mca
    • Added machine code analysis for try_ref_from_suffix_with_elems_dynamic_size.
  • benches/try_transmute_ref.rs
    • Renamed to benches/try_transmute_ref_dynamic_size.rs and updated its path.
  • benches/try_transmute_ref.x86-64
    • Renamed to benches/try_transmute_ref_dynamic_size.x86-64.
  • benches/try_transmute_ref.x86-64.mca
    • Renamed to benches/try_transmute_ref_dynamic_size.x86-64.mca.
  • benches/try_transmute_ref_static_size.rs
    • Added a new benchmark for try_transmute_ref with static size.
  • benches/try_transmute_ref_static_size.x86-64
    • Added x86-64 assembly output for try_transmute_ref_static_size.
  • benches/try_transmute_ref_static_size.x86-64.mca
    • Added machine code analysis for try_transmute_ref_static_size.
  • rustdoc/style.css
    • Updated CSS for codegen tabs to use a CSS variable for column count and added styling for the 'Click one of the above headers' message.
    • Updated the CSS selector for open details summary to use the direct child combinator.
  • src/lib.rs
    • Updated documentation for TryFromBytes and FromBytes traits to use the new codegen_section! macro, enabling multi-variant codegen displays.
  • src/macros.rs
    • Updated documentation for transmute_ref! and try_transmute_ref! macros to use the new codegen_section! macro.
  • src/util/macros.rs
    • Introduced new macros (docstring!, tabs!, codegen_example!, codegen_example_suite!, codegen_preamble!, codegen_section!) to improve modularity and flexibility of codegen documentation.
  • tests/codegen.rs
    • Added a println! to show which codegen test is running and removed a redundant println!.
  • tools/doc.sh
    • Removed the --generate-macro-expansion flag from the rustdoc command.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@codecov-commenter
Copy link

codecov-commenter commented Mar 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.87%. Comparing base (098b966) to head (3c652d7).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3085   +/-   ##
=======================================
  Coverage   91.87%   91.87%           
=======================================
  Files          20       20           
  Lines        6057     6057           
=======================================
  Hits         5565     5565           
  Misses        492      492           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a significant refactoring of the benchmark tests and their documentation to showcase codegen under different data layouts. The changes are extensive, renaming and adding many files to create separate benchmarks for static_size, dynamic_size, and dynamic_padding layouts. The documentation macros have been completely overhauled for better modularity and to support these new tabbed examples. While the changes are generally excellent, I've found a minor issue in the CSS and a potential improvement in the new macro definitions.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request is a significant and well-executed refactoring of the code generation documentation. It introduces a more flexible and powerful macro-based system for generating documentation with tabbed examples for different memory layouts. This greatly improves the documentation's utility for understanding the relationship between type complexity and codegen complexity. The addition of new benchmark variants for static size, dynamic size, and dynamic padding is also a valuable improvement to the test suite's robustness. The changes are consistent and well-structured. I have one suggestion to improve the documentation further.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the code generation benchmark documentation within the zerocopy crate. The changes involve replacing the existing codegen_tabs! macro with a new, more flexible suite of macros (tabs!, codegen_example!, codegen_example_suite!, codegen_preamble!, and codegen_section!). This new macro system allows for the documentation of multiple benchmark variants (static size, dynamic size, and dynamic padding) using HTML tabs in rustdoc, providing a more organized and detailed view of code generation. Consequently, numerous benchmark definitions in src/lib.rs and src/macros.rs have been updated to utilize the new codegen_section! macro, and new benchmark files, along with their assembly and machine code analysis outputs, have been added for these variants. The rustdoc/style.css file was also updated to support the new tabbed layout. Review comments indicate issues with the new documentation macros, specifically that the tabs! macro incorrectly generates the open HTML attribute, contains a stray backslash in its output, and has a mismatch in how it expects the open argument from codegen_example_suite!. The reviewer suggests using helper arms in the tabs! macro to correctly handle the optional open attribute.

Note: Security Review did not run due to the size of the PR.

@jswrenn jswrenn force-pushed the G39e297d5b891f5115ef9607b090c5fbe95427d68 branch from 6f24e9a to efab483 Compare March 6, 2026 20:54
@jswrenn jswrenn force-pushed the G39e297d5b891f5115ef9607b090c5fbe95427d68 branch 2 times, most recently from 89ab1c2 to a9921b5 Compare March 6, 2026 23:53
@jswrenn jswrenn force-pushed the G04affc58395810ba04b941f14dfdc20563fa850b branch from 11a76fa to 57741d2 Compare March 6, 2026 23:53
@jswrenn jswrenn force-pushed the G39e297d5b891f5115ef9607b090c5fbe95427d68 branch from a9921b5 to 87f0c90 Compare March 7, 2026 00:35
@jswrenn jswrenn force-pushed the G04affc58395810ba04b941f14dfdc20563fa850b branch from 57741d2 to 5eafa06 Compare March 7, 2026 00:35
Base automatically changed from G04affc58395810ba04b941f14dfdc20563fa850b to main March 7, 2026 01:10
@jswrenn jswrenn force-pushed the G39e297d5b891f5115ef9607b090c5fbe95427d68 branch from 87f0c90 to 95834fc Compare March 8, 2026 23:31
@jswrenn jswrenn enabled auto-merge March 8, 2026 23:34
@jswrenn jswrenn force-pushed the G39e297d5b891f5115ef9607b090c5fbe95427d68 branch from 95834fc to 1662134 Compare March 8, 2026 23:41
This improves the robustness of our suite to different code paths, and
illustrates in our documentation the relationship between type
complexity and codegen complexity.

gherrit-pr-id: G39e297d5b891f5115ef9607b090c5fbe95427d68
@jswrenn jswrenn force-pushed the G39e297d5b891f5115ef9607b090c5fbe95427d68 branch from 1662134 to f5a1f81 Compare March 9, 2026 00:17
@jswrenn jswrenn added this pull request to the merge queue Mar 9, 2026
Merged via the queue into main with commit fc73624 Mar 9, 2026
105 checks passed
@jswrenn jswrenn deleted the G39e297d5b891f5115ef9607b090c5fbe95427d68 branch March 9, 2026 03:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants