Skip to content

501: feat: Use macrotest to test the expanded macro code#62

Open
martin-augment wants to merge 6 commits intomainfrom
pr-501-2026-03-05-13-03-08
Open

501: feat: Use macrotest to test the expanded macro code#62
martin-augment wants to merge 6 commits intomainfrom
pr-501-2026-03-05-13-03-08

Conversation

@martin-augment
Copy link
Copy Markdown
Owner

501: To review by AI

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 5, 2026

Walkthrough

The pull request enhances the Avro schema derivation macro by improving code generation quality through fully-qualified type paths (e.g., ::std::option::Option::Some instead of Some) and explicit container initialization (e.g., BTreeMap::new() instead of Default::default()). It introduces macro expansion testing infrastructure via the macrotest crate, adding comprehensive test coverage with captured macro expansions for enum defaults, field attributes, renaming strategies, namespaces, and error conditions. The CI workflow is updated to use taiki-e/install-action for dependency installation, and license configuration is modified to exclude generated test files.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch pr-501-2026-03-05-13-03-08

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Copy Markdown

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 enhances the testing infrastructure for the avro_derive procedural macro. By integrating the macrotest crate, the project can now automatically verify the expanded macro code, ensuring correctness and simplifying future development. This change also standardizes how Option and BTreeMap are initialized within the generated code, improving consistency. The old, manually asserted macro tests have been replaced with a more automated and scalable testing approach, including new UI tests for compile-time errors.

Highlights

  • Macro Testing Improvement: Refactored macro expansion tests to utilize the macrotest crate, enabling more robust and maintainable testing of generated code.
  • Standardized Code Generation: Updated generated code to use fully qualified paths for Option and BTreeMap initializations (e.g., ::std::option::Option::None and ::std::collections::BTreeMap::new()) for consistency and clarity.
  • New Test Infrastructure: Introduced new expanded and ui test directories, with .rs and .expanded.rs files for macro expansion tests and .rs and .stderr files for compile-time error tests, respectively.
  • Removed Legacy Tests: Eliminated a large suite of manual macro tests from avro_derive/src/lib.rs in favor of the new macrotest-based approach.
Changelog
  • Cargo.lock
    • Added macrotest and fastrand dependencies to support new macro testing framework.
  • avro_derive/Cargo.toml
    • Added macrotest as a development dependency for macro expansion testing.
  • avro_derive/src/enums/plain.rs
    • Removed a redundant full_schema_name variable.
    • Standardized BTreeMap initialization to ::std::collections::BTreeMap::new().
  • avro_derive/src/lib.rs
    • Replaced direct None with ::std::option::Option::None for optional values.
    • Updated expect message for JSON parsing to be more concise.
    • Standardized Vec and BTreeMap initializations with fully qualified paths.
    • Removed extensive manual macro tests, replacing them with macrotest-based files.
  • avro_derive/tests/expand.rs
    • Added a new test file to run macrotest on macro expansions, ignoring on non-nightly Rust versions.
  • avro_derive/tests/expanded/avro_3687_basic_enum_with_default.expanded.rs
    • Added expanded macro output for basic enum with default variant.
  • avro_derive/tests/expanded/avro_3687_basic_enum_with_default.rs
    • Added source file for basic enum with default variant for macro expansion testing.
  • avro_derive/tests/expanded/avro_3709_record_field_attributes.expanded.rs
    • Added expanded macro output for record field attributes.
  • avro_derive/tests/expanded/avro_3709_record_field_attributes.rs
    • Added source file for record field attributes for macro expansion testing.
  • avro_derive/tests/expanded/avro_rs_207_rename_all_attribute.expanded.rs
    • Added expanded macro output for rename_all attribute.
  • avro_derive/tests/expanded/avro_rs_207_rename_all_attribute.rs
    • Added source file for rename_all attribute for macro expansion testing.
  • avro_derive/tests/expanded/avro_rs_207_rename_attr_over_rename_all_attribute.expanded.rs
    • Added expanded macro output for rename attribute overriding rename_all.
  • avro_derive/tests/expanded/avro_rs_207_rename_attr_over_rename_all_attribute.rs
    • Added source file for rename attribute overriding rename_all for macro expansion testing.
  • avro_derive/tests/expanded/avro_rs_501_basic.expanded.rs
    • Added expanded macro output for basic struct and enum.
  • avro_derive/tests/expanded/avro_rs_501_basic.rs
    • Added source file for basic struct and enum for macro expansion testing.
  • avro_derive/tests/expanded/avro_rs_501_namespace.expanded.rs
    • Added expanded macro output for struct with namespace attribute.
  • avro_derive/tests/expanded/avro_rs_501_namespace.rs
    • Added source file for struct with namespace attribute for macro expansion testing.
  • avro_derive/tests/expanded/avro_rs_501_reference.expanded.rs
    • Added expanded macro output for struct with references.
  • avro_derive/tests/expanded/avro_rs_501_reference.rs
    • Added source file for struct with references for macro expansion testing.
  • avro_derive/tests/expanded/avro_rs_501_struct_with_optional.expanded.rs
    • Added expanded macro output for struct with optional field.
  • avro_derive/tests/expanded/avro_rs_501_struct_with_optional.rs
    • Added source file for struct with optional field for macro expansion testing.
  • avro_derive/tests/expanded/mod.rs
    • Added module declaration for new macro expansion test files.
  • avro_derive/tests/ui/avro_3687_basic_enum_with_default_twice.rs
    • Added UI test for enums with multiple default variants.
  • avro_derive/tests/ui/avro_3687_basic_enum_with_default_twice.stderr
    • Added expected stderr output for multiple default enum UI test.
  • avro_derive/tests/ui/avro_rs_501_non_basic_enum.rs
    • Added UI test for enums with non-unit struct variants.
  • avro_derive/tests/ui/avro_rs_501_non_basic_enum.stderr
    • Added expected stderr output for non-unit struct enum UI test.
  • avro_derive/tests/ui/avro_rs_501_tuple_struct.rs
    • Added UI test for tuple structs.
  • avro_derive/tests/ui/avro_rs_501_tuple_struct.stderr
    • Added expected stderr output for tuple struct UI test.
  • avro_derive/tests/ui/avro_rs_501_unit_struct.rs
    • Added UI test for unit structs.
  • avro_derive/tests/ui/avro_rs_501_unit_struct.stderr
    • Added expected stderr output for unit struct UI test.
  • licenserc.toml
    • Excluded .expanded.rs files from license header checks.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/test-lang-rust-ci.yml
