|
1 | 1 | //! Determining which types for which we can emit `#[derive(Debug)]`.
|
2 | 2 |
|
3 | 3 | use super::{ConstrainResult, MonotoneFramework};
|
4 |
| -use ir::context::{BindgenContext, ItemId}; |
5 |
| -use ir::item::ItemSet; |
6 | 4 | use std::collections::HashSet;
|
7 | 5 | use std::collections::HashMap;
|
| 6 | +use ir::context::{BindgenContext, ItemId}; |
8 | 7 | use ir::traversal::EdgeKind;
|
9 | 8 | use ir::ty::RUST_DERIVE_IN_ARRAY_LIMIT;
|
10 | 9 | use ir::ty::TypeKind;
|
@@ -97,30 +96,19 @@ impl<'ctx, 'gen> MonotoneFramework for CannotDeriveDebug<'ctx, 'gen> {
|
97 | 96 | fn new(ctx: &'ctx BindgenContext<'gen>) -> CannotDeriveDebug<'ctx, 'gen> {
|
98 | 97 | let cannot_derive_debug = HashSet::new();
|
99 | 98 | let mut dependencies = HashMap::new();
|
100 |
| - let whitelisted_items: HashSet<_> = ctx.whitelisted_items().iter().cloned().collect(); |
101 |
| - |
102 |
| - let whitelisted_and_blacklisted_items: ItemSet = whitelisted_items.iter() |
103 |
| - .cloned() |
104 |
| - .flat_map(|i| { |
105 |
| - let mut reachable = vec![i]; |
106 |
| - i.trace(ctx, &mut |s, _| { |
107 |
| - reachable.push(s); |
108 |
| - }, &()); |
109 |
| - reachable |
110 |
| - }) |
111 |
| - .collect(); |
112 | 99 |
|
113 |
| - for item in whitelisted_and_blacklisted_items { |
| 100 | + for &item in ctx.whitelisted_items() { |
114 | 101 | dependencies.entry(item).or_insert(vec![]);
|
115 | 102 |
|
116 | 103 | {
|
117 | 104 | // We reverse our natural IR graph edges to find dependencies
|
118 | 105 | // between nodes.
|
119 | 106 | item.trace(ctx, &mut |sub_item: ItemId, edge_kind| {
|
120 |
| - if Self::consider_edge(edge_kind) { |
121 |
| - dependencies.entry(sub_item) |
122 |
| - .or_insert(vec![]) |
123 |
| - .push(item); |
| 107 | + if ctx.whitelisted_items().contains(&sub_item) && |
| 108 | + Self::consider_edge(edge_kind) { |
| 109 | + dependencies.entry(sub_item) |
| 110 | + .or_insert(vec![]) |
| 111 | + .push(item); |
124 | 112 | }
|
125 | 113 | }, &());
|
126 | 114 | }
|
|
0 commit comments