summaryrefslogtreecommitdiff
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.rs24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/codegen/impl_debug.rs b/src/codegen/impl_debug.rs
index fd486511..eac54fd1 100644
--- a/src/codegen/impl_debug.rs
+++ b/src/codegen/impl_debug.rs
@@ -1,7 +1,7 @@
use ir::comp::{BitfieldUnit, CompKind, Field, FieldData, FieldMethods};
use ir::context::BindgenContext;
use ir::item::{HasTypeParamInArray, IsOpaque, Item, ItemCanonicalName};
-use ir::ty::{RUST_DERIVE_IN_ARRAY_LIMIT, TypeKind};
+use ir::ty::{TypeKind, RUST_DERIVE_IN_ARRAY_LIMIT};
use proc_macro2;
pub fn gen_debug_impl(
@@ -177,9 +177,10 @@ impl<'a> ImplDebug<'a> for Item {
TypeKind::Array(_, len) => {
// Generics are not required to implement Debug
if self.has_type_param_in_array(ctx) {
- Some(
- (format!("{}: Array with length {}", name, len), vec![]),
- )
+ Some((
+ format!("{}: Array with length {}", name, len),
+ vec![],
+ ))
} else if len < RUST_DERIVE_IN_ARRAY_LIMIT {
// The simple case
debug_print(name, quote! { #name_ident })
@@ -187,9 +188,7 @@ impl<'a> ImplDebug<'a> for Item {
if ctx.options().use_core {
// There is no String in core; reducing field visibility to avoid breaking
// no_std setups.
- Some((
- format!("{}: [...]", name), vec![]
- ))
+ Some((format!("{}: [...]", name), vec![]))
} else {
// Let's implement our own print function
Some((
@@ -209,16 +208,14 @@ impl<'a> ImplDebug<'a> for Item {
if ctx.options().use_core {
// There is no format! in core; reducing field visibility to avoid breaking
// no_std setups.
- Some((
- format!("{}(...)", name), vec![]
- ))
+ Some((format!("{}(...)", name), vec![]))
} else {
let self_ids = 0..len;
Some((
format!("{}({{}})", name),
vec![quote! {
#(format!("{:?}", self.#self_ids)),*
- }]
+ }],
))
}
}
@@ -235,8 +232,9 @@ impl<'a> ImplDebug<'a> for Item {
let inner_type = ctx.resolve_type(inner).canonical_type(ctx);
match *inner_type.kind() {
TypeKind::Function(ref sig)
- if !sig.function_pointers_can_derive() => {
- Some((format!("{}: FunctionPointer", name), vec![]))
+ if !sig.function_pointers_can_derive() =>
+ {
+ Some((format!("{}: FunctionPointer", name), vec![]))
}
_ => debug_print(name, quote! { #name_ident }),
}