| 1 | use craterust-analyzer cargo const_format_proc_macros 0.2.34 crate/::datastructurerust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/::{DataStructurerust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataStructure#, DataVariantrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataVariant#, Fieldrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Field#, StructKindrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructKind#}; |
| 2 | |
| 3 | use proc_macro2rust-analyzer cargo proc-macro2 1.0.107 crate/::{Spanrust-analyzer cargo proc-macro2 1.0.107 Span#, TokenStreamrust-analyzer cargo proc-macro2 1.0.107 TokenStream# as TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream#}; |
| 4 | |
| 5 | use quoterust-analyzer cargo quote 1.0.47 crate/::{quoterust-analyzer cargo quote 1.0.47 quote!, quote_spannedrust-analyzer cargo quote 1.0.47 quote_spanned!, quote_spannedrust-analyzer cargo quote 1.0.47 quote_spanned! as quote_srust-analyzer cargo quote 1.0.47 quote_spanned!, ToTokensrust-analyzer cargo quote 1.0.47 to_tokens/ToTokens#, TokenStreamExtrust-analyzer cargo quote 1.0.47 ext/TokenStreamExt#}; |
| 6 | |
| 7 | use synrust-analyzer cargo syn 1.0.109 crate/::{DeriveInputrust-analyzer cargo syn 1.0.109 derive/DeriveInput#, Identrust-analyzer cargo proc-macro2 1.0.107 Ident#}; |
| 8 | |
| 9 | mod attribute_parsingrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/attribute_parsing/; |
| 10 | mod syntaxrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/syntax/; |
| 11 | mod type_detectionrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/type_detection/; |
| 12 | |
| 13 | use selfrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/::attribute_parsingrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/attribute_parsing/::HowToFmtrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/attribute_parsing/HowToFmt#; |
| 14 | |
| 15 | pub(craterust-analyzer cargo const_format_proc_macros 0.2.34 crate/) fn derive_constdebug_implrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/derive_constdebug_impl().(input: DeriveInputrust-analyzer cargo syn 1.0.109 derive/DeriveInput#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream#, craterust-analyzer cargo const_format_proc_macros 0.2.34 crate/::Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#> { |
| 16 | let ds = &DataStructurerust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataStructure#::newrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/impl#[`DataStructure<'a>`]new().(&input); |
| 17 | let config = attribute_parsingrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/attribute_parsing/::parse_attrs_for_deriverust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/attribute_parsing/parse_attrs_for_derive().(ds)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 18 | let cratep = match &config.crate_pathrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/attribute_parsing/ConstDebugConfig#crate_path. { |
| 19 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(p) => p.to_token_streamrust-analyzer cargo quote 1.0.47 to_tokens/ToTokens#to_token_stream().(), |
| 20 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => quoterust-analyzer cargo quote 1.0.47 quote!!(::const_format), |
| 21 | }; |
| 22 | |
| 23 | let vis = ds.visrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataStructure#vis.; |
| 24 | |
| 25 | let name = ds.namerust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataStructure#name.; |
| 26 | |
| 27 | let mut impl_headers; |
| 28 | |
| 29 | if config.implsrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/attribute_parsing/ConstDebugConfig#impls..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() { |
| 30 | let impl_params = ds.genericsrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataStructure#generics..paramsrust-analyzer cargo syn 1.0.109 generics/Generics#params..iterrust-analyzer cargo syn 1.0.109 punctuated/impl#[`Punctuated<T, P>`]iter().(); |
| 31 | let (_, tygen, _) = ds.genericsrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataStructure#generics..split_for_implrust-analyzer cargo syn 1.0.109 generics/impl#[Generics]split_for_impl().(); |
| 32 | let where_clause = get_where_clause_tokensrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/get_where_clause_tokens().(&ds.genericsrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataStructure#generics..where_clauserust-analyzer cargo syn 1.0.109 generics/Generics#where_clause.); |
| 33 | |
| 34 | impl_headers = quoterust-analyzer cargo quote 1.0.47 quote!!( |
| 35 | impl[#( #impl_params ,)*] #name #tygen |
| 36 | #where_clause; |
| 37 | ); |
| 38 | } else { |
| 39 | impl_headers = TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream#::newrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream]new().(); |
| 40 | |
| 41 | for imp in config.implsrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/attribute_parsing/ConstDebugConfig#impls..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() { |
| 42 | let params = imp.genericsrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/syntax/ImplHeader#generics..paramsrust-analyzer cargo syn 1.0.109 generics/Generics#params..iterrust-analyzer cargo syn 1.0.109 punctuated/impl#[`Punctuated<T, P>`]iter().(); |
| 43 | let self_ty = &imp.self_tyrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/syntax/ImplHeader#self_ty.; |
| 44 | let where_clause = get_where_clause_tokensrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/get_where_clause_tokens().(&imp.genericsrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/syntax/ImplHeader#generics..where_clauserust-analyzer cargo syn 1.0.109 generics/Generics#where_clause.); |
| 45 | |
| 46 | impl_headers.append_allrust-analyzer cargo quote 1.0.47 ext/impl#[TokenStream][TokenStreamExt]append_all().(quoterust-analyzer cargo quote 1.0.47 quote!!( |
| 47 | impl[#(#params)*] #self_ty |
| 48 | #where_clause; |
| 49 | )); |
| 50 | } |
| 51 | }; |
| 52 | |
| 53 | let enum_prefix = match ds.data_variantrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataStructure#data_variant. { |
| 54 | DataVariantrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataVariant#::Enumrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataVariant#Enum# => quoterust-analyzer cargo quote 1.0.47 quote!!(#name::), |
| 55 | DataVariantrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataVariant#::Structrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataVariant#Struct# => TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream#::newrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream]new().(), |
| 56 | DataVariantrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataVariant#::Unionrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataVariant#Union# => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Cannot derive ConstDebug on unions"), |
| 57 | }; |
| 58 | |
| 59 | let variant_branches = ds.variantsrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataStructure#variants..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|variant| { |
| 60 | let vname = variant.namerust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Struct#name.; |
| 61 | |
| 62 | let debug_method = match variant.kindrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Struct#kind. { |
| 63 | StructKindrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructKind#::Bracedrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructKind#Braced# => Identrust-analyzer cargo proc-macro2 1.0.107 Ident#::newrust-analyzer cargo proc-macro2 1.0.107 impl#[Ident]new().("debug_struct", Spanrust-analyzer cargo proc-macro2 1.0.107 Span#::call_siterust-analyzer cargo proc-macro2 1.0.107 impl#[Span]call_site().()), |
| 64 | StructKindrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructKind#::Tupledrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructKind#Tupled# => Identrust-analyzer cargo proc-macro2 1.0.107 Ident#::newrust-analyzer cargo proc-macro2 1.0.107 impl#[Ident]new().("debug_tuple", Spanrust-analyzer cargo proc-macro2 1.0.107 Span#::call_siterust-analyzer cargo proc-macro2 1.0.107 impl#[Span]call_site().()), |
| 65 | }; |
| 66 | |
| 67 | let patt = variant |
| 68 | .fieldsrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Struct#fields. |
| 69 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 70 | .filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(|f| -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream#> { |
| 71 | if let HowToFmtrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/attribute_parsing/HowToFmt#::Ignorerust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/attribute_parsing/HowToFmt#Ignore# = config.field_maprust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/attribute_parsing/ConstDebugConfig#field_map.[rust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/field_map/impl#[`FieldMap<T>`][`Index<&'a Field<'a>>`]index().f]rust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/field_map/impl#[`FieldMap<T>`][`Index<&'a Field<'a>>`]index()..how_to_fmtrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/attribute_parsing/FieldConfig#how_to_fmt. { |
| 72 | return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 73 | } |
| 74 | |
| 75 | let pat = &f.identrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Field#ident.; |
| 76 | let variable = f.pattern_identrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/impl#[`Field<'a>`]pattern_ident().(); |
| 77 | |
| 78 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(quoterust-analyzer cargo quote 1.0.47 quote!!(#pat : #variable,)) |
| 79 | }); |
| 80 | |
| 81 | let fmt_call = variant |
| 82 | .fieldsrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Struct#fields. |
| 83 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 84 | .filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(|f| -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream#> { |
| 85 | let how_to_fmt = &config.field_maprust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/attribute_parsing/ConstDebugConfig#field_map.[rust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/field_map/impl#[`FieldMap<T>`][`Index<&'a Field<'a>>`]index().f]rust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/field_map/impl#[`FieldMap<T>`][`Index<&'a Field<'a>>`]index()..how_to_fmtrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/attribute_parsing/FieldConfig#how_to_fmt.; |
| 86 | if let HowToFmtrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/attribute_parsing/HowToFmt#::Ignorerust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/attribute_parsing/HowToFmt#Ignore# = how_to_fmt { |
| 87 | return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 88 | } |
| 89 | |
| 90 | let fspan = f.pattern_identrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/impl#[`Field<'a>`]pattern_ident().().spanrust-analyzer cargo proc-macro2 1.0.107 impl#[Ident]span().(); |
| 91 | |
| 92 | let field_name_str = match variant.kindrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Struct#kind. { |
| 93 | StructKindrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructKind#::Bracedrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructKind#Braced# => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(f.identrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Field#ident..to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), |
| 94 | StructKindrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructKind#::Tupledrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructKind#Tupled# => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 95 | } |
| 96 | .into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][IntoIterator]into_iter().(); |
| 97 | |
| 98 | let mut field_ts = quote_spannedrust-analyzer cargo quote 1.0.47 quote_spanned!!(fspan=> |
| 99 | let mut field_formatter = formatter.field(#(#field_name_str)*); |
| 100 | ); |
| 101 | |
| 102 | field_ts.append_allrust-analyzer cargo quote 1.0.47 ext/impl#[TokenStream][TokenStreamExt]append_all().(match &how_to_fmt { |
| 103 | HowToFmtrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/attribute_parsing/HowToFmt#::Regularrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/attribute_parsing/HowToFmt#Regular# => coerce_and_fmtrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/coerce_and_fmt().(&cratep, f), |
| 104 | HowToFmtrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/attribute_parsing/HowToFmt#::Ignorerust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/attribute_parsing/HowToFmt#Ignore# => unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!(), |
| 105 | HowToFmtrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/attribute_parsing/HowToFmt#::Slicerust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/attribute_parsing/HowToFmt#Slice# => fmt_slicerust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/fmt_slice().(&cratep, f), |
| 106 | HowToFmtrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/attribute_parsing/HowToFmt#::Option_rust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/attribute_parsing/HowToFmt#Option_# => fmt_optionrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/fmt_option().(&cratep, f), |
| 107 | HowToFmtrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/attribute_parsing/HowToFmt#::Newtyperust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/attribute_parsing/HowToFmt#Newtype#(newtype) => fmt_newtyperust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/fmt_newtype().(&cratep, newtype, f), |
| 108 | HowToFmtrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/attribute_parsing/HowToFmt#::Withrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/attribute_parsing/HowToFmt#With#(with) => call_with_functionrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/call_with_function().(&cratep, f, with), |
| 109 | HowToFmtrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/attribute_parsing/HowToFmt#::WithMacrorust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/attribute_parsing/HowToFmt#WithMacro#(with) => call_with_macrorust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/call_with_macro().(&cratep, f, with), |
| 110 | HowToFmtrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/attribute_parsing/HowToFmt#::WithWrapperrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/attribute_parsing/HowToFmt#WithWrapper#(with) => call_with_wrapperrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/call_with_wrapper().(&cratep, f, with), |
| 111 | }); |
| 112 | |
| 113 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(field_ts) |
| 114 | }); |
| 115 | |
| 116 | quoterust-analyzer cargo quote 1.0.47 quote!!( |
| 117 | #enum_prefix #vname { #(#patt)* .. } => { |
| 118 | let mut formatter = formatter.#debug_method(stringify!(#vname)); |
| 119 | #(#fmt_call)* |
| 120 | formatter.finish() |
| 121 | } |
| 122 | ) |
| 123 | }); |
| 124 | |
| 125 | let ret = quoterust-analyzer cargo quote 1.0.47 quote!!( |
| 126 | #cratep::impl_fmt!{ |
| 127 | #impl_headers |
| 128 | |
| 129 | #vis const fn const_debug_fmt( |
| 130 | &self, |
| 131 | formatter: &mut #cratep::pmr::Formatter<'_>, |
| 132 | ) -> #cratep::pmr::Result<(), #cratep::pmr::Error> { |
| 133 | match self { |
| 134 | #( |
| 135 | #variant_branches |
| 136 | )* |
| 137 | } |
| 138 | } |
| 139 | } |
| 140 | ); |
| 141 | |
| 142 | if config.debug_printrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/attribute_parsing/ConstDebugConfig#debug_print. { |
| 143 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("\n\n\n{}\n\n\n", ret); |
| 144 | } |
| 145 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ret) |
| 146 | } |
| 147 | |
| 148 | // Copying the definitino of the `const_format::coerce_to_fn` macro here |
| 149 | // because the compiler points inside the coerce_to_fn macro otherwise |
| 150 | fn coerce_and_fmtrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/coerce_and_fmt().(cratep: &TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream#, field: &Fieldrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Field#<'_>) -> TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream# { |
| 151 | let var = field.pattern_identrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/impl#[`Field<'a>`]pattern_ident().(); |
| 152 | let fspan = var.spanrust-analyzer cargo proc-macro2 1.0.107 impl#[Ident]span().(); |
| 153 | |
| 154 | quote_spannedrust-analyzer cargo quote 1.0.47 quote_spanned!!(fspan=> |
| 155 | let mut marker = #cratep::pmr::IsAFormatMarker::NEW; |
| 156 | if false { |
| 157 | marker = marker.infer_type(#var); |
| 158 | } |
| 159 | #cratep::try_!( |
| 160 | marker.coerce(marker.unreference(#var)) |
| 161 | .const_debug_fmt(field_formatter) |
| 162 | ); |
| 163 | ) |
| 164 | } |
| 165 | |
| 166 | fn fmt_slicerust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/fmt_slice().(cratep: &TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream#, field: &Fieldrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Field#<'_>) -> TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream# { |
| 167 | let var = field.pattern_identrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/impl#[`Field<'a>`]pattern_ident().(); |
| 168 | let fspan = var.spanrust-analyzer cargo proc-macro2 1.0.107 impl#[Ident]span().(); |
| 169 | |
| 170 | let call = call_debug_fmtrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/call_debug_fmt().( |
| 171 | cratep, |
| 172 | quote_srust-analyzer cargo quote 1.0.47 quote_spanned!!(fspan=> &#var[n]), |
| 173 | quote_srust-analyzer cargo quote 1.0.47 quote_spanned!!(fspan=> slice_fmt.entry()), |
| 174 | fspan, |
| 175 | ); |
| 176 | |
| 177 | quote_spannedrust-analyzer cargo quote 1.0.47 quote_spanned!!(fspan=>{ |
| 178 | let mut slice_fmt = field_formatter.debug_list(); |
| 179 | let mut n = 0; |
| 180 | let len = #var.len(); |
| 181 | while n != len { |
| 182 | #call |
| 183 | n += 1; |
| 184 | } |
| 185 | #cratep::try_!(slice_fmt.finish()); |
| 186 | }) |
| 187 | } |
| 188 | |
| 189 | fn fmt_optionrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/fmt_option().(cratep: &TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream#, field: &Fieldrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Field#<'_>) -> TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream# { |
| 190 | let var = field.pattern_identrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/impl#[`Field<'a>`]pattern_ident().(); |
| 191 | let fspan = var.spanrust-analyzer cargo proc-macro2 1.0.107 impl#[Ident]span().(); |
| 192 | |
| 193 | let call = call_debug_fmtrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/call_debug_fmt().( |
| 194 | cratep, |
| 195 | quote_srust-analyzer cargo quote 1.0.47 quote_spanned!!(fspan=>val), |
| 196 | quote_srust-analyzer cargo quote 1.0.47 quote_spanned!!(fspan=>f.field()), |
| 197 | fspan, |
| 198 | ); |
| 199 | |
| 200 | quote_spannedrust-analyzer cargo quote 1.0.47 quote_spanned!!(fspan=> |
| 201 | #cratep::try_!(match #var { |
| 202 | #cratep::pmr::Some(val) => { |
| 203 | let mut f = field_formatter.debug_tuple("Some"); |
| 204 | #call |
| 205 | f.finish() |
| 206 | } |
| 207 | #cratep::pmr::None => field_formatter.write_str("None"), |
| 208 | }); |
| 209 | ) |
| 210 | } |
| 211 | |
| 212 | fn fmt_newtyperust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/fmt_newtype().(cratep: &TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream#, newtype: &synrust-analyzer cargo syn 1.0.109 crate/::Identrust-analyzer cargo proc-macro2 1.0.107 Ident#, field: &Fieldrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Field#<'_>) -> TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream# { |
| 213 | let var = field.pattern_identrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/impl#[`Field<'a>`]pattern_ident().(); |
| 214 | let fspan = var.spanrust-analyzer cargo proc-macro2 1.0.107 impl#[Ident]span().(); |
| 215 | let ty_str = newtype.to_token_streamrust-analyzer cargo quote 1.0.47 to_tokens/ToTokens#to_token_stream().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(); |
| 216 | |
| 217 | let call = call_debug_fmtrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/call_debug_fmt().( |
| 218 | cratep, |
| 219 | quote_srust-analyzer cargo quote 1.0.47 quote_spanned!!(fspan=> &#var.0 ), |
| 220 | quote_srust-analyzer cargo quote 1.0.47 quote_spanned!!(fspan=> f.field() ), |
| 221 | fspan, |
| 222 | ); |
| 223 | |
| 224 | quote_spannedrust-analyzer cargo quote 1.0.47 quote_spanned!!(fspan=>{ |
| 225 | #cratep::try_!({ |
| 226 | let mut f = field_formatter.debug_tuple(#ty_str); |
| 227 | #call |
| 228 | f.finish() |
| 229 | }); |
| 230 | }) |
| 231 | } |
| 232 | |
| 233 | fn call_with_functionrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/call_with_function().(cratep: &TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream#, field: &Fieldrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Field#<'_>, func: &synrust-analyzer cargo syn 1.0.109 crate/::Pathrust-analyzer cargo syn 1.0.109 path/Path#) -> TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream# { |
| 234 | let var = field.pattern_identrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/impl#[`Field<'a>`]pattern_ident().(); |
| 235 | let fspan = var.spanrust-analyzer cargo proc-macro2 1.0.107 impl#[Ident]span().(); |
| 236 | |
| 237 | quote_spannedrust-analyzer cargo quote 1.0.47 quote_spanned!!(fspan=> #cratep::try_!(#func(#var, field_formatter)); ) |
| 238 | } |
| 239 | |
| 240 | fn call_with_macrorust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/call_with_macro().(cratep: &TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream#, field: &Fieldrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Field#<'_>, macr: &synrust-analyzer cargo syn 1.0.109 crate/::Pathrust-analyzer cargo syn 1.0.109 path/Path#) -> TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream# { |
| 241 | let var = field.pattern_identrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/impl#[`Field<'a>`]pattern_ident().(); |
| 242 | let fspan = var.spanrust-analyzer cargo proc-macro2 1.0.107 impl#[Ident]span().(); |
| 243 | |
| 244 | quote_spannedrust-analyzer cargo quote 1.0.47 quote_spanned!!(fspan=> #cratep::try_!(#macr!(#var, field_formatter)); ) |
| 245 | } |
| 246 | |
| 247 | fn call_with_wrapperrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/call_with_wrapper().( |
| 248 | cratep: &TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream#, |
| 249 | field: &Fieldrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Field#<'_>, |
| 250 | newtype: &synrust-analyzer cargo syn 1.0.109 crate/::Pathrust-analyzer cargo syn 1.0.109 path/Path#, |
| 251 | ) -> TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream# { |
| 252 | let var = field.pattern_identrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/impl#[`Field<'a>`]pattern_ident().(); |
| 253 | let fspan = var.spanrust-analyzer cargo proc-macro2 1.0.107 impl#[Ident]span().(); |
| 254 | |
| 255 | quote_spannedrust-analyzer cargo quote 1.0.47 quote_spanned!!(fspan=> |
| 256 | #cratep::try_!(#newtype(#var).const_debug_fmt(field_formatter)); |
| 257 | ) |
| 258 | } |
| 259 | |
| 260 | // Helper of the other `call_` functions |
| 261 | fn call_debug_fmtrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/call_debug_fmt().( |
| 262 | cratep: &TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream#, |
| 263 | field: impl ToTokensrust-analyzer cargo quote 1.0.47 to_tokens/ToTokens#, |
| 264 | formatter: impl ToTokensrust-analyzer cargo quote 1.0.47 to_tokens/ToTokens#, |
| 265 | span: Spanrust-analyzer cargo proc-macro2 1.0.107 Span#, |
| 266 | ) -> TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream# { |
| 267 | quote_spannedrust-analyzer cargo quote 1.0.47 quote_spanned!!(span=>{ |
| 268 | // Importing it like this because the error span is wrong otherwise |
| 269 | use #cratep::pmr::IsAFormatMarker as __IsAFormatMarker; |
| 270 | |
| 271 | let mut marker = __IsAFormatMarker::NEW; |
| 272 | if false { |
| 273 | marker = marker.infer_type(#field); |
| 274 | } |
| 275 | #cratep::try_!( |
| 276 | marker.coerce(marker.unreference(#field)).const_debug_fmt(#formatter) |
| 277 | ); |
| 278 | }) |
| 279 | } |
| 280 | |
| 281 | fn get_where_clause_tokensrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/get_where_clause_tokens().(where_clause: &Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<synrust-analyzer cargo syn 1.0.109 crate/::WhereClauserust-analyzer cargo syn 1.0.109 generics/WhereClause#>) -> TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream# { |
| 282 | match where_clause { |
| 283 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(x) => { |
| 284 | let preds = x.predicatesrust-analyzer cargo syn 1.0.109 generics/WhereClause#predicates..iterrust-analyzer cargo syn 1.0.109 punctuated/impl#[`Punctuated<T, P>`]iter().(); |
| 285 | quoterust-analyzer cargo quote 1.0.47 quote!!(where[ #(#preds,)* ]) |
| 286 | } |
| 287 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream#::newrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream]new().(), |
| 288 | } |
| 289 | } |