diff options
author | zzhu <zzhu@mozilla.com> | 2017-08-02 22:32:52 -0700 |
---|---|---|
committer | zzhu <zzhu@mozilla.com> | 2017-08-02 22:32:52 -0700 |
commit | dbc85c67904079caac43923b29cf7e148dc81469 (patch) | |
tree | d0ff306ec54adcac5e240440b76cfa81ecad11b0 /src | |
parent | e9b270e8f9a037cb9bd888181a8e4374a91c8b70 (diff) |
Clean up trivially derive debug
Diffstat (limited to 'src')
-rw-r--r-- | src/ir/analysis/derive_debug.rs | 6 | ||||
-rw-r--r-- | src/ir/derive.rs | 9 | ||||
-rw-r--r-- | src/ir/function.rs | 4 | ||||
-rw-r--r-- | src/ir/layout.rs | 4 |
4 files changed, 6 insertions, 17 deletions
diff --git a/src/ir/analysis/derive_debug.rs b/src/ir/analysis/derive_debug.rs index ef3b1e00..8990d1cc 100644 --- a/src/ir/analysis/derive_debug.rs +++ b/src/ir/analysis/derive_debug.rs @@ -130,7 +130,7 @@ impl<'ctx, 'gen> MonotoneFramework for CannotDeriveDebug<'ctx, 'gen> { if ty.is_opaque(self.ctx, item) { let layout_can_derive = ty.layout(self.ctx).map_or(true, |l| { - l.opaque().can_trivially_derive_debug(self.ctx, ()) + l.opaque().can_trivially_derive_debug() }); return if layout_can_derive { trace!(" we can trivially derive Debug for the layout"); @@ -215,7 +215,7 @@ impl<'ctx, 'gen> MonotoneFramework for CannotDeriveDebug<'ctx, 'gen> { if ty.layout(self.ctx) .map_or(true, - |l| l.opaque().can_trivially_derive_debug(self.ctx, ())) { + |l| l.opaque().can_trivially_derive_debug()) { trace!(" union layout can trivially derive Debug"); return ConstrainResult::Same; } else { @@ -260,7 +260,7 @@ impl<'ctx, 'gen> MonotoneFramework for CannotDeriveDebug<'ctx, 'gen> { TypeKind::Pointer(inner) => { let inner_type = self.ctx.resolve_type(inner).canonical_type(self.ctx); if let TypeKind::Function(ref sig) = *inner_type.kind() { - if !sig.can_trivially_derive_debug(&self.ctx, ()) { + if !sig.can_trivially_derive_debug() { trace!(" function pointer that can't trivially derive Debug"); return self.insert(id); } diff --git a/src/ir/derive.rs b/src/ir/derive.rs index 5bc9cfdd..cfa22b36 100644 --- a/src/ir/derive.rs +++ b/src/ir/derive.rs @@ -20,16 +20,9 @@ pub trait CanDeriveDebug { /// implementing this trait cannot use recursion or lookup result from fix point /// analysis. It's a helper trait for fix point analysis. pub trait CanTriviallyDeriveDebug { - - /// Serve the same purpose as the Extra in CanDeriveDebug. - type Extra; - /// Return `true` if `Debug` can be derived for this thing, `false` /// otherwise. - fn can_trivially_derive_debug(&self, - ctx: &BindgenContext, - extra: Self::Extra) - -> bool; + fn can_trivially_derive_debug(&self) -> bool; } /// A trait that encapsulates the logic for whether or not we can derive `Copy` diff --git a/src/ir/function.rs b/src/ir/function.rs index fbb6121e..99ab8772 100644 --- a/src/ir/function.rs +++ b/src/ir/function.rs @@ -480,9 +480,7 @@ impl Trace for FunctionSig { // // Note that copy is always derived, so we don't need to implement it. impl CanTriviallyDeriveDebug for FunctionSig { - type Extra = (); - - fn can_trivially_derive_debug(&self, _ctx: &BindgenContext, _: ()) -> bool { + fn can_trivially_derive_debug(&self) -> bool { const RUST_DERIVE_FUNPTR_LIMIT: usize = 12; if self.argument_types.len() > RUST_DERIVE_FUNPTR_LIMIT { return false; diff --git a/src/ir/layout.rs b/src/ir/layout.rs index b0ec171a..3fb3af26 100644 --- a/src/ir/layout.rs +++ b/src/ir/layout.rs @@ -104,9 +104,7 @@ impl Opaque { } impl CanTriviallyDeriveDebug for Opaque { - type Extra = (); - - fn can_trivially_derive_debug(&self, _: &BindgenContext, _: ()) -> bool { + fn can_trivially_derive_debug(&self) -> bool { self.array_size() .map_or(false, |size| size <= RUST_DERIVE_IN_ARRAY_LIMIT) } |