| 1 | use quoterust-analyzer cargo quote 1.0.47 crate/::{format_identrust-analyzer cargo quote 1.0.47 format/format_ident!, quoterust-analyzer cargo quote 1.0.47 quote!, ToTokensrust-analyzer cargo quote 1.0.47 to_tokens/ToTokens#}; |
| 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#, Fieldsrust-analyzer cargo syn 2.0.119 data/Fields#, Metarust-analyzer cargo syn 2.0.119 attr/Meta#, Typerust-analyzer cargo syn 2.0.119 ty/Type#}; |
| 3 | |
| 4 | use superrust-analyzer cargo educe 0.6.0 trait_handlers/debug/::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#}; |
| 5 | use craterust-analyzer cargo educe 0.6.0 crate/::{commonrust-analyzer cargo educe 0.6.0 common/::pathrust-analyzer cargo educe 0.6.0 common/path/::path_to_stringrust-analyzer cargo educe 0.6.0 common/path/path_to_string()., supported_traitsrust-analyzer cargo educe 0.6.0 supported_traits/::Traitrust-analyzer cargo educe 0.6.0 supported_traits/Trait#, trait_handlersrust-analyzer cargo educe 0.6.0 trait_handlers/::TraitHandlerrust-analyzer cargo educe 0.6.0 trait_handlers/TraitHandler#}; |
| 6 | |
| 7 | pub(craterust-analyzer cargo educe 0.6.0 crate/) struct DebugEnumHandlerrust-analyzer cargo educe 0.6.0 trait_handlers/debug/debug_enum/DebugEnumHandler#; |
| 8 | |
| 9 | impl TraitHandlerrust-analyzer cargo educe 0.6.0 trait_handlers/TraitHandler# for DebugEnumHandlerrust-analyzer cargo educe 0.6.0 trait_handlers/debug/debug_enum/DebugEnumHandler# { |
| 10 | fn trait_meta_handlerrust-analyzer cargo educe 0.6.0 trait_handlers/debug/debug_enum/impl#[DebugEnumHandler][TraitHandler]trait_meta_handler().( |
| 11 | ast: &DeriveInputrust-analyzer cargo syn 2.0.119 derive/DeriveInput#, |
| 12 | token_stream: &mut proc_macro2rust-analyzer cargo proc-macro2 1.0.107 crate/::TokenStreamrust-analyzer cargo proc-macro2 1.0.107 TokenStream#, |
| 13 | traits: &[Traitrust-analyzer cargo educe 0.6.0 supported_traits/Trait#], |
| 14 | meta: &Metarust-analyzer cargo syn 2.0.119 attr/Meta#, |
| 15 | ) -> synrust-analyzer cargo syn 2.0.119 crate/::Resultrust-analyzer cargo syn 2.0.119 error/Result#<()> { |
| 16 | let type_attribute = TypeAttributeBuilderrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/type_attribute/TypeAttributeBuilder# { |
| 17 | enable_flagrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/type_attribute/TypeAttributeBuilder#enable_flag.: true, |
| 18 | enable_unsaferust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/type_attribute/TypeAttributeBuilder#enable_unsafe.: false, |
| 19 | enable_namerust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/type_attribute/TypeAttributeBuilder#enable_name.: true, |
| 20 | enable_named_fieldrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/type_attribute/TypeAttributeBuilder#enable_named_field.: false, |
| 21 | enable_boundrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/type_attribute/TypeAttributeBuilder#enable_bound.: true, |
| 22 | 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#::Disablerust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/type_attribute/TypeName#Disable#, |
| 23 | named_fieldrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/type_attribute/TypeAttributeBuilder#named_field.: false, |
| 24 | } |
| 25 | .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().; |
| 26 | |
| 27 | 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.); |
| 28 | |
| 29 | let mut debug_types: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<&Typerust-analyzer cargo syn 2.0.119 ty/Type#> = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 30 | |
| 31 | 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().(); |
| 32 | |
| 33 | let mut arms_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().(); |
| 34 | |
| 35 | if let Datarust-analyzer cargo syn 2.0.119 derive/Data#::Enumrust-analyzer cargo syn 2.0.119 derive/Data#Enum#(data) = &ast.datarust-analyzer cargo syn 2.0.119 derive/DeriveInput#data. { |
| 36 | for variant in data.variantsrust-analyzer cargo syn 2.0.119 derive/DataEnum#variants..iterrust-analyzer cargo syn 2.0.119 punctuated/impl#[`Punctuated<T, P>`]iter().() { |
| 37 | let type_attribute = TypeAttributeBuilderrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/type_attribute/TypeAttributeBuilder# { |
| 38 | enable_flagrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/type_attribute/TypeAttributeBuilder#enable_flag.: false, |
| 39 | enable_unsaferust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/type_attribute/TypeAttributeBuilder#enable_unsafe.: false, |
| 40 | enable_namerust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/type_attribute/TypeAttributeBuilder#enable_name.: true, |
| 41 | enable_named_fieldrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/type_attribute/TypeAttributeBuilder#enable_named_field.: true, |
| 42 | enable_boundrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/type_attribute/TypeAttributeBuilder#enable_bound.: false, |
| 43 | 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#, |
| 44 | named_fieldrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/type_attribute/TypeAttributeBuilder#named_field.: matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(&variant.fieldsrust-analyzer cargo syn 2.0.119 data/Variant#fields., Fieldsrust-analyzer cargo syn 2.0.119 data/Fields#::Namedrust-analyzer cargo syn 2.0.119 data/Fields#Named#(_)), |
| 45 | } |
| 46 | .build_from_attributesrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/type_attribute/impl#[TypeAttributeBuilder]build_from_attributes().(&variant.attrsrust-analyzer cargo syn 2.0.119 data/Variant#attrs., traits)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 47 | |
| 48 | let variant_ident = &variant.identrust-analyzer cargo syn 2.0.119 data/Variant#ident.; |
| 49 | |
| 50 | let variant_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().(variant_ident); |
| 51 | |
| 52 | let named_field = type_attribute.named_fieldrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/type_attribute/TypeAttribute#named_field.; |
| 53 | |
| 54 | let name_string = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(name) = name { |
| 55 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(variant_name) = variant_name { |
| 56 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(path_to_stringrust-analyzer cargo educe 0.6.0 common/path/path_to_string().(&synrust-analyzer cargo syn 2.0.119 crate/::parse2rust-analyzer cargo syn 2.0.119 parse2().(quoterust-analyzer cargo quote 1.0.47 quote!!(#name::#variant_name)).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().())) |
| 57 | } else { |
| 58 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(name.into_token_streamrust-analyzer cargo quote 1.0.47 to_tokens/ToTokens#into_token_stream().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()) |
| 59 | } |
| 60 | } else { |
| 61 | variant_name.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|variant_name| variant_name.into_token_streamrust-analyzer cargo quote 1.0.47 to_tokens/ToTokens#into_token_stream().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()) |
| 62 | }; |
| 63 | |
| 64 | match &variant.fieldsrust-analyzer cargo syn 2.0.119 data/Variant#fields. { |
| 65 | Fieldsrust-analyzer cargo syn 2.0.119 data/Fields#::Unitrust-analyzer cargo syn 2.0.119 data/Fields#Unit# => { |
| 66 | if name_string.is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().() { |
| 67 | 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/::unit_variant_need_namerust-analyzer cargo educe 0.6.0 trait_handlers/debug/panic/unit_variant_need_name().(variant)); |
| 68 | } |
| 69 | |
| 70 | arms_token_stream |
| 71 | .extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!!( Self::#variant_ident => f.write_str(#name_string), )); |
| 72 | }, |
| 73 | Fieldsrust-analyzer cargo syn 2.0.119 data/Fields#::Namedrust-analyzer cargo syn 2.0.119 data/Fields#Named#(fields) => { |
| 74 | let mut has_fields = false; |
| 75 | |
| 76 | let mut pattern_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().(); |
| 77 | let mut block_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().(); |
| 78 | |
| 79 | if named_field { |
| 80 | block_token_stream |
| 81 | .extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(create_named_field_builderrust-analyzer cargo educe 0.6.0 trait_handlers/debug/debug_enum/create_named_field_builder().(name_string.as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().())); |
| 82 | |
| 83 | for field in fields.namedrust-analyzer cargo syn 2.0.119 data/FieldsNamed#named..iterrust-analyzer cargo syn 2.0.119 punctuated/impl#[`Punctuated<T, P>`]iter().() { |
| 84 | let field_attribute = FieldAttributeBuilderrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldAttributeBuilder# { |
| 85 | enable_namerust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldAttributeBuilder#enable_name.: true, |
| 86 | enable_ignorerust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldAttributeBuilder#enable_ignore.: true, |
| 87 | enable_methodrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldAttributeBuilder#enable_method.: true, |
| 88 | 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#, |
| 89 | } |
| 90 | .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().; |
| 91 | |
| 92 | let field_name_real = field.identrust-analyzer cargo syn 2.0.119 data/Field#ident..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 93 | let field_name_var = format_identrust-analyzer cargo quote 1.0.47 format/format_ident!!("_{}", field_name_real); |
| 94 | |
| 95 | if field_attribute.ignorerust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldAttribute#ignore. { |
| 96 | pattern_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!!(#field_name_real: _,)); |
| 97 | |
| 98 | continue; |
| 99 | } |
| 100 | |
| 101 | let key = match field_attribute.namerust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldAttribute#name. { |
| 102 | FieldNamerust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldName#::Customrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldName#Custom#(name) => name, |
| 103 | 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# => field_name_real.clonerust-analyzer cargo proc-macro2 1.0.107 impl#[Ident][Clone]clone().(), |
| 104 | }; |
| 105 | |
| 106 | pattern_token_stream |
| 107 | .extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!!(#field_name_real: #field_name_var,)); |
| 108 | |
| 109 | let ty = &field.tyrust-analyzer cargo syn 2.0.119 data/Field#ty.; |
| 110 | |
| 111 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(method) = field_attribute.methodrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldAttribute#method. { |
| 112 | block_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(superrust-analyzer cargo educe 0.6.0 trait_handlers/debug/::commonrust-analyzer cargo educe 0.6.0 trait_handlers/debug/common/::create_format_argrust-analyzer cargo educe 0.6.0 trait_handlers/debug/common/create_format_arg().( |
| 113 | ast, |
| 114 | ty, |
| 115 | &method, |
| 116 | quoterust-analyzer cargo quote 1.0.47 quote!!(#field_name_var), |
| 117 | )); |
| 118 | |
| 119 | block_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(if name_string.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() { |
| 120 | quoterust-analyzer cargo quote 1.0.47 quote!! (builder.field(stringify!(#key), &arg);) |
| 121 | } else { |
| 122 | quoterust-analyzer cargo quote 1.0.47 quote!! (builder.entry(&Educe__RawString(stringify!(#key)), &arg);) |
| 123 | }); |
| 124 | } else { |
| 125 | debug_types.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(ty); |
| 126 | |
| 127 | block_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(if name_string.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() { |
| 128 | quoterust-analyzer cargo quote 1.0.47 quote!! (builder.field(stringify!(#key), #field_name_var);) |
| 129 | } else { |
| 130 | quoterust-analyzer cargo quote 1.0.47 quote!! (builder.entry(&Educe__RawString(stringify!(#key)), #field_name_var);) |
| 131 | }); |
| 132 | } |
| 133 | |
| 134 | has_fields = true; |
| 135 | } |
| 136 | } else { |
| 137 | block_token_stream |
| 138 | .extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!!(let mut builder = f.debug_tuple(#name_string);)); |
| 139 | |
| 140 | for field in fields.namedrust-analyzer cargo syn 2.0.119 data/FieldsNamed#named..iterrust-analyzer cargo syn 2.0.119 punctuated/impl#[`Punctuated<T, P>`]iter().() { |
| 141 | let field_attribute = FieldAttributeBuilderrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldAttributeBuilder# { |
| 142 | enable_namerust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldAttributeBuilder#enable_name.: false, |
| 143 | enable_ignorerust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldAttributeBuilder#enable_ignore.: true, |
| 144 | enable_methodrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldAttributeBuilder#enable_method.: true, |
| 145 | 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#, |
| 146 | } |
| 147 | .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().; |
| 148 | |
| 149 | let field_name_real = field.identrust-analyzer cargo syn 2.0.119 data/Field#ident..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 150 | let field_name_var = format_identrust-analyzer cargo quote 1.0.47 format/format_ident!!("_{}", field_name_real); |
| 151 | |
| 152 | if field_attribute.ignorerust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldAttribute#ignore. { |
| 153 | pattern_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!!(#field_name_real: _,)); |
| 154 | |
| 155 | continue; |
| 156 | } |
| 157 | |
| 158 | pattern_token_stream |
| 159 | .extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!!(#field_name_real: #field_name_var,)); |
| 160 | |
| 161 | let ty = &field.tyrust-analyzer cargo syn 2.0.119 data/Field#ty.; |
| 162 | |
| 163 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(method) = field_attribute.methodrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldAttribute#method. { |
| 164 | block_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(superrust-analyzer cargo educe 0.6.0 trait_handlers/debug/::commonrust-analyzer cargo educe 0.6.0 trait_handlers/debug/common/::create_format_argrust-analyzer cargo educe 0.6.0 trait_handlers/debug/common/create_format_arg().( |
| 165 | ast, |
| 166 | ty, |
| 167 | &method, |
| 168 | quoterust-analyzer cargo quote 1.0.47 quote!!(#field_name_var), |
| 169 | )); |
| 170 | |
| 171 | block_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!! (builder.field(&arg);)); |
| 172 | } else { |
| 173 | debug_types.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(ty); |
| 174 | |
| 175 | block_token_stream |
| 176 | .extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!! (builder.field(#field_name_var);)); |
| 177 | } |
| 178 | |
| 179 | has_fields = true; |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().has_fields && name_string.is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().() { |
| 184 | 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/::unit_struct_need_namerust-analyzer cargo educe 0.6.0 trait_handlers/debug/panic/unit_struct_need_name().(variant_ident)); |
| 185 | } |
| 186 | |
| 187 | arms_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!! { |
| 188 | Self::#variant_ident { #pattern_token_stream } => { |
| 189 | #block_token_stream |
| 190 | |
| 191 | builder.finish() |
| 192 | }, |
| 193 | }); |
| 194 | }, |
| 195 | Fieldsrust-analyzer cargo syn 2.0.119 data/Fields#::Unnamedrust-analyzer cargo syn 2.0.119 data/Fields#Unnamed#(fields) => { |
| 196 | let mut has_fields = false; |
| 197 | |
| 198 | let mut pattern_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().(); |
| 199 | let mut block_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().(); |
| 200 | |
| 201 | if named_field { |
| 202 | block_token_stream |
| 203 | .extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(create_named_field_builderrust-analyzer cargo educe 0.6.0 trait_handlers/debug/debug_enum/create_named_field_builder().(name_string.as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().())); |
| 204 | |
| 205 | for (index, field) in fields.unnamedrust-analyzer cargo syn 2.0.119 data/FieldsUnnamed#unnamed..iterrust-analyzer cargo syn 2.0.119 punctuated/impl#[`Punctuated<T, P>`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() { |
| 206 | let field_attribute = FieldAttributeBuilderrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldAttributeBuilder# { |
| 207 | enable_namerust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldAttributeBuilder#enable_name.: true, |
| 208 | enable_ignorerust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldAttributeBuilder#enable_ignore.: true, |
| 209 | enable_methodrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldAttributeBuilder#enable_method.: true, |
| 210 | 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#, |
| 211 | } |
| 212 | .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().; |
| 213 | |
| 214 | if field_attribute.ignorerust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldAttribute#ignore. { |
| 215 | pattern_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!!(_,)); |
| 216 | |
| 217 | continue; |
| 218 | } |
| 219 | |
| 220 | let field_name_var = format_identrust-analyzer cargo quote 1.0.47 format/format_ident!!("_{}", index); |
| 221 | |
| 222 | let key = match field_attribute.namerust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldAttribute#name. { |
| 223 | FieldNamerust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldName#::Customrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldName#Custom#(name) => name, |
| 224 | 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# => field_name_var.clonerust-analyzer cargo proc-macro2 1.0.107 impl#[Ident][Clone]clone().(), |
| 225 | }; |
| 226 | |
| 227 | pattern_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!!(#field_name_var,)); |
| 228 | |
| 229 | let ty = &field.tyrust-analyzer cargo syn 2.0.119 data/Field#ty.; |
| 230 | |
| 231 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(method) = field_attribute.methodrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldAttribute#method. { |
| 232 | block_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(superrust-analyzer cargo educe 0.6.0 trait_handlers/debug/::commonrust-analyzer cargo educe 0.6.0 trait_handlers/debug/common/::create_format_argrust-analyzer cargo educe 0.6.0 trait_handlers/debug/common/create_format_arg().( |
| 233 | ast, |
| 234 | ty, |
| 235 | &method, |
| 236 | quoterust-analyzer cargo quote 1.0.47 quote!!(#field_name_var), |
| 237 | )); |
| 238 | |
| 239 | block_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(if name_string.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() { |
| 240 | quoterust-analyzer cargo quote 1.0.47 quote!! (builder.field(stringify!(#key), &arg);) |
| 241 | } else { |
| 242 | quoterust-analyzer cargo quote 1.0.47 quote!! (builder.entry(&Educe__RawString(stringify!(#key)), &arg);) |
| 243 | }); |
| 244 | } else { |
| 245 | debug_types.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(ty); |
| 246 | |
| 247 | block_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(if name_string.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() { |
| 248 | quoterust-analyzer cargo quote 1.0.47 quote!! (builder.field(stringify!(#key), #field_name_var);) |
| 249 | } else { |
| 250 | quoterust-analyzer cargo quote 1.0.47 quote!! (builder.entry(&Educe__RawString(stringify!(#key)), #field_name_var);) |
| 251 | }); |
| 252 | } |
| 253 | |
| 254 | has_fields = true; |
| 255 | } |
| 256 | } else { |
| 257 | block_token_stream |
| 258 | .extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!!(let mut builder = f.debug_tuple(#name_string);)); |
| 259 | |
| 260 | for (index, field) in fields.unnamedrust-analyzer cargo syn 2.0.119 data/FieldsUnnamed#unnamed..iterrust-analyzer cargo syn 2.0.119 punctuated/impl#[`Punctuated<T, P>`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() { |
| 261 | let field_attribute = FieldAttributeBuilderrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldAttributeBuilder# { |
| 262 | enable_namerust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldAttributeBuilder#enable_name.: false, |
| 263 | enable_ignorerust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldAttributeBuilder#enable_ignore.: true, |
| 264 | enable_methodrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldAttributeBuilder#enable_method.: true, |
| 265 | 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#, |
| 266 | } |
| 267 | .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().; |
| 268 | |
| 269 | if field_attribute.ignorerust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldAttribute#ignore. { |
| 270 | pattern_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!!(_,)); |
| 271 | |
| 272 | continue; |
| 273 | } |
| 274 | |
| 275 | let field_name_var = format_identrust-analyzer cargo quote 1.0.47 format/format_ident!!("_{}", index); |
| 276 | |
| 277 | pattern_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!!(#field_name_var,)); |
| 278 | |
| 279 | let ty = &field.tyrust-analyzer cargo syn 2.0.119 data/Field#ty.; |
| 280 | |
| 281 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(method) = field_attribute.methodrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/field_attribute/FieldAttribute#method. { |
| 282 | block_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(superrust-analyzer cargo educe 0.6.0 trait_handlers/debug/::commonrust-analyzer cargo educe 0.6.0 trait_handlers/debug/common/::create_format_argrust-analyzer cargo educe 0.6.0 trait_handlers/debug/common/create_format_arg().( |
| 283 | ast, |
| 284 | ty, |
| 285 | &method, |
| 286 | quoterust-analyzer cargo quote 1.0.47 quote!!(#field_name_var), |
| 287 | )); |
| 288 | |
| 289 | block_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!! (builder.field(&arg);)); |
| 290 | } else { |
| 291 | debug_types.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(ty); |
| 292 | |
| 293 | block_token_stream |
| 294 | .extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!! (builder.field(#field_name_var);)); |
| 295 | } |
| 296 | |
| 297 | has_fields = true; |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().has_fields && name_string.is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().() { |
| 302 | 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/::unit_struct_need_namerust-analyzer cargo educe 0.6.0 trait_handlers/debug/panic/unit_struct_need_name().(variant_ident)); |
| 303 | } |
| 304 | |
| 305 | arms_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!! { |
| 306 | Self::#variant_ident ( #pattern_token_stream ) => { |
| 307 | #block_token_stream |
| 308 | |
| 309 | builder.finish() |
| 310 | }, |
| 311 | }); |
| 312 | }, |
| 313 | } |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | let ident = &ast.identrust-analyzer cargo syn 2.0.119 derive/DeriveInput#ident.; |
| 318 | |
| 319 | if arms_token_stream.is_emptyrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream]is_empty().() { |
| 320 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ident) = name { |
| 321 | builder_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!! { |
| 322 | f.write_str(stringify!(#ident)) |
| 323 | }); |
| 324 | } else { |
| 325 | 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/::unit_enum_need_namerust-analyzer cargo educe 0.6.0 trait_handlers/debug/panic/unit_enum_need_name().(ident)); |
| 326 | } |
| 327 | } else { |
| 328 | builder_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!! { |
| 329 | match self { |
| 330 | #arms_token_stream |
| 331 | } |
| 332 | }); |
| 333 | } |
| 334 | |
| 335 | let bound = type_attribute.boundrust-analyzer cargo educe 0.6.0 trait_handlers/debug/models/type_attribute/TypeAttribute#bound..into_where_predicates_by_generic_parameters_check_typesrust-analyzer cargo educe 0.6.0 common/bound/impl#[Bound]into_where_predicates_by_generic_parameters_check_types().( |
| 336 | &ast.genericsrust-analyzer cargo syn 2.0.119 derive/DeriveInput#generics..paramsrust-analyzer cargo syn 2.0.119 generics/Generics#params., |
| 337 | &synrust-analyzer cargo syn 2.0.119 crate/::parse2rust-analyzer cargo syn 2.0.119 parse2().(quoterust-analyzer cargo quote 1.0.47 quote!!(::core::fmt::Debug)).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 338 | &debug_types, |
| 339 | &[], |
| 340 | ); |
| 341 | |
| 342 | let mut generics = ast.genericsrust-analyzer cargo syn 2.0.119 derive/DeriveInput#generics..clonerust-analyzer cargo syn 2.0.119 gen/clone/impl#[`crate::Generics`][Clone]clone().(); |
| 343 | let where_clause = generics.make_where_clauserust-analyzer cargo syn 2.0.119 generics/impl#[Generics]make_where_clause().(); |
| 344 | |
| 345 | for where_predicate in bound { |
| 346 | where_clause.predicatesrust-analyzer cargo syn 2.0.119 generics/WhereClause#predicates..pushrust-analyzer cargo syn 2.0.119 punctuated/impl#[`Punctuated<T, P>`]push().(where_predicate); |
| 347 | } |
| 348 | |
| 349 | let (impl_generics, ty_generics, where_clause) = generics.split_for_implrust-analyzer cargo syn 2.0.119 generics/impl#[Generics]split_for_impl().(); |
| 350 | |
| 351 | token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!! { |
| 352 | impl #impl_generics ::core::fmt::Debug for #ident #ty_generics #where_clause { |
| 353 | #[inline] |
| 354 | fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { |
| 355 | #builder_token_stream |
| 356 | } |
| 357 | } |
| 358 | }); |
| 359 | |
| 360 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 361 | } |
| 362 | } |
| 363 | |
| 364 | #[inline] |
| 365 | fn create_named_field_builderrust-analyzer cargo educe 0.6.0 trait_handlers/debug/debug_enum/create_named_field_builder().(name_string: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str>) -> proc_macro2rust-analyzer cargo proc-macro2 1.0.107 crate/::TokenStreamrust-analyzer cargo proc-macro2 1.0.107 TokenStream# { |
| 366 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(name_string) = name_string { |
| 367 | quoterust-analyzer cargo quote 1.0.47 quote!!(let mut builder = f.debug_struct(#name_string);) |
| 368 | } else { |
| 369 | superrust-analyzer cargo educe 0.6.0 trait_handlers/debug/::commonrust-analyzer cargo educe 0.6.0 trait_handlers/debug/common/::create_debug_map_builderrust-analyzer cargo educe 0.6.0 trait_handlers/debug/common/create_debug_map_builder().() |
| 370 | } |
| 371 | } |