From f5f7456e7c7969ae8e6b6340fa63d17c83a39d14 Mon Sep 17 00:00:00 2001 From: Nick Allison Date: Tue, 15 Apr 2025 10:38:17 -0600 Subject: [PATCH] Added Debug information to layout error --- bindgen/codegen/mod.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bindgen/codegen/mod.rs b/bindgen/codegen/mod.rs index 8da10ff051..682a29437a 100644 --- a/bindgen/codegen/mod.rs +++ b/bindgen/codegen/mod.rs @@ -2339,6 +2339,17 @@ impl CodeGenerator for CompInfo { } else if is_union && !forward_decl { // TODO(emilio): It'd be nice to unify this with the struct path // above somehow. + if layout.is_none() { + let location_option = item.location(); + let error = match location_option { + Some(location) => format!( + "Unable to get layout information from: {location}" + ), + None => "Unable to get layout information or location" + .to_string(), + }; + panic!("{}", error); + } let layout = layout.expect("Unable to get layout information?"); if struct_layout.requires_explicit_align(layout) { explicit_align = Some(layout.align);