Activity
  • The pull request was created by martin-augment with the title '501: feat: Use macrotest to test the expanded macro code' and a description indicating it is 'To review by AI'.
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.

@claude
Copy link
Copy Markdown

claude bot commented Mar 5, 2026

PR Review: Use macrotest to test the expanded macro code

Overall this is a well-structured improvement. Replacing brittle raw-string token comparisons with macrotest snapshot tests is the right direction for testing proc-macros. Here are my findings:

Positives

  • Testing approach: macrotest snapshot tests are far more readable and maintainable than manually comparing raw TokenStream strings. The old avro_3687_basic_enum_with_default test maintained massive unreadable string literals.
  • UI tests: Adding trybuild-style UI tests (.rs + .stderr pairs) for compile-error cases is excellent — much more precise than assert!(derived.is_err()).
  • Bug fix in enums/plain.rs: Reusing the already-computed name variable instead of re-creating Name::new(#full_schema_name) is a meaningful correctness fix — the original code was ignoring namespace context when constructing the EnumSchema name field.
  • Fully-qualified paths: Changing None to ::std::option::Option::None, apache_avro:: to ::apache_avro::, and Default::default() to ::std::collections::BTreeMap::new() is good proc-macro hygiene that reduces the risk of collisions with local bindings in user code.
  • CI simplification: Replacing the hand-rolled cargo install + cache steps for cargo-rdme with taiki-e/install-action@v2 is cleaner. The old cache key cargo-rdme- had no meaningful hash and never actually cached anything.

Concerns

1. Expanded snapshots contain nightly-internal APIs (high risk of spurious CI failures)

The .expanded.rs files contain unstable Rust internals that change between nightly versions:

symbols: ::alloc::boxed::box_assume_init_into_vec_unsafe(
    ::alloc::intrinsics::write_box_via_move(
        ::alloc::boxed::Box::new_uninit(),
        [...],
    ),
),

This is the nightly-specific expansion of vec![] and changes frequently. The CI matrix does not pin a nightly version, so macrotest will fail whenever GitHub Actions upgrades the nightly toolchain — breakage completely unrelated to any actual macro change.

Suggestion: Pin the nightly version using toolchain: nightly-YYYY-MM-DD in the dtolnay/rust-toolchain step for the nightly matrix entry. At minimum, document the update procedure so contributors know to run MACROTEST=overwrite cargo +nightly test expand to regenerate snapshots after a nightly bump.

2. cargo-expand is installed before actions/checkout

The two new taiki-e/install-action steps are placed before the actions/checkout step. This works, but conventional workflow ordering is to checkout first. Consider reordering for clarity.

3. Single test function for all expansion cases

pub fn expand() {
    macrotest::expand("tests/expanded/avro_*.rs");
}

If any snapshot fails, the entire test fails together. Individual #[test] functions per expanded case would give cleaner output and allow running cases in isolation. Minor style point.

4. No documentation for updating snapshots

There is no mention of how to regenerate snapshots when the macro output legitimately changes. Consider adding a comment in expand.rs noting how to run MACROTEST=overwrite cargo +nightly test expand to update snapshots.

Minor notes

  • licenserc.toml: Correctly excludes *.expanded.rs from license header requirements.
  • test_trait_cast was appropriately kept — it tests a pure utility function (type_to_schema_expr) not the full derive pipeline.
  • The mod.rs comment explaining why .expanded.rs files are excluded from the module tree is helpful.

Summary

The core approach is sound and a real improvement in test quality. The main actionable issue before merging is concern 1: without pinning the nightly version, these snapshot tests will generate random CI failures requiring regeneration that is unrelated to actual code changes.

Copy link
Copy Markdown

@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 macrotest to test the expanded macro code, replacing the previous inline tests. The existing tests are migrated to this new framework, using snapshot testing for successful expansions and UI tests for compile-time failures. Additionally, the generated code from the derive macro is updated to use fully qualified paths for types from the standard library, which makes the macro expansion more robust.

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

::apache_avro::schema::Schema::Enum(apache_avro::schema::EnumSchema {
name: ::apache_avro::schema::Name::new(#full_schema_name).expect(&format!("Unable to parse enum name for schema {}", #full_schema_name)[..]),
::apache_avro::schema::Schema::Enum(::apache_avro::schema::EnumSchema {
name,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Enum schema name now differs from record schema name behavior

Medium Severity

The EnumSchema name field now uses the name variable from handle_named_schemas, which is created via Name::new_with_enclosing_namespace (inherits enclosing namespace). Previously it used Name::new(full_schema_name) (ignores enclosing namespace), matching the RecordSchema behavior which still creates its own name via Name::new on line 255 of lib.rs. For enums without an explicit namespace nested inside a namespaced type, the enum's schema name will now include the parent's namespace, while records in the same scenario will not.

Additional Locations (1)

Fix in Cursor Fix in Web

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

value:annoying; category:bug; feedback: The Bugbot AI reviewer is not correct! The new way of constructing the Name is similar to the old one - it still passes the full_schema_name, so it won't use any enclosing namespace if the provided name has a namespace.

fields: schema_fields,
lookup,
attributes: Default::default(),
attributes: ::std::collections::BTreeMap::new(),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Incomplete path qualification in record_fields quotation

Low Severity

The record_fields quotation uses non-fully-qualified Vec and Some, while the schema_def quotation (line 251) was updated to use ::std::vec::Vec. This inconsistency in the same function appears to be an incomplete refactoring, since the whole point of these changes was to use fully qualified paths for macrotest compatibility.

Fix in Cursor Fix in Web

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

value:good-to-have; category:bug; feedback: The Bugbot AI reviewer is correct! Rust macro quoted code should use fully qualified names to prevent clashes with symbols defined in the user code, this is the so called "macro hygiene". Prevents eventual build issues in applications which provide their own structs with names Vec and Some

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
avro_derive/src/lib.rs (1)

249-275: ⚠️ Potential issue | 🟡 Minor

Fully qualify the remaining record_fields return path symbols.

Lines 272 and 274 emit unqualified Vec and Some; these can be shadowed in user scope and cause macro expansion failures. The schema_def block at line 251 correctly uses ::std::vec::Vec, and the same qualification is needed here for consistency.

Required fix
     let record_fields = quote! {
-        let mut schema_fields = Vec::with_capacity(`#minimum_fields`);
+        let mut schema_fields = ::std::vec::Vec::with_capacity(`#minimum_fields`);
         #(`#record_field_exprs`)*
-        Some(schema_fields)
+        ::std::option::Option::Some(schema_fields)
     };
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@avro_derive/src/lib.rs` around lines 249 - 275, The record_fields quote block
uses unqualified Vec and Some which can be shadowed; update the block (symbol:
record_fields) to fully qualify those paths to match schema_def—use
::std::vec::Vec::with_capacity(`#minimum_fields`) (or ::std::vec::Vec) instead of
Vec and ::std::option::Option::Some(...) instead of Some(...); ensure the
`#record_field_exprs` insertion remains unchanged.
🧹 Nitpick comments (2)
avro_derive/tests/ui/avro_rs_501_tuple_struct.rs (1)

20-23: LGTM!

Correctly structured UI test verifying that the AvroSchema derive macro rejects tuple structs with the appropriate error message.

Minor style nit: the space between the struct name and tuple fields (struct B (i32, String)) is unconventional. Standard Rust style is struct B(i32, String). Not blocking since this is a test file.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@avro_derive/tests/ui/avro_rs_501_tuple_struct.rs` around lines 20 - 23,
Update the tuple struct declaration used in the UI test to follow conventional
Rust spacing: remove the space between the struct name and the tuple fields in
the #[derive(AvroSchema)] struct B declaration (the symbol to change is the
tuple struct "struct B (i32, String)" in the test), rewriting it as "struct
B(i32, String)" so the test file uses standard Rust style while preserving the
same semantics and error expectation.
avro_derive/tests/expand.rs (1)

22-27: LGTM!

Well-designed test harness with proper nightly gating via rustversion::attr. The approach of including mod expanded to verify the unexpanded code compiles, combined with macrotest::expand to verify the expansion output, provides comprehensive coverage.

The pub visibility on the test function is unnecessary since test functions don't need to be public. Consider removing it for consistency:

Suggested change
 #[rustversion::attr(not(nightly), ignore)]
 #[test]
-pub fn expand() {
+fn expand() {
     macrotest::expand("tests/expanded/avro_*.rs");
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@avro_derive/tests/expand.rs` around lines 22 - 27, The test function is
unnecessarily public; change the signature of the test function named expand
from "pub fn expand()" to a private test function "fn expand()" (leave the
attributes #[rustversion::attr(not(nightly), ignore)] and #[test] and the
macrotest::expand(...) call intact) so the function has default visibility for
tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@avro_derive/src/lib.rs`:
- Around line 249-275: The record_fields quote block uses unqualified Vec and
Some which can be shadowed; update the block (symbol: record_fields) to fully
qualify those paths to match schema_def—use
::std::vec::Vec::with_capacity(`#minimum_fields`) (or ::std::vec::Vec) instead of
Vec and ::std::option::Option::Some(...) instead of Some(...); ensure the
`#record_field_exprs` insertion remains unchanged.

---

Nitpick comments:
In `@avro_derive/tests/expand.rs`:
- Around line 22-27: The test function is unnecessarily public; change the
signature of the test function named expand from "pub fn expand()" to a private
test function "fn expand()" (leave the attributes
#[rustversion::attr(not(nightly), ignore)] and #[test] and the
macrotest::expand(...) call intact) so the function has default visibility for
tests.

In `@avro_derive/tests/ui/avro_rs_501_tuple_struct.rs`:
- Around line 20-23: Update the tuple struct declaration used in the UI test to
follow conventional Rust spacing: remove the space between the struct name and
the tuple fields in the #[derive(AvroSchema)] struct B declaration (the symbol
to change is the tuple struct "struct B (i32, String)" in the test), rewriting
it as "struct B(i32, String)" so the test file uses standard Rust style while
preserving the same semantics and error expectation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 000dd45c-0b2a-406a-b646-9e6525cc44fb

📥 Commits

Reviewing files that changed from the base of the PR and between 0e7917b and b0f1f60.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (31)
  • .github/workflows/test-lang-rust-ci.yml
  • avro_derive/Cargo.toml
  • avro_derive/src/enums/plain.rs
  • avro_derive/src/lib.rs
  • avro_derive/tests/expand.rs
  • avro_derive/tests/expanded/avro_3687_basic_enum_with_default.expanded.rs
  • avro_derive/tests/expanded/avro_3687_basic_enum_with_default.rs
  • avro_derive/tests/expanded/avro_3709_record_field_attributes.expanded.rs
  • avro_derive/tests/expanded/avro_3709_record_field_attributes.rs
  • avro_derive/tests/expanded/avro_rs_207_rename_all_attribute.expanded.rs
  • avro_derive/tests/expanded/avro_rs_207_rename_all_attribute.rs
  • avro_derive/tests/expanded/avro_rs_207_rename_attr_over_rename_all_attribute.expanded.rs
  • avro_derive/tests/expanded/avro_rs_207_rename_attr_over_rename_all_attribute.rs
  • avro_derive/tests/expanded/avro_rs_501_basic.expanded.rs
  • avro_derive/tests/expanded/avro_rs_501_basic.rs
  • avro_derive/tests/expanded/avro_rs_501_namespace.expanded.rs
  • avro_derive/tests/expanded/avro_rs_501_namespace.rs
  • avro_derive/tests/expanded/avro_rs_501_reference.expanded.rs
  • avro_derive/tests/expanded/avro_rs_501_reference.rs
  • avro_derive/tests/expanded/avro_rs_501_struct_with_optional.expanded.rs
  • avro_derive/tests/expanded/avro_rs_501_struct_with_optional.rs
  • avro_derive/tests/expanded/mod.rs
  • avro_derive/tests/ui/avro_3687_basic_enum_with_default_twice.rs
  • avro_derive/tests/ui/avro_3687_basic_enum_with_default_twice.stderr
  • avro_derive/tests/ui/avro_rs_501_non_basic_enum.rs
  • avro_derive/tests/ui/avro_rs_501_non_basic_enum.stderr
  • avro_derive/tests/ui/avro_rs_501_tuple_struct.rs
  • avro_derive/tests/ui/avro_rs_501_tuple_struct.stderr
  • avro_derive/tests/ui/avro_rs_501_unit_struct.rs
  • avro_derive/tests/ui/avro_rs_501_unit_struct.stderr
  • licenserc.toml

@augmentcode
Copy link
Copy Markdown

augmentcode bot commented Mar 5, 2026

🤖 Augment PR Summary

Summary: This PR switches derive-macro verification to macro-expansion based testing using macrotest, reducing reliance on brittle string comparisons.

Changes:

  • Adds macrotest as a dev-dependency for avro_derive.
  • Replaces large inline unit tests that compared TokenStream::to_string() with nightly-only macro expansion fixtures under avro_derive/tests/expanded.
  • Adds an expansion test harness (avro_derive/tests/expand.rs) and a module loader to ensure the unexpanded fixtures compile.
  • Adds new trybuild UI tests for error cases (tuple/unit structs, non-unit enums, multiple defaults).
  • Tweaks generated code to use more fully-qualified ::std::option::Option paths and explicit empty BTreeMap initializers.
  • Updates CI to install cargo-expand (nightly) and cargo-rdme, and excludes *.expanded.rs from license header checks.

Technical Notes: Expansion and UI tests are marked nightly-only because expanded output can vary with toolchain/tooling versions.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

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

Review completed. 1 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

- uses: taiki-e/install-action@v2
if: matrix.rust == 'nightly'
with:
tool: cargo-expand
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

macrotest comparisons are sensitive to cargo expand output; installing an unpinned cargo-expand version can make nightly CI fail when cargo-expand changes its formatting even if your code hasn’t. Consider pinning a specific cargo-expand version (as macrotest recommends) to reduce test flakiness.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

value:good-to-have; category:bug; feedback: The Augment AI reviewer is correct! Both macrotest and cargo-expand recommend using a pinned version to prevent random build failures when a new version is released. Prevents test failures when unrelated code changes are made.

@martin-augment
Copy link
Copy Markdown
Owner Author

22-27: LGTM!

Well-designed test harness with proper nightly gating via rustversion::attr. The approach of including mod expanded to verify the unexpanded code compiles, combined with macrotest::expand to verify the expansion output, provides comprehensive coverage.

The pub visibility on the test function is unnecessary since test functions don't need to be public. Consider removing it for consistency:

value:good-to-have; category:bug; feedback: The CodeRabbit AI reviewer is correct! There is no need the test function to be public. It does not do any harm either.

@martin-augment
Copy link
Copy Markdown
Owner Author

20-23: LGTM!

Correctly structured UI test verifying that the AvroSchema derive macro rejects tuple structs with the appropriate error message.

Minor style nit: the space between the struct name and tuple fields (struct B (i32, String)) is unconventional. Standard Rust style is struct B(i32, String). Not blocking since this is a test file.

value:good-to-have; category:bug; feedback: The CodeRabbit AI reviewer is correct! There is no need of the space between the struct name and its tuple parameters. Since cargo fmt does not complain there is no really a convention here too

@martin-augment
Copy link
Copy Markdown
Owner Author

249-275: ⚠️ Potential issue | 🟡 Minor

Fully qualify the remaining record_fields return path symbols.

Lines 272 and 274 emit unqualified Vec and Some; these can be shadowed in user scope and cause macro expansion failures. The schema_def block at line 251 correctly uses ::std::vec::Vec, and the same qualification is needed here for consistency.

value:good-to-have; category:bug; feedback: The CodeRabbit AI reviewer is correct! Rust macro quoted code should use fully qualified names to prevent clashes with symbols defined in the user code, this is the so called "macro hygiene". Prevents eventual build issues in applications which provide their own structs with names Vec and Some

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.

2 participants