| 1 | use quoterust-analyzer cargo quote 1.0.47 crate/::quoterust-analyzer cargo quote 1.0.47 quote!; |
| 2 | use synrust-analyzer cargo syn 2.0.119 crate/::{Datarust-analyzer cargo syn 2.0.119 derive/Data#, DeriveInputrust-analyzer cargo syn 2.0.119 derive/DeriveInput#, Metarust-analyzer cargo syn 2.0.119 attr/Meta#}; |
| 3 | |
| 4 | use superrust-analyzer cargo educe 0.6.0 trait_handlers/debug/::{ |
| 5 | modelsrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/::{FieldAttributeBuilderrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldAttributeBuilder#, FieldNamerust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldName#, TypeAttributeBuilderrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/type_attribute/TypeAttributeBuilder#, TypeNamerust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/type_attribute/TypeName#}, |
| 6 | TraitHandlerrust-analyzer cargo educe 0.6.0 trait_handlers/TraitHandler#, |
| 7 | }; |
| 8 | use craterust-analyzer cargo educe 0.6.0 crate/::supported_traitsrust-analyzer cargo educe 0.6.0 supported_traits/::Traitrust-analyzer cargo educe 0.6.0 supported_traits/Trait#; |
| 9 | |
| 10 | pub(craterust-analyzer cargo educe 0.6.0 crate/) struct DebugUnionHandlerrust-analyzer cargo educe 0.6.0 trait_handlers/debug/debug_union/DebugUnionHandler#; |
| 11 | |
| 12 | impl TraitHandlerrust-analyzer cargo educe 0.6.0 trait_handlers/TraitHandler# for DebugUnionHandlerrust-analyzer cargo educe 0.6.0 trait_handlers/debug/debug_union/DebugUnionHandler# { |
| 13 | fn trait_meta_handlerrust-analyzer cargo educe 0.6.0 trait_handlers/debug/debug_union/impl#[DebugUnionHandler][TraitHandler]trait_meta_handler().( |
| 14 | ast: &DeriveInputrust-analyzer cargo syn 2.0.119 derive/DeriveInput#, |
| 15 | token_stream: &mut proc_macro2rust-analyzer cargo proc-macro2 1.0.107 crate/::TokenStreamrust-analyzer cargo proc-macro2 1.0.107 TokenStream#, |
| 16 | traits: &[Traitrust-analyzer cargo educe 0.6.0 supported_traits/Trait#], |
| 17 | meta: &Metarust-analyzer cargo syn 2.0.119 attr/Meta#, |
| 18 | ) -> synrust-analyzer cargo syn 2.0.119 crate/::Resultrust-analyzer cargo syn 2.0.119 error/Result#<()> { |
| 19 | let type_attribute = TypeAttributeBuilderrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/type_attribute/TypeAttributeBuilder# { |
| 20 | enable_flagrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/type_attribute/TypeAttributeBuilder#enable_flag.: true, |
| 21 | enable_unsaferust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/type_attribute/TypeAttributeBuilder#enable_unsafe.: true, |
| 22 | enable_namerust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/type_attribute/TypeAttributeBuilder#enable_name.: true, |
| 23 | enable_named_fieldrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/type_attribute/TypeAttributeBuilder#enable_named_field.: false, |
| 24 | enable_boundrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/type_attribute/TypeAttributeBuilder#enable_bound.: false, |
| 25 | namerust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/type_attribute/TypeAttributeBuilder#name.: TypeNamerust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/type_attribute/TypeName#::Defaultrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/type_attribute/TypeName#Default#, |
| 26 | named_fieldrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/type_attribute/TypeAttributeBuilder#named_field.: false, |
| 27 | } |
| 28 | .build_from_debug_metarust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/type_attribute/impl#[TypeAttributeBuilder]build_from_debug_meta().(meta)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 29 | |
| 30 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().type_attribute.has_unsaferust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/type_attribute/TypeAttribute#has_unsafe. { |
| 31 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(superrust-analyzer cargo educe 0.6.0 trait_handlers/debug/::panicrust-analyzer cargo educe 0.6.0 trait_handlers/debug/panic/::union_without_unsaferust-analyzer cargo educe 0.6.0 trait_handlers/debug/panic/union_without_unsafe().(meta)); |
| 32 | } |
| 33 | |
| 34 | let name = type_attribute.namerust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/type_attribute/TypeAttribute#name..to_ident_by_identrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/type_attribute/impl#[TypeName]to_ident_by_ident().(&ast.identrust-analyzer cargo syn 2.0.119 derive/DeriveInput#ident.); |
| 35 | |
| 36 | let mut builder_token_stream = proc_macro2rust-analyzer cargo proc-macro2 1.0.107 crate/::TokenStreamrust-analyzer cargo proc-macro2 1.0.107 TokenStream#::newrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream]new().(); |
| 37 | |
| 38 | if let Datarust-analyzer cargo syn 2.0.119 derive/Data#::Unionrust-analyzer cargo syn 2.0.119 derive/Data#Union#(data) = &ast.datarust-analyzer cargo syn 2.0.119 derive/DeriveInput#data. { |
| 39 | for field in data.fieldsrust-analyzer cargo syn 2.0.119 derive/DataUnion#fields..namedrust-analyzer cargo syn 2.0.119 data/FieldsNamed#named..iterrust-analyzer cargo syn 2.0.119 punctuated/impl#[`Punctuated<T, P>`]iter().() { |
| 40 | let _ = FieldAttributeBuilderrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldAttributeBuilder# { |
| 41 | enable_namerust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldAttributeBuilder#enable_name.: false, |
| 42 | enable_ignorerust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldAttributeBuilder#enable_ignore.: false, |
| 43 | enable_methodrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldAttributeBuilder#enable_method.: false, |
| 44 | namerust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldAttributeBuilder#name.: FieldNamerust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldName#::Defaultrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldName#Default#, |
| 45 | } |
| 46 | .build_from_attributesrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/impl#[FieldAttributeBuilder]build_from_attributes().(&field.attrsrust-analyzer cargo syn 2.0.119 data/Field#attrs., traits)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 47 | } |
| 48 | |
| 49 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(name) = name { |
| 50 | builder_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!!( |
| 51 | let mut builder = f.debug_tuple(stringify!(#name)); |
| 52 | |
| 53 | let size = ::core::mem::size_of::<Self>(); |
| 54 | |
| 55 | let data = unsafe { ::core::slice::from_raw_parts(self as *const Self as *const u8, size) }; |
| 56 | |
| 57 | builder.field(&data); |
| 58 | |
| 59 | builder.finish() |
| 60 | )); |
| 61 | } else { |
| 62 | builder_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!!( |
| 63 | let size = ::core::mem::size_of::<Self>(); |
| 64 | let data = unsafe { ::core::slice::from_raw_parts(self as *const Self as *const u8, size) }; |
| 65 | |
| 66 | ::core::fmt::Debug::fmt(data, f) |
| 67 | )); |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | let ident = &ast.identrust-analyzer cargo syn 2.0.119 derive/DeriveInput#ident.; |
| 72 | |
| 73 | let (impl_generics, ty_generics, where_clause) = ast.genericsrust-analyzer cargo syn 2.0.119 derive/DeriveInput#generics..split_for_implrust-analyzer cargo syn 2.0.119 generics/impl#[Generics]split_for_impl().(); |
| 74 | |
| 75 | token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!! { |
| 76 | impl #impl_generics ::core::fmt::Debug for #ident #ty_generics #where_clause { |
| 77 | #[inline] |
| 78 | fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { |
| 79 | #builder_token_stream |
| 80 | } |
| 81 | } |
| 82 | }); |
| 83 | |
| 84 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 85 | } |
| 86 | } |