Skip to content

Commit 4142a89

Browse files
author
bors-servo
authored
Auto merge of #890 - photoszzt:clean_up_trivially_debug, r=emilio
Clean up trivially derive debug r? @fitzgen
2 parents e9b270e + dbc85c6 commit 4142a89

File tree

4 files changed

+6
-17
lines changed

4 files changed

+6
-17
lines changed

src/ir/analysis/derive_debug.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ impl<'ctx, 'gen> MonotoneFramework for CannotDeriveDebug<'ctx, 'gen> {
130130

131131
if ty.is_opaque(self.ctx, item) {
132132
let layout_can_derive = ty.layout(self.ctx).map_or(true, |l| {
133-
l.opaque().can_trivially_derive_debug(self.ctx, ())
133+
l.opaque().can_trivially_derive_debug()
134134
});
135135
return if layout_can_derive {
136136
trace!(" we can trivially derive Debug for the layout");
@@ -215,7 +215,7 @@ impl<'ctx, 'gen> MonotoneFramework for CannotDeriveDebug<'ctx, 'gen> {
215215

216216
if ty.layout(self.ctx)
217217
.map_or(true,
218-
|l| l.opaque().can_trivially_derive_debug(self.ctx, ())) {
218+
|l| l.opaque().can_trivially_derive_debug()) {
219219
trace!(" union layout can trivially derive Debug");
220220
return ConstrainResult::Same;
221221
} else {
@@ -260,7 +260,7 @@ impl<'ctx, 'gen> MonotoneFramework for CannotDeriveDebug<'ctx, 'gen> {
260260
TypeKind::Pointer(inner) => {
261261
let inner_type = self.ctx.resolve_type(inner).canonical_type(self.ctx);
262262
if let TypeKind::Function(ref sig) = *inner_type.kind() {
263-
if !sig.can_trivially_derive_debug(&self.ctx, ()) {
263+
if !sig.can_trivially_derive_debug() {
264264
trace!(" function pointer that can't trivially derive Debug");
265265
return self.insert(id);
266266
}

src/ir/derive.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,9 @@ pub trait CanDeriveDebug {
2020
/// implementing this trait cannot use recursion or lookup result from fix point
2121
/// analysis. It's a helper trait for fix point analysis.
2222
pub trait CanTriviallyDeriveDebug {
23-
24-
/// Serve the same purpose as the Extra in CanDeriveDebug.
25-
type Extra;
26-
2723
/// Return `true` if `Debug` can be derived for this thing, `false`
2824
/// otherwise.
29-
fn can_trivially_derive_debug(&self,
30-
ctx: &BindgenContext,
31-
extra: Self::Extra)
32-
-> bool;
25+
fn can_trivially_derive_debug(&self) -> bool;
3326
}
3427

3528
/// A trait that encapsulates the logic for whether or not we can derive `Copy`

src/ir/function.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -480,9 +480,7 @@ impl Trace for FunctionSig {
480480
//
481481
// Note that copy is always derived, so we don't need to implement it.
482482
impl CanTriviallyDeriveDebug for FunctionSig {
483-
type Extra = ();
484-
485-
fn can_trivially_derive_debug(&self, _ctx: &BindgenContext, _: ()) -> bool {
483+
fn can_trivially_derive_debug(&self) -> bool {
486484
const RUST_DERIVE_FUNPTR_LIMIT: usize = 12;
487485
if self.argument_types.len() > RUST_DERIVE_FUNPTR_LIMIT {
488486
return false;

src/ir/layout.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,7 @@ impl Opaque {
104104
}
105105

106106
impl CanTriviallyDeriveDebug for Opaque {
107-
type Extra = ();
108-
109-
fn can_trivially_derive_debug(&self, _: &BindgenContext, _: ()) -> bool {
107+
fn can_trivially_derive_debug(&self) -> bool {
110108
self.array_size()
111109
.map_or(false, |size| size <= RUST_DERIVE_IN_ARRAY_LIMIT)
112110
}

0 commit comments

Comments
 (0)