| 1 | use proc_macro2rust-analyzer cargo proc-macro2 1.0.103 crate/::{Delimiterrust-analyzer cargo proc-macro2 1.0.103 Delimiter#, TokenStreamrust-analyzer cargo proc-macro2 1.0.103 TokenStream#, TokenTreerust-analyzer cargo proc-macro2 1.0.103 TokenTree#}; |
| 2 | use quoterust-analyzer cargo quote 1.0.42 crate/::ToTokensrust-analyzer cargo quote 1.0.42 to_tokens/ToTokens#; |
| 3 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::VecDequerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/VecDeque#; |
| 4 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::Notrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/Not#; |
| 5 | use synrust-analyzer cargo syn 2.0.110 crate/::parserust-analyzer cargo syn 2.0.110 parse/::ParseStreamrust-analyzer cargo syn 2.0.110 parse/ParseStream#; |
| 6 | use synrust-analyzer cargo syn 2.0.110 crate/::{Attributerust-analyzer cargo syn 2.0.110 attr/Attribute#, Errorrust-analyzer cargo syn 2.0.110 error/Error#, Metarust-analyzer cargo syn 2.0.110 attr/Meta#, Pathrust-analyzer cargo syn 2.0.110 path/Path#, PathSegmentrust-analyzer cargo syn 2.0.110 path/PathSegment#, Tokenrust-analyzer cargo syn 2.0.110 token/Token!, TypePathrust-analyzer cargo syn 2.0.110 ty/TypePath#}; |
| 7 | |
| 8 | pub struct CallMethodAttributerust-analyzer cargo delegate 0.13.5 attributes/CallMethodAttribute# { |
| 9 | namerust-analyzer cargo delegate 0.13.5 attributes/CallMethodAttribute#name.: synrust-analyzer cargo syn 2.0.110 crate/::Identrust-analyzer cargo proc-macro2 1.0.103 Ident#, |
| 10 | } |
| 11 | |
| 12 | impl synrust-analyzer cargo syn 2.0.110 crate/::parserust-analyzer cargo syn 2.0.110 parse/::Parserust-analyzer cargo syn 2.0.110 parse/Parse# for CallMethodAttributerust-analyzer cargo delegate 0.13.5 attributes/CallMethodAttribute# { |
| 13 | fn parserust-analyzer cargo delegate 0.13.5 attributes/impl#[CallMethodAttribute][Parse]parse().(input: ParseStreamrust-analyzer cargo syn 2.0.110 parse/ParseStream#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo delegate 0.13.5 attributes/impl#[CallMethodAttribute][Parse], Errorrust-analyzer cargo syn 2.0.110 error/Error#> { |
| 14 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(CallMethodAttributerust-analyzer cargo delegate 0.13.5 attributes/CallMethodAttribute# { |
| 15 | namerust-analyzer cargo delegate 0.13.5 attributes/CallMethodAttribute#name.: input.parserust-analyzer cargo syn 2.0.110 parse/impl#[`ParseBuffer<'a>`]parse().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 16 | }) |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 21 | pub struct GetFieldAttributerust-analyzer cargo delegate 0.13.5 attributes/GetFieldAttribute# { |
| 22 | referencerust-analyzer cargo delegate 0.13.5 attributes/GetFieldAttribute#reference.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(Tokenrust-analyzer cargo syn 2.0.110 token/Token!![&], Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Tokenrust-analyzer cargo syn 2.0.110 token/Token!![mut]>)>, |
| 23 | memberrust-analyzer cargo delegate 0.13.5 attributes/GetFieldAttribute#member.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<synrust-analyzer cargo syn 2.0.110 crate/::Memberrust-analyzer cargo syn 2.0.110 expr/Member#>, |
| 24 | } |
| 25 | |
| 26 | impl GetFieldAttributerust-analyzer cargo delegate 0.13.5 attributes/GetFieldAttribute# { |
| 27 | pub fn reference_tokensrust-analyzer cargo delegate 0.13.5 attributes/impl#[GetFieldAttribute]reference_tokens().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<TokenStreamrust-analyzer cargo proc-macro2 1.0.103 TokenStream#> { |
| 28 | let (ref_, mut_) = self.referencerust-analyzer cargo delegate 0.13.5 attributes/GetFieldAttribute#reference..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().; |
| 29 | let mut tokens = ref_.to_token_streamrust-analyzer cargo quote 1.0.42 to_tokens/ToTokens#to_token_stream().(); |
| 30 | mut_.to_tokensrust-analyzer cargo quote 1.0.42 to_tokens/impl#[`Option<T>`][ToTokens]to_tokens().(&mut tokens); |
| 31 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(tokens) |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | impl synrust-analyzer cargo syn 2.0.110 crate/::parserust-analyzer cargo syn 2.0.110 parse/::Parserust-analyzer cargo syn 2.0.110 parse/Parse# for GetFieldAttributerust-analyzer cargo delegate 0.13.5 attributes/GetFieldAttribute# { |
| 36 | fn parserust-analyzer cargo delegate 0.13.5 attributes/impl#[GetFieldAttribute][Parse]parse().(input: ParseStreamrust-analyzer cargo syn 2.0.110 parse/ParseStream#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo delegate 0.13.5 attributes/impl#[GetFieldAttribute][Parse], Errorrust-analyzer cargo syn 2.0.110 error/Error#> { |
| 37 | let mut reference = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 38 | if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ref_) = input.parserust-analyzer cargo syn 2.0.110 parse/impl#[`ParseBuffer<'a>`]parse().::<synrust-analyzer cargo syn 2.0.110 crate/::Tokenrust-analyzer cargo syn 2.0.110 token/Token!![&]>() { |
| 39 | reference = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((ref_, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#)); |
| 40 | } |
| 41 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((_, mut_)) = &mut reference { |
| 42 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().mut_ = input.parserust-analyzer cargo syn 2.0.110 parse/impl#[`ParseBuffer<'a>`]parse().::<synrust-analyzer cargo syn 2.0.110 crate/::Tokenrust-analyzer cargo syn 2.0.110 token/Token!![mut]>().okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().(); |
| 43 | } |
| 44 | let member = input.is_emptyrust-analyzer cargo syn 2.0.110 parse/impl#[`ParseBuffer<'a>`]is_empty().().notrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().().thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then().(|| input.parserust-analyzer cargo syn 2.0.110 parse/impl#[`ParseBuffer<'a>`]parse().()).transposerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<Result<T, E>>`]transpose().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 45 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(GetFieldAttributerust-analyzer cargo delegate 0.13.5 attributes/GetFieldAttribute# { referencerust-analyzer cargo delegate 0.13.5 attributes/GetFieldAttribute#reference., memberrust-analyzer cargo delegate 0.13.5 attributes/GetFieldAttribute#member. }) |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | struct GenerateAwaitAttributerust-analyzer cargo delegate 0.13.5 attributes/GenerateAwaitAttribute# { |
| 50 | literalrust-analyzer cargo delegate 0.13.5 attributes/GenerateAwaitAttribute#literal.: synrust-analyzer cargo syn 2.0.110 crate/::LitBoolrust-analyzer cargo syn 2.0.110 lit/LitBool#, |
| 51 | } |
| 52 | |
| 53 | impl synrust-analyzer cargo syn 2.0.110 crate/::parserust-analyzer cargo syn 2.0.110 parse/::Parserust-analyzer cargo syn 2.0.110 parse/Parse# for GenerateAwaitAttributerust-analyzer cargo delegate 0.13.5 attributes/GenerateAwaitAttribute# { |
| 54 | fn parserust-analyzer cargo delegate 0.13.5 attributes/impl#[GenerateAwaitAttribute][Parse]parse().(input: ParseStreamrust-analyzer cargo syn 2.0.110 parse/ParseStream#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo delegate 0.13.5 attributes/impl#[GenerateAwaitAttribute][Parse], Errorrust-analyzer cargo syn 2.0.110 error/Error#> { |
| 55 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(GenerateAwaitAttributerust-analyzer cargo delegate 0.13.5 attributes/GenerateAwaitAttribute# { |
| 56 | literalrust-analyzer cargo delegate 0.13.5 attributes/GenerateAwaitAttribute#literal.: input.parserust-analyzer cargo syn 2.0.110 parse/impl#[`ParseBuffer<'a>`]parse().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 57 | }) |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | struct IntoAttributerust-analyzer cargo delegate 0.13.5 attributes/IntoAttribute# { |
| 62 | type_pathrust-analyzer cargo delegate 0.13.5 attributes/IntoAttribute#type_path.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<TypePathrust-analyzer cargo syn 2.0.110 ty/TypePath#>, |
| 63 | } |
| 64 | |
| 65 | impl synrust-analyzer cargo syn 2.0.110 crate/::parserust-analyzer cargo syn 2.0.110 parse/::Parserust-analyzer cargo syn 2.0.110 parse/Parse# for IntoAttributerust-analyzer cargo delegate 0.13.5 attributes/IntoAttribute# { |
| 66 | fn parserust-analyzer cargo delegate 0.13.5 attributes/impl#[IntoAttribute][Parse]parse().(input: ParseStreamrust-analyzer cargo syn 2.0.110 parse/ParseStream#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo delegate 0.13.5 attributes/impl#[IntoAttribute][Parse], Errorrust-analyzer cargo syn 2.0.110 error/Error#> { |
| 67 | let type_path: TypePathrust-analyzer cargo syn 2.0.110 ty/TypePath# = input.parserust-analyzer cargo syn 2.0.110 parse/impl#[`ParseBuffer<'a>`]parse().().map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|error| { |
| 68 | Errorrust-analyzer cargo syn 2.0.110 error/Error#::newrust-analyzer cargo syn 2.0.110 error/impl#[Error]new().( |
| 69 | input.spanrust-analyzer cargo syn 2.0.110 parse/impl#[`ParseBuffer<'a>`]span().(), |
| 70 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{error}\nExpected type name, e.g. #[into(u32)]"), |
| 71 | ) |
| 72 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 73 | |
| 74 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(IntoAttributerust-analyzer cargo delegate 0.13.5 attributes/IntoAttribute# { |
| 75 | type_pathrust-analyzer cargo delegate 0.13.5 attributes/IntoAttribute#type_path.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(type_path), |
| 76 | }) |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | pub struct AssociatedConstantrust-analyzer cargo delegate 0.13.5 attributes/AssociatedConstant# { |
| 81 | pub const_namerust-analyzer cargo delegate 0.13.5 attributes/AssociatedConstant#const_name.: PathSegmentrust-analyzer cargo syn 2.0.110 path/PathSegment#, |
| 82 | pub trait_pathrust-analyzer cargo delegate 0.13.5 attributes/AssociatedConstant#trait_path.: Pathrust-analyzer cargo syn 2.0.110 path/Path#, |
| 83 | } |
| 84 | |
| 85 | impl synrust-analyzer cargo syn 2.0.110 crate/::parserust-analyzer cargo syn 2.0.110 parse/::Parserust-analyzer cargo syn 2.0.110 parse/Parse# for AssociatedConstantrust-analyzer cargo delegate 0.13.5 attributes/AssociatedConstant# { |
| 86 | fn parserust-analyzer cargo delegate 0.13.5 attributes/impl#[AssociatedConstant][Parse]parse().(input: ParseStreamrust-analyzer cargo syn 2.0.110 parse/ParseStream#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo delegate 0.13.5 attributes/impl#[AssociatedConstant][Parse], Errorrust-analyzer cargo syn 2.0.110 error/Error#> { |
| 87 | let mut path = input.parserust-analyzer cargo syn 2.0.110 parse/impl#[`ParseBuffer<'a>`]parse().::<synrust-analyzer cargo syn 2.0.110 crate/::Pathrust-analyzer cargo syn 2.0.110 path/Path#>().map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|error| { |
| 88 | Errorrust-analyzer cargo syn 2.0.110 error/Error#::newrust-analyzer cargo syn 2.0.110 error/impl#[Error]new().( |
| 89 | input.spanrust-analyzer cargo syn 2.0.110 parse/impl#[`ParseBuffer<'a>`]span().(), |
| 90 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 91 | "{error}\nExpected const path, e.g. #[const(path::to::MyTrait::CONST_NAME)]" |
| 92 | ), |
| 93 | ) |
| 94 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 95 | |
| 96 | let const_name = path.segmentsrust-analyzer cargo syn 2.0.110 path/Path#segments..poprust-analyzer cargo syn 2.0.110 punctuated/impl#[`Punctuated<T, P>`]pop().().ok_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or_else().(|| { |
| 97 | Errorrust-analyzer cargo syn 2.0.110 error/Error#::new_spannedrust-analyzer cargo syn 2.0.110 error/impl#[Error]new_spanned().( |
| 98 | &path, |
| 99 | "Expected a path. e.g. #[const(path::to::MyTrait::CONST_NAME)]", |
| 100 | ) |
| 101 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 102 | // poping a segment leads to trailing `::` |
| 103 | path.segmentsrust-analyzer cargo syn 2.0.110 path/Path#segments..pop_punctrust-analyzer cargo syn 2.0.110 punctuated/impl#[`Punctuated<T, P>`]pop_punct().().ok_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or_else().(|| { |
| 104 | Errorrust-analyzer cargo syn 2.0.110 error/Error#::new_spannedrust-analyzer cargo syn 2.0.110 error/impl#[Error]new_spanned().( |
| 105 | &path, |
| 106 | "Expected a multipart path. e.g. #[const(path::to::MyTrait::CONST_NAME)]", |
| 107 | ) |
| 108 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 109 | |
| 110 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo delegate 0.13.5 attributes/impl#[AssociatedConstant][Parse] { |
| 111 | const_namerust-analyzer cargo delegate 0.13.5 attributes/AssociatedConstant#const_name.: const_name.into_valuerust-analyzer cargo syn 2.0.110 punctuated/impl#[`Pair<T, P>`]into_value().(), |
| 112 | trait_pathrust-analyzer cargo delegate 0.13.5 attributes/AssociatedConstant#trait_path.: path, |
| 113 | }) |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 118 | /// Represent the placeholder `$` found inside an expr attribute's template |
| 119 | pub struct ExprPlaceHolderrust-analyzer cargo delegate 0.13.5 attributes/ExprPlaceHolder#; |
| 120 | |
| 121 | impl synrust-analyzer cargo syn 2.0.110 crate/::parserust-analyzer cargo syn 2.0.110 parse/::Parserust-analyzer cargo syn 2.0.110 parse/Parse# for ExprPlaceHolderrust-analyzer cargo delegate 0.13.5 attributes/ExprPlaceHolder# { |
| 122 | fn parserust-analyzer cargo delegate 0.13.5 attributes/impl#[ExprPlaceHolder][Parse]parse().(input: ParseStreamrust-analyzer cargo syn 2.0.110 parse/ParseStream#) -> synrust-analyzer cargo syn 2.0.110 crate/::Resultrust-analyzer cargo syn 2.0.110 error/Result#<Selfrust-analyzer cargo delegate 0.13.5 attributes/impl#[ExprPlaceHolder][Parse]> { |
| 123 | input.parserust-analyzer cargo syn 2.0.110 parse/impl#[`ParseBuffer<'a>`]parse().::<synrust-analyzer cargo syn 2.0.110 crate/::Tokenrust-analyzer cargo syn 2.0.110 token/Token!![$]>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 124 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo delegate 0.13.5 attributes/impl#[ExprPlaceHolder][Parse]) |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | /// Kind of allowed placeholders in an `expr` attribute template |
| 129 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 130 | enum Placeholderrust-analyzer cargo delegate 0.13.5 attributes/Placeholder# { |
| 131 | ExprPlaceholderrust-analyzer cargo delegate 0.13.5 attributes/Placeholder#ExprPlaceholder#(ExprPlaceHolderrust-analyzer cargo delegate 0.13.5 attributes/ExprPlaceHolder#), |
| 132 | } |
| 133 | |
| 134 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 135 | /// Tokens found in the expr attribute's template |
| 136 | /// Token are either |
| 137 | /// - a replacable pattern (placeholder) |
| 138 | /// - a normal token |
| 139 | /// - a group containing a recursive representation of template tokens |
| 140 | enum TemplateTokenrust-analyzer cargo delegate 0.13.5 attributes/TemplateToken# { |
| 141 | Normalrust-analyzer cargo delegate 0.13.5 attributes/TemplateToken#Normal#(TokenTreerust-analyzer cargo proc-macro2 1.0.103 TokenTree#), |
| 142 | Placeholderrust-analyzer cargo delegate 0.13.5 attributes/TemplateToken#Placeholder#(Placeholderrust-analyzer cargo delegate 0.13.5 attributes/Placeholder#), |
| 143 | Grouprust-analyzer cargo delegate 0.13.5 attributes/TemplateToken#Group#(Delimiterrust-analyzer cargo proc-macro2 1.0.103 Delimiter#, TemplateExprrust-analyzer cargo delegate 0.13.5 attributes/TemplateExpr#), |
| 144 | } |
| 145 | |
| 146 | impl TemplateTokenrust-analyzer cargo delegate 0.13.5 attributes/TemplateToken# { |
| 147 | /// Replace relevant placeholder tokens with the provided tokens |
| 148 | fn replacerust-analyzer cargo delegate 0.13.5 attributes/impl#[TemplateToken]replace().(&self, replacement: &TokenStreamrust-analyzer cargo proc-macro2 1.0.103 TokenStream#) -> TokenStreamrust-analyzer cargo proc-macro2 1.0.103 TokenStream# { |
| 149 | match self { |
| 150 | Selfrust-analyzer cargo delegate 0.13.5 attributes/impl#[TemplateToken]::Grouprust-analyzer cargo delegate 0.13.5 attributes/TemplateToken#Group#(del, template) => { |
| 151 | let replaced_tokens = template |
| 152 | .tokensrust-analyzer cargo delegate 0.13.5 attributes/TemplateExpr#tokens. |
| 153 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 154 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|token| token.replacerust-analyzer cargo delegate 0.13.5 attributes/impl#[TemplateToken]replace().(replacement)); |
| 155 | proc_macro2rust-analyzer cargo proc-macro2 1.0.103 crate/::Grouprust-analyzer cargo proc-macro2 1.0.103 Group#::newrust-analyzer cargo proc-macro2 1.0.103 impl#[Group]new().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().del, quoterust-analyzer cargo quote 1.0.42 crate/::quoterust-analyzer cargo quote 1.0.42 quote!! { #(#replaced_tokens)* }) |
| 156 | .to_token_streamrust-analyzer cargo quote 1.0.42 to_tokens/ToTokens#to_token_stream().() |
| 157 | } |
| 158 | Selfrust-analyzer cargo delegate 0.13.5 attributes/impl#[TemplateToken]::Normalrust-analyzer cargo delegate 0.13.5 attributes/TemplateToken#Normal#(token_tree) => token_tree.to_token_streamrust-analyzer cargo quote 1.0.42 to_tokens/ToTokens#to_token_stream().(), |
| 159 | Selfrust-analyzer cargo delegate 0.13.5 attributes/impl#[TemplateToken]::Placeholderrust-analyzer cargo delegate 0.13.5 attributes/TemplateToken#Placeholder#(_) => replacement.clonerust-analyzer cargo proc-macro2 1.0.103 impl#[TokenStream][Clone]clone().(), |
| 160 | } |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 165 | /// An expr attribute's template |
| 166 | pub struct TemplateExprrust-analyzer cargo delegate 0.13.5 attributes/TemplateExpr# { |
| 167 | tokensrust-analyzer cargo delegate 0.13.5 attributes/TemplateExpr#tokens.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<TemplateTokenrust-analyzer cargo delegate 0.13.5 attributes/TemplateToken#>, |
| 168 | } |
| 169 | |
| 170 | impl synrust-analyzer cargo syn 2.0.110 crate/::parserust-analyzer cargo syn 2.0.110 parse/::Parserust-analyzer cargo syn 2.0.110 parse/Parse# for TemplateExprrust-analyzer cargo delegate 0.13.5 attributes/TemplateExpr# { |
| 171 | /// Parsing a template means storing the raw template while differenciating |
| 172 | /// placeholders and "normal" tokens |
| 173 | fn parserust-analyzer cargo delegate 0.13.5 attributes/impl#[TemplateExpr][Parse]parse().(input: ParseStreamrust-analyzer cargo syn 2.0.110 parse/ParseStream#) -> synrust-analyzer cargo syn 2.0.110 crate/::Resultrust-analyzer cargo syn 2.0.110 error/Result#<Selfrust-analyzer cargo delegate 0.13.5 attributes/impl#[TemplateExpr][Parse]> { |
| 174 | let mut tokens = 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().(); |
| 175 | while !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().input.is_emptyrust-analyzer cargo syn 2.0.110 parse/impl#[`ParseBuffer<'a>`]is_empty().() { |
| 176 | if input.forkrust-analyzer cargo syn 2.0.110 parse/impl#[`ParseBuffer<'a>`]fork().().parserust-analyzer cargo syn 2.0.110 parse/impl#[`ParseBuffer<'a>`]parse().::<ExprPlaceHolderrust-analyzer cargo delegate 0.13.5 attributes/ExprPlaceHolder#>().is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().() { |
| 177 | let placeholder = input.parserust-analyzer cargo syn 2.0.110 parse/impl#[`ParseBuffer<'a>`]parse().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 178 | tokens.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(TemplateTokenrust-analyzer cargo delegate 0.13.5 attributes/TemplateToken#::Placeholderrust-analyzer cargo delegate 0.13.5 attributes/TemplateToken#Placeholder#(Placeholderrust-analyzer cargo delegate 0.13.5 attributes/Placeholder#::ExprPlaceholderrust-analyzer cargo delegate 0.13.5 attributes/Placeholder#ExprPlaceholder#( |
| 179 | placeholder, |
| 180 | ))); |
| 181 | continue; |
| 182 | } |
| 183 | |
| 184 | match input.parserust-analyzer cargo syn 2.0.110 parse/impl#[`ParseBuffer<'a>`]parse().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). { |
| 185 | TokenTreerust-analyzer cargo proc-macro2 1.0.103 TokenTree#::Grouprust-analyzer cargo proc-macro2 1.0.103 TokenTree#Group#(group) => { |
| 186 | let inner_stream = group.streamrust-analyzer cargo proc-macro2 1.0.103 impl#[Group]stream().(); |
| 187 | let inner_expr = synrust-analyzer cargo syn 2.0.110 crate/::parse2rust-analyzer cargo syn 2.0.110 parse2().(inner_stream)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 188 | tokens.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(TemplateTokenrust-analyzer cargo delegate 0.13.5 attributes/TemplateToken#::Grouprust-analyzer cargo delegate 0.13.5 attributes/TemplateToken#Group#(group.delimiterrust-analyzer cargo proc-macro2 1.0.103 impl#[Group]delimiter().(), inner_expr)); |
| 189 | } |
| 190 | other => { |
| 191 | tokens.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(TemplateTokenrust-analyzer cargo delegate 0.13.5 attributes/TemplateToken#::Normalrust-analyzer cargo delegate 0.13.5 attributes/TemplateToken#Normal#(other)); |
| 192 | } |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(TemplateExprrust-analyzer cargo delegate 0.13.5 attributes/TemplateExpr# { tokensrust-analyzer cargo delegate 0.13.5 attributes/TemplateExpr#tokens. }) |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | impl TemplateExprrust-analyzer cargo delegate 0.13.5 attributes/TemplateExpr# { |
| 201 | /// returns the template after expanding the relevant placeholders |
| 202 | pub fn expand_templaterust-analyzer cargo delegate 0.13.5 attributes/impl#[TemplateExpr]expand_template().(&self, replacement: &TokenStreamrust-analyzer cargo proc-macro2 1.0.103 TokenStream#) -> TokenStreamrust-analyzer cargo proc-macro2 1.0.103 TokenStream# { |
| 203 | self.tokensrust-analyzer cargo delegate 0.13.5 attributes/TemplateExpr#tokens..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().foldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]fold().(TokenStreamrust-analyzer cargo proc-macro2 1.0.103 TokenStream#::newrust-analyzer cargo proc-macro2 1.0.103 impl#[TokenStream]new().(), |mut ts, tok| { |
| 204 | ts.extendrust-analyzer cargo proc-macro2 1.0.103 impl#[TokenStream][`Extend<TokenTree>`]extend().(tok.replacerust-analyzer cargo delegate 0.13.5 attributes/impl#[TemplateToken]replace().(replacement)); |
| 205 | ts |
| 206 | }) |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | pub struct TraitTargetrust-analyzer cargo delegate 0.13.5 attributes/TraitTarget# { |
| 211 | type_pathrust-analyzer cargo delegate 0.13.5 attributes/TraitTarget#type_path.: TypePathrust-analyzer cargo syn 2.0.110 ty/TypePath#, |
| 212 | } |
| 213 | |
| 214 | impl synrust-analyzer cargo syn 2.0.110 crate/::parserust-analyzer cargo syn 2.0.110 parse/::Parserust-analyzer cargo syn 2.0.110 parse/Parse# for TraitTargetrust-analyzer cargo delegate 0.13.5 attributes/TraitTarget# { |
| 215 | fn parserust-analyzer cargo delegate 0.13.5 attributes/impl#[TraitTarget][Parse]parse().(input: ParseStreamrust-analyzer cargo syn 2.0.110 parse/ParseStream#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo delegate 0.13.5 attributes/impl#[TraitTarget][Parse], Errorrust-analyzer cargo syn 2.0.110 error/Error#> { |
| 216 | let type_path: TypePathrust-analyzer cargo syn 2.0.110 ty/TypePath# = input.parserust-analyzer cargo syn 2.0.110 parse/impl#[`ParseBuffer<'a>`]parse().().map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|error| { |
| 217 | Errorrust-analyzer cargo syn 2.0.110 error/Error#::newrust-analyzer cargo syn 2.0.110 error/impl#[Error]new().( |
| 218 | input.spanrust-analyzer cargo syn 2.0.110 parse/impl#[`ParseBuffer<'a>`]span().(), |
| 219 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{error}\nExpected trait path, e.g. #[through(foo::MyTrait)]"), |
| 220 | ) |
| 221 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 222 | |
| 223 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(TraitTargetrust-analyzer cargo delegate 0.13.5 attributes/TraitTarget# { type_pathrust-analyzer cargo delegate 0.13.5 attributes/TraitTarget#type_path. }) |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 228 | pub enum ReturnExpressionrust-analyzer cargo delegate 0.13.5 attributes/ReturnExpression# { |
| 229 | Intorust-analyzer cargo delegate 0.13.5 attributes/ReturnExpression#Into#(Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<TypePathrust-analyzer cargo syn 2.0.110 ty/TypePath#>), |
| 230 | TryIntorust-analyzer cargo delegate 0.13.5 attributes/ReturnExpression#TryInto#, |
| 231 | Unwraprust-analyzer cargo delegate 0.13.5 attributes/ReturnExpression#Unwrap#, |
| 232 | } |
| 233 | |
| 234 | pub enum TargetSpecifierrust-analyzer cargo delegate 0.13.5 attributes/TargetSpecifier# { |
| 235 | Fieldrust-analyzer cargo delegate 0.13.5 attributes/TargetSpecifier#Field#(GetFieldAttributerust-analyzer cargo delegate 0.13.5 attributes/GetFieldAttribute#), |
| 236 | Methodrust-analyzer cargo delegate 0.13.5 attributes/TargetSpecifier#Method#(CallMethodAttributerust-analyzer cargo delegate 0.13.5 attributes/CallMethodAttribute#), |
| 237 | } |
| 238 | |
| 239 | impl TargetSpecifierrust-analyzer cargo delegate 0.13.5 attributes/TargetSpecifier# { |
| 240 | pub fn get_memberrust-analyzer cargo delegate 0.13.5 attributes/impl#[TargetSpecifier]get_member().(&self, default: &synrust-analyzer cargo syn 2.0.110 crate/::Identrust-analyzer cargo proc-macro2 1.0.103 Ident#) -> synrust-analyzer cargo syn 2.0.110 crate/::Memberrust-analyzer cargo syn 2.0.110 expr/Member# { |
| 241 | match self { |
| 242 | Selfrust-analyzer cargo delegate 0.13.5 attributes/impl#[TargetSpecifier]::Fieldrust-analyzer cargo delegate 0.13.5 attributes/TargetSpecifier#Field#(GetFieldAttributerust-analyzer cargo delegate 0.13.5 attributes/GetFieldAttribute# { |
| 243 | memberrust-analyzer cargo delegate 0.13.5 attributes/GetFieldAttribute#member.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(member), |
| 244 | .. |
| 245 | }) => member.clonerust-analyzer cargo syn 2.0.110 gen/clone/impl#[`crate::Member`][Clone]clone().(), |
| 246 | Selfrust-analyzer cargo delegate 0.13.5 attributes/impl#[TargetSpecifier]::Fieldrust-analyzer cargo delegate 0.13.5 attributes/TargetSpecifier#Field#(_) => default.clonerust-analyzer cargo proc-macro2 1.0.103 impl#[Ident][Clone]clone().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 247 | Selfrust-analyzer cargo delegate 0.13.5 attributes/impl#[TargetSpecifier]::Methodrust-analyzer cargo delegate 0.13.5 attributes/TargetSpecifier#Method#(method) => method.namerust-analyzer cargo delegate 0.13.5 attributes/CallMethodAttribute#name..clonerust-analyzer cargo proc-macro2 1.0.103 impl#[Ident][Clone]clone().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 248 | } |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | enum ParsedAttributerust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute# { |
| 253 | ReturnExpressionrust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#ReturnExpression#(ReturnExpressionrust-analyzer cargo delegate 0.13.5 attributes/ReturnExpression#), |
| 254 | Awaitrust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#Await#(bool), |
| 255 | TargetSpecifierrust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#TargetSpecifier#(TargetSpecifierrust-analyzer cargo delegate 0.13.5 attributes/TargetSpecifier#), |
| 256 | ThroughTraitrust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#ThroughTrait#(TraitTargetrust-analyzer cargo delegate 0.13.5 attributes/TraitTarget#), |
| 257 | ConstantAccessrust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#ConstantAccess#(AssociatedConstantrust-analyzer cargo delegate 0.13.5 attributes/AssociatedConstant#), |
| 258 | Exprrust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#Expr#(TemplateExprrust-analyzer cargo delegate 0.13.5 attributes/TemplateExpr#), |
| 259 | } |
| 260 | |
| 261 | fn parse_attributesrust-analyzer cargo delegate 0.13.5 attributes/parse_attributes().( |
| 262 | attrs: &[Attributerust-analyzer cargo syn 2.0.110 attr/Attribute#], |
| 263 | ) -> ( |
| 264 | impl Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = ParsedAttributerust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#> + '_, |
| 265 | impl Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = &Attributerust-analyzer cargo syn 2.0.110 attr/Attribute#>, |
| 266 | ) { |
| 267 | let (parsed, other): (Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>) = attrs |
| 268 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 269 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|attribute| { |
| 270 | let parsed = if let synrust-analyzer cargo syn 2.0.110 crate/::AttrStylerust-analyzer cargo syn 2.0.110 attr/AttrStyle#::Outerrust-analyzer cargo syn 2.0.110 attr/AttrStyle#Outer# = attribute.stylerust-analyzer cargo syn 2.0.110 attr/Attribute#style. { |
| 271 | let name = attribute |
| 272 | .pathrust-analyzer cargo syn 2.0.110 attr/impl#[Attribute]path().() |
| 273 | .get_identrust-analyzer cargo syn 2.0.110 path/impl#[Path]get_ident().() |
| 274 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|i| i.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()) |
| 275 | .unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().(); |
| 276 | match name.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().() { |
| 277 | "call" => { |
| 278 | let target = attribute |
| 279 | .parse_argsrust-analyzer cargo syn 2.0.110 attr/impl#[Attribute]parse_args().::<CallMethodAttributerust-analyzer cargo delegate 0.13.5 attributes/CallMethodAttribute#>() |
| 280 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Cannot parse `call` attribute"); |
| 281 | let spec = TargetSpecifierrust-analyzer cargo delegate 0.13.5 attributes/TargetSpecifier#::Methodrust-analyzer cargo delegate 0.13.5 attributes/TargetSpecifier#Method#(target); |
| 282 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ParsedAttributerust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#::TargetSpecifierrust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#TargetSpecifier#(spec)) |
| 283 | } |
| 284 | "field" => { |
| 285 | let target = if let synrust-analyzer cargo syn 2.0.110 crate/::Metarust-analyzer cargo syn 2.0.110 attr/Meta#::Pathrust-analyzer cargo syn 2.0.110 attr/Meta#Path#(_) = &attribute.metarust-analyzer cargo syn 2.0.110 attr/Attribute#meta. { |
| 286 | GetFieldAttributerust-analyzer cargo delegate 0.13.5 attributes/GetFieldAttribute#::defaultrust-analyzer cargo delegate 0.13.5 attributes/impl#[GetFieldAttribute][Default]default().() |
| 287 | } else { |
| 288 | attribute |
| 289 | .parse_argsrust-analyzer cargo syn 2.0.110 attr/impl#[Attribute]parse_args().::<GetFieldAttributerust-analyzer cargo delegate 0.13.5 attributes/GetFieldAttribute#>() |
| 290 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Cannot parse `field` attribute") |
| 291 | }; |
| 292 | let spec = TargetSpecifierrust-analyzer cargo delegate 0.13.5 attributes/TargetSpecifier#::Fieldrust-analyzer cargo delegate 0.13.5 attributes/TargetSpecifier#Field#(target); |
| 293 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ParsedAttributerust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#::TargetSpecifierrust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#TargetSpecifier#(spec)) |
| 294 | } |
| 295 | "into" => { |
| 296 | let into = match &attribute.metarust-analyzer cargo syn 2.0.110 attr/Attribute#meta. { |
| 297 | Metarust-analyzer cargo syn 2.0.110 attr/Meta#::NameValuerust-analyzer cargo syn 2.0.110 attr/Meta#NameValue#(_) => { |
| 298 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Cannot parse `into` attribute: expected parentheses") |
| 299 | } |
| 300 | Metarust-analyzer cargo syn 2.0.110 attr/Meta#::Pathrust-analyzer cargo syn 2.0.110 attr/Meta#Path#(_) => IntoAttributerust-analyzer cargo delegate 0.13.5 attributes/IntoAttribute# { type_pathrust-analyzer cargo delegate 0.13.5 attributes/IntoAttribute#type_path.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# }, |
| 301 | Metarust-analyzer cargo syn 2.0.110 attr/Meta#::Listrust-analyzer cargo syn 2.0.110 attr/Meta#List#(meta) => meta |
| 302 | .parse_argsrust-analyzer cargo syn 2.0.110 attr/impl#[MetaList]parse_args().::<IntoAttributerust-analyzer cargo delegate 0.13.5 attributes/IntoAttribute#>() |
| 303 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Cannot parse `into` attribute"), |
| 304 | }; |
| 305 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ParsedAttributerust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#::ReturnExpressionrust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#ReturnExpression#(ReturnExpressionrust-analyzer cargo delegate 0.13.5 attributes/ReturnExpression#::Intorust-analyzer cargo delegate 0.13.5 attributes/ReturnExpression#Into#( |
| 306 | into.type_pathrust-analyzer cargo delegate 0.13.5 attributes/IntoAttribute#type_path., |
| 307 | ))) |
| 308 | } |
| 309 | "try_into" => { |
| 310 | if let Metarust-analyzer cargo syn 2.0.110 attr/Meta#::Listrust-analyzer cargo syn 2.0.110 attr/Meta#List#(meta) = &attribute.metarust-analyzer cargo syn 2.0.110 attr/Attribute#meta. { |
| 311 | meta.parse_nested_metarust-analyzer cargo syn 2.0.110 attr/impl#[MetaList]parse_nested_meta().(|meta| { |
| 312 | if meta.pathrust-analyzer cargo syn 2.0.110 meta/ParseNestedMeta#path..is_identrust-analyzer cargo syn 2.0.110 path/impl#[Path]is_ident().("unwrap") { |
| 313 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!( |
| 314 | "Replace #[try_into(unwrap)] with\n#[try_into]\n#[unwrap]", |
| 315 | ); |
| 316 | } |
| 317 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 318 | }) |
| 319 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Invalid `try_into` arguments"); |
| 320 | } |
| 321 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ParsedAttributerust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#::ReturnExpressionrust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#ReturnExpression#(ReturnExpressionrust-analyzer cargo delegate 0.13.5 attributes/ReturnExpression#::TryIntorust-analyzer cargo delegate 0.13.5 attributes/ReturnExpression#TryInto#)) |
| 322 | } |
| 323 | "unwrap" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ParsedAttributerust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#::ReturnExpressionrust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#ReturnExpression#(ReturnExpressionrust-analyzer cargo delegate 0.13.5 attributes/ReturnExpression#::Unwraprust-analyzer cargo delegate 0.13.5 attributes/ReturnExpression#Unwrap#)), |
| 324 | "await" => { |
| 325 | let generate = attribute |
| 326 | .parse_argsrust-analyzer cargo syn 2.0.110 attr/impl#[Attribute]parse_args().::<GenerateAwaitAttributerust-analyzer cargo delegate 0.13.5 attributes/GenerateAwaitAttribute#>() |
| 327 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Cannot parse `await` attribute"); |
| 328 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ParsedAttributerust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#::Awaitrust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#Await#(generate.literalrust-analyzer cargo delegate 0.13.5 attributes/GenerateAwaitAttribute#literal..valuerust-analyzer cargo syn 2.0.110 lit/LitBool#value.)) |
| 329 | } |
| 330 | "through" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ParsedAttributerust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#::ThroughTraitrust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#ThroughTrait#( |
| 331 | attribute |
| 332 | .parse_argsrust-analyzer cargo syn 2.0.110 attr/impl#[Attribute]parse_args().::<TraitTargetrust-analyzer cargo delegate 0.13.5 attributes/TraitTarget#>() |
| 333 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Cannot parse `through` attribute"), |
| 334 | )), |
| 335 | "const" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ParsedAttributerust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#::ConstantAccessrust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#ConstantAccess#( |
| 336 | attribute |
| 337 | .parse_argsrust-analyzer cargo syn 2.0.110 attr/impl#[Attribute]parse_args().::<AssociatedConstantrust-analyzer cargo delegate 0.13.5 attributes/AssociatedConstant#>() |
| 338 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Cannot parse `const` attribute"), |
| 339 | )), |
| 340 | "expr" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ParsedAttributerust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#::Exprrust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#Expr#( |
| 341 | attribute |
| 342 | .parse_argsrust-analyzer cargo syn 2.0.110 attr/impl#[Attribute]parse_args().::<TemplateExprrust-analyzer cargo delegate 0.13.5 attributes/TemplateExpr#>() |
| 343 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Cannot parse `expr` attribute"), |
| 344 | )), |
| 345 | _ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 346 | } |
| 347 | } else { |
| 348 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 349 | }; |
| 350 | |
| 351 | (parsed, attribute) |
| 352 | }) |
| 353 | .partitionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#partition().(|(parsed, _)| parsed.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().()); |
| 354 | ( |
| 355 | parsed.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(parsed, _)| parsed.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()), |
| 356 | other.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(_, attr)| attr), |
| 357 | ) |
| 358 | } |
| 359 | |
| 360 | pub struct MethodAttributesrust-analyzer cargo delegate 0.13.5 attributes/MethodAttributes#<'a> { |
| 361 | pub attributesrust-analyzer cargo delegate 0.13.5 attributes/MethodAttributes#attributes.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<&'a Attributerust-analyzer cargo syn 2.0.110 attr/Attribute#>, |
| 362 | pub target_specifierrust-analyzer cargo delegate 0.13.5 attributes/MethodAttributes#target_specifier.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<TargetSpecifierrust-analyzer cargo delegate 0.13.5 attributes/TargetSpecifier#>, |
| 363 | pub expressionsrust-analyzer cargo delegate 0.13.5 attributes/MethodAttributes#expressions.: VecDequerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/VecDeque#<ReturnExpressionrust-analyzer cargo delegate 0.13.5 attributes/ReturnExpression#>, |
| 364 | pub generate_awaitrust-analyzer cargo delegate 0.13.5 attributes/MethodAttributes#generate_await.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<bool>, |
| 365 | pub target_traitrust-analyzer cargo delegate 0.13.5 attributes/MethodAttributes#target_trait.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<TypePathrust-analyzer cargo syn 2.0.110 ty/TypePath#>, |
| 366 | pub associated_constantrust-analyzer cargo delegate 0.13.5 attributes/MethodAttributes#associated_constant.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<AssociatedConstantrust-analyzer cargo delegate 0.13.5 attributes/AssociatedConstant#>, |
| 367 | pub expr_attrrust-analyzer cargo delegate 0.13.5 attributes/MethodAttributes#expr_attr.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<TemplateExprrust-analyzer cargo delegate 0.13.5 attributes/TemplateExpr#>, |
| 368 | } |
| 369 | |
| 370 | /// Iterates through the attributes of a method and filters special attributes. |
| 371 | /// - call => sets the name of the target method to call |
| 372 | /// - into => generates a `into()` call after the delegated expression |
| 373 | /// - try_into => generates a `try_into()` call after the delegated expression |
| 374 | /// - await => generates an `.await` expression after the delegated expression |
| 375 | /// - unwrap => generates a `unwrap()` call after the delegated expression |
| 376 | /// - through => generates a UFCS call (`Target::method(&<expr>, ...)`) around the delegated expression |
| 377 | /// - const => generates a getter to a trait associated constant |
| 378 | pub fn parse_method_attributesrust-analyzer cargo delegate 0.13.5 attributes/parse_method_attributes().<'a>( |
| 379 | attrs: &'a [Attributerust-analyzer cargo syn 2.0.110 attr/Attribute#], |
| 380 | method: &synrust-analyzer cargo syn 2.0.110 crate/::TraitItemFnrust-analyzer cargo syn 2.0.110 item/TraitItemFn#, |
| 381 | ) -> MethodAttributesrust-analyzer cargo delegate 0.13.5 attributes/MethodAttributes#<'a> { |
| 382 | let mut target_spec: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<TargetSpecifierrust-analyzer cargo delegate 0.13.5 attributes/TargetSpecifier#> = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 383 | let mut expressions: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<ReturnExpressionrust-analyzer cargo delegate 0.13.5 attributes/ReturnExpression#> = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![]; |
| 384 | let mut generate_await: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<bool> = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 385 | let mut target_trait: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<TraitTargetrust-analyzer cargo delegate 0.13.5 attributes/TraitTarget#> = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 386 | let mut associated_constant: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<AssociatedConstantrust-analyzer cargo delegate 0.13.5 attributes/AssociatedConstant#> = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 387 | let mut expr_attr: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<TemplateExprrust-analyzer cargo delegate 0.13.5 attributes/TemplateExpr#> = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 388 | |
| 389 | let (parsed, other) = parse_attributesrust-analyzer cargo delegate 0.13.5 attributes/parse_attributes().(attrs); |
| 390 | for attr in parsed { |
| 391 | match attr { |
| 392 | ParsedAttributerust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#::ReturnExpressionrust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#ReturnExpression#(expr) => expressions.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(expr), |
| 393 | ParsedAttributerust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#::Awaitrust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#Await#(value) => { |
| 394 | if generate_await.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() { |
| 395 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!( |
| 396 | "Multiple `await` attributes specified for {}", |
| 397 | method.sigrust-analyzer cargo syn 2.0.110 item/TraitItemFn#sig..identrust-analyzer cargo syn 2.0.110 item/Signature#ident. |
| 398 | ) |
| 399 | } |
| 400 | generate_await = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(value); |
| 401 | } |
| 402 | ParsedAttributerust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#::TargetSpecifierrust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#TargetSpecifier#(spec) => { |
| 403 | if target_spec.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() { |
| 404 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!( |
| 405 | "Multiple field/call attributes specified for {}", |
| 406 | method.sigrust-analyzer cargo syn 2.0.110 item/TraitItemFn#sig..identrust-analyzer cargo syn 2.0.110 item/Signature#ident. |
| 407 | ) |
| 408 | } |
| 409 | target_spec = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(spec); |
| 410 | } |
| 411 | ParsedAttributerust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#::ThroughTraitrust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#ThroughTrait#(target) => { |
| 412 | if target_trait.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() { |
| 413 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!( |
| 414 | "Multiple through attributes specified for {}", |
| 415 | method.sigrust-analyzer cargo syn 2.0.110 item/TraitItemFn#sig..identrust-analyzer cargo syn 2.0.110 item/Signature#ident. |
| 416 | ) |
| 417 | } |
| 418 | target_trait = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(target); |
| 419 | } |
| 420 | ParsedAttributerust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#::ConstantAccessrust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#ConstantAccess#(const_attr) => { |
| 421 | if associated_constant.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() { |
| 422 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!( |
| 423 | "Multiple const attributes specified for {}", |
| 424 | method.sigrust-analyzer cargo syn 2.0.110 item/TraitItemFn#sig..identrust-analyzer cargo syn 2.0.110 item/Signature#ident. |
| 425 | ) |
| 426 | } |
| 427 | associated_constant = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(const_attr); |
| 428 | } |
| 429 | ParsedAttributerust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#::Exprrust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#Expr#(token_tree) => { |
| 430 | if expr_attr.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() { |
| 431 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!( |
| 432 | "Multiple expr attributes specified for {}", |
| 433 | method.sigrust-analyzer cargo syn 2.0.110 item/TraitItemFn#sig..identrust-analyzer cargo syn 2.0.110 item/Signature#ident. |
| 434 | ) |
| 435 | } |
| 436 | expr_attr = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(token_tree); |
| 437 | } |
| 438 | } |
| 439 | } |
| 440 | |
| 441 | if associated_constant.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() && target_spec.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() { |
| 442 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Cannot use both `call`/`field` and `const` attributes."); |
| 443 | } |
| 444 | |
| 445 | MethodAttributesrust-analyzer cargo delegate 0.13.5 attributes/MethodAttributes# { |
| 446 | attributesrust-analyzer cargo delegate 0.13.5 attributes/MethodAttributes#attributes.: other.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/impl#[I][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(), |
| 447 | target_specifierrust-analyzer cargo delegate 0.13.5 attributes/MethodAttributes#target_specifier.: target_spec, |
| 448 | generate_awaitrust-analyzer cargo delegate 0.13.5 attributes/MethodAttributes#generate_await., |
| 449 | expressionsrust-analyzer cargo delegate 0.13.5 attributes/MethodAttributes#expressions.: expressions.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 450 | target_traitrust-analyzer cargo delegate 0.13.5 attributes/MethodAttributes#target_trait.: target_trait.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|t| t.type_pathrust-analyzer cargo delegate 0.13.5 attributes/TraitTarget#type_path.), |
| 451 | associated_constantrust-analyzer cargo delegate 0.13.5 attributes/MethodAttributes#associated_constant., |
| 452 | expr_attrrust-analyzer cargo delegate 0.13.5 attributes/MethodAttributes#expr_attr., |
| 453 | } |
| 454 | } |
| 455 | |
| 456 | pub struct SegmentAttributesrust-analyzer cargo delegate 0.13.5 attributes/SegmentAttributes# { |
| 457 | pub expressionsrust-analyzer cargo delegate 0.13.5 attributes/SegmentAttributes#expressions.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<ReturnExpressionrust-analyzer cargo delegate 0.13.5 attributes/ReturnExpression#>, |
| 458 | pub generate_awaitrust-analyzer cargo delegate 0.13.5 attributes/SegmentAttributes#generate_await.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<bool>, |
| 459 | pub target_traitrust-analyzer cargo delegate 0.13.5 attributes/SegmentAttributes#target_trait.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<TypePathrust-analyzer cargo syn 2.0.110 ty/TypePath#>, |
| 460 | pub other_attrsrust-analyzer cargo delegate 0.13.5 attributes/SegmentAttributes#other_attrs.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Attributerust-analyzer cargo syn 2.0.110 attr/Attribute#>, |
| 461 | pub expr_attrrust-analyzer cargo delegate 0.13.5 attributes/SegmentAttributes#expr_attr.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<TemplateExprrust-analyzer cargo delegate 0.13.5 attributes/TemplateExpr#>, |
| 462 | } |
| 463 | |
| 464 | pub fn parse_segment_attributesrust-analyzer cargo delegate 0.13.5 attributes/parse_segment_attributes().(attrs: &[Attributerust-analyzer cargo syn 2.0.110 attr/Attribute#]) -> SegmentAttributesrust-analyzer cargo delegate 0.13.5 attributes/SegmentAttributes# { |
| 465 | let mut expressions: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<ReturnExpressionrust-analyzer cargo delegate 0.13.5 attributes/ReturnExpression#> = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![]; |
| 466 | let mut generate_await: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<bool> = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 467 | let mut target_trait: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<TraitTargetrust-analyzer cargo delegate 0.13.5 attributes/TraitTarget#> = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 468 | let mut expr_attr: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<TemplateExprrust-analyzer cargo delegate 0.13.5 attributes/TemplateExpr#> = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 469 | |
| 470 | let (parsed, other) = parse_attributesrust-analyzer cargo delegate 0.13.5 attributes/parse_attributes().(attrs); |
| 471 | |
| 472 | for attribute in parsed { |
| 473 | match attribute { |
| 474 | ParsedAttributerust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#::ReturnExpressionrust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#ReturnExpression#(expr) => expressions.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(expr), |
| 475 | ParsedAttributerust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#::Awaitrust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#Await#(value) => { |
| 476 | if generate_await.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() { |
| 477 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Multiple `await` attributes specified for segment"); |
| 478 | } |
| 479 | generate_await = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(value); |
| 480 | } |
| 481 | ParsedAttributerust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#::ThroughTraitrust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#ThroughTrait#(target) => { |
| 482 | if target_trait.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() { |
| 483 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Multiple `through` attributes specified for segment"); |
| 484 | } |
| 485 | target_trait = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(target); |
| 486 | } |
| 487 | ParsedAttributerust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#::TargetSpecifierrust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#TargetSpecifier#(_) => { |
| 488 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Field/call attribute cannot be specified on a `to <expr>` segment."); |
| 489 | } |
| 490 | ParsedAttributerust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#::ConstantAccessrust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#ConstantAccess#(_) => { |
| 491 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Const attribute cannot be specified on a `to <expr>` segment."); |
| 492 | } |
| 493 | ParsedAttributerust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#::Exprrust-analyzer cargo delegate 0.13.5 attributes/ParsedAttribute#Expr#(token_tree) => { |
| 494 | if expr_attr.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() { |
| 495 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Multiple `expr` attributes specified for segment"); |
| 496 | } |
| 497 | expr_attr = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(token_tree); |
| 498 | } |
| 499 | } |
| 500 | } |
| 501 | SegmentAttributesrust-analyzer cargo delegate 0.13.5 attributes/SegmentAttributes# { |
| 502 | expressionsrust-analyzer cargo delegate 0.13.5 attributes/SegmentAttributes#expressions., |
| 503 | generate_awaitrust-analyzer cargo delegate 0.13.5 attributes/SegmentAttributes#generate_await., |
| 504 | target_traitrust-analyzer cargo delegate 0.13.5 attributes/SegmentAttributes#target_trait.: target_trait.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|t| t.type_pathrust-analyzer cargo delegate 0.13.5 attributes/TraitTarget#type_path.), |
| 505 | other_attrsrust-analyzer cargo delegate 0.13.5 attributes/SegmentAttributes#other_attrs.: other.clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>(), |
| 506 | expr_attrrust-analyzer cargo delegate 0.13.5 attributes/SegmentAttributes#expr_attr., |
| 507 | } |
| 508 | } |
| 509 | |
| 510 | /// Applies default values from the segment and adds them to the method attributes. |
| 511 | pub fn combine_attributesrust-analyzer cargo delegate 0.13.5 attributes/combine_attributes().<'a>( |
| 512 | mut method_attrs: MethodAttributesrust-analyzer cargo delegate 0.13.5 attributes/MethodAttributes#<'a>, |
| 513 | segment_attrs: &'a SegmentAttributesrust-analyzer cargo delegate 0.13.5 attributes/SegmentAttributes#, |
| 514 | ) -> MethodAttributesrust-analyzer cargo delegate 0.13.5 attributes/MethodAttributes#<'a> { |
| 515 | let SegmentAttributesrust-analyzer cargo delegate 0.13.5 attributes/SegmentAttributes# { |
| 516 | expressionsrust-analyzer cargo delegate 0.13.5 attributes/SegmentAttributes#expressions., |
| 517 | generate_awaitrust-analyzer cargo delegate 0.13.5 attributes/SegmentAttributes#generate_await., |
| 518 | target_traitrust-analyzer cargo delegate 0.13.5 attributes/SegmentAttributes#target_trait., |
| 519 | other_attrsrust-analyzer cargo delegate 0.13.5 attributes/SegmentAttributes#other_attrs., |
| 520 | expr_attrrust-analyzer cargo delegate 0.13.5 attributes/SegmentAttributes#expr_attr., |
| 521 | } = segment_attrs; |
| 522 | |
| 523 | if method_attrs.generate_awaitrust-analyzer cargo delegate 0.13.5 attributes/MethodAttributes#generate_await..is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().() { |
| 524 | method_attrs.generate_awaitrust-analyzer cargo delegate 0.13.5 attributes/MethodAttributes#generate_await. = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().generate_await; |
| 525 | } |
| 526 | |
| 527 | if method_attrs.target_traitrust-analyzer cargo delegate 0.13.5 attributes/MethodAttributes#target_trait..is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().() { |
| 528 | method_attrs.target_traitrust-analyzer cargo delegate 0.13.5 attributes/MethodAttributes#target_trait..clone_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone_from().(target_trait); |
| 529 | } |
| 530 | |
| 531 | if method_attrs.expr_attrrust-analyzer cargo delegate 0.13.5 attributes/MethodAttributes#expr_attr..is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().() { |
| 532 | method_attrs.expr_attrrust-analyzer cargo delegate 0.13.5 attributes/MethodAttributes#expr_attr..clone_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone_from().(expr_attr); |
| 533 | } |
| 534 | |
| 535 | for expr in expressions { |
| 536 | match expr { |
| 537 | ReturnExpressionrust-analyzer cargo delegate 0.13.5 attributes/ReturnExpression#::Intorust-analyzer cargo delegate 0.13.5 attributes/ReturnExpression#Into#(path) => { |
| 538 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().method_attrs |
| 539 | .expressionsrust-analyzer cargo delegate 0.13.5 attributes/MethodAttributes#expressions. |
| 540 | .iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]iter().() |
| 541 | .anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#any().(|expr| matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(expr, ReturnExpressionrust-analyzer cargo delegate 0.13.5 attributes/ReturnExpression#::Intorust-analyzer cargo delegate 0.13.5 attributes/ReturnExpression#Into#(_))) |
| 542 | { |
| 543 | method_attrs |
| 544 | .expressionsrust-analyzer cargo delegate 0.13.5 attributes/MethodAttributes#expressions. |
| 545 | .push_frontrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]push_front().(ReturnExpressionrust-analyzer cargo delegate 0.13.5 attributes/ReturnExpression#::Intorust-analyzer cargo delegate 0.13.5 attributes/ReturnExpression#Into#(path.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().())); |
| 546 | } |
| 547 | } |
| 548 | _ => method_attrs.expressionsrust-analyzer cargo delegate 0.13.5 attributes/MethodAttributes#expressions..push_frontrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]push_front().(expr.clonerust-analyzer cargo delegate 0.13.5 attributes/impl#[ReturnExpression][Clone]clone().()), |
| 549 | } |
| 550 | } |
| 551 | |
| 552 | for other_attr in other_attrs { |
| 553 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().method_attrs |
| 554 | .attributesrust-analyzer cargo delegate 0.13.5 attributes/MethodAttributes#attributes. |
| 555 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 556 | .anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]any().(|attr| attr.pathrust-analyzer cargo syn 2.0.110 attr/impl#[Attribute]path().().get_identrust-analyzer cargo syn 2.0.110 path/impl#[Path]get_ident().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().other_attr.pathrust-analyzer cargo syn 2.0.110 attr/impl#[Attribute]path().().get_identrust-analyzer cargo syn 2.0.110 path/impl#[Path]get_ident().()) |
| 557 | { |
| 558 | method_attrs.attributesrust-analyzer cargo delegate 0.13.5 attributes/MethodAttributes#attributes..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(other_attr); |
| 559 | } |
| 560 | } |
| 561 | |
| 562 | method_attrs |
| 563 | } |