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
2 changes: 1 addition & 1 deletion src/ir/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ impl<'ctx, 'gen> WhitelistedItems<'ctx, 'gen>
where R: IntoIterator<Item = ItemId>,
{
let predicate = if ctx.options().whitelist_recursively {
traversal::codegen_edges
traversal::all_edges
} else {
traversal::no_edges
};
Expand Down
28 changes: 0 additions & 28 deletions src/ir/traversal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,34 +201,6 @@ pub fn all_edges(_: &BindgenContext, _: Edge) -> bool {
true
}

/// A `TraversalPredicate` implementation that only follows edges to items that
/// are enabled for code generation. This lets us skip considering items for
/// which we won't generate any bindings to.
pub fn codegen_edges(ctx: &BindgenContext, edge: Edge) -> bool {
let cc = &ctx.options().codegen_config;
match edge.kind {
EdgeKind::Generic => ctx.resolve_item(edge.to).is_enabled_for_codegen(ctx),

// We statically know the kind of item that non-generic edges can point
// to, so we don't need to actually resolve the item and check
// `Item::is_enabled_for_codegen`.
EdgeKind::TemplateParameterDefinition |
EdgeKind::TemplateArgument |
EdgeKind::TemplateDeclaration |
EdgeKind::BaseMember |
EdgeKind::Field |
EdgeKind::InnerType |
EdgeKind::FunctionReturn |
EdgeKind::FunctionParameter |
EdgeKind::VarType |
EdgeKind::TypeReference => cc.types,
EdgeKind::InnerVar => cc.vars,
EdgeKind::Method => cc.methods,
EdgeKind::Constructor => cc.constructors,
EdgeKind::Destructor => cc.destructors,
}
}

/// A `TraversalPredicate` implementation that never follows any edges, and
/// therefore traversals using this predicate will only visit the traversal's
/// roots.
Expand Down
10 changes: 10 additions & 0 deletions tests/expectations/tests/issue-833.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* automatically generated by rust-bindgen */


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

#[repr(C)] pub struct nsTArray<T> { pub hdr: *const T }

extern "C" {
pub fn func() -> *mut nsTArray<::std::os::raw::c_int>;
}
8 changes: 8 additions & 0 deletions tests/headers/issue-833.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// bindgen-flags: --generate functions --whitelist-function func --raw-line "#[repr(C)] pub struct nsTArray<T> { pub hdr: *const T }"

template<typename T>
class nsTArray {
T* mHeader;
};

extern "C" nsTArray<int>* func();