diff options
-rw-r--r-- | src/ir/context.rs | 12 | ||||
-rw-r--r-- | src/ir/item.rs | 2 | ||||
-rw-r--r-- | tests/expectations/replaces_double.rs | 15 | ||||
-rw-r--r-- | tests/headers/replaces_double.hpp | 20 |
4 files changed, 46 insertions, 3 deletions
diff --git a/src/ir/context.rs b/src/ir/context.rs index 07e93359..e6659697 100644 --- a/src/ir/context.rs +++ b/src/ir/context.rs @@ -647,10 +647,18 @@ impl<'ctx> BindgenContext<'ctx> { self.replacements.insert(name.into(), potential_ty); } - pub fn hidden_by_name(&self, name: &str) -> bool { + pub fn hidden_by_name(&self, name: &str, id: ItemId) -> bool { debug_assert!(self.in_codegen_phase(), "You're not supposed to call this yet"); - self.options.hidden_types.contains(name) + self.options.hidden_types.contains(name) || + self.is_replaced_type(name, id) + } + + pub fn is_replaced_type(&self, name: &str, id: ItemId) -> bool { + match self.replacements.get(name) { + Some(replaced_by) if *replaced_by != id => true, + _ => false, + } } pub fn opaque_by_name(&self, name: &str) -> bool { diff --git a/src/ir/item.rs b/src/ir/item.rs index 80085c8b..56ddf639 100644 --- a/src/ir/item.rs +++ b/src/ir/item.rs @@ -247,7 +247,7 @@ impl Item { debug_assert!(ctx.in_codegen_phase(), "You're not supposed to call this yet"); self.annotations.hide() || - ctx.hidden_by_name(&self.real_canonical_name(ctx, false)) + ctx.hidden_by_name(&self.real_canonical_name(ctx, false), self.id) } pub fn is_opaque(&self, ctx: &BindgenContext) -> bool { diff --git a/tests/expectations/replaces_double.rs b/tests/expectations/replaces_double.rs new file mode 100644 index 00000000..50dafd42 --- /dev/null +++ b/tests/expectations/replaces_double.rs @@ -0,0 +1,15 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct Rooted<T> { + pub ptr: Rooted_MaybeWrapped<T>, +} +/** + * <div rustbindgen replaces="Rooted_MaybeWrapped"></div> + */ +pub type Rooted_MaybeWrapped<T> = T; diff --git a/tests/headers/replaces_double.hpp b/tests/headers/replaces_double.hpp new file mode 100644 index 00000000..1a78b0d9 --- /dev/null +++ b/tests/headers/replaces_double.hpp @@ -0,0 +1,20 @@ +// bindgen-flags: --blacklist-type Wrapper -- --std=c++11 + +template<typename T> +struct Wrapper { + struct Wrapped { + T t; + }; + using Type = Wrapped; +}; + +template<typename T> +class Rooted { + using MaybeWrapped = typename Wrapper<T>::Type; + MaybeWrapped ptr; + + /** + * <div rustbindgen replaces="Rooted_MaybeWrapped"></div> + */ + using MaybeWrapped_simple = T; +}; |