| 1 | use quoterust-analyzer cargo quote 1.0.47 crate/::{quoterust-analyzer cargo quote 1.0.47 quote!, ToTokensrust-analyzer cargo quote 1.0.47 to_tokens/ToTokens#}; |
| 2 | use synrust-analyzer cargo syn 2.0.119 crate/::{ |
| 3 | parserust-analyzer cargo syn 2.0.119 parse/::{Parserust-analyzer cargo syn 2.0.119 parse/Parse#, ParseStreamrust-analyzer cargo syn 2.0.119 parse/ParseStream#}, |
| 4 | punctuatedrust-analyzer cargo syn 2.0.119 punctuated/::Punctuatedrust-analyzer cargo syn 2.0.119 punctuated/Punctuated#, |
| 5 | spannedrust-analyzer cargo syn 2.0.119 spanned/::Spannedrust-analyzer cargo syn 2.0.119 spanned/Spanned#, |
| 6 | tokenrust-analyzer cargo syn 2.0.119 token/::Commarust-analyzer cargo syn 2.0.119 token/Comma#, |
| 7 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#, GenericParamrust-analyzer cargo syn 2.0.119 generics/GenericParam#, Litrust-analyzer cargo syn 2.0.119 lit/Lit#, Metarust-analyzer cargo syn 2.0.119 attr/Meta#, MetaNameValuerust-analyzer cargo syn 2.0.119 attr/MetaNameValue#, Pathrust-analyzer cargo syn 2.0.119 path/Path#, Tokenrust-analyzer cargo syn 2.0.119 token/Token!, Typerust-analyzer cargo syn 2.0.119 ty/Type#, WherePredicaterust-analyzer cargo syn 2.0.119 generics/WherePredicate#, |
| 8 | }; |
| 9 | |
| 10 | use superrust-analyzer cargo educe 0.6.0 common/::pathrust-analyzer cargo educe 0.6.0 common/path/::path_to_stringrust-analyzer cargo educe 0.6.0 common/path/path_to_string().; |
| 11 | |
| 12 | pub(craterust-analyzer cargo educe 0.6.0 crate/) type WherePredicatesrust-analyzer cargo educe 0.6.0 common/where_predicates_bool/WherePredicates# = Punctuatedrust-analyzer cargo syn 2.0.119 punctuated/Punctuated#<WherePredicaterust-analyzer cargo syn 2.0.119 generics/WherePredicate#, Tokenrust-analyzer cargo syn 2.0.119 token/Token!![,]>; |
| 13 | |
| 14 | pub(craterust-analyzer cargo educe 0.6.0 crate/) enum WherePredicatesOrBoolrust-analyzer cargo educe 0.6.0 common/where_predicates_bool/WherePredicatesOrBool# { |
| 15 | WherePredicatesrust-analyzer cargo educe 0.6.0 common/where_predicates_bool/WherePredicatesOrBool#WherePredicates#(WherePredicatesrust-analyzer cargo educe 0.6.0 common/where_predicates_bool/WherePredicates#), |
| 16 | Boolrust-analyzer cargo educe 0.6.0 common/where_predicates_bool/WherePredicatesOrBool#Bool#(bool), |
| 17 | Allrust-analyzer cargo educe 0.6.0 common/where_predicates_bool/WherePredicatesOrBool#All#, |
| 18 | } |
| 19 | |
| 20 | impl WherePredicatesOrBoolrust-analyzer cargo educe 0.6.0 common/where_predicates_bool/WherePredicatesOrBool# { |
| 21 | fn from_litrust-analyzer cargo educe 0.6.0 common/where_predicates_bool/impl#[WherePredicatesOrBool]from_lit().(lit: &Litrust-analyzer cargo syn 2.0.119 lit/Lit#) -> synrust-analyzer cargo syn 2.0.119 crate/::Resultrust-analyzer cargo syn 2.0.119 error/Result#<Selfrust-analyzer cargo educe 0.6.0 common/where_predicates_bool/impl#[WherePredicatesOrBool]> { |
| 22 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(match lit { |
| 23 | Litrust-analyzer cargo syn 2.0.119 lit/Lit#::Boolrust-analyzer cargo syn 2.0.119 lit/Lit#Bool#(lit) => Selfrust-analyzer cargo educe 0.6.0 common/where_predicates_bool/impl#[WherePredicatesOrBool]::Boolrust-analyzer cargo educe 0.6.0 common/where_predicates_bool/WherePredicatesOrBool#Bool#(lit.valuerust-analyzer cargo syn 2.0.119 lit/LitBool#value.), |
| 24 | Litrust-analyzer cargo syn 2.0.119 lit/Lit#::Strrust-analyzer cargo syn 2.0.119 lit/Lit#Str#(lit) => match lit.parse_withrust-analyzer cargo syn 2.0.119 lit/impl#[LitStr]parse_with().(WherePredicatesrust-analyzer cargo educe 0.6.0 common/where_predicates_bool/WherePredicates#::parse_terminatedrust-analyzer cargo syn 2.0.119 punctuated/impl#[`Punctuated<T, P>`]parse_terminated().) { |
| 25 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(where_predicates) => Selfrust-analyzer cargo educe 0.6.0 common/where_predicates_bool/impl#[WherePredicatesOrBool]::WherePredicatesrust-analyzer cargo educe 0.6.0 common/where_predicates_bool/WherePredicatesOrBool#WherePredicates#(where_predicates), |
| 26 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_) if lit.valuerust-analyzer cargo syn 2.0.119 lit/impl#[LitStr]value().().is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]is_empty().() => Selfrust-analyzer cargo educe 0.6.0 common/where_predicates_bool/impl#[WherePredicatesOrBool]::Boolrust-analyzer cargo educe 0.6.0 common/where_predicates_bool/WherePredicatesOrBool#Bool#(false), |
| 27 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(error) => return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(error), |
| 28 | }, |
| 29 | other => { |
| 30 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(synrust-analyzer cargo syn 2.0.119 crate/::Errorrust-analyzer cargo syn 2.0.119 error/Error#::newrust-analyzer cargo syn 2.0.119 error/impl#[Error]new().( |
| 31 | other.spanrust-analyzer cargo syn 2.0.119 lit/value/impl#[Lit]span().(), |
| 32 | "unexpected kind of literal (only boolean or string allowed)", |
| 33 | )) |
| 34 | }, |
| 35 | }) |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | impl Parserust-analyzer cargo syn 2.0.119 parse/Parse# for WherePredicatesOrBoolrust-analyzer cargo educe 0.6.0 common/where_predicates_bool/WherePredicatesOrBool# { |
| 40 | #[inline] |
| 41 | fn parserust-analyzer cargo educe 0.6.0 common/where_predicates_bool/impl#[WherePredicatesOrBool][Parse]parse().(input: ParseStreamrust-analyzer cargo syn 2.0.119 parse/ParseStream#) -> synrust-analyzer cargo syn 2.0.119 crate/::Resultrust-analyzer cargo syn 2.0.119 error/Result#<Selfrust-analyzer cargo educe 0.6.0 common/where_predicates_bool/impl#[WherePredicatesOrBool][Parse]> { |
| 42 | if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(lit) = input.parserust-analyzer cargo syn 2.0.119 parse/impl#[`ParseBuffer<'a>`]parse().::<Litrust-analyzer cargo syn 2.0.119 lit/Lit#>() { |
| 43 | return Selfrust-analyzer cargo educe 0.6.0 common/where_predicates_bool/impl#[WherePredicatesOrBool][Parse]::from_litrust-analyzer cargo educe 0.6.0 common/where_predicates_bool/impl#[WherePredicatesOrBool]from_lit().(&lit); |
| 44 | } |
| 45 | |
| 46 | if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(_star) = input.parserust-analyzer cargo syn 2.0.119 parse/impl#[`ParseBuffer<'a>`]parse().::<Tokenrust-analyzer cargo syn 2.0.119 token/Token!![*]>() { |
| 47 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo educe 0.6.0 common/where_predicates_bool/impl#[WherePredicatesOrBool][Parse]::Allrust-analyzer cargo educe 0.6.0 common/where_predicates_bool/WherePredicatesOrBool#All#); |
| 48 | } |
| 49 | |
| 50 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo educe 0.6.0 common/where_predicates_bool/impl#[WherePredicatesOrBool][Parse]::WherePredicatesrust-analyzer cargo educe 0.6.0 common/where_predicates_bool/WherePredicatesOrBool#WherePredicates#(input.parse_terminatedrust-analyzer cargo syn 2.0.119 parse/impl#[`ParseBuffer<'a>`]parse_terminated().(WherePredicaterust-analyzer cargo syn 2.0.119 generics/WherePredicate#::parserust-analyzer cargo syn 2.0.119 generics/parsing/impl#[WherePredicate][Parse]parse()., Tokenrust-analyzer cargo syn 2.0.119 token/Token!![,])?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)) |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | #[inline] |
| 55 | pub(craterust-analyzer cargo educe 0.6.0 crate/) fn meta_name_value_2_where_predicates_boolrust-analyzer cargo educe 0.6.0 common/where_predicates_bool/meta_name_value_2_where_predicates_bool().( |
| 56 | name_value: &MetaNameValuerust-analyzer cargo syn 2.0.119 attr/MetaNameValue#, |
| 57 | ) -> synrust-analyzer cargo syn 2.0.119 crate/::Resultrust-analyzer cargo syn 2.0.119 error/Result#<WherePredicatesOrBoolrust-analyzer cargo educe 0.6.0 common/where_predicates_bool/WherePredicatesOrBool#> { |
| 58 | if let Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Litrust-analyzer cargo syn 2.0.119 expr/Expr#Lit#(lit) = &name_value.valuerust-analyzer cargo syn 2.0.119 attr/MetaNameValue#value. { |
| 59 | return WherePredicatesOrBoolrust-analyzer cargo educe 0.6.0 common/where_predicates_bool/WherePredicatesOrBool#::from_litrust-analyzer cargo educe 0.6.0 common/where_predicates_bool/impl#[WherePredicatesOrBool]from_lit().(&lit.litrust-analyzer cargo syn 2.0.119 expr/ExprLit#lit.); |
| 60 | } |
| 61 | |
| 62 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(synrust-analyzer cargo syn 2.0.119 crate/::Errorrust-analyzer cargo syn 2.0.119 error/Error#::newrust-analyzer cargo syn 2.0.119 error/impl#[Error]new().( |
| 63 | name_value.valuerust-analyzer cargo syn 2.0.119 attr/MetaNameValue#value..spanrust-analyzer cargo syn 2.0.119 spanned/impl#[T][Spanned]span().(), |
| 64 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 65 | "expected `{path} = \"where_predicates\"` or `{path} = false`", |
| 66 | path = path_to_stringrust-analyzer cargo educe 0.6.0 common/path/path_to_string().(&name_value.pathrust-analyzer cargo syn 2.0.119 attr/MetaNameValue#path.) |
| 67 | ), |
| 68 | )) |
| 69 | } |
| 70 | |
| 71 | #[inline] |
| 72 | pub(craterust-analyzer cargo educe 0.6.0 crate/) fn meta_2_where_predicatesrust-analyzer cargo educe 0.6.0 common/where_predicates_bool/meta_2_where_predicates().(meta: &Metarust-analyzer cargo syn 2.0.119 attr/Meta#) -> synrust-analyzer cargo syn 2.0.119 crate/::Resultrust-analyzer cargo syn 2.0.119 error/Result#<WherePredicatesOrBoolrust-analyzer cargo educe 0.6.0 common/where_predicates_bool/WherePredicatesOrBool#> { |
| 73 | match &meta { |
| 74 | Metarust-analyzer cargo syn 2.0.119 attr/Meta#::NameValuerust-analyzer cargo syn 2.0.119 attr/Meta#NameValue#(name_value) => meta_name_value_2_where_predicates_boolrust-analyzer cargo educe 0.6.0 common/where_predicates_bool/meta_name_value_2_where_predicates_bool().(name_value), |
| 75 | Metarust-analyzer cargo syn 2.0.119 attr/Meta#::Listrust-analyzer cargo syn 2.0.119 attr/Meta#List#(list) => list.parse_argsrust-analyzer cargo syn 2.0.119 attr/impl#[MetaList]parse_args().::<WherePredicatesOrBoolrust-analyzer cargo educe 0.6.0 common/where_predicates_bool/WherePredicatesOrBool#>(), |
| 76 | Metarust-analyzer cargo syn 2.0.119 attr/Meta#::Pathrust-analyzer cargo syn 2.0.119 attr/Meta#Path#(path) => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(synrust-analyzer cargo syn 2.0.119 crate/::Errorrust-analyzer cargo syn 2.0.119 error/Error#::newrust-analyzer cargo syn 2.0.119 error/impl#[Error]new().( |
| 77 | path.spanrust-analyzer cargo syn 2.0.119 spanned/impl#[T][Spanned]span().(), |
| 78 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 79 | "expected `{path} = \"where_predicates\"`, `{path}(where_predicates)`, `{path} = \ |
| 80 | false`, or `{path}(false)`", |
| 81 | path = path.clonerust-analyzer cargo syn 2.0.119 gen/clone/impl#[`crate::Path`][Clone]clone().().into_token_streamrust-analyzer cargo quote 1.0.47 to_tokens/ToTokens#into_token_stream().() |
| 82 | ), |
| 83 | )), |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | #[inline] |
| 88 | pub(craterust-analyzer cargo educe 0.6.0 crate/) fn create_where_predicates_from_all_generic_parametersrust-analyzer cargo educe 0.6.0 common/where_predicates_bool/create_where_predicates_from_all_generic_parameters().( |
| 89 | params: &Punctuatedrust-analyzer cargo syn 2.0.119 punctuated/Punctuated#<GenericParamrust-analyzer cargo syn 2.0.119 generics/GenericParam#, Commarust-analyzer cargo syn 2.0.119 token/Comma#>, |
| 90 | bound_trait: &Pathrust-analyzer cargo syn 2.0.119 path/Path#, |
| 91 | ) -> WherePredicatesrust-analyzer cargo educe 0.6.0 common/where_predicates_bool/WherePredicates# { |
| 92 | let mut where_predicates = Punctuatedrust-analyzer cargo syn 2.0.119 punctuated/Punctuated#::newrust-analyzer cargo syn 2.0.119 punctuated/impl#[`Punctuated<T, P>`]new().(); |
| 93 | |
| 94 | for param in params { |
| 95 | if let GenericParamrust-analyzer cargo syn 2.0.119 generics/GenericParam#::Typerust-analyzer cargo syn 2.0.119 generics/GenericParam#Type#(ty) = param { |
| 96 | let ident = &ty.identrust-analyzer cargo syn 2.0.119 generics/TypeParam#ident.; |
| 97 | |
| 98 | where_predicates.pushrust-analyzer cargo syn 2.0.119 punctuated/impl#[`Punctuated<T, P>`]push().(synrust-analyzer cargo syn 2.0.119 crate/::parse2rust-analyzer cargo syn 2.0.119 parse2().(quoterust-analyzer cargo quote 1.0.47 quote!! { #ident: #bound_trait }).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()); |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | where_predicates |
| 103 | } |
| 104 | |
| 105 | #[inline] |
| 106 | pub(craterust-analyzer cargo educe 0.6.0 crate/) fn create_where_predicates_from_generic_parameters_check_typesrust-analyzer cargo educe 0.6.0 common/where_predicates_bool/create_where_predicates_from_generic_parameters_check_types().( |
| 107 | bound_trait: &Pathrust-analyzer cargo syn 2.0.119 path/Path#, |
| 108 | types: &[&Typerust-analyzer cargo syn 2.0.119 ty/Type#], |
| 109 | supertraits: &[proc_macro2rust-analyzer cargo proc-macro2 1.0.107 crate/::TokenStreamrust-analyzer cargo proc-macro2 1.0.107 TokenStream#], |
| 110 | ) -> WherePredicatesrust-analyzer cargo educe 0.6.0 common/where_predicates_bool/WherePredicates# { |
| 111 | let mut where_predicates = Punctuatedrust-analyzer cargo syn 2.0.119 punctuated/Punctuated#::newrust-analyzer cargo syn 2.0.119 punctuated/impl#[`Punctuated<T, P>`]new().(); |
| 112 | |
| 113 | for t in types { |
| 114 | where_predicates.pushrust-analyzer cargo syn 2.0.119 punctuated/impl#[`Punctuated<T, P>`]push().(synrust-analyzer cargo syn 2.0.119 crate/::parse2rust-analyzer cargo syn 2.0.119 parse2().(quoterust-analyzer cargo quote 1.0.47 quote!! { #t: #bound_trait }).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()); |
| 115 | } |
| 116 | |
| 117 | for supertrait in supertraits { |
| 118 | where_predicates.pushrust-analyzer cargo syn 2.0.119 punctuated/impl#[`Punctuated<T, P>`]push().(synrust-analyzer cargo syn 2.0.119 crate/::parse2rust-analyzer cargo syn 2.0.119 parse2().(quoterust-analyzer cargo quote 1.0.47 quote!! { Self: #supertrait }).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()); |
| 119 | } |
| 120 | |
| 121 | where_predicates |
| 122 | } |