Skip to content

Commit 24ece6d

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 20bd752 commit 24ece6d

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;
@@ -97,30 +96,19 @@ impl<'ctx, 'gen> MonotoneFramework for CannotDeriveDebug<'ctx, 'gen> {
9796
fn new(ctx: &'ctx BindgenContext<'gen>) -> CannotDeriveDebug<'ctx, 'gen> {
9897
let cannot_derive_debug = HashSet::new();
9998
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();
11299

113-
for item in whitelisted_and_blacklisted_items {
100+
for &item in ctx.whitelisted_items() {
114101
dependencies.entry(item).or_insert(vec![]);
115102

116103
{
117104
// We reverse our natural IR graph edges to find dependencies
118105
// between nodes.
119106
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);
124112
}
125113
}, &());
126114
}

0 commit comments

Comments
 (0)