summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ir/context.rs6
-rw-r--r--src/ir/traversal.rs12
2 files changed, 12 insertions, 6 deletions
diff --git a/src/ir/context.rs b/src/ir/context.rs
index b453378d..8f8b6158 100644
--- a/src/ir/context.rs
+++ b/src/ir/context.rs
@@ -2291,7 +2291,11 @@ impl BindgenContext {
if self.options().whitelist_recursively {
traversal::all_edges
} else {
- traversal::no_edges
+ // Only follow InnerType edges from the whitelisted roots.
+ // Such inner types (e.g. anonymous structs/unions) are
+ // always emitted by codegen, and they need to be whitelisted
+ // to make sure they are processed by e.g. the derive analysis.
+ traversal::only_inner_type_edges
};
let whitelisted = WhitelistedItemsTraversal::new(
diff --git a/src/ir/traversal.rs b/src/ir/traversal.rs
index 491a15f8..c37b0b5f 100644
--- a/src/ir/traversal.rs
+++ b/src/ir/traversal.rs
@@ -201,11 +201,13 @@ pub fn all_edges(_: &BindgenContext, _: Edge) -> bool {
true
}
-/// A `TraversalPredicate` implementation that never follows any edges, and
-/// therefore traversals using this predicate will only visit the traversal's
-/// roots.
-pub fn no_edges(_: &BindgenContext, _: Edge) -> bool {
- false
+/// A `TraversalPredicate` implementation that only follows
+/// `EdgeKind::InnerType` edges, and therefore traversals using this predicate
+/// will only visit the traversal's roots and their inner types. This is used
+/// in no-recursive-whitelist mode, where inner types such as anonymous
+/// structs/unions still need to be processed.
+pub fn only_inner_type_edges(_: &BindgenContext, edge: Edge) -> bool {
+ edge.kind == EdgeKind::InnerType
}
/// A `TraversalPredicate` implementation that only follows edges to items that