diff options
author | MikuroXina <ryosukadnak@gmail.com> | 2021-10-25 22:06:54 +0900 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2021-10-27 19:22:15 +0200 |
commit | 1e6db4c30689636e31a8bca2817c2edd53991ff8 (patch) | |
tree | 958742ec17eaf372831eca48dd82d32350baa30b /src/codegen/impl_debug.rs | |
parent | 82462a37a149108db8c428f6caa5d8853ba25c40 (diff) |
Fix warnings
Diffstat (limited to 'src/codegen/impl_debug.rs')
-rw-r--r-- | src/codegen/impl_debug.rs | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/src/codegen/impl_debug.rs b/src/codegen/impl_debug.rs index 661711e8..0e2cd33a 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) => { |