Skip to content

Commit faebc0c

Browse files
committed
The CannotDeriveDebug analysis shouldn't special case blacklisting
This is some copy-paste from the template param usage analysis that we don't need here. We already assume that blacklisted items are `derive(Debug)`able, and this doesn't change that.
1 parent 79a03e4 commit faebc0c

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

src/ir/analysis/derive_debug.rs

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
//! Determining which types for which we can emit `#[derive(Debug)]`.
22
33
use super::{ConstrainResult, MonotoneFramework};
4-
use ir::context::{BindgenContext, ItemId};
5-
use ir::item::ItemSet;
64
use std::collections::HashSet;
75
use std::collections::HashMap;
6+
use ir::context::{BindgenContext, ItemId};
87
use ir::traversal::EdgeKind;
98
use ir::ty::RUST_DERIVE_IN_ARRAY_LIMIT;
109
use ir::ty::TypeKind;
@@ -98,30 +97,19 @@ impl<'ctx, 'gen> MonotoneFramework for CannotDeriveDebug<'ctx, 'gen> {
9897
fn new(ctx: &'ctx BindgenContext<'gen>) -> CannotDeriveDebug<'ctx, 'gen> {
9998
let cannot_derive_debug = HashSet::new();
10099
let mut dependencies = HashMap::new();
101-
let whitelisted_items: HashSet<_> = ctx.whitelisted_items().iter().cloned().collect();
102-
103-
let whitelisted_and_blacklisted_items: ItemSet = whitelisted_items.iter()
104-
.cloned()
105-
.flat_map(|i| {
106-
let mut reachable = vec![i];
107-
i.trace(ctx, &mut |s, _| {
108-
reachable.push(s);
109-
}, &());
110-
reachable
111-
})
112-
.collect();
113100

114-
for item in whitelisted_and_blacklisted_items {
101+
for &item in ctx.whitelisted_items() {
115102
dependencies.entry(item).or_insert(vec![]);
116103

117104
{
118105
// We reverse our natural IR graph edges to find dependencies
119106
// between nodes.
120107
item.trace(ctx, &mut |sub_item: ItemId, edge_kind| {
121-
if Self::consider_edge(edge_kind) {
122-
dependencies.entry(sub_item)
123-
.or_insert(vec![])
124-
.push(item);
108+
if ctx.whitelisted_items().contains(&sub_item) &&
109+
Self::consider_edge(edge_kind) {
110+
dependencies.entry(sub_item)
111+
.or_insert(vec![])
112+
.push(item);
125113
}
126114
}, &());
127115
}

0 commit comments

Comments
 (0)