| 1 | use superrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/::{ |
| 2 | ExpandFormattedrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/ExpandFormatted#, ExpandIntorust-analyzer cargo const_format_proc_macros 0.2.34 format_args/ExpandInto#, ExpandWithFormatterrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/ExpandWithFormatter#, FormatArgrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/FormatArg#, FormatArgsrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/FormatArgs#, FormatIfArgsrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/FormatIfArgs#, |
| 3 | LocalVariablerust-analyzer cargo const_format_proc_macros 0.2.34 format_args/LocalVariable#, UncheckedFormatArgrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/UncheckedFormatArg#, UncheckedFormatArgsrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/UncheckedFormatArgs#, WriteArgsrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/WriteArgs#, |
| 4 | }; |
| 5 | |
| 6 | use craterust-analyzer cargo const_format_proc_macros 0.2.34 crate/::{ |
| 7 | format_strrust-analyzer cargo const_format_proc_macros 0.2.34 format_str/::{FmtArgrust-analyzer cargo const_format_proc_macros 0.2.34 format_str/FmtArg#, FmtStrComponentrust-analyzer cargo const_format_proc_macros 0.2.34 format_str/FmtStrComponent#, FormatStrrust-analyzer cargo const_format_proc_macros 0.2.34 format_str/FormatStr#, WhichArgrust-analyzer cargo const_format_proc_macros 0.2.34 format_str/WhichArg#}, |
| 8 | parse_utilsrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/::{LitStrrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/LitStr#, MyParserust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/MyParse#, ParseBufferrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/ParseBuffer#, ParseStreamrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/ParseStream#, TokenTreeExtrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/TokenTreeExt#}, |
| 9 | shared_arg_parsingrust-analyzer cargo const_format_proc_macros 0.2.34 shared_arg_parsing/::ExprArgrust-analyzer cargo const_format_proc_macros 0.2.34 shared_arg_parsing/ExprArg#, |
| 10 | spannedrust-analyzer cargo const_format_proc_macros 0.2.34 spanned/::Spansrust-analyzer cargo const_format_proc_macros 0.2.34 spanned/Spans#, |
| 11 | utilsrust-analyzer cargo const_format_proc_macros 0.2.34 utils/::{dummy_identrust-analyzer cargo const_format_proc_macros 0.2.34 utils/dummy_ident()., LinearResultrust-analyzer cargo const_format_proc_macros 0.2.34 utils/LinearResult#}, |
| 12 | }; |
| 13 | |
| 14 | use proc_macro2rust-analyzer cargo proc-macro2 1.0.107 crate/::{Identrust-analyzer cargo proc-macro2 1.0.107 Ident#, Spanrust-analyzer cargo proc-macro2 1.0.107 Span#, TokenTreerust-analyzer cargo proc-macro2 1.0.107 TokenTree#}; |
| 15 | |
| 16 | //////////////////////////////////////////////// |
| 17 | |
| 18 | impl MyParserust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/MyParse# for UncheckedFormatArgrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/UncheckedFormatArg# { |
| 19 | fn parserust-analyzer cargo const_format_proc_macros 0.2.34 format_args/parsing/impl#[UncheckedFormatArg][MyParse]parse().(input: ParseStreamrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/ParseStream#<'_>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/parsing/impl#[UncheckedFormatArg][MyParse], craterust-analyzer cargo const_format_proc_macros 0.2.34 crate/::Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#> { |
| 20 | // the compile wraps `:expr` in macro_rules macros in a TokenStream::Group |
| 21 | // with no delimiters. |
| 22 | input.parse_unwrap_grouprust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]parse_unwrap_group().(|content| { |
| 23 | let mut ident = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 24 | if matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(content.peek2rust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]peek2().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(x) if x.is_punctrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/TokenTreeExt#is_punct().('=')) { |
| 25 | ident = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(content.parse_identrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]parse_ident().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().); |
| 26 | content.nextrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer][Iterator]next().(); |
| 27 | } |
| 28 | |
| 29 | // For some reason, |
| 30 | // the compile wraps closures in parentheses when passing them as |
| 31 | // expressions to proc macros. |
| 32 | content.parse_unwrap_parenrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]parse_unwrap_paren().(|content| { |
| 33 | let mut fmt_ident = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 34 | |
| 35 | if matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(content.peekrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]peek().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(x) if x.is_punctrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/TokenTreeExt#is_punct().('|')) |
| 36 | && matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(content.peek2rust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]peek2().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(TokenTreerust-analyzer cargo proc-macro2 1.0.107 TokenTree#::Identrust-analyzer cargo proc-macro2 1.0.107 TokenTree#Ident#(_))) |
| 37 | { |
| 38 | content.nextrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer][Iterator]next().(); |
| 39 | fmt_ident = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(content.parse_identrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]parse_ident().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().); |
| 40 | content.parse_punctrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]parse_punct().('|')?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 41 | } |
| 42 | |
| 43 | let (expr, spans) = if content.peek2rust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]peek2().().is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() { |
| 44 | content.parse_token_stream_and_spanrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]parse_token_stream_and_span().() |
| 45 | } else { |
| 46 | content.parse_unwrap_ttrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]parse_unwrap_tt().(|content| Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(content.parse_token_stream_and_spanrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]parse_token_stream_and_span().()))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 47 | }; |
| 48 | |
| 49 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/parsing/impl#[UncheckedFormatArg][MyParse] { |
| 50 | spansrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/UncheckedFormatArg#spans., |
| 51 | identrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/UncheckedFormatArg#ident., |
| 52 | fmt_identrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/UncheckedFormatArg#fmt_ident., |
| 53 | exprrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/UncheckedFormatArg#expr., |
| 54 | }) |
| 55 | }) |
| 56 | }) |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | //////////////////////////////////////////////// |
| 61 | |
| 62 | fn lit_str_to_fmt_litrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/parsing/lit_str_to_fmt_lit().(lit: &LitStrrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/LitStr#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<FormatStrrust-analyzer cargo const_format_proc_macros 0.2.34 format_str/FormatStr#, craterust-analyzer cargo const_format_proc_macros 0.2.34 crate/::Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#> { |
| 63 | let lit_str = lit.valuerust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[LitStr]value().(); |
| 64 | let format_str_span = lit.spanrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/LitStr#span.; |
| 65 | FormatStrrust-analyzer cargo const_format_proc_macros 0.2.34 format_str/FormatStr#::parserust-analyzer cargo const_format_proc_macros 0.2.34 format_str/parsing/impl#[FormatStr]parse().(lit.valuerust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[LitStr]value().(), lit.rawnessrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/LitStr#rawness.) |
| 66 | .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| e.into_crate_errrust-analyzer cargo const_format_proc_macros 0.2.34 format_str/errors/impl#[ParseError]into_crate_err().(format_str_span, lit_str)) |
| 67 | } |
| 68 | |
| 69 | fn parse_fmt_litrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/parsing/parse_fmt_lit().(this: &mut FormatStrrust-analyzer cargo const_format_proc_macros 0.2.34 format_str/FormatStr#, input: ParseStreamrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/ParseStream#<'_>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), craterust-analyzer cargo const_format_proc_macros 0.2.34 crate/::Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#> { |
| 70 | input.parse_unwrap_ttrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]parse_unwrap_tt().(|input| { |
| 71 | let tt = input.nextrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer][Iterator]next().(); |
| 72 | |
| 73 | match tt { |
| 74 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(TokenTreerust-analyzer cargo proc-macro2 1.0.107 TokenTree#::Literalrust-analyzer cargo proc-macro2 1.0.107 TokenTree#Literal#(lit)) => { |
| 75 | let mut lit = lit_str_to_fmt_litrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/parsing/lit_str_to_fmt_lit().(&LitStrrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/LitStr#::parse_from_literalrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[LitStr]parse_from_literal().(&lit)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 76 | |
| 77 | this.listrust-analyzer cargo const_format_proc_macros 0.2.34 format_str/FormatStr#list..appendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]append().(&mut lit.listrust-analyzer cargo const_format_proc_macros 0.2.34 format_str/FormatStr#list.); |
| 78 | |
| 79 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 80 | } |
| 81 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(TokenTreerust-analyzer cargo proc-macro2 1.0.107 TokenTree#::Identrust-analyzer cargo proc-macro2 1.0.107 TokenTree#Ident#(ident)) if ident rust-analyzer cargo proc-macro2 1.0.107 impl#[Ident][`PartialEq<T>`]eq().==rust-analyzer cargo proc-macro2 1.0.107 impl#[Ident][`PartialEq<T>`]eq(). rust-analyzer cargo proc-macro2 1.0.107 impl#[Ident][`PartialEq<T>`]eq()."concat" => { |
| 82 | input.nextrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer][Iterator]next().(); // skipping the `!` |
| 83 | let paren = input.parse_parenrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]parse_paren().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 84 | let mut input = ParseBufferrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/ParseBuffer#::newrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]new().(paren.contentsrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/Parentheses#contents.); |
| 85 | |
| 86 | while !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().input.is_emptyrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]is_empty().() { |
| 87 | parse_fmt_litrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/parsing/parse_fmt_lit().(this, &mut input)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 88 | input.parse_opt_punctrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]parse_opt_punct().(',')?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 89 | } |
| 90 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 91 | } |
| 92 | _ => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()), |
| 93 | } |
| 94 | }) |
| 95 | } |
| 96 | |
| 97 | impl MyParserust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/MyParse# for UncheckedFormatArgsrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/UncheckedFormatArgs# { |
| 98 | fn parserust-analyzer cargo const_format_proc_macros 0.2.34 format_args/parsing/impl#[UncheckedFormatArgs][MyParse]parse().(input: ParseStreamrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/ParseStream#<'_>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/parsing/impl#[UncheckedFormatArgs][MyParse], craterust-analyzer cargo const_format_proc_macros 0.2.34 crate/::Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#> { |
| 99 | let mut literal = FormatStrrust-analyzer cargo const_format_proc_macros 0.2.34 format_str/FormatStr# { listrust-analyzer cargo const_format_proc_macros 0.2.34 format_str/FormatStr#list.: 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().() }; |
| 100 | |
| 101 | // Have to parse `concat!()` because it's not expanded before the proc macro is called. |
| 102 | { |
| 103 | let paren = input.parse_parenrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]parse_paren().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 104 | let mut input = ParseBufferrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/ParseBuffer#::newrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]new().(paren.contentsrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/Parentheses#contents.); |
| 105 | |
| 106 | parse_fmt_litrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/parsing/parse_fmt_lit().(&mut literal, &mut input)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 107 | } |
| 108 | |
| 109 | input.parse_opt_punctrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]parse_opt_punct().(',')?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 110 | |
| 111 | let mut args = 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().(); |
| 112 | |
| 113 | while !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().input.is_emptyrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]is_empty().() { |
| 114 | args.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(UncheckedFormatArgrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/UncheckedFormatArg#::parserust-analyzer cargo const_format_proc_macros 0.2.34 format_args/parsing/impl#[UncheckedFormatArg][MyParse]parse().(input)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().); |
| 115 | |
| 116 | input.parse_opt_punctrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]parse_opt_punct().(',')?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 117 | } |
| 118 | |
| 119 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/parsing/impl#[UncheckedFormatArgs][MyParse] { literalrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/UncheckedFormatArgs#literal., argsrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/UncheckedFormatArgs#args. }) |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | //////////////////////////////////////////////// |
| 124 | |
| 125 | impl MyParserust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/MyParse# for FormatArgsrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/FormatArgs# { |
| 126 | fn parserust-analyzer cargo const_format_proc_macros 0.2.34 format_args/parsing/impl#[FormatArgs][MyParse]parse().(input: ParseStreamrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/ParseStream#<'_>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/parsing/impl#[FormatArgs][MyParse], craterust-analyzer cargo const_format_proc_macros 0.2.34 crate/::Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#> { |
| 127 | let prefix = Identrust-analyzer cargo proc-macro2 1.0.107 Ident#::newrust-analyzer cargo proc-macro2 1.0.107 impl#[Ident]new().("__const_fmt_local_", Spanrust-analyzer cargo proc-macro2 1.0.107 Span#::call_siterust-analyzer cargo proc-macro2 1.0.107 impl#[Span]call_site().()); |
| 128 | FormatArgsrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/FormatArgs#::parse_withrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/parsing/impl#[FormatArgs]parse_with().(input, prefix) |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | impl FormatArgsrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/FormatArgs# { |
| 133 | pub fn parse_withrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/parsing/impl#[FormatArgs]parse_with().(input: ParseStreamrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/ParseStream#<'_>, prefix: Identrust-analyzer cargo proc-macro2 1.0.107 Ident#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<FormatArgsrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/FormatArgs#, craterust-analyzer cargo const_format_proc_macros 0.2.34 crate/::Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#> { |
| 134 | let mut res = LinearResultrust-analyzer cargo const_format_proc_macros 0.2.34 utils/LinearResult#::okrust-analyzer cargo const_format_proc_macros 0.2.34 utils/impl#[LinearResult]ok().(); |
| 135 | |
| 136 | let unchecked_fargs = UncheckedFormatArgsrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/UncheckedFormatArgs#::parserust-analyzer cargo const_format_proc_macros 0.2.34 format_args/parsing/impl#[UncheckedFormatArgs][MyParse]parse().(input)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 137 | |
| 138 | let mut first_named_arg = unchecked_fargs.argsrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/UncheckedFormatArgs#args..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(); |
| 139 | |
| 140 | let mut named_arg_names = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::<Identrust-analyzer cargo proc-macro2 1.0.107 Ident#>::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 141 | let mut args = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::<FormatArgrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/FormatArg#>::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(unchecked_fargs.argsrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/UncheckedFormatArgs#args..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()); |
| 142 | let mut local_variables = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::<LocalVariablerust-analyzer cargo const_format_proc_macros 0.2.34 format_args/LocalVariable#>::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(unchecked_fargs.argsrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/UncheckedFormatArgs#args..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()); |
| 143 | |
| 144 | let arg_span_idents: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(Spansrust-analyzer cargo const_format_proc_macros 0.2.34 spanned/Spans#, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Identrust-analyzer cargo proc-macro2 1.0.107 Ident#>)> = unchecked_fargs |
| 145 | .argsrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/UncheckedFormatArgs#args. |
| 146 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 147 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|x| (x.spansrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/UncheckedFormatArg#spans., x.identrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/UncheckedFormatArg#ident..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().())) |
| 148 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 149 | |
| 150 | { |
| 151 | let mut prev_is_named_arg = false; |
| 152 | for (i, arg) in unchecked_fargs.argsrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/UncheckedFormatArgs#args..into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() { |
| 153 | let expr_span = arg.spansrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/UncheckedFormatArg#spans.; |
| 154 | |
| 155 | let make_ident = |s: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#| Identrust-analyzer cargo proc-macro2 1.0.107 Ident#::newrust-analyzer cargo proc-macro2 1.0.107 impl#[Ident]new().(&s, expr_span.startrust-analyzer cargo const_format_proc_macros 0.2.34 spanned/Spans#start.); |
| 156 | |
| 157 | let is_named_arg = arg.identrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/UncheckedFormatArg#ident..is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().(); |
| 158 | |
| 159 | let var_name = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ident) = arg.identrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/UncheckedFormatArg#ident. { |
| 160 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().prev_is_named_arg { |
| 161 | first_named_arg = i; |
| 162 | } |
| 163 | |
| 164 | let name = make_ident(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}{}", prefix, ident)); |
| 165 | named_arg_names.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(ident); |
| 166 | name |
| 167 | } else { |
| 168 | if prev_is_named_arg { |
| 169 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(craterust-analyzer cargo const_format_proc_macros 0.2.34 crate/::Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#::spannedrust-analyzer cargo const_format_proc_macros 0.2.34 error/impl#[Error]spanned().( |
| 170 | arg.spansrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/UncheckedFormatArg#spans., |
| 171 | "expected a named argument, \ |
| 172 | named arguments cannot be followed by positional arguments.", |
| 173 | )); |
| 174 | } |
| 175 | |
| 176 | make_ident(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}{}", prefix, i)) |
| 177 | }; |
| 178 | |
| 179 | let format_arg = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(fmt_ident) = &arg.fmt_identrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/UncheckedFormatArg#fmt_ident. { |
| 180 | FormatArgrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/FormatArg#::WithFormatterrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/FormatArg#WithFormatter# { |
| 181 | fmt_identrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/FormatArg#WithFormatter#fmt_ident.: fmt_ident.clonerust-analyzer cargo proc-macro2 1.0.107 impl#[Ident][Clone]clone().(), |
| 182 | exprrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/FormatArg#WithFormatter#expr.: arg.exprrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/UncheckedFormatArg#expr..clonerust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][Clone]clone().(), |
| 183 | } |
| 184 | } else { |
| 185 | local_variables.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(LocalVariablerust-analyzer cargo const_format_proc_macros 0.2.34 format_args/LocalVariable# { |
| 186 | identrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/LocalVariable#ident.: var_name.clonerust-analyzer cargo proc-macro2 1.0.107 impl#[Ident][Clone]clone().(), |
| 187 | exprrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/LocalVariable#expr.: arg.exprrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/UncheckedFormatArg#expr..clonerust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][Clone]clone().(), |
| 188 | }); |
| 189 | |
| 190 | FormatArgrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/FormatArg#::WithLocalrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/FormatArg#WithLocal#(var_name) |
| 191 | }; |
| 192 | |
| 193 | args.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(format_arg); |
| 194 | |
| 195 | prev_is_named_arg = is_named_arg; |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | let mut unused_args = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![true; args.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()]; |
| 200 | |
| 201 | let first_named_arg = first_named_arg; |
| 202 | let named_arg_names = named_arg_names; |
| 203 | let args = args; |
| 204 | |
| 205 | let positional_args = &args[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#first_named_arg]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().; |
| 206 | let named_args = &args[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().first_named_arg..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().; |
| 207 | |
| 208 | let fmt_str_components = unchecked_fargs.literalrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/UncheckedFormatArgs#literal..listrust-analyzer cargo const_format_proc_macros 0.2.34 format_str/FormatStr#list.; |
| 209 | |
| 210 | let expanded_into: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<ExpandIntorust-analyzer cargo const_format_proc_macros 0.2.34 format_args/ExpandInto#> = { |
| 211 | let mut current_pos_arg = 0; |
| 212 | let mut get_variable_name = |param: FmtArgrust-analyzer cargo const_format_proc_macros 0.2.34 format_str/FmtArg#| -> ExpandIntorust-analyzer cargo const_format_proc_macros 0.2.34 format_args/ExpandInto# { |
| 213 | let FmtArgrust-analyzer cargo const_format_proc_macros 0.2.34 format_str/FmtArg# { |
| 214 | which_argrust-analyzer cargo const_format_proc_macros 0.2.34 format_str/FmtArg#which_arg., |
| 215 | formattingrust-analyzer cargo const_format_proc_macros 0.2.34 format_str/FmtArg#formatting., |
| 216 | rawnessrust-analyzer cargo const_format_proc_macros 0.2.34 format_str/FmtArg#rawness., |
| 217 | } = param; |
| 218 | |
| 219 | let arg = match which_arg { |
| 220 | WhichArgrust-analyzer cargo const_format_proc_macros 0.2.34 format_str/WhichArg#::Identrust-analyzer cargo const_format_proc_macros 0.2.34 format_str/WhichArg#Ident#(ident) => { |
| 221 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(pos) = named_arg_names.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().positionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]position().(|x| *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().x rust-analyzer cargo proc-macro2 1.0.107 impl#[Ident][`PartialEq<T>`]eq().==rust-analyzer cargo proc-macro2 1.0.107 impl#[Ident][`PartialEq<T>`]eq(). rust-analyzer cargo proc-macro2 1.0.107 impl#[Ident][`PartialEq<T>`]eq().ident) { |
| 222 | unused_args[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut().pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().first_named_arg]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut(). = false; |
| 223 | &named_args[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().pos]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). |
| 224 | } else { |
| 225 | // `formatcp!("{FOO}")` assumes that FOO is a constant in scope |
| 226 | return ExpandIntorust-analyzer cargo const_format_proc_macros 0.2.34 format_args/ExpandInto#::Formattedrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/ExpandInto#Formatted#(ExpandFormattedrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/ExpandFormatted# { |
| 227 | local_variablerust-analyzer cargo const_format_proc_macros 0.2.34 format_args/ExpandFormatted#local_variable.: Identrust-analyzer cargo proc-macro2 1.0.107 Ident#::newrust-analyzer cargo proc-macro2 1.0.107 impl#[Ident]new().(&ident, rawness.spanrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[StrRawness]span().()), |
| 228 | formatrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/ExpandFormatted#format.: formatting, |
| 229 | }); |
| 230 | } |
| 231 | } |
| 232 | WhichArgrust-analyzer cargo const_format_proc_macros 0.2.34 format_str/WhichArg#::Positionalrust-analyzer cargo const_format_proc_macros 0.2.34 format_str/WhichArg#Positional#(opt_pos) => { |
| 233 | let pos = opt_pos.unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_else().(|| { |
| 234 | let pos = current_pos_arg; |
| 235 | current_pos_arg rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1; |
| 236 | pos |
| 237 | }); |
| 238 | |
| 239 | match positional_args.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(pos) { |
| 240 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(arg) => { |
| 241 | unused_args[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut().pos]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut(). = false; |
| 242 | arg |
| 243 | } |
| 244 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => { |
| 245 | res.push_errrust-analyzer cargo const_format_proc_macros 0.2.34 utils/impl#[LinearResult]push_err().(craterust-analyzer cargo const_format_proc_macros 0.2.34 crate/::Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#::newrust-analyzer cargo const_format_proc_macros 0.2.34 error/impl#[Error]new().( |
| 246 | rawness.spanrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[StrRawness]span().(), |
| 247 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 248 | "attempting to use nonexistent positional argument `{}`", |
| 249 | pos, |
| 250 | ), |
| 251 | )); |
| 252 | return ExpandIntorust-analyzer cargo const_format_proc_macros 0.2.34 format_args/ExpandInto#::Formattedrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/ExpandInto#Formatted#(ExpandFormattedrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/ExpandFormatted# { |
| 253 | local_variablerust-analyzer cargo const_format_proc_macros 0.2.34 format_args/ExpandFormatted#local_variable.: dummy_identrust-analyzer cargo const_format_proc_macros 0.2.34 utils/dummy_ident().(), |
| 254 | formatrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/ExpandFormatted#format.: formatting, |
| 255 | }); |
| 256 | } |
| 257 | } |
| 258 | } |
| 259 | }; |
| 260 | |
| 261 | match arg { |
| 262 | FormatArgrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/FormatArg#::WithFormatterrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/FormatArg#WithFormatter# { fmt_identrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/FormatArg#WithFormatter#fmt_ident., exprrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/FormatArg#WithFormatter#expr. } => { |
| 263 | ExpandIntorust-analyzer cargo const_format_proc_macros 0.2.34 format_args/ExpandInto#::WithFormatterrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/ExpandInto#WithFormatter#(ExpandWithFormatterrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/ExpandWithFormatter# { |
| 264 | formatrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/ExpandWithFormatter#format.: formatting, |
| 265 | fmt_identrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/ExpandWithFormatter#fmt_ident.: fmt_ident.clonerust-analyzer cargo proc-macro2 1.0.107 impl#[Ident][Clone]clone().(), |
| 266 | exprrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/ExpandWithFormatter#expr.: expr.clonerust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][Clone]clone().(), |
| 267 | }) |
| 268 | } |
| 269 | FormatArgrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/FormatArg#::WithLocalrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/FormatArg#WithLocal#(local_variable) => { |
| 270 | ExpandIntorust-analyzer cargo const_format_proc_macros 0.2.34 format_args/ExpandInto#::Formattedrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/ExpandInto#Formatted#(ExpandFormattedrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/ExpandFormatted# { |
| 271 | formatrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/ExpandFormatted#format.: formatting, |
| 272 | local_variablerust-analyzer cargo const_format_proc_macros 0.2.34 format_args/ExpandFormatted#local_variable.: local_variable.clonerust-analyzer cargo proc-macro2 1.0.107 impl#[Ident][Clone]clone().(), |
| 273 | }) |
| 274 | } |
| 275 | } |
| 276 | }; |
| 277 | |
| 278 | fmt_str_components |
| 279 | .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().() |
| 280 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|fmt_str_comp| match fmt_str_comp { |
| 281 | FmtStrComponentrust-analyzer cargo const_format_proc_macros 0.2.34 format_str/FmtStrComponent#::Strrust-analyzer cargo const_format_proc_macros 0.2.34 format_str/FmtStrComponent#Str#(str, str_rawness) => ExpandIntorust-analyzer cargo const_format_proc_macros 0.2.34 format_args/ExpandInto#::Strrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/ExpandInto#Str#(str, str_rawness), |
| 282 | FmtStrComponentrust-analyzer cargo const_format_proc_macros 0.2.34 format_str/FmtStrComponent#::Argrust-analyzer cargo const_format_proc_macros 0.2.34 format_str/FmtStrComponent#Arg#(arg) => get_variable_name(arg), |
| 283 | }) |
| 284 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().() |
| 285 | }; |
| 286 | |
| 287 | for (i, (is_it_unused, (spans, ident))) in |
| 288 | unused_args.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(&arg_span_idents).enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() |
| 289 | { |
| 290 | if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().is_it_unused { |
| 291 | let msg = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ident) = ident { |
| 292 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("the '{}' argument is unused", ident) |
| 293 | } else { |
| 294 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("argument number {} is unused", i) |
| 295 | }; |
| 296 | res.push_errrust-analyzer cargo const_format_proc_macros 0.2.34 utils/impl#[LinearResult]push_err().(craterust-analyzer cargo const_format_proc_macros 0.2.34 crate/::Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#::spannedrust-analyzer cargo const_format_proc_macros 0.2.34 error/impl#[Error]spanned().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().spans, msg)); |
| 297 | } |
| 298 | } |
| 299 | res.takerust-analyzer cargo const_format_proc_macros 0.2.34 utils/impl#[LinearResult]take().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 300 | |
| 301 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(FormatArgsrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/FormatArgs# { |
| 302 | conditionrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/FormatArgs#condition.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 303 | local_variablesrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/FormatArgs#local_variables., |
| 304 | expanded_intorust-analyzer cargo const_format_proc_macros 0.2.34 format_args/FormatArgs#expanded_into., |
| 305 | }) |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | //////////////////////////////////////////////// |
| 310 | |
| 311 | impl MyParserust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/MyParse# for FormatIfArgsrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/FormatIfArgs# { |
| 312 | fn parserust-analyzer cargo const_format_proc_macros 0.2.34 format_args/parsing/impl#[FormatIfArgs][MyParse]parse().(input: ParseStreamrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/ParseStream#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/parsing/impl#[FormatIfArgs][MyParse], craterust-analyzer cargo const_format_proc_macros 0.2.34 crate/::Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#> { |
| 313 | let condition = ExprArgrust-analyzer cargo const_format_proc_macros 0.2.34 shared_arg_parsing/ExprArg#::parserust-analyzer cargo const_format_proc_macros 0.2.34 shared_arg_parsing/impl#[ExprArg][MyParse]parse().(input)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 314 | |
| 315 | let mut inner = FormatArgsrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/FormatArgs#::parserust-analyzer cargo const_format_proc_macros 0.2.34 format_args/parsing/impl#[FormatArgs][MyParse]parse().(input)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 316 | inner.conditionrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/FormatArgs#condition. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(condition); |
| 317 | |
| 318 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/parsing/impl#[FormatIfArgs][MyParse] { innerrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/FormatIfArgs#inner. }) |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | //////////////////////////////////////////////// |
| 323 | |
| 324 | impl MyParserust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/MyParse# for WriteArgsrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/WriteArgs# { |
| 325 | fn parserust-analyzer cargo const_format_proc_macros 0.2.34 format_args/parsing/impl#[WriteArgs][MyParse]parse().(input: ParseStreamrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/ParseStream#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/parsing/impl#[WriteArgs][MyParse], craterust-analyzer cargo const_format_proc_macros 0.2.34 crate/::Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#> { |
| 326 | let prefix = Identrust-analyzer cargo proc-macro2 1.0.107 Ident#::newrust-analyzer cargo proc-macro2 1.0.107 impl#[Ident]new().("__const_fmt_local_", Spanrust-analyzer cargo proc-macro2 1.0.107 Span#::call_siterust-analyzer cargo proc-macro2 1.0.107 impl#[Span]call_site().()); |
| 327 | |
| 328 | let paren = input.parse_parenrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]parse_paren().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 329 | |
| 330 | let mut content = ParseBufferrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/ParseBuffer#::newrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]new().(paren.contentsrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/Parentheses#contents.); |
| 331 | |
| 332 | let (writer_expr, spans) = |
| 333 | content.parse_unwrap_ttrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]parse_unwrap_tt().(|content| Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(content.parse_token_stream_and_spanrust-analyzer cargo const_format_proc_macros 0.2.34 parse_utils/impl#[ParseBuffer]parse_token_stream_and_span().()))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 334 | |
| 335 | let format_args = FormatArgsrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/FormatArgs#::parse_withrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/parsing/impl#[FormatArgs]parse_with().(input, prefix)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 336 | |
| 337 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/parsing/impl#[WriteArgs][MyParse] { |
| 338 | writer_exprrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/WriteArgs#writer_expr., |
| 339 | writer_spanrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/WriteArgs#writer_span.: spans.joinedrust-analyzer cargo const_format_proc_macros 0.2.34 spanned/impl#[Spans]joined().(), |
| 340 | format_argsrust-analyzer cargo const_format_proc_macros 0.2.34 format_args/WriteArgs#format_args., |
| 341 | }) |
| 342 | } |
| 343 | } |