| 1 | use quoterust-analyzer cargo quote 1.0.47 crate/::quoterust-analyzer cargo quote 1.0.47 quote!; |
| 2 | use synrust-analyzer cargo syn 2.0.119 crate/::{Datarust-analyzer cargo syn 2.0.119 derive/Data#, DeriveInputrust-analyzer cargo syn 2.0.119 derive/DeriveInput#, Metarust-analyzer cargo syn 2.0.119 attr/Meta#}; |
| 3 | |
| 4 | use superrust-analyzer cargo educe 0.6.0 trait_handlers/clone/::{ |
| 5 | modelsrust-analyzer cargo educe 0.6.0 trait_handlers/clone/models/::{FieldAttributeBuilderrust-analyzer cargo educe 0.6.0 trait_handlers/clone/models/field_attribute/FieldAttributeBuilder#, TypeAttributeBuilderrust-analyzer cargo educe 0.6.0 trait_handlers/clone/models/type_attribute/TypeAttributeBuilder#}, |
| 6 | TraitHandlerrust-analyzer cargo educe 0.6.0 trait_handlers/TraitHandler#, |
| 7 | }; |
| 8 | use craterust-analyzer cargo educe 0.6.0 crate/::supported_traitsrust-analyzer cargo educe 0.6.0 supported_traits/::Traitrust-analyzer cargo educe 0.6.0 supported_traits/Trait#; |
| 9 | |
| 10 | pub(craterust-analyzer cargo educe 0.6.0 crate/) struct CloneUnionHandlerrust-analyzer cargo educe 0.6.0 trait_handlers/clone/clone_union/CloneUnionHandler#; |
| 11 | |
| 12 | impl TraitHandlerrust-analyzer cargo educe 0.6.0 trait_handlers/TraitHandler# for CloneUnionHandlerrust-analyzer cargo educe 0.6.0 trait_handlers/clone/clone_union/CloneUnionHandler# { |
| 13 | fn trait_meta_handlerrust-analyzer cargo educe 0.6.0 trait_handlers/clone/clone_union/impl#[CloneUnionHandler][TraitHandler]trait_meta_handler().( |
| 14 | ast: &DeriveInputrust-analyzer cargo syn 2.0.119 derive/DeriveInput#, |
| 15 | token_stream: &mut proc_macro2rust-analyzer cargo proc-macro2 1.0.107 crate/::TokenStreamrust-analyzer cargo proc-macro2 1.0.107 TokenStream#, |
| 16 | traits: &[Traitrust-analyzer cargo educe 0.6.0 supported_traits/Trait#], |
| 17 | meta: &Metarust-analyzer cargo syn 2.0.119 attr/Meta#, |
| 18 | ) -> synrust-analyzer cargo syn 2.0.119 crate/::Resultrust-analyzer cargo syn 2.0.119 error/Result#<()> { |
| 19 | let type_attribute = TypeAttributeBuilderrust-analyzer cargo educe 0.6.0 trait_handlers/clone/models/type_attribute/TypeAttributeBuilder# { |
| 20 | enable_flagrust-analyzer cargo educe 0.6.0 trait_handlers/clone/models/type_attribute/TypeAttributeBuilder#enable_flag.: true, enable_boundrust-analyzer cargo educe 0.6.0 trait_handlers/clone/models/type_attribute/TypeAttributeBuilder#enable_bound.: true |
| 21 | } |
| 22 | .build_from_clone_metarust-analyzer cargo educe 0.6.0 trait_handlers/clone/models/type_attribute/impl#[TypeAttributeBuilder]build_from_clone_meta().(meta)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 23 | |
| 24 | let mut field_types = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![]; |
| 25 | |
| 26 | if let Datarust-analyzer cargo syn 2.0.119 derive/Data#::Unionrust-analyzer cargo syn 2.0.119 derive/Data#Union#(data) = &ast.datarust-analyzer cargo syn 2.0.119 derive/DeriveInput#data. { |
| 27 | for field in data.fieldsrust-analyzer cargo syn 2.0.119 derive/DataUnion#fields..namedrust-analyzer cargo syn 2.0.119 data/FieldsNamed#named..iterrust-analyzer cargo syn 2.0.119 punctuated/impl#[`Punctuated<T, P>`]iter().() { |
| 28 | field_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.); |
| 29 | let _ = FieldAttributeBuilderrust-analyzer cargo educe 0.6.0 trait_handlers/clone/models/field_attribute/FieldAttributeBuilder# { |
| 30 | enable_methodrust-analyzer cargo educe 0.6.0 trait_handlers/clone/models/field_attribute/FieldAttributeBuilder#enable_method.: false |
| 31 | } |
| 32 | .build_from_attributesrust-analyzer cargo educe 0.6.0 trait_handlers/clone/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().; |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | let ident = &ast.identrust-analyzer cargo syn 2.0.119 derive/DeriveInput#ident.; |
| 37 | |
| 38 | let bound = type_attribute.boundrust-analyzer cargo educe 0.6.0 trait_handlers/clone/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().( |
| 39 | &ast.genericsrust-analyzer cargo syn 2.0.119 derive/DeriveInput#generics..paramsrust-analyzer cargo syn 2.0.119 generics/Generics#params., |
| 40 | &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::marker::Copy)).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 41 | &field_types, |
| 42 | &[], |
| 43 | ); |
| 44 | |
| 45 | 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().(); |
| 46 | let where_clause = generics.make_where_clauserust-analyzer cargo syn 2.0.119 generics/impl#[Generics]make_where_clause().(); |
| 47 | |
| 48 | for where_predicate in bound { |
| 49 | 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); |
| 50 | } |
| 51 | |
| 52 | let (impl_generics, ty_generics, where_clause) = generics.split_for_implrust-analyzer cargo syn 2.0.119 generics/impl#[Generics]split_for_impl().(); |
| 53 | |
| 54 | token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!! { |
| 55 | impl #impl_generics ::core::clone::Clone for #ident #ty_generics #where_clause { |
| 56 | #[inline] |
| 57 | fn clone(&self) -> Self { |
| 58 | *self |
| 59 | } |
| 60 | } |
| 61 | }); |
| 62 | |
| 63 | #[cfg(feature = "Copy")] |
| 64 | 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#::Copyrust-analyzer cargo educe 0.6.0 supported_traits/Trait#Copy#) { |
| 65 | token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!! { |
| 66 | impl #impl_generics ::core::marker::Copy for #ident #ty_generics #where_clause { |
| 67 | } |
| 68 | }); |
| 69 | } |
| 70 | |
| 71 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 72 | } |
| 73 | } |