| 1 | #![allow(clippy::or_fun_call)] |
| 2 | #![allow(clippy::derive_partial_eq_without_eq)] |
| 3 | |
| 4 | use proc_macrorust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro crate/::TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream# as TokenStream1rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#; |
| 5 | |
| 6 | use proc_macro2rust-analyzer cargo proc-macro2 1.0.107 crate/::TokenStreamrust-analyzer cargo proc-macro2 1.0.107 TokenStream# as TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream#; |
| 7 | |
| 8 | #[cfg(feature = "derive")] |
| 9 | #[macro_use] |
| 10 | mod macrosrust-analyzer cargo const_format_proc_macros 0.2.34 macros/; |
| 11 | |
| 12 | #[cfg(feature = "derive")] |
| 13 | mod datastructurerust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/; |
| 14 | |
| 15 | mod errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/; |
| 16 | |
| 17 | #[cfg(feature = "derive")] |
| 18 | mod derive_debugrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/; |
| 19 | |
| 20 | mod format_argsrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/; |
| 21 | |
| 22 | mod format_strrust-analyzer cargo const_format_proc_macros 0.2.34 format_str/; |
| 23 | |
| 24 | mod format_macrorust-analyzer cargo const_format_proc_macros 0.2.34 format_macro/; |
| 25 | |
| 26 | mod formattingrust-analyzer cargo const_format_proc_macros 0.2.34 formatting/; |
| 27 | |
| 28 | mod parse_utilsrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/; |
| 29 | |
| 30 | mod respan_to_macrorust-analyzer cargo const_format_proc_macros 0.2.34 respan_to_macro/; |
| 31 | |
| 32 | mod shared_arg_parsingrust-analyzer cargo const_format_proc_macros 0.2.34 shared_arg_parsing/; |
| 33 | |
| 34 | mod spannedrust-analyzer cargo const_format_proc_macros 0.2.34 spanned/; |
| 35 | |
| 36 | mod utilsrust-analyzer cargo const_format_proc_macros 0.2.34 utils/; |
| 37 | |
| 38 | #[cfg(test)] |
| 39 | mod test_utilsrust-analyzer cargo const_format_proc_macros 0.2.34 test_utils/; |
| 40 | |
| 41 | use craterust-analyzer cargo const_format_proc_macros 0.2.34 crate/::errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/::Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#; |
| 42 | use craterust-analyzer cargo const_format_proc_macros 0.2.34 crate/::parse_utilsrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/::MyParserust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/MyParse#; |
| 43 | |
| 44 | fn compile_err_empty_strrust-analyzer cargo const_format_proc_macros 0.2.34 compile_err_empty_str().(e: craterust-analyzer cargo const_format_proc_macros 0.2.34 crate/::Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#) -> TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream# { |
| 45 | let e = e.to_compile_errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/impl#[Error]to_compile_error().(); |
| 46 | quoterust-analyzer cargo quote 1.0.47 crate/::quoterust-analyzer cargo quote 1.0.47 quote!!({ |
| 47 | #e; |
| 48 | "" |
| 49 | }) |
| 50 | } |
| 51 | |
| 52 | #[doc(hidden)] |
| 53 | #[proc_macro] |
| 54 | pub fn __concatcp_implrust-analyzer cargo const_format_proc_macros 0.2.34 __concatcp_impl!(input: TokenStream1rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#) -> TokenStream1rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream# { |
| 55 | MyParserust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/MyParse#::parse_token_stream_1rust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/MyParse#parse_token_stream_1().(input) |
| 56 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]and_then().(format_macrorust-analyzer cargo const_format_proc_macros 0.2.34 format_macro/::concatcp_implrust-analyzer cargo const_format_proc_macros 0.2.34 format_macro/concatcp_impl().) |
| 57 | .unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or_else().(compile_err_empty_strrust-analyzer cargo const_format_proc_macros 0.2.34 compile_err_empty_str().) |
| 58 | .intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 59 | } |
| 60 | |
| 61 | /// Input syntax: `"format string", (arg0), (name = arg1)` (with optional trailing comma). |
| 62 | /// |
| 63 | /// The arguments are parenthesized to not require syn to parse `arg0` and `arg1` as syn::Expr, |
| 64 | /// they're just parsed as a `TokenStream2`. |
| 65 | /// |
| 66 | /// They're guaranteed to be expressions when this macro is invoked by `const_format` macros, |
| 67 | /// which should be the only ones to do so. |
| 68 | #[doc(hidden)] |
| 69 | #[proc_macro] |
| 70 | pub fn __formatcp_implrust-analyzer cargo const_format_proc_macros 0.2.34 __formatcp_impl!(input: TokenStream1rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#) -> TokenStream1rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream# { |
| 71 | MyParserust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/MyParse#::parse_token_stream_1rust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/MyParse#parse_token_stream_1().(input) |
| 72 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]and_then().(format_macrorust-analyzer cargo const_format_proc_macros 0.2.34 format_macro/::formatcp_implrust-analyzer cargo const_format_proc_macros 0.2.34 format_macro/formatcp_impl().) |
| 73 | .unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or_else().(compile_err_empty_strrust-analyzer cargo const_format_proc_macros 0.2.34 compile_err_empty_str().) |
| 74 | .intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 75 | } |
| 76 | |
| 77 | #[doc(hidden)] |
| 78 | #[proc_macro] |
| 79 | pub fn __formatc_implrust-analyzer cargo const_format_proc_macros 0.2.34 __formatc_impl!(input: TokenStream1rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#) -> TokenStream1rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream# { |
| 80 | MyParserust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/MyParse#::parse_token_stream_1rust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/MyParse#parse_token_stream_1().(input) |
| 81 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]and_then().(format_macrorust-analyzer cargo const_format_proc_macros 0.2.34 format_macro/::formatc_macro_implrust-analyzer cargo const_format_proc_macros 0.2.34 format_macro/formatc_macro_impl().) |
| 82 | .unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or_else().(compile_err_empty_strrust-analyzer cargo const_format_proc_macros 0.2.34 compile_err_empty_str().) |
| 83 | .intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 84 | } |
| 85 | |
| 86 | #[doc(hidden)] |
| 87 | #[proc_macro] |
| 88 | pub fn __formatc_if_implrust-analyzer cargo const_format_proc_macros 0.2.34 __formatc_if_impl!(input: TokenStream1rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#) -> TokenStream1rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream# { |
| 89 | MyParserust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/MyParse#::parse_token_stream_1rust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/MyParse#parse_token_stream_1().(input) |
| 90 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]and_then().(format_macrorust-analyzer cargo const_format_proc_macros 0.2.34 format_macro/::formatc_if_macro_implrust-analyzer cargo const_format_proc_macros 0.2.34 format_macro/formatc_if_macro_impl().) |
| 91 | .unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or_else().(compile_err_empty_strrust-analyzer cargo const_format_proc_macros 0.2.34 compile_err_empty_str().) |
| 92 | .intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 93 | } |
| 94 | |
| 95 | #[doc(hidden)] |
| 96 | #[proc_macro] |
| 97 | pub fn __formatcp_if_implrust-analyzer cargo const_format_proc_macros 0.2.34 __formatcp_if_impl!(input: TokenStream1rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#) -> TokenStream1rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream# { |
| 98 | MyParserust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/MyParse#::parse_token_stream_1rust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/MyParse#parse_token_stream_1().(input) |
| 99 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]and_then().(format_macrorust-analyzer cargo const_format_proc_macros 0.2.34 format_macro/::formatcp_if_macro_implrust-analyzer cargo const_format_proc_macros 0.2.34 format_macro/formatcp_if_macro_impl().) |
| 100 | .unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or_else().(compile_err_empty_strrust-analyzer cargo const_format_proc_macros 0.2.34 compile_err_empty_str().) |
| 101 | .intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 102 | } |
| 103 | |
| 104 | #[doc(hidden)] |
| 105 | #[proc_macro] |
| 106 | pub fn __writec_implrust-analyzer cargo const_format_proc_macros 0.2.34 __writec_impl!(input: TokenStream1rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#) -> TokenStream1rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream# { |
| 107 | MyParserust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/MyParse#::parse_token_stream_1rust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/MyParse#parse_token_stream_1().(input) |
| 108 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]and_then().(format_macrorust-analyzer cargo const_format_proc_macros 0.2.34 format_macro/::writec_macro_implrust-analyzer cargo const_format_proc_macros 0.2.34 format_macro/writec_macro_impl().) |
| 109 | .unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or_else().(|e| { |
| 110 | let e = e.to_compile_errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/impl#[Error]to_compile_error().(); |
| 111 | quoterust-analyzer cargo quote 1.0.47 crate/::quoterust-analyzer cargo quote 1.0.47 quote!!({ |
| 112 | #e; |
| 113 | ::core::result::Result::Ok(()) |
| 114 | }) |
| 115 | }) |
| 116 | .intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 117 | } |
| 118 | |
| 119 | #[cfg(feature = "derive")] |
| 120 | #[proc_macro_derive(ConstDebug, attributes(cdeb))] |
| 121 | pub fn derive_const_debugrust-analyzer cargo const_format_proc_macros 0.2.34 ConstDebug:(input: TokenStream1rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#) -> TokenStream1rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream# { |
| 122 | synrust-analyzer cargo syn 1.0.109 crate/::parserust-analyzer cargo syn 1.0.109 parse().(input) |
| 123 | .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(craterust-analyzer cargo const_format_proc_macros 0.2.34 crate/::Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#::fromrust-analyzer cargo const_format_proc_macros 0.2.34 error/impl#[Error][`From<syn::Error>`]from().) |
| 124 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]and_then().(derive_debugrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/::derive_constdebug_implrust-analyzer cargo const_format_proc_macros 0.2.34 derive_debug/derive_constdebug_impl().) |
| 125 | .unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or_else().(|e| e.to_compile_errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/impl#[Error]to_compile_error().()) |
| 126 | .intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 127 | } |
| 128 | |
| 129 | /// `__respan_to!(( foo tokens ) bar tokens )` |
| 130 | /// Respan all the bar tokens to the span of the foo tokens |
| 131 | #[proc_macro] |
| 132 | pub fn respan_torust-analyzer cargo const_format_proc_macros 0.2.34 respan_to!(input: TokenStream1rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#) -> TokenStream1rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream# { |
| 133 | craterust-analyzer cargo const_format_proc_macros 0.2.34 crate/::respan_to_macrorust-analyzer cargo const_format_proc_macros 0.2.34 respan_to_macro/::implementationrust-analyzer cargo const_format_proc_macros 0.2.34 respan_to_macro/implementation().(input.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 134 | } |