Implement base class upcast Debug formatting.#1394
Open
copybara-service[bot] wants to merge 1 commit into
Open
Implement base class upcast Debug formatting.#1394copybara-service[bot] wants to merge 1 commit into
copybara-service[bot] wants to merge 1 commit into
Conversation
|
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
246e8f7 to
a1a0339
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement base class upcast Debug formatting.
This CL adds support for formatting C++ base classes in generated Rust
Debugimplementations (under the
experimentalfeature flag).Key behaviors:
Debugfor a C++ record, if the target hasexperimentalenabled, it formats all public, unambiguous, non-virtual base classes that themselves implementDebug.derived_field("", &self.base_field)), which formats as: Basein Rust (e.g.PubliclyDerived { : Base, .. }).cc_struct_upcast_implto return the list of successfully verified upcastable base records, allowing the formatting generator to reuse the exact same validation and upcasting logic.derived_debuggableslibrary andderived_debuggables_testtarget intest/debug/, enabled only with theexperimentalaspect hint.test_template_specialization_override_debug_propagationinir_from_cc_test.rsto verify that thecrubit_override_debugannotation propagates correctly to template specializations used as bases (working around the importer's template traversal limitation using C++ type aliases).