From ce2917250db42f087feb48b132f40f84560aeaa0 Mon Sep 17 00:00:00 2001 From: Michael VanBemmel Date: Thu, 13 Nov 2025 01:52:50 -0800 Subject: [PATCH] Refine PartialEq binding generation to support C++ types with only operator!=. Rust's PartialEq trait requires an eq method. Previously, Crubit could not generate bindings for C++ types that only overloaded operator!=. This CL addresses this by generating an eq implementation that calls the C++ operator!= thunk and negates its result. Additionally, when a C++ type overloads both operator== and operator!=, it avoids generating a binding for operator!=. Instead, it relies on the default ne implementation provided by Rust's PartialEq trait, which is more idiomatic and avoids a redundant thunk. PiperOrigin-RevId: 831756584 --- rs_bindings_from_cc/test/golden/nontrivial_type_rs_api.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rs_bindings_from_cc/test/golden/nontrivial_type_rs_api.rs b/rs_bindings_from_cc/test/golden/nontrivial_type_rs_api.rs index 5baeedef9..6d96e3296 100644 --- a/rs_bindings_from_cc/test/golden/nontrivial_type_rs_api.rs +++ b/rs_bindings_from_cc/test/golden/nontrivial_type_rs_api.rs @@ -182,7 +182,7 @@ impl Nontrivial { // //rs_bindings_from_cc/test/golden:nontrivial_type_cc needs [//features:experimental] for Nontrivial::operator== (the type of rhs (parameter #1): references are not supported) // Error while generating bindings for function 'Nontrivial::operator!=': -// operator== is present, skipping bindings for operator!= +// Bindings for this kind of operator (operator != with 2 parameter(s)) are not supported // Error while generating bindings for function 'Nontrivial::operator<': // Can't generate bindings for Nontrivial::operator<, because of missing required features ():