[Feat][Rust] Add leaf lookup dispatch for match_any#685
Conversation
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
There was a problem hiding this comment.
Why we need to add modules here instead of in tests
| let type_key = get_attr(&derive_input, "type_key") | ||
| .map(attr_to_str) | ||
| .expect("Expect #[type_key = \"<my_type_key>\"] attribute"); | ||
| let type_final = match get_attr(&derive_input, "type_final") { |
There was a problem hiding this comment.
I think type_final can be false in cpp side?
There was a problem hiding this comment.
Yes. false is the default, so a type whose C++ definition has _type_final = false simply omits the attribute.
There was a problem hiding this comment.
Tests should not be here. why we have another file for match_any
| /// Whether every instance of this type has exactly `Self::type_index()`. | ||
| /// | ||
| /// A final type must never have a registered subtype. | ||
| #[doc(hidden)] |
There was a problem hiding this comment.
I'm not sure if it's necessary. I think ObjectCore is not designed to be exposed to users.
There was a problem hiding this comment.
ObjectCore is already public because downstream #[derive(Object)]expansions need it; TYPE_FINAL is default-false and #[doc(hidden)], so it remains internal derive metadata rather than a user-facing API.
This PR adds a leaf-only lookup fast path to Rust match_any!. For at least two unguarded arms with simple bindings, when every pattern corresponds to one stable runtime TypeIndex, it lazily maps each TypeIndex to a source-order ArmId and uses a native Rust match to select only the relevant conversion. The table stores no closures or arm bodies, duplicate types preserve first-arm semantics, and misses use the _ fallback. Single-arm, guarded, non-leaf/category, or content-dependent matches retain the Phase 1 ordered path. The PR also adds opt-in final-type metadata and focused integration tests. The two-arm threshold is based on release benchmarks of standard ObjectRef conversions.