Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1504,14 +1504,15 @@ impl CodeGenerator for CompInfo {
continue;
}

let inner = base.ty.to_rust_ty_or_opaque(ctx, &());
let inner_item = ctx.resolve_item(base.ty);
let mut inner = inner_item.to_rust_ty_or_opaque(ctx, &());
inner.append_implicit_template_params(ctx, &inner_item);
let field_name = ctx.rust_ident(&base.field_name);

let base_ty = ctx.resolve_type(base.ty);
struct_layout.saw_base(base_ty);
struct_layout.saw_base(inner_item.expect_type());

fields.push(quote! {
pub #field_name : #inner ,
pub #field_name: #inner,
});
}
}
Expand Down
36 changes: 36 additions & 0 deletions tests/expectations/tests/issue-1514.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* automatically generated by rust-bindgen */

#![allow(
dead_code,
non_snake_case,
non_camel_case_types,
non_upper_case_globals
)]

#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Thing {
pub _address: u8,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct Thing_Inner<T> {
pub ptr: *mut T,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
impl<T> Default for Thing_Inner<T> {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
}
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct Thing_AnotherInner<T> {
pub _base: Thing_Inner<T>,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
impl<T> Default for Thing_AnotherInner<T> {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
}
}
9 changes: 9 additions & 0 deletions tests/headers/issue-1514.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
template<typename T>
struct Thing {
struct Inner {
T *ptr;
};

struct AnotherInner : Inner {
};
};