Skip to content

Implement base class upcast Debug formatting.#1394

Open
copybara-service[bot] wants to merge 1 commit into
mainfrom
test_937701662
Open

Implement base class upcast Debug formatting.#1394
copybara-service[bot] wants to merge 1 commit into
mainfrom
test_937701662

Conversation

@copybara-service

Copy link
Copy Markdown

Implement base class upcast Debug formatting.

This CL adds support for formatting C++ base classes in generated Rust Debug
implementations (under the experimental feature flag).

Key behaviors:

  • When generating Debug for a C++ record, if the target has experimental enabled, it formats all public, unambiguous, non-virtual base classes that themselves implement Debug.
  • Bases are formatted as anonymous components using an empty string for the field name (e.g., derived_field("", &self.base_field)), which formats as : Base in Rust (e.g. PubliclyDerived { : Base, .. }).
  • Refactors cc_struct_upcast_impl to return the list of successfully verified upcastable base records, allowing the formatting generator to reuse the exact same validation and upcasting logic.
  • Isolates experimental inheritance tests into a separate derived_debuggables library and derived_debuggables_test target in test/debug/, enabled only with the experimental aspect hint.
  • Regenerates inheritance golden files to verify the anonymous base formatting.
  • Adds a unit test test_template_specialization_override_debug_propagation in ir_from_cc_test.rs to verify that the crubit_override_debug annotation propagates correctly to template specializations used as bases (working around the importer's template traversal limitation using C++ type aliases).

@google-cla

google-cla Bot commented Jul 9, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

This CL adds support for formatting C++ base classes in generated Rust `Debug`
implementations (under the `experimental` feature flag).

Key behaviors:
*   When generating `Debug` for a C++ record, if the target has `experimental` enabled, it formats all public, unambiguous, non-virtual base classes that themselves implement `Debug`.
*   Bases are formatted as anonymous components using an empty string for the field name (e.g., `derived_field("", &self.base_field)`), which formats as `: Base` in Rust (e.g. `PubliclyDerived { : Base, .. }`).
*   Refactors `cc_struct_upcast_impl` to return the list of successfully verified upcastable base records, allowing the formatting generator to reuse the exact same validation and upcasting logic.
*   Isolates experimental inheritance tests into a separate `derived_debuggables` library and `derived_debuggables_test` target in `test/debug/`, enabled only with the `experimental` aspect hint.
*   Regenerates inheritance golden files to verify the anonymous base formatting.
*   Adds a unit test `test_template_specialization_override_debug_propagation` in `ir_from_cc_test.rs` to verify that the `crubit_override_debug` annotation propagates correctly to template specializations used as bases (working around the importer's template traversal limitation using C++ type aliases).

PiperOrigin-RevId: 937701662
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.

0 participants