summaryrefslogtreecommitdiff
path: root/libbindgen/src
diff options
context:
space:
mode:
Diffstat (limited to 'libbindgen/src')
-rw-r--r--libbindgen/src/ir/comp.rs9
-rw-r--r--libbindgen/src/ir/layout.rs7
2 files changed, 9 insertions, 7 deletions
diff --git a/libbindgen/src/ir/comp.rs b/libbindgen/src/ir/comp.rs
index 3a0f5872..0af8a99e 100644
--- a/libbindgen/src/ir/comp.rs
+++ b/libbindgen/src/ir/comp.rs
@@ -3,13 +3,12 @@
use clang;
use parse::{ClangItemParser, ParseError};
use std::cell::Cell;
-use std::cmp;
use super::annotations::Annotations;
use super::context::{BindgenContext, ItemId};
use super::derive::{CanDeriveCopy, CanDeriveDebug};
use super::item::Item;
use super::layout::Layout;
-use super::ty::{RUST_DERIVE_IN_ARRAY_LIMIT, Type};
+use super::ty::Type;
use super::type_collector::{ItemSet, TypeCollector};
/// The kind of compound type.
@@ -826,9 +825,9 @@ impl CanDeriveDebug for CompInfo {
return false;
}
- let layout = layout.unwrap_or_else(Layout::zero);
- let size_divisor = cmp::max(1, layout.align);
- return layout.size / size_divisor <= RUST_DERIVE_IN_ARRAY_LIMIT;
+ return layout.unwrap_or_else(Layout::zero)
+ .opaque()
+ .can_derive_debug(ctx, ());
}
self.detect_derive_debug_cycle.set(true);
diff --git a/libbindgen/src/ir/layout.rs b/libbindgen/src/ir/layout.rs
index 075f42c9..3a07f7e8 100644
--- a/libbindgen/src/ir/layout.rs
+++ b/libbindgen/src/ir/layout.rs
@@ -1,5 +1,6 @@
//! Intermediate representation for the physical layout of some type.
+use std::cmp;
use super::context::BindgenContext;
use super::derive::{CanDeriveCopy, CanDeriveDebug};
use super::ty::RUST_DERIVE_IN_ARRAY_LIMIT;
@@ -49,7 +50,8 @@ impl CanDeriveDebug for Opaque {
type Extra = ();
fn can_derive_debug(&self, _: &BindgenContext, _: ()) -> bool {
- self.0.size < RUST_DERIVE_IN_ARRAY_LIMIT
+ let size_divisor = cmp::max(1, self.0.align);
+ self.0.size / size_divisor <= RUST_DERIVE_IN_ARRAY_LIMIT
}
}
@@ -57,7 +59,8 @@ impl<'a> CanDeriveCopy<'a> for Opaque {
type Extra = ();
fn can_derive_copy(&self, _: &BindgenContext, _: ()) -> bool {
- self.0.size < RUST_DERIVE_IN_ARRAY_LIMIT
+ let size_divisor = cmp::max(1, self.0.align);
+ self.0.size / size_divisor <= RUST_DERIVE_IN_ARRAY_LIMIT
}
fn can_derive_copy_in_array(&self, ctx: &BindgenContext, _: ()) -> bool {