Skip to content

Commit f5f7456

Browse files
committed
Added Debug information to layout error
1 parent 97ab915 commit f5f7456

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

bindgen/codegen/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2339,6 +2339,17 @@ impl CodeGenerator for CompInfo {
23392339
} else if is_union && !forward_decl {
23402340
// TODO(emilio): It'd be nice to unify this with the struct path
23412341
// above somehow.
2342+
if layout.is_none() {
2343+
let location_option = item.location();
2344+
let error = match location_option {
2345+
Some(location) => format!(
2346+
"Unable to get layout information from: {location}"
2347+
),
2348+
None => "Unable to get layout information or location"
2349+
.to_string(),
2350+
};
2351+
panic!("{}", error);
2352+
}
23422353
let layout = layout.expect("Unable to get layout information?");
23432354
if struct_layout.requires_explicit_align(layout) {
23442355
explicit_align = Some(layout.align);

0 commit comments

Comments
 (0)