Emit debug size/align checks for type map overrides.
This is not an in-depth guarantee of correctness, but it does catch obvious mistakes.
Mistakes it does not catch: mismatch in C ABI when calling by value; mismatch in field offsets; breakage of internal invariants due to incorrect actual values (e.g. std::vector with size > capacity, that sort of thing).
PiperOrigin-RevId: 532188571
diff --git a/rs_bindings_from_cc/ir.rs b/rs_bindings_from_cc/ir.rs
index b20c909..083b036 100644
--- a/rs_bindings_from_cc/ir.rs
+++ b/rs_bindings_from_cc/ir.rs
@@ -517,6 +517,13 @@
#[derive(Debug, PartialEq, Eq, Hash, Clone, Deserialize)]
#[serde(deny_unknown_fields)]
+pub struct SizeAlign {
+ pub size: usize,
+ pub alignment: usize,
+}
+
+#[derive(Debug, PartialEq, Eq, Hash, Clone, Deserialize)]
+#[serde(deny_unknown_fields)]
pub struct Record {
pub rs_name: Rc<str>,
pub cc_name: Rc<str>,
@@ -531,8 +538,7 @@
pub unambiguous_public_bases: Vec<BaseClass>,
pub fields: Vec<Field>,
pub lifetime_params: Vec<LifetimeName>,
- pub size: usize,
- pub alignment: usize,
+ pub size_align: SizeAlign,
pub is_derived_class: bool,
pub override_alignment: bool,
pub copy_constructor: SpecialMemberFunc,
@@ -798,6 +804,7 @@
#[serde(rename(deserialize = "type"))]
pub type_: MappedType,
pub owning_target: BazelLabel,
+ pub size_align: Option<SizeAlign>,
pub id: ItemId,
}