| 1 | 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/::BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#; |
| 2 | |
| 3 | use quoterust-analyzer cargo quote 1.0.47 crate/::{format_identrust-analyzer cargo quote 1.0.47 format/format_ident!, quoterust-analyzer cargo quote 1.0.47 quote!}; |
| 4 | use synrust-analyzer cargo syn 2.0.119 crate/::{spannedrust-analyzer cargo syn 2.0.119 spanned/::Spannedrust-analyzer cargo syn 2.0.119 spanned/Spanned#, Datarust-analyzer cargo syn 2.0.119 derive/Data#, DeriveInputrust-analyzer cargo syn 2.0.119 derive/DeriveInput#, Fieldrust-analyzer cargo syn 2.0.119 data/Field#, Fieldsrust-analyzer cargo syn 2.0.119 data/Fields#, Identrust-analyzer cargo proc-macro2 1.0.107 Ident#, Metarust-analyzer cargo syn 2.0.119 attr/Meta#, Pathrust-analyzer cargo syn 2.0.119 path/Path#, Typerust-analyzer cargo syn 2.0.119 ty/Type#}; |
| 5 | |
| 6 | use superrust-analyzer cargo educe 0.6.0 trait_handlers/ord/::{ |
| 7 | modelsrust-analyzer cargo educe 0.6.0 trait_handlers/ord/models/::{FieldAttributerust-analyzer cargo educe 0.6.0 trait_handlers/ord/models/field_attribute/FieldAttribute#, FieldAttributeBuilderrust-analyzer cargo educe 0.6.0 trait_handlers/ord/models/field_attribute/FieldAttributeBuilder#, TypeAttributeBuilderrust-analyzer cargo educe 0.6.0 trait_handlers/ord/models/type_attribute/TypeAttributeBuilder#}, |
| 8 | TraitHandlerrust-analyzer cargo educe 0.6.0 trait_handlers/TraitHandler#, |
| 9 | }; |
| 10 | use craterust-analyzer cargo educe 0.6.0 crate/::{commonrust-analyzer cargo educe 0.6.0 common/::toolsrust-analyzer cargo educe 0.6.0 common/tools/::DiscriminantTyperust-analyzer cargo educe 0.6.0 common/tools/discriminant_type/DiscriminantType#, Traitrust-analyzer cargo educe 0.6.0 supported_traits/Trait#}; |
| 11 | |
| 12 | pub(craterust-analyzer cargo educe 0.6.0 crate/) struct OrdEnumHandlerrust-analyzer cargo educe 0.6.0 trait_handlers/ord/ord_enum/OrdEnumHandler#; |
| 13 | |
| 14 | impl TraitHandlerrust-analyzer cargo educe 0.6.0 trait_handlers/TraitHandler# for OrdEnumHandlerrust-analyzer cargo educe 0.6.0 trait_handlers/ord/ord_enum/OrdEnumHandler# { |
| 15 | #[inline] |
| 16 | fn trait_meta_handlerrust-analyzer cargo educe 0.6.0 trait_handlers/ord/ord_enum/impl#[OrdEnumHandler][TraitHandler]trait_meta_handler().( |
| 17 | ast: &DeriveInputrust-analyzer cargo syn 2.0.119 derive/DeriveInput#, |
| 18 | token_stream: &mut proc_macro2rust-analyzer cargo proc-macro2 1.0.107 crate/::TokenStreamrust-analyzer cargo proc-macro2 1.0.107 TokenStream#, |
| 19 | traits: &[Traitrust-analyzer cargo educe 0.6.0 supported_traits/Trait#], |
| 20 | meta: &Metarust-analyzer cargo syn 2.0.119 attr/Meta#, |
| 21 | ) -> synrust-analyzer cargo syn 2.0.119 crate/::Resultrust-analyzer cargo syn 2.0.119 error/Result#<()> { |
| 22 | let type_attribute = TypeAttributeBuilderrust-analyzer cargo educe 0.6.0 trait_handlers/ord/models/type_attribute/TypeAttributeBuilder# { |
| 23 | enable_flagrust-analyzer cargo educe 0.6.0 trait_handlers/ord/models/type_attribute/TypeAttributeBuilder#enable_flag.: true, enable_boundrust-analyzer cargo educe 0.6.0 trait_handlers/ord/models/type_attribute/TypeAttributeBuilder#enable_bound.: true |
| 24 | } |
| 25 | .build_from_ord_metarust-analyzer cargo educe 0.6.0 trait_handlers/ord/models/type_attribute/impl#[TypeAttributeBuilder]build_from_ord_meta().(meta)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 26 | |
| 27 | let mut ord_types: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<&Typerust-analyzer cargo syn 2.0.119 ty/Type#> = 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().(); |
| 28 | |
| 29 | let mut cmp_token_stream = proc_macro2rust-analyzer cargo proc-macro2 1.0.107 crate/::TokenStreamrust-analyzer cargo proc-macro2 1.0.107 TokenStream#::newrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream]new().(); |
| 30 | |
| 31 | let discriminant_type = DiscriminantTyperust-analyzer cargo educe 0.6.0 common/tools/discriminant_type/DiscriminantType#::from_astrust-analyzer cargo educe 0.6.0 common/tools/discriminant_type/impl#[DiscriminantType]from_ast().(ast)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 32 | |
| 33 | let mut arms_token_stream = proc_macro2rust-analyzer cargo proc-macro2 1.0.107 crate/::TokenStreamrust-analyzer cargo proc-macro2 1.0.107 TokenStream#::newrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream]new().(); |
| 34 | |
| 35 | let mut all_unit = true; |
| 36 | |
| 37 | if let Datarust-analyzer cargo syn 2.0.119 derive/Data#::Enumrust-analyzer cargo syn 2.0.119 derive/Data#Enum#(data) = &ast.datarust-analyzer cargo syn 2.0.119 derive/DeriveInput#data. { |
| 38 | for variant in data.variantsrust-analyzer cargo syn 2.0.119 derive/DataEnum#variants..iterrust-analyzer cargo syn 2.0.119 punctuated/impl#[`Punctuated<T, P>`]iter().() { |
| 39 | let _ = TypeAttributeBuilderrust-analyzer cargo educe 0.6.0 trait_handlers/ord/models/type_attribute/TypeAttributeBuilder# { |
| 40 | enable_flagrust-analyzer cargo educe 0.6.0 trait_handlers/ord/models/type_attribute/TypeAttributeBuilder#enable_flag.: false, enable_boundrust-analyzer cargo educe 0.6.0 trait_handlers/ord/models/type_attribute/TypeAttributeBuilder#enable_bound.: false |
| 41 | } |
| 42 | .build_from_attributesrust-analyzer cargo educe 0.6.0 trait_handlers/ord/models/type_attribute/impl#[TypeAttributeBuilder]build_from_attributes().(&variant.attrsrust-analyzer cargo syn 2.0.119 data/Variant#attrs., traits)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 43 | |
| 44 | let variant_ident = &variant.identrust-analyzer cargo syn 2.0.119 data/Variant#ident.; |
| 45 | |
| 46 | let built_in_cmp: Pathrust-analyzer cargo syn 2.0.119 path/Path# = synrust-analyzer cargo syn 2.0.119 crate/::parse2rust-analyzer cargo syn 2.0.119 parse2().(quoterust-analyzer cargo quote 1.0.47 quote!!(::core::cmp::Ord::cmp)).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 47 | |
| 48 | match &variant.fieldsrust-analyzer cargo syn 2.0.119 data/Variant#fields. { |
| 49 | Fieldsrust-analyzer cargo syn 2.0.119 data/Fields#::Unitrust-analyzer cargo syn 2.0.119 data/Fields#Unit# => { |
| 50 | arms_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!! { |
| 51 | Self::#variant_ident => { |
| 52 | return ::core::cmp::Ordering::Equal; |
| 53 | } |
| 54 | }); |
| 55 | }, |
| 56 | Fieldsrust-analyzer cargo syn 2.0.119 data/Fields#::Namedrust-analyzer cargo syn 2.0.119 data/Fields#Named#(_) => { |
| 57 | all_unit = false; |
| 58 | |
| 59 | let mut pattern_self_token_stream = proc_macro2rust-analyzer cargo proc-macro2 1.0.107 crate/::TokenStreamrust-analyzer cargo proc-macro2 1.0.107 TokenStream#::newrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream]new().(); |
| 60 | let mut pattern_other_token_stream = proc_macro2rust-analyzer cargo proc-macro2 1.0.107 crate/::TokenStreamrust-analyzer cargo proc-macro2 1.0.107 TokenStream#::newrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream]new().(); |
| 61 | let mut block_token_stream = proc_macro2rust-analyzer cargo proc-macro2 1.0.107 crate/::TokenStreamrust-analyzer cargo proc-macro2 1.0.107 TokenStream#::newrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream]new().(); |
| 62 | |
| 63 | let mut fields: BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#<isize, (&Fieldrust-analyzer cargo syn 2.0.119 data/Field#, Identrust-analyzer cargo proc-macro2 1.0.107 Ident#, Identrust-analyzer cargo proc-macro2 1.0.107 Ident#, FieldAttributerust-analyzer cargo educe 0.6.0 trait_handlers/ord/models/field_attribute/FieldAttribute#)> = |
| 64 | BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V>`]new().(); |
| 65 | |
| 66 | for (index, field) in variant.fieldsrust-analyzer cargo syn 2.0.119 data/Variant#fields..iterrust-analyzer cargo syn 2.0.119 data/impl#[Fields]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() { |
| 67 | let field_attribute = FieldAttributeBuilderrust-analyzer cargo educe 0.6.0 trait_handlers/ord/models/field_attribute/FieldAttributeBuilder# { |
| 68 | enable_ignorerust-analyzer cargo educe 0.6.0 trait_handlers/ord/models/field_attribute/FieldAttributeBuilder#enable_ignore.: true, |
| 69 | enable_methodrust-analyzer cargo educe 0.6.0 trait_handlers/ord/models/field_attribute/FieldAttributeBuilder#enable_method.: true, |
| 70 | enable_rankrust-analyzer cargo educe 0.6.0 trait_handlers/ord/models/field_attribute/FieldAttributeBuilder#enable_rank.: true, |
| 71 | rankrust-analyzer cargo educe 0.6.0 trait_handlers/ord/models/field_attribute/FieldAttributeBuilder#rank.: isize::MINrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[isize]MIN. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][`Add<Self>`]add().index as isize, |
| 72 | } |
| 73 | .build_from_attributesrust-analyzer cargo educe 0.6.0 trait_handlers/ord/models/field_attribute/impl#[FieldAttributeBuilder]build_from_attributes().(&field.attrsrust-analyzer cargo syn 2.0.119 data/Field#attrs., traits)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 74 | |
| 75 | let field_name_real = field.identrust-analyzer cargo syn 2.0.119 data/Field#ident..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 76 | let field_name_var_self = format_identrust-analyzer cargo quote 1.0.47 format/format_ident!!("_s_{}", field_name_real); |
| 77 | let field_name_var_other = format_identrust-analyzer cargo quote 1.0.47 format/format_ident!!("_o_{}", field_name_real); |
| 78 | |
| 79 | if field_attribute.ignorerust-analyzer cargo educe 0.6.0 trait_handlers/ord/models/field_attribute/FieldAttribute#ignore. { |
| 80 | pattern_self_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!!(#field_name_real: _,)); |
| 81 | pattern_other_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!!(#field_name_real: _,)); |
| 82 | |
| 83 | continue; |
| 84 | } |
| 85 | |
| 86 | pattern_self_token_stream |
| 87 | .extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!!(#field_name_real: #field_name_var_self,)); |
| 88 | pattern_other_token_stream |
| 89 | .extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!!(#field_name_real: #field_name_var_other,)); |
| 90 | |
| 91 | let rank = field_attribute.rankrust-analyzer cargo educe 0.6.0 trait_handlers/ord/models/field_attribute/FieldAttribute#rank.; |
| 92 | |
| 93 | if fields.contains_keyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]contains_key().(&rank) { |
| 94 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(superrust-analyzer cargo educe 0.6.0 trait_handlers/ord/::panicrust-analyzer cargo educe 0.6.0 trait_handlers/ord/panic/::reuse_a_rankrust-analyzer cargo educe 0.6.0 trait_handlers/ord/panic/reuse_a_rank().( |
| 95 | field_attribute.rank_spanrust-analyzer cargo educe 0.6.0 trait_handlers/ord/models/field_attribute/FieldAttribute#rank_span..unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_else().(|| field.spanrust-analyzer cargo syn 2.0.119 spanned/impl#[T][Spanned]span().()), |
| 96 | rank, |
| 97 | )); |
| 98 | } |
| 99 | |
| 100 | fields.insertrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]insert().( |
| 101 | rank, |
| 102 | (field, field_name_var_self, field_name_var_other, field_attribute), |
| 103 | ); |
| 104 | } |
| 105 | |
| 106 | for (field, field_name_var_self, field_name_var_other, field_attribute) in |
| 107 | fields.valuesrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]values().() |
| 108 | { |
| 109 | let cmp = field_attribute.methodrust-analyzer cargo educe 0.6.0 trait_handlers/ord/models/field_attribute/FieldAttribute#method..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_else().(|| { |
| 110 | ord_types.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(&field.tyrust-analyzer cargo syn 2.0.119 data/Field#ty.); |
| 111 | |
| 112 | &built_in_cmp |
| 113 | }); |
| 114 | |
| 115 | block_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!! { |
| 116 | match #cmp(#field_name_var_self, #field_name_var_other) { |
| 117 | ::core::cmp::Ordering::Equal => (), |
| 118 | ::core::cmp::Ordering::Greater => return ::core::cmp::Ordering::Greater, |
| 119 | ::core::cmp::Ordering::Less => return ::core::cmp::Ordering::Less, |
| 120 | } |
| 121 | }); |
| 122 | } |
| 123 | |
| 124 | arms_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!! { |
| 125 | Self::#variant_ident { #pattern_self_token_stream } => { |
| 126 | if let Self::#variant_ident { #pattern_other_token_stream } = other { |
| 127 | #block_token_stream |
| 128 | } |
| 129 | } |
| 130 | }); |
| 131 | }, |
| 132 | Fieldsrust-analyzer cargo syn 2.0.119 data/Fields#::Unnamedrust-analyzer cargo syn 2.0.119 data/Fields#Unnamed#(_) => { |
| 133 | all_unit = false; |
| 134 | |
| 135 | let mut pattern_token_stream = proc_macro2rust-analyzer cargo proc-macro2 1.0.107 crate/::TokenStreamrust-analyzer cargo proc-macro2 1.0.107 TokenStream#::newrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream]new().(); |
| 136 | let mut pattern2_token_stream = proc_macro2rust-analyzer cargo proc-macro2 1.0.107 crate/::TokenStreamrust-analyzer cargo proc-macro2 1.0.107 TokenStream#::newrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream]new().(); |
| 137 | let mut block_token_stream = proc_macro2rust-analyzer cargo proc-macro2 1.0.107 crate/::TokenStreamrust-analyzer cargo proc-macro2 1.0.107 TokenStream#::newrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream]new().(); |
| 138 | |
| 139 | let mut fields: BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#<isize, (&Fieldrust-analyzer cargo syn 2.0.119 data/Field#, Identrust-analyzer cargo proc-macro2 1.0.107 Ident#, Identrust-analyzer cargo proc-macro2 1.0.107 Ident#, FieldAttributerust-analyzer cargo educe 0.6.0 trait_handlers/ord/models/field_attribute/FieldAttribute#)> = |
| 140 | BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V>`]new().(); |
| 141 | |
| 142 | for (index, field) in variant.fieldsrust-analyzer cargo syn 2.0.119 data/Variant#fields..iterrust-analyzer cargo syn 2.0.119 data/impl#[Fields]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() { |
| 143 | let field_attribute = FieldAttributeBuilderrust-analyzer cargo educe 0.6.0 trait_handlers/ord/models/field_attribute/FieldAttributeBuilder# { |
| 144 | enable_ignorerust-analyzer cargo educe 0.6.0 trait_handlers/ord/models/field_attribute/FieldAttributeBuilder#enable_ignore.: true, |
| 145 | enable_methodrust-analyzer cargo educe 0.6.0 trait_handlers/ord/models/field_attribute/FieldAttributeBuilder#enable_method.: true, |
| 146 | enable_rankrust-analyzer cargo educe 0.6.0 trait_handlers/ord/models/field_attribute/FieldAttributeBuilder#enable_rank.: true, |
| 147 | rankrust-analyzer cargo educe 0.6.0 trait_handlers/ord/models/field_attribute/FieldAttributeBuilder#rank.: isize::MINrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[isize]MIN. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][`Add<Self>`]add().index as isize, |
| 148 | } |
| 149 | .build_from_attributesrust-analyzer cargo educe 0.6.0 trait_handlers/ord/models/field_attribute/impl#[FieldAttributeBuilder]build_from_attributes().(&field.attrsrust-analyzer cargo syn 2.0.119 data/Field#attrs., traits)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 150 | |
| 151 | let field_name_var_self = format_identrust-analyzer cargo quote 1.0.47 format/format_ident!!("_{}", index); |
| 152 | |
| 153 | if field_attribute.ignorerust-analyzer cargo educe 0.6.0 trait_handlers/ord/models/field_attribute/FieldAttribute#ignore. { |
| 154 | pattern_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!!(_,)); |
| 155 | pattern2_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!!(_,)); |
| 156 | |
| 157 | continue; |
| 158 | } |
| 159 | |
| 160 | let field_name_var_other = format_identrust-analyzer cargo quote 1.0.47 format/format_ident!!("_{}", field_name_var_self); |
| 161 | |
| 162 | pattern_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!!(#field_name_var_self,)); |
| 163 | pattern2_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!!(#field_name_var_other,)); |
| 164 | |
| 165 | let rank = field_attribute.rankrust-analyzer cargo educe 0.6.0 trait_handlers/ord/models/field_attribute/FieldAttribute#rank.; |
| 166 | |
| 167 | if fields.contains_keyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]contains_key().(&rank) { |
| 168 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(superrust-analyzer cargo educe 0.6.0 trait_handlers/ord/::panicrust-analyzer cargo educe 0.6.0 trait_handlers/ord/panic/::reuse_a_rankrust-analyzer cargo educe 0.6.0 trait_handlers/ord/panic/reuse_a_rank().( |
| 169 | field_attribute.rank_spanrust-analyzer cargo educe 0.6.0 trait_handlers/ord/models/field_attribute/FieldAttribute#rank_span..unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_else().(|| field.spanrust-analyzer cargo syn 2.0.119 spanned/impl#[T][Spanned]span().()), |
| 170 | rank, |
| 171 | )); |
| 172 | } |
| 173 | |
| 174 | fields.insertrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]insert().( |
| 175 | rank, |
| 176 | (field, field_name_var_self, field_name_var_other, field_attribute), |
| 177 | ); |
| 178 | } |
| 179 | |
| 180 | for (field, field_name, field_name2, field_attribute) in fields.valuesrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]values().() { |
| 181 | let cmp = field_attribute.methodrust-analyzer cargo educe 0.6.0 trait_handlers/ord/models/field_attribute/FieldAttribute#method..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_else().(|| { |
| 182 | ord_types.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(&field.tyrust-analyzer cargo syn 2.0.119 data/Field#ty.); |
| 183 | |
| 184 | &built_in_cmp |
| 185 | }); |
| 186 | |
| 187 | block_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!! { |
| 188 | match #cmp(#field_name, #field_name2) { |
| 189 | ::core::cmp::Ordering::Equal => (), |
| 190 | ::core::cmp::Ordering::Greater => return ::core::cmp::Ordering::Greater, |
| 191 | ::core::cmp::Ordering::Less => return ::core::cmp::Ordering::Less, |
| 192 | } |
| 193 | }); |
| 194 | } |
| 195 | |
| 196 | arms_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!! { |
| 197 | Self::#variant_ident ( #pattern_token_stream ) => { |
| 198 | if let Self::#variant_ident ( #pattern2_token_stream ) = other { |
| 199 | #block_token_stream |
| 200 | } |
| 201 | } |
| 202 | }); |
| 203 | }, |
| 204 | } |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | if arms_token_stream.is_emptyrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream]is_empty().() { |
| 209 | cmp_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!!(::core::cmp::Ordering::Equal)); |
| 210 | } else { |
| 211 | let discriminant_cmp = quoterust-analyzer cargo quote 1.0.47 quote!! { |
| 212 | unsafe { |
| 213 | ::core::cmp::Ord::cmp(&*<*const _>::from(self).cast::<#discriminant_type>(), &*<*const _>::from(other).cast::<#discriminant_type>()) |
| 214 | } |
| 215 | }; |
| 216 | |
| 217 | cmp_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(if all_unit { |
| 218 | quoterust-analyzer cargo quote 1.0.47 quote!! { |
| 219 | match #discriminant_cmp { |
| 220 | ::core::cmp::Ordering::Equal => ::core::cmp::Ordering::Equal, |
| 221 | ::core::cmp::Ordering::Greater => ::core::cmp::Ordering::Greater, |
| 222 | ::core::cmp::Ordering::Less => ::core::cmp::Ordering::Less, |
| 223 | } |
| 224 | } |
| 225 | } else { |
| 226 | quoterust-analyzer cargo quote 1.0.47 quote!! { |
| 227 | match #discriminant_cmp { |
| 228 | ::core::cmp::Ordering::Equal => { |
| 229 | match self { |
| 230 | #arms_token_stream |
| 231 | } |
| 232 | |
| 233 | ::core::cmp::Ordering::Equal |
| 234 | }, |
| 235 | ::core::cmp::Ordering::Greater => ::core::cmp::Ordering::Greater, |
| 236 | ::core::cmp::Ordering::Less => ::core::cmp::Ordering::Less, |
| 237 | } |
| 238 | } |
| 239 | }); |
| 240 | } |
| 241 | |
| 242 | let ident = &ast.identrust-analyzer cargo syn 2.0.119 derive/DeriveInput#ident.; |
| 243 | |
| 244 | let bound = type_attribute.boundrust-analyzer cargo educe 0.6.0 trait_handlers/ord/models/type_attribute/TypeAttribute#bound..into_where_predicates_by_generic_parameters_check_typesrust-analyzer cargo educe 0.6.0 common/bound/impl#[Bound]into_where_predicates_by_generic_parameters_check_types().( |
| 245 | &ast.genericsrust-analyzer cargo syn 2.0.119 derive/DeriveInput#generics..paramsrust-analyzer cargo syn 2.0.119 generics/Generics#params., |
| 246 | &synrust-analyzer cargo syn 2.0.119 crate/::parse2rust-analyzer cargo syn 2.0.119 parse2().(quoterust-analyzer cargo quote 1.0.47 quote!!(::core::cmp::Ord)).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 247 | &ord_types, |
| 248 | &craterust-analyzer cargo educe 0.6.0 crate/::trait_handlersrust-analyzer cargo educe 0.6.0 trait_handlers/::ordrust-analyzer cargo educe 0.6.0 trait_handlers/ord/::supertraitsrust-analyzer cargo educe 0.6.0 trait_handlers/ord/supertraits().(traits), |
| 249 | ); |
| 250 | |
| 251 | let mut generics = ast.genericsrust-analyzer cargo syn 2.0.119 derive/DeriveInput#generics..clonerust-analyzer cargo syn 2.0.119 gen/clone/impl#[`crate::Generics`][Clone]clone().(); |
| 252 | let where_clause = generics.make_where_clauserust-analyzer cargo syn 2.0.119 generics/impl#[Generics]make_where_clause().(); |
| 253 | |
| 254 | for where_predicate in bound { |
| 255 | where_clause.predicatesrust-analyzer cargo syn 2.0.119 generics/WhereClause#predicates..pushrust-analyzer cargo syn 2.0.119 punctuated/impl#[`Punctuated<T, P>`]push().(where_predicate); |
| 256 | } |
| 257 | |
| 258 | let (impl_generics, ty_generics, where_clause) = generics.split_for_implrust-analyzer cargo syn 2.0.119 generics/impl#[Generics]split_for_impl().(); |
| 259 | |
| 260 | token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!! { |
| 261 | impl #impl_generics ::core::cmp::Ord for #ident #ty_generics #where_clause { |
| 262 | #[inline] |
| 263 | fn cmp(&self, other: &Self) -> ::core::cmp::Ordering { |
| 264 | #cmp_token_stream |
| 265 | } |
| 266 | } |
| 267 | }); |
| 268 | |
| 269 | #[cfg(feature = "PartialOrd")] |
| 270 | if traits.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&Traitrust-analyzer cargo educe 0.6.0 supported_traits/Trait#::PartialOrdrust-analyzer cargo educe 0.6.0 supported_traits/Trait#PartialOrd#) { |
| 271 | token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!! { |
| 272 | impl #impl_generics ::core::cmp::PartialOrd for #ident #ty_generics #where_clause { |
| 273 | #[inline] |
| 274 | fn partial_cmp(&self, other: &Self) -> Option<::core::cmp::Ordering> { |
| 275 | Some(::core::cmp::Ord::cmp(self, other)) |
| 276 | } |
| 277 | } |
| 278 | }); |
| 279 | } |
| 280 | |
| 281 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 282 | } |
| 283 | } |