aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/impl_debug.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/codegen/impl_debug.rs')
-rw-r--r--src/codegen/impl_debug.rs37
1 files changed, 17 insertions, 20 deletions
diff --git a/src/codegen/impl_debug.rs b/src/codegen/impl_debug.rs
index 661711e..0e2cd33 100644
--- a/src/codegen/impl_debug.rs
+++ b/src/codegen/impl_debug.rs
@@ -2,7 +2,6 @@ use crate::ir::comp::{BitfieldUnit, CompKind, Field, FieldData, FieldMethods};
use crate::ir::context::BindgenContext;
use crate::ir::item::{HasTypeParamInArray, IsOpaque, Item, ItemCanonicalName};
use crate::ir::ty::{TypeKind, RUST_DERIVE_IN_ARRAY_LIMIT};
-use proc_macro2;
pub fn gen_debug_impl(
ctx: &BindgenContext,
@@ -23,8 +22,8 @@ pub fn gen_debug_impl(
}
CompKind::Struct => {
let processed_fields = fields.iter().filter_map(|f| match f {
- &Field::DataMember(ref fd) => fd.impl_debug(ctx, ()),
- &Field::Bitfields(ref bu) => bu.impl_debug(ctx, ()),
+ Field::DataMember(ref fd) => fd.impl_debug(ctx, ()),
+ Field::Bitfields(ref bu) => bu.impl_debug(ctx, ()),
});
for (i, (fstring, toks)) in processed_fields.enumerate() {
@@ -186,24 +185,22 @@ impl<'a> ImplDebug<'a> for Item {
{
// The simple case
debug_print(name, quote! { #name_ident })
+ } else if ctx.options().use_core {
+ // There is no String in core; reducing field visibility to avoid breaking
+ // no_std setups.
+ Some((format!("{}: [...]", name), vec![]))
} else {
- if ctx.options().use_core {
- // There is no String in core; reducing field visibility to avoid breaking
- // no_std setups.
- Some((format!("{}: [...]", name), vec![]))
- } else {
- // Let's implement our own print function
- Some((
- format!("{}: [{{}}]", name),
- vec![quote! {
- self.#name_ident
- .iter()
- .enumerate()
- .map(|(i, v)| format!("{}{:?}", if i > 0 { ", " } else { "" }, v))
- .collect::<String>()
- }],
- ))
- }
+ // Let's implement our own print function
+ Some((
+ format!("{}: [{{}}]", name),
+ vec![quote! {
+ self.#name_ident
+ .iter()
+ .enumerate()
+ .map(|(i, v)| format!("{}{:?}", if i > 0 { ", " } else { "" }, v))
+ .collect::<String>()
+ }],
+ ))
}
}
TypeKind::Vector(_, len) => {