Skip to content

Commit 0fab51e

Browse files
author
bors-servo
authored
Auto merge of #862 - fitzgen:remove-unused-extra, r=emilio
Remove unused `Extra` associated types r? @photoszzt or @emilio
2 parents 331862a + 66f600e commit 0fab51e

File tree

6 files changed

+9
-39
lines changed

6 files changed

+9
-39
lines changed

src/codegen/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1414,7 +1414,7 @@ impl CodeGenerator for CompInfo {
14141414

14151415
let is_union = self.kind() == CompKind::Union;
14161416
let mut derives = vec![];
1417-
if item.can_derive_debug(ctx, ()) {
1417+
if item.can_derive_debug(ctx) {
14181418
derives.push("Debug");
14191419
}
14201420

src/ir/analysis/has_vtable.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,6 @@ impl<'ctx, 'gen> From<HasVtableAnalysis<'ctx, 'gen>> for HashSet<ItemId> {
157157
/// looking up the results of the HasVtableAnalysis's computations for a
158158
/// specific thing.
159159
pub trait HasVtable {
160-
161-
/// Implementations can define this type to get access to any extra
162-
/// information required to determine whether they have vtable. If
163-
/// extra information is unneeded, then this should simply be the unit type.
164-
type Extra;
165-
166160
/// Return `true` if this thing has vtable, `false` otherwise.
167-
fn has_vtable(&self, ctx: &BindgenContext, extra: &Self::Extra) -> bool;
161+
fn has_vtable(&self, ctx: &BindgenContext) -> bool;
168162
}

src/ir/context.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,8 @@ impl ItemId {
4040
}
4141

4242
impl CanDeriveDebug for ItemId {
43-
type Extra = ();
44-
45-
fn can_derive_debug(&self, ctx: &BindgenContext, _: ()) -> bool {
46-
ctx.resolve_item(*self).can_derive_debug(ctx, ())
43+
fn can_derive_debug(&self, ctx: &BindgenContext) -> bool {
44+
ctx.options().derive_debug && ctx.lookup_item_id_can_derive_debug(*self)
4745
}
4846
}
4947

src/ir/derive.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,9 @@ use super::context::BindgenContext;
1010
/// derive debug or not, because of the limit rust has on 32 items as max in the
1111
/// array.
1212
pub trait CanDeriveDebug {
13-
/// Implementations can define this type to get access to any extra
14-
/// information required to determine whether they can derive `Debug`. If
15-
/// extra information is unneeded, then this should simply be the unit type.
16-
type Extra;
17-
1813
/// Return `true` if `Debug` can be derived for this thing, `false`
1914
/// otherwise.
20-
fn can_derive_debug(&self,
21-
ctx: &BindgenContext,
22-
extra: Self::Extra)
23-
-> bool;
15+
fn can_derive_debug(&self, ctx: &BindgenContext) -> bool;
2416
}
2517

2618
/// A trait that encapsulates the logic for whether or not we can derive `Debug`.

src/ir/item.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,7 @@ impl Trace for Item {
271271
}
272272

273273
impl CanDeriveDebug for Item {
274-
type Extra = ();
275-
276-
fn can_derive_debug(&self, ctx: &BindgenContext, _: ()) -> bool {
274+
fn can_derive_debug(&self, ctx: &BindgenContext) -> bool {
277275
ctx.options().derive_debug && ctx.lookup_item_id_can_derive_debug(self.id())
278276
}
279277
}
@@ -949,17 +947,13 @@ impl IsOpaque for Item {
949947
}
950948

951949
impl HasVtable for ItemId {
952-
type Extra = ();
953-
954-
fn has_vtable(&self, ctx: &BindgenContext, _: &()) -> bool {
950+
fn has_vtable(&self, ctx: &BindgenContext) -> bool {
955951
ctx.lookup_item_id_has_vtable(self)
956952
}
957953
}
958954

959955
impl HasVtable for Item {
960-
type Extra = ();
961-
962-
fn has_vtable(&self, ctx: &BindgenContext, _: &()) -> bool {
956+
fn has_vtable(&self, ctx: &BindgenContext) -> bool {
963957
ctx.lookup_item_id_has_vtable(&self.id())
964958
}
965959
}

src/ir/ty.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use super::comp::CompInfo;
44
use super::context::{BindgenContext, ItemId};
5-
use super::derive::{CanDeriveCopy, CanDeriveDebug, CanDeriveDefault};
5+
use super::derive::{CanDeriveCopy, CanDeriveDefault};
66
use super::dot::DotAttributes;
77
use super::enum_ty::Enum;
88
use super::function::FunctionSig;
@@ -526,14 +526,6 @@ impl TemplateParameters for TypeKind {
526526
}
527527
}
528528

529-
impl CanDeriveDebug for Type {
530-
type Extra = Item;
531-
532-
fn can_derive_debug(&self, ctx: &BindgenContext, item: Item) -> bool {
533-
ctx.lookup_item_id_can_derive_debug(item.id())
534-
}
535-
}
536-
537529
impl<'a> CanDeriveDefault<'a> for Type {
538530
type Extra = &'a Item;
539531

0 commit comments

Comments
 (0)