From 033e7d5533c0ebd858558d3d0ce5e27428a814e0 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Mon, 30 Nov 2026 20:09:27 +0000 Subject: [PATCH 01/20] Update tests --- .../out/refcount/cross_tu_tag_collision.rs | 15 +- .../out/unsafe/cross_tu_tag_collision.rs | 13 +- .../out/refcount/defaulted_move_cross_tu.rs | 64 ++-- .../out/unsafe/defaulted_move_cross_tu.rs | 36 +- .../out/refcount/friend_operator.rs | 15 +- .../out/unsafe/friend_operator.rs | 13 +- .../out/refcount/opaque_forward_decl.rs | 14 +- .../out/unsafe/opaque_forward_decl.rs | 13 +- .../refcount/out_of_line_methods_cross_tu.rs | 45 ++- .../unsafe/out_of_line_methods_cross_tu.rs | 39 +- .../template_method_late_instantiation.rs | 14 +- .../template_method_late_instantiation.rs | 12 +- .../out/refcount/p14-class-in-two-files.rs | 63 +++- .../out/unsafe/p14-class-in-two-files.rs | 51 ++- .../p15-class-template-static-member.rs | 63 +++- .../p15-class-template-static-member.rs | 51 ++- .../out/refcount/p15-function-template.rs | 78 +++- .../out/unsafe/p15-function-template.rs | 64 +++- .../out/refcount/p15-inline-function.rs | 48 ++- .../out/unsafe/p15-inline-function.rs | 38 +- .../out/refcount/p15-inline-variable.rs | 48 ++- .../out/unsafe/p15-inline-variable.rs | 38 +- .../p16-default-argument-lambda-in-class.rs | 63 +++- .../p16-default-argument-lambda-in-class.rs | 51 ++- .../refcount/p16-lambda-in-inline-function.rs | 48 ++- .../unsafe/p16-lambda-in-inline-function.rs | 38 +- .../basic.link/out/refcount/basic.link.rs | 139 ++++++- .../basic/basic.link/out/unsafe/basic.link.rs | 123 ++++++- .../out/refcount/basic.scope.block.rs | 48 ++- .../out/refcount/basic.scope.class.rs | 28 +- .../out/refcount/basic.scope.param.rs | 16 +- .../out/refcount/basic.scope.pdecl.rs | 27 +- .../out/refcount/basic.scope.scope.rs | 212 ++++++++++- .../out/unsafe/basic.scope.block.rs | 38 +- .../out/unsafe/basic.scope.class.rs | 24 +- .../out/unsafe/basic.scope.param.rs | 14 +- .../out/unsafe/basic.scope.pdecl.rs | 25 +- .../out/unsafe/basic.scope.scope.rs | 189 +++++++++- .../out/refcount/basic.start.term-p1-exit.rs | 15 +- .../out/refcount/basic.start.term.rs | 60 ++- .../out/unsafe/basic.start.term-p1-exit.rs | 13 +- .../out/unsafe/basic.start.term.rs | 52 ++- .../out/refcount/basic.types.general.rs | 30 +- .../out/unsafe/basic.types.general.rs | 26 +- tests/std/basic/out/refcount/basic.def.odr.rs | 276 +++++++++----- tests/std/basic/out/unsafe/basic.def.odr.rs | 172 +++++++-- .../out/refcount/class.base.init.rs | 16 +- .../class.init/out/unsafe/class.base.init.rs | 14 +- .../out/refcount/class.conv.ctor.rs | 16 +- .../class.conv/out/refcount/class.conv.fct.rs | 16 +- .../class.conv/out/unsafe/class.conv.ctor.rs | 14 +- .../class.conv/out/unsafe/class.conv.fct.rs | 14 +- .../out/refcount/class.copy.ctor.rs | 16 +- .../class.ctor/out/unsafe/class.copy.ctor.rs | 8 +- .../class.mem/out/refcount/class.free.rs | 30 +- .../out/refcount/class.mem.general.rs | 28 +- .../class/class.mem/out/unsafe/class.free.rs | 26 +- .../class.mem/out/unsafe/class.mem.general.rs | 24 +- .../dcl.init.general-p6.2-padding-bits.rs | 45 ++- .../dcl.init/out/refcount/dcl.init.general.rs | 126 ++++++- .../dcl.init.general-p6.2-padding-bits.rs | 39 +- .../dcl.init/out/unsafe/dcl.init.general.rs | 113 +++++- .../dcl.meaning/out/refcount/dcl.array.rs | 15 +- .../out/refcount/dcl.fct.default.rs | 58 ++- .../dcl.meaning/out/refcount/dcl.mptr.rs | 72 +++- .../dcl.meaning/out/unsafe/dcl.array.rs | 13 +- .../dcl.meaning/out/unsafe/dcl.fct.default.rs | 50 ++- .../dcl.meaning/out/unsafe/dcl.mptr.rs | 64 +++- tests/std/expr/conv/out/refcount/conv.mem.rs | 15 +- tests/std/expr/conv/out/unsafe/conv.mem.rs | 13 +- .../expr.post/out/refcount/expr.const.cast.rs | 15 +- ...nterpret.cast-p10-result-is-unspecified.rs | 30 +- .../out/refcount/expr.reinterpret.cast.rs | 60 ++- .../expr.post/out/unsafe/expr.const.cast.rs | 13 +- ...nterpret.cast-p10-result-is-unspecified.rs | 26 +- .../out/unsafe/expr.reinterpret.cast.rs | 52 ++- .../expr.unary/out/refcount/expr.pre.incr.rs | 15 +- .../expr.unary/out/refcount/expr.unary.op.rs | 45 ++- .../expr.unary/out/unsafe/expr.pre.incr.rs | 13 +- .../expr.unary/out/unsafe/expr.unary.op.rs | 39 +- .../expr.compound/out/refcount/expr.cond.rs | 15 +- .../expr.compound/out/refcount/expr.eq.rs | 57 ++- ...ptr.oper-p6-null-pointer-to-data-member.rs | 15 +- .../out/refcount/expr.mptr.oper.rs | 128 ++++--- .../expr.compound/out/unsafe/expr.cond.rs | 13 +- .../expr/expr.compound/out/unsafe/expr.eq.rs | 51 ++- ...ptr.oper-p6-null-pointer-to-data-member.rs | 13 +- .../out/unsafe/expr.mptr.oper.rs | 79 +++- .../expr.prim/out/refcount/expr.prim.this.rs | 29 +- .../expr.prim/out/unsafe/expr.prim.this.rs | 27 +- .../allocator.requirements.general.rs | 44 ++- .../unsafe/allocator.requirements.general.rs | 38 +- .../stmt.iter/out/refcount/stmt.while.rs | 28 +- .../stmt.iter/out/unsafe/stmt.while.rs | 24 +- .../stmt.select/out/refcount/stmt.if.rs | 33 +- .../stmt.select/out/refcount/stmt.switch.rs | 47 ++- .../stmt.select/out/unsafe/stmt.if.rs | 25 +- .../stmt.select/out/unsafe/stmt.switch.rs | 37 +- tests/std/temp/out/refcount/temp.type.rs | 60 ++- tests/std/temp/out/unsafe/temp.type.rs | 52 ++- .../temp/temp.spec/out/refcount/temp.inst.rs | 27 +- .../temp/temp.spec/out/unsafe/temp.inst.rs | 18 +- .../utility/out/refcount/forward-helpers.rs | 162 +++++--- .../utilities/utility/out/refcount/forward.rs | 28 +- .../utility/out/refcount/utility.as.const.rs | 15 +- .../utility/out/unsafe/forward-helpers.rs | 118 ++++-- .../utilities/utility/out/unsafe/forward.rs | 23 +- .../utility/out/unsafe/utility.as.const.rs | 13 +- tests/ub/out/refcount/ctor_ref_member.rs | 15 +- .../refcount/self_referencing_initializer.rs | 15 +- tests/ub/out/refcount/ub6.rs | 14 +- tests/ub/out/unsafe/ctor_ref_member.rs | 14 +- .../unsafe/self_referencing_initializer.rs | 13 +- tests/ub/out/unsafe/ub6.rs | 13 +- tests/unit/out/refcount/05_new.rs | 30 +- tests/unit/out/refcount/10_struct.rs | 70 +++- tests/unit/out/refcount/addr_of_global.rs | 29 +- tests/unit/out/refcount/anonymous-struct.rs | 135 ++++++- tests/unit/out/refcount/anonymous-struct_c.rs | 135 ++++++- tests/unit/out/refcount/anonymous_enum.rs | 30 +- tests/unit/out/refcount/anonymous_enum_c.rs | 30 +- tests/unit/out/refcount/any.rs | 15 +- tests/unit/out/refcount/array_const_init.rs | 28 +- tests/unit/out/refcount/array_field_addr.rs | 13 +- .../out/refcount/array_of_noncopy_struct.rs | 28 +- tests/unit/out/refcount/array_reference.rs | 15 +- tests/unit/out/refcount/as_const.rs | 15 +- tests/unit/out/refcount/assign_rhs_first.rs | 14 +- .../out/refcount/assignment_single_eval.rs | 304 +++++++++++++-- tests/unit/out/refcount/bounded_struct_ptr.rs | 15 +- tests/unit/out/refcount/bst.rs | 14 +- tests/unit/out/refcount/c_struct.rs | 74 +++- tests/unit/out/refcount/cast.rs | 77 +++- .../refcount/cast_array_to_pointer_decay.rs | 13 +- tests/unit/out/refcount/class.rs | 60 ++- .../refcount/class_template_lazy_member.rs | 75 +++- tests/unit/out/refcount/class_templates.rs | 219 +++++++++-- tests/unit/out/refcount/clone_vs_move.rs | 42 ++- tests/unit/out/refcount/comma_operator.rs | 15 +- tests/unit/out/refcount/complex_function.rs | 57 ++- .../out/refcount/compound_assign_paren.rs | 15 +- tests/unit/out/refcount/concepts.rs | 15 +- tests/unit/out/refcount/constexpr_function.rs | 30 +- tests/unit/out/refcount/constructor.rs | 29 +- .../refcount/container_element_receiver.rs | 24 +- .../unit/out/refcount/container_field_addr.rs | 34 +- .../conversion_operator_same_translation.rs | 32 +- tests/unit/out/refcount/copy_assign.rs | 183 ++++++--- tests/unit/out/refcount/copy_ctor.rs | 240 +++++++----- .../unit/out/refcount/copy_move_defaulted.rs | 285 +++++++------- tests/unit/out/refcount/copy_move_deleted.rs | 98 +++-- tests/unit/out/refcount/default.rs | 39 +- .../refcount/default_function_arguments.rs | 30 +- tests/unit/out/refcount/default_in_statics.rs | 41 ++- tests/unit/out/refcount/delete_array_order.rs | 15 +- tests/unit/out/refcount/destructor.rs | 164 ++++++++- tests/unit/out/refcount/destructor_params.rs | 30 +- .../out/refcount/destructor_temporaries.rs | 30 +- tests/unit/out/refcount/doubly_linked_list.rs | 14 +- .../out/refcount/enum_default_in_static.rs | 15 +- tests/unit/out/refcount/enum_int_interop.rs | 14 +- tests/unit/out/refcount/enum_int_interop_c.rs | 14 +- .../unit/out/refcount/enum_underlying_type.rs | 14 +- tests/unit/out/refcount/exprs.rs | 29 +- tests/unit/out/refcount/fft.rs | 15 +- tests/unit/out/refcount/field_aliasing.rs | 42 ++- .../unit/out/refcount/field_array_elem_ptr.rs | 28 +- .../out/refcount/field_method_receiver.rs | 53 ++- tests/unit/out/refcount/field_pointers.rs | 78 ++-- .../field_pointers_malloced_struct.rs | 15 +- .../field_reinterpret_write_through.rs | 28 +- tests/unit/out/refcount/find.rs | 15 +- .../refcount/first_field_ptr_covers_struct.rs | 30 +- .../out/refcount/first_member_downcast.rs | 30 +- .../refcount/flex_array_member_incomplete.rs | 13 +- .../flex_array_member_sibling_write.rs | 41 ++- tests/unit/out/refcount/fn_ptr.rs | 15 +- tests/unit/out/refcount/fn_ptr_cast.rs | 14 +- tests/unit/out/refcount/fn_ptr_stable_sort.rs | 15 +- tests/unit/out/refcount/fn_ptr_struct.rs | 44 ++- .../unit/out/refcount/fn_ptr_typedef_cast.rs | 15 +- tests/unit/out/refcount/fn_ptr_vtable.rs | 14 +- tests/unit/out/refcount/fn_ref.rs | 14 +- .../unit/out/refcount/for_body_destructor.rs | 15 +- .../refcount/foreach_disjoint_field_borrow.rs | 34 +- tests/unit/out/refcount/forward_basic.rs | 61 ++- tests/unit/out/refcount/forward_decltype.rs | 36 +- tests/unit/out/refcount/forward_explicit.rs | 42 ++- tests/unit/out/refcount/forward_pack.rs | 66 ++-- tests/unit/out/refcount/friend.rs | 60 ++- .../unit/out/refcount/function_overloading.rs | 15 +- .../out/refcount/global_call_temporaries.rs | 15 +- .../out/refcount/global_init_side_effect.rs | 16 +- .../out/refcount/global_non_const_init.rs | 43 ++- tests/unit/out/refcount/global_pointers.rs | 14 +- .../refcount/global_without_initializer.rs | 15 +- .../out/refcount/goto_aggregate_default.rs | 15 +- tests/unit/out/refcount/goto_cleanup.rs | 14 +- tests/unit/out/refcount/huffman.rs | 60 +-- .../refcount/immutable-deref-on-func-call.rs | 15 +- tests/unit/out/refcount/implicit_autoref.rs | 30 +- .../refcount/in_class_field_initializer.rs | 42 ++- tests/unit/out/refcount/init.rs | 15 +- tests/unit/out/refcount/init_list.rs | 43 ++- .../out/refcount/inline_container_fields.rs | 208 ++++++----- tests/unit/out/refcount/kruskal.rs | 77 ++-- tests/unit/out/refcount/lambda_as_field.rs | 71 +++- .../out/refcount/lambda_capture_copy_ctor.rs | 55 ++- tests/unit/out/refcount/lambda_capture_ref.rs | 15 +- .../out/refcount/lambda_capture_star_this.rs | 15 +- .../unit/out/refcount/lambda_capture_this.rs | 15 +- .../unit/out/refcount/lambda_capture_value.rs | 15 +- .../unit/out/refcount/lambda_decltype_type.rs | 26 +- .../refcount/lambda_generic_explicit_args.rs | 15 +- .../out/refcount/lambda_immediate_init.rs | 14 +- .../out/refcount/lambda_move_only_capture.rs | 19 +- tests/unit/out/refcount/lambda_nested.rs | 15 +- .../unit/out/refcount/lambda_static_local.rs | 15 +- .../refcount/libc_struct_without_default.rs | 65 ++-- tests/unit/out/refcount/linked_list.rs | 14 +- .../refcount/local_anon_struct_collision.rs | 30 +- .../out/refcount/local_record_template.rs | 60 ++- tests/unit/out/refcount/map.rs | 14 +- tests/unit/out/refcount/map_key_copy_ctor.rs | 34 +- tests/unit/out/refcount/map_key_identity.rs | 29 +- tests/unit/out/refcount/map_try_emplace.rs | 58 ++- .../out/refcount/map_try_emplace_lvalues.rs | 77 +++- tests/unit/out/refcount/max.rs | 32 +- .../unit/out/refcount/memcpy_struct_bytes.rs | 15 +- .../out/refcount/memcpy_struct_layouts.rs | 73 +++- .../unit/out/refcount/memcpy_struct_struct.rs | 15 +- tests/unit/out/refcount/memset_struct_tail.rs | 13 +- tests/unit/out/refcount/move_assign.rs | 44 +-- tests/unit/out/refcount/move_ctor.rs | 99 +++-- tests/unit/out/refcount/move_this.rs | 42 ++- tests/unit/out/refcount/nested_structs.rs | 90 ++++- tests/unit/out/refcount/new.rs | 15 +- tests/unit/out/refcount/new_bst.rs | 14 +- tests/unit/out/refcount/new_struct.rs | 30 +- .../refcount/nttp_distinct_specializations.rs | 45 ++- tests/unit/out/refcount/offsetof.rs | 28 +- .../unit/out/refcount/opaque_forward_decl.rs | 14 +- tests/unit/out/refcount/opaque_record_copy.rs | 30 +- .../unit/out/refcount/opaque_then_defined.rs | 28 +- .../out/refcount/operator_arithmetic_free.rs | 15 +- .../refcount/operator_arithmetic_member.rs | 15 +- .../out/refcount/operator_bitwise_free.rs | 15 +- .../out/refcount/operator_bitwise_member.rs | 15 +- .../refcount/operator_comparison_defaulted.rs | 119 +++++- .../out/refcount/operator_comparison_free.rs | 30 +- .../refcount/operator_comparison_member.rs | 15 +- .../out/refcount/operator_comparison_mixed.rs | 15 +- .../refcount/operator_comparison_nonbool.rs | 106 +++++- .../operator_comparison_noncopyable.rs | 9 +- .../operator_compound_assignment_free.rs | 15 +- .../operator_compound_assignment_member.rs | 15 +- tests/unit/out/refcount/operator_friend.rs | 105 +++++- tests/unit/out/refcount/operator_less_than.rs | 15 +- .../out/refcount/operator_logical_free.rs | 15 +- .../out/refcount/operator_logical_member.rs | 15 +- .../refcount/operator_member_pointer_free.rs | 28 +- .../operator_member_pointer_member.rs | 43 ++- .../unit/out/refcount/operator_other_free.rs | 15 +- .../out/refcount/operator_other_member.rs | 31 +- tests/unit/out/refcount/operator_overloads.rs | 15 +- .../unit/out/refcount/operator_qualifiers.rs | 15 +- tests/unit/out/refcount/operator_three_way.rs | 15 +- tests/unit/out/refcount/operator_traits.rs | 75 +++- tests/unit/out/refcount/overload_mangling.rs | 45 ++- .../refcount/pair_converting_construction.rs | 158 +++++++- tests/unit/out/refcount/pod.rs | 15 +- tests/unit/out/refcount/pointer_array.rs | 13 +- tests/unit/out/refcount/pointers.rs | 15 +- tests/unit/out/refcount/polymorphism.rs | 30 +- tests/unit/out/refcount/ptr_cast_init.rs | 30 +- tests/unit/out/refcount/push_emplace_back.rs | 138 +++++-- tests/unit/out/refcount/random.rs | 28 +- tests/unit/out/refcount/reference_wrapper.rs | 15 +- tests/unit/out/refcount/references.rs | 27 +- tests/unit/out/refcount/refs_as_args.rs | 15 +- .../out/refcount/reinterpret_cast_ptr_cmp.rs | 41 ++- .../out/refcount/reinterpret_cast_struct.rs | 15 +- .../reinterpret_cast_struct_to_struct.rs | 30 +- tests/unit/out/refcount/reserved_keywords.rs | 45 ++- tests/unit/out/refcount/return_move.rs | 28 +- tests/unit/out/refcount/rule_of_five.rs | 91 +++-- tests/unit/out/refcount/rule_of_three.rs | 52 +-- .../unit/out/refcount/rvalue_rule_arg_move.rs | 31 +- tests/unit/out/refcount/rvalue_struct.rs | 15 +- .../scalar_builtin_construct_destruct.rs | 15 +- .../refcount/self_referencing_initializer.rs | 41 ++- .../unit/out/refcount/size_t_static_member.rs | 30 +- .../out/refcount/size_t_template_param.rs | 32 +- tests/unit/out/refcount/sort_no_copy.rs | 90 ++--- tests/unit/out/refcount/static_local.rs | 15 +- .../unit/out/refcount/static_var_in_class.rs | 30 +- tests/unit/out/refcount/stdcopy.rs | 16 +- tests/unit/out/refcount/strdup.rs | 14 +- .../out/refcount/string_literal_ptr_init.rs | 14 +- tests/unit/out/refcount/string_substr.rs | 14 +- .../out/refcount/struct_2d_array_field.rs | 13 +- tests/unit/out/refcount/struct_ctor.rs | 45 ++- .../unit/out/refcount/struct_default_ctor.rs | 56 ++- .../refcount/struct_member_array_adjacency.rs | 13 +- tests/unit/out/refcount/struct_ptr.rs | 15 +- .../refcount/structured_binding_copy_ctor.rs | 37 +- .../structured_binding_element_ctor.rs | 58 ++- .../refcount/structured_binding_move_ctor.rs | 58 +-- .../refcount/structured_binding_range_for.rs | 15 +- .../out/refcount/structured_binding_ref.rs | 15 +- .../refcount/structured_binding_trivial.rs | 15 +- tests/unit/out/refcount/swap_map_no_copy.rs | 348 +++++++++--------- .../refcount/tag_vs_identifier_collision.rs | 99 ++++- .../unit/out/refcount/template_default_arg.rs | 61 ++- .../out/refcount/template_static_member.rs | 75 +++- .../unit/out/refcount/temporary_field_addr.rs | 72 ++-- .../out/refcount/temporary_field_ctor_arg.rs | 46 ++- .../out/refcount/temporary_field_two_args.rs | 66 ++-- tests/unit/out/refcount/this.rs | 31 +- .../unit/out/refcount/typedef-anon-struct.rs | 45 ++- .../out/refcount/unary_expr_or_type_trait.rs | 15 +- tests/unit/out/refcount/unboxed_locals.rs | 29 +- tests/unit/out/refcount/unboxed_records.rs | 42 ++- .../out/refcount/union_addrof_external.rs | 39 +- tests/unit/out/refcount/union_basic.rs | 48 ++- .../unit/out/refcount/union_cross_arm_cast.rs | 52 ++- .../out/refcount/union_field_alignment.rs | 26 +- .../out/refcount/union_flex_array_member.rs | 26 +- .../unit/out/refcount/union_memset_memcpy.rs | 52 ++- tests/unit/out/refcount/union_nested.rs | 65 +++- .../out/refcount/union_pointer_pun_address.rs | 41 ++- .../union_pointer_pun_writethrough.rs | 12 +- .../out/refcount/union_struct_dual_use.rs | 41 ++- .../out/refcount/union_tagged_many_arms.rs | 26 +- .../unit/out/refcount/union_tagged_simple.rs | 26 +- .../out/refcount/union_tagged_struct_arms.rs | 70 +++- .../refcount/union_void_ptr_sized_deref.rs | 26 +- tests/unit/out/refcount/unique_ptr.rs | 37 +- .../out/refcount/unique_ptr_const_deref.rs | 24 +- .../out/refcount/unique_ptr_field_reset.rs | 41 ++- tests/unit/out/refcount/unique_ptr_nested.rs | 39 +- tests/unit/out/refcount/unique_ptr_struct.rs | 15 +- tests/unit/out/refcount/va_arg_mixed_types.rs | 15 +- .../out/refcount/va_arg_non_primitive_ptrs.rs | 14 +- tests/unit/out/refcount/va_arg_struct_ctx.rs | 27 +- tests/unit/out/refcount/va_arg_void_ptr.rs | 14 +- tests/unit/out/refcount/va_list_field.rs | 28 +- tests/unit/out/refcount/vector.rs | 49 ++- .../out/refcount/vector_iter_range_ctor.rs | 32 +- .../out/refcount/vector_subscript_direct.rs | 49 ++- .../out/refcount/vector_with_allocator.rs | 30 +- tests/unit/out/refcount/void_cast.rs | 67 ++-- tests/unit/out/unsafe/05_new.rs | 26 +- tests/unit/out/unsafe/10_struct.rs | 64 +++- tests/unit/out/unsafe/addr_of_global.rs | 26 +- tests/unit/out/unsafe/anonymous-struct.rs | 117 +++++- tests/unit/out/unsafe/anonymous-struct_c.rs | 117 +++++- tests/unit/out/unsafe/anonymous_enum.rs | 26 +- tests/unit/out/unsafe/anonymous_enum_c.rs | 26 +- tests/unit/out/unsafe/any.rs | 13 +- tests/unit/out/unsafe/array_const_init.rs | 26 +- tests/unit/out/unsafe/array_field_addr.rs | 13 +- .../out/unsafe/array_of_noncopy_struct.rs | 12 +- tests/unit/out/unsafe/array_reference.rs | 13 +- tests/unit/out/unsafe/as_const.rs | 13 +- tests/unit/out/unsafe/assign_rhs_first.rs | 13 +- .../unit/out/unsafe/assignment_single_eval.rs | 263 +++++++++++-- tests/unit/out/unsafe/bounded_struct_ptr.rs | 13 +- tests/unit/out/unsafe/bst.rs | 13 +- tests/unit/out/unsafe/c_struct.rs | 65 +++- tests/unit/out/unsafe/cast.rs | 55 ++- .../out/unsafe/cast_array_to_pointer_decay.rs | 13 +- tests/unit/out/unsafe/class.rs | 52 ++- .../out/unsafe/class_template_lazy_member.rs | 65 +++- tests/unit/out/unsafe/class_templates.rs | 165 ++++++++- tests/unit/out/unsafe/clone_vs_move.rs | 39 +- tests/unit/out/unsafe/comma_operator.rs | 13 +- tests/unit/out/unsafe/complex_function.rs | 52 ++- .../unit/out/unsafe/compound_assign_paren.rs | 13 +- tests/unit/out/unsafe/concepts.rs | 13 +- tests/unit/out/unsafe/constexpr_function.rs | 26 +- tests/unit/out/unsafe/constructor.rs | 25 +- .../out/unsafe/container_element_receiver.rs | 15 +- tests/unit/out/unsafe/container_field_addr.rs | 16 +- .../conversion_operator_same_translation.rs | 28 +- tests/unit/out/unsafe/copy_assign.rs | 131 +++++-- tests/unit/out/unsafe/copy_ctor.rs | 167 ++++++--- tests/unit/out/unsafe/copy_move_defaulted.rs | 170 +++++---- tests/unit/out/unsafe/copy_move_deleted.rs | 58 +-- tests/unit/out/unsafe/default.rs | 38 +- .../out/unsafe/default_function_arguments.rs | 26 +- tests/unit/out/unsafe/default_in_statics.rs | 39 +- tests/unit/out/unsafe/delete_array_order.rs | 13 +- tests/unit/out/unsafe/destructor.rs | 143 ++++++- tests/unit/out/unsafe/destructor_params.rs | 26 +- .../unit/out/unsafe/destructor_temporaries.rs | 26 +- tests/unit/out/unsafe/doubly_linked_list.rs | 13 +- .../unit/out/unsafe/enum_default_in_static.rs | 13 +- tests/unit/out/unsafe/enum_int_interop.rs | 13 +- tests/unit/out/unsafe/enum_int_interop_c.rs | 13 +- tests/unit/out/unsafe/enum_underlying_type.rs | 12 +- tests/unit/out/unsafe/exprs.rs | 26 +- tests/unit/out/unsafe/fft.rs | 13 +- tests/unit/out/unsafe/field_aliasing.rs | 39 +- tests/unit/out/unsafe/field_array_elem_ptr.rs | 26 +- .../unit/out/unsafe/field_method_receiver.rs | 29 +- tests/unit/out/unsafe/field_pointers.rs | 42 ++- .../unsafe/field_pointers_malloced_struct.rs | 13 +- .../unsafe/field_reinterpret_write_through.rs | 26 +- tests/unit/out/unsafe/find.rs | 13 +- .../unsafe/first_field_ptr_covers_struct.rs | 26 +- .../unit/out/unsafe/first_member_downcast.rs | 26 +- .../unsafe/flex_array_member_incomplete.rs | 12 +- .../unsafe/flex_array_member_sibling_write.rs | 39 +- tests/unit/out/unsafe/fn_ptr.rs | 14 +- tests/unit/out/unsafe/fn_ptr_cast.rs | 13 +- tests/unit/out/unsafe/fn_ptr_stable_sort.rs | 13 +- tests/unit/out/unsafe/fn_ptr_struct.rs | 40 +- tests/unit/out/unsafe/fn_ptr_typedef_cast.rs | 13 +- tests/unit/out/unsafe/fn_ptr_vtable.rs | 13 +- tests/unit/out/unsafe/fn_ref.rs | 13 +- tests/unit/out/unsafe/for_body_destructor.rs | 13 +- .../unsafe/foreach_disjoint_field_borrow.rs | 16 +- tests/unit/out/unsafe/forward_basic.rs | 40 +- tests/unit/out/unsafe/forward_decltype.rs | 20 +- tests/unit/out/unsafe/forward_explicit.rs | 26 +- tests/unit/out/unsafe/forward_pack.rs | 43 ++- tests/unit/out/unsafe/friend.rs | 52 ++- tests/unit/out/unsafe/function_overloading.rs | 13 +- .../out/unsafe/global_call_temporaries.rs | 13 +- .../out/unsafe/global_init_side_effect.rs | 14 +- .../unit/out/unsafe/global_non_const_init.rs | 37 +- tests/unit/out/unsafe/global_pointers.rs | 13 +- .../out/unsafe/global_without_initializer.rs | 13 +- .../unit/out/unsafe/goto_aggregate_default.rs | 13 +- tests/unit/out/unsafe/goto_cleanup.rs | 13 +- tests/unit/out/unsafe/huffman.rs | 23 +- .../unsafe/immutable-deref-on-func-call.rs | 13 +- tests/unit/out/unsafe/implicit_autoref.rs | 16 +- .../out/unsafe/in_class_field_initializer.rs | 36 +- tests/unit/out/unsafe/init.rs | 13 +- tests/unit/out/unsafe/init_list.rs | 37 +- .../out/unsafe/inline_container_fields.rs | 82 +++-- tests/unit/out/unsafe/kruskal.rs | 33 +- tests/unit/out/unsafe/lambda_as_field.rs | 56 ++- .../out/unsafe/lambda_capture_copy_ctor.rs | 39 +- tests/unit/out/unsafe/lambda_capture_ref.rs | 13 +- .../out/unsafe/lambda_capture_star_this.rs | 13 +- tests/unit/out/unsafe/lambda_capture_this.rs | 13 +- tests/unit/out/unsafe/lambda_capture_value.rs | 13 +- tests/unit/out/unsafe/lambda_decltype_type.rs | 22 +- .../unsafe/lambda_generic_explicit_args.rs | 13 +- .../unit/out/unsafe/lambda_immediate_init.rs | 12 +- .../out/unsafe/lambda_move_only_capture.rs | 20 +- tests/unit/out/unsafe/lambda_nested.rs | 13 +- tests/unit/out/unsafe/lambda_static_local.rs | 13 +- .../out/unsafe/libc_struct_without_default.rs | 26 +- tests/unit/out/unsafe/linked_list.rs | 13 +- .../out/unsafe/local_anon_struct_collision.rs | 26 +- .../unit/out/unsafe/local_record_template.rs | 52 ++- tests/unit/out/unsafe/map.rs | 12 +- tests/unit/out/unsafe/map_key_copy_ctor.rs | 26 +- tests/unit/out/unsafe/map_key_identity.rs | 25 +- tests/unit/out/unsafe/map_try_emplace.rs | 43 ++- .../out/unsafe/map_try_emplace_lvalues.rs | 60 ++- tests/unit/out/unsafe/max.rs | 20 +- tests/unit/out/unsafe/memcpy_struct_bytes.rs | 13 +- .../unit/out/unsafe/memcpy_struct_layouts.rs | 65 +++- tests/unit/out/unsafe/memcpy_struct_struct.rs | 13 +- tests/unit/out/unsafe/memset_struct_tail.rs | 13 +- tests/unit/out/unsafe/move_assign.rs | 30 +- tests/unit/out/unsafe/move_ctor.rs | 64 +++- tests/unit/out/unsafe/move_this.rs | 40 +- tests/unit/out/unsafe/nested_structs.rs | 78 +++- tests/unit/out/unsafe/new.rs | 13 +- tests/unit/out/unsafe/new_bst.rs | 13 +- tests/unit/out/unsafe/new_struct.rs | 26 +- .../unsafe/nttp_distinct_specializations.rs | 39 +- tests/unit/out/unsafe/offsetof.rs | 25 +- tests/unit/out/unsafe/opaque_forward_decl.rs | 13 +- tests/unit/out/unsafe/opaque_record_copy.rs | 26 +- tests/unit/out/unsafe/opaque_then_defined.rs | 26 +- .../out/unsafe/operator_arithmetic_free.rs | 13 +- .../out/unsafe/operator_arithmetic_member.rs | 13 +- .../unit/out/unsafe/operator_bitwise_free.rs | 13 +- .../out/unsafe/operator_bitwise_member.rs | 13 +- .../unsafe/operator_comparison_defaulted.rs | 104 +++++- .../out/unsafe/operator_comparison_free.rs | 26 +- .../out/unsafe/operator_comparison_member.rs | 13 +- .../out/unsafe/operator_comparison_mixed.rs | 13 +- .../out/unsafe/operator_comparison_nonbool.rs | 92 ++++- .../unsafe/operator_comparison_noncopyable.rs | 6 +- .../operator_compound_assignment_free.rs | 13 +- .../operator_compound_assignment_member.rs | 13 +- tests/unit/out/unsafe/operator_friend.rs | 91 ++++- tests/unit/out/unsafe/operator_less_than.rs | 13 +- .../unit/out/unsafe/operator_logical_free.rs | 13 +- .../out/unsafe/operator_logical_member.rs | 13 +- .../unsafe/operator_member_pointer_free.rs | 26 +- .../unsafe/operator_member_pointer_member.rs | 39 +- tests/unit/out/unsafe/operator_other_free.rs | 13 +- .../unit/out/unsafe/operator_other_member.rs | 27 +- tests/unit/out/unsafe/operator_overloads.rs | 13 +- tests/unit/out/unsafe/operator_qualifiers.rs | 13 +- tests/unit/out/unsafe/operator_three_way.rs | 13 +- tests/unit/out/unsafe/operator_traits.rs | 65 +++- tests/unit/out/unsafe/overload_mangling.rs | 39 +- .../unsafe/pair_converting_construction.rs | 138 ++++++- tests/unit/out/unsafe/pod.rs | 13 +- tests/unit/out/unsafe/pointer_array.rs | 13 +- tests/unit/out/unsafe/pointers.rs | 13 +- tests/unit/out/unsafe/polymorphism.rs | 26 +- tests/unit/out/unsafe/ptr_cast_init.rs | 26 +- tests/unit/out/unsafe/push_emplace_back.rs | 97 ++++- tests/unit/out/unsafe/random.rs | 26 +- tests/unit/out/unsafe/reference_wrapper.rs | 13 +- tests/unit/out/unsafe/references.rs | 26 +- tests/unit/out/unsafe/refs_as_args.rs | 13 +- .../out/unsafe/reinterpret_cast_ptr_cmp.rs | 39 +- .../out/unsafe/reinterpret_cast_struct.rs | 13 +- .../reinterpret_cast_struct_to_struct.rs | 26 +- tests/unit/out/unsafe/reserved_keywords.rs | 39 +- tests/unit/out/unsafe/return_move.rs | 26 +- tests/unit/out/unsafe/rule_of_five.rs | 42 +-- tests/unit/out/unsafe/rule_of_three.rs | 23 +- tests/unit/out/unsafe/rvalue_rule_arg_move.rs | 24 +- tests/unit/out/unsafe/rvalue_struct.rs | 13 +- .../scalar_builtin_construct_destruct.rs | 13 +- .../unsafe/self_referencing_initializer.rs | 38 +- tests/unit/out/unsafe/size_t_static_member.rs | 26 +- .../unit/out/unsafe/size_t_template_param.rs | 28 +- tests/unit/out/unsafe/sort_no_copy.rs | 56 +-- tests/unit/out/unsafe/static_local.rs | 13 +- tests/unit/out/unsafe/static_var_in_class.rs | 26 +- tests/unit/out/unsafe/stdcopy.rs | 14 +- tests/unit/out/unsafe/strdup.rs | 13 +- .../out/unsafe/string_literal_ptr_init.rs | 13 +- tests/unit/out/unsafe/string_substr.rs | 13 +- .../unit/out/unsafe/struct_2d_array_field.rs | 13 +- tests/unit/out/unsafe/struct_ctor.rs | 39 +- tests/unit/out/unsafe/struct_default_ctor.rs | 50 ++- .../unsafe/struct_member_array_adjacency.rs | 13 +- tests/unit/out/unsafe/struct_ptr.rs | 13 +- .../unsafe/structured_binding_copy_ctor.rs | 21 +- .../unsafe/structured_binding_element_ctor.rs | 41 ++- .../unsafe/structured_binding_move_ctor.rs | 32 +- .../unsafe/structured_binding_range_for.rs | 13 +- .../unit/out/unsafe/structured_binding_ref.rs | 13 +- .../out/unsafe/structured_binding_trivial.rs | 13 +- tests/unit/out/unsafe/swap_map_no_copy.rs | 219 +++++------ .../out/unsafe/tag_vs_identifier_collision.rs | 89 ++++- tests/unit/out/unsafe/template_default_arg.rs | 53 ++- .../unit/out/unsafe/template_static_member.rs | 65 +++- tests/unit/out/unsafe/temporary_field_addr.rs | 36 +- .../out/unsafe/temporary_field_ctor_arg.rs | 30 +- .../out/unsafe/temporary_field_two_args.rs | 36 +- tests/unit/out/unsafe/this.rs | 28 +- tests/unit/out/unsafe/typedef-anon-struct.rs | 29 +- .../out/unsafe/unary_expr_or_type_trait.rs | 13 +- tests/unit/out/unsafe/unboxed_locals.rs | 25 +- tests/unit/out/unsafe/unboxed_records.rs | 38 +- .../unit/out/unsafe/union_addrof_external.rs | 38 +- tests/unit/out/unsafe/union_basic.rs | 48 ++- tests/unit/out/unsafe/union_cross_arm_cast.rs | 51 ++- .../unit/out/unsafe/union_field_alignment.rs | 25 +- .../out/unsafe/union_flex_array_member.rs | 25 +- tests/unit/out/unsafe/union_memset_memcpy.rs | 51 ++- tests/unit/out/unsafe/union_nested.rs | 63 +++- .../out/unsafe/union_pointer_pun_address.rs | 38 +- .../unsafe/union_pointer_pun_writethrough.rs | 12 +- .../unit/out/unsafe/union_struct_dual_use.rs | 38 +- .../unit/out/unsafe/union_tagged_many_arms.rs | 25 +- tests/unit/out/unsafe/union_tagged_simple.rs | 25 +- .../out/unsafe/union_tagged_struct_arms.rs | 64 +++- .../out/unsafe/union_void_ptr_sized_deref.rs | 25 +- tests/unit/out/unsafe/unique_ptr.rs | 23 +- .../unit/out/unsafe/unique_ptr_const_deref.rs | 10 +- .../unit/out/unsafe/unique_ptr_field_reset.rs | 23 +- tests/unit/out/unsafe/unique_ptr_nested.rs | 23 +- tests/unit/out/unsafe/unique_ptr_struct.rs | 13 +- tests/unit/out/unsafe/va_arg_mixed_types.rs | 13 +- .../out/unsafe/va_arg_non_primitive_ptrs.rs | 13 +- tests/unit/out/unsafe/va_arg_struct_ctx.rs | 25 +- tests/unit/out/unsafe/va_arg_void_ptr.rs | 13 +- tests/unit/out/unsafe/va_list_field.rs | 25 +- tests/unit/out/unsafe/vector.rs | 29 +- .../unit/out/unsafe/vector_iter_range_ctor.rs | 28 +- .../out/unsafe/vector_subscript_direct.rs | 29 +- .../unit/out/unsafe/vector_with_allocator.rs | 26 +- tests/unit/out/unsafe/void_cast.rs | 39 +- 590 files changed, 19085 insertions(+), 3771 deletions(-) diff --git a/tests/multi-file/cross_tu_tag_collision/out/refcount/cross_tu_tag_collision.rs b/tests/multi-file/cross_tu_tag_collision/out/refcount/cross_tu_tag_collision.rs index e1598f3b78..44a32a76af 100644 --- a/tests/multi-file/cross_tu_tag_collision/out/refcount/cross_tu_tag_collision.rs +++ b/tests/multi-file/cross_tu_tag_collision/out/refcount/cross_tu_tag_collision.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct widget { #[offset(0)] diff --git a/tests/multi-file/cross_tu_tag_collision/out/unsafe/cross_tu_tag_collision.rs b/tests/multi-file/cross_tu_tag_collision/out/unsafe/cross_tu_tag_collision.rs index a67aba4a6a..52297a0ce2 100644 --- a/tests/multi-file/cross_tu_tag_collision/out/unsafe/cross_tu_tag_collision.rs +++ b/tests/multi-file/cross_tu_tag_collision/out/unsafe/cross_tu_tag_collision.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct widget { pub id: i32, } diff --git a/tests/multi-file/defaulted_move_cross_tu/out/refcount/defaulted_move_cross_tu.rs b/tests/multi-file/defaulted_move_cross_tu/out/refcount/defaulted_move_cross_tu.rs index 5b9a7e89c3..388bec8a0c 100644 --- a/tests/multi-file/defaulted_move_cross_tu/out/refcount/defaulted_move_cross_tu.rs +++ b/tests/multi-file/defaulted_move_cross_tu/out/refcount/defaulted_move_cross_tu.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, MoveCtor, CppFrom, MoveAssign)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom)] #[cpp_from(i32, construct, value)] #[byte_size(32)] pub struct S { @@ -24,7 +24,15 @@ impl Default for S { } } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, MoveAssign, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + CopyAssignable, + Default, )] #[byte_size(24)] pub struct T { @@ -63,7 +71,7 @@ pub fn shuffle_1(mut x: i32) -> i32 { })); let b: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - SImpl::move_from(&__v.as_pointer(), { a.as_pointer() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { a.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); assert!(({ (*a.borrow()).v.is_empty() })); @@ -72,16 +80,16 @@ pub fn shuffle_1(mut x: i32) -> i32 { SImpl::construct(&__v.as_pointer(), { 1 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); - ({ SImpl::move_assign(&c.as_pointer(), b.as_pointer()) }); + ({ MoveAssignable::move_assign(&c.as_pointer(), b.as_pointer()) }); assert!(({ (*b.borrow()).v.is_empty() })); let t: Value = Rc::new(RefCell::new(T { v: Vec::from([1]) })); let u: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - TImpl::move_from(&__v.as_pointer(), { t.as_pointer() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { t.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let w: Value = Rc::new(RefCell::new(::default())); - ({ TImpl::move_assign(&w.as_pointer(), u.as_pointer()) }); + ({ MoveAssignable::move_assign(&w.as_pointer(), u.as_pointer()) }); assert!( ((({ TImpl::size(&t.as_pointer(),) }) == 0) && (({ TImpl::size(&u.as_pointer(),) }) == 0)) && (({ TImpl::size(&w.as_pointer(),) }) == 1) @@ -90,49 +98,53 @@ pub fn shuffle_1(mut x: i32) -> i32 { } pub trait SImpl { fn construct(&self, x: i32); - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; } impl SImpl for Ptr { fn construct(&self, mut x: i32) { field!((*self), v).write(vec![x; (x as usize)]); field!((*self), n).write(Box::new([x, (x + 1)])); } - fn move_from(&self, _a0: Ptr) { - field!((*self), v).write(field!(_a0, v).with_mut(std::mem::take)); - field!((*self), n).write(Box::new(std::array::from_fn::<_, 2, _>(|__i: usize| { - (*_a0.upgrade().deref()).n[(__i) as usize] - }))); - } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), v).with_mut(|__b0| { +} +impl MoveAssignable for S { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), v).with_mut(|__b0| { (*__b0) = field!(_a0, v).with_mut(std::mem::take); }); { - let mut __tmp_0 = { (array_field_ptr!((*self), n)).to_any() }; + let mut __tmp_0 = { (array_field_ptr!((*this), n)).to_any() }; __tmp_0.memcpy(&(array_field_ptr!(_a0, n)).to_any(), 8_usize); (__tmp_0).clone() }; - return (*self).clone(); + return (*this).clone(); + } +} +impl MoveConstructible for S { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), v).write(field!(_a0, v).with_mut(std::mem::take)); + field!((*this), n).write(Box::new(std::array::from_fn::<_, 2, _>(|__i: usize| { + (*_a0.upgrade().deref()).n[(__i) as usize] + }))); } } pub trait TImpl { fn size(&self) -> i32; - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; } impl TImpl for Ptr { fn size(&self) -> i32 { return (((*(*self).upgrade().deref()).v.len()) as i32); } - fn move_from(&self, _a0: Ptr) { - field!((*self), v).write(field!(_a0, v).with_mut(std::mem::take)); - } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), v).with_mut(|__b0| { +} +impl MoveAssignable for T { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), v).with_mut(|__b0| { (*__b0) = field!(_a0, v).with_mut(std::mem::take); }); - return (*self).clone(); + return (*this).clone(); + } +} +impl MoveConstructible for T { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), v).write(field!(_a0, v).with_mut(std::mem::take)); } } pub fn __cpp2rust_init_globals() {} diff --git a/tests/multi-file/defaulted_move_cross_tu/out/unsafe/defaulted_move_cross_tu.rs b/tests/multi-file/defaulted_move_cross_tu/out/unsafe/defaulted_move_cross_tu.rs index 771f119c8b..d866cb761e 100644 --- a/tests/multi-file/defaulted_move_cross_tu/out/unsafe/defaulted_move_cross_tu.rs +++ b/tests/multi-file/defaulted_move_cross_tu/out/unsafe/defaulted_move_cross_tu.rs @@ -7,9 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, CppFromUnsafe, MoveAssignUnsafe, Default, -)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] #[cpp_from(i32, construct, value)] pub struct S { pub v: Vec, @@ -20,11 +18,15 @@ impl S { (&raw mut self.v).write(vec![x; (x as usize)]); (&raw mut self.n).write([x, ((x) + (1))]); } - pub unsafe fn move_from(&mut self, _a0: *mut S) { +} +impl MoveConstructibleUnsafe for S { + unsafe fn move_constructor(&mut self, _a0: *mut S) { (&raw mut self.v).write(std::mem::take(&mut (*_a0).v)); (&raw mut self.n).write(std::array::from_fn::<_, 2, _>(|__i: usize| (*_a0).n[(__i)])); } - pub unsafe fn move_assign(&mut self, _a0: *mut S) -> *mut S { +} +impl MoveAssignableUnsafe for S { + unsafe fn move_assign(&mut self, _a0: *mut S) -> *mut S { { self.v = std::mem::take(&mut (*_a0).v); }; @@ -41,7 +43,13 @@ impl S { } #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + CopyAssignableUnsafe, + Default, )] pub struct T { pub v: Vec, @@ -50,10 +58,14 @@ impl T { pub unsafe fn size(&self) -> i32 { return ((self.v.len()) as i32); } - pub unsafe fn move_from(&mut self, _a0: *mut T) { +} +impl MoveConstructibleUnsafe for T { + unsafe fn move_constructor(&mut self, _a0: *mut T) { (&raw mut self.v).write(std::mem::take(&mut (*_a0).v)); } - pub unsafe fn move_assign(&mut self, _a0: *mut T) -> *mut T { +} +impl MoveAssignableUnsafe for T { + unsafe fn move_assign(&mut self, _a0: *mut T) -> *mut T { { self.v = std::mem::take(&mut (*_a0).v); }; @@ -91,7 +103,7 @@ pub unsafe fn shuffle_1(mut x: i32) -> i32 { }; let mut b: S = { let mut __v: S = ::zero_init(); - S::move_from(&mut __v, { &mut a }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut a }); __v }; assert!(a.v.is_empty()); @@ -100,16 +112,16 @@ pub unsafe fn shuffle_1(mut x: i32) -> i32 { S::construct(&mut __v, { 1 }); __v }; - (unsafe { S::move_assign(&mut c, &mut b) }); + (unsafe { MoveAssignableUnsafe::move_assign(&mut c, &mut b) }); assert!(b.v.is_empty()); let mut t: T = T { v: Vec::from([1]) }; let mut u: T = { let mut __v: T = ::zero_init(); - T::move_from(&mut __v, { &mut t }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut t }); __v }; let mut w: T = ::default(); - (unsafe { T::move_assign(&mut w, &mut u) }); + (unsafe { MoveAssignableUnsafe::move_assign(&mut w, &mut u) }); assert!( (((unsafe { T::size(&t,) }) == (0)) && ((unsafe { T::size(&u,) }) == (0))) && ((unsafe { T::size(&w,) }) == (1)) diff --git a/tests/multi-file/friend_operator/out/refcount/friend_operator.rs b/tests/multi-file/friend_operator/out/refcount/friend_operator.rs index a5413a53c3..403923cdb6 100644 --- a/tests/multi-file/friend_operator/out/refcount/friend_operator.rs +++ b/tests/multi-file/friend_operator/out/refcount/friend_operator.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct S { #[offset(0)] diff --git a/tests/multi-file/friend_operator/out/unsafe/friend_operator.rs b/tests/multi-file/friend_operator/out/unsafe/friend_operator.rs index 121763987a..b9d917bf1a 100644 --- a/tests/multi-file/friend_operator/out/unsafe/friend_operator.rs +++ b/tests/multi-file/friend_operator/out/unsafe/friend_operator.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub a: i32, pub b: i32, diff --git a/tests/multi-file/opaque_forward_decl/out/refcount/opaque_forward_decl.rs b/tests/multi-file/opaque_forward_decl/out/refcount/opaque_forward_decl.rs index bbba0d218a..c444c98785 100644 --- a/tests/multi-file/opaque_forward_decl/out/refcount/opaque_forward_decl.rs +++ b/tests/multi-file/opaque_forward_decl/out/refcount/opaque_forward_decl.rs @@ -6,7 +6,19 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct container { #[offset(0)] diff --git a/tests/multi-file/opaque_forward_decl/out/unsafe/opaque_forward_decl.rs b/tests/multi-file/opaque_forward_decl/out/unsafe/opaque_forward_decl.rs index 251e8e1290..de9b592708 100644 --- a/tests/multi-file/opaque_forward_decl/out/unsafe/opaque_forward_decl.rs +++ b/tests/multi-file/opaque_forward_decl/out/unsafe/opaque_forward_decl.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct container { pub p: *mut opaque, pub x: i32, diff --git a/tests/multi-file/out_of_line_methods_cross_tu/out/refcount/out_of_line_methods_cross_tu.rs b/tests/multi-file/out_of_line_methods_cross_tu/out/refcount/out_of_line_methods_cross_tu.rs index 025f1e0e89..8ad001b459 100644 --- a/tests/multi-file/out_of_line_methods_cross_tu/out/refcount/out_of_line_methods_cross_tu.rs +++ b/tests/multi-file/out_of_line_methods_cross_tu/out/refcount/out_of_line_methods_cross_tu.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] @@ -15,13 +28,39 @@ pub struct S { pub trait Base { fn apply(&mut self, x: i32) -> i32; } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct Derived { #[offset(8)] pub factor: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Pair { #[offset(0)] diff --git a/tests/multi-file/out_of_line_methods_cross_tu/out/unsafe/out_of_line_methods_cross_tu.rs b/tests/multi-file/out_of_line_methods_cross_tu/out/unsafe/out_of_line_methods_cross_tu.rs index a99bc9436a..f3437d0e86 100644 --- a/tests/multi-file/out_of_line_methods_cross_tu/out/unsafe/out_of_line_methods_cross_tu.rs +++ b/tests/multi-file/out_of_line_methods_cross_tu/out/unsafe/out_of_line_methods_cross_tu.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub v: i32, } @@ -20,13 +31,35 @@ pub unsafe trait Base { unsafe fn apply(&mut self, x: i32) -> i32; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Derived { pub factor: i32, } impl Derived {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Pair { pub first: i32, pub second: i32, diff --git a/tests/multi-file/template_method_late_instantiation/out/refcount/template_method_late_instantiation.rs b/tests/multi-file/template_method_late_instantiation/out/refcount/template_method_late_instantiation.rs index a43e8c01ad..126d1c1281 100644 --- a/tests/multi-file/template_method_late_instantiation/out/refcount/template_method_late_instantiation.rs +++ b/tests/multi-file/template_method_late_instantiation/out/refcount/template_method_late_instantiation.rs @@ -6,7 +6,19 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(4)] pub struct S_int_ { #[offset(0)] diff --git a/tests/multi-file/template_method_late_instantiation/out/unsafe/template_method_late_instantiation.rs b/tests/multi-file/template_method_late_instantiation/out/unsafe/template_method_late_instantiation.rs index a6bebb806c..dc6ab55110 100644 --- a/tests/multi-file/template_method_late_instantiation/out/unsafe/template_method_late_instantiation.rs +++ b/tests/multi-file/template_method_late_instantiation/out/unsafe/template_method_late_instantiation.rs @@ -7,7 +7,17 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct S_int_ { pub x: i32, } diff --git a/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/refcount/p14-class-in-two-files.rs b/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/refcount/p14-class-in-two-files.rs index 21d1ed5c32..15967aa9d8 100644 --- a/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/refcount/p14-class-in-two-files.rs +++ b/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/refcount/p14-class-in-two-files.rs @@ -18,7 +18,16 @@ thread_local!( thread_local!( pub static useCount_3: Value = Rc::new(RefCell::new(0)); ); -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyAssign, Destructible)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + MoveConstructible, + MoveAssignable, +)] #[byte_size(4)] pub struct LifetimeTracked { #[offset(0)] @@ -50,7 +59,7 @@ impl Clone for LifetimeTracked { uses: self.uses.clone(), })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -66,7 +75,20 @@ impl Default for LifetimeTracked { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct AssertsDtorCountAtExit { #[offset(0)] @@ -94,7 +116,20 @@ thread_local!( __static }; ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct HasInlineMembers {} impl HasInlineMembers { @@ -151,20 +186,14 @@ impl AssertsDtorCountAtExitImpl for Ptr { } pub trait LifetimeTrackedImpl { fn construct(&self); - fn copy_from(&self, _a0: Ptr); fn destructor(&self); fn use_(&self); - fn copy_assign(&self, _a0: Ptr) -> Ptr; } impl LifetimeTrackedImpl for Ptr { fn construct(&self) { field!((*self), uses).write(0); (*ctorCount_0.with(Value::clone).borrow_mut()).prefix_inc(); } - fn copy_from(&self, _a0: Ptr) { - field!((*self), uses).write(0); - (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); - } fn destructor(&self) { (*dtorCount_2.with(Value::clone).borrow_mut()).prefix_inc(); } @@ -174,9 +203,17 @@ impl LifetimeTrackedImpl for Ptr { }); (*useCount_3.with(Value::clone).borrow_mut()).prefix_inc(); } - fn copy_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), uses).write(_a0.with(|__s| __s.uses)); - return (*self).clone(); +} +impl CopyAssignable for LifetimeTracked { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), uses).write(_a0.with(|__s| __s.uses)); + return (*this).clone(); + } +} +impl CopyConstructible for LifetimeTracked { + fn copy_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), uses).write(0); + (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); } } pub fn __cpp2rust_init_globals() { diff --git a/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/unsafe/p14-class-in-two-files.rs b/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/unsafe/p14-class-in-two-files.rs index cefa6b408a..b44e71819a 100644 --- a/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/unsafe/p14-class-in-two-files.rs +++ b/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/unsafe/p14-class-in-two-files.rs @@ -11,7 +11,14 @@ pub static mut copyCount_1: std::cell::LazyCell = std::cell::LazyCell::new( pub static mut dtorCount_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyAssignUnsafe, DestructibleUnsafe)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + MoveConstructibleUnsafe, + MoveAssignableUnsafe, +)] pub struct LifetimeTracked { pub uses: i32, } @@ -32,10 +39,6 @@ impl LifetimeTracked { (&raw mut self.uses).write(0); (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).prefix_inc(); } - pub unsafe fn copy_from(&mut self, _a0: *const LifetimeTracked) { - (&raw mut self.uses).write(0); - (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)).prefix_inc(); - } pub unsafe fn destructor(&mut self) { (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)).prefix_inc(); } @@ -43,7 +46,15 @@ impl LifetimeTracked { (*(&raw const self.uses).cast_mut()).prefix_inc(); (*std::cell::LazyCell::force_mut(&mut *&raw mut useCount_3)).prefix_inc(); } - pub unsafe fn copy_assign(&mut self, _a0: *const LifetimeTracked) -> *mut LifetimeTracked { +} +impl CopyConstructibleUnsafe for LifetimeTracked { + unsafe fn copy_constructor(&mut self, _a0: *const LifetimeTracked) { + (&raw mut self.uses).write(0); + (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)).prefix_inc(); + } +} +impl CopyAssignableUnsafe for LifetimeTracked { + unsafe fn copy_assign(&mut self, _a0: *const LifetimeTracked) -> *mut LifetimeTracked { self.uses = (*_a0).uses; return &mut (*(self as *mut LifetimeTracked)); } @@ -52,7 +63,7 @@ impl Clone for LifetimeTracked { fn clone(&self) -> Self { unsafe { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::copy_from(&mut __v, self as *const LifetimeTracked); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const LifetimeTracked); __v } } @@ -69,7 +80,18 @@ impl Default for LifetimeTracked { } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct AssertsDtorCountAtExit { pub expected: i32, } @@ -107,7 +129,18 @@ pub static mut shared_5: std::cell::LazyCell = } }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct HasInlineMembers {} impl HasInlineMembers { pub unsafe fn instance() -> *mut LifetimeTracked { diff --git a/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/refcount/p15-class-template-static-member.rs b/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/refcount/p15-class-template-static-member.rs index 0d60533295..bf1f25b47a 100644 --- a/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/refcount/p15-class-template-static-member.rs +++ b/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/refcount/p15-class-template-static-member.rs @@ -18,7 +18,16 @@ thread_local!( thread_local!( pub static useCount_3: Value = Rc::new(RefCell::new(0)); ); -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyAssign, Destructible)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + MoveConstructible, + MoveAssignable, +)] #[byte_size(4)] pub struct LifetimeTracked { #[offset(0)] @@ -50,7 +59,7 @@ impl Clone for LifetimeTracked { uses: self.uses.clone(), })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -79,7 +88,20 @@ thread_local!( __static }; ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct HasStaticMember_int_ {} thread_local!( @@ -95,7 +117,20 @@ thread_local!( __static }; ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct HasStaticMember_long_ {} pub fn main() { @@ -124,20 +159,14 @@ pub fn b_int_address_8() -> Ptr { } pub trait LifetimeTrackedImpl { fn construct(&self); - fn copy_from(&self, _a0: Ptr); fn destructor(&self); fn use_(&self); - fn copy_assign(&self, _a0: Ptr) -> Ptr; } impl LifetimeTrackedImpl for Ptr { fn construct(&self) { field!((*self), uses).write(0); (*ctorCount_0.with(Value::clone).borrow_mut()).prefix_inc(); } - fn copy_from(&self, _a0: Ptr) { - field!((*self), uses).write(0); - (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); - } fn destructor(&self) { (*dtorCount_2.with(Value::clone).borrow_mut()).prefix_inc(); } @@ -147,9 +176,17 @@ impl LifetimeTrackedImpl for Ptr { }); (*useCount_3.with(Value::clone).borrow_mut()).prefix_inc(); } - fn copy_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), uses).write(_a0.with(|__s| __s.uses)); - return (*self).clone(); +} +impl CopyAssignable for LifetimeTracked { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), uses).write(_a0.with(|__s| __s.uses)); + return (*this).clone(); + } +} +impl CopyConstructible for LifetimeTracked { + fn copy_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), uses).write(0); + (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); } } pub fn __cpp2rust_init_globals() { diff --git a/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/unsafe/p15-class-template-static-member.rs b/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/unsafe/p15-class-template-static-member.rs index 34e5ce487f..bba4804456 100644 --- a/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/unsafe/p15-class-template-static-member.rs +++ b/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/unsafe/p15-class-template-static-member.rs @@ -11,7 +11,14 @@ pub static mut copyCount_1: std::cell::LazyCell = std::cell::LazyCell::new( pub static mut dtorCount_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyAssignUnsafe, DestructibleUnsafe)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + MoveConstructibleUnsafe, + MoveAssignableUnsafe, +)] pub struct LifetimeTracked { pub uses: i32, } @@ -32,10 +39,6 @@ impl LifetimeTracked { (&raw mut self.uses).write(0); (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).prefix_inc(); } - pub unsafe fn copy_from(&mut self, _a0: *const LifetimeTracked) { - (&raw mut self.uses).write(0); - (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)).prefix_inc(); - } pub unsafe fn destructor(&mut self) { (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)).prefix_inc(); } @@ -43,7 +46,15 @@ impl LifetimeTracked { (*(&raw const self.uses).cast_mut()).prefix_inc(); (*std::cell::LazyCell::force_mut(&mut *&raw mut useCount_3)).prefix_inc(); } - pub unsafe fn copy_assign(&mut self, _a0: *const LifetimeTracked) -> *mut LifetimeTracked { +} +impl CopyConstructibleUnsafe for LifetimeTracked { + unsafe fn copy_constructor(&mut self, _a0: *const LifetimeTracked) { + (&raw mut self.uses).write(0); + (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)).prefix_inc(); + } +} +impl CopyAssignableUnsafe for LifetimeTracked { + unsafe fn copy_assign(&mut self, _a0: *const LifetimeTracked) -> *mut LifetimeTracked { self.uses = (*_a0).uses; return &mut (*(self as *mut LifetimeTracked)); } @@ -52,7 +63,7 @@ impl Clone for LifetimeTracked { fn clone(&self) -> Self { unsafe { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::copy_from(&mut __v, self as *const LifetimeTracked); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const LifetimeTracked); __v } } @@ -85,7 +96,18 @@ pub static mut member_4: std::cell::LazyCell = } }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct HasStaticMember_int_ {} pub static mut member_5: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { @@ -104,7 +126,18 @@ pub static mut member_5: std::cell::LazyCell = } }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct HasStaticMember_long_ {} pub fn main() { unsafe { diff --git a/tests/std/basic/basic.def.odr/p15-function-template/out/refcount/p15-function-template.rs b/tests/std/basic/basic.def.odr/p15-function-template/out/refcount/p15-function-template.rs index e9dd3137fd..51e2b4e86b 100644 --- a/tests/std/basic/basic.def.odr/p15-function-template/out/refcount/p15-function-template.rs +++ b/tests/std/basic/basic.def.odr/p15-function-template/out/refcount/p15-function-template.rs @@ -18,7 +18,16 @@ thread_local!( thread_local!( pub static useCount_3: Value = Rc::new(RefCell::new(0)); ); -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyAssign, Destructible)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + MoveConstructible, + MoveAssignable, +)] #[byte_size(4)] pub struct LifetimeTracked { #[offset(0)] @@ -50,7 +59,7 @@ impl Clone for LifetimeTracked { uses: self.uses.clone(), })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -66,7 +75,20 @@ impl Default for LifetimeTracked { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct AssertsDtorCountAtExit { #[offset(0)] @@ -156,7 +178,20 @@ fn main_0() -> i32 { assert!((ctorCount_0.with(|rc| *rc.borrow()) == 4)); return 0; } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct S_14 {} pub fn count_18() -> i32 { @@ -187,7 +222,20 @@ pub fn b_count_long_17() -> i32 { pub fn b_count_local_15() -> i32 { return ({ count_18() }); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct S_21 {} pub trait AssertsDtorCountAtExitImpl { @@ -200,20 +248,14 @@ impl AssertsDtorCountAtExitImpl for Ptr { } pub trait LifetimeTrackedImpl { fn construct(&self); - fn copy_from(&self, _a0: Ptr); fn destructor(&self); fn use_(&self); - fn copy_assign(&self, _a0: Ptr) -> Ptr; } impl LifetimeTrackedImpl for Ptr { fn construct(&self) { field!((*self), uses).write(0); (*ctorCount_0.with(Value::clone).borrow_mut()).prefix_inc(); } - fn copy_from(&self, _a0: Ptr) { - field!((*self), uses).write(0); - (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); - } fn destructor(&self) { (*dtorCount_2.with(Value::clone).borrow_mut()).prefix_inc(); } @@ -223,9 +265,17 @@ impl LifetimeTrackedImpl for Ptr { }); (*useCount_3.with(Value::clone).borrow_mut()).prefix_inc(); } - fn copy_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), uses).write(_a0.with(|__s| __s.uses)); - return (*self).clone(); +} +impl CopyAssignable for LifetimeTracked { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), uses).write(_a0.with(|__s| __s.uses)); + return (*this).clone(); + } +} +impl CopyConstructible for LifetimeTracked { + fn copy_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), uses).write(0); + (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); } } pub fn __cpp2rust_init_globals() { diff --git a/tests/std/basic/basic.def.odr/p15-function-template/out/unsafe/p15-function-template.rs b/tests/std/basic/basic.def.odr/p15-function-template/out/unsafe/p15-function-template.rs index 3ac419bcf0..014b802f9e 100644 --- a/tests/std/basic/basic.def.odr/p15-function-template/out/unsafe/p15-function-template.rs +++ b/tests/std/basic/basic.def.odr/p15-function-template/out/unsafe/p15-function-template.rs @@ -11,7 +11,14 @@ pub static mut copyCount_1: std::cell::LazyCell = std::cell::LazyCell::new( pub static mut dtorCount_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyAssignUnsafe, DestructibleUnsafe)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + MoveConstructibleUnsafe, + MoveAssignableUnsafe, +)] pub struct LifetimeTracked { pub uses: i32, } @@ -32,10 +39,6 @@ impl LifetimeTracked { (&raw mut self.uses).write(0); (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).prefix_inc(); } - pub unsafe fn copy_from(&mut self, _a0: *const LifetimeTracked) { - (&raw mut self.uses).write(0); - (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)).prefix_inc(); - } pub unsafe fn destructor(&mut self) { (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)).prefix_inc(); } @@ -43,7 +46,15 @@ impl LifetimeTracked { (*(&raw const self.uses).cast_mut()).prefix_inc(); (*std::cell::LazyCell::force_mut(&mut *&raw mut useCount_3)).prefix_inc(); } - pub unsafe fn copy_assign(&mut self, _a0: *const LifetimeTracked) -> *mut LifetimeTracked { +} +impl CopyConstructibleUnsafe for LifetimeTracked { + unsafe fn copy_constructor(&mut self, _a0: *const LifetimeTracked) { + (&raw mut self.uses).write(0); + (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)).prefix_inc(); + } +} +impl CopyAssignableUnsafe for LifetimeTracked { + unsafe fn copy_assign(&mut self, _a0: *const LifetimeTracked) -> *mut LifetimeTracked { self.uses = (*_a0).uses; return &mut (*(self as *mut LifetimeTracked)); } @@ -52,7 +63,7 @@ impl Clone for LifetimeTracked { fn clone(&self) -> Self { unsafe { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::copy_from(&mut __v, self as *const LifetimeTracked); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const LifetimeTracked); __v } } @@ -69,7 +80,18 @@ impl Default for LifetimeTracked { } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct AssertsDtorCountAtExit { pub expected: i32, } @@ -168,7 +190,18 @@ unsafe fn main_0() -> i32 { return 0; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S_14 {} pub unsafe fn count_18() -> i32 { return (*(*std::cell::LazyCell::force_mut(&mut *&raw mut n_20)).prefix_inc()); @@ -199,7 +232,18 @@ pub unsafe fn b_count_local_15() -> i32 { return (unsafe { count_18() }); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S_21 {} pub unsafe fn __cpp2rust_init_globals() { std::cell::LazyCell::force(&*&raw const ctorCount_0); diff --git a/tests/std/basic/basic.def.odr/p15-inline-function/out/refcount/p15-inline-function.rs b/tests/std/basic/basic.def.odr/p15-inline-function/out/refcount/p15-inline-function.rs index d8c65b58ff..0c6490c7b4 100644 --- a/tests/std/basic/basic.def.odr/p15-inline-function/out/refcount/p15-inline-function.rs +++ b/tests/std/basic/basic.def.odr/p15-inline-function/out/refcount/p15-inline-function.rs @@ -18,7 +18,16 @@ thread_local!( thread_local!( pub static useCount_3: Value = Rc::new(RefCell::new(0)); ); -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyAssign, Destructible)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + MoveConstructible, + MoveAssignable, +)] #[byte_size(4)] pub struct LifetimeTracked { #[offset(0)] @@ -50,7 +59,7 @@ impl Clone for LifetimeTracked { uses: self.uses.clone(), })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -66,7 +75,20 @@ impl Default for LifetimeTracked { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct AssertsDtorCountAtExit { #[offset(0)] @@ -129,20 +151,14 @@ impl AssertsDtorCountAtExitImpl for Ptr { } pub trait LifetimeTrackedImpl { fn construct(&self); - fn copy_from(&self, _a0: Ptr); fn destructor(&self); fn use_(&self); - fn copy_assign(&self, _a0: Ptr) -> Ptr; } impl LifetimeTrackedImpl for Ptr { fn construct(&self) { field!((*self), uses).write(0); (*ctorCount_0.with(Value::clone).borrow_mut()).prefix_inc(); } - fn copy_from(&self, _a0: Ptr) { - field!((*self), uses).write(0); - (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); - } fn destructor(&self) { (*dtorCount_2.with(Value::clone).borrow_mut()).prefix_inc(); } @@ -152,9 +168,17 @@ impl LifetimeTrackedImpl for Ptr { }); (*useCount_3.with(Value::clone).borrow_mut()).prefix_inc(); } - fn copy_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), uses).write(_a0.with(|__s| __s.uses)); - return (*self).clone(); +} +impl CopyAssignable for LifetimeTracked { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), uses).write(_a0.with(|__s| __s.uses)); + return (*this).clone(); + } +} +impl CopyConstructible for LifetimeTracked { + fn copy_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), uses).write(0); + (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); } } pub fn __cpp2rust_init_globals() { diff --git a/tests/std/basic/basic.def.odr/p15-inline-function/out/unsafe/p15-inline-function.rs b/tests/std/basic/basic.def.odr/p15-inline-function/out/unsafe/p15-inline-function.rs index a9d8bb2429..dbcae21ff0 100644 --- a/tests/std/basic/basic.def.odr/p15-inline-function/out/unsafe/p15-inline-function.rs +++ b/tests/std/basic/basic.def.odr/p15-inline-function/out/unsafe/p15-inline-function.rs @@ -11,7 +11,14 @@ pub static mut copyCount_1: std::cell::LazyCell = std::cell::LazyCell::new( pub static mut dtorCount_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyAssignUnsafe, DestructibleUnsafe)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + MoveConstructibleUnsafe, + MoveAssignableUnsafe, +)] pub struct LifetimeTracked { pub uses: i32, } @@ -32,10 +39,6 @@ impl LifetimeTracked { (&raw mut self.uses).write(0); (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).prefix_inc(); } - pub unsafe fn copy_from(&mut self, _a0: *const LifetimeTracked) { - (&raw mut self.uses).write(0); - (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)).prefix_inc(); - } pub unsafe fn destructor(&mut self) { (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)).prefix_inc(); } @@ -43,7 +46,15 @@ impl LifetimeTracked { (*(&raw const self.uses).cast_mut()).prefix_inc(); (*std::cell::LazyCell::force_mut(&mut *&raw mut useCount_3)).prefix_inc(); } - pub unsafe fn copy_assign(&mut self, _a0: *const LifetimeTracked) -> *mut LifetimeTracked { +} +impl CopyConstructibleUnsafe for LifetimeTracked { + unsafe fn copy_constructor(&mut self, _a0: *const LifetimeTracked) { + (&raw mut self.uses).write(0); + (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)).prefix_inc(); + } +} +impl CopyAssignableUnsafe for LifetimeTracked { + unsafe fn copy_assign(&mut self, _a0: *const LifetimeTracked) -> *mut LifetimeTracked { self.uses = (*_a0).uses; return &mut (*(self as *mut LifetimeTracked)); } @@ -52,7 +63,7 @@ impl Clone for LifetimeTracked { fn clone(&self) -> Self { unsafe { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::copy_from(&mut __v, self as *const LifetimeTracked); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const LifetimeTracked); __v } } @@ -69,7 +80,18 @@ impl Default for LifetimeTracked { } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct AssertsDtorCountAtExit { pub expected: i32, } diff --git a/tests/std/basic/basic.def.odr/p15-inline-variable/out/refcount/p15-inline-variable.rs b/tests/std/basic/basic.def.odr/p15-inline-variable/out/refcount/p15-inline-variable.rs index 34ebfc62f9..5c6c9d4232 100644 --- a/tests/std/basic/basic.def.odr/p15-inline-variable/out/refcount/p15-inline-variable.rs +++ b/tests/std/basic/basic.def.odr/p15-inline-variable/out/refcount/p15-inline-variable.rs @@ -18,7 +18,16 @@ thread_local!( thread_local!( pub static useCount_3: Value = Rc::new(RefCell::new(0)); ); -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyAssign, Destructible)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + MoveConstructible, + MoveAssignable, +)] #[byte_size(4)] pub struct LifetimeTracked { #[offset(0)] @@ -50,7 +59,7 @@ impl Clone for LifetimeTracked { uses: self.uses.clone(), })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -66,7 +75,20 @@ impl Default for LifetimeTracked { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct AssertsDtorCountAtExit { #[offset(0)] @@ -124,20 +146,14 @@ impl AssertsDtorCountAtExitImpl for Ptr { } pub trait LifetimeTrackedImpl { fn construct(&self); - fn copy_from(&self, _a0: Ptr); fn destructor(&self); fn use_(&self); - fn copy_assign(&self, _a0: Ptr) -> Ptr; } impl LifetimeTrackedImpl for Ptr { fn construct(&self) { field!((*self), uses).write(0); (*ctorCount_0.with(Value::clone).borrow_mut()).prefix_inc(); } - fn copy_from(&self, _a0: Ptr) { - field!((*self), uses).write(0); - (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); - } fn destructor(&self) { (*dtorCount_2.with(Value::clone).borrow_mut()).prefix_inc(); } @@ -147,9 +163,17 @@ impl LifetimeTrackedImpl for Ptr { }); (*useCount_3.with(Value::clone).borrow_mut()).prefix_inc(); } - fn copy_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), uses).write(_a0.with(|__s| __s.uses)); - return (*self).clone(); +} +impl CopyAssignable for LifetimeTracked { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), uses).write(_a0.with(|__s| __s.uses)); + return (*this).clone(); + } +} +impl CopyConstructible for LifetimeTracked { + fn copy_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), uses).write(0); + (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); } } pub fn __cpp2rust_init_globals() { diff --git a/tests/std/basic/basic.def.odr/p15-inline-variable/out/unsafe/p15-inline-variable.rs b/tests/std/basic/basic.def.odr/p15-inline-variable/out/unsafe/p15-inline-variable.rs index 471dc7023e..1113e95331 100644 --- a/tests/std/basic/basic.def.odr/p15-inline-variable/out/unsafe/p15-inline-variable.rs +++ b/tests/std/basic/basic.def.odr/p15-inline-variable/out/unsafe/p15-inline-variable.rs @@ -11,7 +11,14 @@ pub static mut copyCount_1: std::cell::LazyCell = std::cell::LazyCell::new( pub static mut dtorCount_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyAssignUnsafe, DestructibleUnsafe)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + MoveConstructibleUnsafe, + MoveAssignableUnsafe, +)] pub struct LifetimeTracked { pub uses: i32, } @@ -32,10 +39,6 @@ impl LifetimeTracked { (&raw mut self.uses).write(0); (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).prefix_inc(); } - pub unsafe fn copy_from(&mut self, _a0: *const LifetimeTracked) { - (&raw mut self.uses).write(0); - (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)).prefix_inc(); - } pub unsafe fn destructor(&mut self) { (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)).prefix_inc(); } @@ -43,7 +46,15 @@ impl LifetimeTracked { (*(&raw const self.uses).cast_mut()).prefix_inc(); (*std::cell::LazyCell::force_mut(&mut *&raw mut useCount_3)).prefix_inc(); } - pub unsafe fn copy_assign(&mut self, _a0: *const LifetimeTracked) -> *mut LifetimeTracked { +} +impl CopyConstructibleUnsafe for LifetimeTracked { + unsafe fn copy_constructor(&mut self, _a0: *const LifetimeTracked) { + (&raw mut self.uses).write(0); + (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)).prefix_inc(); + } +} +impl CopyAssignableUnsafe for LifetimeTracked { + unsafe fn copy_assign(&mut self, _a0: *const LifetimeTracked) -> *mut LifetimeTracked { self.uses = (*_a0).uses; return &mut (*(self as *mut LifetimeTracked)); } @@ -52,7 +63,7 @@ impl Clone for LifetimeTracked { fn clone(&self) -> Self { unsafe { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::copy_from(&mut __v, self as *const LifetimeTracked); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const LifetimeTracked); __v } } @@ -69,7 +80,18 @@ impl Default for LifetimeTracked { } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct AssertsDtorCountAtExit { pub expected: i32, } diff --git a/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/refcount/p16-default-argument-lambda-in-class.rs b/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/refcount/p16-default-argument-lambda-in-class.rs index 9a21e5e86e..a5826b7908 100644 --- a/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/refcount/p16-default-argument-lambda-in-class.rs +++ b/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/refcount/p16-default-argument-lambda-in-class.rs @@ -18,7 +18,16 @@ thread_local!( thread_local!( pub static useCount_3: Value = Rc::new(RefCell::new(0)); ); -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyAssign, Destructible)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + MoveConstructible, + MoveAssignable, +)] #[byte_size(4)] pub struct LifetimeTracked { #[offset(0)] @@ -50,7 +59,7 @@ impl Clone for LifetimeTracked { uses: self.uses.clone(), })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -66,13 +75,39 @@ impl Default for LifetimeTracked { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct AssertsDtorCountAtExit { #[offset(0)] pub expected: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct X {} thread_local!( @@ -142,20 +177,14 @@ impl AssertsDtorCountAtExitImpl for Ptr { } pub trait LifetimeTrackedImpl { fn construct(&self); - fn copy_from(&self, _a0: Ptr); fn destructor(&self); fn use_(&self); - fn copy_assign(&self, _a0: Ptr) -> Ptr; } impl LifetimeTrackedImpl for Ptr { fn construct(&self) { field!((*self), uses).write(0); (*ctorCount_0.with(Value::clone).borrow_mut()).prefix_inc(); } - fn copy_from(&self, _a0: Ptr) { - field!((*self), uses).write(0); - (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); - } fn destructor(&self) { (*dtorCount_2.with(Value::clone).borrow_mut()).prefix_inc(); } @@ -165,9 +194,17 @@ impl LifetimeTrackedImpl for Ptr { }); (*useCount_3.with(Value::clone).borrow_mut()).prefix_inc(); } - fn copy_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), uses).write(_a0.with(|__s| __s.uses)); - return (*self).clone(); +} +impl CopyAssignable for LifetimeTracked { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), uses).write(_a0.with(|__s| __s.uses)); + return (*this).clone(); + } +} +impl CopyConstructible for LifetimeTracked { + fn copy_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), uses).write(0); + (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); } } pub trait XImpl { diff --git a/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/unsafe/p16-default-argument-lambda-in-class.rs b/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/unsafe/p16-default-argument-lambda-in-class.rs index dc894849a6..14cc3fcf13 100644 --- a/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/unsafe/p16-default-argument-lambda-in-class.rs +++ b/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/unsafe/p16-default-argument-lambda-in-class.rs @@ -11,7 +11,14 @@ pub static mut copyCount_1: std::cell::LazyCell = std::cell::LazyCell::new( pub static mut dtorCount_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyAssignUnsafe, DestructibleUnsafe)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + MoveConstructibleUnsafe, + MoveAssignableUnsafe, +)] pub struct LifetimeTracked { pub uses: i32, } @@ -32,10 +39,6 @@ impl LifetimeTracked { (&raw mut self.uses).write(0); (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).prefix_inc(); } - pub unsafe fn copy_from(&mut self, _a0: *const LifetimeTracked) { - (&raw mut self.uses).write(0); - (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)).prefix_inc(); - } pub unsafe fn destructor(&mut self) { (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)).prefix_inc(); } @@ -43,7 +46,15 @@ impl LifetimeTracked { (*(&raw const self.uses).cast_mut()).prefix_inc(); (*std::cell::LazyCell::force_mut(&mut *&raw mut useCount_3)).prefix_inc(); } - pub unsafe fn copy_assign(&mut self, _a0: *const LifetimeTracked) -> *mut LifetimeTracked { +} +impl CopyConstructibleUnsafe for LifetimeTracked { + unsafe fn copy_constructor(&mut self, _a0: *const LifetimeTracked) { + (&raw mut self.uses).write(0); + (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)).prefix_inc(); + } +} +impl CopyAssignableUnsafe for LifetimeTracked { + unsafe fn copy_assign(&mut self, _a0: *const LifetimeTracked) -> *mut LifetimeTracked { self.uses = (*_a0).uses; return &mut (*(self as *mut LifetimeTracked)); } @@ -52,7 +63,7 @@ impl Clone for LifetimeTracked { fn clone(&self) -> Self { unsafe { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::copy_from(&mut __v, self as *const LifetimeTracked); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const LifetimeTracked); __v } } @@ -69,7 +80,18 @@ impl Default for LifetimeTracked { } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct AssertsDtorCountAtExit { pub expected: i32, } @@ -79,7 +101,18 @@ impl AssertsDtorCountAtExit { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct X {} impl X { pub unsafe fn h(&mut self, mut cond: bool, mut p: Option) { diff --git a/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/refcount/p16-lambda-in-inline-function.rs b/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/refcount/p16-lambda-in-inline-function.rs index 97c52f8bd9..e1c2462747 100644 --- a/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/refcount/p16-lambda-in-inline-function.rs +++ b/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/refcount/p16-lambda-in-inline-function.rs @@ -18,7 +18,16 @@ thread_local!( thread_local!( pub static useCount_3: Value = Rc::new(RefCell::new(0)); ); -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyAssign, Destructible)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + MoveConstructible, + MoveAssignable, +)] #[byte_size(4)] pub struct LifetimeTracked { #[offset(0)] @@ -50,7 +59,7 @@ impl Clone for LifetimeTracked { uses: self.uses.clone(), })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -66,7 +75,20 @@ impl Default for LifetimeTracked { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct AssertsDtorCountAtExit { #[offset(0)] @@ -135,20 +157,14 @@ impl AssertsDtorCountAtExitImpl for Ptr { } pub trait LifetimeTrackedImpl { fn construct(&self); - fn copy_from(&self, _a0: Ptr); fn destructor(&self); fn use_(&self); - fn copy_assign(&self, _a0: Ptr) -> Ptr; } impl LifetimeTrackedImpl for Ptr { fn construct(&self) { field!((*self), uses).write(0); (*ctorCount_0.with(Value::clone).borrow_mut()).prefix_inc(); } - fn copy_from(&self, _a0: Ptr) { - field!((*self), uses).write(0); - (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); - } fn destructor(&self) { (*dtorCount_2.with(Value::clone).borrow_mut()).prefix_inc(); } @@ -158,9 +174,17 @@ impl LifetimeTrackedImpl for Ptr { }); (*useCount_3.with(Value::clone).borrow_mut()).prefix_inc(); } - fn copy_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), uses).write(_a0.with(|__s| __s.uses)); - return (*self).clone(); +} +impl CopyAssignable for LifetimeTracked { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), uses).write(_a0.with(|__s| __s.uses)); + return (*this).clone(); + } +} +impl CopyConstructible for LifetimeTracked { + fn copy_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), uses).write(0); + (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); } } pub fn __cpp2rust_init_globals() { diff --git a/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/unsafe/p16-lambda-in-inline-function.rs b/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/unsafe/p16-lambda-in-inline-function.rs index c4cf98de49..bf64a509d5 100644 --- a/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/unsafe/p16-lambda-in-inline-function.rs +++ b/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/unsafe/p16-lambda-in-inline-function.rs @@ -11,7 +11,14 @@ pub static mut copyCount_1: std::cell::LazyCell = std::cell::LazyCell::new( pub static mut dtorCount_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyAssignUnsafe, DestructibleUnsafe)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + MoveConstructibleUnsafe, + MoveAssignableUnsafe, +)] pub struct LifetimeTracked { pub uses: i32, } @@ -32,10 +39,6 @@ impl LifetimeTracked { (&raw mut self.uses).write(0); (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).prefix_inc(); } - pub unsafe fn copy_from(&mut self, _a0: *const LifetimeTracked) { - (&raw mut self.uses).write(0); - (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)).prefix_inc(); - } pub unsafe fn destructor(&mut self) { (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)).prefix_inc(); } @@ -43,7 +46,15 @@ impl LifetimeTracked { (*(&raw const self.uses).cast_mut()).prefix_inc(); (*std::cell::LazyCell::force_mut(&mut *&raw mut useCount_3)).prefix_inc(); } - pub unsafe fn copy_assign(&mut self, _a0: *const LifetimeTracked) -> *mut LifetimeTracked { +} +impl CopyConstructibleUnsafe for LifetimeTracked { + unsafe fn copy_constructor(&mut self, _a0: *const LifetimeTracked) { + (&raw mut self.uses).write(0); + (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)).prefix_inc(); + } +} +impl CopyAssignableUnsafe for LifetimeTracked { + unsafe fn copy_assign(&mut self, _a0: *const LifetimeTracked) -> *mut LifetimeTracked { self.uses = (*_a0).uses; return &mut (*(self as *mut LifetimeTracked)); } @@ -52,7 +63,7 @@ impl Clone for LifetimeTracked { fn clone(&self) -> Self { unsafe { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::copy_from(&mut __v, self as *const LifetimeTracked); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const LifetimeTracked); __v } } @@ -69,7 +80,18 @@ impl Default for LifetimeTracked { } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct AssertsDtorCountAtExit { pub expected: i32, } diff --git a/tests/std/basic/basic.link/out/refcount/basic.link.rs b/tests/std/basic/basic.link/out/refcount/basic.link.rs index 41793dcac4..5f95a00a73 100644 --- a/tests/std/basic/basic.link/out/refcount/basic.link.rs +++ b/tests/std/basic/basic.link/out/refcount/basic.link.rs @@ -29,7 +29,17 @@ pub fn test_11() { assert!((ceiling_10.with(|rc| *rc.borrow()) == 40)); assert!(((ceiling_10.with(|v| v.as_pointer())) == ({ ceiling_address_in_b_12() }))); } -#[derive(VaArg, FnPtrArg, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + ByteRepr, + Clone, + ZeroInitialization, +)] #[byte_size(4)] pub struct anon_13 { #[offset(0)] @@ -67,7 +77,19 @@ thread_local!( pub fn bump_18() -> i32 { return (*(*counter_17.with(Value::clone).borrow_mut()).prefix_inc()); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(4)] pub struct Record_19 { #[offset(0)] @@ -103,7 +125,20 @@ pub fn test_29() { level_28.with(|rc| *rc.borrow_mut() = 10); assert!((({ raise_30(1,) }) == 11)); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct Tally_31 {} thread_local!( @@ -115,7 +150,20 @@ pub fn test_33() { assert!((({ add_in_b_34(1,) }) == 102)); assert!((total_32.with(|rc| *rc.borrow()) == 11)); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct p5_members_of_class_with_external_linkage_Ledger {} pub fn test_36() { @@ -183,7 +231,19 @@ pub fn test_55() { assert!((({ second_key_plus_value_53() }) == 32)); assert!((({ key_in_b_56() }) == 400)); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(4)] pub struct Entry_52 { #[offset(0)] @@ -194,7 +254,19 @@ impl Default for Entry_52 { { Entry_52 { key: 1 } } } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(8)] pub struct Entry_54 { #[offset(0)] @@ -266,7 +338,17 @@ thread_local!( pub fn ceiling_address_in_b_12() -> Ptr { return (ceiling_10.with(|v| v.as_pointer())); } -#[derive(VaArg, FnPtrArg, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + ByteRepr, + Clone, + ZeroInitialization, +)] #[byte_size(4)] pub struct anon_62 { #[offset(0)] @@ -304,7 +386,19 @@ thread_local!( pub fn bump_64() -> i32 { return (*(*counter_63.with(Value::clone).borrow_mut()).prefix_inc()); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(16)] pub struct Record_65 { #[offset(0)] @@ -348,7 +442,20 @@ pub fn raise_30(mut by: i32) -> i32 { level_28.with(|rc| *rc.borrow_mut() += by); return level_28.with(|rc| *rc.borrow()); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct Tally_67 {} thread_local!( @@ -390,7 +497,19 @@ pub fn key_in_b_56() -> i32 { let mut entry: Entry_71 = ::default(); return (entry.key as i32); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(8)] pub struct Entry_71 { #[offset(0)] diff --git a/tests/std/basic/basic.link/out/unsafe/basic.link.rs b/tests/std/basic/basic.link/out/unsafe/basic.link.rs index e387afab9a..f5200515a8 100644 --- a/tests/std/basic/basic.link/out/unsafe/basic.link.rs +++ b/tests/std/basic/basic.link/out/unsafe/basic.link.rs @@ -37,7 +37,17 @@ pub unsafe fn test_11() { ); } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub union anon_13 { pub whole: i32, pub fraction: f32, @@ -60,7 +70,17 @@ pub unsafe fn bump_18() -> i32 { return (*(*std::cell::LazyCell::force_mut(&mut *&raw mut counter_17)).prefix_inc()); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct Record_19 { pub id: i32, } @@ -93,7 +113,18 @@ pub unsafe fn test_29() { assert!(((unsafe { raise_30(1,) }) == (11))); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Tally_31 {} impl Tally_31 { pub unsafe fn add(&mut self, mut amount: i32) -> i32 { @@ -109,7 +140,18 @@ pub unsafe fn test_33() { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut total_32)) == (11))); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p5_members_of_class_with_external_linkage_Ledger {} pub unsafe fn test_36() { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut balance_35)) == (50))); @@ -171,7 +213,17 @@ pub unsafe fn test_55() { assert!(((unsafe { key_in_b_56() }) == (400))); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct Entry_52 { pub key: i32, } @@ -181,7 +233,17 @@ impl Default for Entry_52 { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct Entry_54 { pub key: i32, pub value: i32, @@ -243,7 +305,17 @@ pub unsafe fn ceiling_address_in_b_12() -> *const i32 { return (&raw const (*std::cell::LazyCell::force_mut(&mut *&raw mut ceiling_10)) as *const i32); } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub union anon_62 { pub whole: i32, pub fraction: f32, @@ -266,7 +338,17 @@ pub unsafe fn bump_64() -> i32 { return (*(*std::cell::LazyCell::force_mut(&mut *&raw mut counter_63)).prefix_inc()); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct Record_65 { pub id: i64, pub extra: i32, @@ -303,7 +385,18 @@ pub unsafe fn raise_30(mut by: i32) -> i32 { return (*std::cell::LazyCell::force_mut(&mut *&raw mut level_28)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Tally_67 {} impl Tally_67 { pub unsafe fn add(&mut self, mut amount: i32) -> i32 { @@ -341,7 +434,17 @@ pub unsafe fn key_in_b_56() -> i32 { return (entry.key as i32); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct Entry_71 { pub key: i64, } diff --git a/tests/std/basic/basic.scope/out/refcount/basic.scope.block.rs b/tests/std/basic/basic.scope/out/refcount/basic.scope.block.rs index 96054d9eed..181d855811 100644 --- a/tests/std/basic/basic.scope/out/refcount/basic.scope.block.rs +++ b/tests/std/basic/basic.scope/out/refcount/basic.scope.block.rs @@ -18,7 +18,16 @@ thread_local!( thread_local!( pub static useCount_3: Value = Rc::new(RefCell::new(0)); ); -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyAssign, Destructible)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + MoveConstructible, + MoveAssignable, +)] #[byte_size(4)] pub struct LifetimeTracked { #[offset(0)] @@ -50,7 +59,7 @@ impl Clone for LifetimeTracked { uses: self.uses.clone(), })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -75,7 +84,20 @@ thread_local!( thread_local!( pub static dtorCount_6: Value = Rc::new(RefCell::new(0)); ); -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct p1_1_condition_variable_visible_in_else_ConvertsToBool { #[offset(0)] @@ -329,20 +351,14 @@ fn main_0() -> i32 { } pub trait LifetimeTrackedImpl { fn construct(&self); - fn copy_from(&self, _a0: Ptr); fn destructor(&self); fn use_(&self); - fn copy_assign(&self, _a0: Ptr) -> Ptr; } impl LifetimeTrackedImpl for Ptr { fn construct(&self) { field!((*self), uses).write(0); (*ctorCount_0.with(Value::clone).borrow_mut()).prefix_inc(); } - fn copy_from(&self, _a0: Ptr) { - field!((*self), uses).write(0); - (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); - } fn destructor(&self) { (*dtorCount_2.with(Value::clone).borrow_mut()).prefix_inc(); } @@ -352,9 +368,17 @@ impl LifetimeTrackedImpl for Ptr { }); (*useCount_3.with(Value::clone).borrow_mut()).prefix_inc(); } - fn copy_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), uses).write(_a0.with(|__s| __s.uses)); - return (*self).clone(); +} +impl CopyAssignable for LifetimeTracked { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), uses).write(_a0.with(|__s| __s.uses)); + return (*this).clone(); + } +} +impl CopyConstructible for LifetimeTracked { + fn copy_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), uses).write(0); + (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); } } pub trait p1_1_condition_variable_visible_in_else_ConvertsToBoolImpl { diff --git a/tests/std/basic/basic.scope/out/refcount/basic.scope.class.rs b/tests/std/basic/basic.scope/out/refcount/basic.scope.class.rs index d4746df16b..9349e7baa0 100644 --- a/tests/std/basic/basic.scope/out/refcount/basic.scope.class.rs +++ b/tests/std/basic/basic.scope/out/refcount/basic.scope.class.rs @@ -9,7 +9,19 @@ use std::rc::{Rc, Weak}; thread_local!( pub static balance_0: Value = Rc::new(RefCell::new(50)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(4)] pub struct p1_member_hides_namespace_variable_HasBalance { #[offset(0)] @@ -45,7 +57,19 @@ pub fn test_1() { thread_local!( pub static initial_2: Value = Rc::new(RefCell::new(100)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(4)] pub struct p1_out_of_class_definition_is_in_class_scope_HasStaticTotal { #[offset(0)] diff --git a/tests/std/basic/basic.scope/out/refcount/basic.scope.param.rs b/tests/std/basic/basic.scope/out/refcount/basic.scope.param.rs index 43c9eec869..3e024ac3a3 100644 --- a/tests/std/basic/basic.scope/out/refcount/basic.scope.param.rs +++ b/tests/std/basic/basic.scope/out/refcount/basic.scope.param.rs @@ -6,7 +6,21 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct p1_1_parameter_hides_member_in_constructor_HasMemberNamedLikeParameter { diff --git a/tests/std/basic/basic.scope/out/refcount/basic.scope.pdecl.rs b/tests/std/basic/basic.scope/out/refcount/basic.scope.pdecl.rs index da1b9d66d1..4d40eb4dd4 100644 --- a/tests/std/basic/basic.scope/out/refcount/basic.scope.pdecl.rs +++ b/tests/std/basic/basic.scope/out/refcount/basic.scope.pdecl.rs @@ -18,7 +18,19 @@ pub fn test_0() { } assert!((level == 5)); } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct p1_own_address_in_initializer_SelfLinked { #[offset(0)] @@ -73,7 +85,18 @@ pub fn test_3() { pub type anon_4 = u32; pub const anon_4_limit: anon_4 = 13; pub const anon_4_above: anon_4 = 14; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(8)] pub struct p9_func_declared_before_function_body_RecordsConstructorName { #[offset(0)] diff --git a/tests/std/basic/basic.scope/out/refcount/basic.scope.scope.rs b/tests/std/basic/basic.scope/out/refcount/basic.scope.scope.rs index 20d909a493..cd35351468 100644 --- a/tests/std/basic/basic.scope/out/refcount/basic.scope.scope.rs +++ b/tests/std/basic/basic.scope/out/refcount/basic.scope.scope.rs @@ -44,7 +44,20 @@ pub const p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum_Size_small: p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum_Size = 3; pub const p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum_Size_large: p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum_Size = 8; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum {} pub fn test_5() { @@ -72,7 +85,20 @@ pub fn test_5() { thread_local!( pub static count_6: Value = Rc::new(RefCell::new(0)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct p2_12_class_name_in_own_scope_HasStaticCounter {} impl p2_12_class_name_in_own_scope_HasStaticCounter { @@ -88,7 +114,17 @@ pub fn test_7() { count_6.with(|rc| *rc.borrow_mut() = 6); assert!((count_6.with(|rc| *rc.borrow()) == 6)); } -#[derive(VaArg, FnPtrArg, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + ByteRepr, + Clone, + ZeroInitialization, +)] #[byte_size(8)] pub struct anon_8 { #[offset(0)] @@ -114,7 +150,17 @@ impl Default for anon_8 { thread_local!( pub static anon_8: Value = Rc::new(RefCell::new(::default())); ); -#[derive(VaArg, FnPtrArg, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + ByteRepr, + Clone, + ZeroInitialization, +)] #[byte_size(8)] pub struct anon_9 { #[offset(0)] @@ -137,7 +183,19 @@ impl Default for anon_9 { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct p2_13_anonymous_union_members_in_parent_scope_HasAnonymousUnion { #[offset(0)] @@ -173,7 +231,17 @@ pub fn test_10() { anon_11::block_ratio(anon_11.as_pointer()).write(0.75_f64); assert!(((anon_11::block_ratio(anon_11.as_pointer()).read()) == 0.75_f64)); } -#[derive(VaArg, FnPtrArg, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + ByteRepr, + Clone, + ZeroInitialization, +)] #[byte_size(8)] pub struct anon_11 { #[offset(0)] @@ -196,7 +264,19 @@ impl Default for anon_11 { } } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(8)] pub struct p3_2_const_qualified_member_is_distinct_HasConstOverload { #[offset(0)] @@ -240,7 +320,19 @@ thread_local!( thread_local!( pub static rvalue_calls_14: Value = Rc::new(RefCell::new(0)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(4)] pub struct p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload { #[offset(0)] @@ -282,7 +374,20 @@ thread_local!( thread_local!( pub static rvalue_calls_17: Value = Rc::new(RefCell::new(0)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct p3_2_ref_qualified_members_are_distinct_HasRefQualifiedOverloads {} pub fn test_18() { @@ -320,7 +425,19 @@ pub fn test_18() { assert!((lvalue_calls_16.with(|rc| *rc.borrow()) == 1)); assert!((rvalue_calls_17.with(|rc| *rc.borrow()) == 2)); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(8)] pub struct p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload { #[offset(0)] @@ -367,7 +484,20 @@ thread_local!( thread_local!( pub static rvalue_calls_21: Value = Rc::new(RefCell::new(0)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct p3_4_ref_qualified_member_templates_are_distinct_HasRefQualifiedTemplateOverloads {} pub fn test_22() { @@ -397,14 +527,40 @@ pub fn test_22() { thread_local!( pub static friend_calls_23: Value = Rc::new(RefCell::new(0_i32)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct p4_friend_definition_defines_earlier_friend_declaration_DeclaresFriend {} pub fn shared_friend_24() -> i32 { (*friend_calls_23.with(Value::clone).borrow_mut()).prefix_inc(); return 7; } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct p4_friend_definition_defines_earlier_friend_declaration_DefinesFriend {} pub fn test_25() { @@ -436,7 +592,20 @@ pub fn test_30() { thread_local!( pub static function_calls_31: Value = Rc::new(RefCell::new(0_i32)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct p4_2_class_and_function_share_name_Reading { #[offset(0)] @@ -454,7 +623,20 @@ pub fn test_33() { assert!((({ Reading_32(reading.value,) }) == 5)); assert!((function_calls_31.with(|rc| *rc.borrow()) == 1)); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct p4_2_class_and_variable_share_name_Limit { #[offset(0)] diff --git a/tests/std/basic/basic.scope/out/unsafe/basic.scope.block.rs b/tests/std/basic/basic.scope/out/unsafe/basic.scope.block.rs index d5f103c910..54cde79104 100644 --- a/tests/std/basic/basic.scope/out/unsafe/basic.scope.block.rs +++ b/tests/std/basic/basic.scope/out/unsafe/basic.scope.block.rs @@ -11,7 +11,14 @@ pub static mut copyCount_1: std::cell::LazyCell = std::cell::LazyCell::new( pub static mut dtorCount_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyAssignUnsafe, DestructibleUnsafe)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + MoveConstructibleUnsafe, + MoveAssignableUnsafe, +)] pub struct LifetimeTracked { pub uses: i32, } @@ -32,10 +39,6 @@ impl LifetimeTracked { (&raw mut self.uses).write(0); (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).prefix_inc(); } - pub unsafe fn copy_from(&mut self, _a0: *const LifetimeTracked) { - (&raw mut self.uses).write(0); - (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)).prefix_inc(); - } pub unsafe fn destructor(&mut self) { (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)).prefix_inc(); } @@ -43,7 +46,15 @@ impl LifetimeTracked { (*(&raw const self.uses).cast_mut()).prefix_inc(); (*std::cell::LazyCell::force_mut(&mut *&raw mut useCount_3)).prefix_inc(); } - pub unsafe fn copy_assign(&mut self, _a0: *const LifetimeTracked) -> *mut LifetimeTracked { +} +impl CopyConstructibleUnsafe for LifetimeTracked { + unsafe fn copy_constructor(&mut self, _a0: *const LifetimeTracked) { + (&raw mut self.uses).write(0); + (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)).prefix_inc(); + } +} +impl CopyAssignableUnsafe for LifetimeTracked { + unsafe fn copy_assign(&mut self, _a0: *const LifetimeTracked) -> *mut LifetimeTracked { self.uses = (*_a0).uses; return &mut (*(self as *mut LifetimeTracked)); } @@ -52,7 +63,7 @@ impl Clone for LifetimeTracked { fn clone(&self) -> Self { unsafe { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::copy_from(&mut __v, self as *const LifetimeTracked); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const LifetimeTracked); __v } } @@ -74,7 +85,18 @@ pub static mut else_runs_5: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0_i32 }); pub static mut dtorCount_6: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p1_1_condition_variable_visible_in_else_ConvertsToBool { pub value: i32, } diff --git a/tests/std/basic/basic.scope/out/unsafe/basic.scope.class.rs b/tests/std/basic/basic.scope/out/unsafe/basic.scope.class.rs index d332543beb..134f0a879d 100644 --- a/tests/std/basic/basic.scope/out/unsafe/basic.scope.class.rs +++ b/tests/std/basic/basic.scope/out/unsafe/basic.scope.class.rs @@ -8,7 +8,17 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub static mut balance_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 50 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct p1_member_hides_namespace_variable_HasBalance { pub balance: i32, } @@ -46,7 +56,17 @@ pub unsafe fn test_1() { } pub static mut initial_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 100 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct p1_out_of_class_definition_is_in_class_scope_HasStaticTotal { pub held: i32, } diff --git a/tests/std/basic/basic.scope/out/unsafe/basic.scope.param.rs b/tests/std/basic/basic.scope/out/unsafe/basic.scope.param.rs index 7a8e0eb7ff..f60a1d70a2 100644 --- a/tests/std/basic/basic.scope/out/unsafe/basic.scope.param.rs +++ b/tests/std/basic/basic.scope/out/unsafe/basic.scope.param.rs @@ -7,7 +7,19 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct p1_1_parameter_hides_member_in_constructor_HasMemberNamedLikeParameter { pub amount: i32, diff --git a/tests/std/basic/basic.scope/out/unsafe/basic.scope.pdecl.rs b/tests/std/basic/basic.scope/out/unsafe/basic.scope.pdecl.rs index 6f6d6ec66c..7f1678c14f 100644 --- a/tests/std/basic/basic.scope/out/unsafe/basic.scope.pdecl.rs +++ b/tests/std/basic/basic.scope/out/unsafe/basic.scope.pdecl.rs @@ -19,7 +19,18 @@ pub unsafe fn test_0() { assert!(((level) == (5))); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p1_own_address_in_initializer_SelfLinked { pub next: *mut p1_own_address_in_initializer_SelfLinked, pub value: i32, @@ -72,7 +83,17 @@ pub type anon_4 = u32; pub const anon_4_limit: anon_4 = 13; pub const anon_4_above: anon_4 = 14; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct p9_func_declared_before_function_body_RecordsConstructorName { pub name: *const libc::c_char, } diff --git a/tests/std/basic/basic.scope/out/unsafe/basic.scope.scope.rs b/tests/std/basic/basic.scope/out/unsafe/basic.scope.scope.rs index 139e923e4d..9fe830f984 100644 --- a/tests/std/basic/basic.scope/out/unsafe/basic.scope.scope.rs +++ b/tests/std/basic/basic.scope/out/unsafe/basic.scope.scope.rs @@ -42,7 +42,18 @@ pub const p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum_Size_small: pub const p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum_Size_large: p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum_Size = 8; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum {} impl p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum { pub unsafe fn scale(&self, mut count: i32) -> i32 { @@ -69,7 +80,18 @@ pub unsafe fn test_5() { } pub static mut count_6: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p2_12_class_name_in_own_scope_HasStaticCounter {} impl p2_12_class_name_in_own_scope_HasStaticCounter { pub unsafe fn bump() { @@ -85,7 +107,17 @@ pub unsafe fn test_7() { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut count_6)) == (6))); } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub union anon_8 { pub namespace_count: i32, pub namespace_ratio: f64, @@ -98,7 +130,17 @@ impl Default for anon_8 { pub static mut anon_8: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { ::default() }); #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub union anon_9 { pub member_count: i32, pub member_ratio: f64, @@ -109,7 +151,18 @@ impl Default for anon_9 { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p2_13_anonymous_union_members_in_parent_scope_HasAnonymousUnion { pub tag: i32, pub anon_9: anon_9, @@ -146,7 +199,17 @@ pub unsafe fn test_10() { assert!(((anon_11.block_ratio) == (0.75_f64))); } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub union anon_11 { pub block_count: i32, pub block_ratio: f64, @@ -157,7 +220,17 @@ impl Default for anon_11 { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct p3_2_const_qualified_member_is_distinct_HasConstOverload { pub plain_calls: i32, pub const_calls: i32, @@ -205,7 +278,17 @@ pub static mut explicit_calls_13: std::cell::LazyCell = pub static mut rvalue_calls_14: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload { pub base: i32, } @@ -257,7 +340,18 @@ pub static mut lvalue_calls_16: std::cell::LazyCell = pub static mut rvalue_calls_17: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p3_2_ref_qualified_members_are_distinct_HasRefQualifiedOverloads {} impl p3_2_ref_qualified_members_are_distinct_HasRefQualifiedOverloads { pub unsafe fn get_1(&mut self) -> i32 { @@ -297,7 +391,17 @@ pub unsafe fn test_18() { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut rvalue_calls_17)) == (2))); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload { pub plain_calls: i32, pub const_calls: i32, @@ -353,7 +457,18 @@ pub static mut lvalue_calls_20: std::cell::LazyCell = pub static mut rvalue_calls_21: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p3_4_ref_qualified_member_templates_are_distinct_HasRefQualifiedTemplateOverloads {} impl p3_4_ref_qualified_member_templates_are_distinct_HasRefQualifiedTemplateOverloads { pub unsafe fn get_1_int(&mut self, mut value: i32) -> i32 { @@ -392,14 +507,36 @@ pub unsafe fn test_22() { pub static mut friend_calls_23: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0_i32 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p4_friend_definition_defines_earlier_friend_declaration_DeclaresFriend {} pub unsafe fn shared_friend_24() -> i32 { (*std::cell::LazyCell::force_mut(&mut *&raw mut friend_calls_23)).prefix_inc(); return 7; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p4_friend_definition_defines_earlier_friend_declaration_DefinesFriend {} pub unsafe fn test_25() { assert!(((unsafe { shared_friend_24() }) == (7))); @@ -428,7 +565,18 @@ pub unsafe fn test_30() { pub static mut function_calls_31: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0_i32 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p4_2_class_and_function_share_name_Reading { pub value: i32, } @@ -445,7 +593,18 @@ pub unsafe fn test_33() { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut function_calls_31)) == (1))); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p4_2_class_and_variable_share_name_Limit { pub value: i32, } diff --git a/tests/std/basic/basic.start/out/refcount/basic.start.term-p1-exit.rs b/tests/std/basic/basic.start/out/refcount/basic.start.term-p1-exit.rs index 3f53a0a454..4961e3e839 100644 --- a/tests/std/basic/basic.start/out/refcount/basic.start.term-p1-exit.rs +++ b/tests/std/basic/basic.start/out/refcount/basic.start.term-p1-exit.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Tracker { #[offset(0)] diff --git a/tests/std/basic/basic.start/out/refcount/basic.start.term.rs b/tests/std/basic/basic.start/out/refcount/basic.start.term.rs index 58b75dbf81..f32b391eb6 100644 --- a/tests/std/basic/basic.start/out/refcount/basic.start.term.rs +++ b/tests/std/basic/basic.start/out/refcount/basic.start.term.rs @@ -6,20 +6,59 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Tracker { #[offset(0)] pub tag: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct HoldsTracker { #[offset(0)] #[byte_size(4)] pub member: Tracker, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct TriviallyDestructible { #[offset(0)] @@ -107,7 +146,20 @@ thread_local!( pub static trivial_9: Value = Rc::new(RefCell::new(TriviallyDestructible { value: 6 })); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct p3_reverse_completion_order_WithStaticMember {} thread_local!( diff --git a/tests/std/basic/basic.start/out/unsafe/basic.start.term-p1-exit.rs b/tests/std/basic/basic.start/out/unsafe/basic.start.term-p1-exit.rs index dabbb973ac..7f3a3b533c 100644 --- a/tests/std/basic/basic.start/out/unsafe/basic.start.term-p1-exit.rs +++ b/tests/std/basic/basic.start/out/unsafe/basic.start.term-p1-exit.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Tracker { pub tag: i32, } diff --git a/tests/std/basic/basic.start/out/unsafe/basic.start.term.rs b/tests/std/basic/basic.start/out/unsafe/basic.start.term.rs index 1dcdcb2ff4..decfa1dee2 100644 --- a/tests/std/basic/basic.start/out/unsafe/basic.start.term.rs +++ b/tests/std/basic/basic.start/out/unsafe/basic.start.term.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Tracker { pub tag: i32, } @@ -24,7 +35,18 @@ impl Tracker { } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct HoldsTracker { pub member: Tracker, } @@ -34,7 +56,18 @@ impl HoldsTracker { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct TriviallyDestructible { pub value: i32, } @@ -132,7 +165,18 @@ pub static mut holder_8: std::cell::LazyCell = std::cell::LazyCell pub static mut trivial_9: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { TriviallyDestructible { value: 6 } }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p3_reverse_completion_order_WithStaticMember {} pub static mut member_10: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { { diff --git a/tests/std/basic/basic.types/out/refcount/basic.types.general.rs b/tests/std/basic/basic.types/out/refcount/basic.types.general.rs index d50e4c91c2..30c46c525c 100644 --- a/tests/std/basic/basic.types/out/refcount/basic.types.general.rs +++ b/tests/std/basic/basic.types/out/refcount/basic.types.general.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct p2_pointer_to_data_member_bytes_round_trip_HasTwoInts { #[offset(0)] @@ -69,7 +82,20 @@ pub fn test_0() { }; assert!(({ ((*null_pm.borrow()) == -1_isize) })); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct p3_pointer_to_data_member_bytes_copied_to_other_object_HasTwoInts { #[offset(0)] diff --git a/tests/std/basic/basic.types/out/unsafe/basic.types.general.rs b/tests/std/basic/basic.types/out/unsafe/basic.types.general.rs index 954591d54c..a8ce54ab14 100644 --- a/tests/std/basic/basic.types/out/unsafe/basic.types.general.rs +++ b/tests/std/basic/basic.types/out/unsafe/basic.types.general.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p2_pointer_to_data_member_bytes_round_trip_HasTwoInts { pub first: i32, pub second: i32, @@ -76,7 +87,18 @@ pub unsafe fn test_0() { assert!(((null_pm) == -1_isize)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p3_pointer_to_data_member_bytes_copied_to_other_object_HasTwoInts { pub first: i32, pub second: i32, diff --git a/tests/std/basic/out/refcount/basic.def.odr.rs b/tests/std/basic/out/refcount/basic.def.odr.rs index 201482e23f..e771c59df2 100644 --- a/tests/std/basic/out/refcount/basic.def.odr.rs +++ b/tests/std/basic/out/refcount/basic.def.odr.rs @@ -9,7 +9,17 @@ use std::rc::{Rc, Weak}; thread_local!( pub static copyCount_0: Value = Rc::new(RefCell::new(0)); ); -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, CopyAssign, Default)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + MoveConstructible, + MoveAssignable, + Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct HasConstexprCtor { @@ -26,7 +36,7 @@ impl Clone for HasConstexprCtor { let __src: Value = Rc::new(RefCell::new(HasConstexprCtor { m: self.m.clone() })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - HasConstexprCtorImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -42,7 +52,16 @@ thread_local!( thread_local!( pub static useCount_4: Value = Rc::new(RefCell::new(0)); ); -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyAssign, Destructible)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + MoveConstructible, + MoveAssignable, +)] #[byte_size(4)] pub struct LifetimeTracked { #[offset(0)] @@ -74,7 +93,7 @@ impl Clone for LifetimeTracked { uses: self.uses.clone(), })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -233,7 +252,20 @@ thread_local!( pub trait p4_1_pure_virtual_without_definition_HasPureVirtual { fn f(&mut self); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct p4_1_pure_virtual_without_definition_OverridesPureVirtual {} pub fn test_11() { @@ -285,7 +317,7 @@ pub fn test_14() { let r: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::copy_from(&__v.as_pointer(), { (r).clone() }); + CopyConstructible::copy_constructor(&__v.as_pointer(), { (r).clone() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); }, @@ -326,7 +358,7 @@ pub fn test_16() { let k: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - HasConstexprCtorImpl::copy_from(&__v.as_pointer(), { k.as_pointer() }); + CopyConstructible::copy_constructor(&__v.as_pointer(), { k.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); }, @@ -334,7 +366,7 @@ pub fn test_16() { let mut c: HasConstexprCtor = { let __v: Value = Rc::new(RefCell::new(::zero_init())); - HasConstexprCtorImpl::copy_from(&__v.as_pointer(), { k.as_pointer() }); + CopyConstructible::copy_constructor(&__v.as_pointer(), { k.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; return c.m; @@ -357,7 +389,17 @@ pub fn test_17() { thread_local!( pub static copies_18: Value = Rc::new(RefCell::new(0_i32)); ); -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, CopyAssign, Default)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + MoveConstructible, + MoveAssignable, + Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(8)] pub struct p5_2_mutable_subobject_is_odr_used_HasMutableMember { @@ -377,10 +419,7 @@ impl Clone for p5_2_mutable_subobject_is_odr_used_HasMutableMember { let __v: Value = Rc::new( RefCell::new(::zero_init()), ); - p5_2_mutable_subobject_is_odr_used_HasMutableMemberImpl::copy_from( - &__v.as_pointer(), - __src.as_pointer(), - ); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -402,10 +441,7 @@ pub fn test_19() { Rc::new(RefCell::new( ::zero_init(), )); - p5_2_mutable_subobject_is_odr_used_HasMutableMemberImpl::copy_from( - &__v.as_pointer(), - { k.as_pointer() }, - ); + CopyConstructible::copy_constructor(&__v.as_pointer(), { k.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); }, @@ -418,7 +454,17 @@ pub fn test_19() { assert!((copies_18.with(|rc| *rc.borrow()) == 1)); } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyAssign, Destructible, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + CopyConstructible, + MoveConstructible, + MoveAssignable, + Default, )] #[byte_size(8)] pub struct p6_unevaluated_binding_needs_no_capture_HasTwoMembers { @@ -462,7 +508,16 @@ pub fn test_20() { assert!((useCount_4.with(|rc| *rc.borrow()) == 0)); } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyAssign, Destructible, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + CopyConstructible, + MoveConstructible, + MoveAssignable, )] #[byte_size(8)] pub struct p7_member_access_captures_this_HasMemberUsedInLambda { @@ -501,7 +556,17 @@ pub fn test_22() { assert!((copyCount_2.with(|rc| *rc.borrow()) == 0)); } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyAssign, Destructible, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + CopyConstructible, + MoveConstructible, + MoveAssignable, + Default, )] #[byte_size(4)] pub struct p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda { @@ -548,7 +613,19 @@ pub fn test_26() { thread_local!( pub static t_ctors_27: Value = Rc::new(RefCell::new(0_i32)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(1)] pub struct p9_destructor_not_potentially_invoked_HasUndefinedDestructor {} impl Default for p9_destructor_not_potentially_invoked_HasUndefinedDestructor { @@ -620,7 +697,19 @@ pub fn test_31() { thread_local!( pub static m_ctors_32: Value = Rc::new(RefCell::new(0_i32)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(1)] pub struct p9_unused_implicit_assignment_HasUndefinedCopyAssignment {} impl Default for p9_unused_implicit_assignment_HasUndefinedCopyAssignment { @@ -639,7 +728,20 @@ impl Default for p9_unused_implicit_assignment_HasUndefinedCopyAssignment { } } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct p9_unused_implicit_assignment_HasMemberWithUndefinedCopyAssignment { #[offset(0)] @@ -786,38 +888,34 @@ impl p4_1_pure_virtual_without_definition_HasPureVirtual } pub trait HasConstexprCtorImpl { fn construct(&self, v: i32); - fn copy_from(&self, o: Ptr); - fn copy_assign(&self, _a0: Ptr) -> Ptr; } impl HasConstexprCtorImpl for Ptr { fn construct(&self, mut v: i32) { field!((*self), m).write(v); } - fn copy_from(&self, o: Ptr) { - field!((*self), m).write(o.with(|__s| __s.m)); - (*copyCount_0.with(Value::clone).borrow_mut()).prefix_inc(); +} +impl CopyAssignable for HasConstexprCtor { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), m).write(_a0.with(|__s| __s.m)); + return (*this).clone(); } - fn copy_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), m).write(_a0.with(|__s| __s.m)); - return (*self).clone(); +} +impl CopyConstructible for HasConstexprCtor { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), m).write(o.with(|__s| __s.m)); + (*copyCount_0.with(Value::clone).borrow_mut()).prefix_inc(); } } pub trait LifetimeTrackedImpl { fn construct(&self); - fn copy_from(&self, _a0: Ptr); fn destructor(&self); fn use_(&self); - fn copy_assign(&self, _a0: Ptr) -> Ptr; } impl LifetimeTrackedImpl for Ptr { fn construct(&self) { field!((*self), uses).write(0); (*ctorCount_1.with(Value::clone).borrow_mut()).prefix_inc(); } - fn copy_from(&self, _a0: Ptr) { - field!((*self), uses).write(0); - (*copyCount_2.with(Value::clone).borrow_mut()).prefix_inc(); - } fn destructor(&self) { (*dtorCount_3.with(Value::clone).borrow_mut()).prefix_inc(); } @@ -827,18 +925,21 @@ impl LifetimeTrackedImpl for Ptr { }); (*useCount_4.with(Value::clone).borrow_mut()).prefix_inc(); } - fn copy_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), uses).write(_a0.with(|__s| __s.uses)); - return (*self).clone(); +} +impl CopyAssignable for LifetimeTracked { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), uses).write(_a0.with(|__s| __s.uses)); + return (*this).clone(); + } +} +impl CopyConstructible for LifetimeTracked { + fn copy_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), uses).write(0); + (*copyCount_2.with(Value::clone).borrow_mut()).prefix_inc(); } } pub trait p5_2_mutable_subobject_is_odr_used_HasMutableMemberImpl { fn construct(&self, v: i32); - fn copy_from(&self, o: Ptr); - fn copy_assign( - &self, - _a0: Ptr, - ) -> Ptr; } impl p5_2_mutable_subobject_is_odr_used_HasMutableMemberImpl for Ptr @@ -847,49 +948,50 @@ impl p5_2_mutable_subobject_is_odr_used_HasMutableMemberImpl field!((*self), value).write(v); field!((*self), scratch).write(0); } - fn copy_from(&self, o: Ptr) { - field!((*self), value).write(o.with(|__s| __s.value)); - field!((*self), scratch).write(o.with(|__s| __s.scratch)); - (*copies_18.with(Value::clone).borrow_mut()).prefix_inc(); - } +} +impl CopyAssignable for p5_2_mutable_subobject_is_odr_used_HasMutableMember { fn copy_assign( - &self, + this: &Ptr, _a0: Ptr, ) -> Ptr { - field!((*self), value).write(_a0.with(|__s| __s.value)); - field!((*self), scratch).write(_a0.with(|__s| __s.scratch)); - return (*self).clone(); + field!((*this), value).write(_a0.with(|__s| __s.value)); + field!((*this), scratch).write(_a0.with(|__s| __s.scratch)); + return (*this).clone(); + } +} +impl CopyConstructible for p5_2_mutable_subobject_is_odr_used_HasMutableMember { + fn copy_constructor( + this: &Ptr, + o: Ptr, + ) { + field!((*this), value).write(o.with(|__s| __s.value)); + field!((*this), scratch).write(o.with(|__s| __s.scratch)); + (*copies_18.with(Value::clone).borrow_mut()).prefix_inc(); } } pub trait p6_unevaluated_binding_needs_no_capture_HasTwoMembersImpl { - fn copy_assign( - &self, - _a0: Ptr, - ) -> Ptr; fn destructor(&self); } impl p6_unevaluated_binding_needs_no_capture_HasTwoMembersImpl for Ptr { - fn copy_assign( - &self, - _a0: Ptr, - ) -> Ptr { - ({ LifetimeTrackedImpl::copy_assign(&field_ptr!((*self), a), field_ptr!(_a0, a)) }); - ({ LifetimeTrackedImpl::copy_assign(&field_ptr!((*self), b), field_ptr!(_a0, b)) }); - return (*self).clone(); - } fn destructor(&self) { Destructible::destroy(field_ptr!(self, b)); Destructible::destroy(field_ptr!(self, a)); } } +impl CopyAssignable for p6_unevaluated_binding_needs_no_capture_HasTwoMembers { + fn copy_assign( + this: &Ptr, + _a0: Ptr, + ) -> Ptr { + ({ CopyAssignable::copy_assign(&field_ptr!((*this), a), field_ptr!(_a0, a)) }); + ({ CopyAssignable::copy_assign(&field_ptr!((*this), b), field_ptr!(_a0, b)) }); + return (*this).clone(); + } +} pub trait p7_member_access_captures_this_HasMemberUsedInLambdaImpl { fn makeLambda(&self) -> FnPtr i32>; - fn copy_assign( - &self, - _a0: Ptr, - ) -> Ptr; fn destructor(&self); } impl p7_member_access_captures_this_HasMemberUsedInLambdaImpl @@ -907,24 +1009,22 @@ impl p7_member_access_captures_this_HasMemberUsedInLambdaImpl } ); } + fn destructor(&self) { + Destructible::destroy(field_ptr!(self, x)); + } +} +impl CopyAssignable for p7_member_access_captures_this_HasMemberUsedInLambda { fn copy_assign( - &self, + this: &Ptr, _a0: Ptr, ) -> Ptr { - ({ LifetimeTrackedImpl::copy_assign(&field_ptr!((*self), x), field_ptr!(_a0, x)) }); - field!((*self), n).write(_a0.with(|__s| __s.n)); - return (*self).clone(); - } - fn destructor(&self) { - Destructible::destroy(field_ptr!(self, x)); + ({ CopyAssignable::copy_assign(&field_ptr!((*this), x), field_ptr!(_a0, x)) }); + field!((*this), n).write(_a0.with(|__s| __s.n)); + return (*this).clone(); } } pub trait p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambdaImpl { fn sizer(&self) -> FnPtr usize>; - fn copy_assign( - &self, - _a0: Ptr, - ) -> Ptr; fn destructor(&self); } impl p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambdaImpl @@ -937,15 +1037,17 @@ impl p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambdaImpl } }); } + fn destructor(&self) { + Destructible::destroy(field_ptr!(self, x)); + } +} +impl CopyAssignable for p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda { fn copy_assign( - &self, + this: &Ptr, _a0: Ptr, ) -> Ptr { - ({ LifetimeTrackedImpl::copy_assign(&field_ptr!((*self), x), field_ptr!(_a0, x)) }); - return (*self).clone(); - } - fn destructor(&self) { - Destructible::destroy(field_ptr!(self, x)); + ({ CopyAssignable::copy_assign(&field_ptr!((*this), x), field_ptr!(_a0, x)) }); + return (*this).clone(); } } pub trait p9_destructor_not_potentially_invoked_HasUndefinedDestructorImpl { diff --git a/tests/std/basic/out/unsafe/basic.def.odr.rs b/tests/std/basic/out/unsafe/basic.def.odr.rs index 624bd9f248..0344dd5e7d 100644 --- a/tests/std/basic/out/unsafe/basic.def.odr.rs +++ b/tests/std/basic/out/unsafe/basic.def.odr.rs @@ -8,7 +8,15 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub static mut copyCount_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyAssignUnsafe, Default)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + MoveConstructibleUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct HasConstexprCtor { pub m: i32, @@ -20,11 +28,15 @@ impl HasConstexprCtor { pub unsafe fn construct(&mut self, mut v: i32) { (&raw mut self.m).write(v); } - pub unsafe fn copy_from(&mut self, o: *const HasConstexprCtor) { +} +impl CopyConstructibleUnsafe for HasConstexprCtor { + unsafe fn copy_constructor(&mut self, o: *const HasConstexprCtor) { (&raw mut self.m).write((*o).m); (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_0)).prefix_inc(); } - pub unsafe fn copy_assign(&mut self, _a0: *const HasConstexprCtor) -> *mut HasConstexprCtor { +} +impl CopyAssignableUnsafe for HasConstexprCtor { + unsafe fn copy_assign(&mut self, _a0: *const HasConstexprCtor) -> *mut HasConstexprCtor { self.m = (*_a0).m; return &mut (*(self as *mut HasConstexprCtor)); } @@ -33,7 +45,7 @@ impl Clone for HasConstexprCtor { fn clone(&self) -> Self { unsafe { let mut __v: HasConstexprCtor = ::zero_init(); - HasConstexprCtor::copy_from(&mut __v, self as *const HasConstexprCtor); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const HasConstexprCtor); __v } } @@ -43,7 +55,14 @@ pub static mut copyCount_2: std::cell::LazyCell = std::cell::LazyCell::new( pub static mut dtorCount_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut useCount_4: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyAssignUnsafe, DestructibleUnsafe)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + MoveConstructibleUnsafe, + MoveAssignableUnsafe, +)] pub struct LifetimeTracked { pub uses: i32, } @@ -64,10 +83,6 @@ impl LifetimeTracked { (&raw mut self.uses).write(0); (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_1)).prefix_inc(); } - pub unsafe fn copy_from(&mut self, _a0: *const LifetimeTracked) { - (&raw mut self.uses).write(0); - (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_2)).prefix_inc(); - } pub unsafe fn destructor(&mut self) { (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_3)).prefix_inc(); } @@ -75,7 +90,15 @@ impl LifetimeTracked { (*(&raw const self.uses).cast_mut()).prefix_inc(); (*std::cell::LazyCell::force_mut(&mut *&raw mut useCount_4)).prefix_inc(); } - pub unsafe fn copy_assign(&mut self, _a0: *const LifetimeTracked) -> *mut LifetimeTracked { +} +impl CopyConstructibleUnsafe for LifetimeTracked { + unsafe fn copy_constructor(&mut self, _a0: *const LifetimeTracked) { + (&raw mut self.uses).write(0); + (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_2)).prefix_inc(); + } +} +impl CopyAssignableUnsafe for LifetimeTracked { + unsafe fn copy_assign(&mut self, _a0: *const LifetimeTracked) -> *mut LifetimeTracked { self.uses = (*_a0).uses; return &mut (*(self as *mut LifetimeTracked)); } @@ -84,7 +107,7 @@ impl Clone for LifetimeTracked { fn clone(&self) -> Self { unsafe { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::copy_from(&mut __v, self as *const LifetimeTracked); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const LifetimeTracked); __v } } @@ -224,7 +247,18 @@ pub unsafe trait p4_1_pure_virtual_without_definition_HasPureVirtual { unsafe fn f(&mut self); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p4_1_pure_virtual_without_definition_OverridesPureVirtual {} pub unsafe fn test_11() { let mut d: p4_1_pure_virtual_without_definition_OverridesPureVirtual = @@ -279,7 +313,7 @@ pub unsafe fn test_14() { { let r: LifetimeTracked = { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::copy_from(&mut __v, { r }); + CopyConstructibleUnsafe::copy_constructor(&mut __v, { r }); __v }; }, @@ -320,14 +354,14 @@ pub unsafe fn test_16() { { let k: HasConstexprCtor = { let mut __v: HasConstexprCtor = ::zero_init(); - HasConstexprCtor::copy_from(&mut __v, { &k }); + CopyConstructibleUnsafe::copy_constructor(&mut __v, { &k }); __v }; }, || -> i32 { let mut c: HasConstexprCtor = { let mut __v: HasConstexprCtor = ::zero_init(); - HasConstexprCtor::copy_from(&mut __v, { &k }); + CopyConstructibleUnsafe::copy_constructor(&mut __v, { &k }); __v }; return c.m; @@ -348,7 +382,15 @@ pub unsafe fn test_17() { } pub static mut copies_18: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0_i32 }); #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyAssignUnsafe, Default)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + MoveConstructibleUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct p5_2_mutable_subobject_is_odr_used_HasMutableMember { pub value: i32, @@ -359,7 +401,9 @@ impl p5_2_mutable_subobject_is_odr_used_HasMutableMember { (&raw mut self.value).write(v); (&raw mut self.scratch).write(0); } - pub unsafe fn copy_from( +} +impl CopyConstructibleUnsafe for p5_2_mutable_subobject_is_odr_used_HasMutableMember { + unsafe fn copy_constructor( &mut self, o: *const p5_2_mutable_subobject_is_odr_used_HasMutableMember, ) { @@ -367,7 +411,9 @@ impl p5_2_mutable_subobject_is_odr_used_HasMutableMember { (&raw mut self.scratch).write((*o).scratch); (*std::cell::LazyCell::force_mut(&mut *&raw mut copies_18)).prefix_inc(); } - pub unsafe fn copy_assign( +} +impl CopyAssignableUnsafe for p5_2_mutable_subobject_is_odr_used_HasMutableMember { + unsafe fn copy_assign( &mut self, _a0: *const p5_2_mutable_subobject_is_odr_used_HasMutableMember, ) -> *mut p5_2_mutable_subobject_is_odr_used_HasMutableMember { @@ -381,7 +427,7 @@ impl Clone for p5_2_mutable_subobject_is_odr_used_HasMutableMember { unsafe { let mut __v: p5_2_mutable_subobject_is_odr_used_HasMutableMember = ::zero_init(); - p5_2_mutable_subobject_is_odr_used_HasMutableMember::copy_from( + CopyConstructibleUnsafe::copy_constructor( &mut __v, self as *const p5_2_mutable_subobject_is_odr_used_HasMutableMember, ); @@ -401,7 +447,7 @@ pub unsafe fn test_19() { let k: p5_2_mutable_subobject_is_odr_used_HasMutableMember = { let mut __v: p5_2_mutable_subobject_is_odr_used_HasMutableMember = ::zero_init(); - p5_2_mutable_subobject_is_odr_used_HasMutableMember::copy_from(&mut __v, { &k }); + CopyConstructibleUnsafe::copy_constructor(&mut __v, { &k }); __v }; }, @@ -415,24 +461,32 @@ pub unsafe fn test_19() { } #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyAssignUnsafe, DestructibleUnsafe, Default, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + MoveAssignableUnsafe, + Default, )] pub struct p6_unevaluated_binding_needs_no_capture_HasTwoMembers { pub a: LifetimeTracked, pub b: LifetimeTracked, } -impl p6_unevaluated_binding_needs_no_capture_HasTwoMembers { - pub unsafe fn copy_assign( +impl CopyAssignableUnsafe for p6_unevaluated_binding_needs_no_capture_HasTwoMembers { + unsafe fn copy_assign( &mut self, _a0: *const p6_unevaluated_binding_needs_no_capture_HasTwoMembers, ) -> *mut p6_unevaluated_binding_needs_no_capture_HasTwoMembers { (unsafe { let _arg0: *const LifetimeTracked = &(*_a0).a; - LifetimeTracked::copy_assign(&mut self.a, _arg0) + CopyAssignableUnsafe::copy_assign(&mut self.a, _arg0) }); (unsafe { let _arg0: *const LifetimeTracked = &(*_a0).b; - LifetimeTracked::copy_assign(&mut self.b, _arg0) + CopyAssignableUnsafe::copy_assign(&mut self.b, _arg0) }); return &mut (*(self as *mut p6_unevaluated_binding_needs_no_capture_HasTwoMembers)); } @@ -474,7 +528,14 @@ pub unsafe fn test_20() { } #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyAssignUnsafe, DestructibleUnsafe, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + MoveAssignableUnsafe, )] pub struct p7_member_access_captures_this_HasMemberUsedInLambda { pub x: LifetimeTracked, @@ -493,13 +554,15 @@ impl p7_member_access_captures_this_HasMemberUsedInLambda { } ); } - pub unsafe fn copy_assign( +} +impl CopyAssignableUnsafe for p7_member_access_captures_this_HasMemberUsedInLambda { + unsafe fn copy_assign( &mut self, _a0: *const p7_member_access_captures_this_HasMemberUsedInLambda, ) -> *mut p7_member_access_captures_this_HasMemberUsedInLambda { (unsafe { let _arg0: *const LifetimeTracked = &(*_a0).x; - LifetimeTracked::copy_assign(&mut self.x, _arg0) + CopyAssignableUnsafe::copy_assign(&mut self.x, _arg0) }); self.n = (*_a0).n; return &mut (*(self as *mut p7_member_access_captures_this_HasMemberUsedInLambda)); @@ -539,7 +602,15 @@ pub unsafe fn test_22() { } #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyAssignUnsafe, DestructibleUnsafe, Default, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + MoveAssignableUnsafe, + Default, )] pub struct p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda { pub x: LifetimeTracked, @@ -552,13 +623,15 @@ impl p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda { } }); } - pub unsafe fn copy_assign( +} +impl CopyAssignableUnsafe for p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda { + unsafe fn copy_assign( &mut self, _a0: *const p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda, ) -> *mut p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda { (unsafe { let _arg0: *const LifetimeTracked = &(*_a0).x; - LifetimeTracked::copy_assign(&mut self.x, _arg0) + CopyAssignableUnsafe::copy_assign(&mut self.x, _arg0) }); return &mut (*(self as *mut p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda)); } @@ -604,7 +677,17 @@ pub unsafe fn test_26() { } pub static mut t_ctors_27: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0_i32 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct p9_destructor_not_potentially_invoked_HasUndefinedDestructor {} impl p9_destructor_not_potentially_invoked_HasUndefinedDestructor { pub unsafe fn construct(&mut self) { @@ -674,7 +757,17 @@ pub unsafe fn test_31() { } pub static mut m_ctors_32: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0_i32 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct p9_unused_implicit_assignment_HasUndefinedCopyAssignment {} impl p9_unused_implicit_assignment_HasUndefinedCopyAssignment { pub unsafe fn construct(&mut self) { @@ -694,7 +787,18 @@ impl Default for p9_unused_implicit_assignment_HasUndefinedCopyAssignment { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p9_unused_implicit_assignment_HasMemberWithUndefinedCopyAssignment { pub m: p9_unused_implicit_assignment_HasUndefinedCopyAssignment, } diff --git a/tests/std/class/class.init/out/refcount/class.base.init.rs b/tests/std/class/class.init/out/refcount/class.base.init.rs index 6eac6ca310..31137b9550 100644 --- a/tests/std/class/class.init/out/refcount/class.base.init.rs +++ b/tests/std/class/class.init/out/refcount/class.base.init.rs @@ -6,7 +6,21 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(8)] pub struct p13_3_member_reads_earlier_member_Pair { diff --git a/tests/std/class/class.init/out/unsafe/class.base.init.rs b/tests/std/class/class.init/out/unsafe/class.base.init.rs index dc48eed6d5..85351a4133 100644 --- a/tests/std/class/class.init/out/unsafe/class.base.init.rs +++ b/tests/std/class/class.init/out/unsafe/class.base.init.rs @@ -7,7 +7,19 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct p13_3_member_reads_earlier_member_Pair { pub first: i32, diff --git a/tests/std/class/class.mem/class.conv/out/refcount/class.conv.ctor.rs b/tests/std/class/class.mem/class.conv/out/refcount/class.conv.ctor.rs index a5e5f206a7..d585c2809e 100644 --- a/tests/std/class/class.mem/class.conv/out/refcount/class.conv.ctor.rs +++ b/tests/std/class/class.mem/class.conv/out/refcount/class.conv.ctor.rs @@ -6,7 +6,21 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_from(i32, construct_2, value)] #[byte_size(4)] pub struct p1_template_constructor_from_own_type_Probe { diff --git a/tests/std/class/class.mem/class.conv/out/refcount/class.conv.fct.rs b/tests/std/class/class.mem/class.conv/out/refcount/class.conv.fct.rs index 5cac9be66d..85728f61d5 100644 --- a/tests/std/class/class.mem/class.conv/out/refcount/class.conv.fct.rs +++ b/tests/std/class/class.mem/class.conv/out/refcount/class.conv.fct.rs @@ -6,7 +6,21 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_into(i64, to_i64, mut_ptr)] #[byte_size(8)] pub struct p2_non_const_conversion_function_Gauge { diff --git a/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.ctor.rs b/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.ctor.rs index 7ae7d0674b..a482cea564 100644 --- a/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.ctor.rs +++ b/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.ctor.rs @@ -12,7 +12,19 @@ impl p1_template_constructor_from_own_type_Probe { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(i32, construct_2, value)] pub struct p1_template_constructor_from_own_type_Probe { pub value: i32, diff --git a/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.fct.rs b/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.fct.rs index 038852dc89..1b6b3dfc1c 100644 --- a/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.fct.rs +++ b/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.fct.rs @@ -7,7 +7,19 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_into(i64, to_i64, mut_ptr)] pub struct p2_non_const_conversion_function_Gauge { pub value: i64, diff --git a/tests/std/class/class.mem/class.ctor/out/refcount/class.copy.ctor.rs b/tests/std/class/class.mem/class.ctor/out/refcount/class.copy.ctor.rs index 3915204d7e..6bc5af0de4 100644 --- a/tests/std/class/class.mem/class.ctor/out/refcount/class.copy.ctor.rs +++ b/tests/std/class/class.mem/class.ctor/out/refcount/class.copy.ctor.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, MoveCtor, CppFrom, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Default)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct p11_defaulted_move_constructor_is_trivial_MoveOnly { @@ -22,9 +22,7 @@ pub fn pass_0( let __v: Value = Rc::new(RefCell::new( ::zero_init(), )); - p11_defaulted_move_constructor_is_trivial_MoveOnlyImpl::move_from(&__v.as_pointer(), { - object.as_pointer() - }); + MoveConstructible::move_constructor(&__v.as_pointer(), { object.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; } @@ -70,7 +68,6 @@ fn main_0() -> i32 { } pub trait p11_defaulted_move_constructor_is_trivial_MoveOnlyImpl { fn construct(&self, value: i32); - fn move_from(&self, _a0: Ptr); } impl p11_defaulted_move_constructor_is_trivial_MoveOnlyImpl for Ptr @@ -78,8 +75,13 @@ impl p11_defaulted_move_constructor_is_trivial_MoveOnlyImpl fn construct(&self, mut value: i32) { field!((*self), value).write(value); } - fn move_from(&self, _a0: Ptr) { - field!((*self), value).write({ (*_a0.upgrade().deref()).value }); +} +impl MoveConstructible for p11_defaulted_move_constructor_is_trivial_MoveOnly { + fn move_constructor( + this: &Ptr, + _a0: Ptr, + ) { + field!((*this), value).write({ (*_a0.upgrade().deref()).value }); } } pub fn __cpp2rust_init_globals() {} diff --git a/tests/std/class/class.mem/class.ctor/out/unsafe/class.copy.ctor.rs b/tests/std/class/class.mem/class.ctor/out/unsafe/class.copy.ctor.rs index 7b9a26b4bb..8bb6cd8454 100644 --- a/tests/std/class/class.mem/class.ctor/out/unsafe/class.copy.ctor.rs +++ b/tests/std/class/class.mem/class.ctor/out/unsafe/class.copy.ctor.rs @@ -7,7 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, CppFromUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] #[cpp_from(i32, construct, value)] pub struct p11_defaulted_move_constructor_is_trivial_MoveOnly { pub value: i32, @@ -16,7 +16,9 @@ impl p11_defaulted_move_constructor_is_trivial_MoveOnly { pub unsafe fn construct(&mut self, mut value: i32) { (&raw mut self.value).write(value); } - pub unsafe fn move_from( +} +impl MoveConstructibleUnsafe for p11_defaulted_move_constructor_is_trivial_MoveOnly { + unsafe fn move_constructor( &mut self, _a0: *mut p11_defaulted_move_constructor_is_trivial_MoveOnly, ) { @@ -29,7 +31,7 @@ pub unsafe fn pass_0( return { let mut __v: p11_defaulted_move_constructor_is_trivial_MoveOnly = ::zero_init(); - p11_defaulted_move_constructor_is_trivial_MoveOnly::move_from(&mut __v, { &mut object }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut object }); __v }; } diff --git a/tests/std/class/class.mem/out/refcount/class.free.rs b/tests/std/class/class.mem/out/refcount/class.free.rs index f79f771bc7..ec32b03c8f 100644 --- a/tests/std/class/class.mem/out/refcount/class.free.rs +++ b/tests/std/class/class.mem/out/refcount/class.free.rs @@ -9,7 +9,20 @@ use std::rc::{Rc, Weak}; thread_local!( pub static allocations_0: Value = Rc::new(RefCell::new(0)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct p1_allocation_function_is_static_Allocates {} impl p1_allocation_function_is_static_Allocates { @@ -46,7 +59,20 @@ pub fn test_1() { thread_local!( pub static deallocations_2: Value = Rc::new(RefCell::new(0)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct p3_deallocation_function_is_static_Deallocates {} impl p3_deallocation_function_is_static_Deallocates { diff --git a/tests/std/class/class.mem/out/refcount/class.mem.general.rs b/tests/std/class/class.mem/out/refcount/class.mem.general.rs index 5efab48289..263fb84b66 100644 --- a/tests/std/class/class.mem/out/refcount/class.mem.general.rs +++ b/tests/std/class/class.mem/out/refcount/class.mem.general.rs @@ -14,7 +14,19 @@ pub fn minimum_1() -> i32 { } pub type anon_2 = u32; pub const anon_2_reserve: anon_2 = 30; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(4)] pub struct p7_1_function_body_names_later_member_HasLaterMembers { #[offset(0)] @@ -43,7 +55,19 @@ thread_local!( thread_local!( pub static step_5: Value = Rc::new(RefCell::new(4)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(4)] pub struct p7_2_default_argument_names_later_member_HasLaterStaticStep { #[offset(0)] diff --git a/tests/std/class/class.mem/out/unsafe/class.free.rs b/tests/std/class/class.mem/out/unsafe/class.free.rs index c054dea9ca..a13cc8e10f 100644 --- a/tests/std/class/class.mem/out/unsafe/class.free.rs +++ b/tests/std/class/class.mem/out/unsafe/class.free.rs @@ -8,7 +8,18 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub static mut allocations_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p1_allocation_function_is_static_Allocates {} impl p1_allocation_function_is_static_Allocates { pub unsafe fn operator_new(mut size: usize) -> *mut ::libc::c_void { @@ -42,7 +53,18 @@ pub unsafe fn test_1() { pub static mut deallocations_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p3_deallocation_function_is_static_Deallocates {} impl p3_deallocation_function_is_static_Deallocates { pub unsafe fn operator_delete(mut ptr: *mut ::libc::c_void) { diff --git a/tests/std/class/class.mem/out/unsafe/class.mem.general.rs b/tests/std/class/class.mem/out/unsafe/class.mem.general.rs index 6023773883..1a5cd1af5d 100644 --- a/tests/std/class/class.mem/out/unsafe/class.mem.general.rs +++ b/tests/std/class/class.mem/out/unsafe/class.mem.general.rs @@ -13,7 +13,17 @@ pub unsafe fn minimum_1() -> i32 { pub type anon_2 = u32; pub const anon_2_reserve: anon_2 = 30; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct p7_1_function_body_names_later_member_HasLaterMembers { pub stock: i32, } @@ -46,7 +56,17 @@ pub unsafe fn test_3() { pub static mut step_4: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 100 }); pub static mut step_5: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 4 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct p7_2_default_argument_names_later_member_HasLaterStaticStep { pub total: i32, } diff --git a/tests/std/dcl.dcl/dcl.decl/dcl.init/out/refcount/dcl.init.general-p6.2-padding-bits.rs b/tests/std/dcl.dcl/dcl.decl/dcl.init/out/refcount/dcl.init.general-p6.2-padding-bits.rs index 7291632867..80bb7920a3 100644 --- a/tests/std/dcl.dcl/dcl.decl/dcl.init/out/refcount/dcl.init.general-p6.2-padding-bits.rs +++ b/tests/std/dcl.dcl/dcl.decl/dcl.init/out/refcount/dcl.init.general-p6.2-padding-bits.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct p6_2_zero_initialized_padding_Padded { #[offset(0)] @@ -14,7 +27,20 @@ pub struct p6_2_zero_initialized_padding_Padded { #[offset(4)] pub number: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct p6_2_zero_initialized_padding_TailPadded { #[offset(0)] @@ -22,7 +48,20 @@ pub struct p6_2_zero_initialized_padding_TailPadded { #[offset(4)] pub letter: i8, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct p6_2_zero_initialized_padding_HoldsPadded { #[offset(0)] diff --git a/tests/std/dcl.dcl/dcl.decl/dcl.init/out/refcount/dcl.init.general.rs b/tests/std/dcl.dcl/dcl.decl/dcl.init/out/refcount/dcl.init.general.rs index 2255e0a05e..a796920386 100644 --- a/tests/std/dcl.dcl/dcl.decl/dcl.init/out/refcount/dcl.init.general.rs +++ b/tests/std/dcl.dcl/dcl.decl/dcl.init/out/refcount/dcl.init.general.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct p6_1_zero_initialized_pointer_to_member_HasTwoInts { #[offset(0)] @@ -14,7 +27,19 @@ pub struct p6_1_zero_initialized_pointer_to_member_HasTwoInts { #[offset(4)] pub second: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(8)] pub struct p6_1_zero_initialized_pointer_to_member_HoldsSelector { #[offset(0)] @@ -111,7 +136,19 @@ pub fn test_12() { thread_local!( static counter_11: Value = Rc::new(RefCell::new(0_i32)); ); -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(24)] pub struct p6_2_zero_initialized_class_Inner { #[offset(0)] @@ -122,7 +159,18 @@ pub struct p6_2_zero_initialized_class_Inner { #[byte_size(8)] pub pointer: Ptr, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(96)] pub struct p6_2_zero_initialized_class_Outer { #[offset(0)] @@ -193,7 +241,17 @@ pub fn test_15() { ({ check_14((heap_outer).clone()) }); heap_outer.delete(); } -#[derive(VaArg, FnPtrArg, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + ByteRepr, + Clone, + ZeroInitialization, +)] #[byte_size(8)] pub struct p6_3_zero_initialized_union_Number { #[offset(0)] @@ -230,7 +288,20 @@ pub fn test_17() { Rc::new(RefCell::new(::default())); assert!(((p6_3_zero_initialized_union_Number::integer(value_number.as_pointer()).read()) == 0)); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct p6_4_zero_initialized_array_Pair { #[offset(0)] @@ -334,7 +405,19 @@ pub fn test_21() { } heap_numbers.delete(); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(8)] pub struct p9_1_2_zero_then_default_initialized_WithDefaultMember { #[offset(0)] @@ -352,7 +435,19 @@ impl Default for p9_1_2_zero_then_default_initialized_WithDefaultMember { } } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(4)] pub struct p9_1_2_zero_then_default_initialized_LeavesMemberAlone { #[offset(0)] @@ -374,7 +469,20 @@ impl Default for p9_1_2_zero_then_default_initialized_LeavesMemberAlone { } } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAlone { #[offset(0)] diff --git a/tests/std/dcl.dcl/dcl.decl/dcl.init/out/unsafe/dcl.init.general-p6.2-padding-bits.rs b/tests/std/dcl.dcl/dcl.decl/dcl.init/out/unsafe/dcl.init.general-p6.2-padding-bits.rs index cd2397ca8f..da228c7854 100644 --- a/tests/std/dcl.dcl/dcl.decl/dcl.init/out/unsafe/dcl.init.general-p6.2-padding-bits.rs +++ b/tests/std/dcl.dcl/dcl.decl/dcl.init/out/unsafe/dcl.init.general-p6.2-padding-bits.rs @@ -7,19 +7,52 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p6_2_zero_initialized_padding_Padded { pub letter: libc::c_char, pub number: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p6_2_zero_initialized_padding_TailPadded { pub number: i32, pub letter: libc::c_char, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p6_2_zero_initialized_padding_HoldsPadded { pub letter: libc::c_char, pub inner: p6_2_zero_initialized_padding_Padded, diff --git a/tests/std/dcl.dcl/dcl.decl/dcl.init/out/unsafe/dcl.init.general.rs b/tests/std/dcl.dcl/dcl.decl/dcl.init/out/unsafe/dcl.init.general.rs index a8e664d1da..620fc43354 100644 --- a/tests/std/dcl.dcl/dcl.decl/dcl.init/out/unsafe/dcl.init.general.rs +++ b/tests/std/dcl.dcl/dcl.decl/dcl.init/out/unsafe/dcl.init.general.rs @@ -7,13 +7,34 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p6_1_zero_initialized_pointer_to_member_HasTwoInts { pub first: i32, pub second: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct p6_1_zero_initialized_pointer_to_member_HoldsSelector { pub selector: isize, } @@ -107,14 +128,36 @@ pub unsafe fn test_12() { } static mut counter_11: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0_i32 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p6_2_zero_initialized_class_Inner { pub number: i32, pub real: f64, pub pointer: *mut i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p6_2_zero_initialized_class_Outer { pub letter: libc::c_char, pub inner: p6_2_zero_initialized_class_Inner, @@ -166,7 +209,17 @@ pub unsafe fn test_15() { }; } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub union p6_3_zero_initialized_union_Number { pub integer: i32, pub bytes: [libc::c_char; 8], @@ -185,7 +238,18 @@ pub unsafe fn test_17() { assert!(((value_number.integer) == (0))); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p6_4_zero_initialized_array_Pair { pub first: i32, pub second: i32, @@ -275,7 +339,17 @@ pub unsafe fn test_21() { }; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct p9_1_2_zero_then_default_initialized_WithDefaultMember { pub zeroed: i32, pub five: i32, @@ -291,7 +365,17 @@ impl Default for p9_1_2_zero_then_default_initialized_WithDefaultMember { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct p9_1_2_zero_then_default_initialized_LeavesMemberAlone { pub untouched: i32, } @@ -313,7 +397,18 @@ impl Default for p9_1_2_zero_then_default_initialized_LeavesMemberAlone { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAlone { pub number: i32, pub member: p9_1_2_zero_then_default_initialized_LeavesMemberAlone, diff --git a/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/refcount/dcl.array.rs b/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/refcount/dcl.array.rs index f7875ca5e8..6b14b9bb2a 100644 --- a/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/refcount/dcl.array.rs +++ b/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/refcount/dcl.array.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(12)] pub struct p6_array_of_pointers_to_data_members_HasThreeInts { #[offset(0)] diff --git a/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/refcount/dcl.fct.default.rs b/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/refcount/dcl.fct.default.rs index 4e7da1d1a3..d517a6241a 100644 --- a/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/refcount/dcl.fct.default.rs +++ b/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/refcount/dcl.fct.default.rs @@ -54,7 +54,19 @@ thread_local!( thread_local!( pub static step_10: Value = Rc::new(RefCell::new(4)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(4)] pub struct p9_static_member_hides_namespace_variable_HasStaticStep { #[offset(0)] @@ -105,7 +117,20 @@ pub fn count_default_13() -> i32 { pub fn combine_14(mut first: i32, mut second: i32) -> i32 { return ((first * 100) + second); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct p9_evaluated_each_time_called_Widget { @@ -132,7 +157,19 @@ thread_local!( ); pub type anon_16 = u32; pub const anon_16_kBonus: anon_16 = 5; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(4)] pub struct p9_evaluated_each_time_called_Account { #[offset(0)] @@ -221,7 +258,20 @@ pub fn test_17() { pub fn add_18(mut a: i32, mut b: i32) -> i32 { return (a + b); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct p9_not_part_of_the_type_Scale {} impl p9_not_part_of_the_type_Scale { diff --git a/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/refcount/dcl.mptr.rs b/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/refcount/dcl.mptr.rs index 815ad1c1cd..64f4df743b 100644 --- a/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/refcount/dcl.mptr.rs +++ b/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/refcount/dcl.mptr.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(16)] pub struct p2_pointer_to_array_member_HasIntArray { #[offset(0)] @@ -40,7 +51,20 @@ pub fn test_0() { assert!(((array_elem!(obj.as_pointer(), elements, 1).read()) == 7)); assert!(({ (*obj.borrow()).before } == 1)); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct p2_pointer_to_data_member_HasTwoInts { #[offset(0)] @@ -68,7 +92,20 @@ pub fn test_1() { thread_local!( pub static pm_2: Value = Rc::new(RefCell::new(-1_isize)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct p2_pointer_to_member_of_incomplete_class_CompletedLater { #[offset(0)] @@ -97,7 +134,20 @@ pub fn test_3() { == 4) ); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct p2_pointer_to_member_of_pointer_to_member_type_HasTwoInts { #[offset(0)] @@ -105,7 +155,19 @@ pub struct p2_pointer_to_member_of_pointer_to_member_type_HasTwoInts { #[offset(4)] pub second: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(8)] pub struct p2_pointer_to_member_of_pointer_to_member_type_HoldsSelector { #[offset(0)] diff --git a/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/unsafe/dcl.array.rs b/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/unsafe/dcl.array.rs index 204a1d4fcc..2fd0de5220 100644 --- a/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/unsafe/dcl.array.rs +++ b/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/unsafe/dcl.array.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p6_array_of_pointers_to_data_members_HasThreeInts { pub first: i32, pub second: i32, diff --git a/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/unsafe/dcl.fct.default.rs b/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/unsafe/dcl.fct.default.rs index f14341b2a4..f16b206418 100644 --- a/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/unsafe/dcl.fct.default.rs +++ b/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/unsafe/dcl.fct.default.rs @@ -54,7 +54,17 @@ pub unsafe fn test_8() { pub static mut step_9: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 100 }); pub static mut step_10: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 4 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct p9_static_member_hides_namespace_variable_HasStaticStep { pub total: i32, } @@ -105,7 +115,18 @@ pub unsafe fn combine_14(mut first: i32, mut second: i32) -> i32 { return (((first) * (100)) + (second)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] #[cpp_from(i32, construct, value)] pub struct p9_evaluated_each_time_called_Widget { pub id: i32, @@ -133,7 +154,17 @@ static mut base_15: std::cell::LazyCell = std::cell::LazyCell::new(|| unsaf pub type anon_16 = u32; pub const anon_16_kBonus: anon_16 = 5; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct p9_evaluated_each_time_called_Account { pub balance: i32, } @@ -227,7 +258,18 @@ pub unsafe fn add_18(mut a: i32, mut b: i32) -> i32 { return ((a) + (b)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p9_not_part_of_the_type_Scale {} impl p9_not_part_of_the_type_Scale { pub unsafe fn times(mut a: i32, mut b: i32) -> i32 { diff --git a/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/unsafe/dcl.mptr.rs b/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/unsafe/dcl.mptr.rs index 27a87e5ea3..da16258bbd 100644 --- a/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/unsafe/dcl.mptr.rs +++ b/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/unsafe/dcl.mptr.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p2_pointer_to_array_member_HasIntArray { pub before: i32, pub elements: [i32; 3], @@ -38,7 +49,18 @@ pub unsafe fn test_0() { assert!(((obj.before) == (1))); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p2_pointer_to_data_member_HasTwoInts { pub first: i32, pub second: i32, @@ -76,7 +98,18 @@ pub unsafe fn test_1() { } pub static mut pm_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { -1_isize }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p2_pointer_to_member_of_incomplete_class_CompletedLater { pub first: i32, pub second: i32, @@ -100,13 +133,34 @@ pub unsafe fn test_3() { ); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p2_pointer_to_member_of_pointer_to_member_type_HasTwoInts { pub first: i32, pub second: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct p2_pointer_to_member_of_pointer_to_member_type_HoldsSelector { pub selector: isize, } diff --git a/tests/std/expr/conv/out/refcount/conv.mem.rs b/tests/std/expr/conv/out/refcount/conv.mem.rs index 74a595f022..1fce0c3544 100644 --- a/tests/std/expr/conv/out/refcount/conv.mem.rs +++ b/tests/std/expr/conv/out/refcount/conv.mem.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct p1_null_distinct_from_first_member_HasTwoInts { #[offset(0)] diff --git a/tests/std/expr/conv/out/unsafe/conv.mem.rs b/tests/std/expr/conv/out/unsafe/conv.mem.rs index 0c8703d9e1..6c8e75919f 100644 --- a/tests/std/expr/conv/out/unsafe/conv.mem.rs +++ b/tests/std/expr/conv/out/unsafe/conv.mem.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p1_null_distinct_from_first_member_HasTwoInts { pub first: i32, pub second: i32, diff --git a/tests/std/expr/expr.compound/expr.post/out/refcount/expr.const.cast.rs b/tests/std/expr/expr.compound/expr.post/out/refcount/expr.const.cast.rs index 82485c58d0..ecfe5db627 100644 --- a/tests/std/expr/expr.compound/expr.post/out/refcount/expr.const.cast.rs +++ b/tests/std/expr/expr.compound/expr.post/out/refcount/expr.const.cast.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct p4_reference_const_cast_Pair { #[offset(0)] diff --git a/tests/std/expr/expr.compound/expr.post/out/refcount/expr.reinterpret.cast-p10-result-is-unspecified.rs b/tests/std/expr/expr.compound/expr.post/out/refcount/expr.reinterpret.cast-p10-result-is-unspecified.rs index 36e1b8a0b8..f7c402c117 100644 --- a/tests/std/expr/expr.compound/expr.post/out/refcount/expr.reinterpret.cast-p10-result-is-unspecified.rs +++ b/tests/std/expr/expr.compound/expr.post/out/refcount/expr.reinterpret.cast-p10-result-is-unspecified.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct HasTwoInts { #[offset(0)] @@ -14,7 +27,20 @@ pub struct HasTwoInts { #[offset(4)] pub second: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct AlsoHasTwoInts { #[offset(0)] diff --git a/tests/std/expr/expr.compound/expr.post/out/refcount/expr.reinterpret.cast.rs b/tests/std/expr/expr.compound/expr.post/out/refcount/expr.reinterpret.cast.rs index e0ee6af6db..3fa1510435 100644 --- a/tests/std/expr/expr.compound/expr.post/out/refcount/expr.reinterpret.cast.rs +++ b/tests/std/expr/expr.compound/expr.post/out/refcount/expr.reinterpret.cast.rs @@ -16,7 +16,20 @@ pub fn test_0() { (*value.borrow_mut()) = 7; assert!((((converted.read()).read()) == 7)); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct p10_null_converts_to_null_HasTwoInts { #[offset(0)] @@ -24,7 +37,20 @@ pub struct p10_null_converts_to_null_HasTwoInts { #[offset(4)] pub second: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct p10_null_converts_to_null_HasChar { #[offset(0)] @@ -35,7 +61,20 @@ pub fn test_1() { let mut converted: isize = pm; assert!(((converted) == -1_isize)); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct p10_2_data_member_round_trip_HasTwoInts { #[offset(0)] @@ -43,7 +82,20 @@ pub struct p10_2_data_member_round_trip_HasTwoInts { #[offset(4)] pub second: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct p10_2_data_member_round_trip_HasChar { #[offset(0)] diff --git a/tests/std/expr/expr.compound/expr.post/out/unsafe/expr.const.cast.rs b/tests/std/expr/expr.compound/expr.post/out/unsafe/expr.const.cast.rs index 106cbcb48c..c98da93adf 100644 --- a/tests/std/expr/expr.compound/expr.post/out/unsafe/expr.const.cast.rs +++ b/tests/std/expr/expr.compound/expr.post/out/unsafe/expr.const.cast.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p4_reference_const_cast_Pair { pub x: i32, } diff --git a/tests/std/expr/expr.compound/expr.post/out/unsafe/expr.reinterpret.cast-p10-result-is-unspecified.rs b/tests/std/expr/expr.compound/expr.post/out/unsafe/expr.reinterpret.cast-p10-result-is-unspecified.rs index 19f5758fbf..e3c6978429 100644 --- a/tests/std/expr/expr.compound/expr.post/out/unsafe/expr.reinterpret.cast-p10-result-is-unspecified.rs +++ b/tests/std/expr/expr.compound/expr.post/out/unsafe/expr.reinterpret.cast-p10-result-is-unspecified.rs @@ -7,13 +7,35 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct HasTwoInts { pub first: i32, pub second: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct AlsoHasTwoInts { pub first: i32, pub second: i32, diff --git a/tests/std/expr/expr.compound/expr.post/out/unsafe/expr.reinterpret.cast.rs b/tests/std/expr/expr.compound/expr.post/out/unsafe/expr.reinterpret.cast.rs index 712dee1955..fee1aef260 100644 --- a/tests/std/expr/expr.compound/expr.post/out/unsafe/expr.reinterpret.cast.rs +++ b/tests/std/expr/expr.compound/expr.post/out/unsafe/expr.reinterpret.cast.rs @@ -17,13 +17,35 @@ pub unsafe fn test_0() { assert!(((*(*converted)) == (7))); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p10_null_converts_to_null_HasTwoInts { pub first: i32, pub second: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p10_null_converts_to_null_HasChar { pub character: libc::c_char, } @@ -33,13 +55,35 @@ pub unsafe fn test_1() { assert!(((converted) == -1_isize)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p10_2_data_member_round_trip_HasTwoInts { pub first: i32, pub second: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p10_2_data_member_round_trip_HasChar { pub character: libc::c_char, } diff --git a/tests/std/expr/expr.compound/expr.unary/out/refcount/expr.pre.incr.rs b/tests/std/expr/expr.compound/expr.unary/out/refcount/expr.pre.incr.rs index 5abe461cf4..f3f438bd99 100644 --- a/tests/std/expr/expr.compound/expr.unary/out/refcount/expr.pre.incr.rs +++ b/tests/std/expr/expr.compound/expr.unary/out/refcount/expr.pre.incr.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct p1_result_is_updated_operand_Counter { #[offset(0)] diff --git a/tests/std/expr/expr.compound/expr.unary/out/refcount/expr.unary.op.rs b/tests/std/expr/expr.compound/expr.unary/out/refcount/expr.unary.op.rs index b597866a64..fe7284c3f2 100644 --- a/tests/std/expr/expr.compound/expr.unary/out/refcount/expr.unary.op.rs +++ b/tests/std/expr/expr.compound/expr.unary/out/refcount/expr.unary.op.rs @@ -12,7 +12,20 @@ thread_local!( thread_local!( pub static calls_1: Value = Rc::new(RefCell::new(0)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct p3_2_static_member_is_ordinary_pointer_HasStaticMembers {} impl p3_2_static_member_is_ordinary_pointer_HasStaticMembers { @@ -30,7 +43,20 @@ pub fn test_2() { ({ function_pointer.call() }); assert!((calls_1.with(|rc| *rc.borrow()) == 1)); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct p3_2_explicit_object_member_is_ordinary_pointer_HasExplicitObjectMember { #[offset(0)] @@ -46,7 +72,20 @@ pub fn test_3() { (*object.borrow_mut()).base = 5; assert!((({ function_pointer.call(object.as_pointer(), 1,) }) == 6)); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct p4_parenthesized_qualified_id_is_object_pointer_TakesAddressOfOwnMember { #[offset(0)] diff --git a/tests/std/expr/expr.compound/expr.unary/out/unsafe/expr.pre.incr.rs b/tests/std/expr/expr.compound/expr.unary/out/unsafe/expr.pre.incr.rs index 2e68a582ca..d2db15e6f6 100644 --- a/tests/std/expr/expr.compound/expr.unary/out/unsafe/expr.pre.incr.rs +++ b/tests/std/expr/expr.compound/expr.unary/out/unsafe/expr.pre.incr.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p1_result_is_updated_operand_Counter { pub n: i32, } diff --git a/tests/std/expr/expr.compound/expr.unary/out/unsafe/expr.unary.op.rs b/tests/std/expr/expr.compound/expr.unary/out/unsafe/expr.unary.op.rs index 5e194343d7..e66b0bf9f2 100644 --- a/tests/std/expr/expr.compound/expr.unary/out/unsafe/expr.unary.op.rs +++ b/tests/std/expr/expr.compound/expr.unary/out/unsafe/expr.unary.op.rs @@ -9,7 +9,18 @@ use std::rc::Rc; pub static mut shared_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 3 }); pub static mut calls_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p3_2_static_member_is_ordinary_pointer_HasStaticMembers {} impl p3_2_static_member_is_ordinary_pointer_HasStaticMembers { pub unsafe fn run() { @@ -28,7 +39,18 @@ pub unsafe fn test_2() { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut calls_1)) == (1))); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p3_2_explicit_object_member_is_ordinary_pointer_HasExplicitObjectMember { pub base: i32, } @@ -54,7 +76,18 @@ pub unsafe fn test_3() { assert!(((unsafe { (function_pointer).unwrap()(&object, 1,) }) == (6))); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p4_parenthesized_qualified_id_is_object_pointer_TakesAddressOfOwnMember { pub value: i32, } diff --git a/tests/std/expr/expr.compound/out/refcount/expr.cond.rs b/tests/std/expr/expr.compound/out/refcount/expr.cond.rs index d0cf7c81d8..f581300b98 100644 --- a/tests/std/expr/expr.compound/out/refcount/expr.cond.rs +++ b/tests/std/expr/expr.compound/out/refcount/expr.cond.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct p7_4_pointer_to_member_and_null_HasTwoInts { #[offset(0)] diff --git a/tests/std/expr/expr.compound/out/refcount/expr.eq.rs b/tests/std/expr/expr.compound/out/refcount/expr.eq.rs index 2e7cca7b6a..cc3d3351fb 100644 --- a/tests/std/expr/expr.compound/out/refcount/expr.eq.rs +++ b/tests/std/expr/expr.compound/out/refcount/expr.eq.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct p4_1_both_null_HasTwoInts { #[offset(0)] @@ -20,7 +33,20 @@ pub fn test_0() { assert!((first_null == second_null)); assert!(!(first_null != second_null)); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct p4_2_one_null_HasTwoInts { #[offset(0)] @@ -36,7 +62,17 @@ pub fn test_1() { assert!((null_pm != first_pm)); assert!(!(null_pm == first_pm)); } -#[derive(VaArg, FnPtrArg, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + ByteRepr, + Clone, + ZeroInitialization, +)] #[byte_size(4)] pub struct p4_5_members_of_same_union_HasTwoIntMembers { #[offset(0)] @@ -65,7 +101,20 @@ pub fn test_2() { assert!((first_pm == second_pm)); assert!(!(first_pm != second_pm)); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct p4_6_data_members_HasTwoInts { #[offset(0)] diff --git a/tests/std/expr/expr.compound/out/refcount/expr.mptr.oper-p6-null-pointer-to-data-member.rs b/tests/std/expr/expr.compound/out/refcount/expr.mptr.oper-p6-null-pointer-to-data-member.rs index 58dba1bf76..fb13927c1c 100644 --- a/tests/std/expr/expr.compound/out/refcount/expr.mptr.oper-p6-null-pointer-to-data-member.rs +++ b/tests/std/expr/expr.compound/out/refcount/expr.mptr.oper-p6-null-pointer-to-data-member.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct HasTwoInts { #[offset(0)] diff --git a/tests/std/expr/expr.compound/out/refcount/expr.mptr.oper.rs b/tests/std/expr/expr.compound/out/refcount/expr.mptr.oper.rs index 818abc1fc9..77ad11a71c 100644 --- a/tests/std/expr/expr.compound/out/refcount/expr.mptr.oper.rs +++ b/tests/std/expr/expr.compound/out/refcount/expr.mptr.oper.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct p3_arrow_star_HasTwoInts { #[offset(0)] @@ -27,7 +40,20 @@ pub fn test_0() { assert!(({ (*obj.borrow()).first } == 3)); assert!((((p).member::(pm)) == ((p).member::(pm)))); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct p4_object_expression_sequenced_first_HasValue { #[offset(0)] @@ -69,7 +95,20 @@ pub fn test_7() { assert!((object_stamp_2.with(|rc| *rc.borrow()) == 1)); assert!((member_stamp_3.with(|rc| *rc.borrow()) == 2)); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct p6_data_member_of_lvalue_is_lvalue_HasTwoInts { #[offset(0)] @@ -98,7 +137,9 @@ thread_local!( thread_local!( pub static moveCount_10: Value = Rc::new(RefCell::new(0)); ); -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, Default)] +#[derive( + Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyAssignable, MoveAssignable, Default, +)] #[byte_size(1)] pub struct p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves {} impl Clone for p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves { @@ -109,14 +150,22 @@ impl Clone for p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves { let __v: Value = Rc::new( RefCell::new(::zero_init()), ); - p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMovesImpl::copy_from( - &__v.as_pointer(), - __src.as_pointer(), - ); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct p6_data_member_of_rvalue_is_xvalue_HoldsCounted { #[offset(0)] @@ -133,13 +182,10 @@ pub fn test_11() { let __v: Value = Rc::new( RefCell::new(::zero_init()), ); - p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMovesImpl::copy_from( - &__v.as_pointer(), - { - (holder.as_pointer()) - .member::(pm) - }, - ); + CopyConstructible::copy_constructor(&__v.as_pointer(), { + (holder.as_pointer()) + .member::(pm) + }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; assert!((copyCount_9.with(|rc| *rc.borrow()) == 1)); @@ -148,13 +194,10 @@ pub fn test_11() { let __v: Value = Rc::new( RefCell::new(::zero_init()), ); - p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMovesImpl::move_from( - &__v.as_pointer(), - { - (holder.as_pointer()) - .member::(pm) - }, - ); + MoveConstructible::move_constructor(&__v.as_pointer(), { + (holder.as_pointer()) + .member::(pm) + }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; assert!((copyCount_9.with(|rc| *rc.borrow()) == 1)); @@ -171,36 +214,33 @@ fn main_0() -> i32 { ({ test_11() }); return 0; } -pub trait p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMovesImpl { - fn copy_from(&self, _a0: Ptr); - fn move_from(&self, _a0: Ptr); -} -impl p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMovesImpl - for Ptr -{ - fn copy_from(&self, _a0: Ptr) { +impl CopyConstructible for p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves { + fn copy_constructor( + this: &Ptr, + _a0: Ptr, + ) { (*copyCount_9.with(Value::clone).borrow_mut()).prefix_inc(); } - fn move_from(&self, _a0: Ptr) { +} +impl MoveConstructible for p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves { + fn move_constructor( + this: &Ptr, + _a0: Ptr, + ) { (*moveCount_10.with(Value::clone).borrow_mut()).prefix_inc(); } } -pub trait p6_data_member_of_rvalue_is_xvalue_HoldsCountedImpl { - fn move_from(&self, _a0: Ptr); -} -impl p6_data_member_of_rvalue_is_xvalue_HoldsCountedImpl - for Ptr -{ - fn move_from(&self, _a0: Ptr) { - field!((*self), member).write({ +impl MoveConstructible for p6_data_member_of_rvalue_is_xvalue_HoldsCounted { + fn move_constructor( + this: &Ptr, + _a0: Ptr, + ) { + field!((*this), member).write({ let __v: Value = Rc::new(RefCell::new( ::zero_init(), )); - p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMovesImpl::move_from( - &__v.as_pointer(), - { field_ptr!(_a0, member) }, - ); + MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, member) }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }); } diff --git a/tests/std/expr/expr.compound/out/unsafe/expr.cond.rs b/tests/std/expr/expr.compound/out/unsafe/expr.cond.rs index 892aa79d43..7315cf5fb7 100644 --- a/tests/std/expr/expr.compound/out/unsafe/expr.cond.rs +++ b/tests/std/expr/expr.compound/out/unsafe/expr.cond.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p7_4_pointer_to_member_and_null_HasTwoInts { pub first: i32, pub second: i32, diff --git a/tests/std/expr/expr.compound/out/unsafe/expr.eq.rs b/tests/std/expr/expr.compound/out/unsafe/expr.eq.rs index c388d066f0..05141bb97c 100644 --- a/tests/std/expr/expr.compound/out/unsafe/expr.eq.rs +++ b/tests/std/expr/expr.compound/out/unsafe/expr.eq.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p4_1_both_null_HasTwoInts { pub first: i32, pub second: i32, @@ -19,7 +30,18 @@ pub unsafe fn test_0() { assert!(!((first_null) != (second_null))); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p4_2_one_null_HasTwoInts { pub first: i32, pub second: i32, @@ -33,7 +55,17 @@ pub unsafe fn test_1() { assert!(!((null_pm) == (first_pm))); } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub union p4_5_members_of_same_union_HasTwoIntMembers { pub first: i32, pub second: i32, @@ -50,7 +82,18 @@ pub unsafe fn test_2() { assert!(!((first_pm) != (second_pm))); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p4_6_data_members_HasTwoInts { pub first: i32, pub second: i32, diff --git a/tests/std/expr/expr.compound/out/unsafe/expr.mptr.oper-p6-null-pointer-to-data-member.rs b/tests/std/expr/expr.compound/out/unsafe/expr.mptr.oper-p6-null-pointer-to-data-member.rs index 7f8464f86b..b17076e0df 100644 --- a/tests/std/expr/expr.compound/out/unsafe/expr.mptr.oper-p6-null-pointer-to-data-member.rs +++ b/tests/std/expr/expr.compound/out/unsafe/expr.mptr.oper-p6-null-pointer-to-data-member.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct HasTwoInts { pub first: i32, pub second: i32, diff --git a/tests/std/expr/expr.compound/out/unsafe/expr.mptr.oper.rs b/tests/std/expr/expr.compound/out/unsafe/expr.mptr.oper.rs index 2a1e254a13..d1e033c3f2 100644 --- a/tests/std/expr/expr.compound/out/unsafe/expr.mptr.oper.rs +++ b/tests/std/expr/expr.compound/out/unsafe/expr.mptr.oper.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p3_arrow_star_HasTwoInts { pub first: i32, pub second: i32, @@ -31,7 +42,18 @@ pub unsafe fn test_0() { ); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p4_object_expression_sequenced_first_HasValue { pub value: i32, } @@ -65,7 +87,18 @@ pub unsafe fn test_7() { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut member_stamp_3)) == (2))); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p6_data_member_of_lvalue_is_lvalue_HasTwoInts { pub first: i32, pub second: i32, @@ -94,16 +127,20 @@ pub unsafe fn test_8() { pub static mut copyCount_9: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut moveCount_10: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, Default)] +#[derive( + VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, Default, +)] pub struct p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves {} -impl p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves { - pub unsafe fn copy_from( +impl CopyConstructibleUnsafe for p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves { + unsafe fn copy_constructor( &mut self, _a0: *const p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves, ) { (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_9)).prefix_inc(); } - pub unsafe fn move_from( +} +impl MoveConstructibleUnsafe for p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves { + unsafe fn move_constructor( &mut self, _a0: *mut p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves, ) { @@ -115,7 +152,7 @@ impl Clone for p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves { unsafe { let mut __v: p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves = ::zero_init(); - p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves::copy_from( + CopyConstructibleUnsafe::copy_constructor( &mut __v, self as *const p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves, ); @@ -124,18 +161,28 @@ impl Clone for p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves { } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p6_data_member_of_rvalue_is_xvalue_HoldsCounted { pub member: p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves, } -impl p6_data_member_of_rvalue_is_xvalue_HoldsCounted { - pub unsafe fn move_from(&mut self, _a0: *mut p6_data_member_of_rvalue_is_xvalue_HoldsCounted) { +impl MoveConstructibleUnsafe for p6_data_member_of_rvalue_is_xvalue_HoldsCounted { + unsafe fn move_constructor( + &mut self, + _a0: *mut p6_data_member_of_rvalue_is_xvalue_HoldsCounted, + ) { (&raw mut self.member).write({ let mut __v: p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves = ::zero_init(); - p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves::move_from(&mut __v, { - &mut (*_a0).member - }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut (*_a0).member }); __v }); } @@ -148,7 +195,7 @@ pub unsafe fn test_11() { let mut from_lvalue: p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves = { let mut __v: p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves = ::zero_init(); - p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves::copy_from(&mut __v, { + CopyConstructibleUnsafe::copy_constructor(&mut __v, { &(*(&mut holder as *mut p6_data_member_of_rvalue_is_xvalue_HoldsCounted) .wrapping_byte_offset(pm) .cast::()) @@ -160,7 +207,7 @@ pub unsafe fn test_11() { let mut from_xvalue: p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves = { let mut __v: p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves = ::zero_init(); - p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves::move_from(&mut __v, { + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut (*(&mut holder as *mut p6_data_member_of_rvalue_is_xvalue_HoldsCounted) .wrapping_byte_offset(pm) .cast::()) diff --git a/tests/std/expr/expr.prim/out/refcount/expr.prim.this.rs b/tests/std/expr/expr.prim/out/refcount/expr.prim.this.rs index 27248df28a..f47b872527 100644 --- a/tests/std/expr/expr.prim/out/refcount/expr.prim.this.rs +++ b/tests/std/expr/expr.prim/out/refcount/expr.prim.this.rs @@ -6,7 +6,19 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[cpp_from(i32, construct, value)] #[byte_size(16)] pub struct p1_default_member_initializer_names_object_Holder { @@ -31,7 +43,20 @@ pub fn test_0() { }; assert!((holder.value == 4)); } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(16)] pub struct p1_mem_initializer_names_object_Holder { diff --git a/tests/std/expr/expr.prim/out/unsafe/expr.prim.this.rs b/tests/std/expr/expr.prim/out/unsafe/expr.prim.this.rs index 1091720b88..1ce5670202 100644 --- a/tests/std/expr/expr.prim/out/unsafe/expr.prim.this.rs +++ b/tests/std/expr/expr.prim/out/unsafe/expr.prim.this.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] #[cpp_from(i32, construct, value)] pub struct p1_default_member_initializer_names_object_Holder { pub self_: *mut p1_default_member_initializer_names_object_Holder, @@ -37,7 +48,19 @@ pub unsafe fn test_0() { assert!(((holder.value) == (4))); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct p1_mem_initializer_names_object_Holder { pub self_: *mut p1_mem_initializer_names_object_Holder, diff --git a/tests/std/library/requirements/utility.requirements/allocator.requirements/out/refcount/allocator.requirements.general.rs b/tests/std/library/requirements/utility.requirements/allocator.requirements/out/refcount/allocator.requirements.general.rs index 25d3d46062..74cf888083 100644 --- a/tests/std/library/requirements/utility.requirements/allocator.requirements/out/refcount/allocator.requirements.general.rs +++ b/tests/std/library/requirements/utility.requirements/allocator.requirements/out/refcount/allocator.requirements.general.rs @@ -6,10 +6,35 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct p16_rebind_member_Alloc_std_pair_const_int__int___rebind_std_pair_const_int__int__ {} -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(4)] pub struct p16_rebind_member_Alloc_std_pair_const_int__int__ { #[offset(0)] @@ -43,7 +68,20 @@ pub fn test_0() { ); assert!(({ ((*n.borrow()).len() == 1_usize) })); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct p18_rebind_to_container_node_Alloc_std_pair_const_int__int__ {} pub fn test_1() { diff --git a/tests/std/library/requirements/utility.requirements/allocator.requirements/out/unsafe/allocator.requirements.general.rs b/tests/std/library/requirements/utility.requirements/allocator.requirements/out/unsafe/allocator.requirements.general.rs index b3c39ca5b6..23272890a2 100644 --- a/tests/std/library/requirements/utility.requirements/allocator.requirements/out/unsafe/allocator.requirements.general.rs +++ b/tests/std/library/requirements/utility.requirements/allocator.requirements/out/unsafe/allocator.requirements.general.rs @@ -7,10 +7,31 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p16_rebind_member_Alloc_std_pair_const_int__int___rebind_std_pair_const_int__int__ {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct p16_rebind_member_Alloc_std_pair_const_int__int__ { pub id: i32, } @@ -30,7 +51,18 @@ pub unsafe fn test_0() { assert!(((n.len()) == (1_usize))); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p18_rebind_to_container_node_Alloc_std_pair_const_int__int__ {} pub unsafe fn test_1() { let mut m: UnsafeMap = UnsafeMap::new(); diff --git a/tests/std/stmt.stmt/stmt.iter/out/refcount/stmt.while.rs b/tests/std/stmt.stmt/stmt.iter/out/refcount/stmt.while.rs index 32eb159e55..c8a43add69 100644 --- a/tests/std/stmt.stmt/stmt.iter/out/refcount/stmt.while.rs +++ b/tests/std/stmt.stmt/stmt.iter/out/refcount/stmt.while.rs @@ -13,7 +13,19 @@ thread_local!( pub static dtorCount_1: Value = Rc::new(RefCell::new(0)); ); #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Destructible, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, )] #[cpp_from(i32, construct, value)] #[byte_size(4)] @@ -64,7 +76,19 @@ thread_local!( pub static dtorCount_4: Value = Rc::new(RefCell::new(0)); ); #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Destructible, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, )] #[cpp_from(i32, construct, value)] #[byte_size(4)] diff --git a/tests/std/stmt.stmt/stmt.iter/out/unsafe/stmt.while.rs b/tests/std/stmt.stmt/stmt.iter/out/unsafe/stmt.while.rs index 57d7121ea3..2512419e85 100644 --- a/tests/std/stmt.stmt/stmt.iter/out/unsafe/stmt.while.rs +++ b/tests/std/stmt.stmt/stmt.iter/out/unsafe/stmt.while.rs @@ -10,7 +10,17 @@ pub static mut ctorCount_0: std::cell::LazyCell = std::cell::LazyCell::new( pub static mut dtorCount_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, Default, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, )] #[cpp_from(i32, construct, value)] pub struct p2_condition_variable_created_each_iteration_ConvertsToBool { @@ -64,7 +74,17 @@ pub static mut ctorCount_3: std::cell::LazyCell = std::cell::LazyCell::new( pub static mut dtorCount_4: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, Default, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, )] #[cpp_from(i32, construct, value)] pub struct p2_continue_destroys_condition_variable_ConvertsToBool { diff --git a/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.if.rs b/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.if.rs index 9beda4a205..c473ce277b 100644 --- a/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.if.rs +++ b/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.if.rs @@ -18,7 +18,16 @@ thread_local!( thread_local!( pub static useCount_3: Value = Rc::new(RefCell::new(0)); ); -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyAssign, Destructible)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + MoveConstructible, + MoveAssignable, +)] #[byte_size(4)] pub struct LifetimeTracked { #[offset(0)] @@ -50,7 +59,7 @@ impl Clone for LifetimeTracked { uses: self.uses.clone(), })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -200,20 +209,14 @@ fn main_0() -> i32 { } pub trait LifetimeTrackedImpl { fn construct(&self); - fn copy_from(&self, _a0: Ptr); fn destructor(&self); fn use_(&self); - fn copy_assign(&self, _a0: Ptr) -> Ptr; } impl LifetimeTrackedImpl for Ptr { fn construct(&self) { field!((*self), uses).write(0); (*ctorCount_0.with(Value::clone).borrow_mut()).prefix_inc(); } - fn copy_from(&self, _a0: Ptr) { - field!((*self), uses).write(0); - (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); - } fn destructor(&self) { (*dtorCount_2.with(Value::clone).borrow_mut()).prefix_inc(); } @@ -223,9 +226,17 @@ impl LifetimeTrackedImpl for Ptr { }); (*useCount_3.with(Value::clone).borrow_mut()).prefix_inc(); } - fn copy_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), uses).write(_a0.with(|__s| __s.uses)); - return (*self).clone(); +} +impl CopyAssignable for LifetimeTracked { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), uses).write(_a0.with(|__s| __s.uses)); + return (*this).clone(); + } +} +impl CopyConstructible for LifetimeTracked { + fn copy_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), uses).write(0); + (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); } } pub fn __cpp2rust_init_globals() { diff --git a/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs b/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs index 7fa6a24aba..a83fe0b984 100644 --- a/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs +++ b/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs @@ -18,7 +18,16 @@ thread_local!( thread_local!( pub static useCount_3: Value = Rc::new(RefCell::new(0)); ); -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyAssign, Destructible)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + MoveConstructible, + MoveAssignable, +)] #[byte_size(4)] pub struct LifetimeTracked { #[offset(0)] @@ -50,7 +59,7 @@ impl Clone for LifetimeTracked { uses: self.uses.clone(), })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -76,7 +85,19 @@ thread_local!( pub static dtorCount_6: Value = Rc::new(RefCell::new(0)); ); #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Destructible, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, )] #[cpp_into(i32, to_i32)] #[byte_size(4)] @@ -207,20 +228,14 @@ fn main_0() -> i32 { } pub trait LifetimeTrackedImpl { fn construct(&self); - fn copy_from(&self, _a0: Ptr); fn destructor(&self); fn use_(&self); - fn copy_assign(&self, _a0: Ptr) -> Ptr; } impl LifetimeTrackedImpl for Ptr { fn construct(&self) { field!((*self), uses).write(0); (*ctorCount_0.with(Value::clone).borrow_mut()).prefix_inc(); } - fn copy_from(&self, _a0: Ptr) { - field!((*self), uses).write(0); - (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); - } fn destructor(&self) { (*dtorCount_2.with(Value::clone).borrow_mut()).prefix_inc(); } @@ -230,9 +245,17 @@ impl LifetimeTrackedImpl for Ptr { }); (*useCount_3.with(Value::clone).borrow_mut()).prefix_inc(); } - fn copy_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), uses).write(_a0.with(|__s| __s.uses)); - return (*self).clone(); +} +impl CopyAssignable for LifetimeTracked { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), uses).write(_a0.with(|__s| __s.uses)); + return (*this).clone(); + } +} +impl CopyConstructible for LifetimeTracked { + fn copy_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), uses).write(0); + (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); } } pub trait p2_condition_variable_lives_for_whole_statement_ConvertsToIntImpl { diff --git a/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.if.rs b/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.if.rs index b5b0a0df24..1e279040bc 100644 --- a/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.if.rs +++ b/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.if.rs @@ -11,7 +11,14 @@ pub static mut copyCount_1: std::cell::LazyCell = std::cell::LazyCell::new( pub static mut dtorCount_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyAssignUnsafe, DestructibleUnsafe)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + MoveConstructibleUnsafe, + MoveAssignableUnsafe, +)] pub struct LifetimeTracked { pub uses: i32, } @@ -32,10 +39,6 @@ impl LifetimeTracked { (&raw mut self.uses).write(0); (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).prefix_inc(); } - pub unsafe fn copy_from(&mut self, _a0: *const LifetimeTracked) { - (&raw mut self.uses).write(0); - (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)).prefix_inc(); - } pub unsafe fn destructor(&mut self) { (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)).prefix_inc(); } @@ -43,7 +46,15 @@ impl LifetimeTracked { (*(&raw const self.uses).cast_mut()).prefix_inc(); (*std::cell::LazyCell::force_mut(&mut *&raw mut useCount_3)).prefix_inc(); } - pub unsafe fn copy_assign(&mut self, _a0: *const LifetimeTracked) -> *mut LifetimeTracked { +} +impl CopyConstructibleUnsafe for LifetimeTracked { + unsafe fn copy_constructor(&mut self, _a0: *const LifetimeTracked) { + (&raw mut self.uses).write(0); + (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)).prefix_inc(); + } +} +impl CopyAssignableUnsafe for LifetimeTracked { + unsafe fn copy_assign(&mut self, _a0: *const LifetimeTracked) -> *mut LifetimeTracked { self.uses = (*_a0).uses; return &mut (*(self as *mut LifetimeTracked)); } @@ -52,7 +63,7 @@ impl Clone for LifetimeTracked { fn clone(&self) -> Self { unsafe { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::copy_from(&mut __v, self as *const LifetimeTracked); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const LifetimeTracked); __v } } diff --git a/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs b/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs index 4455608afe..ca5209b401 100644 --- a/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs +++ b/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs @@ -11,7 +11,14 @@ pub static mut copyCount_1: std::cell::LazyCell = std::cell::LazyCell::new( pub static mut dtorCount_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyAssignUnsafe, DestructibleUnsafe)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + MoveConstructibleUnsafe, + MoveAssignableUnsafe, +)] pub struct LifetimeTracked { pub uses: i32, } @@ -32,10 +39,6 @@ impl LifetimeTracked { (&raw mut self.uses).write(0); (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).prefix_inc(); } - pub unsafe fn copy_from(&mut self, _a0: *const LifetimeTracked) { - (&raw mut self.uses).write(0); - (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)).prefix_inc(); - } pub unsafe fn destructor(&mut self) { (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)).prefix_inc(); } @@ -43,7 +46,15 @@ impl LifetimeTracked { (*(&raw const self.uses).cast_mut()).prefix_inc(); (*std::cell::LazyCell::force_mut(&mut *&raw mut useCount_3)).prefix_inc(); } - pub unsafe fn copy_assign(&mut self, _a0: *const LifetimeTracked) -> *mut LifetimeTracked { +} +impl CopyConstructibleUnsafe for LifetimeTracked { + unsafe fn copy_constructor(&mut self, _a0: *const LifetimeTracked) { + (&raw mut self.uses).write(0); + (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)).prefix_inc(); + } +} +impl CopyAssignableUnsafe for LifetimeTracked { + unsafe fn copy_assign(&mut self, _a0: *const LifetimeTracked) -> *mut LifetimeTracked { self.uses = (*_a0).uses; return &mut (*(self as *mut LifetimeTracked)); } @@ -52,7 +63,7 @@ impl Clone for LifetimeTracked { fn clone(&self) -> Self { unsafe { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::copy_from(&mut __v, self as *const LifetimeTracked); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const LifetimeTracked); __v } } @@ -75,7 +86,17 @@ pub static mut other_case_runs_5: std::cell::LazyCell = pub static mut dtorCount_6: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, Default, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, )] #[cpp_into(i32, to_i32)] pub struct p2_condition_variable_lives_for_whole_statement_ConvertsToInt { diff --git a/tests/std/temp/out/refcount/temp.type.rs b/tests/std/temp/out/refcount/temp.type.rs index ea929ef43c..8ec5f0cb3c 100644 --- a/tests/std/temp/out/refcount/temp.type.rs +++ b/tests/std/temp/out/refcount/temp.type.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct p2_6_pointer_to_member_argument_HasTwoInts { #[offset(0)] @@ -17,21 +30,60 @@ pub struct p2_6_pointer_to_member_argument_HasTwoInts { thread_local!( pub static count_0: Value = Rc::new(RefCell::new(0)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct p2_6_pointer_to_member_argument_CountsPerMember_refp2_6_pointer_to_member_argument_HasTwoInts_first_ {} thread_local!( pub static count_1: Value = Rc::new(RefCell::new(0)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct p2_6_pointer_to_member_argument_CountsPerMember_refp2_6_pointer_to_member_argument_HasTwoInts_second_ {} thread_local!( pub static count_2: Value = Rc::new(RefCell::new(0)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct p2_6_pointer_to_member_argument_CountsPerMember_nullptr_ {} pub fn test_3() { diff --git a/tests/std/temp/out/unsafe/temp.type.rs b/tests/std/temp/out/unsafe/temp.type.rs index 8b23294894..7dcef77813 100644 --- a/tests/std/temp/out/unsafe/temp.type.rs +++ b/tests/std/temp/out/unsafe/temp.type.rs @@ -7,24 +7,68 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p2_6_pointer_to_member_argument_HasTwoInts { pub first: i32, pub second: i32, } pub static mut count_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p2_6_pointer_to_member_argument_CountsPerMember_refp2_6_pointer_to_member_argument_HasTwoInts_first_ {} pub static mut count_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p2_6_pointer_to_member_argument_CountsPerMember_refp2_6_pointer_to_member_argument_HasTwoInts_second_ {} pub static mut count_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p2_6_pointer_to_member_argument_CountsPerMember_nullptr_ {} pub unsafe fn test_3() { (*std::cell::LazyCell::force_mut(&mut *&raw mut count_0)).prefix_inc(); diff --git a/tests/std/temp/temp.spec/out/refcount/temp.inst.rs b/tests/std/temp/temp.spec/out/refcount/temp.inst.rs index 2eab60289a..94b9dfee9a 100644 --- a/tests/std/temp/temp.spec/out/refcount/temp.inst.rs +++ b/tests/std/temp/temp.spec/out/refcount/temp.inst.rs @@ -6,7 +6,19 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(4)] pub struct p2_reference_does_not_instantiate_Member { #[offset(0)] @@ -17,7 +29,7 @@ impl Default for p2_reference_does_not_instantiate_Member { { p2_reference_does_not_instantiate_Member { value: 1 } } } } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, MoveCtor, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Default)] #[byte_size(4)] pub struct p2_reference_does_not_instantiate_Holder { #[offset(0)] @@ -42,14 +54,9 @@ fn main_0() -> i32 { #[derive(Clone, Copy, Default, ByteRepr, VaArg, FnPtrArg)] #[byte_size(1)] pub struct p2_reference_does_not_instantiate_Wrapper_int_; -pub trait p2_reference_does_not_instantiate_HolderImpl { - fn move_from(&self, _a0: Ptr); -} -impl p2_reference_does_not_instantiate_HolderImpl - for Ptr -{ - fn move_from(&self, _a0: Ptr) { - field!((*self), member).write({ (*_a0.upgrade().deref()).member }); +impl MoveConstructible for p2_reference_does_not_instantiate_Holder { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), member).write({ (*_a0.upgrade().deref()).member }); } } pub trait p2_reference_does_not_instantiate_MemberImpl { diff --git a/tests/std/temp/temp.spec/out/unsafe/temp.inst.rs b/tests/std/temp/temp.spec/out/unsafe/temp.inst.rs index 34ca7bfd39..7337b89ab9 100644 --- a/tests/std/temp/temp.spec/out/unsafe/temp.inst.rs +++ b/tests/std/temp/temp.spec/out/unsafe/temp.inst.rs @@ -7,7 +7,17 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct p2_reference_does_not_instantiate_Member { pub value: i32, } @@ -25,12 +35,12 @@ impl Default for p2_reference_does_not_instantiate_Member { } } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, Default)] pub struct p2_reference_does_not_instantiate_Holder { pub member: p2_reference_does_not_instantiate_Member, } -impl p2_reference_does_not_instantiate_Holder { - pub unsafe fn move_from(&mut self, _a0: *mut p2_reference_does_not_instantiate_Holder) { +impl MoveConstructibleUnsafe for p2_reference_does_not_instantiate_Holder { + unsafe fn move_constructor(&mut self, _a0: *mut p2_reference_does_not_instantiate_Holder) { (&raw mut self.member).write((*_a0).member); } } diff --git a/tests/std/utilities/utility/out/refcount/forward-helpers.rs b/tests/std/utilities/utility/out/refcount/forward-helpers.rs index 2a9f1c97a5..3433246354 100644 --- a/tests/std/utilities/utility/out/refcount/forward-helpers.rs +++ b/tests/std/utilities/utility/out/refcount/forward-helpers.rs @@ -14,7 +14,17 @@ pub fn test_0() { lvalue.write(2); assert!(({ ((*value.borrow()) == 2) })); } -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, CppFrom, Default)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct p6_forward_like_Movable { @@ -29,11 +39,21 @@ impl Clone for p6_forward_like_Movable { })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - p6_forward_like_MovableImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(4)] pub struct p6_forward_like_Holder { #[offset(0)] @@ -58,7 +78,7 @@ pub fn take_1(self_: Ptr) -> p6_forward_like_Movable { return { let __v: Value = Rc::new(RefCell::new(::zero_init())); - p6_forward_like_MovableImpl::copy_from(&__v.as_pointer(), { field_ptr!(self_, member) }); + CopyConstructible::copy_constructor(&__v.as_pointer(), { field_ptr!(self_, member) }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; } @@ -66,7 +86,7 @@ pub fn take_2(self_: Ptr) -> p6_forward_like_Movable { return { let __v: Value = Rc::new(RefCell::new(::zero_init())); - p6_forward_like_MovableImpl::move_from(&__v.as_pointer(), { field_ptr!(self_, member) }); + MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(self_, member) }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; } @@ -78,7 +98,7 @@ pub fn test_3() { let mut moved: p6_forward_like_Movable = ({ take_2(holder.as_pointer()) }); assert!((moved.value == 1) && ({ (*holder.borrow()).member.value } == 0)); } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, MoveCtor, CppFrom, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Default)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct p9_move_Movable { @@ -103,7 +123,7 @@ pub fn test_4() { })); let mut destination: p9_move_Movable = { let __v: Value = Rc::new(RefCell::new(::zero_init())); - p9_move_MovableImpl::move_from(&__v.as_pointer(), { source.as_pointer() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { source.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; assert!((destination.value == 3) && ({ (*source.borrow()).value } == 0)); @@ -129,7 +149,9 @@ pub fn test_4() { }) ); } -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, CppFrom)] +#[derive( + Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, CopyAssignable, MoveAssignable, +)] #[cpp_from(i32, construct, value)] #[byte_size(12)] pub struct p10_forward_in_template_A { @@ -150,7 +172,7 @@ impl Clone for p10_forward_in_template_A { })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - p10_forward_in_template_AImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -163,7 +185,7 @@ pub fn make_5(source: Ptr) -> p10_forward_in_template return { let __v: Value = Rc::new(RefCell::new(::zero_init())); - p10_forward_in_template_AImpl::copy_from(&__v.as_pointer(), { (source).clone() }); + CopyConstructible::copy_constructor(&__v.as_pointer(), { (source).clone() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; } @@ -171,7 +193,7 @@ pub fn make_6(source: Ptr) -> p10_forward_in_template return { let __v: Value = Rc::new(RefCell::new(::zero_init())); - p10_forward_in_template_AImpl::move_from(&__v.as_pointer(), { (source).clone() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { (source).clone() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; } @@ -189,7 +211,17 @@ pub fn test_7() { assert!(((moved.value == 1) && (moved.copies == 0)) && (moved.moves == 1)); assert!(({ (*a.borrow()).value } == 0)); } -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, CppFrom, Default)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct p11_move_if_noexcept_NoexceptMove { @@ -205,11 +237,21 @@ impl Clone for p11_move_if_noexcept_NoexceptMove { let __v: Value = Rc::new(RefCell::new( ::zero_init(), )); - p11_move_if_noexcept_NoexceptMoveImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, CppFrom, Default)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct p11_move_if_noexcept_ThrowingMove { @@ -225,7 +267,7 @@ impl Clone for p11_move_if_noexcept_ThrowingMove { let __v: Value = Rc::new(RefCell::new( ::zero_init(), )); - p11_move_if_noexcept_ThrowingMoveImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -241,9 +283,7 @@ pub fn test_8() { let __v: Value = Rc::new(RefCell::new( ::zero_init(), )); - p11_move_if_noexcept_NoexceptMoveImpl::move_from(&__v.as_pointer(), { - moved_from.as_pointer() - }); + MoveConstructible::move_constructor(&__v.as_pointer(), { moved_from.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; assert!((moved.value == 1) && ({ (*moved_from.borrow()).value } == 0)); @@ -258,9 +298,7 @@ pub fn test_8() { let __v: Value = Rc::new(RefCell::new( ::zero_init(), )); - p11_move_if_noexcept_ThrowingMoveImpl::copy_from(&__v.as_pointer(), { - copied_from.as_pointer() - }); + CopyConstructible::copy_constructor(&__v.as_pointer(), { copied_from.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; assert!((copied.value == 2) && ({ (*copied_from.borrow()).value } == 2)); @@ -279,8 +317,6 @@ fn main_0() -> i32 { } pub trait p10_forward_in_template_AImpl { fn construct(&self, value: i32); - fn copy_from(&self, other: Ptr); - fn move_from(&self, other: Ptr); } impl p10_forward_in_template_AImpl for Ptr { fn construct(&self, mut value: i32) { @@ -288,92 +324,100 @@ impl p10_forward_in_template_AImpl for Ptr { field!((*self), copies).write(0); field!((*self), moves).write(0); } - fn copy_from(&self, other: Ptr) { - field!((*self), value).write(other.with(|__s| __s.value)); - field!((*self), copies).write((other.with(|__s| __s.copies) + 1)); - field!((*self), moves).write(0); +} +impl CopyConstructible for p10_forward_in_template_A { + fn copy_constructor(this: &Ptr, other: Ptr) { + field!((*this), value).write(other.with(|__s| __s.value)); + field!((*this), copies).write((other.with(|__s| __s.copies) + 1)); + field!((*this), moves).write(0); } - fn move_from(&self, other: Ptr) { - field!((*self), value).write(other.with(|__s| __s.value)); - field!((*self), copies).write(0); - field!((*self), moves).write((other.with(|__s| __s.moves) + 1)); +} +impl MoveConstructible for p10_forward_in_template_A { + fn move_constructor(this: &Ptr, other: Ptr) { + field!((*this), value).write(other.with(|__s| __s.value)); + field!((*this), copies).write(0); + field!((*this), moves).write((other.with(|__s| __s.moves) + 1)); field!(other, value).write(0); } } pub trait p11_move_if_noexcept_NoexceptMoveImpl { fn construct(&self, value: i32); - fn copy_from(&self, other: Ptr); - fn move_from(&self, other: Ptr); } impl p11_move_if_noexcept_NoexceptMoveImpl for Ptr { fn construct(&self, mut value: i32) { field!((*self), value).write(value); } - fn copy_from(&self, other: Ptr) { - field!((*self), value).write(other.with(|__s| __s.value)); +} +impl CopyConstructible for p11_move_if_noexcept_NoexceptMove { + fn copy_constructor(this: &Ptr, other: Ptr) { + field!((*this), value).write(other.with(|__s| __s.value)); } - fn move_from(&self, other: Ptr) { - field!((*self), value).write(other.with(|__s| __s.value)); +} +impl MoveConstructible for p11_move_if_noexcept_NoexceptMove { + fn move_constructor(this: &Ptr, other: Ptr) { + field!((*this), value).write(other.with(|__s| __s.value)); field!(other, value).write(0); } } pub trait p11_move_if_noexcept_ThrowingMoveImpl { fn construct(&self, value: i32); - fn copy_from(&self, other: Ptr); - fn move_from(&self, other: Ptr); } impl p11_move_if_noexcept_ThrowingMoveImpl for Ptr { fn construct(&self, mut value: i32) { field!((*self), value).write(value); } - fn copy_from(&self, other: Ptr) { - field!((*self), value).write(other.with(|__s| __s.value)); +} +impl CopyConstructible for p11_move_if_noexcept_ThrowingMove { + fn copy_constructor(this: &Ptr, other: Ptr) { + field!((*this), value).write(other.with(|__s| __s.value)); } - fn move_from(&self, other: Ptr) { - field!((*self), value).write(other.with(|__s| __s.value)); +} +impl MoveConstructible for p11_move_if_noexcept_ThrowingMove { + fn move_constructor(this: &Ptr, other: Ptr) { + field!((*this), value).write(other.with(|__s| __s.value)); field!(other, value).write(0); } } -pub trait p6_forward_like_HolderImpl { - fn move_from(&self, _a0: Ptr); -} -impl p6_forward_like_HolderImpl for Ptr { - fn move_from(&self, _a0: Ptr) { - field!((*self), member).write({ +impl MoveConstructible for p6_forward_like_Holder { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), member).write({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - p6_forward_like_MovableImpl::move_from(&__v.as_pointer(), { field_ptr!(_a0, member) }); + MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, member) }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }); } } pub trait p6_forward_like_MovableImpl { fn construct(&self, value: i32); - fn copy_from(&self, other: Ptr); - fn move_from(&self, other: Ptr); } impl p6_forward_like_MovableImpl for Ptr { fn construct(&self, mut value: i32) { field!((*self), value).write(value); } - fn copy_from(&self, other: Ptr) { - field!((*self), value).write(other.with(|__s| __s.value)); +} +impl CopyConstructible for p6_forward_like_Movable { + fn copy_constructor(this: &Ptr, other: Ptr) { + field!((*this), value).write(other.with(|__s| __s.value)); } - fn move_from(&self, other: Ptr) { - field!((*self), value).write(other.with(|__s| __s.value)); +} +impl MoveConstructible for p6_forward_like_Movable { + fn move_constructor(this: &Ptr, other: Ptr) { + field!((*this), value).write(other.with(|__s| __s.value)); field!(other, value).write(0); } } pub trait p9_move_MovableImpl { fn construct(&self, value: i32); - fn move_from(&self, other: Ptr); } impl p9_move_MovableImpl for Ptr { fn construct(&self, mut value: i32) { field!((*self), value).write(value); } - fn move_from(&self, other: Ptr) { - field!((*self), value).write(other.with(|__s| __s.value)); +} +impl MoveConstructible for p9_move_Movable { + fn move_constructor(this: &Ptr, other: Ptr) { + field!((*this), value).write(other.with(|__s| __s.value)); field!(other, value).write(0); } } diff --git a/tests/std/utilities/utility/out/refcount/forward.rs b/tests/std/utilities/utility/out/refcount/forward.rs index aa13e0440e..97f0a0c4e7 100644 --- a/tests/std/utilities/utility/out/refcount/forward.rs +++ b/tests/std/utilities/utility/out/refcount/forward.rs @@ -12,7 +12,20 @@ pub fn test_0() { assert!((target == 1)); assert!((source == 1)); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct p9_move_trivially_copyable_Point { #[offset(0)] @@ -43,7 +56,7 @@ pub fn test_1() { assert!((points[0_usize].x == 5) && (points[0_usize].y == 6)); assert!((element.x == 5) && (element.y == 6)); } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, MoveCtor, CppFrom, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Default)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct p10_move_constructor_A { @@ -60,7 +73,7 @@ pub fn test_2() { let mut target: p10_move_constructor_A = { let __v: Value = Rc::new(RefCell::new(::zero_init())); - p10_move_constructor_AImpl::move_from(&__v.as_pointer(), { source.as_pointer() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { source.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; assert!((target.value == 1)); @@ -76,7 +89,7 @@ pub fn test_2() { let __a1 = { let __v: Value = Rc::new(RefCell::new(::zero_init())); - p10_move_constructor_AImpl::move_from(&__v.as_pointer(), { element.as_pointer() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { element.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; values.push(__a1) @@ -96,14 +109,15 @@ fn main_0() -> i32 { } pub trait p10_move_constructor_AImpl { fn construct(&self, value: i32); - fn move_from(&self, other: Ptr); } impl p10_move_constructor_AImpl for Ptr { fn construct(&self, mut value: i32) { field!((*self), value).write(value); } - fn move_from(&self, other: Ptr) { - field!((*self), value).write(other.with(|__s| __s.value)); +} +impl MoveConstructible for p10_move_constructor_A { + fn move_constructor(this: &Ptr, other: Ptr) { + field!((*this), value).write(other.with(|__s| __s.value)); field!(other, value).write(0); } } diff --git a/tests/std/utilities/utility/out/refcount/utility.as.const.rs b/tests/std/utilities/utility/out/refcount/utility.as.const.rs index 3d11aa6791..1c5b7a6348 100644 --- a/tests/std/utilities/utility/out/refcount/utility.as.const.rs +++ b/tests/std/utilities/utility/out/refcount/utility.as.const.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct p1_as_const_Counter { #[offset(0)] diff --git a/tests/std/utilities/utility/out/unsafe/forward-helpers.rs b/tests/std/utilities/utility/out/unsafe/forward-helpers.rs index c30596f714..ea83ca0084 100644 --- a/tests/std/utilities/utility/out/unsafe/forward-helpers.rs +++ b/tests/std/utilities/utility/out/unsafe/forward-helpers.rs @@ -15,7 +15,15 @@ pub unsafe fn test_0() { assert!(((value) == (2))); } #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, CppFromUnsafe, Default)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct p6_forward_like_Movable { pub value: i32, @@ -24,10 +32,14 @@ impl p6_forward_like_Movable { pub unsafe fn construct(&mut self, mut value: i32) { (&raw mut self.value).write(value); } - pub unsafe fn copy_from(&mut self, other: *const p6_forward_like_Movable) { +} +impl CopyConstructibleUnsafe for p6_forward_like_Movable { + unsafe fn copy_constructor(&mut self, other: *const p6_forward_like_Movable) { (&raw mut self.value).write((*other).value); } - pub unsafe fn move_from(&mut self, other: *mut p6_forward_like_Movable) { +} +impl MoveConstructibleUnsafe for p6_forward_like_Movable { + unsafe fn move_constructor(&mut self, other: *mut p6_forward_like_Movable) { (&raw mut self.value).write((*other).value); (*other).value = 0; } @@ -36,21 +48,32 @@ impl Clone for p6_forward_like_Movable { fn clone(&self) -> Self { unsafe { let mut __v: p6_forward_like_Movable = ::zero_init(); - p6_forward_like_Movable::copy_from(&mut __v, self as *const p6_forward_like_Movable); + CopyConstructibleUnsafe::copy_constructor( + &mut __v, + self as *const p6_forward_like_Movable, + ); __v } } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct p6_forward_like_Holder { pub member: p6_forward_like_Movable, } -impl p6_forward_like_Holder { - pub unsafe fn move_from(&mut self, _a0: *mut p6_forward_like_Holder) { +impl MoveConstructibleUnsafe for p6_forward_like_Holder { + unsafe fn move_constructor(&mut self, _a0: *mut p6_forward_like_Holder) { (&raw mut self.member).write({ let mut __v: p6_forward_like_Movable = ::zero_init(); - p6_forward_like_Movable::move_from(&mut __v, { &mut (*_a0).member }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut (*_a0).member }); __v }); } @@ -71,14 +94,14 @@ impl Default for p6_forward_like_Holder { pub unsafe fn take_1(self_: *mut p6_forward_like_Holder) -> p6_forward_like_Movable { return { let mut __v: p6_forward_like_Movable = ::zero_init(); - p6_forward_like_Movable::copy_from(&mut __v, { &(*self_).member }); + CopyConstructibleUnsafe::copy_constructor(&mut __v, { &(*self_).member }); __v }; } pub unsafe fn take_2(self_: *mut p6_forward_like_Holder) -> p6_forward_like_Movable { return { let mut __v: p6_forward_like_Movable = ::zero_init(); - p6_forward_like_Movable::move_from(&mut __v, { &mut (*self_).member }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut (*self_).member }); __v }; } @@ -90,7 +113,7 @@ pub unsafe fn test_3() { assert!(((moved.value) == (1)) && ((holder.member.value) == (0))); } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, CppFromUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] #[cpp_from(i32, construct, value)] pub struct p9_move_Movable { pub value: i32, @@ -99,7 +122,9 @@ impl p9_move_Movable { pub unsafe fn construct(&mut self, mut value: i32) { (&raw mut self.value).write(value); } - pub unsafe fn move_from(&mut self, other: *mut p9_move_Movable) { +} +impl MoveConstructibleUnsafe for p9_move_Movable { + unsafe fn move_constructor(&mut self, other: *mut p9_move_Movable) { (&raw mut self.value).write((*other).value); (*other).value = 0; } @@ -121,7 +146,7 @@ pub unsafe fn test_4() { }; let mut destination: p9_move_Movable = { let mut __v: p9_move_Movable = ::zero_init(); - p9_move_Movable::move_from(&mut __v, { &mut source }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut source }); __v }; assert!(((destination.value) == (3)) && ((source.value) == (0))); @@ -146,7 +171,14 @@ pub unsafe fn test_4() { ); } #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, CppFromUnsafe)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] #[cpp_from(i32, construct, value)] pub struct p10_forward_in_template_A { pub value: i32, @@ -159,12 +191,16 @@ impl p10_forward_in_template_A { (&raw mut self.copies).write(0); (&raw mut self.moves).write(0); } - pub unsafe fn copy_from(&mut self, other: *const p10_forward_in_template_A) { +} +impl CopyConstructibleUnsafe for p10_forward_in_template_A { + unsafe fn copy_constructor(&mut self, other: *const p10_forward_in_template_A) { (&raw mut self.value).write((*other).value); (&raw mut self.copies).write((((*other).copies) + (1))); (&raw mut self.moves).write(0); } - pub unsafe fn move_from(&mut self, other: *mut p10_forward_in_template_A) { +} +impl MoveConstructibleUnsafe for p10_forward_in_template_A { + unsafe fn move_constructor(&mut self, other: *mut p10_forward_in_template_A) { (&raw mut self.value).write((*other).value); (&raw mut self.copies).write(0); (&raw mut self.moves).write((((*other).moves) + (1))); @@ -175,7 +211,7 @@ impl Clone for p10_forward_in_template_A { fn clone(&self) -> Self { unsafe { let mut __v: p10_forward_in_template_A = ::zero_init(); - p10_forward_in_template_A::copy_from( + CopyConstructibleUnsafe::copy_constructor( &mut __v, self as *const p10_forward_in_template_A, ); @@ -191,14 +227,14 @@ impl Default for p10_forward_in_template_A { pub unsafe fn make_5(source: *mut p10_forward_in_template_A) -> p10_forward_in_template_A { return { let mut __v: p10_forward_in_template_A = ::zero_init(); - p10_forward_in_template_A::copy_from(&mut __v, { source }); + CopyConstructibleUnsafe::copy_constructor(&mut __v, { source }); __v }; } pub unsafe fn make_6(source: *mut p10_forward_in_template_A) -> p10_forward_in_template_A { return { let mut __v: p10_forward_in_template_A = ::zero_init(); - p10_forward_in_template_A::move_from(&mut __v, { source }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { source }); __v }; } @@ -216,7 +252,15 @@ pub unsafe fn test_7() { assert!(((a.value) == (0))); } #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, CppFromUnsafe, Default)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct p11_move_if_noexcept_NoexceptMove { pub value: i32, @@ -225,10 +269,14 @@ impl p11_move_if_noexcept_NoexceptMove { pub unsafe fn construct(&mut self, mut value: i32) { (&raw mut self.value).write(value); } - pub unsafe fn copy_from(&mut self, other: *const p11_move_if_noexcept_NoexceptMove) { +} +impl CopyConstructibleUnsafe for p11_move_if_noexcept_NoexceptMove { + unsafe fn copy_constructor(&mut self, other: *const p11_move_if_noexcept_NoexceptMove) { (&raw mut self.value).write((*other).value); } - pub unsafe fn move_from(&mut self, other: *mut p11_move_if_noexcept_NoexceptMove) { +} +impl MoveConstructibleUnsafe for p11_move_if_noexcept_NoexceptMove { + unsafe fn move_constructor(&mut self, other: *mut p11_move_if_noexcept_NoexceptMove) { (&raw mut self.value).write((*other).value); (*other).value = 0; } @@ -238,7 +286,7 @@ impl Clone for p11_move_if_noexcept_NoexceptMove { unsafe { let mut __v: p11_move_if_noexcept_NoexceptMove = ::zero_init(); - p11_move_if_noexcept_NoexceptMove::copy_from( + CopyConstructibleUnsafe::copy_constructor( &mut __v, self as *const p11_move_if_noexcept_NoexceptMove, ); @@ -247,7 +295,15 @@ impl Clone for p11_move_if_noexcept_NoexceptMove { } } #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, CppFromUnsafe, Default)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct p11_move_if_noexcept_ThrowingMove { pub value: i32, @@ -256,10 +312,14 @@ impl p11_move_if_noexcept_ThrowingMove { pub unsafe fn construct(&mut self, mut value: i32) { (&raw mut self.value).write(value); } - pub unsafe fn copy_from(&mut self, other: *const p11_move_if_noexcept_ThrowingMove) { +} +impl CopyConstructibleUnsafe for p11_move_if_noexcept_ThrowingMove { + unsafe fn copy_constructor(&mut self, other: *const p11_move_if_noexcept_ThrowingMove) { (&raw mut self.value).write((*other).value); } - pub unsafe fn move_from(&mut self, other: *mut p11_move_if_noexcept_ThrowingMove) { +} +impl MoveConstructibleUnsafe for p11_move_if_noexcept_ThrowingMove { + unsafe fn move_constructor(&mut self, other: *mut p11_move_if_noexcept_ThrowingMove) { (&raw mut self.value).write((*other).value); (*other).value = 0; } @@ -269,7 +329,7 @@ impl Clone for p11_move_if_noexcept_ThrowingMove { unsafe { let mut __v: p11_move_if_noexcept_ThrowingMove = ::zero_init(); - p11_move_if_noexcept_ThrowingMove::copy_from( + CopyConstructibleUnsafe::copy_constructor( &mut __v, self as *const p11_move_if_noexcept_ThrowingMove, ); @@ -287,7 +347,7 @@ pub unsafe fn test_8() { let mut moved: p11_move_if_noexcept_NoexceptMove = { let mut __v: p11_move_if_noexcept_NoexceptMove = ::zero_init(); - p11_move_if_noexcept_NoexceptMove::move_from(&mut __v, { &mut moved_from }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut moved_from }); __v }; assert!(((moved.value) == (1)) && ((moved_from.value) == (0))); @@ -300,7 +360,7 @@ pub unsafe fn test_8() { let mut copied: p11_move_if_noexcept_ThrowingMove = { let mut __v: p11_move_if_noexcept_ThrowingMove = ::zero_init(); - p11_move_if_noexcept_ThrowingMove::copy_from(&mut __v, { &copied_from }); + CopyConstructibleUnsafe::copy_constructor(&mut __v, { &copied_from }); __v }; assert!(((copied.value) == (2)) && ((copied_from.value) == (2))); diff --git a/tests/std/utilities/utility/out/unsafe/forward.rs b/tests/std/utilities/utility/out/unsafe/forward.rs index 4d369471ad..c1c7cf609c 100644 --- a/tests/std/utilities/utility/out/unsafe/forward.rs +++ b/tests/std/utilities/utility/out/unsafe/forward.rs @@ -13,7 +13,18 @@ pub unsafe fn test_0() { assert!(((source) == (1))); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p9_move_trivially_copyable_Point { pub x: i32, pub y: i32, @@ -42,7 +53,7 @@ pub unsafe fn test_1() { assert!(((element.x) == (5)) && ((element.y) == (6))); } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, CppFromUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] #[cpp_from(i32, construct, value)] pub struct p10_move_constructor_A { pub value: i32, @@ -51,7 +62,9 @@ impl p10_move_constructor_A { pub unsafe fn construct(&mut self, mut value: i32) { (&raw mut self.value).write(value); } - pub unsafe fn move_from(&mut self, other: *mut p10_move_constructor_A) { +} +impl MoveConstructibleUnsafe for p10_move_constructor_A { + unsafe fn move_constructor(&mut self, other: *mut p10_move_constructor_A) { (&raw mut self.value).write((*other).value); (*other).value = 0; } @@ -64,7 +77,7 @@ pub unsafe fn test_2() { }; let mut target: p10_move_constructor_A = { let mut __v: p10_move_constructor_A = ::zero_init(); - p10_move_constructor_A::move_from(&mut __v, { &mut source }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut source }); __v }; assert!(((target.value) == (1))); @@ -78,7 +91,7 @@ pub unsafe fn test_2() { { let __a1 = { let mut __v: p10_move_constructor_A = ::zero_init(); - p10_move_constructor_A::move_from(&mut __v, { &mut element }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut element }); __v }; values.push(__a1) diff --git a/tests/std/utilities/utility/out/unsafe/utility.as.const.rs b/tests/std/utilities/utility/out/unsafe/utility.as.const.rs index ae0918d0ef..93766a2402 100644 --- a/tests/std/utilities/utility/out/unsafe/utility.as.const.rs +++ b/tests/std/utilities/utility/out/unsafe/utility.as.const.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct p1_as_const_Counter { pub value: i32, } diff --git a/tests/ub/out/refcount/ctor_ref_member.rs b/tests/ub/out/refcount/ctor_ref_member.rs index 36144e741d..b454dd6b2b 100644 --- a/tests/ub/out/refcount/ctor_ref_member.rs +++ b/tests/ub/out/refcount/ctor_ref_member.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_from(i32, construct, ptr)] #[byte_size(8)] pub struct S { diff --git a/tests/ub/out/refcount/self_referencing_initializer.rs b/tests/ub/out/refcount/self_referencing_initializer.rs index 4dd36b221f..061f44a7e7 100644 --- a/tests/ub/out/refcount/self_referencing_initializer.rs +++ b/tests/ub/out/refcount/self_referencing_initializer.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct pair { #[offset(0)] diff --git a/tests/ub/out/refcount/ub6.rs b/tests/ub/out/refcount/ub6.rs index 3c715edc92..e4140f07b0 100644 --- a/tests/ub/out/refcount/ub6.rs +++ b/tests/ub/out/refcount/ub6.rs @@ -6,7 +6,19 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct Pair { #[offset(0)] diff --git a/tests/ub/out/unsafe/ctor_ref_member.rs b/tests/ub/out/unsafe/ctor_ref_member.rs index dc0191fb67..d0acb17763 100644 --- a/tests/ub/out/unsafe/ctor_ref_member.rs +++ b/tests/ub/out/unsafe/ctor_ref_member.rs @@ -7,7 +7,19 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(i32, construct, ptr)] pub struct S { pub r: *const i32, diff --git a/tests/ub/out/unsafe/self_referencing_initializer.rs b/tests/ub/out/unsafe/self_referencing_initializer.rs index 8036b03c41..20cdab0e43 100644 --- a/tests/ub/out/unsafe/self_referencing_initializer.rs +++ b/tests/ub/out/unsafe/self_referencing_initializer.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct pair { pub a: i32, pub b: i32, diff --git a/tests/ub/out/unsafe/ub6.rs b/tests/ub/out/unsafe/ub6.rs index f0cd73489f..b4456c9332 100644 --- a/tests/ub/out/unsafe/ub6.rs +++ b/tests/ub/out/unsafe/ub6.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Pair { pub x1: *mut i32, pub x2: *mut i32, diff --git a/tests/unit/out/refcount/05_new.rs b/tests/unit/out/refcount/05_new.rs index bc5e4eb072..779beee546 100644 --- a/tests/unit/out/refcount/05_new.rs +++ b/tests/unit/out/refcount/05_new.rs @@ -6,10 +6,36 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct A {} -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct D {} pub fn main() { diff --git a/tests/unit/out/refcount/10_struct.rs b/tests/unit/out/refcount/10_struct.rs index d66369557b..d0cc6b3762 100644 --- a/tests/unit/out/refcount/10_struct.rs +++ b/tests/unit/out/refcount/10_struct.rs @@ -6,7 +6,19 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct GraphNode { #[offset(0)] @@ -15,7 +27,19 @@ pub struct GraphNode { #[byte_size(8)] pub next: Ptr, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct Graph { #[offset(0)] @@ -24,7 +48,18 @@ pub struct Graph { #[byte_size(8)] pub adj: Ptr>, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(8)] pub struct Partial { #[offset(0)] @@ -40,10 +75,35 @@ impl Default for Partial { } } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct Declared {} -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/addr_of_global.rs b/tests/unit/out/refcount/addr_of_global.rs index d9a77441ee..5996d1cc85 100644 --- a/tests/unit/out/refcount/addr_of_global.rs +++ b/tests/unit/out/refcount/addr_of_global.rs @@ -6,13 +6,38 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Inner { #[offset(0)] pub value: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Outer { #[offset(0)] diff --git a/tests/unit/out/refcount/anonymous-struct.rs b/tests/unit/out/refcount/anonymous-struct.rs index eda0623019..ab7952ffbb 100644 --- a/tests/unit/out/refcount/anonymous-struct.rs +++ b/tests/unit/out/refcount/anonymous-struct.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Outer_Named { #[offset(0)] @@ -14,7 +27,20 @@ pub struct Outer_Named { #[offset(4)] pub b: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct anon_0 { #[offset(0)] @@ -22,7 +48,20 @@ pub struct anon_0 { #[offset(4)] pub d: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct anon_1 { #[offset(0)] @@ -30,7 +69,20 @@ pub struct anon_1 { #[offset(4)] pub h: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct anon_2 { #[offset(0)] @@ -38,19 +90,58 @@ pub struct anon_2 { #[offset(4)] pub f: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct anon_4 { #[offset(0)] pub j: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct anon_5 { #[offset(0)] pub k: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(12)] pub struct anon_3 { #[offset(0)] @@ -62,7 +153,20 @@ pub struct anon_3 { #[byte_size(4)] pub anon_5: anon_5, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(44)] pub struct Outer { #[offset(0)] @@ -126,7 +230,20 @@ fn main_0() -> i32 { ); return 0; } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct anon_6 { #[offset(0)] diff --git a/tests/unit/out/refcount/anonymous-struct_c.rs b/tests/unit/out/refcount/anonymous-struct_c.rs index 4dde61ed84..4c9332faeb 100644 --- a/tests/unit/out/refcount/anonymous-struct_c.rs +++ b/tests/unit/out/refcount/anonymous-struct_c.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Named { #[offset(0)] @@ -14,7 +27,20 @@ pub struct Named { #[offset(4)] pub b: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct anon_0 { #[offset(0)] @@ -22,7 +48,20 @@ pub struct anon_0 { #[offset(4)] pub d: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct anon_1 { #[offset(0)] @@ -30,7 +69,20 @@ pub struct anon_1 { #[offset(4)] pub h: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct anon_2 { #[offset(0)] @@ -38,19 +90,58 @@ pub struct anon_2 { #[offset(4)] pub f: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct anon_4 { #[offset(0)] pub j: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct anon_5 { #[offset(0)] pub k: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(12)] pub struct anon_3 { #[offset(0)] @@ -62,7 +153,20 @@ pub struct anon_3 { #[byte_size(4)] pub anon_5: anon_5, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(44)] pub struct Outer { #[offset(0)] @@ -132,7 +236,20 @@ fn main_0() -> i32 { ); return 0; } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct anon_6 { #[offset(0)] diff --git a/tests/unit/out/refcount/anonymous_enum.rs b/tests/unit/out/refcount/anonymous_enum.rs index e2778966b9..10b0ddeed9 100644 --- a/tests/unit/out/refcount/anonymous_enum.rs +++ b/tests/unit/out/refcount/anonymous_enum.rs @@ -12,7 +12,20 @@ pub const anon_0_FIRST_B: anon_0 = 1; pub type anon_1 = u32; pub const anon_1_SECOND_A: anon_1 = 0; pub const anon_1_SECOND_B: anon_1 = 1; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] @@ -24,7 +37,20 @@ pub const TdEnum_TD_B: TdEnum = 1; pub type anon_2 = u32; pub const anon_2_FIELD_A: anon_2 = 0; pub const anon_2_FIELD_B: anon_2 = 1; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct WithAnonField { #[offset(0)] diff --git a/tests/unit/out/refcount/anonymous_enum_c.rs b/tests/unit/out/refcount/anonymous_enum_c.rs index 5b19cd0c46..729c307e80 100644 --- a/tests/unit/out/refcount/anonymous_enum_c.rs +++ b/tests/unit/out/refcount/anonymous_enum_c.rs @@ -12,7 +12,20 @@ pub const anon_0_FIRST_B: anon_0 = 1; pub type anon_1 = u32; pub const anon_1_SECOND_A: anon_1 = 0; pub const anon_1_SECOND_B: anon_1 = 1; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] @@ -24,7 +37,20 @@ pub const TdEnum_enum_TD_B: TdEnum_enum = 1; pub type anon_2 = u32; pub const anon_2_FIELD_A: anon_2 = 0; pub const anon_2_FIELD_B: anon_2 = 1; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct WithAnonField { #[offset(0)] diff --git a/tests/unit/out/refcount/any.rs b/tests/unit/out/refcount/any.rs index 493694219f..2ae0880236 100644 --- a/tests/unit/out/refcount/any.rs +++ b/tests/unit/out/refcount/any.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Point { #[offset(0)] diff --git a/tests/unit/out/refcount/array_const_init.rs b/tests/unit/out/refcount/array_const_init.rs index 46be73bee6..18c1ad08d8 100644 --- a/tests/unit/out/refcount/array_const_init.rs +++ b/tests/unit/out/refcount/array_const_init.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(20)] pub struct S { #[offset(0)] @@ -38,7 +49,20 @@ thread_local!( buf: Box::new([0; 4]), })); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct P { #[offset(0)] diff --git a/tests/unit/out/refcount/array_field_addr.rs b/tests/unit/out/refcount/array_field_addr.rs index 26cbd4303f..5ee1d4db1e 100644 --- a/tests/unit/out/refcount/array_field_addr.rs +++ b/tests/unit/out/refcount/array_field_addr.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(12)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/array_of_noncopy_struct.rs b/tests/unit/out/refcount/array_of_noncopy_struct.rs index bf0ca98779..4eab804d63 100644 --- a/tests/unit/out/refcount/array_of_noncopy_struct.rs +++ b/tests/unit/out/refcount/array_of_noncopy_struct.rs @@ -6,7 +6,9 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, MoveAssign)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyConstructible, CopyAssignable, +)] #[byte_size(32)] pub struct NonCopy { #[offset(0)] @@ -43,21 +45,19 @@ fn main_0() -> i32 { assert!((arr[(2) as usize].data.len() == 0_usize)); return 0; } -pub trait NonCopyImpl { - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; -} -impl NonCopyImpl for Ptr { - fn move_from(&self, _a0: Ptr) { - field!((*self), data).write(field!(_a0, data).with_mut(std::mem::take)); - field!((*self), tag).write({ (*_a0.upgrade().deref()).tag }); - } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), data).with_mut(|__b0| { +impl MoveAssignable for NonCopy { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), data).with_mut(|__b0| { (*__b0) = field!(_a0, data).with_mut(std::mem::take); }); - field!((*self), tag).write({ (*_a0.upgrade().deref()).tag }); - return (*self).clone(); + field!((*this), tag).write({ (*_a0.upgrade().deref()).tag }); + return (*this).clone(); + } +} +impl MoveConstructible for NonCopy { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), data).write(field!(_a0, data).with_mut(std::mem::take)); + field!((*this), tag).write({ (*_a0.upgrade().deref()).tag }); } } pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/array_reference.rs b/tests/unit/out/refcount/array_reference.rs index 7bf1089f73..e6cddbad3c 100644 --- a/tests/unit/out/refcount/array_reference.rs +++ b/tests/unit/out/refcount/array_reference.rs @@ -59,7 +59,20 @@ pub fn fill_and_sum_9(a: Ptr, mut v: i32, out: Ptr) { pub fn pick_10(s: Ptr) -> Ptr { return (s).clone(); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Point { #[offset(0)] diff --git a/tests/unit/out/refcount/as_const.rs b/tests/unit/out/refcount/as_const.rs index cfda0a2235..21a4673f15 100644 --- a/tests/unit/out/refcount/as_const.rs +++ b/tests/unit/out/refcount/as_const.rs @@ -9,7 +9,20 @@ use std::rc::{Rc, Weak}; pub type Overload = u32; pub const Overload_kMutableOverload: Overload = 1; pub const Overload_kConstOverload: Overload = 2; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/assign_rhs_first.rs b/tests/unit/out/refcount/assign_rhs_first.rs index 36b9ea5db5..f445b694ef 100644 --- a/tests/unit/out/refcount/assign_rhs_first.rs +++ b/tests/unit/out/refcount/assign_rhs_first.rs @@ -15,7 +15,19 @@ pub fn advance_1() -> i32 { }); return 10; } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/assignment_single_eval.rs b/tests/unit/out/refcount/assignment_single_eval.rs index bbe8e8fc5e..2380a44db3 100644 --- a/tests/unit/out/refcount/assignment_single_eval.rs +++ b/tests/unit/out/refcount/assignment_single_eval.rs @@ -810,21 +810,57 @@ pub fn test_reference_members_9() { (*other.borrow()) ); } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Slot_6 { #[offset(0)] #[byte_size(8)] pub value: Ptr, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Slot_8 { #[offset(0)] #[byte_size(8)] pub value: Ptr, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Slot_10 { #[offset(0)] @@ -889,7 +925,19 @@ pub fn test_pointer_elements_11() { }; printf!(b"pointer increments %d %d\n", (*index.borrow()), value); } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Holder_12 { #[offset(0)] @@ -923,7 +971,19 @@ pub fn test_reference_pointer_13() { (({ (result).clone() } == { (second.as_pointer()) }) as i32) ); } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Node_14 { #[offset(0)] @@ -1020,26 +1080,76 @@ pub fn test_reference_subfields_18() { ({ (*other.borrow()).value } as i32) ); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Index_16 { #[offset(0)] pub value: u32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Slot_17 { #[offset(0)] #[byte_size(8)] pub ref_: Ptr, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(2)] pub struct Index_19 { #[offset(0)] pub value: i16, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Slot_20 { #[offset(0)] @@ -1081,13 +1191,39 @@ pub fn observe_global_23(mut assigned: i32) -> i32 { pub fn observe_24(mut assigned: i32, mut stored: Ptr) -> i32 { return ({ assigned } + { (stored.read()) }); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct GlobalRecord_Inner { #[offset(0)] pub value: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct GlobalRecord { #[offset(0)] @@ -1328,13 +1464,38 @@ thread_local!( thread_local!( static flag_31: Value = Rc::new(RefCell::new(false)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Record_32 { #[offset(0)] pub value: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Link_33 { #[offset(0)] @@ -1345,7 +1506,20 @@ thread_local!( pub static selected_values_34: Value> = Rc::new(RefCell::new(Box::new([0_u32, 20_u32, 30_u32]))); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct IndexedBinding {} pub fn test_binding_35() { @@ -1580,7 +1754,20 @@ thread_local!( Box::new([20_u32, 30_u32]), ]))); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(12)] pub struct IndexedMember { #[offset(0)] @@ -1941,7 +2128,19 @@ thread_local!( scoped_values_52.with(|v| v.decay()), ]))); ); -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct PointerSelector { #[offset(0)] @@ -2143,7 +2342,15 @@ pub fn test_stable_containers_58() { printf!(b"nonflat values %u %u\n", iterator_value, mapped_value); } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, MoveAssign, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + CopyAssignable, + Default, )] #[byte_size(24)] pub struct Counts_59 { @@ -2151,7 +2358,20 @@ pub struct Counts_59 { #[byte_size(24)] pub counts: Vec, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Pair_60 { #[offset(0)] @@ -2462,13 +2682,37 @@ fn main_0() -> i32 { ); return 0; } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Index_62 { #[offset(0)] pub value: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(12)] pub struct Owner_63 { #[offset(0)] @@ -2488,19 +2732,17 @@ impl Default for Owner_63 { } } } -pub trait Counts_59Impl { - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; -} -impl Counts_59Impl for Ptr { - fn move_from(&self, _a0: Ptr) { - field!((*self), counts).write(field!(_a0, counts).with_mut(std::mem::take)); - } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), counts).with_mut(|__b0| { +impl MoveAssignable for Counts_59 { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), counts).with_mut(|__b0| { (*__b0) = field!(_a0, counts).with_mut(std::mem::take); }); - return (*self).clone(); + return (*this).clone(); + } +} +impl MoveConstructible for Counts_59 { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), counts).write(field!(_a0, counts).with_mut(std::mem::take)); } } pub trait IndexedBindingImpl { diff --git a/tests/unit/out/refcount/bounded_struct_ptr.rs b/tests/unit/out/refcount/bounded_struct_ptr.rs index 1504753273..3c2b5ec6e5 100644 --- a/tests/unit/out/refcount/bounded_struct_ptr.rs +++ b/tests/unit/out/refcount/bounded_struct_ptr.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Foo { #[offset(0)] diff --git a/tests/unit/out/refcount/bst.rs b/tests/unit/out/refcount/bst.rs index bb456f8a87..a838f4dc6e 100644 --- a/tests/unit/out/refcount/bst.rs +++ b/tests/unit/out/refcount/bst.rs @@ -6,7 +6,19 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(24)] pub struct node_t { #[offset(0)] diff --git a/tests/unit/out/refcount/c_struct.rs b/tests/unit/out/refcount/c_struct.rs index 3ca4cf031e..84bf97a5ed 100644 --- a/tests/unit/out/refcount/c_struct.rs +++ b/tests/unit/out/refcount/c_struct.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Point { #[offset(0)] @@ -14,7 +27,20 @@ pub struct Point { #[offset(4)] pub y: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct Line { #[offset(0)] @@ -24,7 +50,19 @@ pub struct Line { #[byte_size(8)] pub end: Point, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct Node { #[offset(0)] @@ -37,7 +75,20 @@ pub type Color = u32; pub const Color_RED: Color = 0; pub const Color_GREEN: Color = 1; pub const Color_BLUE: Color = 2; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Inner { #[offset(0)] @@ -45,7 +96,20 @@ pub struct Inner { #[offset(4)] pub b: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct Container { #[offset(0)] diff --git a/tests/unit/out/refcount/cast.rs b/tests/unit/out/refcount/cast.rs index b935d1fca7..d828894cc8 100644 --- a/tests/unit/out/refcount/cast.rs +++ b/tests/unit/out/refcount/cast.rs @@ -10,7 +10,20 @@ pub type E = u32; pub const E_A: E = 0; pub const E_B: E = 1; pub const E_C: E = 2; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Pair { #[offset(0)] @@ -18,14 +31,38 @@ pub struct Pair { #[offset(4)] pub y: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(64)] #[byte_align(64)] pub struct Wide { #[offset(0)] pub c: i8, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(40)] pub struct Grid { #[offset(0)] @@ -53,7 +90,15 @@ impl Default for Grid { } } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, MoveAssign, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + CopyAssignable, + Default, )] #[byte_size(32)] pub struct Bag { @@ -516,21 +561,19 @@ fn main_0() -> i32 { ({ bool_to_floating_10() }); return 0; } -pub trait BagImpl { - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; -} -impl BagImpl for Ptr { - fn move_from(&self, _a0: Ptr) { - field!((*self), n).write({ (*_a0.upgrade().deref()).n }); - field!((*self), items).write(field!(_a0, items).with_mut(std::mem::take)); - } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), n).write({ (*_a0.upgrade().deref()).n }); - field!((*self), items).with_mut(|__b0| { +impl MoveAssignable for Bag { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), n).write({ (*_a0.upgrade().deref()).n }); + field!((*this), items).with_mut(|__b0| { (*__b0) = field!(_a0, items).with_mut(std::mem::take); }); - return (*self).clone(); + return (*this).clone(); + } +} +impl MoveConstructible for Bag { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), n).write({ (*_a0.upgrade().deref()).n }); + field!((*this), items).write(field!(_a0, items).with_mut(std::mem::take)); } } pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/cast_array_to_pointer_decay.rs b/tests/unit/out/refcount/cast_array_to_pointer_decay.rs index 4c176fcd8b..c94eb59c1f 100644 --- a/tests/unit/out/refcount/cast_array_to_pointer_decay.rs +++ b/tests/unit/out/refcount/cast_array_to_pointer_decay.rs @@ -16,7 +16,18 @@ pub fn strlen_1(mut s: Ptr) -> i32 { } return c; } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(12)] pub struct Row { #[offset(0)] diff --git a/tests/unit/out/refcount/class.rs b/tests/unit/out/refcount/class.rs index ac2303a74e..f805691032 100644 --- a/tests/unit/out/refcount/class.rs +++ b/tests/unit/out/refcount/class.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Pair { #[offset(0)] @@ -14,7 +27,20 @@ pub struct Pair { #[offset(4)] pub second: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct Route { #[offset(0)] @@ -23,7 +49,20 @@ pub struct Route { #[offset(8)] pub cost: f64, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Counter { #[offset(0)] @@ -36,7 +75,20 @@ impl CppEq for Counter { CounterImpl::operator_eq(__lhs, __rhs.clone()) } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Tally { #[offset(0)] diff --git a/tests/unit/out/refcount/class_template_lazy_member.rs b/tests/unit/out/refcount/class_template_lazy_member.rs index 0cd2514117..b1a58db62e 100644 --- a/tests/unit/out/refcount/class_template_lazy_member.rs +++ b/tests/unit/out/refcount/class_template_lazy_member.rs @@ -6,32 +6,97 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Point { #[offset(0)] pub x: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Box_int_ { #[offset(0)] pub val: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Box_Point_ { #[offset(0)] #[byte_size(4)] pub val: Point, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Deduced_int_ { #[offset(0)] pub val: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Deduced_Point_ { #[offset(0)] diff --git a/tests/unit/out/refcount/class_templates.rs b/tests/unit/out/refcount/class_templates.rs index 51f926cd50..f28b39244f 100644 --- a/tests/unit/out/refcount/class_templates.rs +++ b/tests/unit/out/refcount/class_templates.rs @@ -7,7 +7,15 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, MoveAssign, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + CopyAssignable, + Default, )] #[byte_size(24)] pub struct MyContainer_int_ { @@ -16,7 +24,15 @@ pub struct MyContainer_int_ { vec_: Vec, } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, MoveAssign, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + CopyAssignable, + Default, )] #[byte_size(24)] pub struct MyContainer_char_ { @@ -25,7 +41,15 @@ pub struct MyContainer_char_ { vec_: Vec, } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, MoveAssign, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + CopyAssignable, + Default, )] #[byte_size(24)] pub struct MyContainer_float_ { @@ -33,7 +57,20 @@ pub struct MyContainer_float_ { #[byte_size(24)] vec_: Vec, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(2)] pub struct Boxed_short_ { #[offset(0)] @@ -44,7 +81,20 @@ impl Boxed_short_ { return (((v as i32) + (v as i32)) as i16); } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Boxed_int_ { #[offset(0)] @@ -55,7 +105,20 @@ impl Boxed_int_ { return (v + v); } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Boxed_long_ { #[offset(0)] @@ -66,7 +129,20 @@ impl Boxed_long_ { return (v + v); } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Outer_int__Inner_int_ { #[offset(0)] @@ -74,13 +150,39 @@ pub struct Outer_int__Inner_int_ { #[offset(4)] pub u: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Outer_int_ { #[offset(0)] pub v: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct Outer_long__Inner_int_ { #[offset(0)] @@ -88,7 +190,20 @@ pub struct Outer_long__Inner_int_ { #[offset(8)] pub u: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct Outer_long__Inner_char_ { #[offset(0)] @@ -96,13 +211,39 @@ pub struct Outer_long__Inner_char_ { #[offset(8)] pub u: i8, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Outer_long_ { #[offset(0)] pub v: i64, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Elem { #[offset(0)] @@ -228,8 +369,6 @@ pub trait MyContainer_char_Impl { fn back_4(&self) -> Ptr; fn pop_back(&self); fn push_back(&self, item: Ptr); - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; } impl MyContainer_char_Impl for Ptr { fn empty(&self) -> bool { @@ -254,14 +393,18 @@ impl MyContainer_char_Impl for Ptr { field!((*self), vec_).with_mut(|__v: &mut Vec| __v.push(a0_clone)) }; } - fn move_from(&self, _a0: Ptr) { - field!((*self), vec_).write(field!(_a0, vec_).with_mut(std::mem::take)); - } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), vec_).with_mut(|__b0| { +} +impl MoveAssignable for MyContainer_char_ { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), vec_).with_mut(|__b0| { (*__b0) = field!(_a0, vec_).with_mut(std::mem::take); }); - return (*self).clone(); + return (*this).clone(); + } +} +impl MoveConstructible for MyContainer_char_ { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), vec_).write(field!(_a0, vec_).with_mut(std::mem::take)); } } pub trait MyContainer_float_Impl { @@ -273,8 +416,6 @@ pub trait MyContainer_float_Impl { fn back_4(&self) -> Ptr; fn pop_back(&self); fn push_back(&self, item: Ptr); - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; } impl MyContainer_float_Impl for Ptr { fn empty(&self) -> bool { @@ -299,14 +440,18 @@ impl MyContainer_float_Impl for Ptr { field!((*self), vec_).with_mut(|__v: &mut Vec| __v.push(a0_clone)) }; } - fn move_from(&self, _a0: Ptr) { - field!((*self), vec_).write(field!(_a0, vec_).with_mut(std::mem::take)); - } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), vec_).with_mut(|__b0| { +} +impl MoveAssignable for MyContainer_float_ { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), vec_).with_mut(|__b0| { (*__b0) = field!(_a0, vec_).with_mut(std::mem::take); }); - return (*self).clone(); + return (*this).clone(); + } +} +impl MoveConstructible for MyContainer_float_ { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), vec_).write(field!(_a0, vec_).with_mut(std::mem::take)); } } pub trait MyContainer_int_Impl { @@ -318,8 +463,6 @@ pub trait MyContainer_int_Impl { fn back_4(&self) -> Ptr; fn pop_back(&self); fn push_back(&self, item: Ptr); - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; } impl MyContainer_int_Impl for Ptr { fn empty(&self) -> bool { @@ -344,14 +487,18 @@ impl MyContainer_int_Impl for Ptr { field!((*self), vec_).with_mut(|__v: &mut Vec| __v.push(a0_clone)) }; } - fn move_from(&self, _a0: Ptr) { - field!((*self), vec_).write(field!(_a0, vec_).with_mut(std::mem::take)); - } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), vec_).with_mut(|__b0| { +} +impl MoveAssignable for MyContainer_int_ { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), vec_).with_mut(|__b0| { (*__b0) = field!(_a0, vec_).with_mut(std::mem::take); }); - return (*self).clone(); + return (*this).clone(); + } +} +impl MoveConstructible for MyContainer_int_ { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), vec_).write(field!(_a0, vec_).with_mut(std::mem::take)); } } pub trait Outer_int_Impl { diff --git a/tests/unit/out/refcount/clone_vs_move.rs b/tests/unit/out/refcount/clone_vs_move.rs index e039b96e3b..9b727c6698 100644 --- a/tests/unit/out/refcount/clone_vs_move.rs +++ b/tests/unit/out/refcount/clone_vs_move.rs @@ -6,13 +6,37 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Bar { #[offset(0)] pub w: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(40)] pub struct Foo { #[offset(0)] @@ -44,7 +68,19 @@ impl Default for Foo { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct Refs { #[offset(0)] diff --git a/tests/unit/out/refcount/comma_operator.rs b/tests/unit/out/refcount/comma_operator.rs index dfa9317ee4..1fff15389e 100644 --- a/tests/unit/out/refcount/comma_operator.rs +++ b/tests/unit/out/refcount/comma_operator.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Pair { #[offset(0)] diff --git a/tests/unit/out/refcount/complex_function.rs b/tests/unit/out/refcount/complex_function.rs index 67a13bc86d..347689b15a 100644 --- a/tests/unit/out/refcount/complex_function.rs +++ b/tests/unit/out/refcount/complex_function.rs @@ -15,27 +15,76 @@ pub fn ptr_1(mut x: Ptr) -> Ptr { pub fn bar_2(x: Ptr) -> Ptr { return (x).clone(); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct X1 { #[offset(0)] pub v: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct X2 { #[offset(0)] #[byte_size(8)] pub v: Ptr, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct X3 { #[offset(0)] #[byte_size(8)] pub v: Ptr, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct X4 { #[offset(0)] diff --git a/tests/unit/out/refcount/compound_assign_paren.rs b/tests/unit/out/refcount/compound_assign_paren.rs index d0915965f7..f46ef5a654 100644 --- a/tests/unit/out/refcount/compound_assign_paren.rs +++ b/tests/unit/out/refcount/compound_assign_paren.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct Item { #[offset(0)] diff --git a/tests/unit/out/refcount/concepts.rs b/tests/unit/out/refcount/concepts.rs index 2f2400e07d..4b5f8ab2ea 100644 --- a/tests/unit/out/refcount/concepts.rs +++ b/tests/unit/out/refcount/concepts.rs @@ -11,7 +11,20 @@ const _: () = assert!( (::std::mem::size_of::() == 4_usize), "sizeof(int) == 4" ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct Sized {} pub fn is_small_0() -> bool { diff --git a/tests/unit/out/refcount/constexpr_function.rs b/tests/unit/out/refcount/constexpr_function.rs index fc933ae67d..b8bc464459 100644 --- a/tests/unit/out/refcount/constexpr_function.rs +++ b/tests/unit/out/refcount/constexpr_function.rs @@ -21,7 +21,20 @@ pub fn scaled_2(mut x: i32) -> i32 { pub fn half_3(mut x: f64) -> f64 { return (x / 2_f64); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Flag { #[offset(0)] @@ -44,7 +57,20 @@ const _: () = assert!(true, "in_constant_context()"); pub fn imm_7(mut b: bool) -> bool { return b; } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct P { #[offset(0)] diff --git a/tests/unit/out/refcount/constructor.rs b/tests/unit/out/refcount/constructor.rs index 0663e02d8a..ce1ada3201 100644 --- a/tests/unit/out/refcount/constructor.rs +++ b/tests/unit/out/refcount/constructor.rs @@ -10,7 +10,19 @@ thread_local!( pub static total_0: Value = Rc::new(RefCell::new(0)); ); #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Destructible, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, )] #[cpp_from(i32, construct, value)] #[byte_size(4)] @@ -18,7 +30,20 @@ pub struct S { #[offset(0)] pub v: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[cpp_from(i32, construct_1, value)] #[byte_size(8)] pub struct Point { diff --git a/tests/unit/out/refcount/container_element_receiver.rs b/tests/unit/out/refcount/container_element_receiver.rs index ce9e3647ea..85f38d7d25 100644 --- a/tests/unit/out/refcount/container_element_receiver.rs +++ b/tests/unit/out/refcount/container_element_receiver.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(32)] pub struct Holder { #[offset(0)] @@ -132,13 +143,10 @@ fn main_0() -> i32 { assert!((({ sum_1(v.as_pointer(),) }) == 7)); return 0; } -pub trait HolderImpl { - fn move_from(&self, _a0: Ptr); -} -impl HolderImpl for Ptr { - fn move_from(&self, _a0: Ptr) { - field!((*self), ref_).write(({ (*_a0.upgrade().deref()).ref_.clone() }).clone()); - field!((*self), vec_).write(field!(_a0, vec_).with_mut(std::mem::take)); +impl MoveConstructible for Holder { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), ref_).write(({ (*_a0.upgrade().deref()).ref_.clone() }).clone()); + field!((*this), vec_).write(field!(_a0, vec_).with_mut(std::mem::take)); } } pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/container_field_addr.rs b/tests/unit/out/refcount/container_field_addr.rs index 8cf629f6a9..028f3422af 100644 --- a/tests/unit/out/refcount/container_field_addr.rs +++ b/tests/unit/out/refcount/container_field_addr.rs @@ -7,7 +7,15 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, MoveAssign, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + CopyAssignable, + Default, )] #[byte_size(32)] pub struct S { @@ -53,21 +61,19 @@ fn main_0() -> i32 { heap.delete(); return 0; } -pub trait SImpl { - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; -} -impl SImpl for Ptr { - fn move_from(&self, _a0: Ptr) { - field!((*self), tag).write({ (*_a0.upgrade().deref()).tag }); - field!((*self), v).write(field!(_a0, v).with_mut(std::mem::take)); - } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), tag).write({ (*_a0.upgrade().deref()).tag }); - field!((*self), v).with_mut(|__b0| { +impl MoveAssignable for S { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), tag).write({ (*_a0.upgrade().deref()).tag }); + field!((*this), v).with_mut(|__b0| { (*__b0) = field!(_a0, v).with_mut(std::mem::take); }); - return (*self).clone(); + return (*this).clone(); + } +} +impl MoveConstructible for S { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), tag).write({ (*_a0.upgrade().deref()).tag }); + field!((*this), v).write(field!(_a0, v).with_mut(std::mem::take)); } } pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/conversion_operator_same_translation.rs b/tests/unit/out/refcount/conversion_operator_same_translation.rs index bad76bd5f0..dc71c33463 100644 --- a/tests/unit/out/refcount/conversion_operator_same_translation.rs +++ b/tests/unit/out/refcount/conversion_operator_same_translation.rs @@ -6,7 +6,21 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_into(i8, to_i8)] #[cpp_into(u8, to_u8)] #[byte_size(4)] @@ -14,7 +28,21 @@ pub struct S { #[offset(0)] pub v: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_into(i64, to_i64_1)] #[byte_size(4)] pub struct T { diff --git a/tests/unit/out/refcount/copy_assign.rs b/tests/unit/out/refcount/copy_assign.rs index bd09ccb7a8..e061f71757 100644 --- a/tests/unit/out/refcount/copy_assign.rs +++ b/tests/unit/out/refcount/copy_assign.rs @@ -9,7 +9,16 @@ use std::rc::{Rc, Weak}; thread_local!( pub static assigns_0: Value = Rc::new(RefCell::new(0)); ); -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyAssign, Default)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + MoveConstructible, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Partial { #[offset(0)] @@ -24,11 +33,23 @@ impl Clone for Partial { keep: self.keep.clone(), })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - PartialImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(4)] pub struct NonConstAssign { #[offset(0)] @@ -46,7 +67,18 @@ impl Default for NonConstAssign { } } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyAssign)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + MoveAssignable, +)] #[byte_size(4)] pub struct RefQualified { #[offset(0)] @@ -63,7 +95,17 @@ impl Default for RefQualified { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyAssign)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + MoveAssignable, +)] #[byte_size(24)] pub struct Holder { #[offset(0)] @@ -89,7 +131,17 @@ impl Default for Holder { thread_local!( pub static copies_1: Value = Rc::new(RefCell::new(0)); ); -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, CopyAssign, Default)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + MoveConstructible, + MoveAssignable, + Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct CopyCounted { @@ -100,11 +152,21 @@ impl Clone for CopyCounted { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(CopyCounted { v: self.v.clone() })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - CopyCountedImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyAssign)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + MoveAssignable, +)] #[byte_size(12)] pub struct HasCopyCounted { #[offset(0)] @@ -147,18 +209,18 @@ fn main_0() -> i32 { PartialImpl::construct(&__v.as_pointer(), { 3 }, { 300 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); - ({ PartialImpl::copy_assign(&a.as_pointer(), b.as_pointer()) }); + ({ CopyAssignable::copy_assign(&a.as_pointer(), b.as_pointer()) }); assert!(({ (*a.borrow()).v } == 2) && ({ (*a.borrow()).keep } == 100)); assert!((assigns_0.with(|rc| *rc.borrow()) == 1)); ({ - PartialImpl::copy_assign( + CopyAssignable::copy_assign( &c.as_pointer(), - ({ PartialImpl::copy_assign(&a.as_pointer(), b.as_pointer()) }), + ({ CopyAssignable::copy_assign(&a.as_pointer(), b.as_pointer()) }), ) }); assert!(({ (*c.borrow()).v } == 2) && ({ (*c.borrow()).keep } == 300)); assert!((assigns_0.with(|rc| *rc.borrow()) == 3)); - ({ PartialImpl::copy_assign(&a.as_pointer(), a.as_pointer()) }); + ({ CopyAssignable::copy_assign(&a.as_pointer(), a.as_pointer()) }); assert!((assigns_0.with(|rc| *rc.borrow()) == 3)); ({ let _o: Value = Rc::new(RefCell::new({ @@ -166,15 +228,15 @@ fn main_0() -> i32 { PartialImpl::construct(&__v.as_pointer(), { 9 }, { 900 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); - PartialImpl::copy_assign(&a.as_pointer(), _o.as_pointer()) + CopyAssignable::copy_assign(&a.as_pointer(), _o.as_pointer()) }); assert!(({ (*a.borrow()).v } == 9) && ({ (*a.borrow()).keep } == 100)); assert!((assigns_0.with(|rc| *rc.borrow()) == 4)); let ra: Ptr = a.as_pointer(); - ({ PartialImpl::copy_assign(&ra, c.as_pointer()) }); + ({ CopyAssignable::copy_assign(&ra, c.as_pointer()) }); assert!(({ (*a.borrow()).v } == 2)); let mut pa: Ptr = (a.as_pointer()); - ({ PartialImpl::copy_assign(&pa, b.as_pointer()) }); + ({ CopyAssignable::copy_assign(&pa, b.as_pointer()) }); assert!(({ (*a.borrow()).v } == 2)); assert!((assigns_0.with(|rc| *rc.borrow()) == 6)); let h: Value = Rc::new(RefCell::new(Holder { @@ -196,9 +258,9 @@ fn main_0() -> i32 { }, ]), })); - ({ PartialImpl::copy_assign(&field_ptr!(h.as_pointer(), p), b.as_pointer()) }); + ({ CopyAssignable::copy_assign(&field_ptr!(h.as_pointer(), p), b.as_pointer()) }); ({ - PartialImpl::copy_assign( + CopyAssignable::copy_assign( &array_field_ptr!(h.as_pointer(), arr).offset((1) as isize), c.as_pointer(), ) @@ -243,7 +305,7 @@ fn main_0() -> i32 { RefQualifiedImpl::construct(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); - ({ RefQualifiedImpl::copy_assign(&r1.as_pointer(), r.as_pointer()) }); + ({ CopyAssignable::copy_assign(&r1.as_pointer(), r.as_pointer()) }); assert!(({ (*r1.borrow()).mark } == 1)); let h2: Value = Rc::new(RefCell::new(Holder { p: { @@ -264,7 +326,7 @@ fn main_0() -> i32 { }, ]), })); - ({ HolderImpl::copy_assign(&h2.as_pointer(), h.as_pointer()) }); + ({ CopyAssignable::copy_assign(&h2.as_pointer(), h.as_pointer()) }); assert!(({ (*h2.borrow()).p.v } == 2) && ({ (*h2.borrow()).p.keep } == 70)); assert!( (array_elem!(h2.as_pointer(), arr, 1).with(|__s| __s.v) == 2) @@ -281,7 +343,7 @@ fn main_0() -> i32 { CopyCountedImpl::construct(&__v.as_pointer(), { 2 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); - ({ CopyCountedImpl::copy_assign(&cc1.as_pointer(), cc2.as_pointer()) }); + ({ CopyAssignable::copy_assign(&cc1.as_pointer(), cc2.as_pointer()) }); assert!(({ (*cc1.borrow()).v } == 2)); let hc1: Value = Rc::new(RefCell::new(HasCopyCounted { c: { @@ -321,7 +383,7 @@ fn main_0() -> i32 { }, ]), })); - ({ HasCopyCountedImpl::copy_assign(&hc1.as_pointer(), hc2.as_pointer()) }); + ({ CopyAssignable::copy_assign(&hc1.as_pointer(), hc2.as_pointer()) }); assert!( (({ (*hc1.borrow()).c.v } == 4) && (array_elem!(hc1.as_pointer(), arr, 0).with(|__s| __s.v) == 5)) @@ -332,49 +394,45 @@ fn main_0() -> i32 { } pub trait CopyCountedImpl { fn construct(&self, v: i32); - fn copy_from(&self, o: Ptr); - fn copy_assign(&self, _a0: Ptr) -> Ptr; } impl CopyCountedImpl for Ptr { fn construct(&self, mut v: i32) { field!((*self), v).write(v); } - fn copy_from(&self, o: Ptr) { - field!((*self), v).write(o.with(|__s| __s.v)); - (*copies_1.with(Value::clone).borrow_mut()).prefix_inc(); - } - fn copy_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), v).write(_a0.with(|__s| __s.v)); - return (*self).clone(); +} +impl CopyAssignable for CopyCounted { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), v).write(_a0.with(|__s| __s.v)); + return (*this).clone(); } } -pub trait HasCopyCountedImpl { - fn copy_assign(&self, _a0: Ptr) -> Ptr; +impl CopyConstructible for CopyCounted { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + (*copies_1.with(Value::clone).borrow_mut()).prefix_inc(); + } } -impl HasCopyCountedImpl for Ptr { - fn copy_assign(&self, _a0: Ptr) -> Ptr { - ({ CopyCountedImpl::copy_assign(&field_ptr!((*self), c), field_ptr!(_a0, c)) }); +impl CopyAssignable for HasCopyCounted { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + ({ CopyAssignable::copy_assign(&field_ptr!((*this), c), field_ptr!(_a0, c)) }); { - let mut __tmp_0 = { (array_field_ptr!((*self), arr)).to_any() }; + let mut __tmp_0 = { (array_field_ptr!((*this), arr)).to_any() }; __tmp_0.memcpy(&(array_field_ptr!(_a0, arr)).to_any(), 8_usize); (__tmp_0).clone() }; - return (*self).clone(); + return (*this).clone(); } } -pub trait HolderImpl { - fn copy_assign(&self, _a0: Ptr) -> Ptr; -} -impl HolderImpl for Ptr { - fn copy_assign(&self, _a0: Ptr) -> Ptr { - ({ PartialImpl::copy_assign(&field_ptr!((*self), p), field_ptr!(_a0, p)) }); +impl CopyAssignable for Holder { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + ({ CopyAssignable::copy_assign(&field_ptr!((*this), p), field_ptr!(_a0, p)) }); { let mut __i0: usize = 0_usize; 'loop_: while (__i0 != 2_usize) { 'for_body: { ({ - PartialImpl::copy_assign( - &array_field_ptr!((*self), arr).offset((__i0) as isize), + CopyAssignable::copy_assign( + &array_field_ptr!((*this), arr).offset((__i0) as isize), array_field_ptr!(_a0, arr).offset((__i0) as isize), ) }); @@ -382,7 +440,7 @@ impl HolderImpl for Ptr { __i0.prefix_inc(); } } - return (*self).clone(); + return (*this).clone(); } } pub trait NonConstAssignImpl { @@ -405,38 +463,41 @@ impl NonConstAssignImpl for Ptr { } pub trait PartialImpl { fn construct(&self, v: i32, keep: i32); - fn copy_from(&self, o: Ptr); - fn copy_assign(&self, o: Ptr) -> Ptr; } impl PartialImpl for Ptr { fn construct(&self, mut v: i32, mut keep: i32) { field!((*self), v).write(v); field!((*self), keep).write(keep); } - fn copy_from(&self, o: Ptr) { - field!((*self), v).write(o.with(|__s| __s.v)); - field!((*self), keep).write(o.with(|__s| __s.keep)); - } - fn copy_assign(&self, o: Ptr) -> Ptr { - if ((*self) == (o)) { - return (*self).clone(); +} +impl CopyAssignable for Partial { + fn copy_assign(this: &Ptr, o: Ptr) -> Ptr { + if ((*this) == (o)) { + return (*this).clone(); } - field!((*self), v).write(o.with(|__s| __s.v)); + field!((*this), v).write(o.with(|__s| __s.v)); (*assigns_0.with(Value::clone).borrow_mut()).prefix_inc(); - return (*self).clone(); + return (*this).clone(); + } +} +impl CopyConstructible for Partial { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + field!((*this), keep).write(o.with(|__s| __s.keep)); } } pub trait RefQualifiedImpl { fn construct(&self); - fn copy_assign(&self, o: Ptr) -> Ptr; } impl RefQualifiedImpl for Ptr { fn construct(&self) { field!((*self), mark).write(0); } - fn copy_assign(&self, o: Ptr) -> Ptr { - field!((*self), mark).write((o.with(|__s| __s.mark) + 1)); - return (*self).clone(); +} +impl CopyAssignable for RefQualified { + fn copy_assign(this: &Ptr, o: Ptr) -> Ptr { + field!((*this), mark).write((o.with(|__s| __s.mark) + 1)); + return (*this).clone(); } } pub fn __cpp2rust_init_globals() { diff --git a/tests/unit/out/refcount/copy_ctor.rs b/tests/unit/out/refcount/copy_ctor.rs index 5191857c33..b84b15b1e1 100644 --- a/tests/unit/out/refcount/copy_ctor.rs +++ b/tests/unit/out/refcount/copy_ctor.rs @@ -9,7 +9,17 @@ use std::rc::{Rc, Weak}; thread_local!( pub static copies_0: Value = Rc::new(RefCell::new(0)); ); -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, CopyAssign, Default)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + MoveConstructible, + MoveAssignable, + Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct Counted { @@ -20,11 +30,20 @@ impl Clone for Counted { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(Counted { v: self.v.clone() })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - CountedImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyAssign)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + MoveAssignable, +)] #[byte_size(4)] pub struct NonConst { #[offset(0)] @@ -51,7 +70,17 @@ impl Default for NonConst { } } } -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, CopyAssign, Default)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + MoveConstructible, + MoveAssignable, + Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct Ignored { @@ -62,11 +91,21 @@ impl Clone for Ignored { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(Ignored { v: self.v.clone() })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - IgnoredImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyAssign)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + MoveAssignable, +)] #[byte_size(12)] pub struct Holder { #[offset(0)] @@ -89,7 +128,17 @@ impl Default for Holder { } } } -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, CppFrom, Default)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct Box_int_ { @@ -102,18 +151,39 @@ impl Clone for Box_int_ { val: self.val.clone(), })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - Box_int_Impl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Owner { #[offset(0)] #[byte_size(4)] pub box_: Box_int_, } -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, CopyAssign, Default)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + MoveConstructible, + MoveAssignable, + Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct OutOfLine { @@ -124,12 +194,13 @@ impl Clone for OutOfLine { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(OutOfLine { v: self.v.clone() })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - OutOfLineImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } -impl OutOfLine {} -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyAssign)] +#[derive( + Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveConstructible, MoveAssignable, +)] #[byte_size(4)] pub struct Tracked { #[offset(0)] @@ -141,7 +212,7 @@ impl Clone for Tracked { copied_from: self.copied_from.clone(), })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - TrackedImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -166,7 +237,7 @@ pub fn make_3(mut v: i32) -> Counted { })); return { let __v: Value = Rc::new(RefCell::new(::zero_init())); - CountedImpl::copy_from(&__v.as_pointer(), { c.as_pointer() }); + CopyConstructible::copy_constructor(&__v.as_pointer(), { c.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; } @@ -182,17 +253,17 @@ fn main_0() -> i32 { })); let mut b: Counted = { let __v: Value = Rc::new(RefCell::new(::zero_init())); - CountedImpl::copy_from(&__v.as_pointer(), { a.as_pointer() }); + CopyConstructible::copy_constructor(&__v.as_pointer(), { a.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; let mut c: Counted = { let __v: Value = Rc::new(RefCell::new(::zero_init())); - CountedImpl::copy_from(&__v.as_pointer(), { a.as_pointer() }); + CopyConstructible::copy_constructor(&__v.as_pointer(), { a.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; let mut d: Counted = { let __v: Value = Rc::new(RefCell::new(::zero_init())); - CountedImpl::copy_from(&__v.as_pointer(), { a.as_pointer() }); + CopyConstructible::copy_constructor(&__v.as_pointer(), { a.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; assert!((copies_0.with(|rc| *rc.borrow()) == 3)); @@ -201,7 +272,7 @@ fn main_0() -> i32 { (({ by_value_2({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - CountedImpl::copy_from(&__v.as_pointer(), { a.as_pointer() }); + CopyConstructible::copy_constructor(&__v.as_pointer(), { a.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }) }) == 1) @@ -224,7 +295,7 @@ fn main_0() -> i32 { })); let mut h: Counted = { let __v: Value = Rc::new(RefCell::new(::zero_init())); - CountedImpl::copy_from(&__v.as_pointer(), { g.as_pointer() }); + CopyConstructible::copy_constructor(&__v.as_pointer(), { g.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; assert!((h.v == 7)); @@ -267,7 +338,7 @@ fn main_0() -> i32 { })); let mut i2: Ignored = { let __v: Value = Rc::new(RefCell::new(::zero_init())); - IgnoredImpl::copy_from(&__v.as_pointer(), { i1.as_pointer() }); + CopyConstructible::copy_constructor(&__v.as_pointer(), { i1.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; assert!(({ (*i1.borrow()).v } == 1) && (i2.v == -1_i32)); @@ -281,7 +352,7 @@ fn main_0() -> i32 { })); let mut o2: Owner = { let __v: Value = Rc::new(RefCell::new(::zero_init())); - OwnerImpl::move_from(&__v.as_pointer(), { o.as_pointer() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { o.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; assert!((o2.box_.val == 3)); @@ -292,7 +363,7 @@ fn main_0() -> i32 { })); let mut ol2: OutOfLine = { let __v: Value = Rc::new(RefCell::new(::zero_init())); - OutOfLineImpl::copy_from(&__v.as_pointer(), { ol1.as_pointer() }); + CopyConstructible::copy_constructor(&__v.as_pointer(), { ol1.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; assert!((ol2.v == 105)); @@ -322,15 +393,15 @@ fn main_0() -> i32 { let t1: Value = Rc::new(RefCell::new(::default())); let t2: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - TrackedImpl::copy_from(&__v.as_pointer(), { t1.as_pointer() }); + CopyConstructible::copy_constructor(&__v.as_pointer(), { t1.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); - ({ TrackedImpl::copy_assign(&t2.as_pointer(), t1.as_pointer()) }); + ({ CopyAssignable::copy_assign(&t2.as_pointer(), t1.as_pointer()) }); assert!(({ (*t1.borrow()).copied_from } == 2)); let ct: Value = Rc::new(RefCell::new(::default())); let mut t3: Tracked = { let __v: Value = Rc::new(RefCell::new(::zero_init())); - TrackedImpl::copy_from(&__v.as_pointer(), { ct.as_pointer() }); + CopyConstructible::copy_constructor(&__v.as_pointer(), { ct.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; ({ touch_1((ct.as_pointer())) }); @@ -339,75 +410,77 @@ fn main_0() -> i32 { } pub trait Box_int_Impl { fn construct(&self, v: i32); - fn copy_from(&self, o: Ptr); - fn move_from(&self, _a0: Ptr); } impl Box_int_Impl for Ptr { fn construct(&self, mut v: i32) { field!((*self), val).write(v); } - fn copy_from(&self, o: Ptr) { - field!((*self), val).write(o.with(|__s| __s.val)); +} +impl CopyConstructible for Box_int_ { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), val).write(o.with(|__s| __s.val)); } - fn move_from(&self, _a0: Ptr) { - field!((*self), val).write({ (*_a0.upgrade().deref()).val }); +} +impl MoveConstructible for Box_int_ { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), val).write({ (*_a0.upgrade().deref()).val }); } } pub trait CountedImpl { fn construct(&self, v: i32); - fn copy_from(&self, o: Ptr); - fn copy_assign(&self, _a0: Ptr) -> Ptr; } impl CountedImpl for Ptr { fn construct(&self, mut v: i32) { field!((*self), v).write(v); } - fn copy_from(&self, o: Ptr) { - field!((*self), v).write(o.with(|__s| __s.v)); - (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); - } - fn copy_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), v).write(_a0.with(|__s| __s.v)); - return (*self).clone(); +} +impl CopyAssignable for Counted { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), v).write(_a0.with(|__s| __s.v)); + return (*this).clone(); } } -pub trait HolderImpl { - fn copy_assign(&self, _a0: Ptr) -> Ptr; +impl CopyConstructible for Counted { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); + } } -impl HolderImpl for Ptr { - fn copy_assign(&self, _a0: Ptr) -> Ptr { - ({ CountedImpl::copy_assign(&field_ptr!((*self), c), field_ptr!(_a0, c)) }); +impl CopyAssignable for Holder { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + ({ CopyAssignable::copy_assign(&field_ptr!((*this), c), field_ptr!(_a0, c)) }); { - let mut __tmp_0 = { (array_field_ptr!((*self), arr)).to_any() }; + let mut __tmp_0 = { (array_field_ptr!((*this), arr)).to_any() }; __tmp_0.memcpy(&(array_field_ptr!(_a0, arr)).to_any(), 8_usize); (__tmp_0).clone() }; - return (*self).clone(); + return (*this).clone(); } } pub trait IgnoredImpl { fn construct(&self, v: i32); - fn copy_from(&self, _a0: Ptr); - fn copy_assign(&self, _a0: Ptr) -> Ptr; } impl IgnoredImpl for Ptr { fn construct(&self, mut v: i32) { field!((*self), v).write(v); } - fn copy_from(&self, _a0: Ptr) { - field!((*self), v).write(-1_i32); - (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); +} +impl CopyAssignable for Ignored { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), v).write(_a0.with(|__s| __s.v)); + return (*this).clone(); } - fn copy_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), v).write(_a0.with(|__s| __s.v)); - return (*self).clone(); +} +impl CopyConstructible for Ignored { + fn copy_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), v).write(-1_i32); + (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); } } pub trait NonConstImpl { fn construct(&self); fn construct_1(&self, o: Ptr); fn construct_2(&self, o: Ptr); - fn copy_assign(&self, _a0: Ptr) -> Ptr; } impl NonConstImpl for Ptr { fn construct(&self) { @@ -419,57 +492,56 @@ impl NonConstImpl for Ptr { fn construct_2(&self, o: Ptr) { field!((*self), mark).write((o.with(|__s| __s.mark) + 10)); } - fn copy_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), mark).write(_a0.with(|__s| __s.mark)); - return (*self).clone(); +} +impl CopyAssignable for NonConst { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), mark).write(_a0.with(|__s| __s.mark)); + return (*this).clone(); } } pub trait OutOfLineImpl { fn construct(&self, v: i32); - fn copy_from(&self, o: Ptr); - fn copy_assign(&self, _a0: Ptr) -> Ptr; } impl OutOfLineImpl for Ptr { fn construct(&self, mut v: i32) { field!((*self), v).write(v); } - fn copy_from(&self, o: Ptr) { - field!((*self), v).write((o.with(|__s| __s.v) + 100)); - (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); - } - fn copy_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), v).write(_a0.with(|__s| __s.v)); - return (*self).clone(); +} +impl CopyAssignable for OutOfLine { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), v).write(_a0.with(|__s| __s.v)); + return (*this).clone(); } } -pub trait OwnerImpl { - fn move_from(&self, _a0: Ptr); +impl CopyConstructible for OutOfLine { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write((o.with(|__s| __s.v) + 100)); + (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); + } } -impl OwnerImpl for Ptr { - fn move_from(&self, _a0: Ptr) { - field!((*self), box_).write({ +impl MoveConstructible for Owner { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), box_).write({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - Box_int_Impl::move_from(&__v.as_pointer(), { field_ptr!(_a0, box_) }); + MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, box_) }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }); } } -pub trait TrackedImpl { - fn copy_from(&self, o: Ptr); - fn copy_assign(&self, o: Ptr) -> Ptr; -} -impl TrackedImpl for Ptr { - fn copy_from(&self, o: Ptr) { - field!((*self), copied_from).write(0); +impl CopyAssignable for Tracked { + fn copy_assign(this: &Ptr, o: Ptr) -> Ptr { field!(o, copied_from).with_mut(|__v| { __v.prefix_inc(); }); + return (*this).clone(); } - fn copy_assign(&self, o: Ptr) -> Ptr { +} +impl CopyConstructible for Tracked { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), copied_from).write(0); field!(o, copied_from).with_mut(|__v| { __v.prefix_inc(); }); - return (*self).clone(); } } pub fn __cpp2rust_init_globals() { diff --git a/tests/unit/out/refcount/copy_move_defaulted.rs b/tests/unit/out/refcount/copy_move_defaulted.rs index dd1836bdcc..a65f5bc724 100644 --- a/tests/unit/out/refcount/copy_move_defaulted.rs +++ b/tests/unit/out/refcount/copy_move_defaulted.rs @@ -6,13 +6,37 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Inner { #[offset(0)] pub x: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Destructible)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + CopyAssignable, + MoveAssignable, +)] #[cpp_from(i32, construct, value)] #[byte_size(16)] pub struct Explicit { @@ -31,7 +55,18 @@ impl Default for Explicit { { ::zero_init() } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(16)] pub struct Implicit { #[offset(0)] @@ -63,9 +98,8 @@ impl Default for Implicit { ZeroInitialization, VaArg, FnPtrArg, - MoveCtor, CppFrom, - MoveAssign, + CopyAssignable, Default, )] #[cpp_from(i32, construct, value)] @@ -74,18 +108,7 @@ pub struct DefaultCopyUserMove { #[offset(0)] pub v: i32, } -#[derive( - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - MoveCtor, - CppFrom, - CopyAssign, - MoveAssign, - Default, -)] +#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Default)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct UserCopyDefaultMove { @@ -98,11 +121,11 @@ impl Clone for UserCopyDefaultMove { Rc::new(RefCell::new(UserCopyDefaultMove { v: self.v.clone() })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - UserCopyDefaultMoveImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, MoveCtor, CppFrom, MoveAssign)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom)] #[cpp_from(i32, construct, value)] #[byte_size(64)] pub struct Buffer { @@ -124,7 +147,7 @@ impl Default for Buffer { { ::zero_init() } } } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, MoveCtor, MoveAssign)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg)] #[byte_size(48)] pub struct Owner { #[offset(0)] @@ -153,7 +176,15 @@ impl Default for Owner { } } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, MoveAssign, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + CopyAssignable, + Default, )] #[byte_size(24)] pub struct Copyable { @@ -161,17 +192,7 @@ pub struct Copyable { #[byte_size(24)] pub data: Vec, } -#[derive( - Record, - ByteRepr, - ZeroInitialization, - FnPtrArg, - MoveCtor, - CppFrom, - MoveAssign, - Destructible, - Default, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Destructible, Default)] #[cpp_from(i32, construct, value)] #[byte_size(32)] pub struct Holder { @@ -293,7 +314,7 @@ fn main_0() -> i32 { let mut m2: DefaultCopyUserMove = { let __v: Value = Rc::new(RefCell::new(::zero_init())); - DefaultCopyUserMoveImpl::move_from(&__v.as_pointer(), { m.as_pointer() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { m.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; assert!((({ (*m1.borrow()).v } == 7) && (m2.v == 7)) && ({ (*m.borrow()).v } == 0)); @@ -310,7 +331,7 @@ fn main_0() -> i32 { Rc::try_unwrap(__v).ok().unwrap().into_inner() })); m3 = (*m1.borrow()); - ({ DefaultCopyUserMoveImpl::move_assign(&m4.as_pointer(), m1.as_pointer()) }); + ({ MoveAssignable::move_assign(&m4.as_pointer(), m1.as_pointer()) }); assert!(((m3.v == 7) && ({ (*m4.borrow()).v } == 7)) && ({ (*m1.borrow()).v } == 0)); let u: Value = Rc::new(RefCell::new({ let __v: Value = @@ -321,13 +342,13 @@ fn main_0() -> i32 { let mut u1: UserCopyDefaultMove = { let __v: Value = Rc::new(RefCell::new(::zero_init())); - UserCopyDefaultMoveImpl::copy_from(&__v.as_pointer(), { u.as_pointer() }); + CopyConstructible::copy_constructor(&__v.as_pointer(), { u.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; let u2: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - UserCopyDefaultMoveImpl::move_from(&__v.as_pointer(), { u.as_pointer() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { u.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); assert!(((u1.v == 108) && ({ (*u2.borrow()).v } == 8)) && ({ (*u.borrow()).v } == 8)); @@ -343,8 +364,8 @@ fn main_0() -> i32 { UserCopyDefaultMoveImpl::construct(&__v.as_pointer(), { 1 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); - ({ UserCopyDefaultMoveImpl::copy_assign(&u3.as_pointer(), u2.as_pointer()) }); - ({ UserCopyDefaultMoveImpl::move_assign(&u4.as_pointer(), u2.as_pointer()) }); + ({ CopyAssignable::copy_assign(&u3.as_pointer(), u2.as_pointer()) }); + ({ MoveAssignable::move_assign(&u4.as_pointer(), u2.as_pointer()) }); assert!(({ (*u3.borrow()).v } == 108) && ({ (*u4.borrow()).v } == 8)); let p: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); @@ -353,7 +374,7 @@ fn main_0() -> i32 { })); let q: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - BufferImpl::move_from(&__v.as_pointer(), { p.as_pointer() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { p.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); assert!( @@ -368,7 +389,7 @@ fn main_0() -> i32 { BufferImpl::construct(&__v.as_pointer(), { 1 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); - ({ BufferImpl::move_assign(&r.as_pointer(), q.as_pointer()) }); + ({ MoveAssignable::move_assign(&r.as_pointer(), q.as_pointer()) }); assert!( ({ ((({ (*r.borrow()).n } == 3) && ((*r.borrow()).data.len() == 3_usize)) @@ -393,7 +414,7 @@ fn main_0() -> i32 { { let __a1 = { let __v: Value = Rc::new(RefCell::new(::zero_init())); - BufferImpl::move_from(&__v.as_pointer(), { r.as_pointer() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { r.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; (*bufs.borrow_mut()).push(__a1) @@ -402,7 +423,9 @@ fn main_0() -> i32 { let mut __tmp_2 = { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - BufferImpl::move_from(&__v.as_pointer(), { bufs.decay().offset(0_usize) }); + MoveConstructible::move_constructor(&__v.as_pointer(), { + bufs.decay().offset(0_usize) + }); Rc::try_unwrap(__v).ok().unwrap().into_inner() } }; @@ -429,7 +452,7 @@ fn main_0() -> i32 { }; let o2: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - OwnerImpl::move_from(&__v.as_pointer(), { o1.as_pointer() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { o1.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); assert!( @@ -446,7 +469,7 @@ fn main_0() -> i32 { }) ); let o3: Value = Rc::new(RefCell::new(::default())); - ({ OwnerImpl::move_assign(&o3.as_pointer(), o2.as_pointer()) }); + ({ MoveAssignable::move_assign(&o3.as_pointer(), o2.as_pointer()) }); assert!( ((({ (*o3.borrow()).n } == 5) && ((vec_elem!(o3.as_pointer(), data, 0_usize).read()) == 5)) @@ -465,13 +488,13 @@ fn main_0() -> i32 { let mut c2: Copyable = (*c1.borrow()).clone(); let c3: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - CopyableImpl::move_from(&__v.as_pointer(), { c1.as_pointer() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { c1.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); assert!(({ (c2.data.len() == 2_usize) && ((*c3.borrow()).data.len() == 2_usize) })); assert!(({ (*c1.borrow()).data.is_empty() })); let c4: Value = Rc::new(RefCell::new(::default())); - ({ CopyableImpl::move_assign(&c4.as_pointer(), c3.as_pointer()) }); + ({ MoveAssignable::move_assign(&c4.as_pointer(), c3.as_pointer()) }); assert!( ({ ((vec_elem!(c4.as_pointer(), data, 1_usize).read()) == 2) @@ -491,7 +514,7 @@ fn main_0() -> i32 { }; let h2: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - HolderImpl::move_from(&__v.as_pointer(), { h1.as_pointer() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { h1.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let _dtor_h2 = @@ -508,7 +531,7 @@ fn main_0() -> i32 { })); let _dtor_h3 = std::mem::DropGuard::new(h3.clone(), |__p| Destructible::destroy(__p.as_pointer())); - ({ HolderImpl::move_assign(&h3.as_pointer(), h2.as_pointer()) }); + ({ MoveAssignable::move_assign(&h3.as_pointer(), h2.as_pointer()) }); assert!( ((({ (*h3.borrow()).inner.x } == 4) && ((array_elem!(field_ptr!(h3.as_pointer(), e), arr, 1).read()) == 5)) @@ -519,8 +542,6 @@ fn main_0() -> i32 { } pub trait BufferImpl { fn construct(&self, n: i32); - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; } impl BufferImpl for Ptr { fn construct(&self, mut n: i32) { @@ -533,62 +554,66 @@ impl BufferImpl for Ptr { field!((*self), rows).with_mut(|__v: &mut Vec>| __v.push(a0_clone)) }; } - fn move_from(&self, _a0: Ptr) { - field!((*self), data).write(field!(_a0, data).with_mut(std::mem::take)); - field!((*self), rows).write(field!(_a0, rows).with_mut(std::mem::take)); - field!((*self), n).write({ (*_a0.upgrade().deref()).n }); - field!((*self), arr).write(Box::new(std::array::from_fn::<_, 2, _>(|__i: usize| { - (*_a0.upgrade().deref()).arr[(__i) as usize] - }))); - } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), data).with_mut(|__b0| { +} +impl MoveAssignable for Buffer { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), data).with_mut(|__b0| { (*__b0) = field!(_a0, data).with_mut(std::mem::take); }); - field!((*self), rows).with_mut(|__b0| { + field!((*this), rows).with_mut(|__b0| { (*__b0) = field!(_a0, rows).with_mut(std::mem::take); }); - field!((*self), n).write({ (*_a0.upgrade().deref()).n }); + field!((*this), n).write({ (*_a0.upgrade().deref()).n }); { - let mut __tmp_0 = { (array_field_ptr!((*self), arr)).to_any() }; + let mut __tmp_0 = { (array_field_ptr!((*this), arr)).to_any() }; __tmp_0.memcpy(&(array_field_ptr!(_a0, arr)).to_any(), 8_usize); (__tmp_0).clone() }; - return (*self).clone(); + return (*this).clone(); } } -pub trait CopyableImpl { - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; -} -impl CopyableImpl for Ptr { - fn move_from(&self, _a0: Ptr) { - field!((*self), data).write(field!(_a0, data).with_mut(std::mem::take)); +impl MoveConstructible for Buffer { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), data).write(field!(_a0, data).with_mut(std::mem::take)); + field!((*this), rows).write(field!(_a0, rows).with_mut(std::mem::take)); + field!((*this), n).write({ (*_a0.upgrade().deref()).n }); + field!((*this), arr).write(Box::new(std::array::from_fn::<_, 2, _>(|__i: usize| { + (*_a0.upgrade().deref()).arr[(__i) as usize] + }))); } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), data).with_mut(|__b0| { +} +impl MoveAssignable for Copyable { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), data).with_mut(|__b0| { (*__b0) = field!(_a0, data).with_mut(std::mem::take); }); - return (*self).clone(); + return (*this).clone(); + } +} +impl MoveConstructible for Copyable { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), data).write(field!(_a0, data).with_mut(std::mem::take)); } } pub trait DefaultCopyUserMoveImpl { fn construct(&self, v: i32); - fn move_from(&self, o: Ptr); - fn move_assign(&self, o: Ptr) -> Ptr; } impl DefaultCopyUserMoveImpl for Ptr { fn construct(&self, mut v: i32) { field!((*self), v).write(v); } - fn move_from(&self, o: Ptr) { - field!((*self), v).write(o.with(|__s| __s.v)); +} +impl MoveAssignable for DefaultCopyUserMove { + fn move_assign(this: &Ptr, o: Ptr) -> Ptr { + field!((*this), v).write(o.with(|__s| __s.v)); field!(o, v).write(0); + return (*this).clone(); } - fn move_assign(&self, o: Ptr) -> Ptr { - field!((*self), v).write(o.with(|__s| __s.v)); +} +impl MoveConstructible for DefaultCopyUserMove { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); field!(o, v).write(0); - return (*self).clone(); } } pub trait ExplicitImpl { @@ -605,8 +630,6 @@ impl ExplicitImpl for Ptr { } pub trait HolderImpl { fn construct(&self, v: i32); - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; fn destructor(&self); } impl HolderImpl for Ptr { @@ -619,78 +642,84 @@ impl HolderImpl for Ptr { }); field!((*self), p).write(None); } - fn move_from(&self, _a0: Ptr) { - field!((*self), inner).write({ (*_a0.upgrade().deref()).inner }); - field!((*self), e).write({ (*_a0.upgrade().deref()).e.clone() }); - field!((*self), p) - .write(field!(_a0, p).with_mut(|__v: &mut Option>| __v.take())); - } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), inner).write({ (*_a0.upgrade().deref()).inner }); - field!((*self), e).write({ (*_a0.upgrade().deref()).e.clone() }); - field!((*self), p).with_mut(|__b0| { - (*__b0) = field!(_a0, p).with_mut(|__v: &mut Option>| __v.take()); - }); - return (*self).clone(); - } fn destructor(&self) { Destructible::destroy(field_ptr!(self, e)); } } -pub trait OwnerImpl { - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; +impl MoveAssignable for Holder { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), inner).write({ (*_a0.upgrade().deref()).inner }); + field!((*this), e).write({ (*_a0.upgrade().deref()).e.clone() }); + field!((*this), p).with_mut(|__b0| { + (*__b0) = field!(_a0, p).with_mut(|__v: &mut Option>| __v.take()); + }); + return (*this).clone(); + } } -impl OwnerImpl for Ptr { - fn move_from(&self, _a0: Ptr) { - field!((*self), data).write(field!(_a0, data).with_mut(std::mem::take)); - field!((*self), n).write({ (*_a0.upgrade().deref()).n }); - field!((*self), arr).write(Box::new(std::array::from_fn::<_, 2, _>(|__i: usize| { - (*_a0.upgrade().deref()).arr[(__i) as usize] - }))); - field!((*self), p) +impl MoveConstructible for Holder { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), inner).write({ (*_a0.upgrade().deref()).inner }); + field!((*this), e).write({ (*_a0.upgrade().deref()).e.clone() }); + field!((*this), p) .write(field!(_a0, p).with_mut(|__v: &mut Option>| __v.take())); } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), data).with_mut(|__b0| { +} +impl MoveAssignable for Owner { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), data).with_mut(|__b0| { (*__b0) = field!(_a0, data).with_mut(std::mem::take); }); - field!((*self), n).write({ (*_a0.upgrade().deref()).n }); + field!((*this), n).write({ (*_a0.upgrade().deref()).n }); { - let mut __tmp_1 = { (array_field_ptr!((*self), arr)).to_any() }; + let mut __tmp_1 = { (array_field_ptr!((*this), arr)).to_any() }; __tmp_1.memcpy(&(array_field_ptr!(_a0, arr)).to_any(), 8_usize); (__tmp_1).clone() }; - field!((*self), p).with_mut(|__b0| { + field!((*this), p).with_mut(|__b0| { (*__b0) = field!(_a0, p).with_mut(|__v: &mut Option>| __v.take()); }); - return (*self).clone(); + return (*this).clone(); + } +} +impl MoveConstructible for Owner { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), data).write(field!(_a0, data).with_mut(std::mem::take)); + field!((*this), n).write({ (*_a0.upgrade().deref()).n }); + field!((*this), arr).write(Box::new(std::array::from_fn::<_, 2, _>(|__i: usize| { + (*_a0.upgrade().deref()).arr[(__i) as usize] + }))); + field!((*this), p) + .write(field!(_a0, p).with_mut(|__v: &mut Option>| __v.take())); } } pub trait UserCopyDefaultMoveImpl { fn construct(&self, v: i32); - fn copy_from(&self, o: Ptr); - fn move_from(&self, _a0: Ptr); - fn copy_assign(&self, o: Ptr) -> Ptr; - fn move_assign(&self, _a0: Ptr) -> Ptr; } impl UserCopyDefaultMoveImpl for Ptr { fn construct(&self, mut v: i32) { field!((*self), v).write(v); } - fn copy_from(&self, o: Ptr) { - field!((*self), v).write((o.with(|__s| __s.v) + 100)); +} +impl CopyAssignable for UserCopyDefaultMove { + fn copy_assign(this: &Ptr, o: Ptr) -> Ptr { + field!((*this), v).write((o.with(|__s| __s.v) + 100)); + return (*this).clone(); } - fn move_from(&self, _a0: Ptr) { - field!((*self), v).write({ (*_a0.upgrade().deref()).v }); +} +impl CopyConstructible for UserCopyDefaultMove { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write((o.with(|__s| __s.v) + 100)); } - fn copy_assign(&self, o: Ptr) -> Ptr { - field!((*self), v).write((o.with(|__s| __s.v) + 100)); - return (*self).clone(); +} +impl MoveAssignable for UserCopyDefaultMove { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), v).write({ (*_a0.upgrade().deref()).v }); + return (*this).clone(); } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), v).write({ (*_a0.upgrade().deref()).v }); - return (*self).clone(); +} +impl MoveConstructible for UserCopyDefaultMove { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), v).write({ (*_a0.upgrade().deref()).v }); } } pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/copy_move_deleted.rs b/tests/unit/out/refcount/copy_move_deleted.rs index c5e1620098..1fe623fe58 100644 --- a/tests/unit/out/refcount/copy_move_deleted.rs +++ b/tests/unit/out/refcount/copy_move_deleted.rs @@ -6,16 +6,14 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, MoveCtor, CppFrom, MoveAssign, Default, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Default)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct NoCopy { #[offset(0)] pub v: i32, } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, MoveCtor, MoveAssign)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg)] #[byte_size(4)] pub struct PrivateCopy { #[offset(0)] @@ -49,7 +47,7 @@ impl Default for Immovable { } } } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, MoveCtor, MoveAssign, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Default)] #[byte_size(8)] pub struct Container { #[offset(0)] @@ -58,7 +56,7 @@ pub struct Container { #[offset(4)] pub tag: i32, } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, MoveCtor, MoveAssign, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Default)] #[byte_size(24)] pub struct VecHolder { #[offset(0)] @@ -83,11 +81,11 @@ fn main_0() -> i32 { })); let b: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - NoCopyImpl::move_from(&__v.as_pointer(), { a.as_pointer() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { a.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); assert!(({ (*b.borrow()).v } == 1) && ({ (*a.borrow()).v } == 0)); - ({ NoCopyImpl::move_assign(&a.as_pointer(), b.as_pointer()) }); + ({ MoveAssignable::move_assign(&a.as_pointer(), b.as_pointer()) }); assert!(({ (*a.borrow()).v } == 1) && ({ (*b.borrow()).v } == 0)); ({ bump_0((a.as_pointer())) }); assert!(({ (*a.borrow()).v } == 2)); @@ -99,11 +97,11 @@ fn main_0() -> i32 { (*p.borrow_mut()).v = 3; let q: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - PrivateCopyImpl::move_from(&__v.as_pointer(), { p.as_pointer() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { p.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); assert!(({ (*q.borrow()).v } == 3) && ({ (*p.borrow()).v } == 0)); - ({ PrivateCopyImpl::move_assign(&p.as_pointer(), q.as_pointer()) }); + ({ MoveAssignable::move_assign(&p.as_pointer(), q.as_pointer()) }); assert!(({ (*p.borrow()).v } == 3) && ({ (*q.borrow()).v } == 0)); let im: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); @@ -124,36 +122,34 @@ fn main_0() -> i32 { })); let mut d: Container = { let __v: Value = Rc::new(RefCell::new(::zero_init())); - ContainerImpl::move_from(&__v.as_pointer(), { c.as_pointer() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { c.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; assert!(((d.inner.v == 6) && (d.tag == 7)) && ({ (*c.borrow()).inner.v } == 0)); let h: Value = Rc::new(RefCell::new(::default())); let mut h2: VecHolder = { let __v: Value = Rc::new(RefCell::new(::zero_init())); - VecHolderImpl::move_from(&__v.as_pointer(), { h.as_pointer() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { h.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; assert!((h2.items.len() == 0_usize)); return 0; } -pub trait ContainerImpl { - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; +impl MoveAssignable for Container { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + ({ MoveAssignable::move_assign(&field_ptr!((*this), inner), field_ptr!(_a0, inner)) }); + field!((*this), tag).write({ (*_a0.upgrade().deref()).tag }); + return (*this).clone(); + } } -impl ContainerImpl for Ptr { - fn move_from(&self, _a0: Ptr) { - field!((*self), inner).write({ +impl MoveConstructible for Container { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), inner).write({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - NoCopyImpl::move_from(&__v.as_pointer(), { field_ptr!(_a0, inner) }); + MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, inner) }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }); - field!((*self), tag).write({ (*_a0.upgrade().deref()).tag }); - } - fn move_assign(&self, _a0: Ptr) -> Ptr { - ({ NoCopyImpl::move_assign(&field_ptr!((*self), inner), field_ptr!(_a0, inner)) }); - field!((*self), tag).write({ (*_a0.upgrade().deref()).tag }); - return (*self).clone(); + field!((*this), tag).write({ (*_a0.upgrade().deref()).tag }); } } pub trait ImmovableImpl { @@ -166,21 +162,23 @@ impl ImmovableImpl for Ptr { } pub trait NoCopyImpl { fn construct(&self, v: i32); - fn move_from(&self, o: Ptr); - fn move_assign(&self, o: Ptr) -> Ptr; } impl NoCopyImpl for Ptr { fn construct(&self, mut v: i32) { field!((*self), v).write(v); } - fn move_from(&self, o: Ptr) { - field!((*self), v).write(o.with(|__s| __s.v)); +} +impl MoveAssignable for NoCopy { + fn move_assign(this: &Ptr, o: Ptr) -> Ptr { + field!((*this), v).write(o.with(|__s| __s.v)); field!(o, v).write(0); + return (*this).clone(); } - fn move_assign(&self, o: Ptr) -> Ptr { - field!((*self), v).write(o.with(|__s| __s.v)); +} +impl MoveConstructible for NoCopy { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); field!(o, v).write(0); - return (*self).clone(); } } pub trait PrivateCopyImpl { @@ -188,36 +186,36 @@ pub trait PrivateCopyImpl { unimplemented!() } fn construct(&self); - fn move_from(&self, o: Ptr); - fn move_assign(&self, o: Ptr) -> Ptr; } impl PrivateCopyImpl for Ptr { fn construct(&self) { field!((*self), v).write(0); } - fn move_from(&self, o: Ptr) { - field!((*self), v).write(o.with(|__s| __s.v)); +} +impl MoveAssignable for PrivateCopy { + fn move_assign(this: &Ptr, o: Ptr) -> Ptr { + field!((*this), v).write(o.with(|__s| __s.v)); field!(o, v).write(0); + return (*this).clone(); } - fn move_assign(&self, o: Ptr) -> Ptr { - field!((*self), v).write(o.with(|__s| __s.v)); +} +impl MoveConstructible for PrivateCopy { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); field!(o, v).write(0); - return (*self).clone(); } } -pub trait VecHolderImpl { - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; -} -impl VecHolderImpl for Ptr { - fn move_from(&self, _a0: Ptr) { - field!((*self), items).write(field!(_a0, items).with_mut(std::mem::take)); - } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), items).with_mut(|__b0| { +impl MoveAssignable for VecHolder { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), items).with_mut(|__b0| { (*__b0) = field!(_a0, items).with_mut(std::mem::take); }); - return (*self).clone(); + return (*this).clone(); + } +} +impl MoveConstructible for VecHolder { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), items).write(field!(_a0, items).with_mut(std::mem::take)); } } pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/default.rs b/tests/unit/out/refcount/default.rs index 907c89f632..6173e72b5c 100644 --- a/tests/unit/out/refcount/default.rs +++ b/tests/unit/out/refcount/default.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(144)] pub struct Pointers { #[offset(0)] @@ -43,7 +54,18 @@ impl Default for Pointers { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(440)] pub struct SmallArrays { #[offset(0)] @@ -78,7 +100,18 @@ impl Default for SmallArrays { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(132)] pub struct BigArray { #[offset(0)] diff --git a/tests/unit/out/refcount/default_function_arguments.rs b/tests/unit/out/refcount/default_function_arguments.rs index a015bd1070..59e0534c86 100644 --- a/tests/unit/out/refcount/default_function_arguments.rs +++ b/tests/unit/out/refcount/default_function_arguments.rs @@ -12,7 +12,20 @@ pub fn foo_0(mut a: i32, mut b: i32) -> i32 { pub fn baz_1(mut a: Ptr, mut b: Ptr) -> bool { return ({ a } == { b }); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct Bar { @@ -58,7 +71,20 @@ pub fn shifted_8(mut x: i32, mut y: i32) -> i32 { pub fn first_9(r: Ptr) -> i32 { return (elem!(r, 0).read()); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Holder_int_ { #[offset(0)] diff --git a/tests/unit/out/refcount/default_in_statics.rs b/tests/unit/out/refcount/default_in_statics.rs index cabc3838b4..08fddb3f9d 100644 --- a/tests/unit/out/refcount/default_in_statics.rs +++ b/tests/unit/out/refcount/default_in_statics.rs @@ -6,7 +6,19 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct Inner { #[offset(0)] @@ -15,7 +27,18 @@ pub struct Inner { #[byte_size(8)] pub name: Ptr, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(88)] pub struct Outer { #[offset(0)] @@ -61,7 +84,19 @@ impl Default for Outer { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(40)] pub struct Foo { #[offset(0)] diff --git a/tests/unit/out/refcount/delete_array_order.rs b/tests/unit/out/refcount/delete_array_order.rs index 49b00ccf5b..31ae70ed56 100644 --- a/tests/unit/out/refcount/delete_array_order.rs +++ b/tests/unit/out/refcount/delete_array_order.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct Element { #[offset(0)] diff --git a/tests/unit/out/refcount/destructor.rs b/tests/unit/out/refcount/destructor.rs index 4ac2b27a80..87e3924178 100644 --- a/tests/unit/out/refcount/destructor.rs +++ b/tests/unit/out/refcount/destructor.rs @@ -9,31 +9,95 @@ use std::rc::{Rc, Weak}; thread_local!( pub static global_0: Value = Rc::new(RefCell::new(0)); ); -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct S {} -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct Defaulted { #[offset(0)] #[byte_size(1)] pub s: S, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct Middle { #[offset(0)] #[byte_size(1)] pub s: S, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct Outer { #[offset(0)] #[byte_size(1)] pub m: Middle, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(3)] pub struct ArrayMember { #[offset(0)] @@ -50,26 +114,78 @@ impl Default for ArrayMember { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct EmptyBody { #[offset(0)] #[byte_size(1)] pub s: S, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct Templated_char_ { #[offset(0)] pub v: i8, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Templated_int_ { #[offset(0)] pub v: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Copied { #[offset(0)] @@ -82,13 +198,39 @@ thread_local!( thread_local!( pub static order_count_2: Value = Rc::new(RefCell::new(0)); ); -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Tagged { #[offset(0)] pub tag: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(20)] pub struct Ordered { #[offset(0)] diff --git a/tests/unit/out/refcount/destructor_params.rs b/tests/unit/out/refcount/destructor_params.rs index ee4c0cc0cb..a6f18a0747 100644 --- a/tests/unit/out/refcount/destructor_params.rs +++ b/tests/unit/out/refcount/destructor_params.rs @@ -12,7 +12,20 @@ thread_local!( thread_local!( pub static last_1: Value = Rc::new(RefCell::new(0)); ); -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] @@ -27,7 +40,20 @@ pub fn with_default_3(s: S) -> i32 { let s: Value = Rc::new(RefCell::new(s)); return { (*s.borrow()).v }; } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Holder { #[offset(0)] diff --git a/tests/unit/out/refcount/destructor_temporaries.rs b/tests/unit/out/refcount/destructor_temporaries.rs index 382cd76114..569a667581 100644 --- a/tests/unit/out/refcount/destructor_temporaries.rs +++ b/tests/unit/out/refcount/destructor_temporaries.rs @@ -12,13 +12,39 @@ thread_local!( thread_local!( pub static last_1: Value = Rc::new(RefCell::new(0)); ); -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] pub v: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Outer { #[offset(0)] diff --git a/tests/unit/out/refcount/doubly_linked_list.rs b/tests/unit/out/refcount/doubly_linked_list.rs index 827ab5b981..3b5758e9ff 100644 --- a/tests/unit/out/refcount/doubly_linked_list.rs +++ b/tests/unit/out/refcount/doubly_linked_list.rs @@ -6,7 +6,19 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(24)] pub struct Node { #[offset(0)] diff --git a/tests/unit/out/refcount/enum_default_in_static.rs b/tests/unit/out/refcount/enum_default_in_static.rs index bbfeeb0727..e3a1f27ea9 100644 --- a/tests/unit/out/refcount/enum_default_in_static.rs +++ b/tests/unit/out/refcount/enum_default_in_static.rs @@ -10,7 +10,20 @@ pub type Mode = u32; pub const Mode_MODE_NONE: Mode = 0; pub const Mode_MODE_ONE: Mode = 1; pub const Mode_MODE_TWO: Mode = 2; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Config { #[offset(0)] diff --git a/tests/unit/out/refcount/enum_int_interop.rs b/tests/unit/out/refcount/enum_int_interop.rs index fb4ecd5f32..5d673ceaf9 100644 --- a/tests/unit/out/refcount/enum_int_interop.rs +++ b/tests/unit/out/refcount/enum_int_interop.rs @@ -19,7 +19,19 @@ pub type Tag = u32; pub const Tag_TAG_ZERO: Tag = 0; pub const Tag_TAG_ONE: Tag = 1; pub const Tag_TAG_TWO: Tag = 2; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct Entry { #[offset(0)] diff --git a/tests/unit/out/refcount/enum_int_interop_c.rs b/tests/unit/out/refcount/enum_int_interop_c.rs index 3e6628f69c..7bfee05e61 100644 --- a/tests/unit/out/refcount/enum_int_interop_c.rs +++ b/tests/unit/out/refcount/enum_int_interop_c.rs @@ -19,7 +19,19 @@ pub type Tag_enum = u32; pub const Tag_enum_TAG_ZERO: Tag_enum = 0; pub const Tag_enum_TAG_ONE: Tag_enum = 1; pub const Tag_enum_TAG_TWO: Tag_enum = 2; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct Entry { #[offset(0)] diff --git a/tests/unit/out/refcount/enum_underlying_type.rs b/tests/unit/out/refcount/enum_underlying_type.rs index b7f3132c3c..886c1dae96 100644 --- a/tests/unit/out/refcount/enum_underlying_type.rs +++ b/tests/unit/out/refcount/enum_underlying_type.rs @@ -25,7 +25,19 @@ pub type Scoped = i8; pub const Scoped_NEG: Scoped = -2; pub const Scoped_POS: Scoped = 2; pub type Empty = bool; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(1)] pub struct HoldsEmpty { #[offset(0)] diff --git a/tests/unit/out/refcount/exprs.rs b/tests/unit/out/refcount/exprs.rs index 4e234f4962..1c16613cf6 100644 --- a/tests/unit/out/refcount/exprs.rs +++ b/tests/unit/out/refcount/exprs.rs @@ -6,13 +6,38 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct X { #[offset(0)] pub x: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct Y { #[offset(0)] diff --git a/tests/unit/out/refcount/fft.rs b/tests/unit/out/refcount/fft.rs index e59b50a1cb..9c8d70b8c8 100644 --- a/tests/unit/out/refcount/fft.rs +++ b/tests/unit/out/refcount/fft.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct Complex { #[offset(0)] diff --git a/tests/unit/out/refcount/field_aliasing.rs b/tests/unit/out/refcount/field_aliasing.rs index e367fbe455..281fc1e754 100644 --- a/tests/unit/out/refcount/field_aliasing.rs +++ b/tests/unit/out/refcount/field_aliasing.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct In { #[offset(0)] @@ -14,7 +27,18 @@ pub struct In { #[offset(4)] pub y: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(32)] pub struct S { #[offset(0)] @@ -41,7 +65,19 @@ impl Default for S { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct Node { #[offset(0)] diff --git a/tests/unit/out/refcount/field_array_elem_ptr.rs b/tests/unit/out/refcount/field_array_elem_ptr.rs index c16d51922f..5f5467ca87 100644 --- a/tests/unit/out/refcount/field_array_elem_ptr.rs +++ b/tests/unit/out/refcount/field_array_elem_ptr.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Point { #[offset(0)] @@ -14,7 +27,18 @@ pub struct Point { #[offset(4)] pub y: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(48)] pub struct Shape { #[offset(0)] diff --git a/tests/unit/out/refcount/field_method_receiver.rs b/tests/unit/out/refcount/field_method_receiver.rs index a4ce080c59..e003c4afd1 100644 --- a/tests/unit/out/refcount/field_method_receiver.rs +++ b/tests/unit/out/refcount/field_method_receiver.rs @@ -6,13 +6,28 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Counter { #[offset(0)] pub n: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, MoveAssign)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyConstructible, CopyAssignable, +)] #[byte_size(40)] pub struct S { #[offset(0)] @@ -117,33 +132,35 @@ impl CounterImpl for Ptr { } pub trait SImpl { fn bump(&self); - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; } impl SImpl for Ptr { fn bump(&self) { ({ CounterImpl::add(&field_ptr!((*self), c), (*self).with(|__s| __s.tag)) }); } - fn move_from(&self, _a0: Ptr) { - field!((*self), tag).write({ (*_a0.upgrade().deref()).tag }); - field!((*self), c).write({ (*_a0.upgrade().deref()).c }); - field!((*self), arr).write(Box::new(std::array::from_fn::<_, 2, _>(|__i: usize| { - (*_a0.upgrade().deref()).arr[(__i) as usize] - }))); - field!((*self), v).write(field!(_a0, v).with_mut(std::mem::take)); - } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), tag).write({ (*_a0.upgrade().deref()).tag }); - field!((*self), c).write({ (*_a0.upgrade().deref()).c }); +} +impl MoveAssignable for S { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), tag).write({ (*_a0.upgrade().deref()).tag }); + field!((*this), c).write({ (*_a0.upgrade().deref()).c }); { - let mut __tmp_0 = { (array_field_ptr!((*self), arr)).to_any() }; + let mut __tmp_0 = { (array_field_ptr!((*this), arr)).to_any() }; __tmp_0.memcpy(&(array_field_ptr!(_a0, arr)).to_any(), 8_usize); (__tmp_0).clone() }; - field!((*self), v).with_mut(|__b0| { + field!((*this), v).with_mut(|__b0| { (*__b0) = field!(_a0, v).with_mut(std::mem::take); }); - return (*self).clone(); + return (*this).clone(); + } +} +impl MoveConstructible for S { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), tag).write({ (*_a0.upgrade().deref()).tag }); + field!((*this), c).write({ (*_a0.upgrade().deref()).c }); + field!((*this), arr).write(Box::new(std::array::from_fn::<_, 2, _>(|__i: usize| { + (*_a0.upgrade().deref()).arr[(__i) as usize] + }))); + field!((*this), v).write(field!(_a0, v).with_mut(std::mem::take)); } } pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/field_pointers.rs b/tests/unit/out/refcount/field_pointers.rs index 30c229b036..8fa8c9f54e 100644 --- a/tests/unit/out/refcount/field_pointers.rs +++ b/tests/unit/out/refcount/field_pointers.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(12)] pub struct Inner { #[offset(0)] @@ -26,7 +37,20 @@ impl Default for Inner { } } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Header { #[offset(0)] @@ -34,7 +58,9 @@ pub struct Header { #[offset(4)] pub size: i16, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, MoveAssign)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyConstructible, CopyAssignable, +)] #[byte_size(104)] pub struct Outer { #[offset(0)] @@ -212,8 +238,6 @@ pub trait OuterImpl { fn next(&self) -> i32; fn sum(&self) -> i32; fn push(&self, k: i32); - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; } impl OuterImpl for Ptr { fn next(&self) -> i32 { @@ -233,36 +257,40 @@ impl OuterImpl for Ptr { field!((*self), v).with_mut(|__v: &mut Vec| __v.push(__a1)) }; } - fn move_from(&self, _a0: Ptr) { - field!((*self), x).write({ (*_a0.upgrade().deref()).x }); - field!((*self), inner).write({ (*_a0.upgrade().deref()).inner.clone() }); - field!((*self), items).write(Box::new(std::array::from_fn::<_, 3, _>(|__i: usize| { - ((*_a0.upgrade().deref()).items[(__i) as usize]).clone() - }))); - field!((*self), v).write(field!(_a0, v).with_mut(std::mem::take)); - field!((*self), cursor).write({ (*_a0.upgrade().deref()).cursor.clone() }); - field!((*self), buf).write(Box::new(std::array::from_fn::<_, 4, _>(|__i: usize| { - (*_a0.upgrade().deref()).buf[(__i) as usize] - }))); - } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), x).write({ (*_a0.upgrade().deref()).x }); - field!((*self), inner).write({ (*_a0.upgrade().deref()).inner.clone() }); +} +impl MoveAssignable for Outer { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), x).write({ (*_a0.upgrade().deref()).x }); + field!((*this), inner).write({ (*_a0.upgrade().deref()).inner.clone() }); { - let mut __tmp_0 = { (array_field_ptr!((*self), items)).to_any() }; + let mut __tmp_0 = { (array_field_ptr!((*this), items)).to_any() }; __tmp_0.memcpy(&(array_field_ptr!(_a0, items)).to_any(), 36_usize); (__tmp_0).clone() }; - field!((*self), v).with_mut(|__b0| { + field!((*this), v).with_mut(|__b0| { (*__b0) = field!(_a0, v).with_mut(std::mem::take); }); - field!((*self), cursor).write({ (*_a0.upgrade().deref()).cursor.clone() }); + field!((*this), cursor).write({ (*_a0.upgrade().deref()).cursor.clone() }); { - let mut __tmp_1 = { (array_field_ptr!((*self), buf)).to_any() }; + let mut __tmp_1 = { (array_field_ptr!((*this), buf)).to_any() }; __tmp_1.memcpy(&(array_field_ptr!(_a0, buf)).to_any(), 16_usize); (__tmp_1).clone() }; - return (*self).clone(); + return (*this).clone(); + } +} +impl MoveConstructible for Outer { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), x).write({ (*_a0.upgrade().deref()).x }); + field!((*this), inner).write({ (*_a0.upgrade().deref()).inner.clone() }); + field!((*this), items).write(Box::new(std::array::from_fn::<_, 3, _>(|__i: usize| { + ((*_a0.upgrade().deref()).items[(__i) as usize]).clone() + }))); + field!((*this), v).write(field!(_a0, v).with_mut(std::mem::take)); + field!((*this), cursor).write({ (*_a0.upgrade().deref()).cursor.clone() }); + field!((*this), buf).write(Box::new(std::array::from_fn::<_, 4, _>(|__i: usize| { + (*_a0.upgrade().deref()).buf[(__i) as usize] + }))); } } pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/field_pointers_malloced_struct.rs b/tests/unit/out/refcount/field_pointers_malloced_struct.rs index 57d6b0f8d2..110b5f4d14 100644 --- a/tests/unit/out/refcount/field_pointers_malloced_struct.rs +++ b/tests/unit/out/refcount/field_pointers_malloced_struct.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(12)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/field_reinterpret_write_through.rs b/tests/unit/out/refcount/field_reinterpret_write_through.rs index f8bfab8fe5..ead637bab7 100644 --- a/tests/unit/out/refcount/field_reinterpret_write_through.rs +++ b/tests/unit/out/refcount/field_reinterpret_write_through.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct In { #[offset(0)] @@ -14,7 +27,18 @@ pub struct In { #[offset(4)] pub b: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(40)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/find.rs b/tests/unit/out/refcount/find.rs index b1b2b36bdb..217d2b0d3f 100644 --- a/tests/unit/out/refcount/find.rs +++ b/tests/unit/out/refcount/find.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct P { #[offset(0)] diff --git a/tests/unit/out/refcount/first_field_ptr_covers_struct.rs b/tests/unit/out/refcount/first_field_ptr_covers_struct.rs index 81358273ee..d2f0e08919 100644 --- a/tests/unit/out/refcount/first_field_ptr_covers_struct.rs +++ b/tests/unit/out/refcount/first_field_ptr_covers_struct.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct In { #[offset(0)] @@ -14,7 +27,20 @@ pub struct In { #[offset(2)] pub b: i16, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(12)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/first_member_downcast.rs b/tests/unit/out/refcount/first_member_downcast.rs index 0e766a79e7..df0a158b10 100644 --- a/tests/unit/out/refcount/first_member_downcast.rs +++ b/tests/unit/out/refcount/first_member_downcast.rs @@ -6,13 +6,39 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct base { #[offset(0)] pub kind: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct derived { #[offset(0)] diff --git a/tests/unit/out/refcount/flex_array_member_incomplete.rs b/tests/unit/out/refcount/flex_array_member_incomplete.rs index 1be33956bd..3a1ec71970 100644 --- a/tests/unit/out/refcount/flex_array_member_incomplete.rs +++ b/tests/unit/out/refcount/flex_array_member_incomplete.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(4)] pub struct F { #[offset(0)] diff --git a/tests/unit/out/refcount/flex_array_member_sibling_write.rs b/tests/unit/out/refcount/flex_array_member_sibling_write.rs index 443107535a..79f16e6490 100644 --- a/tests/unit/out/refcount/flex_array_member_sibling_write.rs +++ b/tests/unit/out/refcount/flex_array_member_sibling_write.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(8)] pub struct S { #[offset(0)] @@ -26,7 +37,20 @@ impl Default for S { } } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct E { #[offset(0)] @@ -34,7 +58,18 @@ pub struct E { #[offset(4)] pub w: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(16)] pub struct T { #[offset(0)] diff --git a/tests/unit/out/refcount/fn_ptr.rs b/tests/unit/out/refcount/fn_ptr.rs index 28d06980e6..557f0833d3 100644 --- a/tests/unit/out/refcount/fn_ptr.rs +++ b/tests/unit/out/refcount/fn_ptr.rs @@ -28,7 +28,20 @@ pub fn call_fn_5(mut f: FnPtr usize>, mut v: i32) -> usize { pub fn identity_hash_6(mut v: bool) -> usize { return (v as usize); } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_from(FnPtr u64 > , construct, ptr)] #[byte_size(8)] pub struct HashHolder_unsigned_long__ptr__bool__ { diff --git a/tests/unit/out/refcount/fn_ptr_cast.rs b/tests/unit/out/refcount/fn_ptr_cast.rs index 72fe1d2075..9962b48bc6 100644 --- a/tests/unit/out/refcount/fn_ptr_cast.rs +++ b/tests/unit/out/refcount/fn_ptr_cast.rs @@ -24,7 +24,19 @@ pub fn test_double_cast_2() { assert!((({ fn2.call(5,) }) == 10)); assert!(({ (fn2).clone() } == { (fn_).clone() })); } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Command { #[offset(0)] diff --git a/tests/unit/out/refcount/fn_ptr_stable_sort.rs b/tests/unit/out/refcount/fn_ptr_stable_sort.rs index aa4abe2bfa..314c801323 100644 --- a/tests/unit/out/refcount/fn_ptr_stable_sort.rs +++ b/tests/unit/out/refcount/fn_ptr_stable_sort.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Item { #[offset(0)] diff --git a/tests/unit/out/refcount/fn_ptr_struct.rs b/tests/unit/out/refcount/fn_ptr_struct.rs index e01ed25ebb..ad2b36fea2 100644 --- a/tests/unit/out/refcount/fn_ptr_struct.rs +++ b/tests/unit/out/refcount/fn_ptr_struct.rs @@ -6,7 +6,19 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct Handler { #[offset(0)] @@ -21,7 +33,20 @@ pub fn double_it_0(mut x: i32) -> i32 { pub fn negate_1(mut x: i32) -> i32 { return -x; } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct S {} impl S { @@ -35,7 +60,7 @@ impl S { return (x + 3); } } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, MoveCtor, CppFrom, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Default)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct MoveOnly { @@ -97,7 +122,7 @@ fn main_0() -> i32 { ({ sc.call({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - MoveOnlyImpl::move_from(&__v.as_pointer(), { m.as_pointer() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { m.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }) }), @@ -108,19 +133,20 @@ fn main_0() -> i32 { } pub trait MoveOnlyImpl { fn construct(&self, data: i32); - fn move_from(&self, x: Ptr); fn get(&self) -> i32; } impl MoveOnlyImpl for Ptr { fn construct(&self, mut data: i32) { field!((*self), data_).write(data); } - fn move_from(&self, x: Ptr) { - field!((*self), data_).write(x.with(|__s| __s.data_)); - field!(x, data_).write(0); - } fn get(&self) -> i32 { return (*self).with(|__s| __s.data_); } } +impl MoveConstructible for MoveOnly { + fn move_constructor(this: &Ptr, x: Ptr) { + field!((*this), data_).write(x.with(|__s| __s.data_)); + field!(x, data_).write(0); + } +} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/fn_ptr_typedef_cast.rs b/tests/unit/out/refcount/fn_ptr_typedef_cast.rs index a72c15adba..74431e2726 100644 --- a/tests/unit/out/refcount/fn_ptr_typedef_cast.rs +++ b/tests/unit/out/refcount/fn_ptr_typedef_cast.rs @@ -18,7 +18,20 @@ pub fn via_size_t_param_2(mut b: usize) -> u64 { pub fn via_size_t_return_3(mut b: u64) -> usize { return (b as usize); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct pair { #[offset(0)] diff --git a/tests/unit/out/refcount/fn_ptr_vtable.rs b/tests/unit/out/refcount/fn_ptr_vtable.rs index b9281b2847..b04a669794 100644 --- a/tests/unit/out/refcount/fn_ptr_vtable.rs +++ b/tests/unit/out/refcount/fn_ptr_vtable.rs @@ -6,7 +6,19 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(24)] pub struct Vtable { #[offset(0)] diff --git a/tests/unit/out/refcount/fn_ref.rs b/tests/unit/out/refcount/fn_ref.rs index e00efd7f20..084c702e2a 100644 --- a/tests/unit/out/refcount/fn_ref.rs +++ b/tests/unit/out/refcount/fn_ref.rs @@ -21,7 +21,19 @@ pub fn call_deduced_3(f: FnPtr i32>, mut x: i32) -> i32 { pub fn call_forwarded_4(f: FnPtr i32>, mut x: i32) -> i32 { return ({ f.call(x) }); } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Holder { #[offset(0)] diff --git a/tests/unit/out/refcount/for_body_destructor.rs b/tests/unit/out/refcount/for_body_destructor.rs index 986304af95..9771b1d4fc 100644 --- a/tests/unit/out/refcount/for_body_destructor.rs +++ b/tests/unit/out/refcount/for_body_destructor.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Guard { #[offset(0)] diff --git a/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs b/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs index fb614609a0..fc0af5ea1e 100644 --- a/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs +++ b/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs @@ -7,7 +7,15 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, MoveAssign, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + CopyAssignable, + Default, )] #[byte_size(32)] pub struct S { @@ -36,21 +44,19 @@ fn main_0() -> i32 { } return 0; } -pub trait SImpl { - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; -} -impl SImpl for Ptr { - fn move_from(&self, _a0: Ptr) { - field!((*self), v).write(field!(_a0, v).with_mut(std::mem::take)); - field!((*self), a).write({ (*_a0.upgrade().deref()).a }); - } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), v).with_mut(|__b0| { +impl MoveAssignable for S { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), v).with_mut(|__b0| { (*__b0) = field!(_a0, v).with_mut(std::mem::take); }); - field!((*self), a).write({ (*_a0.upgrade().deref()).a }); - return (*self).clone(); + field!((*this), a).write({ (*_a0.upgrade().deref()).a }); + return (*this).clone(); + } +} +impl MoveConstructible for S { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), v).write(field!(_a0, v).with_mut(std::mem::take)); + field!((*this), a).write({ (*_a0.upgrade().deref()).a }); } } pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/forward_basic.rs b/tests/unit/out/refcount/forward_basic.rs index ee9c29495f..c6cae169d0 100644 --- a/tests/unit/out/refcount/forward_basic.rs +++ b/tests/unit/out/refcount/forward_basic.rs @@ -9,7 +9,17 @@ use std::rc::{Rc, Weak}; pub type Overload = u32; pub const Overload_kLvalueOverload: Overload = 1; pub const Overload_kRvalueOverload: Overload = 2; -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, CppFrom, Default)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(12)] pub struct Tracked { @@ -28,7 +38,7 @@ impl Clone for Tracked { moves: self.moves.clone(), })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - TrackedImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -39,7 +49,17 @@ pub fn chosen_overload_1(_a0: Ptr) -> Overload { return Overload_kRvalueOverload; } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, CppFrom, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + CopyAssignable, + MoveAssignable, + Default, )] #[cpp_from(Tracked, construct_1, mut_ptr)] #[cpp_from_move(Tracked, construct_2, ptr)] @@ -147,35 +167,34 @@ fn main_0() -> i32 { pub trait HolderImpl { fn construct_1(&self, x: Ptr); fn construct_2(&self, x: Ptr); - fn move_from(&self, _a0: Ptr); } impl HolderImpl for Ptr { fn construct_1(&self, x: Ptr) { field!((*self), t).write({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - TrackedImpl::copy_from(&__v.as_pointer(), { (x).clone() }); + CopyConstructible::copy_constructor(&__v.as_pointer(), { (x).clone() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }); } fn construct_2(&self, x: Ptr) { field!((*self), t).write({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - TrackedImpl::move_from(&__v.as_pointer(), { (x).clone() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { (x).clone() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }); } - fn move_from(&self, _a0: Ptr) { - field!((*self), t).write({ +} +impl MoveConstructible for Holder { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), t).write({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - TrackedImpl::move_from(&__v.as_pointer(), { field_ptr!(_a0, t) }); + MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, t) }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }); } } pub trait TrackedImpl { fn construct(&self, v: i32); - fn copy_from(&self, o: Ptr); - fn move_from(&self, o: Ptr); } impl TrackedImpl for Ptr { fn construct(&self, mut v: i32) { @@ -183,15 +202,19 @@ impl TrackedImpl for Ptr { field!((*self), copies).write(0); field!((*self), moves).write(0); } - fn copy_from(&self, o: Ptr) { - field!((*self), v).write(o.with(|__s| __s.v)); - field!((*self), copies).write((o.with(|__s| __s.copies) + 1)); - field!((*self), moves).write(o.with(|__s| __s.moves)); +} +impl CopyConstructible for Tracked { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + field!((*this), copies).write((o.with(|__s| __s.copies) + 1)); + field!((*this), moves).write(o.with(|__s| __s.moves)); } - fn move_from(&self, o: Ptr) { - field!((*self), v).write(o.with(|__s| __s.v)); - field!((*self), copies).write(o.with(|__s| __s.copies)); - field!((*self), moves).write((o.with(|__s| __s.moves) + 1)); +} +impl MoveConstructible for Tracked { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + field!((*this), copies).write(o.with(|__s| __s.copies)); + field!((*this), moves).write((o.with(|__s| __s.moves) + 1)); field!(o, v).write(0); } } diff --git a/tests/unit/out/refcount/forward_decltype.rs b/tests/unit/out/refcount/forward_decltype.rs index 0a2ee40a47..f29812b9c2 100644 --- a/tests/unit/out/refcount/forward_decltype.rs +++ b/tests/unit/out/refcount/forward_decltype.rs @@ -9,7 +9,17 @@ use std::rc::{Rc, Weak}; pub type Overload = u32; pub const Overload_kLvalueOverload: Overload = 1; pub const Overload_kRvalueOverload: Overload = 2; -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, CppFrom, Default)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(12)] pub struct Tracked { @@ -28,7 +38,7 @@ impl Clone for Tracked { moves: self.moves.clone(), })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - TrackedImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -122,8 +132,6 @@ fn main_0() -> i32 { } pub trait TrackedImpl { fn construct(&self, v: i32); - fn copy_from(&self, o: Ptr); - fn move_from(&self, o: Ptr); } impl TrackedImpl for Ptr { fn construct(&self, mut v: i32) { @@ -131,15 +139,19 @@ impl TrackedImpl for Ptr { field!((*self), copies).write(0); field!((*self), moves).write(0); } - fn copy_from(&self, o: Ptr) { - field!((*self), v).write(o.with(|__s| __s.v)); - field!((*self), copies).write((o.with(|__s| __s.copies) + 1)); - field!((*self), moves).write(o.with(|__s| __s.moves)); +} +impl CopyConstructible for Tracked { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + field!((*this), copies).write((o.with(|__s| __s.copies) + 1)); + field!((*this), moves).write(o.with(|__s| __s.moves)); } - fn move_from(&self, o: Ptr) { - field!((*self), v).write(o.with(|__s| __s.v)); - field!((*self), copies).write(o.with(|__s| __s.copies)); - field!((*self), moves).write((o.with(|__s| __s.moves) + 1)); +} +impl MoveConstructible for Tracked { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + field!((*this), copies).write(o.with(|__s| __s.copies)); + field!((*this), moves).write((o.with(|__s| __s.moves) + 1)); field!(o, v).write(0); } } diff --git a/tests/unit/out/refcount/forward_explicit.rs b/tests/unit/out/refcount/forward_explicit.rs index f4e9495078..5ddb17a054 100644 --- a/tests/unit/out/refcount/forward_explicit.rs +++ b/tests/unit/out/refcount/forward_explicit.rs @@ -11,7 +11,17 @@ pub const Overload_kLvalueOverload: Overload = 1; pub const Overload_kRvalueOverload: Overload = 2; pub const Overload_kIntLvalueOverload: Overload = 3; pub const Overload_kIntRvalueOverload: Overload = 4; -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, CppFrom, Default)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(12)] pub struct Tracked { @@ -30,7 +40,7 @@ impl Clone for Tracked { moves: self.moves.clone(), })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - TrackedImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -50,7 +60,7 @@ pub fn copy_or_move_into_param_4(t: Tracked) -> Tracked { let t: Value = Rc::new(RefCell::new(t)); return { let __v: Value = Rc::new(RefCell::new(::zero_init())); - TrackedImpl::move_from(&__v.as_pointer(), { t.as_pointer() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { t.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; } @@ -80,7 +90,7 @@ fn main_0() -> i32 { let mut moved: Tracked = ({ copy_or_move_into_param_4({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - TrackedImpl::move_from(&__v.as_pointer(), { b.as_pointer() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { b.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }) }); @@ -96,7 +106,7 @@ fn main_0() -> i32 { let mut copied: Tracked = ({ copy_or_move_into_param_4({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - TrackedImpl::copy_from(&__v.as_pointer(), { c.as_pointer() }); + CopyConstructible::copy_constructor(&__v.as_pointer(), { c.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }) }); @@ -119,8 +129,6 @@ fn main_0() -> i32 { } pub trait TrackedImpl { fn construct(&self, v: i32); - fn copy_from(&self, o: Ptr); - fn move_from(&self, o: Ptr); } impl TrackedImpl for Ptr { fn construct(&self, mut v: i32) { @@ -128,15 +136,19 @@ impl TrackedImpl for Ptr { field!((*self), copies).write(0); field!((*self), moves).write(0); } - fn copy_from(&self, o: Ptr) { - field!((*self), v).write(o.with(|__s| __s.v)); - field!((*self), copies).write((o.with(|__s| __s.copies) + 1)); - field!((*self), moves).write(o.with(|__s| __s.moves)); +} +impl CopyConstructible for Tracked { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + field!((*this), copies).write((o.with(|__s| __s.copies) + 1)); + field!((*this), moves).write(o.with(|__s| __s.moves)); } - fn move_from(&self, o: Ptr) { - field!((*self), v).write(o.with(|__s| __s.v)); - field!((*self), copies).write(o.with(|__s| __s.copies)); - field!((*self), moves).write((o.with(|__s| __s.moves) + 1)); +} +impl MoveConstructible for Tracked { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + field!((*this), copies).write(o.with(|__s| __s.copies)); + field!((*this), moves).write((o.with(|__s| __s.moves) + 1)); field!(o, v).write(0); } } diff --git a/tests/unit/out/refcount/forward_pack.rs b/tests/unit/out/refcount/forward_pack.rs index 561384a886..a5d10372dd 100644 --- a/tests/unit/out/refcount/forward_pack.rs +++ b/tests/unit/out/refcount/forward_pack.rs @@ -11,7 +11,17 @@ pub const Overload_kLvalueOverload: Overload = 1; pub const Overload_kRvalueOverload: Overload = 2; pub const Overload_kIntLvalueOverload: Overload = 3; pub const Overload_kIntRvalueOverload: Overload = 4; -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, CppFrom, Default)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(12)] pub struct Tracked { @@ -30,7 +40,7 @@ impl Clone for Tracked { moves: self.moves.clone(), })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - TrackedImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -82,7 +92,18 @@ pub fn forward_pack_7( }; return digits; } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(24)] pub struct Pair { #[offset(0)] @@ -166,38 +187,37 @@ fn main_0() -> i32 { } pub trait PairImpl { fn construct(&self, x: Ptr, y: Ptr); - fn move_from(&self, _a0: Ptr); } impl PairImpl for Ptr { fn construct(&self, x: Ptr, y: Ptr) { field!((*self), a).write({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - TrackedImpl::copy_from(&__v.as_pointer(), { (x).clone() }); + CopyConstructible::copy_constructor(&__v.as_pointer(), { (x).clone() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }); field!((*self), b).write({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - TrackedImpl::move_from(&__v.as_pointer(), { (y).clone() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { (y).clone() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }); } - fn move_from(&self, _a0: Ptr) { - field!((*self), a).write({ +} +impl MoveConstructible for Pair { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), a).write({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - TrackedImpl::move_from(&__v.as_pointer(), { field_ptr!(_a0, a) }); + MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, a) }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }); - field!((*self), b).write({ + field!((*this), b).write({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - TrackedImpl::move_from(&__v.as_pointer(), { field_ptr!(_a0, b) }); + MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, b) }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }); } } pub trait TrackedImpl { fn construct(&self, v: i32); - fn copy_from(&self, o: Ptr); - fn move_from(&self, o: Ptr); } impl TrackedImpl for Ptr { fn construct(&self, mut v: i32) { @@ -205,15 +225,19 @@ impl TrackedImpl for Ptr { field!((*self), copies).write(0); field!((*self), moves).write(0); } - fn copy_from(&self, o: Ptr) { - field!((*self), v).write(o.with(|__s| __s.v)); - field!((*self), copies).write((o.with(|__s| __s.copies) + 1)); - field!((*self), moves).write(o.with(|__s| __s.moves)); +} +impl CopyConstructible for Tracked { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + field!((*this), copies).write((o.with(|__s| __s.copies) + 1)); + field!((*this), moves).write(o.with(|__s| __s.moves)); } - fn move_from(&self, o: Ptr) { - field!((*self), v).write(o.with(|__s| __s.v)); - field!((*self), copies).write(o.with(|__s| __s.copies)); - field!((*self), moves).write((o.with(|__s| __s.moves) + 1)); +} +impl MoveConstructible for Tracked { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + field!((*this), copies).write(o.with(|__s| __s.copies)); + field!((*this), moves).write((o.with(|__s| __s.moves) + 1)); field!(o, v).write(0); } } diff --git a/tests/unit/out/refcount/friend.rs b/tests/unit/out/refcount/friend.rs index 95cc1dd0b7..ac847891a7 100644 --- a/tests/unit/out/refcount/friend.rs +++ b/tests/unit/out/refcount/friend.rs @@ -18,7 +18,20 @@ pub fn scaled_2(v: Ptr, mut k: i32) -> i32 { pub fn scaled_3(v: Ptr, mut k: f64) -> f64 { return ({ (v.with(|__s| __s.x) as f64) } * { k }); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct V { #[offset(0)] @@ -32,7 +45,20 @@ impl CppEq for V { pub fn get_4(w: Ptr) -> i32 { return w.with(|__s| __s.x); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct W_int_ { #[offset(0)] @@ -41,13 +67,39 @@ pub struct W_int_ { pub fn get_5(w: Ptr) -> i64 { return w.with(|__s| __s.x); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct W_long_ { #[offset(0)] pub x: i64, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct D { #[offset(0)] diff --git a/tests/unit/out/refcount/function_overloading.rs b/tests/unit/out/refcount/function_overloading.rs index 68f8ead863..588625513b 100644 --- a/tests/unit/out/refcount/function_overloading.rs +++ b/tests/unit/out/refcount/function_overloading.rs @@ -21,7 +21,20 @@ pub fn foo_3(mut x: Ptr, mut y: Ptr, z: Ptr) -> i32 { pub fn bar_4(x: Ptr) -> i32 { return (x.read()); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct Foo {} pub fn func_5(mut x: i32) -> i32 { diff --git a/tests/unit/out/refcount/global_call_temporaries.rs b/tests/unit/out/refcount/global_call_temporaries.rs index d193aca603..a64c64c5a2 100644 --- a/tests/unit/out/refcount/global_call_temporaries.rs +++ b/tests/unit/out/refcount/global_call_temporaries.rs @@ -94,7 +94,20 @@ thread_local!( }) })); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Item { #[offset(0)] diff --git a/tests/unit/out/refcount/global_init_side_effect.rs b/tests/unit/out/refcount/global_init_side_effect.rs index b9d2bfff87..771ffa1bbb 100644 --- a/tests/unit/out/refcount/global_init_side_effect.rs +++ b/tests/unit/out/refcount/global_init_side_effect.rs @@ -9,7 +9,21 @@ use std::rc::{Rc, Weak}; thread_local!( pub static total_0: Value = Rc::new(RefCell::new(0)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(1)] pub struct S {} diff --git a/tests/unit/out/refcount/global_non_const_init.rs b/tests/unit/out/refcount/global_non_const_init.rs index 314f10214c..e7758d6004 100644 --- a/tests/unit/out/refcount/global_non_const_init.rs +++ b/tests/unit/out/refcount/global_non_const_init.rs @@ -32,7 +32,19 @@ thread_local!( pub static depends_on_call_6: Value = Rc::new(RefCell::new((from_call_5.with(|rc| *rc.borrow()) + 1))); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(4)] pub struct Ctor { #[offset(0)] @@ -77,7 +89,20 @@ thread_local!( Rc::try_unwrap(__v).ok().unwrap().into_inner() })); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct Holder {} thread_local!( @@ -96,7 +121,19 @@ thread_local!( Rc::try_unwrap(__v).ok().unwrap().into_inner() })); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(4)] pub struct Singleton { #[offset(0)] diff --git a/tests/unit/out/refcount/global_pointers.rs b/tests/unit/out/refcount/global_pointers.rs index 5fe456b7d9..c5df9f51e1 100644 --- a/tests/unit/out/refcount/global_pointers.rs +++ b/tests/unit/out/refcount/global_pointers.rs @@ -6,7 +6,19 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct Entry { #[offset(0)] diff --git a/tests/unit/out/refcount/global_without_initializer.rs b/tests/unit/out/refcount/global_without_initializer.rs index 1990136dff..a671a1ce42 100644 --- a/tests/unit/out/refcount/global_without_initializer.rs +++ b/tests/unit/out/refcount/global_without_initializer.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/goto_aggregate_default.rs b/tests/unit/out/refcount/goto_aggregate_default.rs index 0449ac8471..79ac884a1a 100644 --- a/tests/unit/out/refcount/goto_aggregate_default.rs +++ b/tests/unit/out/refcount/goto_aggregate_default.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Point { #[offset(0)] diff --git a/tests/unit/out/refcount/goto_cleanup.rs b/tests/unit/out/refcount/goto_cleanup.rs index 6dd03f7dd7..4c97fc9bb6 100644 --- a/tests/unit/out/refcount/goto_cleanup.rs +++ b/tests/unit/out/refcount/goto_cleanup.rs @@ -76,7 +76,19 @@ pub fn from_switch_2(mut n: i32) -> i32 { }); panic!("ub: non-void function does not return a value") } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct wrapper { #[offset(0)] diff --git a/tests/unit/out/refcount/huffman.rs b/tests/unit/out/refcount/huffman.rs index f0bffcbeb3..177e370aff 100644 --- a/tests/unit/out/refcount/huffman.rs +++ b/tests/unit/out/refcount/huffman.rs @@ -6,7 +6,19 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(24)] pub struct MinHeapNode { #[offset(0)] @@ -40,7 +52,7 @@ pub fn Swap_0(a: Ptr, b: Ptr) { right: (t.right).clone(), }); } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, MoveCtor, MoveAssign, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Default)] #[byte_size(32)] pub struct MinHeap { #[offset(0)] @@ -272,8 +284,6 @@ pub trait MinHeapImpl { freq: Ptr>>>, n: i32, ); - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; } impl MinHeapImpl for Ptr { fn Alloc(&self, mut data: i8, mut freq: i32) -> Ptr { @@ -439,31 +449,35 @@ impl MinHeapImpl for Ptr { } } } - fn move_from(&self, _a0: Ptr) { - field!((*self), size).write({ (*_a0.upgrade().deref()).size }); - field!((*self), capacity).write({ (*_a0.upgrade().deref()).capacity }); - field!((*self), arr).write( - field!(_a0, arr) - .with_mut(|__v: &mut Option]>>>| __v.take()), - ); - field!((*self), next).write({ (*_a0.upgrade().deref()).next }); - field!((*self), alloc).write( - field!(_a0, alloc).with_mut(|__v: &mut Option>>| __v.take()), - ); - } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), size).write({ (*_a0.upgrade().deref()).size }); - field!((*self), capacity).write({ (*_a0.upgrade().deref()).capacity }); - field!((*self), arr).with_mut(|__b0| { +} +impl MoveAssignable for MinHeap { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), size).write({ (*_a0.upgrade().deref()).size }); + field!((*this), capacity).write({ (*_a0.upgrade().deref()).capacity }); + field!((*this), arr).with_mut(|__b0| { (*__b0) = field!(_a0, arr) .with_mut(|__v: &mut Option]>>>| __v.take()); }); - field!((*self), next).write({ (*_a0.upgrade().deref()).next }); - field!((*self), alloc).with_mut(|__b0| { + field!((*this), next).write({ (*_a0.upgrade().deref()).next }); + field!((*this), alloc).with_mut(|__b0| { (*__b0) = field!(_a0, alloc) .with_mut(|__v: &mut Option>>| __v.take()); }); - return (*self).clone(); + return (*this).clone(); + } +} +impl MoveConstructible for MinHeap { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), size).write({ (*_a0.upgrade().deref()).size }); + field!((*this), capacity).write({ (*_a0.upgrade().deref()).capacity }); + field!((*this), arr).write( + field!(_a0, arr) + .with_mut(|__v: &mut Option]>>>| __v.take()), + ); + field!((*this), next).write({ (*_a0.upgrade().deref()).next }); + field!((*this), alloc).write( + field!(_a0, alloc).with_mut(|__v: &mut Option>>| __v.take()), + ); } } pub trait MinHeapNodeImpl { diff --git a/tests/unit/out/refcount/immutable-deref-on-func-call.rs b/tests/unit/out/refcount/immutable-deref-on-func-call.rs index 49e3c1531e..7e41439672 100644 --- a/tests/unit/out/refcount/immutable-deref-on-func-call.rs +++ b/tests/unit/out/refcount/immutable-deref-on-func-call.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Item { #[offset(0)] diff --git a/tests/unit/out/refcount/implicit_autoref.rs b/tests/unit/out/refcount/implicit_autoref.rs index 46b99638a5..9771d17a19 100644 --- a/tests/unit/out/refcount/implicit_autoref.rs +++ b/tests/unit/out/refcount/implicit_autoref.rs @@ -7,7 +7,15 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, MoveAssign, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + CopyAssignable, + Default, )] #[byte_size(24)] pub struct Holder { @@ -64,19 +72,17 @@ fn main_0() -> i32 { assert!(((index!(p, 0_usize).read()) == 42)); return 0; } -pub trait HolderImpl { - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; -} -impl HolderImpl for Ptr { - fn move_from(&self, _a0: Ptr) { - field!((*self), v).write(field!(_a0, v).with_mut(std::mem::take)); - } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), v).with_mut(|__b0| { +impl MoveAssignable for Holder { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), v).with_mut(|__b0| { (*__b0) = field!(_a0, v).with_mut(std::mem::take); }); - return (*self).clone(); + return (*this).clone(); + } +} +impl MoveConstructible for Holder { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), v).write(field!(_a0, v).with_mut(std::mem::take)); } } pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/in_class_field_initializer.rs b/tests/unit/out/refcount/in_class_field_initializer.rs index 9551e73365..bd20773e93 100644 --- a/tests/unit/out/refcount/in_class_field_initializer.rs +++ b/tests/unit/out/refcount/in_class_field_initializer.rs @@ -6,7 +6,19 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(8)] pub struct Inner { #[offset(0)] @@ -19,7 +31,19 @@ impl Default for Inner { { Inner { x: 3, y: 4 } } } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(24)] pub struct S { #[offset(0)] @@ -45,7 +69,19 @@ impl Default for S { } } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(8)] pub struct Boxed_int_ { #[offset(0)] diff --git a/tests/unit/out/refcount/init.rs b/tests/unit/out/refcount/init.rs index f9b6d67e5a..c18b857a91 100644 --- a/tests/unit/out/refcount/init.rs +++ b/tests/unit/out/refcount/init.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct X { #[offset(0)] diff --git a/tests/unit/out/refcount/init_list.rs b/tests/unit/out/refcount/init_list.rs index cc2f4ea860..87eb1b698e 100644 --- a/tests/unit/out/refcount/init_list.rs +++ b/tests/unit/out/refcount/init_list.rs @@ -9,7 +9,20 @@ use std::rc::{Rc, Weak}; pub fn f_0(list: Vec) { let list: Value> = Rc::new(RefCell::new(list)); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Pair { #[offset(0)] @@ -17,7 +30,19 @@ pub struct Pair { #[offset(4)] pub b: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(8)] pub struct Holder { #[offset(0)] @@ -36,7 +61,19 @@ impl Default for Holder { pub fn sum_1(p: Ptr) -> i32 { return ({ p.with(|__s| __s.a) } + { p.with(|__s| __s.b) }); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(4)] pub struct Seven { #[offset(0)] diff --git a/tests/unit/out/refcount/inline_container_fields.rs b/tests/unit/out/refcount/inline_container_fields.rs index 0910c0c4fa..9929980cf6 100644 --- a/tests/unit/out/refcount/inline_container_fields.rs +++ b/tests/unit/out/refcount/inline_container_fields.rs @@ -6,7 +6,9 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, MoveAssign)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyConstructible, CopyAssignable, +)] #[byte_size(48)] pub struct Elem { #[offset(0)] @@ -30,7 +32,9 @@ impl Default for Elem { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, MoveAssign)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyConstructible, CopyAssignable, +)] #[byte_size(88)] pub struct State { #[offset(0)] @@ -127,9 +131,7 @@ thread_local!( thread_local!( pub static move_assigns_5: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, CopyAssign, MoveAssign, -)] +#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] #[byte_size(4)] pub struct Counted { #[offset(0)] @@ -139,7 +141,7 @@ impl Clone for Counted { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(Counted { v: self.v.clone() })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - CountedImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -268,7 +270,7 @@ fn main_0() -> i32 { ); let moved: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - StateImpl::move_from(&__v.as_pointer(), { t.as_pointer() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { t.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); assert!( @@ -288,7 +290,7 @@ fn main_0() -> i32 { && ((elem!(field_ref!(t.as_pointer(), arr).decay(), 1_usize).read()) == 7) ); let assigned: Value = Rc::new(RefCell::new(::default())); - ({ StateImpl::move_assign(&assigned.as_pointer(), moved.as_pointer()) }); + ({ MoveAssignable::move_assign(&assigned.as_pointer(), moved.as_pointer()) }); assert!( ({ ((*assigned.borrow()).grid[(0) as usize][(0) as usize] == 100) @@ -319,11 +321,16 @@ fn main_0() -> i32 { ::default() })))); (*ca.borrow_mut())[1_usize].v = 5; - let cb: Value> = Rc::new(RefCell::new( - (0..3) - .map(|__i| ::move_ctor(ca.decay().offset(__i))) - .collect(), - )); + let cb: Value> = Rc::new(RefCell::new({ + let __v: Value> = Rc::new(RefCell::new( + (0..3).map(|_| ::zero_init()).collect(), + )); + let __p: Ptr = __v.decay(); + for __i in 0..3 { + MoveConstructible::move_constructor(&__p.offset(__i), ca.decay().offset(__i)); + } + Rc::try_unwrap(__v).ok().unwrap().into_inner() + })); assert!( (((moves_3.with(|rc| *rc.borrow()) == 3) && (copies_2.with(|rc| *rc.borrow()) == 0)) && ({ (*cb.borrow())[1_usize].v } == 5)) @@ -340,10 +347,10 @@ fn main_0() -> i32 { (*cc.borrow_mut())[2_usize].v = 8; { for __i in 0..3 { - &cb.as_pointer() - .decay() - .offset(__i) - .copy_assign(cc.decay().offset(__i)); + CopyAssignable::copy_assign( + &cb.as_pointer().decay().offset(__i), + cc.decay().offset(__i), + ); } cb.as_pointer() }; @@ -354,10 +361,10 @@ fn main_0() -> i32 { ); { for __i in 0..3 { - &ca.as_pointer() - .decay() - .offset(__i) - .move_assign(cb.decay().offset(__i)); + MoveAssignable::move_assign( + &ca.as_pointer().decay().offset(__i), + cb.decay().offset(__i), + ); } ca.as_pointer() }; @@ -376,11 +383,16 @@ fn main_0() -> i32 { let __a1 = 1; elem!(va.decay(), 0_usize).with_mut(|__v: &mut Vec| __v.push(__a1)) }; - let vb: Value]>> = Rc::new(RefCell::new( - (0..2) - .map(|__i| as MoveCtor>::move_ctor(va.decay().offset(__i))) - .collect(), - )); + let vb: Value]>> = Rc::new(RefCell::new({ + let __v: Value]>> = Rc::new(RefCell::new( + (0..2).map(|_| >::zero_init()).collect(), + )); + let __p: Ptr> = __v.decay(); + for __i in 0..2 { + MoveConstructible::move_constructor(&__p.offset(__i), va.decay().offset(__i)); + } + Rc::try_unwrap(__v).ok().unwrap().into_inner() + })); assert!( ({ ((*vb.decay().offset(0_usize).upgrade().deref()).len() == 1_usize) @@ -392,10 +404,10 @@ fn main_0() -> i32 { ))); { for __i in 0..2 { - &vc.as_pointer() - .decay() - .offset(__i) - .write( as MoveCtor>::move_ctor(vb.decay().offset(__i))); + MoveAssignable::move_assign( + &vc.as_pointer().decay().offset(__i), + vb.decay().offset(__i), + ); } vc.as_pointer() }; @@ -407,103 +419,105 @@ fn main_0() -> i32 { ); return 0; } -pub trait CountedImpl { - fn copy_from(&self, o: Ptr); - fn move_from(&self, o: Ptr); - fn copy_assign(&self, o: Ptr) -> Ptr; - fn move_assign(&self, o: Ptr) -> Ptr; +impl CopyAssignable for Counted { + fn copy_assign(this: &Ptr, o: Ptr) -> Ptr { + field!((*this), v).write(o.with(|__s| __s.v)); + (*copy_assigns_4.with(Value::clone).borrow_mut()).prefix_inc(); + return (*this).clone(); + } } -impl CountedImpl for Ptr { - fn copy_from(&self, o: Ptr) { - field!((*self), v).write(o.with(|__s| __s.v)); +impl CopyConstructible for Counted { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); (*copies_2.with(Value::clone).borrow_mut()).prefix_inc(); } - fn move_from(&self, o: Ptr) { - field!((*self), v).write(o.with(|__s| __s.v)); - field!(o, v).write(-1_i32); - (*moves_3.with(Value::clone).borrow_mut()).prefix_inc(); - } - fn copy_assign(&self, o: Ptr) -> Ptr { - field!((*self), v).write(o.with(|__s| __s.v)); - (*copy_assigns_4.with(Value::clone).borrow_mut()).prefix_inc(); - return (*self).clone(); - } - fn move_assign(&self, o: Ptr) -> Ptr { - field!((*self), v).write(o.with(|__s| __s.v)); +} +impl MoveAssignable for Counted { + fn move_assign(this: &Ptr, o: Ptr) -> Ptr { + field!((*this), v).write(o.with(|__s| __s.v)); field!(o, v).write(-1_i32); (*move_assigns_5.with(Value::clone).borrow_mut()).prefix_inc(); - return (*self).clone(); + return (*this).clone(); } } -pub trait ElemImpl { - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; -} -impl ElemImpl for Ptr { - fn move_from(&self, _a0: Ptr) { - field!((*self), id).write({ (*_a0.upgrade().deref()).id }); - field!((*self), hist).write(Box::new(std::array::from_fn::<_, 4, _>(|__i: usize| { - (*_a0.upgrade().deref()).hist[(__i) as usize] - }))); - field!((*self), coeffs).write(field!(_a0, coeffs).with_mut(std::mem::take)); +impl MoveConstructible for Counted { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + field!(o, v).write(-1_i32); + (*moves_3.with(Value::clone).borrow_mut()).prefix_inc(); } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), id).write({ (*_a0.upgrade().deref()).id }); +} +impl MoveAssignable for Elem { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), id).write({ (*_a0.upgrade().deref()).id }); { - let mut __tmp_0 = { (array_field_ptr!((*self), hist)).to_any() }; + let mut __tmp_0 = { (array_field_ptr!((*this), hist)).to_any() }; __tmp_0.memcpy(&(array_field_ptr!(_a0, hist)).to_any(), 16_usize); (__tmp_0).clone() }; - field!((*self), coeffs).with_mut(|__b0| { + field!((*this), coeffs).with_mut(|__b0| { (*__b0) = field!(_a0, coeffs).with_mut(std::mem::take); }); - return (*self).clone(); + return (*this).clone(); } } -pub trait StateImpl { - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; -} -impl StateImpl for Ptr { - fn move_from(&self, _a0: Ptr) { - field!((*self), count).write({ (*_a0.upgrade().deref()).count }); - field!((*self), grid).write(Box::new(std::array::from_fn::<_, 2, _>(|__i: usize| { - Box::<[_]>::from(std::array::from_fn::<_, 3, _>(|__i2: usize| { - (*_a0.upgrade().deref()).grid[(__i) as usize][(__i2) as usize] - })) +impl MoveConstructible for Elem { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), id).write({ (*_a0.upgrade().deref()).id }); + field!((*this), hist).write(Box::new(std::array::from_fn::<_, 4, _>(|__i: usize| { + (*_a0.upgrade().deref()).hist[(__i) as usize] }))); - field!((*self), arr).write( - (0..3) - .map(|__i| field_ref!(_a0, arr).decay().offset(__i).read()) - .collect(), - ); - field!((*self), elems).write(field!(_a0, elems).with_mut(std::mem::take)); - field!((*self), rows).write(field!(_a0, rows).with_mut(std::mem::take)); + field!((*this), coeffs).write(field!(_a0, coeffs).with_mut(std::mem::take)); } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), count).write({ (*_a0.upgrade().deref()).count }); +} +impl MoveAssignable for State { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), count).write({ (*_a0.upgrade().deref()).count }); { - let mut __tmp_1 = { (array_field_ptr!((*self), grid)).to_any() }; + let mut __tmp_1 = { (array_field_ptr!((*this), grid)).to_any() }; __tmp_1.memcpy(&(array_field_ptr!(_a0, grid)).to_any(), 24_usize); (__tmp_1).clone() }; { for __i in 0..3 { - &field_ref!((*self), arr) - .as_pointer() - .decay() - .offset(__i) - .write(field_ref!(_a0, arr).decay().offset(__i).read()); + MoveAssignable::move_assign( + &field_ref!((*this), arr).as_pointer().decay().offset(__i), + field_ref!(_a0, arr).decay().offset(__i), + ); } - field_ref!((*self), arr).as_pointer() + field_ref!((*this), arr).as_pointer() }; - field!((*self), elems).with_mut(|__b0| { + field!((*this), elems).with_mut(|__b0| { (*__b0) = field!(_a0, elems).with_mut(std::mem::take); }); - field!((*self), rows).with_mut(|__b0| { + field!((*this), rows).with_mut(|__b0| { (*__b0) = field!(_a0, rows).with_mut(std::mem::take); }); - return (*self).clone(); + return (*this).clone(); + } +} +impl MoveConstructible for State { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), count).write({ (*_a0.upgrade().deref()).count }); + field!((*this), grid).write(Box::new(std::array::from_fn::<_, 2, _>(|__i: usize| { + Box::<[_]>::from(std::array::from_fn::<_, 3, _>(|__i2: usize| { + (*_a0.upgrade().deref()).grid[(__i) as usize][(__i2) as usize] + })) + }))); + field!((*this), arr).write({ + let __v: Value> = + Rc::new(RefCell::new((0..3).map(|_| ::zero_init()).collect())); + let __p: Ptr = __v.decay(); + for __i in 0..3 { + MoveConstructible::move_constructor( + &__p.offset(__i), + field_ref!(_a0, arr).decay().offset(__i), + ); + } + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }); + field!((*this), elems).write(field!(_a0, elems).with_mut(std::mem::take)); + field!((*this), rows).write(field!(_a0, rows).with_mut(std::mem::take)); } } pub fn __cpp2rust_init_globals() { diff --git a/tests/unit/out/refcount/kruskal.rs b/tests/unit/out/refcount/kruskal.rs index bb969d73c1..6f1db27f21 100644 --- a/tests/unit/out/refcount/kruskal.rs +++ b/tests/unit/out/refcount/kruskal.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct Edge { #[offset(0)] @@ -99,7 +112,7 @@ pub fn quicksort_1(arr: Ptr>>>, mut start: i32, mut end ({ quicksort_1((arr).clone(), start, (p - 1)) }); ({ quicksort_1((arr).clone(), (p + 1), end) }); } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, MoveCtor, MoveAssign, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Default)] #[byte_size(24)] pub struct DisjointSet { #[offset(0)] @@ -111,7 +124,7 @@ pub struct DisjointSet { #[offset(16)] pub n: i32, } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, MoveCtor, MoveAssign, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Default)] #[byte_size(16)] pub struct Graph { #[offset(0)] @@ -234,8 +247,6 @@ pub trait DisjointSetImpl { fn makeSet(&self); fn find(&self, x: i32) -> i32; fn merge(&self, x: i32, y: i32); - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; } impl DisjointSetImpl for Ptr { fn makeSet(&self) { @@ -346,44 +357,46 @@ impl DisjointSetImpl for Ptr { ); } } - fn move_from(&self, _a0: Ptr) { - field!((*self), rank) - .write(field!(_a0, rank).with_mut(|__v: &mut Option>>| __v.take())); - field!((*self), parent) - .write(field!(_a0, parent).with_mut(|__v: &mut Option>>| __v.take())); - field!((*self), n).write({ (*_a0.upgrade().deref()).n }); - } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), rank).with_mut(|__b0| { +} +impl MoveAssignable for DisjointSet { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), rank).with_mut(|__b0| { (*__b0) = field!(_a0, rank).with_mut(|__v: &mut Option>>| __v.take()); }); - field!((*self), parent).with_mut(|__b0| { + field!((*this), parent).with_mut(|__b0| { (*__b0) = field!(_a0, parent).with_mut(|__v: &mut Option>>| __v.take()); }); - field!((*self), n).write({ (*_a0.upgrade().deref()).n }); - return (*self).clone(); + field!((*this), n).write({ (*_a0.upgrade().deref()).n }); + return (*this).clone(); } } -pub trait GraphImpl { - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; -} -impl GraphImpl for Ptr { - fn move_from(&self, _a0: Ptr) { - field!((*self), edges) - .write(field!(_a0, edges).with_mut(|__v: &mut Option>>| __v.take())); - field!((*self), V).write({ (*_a0.upgrade().deref()).V }); - field!((*self), E).write({ (*_a0.upgrade().deref()).E }); +impl MoveConstructible for DisjointSet { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), rank) + .write(field!(_a0, rank).with_mut(|__v: &mut Option>>| __v.take())); + field!((*this), parent) + .write(field!(_a0, parent).with_mut(|__v: &mut Option>>| __v.take())); + field!((*this), n).write({ (*_a0.upgrade().deref()).n }); } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), edges).with_mut(|__b0| { +} +impl MoveAssignable for Graph { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), edges).with_mut(|__b0| { (*__b0) = field!(_a0, edges).with_mut(|__v: &mut Option>>| __v.take()); }); - field!((*self), V).write({ (*_a0.upgrade().deref()).V }); - field!((*self), E).write({ (*_a0.upgrade().deref()).E }); - return (*self).clone(); + field!((*this), V).write({ (*_a0.upgrade().deref()).V }); + field!((*this), E).write({ (*_a0.upgrade().deref()).E }); + return (*this).clone(); + } +} +impl MoveConstructible for Graph { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), edges) + .write(field!(_a0, edges).with_mut(|__v: &mut Option>>| __v.take())); + field!((*this), V).write({ (*_a0.upgrade().deref()).V }); + field!((*this), E).write({ (*_a0.upgrade().deref()).E }); } } pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/lambda_as_field.rs b/tests/unit/out/refcount/lambda_as_field.rs index edd5e2beea..961ad581cb 100644 --- a/tests/unit/out/refcount/lambda_as_field.rs +++ b/tests/unit/out/refcount/lambda_as_field.rs @@ -6,7 +6,19 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(1)] pub struct Guard__lambda_at_lambda_as_field_cpp_34_13__ { #[offset(0)] @@ -24,14 +36,38 @@ impl Default for Guard__lambda_at_lambda_as_field_cpp_34_13__ { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Guard__lambda_at_lambda_as_field_cpp_45_13__ { #[offset(0)] #[byte_size(8)] pub f: FnPtr, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(8)] pub struct Holder__lambda_at_lambda_as_field_cpp_39_12__ { #[offset(0)] @@ -54,7 +90,19 @@ impl Default for Holder__lambda_at_lambda_as_field_cpp_39_12__ { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Holder__lambda_at_lambda_as_field_cpp_51_12__ { #[offset(0)] @@ -63,7 +111,7 @@ pub struct Holder__lambda_at_lambda_as_field_cpp_51_12__ { #[offset(4)] pub calls: i32, } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, MoveCtor, CppFrom)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom)] #[cpp_from(FnPtr i32 > , construct, value)] #[byte_size(8)] pub struct Moving__lambda_at_lambda_as_field_cpp_64_12__ { @@ -212,9 +260,7 @@ fn main_0() -> i32 { let __v: Value = Rc::new(RefCell::new( ::zero_init(), )); - Moving__lambda_at_lambda_as_field_cpp_64_12__Impl::move_from(&__v.as_pointer(), { - m.as_pointer() - }); + MoveConstructible::move_constructor(&__v.as_pointer(), { m.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); assert!(({ (({ (*m2.borrow()).f.call(3,) }) == 6) })); @@ -265,7 +311,6 @@ impl Holder__lambda_at_lambda_as_field_cpp_51_12__Impl } pub trait Moving__lambda_at_lambda_as_field_cpp_64_12__Impl { fn construct(&self, f: FnPtr i32>); - fn move_from(&self, o: Ptr); } impl Moving__lambda_at_lambda_as_field_cpp_64_12__Impl for Ptr @@ -275,9 +320,11 @@ impl Moving__lambda_at_lambda_as_field_cpp_64_12__Impl field!((*self), f).write((*f.borrow()).copy_from()); field!((*self), moves).write(0); } - fn move_from(&self, o: Ptr) { - field!((*self), f).write((*o.upgrade().deref()).f.move_from()); - field!((*self), moves).write((o.with(|__s| __s.moves) + 1)); +} +impl MoveConstructible for Moving__lambda_at_lambda_as_field_cpp_64_12__ { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), f).write((*o.upgrade().deref()).f.move_from()); + field!((*this), moves).write((o.with(|__s| __s.moves) + 1)); } } pub fn __cpp2rust_init_globals() { diff --git a/tests/unit/out/refcount/lambda_capture_copy_ctor.rs b/tests/unit/out/refcount/lambda_capture_copy_ctor.rs index 0379ac5c45..46a79d1873 100644 --- a/tests/unit/out/refcount/lambda_capture_copy_ctor.rs +++ b/tests/unit/out/refcount/lambda_capture_copy_ctor.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor)] +#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyAssignable, MoveAssignable)] #[byte_size(8)] pub struct Counted { #[offset(0)] @@ -21,7 +21,7 @@ impl Clone for Counted { moves: self.moves.clone(), })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - CountedImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -39,14 +39,23 @@ impl Default for Counted { thread_local!( pub static drops_0: Value = Rc::new(RefCell::new(0)); ); -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, Destructible)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(1)] pub struct Dropped {} impl Clone for Dropped { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(Dropped {})); let __v: Value = Rc::new(RefCell::new(::zero_init())); - DroppedImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -75,7 +84,7 @@ fn main_0() -> i32 { { let c: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - CountedImpl::copy_from(&__v.as_pointer(), { c.as_pointer() }); + CopyConstructible::copy_constructor(&__v.as_pointer(), { c.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); }, @@ -95,14 +104,14 @@ fn main_0() -> i32 { { let c: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - CountedImpl::copy_from(&__v.as_pointer(), { c.as_pointer() }); + CopyConstructible::copy_constructor(&__v.as_pointer(), { c.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); }, || -> Counted { return { let __v: Value = Rc::new(RefCell::new(::zero_init())); - CountedImpl::copy_from(&__v.as_pointer(), { c.as_pointer() }); + CopyConstructible::copy_constructor(&__v.as_pointer(), { c.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; } @@ -124,7 +133,9 @@ fn main_0() -> i32 { let arr: Value> = Rc::new(RefCell::new(Box::new( std::array::from_fn::<_, 2, _>(|__i: usize| { let __v: Value = Rc::new(RefCell::new(::zero_init())); - CountedImpl::copy_from(&__v.as_pointer(), { arr.decay().offset(__i) }); + CopyConstructible::copy_constructor(&__v.as_pointer(), { + arr.decay().offset(__i) + }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }), ))); @@ -204,37 +215,41 @@ fn main_0() -> i32 { } pub trait CountedImpl { fn construct(&self); - fn copy_from(&self, o: Ptr); - fn move_from(&self, o: Ptr); } impl CountedImpl for Ptr { fn construct(&self) { field!((*self), copies).write(0); field!((*self), moves).write(0); } - fn copy_from(&self, o: Ptr) { - field!((*self), copies).write((o.with(|__s| __s.copies) + 1)); - field!((*self), moves).write(o.with(|__s| __s.moves)); +} +impl CopyConstructible for Counted { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), copies).write((o.with(|__s| __s.copies) + 1)); + field!((*this), moves).write(o.with(|__s| __s.moves)); } - fn move_from(&self, o: Ptr) { - field!((*self), copies).write(o.with(|__s| __s.copies)); - field!((*self), moves).write((o.with(|__s| __s.moves) + 1)); +} +impl MoveConstructible for Counted { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), copies).write(o.with(|__s| __s.copies)); + field!((*this), moves).write((o.with(|__s| __s.moves) + 1)); } } pub trait DroppedImpl { fn construct(&self); - fn copy_from(&self, _a0: Ptr); - fn move_from(&self, _a0: Ptr); fn destructor(&self); } impl DroppedImpl for Ptr { fn construct(&self) {} - fn copy_from(&self, _a0: Ptr) {} - fn move_from(&self, _a0: Ptr) {} fn destructor(&self) { (*drops_0.with(Value::clone).borrow_mut()).postfix_inc(); } } +impl CopyConstructible for Dropped { + fn copy_constructor(this: &Ptr, _a0: Ptr) {} +} +impl MoveConstructible for Dropped { + fn move_constructor(this: &Ptr, _a0: Ptr) {} +} pub fn __cpp2rust_init_globals() { let _ = drops_0.with(|_| ()); } diff --git a/tests/unit/out/refcount/lambda_capture_ref.rs b/tests/unit/out/refcount/lambda_capture_ref.rs index 6ececc76f2..899d4798f7 100644 --- a/tests/unit/out/refcount/lambda_capture_ref.rs +++ b/tests/unit/out/refcount/lambda_capture_ref.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/lambda_capture_star_this.rs b/tests/unit/out/refcount/lambda_capture_star_this.rs index baebf700dd..02520ff7d1 100644 --- a/tests/unit/out/refcount/lambda_capture_star_this.rs +++ b/tests/unit/out/refcount/lambda_capture_star_this.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/lambda_capture_this.rs b/tests/unit/out/refcount/lambda_capture_this.rs index 66a24ed128..4480b2a8ec 100644 --- a/tests/unit/out/refcount/lambda_capture_this.rs +++ b/tests/unit/out/refcount/lambda_capture_this.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/lambda_capture_value.rs b/tests/unit/out/refcount/lambda_capture_value.rs index 4fa6b5688b..a3bfd7c3e0 100644 --- a/tests/unit/out/refcount/lambda_capture_value.rs +++ b/tests/unit/out/refcount/lambda_capture_value.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/lambda_decltype_type.rs b/tests/unit/out/refcount/lambda_decltype_type.rs index 7237a10fac..d5648c025f 100644 --- a/tests/unit/out/refcount/lambda_decltype_type.rs +++ b/tests/unit/out/refcount/lambda_decltype_type.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(24)] pub struct Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { #[offset(0)] @@ -34,7 +45,18 @@ impl Default for Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(24)] pub struct Sorted__lambda_at_lambda_decltype_type_cpp_19_23__ { #[offset(0)] diff --git a/tests/unit/out/refcount/lambda_generic_explicit_args.rs b/tests/unit/out/refcount/lambda_generic_explicit_args.rs index d8889d4ff4..22de36f6a7 100644 --- a/tests/unit/out/refcount/lambda_generic_explicit_args.rs +++ b/tests/unit/out/refcount/lambda_generic_explicit_args.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Val { #[offset(0)] diff --git a/tests/unit/out/refcount/lambda_immediate_init.rs b/tests/unit/out/refcount/lambda_immediate_init.rs index 6aeb494e2e..a61e38ba16 100644 --- a/tests/unit/out/refcount/lambda_immediate_init.rs +++ b/tests/unit/out/refcount/lambda_immediate_init.rs @@ -9,7 +9,19 @@ use std::rc::{Rc, Weak}; pub fn pick_0(mut x: i32) -> i32 { return x; } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(8)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/lambda_move_only_capture.rs b/tests/unit/out/refcount/lambda_move_only_capture.rs index 4d45c1d7cd..b5fd38ee0f 100644 --- a/tests/unit/out/refcount/lambda_move_only_capture.rs +++ b/tests/unit/out/refcount/lambda_move_only_capture.rs @@ -6,9 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, MoveCtor, CppFrom, Destructible, Default, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Destructible, Default)] #[cpp_from(i32, construct, value)] #[byte_size(8)] pub struct Owner { @@ -32,7 +30,7 @@ fn main_0() -> i32 { { let h: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - OwnerImpl::move_from(&__v.as_pointer(), { o.as_pointer() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { o.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); }, @@ -89,7 +87,6 @@ fn main_0() -> i32 { } pub trait OwnerImpl { fn construct(&self, v: i32); - fn move_from(&self, o: Ptr); fn destructor(&self); fn take(&self) -> FnPtr i32>; } @@ -97,10 +94,6 @@ impl OwnerImpl for Ptr { fn construct(&self, mut v: i32) { field!((*self), p).write(Ptr::alloc(v)); } - fn move_from(&self, o: Ptr) { - field!((*self), p).write(o.with(|__s| __s.p.clone())); - field!(o, p).write(Ptr::::null()); - } fn destructor(&self) { (*self).with(|__s| __s.p.clone()).delete(); } @@ -109,7 +102,7 @@ impl OwnerImpl for Ptr { { let self_: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - OwnerImpl::move_from(&__v.as_pointer(), { (*self).clone() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { (*self).clone() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); }, @@ -119,4 +112,10 @@ impl OwnerImpl for Ptr { ); } } +impl MoveConstructible for Owner { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), p).write(o.with(|__s| __s.p.clone())); + field!(o, p).write(Ptr::::null()); + } +} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/lambda_nested.rs b/tests/unit/out/refcount/lambda_nested.rs index ba8bf59b16..b0138f7796 100644 --- a/tests/unit/out/refcount/lambda_nested.rs +++ b/tests/unit/out/refcount/lambda_nested.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/lambda_static_local.rs b/tests/unit/out/refcount/lambda_static_local.rs index 7015e7960a..c2aad33903 100644 --- a/tests/unit/out/refcount/lambda_static_local.rs +++ b/tests/unit/out/refcount/lambda_static_local.rs @@ -78,7 +78,20 @@ thread_local!( thread_local!( static calls_3: Value = Rc::new(RefCell::new(0)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct P_4 { #[offset(0)] diff --git a/tests/unit/out/refcount/libc_struct_without_default.rs b/tests/unit/out/refcount/libc_struct_without_default.rs index 77edb687dc..6e0f0f88c1 100644 --- a/tests/unit/out/refcount/libc_struct_without_default.rs +++ b/tests/unit/out/refcount/libc_struct_without_default.rs @@ -6,7 +6,9 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, MoveAssign)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyConstructible, CopyAssignable, +)] #[byte_size(32)] pub struct UserDefined { #[offset(0)] @@ -27,7 +29,18 @@ impl Default for UserDefined { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(16)] pub struct FieldIsLibcType { #[offset(0)] @@ -77,34 +90,38 @@ fn main_0() -> i32 { assert!(((filt.addr.sa_family as i32) == 2)); return 0; } -pub trait UserDefinedImpl { - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; -} -impl UserDefinedImpl for Ptr { - fn move_from(&self, _a0: Ptr) { - field!((*self), a).write( - (0..1) - .map(|__i| field_ref!(_a0, a).decay().offset(__i).read()) - .collect(), - ); - field!((*self), v).write(field!(_a0, v).with_mut(std::mem::take)); - } - fn move_assign(&self, _a0: Ptr) -> Ptr { +impl MoveAssignable for UserDefined { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { { for __i in 0..1 { - &field_ref!((*self), a) - .as_pointer() - .decay() - .offset(__i) - .write(field_ref!(_a0, a).decay().offset(__i).read()); + MoveAssignable::move_assign( + &field_ref!((*this), a).as_pointer().decay().offset(__i), + field_ref!(_a0, a).decay().offset(__i), + ); } - field_ref!((*self), a).as_pointer() + field_ref!((*this), a).as_pointer() }; - field!((*self), v).with_mut(|__b0| { + field!((*this), v).with_mut(|__b0| { (*__b0) = field!(_a0, v).with_mut(std::mem::take); }); - return (*self).clone(); + return (*this).clone(); + } +} +impl MoveConstructible for UserDefined { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), a).write({ + let __v: Value> = + Rc::new(RefCell::new((0..1).map(|_| ::zero_init()).collect())); + let __p: Ptr = __v.decay(); + for __i in 0..1 { + MoveConstructible::move_constructor( + &__p.offset(__i), + field_ref!(_a0, a).decay().offset(__i), + ); + } + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }); + field!((*this), v).write(field!(_a0, v).with_mut(std::mem::take)); } } pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/linked_list.rs b/tests/unit/out/refcount/linked_list.rs index 703bb1b63e..e027995d7d 100644 --- a/tests/unit/out/refcount/linked_list.rs +++ b/tests/unit/out/refcount/linked_list.rs @@ -6,7 +6,19 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct Node { #[offset(0)] diff --git a/tests/unit/out/refcount/local_anon_struct_collision.rs b/tests/unit/out/refcount/local_anon_struct_collision.rs index c00fcb21b3..5b0c181b35 100644 --- a/tests/unit/out/refcount/local_anon_struct_collision.rs +++ b/tests/unit/out/refcount/local_anon_struct_collision.rs @@ -12,7 +12,20 @@ pub fn first_0() -> i32 { p.y = 2; return (p.x + p.y); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct anon_1 { #[offset(0)] @@ -26,7 +39,20 @@ pub fn second_2() -> i32 { q.b = 20_i64; return ((q.a + q.b) as i32); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct anon_3 { #[offset(0)] diff --git a/tests/unit/out/refcount/local_record_template.rs b/tests/unit/out/refcount/local_record_template.rs index a8902e358c..f0695353b4 100644 --- a/tests/unit/out/refcount/local_record_template.rs +++ b/tests/unit/out/refcount/local_record_template.rs @@ -29,13 +29,39 @@ pub fn wrap_10(mut v: i64) -> i32 { let mut l: Local_7 = Local_7 { x: v }; return ({ get_6(l) }); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Local_5 { #[offset(0)] pub x: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Local_7 { #[offset(0)] @@ -45,7 +71,20 @@ pub fn other_11() -> i32 { let mut l: Local_1 = Local_1 { x: 3_i64, y: 4_i64 }; return (({ get_0(l) }) + (l.y as i32)); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct Local_1 { #[offset(0)] @@ -66,7 +105,20 @@ fn main_0() -> i32 { assert!((({ wrap_10(6_i64,) }) == 6)); return 0; } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Local_3 { #[offset(0)] diff --git a/tests/unit/out/refcount/map.rs b/tests/unit/out/refcount/map.rs index f24a258731..e2f8bd6f6d 100644 --- a/tests/unit/out/refcount/map.rs +++ b/tests/unit/out/refcount/map.rs @@ -12,7 +12,19 @@ pub fn foo_0(mut x: u32) { pub fn bar_1(x: Ptr) { x.write((x.read()).wrapping_add(1_u32)); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(8)] pub struct Point { #[offset(0)] diff --git a/tests/unit/out/refcount/map_key_copy_ctor.rs b/tests/unit/out/refcount/map_key_copy_ctor.rs index 34c8521669..cb108c1eaa 100644 --- a/tests/unit/out/refcount/map_key_copy_ctor.rs +++ b/tests/unit/out/refcount/map_key_copy_ctor.rs @@ -15,7 +15,17 @@ thread_local!( thread_local!( pub static made_2: Value = Rc::new(RefCell::new(0)); ); -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, CppFrom, Default)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct Key { @@ -37,7 +47,7 @@ impl Clone for Key { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(Key { k: self.k.clone() })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - KeyImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -286,25 +296,27 @@ fn main_0() -> i32 { } pub trait KeyImpl { fn construct(&self, k: i32); - fn copy_from(&self, o: Ptr); - fn move_from(&self, o: Ptr); fn operator_lt(&self, o: Ptr) -> bool; } impl KeyImpl for Ptr { fn construct(&self, mut k: i32) { field!((*self), k).write(k); } - fn copy_from(&self, o: Ptr) { - field!((*self), k).write(o.with(|__s| __s.k)); + fn operator_lt(&self, o: Ptr) -> bool { + return ({ (*self).with(|__s| __s.k) } < { o.with(|__s| __s.k) }); + } +} +impl CopyConstructible for Key { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), k).write(o.with(|__s| __s.k)); (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); } - fn move_from(&self, o: Ptr) { - field!((*self), k).write(o.with(|__s| __s.k)); +} +impl MoveConstructible for Key { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), k).write(o.with(|__s| __s.k)); (*moves_1.with(Value::clone).borrow_mut()).prefix_inc(); } - fn operator_lt(&self, o: Ptr) -> bool { - return ({ (*self).with(|__s| __s.k) } < { o.with(|__s| __s.k) }); - } } pub fn __cpp2rust_init_globals() { let _ = copies_0.with(|_| ()); diff --git a/tests/unit/out/refcount/map_key_identity.rs b/tests/unit/out/refcount/map_key_identity.rs index ed8ffcd313..02258d964d 100644 --- a/tests/unit/out/refcount/map_key_identity.rs +++ b/tests/unit/out/refcount/map_key_identity.rs @@ -9,7 +9,20 @@ use std::rc::{Rc, Weak}; thread_local!( pub static default_constructions_0: Value = Rc::new(RefCell::new(0)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Key { #[offset(0)] @@ -33,7 +46,19 @@ pub fn operator_lt_1(a: Ptr, b: Ptr) -> bool { pub fn operator_eq_2(a: Ptr, b: Ptr) -> bool { return ({ a.with(|__s| __s.identity) } == { b.with(|__s| __s.identity) }); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(4)] pub struct Mapped { #[offset(0)] diff --git a/tests/unit/out/refcount/map_try_emplace.rs b/tests/unit/out/refcount/map_try_emplace.rs index 2d50a7996a..ad55daf035 100644 --- a/tests/unit/out/refcount/map_try_emplace.rs +++ b/tests/unit/out/refcount/map_try_emplace.rs @@ -18,7 +18,9 @@ thread_local!( thread_local!( pub static moves_3: Value = Rc::new(RefCell::new(0)); ); -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, CppFrom)] +#[derive( + Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, CopyAssignable, MoveAssignable, +)] #[cpp_from(i32, construct_1, value)] #[byte_size(4)] pub struct Item { @@ -31,7 +33,7 @@ impl Clone for Item { value: self.value.clone(), })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - ItemImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -50,7 +52,19 @@ pub fn argument_4(item: Ptr) -> Ptr { (*calls_0.with(Value::clone).borrow_mut()).prefix_inc(); return (item).clone(); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(4)] pub struct RefItem { #[offset(0)] @@ -369,7 +383,9 @@ fn main_0() -> i32 { Rc::new(RefCell::new(key.as_pointer().read())), Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - ItemImpl::copy_from(&__v.as_pointer(), { (__tmp_6).clone() }); + CopyConstructible::copy_constructor(&__v.as_pointer(), { + (__tmp_6).clone() + }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })), ) @@ -408,7 +424,9 @@ fn main_0() -> i32 { Rc::new(RefCell::new(key.as_pointer().read())), Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - ItemImpl::move_from(&__v.as_pointer(), { (__tmp_7).clone() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { + (__tmp_7).clone() + }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })), ) @@ -446,7 +464,9 @@ fn main_0() -> i32 { Rc::new(RefCell::new(key.as_pointer().read())), Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - ItemImpl::copy_from(&__v.as_pointer(), { (__tmp_8).clone() }); + CopyConstructible::copy_constructor(&__v.as_pointer(), { + (__tmp_8).clone() + }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })), ) @@ -486,7 +506,9 @@ fn main_0() -> i32 { Rc::new(RefCell::new(key.as_pointer().read())), Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - ItemImpl::move_from(&__v.as_pointer(), { (__tmp_9).clone() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { + (__tmp_9).clone() + }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })), ) @@ -642,7 +664,9 @@ fn main_0() -> i32 { Rc::new(RefCell::new(key.as_pointer().read())), Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - ItemImpl::move_from(&__v.as_pointer(), { (__tmp_12).clone() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { + (__tmp_12).clone() + }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })), ) @@ -686,7 +710,9 @@ fn main_0() -> i32 { Rc::new(RefCell::new(key.as_pointer().read())), Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - ItemImpl::move_from(&__v.as_pointer(), { (__tmp_14).clone() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { + (__tmp_14).clone() + }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })), ) @@ -726,8 +752,6 @@ fn main_0() -> i32 { pub trait ItemImpl { fn construct_2(&self); fn construct_1(&self, value: i32); - fn copy_from(&self, other: Ptr); - fn move_from(&self, other: Ptr); } impl ItemImpl for Ptr { fn construct_2(&self) { @@ -737,12 +761,16 @@ impl ItemImpl for Ptr { field!((*self), value).write(value); (*made_1.with(Value::clone).borrow_mut()).prefix_inc(); } - fn copy_from(&self, other: Ptr) { - field!((*self), value).write(other.with(|__s| __s.value)); +} +impl CopyConstructible for Item { + fn copy_constructor(this: &Ptr, other: Ptr) { + field!((*this), value).write(other.with(|__s| __s.value)); (*copies_2.with(Value::clone).borrow_mut()).prefix_inc(); } - fn move_from(&self, other: Ptr) { - field!((*self), value).write(other.with(|__s| __s.value)); +} +impl MoveConstructible for Item { + fn move_constructor(this: &Ptr, other: Ptr) { + field!((*this), value).write(other.with(|__s| __s.value)); (*moves_3.with(Value::clone).borrow_mut()).prefix_inc(); field!(other, value).write(-1_i32); } diff --git a/tests/unit/out/refcount/map_try_emplace_lvalues.rs b/tests/unit/out/refcount/map_try_emplace_lvalues.rs index ef25415bda..d2757625a5 100644 --- a/tests/unit/out/refcount/map_try_emplace_lvalues.rs +++ b/tests/unit/out/refcount/map_try_emplace_lvalues.rs @@ -12,7 +12,19 @@ thread_local!( thread_local!( pub static visits_1: Value = Rc::new(RefCell::new(0)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(4)] pub struct Item { #[offset(0)] @@ -42,7 +54,18 @@ pub fn place_3(n: Ptr) -> Ptr { thread_local!( pub static temporary_calls_4: Value = Rc::new(RefCell::new(0)); ); -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(12)] pub struct Temporary { #[offset(0)] @@ -63,7 +86,19 @@ impl Default for Temporary { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(12)] pub struct Nested { #[offset(0)] @@ -80,7 +115,7 @@ pub fn make_temporary_5() -> Temporary { pub fn make_nested_6() -> Nested { return ::default(); } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, MoveCtor, MoveAssign)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg)] #[byte_size(8)] pub struct Owner { #[offset(0)] @@ -109,7 +144,19 @@ impl Default for Noncopy { { Noncopy { n: 5 } } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[cpp_from(i32, construct_1, ptr)] #[byte_size(8)] pub struct Held { @@ -2434,8 +2481,6 @@ impl ItemImpl for Ptr { pub trait OwnerImpl { fn construct(&self); fn value(&self) -> Ptr; - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; } impl OwnerImpl for Ptr { fn construct(&self) { @@ -2448,15 +2493,19 @@ impl OwnerImpl for Ptr { fn value(&self) -> Ptr { return field_ptr!((*self).with(|__s| __s.ptr.clone()).as_pointer(), n); } - fn move_from(&self, _a0: Ptr) { - field!((*self), ptr) - .write(field!(_a0, ptr).with_mut(|__v: &mut Option>| __v.take())); - } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), ptr).with_mut(|__b0| { +} +impl MoveAssignable for Owner { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), ptr).with_mut(|__b0| { (*__b0) = field!(_a0, ptr).with_mut(|__v: &mut Option>| __v.take()); }); - return (*self).clone(); + return (*this).clone(); + } +} +impl MoveConstructible for Owner { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), ptr) + .write(field!(_a0, ptr).with_mut(|__v: &mut Option>| __v.take())); } } pub trait TemporaryImpl { diff --git a/tests/unit/out/refcount/max.rs b/tests/unit/out/refcount/max.rs index 0cd14d48ef..88e283b4b6 100644 --- a/tests/unit/out/refcount/max.rs +++ b/tests/unit/out/refcount/max.rs @@ -20,7 +20,17 @@ pub fn pick_3(mut i: i32) -> Ptr { (*calls_0.with(Value::clone).borrow_mut()).prefix_inc(); return xs_1.with(|v| v.decay()).offset(i); } -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, CopyAssign, Default)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + MoveConstructible, + MoveAssignable, + Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct Bag { @@ -42,7 +52,7 @@ impl Clone for Bag { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(Bag { n: self.n.clone() })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - BagImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -207,20 +217,22 @@ fn main_0() -> i32 { } pub trait BagImpl { fn construct(&self, n: i32); - fn copy_from(&self, o: Ptr); - fn copy_assign(&self, _a0: Ptr) -> Ptr; } impl BagImpl for Ptr { fn construct(&self, mut n: i32) { field!((*self), n).write(n); } - fn copy_from(&self, o: Ptr) { - field!((*self), n).write(o.with(|__s| __s.n)); - (*calls_0.with(Value::clone).borrow_mut()).prefix_inc(); +} +impl CopyAssignable for Bag { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), n).write(_a0.with(|__s| __s.n)); + return (*this).clone(); } - fn copy_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), n).write(_a0.with(|__s| __s.n)); - return (*self).clone(); +} +impl CopyConstructible for Bag { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), n).write(o.with(|__s| __s.n)); + (*calls_0.with(Value::clone).borrow_mut()).prefix_inc(); } } pub fn __cpp2rust_init_globals() { diff --git a/tests/unit/out/refcount/memcpy_struct_bytes.rs b/tests/unit/out/refcount/memcpy_struct_bytes.rs index af4970383b..4772b3faa1 100644 --- a/tests/unit/out/refcount/memcpy_struct_bytes.rs +++ b/tests/unit/out/refcount/memcpy_struct_bytes.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct point { #[offset(0)] diff --git a/tests/unit/out/refcount/memcpy_struct_layouts.rs b/tests/unit/out/refcount/memcpy_struct_layouts.rs index a90e59a069..8a6d5a2ac8 100644 --- a/tests/unit/out/refcount/memcpy_struct_layouts.rs +++ b/tests/unit/out/refcount/memcpy_struct_layouts.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct packed { #[offset(0)] @@ -18,7 +31,20 @@ pub struct packed { #[offset(6)] pub d: i16, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(12)] pub struct reordered { #[offset(0)] @@ -28,7 +54,20 @@ pub struct reordered { #[offset(8)] pub c: i8, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct tail { #[offset(0)] @@ -36,7 +75,20 @@ pub struct tail { #[offset(8)] pub b: f64, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(24)] pub struct nested { #[offset(0)] @@ -45,7 +97,18 @@ pub struct nested { #[offset(16)] pub c: i8, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(8)] pub struct array { #[offset(0)] diff --git a/tests/unit/out/refcount/memcpy_struct_struct.rs b/tests/unit/out/refcount/memcpy_struct_struct.rs index 3aa8c319d5..413286fe0b 100644 --- a/tests/unit/out/refcount/memcpy_struct_struct.rs +++ b/tests/unit/out/refcount/memcpy_struct_struct.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Entry { #[offset(0)] diff --git a/tests/unit/out/refcount/memset_struct_tail.rs b/tests/unit/out/refcount/memset_struct_tail.rs index eca67abf50..625af5d21b 100644 --- a/tests/unit/out/refcount/memset_struct_tail.rs +++ b/tests/unit/out/refcount/memset_struct_tail.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(32)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/move_assign.rs b/tests/unit/out/refcount/move_assign.rs index b98f1c1fab..947e784753 100644 --- a/tests/unit/out/refcount/move_assign.rs +++ b/tests/unit/out/refcount/move_assign.rs @@ -6,9 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, MoveCtor, CppFrom, MoveAssign, Default, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Default)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct MoveOnly { @@ -41,7 +39,7 @@ pub fn make_0(mut v: i32) -> MoveOnly { })); return { let __v: Value = Rc::new(RefCell::new(::zero_init())); - MoveOnlyImpl::move_from(&__v.as_pointer(), { m.as_pointer() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { m.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; } @@ -65,7 +63,7 @@ fn main_0() -> i32 { MoveOnlyImpl::construct(&__v.as_pointer(), { 3 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); - ({ MoveOnlyImpl::move_assign(&a.as_pointer(), b.as_pointer()) }); + ({ MoveAssignable::move_assign(&a.as_pointer(), b.as_pointer()) }); assert!(({ (*a.borrow()).v } == 2)); assert!(({ (*b.borrow()).v } == 0)); ({ @@ -74,12 +72,12 @@ fn main_0() -> i32 { MoveOnlyImpl::construct(&__v.as_pointer(), { 3 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); - MoveOnlyImpl::move_assign(&b.as_pointer(), _o.as_pointer()) + MoveAssignable::move_assign(&b.as_pointer(), _o.as_pointer()) }); ({ - MoveOnlyImpl::move_assign( + MoveAssignable::move_assign( &c.as_pointer(), - ({ MoveOnlyImpl::move_assign(&a.as_pointer(), b.as_pointer()) }), + ({ MoveAssignable::move_assign(&a.as_pointer(), b.as_pointer()) }), ) }); assert!( @@ -91,15 +89,15 @@ fn main_0() -> i32 { MoveOnlyImpl::construct(&__v.as_pointer(), { 5 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); - MoveOnlyImpl::move_assign(&a.as_pointer(), _o.as_pointer()) + MoveAssignable::move_assign(&a.as_pointer(), _o.as_pointer()) }); assert!(({ (*a.borrow()).v } == 5)); ({ let _o: Value = Rc::new(RefCell::new(({ make_0(6) }))); - MoveOnlyImpl::move_assign(&a.as_pointer(), _o.as_pointer()) + MoveAssignable::move_assign(&a.as_pointer(), _o.as_pointer()) }); assert!(({ (*a.borrow()).v } == 6)); - ({ MoveOnlyImpl::move_assign(&a.as_pointer(), a.as_pointer()) }); + ({ MoveAssignable::move_assign(&a.as_pointer(), a.as_pointer()) }); assert!(({ (*a.borrow()).v } == 6)); let vec_: Value> = Rc::new(RefCell::new(Vec::new())); { @@ -115,7 +113,7 @@ fn main_0() -> i32 { MoveOnlyImpl::construct(&__v.as_pointer(), { 8 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); - ({ MoveOnlyImpl::move_assign(&vec_.decay().offset(0_usize), d.as_pointer()) }); + ({ MoveAssignable::move_assign(&vec_.decay().offset(0_usize), d.as_pointer()) }); assert!(({ (*vec_.borrow())[0_usize].v } == 8)); assert!(({ (*d.borrow()).v } == 0)); let m: Value = Rc::new(RefCell::new({ @@ -164,24 +162,26 @@ impl ConstMoveAssignImpl for Ptr { } pub trait MoveOnlyImpl { fn construct(&self, v: i32); - fn move_from(&self, o: Ptr); - fn move_assign(&self, o: Ptr) -> Ptr; } impl MoveOnlyImpl for Ptr { fn construct(&self, mut v: i32) { field!((*self), v).write(v); } - fn move_from(&self, o: Ptr) { - field!((*self), v).write(o.with(|__s| __s.v)); +} +impl MoveAssignable for MoveOnly { + fn move_assign(this: &Ptr, o: Ptr) -> Ptr { + if ((*this) == (o)) { + return (*this).clone(); + } + field!((*this), v).write(o.with(|__s| __s.v)); field!(o, v).write(0); + return (*this).clone(); } - fn move_assign(&self, o: Ptr) -> Ptr { - if ((*self) == (o)) { - return (*self).clone(); - } - field!((*self), v).write(o.with(|__s| __s.v)); +} +impl MoveConstructible for MoveOnly { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); field!(o, v).write(0); - return (*self).clone(); } } pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/move_ctor.rs b/tests/unit/out/refcount/move_ctor.rs index e93ce86953..9f8531c6b3 100644 --- a/tests/unit/out/refcount/move_ctor.rs +++ b/tests/unit/out/refcount/move_ctor.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, MoveCtor, CppFrom, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Default)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct MoveOnly { @@ -30,7 +30,17 @@ impl Default for ConstMove { } } } -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, CppFrom, Default)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(12)] pub struct ThrowingMove { @@ -49,11 +59,21 @@ impl Clone for ThrowingMove { moves: self.moves.clone(), })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - ThrowingMoveImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, CppFrom, Default)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(12)] pub struct NoexceptMove { @@ -72,7 +92,7 @@ impl Clone for NoexceptMove { moves: self.moves.clone(), })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - NoexceptMoveImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -87,7 +107,7 @@ pub fn make_1(mut v: i32) -> MoveOnly { })); return { let __v: Value = Rc::new(RefCell::new(::zero_init())); - MoveOnlyImpl::move_from(&__v.as_pointer(), { m.as_pointer() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { m.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; } @@ -103,21 +123,21 @@ fn main_0() -> i32 { })); let b: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - MoveOnlyImpl::move_from(&__v.as_pointer(), { a.as_pointer() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { a.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); assert!(({ (*b.borrow()).v } == 1)); assert!(({ (*a.borrow()).v } == 0)); let c: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - MoveOnlyImpl::move_from(&__v.as_pointer(), { b.as_pointer() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { b.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); assert!(({ (*c.borrow()).v } == 1)); assert!(({ (*b.borrow()).v } == 0)); let mut d: MoveOnly = { let __v: Value = Rc::new(RefCell::new(::zero_init())); - MoveOnlyImpl::move_from(&__v.as_pointer(), { c.as_pointer() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { c.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; assert!((d.v == 1)); @@ -137,7 +157,7 @@ fn main_0() -> i32 { (({ by_value_0({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - MoveOnlyImpl::move_from(&__v.as_pointer(), { e.as_pointer() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { e.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }) }) == 5) @@ -160,7 +180,7 @@ fn main_0() -> i32 { { let __a1 = { let __v: Value = Rc::new(RefCell::new(::zero_init())); - MoveOnlyImpl::move_from(&__v.as_pointer(), { f.as_pointer() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { f.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; vec_.push(__a1) @@ -196,7 +216,7 @@ fn main_0() -> i32 { })); let mut t1: ThrowingMove = { let __v: Value = Rc::new(RefCell::new(::zero_init())); - ThrowingMoveImpl::copy_from(&__v.as_pointer(), { t.as_pointer() }); + CopyConstructible::copy_constructor(&__v.as_pointer(), { t.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; assert!((t1.v == 1)); @@ -210,7 +230,7 @@ fn main_0() -> i32 { })); let mut n1: NoexceptMove = { let __v: Value = Rc::new(RefCell::new(::zero_init())); - NoexceptMoveImpl::move_from(&__v.as_pointer(), { n.as_pointer() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { n.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; assert!((n1.v == 2)); @@ -224,7 +244,7 @@ fn main_0() -> i32 { })); let mut g1: MoveOnly = { let __v: Value = Rc::new(RefCell::new(::zero_init())); - MoveOnlyImpl::move_from(&__v.as_pointer(), { g.as_pointer() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { g.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; assert!((g1.v == 3)); @@ -249,21 +269,20 @@ impl ConstMoveImpl for Ptr { } pub trait MoveOnlyImpl { fn construct(&self, v: i32); - fn move_from(&self, o: Ptr); } impl MoveOnlyImpl for Ptr { fn construct(&self, mut v: i32) { field!((*self), v).write(v); } - fn move_from(&self, o: Ptr) { - field!((*self), v).write(o.with(|__s| __s.v)); +} +impl MoveConstructible for MoveOnly { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); field!(o, v).write(0); } } pub trait NoexceptMoveImpl { fn construct(&self, v: i32); - fn copy_from(&self, o: Ptr); - fn move_from(&self, o: Ptr); } impl NoexceptMoveImpl for Ptr { fn construct(&self, mut v: i32) { @@ -271,22 +290,24 @@ impl NoexceptMoveImpl for Ptr { field!((*self), copies).write(0); field!((*self), moves).write(0); } - fn copy_from(&self, o: Ptr) { - field!((*self), v).write(o.with(|__s| __s.v)); - field!((*self), copies).write((o.with(|__s| __s.copies) + 1)); - field!((*self), moves).write(o.with(|__s| __s.moves)); +} +impl CopyConstructible for NoexceptMove { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + field!((*this), copies).write((o.with(|__s| __s.copies) + 1)); + field!((*this), moves).write(o.with(|__s| __s.moves)); } - fn move_from(&self, o: Ptr) { - field!((*self), v).write(o.with(|__s| __s.v)); - field!((*self), copies).write(o.with(|__s| __s.copies)); - field!((*self), moves).write((o.with(|__s| __s.moves) + 1)); +} +impl MoveConstructible for NoexceptMove { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + field!((*this), copies).write(o.with(|__s| __s.copies)); + field!((*this), moves).write((o.with(|__s| __s.moves) + 1)); field!(o, v).write(0); } } pub trait ThrowingMoveImpl { fn construct(&self, v: i32); - fn copy_from(&self, o: Ptr); - fn move_from(&self, o: Ptr); } impl ThrowingMoveImpl for Ptr { fn construct(&self, mut v: i32) { @@ -294,15 +315,19 @@ impl ThrowingMoveImpl for Ptr { field!((*self), copies).write(0); field!((*self), moves).write(0); } - fn copy_from(&self, o: Ptr) { - field!((*self), v).write(o.with(|__s| __s.v)); - field!((*self), copies).write((o.with(|__s| __s.copies) + 1)); - field!((*self), moves).write(o.with(|__s| __s.moves)); +} +impl CopyConstructible for ThrowingMove { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + field!((*this), copies).write((o.with(|__s| __s.copies) + 1)); + field!((*this), moves).write(o.with(|__s| __s.moves)); } - fn move_from(&self, o: Ptr) { - field!((*self), v).write(o.with(|__s| __s.v)); - field!((*self), copies).write(o.with(|__s| __s.copies)); - field!((*self), moves).write((o.with(|__s| __s.moves) + 1)); +} +impl MoveConstructible for ThrowingMove { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + field!((*this), copies).write(o.with(|__s| __s.copies)); + field!((*this), moves).write((o.with(|__s| __s.moves) + 1)); field!(o, v).write(0); } } diff --git a/tests/unit/out/refcount/move_this.rs b/tests/unit/out/refcount/move_this.rs index 6ca5996737..caac1e71ff 100644 --- a/tests/unit/out/refcount/move_this.rs +++ b/tests/unit/out/refcount/move_this.rs @@ -6,7 +6,17 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, CppFrom, Default)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct Chain { @@ -17,7 +27,7 @@ impl Clone for Chain { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(Chain { v: self.v.clone() })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - ChainImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -43,7 +53,7 @@ fn main_0() -> i32 { })); let mut b: Chain = { let __v: Value = Rc::new(RefCell::new(::zero_init())); - ChainImpl::move_from(&__v.as_pointer(), { + MoveConstructible::move_constructor(&__v.as_pointer(), { ({ ChainImpl::add_5(&({ ChainImpl::add_5(&b0.as_pointer(), 1) }), 1) }) }); Rc::try_unwrap(__v).ok().unwrap().into_inner() @@ -73,7 +83,7 @@ fn main_0() -> i32 { (({ consume_0({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - ChainImpl::move_from(&__v.as_pointer(), { + MoveConstructible::move_constructor(&__v.as_pointer(), { ({ ChainImpl::self_(&g.as_pointer()) }) }); Rc::try_unwrap(__v).ok().unwrap().into_inner() @@ -91,8 +101,6 @@ fn main_0() -> i32 { } pub trait ChainImpl { fn construct(&self, v: i32); - fn copy_from(&self, o: Ptr); - fn move_from(&self, o: Ptr); fn add_4(&self, n: i32) -> Ptr; fn add_5(&self, n: i32) -> Ptr; fn take(&self) -> Chain; @@ -103,13 +111,6 @@ impl ChainImpl for Ptr { fn construct(&self, mut v: i32) { field!((*self), v).write(v); } - fn copy_from(&self, o: Ptr) { - field!((*self), v).write((o.with(|__s| __s.v) + 100)); - } - fn move_from(&self, o: Ptr) { - field!((*self), v).write((o.with(|__s| __s.v) + 1)); - field!(o, v).write(0); - } fn add_4(&self, mut n: i32) -> Ptr { { field!((*self), v).with_mut(|__v| *__v = *__v + n) @@ -125,14 +126,14 @@ impl ChainImpl for Ptr { fn take(&self) -> Chain { return { let __v: Value = Rc::new(RefCell::new(::zero_init())); - ChainImpl::move_from(&__v.as_pointer(), { (*self).clone() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { (*self).clone() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; } fn copy(&self) -> Chain { return { let __v: Value = Rc::new(RefCell::new(::zero_init())); - ChainImpl::copy_from(&__v.as_pointer(), { (*self).clone() }); + CopyConstructible::copy_constructor(&__v.as_pointer(), { (*self).clone() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; } @@ -140,4 +141,15 @@ impl ChainImpl for Ptr { return (*self).clone(); } } +impl CopyConstructible for Chain { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write((o.with(|__s| __s.v) + 100)); + } +} +impl MoveConstructible for Chain { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write((o.with(|__s| __s.v) + 1)); + field!(o, v).write(0); + } +} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/nested_structs.rs b/tests/unit/out/refcount/nested_structs.rs index 92ff0d5cc2..43e3f935c2 100644 --- a/tests/unit/out/refcount/nested_structs.rs +++ b/tests/unit/out/refcount/nested_structs.rs @@ -6,13 +6,39 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Level0_Level1_1_Level2_1_Level3_1 { #[offset(0)] pub x1: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Level0_Level1_1_Level2_1_Level3_2 { #[offset(0)] @@ -20,19 +46,58 @@ pub struct Level0_Level1_1_Level2_1_Level3_2 { #[offset(4)] pub x2: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Level0_Level1_1_Level2_1 { #[offset(0)] pub x1: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Level0_Level1_1 { #[offset(0)] pub x1: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Level0_Level1_2 { #[offset(0)] @@ -40,7 +105,20 @@ pub struct Level0_Level1_2 { #[offset(4)] pub x2: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct Level0 {} pub fn main() { diff --git a/tests/unit/out/refcount/new.rs b/tests/unit/out/refcount/new.rs index 0bf358cc6a..36c83b4eab 100644 --- a/tests/unit/out/refcount/new.rs +++ b/tests/unit/out/refcount/new.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Pair { #[offset(0)] diff --git a/tests/unit/out/refcount/new_bst.rs b/tests/unit/out/refcount/new_bst.rs index e442c4263b..26328c6bac 100644 --- a/tests/unit/out/refcount/new_bst.rs +++ b/tests/unit/out/refcount/new_bst.rs @@ -6,7 +6,19 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(24)] pub struct node_t { #[offset(0)] diff --git a/tests/unit/out/refcount/new_struct.rs b/tests/unit/out/refcount/new_struct.rs index 0431d6d7d1..b78a9f3bad 100644 --- a/tests/unit/out/refcount/new_struct.rs +++ b/tests/unit/out/refcount/new_struct.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Pair { #[offset(0)] @@ -14,7 +27,20 @@ pub struct Pair { #[offset(4)] pub y: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct Triple { #[offset(0)] diff --git a/tests/unit/out/refcount/nttp_distinct_specializations.rs b/tests/unit/out/refcount/nttp_distinct_specializations.rs index 7c5fb3ec65..a850b560b7 100644 --- a/tests/unit/out/refcount/nttp_distinct_specializations.rs +++ b/tests/unit/out/refcount/nttp_distinct_specializations.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct S_2_ { #[offset(0)] @@ -14,13 +27,39 @@ pub struct S_2_ { #[offset(4)] pub w: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct S_1_ { #[offset(0)] pub v: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct S_3_ { #[offset(0)] diff --git a/tests/unit/out/refcount/offsetof.rs b/tests/unit/out/refcount/offsetof.rs index db02cf3294..cde6a6d77d 100644 --- a/tests/unit/out/refcount/offsetof.rs +++ b/tests/unit/out/refcount/offsetof.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(12)] pub struct Layout { #[offset(0)] @@ -16,7 +29,18 @@ pub struct Layout { #[offset(8)] pub c: u16, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(66)] pub struct Frame { #[offset(0)] diff --git a/tests/unit/out/refcount/opaque_forward_decl.rs b/tests/unit/out/refcount/opaque_forward_decl.rs index 68b7285f7f..5031ac50a8 100644 --- a/tests/unit/out/refcount/opaque_forward_decl.rs +++ b/tests/unit/out/refcount/opaque_forward_decl.rs @@ -6,7 +6,19 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct container { #[offset(0)] diff --git a/tests/unit/out/refcount/opaque_record_copy.rs b/tests/unit/out/refcount/opaque_record_copy.rs index 52f209175c..725a1103e4 100644 --- a/tests/unit/out/refcount/opaque_record_copy.rs +++ b/tests/unit/out/refcount/opaque_record_copy.rs @@ -6,10 +6,36 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct Probe {} -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Wrapper_Probe_ { #[offset(0)] diff --git a/tests/unit/out/refcount/opaque_then_defined.rs b/tests/unit/out/refcount/opaque_then_defined.rs index c848e68b1a..b690b0bd63 100644 --- a/tests/unit/out/refcount/opaque_then_defined.rs +++ b/tests/unit/out/refcount/opaque_then_defined.rs @@ -6,7 +6,19 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct list { #[offset(0)] @@ -15,7 +27,19 @@ pub struct list { #[offset(8)] pub size: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct node { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_arithmetic_free.rs b/tests/unit/out/refcount/operator_arithmetic_free.rs index 02d95197f9..4a96a06525 100644 --- a/tests/unit/out/refcount/operator_arithmetic_free.rs +++ b/tests/unit/out/refcount/operator_arithmetic_free.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_arithmetic_member.rs b/tests/unit/out/refcount/operator_arithmetic_member.rs index eaacebd799..954ca4fd1b 100644 --- a/tests/unit/out/refcount/operator_arithmetic_member.rs +++ b/tests/unit/out/refcount/operator_arithmetic_member.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_bitwise_free.rs b/tests/unit/out/refcount/operator_bitwise_free.rs index 63f57d0d91..8b92780cba 100644 --- a/tests/unit/out/refcount/operator_bitwise_free.rs +++ b/tests/unit/out/refcount/operator_bitwise_free.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_bitwise_member.rs b/tests/unit/out/refcount/operator_bitwise_member.rs index 45aba391cb..9d4779b2cf 100644 --- a/tests/unit/out/refcount/operator_bitwise_member.rs +++ b/tests/unit/out/refcount/operator_bitwise_member.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_comparison_defaulted.rs b/tests/unit/out/refcount/operator_comparison_defaulted.rs index ecf6df1e15..b48db17cdf 100644 --- a/tests/unit/out/refcount/operator_comparison_defaulted.rs +++ b/tests/unit/out/refcount/operator_comparison_defaulted.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Eq { #[offset(0)] @@ -19,7 +32,20 @@ impl CppEq for Eq { EqImpl::operator_eq(__lhs, __rhs.clone()) } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Cmp { #[offset(0)] @@ -37,7 +63,20 @@ impl CppEq for Cmp { CmpImpl::operator_cmp(__lhs, __rhs.clone()) == std::cmp::Ordering::Equal } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Both { #[offset(0)] @@ -53,7 +92,20 @@ impl CppEq for Both { BothImpl::operator_eq(__lhs, __rhs.clone()) } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct OrdOnly { #[offset(0)] @@ -69,7 +121,20 @@ impl CppEq for OrdOnly { OrdOnlyImpl::operator_cmp(__lhs, __rhs.clone()) == std::cmp::Ordering::Equal } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Inner { #[offset(0)] @@ -85,7 +150,20 @@ impl CppEq for Inner { InnerImpl::operator_cmp(__lhs, __rhs.clone()) == std::cmp::Ordering::Equal } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Outer { #[offset(0)] @@ -104,7 +182,20 @@ impl CppEq for Outer { OuterImpl::operator_cmp(__lhs, __rhs.clone()) == std::cmp::Ordering::Equal } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Secondary { #[offset(0)] @@ -120,7 +211,19 @@ impl CppEq for Secondary { SecondaryImpl::operator_eq(__lhs, __rhs.clone()) } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct PtrMember { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_comparison_free.rs b/tests/unit/out/refcount/operator_comparison_free.rs index eb141c4358..5003d6c2d8 100644 --- a/tests/unit/out/refcount/operator_comparison_free.rs +++ b/tests/unit/out/refcount/operator_comparison_free.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] @@ -46,7 +59,20 @@ pub fn operator_lt_6(a: Ptr, mut b: i32) -> bool { pub fn operator_lt_7(mut a: i32, b: Ptr) -> bool { return ({ a } < { b.with(|__s| __s.v) }); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct V { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_comparison_member.rs b/tests/unit/out/refcount/operator_comparison_member.rs index c6316b011c..074ebcb451 100644 --- a/tests/unit/out/refcount/operator_comparison_member.rs +++ b/tests/unit/out/refcount/operator_comparison_member.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_comparison_mixed.rs b/tests/unit/out/refcount/operator_comparison_mixed.rs index d4cc7e01d0..9cd74978db 100644 --- a/tests/unit/out/refcount/operator_comparison_mixed.rs +++ b/tests/unit/out/refcount/operator_comparison_mixed.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_comparison_nonbool.rs b/tests/unit/out/refcount/operator_comparison_nonbool.rs index 455f1ffdc5..fd225343c3 100644 --- a/tests/unit/out/refcount/operator_comparison_nonbool.rs +++ b/tests/unit/out/refcount/operator_comparison_nonbool.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct X { #[offset(0)] @@ -40,19 +53,58 @@ pub fn operator_le_4(mut a: X, mut b: X) -> i32 { pub fn operator_ge_5(mut a: X, mut b: X) -> i32 { return if (a.v >= b.v) { 7 } else { 0 }; } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Result { #[offset(0)] pub r: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Custom { #[offset(0)] pub v: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Mixed { #[offset(0)] @@ -68,14 +120,41 @@ impl CppEq for Mixed { ((MixedImpl::operator_eq(__lhs, __rhs.clone())) != 0) } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_into(bool, to_bool)] #[byte_size(1)] pub struct MyBool { #[offset(0)] pub value: bool, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Boolish { #[offset(0)] @@ -125,7 +204,20 @@ thread_local!( Rc::try_unwrap(__v).ok().unwrap().into_inner() })); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct RefInt { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_comparison_noncopyable.rs b/tests/unit/out/refcount/operator_comparison_noncopyable.rs index c99f609601..2dec5cb0ac 100644 --- a/tests/unit/out/refcount/operator_comparison_noncopyable.rs +++ b/tests/unit/out/refcount/operator_comparison_noncopyable.rs @@ -12,7 +12,7 @@ pub fn operator_eq_0(x: Ptr, y: Ptr) -> bool { pub fn operator_lt_1(x: Ptr, y: Ptr) -> bool { return ({ x.with(|__s| __s.data_) } < { y.with(|__s| __s.data_) }); } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, MoveCtor, CppFrom, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Default)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct S { @@ -56,14 +56,15 @@ fn main_0() -> i32 { } pub trait SImpl { fn construct(&self, data: i32); - fn move_from(&self, _a0: Ptr); } impl SImpl for Ptr { fn construct(&self, mut data: i32) { field!((*self), data_).write(data); } - fn move_from(&self, _a0: Ptr) { - field!((*self), data_).write({ (*_a0.upgrade().deref()).data_ }); +} +impl MoveConstructible for S { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), data_).write({ (*_a0.upgrade().deref()).data_ }); } } pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/operator_compound_assignment_free.rs b/tests/unit/out/refcount/operator_compound_assignment_free.rs index 865ca036ff..5261bedcbf 100644 --- a/tests/unit/out/refcount/operator_compound_assignment_free.rs +++ b/tests/unit/out/refcount/operator_compound_assignment_free.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_compound_assignment_member.rs b/tests/unit/out/refcount/operator_compound_assignment_member.rs index 3cfb3136fc..dba4e0ee85 100644 --- a/tests/unit/out/refcount/operator_compound_assignment_member.rs +++ b/tests/unit/out/refcount/operator_compound_assignment_member.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_friend.rs b/tests/unit/out/refcount/operator_friend.rs index 57ea87a36f..9c45d054bb 100644 --- a/tests/unit/out/refcount/operator_friend.rs +++ b/tests/unit/out/refcount/operator_friend.rs @@ -10,7 +10,20 @@ pub fn operator_eq_0(_a0: Ptr, _a1: Ptr) -> bool { return ({ _a0.with(|__s| __s.a) } == { _a1.with(|__s| __s.a) }) && ({ _a0.with(|__s| __s.b) } == { _a1.with(|__s| __s.b) }); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Defaulted { #[offset(0)] @@ -38,7 +51,20 @@ pub fn operator_cmp_1(_a0: Ptr, _a1: Ptr) -> std::cm pub fn operator_eq_2(_a0: Ptr, _a1: Ptr) -> bool { return ({ _a0.with(|__s| __s.a) } == { _a1.with(|__s| __s.a) }); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct DefaultedOrd { #[offset(0)] @@ -65,7 +91,20 @@ pub fn operator_add_5(x: Ptr, y: Ptr) -> Inline { a: ({ x.with(|__s| __s.a) } + { y.with(|__s| __s.a) }), }; } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Inline { #[offset(0)] @@ -81,7 +120,20 @@ impl CppEq for Inline { operator_eq_3(__lhs.clone(), __rhs.clone()) } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct OutOfLine { #[offset(0)] @@ -107,7 +159,20 @@ pub fn operator_lt_9(x: Ptr, y: Ptr) -> bool { pub fn operator_eq_10(x: Ptr, y: Ptr) -> bool { return ({ (x.with(|__s| __s.v) as i64) } == { y.with(|__s| __s.v) }); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Tmpl_int_ { #[offset(0)] @@ -123,7 +188,20 @@ impl CppEq for Tmpl_int_ { operator_eq_8(__lhs.clone(), __rhs.clone()) } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Tmpl_long_ { #[offset(0)] @@ -132,7 +210,20 @@ pub struct Tmpl_long_ { pub fn operator_eq_11(_a0: Ptr, _a1: Ptr) -> bool { return ({ _a0.with(|__s| __s.v) } == { _a1.with(|__s| __s.v) }); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct TmplDefaulted_int_ { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_less_than.rs b/tests/unit/out/refcount/operator_less_than.rs index 7785126728..5f7820506b 100644 --- a/tests/unit/out/refcount/operator_less_than.rs +++ b/tests/unit/out/refcount/operator_less_than.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Pair { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_logical_free.rs b/tests/unit/out/refcount/operator_logical_free.rs index 19d2e7e167..98eb00a2a9 100644 --- a/tests/unit/out/refcount/operator_logical_free.rs +++ b/tests/unit/out/refcount/operator_logical_free.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_logical_member.rs b/tests/unit/out/refcount/operator_logical_member.rs index 7db68dd321..9fb2f52bda 100644 --- a/tests/unit/out/refcount/operator_logical_member.rs +++ b/tests/unit/out/refcount/operator_logical_member.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_member_pointer_free.rs b/tests/unit/out/refcount/operator_member_pointer_free.rs index 0a7ee74641..5536472703 100644 --- a/tests/unit/out/refcount/operator_member_pointer_free.rs +++ b/tests/unit/out/refcount/operator_member_pointer_free.rs @@ -6,13 +6,37 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Inner { #[offset(0)] pub x: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(16)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_member_pointer_member.rs b/tests/unit/out/refcount/operator_member_pointer_member.rs index ed1b0db50b..3af4543655 100644 --- a/tests/unit/out/refcount/operator_member_pointer_member.rs +++ b/tests/unit/out/refcount/operator_member_pointer_member.rs @@ -6,13 +6,39 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Inner { #[offset(0)] pub x: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct Table {} impl Table { @@ -23,7 +49,18 @@ impl Table { thread_local!( pub static table_0: Value> = Rc::new(RefCell::new(Box::new([7, 8, 9]))); ); -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(16)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_other_free.rs b/tests/unit/out/refcount/operator_other_free.rs index 1171d169bf..0373f26a7a 100644 --- a/tests/unit/out/refcount/operator_other_free.rs +++ b/tests/unit/out/refcount/operator_other_free.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_other_member.rs b/tests/unit/out/refcount/operator_other_member.rs index 3b627eea25..f7713d73fc 100644 --- a/tests/unit/out/refcount/operator_other_member.rs +++ b/tests/unit/out/refcount/operator_other_member.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct Static {} impl Static { @@ -14,7 +27,21 @@ impl Static { return (a * b); } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_into(i32, to_i32)] #[byte_size(4)] pub struct S { diff --git a/tests/unit/out/refcount/operator_overloads.rs b/tests/unit/out/refcount/operator_overloads.rs index 6c532c24ef..a363686ead 100644 --- a/tests/unit/out/refcount/operator_overloads.rs +++ b/tests/unit/out/refcount/operator_overloads.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_qualifiers.rs b/tests/unit/out/refcount/operator_qualifiers.rs index 6bf6f81a61..6a62ff4a20 100644 --- a/tests/unit/out/refcount/operator_qualifiers.rs +++ b/tests/unit/out/refcount/operator_qualifiers.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_three_way.rs b/tests/unit/out/refcount/operator_three_way.rs index 9298036a09..3bafe107d9 100644 --- a/tests/unit/out/refcount/operator_three_way.rs +++ b/tests/unit/out/refcount/operator_three_way.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_traits.rs b/tests/unit/out/refcount/operator_traits.rs index 8b372ebfe5..8063037cdb 100644 --- a/tests/unit/out/refcount/operator_traits.rs +++ b/tests/unit/out/refcount/operator_traits.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Lt { #[offset(0)] @@ -22,7 +35,20 @@ impl CppEq for Lt { !(LtImpl::operator_lt(__lhs, __rhs.clone())) && !(LtImpl::operator_lt(__rhs, __lhs.clone())) } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Eq { #[offset(0)] @@ -33,7 +59,20 @@ impl CppEq for Eq { EqImpl::operator_eq(__lhs, __rhs.clone()) } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Cmp { #[offset(0)] @@ -49,7 +88,20 @@ impl CppEq for Cmp { CmpImpl::operator_eq(__lhs, __rhs.clone()) } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Free { #[offset(0)] @@ -71,7 +123,20 @@ pub fn operator_lt_0(a: Ptr, b: Ptr) -> bool { pub fn operator_eq_1(a: Ptr, b: Ptr) -> bool { return ({ a.with(|__s| __s.v) } == { b.with(|__s| __s.v) }); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Wrapped_int_ { #[offset(0)] diff --git a/tests/unit/out/refcount/overload_mangling.rs b/tests/unit/out/refcount/overload_mangling.rs index 0ae65e219a..2273b84403 100644 --- a/tests/unit/out/refcount/overload_mangling.rs +++ b/tests/unit/out/refcount/overload_mangling.rs @@ -19,16 +19,55 @@ pub fn add_1(mut p: Ptr, mut n: i32) { pub fn twice_2(mut n: i32) -> i32 { return (n * 2); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct Access_S_ {} -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] pub base: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Box_ { #[offset(0)] diff --git a/tests/unit/out/refcount/pair_converting_construction.rs b/tests/unit/out/refcount/pair_converting_construction.rs index fcef65dc27..7326756827 100644 --- a/tests/unit/out/refcount/pair_converting_construction.rs +++ b/tests/unit/out/refcount/pair_converting_construction.rs @@ -6,28 +6,84 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct Celsius { #[offset(0)] pub degrees: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_into(i32, to_i32)] #[byte_size(4)] pub struct Meters { #[offset(0)] pub value: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_from(Celsius, construct, ptr)] #[byte_size(4)] pub struct Label { #[offset(0)] pub id: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_from(Celsius, construct_1, ptr)] #[cpp_from_move(Celsius, construct_2, ptr)] #[byte_size(8)] @@ -37,14 +93,41 @@ pub struct Owner { #[offset(4)] pub copied: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_from(Celsius, construct, value)] #[byte_size(4)] pub struct Holder { #[offset(0)] pub value: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct Fallback { @@ -62,27 +145,82 @@ impl Default for Fallback { } } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Counter { #[offset(0)] pub hits: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_from(Counter, construct, mut_ptr)] #[byte_size(4)] pub struct Observer { #[offset(0)] pub seen: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_from(Celsius, construct, ptr)] #[byte_size(4)] pub struct Tag { #[offset(0)] pub code: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_from(Ptr< i8 > , construct, value)] #[byte_size(4)] pub struct Name { diff --git a/tests/unit/out/refcount/pod.rs b/tests/unit/out/refcount/pod.rs index 3cec3b41ca..23f5e50ee3 100644 --- a/tests/unit/out/refcount/pod.rs +++ b/tests/unit/out/refcount/pod.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(12)] pub struct POD { #[offset(0)] diff --git a/tests/unit/out/refcount/pointer_array.rs b/tests/unit/out/refcount/pointer_array.rs index 266a5c06da..0273af457c 100644 --- a/tests/unit/out/refcount/pointer_array.rs +++ b/tests/unit/out/refcount/pointer_array.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(24)] pub struct StackArray { #[offset(0)] diff --git a/tests/unit/out/refcount/pointers.rs b/tests/unit/out/refcount/pointers.rs index b8b20f0d84..24bba58442 100644 --- a/tests/unit/out/refcount/pointers.rs +++ b/tests/unit/out/refcount/pointers.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Test { #[offset(0)] diff --git a/tests/unit/out/refcount/polymorphism.rs b/tests/unit/out/refcount/polymorphism.rs index 4d5ad299ef..1b4a4188a3 100644 --- a/tests/unit/out/refcount/polymorphism.rs +++ b/tests/unit/out/refcount/polymorphism.rs @@ -9,10 +9,36 @@ use std::rc::{Rc, Weak}; pub trait Animal { fn bark(&self) -> bool; } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Dog {} -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Cat {} pub fn main() { diff --git a/tests/unit/out/refcount/ptr_cast_init.rs b/tests/unit/out/refcount/ptr_cast_init.rs index c46b52bef4..7ec3cb2ed4 100644 --- a/tests/unit/out/refcount/ptr_cast_init.rs +++ b/tests/unit/out/refcount/ptr_cast_init.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct header { #[offset(0)] @@ -14,7 +27,20 @@ pub struct header { #[offset(4)] pub size: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct view { #[offset(0)] diff --git a/tests/unit/out/refcount/push_emplace_back.rs b/tests/unit/out/refcount/push_emplace_back.rs index f417b12556..15a7b17381 100644 --- a/tests/unit/out/refcount/push_emplace_back.rs +++ b/tests/unit/out/refcount/push_emplace_back.rs @@ -6,13 +6,38 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Chunk { #[offset(0)] pub data: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct Writer { #[offset(0)] @@ -23,7 +48,15 @@ pub struct Writer { pub chunk: Chunk, } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, MoveAssign, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + CopyAssignable, + Default, )] #[byte_size(48)] pub struct JPEGData { @@ -108,7 +141,20 @@ pub fn self_ref_push_6(mut comps: Ptr>) { comps.with_mut(|__v: &mut Vec| __v.push(a0_clone)) }; } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[cpp_from(i32, construct_1, value)] #[byte_size(8)] pub struct Pair { @@ -277,7 +323,9 @@ pub fn emplace_ref_self_read_13(values: Ptr>) -> Ptr { }) }; } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, MoveAssign)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyConstructible, CopyAssignable, +)] #[byte_size(32)] pub struct Bytes { #[offset(0)] @@ -316,7 +364,18 @@ pub fn emplace_from_element_14(mut v: Ptr>>) { v.with_mut(|__v: &mut Vec>| __v.push(__tmp_15)); }; } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(24)] pub struct Plain { #[offset(0)] @@ -349,7 +408,20 @@ thread_local!( pub static all_counted_16: Value>> = Rc::new(RefCell::new(Ptr::>::null())); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Counted { #[offset(0)] @@ -606,27 +678,25 @@ fn main_0() -> i32 { ); return 0; } -pub trait BytesImpl { - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; -} -impl BytesImpl for Ptr { - fn move_from(&self, _a0: Ptr) { - field!((*self), v).write(field!(_a0, v).with_mut(std::mem::take)); - field!((*self), b).write(Box::new(std::array::from_fn::<_, 3, _>(|__i: usize| { - (*_a0.upgrade().deref()).b[(__i) as usize] - }))); - } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), v).with_mut(|__b0| { +impl MoveAssignable for Bytes { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), v).with_mut(|__b0| { (*__b0) = field!(_a0, v).with_mut(std::mem::take); }); { - let mut __tmp_13 = { (array_field_ptr!((*self), b)).to_any() }; + let mut __tmp_13 = { (array_field_ptr!((*this), b)).to_any() }; __tmp_13.memcpy(&(array_field_ptr!(_a0, b)).to_any(), 3_usize); (__tmp_13).clone() }; - return (*self).clone(); + return (*this).clone(); + } +} +impl MoveConstructible for Bytes { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), v).write(field!(_a0, v).with_mut(std::mem::take)); + field!((*this), b).write(Box::new(std::array::from_fn::<_, 3, _>(|__i: usize| { + (*_a0.upgrade().deref()).b[(__i) as usize] + }))); } } pub trait CountedImpl { @@ -642,23 +712,21 @@ impl CountedImpl for Ptr { ); } } -pub trait JPEGDataImpl { - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; -} -impl JPEGDataImpl for Ptr { - fn move_from(&self, _a0: Ptr) { - field!((*self), com_data).write(field!(_a0, com_data).with_mut(std::mem::take)); - field!((*self), app_data).write(field!(_a0, app_data).with_mut(std::mem::take)); - } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), com_data).with_mut(|__b0| { +impl MoveAssignable for JPEGData { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), com_data).with_mut(|__b0| { (*__b0) = field!(_a0, com_data).with_mut(std::mem::take); }); - field!((*self), app_data).with_mut(|__b0| { + field!((*this), app_data).with_mut(|__b0| { (*__b0) = field!(_a0, app_data).with_mut(std::mem::take); }); - return (*self).clone(); + return (*this).clone(); + } +} +impl MoveConstructible for JPEGData { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), com_data).write(field!(_a0, com_data).with_mut(std::mem::take)); + field!((*this), app_data).write(field!(_a0, app_data).with_mut(std::mem::take)); } } pub trait PairImpl { diff --git a/tests/unit/out/refcount/random.rs b/tests/unit/out/refcount/random.rs index e6df9f83f1..bc71a9a03a 100644 --- a/tests/unit/out/refcount/random.rs +++ b/tests/unit/out/refcount/random.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(72)] pub struct Pair { #[offset(0)] @@ -51,7 +62,20 @@ impl Default for Pair { pub fn zero_0() -> i32 { return 0; } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct X1 {} pub fn foo_1(mut x1: i32, x2: Ptr, mut x3: Ptr, p2: Ptr, mut p3: Ptr) {} diff --git a/tests/unit/out/refcount/reference_wrapper.rs b/tests/unit/out/refcount/reference_wrapper.rs index 1faada9efa..740d028c37 100644 --- a/tests/unit/out/refcount/reference_wrapper.rs +++ b/tests/unit/out/refcount/reference_wrapper.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Point { #[offset(0)] diff --git a/tests/unit/out/refcount/references.rs b/tests/unit/out/refcount/references.rs index af7cbe7a47..c3428f7a2e 100644 --- a/tests/unit/out/refcount/references.rs +++ b/tests/unit/out/refcount/references.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(16)] pub struct Pair { #[offset(0)] @@ -29,7 +40,19 @@ impl Default for Pair { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct Nested { #[offset(0)] diff --git a/tests/unit/out/refcount/refs_as_args.rs b/tests/unit/out/refcount/refs_as_args.rs index 27bd3854be..d2c12bac93 100644 --- a/tests/unit/out/refcount/refs_as_args.rs +++ b/tests/unit/out/refcount/refs_as_args.rs @@ -30,7 +30,20 @@ pub fn more_refs_0(x1: i32, x2: i32, r1: Ptr, r2: Ptr) { }; r1.write((rx2.read())); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Val { #[offset(0)] diff --git a/tests/unit/out/refcount/reinterpret_cast_ptr_cmp.rs b/tests/unit/out/refcount/reinterpret_cast_ptr_cmp.rs index 16a49ba0ec..96edfc8562 100644 --- a/tests/unit/out/refcount/reinterpret_cast_ptr_cmp.rs +++ b/tests/unit/out/refcount/reinterpret_cast_ptr_cmp.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct S { #[offset(0)] @@ -14,7 +27,18 @@ pub struct S { #[offset(4)] pub y: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(28)] pub struct W { #[offset(0)] @@ -34,7 +58,18 @@ impl Default for W { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(32)] pub struct P { #[offset(0)] diff --git a/tests/unit/out/refcount/reinterpret_cast_struct.rs b/tests/unit/out/refcount/reinterpret_cast_struct.rs index e823d6b293..969bf1b61f 100644 --- a/tests/unit/out/refcount/reinterpret_cast_struct.rs +++ b/tests/unit/out/refcount/reinterpret_cast_struct.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Point { #[offset(0)] diff --git a/tests/unit/out/refcount/reinterpret_cast_struct_to_struct.rs b/tests/unit/out/refcount/reinterpret_cast_struct_to_struct.rs index f2f3dc1419..8e3f0aa6fa 100644 --- a/tests/unit/out/refcount/reinterpret_cast_struct_to_struct.rs +++ b/tests/unit/out/refcount/reinterpret_cast_struct_to_struct.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Point { #[offset(0)] @@ -14,7 +27,20 @@ pub struct Point { #[offset(4)] pub y: u32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Pair { #[offset(0)] diff --git a/tests/unit/out/refcount/reserved_keywords.rs b/tests/unit/out/refcount/reserved_keywords.rs index 93b8d77d2a..9290260779 100644 --- a/tests/unit/out/refcount/reserved_keywords.rs +++ b/tests/unit/out/refcount/reserved_keywords.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(152)] pub struct S { #[offset(0)] @@ -86,13 +99,39 @@ pub struct S { #[offset(148)] pub vec_: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct type_ { #[offset(0)] pub v: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct loop_ { #[offset(0)] diff --git a/tests/unit/out/refcount/return_move.rs b/tests/unit/out/refcount/return_move.rs index fa754bd11b..64a1adceeb 100644 --- a/tests/unit/out/refcount/return_move.rs +++ b/tests/unit/out/refcount/return_move.rs @@ -6,7 +6,19 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct node { #[offset(0)] @@ -15,7 +27,19 @@ pub struct node { #[byte_size(8)] pub next: Ptr, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct pair_t { #[offset(0)] diff --git a/tests/unit/out/refcount/rule_of_five.rs b/tests/unit/out/refcount/rule_of_five.rs index 50fd3a28b2..04f1239558 100644 --- a/tests/unit/out/refcount/rule_of_five.rs +++ b/tests/unit/out/refcount/rule_of_five.rs @@ -15,18 +15,7 @@ thread_local!( thread_local!( pub static moves_2: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - MoveCtor, - CppFrom, - CopyAssign, - MoveAssign, - Destructible, -)] +#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Destructible)] #[cpp_from(i32, construct, value)] #[byte_size(20)] pub struct Buffer { @@ -44,7 +33,7 @@ impl Clone for Buffer { size: self.size.clone(), })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - BufferImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -63,7 +52,7 @@ pub fn make_3(mut size: i32) -> Buffer { std::mem::DropGuard::new(b.clone(), |__p| Destructible::destroy(__p.as_pointer())); return { let __v: Value = Rc::new(RefCell::new(::zero_init())); - BufferImpl::move_from(&__v.as_pointer(), { b.as_pointer() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { b.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; } @@ -82,7 +71,7 @@ fn main_0() -> i32 { std::mem::DropGuard::new(a.clone(), |__p| Destructible::destroy(__p.as_pointer())); let b: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - BufferImpl::copy_from(&__v.as_pointer(), { a.as_pointer() }); + CopyConstructible::copy_constructor(&__v.as_pointer(), { a.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let _dtor_b = @@ -95,7 +84,7 @@ fn main_0() -> i32 { assert!(((array_elem!(a.as_pointer(), data, 0).read()) == 0)); let c: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - BufferImpl::move_from(&__v.as_pointer(), { a.as_pointer() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { a.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let _dtor_c = @@ -112,18 +101,18 @@ fn main_0() -> i32 { let _dtor_d = std::mem::DropGuard::new(d.clone(), |__p| Destructible::destroy(__p.as_pointer())); assert!(({ (*d.borrow()).size } == 2) && (moves_2.with(|rc| *rc.borrow()) == 2)); - ({ BufferImpl::copy_assign(&d.as_pointer(), b.as_pointer()) }); + ({ CopyAssignable::copy_assign(&d.as_pointer(), b.as_pointer()) }); assert!( (({ (*d.borrow()).size } == 4) && ((array_elem!(d.as_pointer(), data, 0).read()) == 100)) && (copies_1.with(|rc| *rc.borrow()) == 2) ); - ({ BufferImpl::move_assign(&d.as_pointer(), c.as_pointer()) }); + ({ MoveAssignable::move_assign(&d.as_pointer(), c.as_pointer()) }); assert!( (((array_elem!(d.as_pointer(), data, 0).read()) == 0) && ({ (*c.borrow()).size } == 0)) && (moves_2.with(|rc| *rc.borrow()) == 3) ); - ({ BufferImpl::move_assign(&d.as_pointer(), d.as_pointer()) }); + ({ MoveAssignable::move_assign(&d.as_pointer(), d.as_pointer()) }); assert!(({ (*d.borrow()).size } == 4) && (moves_2.with(|rc| *rc.borrow()) == 3)); } assert!((alive_0.with(|rc| *rc.borrow()) == 0)); @@ -132,10 +121,6 @@ fn main_0() -> i32 { pub trait BufferImpl { fn construct(&self, size: i32); fn destructor(&self); - fn copy_from(&self, o: Ptr); - fn move_from(&self, o: Ptr); - fn copy_assign(&self, o: Ptr) -> Ptr; - fn move_assign(&self, o: Ptr) -> Ptr; } impl BufferImpl for Ptr { fn construct(&self, mut size: i32) { @@ -155,73 +140,81 @@ impl BufferImpl for Ptr { fn destructor(&self) { (*alive_0.with(Value::clone).borrow_mut()).prefix_dec(); } - fn copy_from(&self, o: Ptr) { - field!((*self), data).write((0..4).map(|_| 0_i32).collect::>()); - field!((*self), size).write(o.with(|__s| __s.size)); +} +impl CopyAssignable for Buffer { + fn copy_assign(this: &Ptr, o: Ptr) -> Ptr { + if ((*this) == (o)) { + return (*this).clone(); + } + field!((*this), size).write(o.with(|__s| __s.size)); { let mut i: i32 = 0; 'loop_: while (i < 4) { 'for_body: { - array_elem!((*self), data, i).write((array_elem!(o, data, i).read())); + array_elem!((*this), data, i).write((array_elem!(o, data, i).read())); } i.prefix_inc(); } } - (*alive_0.with(Value::clone).borrow_mut()).prefix_inc(); (*copies_1.with(Value::clone).borrow_mut()).prefix_inc(); + return (*this).clone(); } - fn move_from(&self, o: Ptr) { - field!((*self), data).write((0..4).map(|_| 0_i32).collect::>()); - field!((*self), size).write(o.with(|__s| __s.size)); +} +impl CopyConstructible for Buffer { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), data).write((0..4).map(|_| 0_i32).collect::>()); + field!((*this), size).write(o.with(|__s| __s.size)); { let mut i: i32 = 0; 'loop_: while (i < 4) { 'for_body: { - array_elem!((*self), data, i).write((array_elem!(o, data, i).read())); - array_elem!(o, data, i).write(-1_i32); + array_elem!((*this), data, i).write((array_elem!(o, data, i).read())); } i.prefix_inc(); } } - field!(o, size).write(0); (*alive_0.with(Value::clone).borrow_mut()).prefix_inc(); - (*moves_2.with(Value::clone).borrow_mut()).prefix_inc(); + (*copies_1.with(Value::clone).borrow_mut()).prefix_inc(); } - fn copy_assign(&self, o: Ptr) -> Ptr { - if ((*self) == (o)) { - return (*self).clone(); +} +impl MoveAssignable for Buffer { + fn move_assign(this: &Ptr, o: Ptr) -> Ptr { + if ((*this) == (o)) { + return (*this).clone(); } - field!((*self), size).write(o.with(|__s| __s.size)); + field!((*this), size).write(o.with(|__s| __s.size)); { let mut i: i32 = 0; 'loop_: while (i < 4) { 'for_body: { - array_elem!((*self), data, i).write((array_elem!(o, data, i).read())); + array_elem!((*this), data, i).write((array_elem!(o, data, i).read())); + array_elem!(o, data, i).write(-1_i32); } i.prefix_inc(); } } - (*copies_1.with(Value::clone).borrow_mut()).prefix_inc(); - return (*self).clone(); + field!(o, size).write(0); + (*moves_2.with(Value::clone).borrow_mut()).prefix_inc(); + return (*this).clone(); } - fn move_assign(&self, o: Ptr) -> Ptr { - if ((*self) == (o)) { - return (*self).clone(); - } - field!((*self), size).write(o.with(|__s| __s.size)); +} +impl MoveConstructible for Buffer { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), data).write((0..4).map(|_| 0_i32).collect::>()); + field!((*this), size).write(o.with(|__s| __s.size)); { let mut i: i32 = 0; 'loop_: while (i < 4) { 'for_body: { - array_elem!((*self), data, i).write((array_elem!(o, data, i).read())); + array_elem!((*this), data, i).write((array_elem!(o, data, i).read())); array_elem!(o, data, i).write(-1_i32); } i.prefix_inc(); } } field!(o, size).write(0); + (*alive_0.with(Value::clone).borrow_mut()).prefix_inc(); (*moves_2.with(Value::clone).borrow_mut()).prefix_inc(); - return (*self).clone(); } } pub fn __cpp2rust_init_globals() { diff --git a/tests/unit/out/refcount/rule_of_three.rs b/tests/unit/out/refcount/rule_of_three.rs index 1b3279006d..81884ecd78 100644 --- a/tests/unit/out/refcount/rule_of_three.rs +++ b/tests/unit/out/refcount/rule_of_three.rs @@ -13,7 +13,15 @@ thread_local!( pub static copies_1: Value = Rc::new(RefCell::new(0)); ); #[derive( - Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, CopyAssign, Destructible, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + MoveConstructible, + MoveAssignable, )] #[cpp_from(i32, construct, value)] #[byte_size(20)] @@ -32,7 +40,7 @@ impl Clone for Buffer { size: self.size.clone(), })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - BufferImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -69,7 +77,7 @@ fn main_0() -> i32 { std::mem::DropGuard::new(a.clone(), |__p| Destructible::destroy(__p.as_pointer())); let b: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - BufferImpl::copy_from(&__v.as_pointer(), { a.as_pointer() }); + CopyConstructible::copy_constructor(&__v.as_pointer(), { a.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let _dtor_b = @@ -84,18 +92,18 @@ fn main_0() -> i32 { })); let _dtor_c = std::mem::DropGuard::new(c.clone(), |__p| Destructible::destroy(__p.as_pointer())); - ({ BufferImpl::copy_assign(&c.as_pointer(), a.as_pointer()) }); + ({ CopyAssignable::copy_assign(&c.as_pointer(), a.as_pointer()) }); assert!( ({ (*c.borrow()).size } == 4) && ((array_elem!(c.as_pointer(), data, 3).read()) == 3) ); assert!((alive_0.with(|rc| *rc.borrow()) == 3) && (copies_1.with(|rc| *rc.borrow()) == 2)); - ({ BufferImpl::copy_assign(&c.as_pointer(), c.as_pointer()) }); + ({ CopyAssignable::copy_assign(&c.as_pointer(), c.as_pointer()) }); assert!((copies_1.with(|rc| *rc.borrow()) == 2)); assert!((({ sum_2(a.as_pointer(),) }) == 6)); assert!((({ sum_2(b.as_pointer(),) }) == 106)); let d: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - BufferImpl::copy_from(&__v.as_pointer(), { a.as_pointer() }); + CopyConstructible::copy_constructor(&__v.as_pointer(), { a.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let _dtor_d = @@ -104,7 +112,7 @@ fn main_0() -> i32 { assert!( ({ (*a.borrow()).size } == 4) && ((array_elem!(a.as_pointer(), data, 3).read()) == 3) ); - ({ BufferImpl::copy_assign(&d.as_pointer(), b.as_pointer()) }); + ({ CopyAssignable::copy_assign(&d.as_pointer(), b.as_pointer()) }); assert!((copies_1.with(|rc| *rc.borrow()) == 4)); assert!( ((array_elem!(b.as_pointer(), data, 0).read()) == 100) @@ -117,8 +125,6 @@ fn main_0() -> i32 { pub trait BufferImpl { fn construct(&self, size: i32); fn destructor(&self); - fn copy_from(&self, o: Ptr); - fn copy_assign(&self, o: Ptr) -> Ptr; } impl BufferImpl for Ptr { fn construct(&self, mut size: i32) { @@ -138,37 +144,41 @@ impl BufferImpl for Ptr { fn destructor(&self) { (*alive_0.with(Value::clone).borrow_mut()).prefix_dec(); } - fn copy_from(&self, o: Ptr) { - field!((*self), data).write((0..4).map(|_| 0_i32).collect::>()); - field!((*self), size).write(o.with(|__s| __s.size)); +} +impl CopyAssignable for Buffer { + fn copy_assign(this: &Ptr, o: Ptr) -> Ptr { + if ((*this) == (o)) { + return (*this).clone(); + } + field!((*this), size).write(o.with(|__s| __s.size)); { let mut i: i32 = 0; 'loop_: while (i < 4) { 'for_body: { - array_elem!((*self), data, i).write((array_elem!(o, data, i).read())); + array_elem!((*this), data, i).write((array_elem!(o, data, i).read())); } i.prefix_inc(); } } - (*alive_0.with(Value::clone).borrow_mut()).prefix_inc(); (*copies_1.with(Value::clone).borrow_mut()).prefix_inc(); + return (*this).clone(); } - fn copy_assign(&self, o: Ptr) -> Ptr { - if ((*self) == (o)) { - return (*self).clone(); - } - field!((*self), size).write(o.with(|__s| __s.size)); +} +impl CopyConstructible for Buffer { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), data).write((0..4).map(|_| 0_i32).collect::>()); + field!((*this), size).write(o.with(|__s| __s.size)); { let mut i: i32 = 0; 'loop_: while (i < 4) { 'for_body: { - array_elem!((*self), data, i).write((array_elem!(o, data, i).read())); + array_elem!((*this), data, i).write((array_elem!(o, data, i).read())); } i.prefix_inc(); } } + (*alive_0.with(Value::clone).borrow_mut()).prefix_inc(); (*copies_1.with(Value::clone).borrow_mut()).prefix_inc(); - return (*self).clone(); } } pub fn __cpp2rust_init_globals() { diff --git a/tests/unit/out/refcount/rvalue_rule_arg_move.rs b/tests/unit/out/refcount/rvalue_rule_arg_move.rs index 1355ce2156..c4a02cf356 100644 --- a/tests/unit/out/refcount/rvalue_rule_arg_move.rs +++ b/tests/unit/out/refcount/rvalue_rule_arg_move.rs @@ -13,7 +13,7 @@ thread_local!( pub static moves_1: Value = Rc::new(RefCell::new(0)); ); #[derive( - Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, CppFrom, CopyAssign, Default, + Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, MoveAssignable, Default, )] #[cpp_from(i32, construct, value)] #[byte_size(4)] @@ -25,7 +25,7 @@ impl Clone for Elem { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(Elem { v: self.v.clone() })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - ElemImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -55,7 +55,7 @@ fn main_0() -> i32 { let mut __tmp_0 = { >::from(v.decay().end()) }; (*v.borrow_mut()).insert(__tmp_0.index(), { let __v: Value = Rc::new(RefCell::new(::zero_init())); - ElemImpl::move_from(&__v.as_pointer(), { a.as_pointer() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { a.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }); (__tmp_0).clone() @@ -80,26 +80,29 @@ fn main_0() -> i32 { } pub trait ElemImpl { fn construct(&self, v: i32); - fn copy_from(&self, o: Ptr); - fn move_from(&self, o: Ptr); - fn copy_assign(&self, _a0: Ptr) -> Ptr; } impl ElemImpl for Ptr { fn construct(&self, mut v: i32) { field!((*self), v).write(v); } - fn copy_from(&self, o: Ptr) { - field!((*self), v).write(o.with(|__s| __s.v)); +} +impl CopyAssignable for Elem { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), v).write(_a0.with(|__s| __s.v)); + return (*this).clone(); + } +} +impl CopyConstructible for Elem { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); } - fn move_from(&self, o: Ptr) { - field!((*self), v).write(o.with(|__s| __s.v)); +} +impl MoveConstructible for Elem { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); (*moves_1.with(Value::clone).borrow_mut()).prefix_inc(); } - fn copy_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), v).write(_a0.with(|__s| __s.v)); - return (*self).clone(); - } } pub fn __cpp2rust_init_globals() { let _ = copies_0.with(|_| ()); diff --git a/tests/unit/out/refcount/rvalue_struct.rs b/tests/unit/out/refcount/rvalue_struct.rs index a4211a9a33..1a3fe64d2e 100644 --- a/tests/unit/out/refcount/rvalue_struct.rs +++ b/tests/unit/out/refcount/rvalue_struct.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/scalar_builtin_construct_destruct.rs b/tests/unit/out/refcount/scalar_builtin_construct_destruct.rs index 03011be665..155b7bcd9c 100644 --- a/tests/unit/out/refcount/scalar_builtin_construct_destruct.rs +++ b/tests/unit/out/refcount/scalar_builtin_construct_destruct.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Pod { #[offset(0)] diff --git a/tests/unit/out/refcount/self_referencing_initializer.rs b/tests/unit/out/refcount/self_referencing_initializer.rs index cefaaf414b..1dddcfe426 100644 --- a/tests/unit/out/refcount/self_referencing_initializer.rs +++ b/tests/unit/out/refcount/self_referencing_initializer.rs @@ -6,14 +6,38 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct list_head { #[offset(0)] #[byte_size(8)] pub next: Ptr, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct node { #[offset(0)] @@ -22,7 +46,18 @@ pub struct node { #[byte_size(8)] pub value_ptr: Ptr, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(16)] pub struct node_with_defaults { #[offset(0)] diff --git a/tests/unit/out/refcount/size_t_static_member.rs b/tests/unit/out/refcount/size_t_static_member.rs index 10d3177ae3..7e781b899f 100644 --- a/tests/unit/out/refcount/size_t_static_member.rs +++ b/tests/unit/out/refcount/size_t_static_member.rs @@ -9,13 +9,39 @@ use std::rc::{Rc, Weak}; thread_local!( pub static c_0: Value = Rc::new(RefCell::new(5_usize)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct S {} thread_local!( pub static table_size_1: Value = Rc::new(RefCell::new(256_usize)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct Table_char_ {} pub fn main() { diff --git a/tests/unit/out/refcount/size_t_template_param.rs b/tests/unit/out/refcount/size_t_template_param.rs index 488e0e08f6..76db83e3c6 100644 --- a/tests/unit/out/refcount/size_t_template_param.rs +++ b/tests/unit/out/refcount/size_t_template_param.rs @@ -10,14 +10,42 @@ pub fn array_ref_0(a: Ptr) -> u64 { elem!(a, 0).write({ (elem!(a, 0).read()).wrapping_add(1_u64) }); return (elem!(a, (3_u64 as u64).wrapping_sub(1_u64)).read()); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_from(Ptr< u64 > , construct, value)] #[byte_size(8)] pub struct PtrCtor_unsigned_long_ { #[offset(0)] pub v: u64, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_from(u64, construct, ptr)] #[byte_size(8)] pub struct RefCtor_unsigned_long_ { diff --git a/tests/unit/out/refcount/sort_no_copy.rs b/tests/unit/out/refcount/sort_no_copy.rs index 7c10ca9b49..ac120137c8 100644 --- a/tests/unit/out/refcount/sort_no_copy.rs +++ b/tests/unit/out/refcount/sort_no_copy.rs @@ -9,9 +9,7 @@ use std::rc::{Rc, Weak}; thread_local!( pub static copies_0: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, CppFrom, CopyAssign, MoveAssign, -)] +#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom)] #[cpp_from(i32, construct_1, value)] #[byte_size(4)] pub struct Tracked { @@ -33,7 +31,7 @@ impl Clone for Tracked { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(Tracked { v: self.v.clone() })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - TrackedImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -54,9 +52,7 @@ pub fn operator_lt_1(a: Ptr, b: Ptr) -> bool { pub fn greater_2(a: Ptr, b: Ptr) -> bool { return ({ a.with(|__s| __s.v) } > { b.with(|__s| __s.v) }); } -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, MoveCtor, CppFrom, MoveAssign, Default, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Default)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct MoveOnly { @@ -78,7 +74,15 @@ pub fn operator_lt_3(a: Ptr, b: Ptr) -> bool { return ({ a.with(|__s| __s.v) } < { b.with(|__s| __s.v) }); } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, MoveAssign, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + CopyAssignable, + Default, )] #[byte_size(24)] pub struct Bag { @@ -551,45 +555,41 @@ fn main_0() -> i32 { ); return copies_0.with(|rc| *rc.borrow()); } -pub trait BagImpl { - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; -} -impl BagImpl for Ptr { - fn move_from(&self, _a0: Ptr) { - field!((*self), items).write(field!(_a0, items).with_mut(std::mem::take)); - } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), items).with_mut(|__b0| { +impl MoveAssignable for Bag { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), items).with_mut(|__b0| { (*__b0) = field!(_a0, items).with_mut(std::mem::take); }); - return (*self).clone(); + return (*this).clone(); + } +} +impl MoveConstructible for Bag { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), items).write(field!(_a0, items).with_mut(std::mem::take)); } } pub trait MoveOnlyImpl { fn construct(&self, v: i32); - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; } impl MoveOnlyImpl for Ptr { fn construct(&self, mut v: i32) { field!((*self), v).write(v); } - fn move_from(&self, _a0: Ptr) { - field!((*self), v).write({ (*_a0.upgrade().deref()).v }); +} +impl MoveAssignable for MoveOnly { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), v).write({ (*_a0.upgrade().deref()).v }); + return (*this).clone(); } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), v).write({ (*_a0.upgrade().deref()).v }); - return (*self).clone(); +} +impl MoveConstructible for MoveOnly { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), v).write({ (*_a0.upgrade().deref()).v }); } } pub trait TrackedImpl { fn construct_2(&self); fn construct_1(&self, v: i32); - fn copy_from(&self, o: Ptr); - fn move_from(&self, o: Ptr); - fn copy_assign(&self, o: Ptr) -> Ptr; - fn move_assign(&self, o: Ptr) -> Ptr; } impl TrackedImpl for Ptr { fn construct_2(&self) { @@ -598,21 +598,29 @@ impl TrackedImpl for Ptr { fn construct_1(&self, mut v: i32) { field!((*self), v).write(v); } - fn copy_from(&self, o: Ptr) { - field!((*self), v).write(o.with(|__s| __s.v)); +} +impl CopyAssignable for Tracked { + fn copy_assign(this: &Ptr, o: Ptr) -> Ptr { + field!((*this), v).write(o.with(|__s| __s.v)); (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); + return (*this).clone(); } - fn move_from(&self, o: Ptr) { - field!((*self), v).write(o.with(|__s| __s.v)); - } - fn copy_assign(&self, o: Ptr) -> Ptr { - field!((*self), v).write(o.with(|__s| __s.v)); +} +impl CopyConstructible for Tracked { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); - return (*self).clone(); } - fn move_assign(&self, o: Ptr) -> Ptr { - field!((*self), v).write(o.with(|__s| __s.v)); - return (*self).clone(); +} +impl MoveAssignable for Tracked { + fn move_assign(this: &Ptr, o: Ptr) -> Ptr { + field!((*this), v).write(o.with(|__s| __s.v)); + return (*this).clone(); + } +} +impl MoveConstructible for Tracked { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); } } pub fn __cpp2rust_init_globals() { diff --git a/tests/unit/out/refcount/static_local.rs b/tests/unit/out/refcount/static_local.rs index 388d6c7496..c723620116 100644 --- a/tests/unit/out/refcount/static_local.rs +++ b/tests/unit/out/refcount/static_local.rs @@ -33,7 +33,20 @@ pub fn from_local_class_6() -> i32 { thread_local!( static x_7: Value = Rc::new(RefCell::new(3)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct S_8 {} pub fn main() { diff --git a/tests/unit/out/refcount/static_var_in_class.rs b/tests/unit/out/refcount/static_var_in_class.rs index ccae0ec716..2801efac3b 100644 --- a/tests/unit/out/refcount/static_var_in_class.rs +++ b/tests/unit/out/refcount/static_var_in_class.rs @@ -9,7 +9,20 @@ use std::rc::{Rc, Weak}; thread_local!( static inner_const_0: Value = Rc::new(RefCell::new(1)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct C {} thread_local!( @@ -17,7 +30,20 @@ thread_local!( ); pub type anon_3 = u32; pub const anon_3_kValue: anon_3 = 3; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct S {} impl S { diff --git a/tests/unit/out/refcount/stdcopy.rs b/tests/unit/out/refcount/stdcopy.rs index 18e5dd694b..37ad502264 100644 --- a/tests/unit/out/refcount/stdcopy.rs +++ b/tests/unit/out/refcount/stdcopy.rs @@ -6,7 +6,21 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct Degrees { diff --git a/tests/unit/out/refcount/strdup.rs b/tests/unit/out/refcount/strdup.rs index 11e6da6767..29bb66ec9e 100644 --- a/tests/unit/out/refcount/strdup.rs +++ b/tests/unit/out/refcount/strdup.rs @@ -6,7 +6,19 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct record { #[offset(0)] diff --git a/tests/unit/out/refcount/string_literal_ptr_init.rs b/tests/unit/out/refcount/string_literal_ptr_init.rs index f37832da8a..6421fb52fa 100644 --- a/tests/unit/out/refcount/string_literal_ptr_init.rs +++ b/tests/unit/out/refcount/string_literal_ptr_init.rs @@ -6,7 +6,19 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(24)] pub struct label { #[offset(0)] diff --git a/tests/unit/out/refcount/string_substr.rs b/tests/unit/out/refcount/string_substr.rs index 1139944553..b2873d4c4f 100644 --- a/tests/unit/out/refcount/string_substr.rs +++ b/tests/unit/out/refcount/string_substr.rs @@ -6,7 +6,19 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Text { #[offset(0)] diff --git a/tests/unit/out/refcount/struct_2d_array_field.rs b/tests/unit/out/refcount/struct_2d_array_field.rs index 48508b8750..dc55374db6 100644 --- a/tests/unit/out/refcount/struct_2d_array_field.rs +++ b/tests/unit/out/refcount/struct_2d_array_field.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(40)] pub struct table { #[offset(0)] diff --git a/tests/unit/out/refcount/struct_ctor.rs b/tests/unit/out/refcount/struct_ctor.rs index 08388d9416..954baef67d 100644 --- a/tests/unit/out/refcount/struct_ctor.rs +++ b/tests/unit/out/refcount/struct_ctor.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct StructWithCtor { #[offset(0)] @@ -17,14 +30,40 @@ pub struct StructWithCtor { pub fn foo_0(x: Ptr) -> Ptr { return (x).clone(); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct Value_ { #[offset(0)] pub v: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(8)] pub struct Ptr_ { #[offset(0)] diff --git a/tests/unit/out/refcount/struct_default_ctor.rs b/tests/unit/out/refcount/struct_default_ctor.rs index 419500f560..b424ef89d4 100644 --- a/tests/unit/out/refcount/struct_default_ctor.rs +++ b/tests/unit/out/refcount/struct_default_ctor.rs @@ -6,7 +6,19 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(8)] pub struct S { #[offset(0)] @@ -25,13 +37,37 @@ impl Default for S { } } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Declared { #[offset(0)] pub v: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(16)] pub struct Holder { #[offset(0)] @@ -51,7 +87,19 @@ impl Default for Holder { thread_local!( pub static kInit_0: Value = Rc::new(RefCell::new(3)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(4)] pub struct FromStatic { #[offset(0)] diff --git a/tests/unit/out/refcount/struct_member_array_adjacency.rs b/tests/unit/out/refcount/struct_member_array_adjacency.rs index 9392526a17..20f1ae7918 100644 --- a/tests/unit/out/refcount/struct_member_array_adjacency.rs +++ b/tests/unit/out/refcount/struct_member_array_adjacency.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(32)] pub struct pair { #[offset(0)] diff --git a/tests/unit/out/refcount/struct_ptr.rs b/tests/unit/out/refcount/struct_ptr.rs index c34fbc8c35..1f8f6c16c5 100644 --- a/tests/unit/out/refcount/struct_ptr.rs +++ b/tests/unit/out/refcount/struct_ptr.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct XX { #[offset(0)] diff --git a/tests/unit/out/refcount/structured_binding_copy_ctor.rs b/tests/unit/out/refcount/structured_binding_copy_ctor.rs index f98ca642eb..baf5cd52dc 100644 --- a/tests/unit/out/refcount/structured_binding_copy_ctor.rs +++ b/tests/unit/out/refcount/structured_binding_copy_ctor.rs @@ -9,7 +9,16 @@ use std::rc::{Rc, Weak}; thread_local!( pub static copies_0: Value = Rc::new(RefCell::new(0)); ); -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyAssign, Default)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + MoveConstructible, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Counted { #[offset(0)] @@ -24,7 +33,7 @@ impl Clone for Counted { y: self.y.clone(), })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - CountedImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -47,7 +56,7 @@ fn main_0() -> i32 { })); let __decomp_2: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - CountedImpl::copy_from(&__v.as_pointer(), { s.as_pointer() }); + CopyConstructible::copy_constructor(&__v.as_pointer(), { s.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); assert!((copies_0.with(|rc| *rc.borrow()) == 1)); @@ -68,23 +77,25 @@ fn main_0() -> i32 { } pub trait CountedImpl { fn construct(&self, x: i32, y: i32); - fn copy_from(&self, other: Ptr); - fn copy_assign(&self, _a0: Ptr) -> Ptr; } impl CountedImpl for Ptr { fn construct(&self, mut x: i32, mut y: i32) { field!((*self), x).write(x); field!((*self), y).write(y); } - fn copy_from(&self, other: Ptr) { - field!((*self), x).write((other.with(|__s| __s.x) * 2)); - field!((*self), y).write((other.with(|__s| __s.y) * 2)); - (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); +} +impl CopyAssignable for Counted { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), x).write(_a0.with(|__s| __s.x)); + field!((*this), y).write(_a0.with(|__s| __s.y)); + return (*this).clone(); } - fn copy_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), x).write(_a0.with(|__s| __s.x)); - field!((*self), y).write(_a0.with(|__s| __s.y)); - return (*self).clone(); +} +impl CopyConstructible for Counted { + fn copy_constructor(this: &Ptr, other: Ptr) { + field!((*this), x).write((other.with(|__s| __s.x) * 2)); + field!((*this), y).write((other.with(|__s| __s.y) * 2)); + (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); } } pub fn __cpp2rust_init_globals() { diff --git a/tests/unit/out/refcount/structured_binding_element_ctor.rs b/tests/unit/out/refcount/structured_binding_element_ctor.rs index f73a2d0c41..40dc29f789 100644 --- a/tests/unit/out/refcount/structured_binding_element_ctor.rs +++ b/tests/unit/out/refcount/structured_binding_element_ctor.rs @@ -12,7 +12,17 @@ thread_local!( thread_local!( pub static moves_1: Value = Rc::new(RefCell::new(0)); ); -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, CppFrom, Default)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct Elem { @@ -23,11 +33,22 @@ impl Clone for Elem { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(Elem { v: self.v.clone() })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - ElemImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Two { #[offset(0)] @@ -82,7 +103,7 @@ fn main_0() -> i32 { assert!(({ (*t.borrow()).a.v } == 50)); let __decomp_5: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - TwoImpl::move_from(&__v.as_pointer(), { t.as_pointer() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { t.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); assert!((moves_1.with(|rc| *rc.borrow()) == (base_moves + 2))); @@ -121,36 +142,35 @@ fn main_0() -> i32 { } pub trait ElemImpl { fn construct(&self, v: i32); - fn copy_from(&self, other: Ptr); - fn move_from(&self, other: Ptr); } impl ElemImpl for Ptr { fn construct(&self, mut v: i32) { field!((*self), v).write(v); } - fn copy_from(&self, other: Ptr) { - field!((*self), v).write((other.with(|__s| __s.v) + 100)); +} +impl CopyConstructible for Elem { + fn copy_constructor(this: &Ptr, other: Ptr) { + field!((*this), v).write((other.with(|__s| __s.v) + 100)); (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); } - fn move_from(&self, other: Ptr) { - field!((*self), v).write((other.with(|__s| __s.v) + 1000)); +} +impl MoveConstructible for Elem { + fn move_constructor(this: &Ptr, other: Ptr) { + field!((*this), v).write((other.with(|__s| __s.v) + 1000)); field!(other, v).write(-1_i32); (*moves_1.with(Value::clone).borrow_mut()).prefix_inc(); } } -pub trait TwoImpl { - fn move_from(&self, _a0: Ptr); -} -impl TwoImpl for Ptr { - fn move_from(&self, _a0: Ptr) { - field!((*self), a).write({ +impl MoveConstructible for Two { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), a).write({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - ElemImpl::move_from(&__v.as_pointer(), { field_ptr!(_a0, a) }); + MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, a) }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }); - field!((*self), b).write({ + field!((*this), b).write({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - ElemImpl::move_from(&__v.as_pointer(), { field_ptr!(_a0, b) }); + MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, b) }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }); } diff --git a/tests/unit/out/refcount/structured_binding_move_ctor.rs b/tests/unit/out/refcount/structured_binding_move_ctor.rs index 8fce5a265f..f7dbdd9854 100644 --- a/tests/unit/out/refcount/structured_binding_move_ctor.rs +++ b/tests/unit/out/refcount/structured_binding_move_ctor.rs @@ -12,7 +12,9 @@ thread_local!( thread_local!( pub static moves_1: Value = Rc::new(RefCell::new(0)); ); -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, Default)] +#[derive( + Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyAssignable, MoveAssignable, Default, +)] #[byte_size(8)] pub struct Movable { #[offset(0)] @@ -27,12 +29,20 @@ impl Clone for Movable { y: self.y.clone(), })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - MovableImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, MoveAssign, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + CopyAssignable, + Default, )] #[byte_size(48)] pub struct Holder { @@ -55,7 +65,7 @@ fn main_0() -> i32 { })); let __decomp_2: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - MovableImpl::move_from(&__v.as_pointer(), { m.as_pointer() }); + MoveConstructible::move_constructor(&__v.as_pointer(), { m.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); assert!((moves_1.with(|rc| *rc.borrow()) == 1)); @@ -80,8 +90,6 @@ fn main_0() -> i32 { } pub trait HolderImpl { fn extract(&self) -> Holder; - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; } impl HolderImpl for Ptr { fn extract(&self) -> Holder { @@ -90,38 +98,44 @@ impl HolderImpl for Ptr { ys: field!((*self), ys).with_mut(std::mem::take), }; } - fn move_from(&self, _a0: Ptr) { - field!((*self), xs).write(field!(_a0, xs).with_mut(std::mem::take)); - field!((*self), ys).write(field!(_a0, ys).with_mut(std::mem::take)); - } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), xs).with_mut(|__b0| { +} +impl MoveAssignable for Holder { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), xs).with_mut(|__b0| { (*__b0) = field!(_a0, xs).with_mut(std::mem::take); }); - field!((*self), ys).with_mut(|__b0| { + field!((*this), ys).with_mut(|__b0| { (*__b0) = field!(_a0, ys).with_mut(std::mem::take); }); - return (*self).clone(); + return (*this).clone(); + } +} +impl MoveConstructible for Holder { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), xs).write(field!(_a0, xs).with_mut(std::mem::take)); + field!((*this), ys).write(field!(_a0, ys).with_mut(std::mem::take)); } } pub trait MovableImpl { fn construct(&self, x: i32, y: i32); - fn copy_from(&self, other: Ptr); - fn move_from(&self, other: Ptr); } impl MovableImpl for Ptr { fn construct(&self, mut x: i32, mut y: i32) { field!((*self), x).write(x); field!((*self), y).write(y); } - fn copy_from(&self, other: Ptr) { - field!((*self), x).write(other.with(|__s| __s.x)); - field!((*self), y).write(other.with(|__s| __s.y)); +} +impl CopyConstructible for Movable { + fn copy_constructor(this: &Ptr, other: Ptr) { + field!((*this), x).write(other.with(|__s| __s.x)); + field!((*this), y).write(other.with(|__s| __s.y)); (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); } - fn move_from(&self, other: Ptr) { - field!((*self), x).write(other.with(|__s| __s.x)); - field!((*self), y).write(other.with(|__s| __s.y)); +} +impl MoveConstructible for Movable { + fn move_constructor(this: &Ptr, other: Ptr) { + field!((*this), x).write(other.with(|__s| __s.x)); + field!((*this), y).write(other.with(|__s| __s.y)); field!(other, x).write(0); field!(other, y).write(0); (*moves_1.with(Value::clone).borrow_mut()).prefix_inc(); diff --git a/tests/unit/out/refcount/structured_binding_range_for.rs b/tests/unit/out/refcount/structured_binding_range_for.rs index 468abc78a8..fa8d1d288c 100644 --- a/tests/unit/out/refcount/structured_binding_range_for.rs +++ b/tests/unit/out/refcount/structured_binding_range_for.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Pair { #[offset(0)] diff --git a/tests/unit/out/refcount/structured_binding_ref.rs b/tests/unit/out/refcount/structured_binding_ref.rs index b0fbabb77b..6ddfa0d97b 100644 --- a/tests/unit/out/refcount/structured_binding_ref.rs +++ b/tests/unit/out/refcount/structured_binding_ref.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(12)] pub struct Triple { #[offset(0)] diff --git a/tests/unit/out/refcount/structured_binding_trivial.rs b/tests/unit/out/refcount/structured_binding_trivial.rs index 8d4fcf3756..6866274183 100644 --- a/tests/unit/out/refcount/structured_binding_trivial.rs +++ b/tests/unit/out/refcount/structured_binding_trivial.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Pair { #[offset(0)] diff --git a/tests/unit/out/refcount/swap_map_no_copy.rs b/tests/unit/out/refcount/swap_map_no_copy.rs index 1cecae8b63..d284cd1bee 100644 --- a/tests/unit/out/refcount/swap_map_no_copy.rs +++ b/tests/unit/out/refcount/swap_map_no_copy.rs @@ -9,9 +9,7 @@ use std::rc::{Rc, Weak}; thread_local!( pub static copies_0: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, CppFrom, CopyAssign, MoveAssign, -)] +#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom)] #[cpp_from(i32, construct_1, value)] #[byte_size(4)] pub struct Tracked { @@ -22,7 +20,7 @@ impl Clone for Tracked { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(Tracked { v: self.v.clone() })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - TrackedImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -38,16 +36,7 @@ impl Default for Tracked { } } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - MoveCtor, - CopyAssign, - MoveAssign, - Default, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyConstructible, Default, )] #[byte_size(8)] pub struct Pair { @@ -58,9 +47,7 @@ pub struct Pair { #[byte_size(4)] pub y: Tracked, } -#[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, CopyAssign, MoveAssign, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyConstructible)] #[byte_size(16)] pub struct Arrays { #[offset(0)] @@ -99,8 +86,9 @@ thread_local!( VaArg, FnPtrArg, CppFrom, - CopyAssign, Destructible, + MoveConstructible, + MoveAssignable, Default, )] #[cpp_from(i32, construct, value)] @@ -113,12 +101,22 @@ impl Clone for CopyOnly { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(CopyOnly { v: self.v.clone() })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - CopyOnlyImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyAssign, Destructible, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + CopyConstructible, + MoveConstructible, + MoveAssignable, + Default, )] #[byte_size(8)] pub struct CopyOnlyPair { @@ -138,19 +136,7 @@ thread_local!( thread_local!( pub static moved_dtors_5: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - MoveCtor, - CppFrom, - CopyAssign, - MoveAssign, - Destructible, - Default, -)] +#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Destructible, Default)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct Moved { @@ -161,7 +147,7 @@ impl Clone for Moved { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(Moved { v: self.v.clone() })); let __v: Value = Rc::new(RefCell::new(::zero_init())); - MovedImpl::copy_from(&__v.as_pointer(), __src.as_pointer()); + CopyConstructible::copy_constructor(&__v.as_pointer(), __src.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -172,10 +158,8 @@ impl Clone for Moved { ZeroInitialization, VaArg, FnPtrArg, - MoveCtor, - CopyAssign, - MoveAssign, Destructible, + CopyConstructible, Default, )] #[byte_size(8)] @@ -204,7 +188,7 @@ pub fn swapped_once_6() -> bool { }); return ok; } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, MoveCtor, MoveAssign, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Default)] #[byte_size(8)] pub struct Owner { #[offset(0)] @@ -236,7 +220,7 @@ fn main_0() -> i32 { TrackedImpl::construct_1(&__v.as_pointer(), { 10 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); - TrackedImpl::move_assign( + MoveAssignable::move_assign( &match (Rc::new(RefCell::new(1)).as_pointer(),) { (__tmp_0,) => { ({ @@ -257,7 +241,7 @@ fn main_0() -> i32 { TrackedImpl::construct_1(&__v.as_pointer(), { 20 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); - TrackedImpl::move_assign( + MoveAssignable::move_assign( &match (Rc::new(RefCell::new(2)).as_pointer(),) { (__tmp_1,) => { ({ @@ -279,7 +263,7 @@ fn main_0() -> i32 { TrackedImpl::construct_1(&__v.as_pointer(), { 30 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); - TrackedImpl::move_assign( + MoveAssignable::move_assign( &match (Rc::new(RefCell::new(3)).as_pointer(),) { (__tmp_2,) => { ({ @@ -585,7 +569,7 @@ fn main_0() -> i32 { TrackedImpl::construct_1(&__v.as_pointer(), { 1 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); - TrackedImpl::move_assign( + MoveAssignable::move_assign( &match (Rc::new(RefCell::new(1)).as_pointer(),) { (__tmp_18,) => { ({ @@ -606,7 +590,7 @@ fn main_0() -> i32 { TrackedImpl::construct_1(&__v.as_pointer(), { 2 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); - TrackedImpl::move_assign( + MoveAssignable::move_assign( &match (Rc::new(RefCell::new(2)).as_pointer(),) { (__tmp_19,) => { ({ @@ -789,32 +773,15 @@ fn main_0() -> i32 { ); return copies_0.with(|rc| *rc.borrow()); } -pub trait ArraysImpl { - fn move_from(&self, _a0: Ptr); - fn copy_assign(&self, _a0: Ptr) -> Ptr; - fn move_assign(&self, _a0: Ptr) -> Ptr; -} -impl ArraysImpl for Ptr { - fn move_from(&self, _a0: Ptr) { - field!((*self), a).write(Box::new(std::array::from_fn::<_, 2, _>(|__i: usize| { - let __v: Value = Rc::new(RefCell::new(::zero_init())); - TrackedImpl::move_from(&__v.as_pointer(), { array_field_ptr!(_a0, a).offset(__i) }); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }))); - field!((*self), b).write(Box::new(std::array::from_fn::<_, 2, _>(|__i: usize| { - let __v: Value = Rc::new(RefCell::new(::zero_init())); - TrackedImpl::move_from(&__v.as_pointer(), { array_field_ptr!(_a0, b).offset(__i) }); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }))); - } - fn copy_assign(&self, _a0: Ptr) -> Ptr { +impl CopyAssignable for Arrays { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { { let mut __i0: usize = 0_usize; 'loop_: while (__i0 != 2_usize) { 'for_body: { ({ - TrackedImpl::copy_assign( - &array_field_ptr!((*self), a).offset((__i0) as isize), + CopyAssignable::copy_assign( + &array_field_ptr!((*this), a).offset((__i0) as isize), array_field_ptr!(_a0, a).offset((__i0) as isize), ) }); @@ -827,8 +794,8 @@ impl ArraysImpl for Ptr { 'loop_: while (__i0 != 2_usize) { 'for_body: { ({ - TrackedImpl::copy_assign( - &array_field_ptr!((*self), b).offset((__i0) as isize), + CopyAssignable::copy_assign( + &array_field_ptr!((*this), b).offset((__i0) as isize), array_field_ptr!(_a0, b).offset((__i0) as isize), ) }); @@ -836,16 +803,18 @@ impl ArraysImpl for Ptr { __i0.prefix_inc(); } } - return (*self).clone(); + return (*this).clone(); } - fn move_assign(&self, _a0: Ptr) -> Ptr { +} +impl MoveAssignable for Arrays { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { { let mut __i0: usize = 0_usize; 'loop_: while (__i0 != 2_usize) { 'for_body: { ({ - TrackedImpl::move_assign( - &array_field_ptr!((*self), a).offset((__i0) as isize), + MoveAssignable::move_assign( + &array_field_ptr!((*this), a).offset((__i0) as isize), array_field_ptr!(_a0, a).offset((__i0) as isize), ) }); @@ -858,8 +827,8 @@ impl ArraysImpl for Ptr { 'loop_: while (__i0 != 2_usize) { 'for_body: { ({ - TrackedImpl::move_assign( - &array_field_ptr!((*self), b).offset((__i0) as isize), + MoveAssignable::move_assign( + &array_field_ptr!((*this), b).offset((__i0) as isize), array_field_ptr!(_a0, b).offset((__i0) as isize), ) }); @@ -867,169 +836,190 @@ impl ArraysImpl for Ptr { __i0.prefix_inc(); } } - return (*self).clone(); + return (*this).clone(); + } +} +impl MoveConstructible for Arrays { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), a).write(Box::new(std::array::from_fn::<_, 2, _>(|__i: usize| { + let __v: Value = Rc::new(RefCell::new(::zero_init())); + MoveConstructible::move_constructor(&__v.as_pointer(), { + array_field_ptr!(_a0, a).offset(__i) + }); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }))); + field!((*this), b).write(Box::new(std::array::from_fn::<_, 2, _>(|__i: usize| { + let __v: Value = Rc::new(RefCell::new(::zero_init())); + MoveConstructible::move_constructor(&__v.as_pointer(), { + array_field_ptr!(_a0, b).offset(__i) + }); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }))); } } pub trait CopyOnlyImpl { fn construct(&self, v: i32); - fn copy_from(&self, o: Ptr); fn destructor(&self); - fn copy_assign(&self, o: Ptr) -> Ptr; } impl CopyOnlyImpl for Ptr { fn construct(&self, mut v: i32) { field!((*self), v).write(v); } - fn copy_from(&self, o: Ptr) { - field!((*self), v).write(o.with(|__s| __s.v)); - (*copy_only_copies_1.with(Value::clone).borrow_mut()).prefix_inc(); - } fn destructor(&self) { (*copy_only_dtors_2.with(Value::clone).borrow_mut()).prefix_inc(); } - fn copy_assign(&self, o: Ptr) -> Ptr { - field!((*self), v).write(o.with(|__s| __s.v)); +} +impl CopyAssignable for CopyOnly { + fn copy_assign(this: &Ptr, o: Ptr) -> Ptr { + field!((*this), v).write(o.with(|__s| __s.v)); + (*copy_only_copies_1.with(Value::clone).borrow_mut()).prefix_inc(); + return (*this).clone(); + } +} +impl CopyConstructible for CopyOnly { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); (*copy_only_copies_1.with(Value::clone).borrow_mut()).prefix_inc(); - return (*self).clone(); } } pub trait CopyOnlyPairImpl { - fn copy_assign(&self, _a0: Ptr) -> Ptr; fn destructor(&self); } impl CopyOnlyPairImpl for Ptr { - fn copy_assign(&self, _a0: Ptr) -> Ptr { - ({ CopyOnlyImpl::copy_assign(&field_ptr!((*self), x), field_ptr!(_a0, x)) }); - ({ CopyOnlyImpl::copy_assign(&field_ptr!((*self), y), field_ptr!(_a0, y)) }); - return (*self).clone(); - } fn destructor(&self) { Destructible::destroy(field_ptr!(self, y)); Destructible::destroy(field_ptr!(self, x)); } } +impl CopyAssignable for CopyOnlyPair { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + ({ CopyAssignable::copy_assign(&field_ptr!((*this), x), field_ptr!(_a0, x)) }); + ({ CopyAssignable::copy_assign(&field_ptr!((*this), y), field_ptr!(_a0, y)) }); + return (*this).clone(); + } +} pub trait MovedImpl { fn construct(&self, v: i32); - fn copy_from(&self, o: Ptr); - fn move_from(&self, o: Ptr); - fn copy_assign(&self, o: Ptr) -> Ptr; - fn move_assign(&self, o: Ptr) -> Ptr; fn destructor(&self); } impl MovedImpl for Ptr { fn construct(&self, mut v: i32) { field!((*self), v).write(v); } - fn copy_from(&self, o: Ptr) { - field!((*self), v).write(o.with(|__s| __s.v)); - (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); + fn destructor(&self) { + (*moved_dtors_5.with(Value::clone).borrow_mut()).prefix_inc(); } - fn move_from(&self, o: Ptr) { - field!((*self), v).write(o.with(|__s| __s.v)); - field!(o, v).write(-1_i32); - (*moves_3.with(Value::clone).borrow_mut()).prefix_inc(); +} +impl CopyAssignable for Moved { + fn copy_assign(this: &Ptr, o: Ptr) -> Ptr { + field!((*this), v).write(o.with(|__s| __s.v)); + (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); + return (*this).clone(); } - fn copy_assign(&self, o: Ptr) -> Ptr { - field!((*self), v).write(o.with(|__s| __s.v)); +} +impl CopyConstructible for Moved { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); - return (*self).clone(); } - fn move_assign(&self, o: Ptr) -> Ptr { - field!((*self), v).write(o.with(|__s| __s.v)); +} +impl MoveAssignable for Moved { + fn move_assign(this: &Ptr, o: Ptr) -> Ptr { + field!((*this), v).write(o.with(|__s| __s.v)); field!(o, v).write(-1_i32); (*move_assigns_4.with(Value::clone).borrow_mut()).prefix_inc(); - return (*self).clone(); + return (*this).clone(); } - fn destructor(&self) { - (*moved_dtors_5.with(Value::clone).borrow_mut()).prefix_inc(); +} +impl MoveConstructible for Moved { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + field!(o, v).write(-1_i32); + (*moves_3.with(Value::clone).borrow_mut()).prefix_inc(); } } pub trait MovedPairImpl { - fn move_from(&self, _a0: Ptr); - fn copy_assign(&self, _a0: Ptr) -> Ptr; - fn move_assign(&self, _a0: Ptr) -> Ptr; fn destructor(&self); } impl MovedPairImpl for Ptr { - fn move_from(&self, _a0: Ptr) { - field!((*self), x).write({ + fn destructor(&self) { + Destructible::destroy(field_ptr!(self, y)); + Destructible::destroy(field_ptr!(self, x)); + } +} +impl CopyAssignable for MovedPair { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + ({ CopyAssignable::copy_assign(&field_ptr!((*this), x), field_ptr!(_a0, x)) }); + ({ CopyAssignable::copy_assign(&field_ptr!((*this), y), field_ptr!(_a0, y)) }); + return (*this).clone(); + } +} +impl MoveAssignable for MovedPair { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + ({ MoveAssignable::move_assign(&field_ptr!((*this), x), field_ptr!(_a0, x)) }); + ({ MoveAssignable::move_assign(&field_ptr!((*this), y), field_ptr!(_a0, y)) }); + return (*this).clone(); + } +} +impl MoveConstructible for MovedPair { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), x).write({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - MovedImpl::move_from(&__v.as_pointer(), { field_ptr!(_a0, x) }); + MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, x) }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }); - field!((*self), y).write({ + field!((*this), y).write({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - MovedImpl::move_from(&__v.as_pointer(), { field_ptr!(_a0, y) }); + MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, y) }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }); } - fn copy_assign(&self, _a0: Ptr) -> Ptr { - ({ MovedImpl::copy_assign(&field_ptr!((*self), x), field_ptr!(_a0, x)) }); - ({ MovedImpl::copy_assign(&field_ptr!((*self), y), field_ptr!(_a0, y)) }); - return (*self).clone(); - } - fn move_assign(&self, _a0: Ptr) -> Ptr { - ({ MovedImpl::move_assign(&field_ptr!((*self), x), field_ptr!(_a0, x)) }); - ({ MovedImpl::move_assign(&field_ptr!((*self), y), field_ptr!(_a0, y)) }); - return (*self).clone(); - } - fn destructor(&self) { - Destructible::destroy(field_ptr!(self, y)); - Destructible::destroy(field_ptr!(self, x)); - } } -pub trait OwnerImpl { - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; +impl MoveAssignable for Owner { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), p).with_mut(|__b0| { + (*__b0) = field!(_a0, p).with_mut(|__v: &mut Option>| __v.take()); + }); + return (*this).clone(); + } } -impl OwnerImpl for Ptr { - fn move_from(&self, _a0: Ptr) { - field!((*self), p) +impl MoveConstructible for Owner { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), p) .write(field!(_a0, p).with_mut(|__v: &mut Option>| __v.take())); } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), p).with_mut(|__b0| { - (*__b0) = field!(_a0, p).with_mut(|__v: &mut Option>| __v.take()); - }); - return (*self).clone(); +} +impl CopyAssignable for Pair { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + ({ CopyAssignable::copy_assign(&field_ptr!((*this), x), field_ptr!(_a0, x)) }); + ({ CopyAssignable::copy_assign(&field_ptr!((*this), y), field_ptr!(_a0, y)) }); + return (*this).clone(); } } -pub trait PairImpl { - fn move_from(&self, _a0: Ptr); - fn copy_assign(&self, _a0: Ptr) -> Ptr; - fn move_assign(&self, _a0: Ptr) -> Ptr; +impl MoveAssignable for Pair { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + ({ MoveAssignable::move_assign(&field_ptr!((*this), x), field_ptr!(_a0, x)) }); + ({ MoveAssignable::move_assign(&field_ptr!((*this), y), field_ptr!(_a0, y)) }); + return (*this).clone(); + } } -impl PairImpl for Ptr { - fn move_from(&self, _a0: Ptr) { - field!((*self), x).write({ +impl MoveConstructible for Pair { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), x).write({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - TrackedImpl::move_from(&__v.as_pointer(), { field_ptr!(_a0, x) }); + MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, x) }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }); - field!((*self), y).write({ + field!((*this), y).write({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - TrackedImpl::move_from(&__v.as_pointer(), { field_ptr!(_a0, y) }); + MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, y) }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }); } - fn copy_assign(&self, _a0: Ptr) -> Ptr { - ({ TrackedImpl::copy_assign(&field_ptr!((*self), x), field_ptr!(_a0, x)) }); - ({ TrackedImpl::copy_assign(&field_ptr!((*self), y), field_ptr!(_a0, y)) }); - return (*self).clone(); - } - fn move_assign(&self, _a0: Ptr) -> Ptr { - ({ TrackedImpl::move_assign(&field_ptr!((*self), x), field_ptr!(_a0, x)) }); - ({ TrackedImpl::move_assign(&field_ptr!((*self), y), field_ptr!(_a0, y)) }); - return (*self).clone(); - } } pub trait TrackedImpl { fn construct_2(&self); fn construct_1(&self, v: i32); - fn copy_from(&self, o: Ptr); - fn move_from(&self, o: Ptr); - fn copy_assign(&self, o: Ptr) -> Ptr; - fn move_assign(&self, o: Ptr) -> Ptr; } impl TrackedImpl for Ptr { fn construct_2(&self) { @@ -1038,21 +1028,29 @@ impl TrackedImpl for Ptr { fn construct_1(&self, mut v: i32) { field!((*self), v).write(v); } - fn copy_from(&self, o: Ptr) { - field!((*self), v).write(o.with(|__s| __s.v)); +} +impl CopyAssignable for Tracked { + fn copy_assign(this: &Ptr, o: Ptr) -> Ptr { + field!((*this), v).write(o.with(|__s| __s.v)); (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); + return (*this).clone(); } - fn move_from(&self, o: Ptr) { - field!((*self), v).write(o.with(|__s| __s.v)); - } - fn copy_assign(&self, o: Ptr) -> Ptr { - field!((*self), v).write(o.with(|__s| __s.v)); +} +impl CopyConstructible for Tracked { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); - return (*self).clone(); } - fn move_assign(&self, o: Ptr) -> Ptr { - field!((*self), v).write(o.with(|__s| __s.v)); - return (*self).clone(); +} +impl MoveAssignable for Tracked { + fn move_assign(this: &Ptr, o: Ptr) -> Ptr { + field!((*this), v).write(o.with(|__s| __s.v)); + return (*this).clone(); + } +} +impl MoveConstructible for Tracked { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); } } pub fn __cpp2rust_init_globals() { diff --git a/tests/unit/out/refcount/tag_vs_identifier_collision.rs b/tests/unit/out/refcount/tag_vs_identifier_collision.rs index 49be6f6017..efd9fabf1c 100644 --- a/tests/unit/out/refcount/tag_vs_identifier_collision.rs +++ b/tests/unit/out/refcount/tag_vs_identifier_collision.rs @@ -10,7 +10,20 @@ pub type widget_enum = u32; pub const widget_enum_MODE_IDLE: widget_enum = 0; pub const widget_enum_MODE_ACTIVE: widget_enum = 1; pub const widget_enum_MODE_DONE: widget_enum = 2; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct widget { #[offset(0)] @@ -18,7 +31,20 @@ pub struct widget { #[offset(4)] pub mode: widget_enum, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct point_struct { #[offset(0)] @@ -26,7 +52,17 @@ pub struct point_struct { #[offset(4)] pub y: i32, } -#[derive(VaArg, FnPtrArg, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + ByteRepr, + Clone, + ZeroInitialization, +)] #[byte_size(4)] pub struct point { #[offset(0)] @@ -49,7 +85,17 @@ impl Default for point { } } } -#[derive(VaArg, FnPtrArg, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + ByteRepr, + Clone, + ZeroInitialization, +)] #[byte_size(4)] pub struct slot_union { #[offset(0)] @@ -75,20 +121,59 @@ impl Default for slot_union { pub type slot = u32; pub const slot_SLOT_A: slot = 0; pub const slot_SLOT_B: slot = 1; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Inner { #[offset(0)] pub tag_field: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Outer { #[offset(0)] #[byte_size(4)] pub field: Inner, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Inner_struct { #[offset(0)] diff --git a/tests/unit/out/refcount/template_default_arg.rs b/tests/unit/out/refcount/template_default_arg.rs index 6b720baba4..fc390a4fb0 100644 --- a/tests/unit/out/refcount/template_default_arg.rs +++ b/tests/unit/out/refcount/template_default_arg.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[cpp_from(i32, construct_1, value)] #[byte_size(4)] pub struct A { @@ -24,7 +37,19 @@ impl Default for A { } } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(4)] pub struct B { #[offset(0)] @@ -41,7 +66,21 @@ impl Default for B { } } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct NoDefault { @@ -60,7 +99,21 @@ pub fn scaled_2(mut x: A, mut n: i32) -> i32 { pub fn always_given_3(mut x: NoDefault) -> i32 { return x.v; } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct S_NoDefault_ { diff --git a/tests/unit/out/refcount/template_static_member.rs b/tests/unit/out/refcount/template_static_member.rs index 5af9536c09..9e53a9d2b4 100644 --- a/tests/unit/out/refcount/template_static_member.rs +++ b/tests/unit/out/refcount/template_static_member.rs @@ -9,19 +9,58 @@ use std::rc::{Rc, Weak}; thread_local!( pub static s_0: Value = Rc::new(RefCell::new(55)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct Static_int_ {} thread_local!( pub static s_1: Value = Rc::new(RefCell::new(55_i8)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct Static_char_ {} thread_local!( pub static s_2: Value = Rc::new(RefCell::new(55_i64)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct Static_long_ {} thread_local!( @@ -30,7 +69,20 @@ thread_local!( thread_local!( pub static hi_4: Value = Rc::new(RefCell::new(1)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct Range_int_ {} thread_local!( @@ -39,7 +91,20 @@ thread_local!( thread_local!( pub static hi_6: Value = Rc::new(RefCell::new(2_i64)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct Range_long_ {} pub fn main() { diff --git a/tests/unit/out/refcount/temporary_field_addr.rs b/tests/unit/out/refcount/temporary_field_addr.rs index 4c828b2701..5841ecc65a 100644 --- a/tests/unit/out/refcount/temporary_field_addr.rs +++ b/tests/unit/out/refcount/temporary_field_addr.rs @@ -7,7 +7,15 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, MoveAssign, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + CopyAssignable, + Default, )] #[byte_size(24)] pub struct Inner { @@ -15,7 +23,9 @@ pub struct Inner { #[byte_size(24)] pub values: Vec, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, MoveAssign)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyConstructible, CopyAssignable, +)] #[byte_size(56)] pub struct Outer { #[offset(0)] @@ -126,48 +136,44 @@ fn main_0() -> i32 { ); return 0; } -pub trait InnerImpl { - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; -} -impl InnerImpl for Ptr { - fn move_from(&self, _a0: Ptr) { - field!((*self), values).write(field!(_a0, values).with_mut(std::mem::take)); - } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), values).with_mut(|__b0| { +impl MoveAssignable for Inner { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), values).with_mut(|__b0| { (*__b0) = field!(_a0, values).with_mut(std::mem::take); }); - return (*self).clone(); + return (*this).clone(); } } -pub trait OuterImpl { - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; -} -impl OuterImpl for Ptr { - fn move_from(&self, _a0: Ptr) { - field!((*self), values).write(field!(_a0, values).with_mut(std::mem::take)); - field!((*self), inner).write({ - let __v: Value = Rc::new(RefCell::new(::zero_init())); - InnerImpl::move_from(&__v.as_pointer(), { field_ptr!(_a0, inner) }); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }); - field!((*self), name).write(Box::new(std::array::from_fn::<_, 8, _>(|__i: usize| { - (*_a0.upgrade().deref()).name[(__i) as usize] - }))); +impl MoveConstructible for Inner { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), values).write(field!(_a0, values).with_mut(std::mem::take)); } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), values).with_mut(|__b0| { +} +impl MoveAssignable for Outer { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), values).with_mut(|__b0| { (*__b0) = field!(_a0, values).with_mut(std::mem::take); }); - ({ InnerImpl::move_assign(&field_ptr!((*self), inner), field_ptr!(_a0, inner)) }); + ({ MoveAssignable::move_assign(&field_ptr!((*this), inner), field_ptr!(_a0, inner)) }); { - let mut __tmp_0 = { (array_field_ptr!((*self), name)).to_any() }; + let mut __tmp_0 = { (array_field_ptr!((*this), name)).to_any() }; __tmp_0.memcpy(&(array_field_ptr!(_a0, name)).to_any(), 8_usize); (__tmp_0).clone() }; - return (*self).clone(); + return (*this).clone(); + } +} +impl MoveConstructible for Outer { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), values).write(field!(_a0, values).with_mut(std::mem::take)); + field!((*this), inner).write({ + let __v: Value = Rc::new(RefCell::new(::zero_init())); + MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, inner) }); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }); + field!((*this), name).write(Box::new(std::array::from_fn::<_, 8, _>(|__i: usize| { + (*_a0.upgrade().deref()).name[(__i) as usize] + }))); } } pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/temporary_field_ctor_arg.rs b/tests/unit/out/refcount/temporary_field_ctor_arg.rs index 6cbd2d0a77..53a527d7fc 100644 --- a/tests/unit/out/refcount/temporary_field_ctor_arg.rs +++ b/tests/unit/out/refcount/temporary_field_ctor_arg.rs @@ -7,7 +7,15 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, MoveAssign, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + CopyAssignable, + Default, )] #[byte_size(24)] pub struct Outer { @@ -20,7 +28,21 @@ pub fn make_0() -> Outer { values: Vec::from([1, 2, 3, 4]), }; } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_from(Vec , construct, ptr)] #[byte_size(4)] pub struct H { @@ -52,19 +74,17 @@ impl HImpl for Ptr { field!((*self), last).write((index!(values, 3_usize).read())); } } -pub trait OuterImpl { - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; -} -impl OuterImpl for Ptr { - fn move_from(&self, _a0: Ptr) { - field!((*self), values).write(field!(_a0, values).with_mut(std::mem::take)); - } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), values).with_mut(|__b0| { +impl MoveAssignable for Outer { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), values).with_mut(|__b0| { (*__b0) = field!(_a0, values).with_mut(std::mem::take); }); - return (*self).clone(); + return (*this).clone(); + } +} +impl MoveConstructible for Outer { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), values).write(field!(_a0, values).with_mut(std::mem::take)); } } pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/temporary_field_two_args.rs b/tests/unit/out/refcount/temporary_field_two_args.rs index d0c102171b..22ba39f065 100644 --- a/tests/unit/out/refcount/temporary_field_two_args.rs +++ b/tests/unit/out/refcount/temporary_field_two_args.rs @@ -7,7 +7,15 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, MoveAssign, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + CopyAssignable, + Default, )] #[byte_size(24)] pub struct Inner { @@ -16,7 +24,15 @@ pub struct Inner { pub values: Vec, } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, MoveAssign, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + CopyAssignable, + Default, )] #[byte_size(48)] pub struct Outer { @@ -58,40 +74,36 @@ fn main_0() -> i32 { ); return 0; } -pub trait InnerImpl { - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; +impl MoveAssignable for Inner { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), values).with_mut(|__b0| { + (*__b0) = field!(_a0, values).with_mut(std::mem::take); + }); + return (*this).clone(); + } } -impl InnerImpl for Ptr { - fn move_from(&self, _a0: Ptr) { - field!((*self), values).write(field!(_a0, values).with_mut(std::mem::take)); +impl MoveConstructible for Inner { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), values).write(field!(_a0, values).with_mut(std::mem::take)); } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), values).with_mut(|__b0| { +} +impl MoveAssignable for Outer { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), values).with_mut(|__b0| { (*__b0) = field!(_a0, values).with_mut(std::mem::take); }); - return (*self).clone(); + ({ MoveAssignable::move_assign(&field_ptr!((*this), inner), field_ptr!(_a0, inner)) }); + return (*this).clone(); } } -pub trait OuterImpl { - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; -} -impl OuterImpl for Ptr { - fn move_from(&self, _a0: Ptr) { - field!((*self), values).write(field!(_a0, values).with_mut(std::mem::take)); - field!((*self), inner).write({ +impl MoveConstructible for Outer { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), values).write(field!(_a0, values).with_mut(std::mem::take)); + field!((*this), inner).write({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - InnerImpl::move_from(&__v.as_pointer(), { field_ptr!(_a0, inner) }); + MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, inner) }); Rc::try_unwrap(__v).ok().unwrap().into_inner() }); } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), values).with_mut(|__b0| { - (*__b0) = field!(_a0, values).with_mut(std::mem::take); - }); - ({ InnerImpl::move_assign(&field_ptr!((*self), inner), field_ptr!(_a0, inner)) }); - return (*self).clone(); - } } pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/this.rs b/tests/unit/out/refcount/this.rs index dc4c2bdf58..74c18441e5 100644 --- a/tests/unit/out/refcount/this.rs +++ b/tests/unit/out/refcount/this.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_from(i32, construct_1, value)] #[byte_size(16)] pub struct S { @@ -19,7 +32,21 @@ pub struct S { pub fn bump_0(mut p: Ptr) { field!(p, a_).with_mut(|__v| __v.postfix_inc()); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct D { diff --git a/tests/unit/out/refcount/typedef-anon-struct.rs b/tests/unit/out/refcount/typedef-anon-struct.rs index 1c63a2e7a1..9a555713b6 100644 --- a/tests/unit/out/refcount/typedef-anon-struct.rs +++ b/tests/unit/out/refcount/typedef-anon-struct.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Outer_RunInfo { #[offset(0)] @@ -15,7 +28,15 @@ pub struct Outer_RunInfo { pub num_extra_zero_runs: i32, } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, MoveAssign, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + CopyAssignable, + Default, )] #[byte_size(24)] pub struct Outer { @@ -41,19 +62,17 @@ fn main_0() -> i32 { assert!((o.runs[0_usize].num_extra_zero_runs == 2)); return 0; } -pub trait OuterImpl { - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; -} -impl OuterImpl for Ptr { - fn move_from(&self, _a0: Ptr) { - field!((*self), runs).write(field!(_a0, runs).with_mut(std::mem::take)); - } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), runs).with_mut(|__b0| { +impl MoveAssignable for Outer { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), runs).with_mut(|__b0| { (*__b0) = field!(_a0, runs).with_mut(std::mem::take); }); - return (*self).clone(); + return (*this).clone(); + } +} +impl MoveConstructible for Outer { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), runs).write(field!(_a0, runs).with_mut(std::mem::take)); } } pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/unary_expr_or_type_trait.rs b/tests/unit/out/refcount/unary_expr_or_type_trait.rs index 11cde1b667..d1b3c5b6af 100644 --- a/tests/unit/out/refcount/unary_expr_or_type_trait.rs +++ b/tests/unit/out/refcount/unary_expr_or_type_trait.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/unboxed_locals.rs b/tests/unit/out/refcount/unboxed_locals.rs index b9f631eac6..9ff991b9a6 100644 --- a/tests/unit/out/refcount/unboxed_locals.rs +++ b/tests/unit/out/refcount/unboxed_locals.rs @@ -14,7 +14,20 @@ pub fn inc_1(r: Ptr) { __v.prefix_inc(); }); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Pair { #[offset(0)] @@ -54,7 +67,19 @@ pub fn countdown_4(mut n: i32, mut step: i32) -> i32 { pub trait Shape { fn scale(&mut self, factor: i32) -> i32; } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(16)] pub struct Square { #[offset(8)] diff --git a/tests/unit/out/refcount/unboxed_records.rs b/tests/unit/out/refcount/unboxed_records.rs index ecca76a643..7135557fe1 100644 --- a/tests/unit/out/refcount/unboxed_records.rs +++ b/tests/unit/out/refcount/unboxed_records.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Inner { #[offset(0)] @@ -14,7 +27,18 @@ pub struct Inner { #[offset(4)] pub b: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(48)] pub struct Cookie { #[offset(0)] @@ -46,7 +70,19 @@ impl Default for Cookie { } } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(4)] pub struct Counter { #[offset(0)] diff --git a/tests/unit/out/refcount/union_addrof_external.rs b/tests/unit/out/refcount/union_addrof_external.rs index 19af982d55..c9a51ee9d9 100644 --- a/tests/unit/out/refcount/union_addrof_external.rs +++ b/tests/unit/out/refcount/union_addrof_external.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(16)] pub struct record { #[offset(0)] @@ -32,7 +43,17 @@ impl Default for record { } } } -#[derive(VaArg, FnPtrArg, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + ByteRepr, + Clone, + ZeroInitialization, +)] #[byte_size(128)] pub struct anon_0 { #[offset(0)] @@ -55,7 +76,19 @@ impl Default for anon_0 { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(128)] pub struct Container { #[offset(0)] diff --git a/tests/unit/out/refcount/union_basic.rs b/tests/unit/out/refcount/union_basic.rs index be25047476..537b2fd8fb 100644 --- a/tests/unit/out/refcount/union_basic.rs +++ b/tests/unit/out/refcount/union_basic.rs @@ -6,7 +6,17 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(VaArg, FnPtrArg, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + ByteRepr, + Clone, + ZeroInitialization, +)] #[byte_size(4)] pub struct basic { #[offset(0)] @@ -29,7 +39,17 @@ impl Default for basic { } } } -#[derive(VaArg, FnPtrArg, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + ByteRepr, + Clone, + ZeroInitialization, +)] #[byte_size(1)] pub struct empty { #[offset(0)] @@ -45,7 +65,17 @@ impl Default for empty { } } } -#[derive(VaArg, FnPtrArg, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + ByteRepr, + Clone, + ZeroInitialization, +)] #[byte_size(8)] pub struct underscores { #[offset(0)] @@ -123,7 +153,17 @@ fn main_0() -> i32 { assert!(((__ + ___) == 3)); return 0; } -#[derive(VaArg, FnPtrArg, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + ByteRepr, + Clone, + ZeroInitialization, +)] #[byte_size(4)] pub struct anon_0 { #[offset(0)] diff --git a/tests/unit/out/refcount/union_cross_arm_cast.rs b/tests/unit/out/refcount/union_cross_arm_cast.rs index a9d1479a1e..584b4cfeba 100644 --- a/tests/unit/out/refcount/union_cross_arm_cast.rs +++ b/tests/unit/out/refcount/union_cross_arm_cast.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(16)] pub struct shape_a { #[offset(0)] @@ -26,7 +37,18 @@ impl Default for shape_a { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(28)] pub struct shape_b { #[offset(0)] @@ -55,7 +77,17 @@ impl Default for shape_b { } } } -#[derive(VaArg, FnPtrArg, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + ByteRepr, + Clone, + ZeroInitialization, +)] #[byte_size(64)] pub struct anon_0 { #[offset(0)] @@ -81,7 +113,19 @@ impl Default for anon_0 { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(68)] pub struct Container { #[offset(0)] diff --git a/tests/unit/out/refcount/union_field_alignment.rs b/tests/unit/out/refcount/union_field_alignment.rs index 57809017f9..8a5ae1ae95 100644 --- a/tests/unit/out/refcount/union_field_alignment.rs +++ b/tests/unit/out/refcount/union_field_alignment.rs @@ -6,7 +6,17 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(VaArg, FnPtrArg, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + ByteRepr, + Clone, + ZeroInitialization, +)] #[byte_size(8)] pub struct anon_0 { #[offset(0)] @@ -29,7 +39,19 @@ impl Default for anon_0 { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct node { #[offset(0)] diff --git a/tests/unit/out/refcount/union_flex_array_member.rs b/tests/unit/out/refcount/union_flex_array_member.rs index 31db1da220..c856bc448a 100644 --- a/tests/unit/out/refcount/union_flex_array_member.rs +++ b/tests/unit/out/refcount/union_flex_array_member.rs @@ -6,7 +6,17 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(VaArg, FnPtrArg, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + ByteRepr, + Clone, + ZeroInitialization, +)] #[byte_size(8)] pub struct anon_0 { #[offset(0)] @@ -29,7 +39,19 @@ impl Default for anon_0 { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(24)] pub struct node { #[offset(0)] diff --git a/tests/unit/out/refcount/union_memset_memcpy.rs b/tests/unit/out/refcount/union_memset_memcpy.rs index 517b8b726f..a3e0279bd0 100644 --- a/tests/unit/out/refcount/union_memset_memcpy.rs +++ b/tests/unit/out/refcount/union_memset_memcpy.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(16)] pub struct shape_a { #[offset(0)] @@ -26,7 +37,18 @@ impl Default for shape_a { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(16)] pub struct shape_b { #[offset(0)] @@ -52,7 +74,17 @@ impl Default for shape_b { } } } -#[derive(VaArg, FnPtrArg, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + ByteRepr, + Clone, + ZeroInitialization, +)] #[byte_size(256)] pub struct anon_0 { #[offset(0)] @@ -78,7 +110,19 @@ impl Default for anon_0 { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(256)] pub struct Container { #[offset(0)] diff --git a/tests/unit/out/refcount/union_nested.rs b/tests/unit/out/refcount/union_nested.rs index 7ef5b75524..58a698d0f0 100644 --- a/tests/unit/out/refcount/union_nested.rs +++ b/tests/unit/out/refcount/union_nested.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(16)] pub struct record { #[offset(0)] @@ -26,7 +37,17 @@ impl Default for record { } } } -#[derive(VaArg, FnPtrArg, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + ByteRepr, + Clone, + ZeroInitialization, +)] #[byte_size(128)] pub struct anon_0 { #[offset(0)] @@ -49,14 +70,36 @@ impl Default for anon_0 { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(128)] pub struct inner { #[offset(0)] #[byte_size(128)] pub view: anon_0, } -#[derive(VaArg, FnPtrArg, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + ByteRepr, + Clone, + ZeroInitialization, +)] #[byte_size(128)] pub struct anon_1 { #[offset(0)] @@ -79,7 +122,19 @@ impl Default for anon_1 { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(144)] pub struct Outer { #[offset(0)] diff --git a/tests/unit/out/refcount/union_pointer_pun_address.rs b/tests/unit/out/refcount/union_pointer_pun_address.rs index 39eebeea38..3a1fbf56af 100644 --- a/tests/unit/out/refcount/union_pointer_pun_address.rs +++ b/tests/unit/out/refcount/union_pointer_pun_address.rs @@ -6,13 +6,38 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct node_a { #[offset(0)] pub n: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct node_b { #[offset(0)] @@ -34,7 +59,17 @@ fn main_0() -> i32 { assert!(({ (out).to_any() } == { (a.as_pointer()).to_any() })); return 0; } -#[derive(VaArg, FnPtrArg, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + ByteRepr, + Clone, + ZeroInitialization, +)] #[byte_size(8)] pub struct anon_0 { #[offset(0)] diff --git a/tests/unit/out/refcount/union_pointer_pun_writethrough.rs b/tests/unit/out/refcount/union_pointer_pun_writethrough.rs index c16a0a1c70..cb03400c35 100644 --- a/tests/unit/out/refcount/union_pointer_pun_writethrough.rs +++ b/tests/unit/out/refcount/union_pointer_pun_writethrough.rs @@ -18,7 +18,17 @@ fn main_0() -> i32 { assert!(({ ((*x.borrow()) == 42_i64) })); return 0; } -#[derive(VaArg, FnPtrArg, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + ByteRepr, + Clone, + ZeroInitialization, +)] #[byte_size(8)] pub struct anon_0 { #[offset(0)] diff --git a/tests/unit/out/refcount/union_struct_dual_use.rs b/tests/unit/out/refcount/union_struct_dual_use.rs index 9a272dd59f..102a01eaed 100644 --- a/tests/unit/out/refcount/union_struct_dual_use.rs +++ b/tests/unit/out/refcount/union_struct_dual_use.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Inner { #[offset(0)] @@ -17,7 +30,17 @@ pub struct Inner { pub fn sum_inner_0(mut i: Ptr) -> i32 { return ({ i.with(|__s| __s.a) } + { i.with(|__s| __s.b) }); } -#[derive(VaArg, FnPtrArg, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + ByteRepr, + Clone, + ZeroInitialization, +)] #[byte_size(16)] pub struct anon_1 { #[offset(0)] @@ -40,7 +63,19 @@ impl Default for anon_1 { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct Outer { #[offset(0)] diff --git a/tests/unit/out/refcount/union_tagged_many_arms.rs b/tests/unit/out/refcount/union_tagged_many_arms.rs index e6015b90dc..ca32401bee 100644 --- a/tests/unit/out/refcount/union_tagged_many_arms.rs +++ b/tests/unit/out/refcount/union_tagged_many_arms.rs @@ -12,7 +12,17 @@ pub const Tag_enum_T_NUM_U: Tag_enum = 1; pub const Tag_enum_T_TEXT: Tag_enum = 2; pub const Tag_enum_T_FLOAT: Tag_enum = 3; pub const Tag_enum_T_REF: Tag_enum = 4; -#[derive(VaArg, FnPtrArg, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + ByteRepr, + Clone, + ZeroInitialization, +)] #[byte_size(8)] pub struct anon_0 { #[offset(0)] @@ -44,7 +54,19 @@ impl Default for anon_0 { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct Slot { #[offset(0)] diff --git a/tests/unit/out/refcount/union_tagged_simple.rs b/tests/unit/out/refcount/union_tagged_simple.rs index 40ff56b6a5..fe01276861 100644 --- a/tests/unit/out/refcount/union_tagged_simple.rs +++ b/tests/unit/out/refcount/union_tagged_simple.rs @@ -9,7 +9,17 @@ use std::rc::{Rc, Weak}; pub type Kind_enum = u32; pub const Kind_enum_KIND_NONE: Kind_enum = 0; pub const Kind_enum_KIND_DONE: Kind_enum = 1; -#[derive(VaArg, FnPtrArg, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + ByteRepr, + Clone, + ZeroInitialization, +)] #[byte_size(8)] pub struct anon_0 { #[offset(0)] @@ -32,7 +42,19 @@ impl Default for anon_0 { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(24)] pub struct Event { #[offset(0)] diff --git a/tests/unit/out/refcount/union_tagged_struct_arms.rs b/tests/unit/out/refcount/union_tagged_struct_arms.rs index db388b5ac6..1b4a3c0be7 100644 --- a/tests/unit/out/refcount/union_tagged_struct_arms.rs +++ b/tests/unit/out/refcount/union_tagged_struct_arms.rs @@ -10,7 +10,19 @@ pub type Choice_enum = u32; pub const Choice_enum_C_LIST: Choice_enum = 1; pub const Choice_enum_C_LETTERS: Choice_enum = 2; pub const Choice_enum_C_INTEGERS: Choice_enum = 3; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(24)] pub struct anon_1 { #[offset(0)] @@ -21,7 +33,20 @@ pub struct anon_1 { #[offset(16)] pub cursor: i64, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct anon_2 { #[offset(0)] @@ -33,7 +58,20 @@ pub struct anon_2 { #[offset(12)] pub step: u8, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(40)] pub struct anon_3 { #[offset(0)] @@ -47,7 +85,17 @@ pub struct anon_3 { #[offset(32)] pub width: i32, } -#[derive(VaArg, FnPtrArg, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + ByteRepr, + Clone, + ZeroInitialization, +)] #[byte_size(40)] pub struct anon_0 { #[offset(0)] @@ -73,7 +121,19 @@ impl Default for anon_0 { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(48)] pub struct Branch { #[offset(0)] diff --git a/tests/unit/out/refcount/union_void_ptr_sized_deref.rs b/tests/unit/out/refcount/union_void_ptr_sized_deref.rs index 271b2b7121..171ad64412 100644 --- a/tests/unit/out/refcount/union_void_ptr_sized_deref.rs +++ b/tests/unit/out/refcount/union_void_ptr_sized_deref.rs @@ -10,7 +10,17 @@ pub type Width_enum = u32; pub const Width_enum_W_64: Width_enum = 0; pub const Width_enum_W_32: Width_enum = 1; pub const Width_enum_W_16: Width_enum = 2; -#[derive(VaArg, FnPtrArg, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + ByteRepr, + Clone, + ZeroInitialization, +)] #[byte_size(8)] pub struct anon_0 { #[offset(0)] @@ -39,7 +49,19 @@ impl Default for anon_0 { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct Sink { #[offset(0)] diff --git a/tests/unit/out/refcount/unique_ptr.rs b/tests/unit/out/refcount/unique_ptr.rs index 66fa40e37c..cecedb8631 100644 --- a/tests/unit/out/refcount/unique_ptr.rs +++ b/tests/unit/out/refcount/unique_ptr.rs @@ -6,14 +6,27 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, MoveCtor, MoveAssign, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Default)] #[byte_size(8)] pub struct SafePointer { #[offset(0)] #[byte_size(8)] pub ptr: Option>, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Pair { #[offset(0)] @@ -228,8 +241,6 @@ impl PairImpl for Ptr { } pub trait SafePointerImpl { fn inc(&self); - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; } impl SafePointerImpl for Ptr { fn inc(&self) { @@ -240,15 +251,19 @@ impl SafePointerImpl for Ptr { __v.prefix_inc(); }); } - fn move_from(&self, _a0: Ptr) { - field!((*self), ptr) - .write(field!(_a0, ptr).with_mut(|__v: &mut Option>| __v.take())); - } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), ptr).with_mut(|__b0| { +} +impl MoveAssignable for SafePointer { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), ptr).with_mut(|__b0| { (*__b0) = field!(_a0, ptr).with_mut(|__v: &mut Option>| __v.take()); }); - return (*self).clone(); + return (*this).clone(); + } +} +impl MoveConstructible for SafePointer { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), ptr) + .write(field!(_a0, ptr).with_mut(|__v: &mut Option>| __v.take())); } } pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/unique_ptr_const_deref.rs b/tests/unit/out/refcount/unique_ptr_const_deref.rs index 46da6a9e3f..c17113962c 100644 --- a/tests/unit/out/refcount/unique_ptr_const_deref.rs +++ b/tests/unit/out/refcount/unique_ptr_const_deref.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, MoveCtor, MoveAssign, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Default)] #[byte_size(8)] pub struct Holder { #[offset(0)] @@ -32,20 +32,18 @@ fn main_0() -> i32 { assert!((({ read_val_0((h.as_pointer()),) }) == 42)); return 0; } -pub trait HolderImpl { - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; -} -impl HolderImpl for Ptr { - fn move_from(&self, _a0: Ptr) { - field!((*self), val) - .write(field!(_a0, val).with_mut(|__v: &mut Option>| __v.take())); - } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), val).with_mut(|__b0| { +impl MoveAssignable for Holder { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), val).with_mut(|__b0| { (*__b0) = field!(_a0, val).with_mut(|__v: &mut Option>| __v.take()); }); - return (*self).clone(); + return (*this).clone(); + } +} +impl MoveConstructible for Holder { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), val) + .write(field!(_a0, val).with_mut(|__v: &mut Option>| __v.take())); } } pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/unique_ptr_field_reset.rs b/tests/unit/out/refcount/unique_ptr_field_reset.rs index 2ab5be9d04..b5fa6bc74f 100644 --- a/tests/unit/out/refcount/unique_ptr_field_reset.rs +++ b/tests/unit/out/refcount/unique_ptr_field_reset.rs @@ -6,13 +6,26 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Data { #[offset(0)] pub v: i32, } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, MoveCtor, MoveAssign, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Default)] #[byte_size(16)] pub struct Holder { #[offset(0)] @@ -60,8 +73,6 @@ fn main_0() -> i32 { } pub trait HolderImpl { fn set(&self, p: Ptr); - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; } impl HolderImpl for Ptr { fn set(&self, mut p: Ptr) { @@ -70,17 +81,21 @@ impl HolderImpl for Ptr { field_ptr!((*self), data).write(_p.to_owned_opt()) }; } - fn move_from(&self, _a0: Ptr) { - field!((*self), data) - .write(field!(_a0, data).with_mut(|__v: &mut Option>| __v.take())); - field!((*self), n).write({ (*_a0.upgrade().deref()).n }); - } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), data).with_mut(|__b0| { +} +impl MoveAssignable for Holder { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), data).with_mut(|__b0| { (*__b0) = field!(_a0, data).with_mut(|__v: &mut Option>| __v.take()); }); - field!((*self), n).write({ (*_a0.upgrade().deref()).n }); - return (*self).clone(); + field!((*this), n).write({ (*_a0.upgrade().deref()).n }); + return (*this).clone(); + } +} +impl MoveConstructible for Holder { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), data) + .write(field!(_a0, data).with_mut(|__v: &mut Option>| __v.take())); + field!((*this), n).write({ (*_a0.upgrade().deref()).n }); } } pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/unique_ptr_nested.rs b/tests/unit/out/refcount/unique_ptr_nested.rs index 821aca80d8..9aa85ac092 100644 --- a/tests/unit/out/refcount/unique_ptr_nested.rs +++ b/tests/unit/out/refcount/unique_ptr_nested.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Inner { #[offset(0)] @@ -14,7 +27,7 @@ pub struct Inner { #[offset(4)] pub y: i32, } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, MoveCtor, MoveAssign, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Default)] #[byte_size(8)] pub struct Outer { #[offset(0)] @@ -48,20 +61,18 @@ fn main_0() -> i32 { assert!(((sum + (b.as_pointer().read())) == 135)); return 0; } -pub trait OuterImpl { - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; -} -impl OuterImpl for Ptr { - fn move_from(&self, _a0: Ptr) { - field!((*self), inner) - .write(field!(_a0, inner).with_mut(|__v: &mut Option>| __v.take())); - } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), inner).with_mut(|__b0| { +impl MoveAssignable for Outer { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), inner).with_mut(|__b0| { (*__b0) = field!(_a0, inner).with_mut(|__v: &mut Option>| __v.take()); }); - return (*self).clone(); + return (*this).clone(); + } +} +impl MoveConstructible for Outer { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), inner) + .write(field!(_a0, inner).with_mut(|__v: &mut Option>| __v.take())); } } pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/unique_ptr_struct.rs b/tests/unit/out/refcount/unique_ptr_struct.rs index 3db805c34e..341e4cde7e 100644 --- a/tests/unit/out/refcount/unique_ptr_struct.rs +++ b/tests/unit/out/refcount/unique_ptr_struct.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Point { #[offset(0)] diff --git a/tests/unit/out/refcount/va_arg_mixed_types.rs b/tests/unit/out/refcount/va_arg_mixed_types.rs index 2dd7e4c91d..1c25468b4e 100644 --- a/tests/unit/out/refcount/va_arg_mixed_types.rs +++ b/tests/unit/out/refcount/va_arg_mixed_types.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct pair { #[offset(0)] diff --git a/tests/unit/out/refcount/va_arg_non_primitive_ptrs.rs b/tests/unit/out/refcount/va_arg_non_primitive_ptrs.rs index 7d5b5f9630..857161256c 100644 --- a/tests/unit/out/refcount/va_arg_non_primitive_ptrs.rs +++ b/tests/unit/out/refcount/va_arg_non_primitive_ptrs.rs @@ -6,7 +6,19 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct node { #[offset(0)] diff --git a/tests/unit/out/refcount/va_arg_struct_ctx.rs b/tests/unit/out/refcount/va_arg_struct_ctx.rs index caa0d0e30a..a3d6765015 100644 --- a/tests/unit/out/refcount/va_arg_struct_ctx.rs +++ b/tests/unit/out/refcount/va_arg_struct_ctx.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct context { #[offset(0)] @@ -23,7 +36,17 @@ pub fn set_error_0(mut ctx: Ptr, fmt: Ptr, __args: Box<[VaArg]>) { field!(ctx, last_error).write((*ap.borrow_mut()).arg::()); } } -#[derive(VaArg, FnPtrArg, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + ByteRepr, + Clone, + ZeroInitialization, +)] #[byte_size(8)] pub struct value { #[offset(0)] diff --git a/tests/unit/out/refcount/va_arg_void_ptr.rs b/tests/unit/out/refcount/va_arg_void_ptr.rs index 4e4cb67570..2b67f87af2 100644 --- a/tests/unit/out/refcount/va_arg_void_ptr.rs +++ b/tests/unit/out/refcount/va_arg_void_ptr.rs @@ -6,7 +6,19 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(16)] pub struct registry { #[offset(0)] diff --git a/tests/unit/out/refcount/va_list_field.rs b/tests/unit/out/refcount/va_list_field.rs index 30ecce7183..1ea33c79d7 100644 --- a/tests/unit/out/refcount/va_list_field.rs +++ b/tests/unit/out/refcount/va_list_field.rs @@ -31,7 +31,19 @@ pub fn sum_0(n: i32, __args: Box<[VaArg]>) -> i32 { return total; } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Destructible, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, )] #[cpp_from(Ptr , construct, mut_ptr)] #[byte_size(16)] @@ -62,7 +74,19 @@ pub fn sum_ptr_2(n: i32, __args: Box<[VaArg]>) -> i32 { }; return total; } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Cursor_3 { #[offset(0)] diff --git a/tests/unit/out/refcount/vector.rs b/tests/unit/out/refcount/vector.rs index 8d9bbcd66e..ccd42d5dc8 100644 --- a/tests/unit/out/refcount/vector.rs +++ b/tests/unit/out/refcount/vector.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] @@ -14,7 +27,15 @@ pub struct S { } pub fn copy_0(mut copy_vector: Vec) {} #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, MoveAssign, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + CopyAssignable, + Default, )] #[byte_size(48)] pub struct Foo { @@ -610,23 +631,21 @@ fn main_0() -> i32 { ); return 0; } -pub trait FooImpl { - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; -} -impl FooImpl for Ptr { - fn move_from(&self, _a0: Ptr) { - field!((*self), a).write(field!(_a0, a).with_mut(std::mem::take)); - field!((*self), b).write(field!(_a0, b).with_mut(std::mem::take)); - } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), a).with_mut(|__b0| { +impl MoveAssignable for Foo { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), a).with_mut(|__b0| { (*__b0) = field!(_a0, a).with_mut(std::mem::take); }); - field!((*self), b).with_mut(|__b0| { + field!((*this), b).with_mut(|__b0| { (*__b0) = field!(_a0, b).with_mut(std::mem::take); }); - return (*self).clone(); + return (*this).clone(); + } +} +impl MoveConstructible for Foo { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), a).write(field!(_a0, a).with_mut(std::mem::take)); + field!((*this), b).write(field!(_a0, b).with_mut(std::mem::take)); } } pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/vector_iter_range_ctor.rs b/tests/unit/out/refcount/vector_iter_range_ctor.rs index 6d3021f986..013d2f0247 100644 --- a/tests/unit/out/refcount/vector_iter_range_ctor.rs +++ b/tests/unit/out/refcount/vector_iter_range_ctor.rs @@ -6,14 +6,42 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct Degrees { #[offset(0)] pub value: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[cpp_into(i64, to_i64)] #[byte_size(4)] pub struct Reading { diff --git a/tests/unit/out/refcount/vector_subscript_direct.rs b/tests/unit/out/refcount/vector_subscript_direct.rs index f5558d0954..9cd15ba51b 100644 --- a/tests/unit/out/refcount/vector_subscript_direct.rs +++ b/tests/unit/out/refcount/vector_subscript_direct.rs @@ -6,7 +6,20 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(8)] pub struct Point { #[offset(0)] @@ -15,7 +28,15 @@ pub struct Point { pub y: i32, } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, MoveAssign, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + CopyAssignable, + Default, )] #[byte_size(48)] pub struct Holder { @@ -133,23 +154,21 @@ fn main_0() -> i32 { assert!(({ (*a.borrow())[1_usize] } == 10)); return 0; } -pub trait HolderImpl { - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; -} -impl HolderImpl for Ptr { - fn move_from(&self, _a0: Ptr) { - field!((*self), values).write(field!(_a0, values).with_mut(std::mem::take)); - field!((*self), points).write(field!(_a0, points).with_mut(std::mem::take)); - } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), values).with_mut(|__b0| { +impl MoveAssignable for Holder { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), values).with_mut(|__b0| { (*__b0) = field!(_a0, values).with_mut(std::mem::take); }); - field!((*self), points).with_mut(|__b0| { + field!((*this), points).with_mut(|__b0| { (*__b0) = field!(_a0, points).with_mut(std::mem::take); }); - return (*self).clone(); + return (*this).clone(); + } +} +impl MoveConstructible for Holder { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), values).write(field!(_a0, values).with_mut(std::mem::take)); + field!((*this), points).write(field!(_a0, points).with_mut(std::mem::take)); } } pub trait PointImpl { diff --git a/tests/unit/out/refcount/vector_with_allocator.rs b/tests/unit/out/refcount/vector_with_allocator.rs index baa5b6e9c0..6f3f2309f1 100644 --- a/tests/unit/out/refcount/vector_with_allocator.rs +++ b/tests/unit/out/refcount/vector_with_allocator.rs @@ -6,10 +6,36 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct TestAllocator_int_ {} -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(1)] pub struct TestAllocator_double_ {} pub fn copy_0(mut copy_vector: Vec) {} diff --git a/tests/unit/out/refcount/void_cast.rs b/tests/unit/out/refcount/void_cast.rs index 704036d77a..65e7929971 100644 --- a/tests/unit/out/refcount/void_cast.rs +++ b/tests/unit/out/refcount/void_cast.rs @@ -8,7 +8,15 @@ use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn unused_param_0(mut x: i32) {} #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveCtor, MoveAssign, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + CopyAssignable, + Default, )] #[byte_size(24)] pub struct NonTrivial { @@ -25,13 +33,26 @@ pub fn bump_and_return_4() -> i32 { (*side_effect_counter_3.with(Value::clone).borrow_mut()).prefix_inc(); return side_effect_counter_3.with(|rc| *rc.borrow()); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, + Default, +)] #[byte_size(4)] pub struct Holder { #[offset(0)] pub field: i32, } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, MoveCtor, MoveAssign, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Default)] #[byte_size(8)] pub struct NonCopyable { #[offset(0)] @@ -97,35 +118,31 @@ fn main_0() -> i32 { assert!((({ (*g.borrow()).value.clone() }.as_pointer().read()) == 9)); return 0; } -pub trait NonCopyableImpl { - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; -} -impl NonCopyableImpl for Ptr { - fn move_from(&self, _a0: Ptr) { - field!((*self), value) - .write(field!(_a0, value).with_mut(|__v: &mut Option>| __v.take())); - } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), value).with_mut(|__b0| { +impl MoveAssignable for NonCopyable { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), value).with_mut(|__b0| { (*__b0) = field!(_a0, value).with_mut(|__v: &mut Option>| __v.take()); }); - return (*self).clone(); + return (*this).clone(); } } -pub trait NonTrivialImpl { - fn move_from(&self, _a0: Ptr); - fn move_assign(&self, _a0: Ptr) -> Ptr; -} -impl NonTrivialImpl for Ptr { - fn move_from(&self, _a0: Ptr) { - field!((*self), data).write(field!(_a0, data).with_mut(std::mem::take)); +impl MoveConstructible for NonCopyable { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), value) + .write(field!(_a0, value).with_mut(|__v: &mut Option>| __v.take())); } - fn move_assign(&self, _a0: Ptr) -> Ptr { - field!((*self), data).with_mut(|__b0| { +} +impl MoveAssignable for NonTrivial { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), data).with_mut(|__b0| { (*__b0) = field!(_a0, data).with_mut(std::mem::take); }); - return (*self).clone(); + return (*this).clone(); + } +} +impl MoveConstructible for NonTrivial { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), data).write(field!(_a0, data).with_mut(std::mem::take)); } } pub fn __cpp2rust_init_globals() { diff --git a/tests/unit/out/unsafe/05_new.rs b/tests/unit/out/unsafe/05_new.rs index 6319da620d..54dc9210a1 100644 --- a/tests/unit/out/unsafe/05_new.rs +++ b/tests/unit/out/unsafe/05_new.rs @@ -7,10 +7,32 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct A {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct D {} impl D { pub unsafe fn operator_call(&self, mut ptr: *const A) { diff --git a/tests/unit/out/unsafe/10_struct.rs b/tests/unit/out/unsafe/10_struct.rs index 75a307ae5b..804aefd999 100644 --- a/tests/unit/out/unsafe/10_struct.rs +++ b/tests/unit/out/unsafe/10_struct.rs @@ -7,13 +7,35 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct GraphNode { pub dst: u32, pub next: *mut GraphNode, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Graph { pub V: u32, pub adj: *mut *mut GraphNode, @@ -31,7 +53,17 @@ impl Graph { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct Partial { pub p: *mut i32, } @@ -50,11 +82,33 @@ impl Default for Partial { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Declared {} impl Declared {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub i: i32, pub d: *mut Declared, diff --git a/tests/unit/out/unsafe/addr_of_global.rs b/tests/unit/out/unsafe/addr_of_global.rs index d8ffb6c456..20c2a4d111 100644 --- a/tests/unit/out/unsafe/addr_of_global.rs +++ b/tests/unit/out/unsafe/addr_of_global.rs @@ -7,12 +7,34 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Inner { pub value: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Outer { pub p: *mut Inner, } diff --git a/tests/unit/out/unsafe/anonymous-struct.rs b/tests/unit/out/unsafe/anonymous-struct.rs index a2cfc9f725..deb80beada 100644 --- a/tests/unit/out/unsafe/anonymous-struct.rs +++ b/tests/unit/out/unsafe/anonymous-struct.rs @@ -7,48 +7,136 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Outer_Named { pub a: i32, pub b: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct anon_0 { pub c: i32, pub d: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct anon_1 { pub g: i32, pub h: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct anon_2 { pub e: i32, pub f: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct anon_4 { pub j: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct anon_5 { pub k: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct anon_3 { pub i: i32, pub inner_named: anon_4, pub anon_5: anon_5, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Outer { pub named: Outer_Named, pub anonymous_named_0: anon_0, @@ -104,7 +192,18 @@ unsafe fn main_0() -> i32 { return 0; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct anon_6 { pub x: i32, pub z: i32, diff --git a/tests/unit/out/unsafe/anonymous-struct_c.rs b/tests/unit/out/unsafe/anonymous-struct_c.rs index 4bb61b622d..89fc5c8c89 100644 --- a/tests/unit/out/unsafe/anonymous-struct_c.rs +++ b/tests/unit/out/unsafe/anonymous-struct_c.rs @@ -7,48 +7,136 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Named { pub a: i32, pub b: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct anon_0 { pub c: i32, pub d: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct anon_1 { pub g: i32, pub h: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct anon_2 { pub e: i32, pub f: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct anon_4 { pub j: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct anon_5 { pub k: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct anon_3 { pub i: i32, pub inner_named: anon_4, pub anon_5: anon_5, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Outer { pub named: Named, pub anon0: anon_0, @@ -110,7 +198,18 @@ unsafe fn main_0() -> i32 { return 0; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct anon_6 { pub x: i32, pub z: i32, diff --git a/tests/unit/out/unsafe/anonymous_enum.rs b/tests/unit/out/unsafe/anonymous_enum.rs index 94d75a3a98..f3ab7be9d8 100644 --- a/tests/unit/out/unsafe/anonymous_enum.rs +++ b/tests/unit/out/unsafe/anonymous_enum.rs @@ -13,7 +13,18 @@ pub type anon_1 = u32; pub const anon_1_SECOND_A: anon_1 = 0; pub const anon_1_SECOND_B: anon_1 = 1; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub a: i32, } @@ -24,7 +35,18 @@ pub type anon_2 = u32; pub const anon_2_FIELD_A: anon_2 = 0; pub const anon_2_FIELD_B: anon_2 = 1; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct WithAnonField { pub a: i32, pub field: anon_2, diff --git a/tests/unit/out/unsafe/anonymous_enum_c.rs b/tests/unit/out/unsafe/anonymous_enum_c.rs index f34263d901..f7ce25d583 100644 --- a/tests/unit/out/unsafe/anonymous_enum_c.rs +++ b/tests/unit/out/unsafe/anonymous_enum_c.rs @@ -13,7 +13,18 @@ pub type anon_1 = u32; pub const anon_1_SECOND_A: anon_1 = 0; pub const anon_1_SECOND_B: anon_1 = 1; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub a: i32, } @@ -24,7 +35,18 @@ pub type anon_2 = u32; pub const anon_2_FIELD_A: anon_2 = 0; pub const anon_2_FIELD_B: anon_2 = 1; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct WithAnonField { pub a: i32, pub field: anon_2, diff --git a/tests/unit/out/unsafe/any.rs b/tests/unit/out/unsafe/any.rs index 4426625329..17fecb59cf 100644 --- a/tests/unit/out/unsafe/any.rs +++ b/tests/unit/out/unsafe/any.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Point { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/array_const_init.rs b/tests/unit/out/unsafe/array_const_init.rs index dd3390eaf6..e9aba73630 100644 --- a/tests/unit/out/unsafe/array_const_init.rs +++ b/tests/unit/out/unsafe/array_const_init.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub head: i32, pub tail: [i32; 3], @@ -21,7 +32,18 @@ pub static mut s_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe } }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct P { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/array_field_addr.rs b/tests/unit/out/unsafe/array_field_addr.rs index 319a264a92..d27713328b 100644 --- a/tests/unit/out/unsafe/array_field_addr.rs +++ b/tests/unit/out/unsafe/array_field_addr.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub before: i32, pub mask: [u8; 4], diff --git a/tests/unit/out/unsafe/array_of_noncopy_struct.rs b/tests/unit/out/unsafe/array_of_noncopy_struct.rs index cf44260f8f..770659061b 100644 --- a/tests/unit/out/unsafe/array_of_noncopy_struct.rs +++ b/tests/unit/out/unsafe/array_of_noncopy_struct.rs @@ -7,17 +7,21 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe)] +#[derive( + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, +)] pub struct NonCopy { pub data: Vec, pub tag: i32, } -impl NonCopy { - pub unsafe fn move_from(&mut self, _a0: *mut NonCopy) { +impl MoveConstructibleUnsafe for NonCopy { + unsafe fn move_constructor(&mut self, _a0: *mut NonCopy) { (&raw mut self.data).write(std::mem::take(&mut (*_a0).data)); (&raw mut self.tag).write((*_a0).tag); } - pub unsafe fn move_assign(&mut self, _a0: *mut NonCopy) -> *mut NonCopy { +} +impl MoveAssignableUnsafe for NonCopy { + unsafe fn move_assign(&mut self, _a0: *mut NonCopy) -> *mut NonCopy { { self.data = std::mem::take(&mut (*_a0).data); }; diff --git a/tests/unit/out/unsafe/array_reference.rs b/tests/unit/out/unsafe/array_reference.rs index 0bda2bcfe1..1faf6a520a 100644 --- a/tests/unit/out/unsafe/array_reference.rs +++ b/tests/unit/out/unsafe/array_reference.rs @@ -57,7 +57,18 @@ pub unsafe fn pick_10(s: *const [libc::c_char; 5]) -> *const [libc::c_char; 5] { return s; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Point { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/as_const.rs b/tests/unit/out/unsafe/as_const.rs index a5695608b5..362cabc88d 100644 --- a/tests/unit/out/unsafe/as_const.rs +++ b/tests/unit/out/unsafe/as_const.rs @@ -10,7 +10,18 @@ pub type Overload = u32; pub const Overload_kMutableOverload: Overload = 1; pub const Overload_kConstOverload: Overload = 2; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/assign_rhs_first.rs b/tests/unit/out/unsafe/assign_rhs_first.rs index 94d9dc5f88..d7c023133d 100644 --- a/tests/unit/out/unsafe/assign_rhs_first.rs +++ b/tests/unit/out/unsafe/assign_rhs_first.rs @@ -13,7 +13,18 @@ pub unsafe fn advance_1() -> i32 { return 10; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub ptr: *mut i32, } diff --git a/tests/unit/out/unsafe/assignment_single_eval.rs b/tests/unit/out/unsafe/assignment_single_eval.rs index 95a55113e5..6d0f234563 100644 --- a/tests/unit/out/unsafe/assignment_single_eval.rs +++ b/tests/unit/out/unsafe/assignment_single_eval.rs @@ -836,17 +836,50 @@ pub unsafe fn test_reference_members_9() { }); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Slot_6 { pub value: *mut u32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Slot_8 { pub value: *mut i16, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Slot_10 { pub value: *mut i32, } @@ -895,7 +928,18 @@ pub unsafe fn test_pointer_elements_11() { }); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Holder_12 { pub p: *mut i32, } @@ -921,7 +965,18 @@ pub unsafe fn test_reference_pointer_13() { }); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Node_14 { pub link: *mut *mut Node_14, } @@ -994,22 +1049,66 @@ pub unsafe fn test_reference_subfields_18() { }); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Index_16 { pub value: u32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Slot_17 { pub ref_: *mut Index_16, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Index_19 { pub value: i16, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Slot_20 { pub ref_: *mut Index_19, } @@ -1049,12 +1148,34 @@ pub unsafe fn observe_24(mut assigned: i32, mut stored: *const i32) -> i32 { return ((assigned) + (*stored)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct GlobalRecord_Inner { pub value: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct GlobalRecord { pub inner: GlobalRecord_Inner, } @@ -1320,19 +1441,52 @@ pub unsafe fn test_borrows_29() { static mut promoted_30: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 10_i16 }); static mut flag_31: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { false }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Record_32 { pub value: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Link_33 { pub next: *mut Link_33, } pub static mut selected_values_34: std::cell::LazyCell<[u32; 3]> = std::cell::LazyCell::new(|| unsafe { [0_u32, 20_u32, 30_u32] }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct IndexedBinding {} impl IndexedBinding { pub unsafe fn get_1_0(&mut self) -> *mut u32 { @@ -1551,7 +1705,18 @@ pub static mut global_array_45: std::cell::LazyCell<[u32; 3]> = pub static mut global_rows_46: std::cell::LazyCell<[[u32; 2]; 2]> = std::cell::LazyCell::new(|| unsafe { [[0_u32, 10_u32], [20_u32, 30_u32]] }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct IndexedMember { pub key: i32, pub value: u32, @@ -1810,7 +1975,18 @@ pub static mut scoped_pointers_53: std::cell::LazyCell<[*mut u32; 1]> = [(*std::cell::LazyCell::force_mut(&mut *&raw mut scoped_values_52)).as_mut_ptr()] }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct PointerSelector { pub ptr: *mut u32, } @@ -1967,16 +2143,24 @@ pub unsafe fn test_stable_containers_58() { } #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + CopyAssignableUnsafe, + Default, )] pub struct Counts_59 { pub counts: Vec, } -impl Counts_59 { - pub unsafe fn move_from(&mut self, _a0: *mut Counts_59) { +impl MoveConstructibleUnsafe for Counts_59 { + unsafe fn move_constructor(&mut self, _a0: *mut Counts_59) { (&raw mut self.counts).write(std::mem::take(&mut (*_a0).counts)); } - pub unsafe fn move_assign(&mut self, _a0: *mut Counts_59) -> *mut Counts_59 { +} +impl MoveAssignableUnsafe for Counts_59 { + unsafe fn move_assign(&mut self, _a0: *mut Counts_59) -> *mut Counts_59 { { self.counts = std::mem::take(&mut (*_a0).counts); }; @@ -1984,7 +2168,18 @@ impl Counts_59 { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Pair_60 { pub u: u32, pub f: i32, @@ -2286,12 +2481,34 @@ unsafe fn main_0() -> i32 { return 0; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Index_62 { pub value: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Owner_63 { pub values: [i32; 2], pub index: i32, diff --git a/tests/unit/out/unsafe/bounded_struct_ptr.rs b/tests/unit/out/unsafe/bounded_struct_ptr.rs index 19fdff786f..399e35c883 100644 --- a/tests/unit/out/unsafe/bounded_struct_ptr.rs +++ b/tests/unit/out/unsafe/bounded_struct_ptr.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Foo { pub x1: i32, pub x2: i32, diff --git a/tests/unit/out/unsafe/bst.rs b/tests/unit/out/unsafe/bst.rs index 46e5deefc6..e3205ee94c 100644 --- a/tests/unit/out/unsafe/bst.rs +++ b/tests/unit/out/unsafe/bst.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct node_t { pub left: *mut node_t, pub right: *mut node_t, diff --git a/tests/unit/out/unsafe/c_struct.rs b/tests/unit/out/unsafe/c_struct.rs index 37e28c701b..c175a0274b 100644 --- a/tests/unit/out/unsafe/c_struct.rs +++ b/tests/unit/out/unsafe/c_struct.rs @@ -7,19 +7,52 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Point { pub x: i32, pub y: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Line { pub start: Point, pub end: Point, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Node { pub value: i32, pub next: *mut Node, @@ -29,13 +62,35 @@ pub const Color_RED: Color = 0; pub const Color_GREEN: Color = 1; pub const Color_BLUE: Color = 2; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Inner { pub a: i32, pub b: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Container { pub inner: Inner, pub color: Color, diff --git a/tests/unit/out/unsafe/cast.rs b/tests/unit/out/unsafe/cast.rs index 0a9e9516bd..adafc9da4c 100644 --- a/tests/unit/out/unsafe/cast.rs +++ b/tests/unit/out/unsafe/cast.rs @@ -11,18 +11,51 @@ pub const E_A: E = 0; pub const E_B: E = 1; pub const E_C: E = 2; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Pair { pub x: i32, pub y: i32, } #[repr(C, align(64))] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Wide { pub c: libc::c_char, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Grid { pub h: i32, pub row: [i32; 3], @@ -30,18 +63,26 @@ pub struct Grid { } #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + CopyAssignableUnsafe, + Default, )] pub struct Bag { pub n: i32, pub items: Vec, } -impl Bag { - pub unsafe fn move_from(&mut self, _a0: *mut Bag) { +impl MoveConstructibleUnsafe for Bag { + unsafe fn move_constructor(&mut self, _a0: *mut Bag) { (&raw mut self.n).write((*_a0).n); (&raw mut self.items).write(std::mem::take(&mut (*_a0).items)); } - pub unsafe fn move_assign(&mut self, _a0: *mut Bag) -> *mut Bag { +} +impl MoveAssignableUnsafe for Bag { + unsafe fn move_assign(&mut self, _a0: *mut Bag) -> *mut Bag { self.n = (*_a0).n; { self.items = std::mem::take(&mut (*_a0).items); diff --git a/tests/unit/out/unsafe/cast_array_to_pointer_decay.rs b/tests/unit/out/unsafe/cast_array_to_pointer_decay.rs index b7b8fcacd7..3e45101478 100644 --- a/tests/unit/out/unsafe/cast_array_to_pointer_decay.rs +++ b/tests/unit/out/unsafe/cast_array_to_pointer_decay.rs @@ -17,7 +17,18 @@ pub unsafe fn strlen_1(mut s: *mut libc::c_char) -> i32 { return c; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Row { pub a: [i32; 3], } diff --git a/tests/unit/out/unsafe/class.rs b/tests/unit/out/unsafe/class.rs index 9a9fa256b4..879d638811 100644 --- a/tests/unit/out/unsafe/class.rs +++ b/tests/unit/out/unsafe/class.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Pair { pub first: i32, pub second: i32, @@ -42,7 +53,18 @@ impl Pair { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Route { pub path: Pair, pub cost: f64, @@ -55,7 +77,18 @@ impl Route { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Counter { pub v: i32, pub calls: i32, @@ -77,7 +110,18 @@ impl std::cmp::PartialEq for Counter { } impl std::cmp::Eq for Counter {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Tally { pub calls: i32, } diff --git a/tests/unit/out/unsafe/class_template_lazy_member.rs b/tests/unit/out/unsafe/class_template_lazy_member.rs index c0fbe7957c..9d59135042 100644 --- a/tests/unit/out/unsafe/class_template_lazy_member.rs +++ b/tests/unit/out/unsafe/class_template_lazy_member.rs @@ -7,12 +7,34 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Point { pub x: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Box_int_ { pub val: i32, } @@ -22,7 +44,18 @@ impl Box_int_ { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Box_Point_ { pub val: Point, } @@ -32,7 +65,18 @@ impl Box_Point_ { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Deduced_int_ { pub val: i32, } @@ -42,7 +86,18 @@ impl Deduced_int_ { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Deduced_Point_ { pub val: Point, } diff --git a/tests/unit/out/unsafe/class_templates.rs b/tests/unit/out/unsafe/class_templates.rs index 4876139df6..51de4eb7bc 100644 --- a/tests/unit/out/unsafe/class_templates.rs +++ b/tests/unit/out/unsafe/class_templates.rs @@ -8,7 +8,13 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + CopyAssignableUnsafe, + Default, )] pub struct MyContainer_int_ { vec_: Vec, @@ -36,10 +42,14 @@ impl MyContainer_int_ { self.vec_.push(a0_clone) }; } - pub unsafe fn move_from(&mut self, _a0: *mut MyContainer_int_) { +} +impl MoveConstructibleUnsafe for MyContainer_int_ { + unsafe fn move_constructor(&mut self, _a0: *mut MyContainer_int_) { (&raw mut self.vec_).write(std::mem::take(&mut (*_a0).vec_)); } - pub unsafe fn move_assign(&mut self, _a0: *mut MyContainer_int_) -> *mut MyContainer_int_ { +} +impl MoveAssignableUnsafe for MyContainer_int_ { + unsafe fn move_assign(&mut self, _a0: *mut MyContainer_int_) -> *mut MyContainer_int_ { { self.vec_ = std::mem::take(&mut (*_a0).vec_); }; @@ -48,7 +58,13 @@ impl MyContainer_int_ { } #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + CopyAssignableUnsafe, + Default, )] pub struct MyContainer_char_ { vec_: Vec, @@ -76,10 +92,14 @@ impl MyContainer_char_ { self.vec_.push(a0_clone) }; } - pub unsafe fn move_from(&mut self, _a0: *mut MyContainer_char_) { +} +impl MoveConstructibleUnsafe for MyContainer_char_ { + unsafe fn move_constructor(&mut self, _a0: *mut MyContainer_char_) { (&raw mut self.vec_).write(std::mem::take(&mut (*_a0).vec_)); } - pub unsafe fn move_assign(&mut self, _a0: *mut MyContainer_char_) -> *mut MyContainer_char_ { +} +impl MoveAssignableUnsafe for MyContainer_char_ { + unsafe fn move_assign(&mut self, _a0: *mut MyContainer_char_) -> *mut MyContainer_char_ { { self.vec_ = std::mem::take(&mut (*_a0).vec_); }; @@ -88,7 +108,13 @@ impl MyContainer_char_ { } #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + CopyAssignableUnsafe, + Default, )] pub struct MyContainer_float_ { vec_: Vec, @@ -116,10 +142,14 @@ impl MyContainer_float_ { self.vec_.push(a0_clone) }; } - pub unsafe fn move_from(&mut self, _a0: *mut MyContainer_float_) { +} +impl MoveConstructibleUnsafe for MyContainer_float_ { + unsafe fn move_constructor(&mut self, _a0: *mut MyContainer_float_) { (&raw mut self.vec_).write(std::mem::take(&mut (*_a0).vec_)); } - pub unsafe fn move_assign(&mut self, _a0: *mut MyContainer_float_) -> *mut MyContainer_float_ { +} +impl MoveAssignableUnsafe for MyContainer_float_ { + unsafe fn move_assign(&mut self, _a0: *mut MyContainer_float_) -> *mut MyContainer_float_ { { self.vec_ = std::mem::take(&mut (*_a0).vec_); }; @@ -127,7 +157,18 @@ impl MyContainer_float_ { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Boxed_short_ { pub value: i16, } @@ -140,7 +181,18 @@ impl Boxed_short_ { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Boxed_int_ { pub value: i32, } @@ -153,7 +205,18 @@ impl Boxed_int_ { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Boxed_long_ { pub value: i64, } @@ -166,7 +229,18 @@ impl Boxed_long_ { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Outer_int__Inner_int_ { pub t: i32, pub u: i32, @@ -177,7 +251,18 @@ impl Outer_int__Inner_int_ { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Outer_int_ { pub v: i32, } @@ -187,7 +272,18 @@ impl Outer_int_ { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Outer_long__Inner_int_ { pub t: i64, pub u: i32, @@ -198,7 +294,18 @@ impl Outer_long__Inner_int_ { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Outer_long__Inner_char_ { pub t: i64, pub u: libc::c_char, @@ -209,7 +316,18 @@ impl Outer_long__Inner_char_ { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Outer_long_ { pub v: i64, } @@ -219,7 +337,18 @@ impl Outer_long_ { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Elem { pub i: i32, } diff --git a/tests/unit/out/unsafe/clone_vs_move.rs b/tests/unit/out/unsafe/clone_vs_move.rs index c73dc0b25b..0903a48590 100644 --- a/tests/unit/out/unsafe/clone_vs_move.rs +++ b/tests/unit/out/unsafe/clone_vs_move.rs @@ -7,12 +7,34 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Bar { pub w: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Foo { pub x: i32, pub y: *mut i32, @@ -21,7 +43,18 @@ pub struct Foo { pub bar: Bar, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Refs { pub a: *mut i32, pub b: *mut i32, diff --git a/tests/unit/out/unsafe/comma_operator.rs b/tests/unit/out/unsafe/comma_operator.rs index 6e4e24a5dd..1bb2992193 100644 --- a/tests/unit/out/unsafe/comma_operator.rs +++ b/tests/unit/out/unsafe/comma_operator.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Pair { pub first: i32, pub second: i32, diff --git a/tests/unit/out/unsafe/complex_function.rs b/tests/unit/out/unsafe/complex_function.rs index e470507a2f..5d71f4df98 100644 --- a/tests/unit/out/unsafe/complex_function.rs +++ b/tests/unit/out/unsafe/complex_function.rs @@ -16,12 +16,34 @@ pub unsafe fn bar_2(x: *mut i32) -> *mut i32 { return x; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct X1 { pub v: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct X2 { pub v: *mut X1, } @@ -31,7 +53,18 @@ impl X2 { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct X3 { pub v: *mut X2, } @@ -41,7 +74,18 @@ impl X3 { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct X4 { pub v: X3, } diff --git a/tests/unit/out/unsafe/compound_assign_paren.rs b/tests/unit/out/unsafe/compound_assign_paren.rs index e35bbb0148..481866e84e 100644 --- a/tests/unit/out/unsafe/compound_assign_paren.rs +++ b/tests/unit/out/unsafe/compound_assign_paren.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Item { pub flags: u8, } diff --git a/tests/unit/out/unsafe/concepts.rs b/tests/unit/out/unsafe/concepts.rs index 3e71e246ce..031506d596 100644 --- a/tests/unit/out/unsafe/concepts.rs +++ b/tests/unit/out/unsafe/concepts.rs @@ -12,7 +12,18 @@ const _: () = assert!( "sizeof(int) == 4" ); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Sized {} impl Sized { pub unsafe fn size(&mut self) -> i32 { diff --git a/tests/unit/out/unsafe/constexpr_function.rs b/tests/unit/out/unsafe/constexpr_function.rs index 3848b7afbb..67a2636574 100644 --- a/tests/unit/out/unsafe/constexpr_function.rs +++ b/tests/unit/out/unsafe/constexpr_function.rs @@ -22,7 +22,18 @@ pub unsafe fn half_3(mut x: f64) -> f64 { return ((x) / (2_f64)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Flag { pub v: i32, } @@ -48,7 +59,18 @@ pub unsafe fn imm_7(mut b: bool) -> bool { return b; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct P { pub v: i32, } diff --git a/tests/unit/out/unsafe/constructor.rs b/tests/unit/out/unsafe/constructor.rs index 666fd35c87..56ad0535ed 100644 --- a/tests/unit/out/unsafe/constructor.rs +++ b/tests/unit/out/unsafe/constructor.rs @@ -9,7 +9,17 @@ use std::rc::Rc; pub static mut total_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, Default, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, )] #[cpp_from(i32, construct, value)] pub struct S { @@ -35,7 +45,18 @@ impl S { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] #[cpp_from(i32, construct_1, value)] pub struct Point { pub x: i32, diff --git a/tests/unit/out/unsafe/container_element_receiver.rs b/tests/unit/out/unsafe/container_element_receiver.rs index c6755e8cdb..02ff73af59 100644 --- a/tests/unit/out/unsafe/container_element_receiver.rs +++ b/tests/unit/out/unsafe/container_element_receiver.rs @@ -7,13 +7,22 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Holder { pub ref_: *mut Vec, pub vec_: Vec, } -impl Holder { - pub unsafe fn move_from(&mut self, _a0: *mut Holder) { +impl MoveConstructibleUnsafe for Holder { + unsafe fn move_constructor(&mut self, _a0: *mut Holder) { (&raw mut self.ref_).write((*_a0).ref_); (&raw mut self.vec_).write(std::mem::take(&mut (*_a0).vec_)); } diff --git a/tests/unit/out/unsafe/container_field_addr.rs b/tests/unit/out/unsafe/container_field_addr.rs index 9886cba782..64d0b37510 100644 --- a/tests/unit/out/unsafe/container_field_addr.rs +++ b/tests/unit/out/unsafe/container_field_addr.rs @@ -8,18 +8,26 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + CopyAssignableUnsafe, + Default, )] pub struct S { pub tag: i32, pub v: Vec, } -impl S { - pub unsafe fn move_from(&mut self, _a0: *mut S) { +impl MoveConstructibleUnsafe for S { + unsafe fn move_constructor(&mut self, _a0: *mut S) { (&raw mut self.tag).write((*_a0).tag); (&raw mut self.v).write(std::mem::take(&mut (*_a0).v)); } - pub unsafe fn move_assign(&mut self, _a0: *mut S) -> *mut S { +} +impl MoveAssignableUnsafe for S { + unsafe fn move_assign(&mut self, _a0: *mut S) -> *mut S { self.tag = (*_a0).tag; { self.v = std::mem::take(&mut (*_a0).v); diff --git a/tests/unit/out/unsafe/conversion_operator_same_translation.rs b/tests/unit/out/unsafe/conversion_operator_same_translation.rs index b03dc334a3..071ecdf5ef 100644 --- a/tests/unit/out/unsafe/conversion_operator_same_translation.rs +++ b/tests/unit/out/unsafe/conversion_operator_same_translation.rs @@ -7,7 +7,19 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_into(libc::c_char, to_libcc_char)] #[cpp_into(u8, to_u8)] pub struct S { @@ -22,7 +34,19 @@ impl S { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_into(i64, to_i64_1)] pub struct T { pub v: i32, diff --git a/tests/unit/out/unsafe/copy_assign.rs b/tests/unit/out/unsafe/copy_assign.rs index 2eebab6f65..160e9ff630 100644 --- a/tests/unit/out/unsafe/copy_assign.rs +++ b/tests/unit/out/unsafe/copy_assign.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub static mut assigns_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyAssignUnsafe, Default)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + MoveConstructibleUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Partial { pub v: i32, pub keep: i32, @@ -18,11 +25,15 @@ impl Partial { (&raw mut self.v).write(v); (&raw mut self.keep).write(keep); } - pub unsafe fn copy_from(&mut self, o: *const Partial) { +} +impl CopyConstructibleUnsafe for Partial { + unsafe fn copy_constructor(&mut self, o: *const Partial) { (&raw mut self.v).write((*o).v); (&raw mut self.keep).write((*o).keep); } - pub unsafe fn copy_assign(&mut self, o: *const Partial) -> *mut Partial { +} +impl CopyAssignableUnsafe for Partial { + unsafe fn copy_assign(&mut self, o: *const Partial) -> *mut Partial { if (((self as *mut Partial).cast_const()) == (o)) { return &mut (*(self as *mut Partial)); } @@ -35,13 +46,23 @@ impl Clone for Partial { fn clone(&self) -> Self { unsafe { let mut __v: Partial = ::zero_init(); - Partial::copy_from(&mut __v, self as *const Partial); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const Partial); __v } } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct NonConstAssign { pub mark: i32, } @@ -70,7 +91,16 @@ impl Default for NonConstAssign { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyAssignUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + MoveAssignableUnsafe, +)] pub struct RefQualified { pub mark: i32, } @@ -78,7 +108,9 @@ impl RefQualified { pub unsafe fn construct(&mut self) { (&raw mut self.mark).write(0); } - pub unsafe fn copy_assign(&mut self, o: *const RefQualified) -> *mut RefQualified { +} +impl CopyAssignableUnsafe for RefQualified { + unsafe fn copy_assign(&mut self, o: *const RefQualified) -> *mut RefQualified { self.mark = (((*o).mark) + (1)); return &mut (*(self as *mut RefQualified)); } @@ -95,16 +127,25 @@ impl Default for RefQualified { } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyAssignUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Holder { pub p: Partial, pub arr: [Partial; 2], } -impl Holder { - pub unsafe fn copy_assign(&mut self, _a0: *const Holder) -> *mut Holder { +impl CopyAssignableUnsafe for Holder { + unsafe fn copy_assign(&mut self, _a0: *const Holder) -> *mut Holder { (unsafe { let _o: *const Partial = &(*_a0).p; - Partial::copy_assign(&mut self.p, _o) + CopyAssignableUnsafe::copy_assign(&mut self.p, _o) }); { let mut __i0: usize = 0_usize; @@ -112,7 +153,7 @@ impl Holder { 'for_body: { (unsafe { let _o: *const Partial = &(*_a0).arr[(__i0)]; - Partial::copy_assign(&mut self.arr[(__i0)], _o) + CopyAssignableUnsafe::copy_assign(&mut self.arr[(__i0)], _o) }); } __i0.prefix_inc(); @@ -123,7 +164,15 @@ impl Holder { } pub static mut copies_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyAssignUnsafe, Default)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + MoveConstructibleUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct CopyCounted { pub v: i32, @@ -132,11 +181,15 @@ impl CopyCounted { pub unsafe fn construct(&mut self, mut v: i32) { (&raw mut self.v).write(v); } - pub unsafe fn copy_from(&mut self, o: *const CopyCounted) { +} +impl CopyConstructibleUnsafe for CopyCounted { + unsafe fn copy_constructor(&mut self, o: *const CopyCounted) { (&raw mut self.v).write((*o).v); (*std::cell::LazyCell::force_mut(&mut *&raw mut copies_1)).prefix_inc(); } - pub unsafe fn copy_assign(&mut self, _a0: *const CopyCounted) -> *mut CopyCounted { +} +impl CopyAssignableUnsafe for CopyCounted { + unsafe fn copy_assign(&mut self, _a0: *const CopyCounted) -> *mut CopyCounted { self.v = (*_a0).v; return &mut (*(self as *mut CopyCounted)); } @@ -145,22 +198,31 @@ impl Clone for CopyCounted { fn clone(&self) -> Self { unsafe { let mut __v: CopyCounted = ::zero_init(); - CopyCounted::copy_from(&mut __v, self as *const CopyCounted); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const CopyCounted); __v } } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyAssignUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct HasCopyCounted { pub c: CopyCounted, pub arr: [CopyCounted; 2], } -impl HasCopyCounted { - pub unsafe fn copy_assign(&mut self, _a0: *const HasCopyCounted) -> *mut HasCopyCounted { +impl CopyAssignableUnsafe for HasCopyCounted { + unsafe fn copy_assign(&mut self, _a0: *const HasCopyCounted) -> *mut HasCopyCounted { (unsafe { let _arg0: *const CopyCounted = &(*_a0).c; - CopyCounted::copy_assign(&mut self.c, _arg0) + CopyAssignableUnsafe::copy_assign(&mut self.c, _arg0) }); { let mut __tmp_0 = { ((&mut self.arr as *mut [CopyCounted; 2]) as *mut ::libc::c_void) }; @@ -196,15 +258,20 @@ unsafe fn main_0() -> i32 { Partial::construct(&mut __v, { 3 }, { 300 }); __v }; - (unsafe { Partial::copy_assign(&mut a, &b) }); + (unsafe { CopyAssignableUnsafe::copy_assign(&mut a, &b) }); assert!(((a.v) == (2)) && ((a.keep) == (100))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut assigns_0)) == (1))); - (unsafe { Partial::copy_assign(&mut c, &(*(unsafe { Partial::copy_assign(&mut a, &b) }))) }); + (unsafe { + CopyAssignableUnsafe::copy_assign( + &mut c, + &(*(unsafe { CopyAssignableUnsafe::copy_assign(&mut a, &b) })), + ) + }); assert!(((c.v) == (2)) && ((c.keep) == (300))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut assigns_0)) == (3))); (unsafe { let _o: *const Partial = &a; - Partial::copy_assign(&mut a, _o) + CopyAssignableUnsafe::copy_assign(&mut a, _o) }); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut assigns_0)) == (3))); (unsafe { @@ -213,15 +280,15 @@ unsafe fn main_0() -> i32 { Partial::construct(&mut __v, { 9 }, { 900 }); __v }; - Partial::copy_assign(&mut a, &mut _o) + CopyAssignableUnsafe::copy_assign(&mut a, &mut _o) }); assert!(((a.v) == (9)) && ((a.keep) == (100))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut assigns_0)) == (4))); let ra: *mut Partial = &mut a; - (unsafe { Partial::copy_assign(&mut (*ra), &c) }); + (unsafe { CopyAssignableUnsafe::copy_assign(&mut (*ra), &c) }); assert!(((a.v) == (2))); let mut pa: *mut Partial = (&mut a as *mut Partial); - (unsafe { Partial::copy_assign(&mut (*pa), &b) }); + (unsafe { CopyAssignableUnsafe::copy_assign(&mut (*pa), &b) }); assert!(((a.v) == (2))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut assigns_0)) == (6))); let mut h: Holder = Holder { @@ -243,8 +310,8 @@ unsafe fn main_0() -> i32 { }, ], }; - (unsafe { Partial::copy_assign(&mut h.p, &b) }); - (unsafe { Partial::copy_assign(&mut h.arr[(1) as usize], &c) }); + (unsafe { CopyAssignableUnsafe::copy_assign(&mut h.p, &b) }); + (unsafe { CopyAssignableUnsafe::copy_assign(&mut h.arr[(1) as usize], &c) }); assert!(((h.p.v) == (2)) && ((h.p.keep) == (40))); assert!(((h.arr[(1) as usize].v) == (2)) && ((h.arr[(1) as usize].keep) == (60))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut assigns_0)) == (8))); @@ -282,7 +349,7 @@ unsafe fn main_0() -> i32 { RefQualified::construct(&mut __v); __v }; - (unsafe { RefQualified::copy_assign(&mut r1, &r) }); + (unsafe { CopyAssignableUnsafe::copy_assign(&mut r1, &r) }); assert!(((r1.mark) == (1))); let mut h2: Holder = Holder { p: { @@ -303,7 +370,7 @@ unsafe fn main_0() -> i32 { }, ], }; - (unsafe { Holder::copy_assign(&mut h2, &h) }); + (unsafe { CopyAssignableUnsafe::copy_assign(&mut h2, &h) }); assert!(((h2.p.v) == (2)) && ((h2.p.keep) == (70))); assert!(((h2.arr[(1) as usize].v) == (2)) && ((h2.arr[(1) as usize].keep) == (90))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut assigns_0)) == (11))); @@ -317,7 +384,7 @@ unsafe fn main_0() -> i32 { CopyCounted::construct(&mut __v, { 2 }); __v }; - (unsafe { CopyCounted::copy_assign(&mut cc1, &cc2) }); + (unsafe { CopyAssignableUnsafe::copy_assign(&mut cc1, &cc2) }); assert!(((cc1.v) == (2))); let mut hc1: HasCopyCounted = HasCopyCounted { c: { @@ -357,7 +424,7 @@ unsafe fn main_0() -> i32 { }, ], }; - (unsafe { HasCopyCounted::copy_assign(&mut hc1, &hc2) }); + (unsafe { CopyAssignableUnsafe::copy_assign(&mut hc1, &hc2) }); assert!( (((hc1.c.v) == (4)) && ((hc1.arr[(0) as usize].v) == (5))) && ((hc1.arr[(1) as usize].v) == (6)) diff --git a/tests/unit/out/unsafe/copy_ctor.rs b/tests/unit/out/unsafe/copy_ctor.rs index be812d8f53..0b1e99b307 100644 --- a/tests/unit/out/unsafe/copy_ctor.rs +++ b/tests/unit/out/unsafe/copy_ctor.rs @@ -8,7 +8,15 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub static mut copies_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyAssignUnsafe, Default)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + MoveConstructibleUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct Counted { pub v: i32, @@ -17,11 +25,15 @@ impl Counted { pub unsafe fn construct(&mut self, mut v: i32) { (&raw mut self.v).write(v); } - pub unsafe fn copy_from(&mut self, o: *const Counted) { +} +impl CopyConstructibleUnsafe for Counted { + unsafe fn copy_constructor(&mut self, o: *const Counted) { (&raw mut self.v).write((*o).v); (*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)).prefix_inc(); } - pub unsafe fn copy_assign(&mut self, _a0: *const Counted) -> *mut Counted { +} +impl CopyAssignableUnsafe for Counted { + unsafe fn copy_assign(&mut self, _a0: *const Counted) -> *mut Counted { self.v = (*_a0).v; return &mut (*(self as *mut Counted)); } @@ -30,13 +42,20 @@ impl Clone for Counted { fn clone(&self) -> Self { unsafe { let mut __v: Counted = ::zero_init(); - Counted::copy_from(&mut __v, self as *const Counted); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const Counted); __v } } } #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyAssignUnsafe)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + MoveAssignableUnsafe, +)] pub struct NonConst { pub mark: i32, } @@ -50,7 +69,9 @@ impl NonConst { pub unsafe fn construct_2(&mut self, o: *const NonConst) { (&raw mut self.mark).write((((*o).mark) + (10))); } - pub unsafe fn copy_assign(&mut self, _a0: *const NonConst) -> *mut NonConst { +} +impl CopyAssignableUnsafe for NonConst { + unsafe fn copy_assign(&mut self, _a0: *const NonConst) -> *mut NonConst { self.mark = (*_a0).mark; return &mut (*(self as *mut NonConst)); } @@ -76,7 +97,15 @@ impl Default for NonConst { } } #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyAssignUnsafe, Default)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + MoveConstructibleUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct Ignored { pub v: i32, @@ -85,11 +114,15 @@ impl Ignored { pub unsafe fn construct(&mut self, mut v: i32) { (&raw mut self.v).write(v); } - pub unsafe fn copy_from(&mut self, _a0: *const Ignored) { +} +impl CopyConstructibleUnsafe for Ignored { + unsafe fn copy_constructor(&mut self, _a0: *const Ignored) { (&raw mut self.v).write(-1_i32); (*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)).prefix_inc(); } - pub unsafe fn copy_assign(&mut self, _a0: *const Ignored) -> *mut Ignored { +} +impl CopyAssignableUnsafe for Ignored { + unsafe fn copy_assign(&mut self, _a0: *const Ignored) -> *mut Ignored { self.v = (*_a0).v; return &mut (*(self as *mut Ignored)); } @@ -98,22 +131,31 @@ impl Clone for Ignored { fn clone(&self) -> Self { unsafe { let mut __v: Ignored = ::zero_init(); - Ignored::copy_from(&mut __v, self as *const Ignored); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const Ignored); __v } } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyAssignUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Holder { pub c: Counted, pub arr: [Counted; 2], } -impl Holder { - pub unsafe fn copy_assign(&mut self, _a0: *const Holder) -> *mut Holder { +impl CopyAssignableUnsafe for Holder { + unsafe fn copy_assign(&mut self, _a0: *const Holder) -> *mut Holder { (unsafe { let _arg0: *const Counted = &(*_a0).c; - Counted::copy_assign(&mut self.c, _arg0) + CopyAssignableUnsafe::copy_assign(&mut self.c, _arg0) }); { let mut __tmp_0 = { ((&mut self.arr as *mut [Counted; 2]) as *mut ::libc::c_void) }; @@ -127,7 +169,15 @@ impl Holder { } } #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, CppFromUnsafe, Default)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct Box_int_ { pub val: i32, @@ -136,10 +186,14 @@ impl Box_int_ { pub unsafe fn construct(&mut self, mut v: i32) { (&raw mut self.val).write(v); } - pub unsafe fn copy_from(&mut self, o: *const Box_int_) { +} +impl CopyConstructibleUnsafe for Box_int_ { + unsafe fn copy_constructor(&mut self, o: *const Box_int_) { (&raw mut self.val).write((*o).val); } - pub unsafe fn move_from(&mut self, _a0: *mut Box_int_) { +} +impl MoveConstructibleUnsafe for Box_int_ { + unsafe fn move_constructor(&mut self, _a0: *mut Box_int_) { (&raw mut self.val).write((*_a0).val); } } @@ -147,27 +201,44 @@ impl Clone for Box_int_ { fn clone(&self) -> Self { unsafe { let mut __v: Box_int_ = ::zero_init(); - Box_int_::copy_from(&mut __v, self as *const Box_int_); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const Box_int_); __v } } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Owner { pub box_: Box_int_, } -impl Owner { - pub unsafe fn move_from(&mut self, _a0: *mut Owner) { +impl MoveConstructibleUnsafe for Owner { + unsafe fn move_constructor(&mut self, _a0: *mut Owner) { (&raw mut self.box_).write({ let mut __v: Box_int_ = ::zero_init(); - Box_int_::move_from(&mut __v, { &mut (*_a0).box_ }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut (*_a0).box_ }); __v }); } } #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyAssignUnsafe, Default)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + MoveConstructibleUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct OutOfLine { pub v: i32, @@ -176,11 +247,15 @@ impl OutOfLine { pub unsafe fn construct(&mut self, mut v: i32) { (&raw mut self.v).write(v); } - pub unsafe fn copy_from(&mut self, o: *const OutOfLine) { +} +impl CopyConstructibleUnsafe for OutOfLine { + unsafe fn copy_constructor(&mut self, o: *const OutOfLine) { (&raw mut self.v).write((((*o).v) + (100))); (*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)).prefix_inc(); } - pub unsafe fn copy_assign(&mut self, _a0: *const OutOfLine) -> *mut OutOfLine { +} +impl CopyAssignableUnsafe for OutOfLine { + unsafe fn copy_assign(&mut self, _a0: *const OutOfLine) -> *mut OutOfLine { self.v = (*_a0).v; return &mut (*(self as *mut OutOfLine)); } @@ -189,23 +264,27 @@ impl Clone for OutOfLine { fn clone(&self) -> Self { unsafe { let mut __v: OutOfLine = ::zero_init(); - OutOfLine::copy_from(&mut __v, self as *const OutOfLine); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const OutOfLine); __v } } } -impl OutOfLine {} +impl CopyConstructibleUnsafe for OutOfLine {} #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyAssignUnsafe)] +#[derive( + VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, +)] pub struct Tracked { pub copied_from: i32, } -impl Tracked { - pub unsafe fn copy_from(&mut self, o: *const Tracked) { +impl CopyConstructibleUnsafe for Tracked { + unsafe fn copy_constructor(&mut self, o: *const Tracked) { (&raw mut self.copied_from).write(0); (*(&raw const (*o).copied_from).cast_mut()).prefix_inc(); } - pub unsafe fn copy_assign(&mut self, o: *const Tracked) -> *mut Tracked { +} +impl CopyAssignableUnsafe for Tracked { + unsafe fn copy_assign(&mut self, o: *const Tracked) -> *mut Tracked { (*(&raw const (*o).copied_from).cast_mut()).prefix_inc(); return &mut (*(self as *mut Tracked)); } @@ -214,7 +293,7 @@ impl Clone for Tracked { fn clone(&self) -> Self { unsafe { let mut __v: Tracked = ::zero_init(); - Tracked::copy_from(&mut __v, self as *const Tracked); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const Tracked); __v } } @@ -238,7 +317,7 @@ pub unsafe fn make_3(mut v: i32) -> Counted { }; return { let mut __v: Counted = ::zero_init(); - Counted::copy_from(&mut __v, { &c }); + CopyConstructibleUnsafe::copy_constructor(&mut __v, { &c }); __v }; } @@ -256,17 +335,17 @@ unsafe fn main_0() -> i32 { }; let mut b: Counted = { let mut __v: Counted = ::zero_init(); - Counted::copy_from(&mut __v, { &a }); + CopyConstructibleUnsafe::copy_constructor(&mut __v, { &a }); __v }; let mut c: Counted = { let mut __v: Counted = ::zero_init(); - Counted::copy_from(&mut __v, { &a }); + CopyConstructibleUnsafe::copy_constructor(&mut __v, { &a }); __v }; let mut d: Counted = { let mut __v: Counted = ::zero_init(); - Counted::copy_from(&mut __v, { &a }); + CopyConstructibleUnsafe::copy_constructor(&mut __v, { &a }); __v }; assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (3))); @@ -275,7 +354,7 @@ unsafe fn main_0() -> i32 { ((unsafe { by_value_2({ let mut __v: Counted = ::zero_init(); - Counted::copy_from(&mut __v, { &a }); + CopyConstructibleUnsafe::copy_constructor(&mut __v, { &a }); __v }) }) == (1)) @@ -298,7 +377,7 @@ unsafe fn main_0() -> i32 { }; let mut h: Counted = { let mut __v: Counted = ::zero_init(); - Counted::copy_from(&mut __v, { &g }); + CopyConstructibleUnsafe::copy_constructor(&mut __v, { &g }); __v }; assert!(((h.v) == (7))); @@ -342,7 +421,7 @@ unsafe fn main_0() -> i32 { }; let mut i2: Ignored = { let mut __v: Ignored = ::zero_init(); - Ignored::copy_from(&mut __v, { &i1 }); + CopyConstructibleUnsafe::copy_constructor(&mut __v, { &i1 }); __v }; assert!(((i1.v) == (1)) && ((i2.v) == (-1_i32))); @@ -356,7 +435,7 @@ unsafe fn main_0() -> i32 { }; let mut o2: Owner = { let mut __v: Owner = ::zero_init(); - Owner::move_from(&mut __v, { &mut o }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut o }); __v }; assert!(((o2.box_.val) == (3))); @@ -367,7 +446,7 @@ unsafe fn main_0() -> i32 { }; let mut ol2: OutOfLine = { let mut __v: OutOfLine = ::zero_init(); - OutOfLine::copy_from(&mut __v, { &ol1 }); + CopyConstructibleUnsafe::copy_constructor(&mut __v, { &ol1 }); __v }; assert!(((ol2.v) == (105))); @@ -397,15 +476,15 @@ unsafe fn main_0() -> i32 { let mut t1: Tracked = ::default(); let mut t2: Tracked = { let mut __v: Tracked = ::zero_init(); - Tracked::copy_from(&mut __v, { &t1 }); + CopyConstructibleUnsafe::copy_constructor(&mut __v, { &t1 }); __v }; - (unsafe { Tracked::copy_assign(&mut t2, &t1) }); + (unsafe { CopyAssignableUnsafe::copy_assign(&mut t2, &t1) }); assert!(((t1.copied_from) == (2))); let ct: Tracked = ::default(); let mut t3: Tracked = { let mut __v: Tracked = ::zero_init(); - Tracked::copy_from(&mut __v, { &ct }); + CopyConstructibleUnsafe::copy_constructor(&mut __v, { &ct }); __v }; (unsafe { touch_1((&ct as *const Tracked)) }); diff --git a/tests/unit/out/unsafe/copy_move_defaulted.rs b/tests/unit/out/unsafe/copy_move_defaulted.rs index f7770e3ba4..c3d71c5c65 100644 --- a/tests/unit/out/unsafe/copy_move_defaulted.rs +++ b/tests/unit/out/unsafe/copy_move_defaulted.rs @@ -7,13 +7,32 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Inner { pub x: i32, } #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, Default, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, )] #[cpp_from(i32, construct, value)] pub struct Explicit { @@ -30,7 +49,18 @@ impl Explicit { pub unsafe fn destructor(&mut self) {} } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Implicit { pub v: i32, pub inner: Inner, @@ -43,9 +73,8 @@ pub struct Implicit { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MoveCtorUnsafe, CppFromUnsafe, - MoveAssignUnsafe, + CopyAssignableUnsafe, Default, )] #[cpp_from(i32, construct, value)] @@ -56,27 +85,22 @@ impl DefaultCopyUserMove { pub unsafe fn construct(&mut self, mut v: i32) { (&raw mut self.v).write(v); } - pub unsafe fn move_from(&mut self, o: *mut DefaultCopyUserMove) { +} +impl MoveConstructibleUnsafe for DefaultCopyUserMove { + unsafe fn move_constructor(&mut self, o: *mut DefaultCopyUserMove) { (&raw mut self.v).write((*o).v); (*o).v = 0; } - pub unsafe fn move_assign(&mut self, o: *mut DefaultCopyUserMove) -> *mut DefaultCopyUserMove { +} +impl MoveAssignableUnsafe for DefaultCopyUserMove { + unsafe fn move_assign(&mut self, o: *mut DefaultCopyUserMove) -> *mut DefaultCopyUserMove { self.v = (*o).v; (*o).v = 0; return &mut (*(self as *mut DefaultCopyUserMove)); } } #[repr(C)] -#[derive( - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - MoveCtorUnsafe, - CppFromUnsafe, - CopyAssignUnsafe, - MoveAssignUnsafe, - Default, -)] +#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] #[cpp_from(i32, construct, value)] pub struct UserCopyDefaultMove { pub v: i32, @@ -85,23 +109,25 @@ impl UserCopyDefaultMove { pub unsafe fn construct(&mut self, mut v: i32) { (&raw mut self.v).write(v); } - pub unsafe fn copy_from(&mut self, o: *const UserCopyDefaultMove) { +} +impl CopyConstructibleUnsafe for UserCopyDefaultMove { + unsafe fn copy_constructor(&mut self, o: *const UserCopyDefaultMove) { (&raw mut self.v).write((((*o).v) + (100))); } - pub unsafe fn move_from(&mut self, _a0: *mut UserCopyDefaultMove) { +} +impl MoveConstructibleUnsafe for UserCopyDefaultMove { + unsafe fn move_constructor(&mut self, _a0: *mut UserCopyDefaultMove) { (&raw mut self.v).write((*_a0).v); } - pub unsafe fn copy_assign( - &mut self, - o: *const UserCopyDefaultMove, - ) -> *mut UserCopyDefaultMove { +} +impl CopyAssignableUnsafe for UserCopyDefaultMove { + unsafe fn copy_assign(&mut self, o: *const UserCopyDefaultMove) -> *mut UserCopyDefaultMove { self.v = (((*o).v) + (100)); return &mut (*(self as *mut UserCopyDefaultMove)); } - pub unsafe fn move_assign( - &mut self, - _a0: *mut UserCopyDefaultMove, - ) -> *mut UserCopyDefaultMove { +} +impl MoveAssignableUnsafe for UserCopyDefaultMove { + unsafe fn move_assign(&mut self, _a0: *mut UserCopyDefaultMove) -> *mut UserCopyDefaultMove { self.v = (*_a0).v; return &mut (*(self as *mut UserCopyDefaultMove)); } @@ -110,15 +136,13 @@ impl Clone for UserCopyDefaultMove { fn clone(&self) -> Self { unsafe { let mut __v: UserCopyDefaultMove = ::zero_init(); - UserCopyDefaultMove::copy_from(&mut __v, self as *const UserCopyDefaultMove); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const UserCopyDefaultMove); __v } } } #[repr(C)] -#[derive( - FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, CppFromUnsafe, MoveAssignUnsafe, Default, -)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] #[cpp_from(i32, construct, value)] pub struct Buffer { pub data: Vec, @@ -137,7 +161,9 @@ impl Buffer { self.rows.push(a0_clone) }; } - pub unsafe fn move_from(&mut self, _a0: *mut Buffer) { +} +impl MoveConstructibleUnsafe for Buffer { + unsafe fn move_constructor(&mut self, _a0: *mut Buffer) { (&raw mut self.data).write(std::mem::take(&mut (*_a0).data)); (&raw mut self.rows).write(std::mem::take(&mut (*_a0).rows)); (&raw mut self.n).write((*_a0).n); @@ -145,7 +171,9 @@ impl Buffer { (*_a0).arr[(__i)] })); } - pub unsafe fn move_assign(&mut self, _a0: *mut Buffer) -> *mut Buffer { +} +impl MoveAssignableUnsafe for Buffer { + unsafe fn move_assign(&mut self, _a0: *mut Buffer) -> *mut Buffer { { self.data = std::mem::take(&mut (*_a0).data); }; @@ -165,15 +193,15 @@ impl Buffer { } } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, Default)] pub struct Owner { pub data: Vec, pub n: i32, pub arr: [i32; 2], pub p: Option>, } -impl Owner { - pub unsafe fn move_from(&mut self, _a0: *mut Owner) { +impl MoveConstructibleUnsafe for Owner { + unsafe fn move_constructor(&mut self, _a0: *mut Owner) { (&raw mut self.data).write(std::mem::take(&mut (*_a0).data)); (&raw mut self.n).write((*_a0).n); (&raw mut self.arr).write(std::array::from_fn::<_, 2, _>(|__i: usize| { @@ -181,7 +209,9 @@ impl Owner { })); (&raw mut self.p).write((*_a0).p.take()); } - pub unsafe fn move_assign(&mut self, _a0: *mut Owner) -> *mut Owner { +} +impl MoveAssignableUnsafe for Owner { + unsafe fn move_assign(&mut self, _a0: *mut Owner) -> *mut Owner { { self.data = std::mem::take(&mut (*_a0).data); }; @@ -202,16 +232,24 @@ impl Owner { } #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + CopyAssignableUnsafe, + Default, )] pub struct Copyable { pub data: Vec, } -impl Copyable { - pub unsafe fn move_from(&mut self, _a0: *mut Copyable) { +impl MoveConstructibleUnsafe for Copyable { + unsafe fn move_constructor(&mut self, _a0: *mut Copyable) { (&raw mut self.data).write(std::mem::take(&mut (*_a0).data)); } - pub unsafe fn move_assign(&mut self, _a0: *mut Copyable) -> *mut Copyable { +} +impl MoveAssignableUnsafe for Copyable { + unsafe fn move_assign(&mut self, _a0: *mut Copyable) -> *mut Copyable { { self.data = std::mem::take(&mut (*_a0).data); }; @@ -219,15 +257,7 @@ impl Copyable { } } #[repr(C)] -#[derive( - FnPtrArg, - ZeroInitializationUnsafe, - MoveCtorUnsafe, - CppFromUnsafe, - MoveAssignUnsafe, - DestructibleUnsafe, - Default, -)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, Default)] #[cpp_from(i32, construct, value)] pub struct Holder { pub inner: Inner, @@ -244,12 +274,16 @@ impl Holder { }); (&raw mut self.p).write(None); } - pub unsafe fn move_from(&mut self, _a0: *mut Holder) { +} +impl MoveConstructibleUnsafe for Holder { + unsafe fn move_constructor(&mut self, _a0: *mut Holder) { (&raw mut self.inner).write((*_a0).inner); (&raw mut self.e).write((*_a0).e.clone()); (&raw mut self.p).write((*_a0).p.take()); } - pub unsafe fn move_assign(&mut self, _a0: *mut Holder) -> *mut Holder { +} +impl MoveAssignableUnsafe for Holder { + unsafe fn move_assign(&mut self, _a0: *mut Holder) -> *mut Holder { self.inner = (*_a0).inner; self.e = ((*_a0).e).clone(); { @@ -369,7 +403,7 @@ unsafe fn main_0() -> i32 { let mut m1: DefaultCopyUserMove = m; let mut m2: DefaultCopyUserMove = { let mut __v: DefaultCopyUserMove = ::zero_init(); - DefaultCopyUserMove::move_from(&mut __v, { &mut m }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut m }); __v }; assert!((((m1.v) == (7)) && ((m2.v) == (7))) && ((m.v) == (0))); @@ -384,7 +418,7 @@ unsafe fn main_0() -> i32 { __v }; m3 = m1; - (unsafe { DefaultCopyUserMove::move_assign(&mut m4, &mut m1) }); + (unsafe { MoveAssignableUnsafe::move_assign(&mut m4, &mut m1) }); assert!((((m3.v) == (7)) && ((m4.v) == (7))) && ((m1.v) == (0))); let mut u: UserCopyDefaultMove = { let mut __v: UserCopyDefaultMove = ::zero_init(); @@ -393,12 +427,12 @@ unsafe fn main_0() -> i32 { }; let mut u1: UserCopyDefaultMove = { let mut __v: UserCopyDefaultMove = ::zero_init(); - UserCopyDefaultMove::copy_from(&mut __v, { &u }); + CopyConstructibleUnsafe::copy_constructor(&mut __v, { &u }); __v }; let mut u2: UserCopyDefaultMove = { let mut __v: UserCopyDefaultMove = ::zero_init(); - UserCopyDefaultMove::move_from(&mut __v, { &mut u }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut u }); __v }; assert!((((u1.v) == (108)) && ((u2.v) == (8))) && ((u.v) == (8))); @@ -412,8 +446,8 @@ unsafe fn main_0() -> i32 { UserCopyDefaultMove::construct(&mut __v, { 1 }); __v }; - (unsafe { UserCopyDefaultMove::copy_assign(&mut u3, &u2) }); - (unsafe { UserCopyDefaultMove::move_assign(&mut u4, &mut u2) }); + (unsafe { CopyAssignableUnsafe::copy_assign(&mut u3, &u2) }); + (unsafe { MoveAssignableUnsafe::move_assign(&mut u4, &mut u2) }); assert!(((u3.v) == (108)) && ((u4.v) == (8))); let mut p: Buffer = { let mut __v: Buffer = ::zero_init(); @@ -422,7 +456,7 @@ unsafe fn main_0() -> i32 { }; let mut q: Buffer = { let mut __v: Buffer = ::zero_init(); - Buffer::move_from(&mut __v, { &mut p }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut p }); __v }; assert!( @@ -434,7 +468,7 @@ unsafe fn main_0() -> i32 { Buffer::construct(&mut __v, { 1 }); __v }; - (unsafe { Buffer::move_assign(&mut r, &mut q) }); + (unsafe { MoveAssignableUnsafe::move_assign(&mut r, &mut q) }); assert!( ((((r.n) == (3)) && ((r.data.len()) == (3_usize))) && ((r.arr[(1) as usize]) == (4))) && (q.data.is_empty()) @@ -447,7 +481,7 @@ unsafe fn main_0() -> i32 { { let __a1 = { let mut __v: Buffer = ::zero_init(); - Buffer::move_from(&mut __v, { &mut r }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut r }); __v }; bufs.push(__a1) @@ -456,7 +490,7 @@ unsafe fn main_0() -> i32 { let mut __tmp_4 = { { let mut __v: Buffer = ::zero_init(); - Buffer::move_from(&mut __v, { &mut bufs[(0_usize)] }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut bufs[(0_usize)] }); __v } }; @@ -484,7 +518,7 @@ unsafe fn main_0() -> i32 { }; let mut o2: Owner = { let mut __v: Owner = ::zero_init(); - Owner::move_from(&mut __v, { &mut o1 }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut o1 }); __v }; assert!( @@ -504,7 +538,7 @@ unsafe fn main_0() -> i32 { .is_null()) ); let mut o3: Owner = ::default(); - (unsafe { Owner::move_assign(&mut o3, &mut o2) }); + (unsafe { MoveAssignableUnsafe::move_assign(&mut o3, &mut o2) }); assert!( ((((o3.n) == (5)) && ((o3.data[(0_usize)]) == (5))) && ((o3.arr[(0) as usize]) == (5))) && ((*o3 @@ -527,13 +561,13 @@ unsafe fn main_0() -> i32 { let mut c2: Copyable = c1.clone(); let mut c3: Copyable = { let mut __v: Copyable = ::zero_init(); - Copyable::move_from(&mut __v, { &mut c1 }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut c1 }); __v }; assert!(((c2.data.len()) == (2_usize)) && ((c3.data.len()) == (2_usize))); assert!(c1.data.is_empty()); let mut c4: Copyable = ::default(); - (unsafe { Copyable::move_assign(&mut c4, &mut c3) }); + (unsafe { MoveAssignableUnsafe::move_assign(&mut c4, &mut c3) }); assert!(((c4.data[(1_usize)]) == (2)) && (c3.data.is_empty())); let mut h1: Holder = { let mut __v: Holder = ::zero_init(); @@ -553,7 +587,7 @@ unsafe fn main_0() -> i32 { }; let mut h2: Holder = { let mut __v: Holder = ::zero_init(); - Holder::move_from(&mut __v, { &mut h1 }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut h1 }); __v }; let _dtor_h2 = std::mem::DropGuard::new(&raw mut h2, |__p| unsafe { @@ -580,7 +614,7 @@ unsafe fn main_0() -> i32 { let _dtor_h3 = std::mem::DropGuard::new(&raw mut h3, |__p| unsafe { DestructibleUnsafe::destroy(__p) }); - (unsafe { Holder::move_assign(&mut h3, &mut h2) }); + (unsafe { MoveAssignableUnsafe::move_assign(&mut h3, &mut h2) }); assert!( ((((h3.inner.x) == (4)) && ((h3.e.arr[(1) as usize]) == (5))) && ((*h3 diff --git a/tests/unit/out/unsafe/copy_move_deleted.rs b/tests/unit/out/unsafe/copy_move_deleted.rs index 89849f20f5..b113919eb2 100644 --- a/tests/unit/out/unsafe/copy_move_deleted.rs +++ b/tests/unit/out/unsafe/copy_move_deleted.rs @@ -7,9 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, CppFromUnsafe, MoveAssignUnsafe, Default, -)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] #[cpp_from(i32, construct, value)] pub struct NoCopy { pub v: i32, @@ -18,18 +16,22 @@ impl NoCopy { pub unsafe fn construct(&mut self, mut v: i32) { (&raw mut self.v).write(v); } - pub unsafe fn move_from(&mut self, o: *mut NoCopy) { +} +impl MoveConstructibleUnsafe for NoCopy { + unsafe fn move_constructor(&mut self, o: *mut NoCopy) { (&raw mut self.v).write((*o).v); (*o).v = 0; } - pub unsafe fn move_assign(&mut self, o: *mut NoCopy) -> *mut NoCopy { +} +impl MoveAssignableUnsafe for NoCopy { + unsafe fn move_assign(&mut self, o: *mut NoCopy) -> *mut NoCopy { self.v = (*o).v; (*o).v = 0; return &mut (*(self as *mut NoCopy)); } } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe)] +#[derive(FnPtrArg, ZeroInitializationUnsafe)] pub struct PrivateCopy { pub v: i32, } @@ -37,11 +39,15 @@ impl PrivateCopy { pub unsafe fn construct(&mut self) { (&raw mut self.v).write(0); } - pub unsafe fn move_from(&mut self, o: *mut PrivateCopy) { +} +impl MoveConstructibleUnsafe for PrivateCopy { + unsafe fn move_constructor(&mut self, o: *mut PrivateCopy) { (&raw mut self.v).write((*o).v); (*o).v = 0; } - pub unsafe fn move_assign(&mut self, o: *mut PrivateCopy) -> *mut PrivateCopy { +} +impl MoveAssignableUnsafe for PrivateCopy { + unsafe fn move_assign(&mut self, o: *mut PrivateCopy) -> *mut PrivateCopy { self.v = (*o).v; (*o).v = 0; return &mut (*(self as *mut PrivateCopy)); @@ -80,39 +86,43 @@ impl Default for Immovable { } } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, Default)] pub struct Container { pub inner: NoCopy, pub tag: i32, } -impl Container { - pub unsafe fn move_from(&mut self, _a0: *mut Container) { +impl MoveConstructibleUnsafe for Container { + unsafe fn move_constructor(&mut self, _a0: *mut Container) { (&raw mut self.inner).write({ let mut __v: NoCopy = ::zero_init(); - NoCopy::move_from(&mut __v, { &mut (*_a0).inner }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut (*_a0).inner }); __v }); (&raw mut self.tag).write((*_a0).tag); } - pub unsafe fn move_assign(&mut self, _a0: *mut Container) -> *mut Container { +} +impl MoveAssignableUnsafe for Container { + unsafe fn move_assign(&mut self, _a0: *mut Container) -> *mut Container { (unsafe { let _o: *mut NoCopy = &mut (*_a0).inner; - NoCopy::move_assign(&mut self.inner, _o) + MoveAssignableUnsafe::move_assign(&mut self.inner, _o) }); self.tag = (*_a0).tag; return &mut (*(self as *mut Container)); } } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, Default)] pub struct VecHolder { pub items: Vec, } -impl VecHolder { - pub unsafe fn move_from(&mut self, _a0: *mut VecHolder) { +impl MoveConstructibleUnsafe for VecHolder { + unsafe fn move_constructor(&mut self, _a0: *mut VecHolder) { (&raw mut self.items).write(std::mem::take(&mut (*_a0).items)); } - pub unsafe fn move_assign(&mut self, _a0: *mut VecHolder) -> *mut VecHolder { +} +impl MoveAssignableUnsafe for VecHolder { + unsafe fn move_assign(&mut self, _a0: *mut VecHolder) -> *mut VecHolder { { self.items = std::mem::take(&mut (*_a0).items); }; @@ -139,11 +149,11 @@ unsafe fn main_0() -> i32 { }; let mut b: NoCopy = { let mut __v: NoCopy = ::zero_init(); - NoCopy::move_from(&mut __v, { &mut a }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut a }); __v }; assert!(((b.v) == (1)) && ((a.v) == (0))); - (unsafe { NoCopy::move_assign(&mut a, &mut b) }); + (unsafe { MoveAssignableUnsafe::move_assign(&mut a, &mut b) }); assert!(((a.v) == (1)) && ((b.v) == (0))); (unsafe { bump_0((&mut a as *mut NoCopy)) }); assert!(((a.v) == (2))); @@ -155,11 +165,11 @@ unsafe fn main_0() -> i32 { p.v = 3; let mut q: PrivateCopy = { let mut __v: PrivateCopy = ::zero_init(); - PrivateCopy::move_from(&mut __v, { &mut p }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut p }); __v }; assert!(((q.v) == (3)) && ((p.v) == (0))); - (unsafe { PrivateCopy::move_assign(&mut p, &mut q) }); + (unsafe { MoveAssignableUnsafe::move_assign(&mut p, &mut q) }); assert!(((p.v) == (3)) && ((q.v) == (0))); let mut im: Immovable = { let mut __v: Immovable = ::zero_init(); @@ -180,14 +190,14 @@ unsafe fn main_0() -> i32 { }; let mut d: Container = { let mut __v: Container = ::zero_init(); - Container::move_from(&mut __v, { &mut c }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut c }); __v }; assert!((((d.inner.v) == (6)) && ((d.tag) == (7))) && ((c.inner.v) == (0))); let mut h: VecHolder = ::default(); let mut h2: VecHolder = { let mut __v: VecHolder = ::zero_init(); - VecHolder::move_from(&mut __v, { &mut h }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut h }); __v }; assert!(((h2.items.len()) == (0_usize))); diff --git a/tests/unit/out/unsafe/default.rs b/tests/unit/out/unsafe/default.rs index 05fd21467a..bb0ed7f3e8 100644 --- a/tests/unit/out/unsafe/default.rs +++ b/tests/unit/out/unsafe/default.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Pointers { pub x1: *mut i32, pub x2: *const i32, @@ -16,7 +27,18 @@ pub struct Pointers { pub x5: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct SmallArrays { pub a: [i32; 32], pub f: Option i32>, @@ -24,7 +46,17 @@ pub struct SmallArrays { pub p: [Pointers; 2], } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct BigArray { pub a: [i32; 33], } diff --git a/tests/unit/out/unsafe/default_function_arguments.rs b/tests/unit/out/unsafe/default_function_arguments.rs index 33bed19cf6..218ca0ea87 100644 --- a/tests/unit/out/unsafe/default_function_arguments.rs +++ b/tests/unit/out/unsafe/default_function_arguments.rs @@ -13,7 +13,18 @@ pub unsafe fn baz_1(mut a: *mut i32, mut b: *mut i32) -> bool { return ((a) == (b)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] #[cpp_from(i32, construct, value)] pub struct Bar { pub v: i32, @@ -61,7 +72,18 @@ pub unsafe fn first_9(r: *mut [i32; 3]) -> i32 { return (*r)[(0) as usize]; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Holder_int_ { pub v: i32, } diff --git a/tests/unit/out/unsafe/default_in_statics.rs b/tests/unit/out/unsafe/default_in_statics.rs index 15f4dfe71c..3f63e2518e 100644 --- a/tests/unit/out/unsafe/default_in_statics.rs +++ b/tests/unit/out/unsafe/default_in_statics.rs @@ -7,13 +7,35 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Inner { pub v: i32, pub name: *const libc::c_char, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Outer { pub p1: *mut i32, pub p2: *const i32, @@ -25,7 +47,18 @@ pub struct Outer { pub fn_: Option i32>, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Foo { pub s1: *const libc::c_char, pub s2: *const libc::c_char, diff --git a/tests/unit/out/unsafe/delete_array_order.rs b/tests/unit/out/unsafe/delete_array_order.rs index 81497cbb60..3af1e439b8 100644 --- a/tests/unit/out/unsafe/delete_array_order.rs +++ b/tests/unit/out/unsafe/delete_array_order.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Element { pub id: i64, pub value: i64, diff --git a/tests/unit/out/unsafe/destructor.rs b/tests/unit/out/unsafe/destructor.rs index 9d957882a6..7e5c2d3379 100644 --- a/tests/unit/out/unsafe/destructor.rs +++ b/tests/unit/out/unsafe/destructor.rs @@ -8,7 +8,18 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub static mut global_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S {} impl S { pub unsafe fn destructor(&mut self) { @@ -16,7 +27,18 @@ impl S { } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Defaulted { pub s: S, } @@ -26,7 +48,18 @@ impl Defaulted { } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Middle { pub s: S, } @@ -36,7 +69,18 @@ impl Middle { } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Outer { pub m: Middle, } @@ -46,7 +90,18 @@ impl Outer { } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct ArrayMember { pub items: [S; 3], } @@ -56,7 +111,18 @@ impl ArrayMember { } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct EmptyBody { pub s: S, } @@ -66,7 +132,18 @@ impl EmptyBody { } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Templated_char_ { pub v: libc::c_char, } @@ -78,7 +155,18 @@ impl Templated_char_ { } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Templated_int_ { pub v: i32, } @@ -90,7 +178,18 @@ impl Templated_int_ { } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Copied { pub v: i32, } @@ -103,7 +202,18 @@ pub static mut order_1: std::cell::LazyCell<[i32; 3]> = std::cell::LazyCell::new(|| unsafe { [0_i32; 3] }); pub static mut order_count_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Tagged { pub tag: i32, } @@ -115,7 +225,18 @@ impl Tagged { } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Ordered { pub first: Tagged, pub dummy1: i32, diff --git a/tests/unit/out/unsafe/destructor_params.rs b/tests/unit/out/unsafe/destructor_params.rs index 6dc8046c61..29d9ee4965 100644 --- a/tests/unit/out/unsafe/destructor_params.rs +++ b/tests/unit/out/unsafe/destructor_params.rs @@ -9,7 +9,18 @@ use std::rc::Rc; pub static mut destroyed_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut last_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub v: i32, } @@ -27,7 +38,18 @@ pub unsafe fn with_default_3(mut s: S) -> i32 { return s.v; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Holder { pub v: i32, } diff --git a/tests/unit/out/unsafe/destructor_temporaries.rs b/tests/unit/out/unsafe/destructor_temporaries.rs index fa79b0547c..84122d3f6d 100644 --- a/tests/unit/out/unsafe/destructor_temporaries.rs +++ b/tests/unit/out/unsafe/destructor_temporaries.rs @@ -9,7 +9,18 @@ use std::rc::Rc; pub static mut destroyed_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut last_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub v: i32, } @@ -23,7 +34,18 @@ impl S { } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Outer { pub inner: S, pub w: i32, diff --git a/tests/unit/out/unsafe/doubly_linked_list.rs b/tests/unit/out/unsafe/doubly_linked_list.rs index 912cdbf0ca..fba16b50a9 100644 --- a/tests/unit/out/unsafe/doubly_linked_list.rs +++ b/tests/unit/out/unsafe/doubly_linked_list.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Node { pub val: i32, pub next: *mut Node, diff --git a/tests/unit/out/unsafe/enum_default_in_static.rs b/tests/unit/out/unsafe/enum_default_in_static.rs index 472094aeb9..2318d55e74 100644 --- a/tests/unit/out/unsafe/enum_default_in_static.rs +++ b/tests/unit/out/unsafe/enum_default_in_static.rs @@ -11,7 +11,18 @@ pub const Mode_MODE_NONE: Mode = 0; pub const Mode_MODE_ONE: Mode = 1; pub const Mode_MODE_TWO: Mode = 2; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Config { pub count: i32, pub mode: Mode, diff --git a/tests/unit/out/unsafe/enum_int_interop.rs b/tests/unit/out/unsafe/enum_int_interop.rs index 211b2e447c..37429e688b 100644 --- a/tests/unit/out/unsafe/enum_int_interop.rs +++ b/tests/unit/out/unsafe/enum_int_interop.rs @@ -20,7 +20,18 @@ pub const Tag_TAG_ZERO: Tag = 0; pub const Tag_TAG_ONE: Tag = 1; pub const Tag_TAG_TWO: Tag = 2; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Entry { pub name: *const libc::c_char, pub color: Color, diff --git a/tests/unit/out/unsafe/enum_int_interop_c.rs b/tests/unit/out/unsafe/enum_int_interop_c.rs index fdc625c087..263cb76cb5 100644 --- a/tests/unit/out/unsafe/enum_int_interop_c.rs +++ b/tests/unit/out/unsafe/enum_int_interop_c.rs @@ -20,7 +20,18 @@ pub const Tag_enum_TAG_ZERO: Tag_enum = 0; pub const Tag_enum_TAG_ONE: Tag_enum = 1; pub const Tag_enum_TAG_TWO: Tag_enum = 2; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Entry { pub name: *const libc::c_char, pub color: Color, diff --git a/tests/unit/out/unsafe/enum_underlying_type.rs b/tests/unit/out/unsafe/enum_underlying_type.rs index 6b128a0f78..bd1a9c8e8d 100644 --- a/tests/unit/out/unsafe/enum_underlying_type.rs +++ b/tests/unit/out/unsafe/enum_underlying_type.rs @@ -26,7 +26,17 @@ pub const Scoped_NEG: Scoped = -2; pub const Scoped_POS: Scoped = 2; pub type Empty = bool; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct HoldsEmpty { pub e: Empty, } diff --git a/tests/unit/out/unsafe/exprs.rs b/tests/unit/out/unsafe/exprs.rs index cb3339a6fe..565af5e37e 100644 --- a/tests/unit/out/unsafe/exprs.rs +++ b/tests/unit/out/unsafe/exprs.rs @@ -7,12 +7,34 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct X { pub x: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Y { pub x: X, pub p: *mut X, diff --git a/tests/unit/out/unsafe/fft.rs b/tests/unit/out/unsafe/fft.rs index 6459d36e64..80dcecf559 100644 --- a/tests/unit/out/unsafe/fft.rs +++ b/tests/unit/out/unsafe/fft.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Complex { pub re: f64, pub img: f64, diff --git a/tests/unit/out/unsafe/field_aliasing.rs b/tests/unit/out/unsafe/field_aliasing.rs index a7c6f15676..1700c09a89 100644 --- a/tests/unit/out/unsafe/field_aliasing.rs +++ b/tests/unit/out/unsafe/field_aliasing.rs @@ -7,13 +7,35 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct In { pub x: i32, pub y: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub in_: In, pub total: i32, @@ -21,7 +43,18 @@ pub struct S { pub arr: [i32; 4], } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Node { pub x: i32, pub self_: *mut Node, diff --git a/tests/unit/out/unsafe/field_array_elem_ptr.rs b/tests/unit/out/unsafe/field_array_elem_ptr.rs index 7fcffe7186..ee14d97896 100644 --- a/tests/unit/out/unsafe/field_array_elem_ptr.rs +++ b/tests/unit/out/unsafe/field_array_elem_ptr.rs @@ -7,13 +7,35 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Point { pub x: i32, pub y: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Shape { pub id: i32, pub coords: [i32; 4], diff --git a/tests/unit/out/unsafe/field_method_receiver.rs b/tests/unit/out/unsafe/field_method_receiver.rs index 038fbb710b..48527ce857 100644 --- a/tests/unit/out/unsafe/field_method_receiver.rs +++ b/tests/unit/out/unsafe/field_method_receiver.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Counter { pub n: i32, } @@ -28,7 +39,13 @@ impl Counter { } #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + CopyAssignableUnsafe, + Default, )] pub struct S { pub tag: i32, @@ -43,7 +60,9 @@ impl S { Counter::add(&mut self.c, _k) }); } - pub unsafe fn move_from(&mut self, _a0: *mut S) { +} +impl MoveConstructibleUnsafe for S { + unsafe fn move_constructor(&mut self, _a0: *mut S) { (&raw mut self.tag).write((*_a0).tag); (&raw mut self.c).write((*_a0).c); (&raw mut self.arr).write(std::array::from_fn::<_, 2, _>(|__i: usize| { @@ -51,7 +70,9 @@ impl S { })); (&raw mut self.v).write(std::mem::take(&mut (*_a0).v)); } - pub unsafe fn move_assign(&mut self, _a0: *mut S) -> *mut S { +} +impl MoveAssignableUnsafe for S { + unsafe fn move_assign(&mut self, _a0: *mut S) -> *mut S { self.tag = (*_a0).tag; self.c = (*_a0).c; { diff --git a/tests/unit/out/unsafe/field_pointers.rs b/tests/unit/out/unsafe/field_pointers.rs index 6dde0af000..9dc0bc2696 100644 --- a/tests/unit/out/unsafe/field_pointers.rs +++ b/tests/unit/out/unsafe/field_pointers.rs @@ -7,20 +7,48 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Inner { pub a: i32, pub name: [libc::c_char; 8], } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Header { pub tag: i32, pub size: i16, } #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + CopyAssignableUnsafe, + Default, )] pub struct Outer { pub x: i32, @@ -43,7 +71,9 @@ impl Outer { self.v.push(__a1) }; } - pub unsafe fn move_from(&mut self, _a0: *mut Outer) { +} +impl MoveConstructibleUnsafe for Outer { + unsafe fn move_constructor(&mut self, _a0: *mut Outer) { (&raw mut self.x).write((*_a0).x); (&raw mut self.inner).write((*_a0).inner); (&raw mut self.items).write(std::array::from_fn::<_, 3, _>(|__i: usize| { @@ -55,7 +85,9 @@ impl Outer { (*_a0).buf[(__i)] })); } - pub unsafe fn move_assign(&mut self, _a0: *mut Outer) -> *mut Outer { +} +impl MoveAssignableUnsafe for Outer { + unsafe fn move_assign(&mut self, _a0: *mut Outer) -> *mut Outer { self.x = (*_a0).x; self.inner = (*_a0).inner; { diff --git a/tests/unit/out/unsafe/field_pointers_malloced_struct.rs b/tests/unit/out/unsafe/field_pointers_malloced_struct.rs index 13b23f2a2f..cb645af49b 100644 --- a/tests/unit/out/unsafe/field_pointers_malloced_struct.rs +++ b/tests/unit/out/unsafe/field_pointers_malloced_struct.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub a: i32, pub b: i32, diff --git a/tests/unit/out/unsafe/field_reinterpret_write_through.rs b/tests/unit/out/unsafe/field_reinterpret_write_through.rs index de74176526..e8631a5743 100644 --- a/tests/unit/out/unsafe/field_reinterpret_write_through.rs +++ b/tests/unit/out/unsafe/field_reinterpret_write_through.rs @@ -7,13 +7,35 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct In { pub a: i16, pub b: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub x: i32, pub in_: In, diff --git a/tests/unit/out/unsafe/find.rs b/tests/unit/out/unsafe/find.rs index 70572a49b2..686457b5af 100644 --- a/tests/unit/out/unsafe/find.rs +++ b/tests/unit/out/unsafe/find.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct P { pub x: i32, } diff --git a/tests/unit/out/unsafe/first_field_ptr_covers_struct.rs b/tests/unit/out/unsafe/first_field_ptr_covers_struct.rs index 25518f53be..609c5a41b8 100644 --- a/tests/unit/out/unsafe/first_field_ptr_covers_struct.rs +++ b/tests/unit/out/unsafe/first_field_ptr_covers_struct.rs @@ -7,13 +7,35 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct In { pub a: i16, pub b: i16, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub x: i32, pub in_: In, diff --git a/tests/unit/out/unsafe/first_member_downcast.rs b/tests/unit/out/unsafe/first_member_downcast.rs index f6ddfb29a4..ddf30080c7 100644 --- a/tests/unit/out/unsafe/first_member_downcast.rs +++ b/tests/unit/out/unsafe/first_member_downcast.rs @@ -7,12 +7,34 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct base { pub kind: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct derived { pub head: base, pub value: usize, diff --git a/tests/unit/out/unsafe/flex_array_member_incomplete.rs b/tests/unit/out/unsafe/flex_array_member_incomplete.rs index 07ee75a28f..2fc130a26a 100644 --- a/tests/unit/out/unsafe/flex_array_member_incomplete.rs +++ b/tests/unit/out/unsafe/flex_array_member_incomplete.rs @@ -7,7 +7,17 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct F { pub n: i32, pub tail: [libc::c_char; 0], diff --git a/tests/unit/out/unsafe/flex_array_member_sibling_write.rs b/tests/unit/out/unsafe/flex_array_member_sibling_write.rs index be0df75738..02ccc1de70 100644 --- a/tests/unit/out/unsafe/flex_array_member_sibling_write.rs +++ b/tests/unit/out/unsafe/flex_array_member_sibling_write.rs @@ -7,19 +7,52 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub n: i32, pub name: [libc::c_char; 1], } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct E { pub id: i32, pub w: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct T { pub n: i32, pub cap: i32, diff --git a/tests/unit/out/unsafe/fn_ptr.rs b/tests/unit/out/unsafe/fn_ptr.rs index abad5a3c0d..e3474bcf37 100644 --- a/tests/unit/out/unsafe/fn_ptr.rs +++ b/tests/unit/out/unsafe/fn_ptr.rs @@ -32,7 +32,19 @@ pub unsafe fn identity_hash_6(mut v: bool) -> usize { return (v as usize); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(Option u64 > , construct, ptr)] pub struct HashHolder_unsigned_long__ptr__bool__ { pub h: Option u64>, diff --git a/tests/unit/out/unsafe/fn_ptr_cast.rs b/tests/unit/out/unsafe/fn_ptr_cast.rs index e9d0bc2af1..73423fc5cd 100644 --- a/tests/unit/out/unsafe/fn_ptr_cast.rs +++ b/tests/unit/out/unsafe/fn_ptr_cast.rs @@ -30,7 +30,18 @@ pub unsafe fn test_double_cast_2() { assert!(((fn2) == (fn_))); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Command { pub data: *mut ::libc::c_void, } diff --git a/tests/unit/out/unsafe/fn_ptr_stable_sort.rs b/tests/unit/out/unsafe/fn_ptr_stable_sort.rs index 6ab8577bde..7cb4fedf32 100644 --- a/tests/unit/out/unsafe/fn_ptr_stable_sort.rs +++ b/tests/unit/out/unsafe/fn_ptr_stable_sort.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Item { pub key: i32, pub value: i32, diff --git a/tests/unit/out/unsafe/fn_ptr_struct.rs b/tests/unit/out/unsafe/fn_ptr_struct.rs index 9164445c60..e5e6066e5a 100644 --- a/tests/unit/out/unsafe/fn_ptr_struct.rs +++ b/tests/unit/out/unsafe/fn_ptr_struct.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Handler { pub tag: i32, pub cb: Option i32>, @@ -19,7 +30,18 @@ pub unsafe fn negate_1(mut x: i32) -> i32 { return -x; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S {} impl S { pub unsafe fn pick_1(mut x: i32) -> i32 { @@ -33,7 +55,7 @@ impl S { } } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, CppFromUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] #[cpp_from(i32, construct, value)] pub struct MoveOnly { pub data_: i32, @@ -42,14 +64,16 @@ impl MoveOnly { pub unsafe fn construct(&mut self, mut data: i32) { (&raw mut self.data_).write(data); } - pub unsafe fn move_from(&mut self, x: *mut MoveOnly) { - (&raw mut self.data_).write((*x).data_); - (*x).data_ = 0; - } pub unsafe fn get(&self) -> i32 { return self.data_; } } +impl MoveConstructibleUnsafe for MoveOnly { + unsafe fn move_constructor(&mut self, x: *mut MoveOnly) { + (&raw mut self.data_).write((*x).data_); + (*x).data_ = 0; + } +} pub unsafe fn make_move_only_2() -> MoveOnly { return { let mut __v: MoveOnly = ::zero_init(); @@ -102,7 +126,7 @@ unsafe fn main_0() -> i32 { let mut n: MoveOnly = (unsafe { (sc).unwrap()({ let mut __v: MoveOnly = ::zero_init(); - MoveOnly::move_from(&mut __v, { &mut m }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut m }); __v }) }); diff --git a/tests/unit/out/unsafe/fn_ptr_typedef_cast.rs b/tests/unit/out/unsafe/fn_ptr_typedef_cast.rs index 1d69da2fbb..768b8a5311 100644 --- a/tests/unit/out/unsafe/fn_ptr_typedef_cast.rs +++ b/tests/unit/out/unsafe/fn_ptr_typedef_cast.rs @@ -19,7 +19,18 @@ pub unsafe fn via_size_t_return_3(mut b: u64) -> usize { return (b as usize); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct pair { pub a: i32, pub b: i32, diff --git a/tests/unit/out/unsafe/fn_ptr_vtable.rs b/tests/unit/out/unsafe/fn_ptr_vtable.rs index 250cedb781..cf75ca12da 100644 --- a/tests/unit/out/unsafe/fn_ptr_vtable.rs +++ b/tests/unit/out/unsafe/fn_ptr_vtable.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Vtable { pub create: Option *mut ::libc::c_void>, pub get: Option i32>, diff --git a/tests/unit/out/unsafe/fn_ref.rs b/tests/unit/out/unsafe/fn_ref.rs index c99ffe2a90..ab5509e068 100644 --- a/tests/unit/out/unsafe/fn_ref.rs +++ b/tests/unit/out/unsafe/fn_ref.rs @@ -22,7 +22,18 @@ pub unsafe fn call_forwarded_4(f: Option i32>, mut x: i32) -> return (unsafe { (f).unwrap()(x) }); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Holder { pub f: Option i32>, } diff --git a/tests/unit/out/unsafe/for_body_destructor.rs b/tests/unit/out/unsafe/for_body_destructor.rs index 5810e7d54b..681f90beda 100644 --- a/tests/unit/out/unsafe/for_body_destructor.rs +++ b/tests/unit/out/unsafe/for_body_destructor.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Guard { pub digit: i32, } diff --git a/tests/unit/out/unsafe/foreach_disjoint_field_borrow.rs b/tests/unit/out/unsafe/foreach_disjoint_field_borrow.rs index f7ca6d019e..24771dd454 100644 --- a/tests/unit/out/unsafe/foreach_disjoint_field_borrow.rs +++ b/tests/unit/out/unsafe/foreach_disjoint_field_borrow.rs @@ -8,18 +8,26 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + CopyAssignableUnsafe, + Default, )] pub struct S { pub v: Vec, pub a: i32, } -impl S { - pub unsafe fn move_from(&mut self, _a0: *mut S) { +impl MoveConstructibleUnsafe for S { + unsafe fn move_constructor(&mut self, _a0: *mut S) { (&raw mut self.v).write(std::mem::take(&mut (*_a0).v)); (&raw mut self.a).write((*_a0).a); } - pub unsafe fn move_assign(&mut self, _a0: *mut S) -> *mut S { +} +impl MoveAssignableUnsafe for S { + unsafe fn move_assign(&mut self, _a0: *mut S) -> *mut S { { self.v = std::mem::take(&mut (*_a0).v); }; diff --git a/tests/unit/out/unsafe/forward_basic.rs b/tests/unit/out/unsafe/forward_basic.rs index 571d71b29a..a13777820c 100644 --- a/tests/unit/out/unsafe/forward_basic.rs +++ b/tests/unit/out/unsafe/forward_basic.rs @@ -10,7 +10,15 @@ pub type Overload = u32; pub const Overload_kLvalueOverload: Overload = 1; pub const Overload_kRvalueOverload: Overload = 2; #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, CppFromUnsafe, Default)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct Tracked { pub v: i32, @@ -23,12 +31,16 @@ impl Tracked { (&raw mut self.copies).write(0); (&raw mut self.moves).write(0); } - pub unsafe fn copy_from(&mut self, o: *const Tracked) { +} +impl CopyConstructibleUnsafe for Tracked { + unsafe fn copy_constructor(&mut self, o: *const Tracked) { (&raw mut self.v).write((*o).v); (&raw mut self.copies).write((((*o).copies) + (1))); (&raw mut self.moves).write((*o).moves); } - pub unsafe fn move_from(&mut self, o: *mut Tracked) { +} +impl MoveConstructibleUnsafe for Tracked { + unsafe fn move_constructor(&mut self, o: *mut Tracked) { (&raw mut self.v).write((*o).v); (&raw mut self.copies).write((*o).copies); (&raw mut self.moves).write((((*o).moves) + (1))); @@ -39,7 +51,7 @@ impl Clone for Tracked { fn clone(&self) -> Self { unsafe { let mut __v: Tracked = ::zero_init(); - Tracked::copy_from(&mut __v, self as *const Tracked); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const Tracked); __v } } @@ -54,7 +66,7 @@ impl Holder { pub unsafe fn construct_1(&mut self, x: *mut Tracked) { (&raw mut self.t).write({ let mut __v: Tracked = ::zero_init(); - Tracked::copy_from(&mut __v, { x }); + CopyConstructibleUnsafe::copy_constructor(&mut __v, { x }); __v }); } @@ -63,25 +75,33 @@ impl Holder { pub unsafe fn construct_2(&mut self, x: *mut Tracked) { (&raw mut self.t).write({ let mut __v: Tracked = ::zero_init(); - Tracked::move_from(&mut __v, { x }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { x }); __v }); } } #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, CppFromUnsafe, Default, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, )] #[cpp_from(Tracked, construct_1, mut_ptr)] #[cpp_from_move(Tracked, construct_2, ptr)] pub struct Holder { pub t: Tracked, } -impl Holder { - pub unsafe fn move_from(&mut self, _a0: *mut Holder) { +impl MoveConstructibleUnsafe for Holder { + unsafe fn move_constructor(&mut self, _a0: *mut Holder) { (&raw mut self.t).write({ let mut __v: Tracked = ::zero_init(); - Tracked::move_from(&mut __v, { &mut (*_a0).t }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut (*_a0).t }); __v }); } diff --git a/tests/unit/out/unsafe/forward_decltype.rs b/tests/unit/out/unsafe/forward_decltype.rs index cc34376dd2..b9dd263cfb 100644 --- a/tests/unit/out/unsafe/forward_decltype.rs +++ b/tests/unit/out/unsafe/forward_decltype.rs @@ -10,7 +10,15 @@ pub type Overload = u32; pub const Overload_kLvalueOverload: Overload = 1; pub const Overload_kRvalueOverload: Overload = 2; #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, CppFromUnsafe, Default)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct Tracked { pub v: i32, @@ -23,12 +31,16 @@ impl Tracked { (&raw mut self.copies).write(0); (&raw mut self.moves).write(0); } - pub unsafe fn copy_from(&mut self, o: *const Tracked) { +} +impl CopyConstructibleUnsafe for Tracked { + unsafe fn copy_constructor(&mut self, o: *const Tracked) { (&raw mut self.v).write((*o).v); (&raw mut self.copies).write((((*o).copies) + (1))); (&raw mut self.moves).write((*o).moves); } - pub unsafe fn move_from(&mut self, o: *mut Tracked) { +} +impl MoveConstructibleUnsafe for Tracked { + unsafe fn move_constructor(&mut self, o: *mut Tracked) { (&raw mut self.v).write((*o).v); (&raw mut self.copies).write((*o).copies); (&raw mut self.moves).write((((*o).moves) + (1))); @@ -39,7 +51,7 @@ impl Clone for Tracked { fn clone(&self) -> Self { unsafe { let mut __v: Tracked = ::zero_init(); - Tracked::copy_from(&mut __v, self as *const Tracked); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const Tracked); __v } } diff --git a/tests/unit/out/unsafe/forward_explicit.rs b/tests/unit/out/unsafe/forward_explicit.rs index 561432313b..8f32ba673b 100644 --- a/tests/unit/out/unsafe/forward_explicit.rs +++ b/tests/unit/out/unsafe/forward_explicit.rs @@ -12,7 +12,15 @@ pub const Overload_kRvalueOverload: Overload = 2; pub const Overload_kIntLvalueOverload: Overload = 3; pub const Overload_kIntRvalueOverload: Overload = 4; #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, CppFromUnsafe, Default)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct Tracked { pub v: i32, @@ -25,12 +33,16 @@ impl Tracked { (&raw mut self.copies).write(0); (&raw mut self.moves).write(0); } - pub unsafe fn copy_from(&mut self, o: *const Tracked) { +} +impl CopyConstructibleUnsafe for Tracked { + unsafe fn copy_constructor(&mut self, o: *const Tracked) { (&raw mut self.v).write((*o).v); (&raw mut self.copies).write((((*o).copies) + (1))); (&raw mut self.moves).write((*o).moves); } - pub unsafe fn move_from(&mut self, o: *mut Tracked) { +} +impl MoveConstructibleUnsafe for Tracked { + unsafe fn move_constructor(&mut self, o: *mut Tracked) { (&raw mut self.v).write((*o).v); (&raw mut self.copies).write((*o).copies); (&raw mut self.moves).write((((*o).moves) + (1))); @@ -41,7 +53,7 @@ impl Clone for Tracked { fn clone(&self) -> Self { unsafe { let mut __v: Tracked = ::zero_init(); - Tracked::copy_from(&mut __v, self as *const Tracked); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const Tracked); __v } } @@ -61,7 +73,7 @@ pub unsafe fn chosen_overload_3(_a0: *mut i32) -> Overload { pub unsafe fn copy_or_move_into_param_4(mut t: Tracked) -> Tracked { return { let mut __v: Tracked = ::zero_init(); - Tracked::move_from(&mut __v, { &mut t }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut t }); __v }; } @@ -91,7 +103,7 @@ unsafe fn main_0() -> i32 { let mut moved: Tracked = (unsafe { copy_or_move_into_param_4({ let mut __v: Tracked = ::zero_init(); - Tracked::move_from(&mut __v, { &mut b }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut b }); __v }) }); @@ -107,7 +119,7 @@ unsafe fn main_0() -> i32 { let mut copied: Tracked = (unsafe { copy_or_move_into_param_4({ let mut __v: Tracked = ::zero_init(); - Tracked::copy_from(&mut __v, { &c }); + CopyConstructibleUnsafe::copy_constructor(&mut __v, { &c }); __v }) }); diff --git a/tests/unit/out/unsafe/forward_pack.rs b/tests/unit/out/unsafe/forward_pack.rs index 95c39c0261..8dd3c3084a 100644 --- a/tests/unit/out/unsafe/forward_pack.rs +++ b/tests/unit/out/unsafe/forward_pack.rs @@ -12,7 +12,15 @@ pub const Overload_kRvalueOverload: Overload = 2; pub const Overload_kIntLvalueOverload: Overload = 3; pub const Overload_kIntRvalueOverload: Overload = 4; #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, CppFromUnsafe, Default)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct Tracked { pub v: i32, @@ -25,12 +33,16 @@ impl Tracked { (&raw mut self.copies).write(0); (&raw mut self.moves).write(0); } - pub unsafe fn copy_from(&mut self, o: *const Tracked) { +} +impl CopyConstructibleUnsafe for Tracked { + unsafe fn copy_constructor(&mut self, o: *const Tracked) { (&raw mut self.v).write((*o).v); (&raw mut self.copies).write((((*o).copies) + (1))); (&raw mut self.moves).write((*o).moves); } - pub unsafe fn move_from(&mut self, o: *mut Tracked) { +} +impl MoveConstructibleUnsafe for Tracked { + unsafe fn move_constructor(&mut self, o: *mut Tracked) { (&raw mut self.v).write((*o).v); (&raw mut self.copies).write((*o).copies); (&raw mut self.moves).write((((*o).moves) + (1))); @@ -41,7 +53,7 @@ impl Clone for Tracked { fn clone(&self) -> Self { unsafe { let mut __v: Tracked = ::zero_init(); - Tracked::copy_from(&mut __v, self as *const Tracked); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const Tracked); __v } } @@ -96,32 +108,41 @@ impl Pair { pub unsafe fn construct(&mut self, x: *mut Tracked, y: *mut Tracked) { (&raw mut self.a).write({ let mut __v: Tracked = ::zero_init(); - Tracked::copy_from(&mut __v, { x }); + CopyConstructibleUnsafe::copy_constructor(&mut __v, { x }); __v }); (&raw mut self.b).write({ let mut __v: Tracked = ::zero_init(); - Tracked::move_from(&mut __v, { y }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { y }); __v }); } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Pair { pub a: Tracked, pub b: Tracked, } -impl Pair { - pub unsafe fn move_from(&mut self, _a0: *mut Pair) { +impl MoveConstructibleUnsafe for Pair { + unsafe fn move_constructor(&mut self, _a0: *mut Pair) { (&raw mut self.a).write({ let mut __v: Tracked = ::zero_init(); - Tracked::move_from(&mut __v, { &mut (*_a0).a }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut (*_a0).a }); __v }); (&raw mut self.b).write({ let mut __v: Tracked = ::zero_init(); - Tracked::move_from(&mut __v, { &mut (*_a0).b }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut (*_a0).b }); __v }); } diff --git a/tests/unit/out/unsafe/friend.rs b/tests/unit/out/unsafe/friend.rs index 0f563e6240..22676d35ce 100644 --- a/tests/unit/out/unsafe/friend.rs +++ b/tests/unit/out/unsafe/friend.rs @@ -19,7 +19,18 @@ pub unsafe fn scaled_3(v: *const V, mut k: f64) -> f64 { return (((*v).x as f64) * (k)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct V { pub x: i32, } @@ -33,7 +44,18 @@ pub unsafe fn get_4(w: *const W_int_) -> i32 { return (*w).x; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct W_int_ { pub x: i32, } @@ -41,12 +63,34 @@ pub unsafe fn get_5(w: *const W_long_) -> i64 { return (*w).x; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct W_long_ { pub x: i64, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct D { pub x: i32, } diff --git a/tests/unit/out/unsafe/function_overloading.rs b/tests/unit/out/unsafe/function_overloading.rs index e3925aa83c..b88b101729 100644 --- a/tests/unit/out/unsafe/function_overloading.rs +++ b/tests/unit/out/unsafe/function_overloading.rs @@ -22,7 +22,18 @@ pub unsafe fn bar_4(x: *mut i32) -> i32 { return (*x); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Foo {} impl Foo { pub unsafe fn foo_1(&self) {} diff --git a/tests/unit/out/unsafe/global_call_temporaries.rs b/tests/unit/out/unsafe/global_call_temporaries.rs index d256027f66..37ebf57a01 100644 --- a/tests/unit/out/unsafe/global_call_temporaries.rs +++ b/tests/unit/out/unsafe/global_call_temporaries.rs @@ -77,7 +77,18 @@ pub static mut call_assigned_6: std::cell::LazyCell = std::cell::LazyCell:: } }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Item { pub value: i32, } diff --git a/tests/unit/out/unsafe/global_init_side_effect.rs b/tests/unit/out/unsafe/global_init_side_effect.rs index 774dfa61f5..94926f0d17 100644 --- a/tests/unit/out/unsafe/global_init_side_effect.rs +++ b/tests/unit/out/unsafe/global_init_side_effect.rs @@ -8,7 +8,19 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub static mut total_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct S {} impl S { diff --git a/tests/unit/out/unsafe/global_non_const_init.rs b/tests/unit/out/unsafe/global_non_const_init.rs index ca5bbaf708..472ceda8f6 100644 --- a/tests/unit/out/unsafe/global_non_const_init.rs +++ b/tests/unit/out/unsafe/global_non_const_init.rs @@ -28,7 +28,17 @@ pub static mut depends_on_call_6: std::cell::LazyCell = std::cell::LazyCell ((*std::cell::LazyCell::force_mut(&mut *&raw mut from_call_5)) + (1)) }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct Ctor { pub v: i32, } @@ -81,7 +91,18 @@ pub static mut inline_member_11: std::cell::LazyCell = std::cell::LazyCell } }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Holder {} pub static mut member_10: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { (unsafe { next_0() }) }); @@ -99,7 +120,17 @@ static mut local_ctor_14: std::cell::LazyCell = std::cell::LazyCell::new(| } }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct Singleton { pub hits: i32, } diff --git a/tests/unit/out/unsafe/global_pointers.rs b/tests/unit/out/unsafe/global_pointers.rs index 383073d278..84890d2b37 100644 --- a/tests/unit/out/unsafe/global_pointers.rs +++ b/tests/unit/out/unsafe/global_pointers.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Entry { pub name: *const libc::c_char, pub p: *mut i32, diff --git a/tests/unit/out/unsafe/global_without_initializer.rs b/tests/unit/out/unsafe/global_without_initializer.rs index fcf308d00a..a7bf1cbe44 100644 --- a/tests/unit/out/unsafe/global_without_initializer.rs +++ b/tests/unit/out/unsafe/global_without_initializer.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub a: i32, } diff --git a/tests/unit/out/unsafe/goto_aggregate_default.rs b/tests/unit/out/unsafe/goto_aggregate_default.rs index f16513aa2b..ed5c60b4f4 100644 --- a/tests/unit/out/unsafe/goto_aggregate_default.rs +++ b/tests/unit/out/unsafe/goto_aggregate_default.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Point { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/goto_cleanup.rs b/tests/unit/out/unsafe/goto_cleanup.rs index 23f9c2bf84..019821bafe 100644 --- a/tests/unit/out/unsafe/goto_cleanup.rs +++ b/tests/unit/out/unsafe/goto_cleanup.rs @@ -77,7 +77,18 @@ pub unsafe fn from_switch_2(mut n: i32) -> i32 { panic!("ub: non-void function does not return a value") } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct wrapper { pub item: *mut i32, } diff --git a/tests/unit/out/unsafe/huffman.rs b/tests/unit/out/unsafe/huffman.rs index a0401b093c..b56a78b8c0 100644 --- a/tests/unit/out/unsafe/huffman.rs +++ b/tests/unit/out/unsafe/huffman.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct MinHeapNode { pub data: libc::c_char, pub freq: i32, @@ -40,7 +51,7 @@ pub unsafe fn Swap_0(a: *mut MinHeapNode, b: *mut MinHeapNode) { }; } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, Default)] pub struct MinHeap { pub size: i32, pub capacity: i32, @@ -234,14 +245,18 @@ impl MinHeap { } } } - pub unsafe fn move_from(&mut self, _a0: *mut MinHeap) { +} +impl MoveConstructibleUnsafe for MinHeap { + unsafe fn move_constructor(&mut self, _a0: *mut MinHeap) { (&raw mut self.size).write((*_a0).size); (&raw mut self.capacity).write((*_a0).capacity); (&raw mut self.arr).write((*_a0).arr.take()); (&raw mut self.next).write((*_a0).next); (&raw mut self.alloc).write((*_a0).alloc.take()); } - pub unsafe fn move_assign(&mut self, _a0: *mut MinHeap) -> *mut MinHeap { +} +impl MoveAssignableUnsafe for MinHeap { + unsafe fn move_assign(&mut self, _a0: *mut MinHeap) -> *mut MinHeap { self.size = (*_a0).size; self.capacity = (*_a0).capacity; { diff --git a/tests/unit/out/unsafe/immutable-deref-on-func-call.rs b/tests/unit/out/unsafe/immutable-deref-on-func-call.rs index 1957ce4a35..e26afcde51 100644 --- a/tests/unit/out/unsafe/immutable-deref-on-func-call.rs +++ b/tests/unit/out/unsafe/immutable-deref-on-func-call.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Item { pub value: i32, } diff --git a/tests/unit/out/unsafe/implicit_autoref.rs b/tests/unit/out/unsafe/implicit_autoref.rs index 75493d1304..7ce5cc0cfb 100644 --- a/tests/unit/out/unsafe/implicit_autoref.rs +++ b/tests/unit/out/unsafe/implicit_autoref.rs @@ -8,16 +8,24 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + CopyAssignableUnsafe, + Default, )] pub struct Holder { pub v: Vec, } -impl Holder { - pub unsafe fn move_from(&mut self, _a0: *mut Holder) { +impl MoveConstructibleUnsafe for Holder { + unsafe fn move_constructor(&mut self, _a0: *mut Holder) { (&raw mut self.v).write(std::mem::take(&mut (*_a0).v)); } - pub unsafe fn move_assign(&mut self, _a0: *mut Holder) -> *mut Holder { +} +impl MoveAssignableUnsafe for Holder { + unsafe fn move_assign(&mut self, _a0: *mut Holder) -> *mut Holder { { self.v = std::mem::take(&mut (*_a0).v); }; diff --git a/tests/unit/out/unsafe/in_class_field_initializer.rs b/tests/unit/out/unsafe/in_class_field_initializer.rs index 7e89b20108..813969db5f 100644 --- a/tests/unit/out/unsafe/in_class_field_initializer.rs +++ b/tests/unit/out/unsafe/in_class_field_initializer.rs @@ -7,7 +7,17 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct Inner { pub x: i32, pub y: i32, @@ -18,7 +28,17 @@ impl Default for Inner { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct S { pub a: i32, pub b: libc::c_char, @@ -38,7 +58,17 @@ impl Default for S { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct Boxed_int_ { pub v: i32, pub tag: i32, diff --git a/tests/unit/out/unsafe/init.rs b/tests/unit/out/unsafe/init.rs index 76e510a3d2..a1f37d6af0 100644 --- a/tests/unit/out/unsafe/init.rs +++ b/tests/unit/out/unsafe/init.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct X { pub x: i32, } diff --git a/tests/unit/out/unsafe/init_list.rs b/tests/unit/out/unsafe/init_list.rs index a25486b0e7..d33d3a7416 100644 --- a/tests/unit/out/unsafe/init_list.rs +++ b/tests/unit/out/unsafe/init_list.rs @@ -8,13 +8,34 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub unsafe fn f_0(mut list: Vec) {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Pair { pub a: i32, pub b: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct Holder { pub p: Pair, } @@ -37,7 +58,17 @@ pub unsafe fn sum_1(p: *const Pair) -> i32 { return (((*p).a) + ((*p).b)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct Seven { pub v: i32, } diff --git a/tests/unit/out/unsafe/inline_container_fields.rs b/tests/unit/out/unsafe/inline_container_fields.rs index aa743542bc..46da544ecd 100644 --- a/tests/unit/out/unsafe/inline_container_fields.rs +++ b/tests/unit/out/unsafe/inline_container_fields.rs @@ -8,22 +8,30 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + CopyAssignableUnsafe, + Default, )] pub struct Elem { pub id: i32, pub hist: [i32; 4], pub coeffs: Vec, } -impl Elem { - pub unsafe fn move_from(&mut self, _a0: *mut Elem) { +impl MoveConstructibleUnsafe for Elem { + unsafe fn move_constructor(&mut self, _a0: *mut Elem) { (&raw mut self.id).write((*_a0).id); (&raw mut self.hist).write(std::array::from_fn::<_, 4, _>(|__i: usize| { (*_a0).hist[(__i)] })); (&raw mut self.coeffs).write(std::mem::take(&mut (*_a0).coeffs)); } - pub unsafe fn move_assign(&mut self, _a0: *mut Elem) -> *mut Elem { +} +impl MoveAssignableUnsafe for Elem { + unsafe fn move_assign(&mut self, _a0: *mut Elem) -> *mut Elem { self.id = (*_a0).id; { let mut __tmp_0 = { ((&mut self.hist as *mut [i32; 4]) as *mut ::libc::c_void) }; @@ -40,7 +48,9 @@ impl Elem { } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe)] +#[derive( + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, +)] pub struct State { pub count: i32, pub grid: [[i32; 3]; 2], @@ -48,8 +58,8 @@ pub struct State { pub elems: Vec, pub rows: Vec>, } -impl State { - pub unsafe fn move_from(&mut self, _a0: *mut State) { +impl MoveConstructibleUnsafe for State { + unsafe fn move_constructor(&mut self, _a0: *mut State) { (&raw mut self.count).write((*_a0).count); (&raw mut self.grid).write(std::array::from_fn::<_, 2, _>(|__i: usize| { std::array::from_fn::<_, 3, _>(|__i2: usize| (*_a0).grid[(__i)][(__i2)]) @@ -58,7 +68,9 @@ impl State { (&raw mut self.elems).write(std::mem::take(&mut (*_a0).elems)); (&raw mut self.rows).write(std::mem::take(&mut (*_a0).rows)); } - pub unsafe fn move_assign(&mut self, _a0: *mut State) -> *mut State { +} +impl MoveAssignableUnsafe for State { + unsafe fn move_assign(&mut self, _a0: *mut State) -> *mut State { self.count = (*_a0).count; { let mut __tmp_2 = { ((&mut self.grid as *mut [[i32; 3]; 2]) as *mut ::libc::c_void) }; @@ -71,7 +83,7 @@ impl State { }; { for __i in 0..3 { - *&mut self.arr[__i] = (*&mut (&mut (*_a0)).arr[__i]); + self.arr[__i].move_assign(&mut (&mut (*_a0)).arr[__i]); } }; { @@ -152,28 +164,32 @@ pub static mut moves_3: std::cell::LazyCell = std::cell::LazyCell::new(|| u pub static mut copy_assigns_4: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut move_assigns_5: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, CopyAssignUnsafe, MoveAssignUnsafe, -)] +#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe)] pub struct Counted { pub v: i32, } -impl Counted { - pub unsafe fn copy_from(&mut self, o: *const Counted) { +impl CopyConstructibleUnsafe for Counted { + unsafe fn copy_constructor(&mut self, o: *const Counted) { (&raw mut self.v).write((*o).v); (*std::cell::LazyCell::force_mut(&mut *&raw mut copies_2)).prefix_inc(); } - pub unsafe fn move_from(&mut self, o: *mut Counted) { +} +impl MoveConstructibleUnsafe for Counted { + unsafe fn move_constructor(&mut self, o: *mut Counted) { (&raw mut self.v).write((*o).v); (*o).v = -1_i32; (*std::cell::LazyCell::force_mut(&mut *&raw mut moves_3)).prefix_inc(); } - pub unsafe fn copy_assign(&mut self, o: *const Counted) -> *mut Counted { +} +impl CopyAssignableUnsafe for Counted { + unsafe fn copy_assign(&mut self, o: *const Counted) -> *mut Counted { self.v = (*o).v; (*std::cell::LazyCell::force_mut(&mut *&raw mut copy_assigns_4)).prefix_inc(); return &mut (*(self as *mut Counted)); } - pub unsafe fn move_assign(&mut self, o: *mut Counted) -> *mut Counted { +} +impl MoveAssignableUnsafe for Counted { + unsafe fn move_assign(&mut self, o: *mut Counted) -> *mut Counted { self.v = (*o).v; (*o).v = -1_i32; (*std::cell::LazyCell::force_mut(&mut *&raw mut move_assigns_5)).prefix_inc(); @@ -184,7 +200,7 @@ impl Clone for Counted { fn clone(&self) -> Self { unsafe { let mut __v: Counted = ::zero_init(); - Counted::copy_from(&mut __v, self as *const Counted); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const Counted); __v } } @@ -268,7 +284,7 @@ unsafe fn main_0() -> i32 { ); let mut moved: State = { let mut __v: State = ::zero_init(); - State::move_from(&mut __v, { &mut t }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut t }); __v }; assert!( @@ -278,7 +294,7 @@ unsafe fn main_0() -> i32 { assert!((((moved.elems.len()) == (4_usize)) && (t.elems.is_empty())) && (t.rows.is_empty())); assert!(((moved.arr[(1_usize)]) == (7)) && ((t.arr[(1_usize)]) == (7))); let mut assigned: State = ::default(); - (unsafe { State::move_assign(&mut assigned, &mut moved) }); + (unsafe { MoveAssignableUnsafe::move_assign(&mut assigned, &mut moved) }); assert!( ((assigned.grid[(0) as usize][(0) as usize]) == (100)) && ((assigned.grid[(1) as usize][(1) as usize]) == (4)) @@ -289,8 +305,14 @@ unsafe fn main_0() -> i32 { assert!(((assigned.arr[(1_usize)]) == (7)) && ((moved.arr[(1_usize)]) == (7))); let mut ca: [Counted; 3] = std::array::from_fn::<_, 3, _>(|_| ::default()); ca[(1_usize)].v = 5; - let mut cb: [Counted; 3] = - std::array::from_fn(|__i| ::move_ctor(&mut ca[__i])); + let mut cb: [Counted; 3] = { + let mut __v = std::mem::MaybeUninit::<[Counted; 3]>::uninit(); + let __p = __v.as_mut_ptr() as *mut Counted; + for __i in 0..3 { + (*__p.add(__i)).move_constructor(&mut ca[__i]); + } + __v.assume_init() + }; assert!( ((((*std::cell::LazyCell::force_mut(&mut *&raw mut moves_3)) == (3)) && ((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_2)) == (0))) @@ -307,7 +329,7 @@ unsafe fn main_0() -> i32 { cc[(2_usize)].v = 8; { for __i in 0..3 { - (*&mut cb[__i]).copy_assign(&cc[__i]); + cb[__i].copy_assign(&cc[__i]); } }; assert!( @@ -317,7 +339,7 @@ unsafe fn main_0() -> i32 { ); { for __i in 0..3 { - (*&mut ca[__i]).move_assign(&mut cb[__i]); + ca[__i].move_assign(&mut cb[__i]); } }; assert!( @@ -335,13 +357,19 @@ unsafe fn main_0() -> i32 { let __a1 = 1; va[(0_usize)].push(__a1) }; - let mut vb: [Vec; 2] = - std::array::from_fn(|__i| as MoveCtorUnsafe>::move_ctor(&mut va[__i])); + let mut vb: [Vec; 2] = { + let mut __v = std::mem::MaybeUninit::<[Vec; 2]>::uninit(); + let __p = __v.as_mut_ptr() as *mut Vec; + for __i in 0..2 { + (*__p.add(__i)).move_constructor(&mut va[__i]); + } + __v.assume_init() + }; assert!(((vb[(0_usize)].len()) == (1_usize)) && (va[(0_usize)].is_empty())); let mut vc: [Vec; 2] = std::array::from_fn::<_, 2, _>(|_| Default::default()); { for __i in 0..2 { - *&mut vc[__i] = as MoveCtorUnsafe>::move_ctor(&mut vb[__i]); + vc[__i].move_assign(&mut vb[__i]); } }; assert!(((vc[(0_usize)].len()) == (1_usize)) && (vb[(0_usize)].is_empty())); diff --git a/tests/unit/out/unsafe/kruskal.rs b/tests/unit/out/unsafe/kruskal.rs index 5dc49ca0bf..3451917a38 100644 --- a/tests/unit/out/unsafe/kruskal.rs +++ b/tests/unit/out/unsafe/kruskal.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Edge { pub u: i32, pub v: i32, @@ -164,7 +175,7 @@ pub unsafe fn quicksort_1(arr: *mut Option>, mut start: i32, mut end (unsafe { quicksort_1(arr, ((p) + (1)), end) }); } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, Default)] pub struct DisjointSet { pub rank: Option>, pub parent: Option>, @@ -274,12 +285,16 @@ impl DisjointSet { + (1)); } } - pub unsafe fn move_from(&mut self, _a0: *mut DisjointSet) { +} +impl MoveConstructibleUnsafe for DisjointSet { + unsafe fn move_constructor(&mut self, _a0: *mut DisjointSet) { (&raw mut self.rank).write((*_a0).rank.take()); (&raw mut self.parent).write((*_a0).parent.take()); (&raw mut self.n).write((*_a0).n); } - pub unsafe fn move_assign(&mut self, _a0: *mut DisjointSet) -> *mut DisjointSet { +} +impl MoveAssignableUnsafe for DisjointSet { + unsafe fn move_assign(&mut self, _a0: *mut DisjointSet) -> *mut DisjointSet { { self.rank = (*_a0).rank.take(); }; @@ -291,19 +306,21 @@ impl DisjointSet { } } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, Default)] pub struct Graph { pub edges: Option>, pub V: i32, pub E: i32, } -impl Graph { - pub unsafe fn move_from(&mut self, _a0: *mut Graph) { +impl MoveConstructibleUnsafe for Graph { + unsafe fn move_constructor(&mut self, _a0: *mut Graph) { (&raw mut self.edges).write((*_a0).edges.take()); (&raw mut self.V).write((*_a0).V); (&raw mut self.E).write((*_a0).E); } - pub unsafe fn move_assign(&mut self, _a0: *mut Graph) -> *mut Graph { +} +impl MoveAssignableUnsafe for Graph { + unsafe fn move_assign(&mut self, _a0: *mut Graph) -> *mut Graph { { self.edges = (*_a0).edges.take(); }; diff --git a/tests/unit/out/unsafe/lambda_as_field.rs b/tests/unit/out/unsafe/lambda_as_field.rs index 3dada1c532..9801af2fb3 100644 --- a/tests/unit/out/unsafe/lambda_as_field.rs +++ b/tests/unit/out/unsafe/lambda_as_field.rs @@ -7,7 +7,17 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct Guard__lambda_at_lambda_as_field_cpp_34_13__ { pub f: FnPtr, } @@ -28,7 +38,18 @@ impl Default for Guard__lambda_at_lambda_as_field_cpp_34_13__ { } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Guard__lambda_at_lambda_as_field_cpp_45_13__ { pub f: FnPtr, } @@ -38,7 +59,16 @@ impl Guard__lambda_at_lambda_as_field_cpp_45_13__ { } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct Holder__lambda_at_lambda_as_field_cpp_39_12__ { pub f: FnPtr i32>, pub calls: i32, @@ -64,7 +94,17 @@ impl Default for Holder__lambda_at_lambda_as_field_cpp_39_12__ { } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Holder__lambda_at_lambda_as_field_cpp_51_12__ { pub f: FnPtr i32>, pub calls: i32, @@ -76,7 +116,7 @@ impl Holder__lambda_at_lambda_as_field_cpp_51_12__ { } } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, CppFromUnsafe)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe)] #[cpp_from(FnPtr i32 > , construct, value)] pub struct Moving__lambda_at_lambda_as_field_cpp_64_12__ { pub f: FnPtr i32>, @@ -87,7 +127,9 @@ impl Moving__lambda_at_lambda_as_field_cpp_64_12__ { (&raw mut self.f).write(f.copy_from()); (&raw mut self.moves).write(0); } - pub unsafe fn move_from(&mut self, o: *mut Moving__lambda_at_lambda_as_field_cpp_64_12__) { +} +impl MoveConstructibleUnsafe for Moving__lambda_at_lambda_as_field_cpp_64_12__ { + unsafe fn move_constructor(&mut self, o: *mut Moving__lambda_at_lambda_as_field_cpp_64_12__) { (&raw mut self.f).write((*o).f.move_from()); (&raw mut self.moves).write((((*o).moves) + (1))); } @@ -214,7 +256,7 @@ unsafe fn main_0() -> i32 { let mut m2: Moving__lambda_at_lambda_as_field_cpp_64_12__ = { let mut __v: Moving__lambda_at_lambda_as_field_cpp_64_12__ = ::zero_init(); - Moving__lambda_at_lambda_as_field_cpp_64_12__::move_from(&mut __v, { &mut m }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut m }); __v }; assert!(((unsafe { m2.f.call(3,) }) == (6))); diff --git a/tests/unit/out/unsafe/lambda_capture_copy_ctor.rs b/tests/unit/out/unsafe/lambda_capture_copy_ctor.rs index 96a97ceea8..c1ec2bcc50 100644 --- a/tests/unit/out/unsafe/lambda_capture_copy_ctor.rs +++ b/tests/unit/out/unsafe/lambda_capture_copy_ctor.rs @@ -7,7 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe)] +#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe)] pub struct Counted { pub copies: i32, pub moves: i32, @@ -17,11 +17,15 @@ impl Counted { (&raw mut self.copies).write(0); (&raw mut self.moves).write(0); } - pub unsafe fn copy_from(&mut self, o: *const Counted) { +} +impl CopyConstructibleUnsafe for Counted { + unsafe fn copy_constructor(&mut self, o: *const Counted) { (&raw mut self.copies).write((((*o).copies) + (1))); (&raw mut self.moves).write((*o).moves); } - pub unsafe fn move_from(&mut self, o: *mut Counted) { +} +impl MoveConstructibleUnsafe for Counted { + unsafe fn move_constructor(&mut self, o: *mut Counted) { (&raw mut self.copies).write((*o).copies); (&raw mut self.moves).write((((*o).moves) + (1))); } @@ -30,7 +34,7 @@ impl Clone for Counted { fn clone(&self) -> Self { unsafe { let mut __v: Counted = ::zero_init(); - Counted::copy_from(&mut __v, self as *const Counted); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const Counted); __v } } @@ -48,21 +52,32 @@ impl Default for Counted { } pub static mut drops_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, DestructibleUnsafe)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct Dropped {} impl Dropped { pub unsafe fn construct(&mut self) {} - pub unsafe fn copy_from(&mut self, _a0: *const Dropped) {} - pub unsafe fn move_from(&mut self, _a0: *mut Dropped) {} pub unsafe fn destructor(&mut self) { (*std::cell::LazyCell::force_mut(&mut *&raw mut drops_0)).postfix_inc(); } } +impl CopyConstructibleUnsafe for Dropped { + unsafe fn copy_constructor(&mut self, _a0: *const Dropped) {} +} +impl MoveConstructibleUnsafe for Dropped { + unsafe fn move_constructor(&mut self, _a0: *mut Dropped) {} +} impl Clone for Dropped { fn clone(&self) -> Self { unsafe { let mut __v: Dropped = ::zero_init(); - Dropped::copy_from(&mut __v, self as *const Dropped); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const Dropped); __v } } @@ -94,7 +109,7 @@ unsafe fn main_0() -> i32 { { let c: Counted = { let mut __v: Counted = ::zero_init(); - Counted::copy_from(&mut __v, { &c }); + CopyConstructibleUnsafe::copy_constructor(&mut __v, { &c }); __v }; }, @@ -113,14 +128,14 @@ unsafe fn main_0() -> i32 { { let c: Counted = { let mut __v: Counted = ::zero_init(); - Counted::copy_from(&mut __v, { &c }); + CopyConstructibleUnsafe::copy_constructor(&mut __v, { &c }); __v }; }, || -> Counted { return { let mut __v: Counted = ::zero_init(); - Counted::copy_from(&mut __v, { &c }); + CopyConstructibleUnsafe::copy_constructor(&mut __v, { &c }); __v }; } @@ -138,7 +153,7 @@ unsafe fn main_0() -> i32 { { let arr: [Counted; 2] = std::array::from_fn::<_, 2, _>(|__i: usize| { let mut __v: Counted = ::zero_init(); - Counted::copy_from(&mut __v, { &arr[(__i)] }); + CopyConstructibleUnsafe::copy_constructor(&mut __v, { &arr[(__i)] }); __v }); }, diff --git a/tests/unit/out/unsafe/lambda_capture_ref.rs b/tests/unit/out/unsafe/lambda_capture_ref.rs index 3d87b57384..5b429d2c55 100644 --- a/tests/unit/out/unsafe/lambda_capture_ref.rs +++ b/tests/unit/out/unsafe/lambda_capture_ref.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/lambda_capture_star_this.rs b/tests/unit/out/unsafe/lambda_capture_star_this.rs index d35f3f26d7..3c5453ec98 100644 --- a/tests/unit/out/unsafe/lambda_capture_star_this.rs +++ b/tests/unit/out/unsafe/lambda_capture_star_this.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub n: i32, } diff --git a/tests/unit/out/unsafe/lambda_capture_this.rs b/tests/unit/out/unsafe/lambda_capture_this.rs index 324c3fdfce..803c2125d7 100644 --- a/tests/unit/out/unsafe/lambda_capture_this.rs +++ b/tests/unit/out/unsafe/lambda_capture_this.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub n: i32, pub step: i32, diff --git a/tests/unit/out/unsafe/lambda_capture_value.rs b/tests/unit/out/unsafe/lambda_capture_value.rs index 72d0840e72..3078dd26be 100644 --- a/tests/unit/out/unsafe/lambda_capture_value.rs +++ b/tests/unit/out/unsafe/lambda_capture_value.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/lambda_decltype_type.rs b/tests/unit/out/unsafe/lambda_decltype_type.rs index 8687ec472c..fc95024c3e 100644 --- a/tests/unit/out/unsafe/lambda_decltype_type.rs +++ b/tests/unit/out/unsafe/lambda_decltype_type.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { pub items: [i32; 4], pub size: i32, @@ -45,7 +54,16 @@ impl Default for Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct Sorted__lambda_at_lambda_decltype_type_cpp_19_23__ { pub items: [i32; 4], pub size: i32, diff --git a/tests/unit/out/unsafe/lambda_generic_explicit_args.rs b/tests/unit/out/unsafe/lambda_generic_explicit_args.rs index 299ff8311f..6ff8c417c3 100644 --- a/tests/unit/out/unsafe/lambda_generic_explicit_args.rs +++ b/tests/unit/out/unsafe/lambda_generic_explicit_args.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Val { pub x: i32, } diff --git a/tests/unit/out/unsafe/lambda_immediate_init.rs b/tests/unit/out/unsafe/lambda_immediate_init.rs index 08b7779573..63aafc5499 100644 --- a/tests/unit/out/unsafe/lambda_immediate_init.rs +++ b/tests/unit/out/unsafe/lambda_immediate_init.rs @@ -10,7 +10,17 @@ pub unsafe fn pick_0(mut x: i32) -> i32 { return x; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct S { pub j: i32, pub k: i32, diff --git a/tests/unit/out/unsafe/lambda_move_only_capture.rs b/tests/unit/out/unsafe/lambda_move_only_capture.rs index 24919581ed..a380ac74ac 100644 --- a/tests/unit/out/unsafe/lambda_move_only_capture.rs +++ b/tests/unit/out/unsafe/lambda_move_only_capture.rs @@ -7,9 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, CppFromUnsafe, DestructibleUnsafe, Default, -)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, Default)] #[cpp_from(i32, construct, value)] pub struct Owner { pub p: *mut i32, @@ -18,10 +16,6 @@ impl Owner { pub unsafe fn construct(&mut self, mut v: i32) { (&raw mut self.p).write((Box::leak(Box::new(v)) as *mut i32)); } - pub unsafe fn move_from(&mut self, o: *mut Owner) { - (&raw mut self.p).write((*o).p); - (*o).p = std::ptr::null_mut(); - } pub unsafe fn destructor(&mut self) { { let __p = self.p; @@ -35,7 +29,9 @@ impl Owner { { let self_: Owner = { let mut __v: Owner = ::zero_init(); - Owner::move_from(&mut __v, { &mut (*(self as *mut Owner)) }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { + &mut (*(self as *mut Owner)) + }); __v }; }, @@ -45,6 +41,12 @@ impl Owner { ); } } +impl MoveConstructibleUnsafe for Owner { + unsafe fn move_constructor(&mut self, o: *mut Owner) { + (&raw mut self.p).write((*o).p); + (*o).p = std::ptr::null_mut(); + } +} pub fn main() { unsafe { __cpp2rust_init_globals(); @@ -64,7 +66,7 @@ unsafe fn main_0() -> i32 { { let h: Owner = { let mut __v: Owner = ::zero_init(); - Owner::move_from(&mut __v, { &mut o }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut o }); __v }; }, diff --git a/tests/unit/out/unsafe/lambda_nested.rs b/tests/unit/out/unsafe/lambda_nested.rs index fc5e249862..f412980457 100644 --- a/tests/unit/out/unsafe/lambda_nested.rs +++ b/tests/unit/out/unsafe/lambda_nested.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/lambda_static_local.rs b/tests/unit/out/unsafe/lambda_static_local.rs index 00c32d0d0d..e97f08ff16 100644 --- a/tests/unit/out/unsafe/lambda_static_local.rs +++ b/tests/unit/out/unsafe/lambda_static_local.rs @@ -68,7 +68,18 @@ static mut n_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { static mut calls_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); static mut calls_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct P_4 { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/libc_struct_without_default.rs b/tests/unit/out/unsafe/libc_struct_without_default.rs index 6467e8c51f..6de0f7324f 100644 --- a/tests/unit/out/unsafe/libc_struct_without_default.rs +++ b/tests/unit/out/unsafe/libc_struct_without_default.rs @@ -7,20 +7,24 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe)] +#[derive( + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, +)] pub struct UserDefined { pub a: [i32; 1], pub v: Vec, } -impl UserDefined { - pub unsafe fn move_from(&mut self, _a0: *mut UserDefined) { +impl MoveConstructibleUnsafe for UserDefined { + unsafe fn move_constructor(&mut self, _a0: *mut UserDefined) { (&raw mut self.a).write((*_a0).a.clone()); (&raw mut self.v).write(std::mem::take(&mut (*_a0).v)); } - pub unsafe fn move_assign(&mut self, _a0: *mut UserDefined) -> *mut UserDefined { +} +impl MoveAssignableUnsafe for UserDefined { + unsafe fn move_assign(&mut self, _a0: *mut UserDefined) -> *mut UserDefined { { for __i in 0..1 { - *&mut self.a[__i] = (*&mut (&mut (*_a0)).a[__i]); + self.a[__i].move_assign(&mut (&mut (*_a0)).a[__i]); } }; { @@ -40,7 +44,17 @@ impl Default for UserDefined { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct FieldIsLibcType { pub addr: libc::sockaddr, } diff --git a/tests/unit/out/unsafe/linked_list.rs b/tests/unit/out/unsafe/linked_list.rs index 211ccf73ed..47acde0be0 100644 --- a/tests/unit/out/unsafe/linked_list.rs +++ b/tests/unit/out/unsafe/linked_list.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Node { pub val: i32, pub next: *mut Node, diff --git a/tests/unit/out/unsafe/local_anon_struct_collision.rs b/tests/unit/out/unsafe/local_anon_struct_collision.rs index 97456f247e..586b2251c0 100644 --- a/tests/unit/out/unsafe/local_anon_struct_collision.rs +++ b/tests/unit/out/unsafe/local_anon_struct_collision.rs @@ -13,7 +13,18 @@ pub unsafe fn first_0() -> i32 { return ((p.x) + (p.y)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct anon_1 { pub x: i32, pub y: i32, @@ -25,7 +36,18 @@ pub unsafe fn second_2() -> i32 { return (((q.a) + (q.b)) as i32); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct anon_3 { pub a: i64, pub b: i64, diff --git a/tests/unit/out/unsafe/local_record_template.rs b/tests/unit/out/unsafe/local_record_template.rs index 6e8b5cc30d..f9b0868d8e 100644 --- a/tests/unit/out/unsafe/local_record_template.rs +++ b/tests/unit/out/unsafe/local_record_template.rs @@ -30,12 +30,34 @@ pub unsafe fn wrap_10(mut v: i64) -> i32 { return (unsafe { get_6(l) }); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Local_5 { pub x: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Local_7 { pub x: i64, } @@ -44,7 +66,18 @@ pub unsafe fn other_11() -> i32 { return ((unsafe { get_0(l) }) + (l.y as i32)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Local_1 { pub x: i64, pub y: i64, @@ -65,7 +98,18 @@ unsafe fn main_0() -> i32 { return 0; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Local_3 { pub x: i32, } diff --git a/tests/unit/out/unsafe/map.rs b/tests/unit/out/unsafe/map.rs index 53348c3337..cfcb2a6410 100644 --- a/tests/unit/out/unsafe/map.rs +++ b/tests/unit/out/unsafe/map.rs @@ -13,7 +13,17 @@ pub unsafe fn bar_1(x: *mut u32) { (*x) = (*x).wrapping_add(1_u32); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct Point { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/map_key_copy_ctor.rs b/tests/unit/out/unsafe/map_key_copy_ctor.rs index 6c24884584..eb907962e3 100644 --- a/tests/unit/out/unsafe/map_key_copy_ctor.rs +++ b/tests/unit/out/unsafe/map_key_copy_ctor.rs @@ -10,7 +10,15 @@ pub static mut copies_0: std::cell::LazyCell = std::cell::LazyCell::new(|| pub static mut moves_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut made_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, CppFromUnsafe, Default)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct Key { pub k: i32, @@ -19,17 +27,21 @@ impl Key { pub unsafe fn construct(&mut self, mut k: i32) { (&raw mut self.k).write(k); } - pub unsafe fn copy_from(&mut self, o: *const Key) { + pub unsafe fn operator_lt(&self, o: *const Key) -> bool { + return ((self.k) < ((*o).k)); + } +} +impl CopyConstructibleUnsafe for Key { + unsafe fn copy_constructor(&mut self, o: *const Key) { (&raw mut self.k).write((*o).k); (*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)).prefix_inc(); } - pub unsafe fn move_from(&mut self, o: *mut Key) { +} +impl MoveConstructibleUnsafe for Key { + unsafe fn move_constructor(&mut self, o: *mut Key) { (&raw mut self.k).write((*o).k); (*std::cell::LazyCell::force_mut(&mut *&raw mut moves_1)).prefix_inc(); } - pub unsafe fn operator_lt(&self, o: *const Key) -> bool { - return ((self.k) < ((*o).k)); - } } impl std::cmp::Ord for Key { fn cmp(&self, other: &Self) -> std::cmp::Ordering { @@ -62,7 +74,7 @@ impl Clone for Key { fn clone(&self) -> Self { unsafe { let mut __v: Key = ::zero_init(); - Key::copy_from(&mut __v, self as *const Key); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const Key); __v } } diff --git a/tests/unit/out/unsafe/map_key_identity.rs b/tests/unit/out/unsafe/map_key_identity.rs index 7f46f2cfa0..0eedf808a1 100644 --- a/tests/unit/out/unsafe/map_key_identity.rs +++ b/tests/unit/out/unsafe/map_key_identity.rs @@ -9,7 +9,18 @@ use std::rc::Rc; pub static mut default_constructions_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Key { pub order: i32, pub identity: i32, @@ -45,7 +56,17 @@ pub unsafe fn operator_eq_2(a: *const Key, b: *const Key) -> bool { return (((*a).identity) == ((*b).identity)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct Mapped { pub value: i32, } diff --git a/tests/unit/out/unsafe/map_try_emplace.rs b/tests/unit/out/unsafe/map_try_emplace.rs index 6ac3acbe5a..4251253586 100644 --- a/tests/unit/out/unsafe/map_try_emplace.rs +++ b/tests/unit/out/unsafe/map_try_emplace.rs @@ -11,7 +11,14 @@ pub static mut made_1: std::cell::LazyCell = std::cell::LazyCell::new(|| un pub static mut copies_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut moves_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, CppFromUnsafe)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] #[cpp_from(i32, construct_1, value)] pub struct Item { pub value: i32, @@ -24,11 +31,15 @@ impl Item { (&raw mut self.value).write(value); (*std::cell::LazyCell::force_mut(&mut *&raw mut made_1)).prefix_inc(); } - pub unsafe fn copy_from(&mut self, other: *const Item) { +} +impl CopyConstructibleUnsafe for Item { + unsafe fn copy_constructor(&mut self, other: *const Item) { (&raw mut self.value).write((*other).value); (*std::cell::LazyCell::force_mut(&mut *&raw mut copies_2)).prefix_inc(); } - pub unsafe fn move_from(&mut self, other: *mut Item) { +} +impl MoveConstructibleUnsafe for Item { + unsafe fn move_constructor(&mut self, other: *mut Item) { (&raw mut self.value).write((*other).value); (*std::cell::LazyCell::force_mut(&mut *&raw mut moves_3)).prefix_inc(); (*other).value = -1_i32; @@ -38,7 +49,7 @@ impl Clone for Item { fn clone(&self) -> Self { unsafe { let mut __v: Item = ::zero_init(); - Item::copy_from(&mut __v, self as *const Item); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const Item); __v } } @@ -59,7 +70,17 @@ pub unsafe fn argument_4(item: *mut Item) -> *mut Item { return item; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct RefItem { pub value: i32, } @@ -271,7 +292,7 @@ unsafe fn main_0() -> i32 { match (((unsafe { argument_4(&mut source) }) as *mut Item),) { (__tmp_6,) => items.try_emplace(key, || { let mut __v: Item = ::zero_init(); - Item::copy_from(&mut __v, { __tmp_6 }); + CopyConstructibleUnsafe::copy_constructor(&mut __v, { __tmp_6 }); __v }), }; @@ -287,7 +308,7 @@ unsafe fn main_0() -> i32 { match (((unsafe { argument_4(&mut source) }) as *mut Item),) { (__tmp_7,) => items.try_emplace(key, || { let mut __v: Item = ::zero_init(); - Item::move_from(&mut __v, { __tmp_7 }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { __tmp_7 }); __v }), }; @@ -304,7 +325,7 @@ unsafe fn main_0() -> i32 { match (((unsafe { argument_4(&mut source) }) as *mut Item),) { (__tmp_8,) => items.try_emplace(key, || { let mut __v: Item = ::zero_init(); - Item::copy_from(&mut __v, { __tmp_8 }); + CopyConstructibleUnsafe::copy_constructor(&mut __v, { __tmp_8 }); __v }), }; @@ -321,7 +342,7 @@ unsafe fn main_0() -> i32 { match (((unsafe { argument_4(&mut source) }) as *mut Item),) { (__tmp_9,) => items.try_emplace(key, || { let mut __v: Item = ::zero_init(); - Item::move_from(&mut __v, { __tmp_9 }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { __tmp_9 }); __v }), }; @@ -399,7 +420,7 @@ unsafe fn main_0() -> i32 { { (__tmp_12,) => items.try_emplace(key, || { let mut __v: Item = ::zero_init(); - Item::move_from(&mut __v, { __tmp_12 }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { __tmp_12 }); __v }), } @@ -426,7 +447,7 @@ unsafe fn main_0() -> i32 { { (__tmp_14,) => items.try_emplace(key, || { let mut __v: Item = ::zero_init(); - Item::move_from(&mut __v, { __tmp_14 }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { __tmp_14 }); __v }), } diff --git a/tests/unit/out/unsafe/map_try_emplace_lvalues.rs b/tests/unit/out/unsafe/map_try_emplace_lvalues.rs index 3543262da1..2ef48c8a59 100644 --- a/tests/unit/out/unsafe/map_try_emplace_lvalues.rs +++ b/tests/unit/out/unsafe/map_try_emplace_lvalues.rs @@ -9,7 +9,17 @@ use std::rc::Rc; pub static mut made_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut visits_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct Item { pub value: i32, } @@ -47,7 +57,17 @@ pub unsafe fn place_3(n: *mut i32) -> *mut i32 { pub static mut temporary_calls_4: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct Temporary { pub n: i32, pub data: [i32; 2], @@ -71,7 +91,18 @@ impl Default for Temporary { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Nested { pub inner: Temporary, } @@ -86,7 +117,7 @@ pub unsafe fn make_nested_6() -> Nested { return ::default(); } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe)] +#[derive(FnPtrArg, ZeroInitializationUnsafe)] pub struct Owner { pub ptr: Option>, } @@ -104,10 +135,14 @@ impl Owner { })) .n; } - pub unsafe fn move_from(&mut self, _a0: *mut Owner) { +} +impl MoveConstructibleUnsafe for Owner { + unsafe fn move_constructor(&mut self, _a0: *mut Owner) { (&raw mut self.ptr).write((*_a0).ptr.take()); } - pub unsafe fn move_assign(&mut self, _a0: *mut Owner) -> *mut Owner { +} +impl MoveAssignableUnsafe for Owner { + unsafe fn move_assign(&mut self, _a0: *mut Owner) -> *mut Owner { { self.ptr = (*_a0).ptr.take(); }; @@ -136,7 +171,18 @@ impl Default for Noncopy { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] #[cpp_from(i32, construct_1, ptr)] pub struct Held { pub ptr: *const i32, diff --git a/tests/unit/out/unsafe/max.rs b/tests/unit/out/unsafe/max.rs index ba4bdc0a23..4bc1060e1e 100644 --- a/tests/unit/out/unsafe/max.rs +++ b/tests/unit/out/unsafe/max.rs @@ -17,7 +17,15 @@ pub unsafe fn pick_3(mut i: i32) -> *mut i32 { return &mut (*std::cell::LazyCell::force_mut(&mut *&raw mut xs_1))[(i) as usize]; } #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyAssignUnsafe, Default)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + MoveConstructibleUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct Bag { pub n: i32, @@ -26,11 +34,15 @@ impl Bag { pub unsafe fn construct(&mut self, mut n: i32) { (&raw mut self.n).write(n); } - pub unsafe fn copy_from(&mut self, o: *const Bag) { +} +impl CopyConstructibleUnsafe for Bag { + unsafe fn copy_constructor(&mut self, o: *const Bag) { (&raw mut self.n).write((*o).n); (*std::cell::LazyCell::force_mut(&mut *&raw mut calls_0)).prefix_inc(); } - pub unsafe fn copy_assign(&mut self, _a0: *const Bag) -> *mut Bag { +} +impl CopyAssignableUnsafe for Bag { + unsafe fn copy_assign(&mut self, _a0: *const Bag) -> *mut Bag { self.n = (*_a0).n; return &mut (*(self as *mut Bag)); } @@ -66,7 +78,7 @@ impl Clone for Bag { fn clone(&self) -> Self { unsafe { let mut __v: Bag = ::zero_init(); - Bag::copy_from(&mut __v, self as *const Bag); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const Bag); __v } } diff --git a/tests/unit/out/unsafe/memcpy_struct_bytes.rs b/tests/unit/out/unsafe/memcpy_struct_bytes.rs index 1e1546550b..8e8f41e25b 100644 --- a/tests/unit/out/unsafe/memcpy_struct_bytes.rs +++ b/tests/unit/out/unsafe/memcpy_struct_bytes.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct point { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/memcpy_struct_layouts.rs b/tests/unit/out/unsafe/memcpy_struct_layouts.rs index e8b124bb5a..35b7728086 100644 --- a/tests/unit/out/unsafe/memcpy_struct_layouts.rs +++ b/tests/unit/out/unsafe/memcpy_struct_layouts.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct packed { pub a: i32, pub b: libc::c_char, @@ -15,26 +26,70 @@ pub struct packed { pub d: i16, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct reordered { pub a: libc::c_char, pub b: i32, pub c: libc::c_char, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct tail { pub a: libc::c_char, pub b: f64, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct nested { pub t: tail, pub c: libc::c_char, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct array { pub name: [libc::c_char; 3], pub x: i32, diff --git a/tests/unit/out/unsafe/memcpy_struct_struct.rs b/tests/unit/out/unsafe/memcpy_struct_struct.rs index aa5d26b764..d78d033759 100644 --- a/tests/unit/out/unsafe/memcpy_struct_struct.rs +++ b/tests/unit/out/unsafe/memcpy_struct_struct.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Entry { pub bits: u8, pub value: u16, diff --git a/tests/unit/out/unsafe/memset_struct_tail.rs b/tests/unit/out/unsafe/memset_struct_tail.rs index a15533127c..bc351f788c 100644 --- a/tests/unit/out/unsafe/memset_struct_tail.rs +++ b/tests/unit/out/unsafe/memset_struct_tail.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub keep: i32, pub a: i32, diff --git a/tests/unit/out/unsafe/move_assign.rs b/tests/unit/out/unsafe/move_assign.rs index 14fa537b99..ad32567771 100644 --- a/tests/unit/out/unsafe/move_assign.rs +++ b/tests/unit/out/unsafe/move_assign.rs @@ -7,9 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, CppFromUnsafe, MoveAssignUnsafe, Default, -)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] #[cpp_from(i32, construct, value)] pub struct MoveOnly { pub v: i32, @@ -18,11 +16,15 @@ impl MoveOnly { pub unsafe fn construct(&mut self, mut v: i32) { (&raw mut self.v).write(v); } - pub unsafe fn move_from(&mut self, o: *mut MoveOnly) { +} +impl MoveConstructibleUnsafe for MoveOnly { + unsafe fn move_constructor(&mut self, o: *mut MoveOnly) { (&raw mut self.v).write((*o).v); (*o).v = 0; } - pub unsafe fn move_assign(&mut self, o: *mut MoveOnly) -> *mut MoveOnly { +} +impl MoveAssignableUnsafe for MoveOnly { + unsafe fn move_assign(&mut self, o: *mut MoveOnly) -> *mut MoveOnly { if ((self as *mut MoveOnly) == (o)) { return &mut (*(self as *mut MoveOnly)); } @@ -68,7 +70,7 @@ pub unsafe fn make_0(mut v: i32) -> MoveOnly { }; return { let mut __v: MoveOnly = ::zero_init(); - MoveOnly::move_from(&mut __v, { &mut m }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut m }); __v }; } @@ -94,7 +96,7 @@ unsafe fn main_0() -> i32 { MoveOnly::construct(&mut __v, { 3 }); __v }; - (unsafe { MoveOnly::move_assign(&mut a, &mut b) }); + (unsafe { MoveAssignableUnsafe::move_assign(&mut a, &mut b) }); assert!(((a.v) == (2))); assert!(((b.v) == (0))); (unsafe { @@ -103,12 +105,12 @@ unsafe fn main_0() -> i32 { MoveOnly::construct(&mut __v, { 3 }); __v }; - MoveOnly::move_assign(&mut b, &mut _o) + MoveAssignableUnsafe::move_assign(&mut b, &mut _o) }); (unsafe { - MoveOnly::move_assign( + MoveAssignableUnsafe::move_assign( &mut c, - &mut (*(unsafe { MoveOnly::move_assign(&mut a, &mut b) })), + &mut (*(unsafe { MoveAssignableUnsafe::move_assign(&mut a, &mut b) })), ) }); assert!((((b.v) == (0)) && ((a.v) == (0))) && ((c.v) == (3))); @@ -118,17 +120,17 @@ unsafe fn main_0() -> i32 { MoveOnly::construct(&mut __v, { 5 }); __v }; - MoveOnly::move_assign(&mut a, &mut _o) + MoveAssignableUnsafe::move_assign(&mut a, &mut _o) }); assert!(((a.v) == (5))); (unsafe { let mut _o: MoveOnly = (unsafe { make_0(6) }); - MoveOnly::move_assign(&mut a, &mut _o) + MoveAssignableUnsafe::move_assign(&mut a, &mut _o) }); assert!(((a.v) == (6))); (unsafe { let _o: *mut MoveOnly = &mut a; - MoveOnly::move_assign(&mut a, _o) + MoveAssignableUnsafe::move_assign(&mut a, _o) }); assert!(((a.v) == (6))); let mut vec_: Vec = Vec::new(); @@ -145,7 +147,7 @@ unsafe fn main_0() -> i32 { MoveOnly::construct(&mut __v, { 8 }); __v }; - (unsafe { MoveOnly::move_assign(&mut vec_[(0_usize)], &mut d) }); + (unsafe { MoveAssignableUnsafe::move_assign(&mut vec_[(0_usize)], &mut d) }); assert!(((vec_[(0_usize)].v) == (8))); assert!(((d.v) == (0))); let mut m: ConstMoveAssign = { diff --git a/tests/unit/out/unsafe/move_ctor.rs b/tests/unit/out/unsafe/move_ctor.rs index d86400308c..7001eee52d 100644 --- a/tests/unit/out/unsafe/move_ctor.rs +++ b/tests/unit/out/unsafe/move_ctor.rs @@ -7,7 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, CppFromUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] #[cpp_from(i32, construct, value)] pub struct MoveOnly { pub v: i32, @@ -16,7 +16,9 @@ impl MoveOnly { pub unsafe fn construct(&mut self, mut v: i32) { (&raw mut self.v).write(v); } - pub unsafe fn move_from(&mut self, o: *mut MoveOnly) { +} +impl MoveConstructibleUnsafe for MoveOnly { + unsafe fn move_constructor(&mut self, o: *mut MoveOnly) { (&raw mut self.v).write((*o).v); (*o).v = 0; } @@ -49,7 +51,15 @@ impl Default for ConstMove { } } #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, CppFromUnsafe, Default)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct ThrowingMove { pub v: i32, @@ -62,12 +72,16 @@ impl ThrowingMove { (&raw mut self.copies).write(0); (&raw mut self.moves).write(0); } - pub unsafe fn copy_from(&mut self, o: *const ThrowingMove) { +} +impl CopyConstructibleUnsafe for ThrowingMove { + unsafe fn copy_constructor(&mut self, o: *const ThrowingMove) { (&raw mut self.v).write((*o).v); (&raw mut self.copies).write((((*o).copies) + (1))); (&raw mut self.moves).write((*o).moves); } - pub unsafe fn move_from(&mut self, o: *mut ThrowingMove) { +} +impl MoveConstructibleUnsafe for ThrowingMove { + unsafe fn move_constructor(&mut self, o: *mut ThrowingMove) { (&raw mut self.v).write((*o).v); (&raw mut self.copies).write((*o).copies); (&raw mut self.moves).write((((*o).moves) + (1))); @@ -78,13 +92,21 @@ impl Clone for ThrowingMove { fn clone(&self) -> Self { unsafe { let mut __v: ThrowingMove = ::zero_init(); - ThrowingMove::copy_from(&mut __v, self as *const ThrowingMove); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const ThrowingMove); __v } } } #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, CppFromUnsafe, Default)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct NoexceptMove { pub v: i32, @@ -97,12 +119,16 @@ impl NoexceptMove { (&raw mut self.copies).write(0); (&raw mut self.moves).write(0); } - pub unsafe fn copy_from(&mut self, o: *const NoexceptMove) { +} +impl CopyConstructibleUnsafe for NoexceptMove { + unsafe fn copy_constructor(&mut self, o: *const NoexceptMove) { (&raw mut self.v).write((*o).v); (&raw mut self.copies).write((((*o).copies) + (1))); (&raw mut self.moves).write((*o).moves); } - pub unsafe fn move_from(&mut self, o: *mut NoexceptMove) { +} +impl MoveConstructibleUnsafe for NoexceptMove { + unsafe fn move_constructor(&mut self, o: *mut NoexceptMove) { (&raw mut self.v).write((*o).v); (&raw mut self.copies).write((*o).copies); (&raw mut self.moves).write((((*o).moves) + (1))); @@ -113,7 +139,7 @@ impl Clone for NoexceptMove { fn clone(&self) -> Self { unsafe { let mut __v: NoexceptMove = ::zero_init(); - NoexceptMove::copy_from(&mut __v, self as *const NoexceptMove); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const NoexceptMove); __v } } @@ -129,7 +155,7 @@ pub unsafe fn make_1(mut v: i32) -> MoveOnly { }; return { let mut __v: MoveOnly = ::zero_init(); - MoveOnly::move_from(&mut __v, { &mut m }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut m }); __v }; } @@ -147,21 +173,21 @@ unsafe fn main_0() -> i32 { }; let mut b: MoveOnly = { let mut __v: MoveOnly = ::zero_init(); - MoveOnly::move_from(&mut __v, { &mut a }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut a }); __v }; assert!(((b.v) == (1))); assert!(((a.v) == (0))); let mut c: MoveOnly = { let mut __v: MoveOnly = ::zero_init(); - MoveOnly::move_from(&mut __v, { &mut b }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut b }); __v }; assert!(((c.v) == (1))); assert!(((b.v) == (0))); let mut d: MoveOnly = { let mut __v: MoveOnly = ::zero_init(); - MoveOnly::move_from(&mut __v, { &mut c }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut c }); __v }; assert!(((d.v) == (1))); @@ -181,7 +207,7 @@ unsafe fn main_0() -> i32 { ((unsafe { by_value_0({ let mut __v: MoveOnly = ::zero_init(); - MoveOnly::move_from(&mut __v, { &mut e }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut e }); __v }) }) == (5)) @@ -204,7 +230,7 @@ unsafe fn main_0() -> i32 { { let __a1 = { let mut __v: MoveOnly = ::zero_init(); - MoveOnly::move_from(&mut __v, { &mut f }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut f }); __v }; vec_.push(__a1) @@ -240,7 +266,7 @@ unsafe fn main_0() -> i32 { }; let mut t1: ThrowingMove = { let mut __v: ThrowingMove = ::zero_init(); - ThrowingMove::copy_from(&mut __v, { &t }); + CopyConstructibleUnsafe::copy_constructor(&mut __v, { &t }); __v }; assert!(((t1.v) == (1))); @@ -254,7 +280,7 @@ unsafe fn main_0() -> i32 { }; let mut n1: NoexceptMove = { let mut __v: NoexceptMove = ::zero_init(); - NoexceptMove::move_from(&mut __v, { &mut n }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut n }); __v }; assert!(((n1.v) == (2))); @@ -268,7 +294,7 @@ unsafe fn main_0() -> i32 { }; let mut g1: MoveOnly = { let mut __v: MoveOnly = ::zero_init(); - MoveOnly::move_from(&mut __v, { &mut g }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut g }); __v }; assert!(((g1.v) == (3))); diff --git a/tests/unit/out/unsafe/move_this.rs b/tests/unit/out/unsafe/move_this.rs index 4430228e22..d64961f6f7 100644 --- a/tests/unit/out/unsafe/move_this.rs +++ b/tests/unit/out/unsafe/move_this.rs @@ -7,7 +7,15 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, CppFromUnsafe, Default)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct Chain { pub v: i32, @@ -16,13 +24,6 @@ impl Chain { pub unsafe fn construct(&mut self, mut v: i32) { (&raw mut self.v).write(v); } - pub unsafe fn copy_from(&mut self, o: *const Chain) { - (&raw mut self.v).write((((*o).v) + (100))); - } - pub unsafe fn move_from(&mut self, o: *mut Chain) { - (&raw mut self.v).write((((*o).v) + (1))); - (*o).v = 0; - } pub unsafe fn add_4(&mut self, mut n: i32) -> *mut Chain { self.v += n; return &mut (*(self as *mut Chain)); @@ -34,14 +35,14 @@ impl Chain { pub unsafe fn take(&mut self) -> Chain { return { let mut __v: Chain = ::zero_init(); - Chain::move_from(&mut __v, { &mut (*(self as *mut Chain)) }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut (*(self as *mut Chain)) }); __v }; } pub unsafe fn copy(&self) -> Chain { return { let mut __v: Chain = ::zero_init(); - Chain::copy_from(&mut __v, { &(*(self as *const Chain)) }); + CopyConstructibleUnsafe::copy_constructor(&mut __v, { &(*(self as *const Chain)) }); __v }; } @@ -49,11 +50,22 @@ impl Chain { return &mut (*(self as *mut Chain)); } } +impl CopyConstructibleUnsafe for Chain { + unsafe fn copy_constructor(&mut self, o: *const Chain) { + (&raw mut self.v).write((((*o).v) + (100))); + } +} +impl MoveConstructibleUnsafe for Chain { + unsafe fn move_constructor(&mut self, o: *mut Chain) { + (&raw mut self.v).write((((*o).v) + (1))); + (*o).v = 0; + } +} impl Clone for Chain { fn clone(&self) -> Self { unsafe { let mut __v: Chain = ::zero_init(); - Chain::copy_from(&mut __v, self as *const Chain); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const Chain); __v } } @@ -82,7 +94,7 @@ unsafe fn main_0() -> i32 { }; let mut b: Chain = { let mut __v: Chain = ::zero_init(); - Chain::move_from(&mut __v, { + MoveConstructibleUnsafe::move_constructor(&mut __v, { (unsafe { Chain::add_5(&mut (*(unsafe { Chain::add_5(&mut b0, 1) })), 1) }) }); __v @@ -107,7 +119,9 @@ unsafe fn main_0() -> i32 { ((unsafe { consume_0({ let mut __v: Chain = ::zero_init(); - Chain::move_from(&mut __v, { (unsafe { Chain::self_(&mut g) }) }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { + (unsafe { Chain::self_(&mut g) }) + }); __v }) }) == (21)) diff --git a/tests/unit/out/unsafe/nested_structs.rs b/tests/unit/out/unsafe/nested_structs.rs index d8c41c8069..988606062e 100644 --- a/tests/unit/out/unsafe/nested_structs.rs +++ b/tests/unit/out/unsafe/nested_structs.rs @@ -7,34 +7,100 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Level0_Level1_1_Level2_1_Level3_1 { pub x1: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Level0_Level1_1_Level2_1_Level3_2 { pub x1: i32, pub x2: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Level0_Level1_1_Level2_1 { pub x1: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Level0_Level1_1 { pub x1: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Level0_Level1_2 { pub x1: i32, pub x2: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Level0 {} pub fn main() { unsafe { diff --git a/tests/unit/out/unsafe/new.rs b/tests/unit/out/unsafe/new.rs index 5731da5eae..46cb8bd238 100644 --- a/tests/unit/out/unsafe/new.rs +++ b/tests/unit/out/unsafe/new.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Pair { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/new_bst.rs b/tests/unit/out/unsafe/new_bst.rs index 9ea5e7195c..964e97a8a4 100644 --- a/tests/unit/out/unsafe/new_bst.rs +++ b/tests/unit/out/unsafe/new_bst.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct node_t { pub left: *mut node_t, pub right: *mut node_t, diff --git a/tests/unit/out/unsafe/new_struct.rs b/tests/unit/out/unsafe/new_struct.rs index 89e8da7bff..e180c6c4cd 100644 --- a/tests/unit/out/unsafe/new_struct.rs +++ b/tests/unit/out/unsafe/new_struct.rs @@ -7,13 +7,35 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Pair { pub x: i32, pub y: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Triple { pub a: i32, pub b: i32, diff --git a/tests/unit/out/unsafe/nttp_distinct_specializations.rs b/tests/unit/out/unsafe/nttp_distinct_specializations.rs index 2052ce4e57..022bbdc13d 100644 --- a/tests/unit/out/unsafe/nttp_distinct_specializations.rs +++ b/tests/unit/out/unsafe/nttp_distinct_specializations.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S_2_ { pub v: i32, pub w: i32, @@ -18,7 +29,18 @@ impl S_2_ { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S_1_ { pub v: i32, } @@ -28,7 +50,18 @@ impl S_1_ { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S_3_ { pub v: i32, } diff --git a/tests/unit/out/unsafe/offsetof.rs b/tests/unit/out/unsafe/offsetof.rs index 0128737ecf..79770f687e 100644 --- a/tests/unit/out/unsafe/offsetof.rs +++ b/tests/unit/out/unsafe/offsetof.rs @@ -7,14 +7,35 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Layout { pub a: u8, pub b: u32, pub c: u16, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct Frame { pub tag: u16, pub body: [libc::c_char; 64], diff --git a/tests/unit/out/unsafe/opaque_forward_decl.rs b/tests/unit/out/unsafe/opaque_forward_decl.rs index ad48def68c..5dfc623f72 100644 --- a/tests/unit/out/unsafe/opaque_forward_decl.rs +++ b/tests/unit/out/unsafe/opaque_forward_decl.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct container { pub p: *mut opaque, pub x: i32, diff --git a/tests/unit/out/unsafe/opaque_record_copy.rs b/tests/unit/out/unsafe/opaque_record_copy.rs index 0e0276abc2..c90f2fa8da 100644 --- a/tests/unit/out/unsafe/opaque_record_copy.rs +++ b/tests/unit/out/unsafe/opaque_record_copy.rs @@ -7,10 +7,32 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Probe {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Wrapper_Probe_ { pub base_: Probe, pub tag: i32, diff --git a/tests/unit/out/unsafe/opaque_then_defined.rs b/tests/unit/out/unsafe/opaque_then_defined.rs index 23cd9f91cc..c49022dba3 100644 --- a/tests/unit/out/unsafe/opaque_then_defined.rs +++ b/tests/unit/out/unsafe/opaque_then_defined.rs @@ -7,13 +7,35 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct list { pub head: *mut node, pub size: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct node { pub value: i32, pub next: *mut node, diff --git a/tests/unit/out/unsafe/operator_arithmetic_free.rs b/tests/unit/out/unsafe/operator_arithmetic_free.rs index 7e49ca33fd..cc1c18c0cf 100644 --- a/tests/unit/out/unsafe/operator_arithmetic_free.rs +++ b/tests/unit/out/unsafe/operator_arithmetic_free.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_arithmetic_member.rs b/tests/unit/out/unsafe/operator_arithmetic_member.rs index 7c3c8e8486..d1d32e4e85 100644 --- a/tests/unit/out/unsafe/operator_arithmetic_member.rs +++ b/tests/unit/out/unsafe/operator_arithmetic_member.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_bitwise_free.rs b/tests/unit/out/unsafe/operator_bitwise_free.rs index 8594a0b335..8a899e7ca4 100644 --- a/tests/unit/out/unsafe/operator_bitwise_free.rs +++ b/tests/unit/out/unsafe/operator_bitwise_free.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub v: u32, } diff --git a/tests/unit/out/unsafe/operator_bitwise_member.rs b/tests/unit/out/unsafe/operator_bitwise_member.rs index 5659930911..12c59d82a7 100644 --- a/tests/unit/out/unsafe/operator_bitwise_member.rs +++ b/tests/unit/out/unsafe/operator_bitwise_member.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub v: u32, } diff --git a/tests/unit/out/unsafe/operator_comparison_defaulted.rs b/tests/unit/out/unsafe/operator_comparison_defaulted.rs index 90ade9a4bb..d980f46d8e 100644 --- a/tests/unit/out/unsafe/operator_comparison_defaulted.rs +++ b/tests/unit/out/unsafe/operator_comparison_defaulted.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Eq { pub a: i32, pub b: i32, @@ -25,7 +36,18 @@ impl std::cmp::PartialEq for Eq { } impl std::cmp::Eq for Eq {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Cmp { pub a: i32, pub b: i32, @@ -70,7 +92,18 @@ impl std::cmp::PartialEq for Cmp { } impl std::cmp::Eq for Cmp {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Both { pub a: i32, } @@ -106,7 +139,18 @@ impl std::cmp::PartialEq for Both { } impl std::cmp::Eq for Both {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct OrdOnly { pub a: i32, } @@ -139,7 +183,18 @@ impl std::cmp::PartialEq for OrdOnly { } impl std::cmp::Eq for OrdOnly {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Inner { pub x: i32, } @@ -175,7 +230,18 @@ impl std::cmp::PartialEq for Inner { } impl std::cmp::Eq for Inner {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Outer { pub i: Inner, pub y: i32, @@ -224,7 +290,18 @@ impl std::cmp::PartialEq for Outer { } impl std::cmp::Eq for Outer {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Secondary { pub a: i32, } @@ -271,7 +348,18 @@ impl std::cmp::PartialEq for Secondary { } impl std::cmp::Eq for Secondary {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct PtrMember { pub p: *mut i32, } diff --git a/tests/unit/out/unsafe/operator_comparison_free.rs b/tests/unit/out/unsafe/operator_comparison_free.rs index f01d77b248..13be95ca19 100644 --- a/tests/unit/out/unsafe/operator_comparison_free.rs +++ b/tests/unit/out/unsafe/operator_comparison_free.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub v: i32, } @@ -60,7 +71,18 @@ pub unsafe fn operator_lt_7(mut a: i32, b: *const S) -> bool { return ((a) < ((*b).v)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct V { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_comparison_member.rs b/tests/unit/out/unsafe/operator_comparison_member.rs index a31f1cfc20..84d166d588 100644 --- a/tests/unit/out/unsafe/operator_comparison_member.rs +++ b/tests/unit/out/unsafe/operator_comparison_member.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_comparison_mixed.rs b/tests/unit/out/unsafe/operator_comparison_mixed.rs index f1588054e9..ec859c2b41 100644 --- a/tests/unit/out/unsafe/operator_comparison_mixed.rs +++ b/tests/unit/out/unsafe/operator_comparison_mixed.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_comparison_nonbool.rs b/tests/unit/out/unsafe/operator_comparison_nonbool.rs index 8be2263ce3..d9f6036013 100644 --- a/tests/unit/out/unsafe/operator_comparison_nonbool.rs +++ b/tests/unit/out/unsafe/operator_comparison_nonbool.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct X { pub v: i32, } @@ -54,12 +65,34 @@ pub unsafe fn operator_ge_5(mut a: X, mut b: X) -> i32 { return if ((a.v) >= (b.v)) { 7 } else { 0 }; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Result { pub r: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Custom { pub v: i32, } @@ -71,7 +104,18 @@ impl Custom { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Mixed { pub v: i32, } @@ -113,7 +157,19 @@ impl std::cmp::PartialEq for Mixed { } impl std::cmp::Eq for Mixed {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_into(bool, to_bool)] pub struct MyBool { pub value: bool, @@ -127,7 +183,18 @@ impl MyBool { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Boolish { pub v: i32, } @@ -202,7 +269,18 @@ pub static mut ref_true_8: std::cell::LazyCell = std::cell::LazyCell::n } }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct RefInt { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_comparison_noncopyable.rs b/tests/unit/out/unsafe/operator_comparison_noncopyable.rs index 36c5023eae..8d446736a8 100644 --- a/tests/unit/out/unsafe/operator_comparison_noncopyable.rs +++ b/tests/unit/out/unsafe/operator_comparison_noncopyable.rs @@ -13,7 +13,7 @@ pub unsafe fn operator_lt_1(x: *const S, y: *const S) -> bool { return (((*x).data_) < ((*y).data_)); } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, CppFromUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] #[cpp_from(i32, construct, value)] pub struct S { data_: i32, @@ -22,7 +22,9 @@ impl S { pub unsafe fn construct(&mut self, mut data: i32) { (&raw mut self.data_).write(data); } - pub unsafe fn move_from(&mut self, _a0: *mut S) { +} +impl MoveConstructibleUnsafe for S { + unsafe fn move_constructor(&mut self, _a0: *mut S) { (&raw mut self.data_).write((*_a0).data_); } } diff --git a/tests/unit/out/unsafe/operator_compound_assignment_free.rs b/tests/unit/out/unsafe/operator_compound_assignment_free.rs index 2996a6581b..0894e1cab6 100644 --- a/tests/unit/out/unsafe/operator_compound_assignment_free.rs +++ b/tests/unit/out/unsafe/operator_compound_assignment_free.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub v: u32, } diff --git a/tests/unit/out/unsafe/operator_compound_assignment_member.rs b/tests/unit/out/unsafe/operator_compound_assignment_member.rs index 610a63b2a7..9b6d0d2985 100644 --- a/tests/unit/out/unsafe/operator_compound_assignment_member.rs +++ b/tests/unit/out/unsafe/operator_compound_assignment_member.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub v: u32, } diff --git a/tests/unit/out/unsafe/operator_friend.rs b/tests/unit/out/unsafe/operator_friend.rs index 905d24a0b7..50cc0b0795 100644 --- a/tests/unit/out/unsafe/operator_friend.rs +++ b/tests/unit/out/unsafe/operator_friend.rs @@ -10,7 +10,18 @@ pub unsafe fn operator_eq_0(_a0: *const Defaulted, _a1: *const Defaulted) -> boo return (((*_a0).a) == ((*_a1).a)) && (((*_a0).b) == ((*_a1).b)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Defaulted { pub a: i32, pub b: i32, @@ -37,7 +48,18 @@ pub unsafe fn operator_eq_2(_a0: *const DefaultedOrd, _a1: *const DefaultedOrd) return (((*_a0).a) == ((*_a1).a)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct DefaultedOrd { pub a: i32, } @@ -69,7 +91,18 @@ pub unsafe fn operator_add_5(x: *const Inline, y: *const Inline) -> Inline { }; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Inline { pub a: i32, } @@ -98,7 +131,18 @@ impl std::cmp::PartialEq for Inline { } impl std::cmp::Eq for Inline {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct OutOfLine { pub a: i32, } @@ -127,7 +171,18 @@ pub unsafe fn operator_eq_10(x: *const Tmpl_int_, y: *const Tmpl_long_) -> bool return (((*x).v as i64) == ((*y).v)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Tmpl_int_ { pub v: i32, } @@ -156,7 +211,18 @@ impl std::cmp::PartialEq for Tmpl_int_ { } impl std::cmp::Eq for Tmpl_int_ {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Tmpl_long_ { pub v: i64, } @@ -167,7 +233,18 @@ pub unsafe fn operator_eq_11( return (((*_a0).v) == ((*_a1).v)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct TmplDefaulted_int_ { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_less_than.rs b/tests/unit/out/unsafe/operator_less_than.rs index 714d01103a..b92eb7b3d7 100644 --- a/tests/unit/out/unsafe/operator_less_than.rs +++ b/tests/unit/out/unsafe/operator_less_than.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Pair { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/operator_logical_free.rs b/tests/unit/out/unsafe/operator_logical_free.rs index e888dc8141..cc31b7b52b 100644 --- a/tests/unit/out/unsafe/operator_logical_free.rs +++ b/tests/unit/out/unsafe/operator_logical_free.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_logical_member.rs b/tests/unit/out/unsafe/operator_logical_member.rs index e7029ceab2..5a175a2189 100644 --- a/tests/unit/out/unsafe/operator_logical_member.rs +++ b/tests/unit/out/unsafe/operator_logical_member.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_member_pointer_free.rs b/tests/unit/out/unsafe/operator_member_pointer_free.rs index ce8fa2513e..93a51f40f2 100644 --- a/tests/unit/out/unsafe/operator_member_pointer_free.rs +++ b/tests/unit/out/unsafe/operator_member_pointer_free.rs @@ -7,12 +7,34 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Inner { pub x: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub data: [i32; 3], pub inner: Inner, diff --git a/tests/unit/out/unsafe/operator_member_pointer_member.rs b/tests/unit/out/unsafe/operator_member_pointer_member.rs index 90c64cba8e..a5dfc26d8a 100644 --- a/tests/unit/out/unsafe/operator_member_pointer_member.rs +++ b/tests/unit/out/unsafe/operator_member_pointer_member.rs @@ -7,12 +7,34 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Inner { pub x: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Table {} impl Table { pub unsafe fn operator_index(mut i: i32) -> *mut i32 { @@ -22,7 +44,18 @@ impl Table { pub static mut table_0: std::cell::LazyCell<[i32; 3]> = std::cell::LazyCell::new(|| unsafe { [7, 8, 9] }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub data: [i32; 3], pub inner: Inner, diff --git a/tests/unit/out/unsafe/operator_other_free.rs b/tests/unit/out/unsafe/operator_other_free.rs index 6ef8081373..0b21ff3217 100644 --- a/tests/unit/out/unsafe/operator_other_free.rs +++ b/tests/unit/out/unsafe/operator_other_free.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_other_member.rs b/tests/unit/out/unsafe/operator_other_member.rs index 3d412fc229..4d32dabead 100644 --- a/tests/unit/out/unsafe/operator_other_member.rs +++ b/tests/unit/out/unsafe/operator_other_member.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Static {} impl Static { pub unsafe fn operator_call(mut a: i32, mut b: i32) -> i32 { @@ -15,7 +26,19 @@ impl Static { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_into(i32, to_i32)] pub struct S { pub v: i32, diff --git a/tests/unit/out/unsafe/operator_overloads.rs b/tests/unit/out/unsafe/operator_overloads.rs index 2d6ab5e58d..704b1de6c1 100644 --- a/tests/unit/out/unsafe/operator_overloads.rs +++ b/tests/unit/out/unsafe/operator_overloads.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_qualifiers.rs b/tests/unit/out/unsafe/operator_qualifiers.rs index dd0e64f6d5..e860530ebc 100644 --- a/tests/unit/out/unsafe/operator_qualifiers.rs +++ b/tests/unit/out/unsafe/operator_qualifiers.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_three_way.rs b/tests/unit/out/unsafe/operator_three_way.rs index 7d742a4677..f65f13b18e 100644 --- a/tests/unit/out/unsafe/operator_three_way.rs +++ b/tests/unit/out/unsafe/operator_three_way.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_traits.rs b/tests/unit/out/unsafe/operator_traits.rs index 6ab10c49d0..582791c6ee 100644 --- a/tests/unit/out/unsafe/operator_traits.rs +++ b/tests/unit/out/unsafe/operator_traits.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Lt { pub v: i32, } @@ -44,7 +55,18 @@ impl std::cmp::PartialEq for Lt { } impl std::cmp::Eq for Lt {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Eq { pub v: i32, } @@ -60,7 +82,18 @@ impl std::cmp::PartialEq for Eq { } impl std::cmp::Eq for Eq {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Cmp { pub v: i32, } @@ -89,7 +122,18 @@ impl std::cmp::PartialEq for Cmp { } impl std::cmp::Eq for Cmp {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Free { pub v: i32, } @@ -124,7 +168,18 @@ pub unsafe fn operator_eq_1(a: *const Free, b: *const Free) -> bool { return (((*a).v) == ((*b).v)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Wrapped_int_ { pub v: i32, } diff --git a/tests/unit/out/unsafe/overload_mangling.rs b/tests/unit/out/unsafe/overload_mangling.rs index 0c23dd1cce..e1cd7b9390 100644 --- a/tests/unit/out/unsafe/overload_mangling.rs +++ b/tests/unit/out/unsafe/overload_mangling.rs @@ -16,7 +16,18 @@ pub unsafe fn twice_2(mut n: i32) -> i32 { return ((n) * (2)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Access_S_ {} impl Access_S_ { pub unsafe fn get_1(&mut self, mut p: *mut S) -> i32 { @@ -33,7 +44,18 @@ impl Access_S_ { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub base: i32, } @@ -107,7 +129,18 @@ impl S { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Box_ { pub v: i32, } diff --git a/tests/unit/out/unsafe/pair_converting_construction.rs b/tests/unit/out/unsafe/pair_converting_construction.rs index d7372c6d86..d42b69c578 100644 --- a/tests/unit/out/unsafe/pair_converting_construction.rs +++ b/tests/unit/out/unsafe/pair_converting_construction.rs @@ -7,7 +7,19 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct Celsius { pub degrees: i32, @@ -18,7 +30,19 @@ impl Celsius { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_into(i32, to_i32)] pub struct Meters { pub value: i32, @@ -29,7 +53,19 @@ impl Meters { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(Celsius, construct, ptr)] pub struct Label { pub id: i32, @@ -40,7 +76,19 @@ impl Label { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(Celsius, construct_1, ptr)] #[cpp_from_move(Celsius, construct_2, ptr)] pub struct Owner { @@ -58,7 +106,19 @@ impl Owner { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(Celsius, construct, value)] pub struct Holder { pub value: i32, @@ -69,7 +129,18 @@ impl Holder { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] #[cpp_from(i32, construct, value)] pub struct Fallback { pub value: i32, @@ -91,12 +162,35 @@ impl Default for Fallback { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Counter { pub hits: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(Counter, construct, mut_ptr)] pub struct Observer { pub seen: i32, @@ -113,13 +207,37 @@ impl Tag { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(Celsius, construct, ptr)] pub struct Tag { pub code: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(*const libc::c_char , construct, value)] pub struct Name { pub len: i32, diff --git a/tests/unit/out/unsafe/pod.rs b/tests/unit/out/unsafe/pod.rs index e406666f6e..de1a2a34a0 100644 --- a/tests/unit/out/unsafe/pod.rs +++ b/tests/unit/out/unsafe/pod.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct POD { pub x1: i32, pub x2: i32, diff --git a/tests/unit/out/unsafe/pointer_array.rs b/tests/unit/out/unsafe/pointer_array.rs index 0f91664e48..b384ba916d 100644 --- a/tests/unit/out/unsafe/pointer_array.rs +++ b/tests/unit/out/unsafe/pointer_array.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct StackArray { pub arr: [*mut i32; 3], } diff --git a/tests/unit/out/unsafe/pointers.rs b/tests/unit/out/unsafe/pointers.rs index 8112e83a98..4b8c2a8b49 100644 --- a/tests/unit/out/unsafe/pointers.rs +++ b/tests/unit/out/unsafe/pointers.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Test { pub x: i32, } diff --git a/tests/unit/out/unsafe/polymorphism.rs b/tests/unit/out/unsafe/polymorphism.rs index da9d32dbe7..da0c53e34e 100644 --- a/tests/unit/out/unsafe/polymorphism.rs +++ b/tests/unit/out/unsafe/polymorphism.rs @@ -10,10 +10,32 @@ pub unsafe trait Animal { unsafe fn bark(&self) -> bool; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Dog {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Cat {} impl Cat { unsafe fn meow(&self) -> bool { diff --git a/tests/unit/out/unsafe/ptr_cast_init.rs b/tests/unit/out/unsafe/ptr_cast_init.rs index 18960f6967..bf827f8f3c 100644 --- a/tests/unit/out/unsafe/ptr_cast_init.rs +++ b/tests/unit/out/unsafe/ptr_cast_init.rs @@ -7,13 +7,35 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct header { pub tag: i32, pub size: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct view { pub tag: i32, } diff --git a/tests/unit/out/unsafe/push_emplace_back.rs b/tests/unit/out/unsafe/push_emplace_back.rs index a885c7dc7e..3b4bb7081b 100644 --- a/tests/unit/out/unsafe/push_emplace_back.rs +++ b/tests/unit/out/unsafe/push_emplace_back.rs @@ -7,30 +7,60 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Chunk { pub data: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Writer { pub output: *mut Vec, pub chunk: Chunk, } #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + CopyAssignableUnsafe, + Default, )] pub struct JPEGData { pub com_data: Vec>, pub app_data: Vec>, } -impl JPEGData { - pub unsafe fn move_from(&mut self, _a0: *mut JPEGData) { +impl MoveConstructibleUnsafe for JPEGData { + unsafe fn move_constructor(&mut self, _a0: *mut JPEGData) { (&raw mut self.com_data).write(std::mem::take(&mut (*_a0).com_data)); (&raw mut self.app_data).write(std::mem::take(&mut (*_a0).app_data)); } - pub unsafe fn move_assign(&mut self, _a0: *mut JPEGData) -> *mut JPEGData { +} +impl MoveAssignableUnsafe for JPEGData { + unsafe fn move_assign(&mut self, _a0: *mut JPEGData) -> *mut JPEGData { { self.com_data = std::mem::take(&mut (*_a0).com_data); }; @@ -106,7 +136,18 @@ pub unsafe fn self_ref_push_6(mut comps: *mut Vec) { }; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] #[cpp_from(i32, construct_1, value)] pub struct Pair { pub first: i32, @@ -211,18 +252,26 @@ pub unsafe fn emplace_ref_self_read_13(values: *mut Vec) -> *mut i64 { } #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + CopyAssignableUnsafe, + Default, )] pub struct Bytes { pub v: Vec>, pub b: [u8; 3], } -impl Bytes { - pub unsafe fn move_from(&mut self, _a0: *mut Bytes) { +impl MoveConstructibleUnsafe for Bytes { + unsafe fn move_constructor(&mut self, _a0: *mut Bytes) { (&raw mut self.v).write(std::mem::take(&mut (*_a0).v)); (&raw mut self.b).write(std::array::from_fn::<_, 3, _>(|__i: usize| (*_a0).b[(__i)])); } - pub unsafe fn move_assign(&mut self, _a0: *mut Bytes) -> *mut Bytes { +} +impl MoveAssignableUnsafe for Bytes { + unsafe fn move_assign(&mut self, _a0: *mut Bytes) -> *mut Bytes { { self.v = std::mem::take(&mut (*_a0).v); }; @@ -251,7 +300,18 @@ pub unsafe fn emplace_from_element_14(mut v: *mut Vec>) { }); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Plain { pub a: i32, pub b: [f64; 2], @@ -266,7 +326,18 @@ pub unsafe fn emplace_plain_15(mut v: *mut Vec) { pub static mut all_counted_16: std::cell::LazyCell<*mut Vec> = std::cell::LazyCell::new(|| unsafe { std::ptr::null_mut() }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Counted { pub seen: usize, } diff --git a/tests/unit/out/unsafe/random.rs b/tests/unit/out/unsafe/random.rs index 2971074173..16b125e40d 100644 --- a/tests/unit/out/unsafe/random.rs +++ b/tests/unit/out/unsafe/random.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Pair { pub x: i32, pub y: i32, @@ -41,7 +52,18 @@ pub unsafe fn zero_0() -> i32 { return 0; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct X1 {} pub unsafe fn foo_1(mut x1: i32, x2: *mut i32, mut x3: *mut i32, p2: *mut Pair, mut p3: *mut Pair) { } diff --git a/tests/unit/out/unsafe/reference_wrapper.rs b/tests/unit/out/unsafe/reference_wrapper.rs index 4fa29de55c..d7a7cbb2b8 100644 --- a/tests/unit/out/unsafe/reference_wrapper.rs +++ b/tests/unit/out/unsafe/reference_wrapper.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Point { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/references.rs b/tests/unit/out/unsafe/references.rs index 709dca3817..18c384a8d2 100644 --- a/tests/unit/out/unsafe/references.rs +++ b/tests/unit/out/unsafe/references.rs @@ -7,14 +7,36 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Pair { pub x: i32, pub y: i32, pub arr: [i32; 2], } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Nested { pub p: Pair, } diff --git a/tests/unit/out/unsafe/refs_as_args.rs b/tests/unit/out/unsafe/refs_as_args.rs index 45a5ae3708..962b87863a 100644 --- a/tests/unit/out/unsafe/refs_as_args.rs +++ b/tests/unit/out/unsafe/refs_as_args.rs @@ -18,7 +18,18 @@ pub unsafe fn more_refs_0(mut x1: i32, mut x2: i32, r1: *mut i32, r2: *const i32 (*r1) = (*rx2); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Val { pub x: i32, } diff --git a/tests/unit/out/unsafe/reinterpret_cast_ptr_cmp.rs b/tests/unit/out/unsafe/reinterpret_cast_ptr_cmp.rs index 45d8e80e36..5ac98d6b52 100644 --- a/tests/unit/out/unsafe/reinterpret_cast_ptr_cmp.rs +++ b/tests/unit/out/unsafe/reinterpret_cast_ptr_cmp.rs @@ -7,19 +7,52 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub x: i32, pub y: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct W { pub h: i32, pub arr: [S; 3], } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct P { pub a: *mut i32, pub arr: [*mut i32; 3], diff --git a/tests/unit/out/unsafe/reinterpret_cast_struct.rs b/tests/unit/out/unsafe/reinterpret_cast_struct.rs index b348cf519b..d0fcd3c68b 100644 --- a/tests/unit/out/unsafe/reinterpret_cast_struct.rs +++ b/tests/unit/out/unsafe/reinterpret_cast_struct.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Point { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/reinterpret_cast_struct_to_struct.rs b/tests/unit/out/unsafe/reinterpret_cast_struct_to_struct.rs index a29b90dea5..72500598c6 100644 --- a/tests/unit/out/unsafe/reinterpret_cast_struct_to_struct.rs +++ b/tests/unit/out/unsafe/reinterpret_cast_struct_to_struct.rs @@ -7,13 +7,35 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Point { pub x: u32, pub y: u32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Pair { pub first: u32, pub second: u32, diff --git a/tests/unit/out/unsafe/reserved_keywords.rs b/tests/unit/out/unsafe/reserved_keywords.rs index e4634df776..102ee287e8 100644 --- a/tests/unit/out/unsafe/reserved_keywords.rs +++ b/tests/unit/out/unsafe/reserved_keywords.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub as_: i32, pub async_: i32, @@ -49,12 +60,34 @@ pub struct S { pub vec_: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct type_ { pub v: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct loop_ { pub t: type_, } diff --git a/tests/unit/out/unsafe/return_move.rs b/tests/unit/out/unsafe/return_move.rs index 143c456492..38b3016ad4 100644 --- a/tests/unit/out/unsafe/return_move.rs +++ b/tests/unit/out/unsafe/return_move.rs @@ -7,13 +7,35 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct node { pub value: i32, pub next: *mut node, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct pair_t { pub a: i32, pub n: *mut node, diff --git a/tests/unit/out/unsafe/rule_of_five.rs b/tests/unit/out/unsafe/rule_of_five.rs index 0745283e1b..e6785642ba 100644 --- a/tests/unit/out/unsafe/rule_of_five.rs +++ b/tests/unit/out/unsafe/rule_of_five.rs @@ -10,17 +10,7 @@ pub static mut alive_0: std::cell::LazyCell = std::cell::LazyCell::new(|| u pub static mut copies_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut moves_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - MoveCtorUnsafe, - CppFromUnsafe, - CopyAssignUnsafe, - MoveAssignUnsafe, - DestructibleUnsafe, - Default, -)] +#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, Default)] #[cpp_from(i32, construct, value)] pub struct Buffer { pub data: [i32; 4], @@ -44,7 +34,9 @@ impl Buffer { pub unsafe fn destructor(&mut self) { (*std::cell::LazyCell::force_mut(&mut *&raw mut alive_0)).prefix_dec(); } - pub unsafe fn copy_from(&mut self, o: *const Buffer) { +} +impl CopyConstructibleUnsafe for Buffer { + unsafe fn copy_constructor(&mut self, o: *const Buffer) { (&raw mut self.data).write([0_i32; 4]); (&raw mut self.size).write((*o).size); { @@ -59,7 +51,9 @@ impl Buffer { (*std::cell::LazyCell::force_mut(&mut *&raw mut alive_0)).prefix_inc(); (*std::cell::LazyCell::force_mut(&mut *&raw mut copies_1)).prefix_inc(); } - pub unsafe fn move_from(&mut self, o: *mut Buffer) { +} +impl MoveConstructibleUnsafe for Buffer { + unsafe fn move_constructor(&mut self, o: *mut Buffer) { (&raw mut self.data).write([0_i32; 4]); (&raw mut self.size).write((*o).size); { @@ -76,7 +70,9 @@ impl Buffer { (*std::cell::LazyCell::force_mut(&mut *&raw mut alive_0)).prefix_inc(); (*std::cell::LazyCell::force_mut(&mut *&raw mut moves_2)).prefix_inc(); } - pub unsafe fn copy_assign(&mut self, o: *const Buffer) -> *mut Buffer { +} +impl CopyAssignableUnsafe for Buffer { + unsafe fn copy_assign(&mut self, o: *const Buffer) -> *mut Buffer { if (((self as *mut Buffer).cast_const()) == (o)) { return &mut (*(self as *mut Buffer)); } @@ -93,7 +89,9 @@ impl Buffer { (*std::cell::LazyCell::force_mut(&mut *&raw mut copies_1)).prefix_inc(); return &mut (*(self as *mut Buffer)); } - pub unsafe fn move_assign(&mut self, o: *mut Buffer) -> *mut Buffer { +} +impl MoveAssignableUnsafe for Buffer { + unsafe fn move_assign(&mut self, o: *mut Buffer) -> *mut Buffer { if ((self as *mut Buffer) == (o)) { return &mut (*(self as *mut Buffer)); } @@ -117,7 +115,7 @@ impl Clone for Buffer { fn clone(&self) -> Self { unsafe { let mut __v: Buffer = ::zero_init(); - Buffer::copy_from(&mut __v, self as *const Buffer); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const Buffer); __v } } @@ -133,7 +131,7 @@ pub unsafe fn make_3(mut size: i32) -> Buffer { }); return { let mut __v: Buffer = ::zero_init(); - Buffer::move_from(&mut __v, { &mut b }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut b }); __v }; } @@ -155,7 +153,7 @@ unsafe fn main_0() -> i32 { }); let mut b: Buffer = { let mut __v: Buffer = ::zero_init(); - Buffer::copy_from(&mut __v, { &a }); + CopyConstructibleUnsafe::copy_constructor(&mut __v, { &a }); __v }; let _dtor_b = std::mem::DropGuard::new(&raw mut b, |__p| unsafe { @@ -170,7 +168,7 @@ unsafe fn main_0() -> i32 { assert!(((a.data[(0) as usize]) == (0))); let mut c: Buffer = { let mut __v: Buffer = ::zero_init(); - Buffer::move_from(&mut __v, { &mut a }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut a }); __v }; let _dtor_c = std::mem::DropGuard::new(&raw mut c, |__p| unsafe { @@ -189,19 +187,19 @@ unsafe fn main_0() -> i32 { assert!( ((d.size) == (2)) && ((*std::cell::LazyCell::force_mut(&mut *&raw mut moves_2)) == (2)) ); - (unsafe { Buffer::copy_assign(&mut d, &b) }); + (unsafe { CopyAssignableUnsafe::copy_assign(&mut d, &b) }); assert!( (((d.size) == (4)) && ((d.data[(0) as usize]) == (100))) && ((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_1)) == (2)) ); - (unsafe { Buffer::move_assign(&mut d, &mut c) }); + (unsafe { MoveAssignableUnsafe::move_assign(&mut d, &mut c) }); assert!( (((d.data[(0) as usize]) == (0)) && ((c.size) == (0))) && ((*std::cell::LazyCell::force_mut(&mut *&raw mut moves_2)) == (3)) ); (unsafe { let _o: *mut Buffer = &mut d; - Buffer::move_assign(&mut d, _o) + MoveAssignableUnsafe::move_assign(&mut d, _o) }); assert!( ((d.size) == (4)) && ((*std::cell::LazyCell::force_mut(&mut *&raw mut moves_2)) == (3)) diff --git a/tests/unit/out/unsafe/rule_of_three.rs b/tests/unit/out/unsafe/rule_of_three.rs index c54d92ae60..206cabd63b 100644 --- a/tests/unit/out/unsafe/rule_of_three.rs +++ b/tests/unit/out/unsafe/rule_of_three.rs @@ -14,8 +14,9 @@ pub static mut copies_1: std::cell::LazyCell = std::cell::LazyCell::new(|| FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - CopyAssignUnsafe, DestructibleUnsafe, + MoveConstructibleUnsafe, + MoveAssignableUnsafe, Default, )] #[cpp_from(i32, construct, value)] @@ -41,7 +42,9 @@ impl Buffer { pub unsafe fn destructor(&mut self) { (*std::cell::LazyCell::force_mut(&mut *&raw mut alive_0)).prefix_dec(); } - pub unsafe fn copy_from(&mut self, o: *const Buffer) { +} +impl CopyConstructibleUnsafe for Buffer { + unsafe fn copy_constructor(&mut self, o: *const Buffer) { (&raw mut self.data).write([0_i32; 4]); (&raw mut self.size).write((*o).size); { @@ -56,7 +59,9 @@ impl Buffer { (*std::cell::LazyCell::force_mut(&mut *&raw mut alive_0)).prefix_inc(); (*std::cell::LazyCell::force_mut(&mut *&raw mut copies_1)).prefix_inc(); } - pub unsafe fn copy_assign(&mut self, o: *const Buffer) -> *mut Buffer { +} +impl CopyAssignableUnsafe for Buffer { + unsafe fn copy_assign(&mut self, o: *const Buffer) -> *mut Buffer { if (((self as *mut Buffer).cast_const()) == (o)) { return &mut (*(self as *mut Buffer)); } @@ -78,7 +83,7 @@ impl Clone for Buffer { fn clone(&self) -> Self { unsafe { let mut __v: Buffer = ::zero_init(); - Buffer::copy_from(&mut __v, self as *const Buffer); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const Buffer); __v } } @@ -114,7 +119,7 @@ unsafe fn main_0() -> i32 { }); let mut b: Buffer = { let mut __v: Buffer = ::zero_init(); - Buffer::copy_from(&mut __v, { &a }); + CopyConstructibleUnsafe::copy_constructor(&mut __v, { &a }); __v }; let _dtor_b = std::mem::DropGuard::new(&raw mut b, |__p| unsafe { @@ -134,7 +139,7 @@ unsafe fn main_0() -> i32 { let _dtor_c = std::mem::DropGuard::new(&raw mut c, |__p| unsafe { DestructibleUnsafe::destroy(__p) }); - (unsafe { Buffer::copy_assign(&mut c, &a) }); + (unsafe { CopyAssignableUnsafe::copy_assign(&mut c, &a) }); assert!(((c.size) == (4)) && ((c.data[(3) as usize]) == (3))); assert!( ((*std::cell::LazyCell::force_mut(&mut *&raw mut alive_0)) == (3)) @@ -142,14 +147,14 @@ unsafe fn main_0() -> i32 { ); (unsafe { let _o: *const Buffer = &c; - Buffer::copy_assign(&mut c, _o) + CopyAssignableUnsafe::copy_assign(&mut c, _o) }); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_1)) == (2))); assert!(((unsafe { sum_2(&a,) }) == (6))); assert!(((unsafe { sum_2(&b,) }) == (106))); let mut d: Buffer = { let mut __v: Buffer = ::zero_init(); - Buffer::copy_from(&mut __v, { &a }); + CopyConstructibleUnsafe::copy_constructor(&mut __v, { &a }); __v }; let _dtor_d = std::mem::DropGuard::new(&raw mut d, |__p| unsafe { @@ -160,7 +165,7 @@ unsafe fn main_0() -> i32 { && ((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_1)) == (3)) ); assert!(((a.size) == (4)) && ((a.data[(3) as usize]) == (3))); - (unsafe { Buffer::copy_assign(&mut d, &b) }); + (unsafe { CopyAssignableUnsafe::copy_assign(&mut d, &b) }); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_1)) == (4))); assert!(((b.data[(0) as usize]) == (100)) && ((d.data[(0) as usize]) == (100))); } diff --git a/tests/unit/out/unsafe/rvalue_rule_arg_move.rs b/tests/unit/out/unsafe/rvalue_rule_arg_move.rs index 8dbae5240c..6f148213b5 100644 --- a/tests/unit/out/unsafe/rvalue_rule_arg_move.rs +++ b/tests/unit/out/unsafe/rvalue_rule_arg_move.rs @@ -10,13 +10,7 @@ pub static mut copies_0: std::cell::LazyCell = std::cell::LazyCell::new(|| pub static mut moves_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] #[derive( - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - MoveCtorUnsafe, - CppFromUnsafe, - CopyAssignUnsafe, - Default, + VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, MoveAssignableUnsafe, Default, )] #[cpp_from(i32, construct, value)] pub struct Elem { @@ -26,15 +20,21 @@ impl Elem { pub unsafe fn construct(&mut self, mut v: i32) { (&raw mut self.v).write(v); } - pub unsafe fn copy_from(&mut self, o: *const Elem) { +} +impl CopyConstructibleUnsafe for Elem { + unsafe fn copy_constructor(&mut self, o: *const Elem) { (&raw mut self.v).write((*o).v); (*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)).prefix_inc(); } - pub unsafe fn move_from(&mut self, o: *mut Elem) { +} +impl MoveConstructibleUnsafe for Elem { + unsafe fn move_constructor(&mut self, o: *mut Elem) { (&raw mut self.v).write((*o).v); (*std::cell::LazyCell::force_mut(&mut *&raw mut moves_1)).prefix_inc(); } - pub unsafe fn copy_assign(&mut self, _a0: *const Elem) -> *mut Elem { +} +impl CopyAssignableUnsafe for Elem { + unsafe fn copy_assign(&mut self, _a0: *const Elem) -> *mut Elem { self.v = (*_a0).v; return &mut (*(self as *mut Elem)); } @@ -43,7 +43,7 @@ impl Clone for Elem { fn clone(&self) -> Self { unsafe { let mut __v: Elem = ::zero_init(); - Elem::copy_from(&mut __v, self as *const Elem); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const Elem); __v } } @@ -76,7 +76,7 @@ unsafe fn main_0() -> i32 { as usize; UnsafeRandomAccessIterator::Vec(v.insert_mut(pos, { let mut __v: Elem = ::zero_init(); - Elem::move_from(&mut __v, { &mut a }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut a }); __v })) }; diff --git a/tests/unit/out/unsafe/rvalue_struct.rs b/tests/unit/out/unsafe/rvalue_struct.rs index ab46e9daef..06509535f4 100644 --- a/tests/unit/out/unsafe/rvalue_struct.rs +++ b/tests/unit/out/unsafe/rvalue_struct.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub a: i32, pub b: i32, diff --git a/tests/unit/out/unsafe/scalar_builtin_construct_destruct.rs b/tests/unit/out/unsafe/scalar_builtin_construct_destruct.rs index c28c9079f0..89cfbe56e6 100644 --- a/tests/unit/out/unsafe/scalar_builtin_construct_destruct.rs +++ b/tests/unit/out/unsafe/scalar_builtin_construct_destruct.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Pod { pub v: i32, } diff --git a/tests/unit/out/unsafe/self_referencing_initializer.rs b/tests/unit/out/unsafe/self_referencing_initializer.rs index bba35fcbfa..6d130f69ca 100644 --- a/tests/unit/out/unsafe/self_referencing_initializer.rs +++ b/tests/unit/out/unsafe/self_referencing_initializer.rs @@ -7,18 +7,50 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct list_head { pub next: *mut list_head, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct node { pub value: i32, pub value_ptr: *mut i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct node_with_defaults { pub next: *mut node_with_defaults, pub value: i32, diff --git a/tests/unit/out/unsafe/size_t_static_member.rs b/tests/unit/out/unsafe/size_t_static_member.rs index 58dd977872..22f0869f50 100644 --- a/tests/unit/out/unsafe/size_t_static_member.rs +++ b/tests/unit/out/unsafe/size_t_static_member.rs @@ -8,12 +8,34 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub static mut c_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 5_usize }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S {} pub static mut table_size_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 256_usize }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Table_char_ {} pub fn main() { unsafe { diff --git a/tests/unit/out/unsafe/size_t_template_param.rs b/tests/unit/out/unsafe/size_t_template_param.rs index 1712711678..5c833f0413 100644 --- a/tests/unit/out/unsafe/size_t_template_param.rs +++ b/tests/unit/out/unsafe/size_t_template_param.rs @@ -11,7 +11,19 @@ pub unsafe fn array_ref_0(a: *mut [u64; 3]) -> u64 { return (*a)[((3_u64 as u64).wrapping_sub(1_u64)) as usize]; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(*const u64 , construct, value)] pub struct PtrCtor_unsigned_long_ { pub v: u64, @@ -22,7 +34,19 @@ impl PtrCtor_unsigned_long_ { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(u64, construct, ptr)] pub struct RefCtor_unsigned_long_ { pub v: u64, diff --git a/tests/unit/out/unsafe/sort_no_copy.rs b/tests/unit/out/unsafe/sort_no_copy.rs index 99ca033251..2cf3500828 100644 --- a/tests/unit/out/unsafe/sort_no_copy.rs +++ b/tests/unit/out/unsafe/sort_no_copy.rs @@ -8,15 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub static mut copies_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - MoveCtorUnsafe, - CppFromUnsafe, - CopyAssignUnsafe, - MoveAssignUnsafe, -)] +#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe)] #[cpp_from(i32, construct_1, value)] pub struct Tracked { pub v: i32, @@ -28,19 +20,27 @@ impl Tracked { pub unsafe fn construct_1(&mut self, mut v: i32) { (&raw mut self.v).write(v); } - pub unsafe fn copy_from(&mut self, o: *const Tracked) { +} +impl CopyConstructibleUnsafe for Tracked { + unsafe fn copy_constructor(&mut self, o: *const Tracked) { (&raw mut self.v).write((*o).v); (*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)).prefix_inc(); } - pub unsafe fn move_from(&mut self, o: *mut Tracked) { +} +impl MoveConstructibleUnsafe for Tracked { + unsafe fn move_constructor(&mut self, o: *mut Tracked) { (&raw mut self.v).write((*o).v); } - pub unsafe fn copy_assign(&mut self, o: *const Tracked) -> *mut Tracked { +} +impl CopyAssignableUnsafe for Tracked { + unsafe fn copy_assign(&mut self, o: *const Tracked) -> *mut Tracked { self.v = (*o).v; (*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)).prefix_inc(); return &mut (*(self as *mut Tracked)); } - pub unsafe fn move_assign(&mut self, o: *mut Tracked) -> *mut Tracked { +} +impl MoveAssignableUnsafe for Tracked { + unsafe fn move_assign(&mut self, o: *mut Tracked) -> *mut Tracked { self.v = (*o).v; return &mut (*(self as *mut Tracked)); } @@ -76,7 +76,7 @@ impl Clone for Tracked { fn clone(&self) -> Self { unsafe { let mut __v: Tracked = ::zero_init(); - Tracked::copy_from(&mut __v, self as *const Tracked); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const Tracked); __v } } @@ -99,9 +99,7 @@ pub unsafe fn greater_2(a: *const Tracked, b: *const Tracked) -> bool { return (((*a).v) > ((*b).v)); } #[repr(C)] -#[derive( - FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, CppFromUnsafe, MoveAssignUnsafe, Default, -)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] #[cpp_from(i32, construct, value)] pub struct MoveOnly { pub v: i32, @@ -110,10 +108,14 @@ impl MoveOnly { pub unsafe fn construct(&mut self, mut v: i32) { (&raw mut self.v).write(v); } - pub unsafe fn move_from(&mut self, _a0: *mut MoveOnly) { +} +impl MoveConstructibleUnsafe for MoveOnly { + unsafe fn move_constructor(&mut self, _a0: *mut MoveOnly) { (&raw mut self.v).write((*_a0).v); } - pub unsafe fn move_assign(&mut self, _a0: *mut MoveOnly) -> *mut MoveOnly { +} +impl MoveAssignableUnsafe for MoveOnly { + unsafe fn move_assign(&mut self, _a0: *mut MoveOnly) -> *mut MoveOnly { self.v = (*_a0).v; return &mut (*(self as *mut MoveOnly)); } @@ -150,16 +152,24 @@ pub unsafe fn operator_lt_3(a: *const MoveOnly, b: *const MoveOnly) -> bool { } #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + CopyAssignableUnsafe, + Default, )] pub struct Bag { pub items: Vec, } -impl Bag { - pub unsafe fn move_from(&mut self, _a0: *mut Bag) { +impl MoveConstructibleUnsafe for Bag { + unsafe fn move_constructor(&mut self, _a0: *mut Bag) { (&raw mut self.items).write(std::mem::take(&mut (*_a0).items)); } - pub unsafe fn move_assign(&mut self, _a0: *mut Bag) -> *mut Bag { +} +impl MoveAssignableUnsafe for Bag { + unsafe fn move_assign(&mut self, _a0: *mut Bag) -> *mut Bag { { self.items = std::mem::take(&mut (*_a0).items); }; diff --git a/tests/unit/out/unsafe/static_local.rs b/tests/unit/out/unsafe/static_local.rs index 50fd4588f8..7430113d6c 100644 --- a/tests/unit/out/unsafe/static_local.rs +++ b/tests/unit/out/unsafe/static_local.rs @@ -22,7 +22,18 @@ pub unsafe fn from_local_class_6() -> i32 { } static mut x_7: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 3 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S_8 {} impl S_8 { pub unsafe fn get(&self) -> i32 { diff --git a/tests/unit/out/unsafe/static_var_in_class.rs b/tests/unit/out/unsafe/static_var_in_class.rs index e7586525f7..b039adb0ae 100644 --- a/tests/unit/out/unsafe/static_var_in_class.rs +++ b/tests/unit/out/unsafe/static_var_in_class.rs @@ -8,7 +8,18 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; static mut inner_const_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 1 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct C {} impl C { pub unsafe fn get(&mut self) -> i32 { @@ -19,7 +30,18 @@ pub static mut inner_const_1: std::cell::LazyCell = std::cell::LazyCell::ne pub type anon_3 = u32; pub const anon_3_kValue: anon_3 = 3; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S {} impl S { pub unsafe fn f() -> i32 { diff --git a/tests/unit/out/unsafe/stdcopy.rs b/tests/unit/out/unsafe/stdcopy.rs index ab9b47b775..ff6cc9c0ed 100644 --- a/tests/unit/out/unsafe/stdcopy.rs +++ b/tests/unit/out/unsafe/stdcopy.rs @@ -7,7 +7,19 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct Degrees { pub value: i32, diff --git a/tests/unit/out/unsafe/strdup.rs b/tests/unit/out/unsafe/strdup.rs index 351bd03515..c16cc7309d 100644 --- a/tests/unit/out/unsafe/strdup.rs +++ b/tests/unit/out/unsafe/strdup.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct record { pub name: *mut libc::c_char, } diff --git a/tests/unit/out/unsafe/string_literal_ptr_init.rs b/tests/unit/out/unsafe/string_literal_ptr_init.rs index c0821ba4e1..e125a7c07f 100644 --- a/tests/unit/out/unsafe/string_literal_ptr_init.rs +++ b/tests/unit/out/unsafe/string_literal_ptr_init.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct label { pub name: *const libc::c_char, pub probe: Option i32>, diff --git a/tests/unit/out/unsafe/string_substr.rs b/tests/unit/out/unsafe/string_substr.rs index b8ab2533a5..255ce85c83 100644 --- a/tests/unit/out/unsafe/string_substr.rs +++ b/tests/unit/out/unsafe/string_substr.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Text { pub value: *mut Vec, } diff --git a/tests/unit/out/unsafe/struct_2d_array_field.rs b/tests/unit/out/unsafe/struct_2d_array_field.rs index 862bde13fd..c2e4f69519 100644 --- a/tests/unit/out/unsafe/struct_2d_array_field.rs +++ b/tests/unit/out/unsafe/struct_2d_array_field.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct table { pub rows: [[libc::c_char; 10]; 3], pub count: usize, diff --git a/tests/unit/out/unsafe/struct_ctor.rs b/tests/unit/out/unsafe/struct_ctor.rs index 812b350c7c..9f727c63bd 100644 --- a/tests/unit/out/unsafe/struct_ctor.rs +++ b/tests/unit/out/unsafe/struct_ctor.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct StructWithCtor { x1_: i32, x2_: i32, @@ -30,7 +41,19 @@ pub unsafe fn foo_0(x: *mut i32) -> *mut i32 { return x; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct Value_ { pub v: i32, @@ -41,7 +64,17 @@ impl Value_ { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct Ptr_ { pub v1: Value_, pub v2: Value_, diff --git a/tests/unit/out/unsafe/struct_default_ctor.rs b/tests/unit/out/unsafe/struct_default_ctor.rs index e55c02d7e2..ca0dc49c5f 100644 --- a/tests/unit/out/unsafe/struct_default_ctor.rs +++ b/tests/unit/out/unsafe/struct_default_ctor.rs @@ -7,7 +7,17 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct S { pub a: i32, pub b: bool, @@ -30,19 +40,51 @@ impl Default for S { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Declared { pub v: i32, } impl Declared {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Holder { pub items: [S; 2], } pub static mut kInit_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 3 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct FromStatic { pub v: i32, } diff --git a/tests/unit/out/unsafe/struct_member_array_adjacency.rs b/tests/unit/out/unsafe/struct_member_array_adjacency.rs index d989b19db8..e2f4e04a66 100644 --- a/tests/unit/out/unsafe/struct_member_array_adjacency.rs +++ b/tests/unit/out/unsafe/struct_member_array_adjacency.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct pair { pub a: [i32; 4], pub b: [i32; 4], diff --git a/tests/unit/out/unsafe/struct_ptr.rs b/tests/unit/out/unsafe/struct_ptr.rs index 8857f43498..892919cb4f 100644 --- a/tests/unit/out/unsafe/struct_ptr.rs +++ b/tests/unit/out/unsafe/struct_ptr.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct XX { pub x: i32, } diff --git a/tests/unit/out/unsafe/structured_binding_copy_ctor.rs b/tests/unit/out/unsafe/structured_binding_copy_ctor.rs index bbac1d8016..daf0cc190b 100644 --- a/tests/unit/out/unsafe/structured_binding_copy_ctor.rs +++ b/tests/unit/out/unsafe/structured_binding_copy_ctor.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub static mut copies_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyAssignUnsafe, Default)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + MoveConstructibleUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Counted { pub x: i32, pub y: i32, @@ -18,12 +25,16 @@ impl Counted { (&raw mut self.x).write(x); (&raw mut self.y).write(y); } - pub unsafe fn copy_from(&mut self, other: *const Counted) { +} +impl CopyConstructibleUnsafe for Counted { + unsafe fn copy_constructor(&mut self, other: *const Counted) { (&raw mut self.x).write((((*other).x) * (2))); (&raw mut self.y).write((((*other).y) * (2))); (*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)).prefix_inc(); } - pub unsafe fn copy_assign(&mut self, _a0: *const Counted) -> *mut Counted { +} +impl CopyAssignableUnsafe for Counted { + unsafe fn copy_assign(&mut self, _a0: *const Counted) -> *mut Counted { self.x = (*_a0).x; self.y = (*_a0).y; return &mut (*(self as *mut Counted)); @@ -33,7 +44,7 @@ impl Clone for Counted { fn clone(&self) -> Self { unsafe { let mut __v: Counted = ::zero_init(); - Counted::copy_from(&mut __v, self as *const Counted); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const Counted); __v } } @@ -59,7 +70,7 @@ unsafe fn main_0() -> i32 { }; let mut __decomp_2: Counted = { let mut __v: Counted = ::zero_init(); - Counted::copy_from(&mut __v, { &s }); + CopyConstructibleUnsafe::copy_constructor(&mut __v, { &s }); __v }; assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (1))); diff --git a/tests/unit/out/unsafe/structured_binding_element_ctor.rs b/tests/unit/out/unsafe/structured_binding_element_ctor.rs index ec6a6f9fc9..f2925d8dd8 100644 --- a/tests/unit/out/unsafe/structured_binding_element_ctor.rs +++ b/tests/unit/out/unsafe/structured_binding_element_ctor.rs @@ -9,7 +9,15 @@ use std::rc::Rc; pub static mut copies_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut moves_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, CppFromUnsafe, Default)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct Elem { pub v: i32, @@ -18,11 +26,15 @@ impl Elem { pub unsafe fn construct(&mut self, mut v: i32) { (&raw mut self.v).write(v); } - pub unsafe fn copy_from(&mut self, other: *const Elem) { +} +impl CopyConstructibleUnsafe for Elem { + unsafe fn copy_constructor(&mut self, other: *const Elem) { (&raw mut self.v).write((((*other).v) + (100))); (*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)).prefix_inc(); } - pub unsafe fn move_from(&mut self, other: *mut Elem) { +} +impl MoveConstructibleUnsafe for Elem { + unsafe fn move_constructor(&mut self, other: *mut Elem) { (&raw mut self.v).write((((*other).v) + (1000))); (*other).v = -1_i32; (*std::cell::LazyCell::force_mut(&mut *&raw mut moves_1)).prefix_inc(); @@ -32,27 +44,36 @@ impl Clone for Elem { fn clone(&self) -> Self { unsafe { let mut __v: Elem = ::zero_init(); - Elem::copy_from(&mut __v, self as *const Elem); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const Elem); __v } } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Two { pub a: Elem, pub b: Elem, } -impl Two { - pub unsafe fn move_from(&mut self, _a0: *mut Two) { +impl MoveConstructibleUnsafe for Two { + unsafe fn move_constructor(&mut self, _a0: *mut Two) { (&raw mut self.a).write({ let mut __v: Elem = ::zero_init(); - Elem::move_from(&mut __v, { &mut (*_a0).a }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut (*_a0).a }); __v }); (&raw mut self.b).write({ let mut __v: Elem = ::zero_init(); - Elem::move_from(&mut __v, { &mut (*_a0).b }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut (*_a0).b }); __v }); } @@ -104,7 +125,7 @@ unsafe fn main_0() -> i32 { assert!(((t.a.v) == (50))); let mut __decomp_5: Two = { let mut __v: Two = ::zero_init(); - Two::move_from(&mut __v, { &mut t }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut t }); __v }; assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut moves_1)) == ((base_moves) + (2)))); diff --git a/tests/unit/out/unsafe/structured_binding_move_ctor.rs b/tests/unit/out/unsafe/structured_binding_move_ctor.rs index 399d57d9ef..24ebdad87d 100644 --- a/tests/unit/out/unsafe/structured_binding_move_ctor.rs +++ b/tests/unit/out/unsafe/structured_binding_move_ctor.rs @@ -9,7 +9,9 @@ use std::rc::Rc; pub static mut copies_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut moves_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, Default)] +#[derive( + VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, Default, +)] pub struct Movable { pub x: i32, pub y: i32, @@ -19,12 +21,16 @@ impl Movable { (&raw mut self.x).write(x); (&raw mut self.y).write(y); } - pub unsafe fn copy_from(&mut self, other: *const Movable) { +} +impl CopyConstructibleUnsafe for Movable { + unsafe fn copy_constructor(&mut self, other: *const Movable) { (&raw mut self.x).write((*other).x); (&raw mut self.y).write((*other).y); (*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)).prefix_inc(); } - pub unsafe fn move_from(&mut self, other: *mut Movable) { +} +impl MoveConstructibleUnsafe for Movable { + unsafe fn move_constructor(&mut self, other: *mut Movable) { (&raw mut self.x).write((*other).x); (&raw mut self.y).write((*other).y); (*other).x = 0; @@ -36,14 +42,20 @@ impl Clone for Movable { fn clone(&self) -> Self { unsafe { let mut __v: Movable = ::zero_init(); - Movable::copy_from(&mut __v, self as *const Movable); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const Movable); __v } } } #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + CopyAssignableUnsafe, + Default, )] pub struct Holder { pub xs: Vec, @@ -56,11 +68,15 @@ impl Holder { ys: std::mem::take(&mut self.ys), }; } - pub unsafe fn move_from(&mut self, _a0: *mut Holder) { +} +impl MoveConstructibleUnsafe for Holder { + unsafe fn move_constructor(&mut self, _a0: *mut Holder) { (&raw mut self.xs).write(std::mem::take(&mut (*_a0).xs)); (&raw mut self.ys).write(std::mem::take(&mut (*_a0).ys)); } - pub unsafe fn move_assign(&mut self, _a0: *mut Holder) -> *mut Holder { +} +impl MoveAssignableUnsafe for Holder { + unsafe fn move_assign(&mut self, _a0: *mut Holder) -> *mut Holder { { self.xs = std::mem::take(&mut (*_a0).xs); }; @@ -84,7 +100,7 @@ unsafe fn main_0() -> i32 { }; let mut __decomp_2: Movable = { let mut __v: Movable = ::zero_init(); - Movable::move_from(&mut __v, { &mut m }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut m }); __v }; assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut moves_1)) == (1))); diff --git a/tests/unit/out/unsafe/structured_binding_range_for.rs b/tests/unit/out/unsafe/structured_binding_range_for.rs index dbadfe57a2..0ac56b67ab 100644 --- a/tests/unit/out/unsafe/structured_binding_range_for.rs +++ b/tests/unit/out/unsafe/structured_binding_range_for.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Pair { pub first: i32, pub second: i32, diff --git a/tests/unit/out/unsafe/structured_binding_ref.rs b/tests/unit/out/unsafe/structured_binding_ref.rs index e2d3b5c4d3..077982f137 100644 --- a/tests/unit/out/unsafe/structured_binding_ref.rs +++ b/tests/unit/out/unsafe/structured_binding_ref.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Triple { pub a: i32, pub b: bool, diff --git a/tests/unit/out/unsafe/structured_binding_trivial.rs b/tests/unit/out/unsafe/structured_binding_trivial.rs index 0aeb2330ef..c81ea16ee2 100644 --- a/tests/unit/out/unsafe/structured_binding_trivial.rs +++ b/tests/unit/out/unsafe/structured_binding_trivial.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Pair { pub first: i32, pub second: i32, diff --git a/tests/unit/out/unsafe/swap_map_no_copy.rs b/tests/unit/out/unsafe/swap_map_no_copy.rs index f824eb7c11..81f972290b 100644 --- a/tests/unit/out/unsafe/swap_map_no_copy.rs +++ b/tests/unit/out/unsafe/swap_map_no_copy.rs @@ -8,15 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub static mut copies_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - MoveCtorUnsafe, - CppFromUnsafe, - CopyAssignUnsafe, - MoveAssignUnsafe, -)] +#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe)] #[cpp_from(i32, construct_1, value)] pub struct Tracked { pub v: i32, @@ -28,19 +20,27 @@ impl Tracked { pub unsafe fn construct_1(&mut self, mut v: i32) { (&raw mut self.v).write(v); } - pub unsafe fn copy_from(&mut self, o: *const Tracked) { +} +impl CopyConstructibleUnsafe for Tracked { + unsafe fn copy_constructor(&mut self, o: *const Tracked) { (&raw mut self.v).write((*o).v); (*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)).prefix_inc(); } - pub unsafe fn move_from(&mut self, o: *mut Tracked) { +} +impl MoveConstructibleUnsafe for Tracked { + unsafe fn move_constructor(&mut self, o: *mut Tracked) { (&raw mut self.v).write((*o).v); } - pub unsafe fn copy_assign(&mut self, o: *const Tracked) -> *mut Tracked { +} +impl CopyAssignableUnsafe for Tracked { + unsafe fn copy_assign(&mut self, o: *const Tracked) -> *mut Tracked { self.v = (*o).v; (*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)).prefix_inc(); return &mut (*(self as *mut Tracked)); } - pub unsafe fn move_assign(&mut self, o: *mut Tracked) -> *mut Tracked { +} +impl MoveAssignableUnsafe for Tracked { + unsafe fn move_assign(&mut self, o: *mut Tracked) -> *mut Tracked { self.v = (*o).v; return &mut (*(self as *mut Tracked)); } @@ -49,7 +49,7 @@ impl Clone for Tracked { fn clone(&self) -> Self { unsafe { let mut __v: Tracked = ::zero_init(); - Tracked::copy_from(&mut __v, self as *const Tracked); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const Tracked); __v } } @@ -66,92 +66,80 @@ impl Default for Tracked { } } #[repr(C)] -#[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - MoveCtorUnsafe, - CopyAssignUnsafe, - MoveAssignUnsafe, - Default, -)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyConstructibleUnsafe, Default)] pub struct Pair { pub x: Tracked, pub y: Tracked, } -impl Pair { - pub unsafe fn move_from(&mut self, _a0: *mut Pair) { +impl MoveConstructibleUnsafe for Pair { + unsafe fn move_constructor(&mut self, _a0: *mut Pair) { (&raw mut self.x).write({ let mut __v: Tracked = ::zero_init(); - Tracked::move_from(&mut __v, { &mut (*_a0).x }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut (*_a0).x }); __v }); (&raw mut self.y).write({ let mut __v: Tracked = ::zero_init(); - Tracked::move_from(&mut __v, { &mut (*_a0).y }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut (*_a0).y }); __v }); } - pub unsafe fn copy_assign(&mut self, _a0: *const Pair) -> *mut Pair { +} +impl CopyAssignableUnsafe for Pair { + unsafe fn copy_assign(&mut self, _a0: *const Pair) -> *mut Pair { (unsafe { let _o: *const Tracked = &(*_a0).x; - Tracked::copy_assign(&mut self.x, _o) + CopyAssignableUnsafe::copy_assign(&mut self.x, _o) }); (unsafe { let _o: *const Tracked = &(*_a0).y; - Tracked::copy_assign(&mut self.y, _o) + CopyAssignableUnsafe::copy_assign(&mut self.y, _o) }); return &mut (*(self as *mut Pair)); } - pub unsafe fn move_assign(&mut self, _a0: *mut Pair) -> *mut Pair { +} +impl MoveAssignableUnsafe for Pair { + unsafe fn move_assign(&mut self, _a0: *mut Pair) -> *mut Pair { (unsafe { let _o: *mut Tracked = &mut (*_a0).x; - Tracked::move_assign(&mut self.x, _o) + MoveAssignableUnsafe::move_assign(&mut self.x, _o) }); (unsafe { let _o: *mut Tracked = &mut (*_a0).y; - Tracked::move_assign(&mut self.y, _o) + MoveAssignableUnsafe::move_assign(&mut self.y, _o) }); return &mut (*(self as *mut Pair)); } } #[repr(C)] -#[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - MoveCtorUnsafe, - CopyAssignUnsafe, - MoveAssignUnsafe, - Default, -)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyConstructibleUnsafe, Default)] pub struct Arrays { pub a: [Tracked; 2], pub b: [Tracked; 2], } -impl Arrays { - pub unsafe fn move_from(&mut self, _a0: *mut Arrays) { +impl MoveConstructibleUnsafe for Arrays { + unsafe fn move_constructor(&mut self, _a0: *mut Arrays) { (&raw mut self.a).write(std::array::from_fn::<_, 2, _>(|__i: usize| { let mut __v: Tracked = ::zero_init(); - Tracked::move_from(&mut __v, { &mut (*_a0).a[(__i)] }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut (*_a0).a[(__i)] }); __v })); (&raw mut self.b).write(std::array::from_fn::<_, 2, _>(|__i: usize| { let mut __v: Tracked = ::zero_init(); - Tracked::move_from(&mut __v, { &mut (*_a0).b[(__i)] }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut (*_a0).b[(__i)] }); __v })); } - pub unsafe fn copy_assign(&mut self, _a0: *const Arrays) -> *mut Arrays { +} +impl CopyAssignableUnsafe for Arrays { + unsafe fn copy_assign(&mut self, _a0: *const Arrays) -> *mut Arrays { { let mut __i0: usize = 0_usize; 'loop_: while ((__i0) != (2_usize)) { 'for_body: { (unsafe { let _o: *const Tracked = &(*_a0).a[(__i0)]; - Tracked::copy_assign(&mut self.a[(__i0)], _o) + CopyAssignableUnsafe::copy_assign(&mut self.a[(__i0)], _o) }); } __i0.prefix_inc(); @@ -163,7 +151,7 @@ impl Arrays { 'for_body: { (unsafe { let _o: *const Tracked = &(*_a0).b[(__i0)]; - Tracked::copy_assign(&mut self.b[(__i0)], _o) + CopyAssignableUnsafe::copy_assign(&mut self.b[(__i0)], _o) }); } __i0.prefix_inc(); @@ -171,14 +159,16 @@ impl Arrays { } return &mut (*(self as *mut Arrays)); } - pub unsafe fn move_assign(&mut self, _a0: *mut Arrays) -> *mut Arrays { +} +impl MoveAssignableUnsafe for Arrays { + unsafe fn move_assign(&mut self, _a0: *mut Arrays) -> *mut Arrays { { let mut __i0: usize = 0_usize; 'loop_: while ((__i0) != (2_usize)) { 'for_body: { (unsafe { let _o: *mut Tracked = &mut (*_a0).a[(__i0)]; - Tracked::move_assign(&mut self.a[(__i0)], _o) + MoveAssignableUnsafe::move_assign(&mut self.a[(__i0)], _o) }); } __i0.prefix_inc(); @@ -190,7 +180,7 @@ impl Arrays { 'for_body: { (unsafe { let _o: *mut Tracked = &mut (*_a0).b[(__i0)]; - Tracked::move_assign(&mut self.b[(__i0)], _o) + MoveAssignableUnsafe::move_assign(&mut self.b[(__i0)], _o) }); } __i0.prefix_inc(); @@ -209,8 +199,9 @@ pub static mut copy_only_dtors_2: std::cell::LazyCell = FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - CopyAssignUnsafe, DestructibleUnsafe, + MoveConstructibleUnsafe, + MoveAssignableUnsafe, Default, )] #[cpp_from(i32, construct, value)] @@ -221,14 +212,18 @@ impl CopyOnly { pub unsafe fn construct(&mut self, mut v: i32) { (&raw mut self.v).write(v); } - pub unsafe fn copy_from(&mut self, o: *const CopyOnly) { - (&raw mut self.v).write((*o).v); - (*std::cell::LazyCell::force_mut(&mut *&raw mut copy_only_copies_1)).prefix_inc(); - } pub unsafe fn destructor(&mut self) { (*std::cell::LazyCell::force_mut(&mut *&raw mut copy_only_dtors_2)).prefix_inc(); } - pub unsafe fn copy_assign(&mut self, o: *const CopyOnly) -> *mut CopyOnly { +} +impl CopyConstructibleUnsafe for CopyOnly { + unsafe fn copy_constructor(&mut self, o: *const CopyOnly) { + (&raw mut self.v).write((*o).v); + (*std::cell::LazyCell::force_mut(&mut *&raw mut copy_only_copies_1)).prefix_inc(); + } +} +impl CopyAssignableUnsafe for CopyOnly { + unsafe fn copy_assign(&mut self, o: *const CopyOnly) -> *mut CopyOnly { self.v = (*o).v; (*std::cell::LazyCell::force_mut(&mut *&raw mut copy_only_copies_1)).prefix_inc(); return &mut (*(self as *mut CopyOnly)); @@ -238,28 +233,36 @@ impl Clone for CopyOnly { fn clone(&self) -> Self { unsafe { let mut __v: CopyOnly = ::zero_init(); - CopyOnly::copy_from(&mut __v, self as *const CopyOnly); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const CopyOnly); __v } } } #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyAssignUnsafe, DestructibleUnsafe, Default, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + MoveAssignableUnsafe, + Default, )] pub struct CopyOnlyPair { pub x: CopyOnly, pub y: CopyOnly, } -impl CopyOnlyPair { - pub unsafe fn copy_assign(&mut self, _a0: *const CopyOnlyPair) -> *mut CopyOnlyPair { +impl CopyAssignableUnsafe for CopyOnlyPair { + unsafe fn copy_assign(&mut self, _a0: *const CopyOnlyPair) -> *mut CopyOnlyPair { (unsafe { let _o: *const CopyOnly = &(*_a0).x; - CopyOnly::copy_assign(&mut self.x, _o) + CopyAssignableUnsafe::copy_assign(&mut self.x, _o) }); (unsafe { let _o: *const CopyOnly = &(*_a0).y; - CopyOnly::copy_assign(&mut self.y, _o) + CopyAssignableUnsafe::copy_assign(&mut self.y, _o) }); return &mut (*(self as *mut CopyOnlyPair)); } @@ -274,17 +277,7 @@ pub static mut moves_3: std::cell::LazyCell = std::cell::LazyCell::new(|| u pub static mut move_assigns_4: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut moved_dtors_5: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - MoveCtorUnsafe, - CppFromUnsafe, - CopyAssignUnsafe, - MoveAssignUnsafe, - DestructibleUnsafe, - Default, -)] +#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, Default)] #[cpp_from(i32, construct, value)] pub struct Moved { pub v: i32, @@ -293,35 +286,43 @@ impl Moved { pub unsafe fn construct(&mut self, mut v: i32) { (&raw mut self.v).write(v); } - pub unsafe fn copy_from(&mut self, o: *const Moved) { + pub unsafe fn destructor(&mut self) { + (*std::cell::LazyCell::force_mut(&mut *&raw mut moved_dtors_5)).prefix_inc(); + } +} +impl CopyConstructibleUnsafe for Moved { + unsafe fn copy_constructor(&mut self, o: *const Moved) { (&raw mut self.v).write((*o).v); (*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)).prefix_inc(); } - pub unsafe fn move_from(&mut self, o: *mut Moved) { +} +impl MoveConstructibleUnsafe for Moved { + unsafe fn move_constructor(&mut self, o: *mut Moved) { (&raw mut self.v).write((*o).v); (*o).v = -1_i32; (*std::cell::LazyCell::force_mut(&mut *&raw mut moves_3)).prefix_inc(); } - pub unsafe fn copy_assign(&mut self, o: *const Moved) -> *mut Moved { +} +impl CopyAssignableUnsafe for Moved { + unsafe fn copy_assign(&mut self, o: *const Moved) -> *mut Moved { self.v = (*o).v; (*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)).prefix_inc(); return &mut (*(self as *mut Moved)); } - pub unsafe fn move_assign(&mut self, o: *mut Moved) -> *mut Moved { +} +impl MoveAssignableUnsafe for Moved { + unsafe fn move_assign(&mut self, o: *mut Moved) -> *mut Moved { self.v = (*o).v; (*o).v = -1_i32; (*std::cell::LazyCell::force_mut(&mut *&raw mut move_assigns_4)).prefix_inc(); return &mut (*(self as *mut Moved)); } - pub unsafe fn destructor(&mut self) { - (*std::cell::LazyCell::force_mut(&mut *&raw mut moved_dtors_5)).prefix_inc(); - } } impl Clone for Moved { fn clone(&self) -> Self { unsafe { let mut __v: Moved = ::zero_init(); - Moved::copy_from(&mut __v, self as *const Moved); + CopyConstructibleUnsafe::copy_constructor(&mut __v, self as *const Moved); __v } } @@ -332,48 +333,50 @@ impl Clone for Moved { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MoveCtorUnsafe, - CopyAssignUnsafe, - MoveAssignUnsafe, DestructibleUnsafe, + CopyConstructibleUnsafe, Default, )] pub struct MovedPair { pub x: Moved, pub y: Moved, } -impl MovedPair { - pub unsafe fn move_from(&mut self, _a0: *mut MovedPair) { +impl MoveConstructibleUnsafe for MovedPair { + unsafe fn move_constructor(&mut self, _a0: *mut MovedPair) { (&raw mut self.x).write({ let mut __v: Moved = ::zero_init(); - Moved::move_from(&mut __v, { &mut (*_a0).x }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut (*_a0).x }); __v }); (&raw mut self.y).write({ let mut __v: Moved = ::zero_init(); - Moved::move_from(&mut __v, { &mut (*_a0).y }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut (*_a0).y }); __v }); } - pub unsafe fn copy_assign(&mut self, _a0: *const MovedPair) -> *mut MovedPair { +} +impl CopyAssignableUnsafe for MovedPair { + unsafe fn copy_assign(&mut self, _a0: *const MovedPair) -> *mut MovedPair { (unsafe { let _o: *const Moved = &(*_a0).x; - Moved::copy_assign(&mut self.x, _o) + CopyAssignableUnsafe::copy_assign(&mut self.x, _o) }); (unsafe { let _o: *const Moved = &(*_a0).y; - Moved::copy_assign(&mut self.y, _o) + CopyAssignableUnsafe::copy_assign(&mut self.y, _o) }); return &mut (*(self as *mut MovedPair)); } - pub unsafe fn move_assign(&mut self, _a0: *mut MovedPair) -> *mut MovedPair { +} +impl MoveAssignableUnsafe for MovedPair { + unsafe fn move_assign(&mut self, _a0: *mut MovedPair) -> *mut MovedPair { (unsafe { let _o: *mut Moved = &mut (*_a0).x; - Moved::move_assign(&mut self.x, _o) + MoveAssignableUnsafe::move_assign(&mut self.x, _o) }); (unsafe { let _o: *mut Moved = &mut (*_a0).y; - Moved::move_assign(&mut self.y, _o) + MoveAssignableUnsafe::move_assign(&mut self.y, _o) }); return &mut (*(self as *mut MovedPair)); } @@ -398,15 +401,17 @@ pub unsafe fn swapped_once_6() -> bool { return ok; } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, Default)] pub struct Owner { pub p: Option>, } -impl Owner { - pub unsafe fn move_from(&mut self, _a0: *mut Owner) { +impl MoveConstructibleUnsafe for Owner { + unsafe fn move_constructor(&mut self, _a0: *mut Owner) { (&raw mut self.p).write((*_a0).p.take()); } - pub unsafe fn move_assign(&mut self, _a0: *mut Owner) -> *mut Owner { +} +impl MoveAssignableUnsafe for Owner { + unsafe fn move_assign(&mut self, _a0: *mut Owner) -> *mut Owner { { self.p = (*_a0).p.take(); }; @@ -440,7 +445,7 @@ unsafe fn main_0() -> i32 { Tracked::construct_1(&mut __v, { 10 }); __v }; - Tracked::move_assign( + MoveAssignableUnsafe::move_assign( &mut (*m1.subscript_move(&mut 1, |__k| cpp_move_unsafe!(__k), || ::default())), &mut _o, ) @@ -451,7 +456,7 @@ unsafe fn main_0() -> i32 { Tracked::construct_1(&mut __v, { 20 }); __v }; - Tracked::move_assign( + MoveAssignableUnsafe::move_assign( &mut (*m1.subscript_move(&mut 2, |__k| cpp_move_unsafe!(__k), || ::default())), &mut _o, ) @@ -463,7 +468,7 @@ unsafe fn main_0() -> i32 { Tracked::construct_1(&mut __v, { 30 }); __v }; - Tracked::move_assign( + MoveAssignableUnsafe::move_assign( &mut (*m2.subscript_move(&mut 3, |__k| cpp_move_unsafe!(__k), || ::default())), &mut _o, ) @@ -634,7 +639,7 @@ unsafe fn main_0() -> i32 { Tracked::construct_1(&mut __v, { 1 }); __v }; - Tracked::move_assign( + MoveAssignableUnsafe::move_assign( &mut (*maps[(0) as usize].subscript_move( &mut 1, |__k| cpp_move_unsafe!(__k), @@ -649,7 +654,7 @@ unsafe fn main_0() -> i32 { Tracked::construct_1(&mut __v, { 2 }); __v }; - Tracked::move_assign( + MoveAssignableUnsafe::move_assign( &mut (*maps[(1) as usize].subscript_move( &mut 2, |__k| cpp_move_unsafe!(__k), diff --git a/tests/unit/out/unsafe/tag_vs_identifier_collision.rs b/tests/unit/out/unsafe/tag_vs_identifier_collision.rs index f42c07b866..960b282eae 100644 --- a/tests/unit/out/unsafe/tag_vs_identifier_collision.rs +++ b/tests/unit/out/unsafe/tag_vs_identifier_collision.rs @@ -11,19 +11,51 @@ pub const widget_enum_MODE_IDLE: widget_enum = 0; pub const widget_enum_MODE_ACTIVE: widget_enum = 1; pub const widget_enum_MODE_DONE: widget_enum = 2; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct widget { pub id: i32, pub mode: widget_enum, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct point_struct { pub x: i32, pub y: i32, } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub union point { pub whole: i32, pub half: i16, @@ -34,7 +66,17 @@ impl Default for point { } } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub union slot_union { pub i: i32, pub u: u32, @@ -48,17 +90,50 @@ pub type slot = u32; pub const slot_SLOT_A: slot = 0; pub const slot_SLOT_B: slot = 1; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Inner { pub tag_field: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Outer { pub field: Inner, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Inner_struct { pub typedef_field: i32, } diff --git a/tests/unit/out/unsafe/template_default_arg.rs b/tests/unit/out/unsafe/template_default_arg.rs index a7643f888b..b5e50d6986 100644 --- a/tests/unit/out/unsafe/template_default_arg.rs +++ b/tests/unit/out/unsafe/template_default_arg.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] #[cpp_from(i32, construct_1, value)] pub struct A { pub v: i32, @@ -32,7 +43,17 @@ impl Default for A { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct B { pub v: i32, } @@ -53,7 +74,19 @@ impl Default for B { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct NoDefault { pub v: i32, @@ -76,7 +109,19 @@ pub unsafe fn always_given_3(mut x: NoDefault) -> i32 { return x.v; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct S_NoDefault_ { pub v: i32, diff --git a/tests/unit/out/unsafe/template_static_member.rs b/tests/unit/out/unsafe/template_static_member.rs index f608130a07..290f827e88 100644 --- a/tests/unit/out/unsafe/template_static_member.rs +++ b/tests/unit/out/unsafe/template_static_member.rs @@ -8,27 +8,82 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub static mut s_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 55 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Static_int_ {} pub static mut s_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { (55 as libc::c_char) }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Static_char_ {} pub static mut s_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 55_i64 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Static_long_ {} pub static mut lo_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { -1_i32 }); pub static mut hi_4: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 1 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Range_int_ {} pub static mut lo_5: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { (-2_i32 as i64) }); pub static mut hi_6: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 2_i64 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Range_long_ {} pub fn main() { unsafe { diff --git a/tests/unit/out/unsafe/temporary_field_addr.rs b/tests/unit/out/unsafe/temporary_field_addr.rs index 6f3be4b293..3caba06085 100644 --- a/tests/unit/out/unsafe/temporary_field_addr.rs +++ b/tests/unit/out/unsafe/temporary_field_addr.rs @@ -8,16 +8,24 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + CopyAssignableUnsafe, + Default, )] pub struct Inner { pub values: Vec, } -impl Inner { - pub unsafe fn move_from(&mut self, _a0: *mut Inner) { +impl MoveConstructibleUnsafe for Inner { + unsafe fn move_constructor(&mut self, _a0: *mut Inner) { (&raw mut self.values).write(std::mem::take(&mut (*_a0).values)); } - pub unsafe fn move_assign(&mut self, _a0: *mut Inner) -> *mut Inner { +} +impl MoveAssignableUnsafe for Inner { + unsafe fn move_assign(&mut self, _a0: *mut Inner) -> *mut Inner { { self.values = std::mem::take(&mut (*_a0).values); }; @@ -26,32 +34,40 @@ impl Inner { } #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + CopyAssignableUnsafe, + Default, )] pub struct Outer { pub values: Vec, pub inner: Inner, pub name: [libc::c_char; 8], } -impl Outer { - pub unsafe fn move_from(&mut self, _a0: *mut Outer) { +impl MoveConstructibleUnsafe for Outer { + unsafe fn move_constructor(&mut self, _a0: *mut Outer) { (&raw mut self.values).write(std::mem::take(&mut (*_a0).values)); (&raw mut self.inner).write({ let mut __v: Inner = ::zero_init(); - Inner::move_from(&mut __v, { &mut (*_a0).inner }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut (*_a0).inner }); __v }); (&raw mut self.name).write(std::array::from_fn::<_, 8, _>(|__i: usize| { (*_a0).name[(__i)] })); } - pub unsafe fn move_assign(&mut self, _a0: *mut Outer) -> *mut Outer { +} +impl MoveAssignableUnsafe for Outer { + unsafe fn move_assign(&mut self, _a0: *mut Outer) -> *mut Outer { { self.values = std::mem::take(&mut (*_a0).values); }; (unsafe { let _arg0: *mut Inner = &mut (*_a0).inner; - Inner::move_assign(&mut self.inner, _arg0) + MoveAssignableUnsafe::move_assign(&mut self.inner, _arg0) }); { let mut __tmp_0 = diff --git a/tests/unit/out/unsafe/temporary_field_ctor_arg.rs b/tests/unit/out/unsafe/temporary_field_ctor_arg.rs index 333b326277..9b27f4719e 100644 --- a/tests/unit/out/unsafe/temporary_field_ctor_arg.rs +++ b/tests/unit/out/unsafe/temporary_field_ctor_arg.rs @@ -8,16 +8,24 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + CopyAssignableUnsafe, + Default, )] pub struct Outer { pub values: Vec, } -impl Outer { - pub unsafe fn move_from(&mut self, _a0: *mut Outer) { +impl MoveConstructibleUnsafe for Outer { + unsafe fn move_constructor(&mut self, _a0: *mut Outer) { (&raw mut self.values).write(std::mem::take(&mut (*_a0).values)); } - pub unsafe fn move_assign(&mut self, _a0: *mut Outer) -> *mut Outer { +} +impl MoveAssignableUnsafe for Outer { + unsafe fn move_assign(&mut self, _a0: *mut Outer) -> *mut Outer { { self.values = std::mem::take(&mut (*_a0).values); }; @@ -30,7 +38,19 @@ pub unsafe fn make_0() -> Outer { }; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(Vec , construct, ptr)] pub struct H { pub last: i32, diff --git a/tests/unit/out/unsafe/temporary_field_two_args.rs b/tests/unit/out/unsafe/temporary_field_two_args.rs index c9d4edf8b5..67cee7bea9 100644 --- a/tests/unit/out/unsafe/temporary_field_two_args.rs +++ b/tests/unit/out/unsafe/temporary_field_two_args.rs @@ -8,16 +8,24 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + CopyAssignableUnsafe, + Default, )] pub struct Inner { pub values: Vec, } -impl Inner { - pub unsafe fn move_from(&mut self, _a0: *mut Inner) { +impl MoveConstructibleUnsafe for Inner { + unsafe fn move_constructor(&mut self, _a0: *mut Inner) { (&raw mut self.values).write(std::mem::take(&mut (*_a0).values)); } - pub unsafe fn move_assign(&mut self, _a0: *mut Inner) -> *mut Inner { +} +impl MoveAssignableUnsafe for Inner { + unsafe fn move_assign(&mut self, _a0: *mut Inner) -> *mut Inner { { self.values = std::mem::take(&mut (*_a0).values); }; @@ -26,28 +34,36 @@ impl Inner { } #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + CopyAssignableUnsafe, + Default, )] pub struct Outer { pub values: Vec, pub inner: Inner, } -impl Outer { - pub unsafe fn move_from(&mut self, _a0: *mut Outer) { +impl MoveConstructibleUnsafe for Outer { + unsafe fn move_constructor(&mut self, _a0: *mut Outer) { (&raw mut self.values).write(std::mem::take(&mut (*_a0).values)); (&raw mut self.inner).write({ let mut __v: Inner = ::zero_init(); - Inner::move_from(&mut __v, { &mut (*_a0).inner }); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut (*_a0).inner }); __v }); } - pub unsafe fn move_assign(&mut self, _a0: *mut Outer) -> *mut Outer { +} +impl MoveAssignableUnsafe for Outer { + unsafe fn move_assign(&mut self, _a0: *mut Outer) -> *mut Outer { { self.values = std::mem::take(&mut (*_a0).values); }; (unsafe { let _arg0: *mut Inner = &mut (*_a0).inner; - Inner::move_assign(&mut self.inner, _arg0) + MoveAssignableUnsafe::move_assign(&mut self.inner, _arg0) }); return &mut (*(self as *mut Outer)); } diff --git a/tests/unit/out/unsafe/this.rs b/tests/unit/out/unsafe/this.rs index 6685cbb12b..e6d3e1445d 100644 --- a/tests/unit/out/unsafe/this.rs +++ b/tests/unit/out/unsafe/this.rs @@ -7,7 +7,19 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(i32, construct_1, value)] pub struct S { pub a_: i32, @@ -101,7 +113,19 @@ pub unsafe fn bump_0(mut p: *mut S) { (*p).a_.postfix_inc(); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct D { pub a_: i32, diff --git a/tests/unit/out/unsafe/typedef-anon-struct.rs b/tests/unit/out/unsafe/typedef-anon-struct.rs index 4bf4e7dbac..d0ca058a5c 100644 --- a/tests/unit/out/unsafe/typedef-anon-struct.rs +++ b/tests/unit/out/unsafe/typedef-anon-struct.rs @@ -7,23 +7,42 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Outer_RunInfo { pub block_idx: i32, pub num_extra_zero_runs: i32, } #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + CopyAssignableUnsafe, + Default, )] pub struct Outer { pub runs: Vec, } -impl Outer { - pub unsafe fn move_from(&mut self, _a0: *mut Outer) { +impl MoveConstructibleUnsafe for Outer { + unsafe fn move_constructor(&mut self, _a0: *mut Outer) { (&raw mut self.runs).write(std::mem::take(&mut (*_a0).runs)); } - pub unsafe fn move_assign(&mut self, _a0: *mut Outer) -> *mut Outer { +} +impl MoveAssignableUnsafe for Outer { + unsafe fn move_assign(&mut self, _a0: *mut Outer) -> *mut Outer { { self.runs = std::mem::take(&mut (*_a0).runs); }; diff --git a/tests/unit/out/unsafe/unary_expr_or_type_trait.rs b/tests/unit/out/unsafe/unary_expr_or_type_trait.rs index f9706e575d..7688e810f0 100644 --- a/tests/unit/out/unsafe/unary_expr_or_type_trait.rs +++ b/tests/unit/out/unsafe/unary_expr_or_type_trait.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C, align(16))] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub c: libc::c_char, pub x: i64, diff --git a/tests/unit/out/unsafe/unboxed_locals.rs b/tests/unit/out/unsafe/unboxed_locals.rs index 26765ab651..240dd6f42d 100644 --- a/tests/unit/out/unsafe/unboxed_locals.rs +++ b/tests/unit/out/unsafe/unboxed_locals.rs @@ -13,7 +13,18 @@ pub unsafe fn inc_1(r: *mut i32) { (*r).prefix_inc(); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Pair { pub first: i32, pub second: i32, @@ -51,7 +62,17 @@ pub unsafe trait Shape { unsafe fn scale(&mut self, factor: i32) -> i32; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct Square { pub side: i32, } diff --git a/tests/unit/out/unsafe/unboxed_records.rs b/tests/unit/out/unsafe/unboxed_records.rs index ffc5ae1f61..dd244ca80f 100644 --- a/tests/unit/out/unsafe/unboxed_records.rs +++ b/tests/unit/out/unsafe/unboxed_records.rs @@ -7,13 +7,35 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Inner { pub a: i32, pub b: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Cookie { pub x: i32, pub data: *mut i32, @@ -22,7 +44,17 @@ pub struct Cookie { pub arr: [i32; 4], } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub struct Counter { pub n: i32, } diff --git a/tests/unit/out/unsafe/union_addrof_external.rs b/tests/unit/out/unsafe/union_addrof_external.rs index ce86efb8a0..b0e921749e 100644 --- a/tests/unit/out/unsafe/union_addrof_external.rs +++ b/tests/unit/out/unsafe/union_addrof_external.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct record { pub code: u16, pub lo: u16, @@ -15,7 +26,17 @@ pub struct record { pub pad: [libc::c_char; 8], } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub union anon_0 { pub h: record, pub raw_: [libc::c_char; 128], @@ -26,7 +47,18 @@ impl Default for anon_0 { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Container { pub view: anon_0, } diff --git a/tests/unit/out/unsafe/union_basic.rs b/tests/unit/out/unsafe/union_basic.rs index 033ee69b95..60040ba39d 100644 --- a/tests/unit/out/unsafe/union_basic.rs +++ b/tests/unit/out/unsafe/union_basic.rs @@ -7,7 +7,17 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub union basic { pub i: i32, pub f: f32, @@ -18,7 +28,17 @@ impl Default for basic { } } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub union empty { __empty: u8, } @@ -28,7 +48,17 @@ impl Default for empty { } } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub union underscores { pub __: i32, pub ___: f64, @@ -91,7 +121,17 @@ unsafe fn main_0() -> i32 { return 0; } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub union anon_0 { pub ai: i32, pub af: f32, diff --git a/tests/unit/out/unsafe/union_cross_arm_cast.rs b/tests/unit/out/unsafe/union_cross_arm_cast.rs index 41e760b27a..ccf6772e28 100644 --- a/tests/unit/out/unsafe/union_cross_arm_cast.rs +++ b/tests/unit/out/unsafe/union_cross_arm_cast.rs @@ -7,13 +7,35 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct shape_a { pub code: u16, pub pad: [libc::c_char; 14], } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct shape_b { pub code: u16, pub lo: u16, @@ -22,7 +44,17 @@ pub struct shape_b { pub tail: u32, } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub union anon_0 { pub a: shape_a, pub b: shape_b, @@ -34,7 +66,18 @@ impl Default for anon_0 { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Container { pub len: u32, pub u: anon_0, diff --git a/tests/unit/out/unsafe/union_field_alignment.rs b/tests/unit/out/unsafe/union_field_alignment.rs index b5d7319f40..c1f961ad34 100644 --- a/tests/unit/out/unsafe/union_field_alignment.rs +++ b/tests/unit/out/unsafe/union_field_alignment.rs @@ -7,7 +7,17 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub union anon_0 { pub bytes: [u8; 1], pub aligner: *mut ::libc::c_void, @@ -18,7 +28,18 @@ impl Default for anon_0 { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct node { pub next: *mut node, pub x: anon_0, diff --git a/tests/unit/out/unsafe/union_flex_array_member.rs b/tests/unit/out/unsafe/union_flex_array_member.rs index 7a9fbe5437..fd3182483a 100644 --- a/tests/unit/out/unsafe/union_flex_array_member.rs +++ b/tests/unit/out/unsafe/union_flex_array_member.rs @@ -7,7 +7,17 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub union anon_0 { pub bytes: [u8; 1], pub aligner: *mut ::libc::c_void, @@ -18,7 +28,18 @@ impl Default for anon_0 { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct node { pub len: usize, pub pos: usize, diff --git a/tests/unit/out/unsafe/union_memset_memcpy.rs b/tests/unit/out/unsafe/union_memset_memcpy.rs index 1f163c6dae..1ffeb07004 100644 --- a/tests/unit/out/unsafe/union_memset_memcpy.rs +++ b/tests/unit/out/unsafe/union_memset_memcpy.rs @@ -7,13 +7,35 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct shape_a { pub code: u16, pub pad: [libc::c_char; 14], } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct shape_b { pub code: u16, pub lo: u16, @@ -21,7 +43,17 @@ pub struct shape_b { pub fill: [libc::c_char; 8], } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub union anon_0 { pub a: shape_a, pub b: shape_b, @@ -33,7 +65,18 @@ impl Default for anon_0 { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Container { pub view: anon_0, } diff --git a/tests/unit/out/unsafe/union_nested.rs b/tests/unit/out/unsafe/union_nested.rs index 390e7c0e14..7bd85ab3e5 100644 --- a/tests/unit/out/unsafe/union_nested.rs +++ b/tests/unit/out/unsafe/union_nested.rs @@ -7,13 +7,34 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct record { pub code: u16, pub pad: [libc::c_char; 14], } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub union anon_0 { pub h: record, pub raw_: [libc::c_char; 128], @@ -24,12 +45,33 @@ impl Default for anon_0 { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct inner { pub view: anon_0, } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub union anon_1 { pub h: record, pub nested: inner, @@ -40,7 +82,18 @@ impl Default for anon_1 { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Outer { pub kind: i32, pub level: i32, diff --git a/tests/unit/out/unsafe/union_pointer_pun_address.rs b/tests/unit/out/unsafe/union_pointer_pun_address.rs index 0afe442843..ac517bdb91 100644 --- a/tests/unit/out/unsafe/union_pointer_pun_address.rs +++ b/tests/unit/out/unsafe/union_pointer_pun_address.rs @@ -7,12 +7,34 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct node_a { pub n: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct node_b { pub data: *mut ::libc::c_void, pub next: *mut node_b, @@ -32,7 +54,17 @@ unsafe fn main_0() -> i32 { return 0; } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub union anon_0 { pub to_a: *mut node_a, pub to_b: *mut node_b, diff --git a/tests/unit/out/unsafe/union_pointer_pun_writethrough.rs b/tests/unit/out/unsafe/union_pointer_pun_writethrough.rs index d0bf2b5109..d32f3e0f2e 100644 --- a/tests/unit/out/unsafe/union_pointer_pun_writethrough.rs +++ b/tests/unit/out/unsafe/union_pointer_pun_writethrough.rs @@ -21,7 +21,17 @@ unsafe fn main_0() -> i32 { return 0; } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub union anon_0 { pub as_unsigned: *mut u64, pub as_signed: *mut i64, diff --git a/tests/unit/out/unsafe/union_struct_dual_use.rs b/tests/unit/out/unsafe/union_struct_dual_use.rs index 295c852b76..fcb014f0eb 100644 --- a/tests/unit/out/unsafe/union_struct_dual_use.rs +++ b/tests/unit/out/unsafe/union_struct_dual_use.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Inner { pub a: i32, pub b: i32, @@ -16,7 +27,17 @@ pub unsafe fn sum_inner_0(mut i: *mut Inner) -> i32 { return (((*i).a) + ((*i).b)); } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub union anon_1 { pub inner: Inner, pub raw_: [libc::c_char; 16], @@ -27,7 +48,18 @@ impl Default for anon_1 { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Outer { pub u: anon_1, } diff --git a/tests/unit/out/unsafe/union_tagged_many_arms.rs b/tests/unit/out/unsafe/union_tagged_many_arms.rs index 650409ef66..955eebc215 100644 --- a/tests/unit/out/unsafe/union_tagged_many_arms.rs +++ b/tests/unit/out/unsafe/union_tagged_many_arms.rs @@ -13,7 +13,17 @@ pub const Tag_enum_T_TEXT: Tag_enum = 2; pub const Tag_enum_T_FLOAT: Tag_enum = 3; pub const Tag_enum_T_REF: Tag_enum = 4; #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub union anon_0 { pub text: *const libc::c_char, pub handle: *mut ::libc::c_void, @@ -27,7 +37,18 @@ impl Default for anon_0 { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Slot { pub tag: Tag_enum, pub payload: anon_0, diff --git a/tests/unit/out/unsafe/union_tagged_simple.rs b/tests/unit/out/unsafe/union_tagged_simple.rs index 520b857b71..5b5d36a81c 100644 --- a/tests/unit/out/unsafe/union_tagged_simple.rs +++ b/tests/unit/out/unsafe/union_tagged_simple.rs @@ -10,7 +10,17 @@ pub type Kind_enum = u32; pub const Kind_enum_KIND_NONE: Kind_enum = 0; pub const Kind_enum_KIND_DONE: Kind_enum = 1; #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub union anon_0 { pub obj: *mut ::libc::c_void, pub code: i32, @@ -21,7 +31,18 @@ impl Default for anon_0 { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Event { pub kind: Kind_enum, pub handle: *mut ::libc::c_void, diff --git a/tests/unit/out/unsafe/union_tagged_struct_arms.rs b/tests/unit/out/unsafe/union_tagged_struct_arms.rs index 4f592783e7..4b1d4e930e 100644 --- a/tests/unit/out/unsafe/union_tagged_struct_arms.rs +++ b/tests/unit/out/unsafe/union_tagged_struct_arms.rs @@ -11,14 +11,36 @@ pub const Choice_enum_C_LIST: Choice_enum = 1; pub const Choice_enum_C_LETTERS: Choice_enum = 2; pub const Choice_enum_C_INTEGERS: Choice_enum = 3; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct anon_1 { pub items: *mut *mut libc::c_char, pub count: i64, pub cursor: i64, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct anon_2 { pub lo: i32, pub hi: i32, @@ -26,7 +48,18 @@ pub struct anon_2 { pub step: u8, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct anon_3 { pub lo: i64, pub hi: i64, @@ -35,7 +68,17 @@ pub struct anon_3 { pub width: i32, } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub union anon_0 { pub list: anon_1, pub letters: anon_2, @@ -47,7 +90,18 @@ impl Default for anon_0 { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Branch { pub choice: Choice_enum, pub index: i32, diff --git a/tests/unit/out/unsafe/union_void_ptr_sized_deref.rs b/tests/unit/out/unsafe/union_void_ptr_sized_deref.rs index 840d919779..ec79d3e132 100644 --- a/tests/unit/out/unsafe/union_void_ptr_sized_deref.rs +++ b/tests/unit/out/unsafe/union_void_ptr_sized_deref.rs @@ -11,7 +11,17 @@ pub const Width_enum_W_64: Width_enum = 0; pub const Width_enum_W_32: Width_enum = 1; pub const Width_enum_W_16: Width_enum = 2; #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub union anon_0 { pub text: *const libc::c_char, pub handle: *mut ::libc::c_void, @@ -24,7 +34,18 @@ impl Default for anon_0 { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Sink { pub width: Width_enum, pub out: anon_0, diff --git a/tests/unit/out/unsafe/unique_ptr.rs b/tests/unit/out/unsafe/unique_ptr.rs index d5e859edbb..55dbd09aff 100644 --- a/tests/unit/out/unsafe/unique_ptr.rs +++ b/tests/unit/out/unsafe/unique_ptr.rs @@ -7,7 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, Default)] pub struct SafePointer { pub ptr: Option>, } @@ -19,10 +19,14 @@ impl SafePointer { .map_or(::std::ptr::null_mut(), |v| v as *const i32 as *mut i32)) .prefix_inc(); } - pub unsafe fn move_from(&mut self, _a0: *mut SafePointer) { +} +impl MoveConstructibleUnsafe for SafePointer { + unsafe fn move_constructor(&mut self, _a0: *mut SafePointer) { (&raw mut self.ptr).write((*_a0).ptr.take()); } - pub unsafe fn move_assign(&mut self, _a0: *mut SafePointer) -> *mut SafePointer { +} +impl MoveAssignableUnsafe for SafePointer { + unsafe fn move_assign(&mut self, _a0: *mut SafePointer) -> *mut SafePointer { { self.ptr = (*_a0).ptr.take(); }; @@ -30,7 +34,18 @@ impl SafePointer { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Pair { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/unique_ptr_const_deref.rs b/tests/unit/out/unsafe/unique_ptr_const_deref.rs index c562a90046..53e417efaa 100644 --- a/tests/unit/out/unsafe/unique_ptr_const_deref.rs +++ b/tests/unit/out/unsafe/unique_ptr_const_deref.rs @@ -7,15 +7,17 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, Default)] pub struct Holder { pub val: Option>, } -impl Holder { - pub unsafe fn move_from(&mut self, _a0: *mut Holder) { +impl MoveConstructibleUnsafe for Holder { + unsafe fn move_constructor(&mut self, _a0: *mut Holder) { (&raw mut self.val).write((*_a0).val.take()); } - pub unsafe fn move_assign(&mut self, _a0: *mut Holder) -> *mut Holder { +} +impl MoveAssignableUnsafe for Holder { + unsafe fn move_assign(&mut self, _a0: *mut Holder) -> *mut Holder { { self.val = (*_a0).val.take(); }; diff --git a/tests/unit/out/unsafe/unique_ptr_field_reset.rs b/tests/unit/out/unsafe/unique_ptr_field_reset.rs index cfbc406e42..0d623841a3 100644 --- a/tests/unit/out/unsafe/unique_ptr_field_reset.rs +++ b/tests/unit/out/unsafe/unique_ptr_field_reset.rs @@ -7,12 +7,23 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Data { pub v: i32, } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, Default)] pub struct Holder { pub data: Option>, pub n: i32, @@ -28,11 +39,15 @@ impl Holder { } }; } - pub unsafe fn move_from(&mut self, _a0: *mut Holder) { +} +impl MoveConstructibleUnsafe for Holder { + unsafe fn move_constructor(&mut self, _a0: *mut Holder) { (&raw mut self.data).write((*_a0).data.take()); (&raw mut self.n).write((*_a0).n); } - pub unsafe fn move_assign(&mut self, _a0: *mut Holder) -> *mut Holder { +} +impl MoveAssignableUnsafe for Holder { + unsafe fn move_assign(&mut self, _a0: *mut Holder) -> *mut Holder { { self.data = (*_a0).data.take(); }; diff --git a/tests/unit/out/unsafe/unique_ptr_nested.rs b/tests/unit/out/unsafe/unique_ptr_nested.rs index 70bdf6bfb6..7edafe860c 100644 --- a/tests/unit/out/unsafe/unique_ptr_nested.rs +++ b/tests/unit/out/unsafe/unique_ptr_nested.rs @@ -7,21 +7,34 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Inner { pub x: i32, pub y: i32, } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, Default)] pub struct Outer { pub inner: Option>, } -impl Outer { - pub unsafe fn move_from(&mut self, _a0: *mut Outer) { +impl MoveConstructibleUnsafe for Outer { + unsafe fn move_constructor(&mut self, _a0: *mut Outer) { (&raw mut self.inner).write((*_a0).inner.take()); } - pub unsafe fn move_assign(&mut self, _a0: *mut Outer) -> *mut Outer { +} +impl MoveAssignableUnsafe for Outer { + unsafe fn move_assign(&mut self, _a0: *mut Outer) -> *mut Outer { { self.inner = (*_a0).inner.take(); }; diff --git a/tests/unit/out/unsafe/unique_ptr_struct.rs b/tests/unit/out/unsafe/unique_ptr_struct.rs index f42266cd30..15a975517a 100644 --- a/tests/unit/out/unsafe/unique_ptr_struct.rs +++ b/tests/unit/out/unsafe/unique_ptr_struct.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Point { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/va_arg_mixed_types.rs b/tests/unit/out/unsafe/va_arg_mixed_types.rs index 207efc9868..7a48193d35 100644 --- a/tests/unit/out/unsafe/va_arg_mixed_types.rs +++ b/tests/unit/out/unsafe/va_arg_mixed_types.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct pair { pub a: i32, pub b: i32, diff --git a/tests/unit/out/unsafe/va_arg_non_primitive_ptrs.rs b/tests/unit/out/unsafe/va_arg_non_primitive_ptrs.rs index cdabfbe70b..3f86b46ea4 100644 --- a/tests/unit/out/unsafe/va_arg_non_primitive_ptrs.rs +++ b/tests/unit/out/unsafe/va_arg_non_primitive_ptrs.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct node { pub data: i32, pub next: *mut node, diff --git a/tests/unit/out/unsafe/va_arg_struct_ctx.rs b/tests/unit/out/unsafe/va_arg_struct_ctx.rs index ce5ac254c4..ee076861cb 100644 --- a/tests/unit/out/unsafe/va_arg_struct_ctx.rs +++ b/tests/unit/out/unsafe/va_arg_struct_ctx.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct context { pub verbose: i32, pub last_error: i32, @@ -24,7 +35,17 @@ pub unsafe fn set_error_0( } } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, +)] pub union value { pub i: i32, pub l: i64, diff --git a/tests/unit/out/unsafe/va_arg_void_ptr.rs b/tests/unit/out/unsafe/va_arg_void_ptr.rs index c544bf2b55..9404400fe8 100644 --- a/tests/unit/out/unsafe/va_arg_void_ptr.rs +++ b/tests/unit/out/unsafe/va_arg_void_ptr.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct registry { pub slot: *mut ::libc::c_void, pub level: i64, diff --git a/tests/unit/out/unsafe/va_list_field.rs b/tests/unit/out/unsafe/va_list_field.rs index 8bbb36df0e..0aa081a2f4 100644 --- a/tests/unit/out/unsafe/va_list_field.rs +++ b/tests/unit/out/unsafe/va_list_field.rs @@ -31,7 +31,17 @@ pub unsafe fn sum_0(mut n: i32, __args: Box<[VaArg]>) -> i32 { } #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, Default, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, )] #[cpp_from(*const VaArg , construct, mut_ptr)] pub struct Guard_1 { @@ -66,7 +76,18 @@ pub unsafe fn sum_ptr_2(mut n: i32, __args: Box<[VaArg]>) -> i32 { return total; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Cursor_3 { pub ap: *mut *const VaArg, } diff --git a/tests/unit/out/unsafe/vector.rs b/tests/unit/out/unsafe/vector.rs index 3589f5dbd7..dfd4e95435 100644 --- a/tests/unit/out/unsafe/vector.rs +++ b/tests/unit/out/unsafe/vector.rs @@ -7,25 +7,44 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct S { pub x: i32, } pub unsafe fn copy_0(mut copy_vector: Vec) {} #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + CopyAssignableUnsafe, + Default, )] pub struct Foo { pub a: Vec, pub b: Vec, } -impl Foo { - pub unsafe fn move_from(&mut self, _a0: *mut Foo) { +impl MoveConstructibleUnsafe for Foo { + unsafe fn move_constructor(&mut self, _a0: *mut Foo) { (&raw mut self.a).write(std::mem::take(&mut (*_a0).a)); (&raw mut self.b).write(std::mem::take(&mut (*_a0).b)); } - pub unsafe fn move_assign(&mut self, _a0: *mut Foo) -> *mut Foo { +} +impl MoveAssignableUnsafe for Foo { + unsafe fn move_assign(&mut self, _a0: *mut Foo) -> *mut Foo { { self.a = std::mem::take(&mut (*_a0).a); }; diff --git a/tests/unit/out/unsafe/vector_iter_range_ctor.rs b/tests/unit/out/unsafe/vector_iter_range_ctor.rs index fdb50df128..9e16e89071 100644 --- a/tests/unit/out/unsafe/vector_iter_range_ctor.rs +++ b/tests/unit/out/unsafe/vector_iter_range_ctor.rs @@ -7,7 +7,19 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct Degrees { pub value: i32, @@ -18,7 +30,19 @@ impl Degrees { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] #[cpp_into(i64, to_i64)] pub struct Reading { pub raw_: i32, diff --git a/tests/unit/out/unsafe/vector_subscript_direct.rs b/tests/unit/out/unsafe/vector_subscript_direct.rs index c8fd3d8523..0bf29311f5 100644 --- a/tests/unit/out/unsafe/vector_subscript_direct.rs +++ b/tests/unit/out/unsafe/vector_subscript_direct.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Point { pub x: i32, pub y: i32, @@ -19,18 +30,26 @@ impl Point { } #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + CopyAssignableUnsafe, + Default, )] pub struct Holder { pub values: Vec, pub points: Vec, } -impl Holder { - pub unsafe fn move_from(&mut self, _a0: *mut Holder) { +impl MoveConstructibleUnsafe for Holder { + unsafe fn move_constructor(&mut self, _a0: *mut Holder) { (&raw mut self.values).write(std::mem::take(&mut (*_a0).values)); (&raw mut self.points).write(std::mem::take(&mut (*_a0).points)); } - pub unsafe fn move_assign(&mut self, _a0: *mut Holder) -> *mut Holder { +} +impl MoveAssignableUnsafe for Holder { + unsafe fn move_assign(&mut self, _a0: *mut Holder) -> *mut Holder { { self.values = std::mem::take(&mut (*_a0).values); }; diff --git a/tests/unit/out/unsafe/vector_with_allocator.rs b/tests/unit/out/unsafe/vector_with_allocator.rs index b35e468262..11f49b822c 100644 --- a/tests/unit/out/unsafe/vector_with_allocator.rs +++ b/tests/unit/out/unsafe/vector_with_allocator.rs @@ -7,7 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct TestAllocator_int_ {} impl TestAllocator_int_ { pub unsafe fn allocate(&mut self, mut n: usize) -> *mut i32 { @@ -27,7 +38,18 @@ impl TestAllocator_int_ { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct TestAllocator_double_ {} impl TestAllocator_double_ { pub unsafe fn allocate(&mut self, mut n: usize) -> *mut f64 { diff --git a/tests/unit/out/unsafe/void_cast.rs b/tests/unit/out/unsafe/void_cast.rs index ac603b501f..04ad7e27ae 100644 --- a/tests/unit/out/unsafe/void_cast.rs +++ b/tests/unit/out/unsafe/void_cast.rs @@ -9,16 +9,24 @@ use std::rc::Rc; pub unsafe fn unused_param_0(mut x: i32) {} #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + CopyAssignableUnsafe, + Default, )] pub struct NonTrivial { pub data: Vec, } -impl NonTrivial { - pub unsafe fn move_from(&mut self, _a0: *mut NonTrivial) { +impl MoveConstructibleUnsafe for NonTrivial { + unsafe fn move_constructor(&mut self, _a0: *mut NonTrivial) { (&raw mut self.data).write(std::mem::take(&mut (*_a0).data)); } - pub unsafe fn move_assign(&mut self, _a0: *mut NonTrivial) -> *mut NonTrivial { +} +impl MoveAssignableUnsafe for NonTrivial { + unsafe fn move_assign(&mut self, _a0: *mut NonTrivial) -> *mut NonTrivial { { self.data = std::mem::take(&mut (*_a0).data); }; @@ -34,20 +42,33 @@ pub unsafe fn bump_and_return_4() -> i32 { return (*std::cell::LazyCell::force_mut(&mut *&raw mut side_effect_counter_3)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + Default, +)] pub struct Holder { pub field: i32, } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, MoveCtorUnsafe, MoveAssignUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, Default)] pub struct NonCopyable { pub value: Option>, } -impl NonCopyable { - pub unsafe fn move_from(&mut self, _a0: *mut NonCopyable) { +impl MoveConstructibleUnsafe for NonCopyable { + unsafe fn move_constructor(&mut self, _a0: *mut NonCopyable) { (&raw mut self.value).write((*_a0).value.take()); } - pub unsafe fn move_assign(&mut self, _a0: *mut NonCopyable) -> *mut NonCopyable { +} +impl MoveAssignableUnsafe for NonCopyable { + unsafe fn move_assign(&mut self, _a0: *mut NonCopyable) -> *mut NonCopyable { { self.value = (*_a0).value.take(); }; From 5cbdb736707df8c9cbe7116f861cf0873f4478b5 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Mon, 30 Nov 2026 20:30:26 +0000 Subject: [PATCH 02/20] Implement the copy/move traits in shims --- rules/dirent/shim.rs | 20 +++++++++++-- rules/ifaddrs/shim.rs | 19 ++++++++++-- rules/ip/shim.rs | 33 +++++++++++++++++++-- rules/netdb/shim.rs | 21 +++++++++++-- rules/poll/shim.rs | 21 +++++++++++-- rules/pwd/shim.rs | 21 +++++++++++-- rules/select/shim.rs | 4 ++- rules/socket/shim.rs | 69 +++++++++++++++++++++++++++++++++++++++---- rules/stat/shim.rs | 20 +++++++++++-- rules/termios/shim.rs | 28 ++++++++++++++++-- rules/time/shim.rs | 47 ++++++++++++++++++++++++++--- 11 files changed, 274 insertions(+), 29 deletions(-) diff --git a/rules/dirent/shim.rs b/rules/dirent/shim.rs index 1d738cf2cc..93e35b8e28 100644 --- a/rules/dirent/shim.rs +++ b/rules/dirent/shim.rs @@ -1,11 +1,23 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use crate::{ByteRepr, Record, ZeroInitialization, size_of_field}; +use crate::{ + ByteRepr, CopyAssignable, CopyConstructible, MoveAssignable, MoveConstructible, Record, + ZeroInitialization, size_of_field, +}; use std::cell::Cell; use std::mem::{offset_of, size_of}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(size_of::<::libc::dirent>())] pub struct Dirent { #[offset(offset_of!(::libc::dirent, d_ino))] @@ -85,3 +97,7 @@ impl CDir { impl ByteRepr for CDir {} impl ByteRepr for ::libc::dirent {} + +crate::constructor::impl_trivial_copy_move!( + ::libc::dirent, +); diff --git a/rules/ifaddrs/shim.rs b/rules/ifaddrs/shim.rs index eff408a936..3b55023af1 100644 --- a/rules/ifaddrs/shim.rs +++ b/rules/ifaddrs/shim.rs @@ -2,11 +2,22 @@ // Distributed under the MIT license that can be found in the LICENSE file. use crate::{ - ByteRepr, Ptr, Record, Sockaddr, SockaddrIn, SockaddrIn6, SockaddrStorage, ZeroInitialization, + ByteRepr, CopyAssignable, CopyConstructible, MoveAssignable, MoveConstructible, Ptr, Record, + Sockaddr, SockaddrIn, SockaddrIn6, SockaddrStorage, ZeroInitialization, }; use std::mem::{offset_of, size_of}; -#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization)] +#[derive( + Clone, + Default, + Record, + ByteRepr, + ZeroInitialization, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(size_of::<::libc::ifaddrs>())] pub struct Ifaddrs { #[offset(offset_of!(::libc::ifaddrs, ifa_next))] @@ -56,3 +67,7 @@ impl Ifaddrs { } impl ByteRepr for ::libc::ifaddrs {} + +crate::constructor::impl_trivial_copy_move!( + ::libc::ifaddrs, +); diff --git a/rules/ip/shim.rs b/rules/ip/shim.rs index 842f81350e..f25f7d8c01 100644 --- a/rules/ip/shim.rs +++ b/rules/ip/shim.rs @@ -1,16 +1,38 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use crate::{ByteRepr, Ptr, Record, ZeroInitialization}; +use crate::{ + ByteRepr, CopyAssignable, CopyConstructible, MoveAssignable, MoveConstructible, Ptr, Record, + ZeroInitialization, +}; -#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization)] +#[derive( + Clone, + Default, + Record, + ByteRepr, + ZeroInitialization, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(4)] pub struct InAddr { #[offset(0)] pub s_addr: u32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(16)] pub struct In6Addr { #[offset(0)] @@ -35,3 +57,8 @@ impl Default for In6Addr { impl ByteRepr for ::libc::in_addr {} impl ByteRepr for ::libc::in6_addr {} + +crate::constructor::impl_trivial_copy_move!( + ::libc::in_addr, + ::libc::in6_addr, +); diff --git a/rules/netdb/shim.rs b/rules/netdb/shim.rs index 9432b2adcf..164d13f75a 100644 --- a/rules/netdb/shim.rs +++ b/rules/netdb/shim.rs @@ -1,10 +1,23 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use crate::{ByteRepr, Ptr, Record, Sockaddr, ZeroInitialization}; +use crate::{ + ByteRepr, CopyAssignable, CopyConstructible, MoveAssignable, MoveConstructible, Ptr, Record, + Sockaddr, ZeroInitialization, +}; use std::mem::{offset_of, size_of}; -#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization)] +#[derive( + Clone, + Default, + Record, + ByteRepr, + ZeroInitialization, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(size_of::<::libc::addrinfo>())] pub struct Addrinfo { #[offset(offset_of!(::libc::addrinfo, ai_flags))] @@ -26,3 +39,7 @@ pub struct Addrinfo { } impl ByteRepr for ::libc::addrinfo {} + +crate::constructor::impl_trivial_copy_move!( + ::libc::addrinfo, +); diff --git a/rules/poll/shim.rs b/rules/poll/shim.rs index 06f6daa720..27e8d0e12d 100644 --- a/rules/poll/shim.rs +++ b/rules/poll/shim.rs @@ -1,10 +1,23 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use crate::{ByteRepr, Record, ZeroInitialization}; +use crate::{ + ByteRepr, CopyAssignable, CopyConstructible, MoveAssignable, MoveConstructible, Record, + ZeroInitialization, +}; use std::mem::{offset_of, size_of}; -#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization)] +#[derive( + Clone, + Default, + Record, + ByteRepr, + ZeroInitialization, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(size_of::<::libc::pollfd>())] pub struct Pollfd { #[offset(offset_of!(::libc::pollfd, fd))] @@ -16,3 +29,7 @@ pub struct Pollfd { } impl ByteRepr for ::libc::pollfd {} + +crate::constructor::impl_trivial_copy_move!( + ::libc::pollfd, +); diff --git a/rules/pwd/shim.rs b/rules/pwd/shim.rs index 01229b236f..db190c9fa8 100644 --- a/rules/pwd/shim.rs +++ b/rules/pwd/shim.rs @@ -1,10 +1,23 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use crate::{ByteRepr, Ptr, Record, ZeroInitialization}; +use crate::{ + ByteRepr, CopyAssignable, CopyConstructible, MoveAssignable, MoveConstructible, Ptr, Record, + ZeroInitialization, +}; use std::mem::{offset_of, size_of}; -#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization)] +#[derive( + Clone, + Default, + Record, + ByteRepr, + ZeroInitialization, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(size_of::<::libc::passwd>())] pub struct Passwd { #[offset(offset_of!(::libc::passwd, pw_name))] @@ -51,3 +64,7 @@ impl Passwd { } impl ByteRepr for ::libc::passwd {} + +crate::constructor::impl_trivial_copy_move!( + ::libc::passwd, +); diff --git a/rules/select/shim.rs b/rules/select/shim.rs index 7a108b2223..f43e2f387b 100644 --- a/rules/select/shim.rs +++ b/rules/select/shim.rs @@ -3,7 +3,9 @@ use std::collections::BTreeSet; -#[derive(Clone, Default)] +use crate::{CopyAssignable, CopyConstructible, MoveAssignable, MoveConstructible}; + +#[derive(Clone, Default, CopyConstructible, MoveConstructible, CopyAssignable, MoveAssignable)] pub struct CFdSet { fds: BTreeSet, } diff --git a/rules/socket/shim.rs b/rules/socket/shim.rs index 47ef06c5f9..dc9fc3318f 100644 --- a/rules/socket/shim.rs +++ b/rules/socket/shim.rs @@ -1,10 +1,22 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use crate::{ByteRepr, CChar, In6Addr, InAddr, Ptr, Record, ZeroInitialization}; +use crate::{ + ByteRepr, CChar, CopyAssignable, CopyConstructible, In6Addr, InAddr, MoveAssignable, + MoveConstructible, Ptr, Record, ZeroInitialization, +}; // The fields are at the offsets of the byte representation below. -#[derive(Clone, Record, ByteRepr, ZeroInitialization)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(16)] pub struct Sockaddr { #[offset(0)] @@ -15,7 +27,16 @@ pub struct Sockaddr { pub sa_data: Box<[i8]>, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(16)] pub struct SockaddrIn { #[offset(0)] @@ -30,7 +51,17 @@ pub struct SockaddrIn { pub sin_zero: Box<[u8]>, } -#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization)] +#[derive( + Clone, + Default, + Record, + ByteRepr, + ZeroInitialization, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(28)] pub struct SockaddrIn6 { #[offset(0)] @@ -45,7 +76,16 @@ pub struct SockaddrIn6 { pub sin6_scope_id: u32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(110)] pub struct SockaddrUn { #[offset(0)] @@ -56,7 +96,16 @@ pub struct SockaddrUn { pub sun_path: Box<[i8]>, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(128)] pub struct SockaddrStorage { #[offset(0)] @@ -397,3 +446,11 @@ pub fn setsockopt_refcount(fd: i32, level: i32, optname: i32, optval: crate::Any } } } + +crate::constructor::impl_trivial_copy_move!( + ::libc::sockaddr, + ::libc::sockaddr_in, + ::libc::sockaddr_in6, + ::libc::sockaddr_un, + ::libc::sockaddr_storage, +); diff --git a/rules/stat/shim.rs b/rules/stat/shim.rs index 423b6bbdd6..679dd536f0 100644 --- a/rules/stat/shim.rs +++ b/rules/stat/shim.rs @@ -1,10 +1,22 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use crate::{ByteRepr, Record, ZeroInitialization}; +use crate::{ + ByteRepr, CopyAssignable, CopyConstructible, MoveAssignable, MoveConstructible, Record, + ZeroInitialization, +}; use std::mem::{offset_of, size_of}; -#[derive(Clone, Default, Record, ZeroInitialization)] +#[derive( + Clone, + Default, + Record, + ZeroInitialization, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] // The fields have the sizes of those of libc::stat only in x86-64 Linux. #[cfg_attr( all(target_os = "linux", target_arch = "x86_64"), @@ -69,3 +81,7 @@ impl ByteRepr for Stat { } impl ByteRepr for ::libc::stat {} + +crate::constructor::impl_trivial_copy_move!( + ::libc::stat, +); diff --git a/rules/termios/shim.rs b/rules/termios/shim.rs index 2a4ea03734..68cabc43ee 100644 --- a/rules/termios/shim.rs +++ b/rules/termios/shim.rs @@ -1,10 +1,22 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use crate::{ByteRepr, Record, ZeroInitialization}; +use crate::{ + ByteRepr, CopyAssignable, CopyConstructible, MoveAssignable, MoveConstructible, Record, + ZeroInitialization, +}; use std::mem::{offset_of, size_of}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(size_of::<::libc::termios>())] pub struct Termios { #[offset(offset_of!(::libc::termios, c_iflag))] @@ -105,7 +117,17 @@ impl Termios { } } -#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization)] +#[derive( + Clone, + Default, + Record, + ByteRepr, + ZeroInitialization, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(size_of::<::libc::winsize>())] pub struct Winsize { #[offset(offset_of!(::libc::winsize, ws_row))] diff --git a/rules/time/shim.rs b/rules/time/shim.rs index 2c9066f65c..c4944884db 100644 --- a/rules/time/shim.rs +++ b/rules/time/shim.rs @@ -1,10 +1,23 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use crate::{ByteRepr, Ptr, Record, ZeroInitialization}; +use crate::{ + ByteRepr, CopyAssignable, CopyConstructible, MoveAssignable, MoveConstructible, Ptr, Record, + ZeroInitialization, +}; use std::mem::{offset_of, size_of}; -#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization)] +#[derive( + Clone, + Default, + Record, + ByteRepr, + ZeroInitialization, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(size_of::<::libc::tm>())] pub struct Tm { #[offset(offset_of!(::libc::tm, tm_sec))] @@ -65,7 +78,17 @@ impl Tm { } } -#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization)] +#[derive( + Clone, + Default, + Record, + ByteRepr, + ZeroInitialization, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(size_of::<::libc::timeval>())] pub struct Timeval { #[offset(offset_of!(::libc::timeval, tv_sec))] @@ -74,7 +97,17 @@ pub struct Timeval { pub tv_usec: i64, } -#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization)] +#[derive( + Clone, + Default, + Record, + ByteRepr, + ZeroInitialization, + CopyConstructible, + MoveConstructible, + CopyAssignable, + MoveAssignable, +)] #[byte_size(size_of::<::libc::timespec>())] pub struct Timespec { #[offset(offset_of!(::libc::timespec, tv_sec))] @@ -86,3 +119,9 @@ pub struct Timespec { impl ByteRepr for ::libc::tm {} impl ByteRepr for ::libc::timeval {} impl ByteRepr for ::libc::timespec {} + +crate::constructor::impl_trivial_copy_move!( + ::libc::tm, + ::libc::timeval, + ::libc::timespec, +); From 16f5b3a7082b0fbf52fce32bd5ff86f6aad88005 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Mon, 30 Nov 2026 20:31:33 +0000 Subject: [PATCH 03/20] Fix array rules --- rules/array/tgt_refcount.rs | 20 ++++++++++++++------ rules/array/tgt_unsafe.rs | 17 +++++++++++------ tests/unit/out/unsafe/copy_ctor.rs | 1 - 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/rules/array/tgt_refcount.rs b/rules/array/tgt_refcount.rs index a7eec2a600..dfd5d52304 100644 --- a/rules/array/tgt_refcount.rs +++ b/rules/array/tgt_refcount.rs @@ -29,16 +29,24 @@ fn f3(a0: Ptr) -> Ptr { a0 } -fn f4(a0: Ptr) -> Box<[T1]> { - (0..T2).map(|__i| T1::move_ctor(a0.offset(__i))).collect() +fn f4( + a0: Ptr, +) -> Box<[T1]> { + let __v: Value> = + Rc::new(RefCell::new((0..T2).map(|_| T1::zero_init()).collect())); + let __p: Ptr = __v.decay(); + for __i in 0..T2 { + MoveConstructible::move_constructor(&__p.offset(__i), a0.offset(__i)); + } + Rc::try_unwrap(__v).ok().unwrap().into_inner() } -fn f5( +fn f5( a0: Ptr>, a1: Ptr, ) -> Ptr> { for __i in 0..T2 { - T1::move_assign(&a0.decay().offset(__i), a1.offset(__i)); + MoveAssignable::move_assign(&a0.decay().offset(__i), a1.offset(__i)); } a0 } @@ -47,12 +55,12 @@ fn f6(a0: Ptr) -> Box<[T1]> { (0..T2).map(|__i| a0.read_at(__i)).collect() } -fn f7( +fn f7( a0: Ptr>, a1: Ptr, ) -> Ptr> { for __i in 0..T2 { - T1::copy_assign(&a0.decay().offset(__i), a1.offset(__i)); + CopyAssignable::copy_assign(&a0.decay().offset(__i), a1.offset(__i)); } a0 } diff --git a/rules/array/tgt_unsafe.rs b/rules/array/tgt_unsafe.rs index 29337299e1..8d01c78699 100644 --- a/rules/array/tgt_unsafe.rs +++ b/rules/array/tgt_unsafe.rs @@ -39,16 +39,21 @@ fn f3(a0: &mut [T1; T2]) -> *mut T1 { a0.as_mut_ptr() } -unsafe fn f4(a0: &mut [T1; T2]) -> [T1; T2] { - std::array::from_fn(|__i| T1::move_ctor(&mut a0[__i])) +unsafe fn f4(a0: &mut [T1; T2]) -> [T1; T2] { + let mut __v = std::mem::MaybeUninit::<[T1; T2]>::uninit(); + let __p = __v.as_mut_ptr() as *mut T1; + for __i in 0..T2 { + (*__p.add(__i)).move_constructor(&mut a0[__i]); + } + __v.assume_init() } -unsafe fn f5<'a, T1: MoveAssignUnsafe, const T2: usize>( +unsafe fn f5<'a, T1: MoveAssignableUnsafe, const T2: usize>( a0: &'a mut [T1; T2], a1: &mut [T1; T2], ) -> &'a mut [T1; T2] { for __i in 0..T2 { - T1::move_assign(&mut a0[__i], &mut a1[__i]); + a0[__i].move_assign(&mut a1[__i]); } a0 } @@ -57,12 +62,12 @@ fn f6(a0: [T1; T2]) -> [T1; T2] { a0.clone() } -unsafe fn f7<'a, T1: CopyAssignUnsafe, const T2: usize>( +unsafe fn f7<'a, T1: CopyAssignableUnsafe, const T2: usize>( a0: &'a mut [T1; T2], a1: &[T1; T2], ) -> &'a mut [T1; T2] { for __i in 0..T2 { - T1::copy_assign(&mut a0[__i], &a1[__i]); + a0[__i].copy_assign(&a1[__i]); } a0 } diff --git a/tests/unit/out/unsafe/copy_ctor.rs b/tests/unit/out/unsafe/copy_ctor.rs index 0b1e99b307..d0b6f03e98 100644 --- a/tests/unit/out/unsafe/copy_ctor.rs +++ b/tests/unit/out/unsafe/copy_ctor.rs @@ -269,7 +269,6 @@ impl Clone for OutOfLine { } } } -impl CopyConstructibleUnsafe for OutOfLine {} #[repr(C)] #[derive( VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, From 3af73ad60ffeb32ee39b5b3c95e559b14476980f Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Mon, 30 Nov 2026 20:38:43 +0000 Subject: [PATCH 04/20] Receive this in Move/Copy Constructible/Assignable --- libcc2rs-macros/src/assign.rs | 49 ---- libcc2rs-macros/src/constructor.rs | 75 ++++++ libcc2rs-macros/src/lambda.rs | 4 +- libcc2rs-macros/src/lib.rs | 69 ++--- libcc2rs-macros/src/move_ctor.rs | 32 --- libcc2rs/src/capture.rs | 160 ++--------- libcc2rs/src/constructor.rs | 415 +++++++++++++++++++++++++++++ libcc2rs/src/initialization.rs | 14 + libcc2rs/src/lib.rs | 21 +- libcc2rs/src/swap.rs | 91 ++++--- 10 files changed, 629 insertions(+), 301 deletions(-) delete mode 100644 libcc2rs-macros/src/assign.rs create mode 100644 libcc2rs-macros/src/constructor.rs delete mode 100644 libcc2rs-macros/src/move_ctor.rs create mode 100644 libcc2rs/src/constructor.rs diff --git a/libcc2rs-macros/src/assign.rs b/libcc2rs-macros/src/assign.rs deleted file mode 100644 index 4f83875cf6..0000000000 --- a/libcc2rs-macros/src/assign.rs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) 2022-present INESC-ID. -// Distributed under the MIT license that can be found in the LICENSE file. - -use proc_macro::TokenStream; -use quote::{format_ident, quote}; -use syn::{DeriveInput, parse_macro_input}; - -// Implements libcc2rs::CopyAssign or MoveAssign (or their unsafe versions) -// with the method of the same name, for `op` "copy" or "move". -pub fn expand(input: TokenStream, op: &str, is_unsafe: bool) -> TokenStream { - let input = parse_macro_input!(input as DeriveInput); - let name = &input.ident; - let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl(); - let method = format_ident!("{}_assign", op); - let is_move = op == "move"; - if is_unsafe { - let tr = if is_move { - quote!(::libcc2rs::MoveAssignUnsafe) - } else { - quote!(::libcc2rs::CopyAssignUnsafe) - }; - let src_ty = if is_move { - quote!(*mut Self) - } else { - quote!(*const Self) - }; - quote! { - impl #impl_generics #tr for #name #ty_generics #where_clause { - unsafe fn #method(dst: *mut Self, src: #src_ty) { - unsafe { (*dst).#method(src) }; - } - } - } - } else { - let tr = if is_move { - quote!(::libcc2rs::MoveAssign) - } else { - quote!(::libcc2rs::CopyAssign) - }; - quote! { - impl #impl_generics #tr for #name #ty_generics #where_clause { - fn #method(dst: &::libcc2rs::Ptr, src: ::libcc2rs::Ptr) { - dst.#method(src); - } - } - } - } - .into() -} diff --git a/libcc2rs-macros/src/constructor.rs b/libcc2rs-macros/src/constructor.rs new file mode 100644 index 0000000000..bd2bfda66b --- /dev/null +++ b/libcc2rs-macros/src/constructor.rs @@ -0,0 +1,75 @@ +// Copyright (c) 2022-present INESC-ID. +// Distributed under the MIT license that can be found in the LICENSE file. + +use proc_macro::TokenStream; +use quote::{format_ident, quote}; +use syn::{DeriveInput, parse_macro_input}; + +pub fn expand(input: TokenStream, op: &str, is_assign: bool, is_unsafe: bool) -> TokenStream { + let input = parse_macro_input!(input as DeriveInput); + let name = &input.ident; + let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl(); + let is_move = op == "move"; + let trait_name = format_ident!( + "{}{}{}", + if is_move { "Move" } else { "Copy" }, + if is_assign { + "Assignable" + } else { + "Constructible" + }, + if is_unsafe { "Unsafe" } else { "" } + ); + let method = if is_assign { + format_ident!("{}_assign", op) + } else { + format_ident!("{}_constructor", op) + }; + if is_unsafe { + let src_ty = if is_move { + quote!(*mut Self) + } else { + quote!(*const Self) + }; + let body = if is_assign { + quote! { + unsafe { *self = (*src).clone() }; + self + } + } else { + quote!(unsafe { ::std::ptr::write(self, (*src).clone()) }) + }; + let ret = if is_assign { + quote!(-> *mut Self) + } else { + quote!() + }; + quote! { + impl #impl_generics ::libcc2rs::#trait_name for #name #ty_generics #where_clause { + unsafe fn #method(&mut self, src: #src_ty) #ret { + #body + } + } + } + } else { + let ret = if is_assign { + quote!(-> ::libcc2rs::Ptr) + } else { + quote!() + }; + let tail = if is_assign { + quote!(this.clone()) + } else { + quote!() + }; + quote! { + impl #impl_generics ::libcc2rs::#trait_name for #name #ty_generics #where_clause { + fn #method(this: &::libcc2rs::Ptr, src: ::libcc2rs::Ptr) #ret { + this.write(src.read()); + #tail + } + } + } + } + .into() +} diff --git a/libcc2rs-macros/src/lambda.rs b/libcc2rs-macros/src/lambda.rs index dd1bcc2775..c5c1c53960 100644 --- a/libcc2rs-macros/src/lambda.rs +++ b/libcc2rs-macros/src/lambda.rs @@ -258,9 +258,7 @@ fn expand_lambda(lambda: Lambda, is_unsafe: bool) -> Result TokenStream { initialization::expand_unsafe(input) } -// #[derive(MoveCtor)] -// pub struct S { ... } -// impl S { -// pub fn move_from(o: Ptr) -> Self { ... } -// } -// -// Implements libcc2rs::MoveCtor for S with its move constructor, move_from, -// such that lambda! moves the captures of type S with it. MoveCtorUnsafe is -// the same for the unsafe model, whose move_from takes a *mut S. +#[proc_macro_derive(CopyConstructible)] +pub fn derive_copy_constructible(input: TokenStream) -> TokenStream { + constructor::expand(input, "copy", false, false) +} -#[proc_macro_derive(MoveCtor)] -pub fn derive_move_ctor(input: TokenStream) -> TokenStream { - move_ctor::expand(input, false) +#[proc_macro_derive(CopyConstructibleUnsafe)] +pub fn derive_copy_constructible_unsafe(input: TokenStream) -> TokenStream { + constructor::expand(input, "copy", false, true) } -#[proc_macro_derive(MoveCtorUnsafe)] -pub fn derive_move_ctor_unsafe(input: TokenStream) -> TokenStream { - move_ctor::expand(input, true) +#[proc_macro_derive(CopyAssignable)] +pub fn derive_copy_assignable(input: TokenStream) -> TokenStream { + constructor::expand(input, "copy", true, false) } -// #[derive(CopyAssign, MoveAssign)] -// pub struct S { ... } -// impl SImpl for Ptr { -// fn copy_assign(&self, o: Ptr) -> Ptr { ... } -// fn move_assign(&self, o: Ptr) -> Ptr { ... } -// } -// -// Implements libcc2rs::CopyAssign and MoveAssign for S with its copy and move -// assignment operators, such that std::swap assigns the values of type S -// with them, as C++ does. CopyAssignUnsafe and MoveAssignUnsafe are the same -// for the unsafe model, whose copy_assign and move_assign are methods of S. - -#[proc_macro_derive(CopyAssign)] -pub fn derive_copy_assign(input: TokenStream) -> TokenStream { - assign::expand(input, "copy", false) +#[proc_macro_derive(CopyAssignableUnsafe)] +pub fn derive_copy_assignable_unsafe(input: TokenStream) -> TokenStream { + constructor::expand(input, "copy", true, true) +} + +#[proc_macro_derive(MoveConstructible)] +pub fn derive_move_constructible(input: TokenStream) -> TokenStream { + constructor::expand(input, "move", false, false) } -#[proc_macro_derive(CopyAssignUnsafe)] -pub fn derive_copy_assign_unsafe(input: TokenStream) -> TokenStream { - assign::expand(input, "copy", true) +#[proc_macro_derive(MoveConstructibleUnsafe)] +pub fn derive_move_constructible_unsafe(input: TokenStream) -> TokenStream { + constructor::expand(input, "move", false, true) } -#[proc_macro_derive(MoveAssign)] -pub fn derive_move_assign(input: TokenStream) -> TokenStream { - assign::expand(input, "move", false) +#[proc_macro_derive(MoveAssignable)] +pub fn derive_move_assignable(input: TokenStream) -> TokenStream { + constructor::expand(input, "move", true, false) } -#[proc_macro_derive(MoveAssignUnsafe)] -pub fn derive_move_assign_unsafe(input: TokenStream) -> TokenStream { - assign::expand(input, "move", true) +#[proc_macro_derive(MoveAssignableUnsafe)] +pub fn derive_move_assignable_unsafe(input: TokenStream) -> TokenStream { + constructor::expand(input, "move", true, true) } // #[derive(Destructible)] diff --git a/libcc2rs-macros/src/move_ctor.rs b/libcc2rs-macros/src/move_ctor.rs deleted file mode 100644 index 7848b56352..0000000000 --- a/libcc2rs-macros/src/move_ctor.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) 2022-present INESC-ID. -// Distributed under the MIT license that can be found in the LICENSE file. - -use proc_macro::TokenStream; -use quote::{format_ident, quote}; -use syn::{DeriveInput, parse_macro_input}; - -pub fn expand(input: TokenStream, is_unsafe: bool) -> TokenStream { - let input = parse_macro_input!(input as DeriveInput); - let name = &input.ident; - let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl(); - let body = - crate::initialization::construct(is_unsafe, name, &format_ident!("move_from"), quote!(src)); - if is_unsafe { - quote! { - impl #impl_generics ::libcc2rs::MoveCtorUnsafe for #name #ty_generics #where_clause { - unsafe fn move_ctor(src: *mut Self) -> Self { - unsafe { #body } - } - } - } - } else { - quote! { - impl #impl_generics ::libcc2rs::MoveCtor for #name #ty_generics #where_clause { - fn move_ctor(src: ::libcc2rs::Ptr) -> Self { - #body - } - } - } - } - .into() -} diff --git a/libcc2rs/src/capture.rs b/libcc2rs/src/capture.rs index e0eca957fd..6db6c7c344 100644 --- a/libcc2rs/src/capture.rs +++ b/libcc2rs/src/capture.rs @@ -7,7 +7,7 @@ // specialization picks, among the impls below, the one with the most `&`s // whose bounds the capture's type satisfies: // - a lambda (a FnPtr) is copied and moved with its own constructors; -// - a type with a C++ move constructor (MoveCtor) is moved with it; +// - a type with a C++ move constructor (MoveConstructible) is moved with it; // - any other type is copied with Clone, also when it is moved, as C++ // copies the types without a move constructor; // - a type that is not Clone is not copyable, and neither is the lambda, @@ -20,119 +20,15 @@ #![allow(private_bounds, clippy::missing_safety_doc)] use std::cell::RefCell; -use std::collections::BTreeMap; use std::rc::Rc; +use crate::constructor::{ + CopyConstructible, CopyConstructibleUnsafe, MoveConstructible, MoveConstructibleUnsafe, +}; use crate::fn_ptr::{FnPtr, FnSig}; +use crate::initialization::ZeroInitialization; use crate::rc::{AsPointer, Decay, Ptr, Value}; use crate::reinterpret::ByteRepr; -use crate::{Map, UnsafeMap}; - -// The C++ move constructor of a type, in the refcount model, for the types -// whose move isn't a copy. Records implement it with #[derive(MoveCtor)]. -pub trait MoveCtor: Sized { - fn move_ctor(src: Ptr) -> Self; -} - -// The C++ move constructor of a type, in the unsafe model. Records implement -// it with #[derive(MoveCtorUnsafe)]. -pub trait MoveCtorUnsafe: Sized { - /// # Safety - /// `src` must point to a live value. - unsafe fn move_ctor(src: *mut Self) -> Self; -} - -// The C++ copy assignment operator of a type, in the refcount model, for the -// types whose copy assignment isn't an assignment of a clone. Records -// implement it with #[derive(CopyAssign)]. -pub trait CopyAssign: Sized { - fn copy_assign(dst: &Ptr, src: Ptr); -} - -// The C++ copy assignment operator of a type, in the unsafe model. Records -// implement it with #[derive(CopyAssignUnsafe)]. -pub trait CopyAssignUnsafe: Sized { - /// # Safety - /// `dst` and `src` must point to live values. - unsafe fn copy_assign(dst: *mut Self, src: *const Self); -} - -// The C++ move assignment operator of a type, in the refcount model, for the -// types whose move assignment isn't an assignment of a moved value. Records -// implement it with #[derive(MoveAssign)]. -pub trait MoveAssign: Sized { - fn move_assign(dst: &Ptr, src: Ptr); -} - -// The C++ move assignment operator of a type, in the unsafe model. Records -// implement it with #[derive(MoveAssignUnsafe)]. -pub trait MoveAssignUnsafe: Sized { - /// # Safety - /// `dst` and `src` must point to live values. - unsafe fn move_assign(dst: *mut Self, src: *mut Self); -} - -impl MoveCtor for FnPtr { - fn move_ctor(src: Ptr) -> Self { - src.with(FnPtr::move_from) - } -} - -impl MoveCtorUnsafe for FnPtr { - unsafe fn move_ctor(src: *mut Self) -> Self { - unsafe { (*src).move_from() } - } -} - -// The library types whose move leaves the source empty. -macro_rules! impl_move_ctor_by_take { - ($(<$($param:ident),*> $ty:ty),* $(,)?) => {$( - impl<$($param),*> MoveCtor for $ty - where - Self: ByteRepr, - { - fn move_ctor(src: Ptr) -> Self { - src.with_mut(std::mem::take) - } - } - - impl<$($param),*> MoveCtorUnsafe for $ty { - unsafe fn move_ctor(src: *mut Self) -> Self { - std::mem::take(unsafe { &mut *src }) - } - } - )*}; -} - -impl_move_ctor_by_take!( - Vec, - BTreeMap, - Map, - UnsafeMap, -); - -// unique_ptr. -impl MoveCtor for Option> -where - Self: ByteRepr, -{ - fn move_ctor(src: Ptr) -> Self { - src.with_mut(Option::take) - } -} - -impl MoveCtorUnsafe for Option> { - unsafe fn move_ctor(src: *mut Self) -> Self { - unsafe { (*src).take() } - } -} - -impl MoveCtorUnsafe for [T; N] { - unsafe fn move_ctor(src: *mut Self) -> Self { - let src = src as *mut T; - std::array::from_fn(|i| unsafe { T::move_ctor(src.add(i)) }) - } -} // The C++ destructor of a type, in the refcount model, for the types that // have one. Records implement it with #[derive(Destructible)]. @@ -187,7 +83,12 @@ pub trait CopyLambda { impl CopyLambda>> for &&Capture<'_, Value>> { fn copy_capture(&self) -> Value> { - Rc::new(RefCell::new(self.0.borrow().copy_from())) + let dst: Value> = Rc::new(RefCell::new(FnPtr::zero_init())); + CopyConstructible::copy_constructor( + &AsPointer::>::as_pointer(&dst), + AsPointer::>::as_pointer(self.0), + ); + dst } } @@ -217,29 +118,18 @@ impl CopyNone for Capture<'_, T> { } } -pub trait MoveElems { - fn move_capture(&self) -> T; -} - -impl MoveElems>> for &&&Capture<'_, Value>> { - fn move_capture(&self) -> Value> { - let src: Ptr = self.0.decay(); - let len = self.0.borrow().len(); - Rc::new(RefCell::new( - (0..len).map(|i| T::move_ctor(src.offset(i))).collect(), - )) - } -} - pub trait MoveWithCtor { fn move_capture(&self) -> T; } -impl MoveWithCtor> for &&Capture<'_, Value> { +impl MoveWithCtor> for &&Capture<'_, Value> { fn move_capture(&self) -> Value { - Rc::new(RefCell::new(T::move_ctor(AsPointer::::as_pointer( - self.0, - )))) + let dst: Value = Rc::new(RefCell::new(T::zero_init())); + T::move_constructor( + &AsPointer::::as_pointer(&dst), + AsPointer::::as_pointer(self.0), + ); + dst } } @@ -310,7 +200,11 @@ pub trait CopyLambdaUnsafe { impl CopyLambdaUnsafe> for &&CaptureUnsafe> { unsafe fn copy_capture(&self) -> FnPtr { - unsafe { (*self.0).copy_from() } + let mut dst = std::mem::MaybeUninit::>::uninit(); + unsafe { + (*dst.as_mut_ptr()).copy_constructor(self.0); + dst.assume_init() + } } } @@ -338,9 +232,13 @@ pub trait MoveWithCtorUnsafe { unsafe fn move_capture(&self) -> T; } -impl MoveWithCtorUnsafe for &&CaptureUnsafe { +impl MoveWithCtorUnsafe for &&CaptureUnsafe { unsafe fn move_capture(&self) -> T { - unsafe { T::move_ctor(self.0) } + let mut dst = std::mem::MaybeUninit::::uninit(); + unsafe { + (*dst.as_mut_ptr()).move_constructor(self.0); + dst.assume_init() + } } } diff --git a/libcc2rs/src/constructor.rs b/libcc2rs/src/constructor.rs new file mode 100644 index 0000000000..55e2564e0f --- /dev/null +++ b/libcc2rs/src/constructor.rs @@ -0,0 +1,415 @@ +// Copyright (c) 2022-present INESC-ID. +// Distributed under the MIT license that can be found in the LICENSE file. + +use std::collections::BTreeMap; + +use crate::fn_ptr::{FnPtr, FnSig}; +use crate::initialization::ZeroInitialization; +use crate::rc::{Ptr, Value}; +use crate::reinterpret::ByteRepr; +use crate::void::AnyPtr; +use crate::{Map, UnsafeMap}; + +pub trait MoveConstructible: Sized { + fn move_constructor(this: &Ptr, src: Ptr); +} + +pub trait CopyConstructible: Sized { + fn copy_constructor(this: &Ptr, src: Ptr); +} + +pub trait CopyAssignable: Sized { + fn copy_assign(this: &Ptr, src: Ptr) -> Ptr; +} + +pub trait MoveAssignable: Sized { + fn move_assign(this: &Ptr, src: Ptr) -> Ptr; +} + +pub trait MoveConstructibleUnsafe { + /// # Safety + /// `src` must point to a live value. + unsafe fn move_constructor(&mut self, src: *mut Self); +} + +pub trait CopyConstructibleUnsafe { + /// # Safety + /// `src` must point to a live value. + unsafe fn copy_constructor(&mut self, src: *const Self); +} + +pub trait CopyAssignableUnsafe { + /// # Safety + /// `src` must point to a live value. + unsafe fn copy_assign(&mut self, src: *const Self) -> *mut Self; +} + +pub trait MoveAssignableUnsafe { + /// # Safety + /// `src` must point to a live value. + unsafe fn move_assign(&mut self, src: *mut Self) -> *mut Self; +} + +macro_rules! impl_copy_by_clone { + ($(<$($param:ident),*> $ty:ty),* $(,)?) => {$( + impl<$($param),*> $crate::CopyConstructible for $ty + where + $ty: Clone + $crate::ByteRepr, + { + fn copy_constructor(this: &$crate::Ptr, src: $crate::Ptr) { + this.write(src.read()); + } + } + + impl<$($param),*> $crate::CopyAssignable for $ty + where + $ty: Clone + $crate::ByteRepr, + { + fn copy_assign(this: &$crate::Ptr, src: $crate::Ptr) -> $crate::Ptr { + this.write(src.read()); + this.clone() + } + } + + impl<$($param),*> $crate::CopyConstructibleUnsafe for $ty + where + $ty: Clone, + { + unsafe fn copy_constructor(&mut self, src: *const Self) { + unsafe { std::ptr::write(self, (*src).clone()) } + } + } + + impl<$($param),*> $crate::CopyAssignableUnsafe for $ty + where + $ty: Clone, + { + unsafe fn copy_assign(&mut self, src: *const Self) -> *mut Self { + unsafe { *self = (*src).clone() }; + self + } + } + )*}; +} +pub(crate) use impl_copy_by_clone; + +macro_rules! impl_move_by_clone { + ($(<$($param:ident),*> $ty:ty),* $(,)?) => {$( + impl<$($param),*> $crate::MoveConstructible for $ty + where + $ty: Clone + $crate::ByteRepr, + { + fn move_constructor(this: &$crate::Ptr, src: $crate::Ptr) { + this.write(src.read()); + } + } + + impl<$($param),*> $crate::MoveAssignable for $ty + where + $ty: Clone + $crate::ByteRepr, + { + fn move_assign(this: &$crate::Ptr, src: $crate::Ptr) -> $crate::Ptr { + this.write(src.read()); + this.clone() + } + } + + impl<$($param),*> $crate::MoveConstructibleUnsafe for $ty + where + $ty: Clone, + { + unsafe fn move_constructor(&mut self, src: *mut Self) { + unsafe { std::ptr::write(self, (*src).clone()) } + } + } + + impl<$($param),*> $crate::MoveAssignableUnsafe for $ty + where + $ty: Clone, + { + unsafe fn move_assign(&mut self, src: *mut Self) -> *mut Self { + unsafe { *self = (*src).clone() }; + self + } + } + )*}; +} +pub(crate) use impl_move_by_clone; + +macro_rules! impl_trivial_copy_move { + ($(<$($param:ident),*> $ty:ty),* $(,)?) => { + $crate::constructor::impl_copy_by_clone!($(<$($param),*> $ty),*); + $crate::constructor::impl_move_by_clone!($(<$($param),*> $ty),*); + }; + ($($ty:ty),* $(,)?) => { + $crate::constructor::impl_trivial_copy_move!($(<> $ty),*); + }; +} +pub(crate) use impl_trivial_copy_move; + +// The library types whose move leaves the source empty. +macro_rules! impl_move_by_take { + ($(<$($param:ident),*> $ty:ty),* $(,)?) => {$( + impl<$($param),*> MoveConstructible for $ty + where + $ty: Default + ByteRepr, + { + fn move_constructor(this: &Ptr, src: Ptr) { + let value = src.with_mut(std::mem::take); + this.with_mut(|dst| *dst = value); + } + } + + impl<$($param),*> MoveAssignable for $ty + where + $ty: Default + ByteRepr, + { + fn move_assign(this: &Ptr, src: Ptr) -> Ptr { + let value = src.with_mut(std::mem::take); + this.with_mut(|dst| *dst = value); + this.clone() + } + } + + impl<$($param),*> MoveConstructibleUnsafe for $ty + where + $ty: Default, + { + unsafe fn move_constructor(&mut self, src: *mut Self) { + unsafe { std::ptr::write(self, std::mem::take(&mut *src)) } + } + } + + impl<$($param),*> MoveAssignableUnsafe for $ty + where + $ty: Default, + { + unsafe fn move_assign(&mut self, src: *mut Self) -> *mut Self { + unsafe { *self = std::mem::take(&mut *src) }; + self + } + } + )*}; +} + +impl_trivial_copy_move!( + (), + bool, + i8, + u8, + i16, + u16, + i32, + u32, + i64, + u64, + i128, + u128, + isize, + usize, + f32, + f64, + std::cmp::Ordering, + AnyPtr, + crate::VaArg, + std::rc::Rc, +); + +impl_trivial_copy_move!( + Ptr, + *mut T, + *const T, + (A, B), +); + +impl_copy_by_clone!( + Vec, + BTreeMap, + Map, + UnsafeMap, +); + +impl_move_by_take!( + Vec, + BTreeMap, + Map, + UnsafeMap, +); + +impl MoveConstructible for FnPtr { + fn move_constructor(this: &Ptr, src: Ptr) { + let value = src.with(FnPtr::move_from); + this.with_mut(|dst| *dst = value); + } +} + +impl CopyConstructible for FnPtr { + fn copy_constructor(this: &Ptr, src: Ptr) { + let value = src.with(FnPtr::copy_from); + this.with_mut(|dst| *dst = value); + } +} + +impl MoveAssignable for FnPtr { + fn move_assign(this: &Ptr, src: Ptr) -> Ptr { + ::move_constructor(this, src); + this.clone() + } +} + +impl CopyAssignable for FnPtr { + fn copy_assign(this: &Ptr, src: Ptr) -> Ptr { + ::copy_constructor(this, src); + this.clone() + } +} + +impl MoveConstructibleUnsafe for FnPtr { + unsafe fn move_constructor(&mut self, src: *mut Self) { + unsafe { std::ptr::write(self, (*src).move_from()) } + } +} + +impl CopyConstructibleUnsafe for FnPtr { + unsafe fn copy_constructor(&mut self, src: *const Self) { + unsafe { std::ptr::write(self, (*src).copy_from()) } + } +} + +impl MoveAssignableUnsafe for FnPtr { + unsafe fn move_assign(&mut self, src: *mut Self) -> *mut Self { + unsafe { *self = (*src).move_from() }; + self + } +} + +impl CopyAssignableUnsafe for FnPtr { + unsafe fn copy_assign(&mut self, src: *const Self) -> *mut Self { + unsafe { *self = (*src).copy_from() }; + self + } +} + +// C arrays, element by element. +fn construct_elems( + this: &Ptr>, + src: &Ptr>, + construct: fn(&Ptr, Ptr), +) { + let len = src.with(|elems| elems.len()); + this.with_mut(|elems| *elems = (0..len).map(|_| T::zero_init()).collect()); + let (dst, src) = (this.decay(), src.decay()); + for i in 0..len { + construct(&dst.offset(i), src.offset(i)); + } +} + +fn assign_elems( + this: &Ptr>, + src: &Ptr>, + assign: fn(&Ptr, Ptr) -> Ptr, +) -> Ptr> { + let len = src.with(|elems| elems.len()); + let (dst, src) = (this.decay(), src.decay()); + for i in 0..len { + assign(&dst.offset(i), src.offset(i)); + } + this.clone() +} + +impl MoveConstructible for Box<[T]> { + fn move_constructor(this: &Ptr, src: Ptr) { + construct_elems(this, &src, T::move_constructor); + } +} + +impl CopyConstructible for Box<[T]> { + fn copy_constructor(this: &Ptr, src: Ptr) { + construct_elems(this, &src, T::copy_constructor); + } +} + +impl MoveAssignable for Box<[T]> { + fn move_assign(this: &Ptr, src: Ptr) -> Ptr { + assign_elems(this, &src, T::move_assign) + } +} + +impl CopyAssignable for Box<[T]> { + fn copy_assign(this: &Ptr, src: Ptr) -> Ptr { + assign_elems(this, &src, T::copy_assign) + } +} + +// unique_ptr. +impl MoveConstructible for Option> +where + Self: ByteRepr, +{ + fn move_constructor(this: &Ptr, src: Ptr) { + let value = src.with_mut(Option::take); + this.with_mut(|dst| *dst = value); + } +} + +impl MoveAssignable for Option> +where + Self: ByteRepr, +{ + fn move_assign(this: &Ptr, src: Ptr) -> Ptr { + let value = src.with_mut(Option::take); + this.with_mut(|dst| *dst = value); + this.clone() + } +} + +impl MoveConstructibleUnsafe for Option> { + unsafe fn move_constructor(&mut self, src: *mut Self) { + unsafe { std::ptr::write(self, (*src).take()) } + } +} + +impl MoveAssignableUnsafe for Option> { + unsafe fn move_assign(&mut self, src: *mut Self) -> *mut Self { + unsafe { *self = (*src).take() }; + self + } +} + +impl MoveConstructibleUnsafe for [T; N] { + unsafe fn move_constructor(&mut self, src: *mut Self) { + let src = src as *mut T; + for (i, elem) in self.iter_mut().enumerate() { + unsafe { elem.move_constructor(src.add(i)) } + } + } +} + +impl CopyConstructibleUnsafe for [T; N] { + unsafe fn copy_constructor(&mut self, src: *const Self) { + let src = src as *const T; + for (i, elem) in self.iter_mut().enumerate() { + unsafe { elem.copy_constructor(src.add(i)) } + } + } +} + +impl MoveAssignableUnsafe for [T; N] { + unsafe fn move_assign(&mut self, src: *mut Self) -> *mut Self { + let src = src as *mut T; + for (i, elem) in self.iter_mut().enumerate() { + unsafe { elem.move_assign(src.add(i)) }; + } + self + } +} + +impl CopyAssignableUnsafe for [T; N] { + unsafe fn copy_assign(&mut self, src: *const Self) -> *mut Self { + let src = src as *const T; + for (i, elem) in self.iter_mut().enumerate() { + unsafe { elem.copy_assign(src.add(i)) }; + } + self + } +} diff --git a/libcc2rs/src/initialization.rs b/libcc2rs/src/initialization.rs index afb1c38722..e8a9cc87c2 100644 --- a/libcc2rs/src/initialization.rs +++ b/libcc2rs/src/initialization.rs @@ -69,6 +69,20 @@ impl ZeroInitialization for Vec { } } +impl ZeroInitialization for Box<[T]> { + #[inline] + fn zero_init() -> Self { + Box::new([]) + } +} + +impl ZeroInitialization for std::collections::BTreeMap { + #[inline] + fn zero_init() -> Self { + std::collections::BTreeMap::new() + } +} + impl ZeroInitialization for Rc> { #[inline] fn zero_init() -> Self { diff --git a/libcc2rs/src/lib.rs b/libcc2rs/src/lib.rs index 50998a26ee..0658962159 100644 --- a/libcc2rs/src/lib.rs +++ b/libcc2rs/src/lib.rs @@ -42,9 +42,12 @@ mod fn_ptr; pub use fn_ptr::{FnPtr, Generic}; mod capture; -pub use capture::{ - CopyAssign, CopyAssignUnsafe, Destructible, DestructibleUnsafe, MoveAssign, MoveAssignUnsafe, - MoveCtor, MoveCtorUnsafe, +pub use capture::{Destructible, DestructibleUnsafe}; + +mod constructor; +pub use constructor::{ + CopyAssignable, CopyAssignableUnsafe, CopyConstructible, CopyConstructibleUnsafe, + MoveAssignable, MoveAssignableUnsafe, MoveConstructible, MoveConstructibleUnsafe, }; mod cmp; @@ -68,8 +71,8 @@ pub mod __capture { pub use crate::capture::{ Capture, CaptureUnsafe, CopyClone, CopyCloneUnsafe, CopyLambda, CopyLambdaUnsafe, CopyNone, CopyNoneUnsafe, DestroyElems, DestroyNone, DestroyNoneUnsafe, DestroyWithDtor, - DestroyWithDtorUnsafe, MoveClone, MoveCloneUnsafe, MoveElems, MoveNone, MoveNoneUnsafe, - MoveWithCtor, MoveWithCtorUnsafe, + DestroyWithDtorUnsafe, MoveClone, MoveCloneUnsafe, MoveNone, MoveNoneUnsafe, MoveWithCtor, + MoveWithCtorUnsafe, }; } @@ -107,8 +110,8 @@ mod format; pub use format::*; pub use libcc2rs_macros::{ - ByteRepr, CopyAssign, CopyAssignUnsafe, CppFrom, CppFromUnsafe, Destructible, - DestructibleUnsafe, FnPtrArg, MoveAssign, MoveAssignUnsafe, MoveCtor, MoveCtorUnsafe, Record, - VaArg, ZeroInitialization, ZeroInitializationUnsafe, goto, goto_block, lambda, lambda_unsafe, - switch, + ByteRepr, CopyAssignable, CopyAssignableUnsafe, CopyConstructible, CopyConstructibleUnsafe, + CppFrom, CppFromUnsafe, Destructible, DestructibleUnsafe, FnPtrArg, MoveAssignable, + MoveAssignableUnsafe, MoveConstructible, MoveConstructibleUnsafe, Record, VaArg, + ZeroInitialization, ZeroInitializationUnsafe, goto, goto_block, lambda, lambda_unsafe, switch, }; diff --git a/libcc2rs/src/swap.rs b/libcc2rs/src/swap.rs index bd7eeb4ef7..b3b0d16111 100644 --- a/libcc2rs/src/swap.rs +++ b/libcc2rs/src/swap.rs @@ -10,13 +10,13 @@ // `(&&&Construct(..)).construct()`, `(&&&&&Assign(..)).assign()` and // `(&&Destroy(..)).destroy()`, and autoref specialization picks, among the // impls below, the one with the most `&`s whose bounds the type satisfies: -// - the temporary is made with the move constructor (MoveCtor), or else -// with the copy constructor (Clone); -// - a value is assigned with the move assignment operator (MoveAssign), or -// else with the copy assignment operator (CopyAssign), as C++ copies the -// types without one; the other types are assigned as a whole, by moving -// the value with the move constructor (MoveCtor), or else by copying it -// (Clone); +// - the temporary is made with the move constructor (MoveConstructible), +// or else with the copy constructor (Clone); +// - a value is assigned with the move assignment operator (MoveAssignable), +// or else with the copy assignment operator (CopyAssignable), as C++ +// copies the types without one; the other types are assigned as a whole, +// by moving the value with the move constructor (MoveConstructible), or +// else by copying it (Clone); // - the temporary is destroyed with the destructor, if any (Destructible). // The values are accessed one at a time, so they may be in the same // allocation, e.g., two fields of a struct. @@ -31,10 +31,12 @@ use std::cell::RefCell; use std::rc::Rc; -use crate::capture::{ - CopyAssign, CopyAssignUnsafe, Destructible, DestructibleUnsafe, MoveAssign, MoveAssignUnsafe, - MoveCtor, MoveCtorUnsafe, +use crate::capture::{Destructible, DestructibleUnsafe}; +use crate::constructor::{ + CopyAssignable, CopyAssignableUnsafe, MoveAssignable, MoveAssignableUnsafe, MoveConstructible, + MoveConstructibleUnsafe, }; +use crate::initialization::ZeroInitialization; use crate::rc::{AsPointer, Ptr, Value}; use crate::reinterpret::ByteRepr; @@ -108,14 +110,17 @@ macro_rules! cpp_move_unsafe { // Whether the type has none of the special members that the swap calls. macro_rules! trivial { - ($wrapper:ident, $ptr:ty, $none:ident, $($tr:ident: $bound:ident for $recv:ty),*) => { + ($wrapper:ident, $ptr:ty, $none:ident, $($tr:ident: $bty:ty: $bound:ident for $recv:ty),*) => { pub struct $wrapper<'a, T>(pub &'a $ptr); $( pub trait $tr { fn trivial(self) -> bool; } - impl $tr for $recv { + impl $tr for $recv + where + $bty: $bound, + { fn trivial(self) -> bool { false } @@ -135,17 +140,17 @@ macro_rules! trivial { } trivial!(Trivial, Ptr, HasNone, - HasMoveCtor: MoveCtor for &&&&&Trivial<'_, T>, - HasMoveAssign: MoveAssign for &&&&Trivial<'_, T>, - HasCopyAssign: CopyAssign for &&&Trivial<'_, T>, - HasDestructor: Destructible for &&Trivial<'_, T> + HasMoveCtor: T: MoveConstructible for &&&&&Trivial<'_, T>, + HasMoveAssign: T: MoveAssignable for &&&&Trivial<'_, T>, + HasCopyAssign: T: CopyAssignable for &&&Trivial<'_, T>, + HasDestructor: T: Destructible for &&Trivial<'_, T> ); trivial!(TrivialUnsafe, *mut T, HasNoneUnsafe, - HasMoveCtorUnsafe: MoveCtorUnsafe for &&&&&TrivialUnsafe<'_, T>, - HasMoveAssignUnsafe: MoveAssignUnsafe for &&&&TrivialUnsafe<'_, T>, - HasCopyAssignUnsafe: CopyAssignUnsafe for &&&TrivialUnsafe<'_, T>, - HasDestructorUnsafe: DestructibleUnsafe for &&TrivialUnsafe<'_, T> + HasMoveCtorUnsafe: T: MoveConstructibleUnsafe for &&&&&TrivialUnsafe<'_, T>, + HasMoveAssignUnsafe: T: MoveAssignableUnsafe for &&&&TrivialUnsafe<'_, T>, + HasCopyAssignUnsafe: T: CopyAssignableUnsafe for &&&TrivialUnsafe<'_, T>, + HasDestructorUnsafe: T: DestructibleUnsafe for &&TrivialUnsafe<'_, T> ); #[cold] @@ -187,6 +192,20 @@ pub fn pointer(value: &Value) -> Ptr { as AsPointer>::as_pointer(value) } +fn move_constructed(src: &Ptr) -> T { + let dst: Value = Rc::new(RefCell::new(T::zero_init())); + T::move_constructor(&pointer(&dst), src.clone()); + Rc::try_unwrap(dst).ok().unwrap().into_inner() +} + +unsafe fn move_constructed_unsafe(src: *mut T) -> T { + let mut dst = std::mem::MaybeUninit::::uninit(); + unsafe { + (*dst.as_mut_ptr()).move_constructor(src); + dst.assume_init() + } +} + pub struct Construct<'a, T>(pub &'a Ptr); pub trait ConstructMove { @@ -201,9 +220,9 @@ pub trait ConstructNone { fn construct(self) -> T; } -impl ConstructMove for &&&Construct<'_, T> { +impl ConstructMove for &&&Construct<'_, T> { fn construct(self) -> T { - T::move_ctor(self.0.clone()) + move_constructed(self.0) } } @@ -242,21 +261,21 @@ pub trait AssignNone { fn assign(self); } -impl AssignMove for &&&&&Assign<'_, T> { +impl AssignMove for &&&&&Assign<'_, T> { fn assign(self) { - T::move_assign(self.0, self.1.clone()) + T::move_assign(self.0, self.1.clone()); } } -impl AssignCopy for &&&&Assign<'_, T> { +impl AssignCopy for &&&&Assign<'_, T> { fn assign(self) { - T::copy_assign(self.0, self.1.clone()) + T::copy_assign(self.0, self.1.clone()); } } -impl AssignMoveCtor for &&&Assign<'_, T> { +impl AssignMoveCtor for &&&Assign<'_, T> { fn assign(self) { - self.0.write(T::move_ctor(self.1.clone())) + self.0.write(move_constructed(self.1)) } } @@ -306,9 +325,9 @@ pub trait ConstructNoneUnsafe { unsafe fn construct(self) -> T; } -impl ConstructMoveUnsafe for &&&ConstructUnsafe { +impl ConstructMoveUnsafe for &&&ConstructUnsafe { unsafe fn construct(self) -> T { - unsafe { T::move_ctor(self.0) } + unsafe { move_constructed_unsafe(self.0) } } } @@ -346,21 +365,21 @@ pub trait AssignNoneUnsafe { unsafe fn assign(self); } -impl AssignMoveUnsafe for &&&&&AssignUnsafe { +impl AssignMoveUnsafe for &&&&&AssignUnsafe { unsafe fn assign(self) { - unsafe { T::move_assign(self.0, self.1) } + unsafe { (*self.0).move_assign(self.1) }; } } -impl AssignCopyUnsafe for &&&&AssignUnsafe { +impl AssignCopyUnsafe for &&&&AssignUnsafe { unsafe fn assign(self) { - unsafe { T::copy_assign(self.0, self.1) } + unsafe { (*self.0).copy_assign(self.1) }; } } -impl AssignMoveCtorUnsafe for &&&AssignUnsafe { +impl AssignMoveCtorUnsafe for &&&AssignUnsafe { unsafe fn assign(self) { - unsafe { *self.0 = T::move_ctor(self.1) } + unsafe { *self.0 = move_constructed_unsafe(self.1) } } } From 68505d6fac5d81b4513f78fa3422f606dbdcefe8 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Mon, 30 Nov 2026 20:47:40 +0000 Subject: [PATCH 05/20] Update tests --- .../out/refcount/defaulted_move_cross_tu.rs | 68 +-- .../out/refcount/p14-class-in-two-files.rs | 24 +- .../p15-class-template-static-member.rs | 24 +- .../out/refcount/p15-function-template.rs | 24 +- .../out/refcount/p15-inline-function.rs | 24 +- .../out/refcount/p15-inline-variable.rs | 24 +- .../p16-default-argument-lambda-in-class.rs | 24 +- .../refcount/p16-lambda-in-inline-function.rs | 24 +- .../out/refcount/basic.scope.block.rs | 24 +- tests/std/basic/out/refcount/basic.def.odr.rs | 146 +++--- .../out/refcount/class.copy.ctor.rs | 16 +- .../out/refcount/expr.mptr.oper.rs | 62 +-- .../stmt.select/out/refcount/stmt.if.rs | 24 +- .../stmt.select/out/refcount/stmt.switch.rs | 24 +- .../temp/temp.spec/out/refcount/temp.inst.rs | 10 +- .../utility/out/refcount/forward-helpers.rs | 128 ++--- .../utilities/utility/out/refcount/forward.rs | 12 +- .../out/refcount/array_of_noncopy_struct.rs | 30 +- .../out/refcount/assignment_single_eval.rs | 26 +- tests/unit/out/refcount/cast.rs | 30 +- tests/unit/out/refcount/class_templates.rs | 78 +-- .../refcount/container_element_receiver.rs | 12 +- .../unit/out/refcount/container_field_addr.rs | 30 +- tests/unit/out/refcount/copy_assign.rs | 130 ++--- tests/unit/out/refcount/copy_ctor.rs | 176 +++---- .../unit/out/refcount/copy_move_defaulted.rs | 242 +++++----- tests/unit/out/refcount/copy_move_deleted.rs | 112 ++--- .../out/refcount/field_method_receiver.rs | 50 +- tests/unit/out/refcount/field_pointers.rs | 70 +-- tests/unit/out/refcount/fn_ptr_struct.rs | 12 +- .../refcount/foreach_disjoint_field_borrow.rs | 30 +- tests/unit/out/refcount/forward_basic.rs | 48 +- tests/unit/out/refcount/forward_decltype.rs | 30 +- tests/unit/out/refcount/forward_explicit.rs | 30 +- tests/unit/out/refcount/forward_pack.rs | 58 +-- tests/unit/out/refcount/huffman.rs | 60 +-- tests/unit/out/refcount/implicit_autoref.rs | 26 +- .../out/refcount/inline_container_fields.rs | 202 ++++---- tests/unit/out/refcount/kruskal.rs | 82 ++-- tests/unit/out/refcount/lambda_as_field.rs | 12 +- .../out/refcount/lambda_capture_copy_ctor.rs | 36 +- .../out/refcount/lambda_move_only_capture.rs | 12 +- .../refcount/libc_struct_without_default.rs | 68 +-- tests/unit/out/refcount/map_key_copy_ctor.rs | 24 +- tests/unit/out/refcount/map_try_emplace.rs | 26 +- .../out/refcount/map_try_emplace_lvalues.rs | 28 +- tests/unit/out/refcount/max.rs | 24 +- tests/unit/out/refcount/move_assign.rs | 32 +- tests/unit/out/refcount/move_ctor.rs | 72 +-- tests/unit/out/refcount/move_this.rs | 22 +- .../operator_comparison_noncopyable.rs | 10 +- tests/unit/out/refcount/push_emplace_back.rs | 76 +-- tests/unit/out/refcount/rule_of_five.rs | 152 +++--- tests/unit/out/refcount/rule_of_three.rs | 72 +-- .../unit/out/refcount/rvalue_rule_arg_move.rs | 36 +- tests/unit/out/refcount/sort_no_copy.rs | 96 ++-- .../refcount/structured_binding_copy_ctor.rs | 28 +- .../structured_binding_element_ctor.rs | 54 +-- .../refcount/structured_binding_move_ctor.rs | 66 +-- tests/unit/out/refcount/swap_map_no_copy.rs | 452 +++++++++--------- .../unit/out/refcount/temporary_field_addr.rs | 80 ++-- .../out/refcount/temporary_field_ctor_arg.rs | 26 +- .../out/refcount/temporary_field_two_args.rs | 64 +-- .../unit/out/refcount/typedef-anon-struct.rs | 26 +- tests/unit/out/refcount/unique_ptr.rs | 28 +- .../out/refcount/unique_ptr_const_deref.rs | 28 +- .../out/refcount/unique_ptr_field_reset.rs | 32 +- tests/unit/out/refcount/unique_ptr_nested.rs | 28 +- tests/unit/out/refcount/vector.rs | 34 +- .../out/refcount/vector_subscript_direct.rs | 34 +- tests/unit/out/refcount/void_cast.rs | 54 +-- 71 files changed, 2039 insertions(+), 2039 deletions(-) diff --git a/tests/multi-file/defaulted_move_cross_tu/out/refcount/defaulted_move_cross_tu.rs b/tests/multi-file/defaulted_move_cross_tu/out/refcount/defaulted_move_cross_tu.rs index 388bec8a0c..699e27548a 100644 --- a/tests/multi-file/defaulted_move_cross_tu/out/refcount/defaulted_move_cross_tu.rs +++ b/tests/multi-file/defaulted_move_cross_tu/out/refcount/defaulted_move_cross_tu.rs @@ -18,6 +18,27 @@ pub struct S { #[array_len(2)] pub n: Box<[i32]>, } +impl MoveConstructible for S { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), v).write(field!(_a0, v).with_mut(std::mem::take)); + field!((*this), n).write(Box::new(std::array::from_fn::<_, 2, _>(|__i: usize| { + (*_a0.upgrade().deref()).n[(__i) as usize] + }))); + } +} +impl MoveAssignable for S { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), v).with_mut(|__b0| { + (*__b0) = field!(_a0, v).with_mut(std::mem::take); + }); + { + let mut __tmp_0 = { (array_field_ptr!((*this), n)).to_any() }; + __tmp_0.memcpy(&(array_field_ptr!(_a0, n)).to_any(), 8_usize); + (__tmp_0).clone() + }; + return (*this).clone(); + } +} impl Default for S { fn default() -> Self { { ::zero_init() } @@ -40,6 +61,19 @@ pub struct T { #[byte_size(24)] pub v: Vec, } +impl MoveConstructible for T { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), v).write(field!(_a0, v).with_mut(std::mem::take)); + } +} +impl MoveAssignable for T { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), v).with_mut(|__b0| { + (*__b0) = field!(_a0, v).with_mut(std::mem::take); + }); + return (*this).clone(); + } +} pub fn sum_0(s: Ptr) -> i32 { return ({ ({ (((*s.upgrade().deref()).v.len()) as i32) } + { (array_elem!(s, n, 0).read()) }) @@ -105,27 +139,6 @@ impl SImpl for Ptr { field!((*self), n).write(Box::new([x, (x + 1)])); } } -impl MoveAssignable for S { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), v).with_mut(|__b0| { - (*__b0) = field!(_a0, v).with_mut(std::mem::take); - }); - { - let mut __tmp_0 = { (array_field_ptr!((*this), n)).to_any() }; - __tmp_0.memcpy(&(array_field_ptr!(_a0, n)).to_any(), 8_usize); - (__tmp_0).clone() - }; - return (*this).clone(); - } -} -impl MoveConstructible for S { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), v).write(field!(_a0, v).with_mut(std::mem::take)); - field!((*this), n).write(Box::new(std::array::from_fn::<_, 2, _>(|__i: usize| { - (*_a0.upgrade().deref()).n[(__i) as usize] - }))); - } -} pub trait TImpl { fn size(&self) -> i32; } @@ -134,17 +147,4 @@ impl TImpl for Ptr { return (((*(*self).upgrade().deref()).v.len()) as i32); } } -impl MoveAssignable for T { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), v).with_mut(|__b0| { - (*__b0) = field!(_a0, v).with_mut(std::mem::take); - }); - return (*this).clone(); - } -} -impl MoveConstructible for T { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), v).write(field!(_a0, v).with_mut(std::mem::take)); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/refcount/p14-class-in-two-files.rs b/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/refcount/p14-class-in-two-files.rs index 15967aa9d8..9a1d1866ae 100644 --- a/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/refcount/p14-class-in-two-files.rs +++ b/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/refcount/p14-class-in-two-files.rs @@ -53,6 +53,18 @@ impl LifetimeTracked { }); } } +impl CopyConstructible for LifetimeTracked { + fn copy_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), uses).write(0); + (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); + } +} +impl CopyAssignable for LifetimeTracked { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), uses).write(_a0.with(|__s| __s.uses)); + return (*this).clone(); + } +} impl Clone for LifetimeTracked { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(LifetimeTracked { @@ -204,18 +216,6 @@ impl LifetimeTrackedImpl for Ptr { (*useCount_3.with(Value::clone).borrow_mut()).prefix_inc(); } } -impl CopyAssignable for LifetimeTracked { - fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), uses).write(_a0.with(|__s| __s.uses)); - return (*this).clone(); - } -} -impl CopyConstructible for LifetimeTracked { - fn copy_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), uses).write(0); - (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); - } -} pub fn __cpp2rust_init_globals() { let _ = ctorCount_0.with(|_| ()); let _ = copyCount_1.with(|_| ()); diff --git a/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/refcount/p15-class-template-static-member.rs b/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/refcount/p15-class-template-static-member.rs index bf1f25b47a..76437976ad 100644 --- a/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/refcount/p15-class-template-static-member.rs +++ b/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/refcount/p15-class-template-static-member.rs @@ -53,6 +53,18 @@ impl LifetimeTracked { }); } } +impl CopyConstructible for LifetimeTracked { + fn copy_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), uses).write(0); + (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); + } +} +impl CopyAssignable for LifetimeTracked { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), uses).write(_a0.with(|__s| __s.uses)); + return (*this).clone(); + } +} impl Clone for LifetimeTracked { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(LifetimeTracked { @@ -177,18 +189,6 @@ impl LifetimeTrackedImpl for Ptr { (*useCount_3.with(Value::clone).borrow_mut()).prefix_inc(); } } -impl CopyAssignable for LifetimeTracked { - fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), uses).write(_a0.with(|__s| __s.uses)); - return (*this).clone(); - } -} -impl CopyConstructible for LifetimeTracked { - fn copy_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), uses).write(0); - (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); - } -} pub fn __cpp2rust_init_globals() { let _ = ctorCount_0.with(|_| ()); let _ = copyCount_1.with(|_| ()); diff --git a/tests/std/basic/basic.def.odr/p15-function-template/out/refcount/p15-function-template.rs b/tests/std/basic/basic.def.odr/p15-function-template/out/refcount/p15-function-template.rs index 51e2b4e86b..14ec4cccb5 100644 --- a/tests/std/basic/basic.def.odr/p15-function-template/out/refcount/p15-function-template.rs +++ b/tests/std/basic/basic.def.odr/p15-function-template/out/refcount/p15-function-template.rs @@ -53,6 +53,18 @@ impl LifetimeTracked { }); } } +impl CopyConstructible for LifetimeTracked { + fn copy_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), uses).write(0); + (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); + } +} +impl CopyAssignable for LifetimeTracked { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), uses).write(_a0.with(|__s| __s.uses)); + return (*this).clone(); + } +} impl Clone for LifetimeTracked { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(LifetimeTracked { @@ -266,18 +278,6 @@ impl LifetimeTrackedImpl for Ptr { (*useCount_3.with(Value::clone).borrow_mut()).prefix_inc(); } } -impl CopyAssignable for LifetimeTracked { - fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), uses).write(_a0.with(|__s| __s.uses)); - return (*this).clone(); - } -} -impl CopyConstructible for LifetimeTracked { - fn copy_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), uses).write(0); - (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); - } -} pub fn __cpp2rust_init_globals() { let _ = ctorCount_0.with(|_| ()); let _ = copyCount_1.with(|_| ()); diff --git a/tests/std/basic/basic.def.odr/p15-inline-function/out/refcount/p15-inline-function.rs b/tests/std/basic/basic.def.odr/p15-inline-function/out/refcount/p15-inline-function.rs index 0c6490c7b4..6eb3b7b1f9 100644 --- a/tests/std/basic/basic.def.odr/p15-inline-function/out/refcount/p15-inline-function.rs +++ b/tests/std/basic/basic.def.odr/p15-inline-function/out/refcount/p15-inline-function.rs @@ -53,6 +53,18 @@ impl LifetimeTracked { }); } } +impl CopyConstructible for LifetimeTracked { + fn copy_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), uses).write(0); + (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); + } +} +impl CopyAssignable for LifetimeTracked { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), uses).write(_a0.with(|__s| __s.uses)); + return (*this).clone(); + } +} impl Clone for LifetimeTracked { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(LifetimeTracked { @@ -169,18 +181,6 @@ impl LifetimeTrackedImpl for Ptr { (*useCount_3.with(Value::clone).borrow_mut()).prefix_inc(); } } -impl CopyAssignable for LifetimeTracked { - fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), uses).write(_a0.with(|__s| __s.uses)); - return (*this).clone(); - } -} -impl CopyConstructible for LifetimeTracked { - fn copy_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), uses).write(0); - (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); - } -} pub fn __cpp2rust_init_globals() { let _ = ctorCount_0.with(|_| ()); let _ = copyCount_1.with(|_| ()); diff --git a/tests/std/basic/basic.def.odr/p15-inline-variable/out/refcount/p15-inline-variable.rs b/tests/std/basic/basic.def.odr/p15-inline-variable/out/refcount/p15-inline-variable.rs index 5c6c9d4232..5e033f6bfc 100644 --- a/tests/std/basic/basic.def.odr/p15-inline-variable/out/refcount/p15-inline-variable.rs +++ b/tests/std/basic/basic.def.odr/p15-inline-variable/out/refcount/p15-inline-variable.rs @@ -53,6 +53,18 @@ impl LifetimeTracked { }); } } +impl CopyConstructible for LifetimeTracked { + fn copy_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), uses).write(0); + (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); + } +} +impl CopyAssignable for LifetimeTracked { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), uses).write(_a0.with(|__s| __s.uses)); + return (*this).clone(); + } +} impl Clone for LifetimeTracked { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(LifetimeTracked { @@ -164,18 +176,6 @@ impl LifetimeTrackedImpl for Ptr { (*useCount_3.with(Value::clone).borrow_mut()).prefix_inc(); } } -impl CopyAssignable for LifetimeTracked { - fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), uses).write(_a0.with(|__s| __s.uses)); - return (*this).clone(); - } -} -impl CopyConstructible for LifetimeTracked { - fn copy_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), uses).write(0); - (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); - } -} pub fn __cpp2rust_init_globals() { let _ = ctorCount_0.with(|_| ()); let _ = copyCount_1.with(|_| ()); diff --git a/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/refcount/p16-default-argument-lambda-in-class.rs b/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/refcount/p16-default-argument-lambda-in-class.rs index a5826b7908..0ee1b641ca 100644 --- a/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/refcount/p16-default-argument-lambda-in-class.rs +++ b/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/refcount/p16-default-argument-lambda-in-class.rs @@ -53,6 +53,18 @@ impl LifetimeTracked { }); } } +impl CopyConstructible for LifetimeTracked { + fn copy_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), uses).write(0); + (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); + } +} +impl CopyAssignable for LifetimeTracked { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), uses).write(_a0.with(|__s| __s.uses)); + return (*this).clone(); + } +} impl Clone for LifetimeTracked { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(LifetimeTracked { @@ -195,18 +207,6 @@ impl LifetimeTrackedImpl for Ptr { (*useCount_3.with(Value::clone).borrow_mut()).prefix_inc(); } } -impl CopyAssignable for LifetimeTracked { - fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), uses).write(_a0.with(|__s| __s.uses)); - return (*this).clone(); - } -} -impl CopyConstructible for LifetimeTracked { - fn copy_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), uses).write(0); - (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); - } -} pub trait XImpl { fn h(&self, cond: bool, p: FnPtr); } diff --git a/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/refcount/p16-lambda-in-inline-function.rs b/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/refcount/p16-lambda-in-inline-function.rs index e1c2462747..cb608757dd 100644 --- a/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/refcount/p16-lambda-in-inline-function.rs +++ b/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/refcount/p16-lambda-in-inline-function.rs @@ -53,6 +53,18 @@ impl LifetimeTracked { }); } } +impl CopyConstructible for LifetimeTracked { + fn copy_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), uses).write(0); + (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); + } +} +impl CopyAssignable for LifetimeTracked { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), uses).write(_a0.with(|__s| __s.uses)); + return (*this).clone(); + } +} impl Clone for LifetimeTracked { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(LifetimeTracked { @@ -175,18 +187,6 @@ impl LifetimeTrackedImpl for Ptr { (*useCount_3.with(Value::clone).borrow_mut()).prefix_inc(); } } -impl CopyAssignable for LifetimeTracked { - fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), uses).write(_a0.with(|__s| __s.uses)); - return (*this).clone(); - } -} -impl CopyConstructible for LifetimeTracked { - fn copy_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), uses).write(0); - (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); - } -} pub fn __cpp2rust_init_globals() { let _ = ctorCount_0.with(|_| ()); let _ = copyCount_1.with(|_| ()); diff --git a/tests/std/basic/basic.scope/out/refcount/basic.scope.block.rs b/tests/std/basic/basic.scope/out/refcount/basic.scope.block.rs index 181d855811..43ffb9408c 100644 --- a/tests/std/basic/basic.scope/out/refcount/basic.scope.block.rs +++ b/tests/std/basic/basic.scope/out/refcount/basic.scope.block.rs @@ -53,6 +53,18 @@ impl LifetimeTracked { }); } } +impl CopyConstructible for LifetimeTracked { + fn copy_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), uses).write(0); + (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); + } +} +impl CopyAssignable for LifetimeTracked { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), uses).write(_a0.with(|__s| __s.uses)); + return (*this).clone(); + } +} impl Clone for LifetimeTracked { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(LifetimeTracked { @@ -369,18 +381,6 @@ impl LifetimeTrackedImpl for Ptr { (*useCount_3.with(Value::clone).borrow_mut()).prefix_inc(); } } -impl CopyAssignable for LifetimeTracked { - fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), uses).write(_a0.with(|__s| __s.uses)); - return (*this).clone(); - } -} -impl CopyConstructible for LifetimeTracked { - fn copy_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), uses).write(0); - (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); - } -} pub trait p1_1_condition_variable_visible_in_else_ConvertsToBoolImpl { fn to_bool(&self) -> bool; fn destructor(&self); diff --git a/tests/std/basic/out/refcount/basic.def.odr.rs b/tests/std/basic/out/refcount/basic.def.odr.rs index e771c59df2..cad3cca8cc 100644 --- a/tests/std/basic/out/refcount/basic.def.odr.rs +++ b/tests/std/basic/out/refcount/basic.def.odr.rs @@ -31,6 +31,18 @@ impl HasConstexprCtor { copyCount_0.with(|rc| *rc.borrow_mut() = 0); } } +impl CopyConstructible for HasConstexprCtor { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), m).write(o.with(|__s| __s.m)); + (*copyCount_0.with(Value::clone).borrow_mut()).prefix_inc(); + } +} +impl CopyAssignable for HasConstexprCtor { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), m).write(_a0.with(|__s| __s.m)); + return (*this).clone(); + } +} impl Clone for HasConstexprCtor { fn clone(&self) -> Self { let __src: Value = @@ -87,6 +99,18 @@ impl LifetimeTracked { }); } } +impl CopyConstructible for LifetimeTracked { + fn copy_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), uses).write(0); + (*copyCount_2.with(Value::clone).borrow_mut()).prefix_inc(); + } +} +impl CopyAssignable for LifetimeTracked { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), uses).write(_a0.with(|__s| __s.uses)); + return (*this).clone(); + } +} impl Clone for LifetimeTracked { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(LifetimeTracked { @@ -408,6 +432,26 @@ pub struct p5_2_mutable_subobject_is_odr_used_HasMutableMember { #[offset(4)] pub scratch: i32, } +impl CopyConstructible for p5_2_mutable_subobject_is_odr_used_HasMutableMember { + fn copy_constructor( + this: &Ptr, + o: Ptr, + ) { + field!((*this), value).write(o.with(|__s| __s.value)); + field!((*this), scratch).write(o.with(|__s| __s.scratch)); + (*copies_18.with(Value::clone).borrow_mut()).prefix_inc(); + } +} +impl CopyAssignable for p5_2_mutable_subobject_is_odr_used_HasMutableMember { + fn copy_assign( + this: &Ptr, + _a0: Ptr, + ) -> Ptr { + field!((*this), value).write(_a0.with(|__s| __s.value)); + field!((*this), scratch).write(_a0.with(|__s| __s.scratch)); + return (*this).clone(); + } +} impl Clone for p5_2_mutable_subobject_is_odr_used_HasMutableMember { fn clone(&self) -> Self { let __src: Value = Rc::new( @@ -475,6 +519,16 @@ pub struct p6_unevaluated_binding_needs_no_capture_HasTwoMembers { #[byte_size(4)] pub b: LifetimeTracked, } +impl CopyAssignable for p6_unevaluated_binding_needs_no_capture_HasTwoMembers { + fn copy_assign( + this: &Ptr, + _a0: Ptr, + ) -> Ptr { + ({ CopyAssignable::copy_assign(&field_ptr!((*this), a), field_ptr!(_a0, a)) }); + ({ CopyAssignable::copy_assign(&field_ptr!((*this), b), field_ptr!(_a0, b)) }); + return (*this).clone(); + } +} pub fn test_20() { ({ LifetimeTracked::reset() }); let p: Value = Rc::new(RefCell::new( @@ -527,6 +581,16 @@ pub struct p7_member_access_captures_this_HasMemberUsedInLambda { #[offset(4)] pub n: i32, } +impl CopyAssignable for p7_member_access_captures_this_HasMemberUsedInLambda { + fn copy_assign( + this: &Ptr, + _a0: Ptr, + ) -> Ptr { + ({ CopyAssignable::copy_assign(&field_ptr!((*this), x), field_ptr!(_a0, x)) }); + field!((*this), n).write(_a0.with(|__s| __s.n)); + return (*this).clone(); + } +} impl Default for p7_member_access_captures_this_HasMemberUsedInLambda { fn default() -> Self { { @@ -574,6 +638,15 @@ pub struct p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda { #[byte_size(4)] pub x: LifetimeTracked, } +impl CopyAssignable for p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda { + fn copy_assign( + this: &Ptr, + _a0: Ptr, + ) -> Ptr { + ({ CopyAssignable::copy_assign(&field_ptr!((*this), x), field_ptr!(_a0, x)) }); + return (*this).clone(); + } +} pub fn test_23() { ({ LifetimeTracked::reset() }); let c: Value = Rc::new( @@ -894,18 +967,6 @@ impl HasConstexprCtorImpl for Ptr { field!((*self), m).write(v); } } -impl CopyAssignable for HasConstexprCtor { - fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), m).write(_a0.with(|__s| __s.m)); - return (*this).clone(); - } -} -impl CopyConstructible for HasConstexprCtor { - fn copy_constructor(this: &Ptr, o: Ptr) { - field!((*this), m).write(o.with(|__s| __s.m)); - (*copyCount_0.with(Value::clone).borrow_mut()).prefix_inc(); - } -} pub trait LifetimeTrackedImpl { fn construct(&self); fn destructor(&self); @@ -926,18 +987,6 @@ impl LifetimeTrackedImpl for Ptr { (*useCount_4.with(Value::clone).borrow_mut()).prefix_inc(); } } -impl CopyAssignable for LifetimeTracked { - fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), uses).write(_a0.with(|__s| __s.uses)); - return (*this).clone(); - } -} -impl CopyConstructible for LifetimeTracked { - fn copy_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), uses).write(0); - (*copyCount_2.with(Value::clone).borrow_mut()).prefix_inc(); - } -} pub trait p5_2_mutable_subobject_is_odr_used_HasMutableMemberImpl { fn construct(&self, v: i32); } @@ -949,26 +998,6 @@ impl p5_2_mutable_subobject_is_odr_used_HasMutableMemberImpl field!((*self), scratch).write(0); } } -impl CopyAssignable for p5_2_mutable_subobject_is_odr_used_HasMutableMember { - fn copy_assign( - this: &Ptr, - _a0: Ptr, - ) -> Ptr { - field!((*this), value).write(_a0.with(|__s| __s.value)); - field!((*this), scratch).write(_a0.with(|__s| __s.scratch)); - return (*this).clone(); - } -} -impl CopyConstructible for p5_2_mutable_subobject_is_odr_used_HasMutableMember { - fn copy_constructor( - this: &Ptr, - o: Ptr, - ) { - field!((*this), value).write(o.with(|__s| __s.value)); - field!((*this), scratch).write(o.with(|__s| __s.scratch)); - (*copies_18.with(Value::clone).borrow_mut()).prefix_inc(); - } -} pub trait p6_unevaluated_binding_needs_no_capture_HasTwoMembersImpl { fn destructor(&self); } @@ -980,16 +1009,6 @@ impl p6_unevaluated_binding_needs_no_capture_HasTwoMembersImpl Destructible::destroy(field_ptr!(self, a)); } } -impl CopyAssignable for p6_unevaluated_binding_needs_no_capture_HasTwoMembers { - fn copy_assign( - this: &Ptr, - _a0: Ptr, - ) -> Ptr { - ({ CopyAssignable::copy_assign(&field_ptr!((*this), a), field_ptr!(_a0, a)) }); - ({ CopyAssignable::copy_assign(&field_ptr!((*this), b), field_ptr!(_a0, b)) }); - return (*this).clone(); - } -} pub trait p7_member_access_captures_this_HasMemberUsedInLambdaImpl { fn makeLambda(&self) -> FnPtr i32>; fn destructor(&self); @@ -1013,16 +1032,6 @@ impl p7_member_access_captures_this_HasMemberUsedInLambdaImpl Destructible::destroy(field_ptr!(self, x)); } } -impl CopyAssignable for p7_member_access_captures_this_HasMemberUsedInLambda { - fn copy_assign( - this: &Ptr, - _a0: Ptr, - ) -> Ptr { - ({ CopyAssignable::copy_assign(&field_ptr!((*this), x), field_ptr!(_a0, x)) }); - field!((*this), n).write(_a0.with(|__s| __s.n)); - return (*this).clone(); - } -} pub trait p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambdaImpl { fn sizer(&self) -> FnPtr usize>; fn destructor(&self); @@ -1041,15 +1050,6 @@ impl p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambdaImpl Destructible::destroy(field_ptr!(self, x)); } } -impl CopyAssignable for p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda { - fn copy_assign( - this: &Ptr, - _a0: Ptr, - ) -> Ptr { - ({ CopyAssignable::copy_assign(&field_ptr!((*this), x), field_ptr!(_a0, x)) }); - return (*this).clone(); - } -} pub trait p9_destructor_not_potentially_invoked_HasUndefinedDestructorImpl { fn construct(&self); fn destructor(&self) { diff --git a/tests/std/class/class.mem/class.ctor/out/refcount/class.copy.ctor.rs b/tests/std/class/class.mem/class.ctor/out/refcount/class.copy.ctor.rs index 6bc5af0de4..4a2c5bcd44 100644 --- a/tests/std/class/class.mem/class.ctor/out/refcount/class.copy.ctor.rs +++ b/tests/std/class/class.mem/class.ctor/out/refcount/class.copy.ctor.rs @@ -13,6 +13,14 @@ pub struct p11_defaulted_move_constructor_is_trivial_MoveOnly { #[offset(0)] pub value: i32, } +impl MoveConstructible for p11_defaulted_move_constructor_is_trivial_MoveOnly { + fn move_constructor( + this: &Ptr, + _a0: Ptr, + ) { + field!((*this), value).write({ (*_a0.upgrade().deref()).value }); + } +} pub fn pass_0( object: p11_defaulted_move_constructor_is_trivial_MoveOnly, ) -> p11_defaulted_move_constructor_is_trivial_MoveOnly { @@ -76,12 +84,4 @@ impl p11_defaulted_move_constructor_is_trivial_MoveOnlyImpl field!((*self), value).write(value); } } -impl MoveConstructible for p11_defaulted_move_constructor_is_trivial_MoveOnly { - fn move_constructor( - this: &Ptr, - _a0: Ptr, - ) { - field!((*this), value).write({ (*_a0.upgrade().deref()).value }); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/std/expr/expr.compound/out/refcount/expr.mptr.oper.rs b/tests/std/expr/expr.compound/out/refcount/expr.mptr.oper.rs index 77ad11a71c..d5632635c8 100644 --- a/tests/std/expr/expr.compound/out/refcount/expr.mptr.oper.rs +++ b/tests/std/expr/expr.compound/out/refcount/expr.mptr.oper.rs @@ -142,6 +142,22 @@ thread_local!( )] #[byte_size(1)] pub struct p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves {} +impl CopyConstructible for p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves { + fn copy_constructor( + this: &Ptr, + _a0: Ptr, + ) { + (*copyCount_9.with(Value::clone).borrow_mut()).prefix_inc(); + } +} +impl MoveConstructible for p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves { + fn move_constructor( + this: &Ptr, + _a0: Ptr, + ) { + (*moveCount_10.with(Value::clone).borrow_mut()).prefix_inc(); + } +} impl Clone for p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves { fn clone(&self) -> Self { let __src: Value = Rc::new( @@ -172,6 +188,21 @@ pub struct p6_data_member_of_rvalue_is_xvalue_HoldsCounted { #[byte_size(1)] pub member: p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves, } +impl MoveConstructible for p6_data_member_of_rvalue_is_xvalue_HoldsCounted { + fn move_constructor( + this: &Ptr, + _a0: Ptr, + ) { + field!((*this), member).write({ + let __v: Value = + Rc::new(RefCell::new( + ::zero_init(), + )); + MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, member) }); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }); + } +} pub fn test_11() { let mut pm: isize = (offset_of_field!(p6_data_member_of_rvalue_is_xvalue_HoldsCounted, member) as isize); @@ -214,37 +245,6 @@ fn main_0() -> i32 { ({ test_11() }); return 0; } -impl CopyConstructible for p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves { - fn copy_constructor( - this: &Ptr, - _a0: Ptr, - ) { - (*copyCount_9.with(Value::clone).borrow_mut()).prefix_inc(); - } -} -impl MoveConstructible for p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves { - fn move_constructor( - this: &Ptr, - _a0: Ptr, - ) { - (*moveCount_10.with(Value::clone).borrow_mut()).prefix_inc(); - } -} -impl MoveConstructible for p6_data_member_of_rvalue_is_xvalue_HoldsCounted { - fn move_constructor( - this: &Ptr, - _a0: Ptr, - ) { - field!((*this), member).write({ - let __v: Value = - Rc::new(RefCell::new( - ::zero_init(), - )); - MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, member) }); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }); - } -} pub fn __cpp2rust_init_globals() { let _ = sequence_1.with(|_| ()); let _ = object_stamp_2.with(|_| ()); diff --git a/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.if.rs b/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.if.rs index c473ce277b..32a097febb 100644 --- a/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.if.rs +++ b/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.if.rs @@ -53,6 +53,18 @@ impl LifetimeTracked { }); } } +impl CopyConstructible for LifetimeTracked { + fn copy_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), uses).write(0); + (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); + } +} +impl CopyAssignable for LifetimeTracked { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), uses).write(_a0.with(|__s| __s.uses)); + return (*this).clone(); + } +} impl Clone for LifetimeTracked { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(LifetimeTracked { @@ -227,18 +239,6 @@ impl LifetimeTrackedImpl for Ptr { (*useCount_3.with(Value::clone).borrow_mut()).prefix_inc(); } } -impl CopyAssignable for LifetimeTracked { - fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), uses).write(_a0.with(|__s| __s.uses)); - return (*this).clone(); - } -} -impl CopyConstructible for LifetimeTracked { - fn copy_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), uses).write(0); - (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); - } -} pub fn __cpp2rust_init_globals() { let _ = ctorCount_0.with(|_| ()); let _ = copyCount_1.with(|_| ()); diff --git a/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs b/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs index a83fe0b984..3253db599e 100644 --- a/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs +++ b/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs @@ -53,6 +53,18 @@ impl LifetimeTracked { }); } } +impl CopyConstructible for LifetimeTracked { + fn copy_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), uses).write(0); + (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); + } +} +impl CopyAssignable for LifetimeTracked { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), uses).write(_a0.with(|__s| __s.uses)); + return (*this).clone(); + } +} impl Clone for LifetimeTracked { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(LifetimeTracked { @@ -246,18 +258,6 @@ impl LifetimeTrackedImpl for Ptr { (*useCount_3.with(Value::clone).borrow_mut()).prefix_inc(); } } -impl CopyAssignable for LifetimeTracked { - fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), uses).write(_a0.with(|__s| __s.uses)); - return (*this).clone(); - } -} -impl CopyConstructible for LifetimeTracked { - fn copy_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), uses).write(0); - (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); - } -} pub trait p2_condition_variable_lives_for_whole_statement_ConvertsToIntImpl { fn to_i32(&self) -> i32; fn destructor(&self); diff --git a/tests/std/temp/temp.spec/out/refcount/temp.inst.rs b/tests/std/temp/temp.spec/out/refcount/temp.inst.rs index 94b9dfee9a..94fff10295 100644 --- a/tests/std/temp/temp.spec/out/refcount/temp.inst.rs +++ b/tests/std/temp/temp.spec/out/refcount/temp.inst.rs @@ -36,6 +36,11 @@ pub struct p2_reference_does_not_instantiate_Holder { #[byte_size(4)] pub member: p2_reference_does_not_instantiate_Member, } +impl MoveConstructible for p2_reference_does_not_instantiate_Holder { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), member).write({ (*_a0.upgrade().deref()).member }); + } +} pub fn test_0() { let mut holder: p2_reference_does_not_instantiate_Holder = ::default(); @@ -54,11 +59,6 @@ fn main_0() -> i32 { #[derive(Clone, Copy, Default, ByteRepr, VaArg, FnPtrArg)] #[byte_size(1)] pub struct p2_reference_does_not_instantiate_Wrapper_int_; -impl MoveConstructible for p2_reference_does_not_instantiate_Holder { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), member).write({ (*_a0.upgrade().deref()).member }); - } -} pub trait p2_reference_does_not_instantiate_MemberImpl { fn construct_1(&self, _a0: Ptr); } diff --git a/tests/std/utilities/utility/out/refcount/forward-helpers.rs b/tests/std/utilities/utility/out/refcount/forward-helpers.rs index 3433246354..548fe4723f 100644 --- a/tests/std/utilities/utility/out/refcount/forward-helpers.rs +++ b/tests/std/utilities/utility/out/refcount/forward-helpers.rs @@ -31,6 +31,17 @@ pub struct p6_forward_like_Movable { #[offset(0)] pub value: i32, } +impl CopyConstructible for p6_forward_like_Movable { + fn copy_constructor(this: &Ptr, other: Ptr) { + field!((*this), value).write(other.with(|__s| __s.value)); + } +} +impl MoveConstructible for p6_forward_like_Movable { + fn move_constructor(this: &Ptr, other: Ptr) { + field!((*this), value).write(other.with(|__s| __s.value)); + field!(other, value).write(0); + } +} impl Clone for p6_forward_like_Movable { fn clone(&self) -> Self { let __src: Value = @@ -60,6 +71,16 @@ pub struct p6_forward_like_Holder { #[byte_size(4)] pub member: p6_forward_like_Movable, } +impl MoveConstructible for p6_forward_like_Holder { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), member).write({ + let __v: Value = + Rc::new(RefCell::new(::zero_init())); + MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, member) }); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }); + } +} impl Default for p6_forward_like_Holder { fn default() -> Self { { @@ -105,6 +126,12 @@ pub struct p9_move_Movable { #[offset(0)] pub value: i32, } +impl MoveConstructible for p9_move_Movable { + fn move_constructor(this: &Ptr, other: Ptr) { + field!((*this), value).write(other.with(|__s| __s.value)); + field!(other, value).write(0); + } +} pub fn test_4() { let mut number: i32 = 1; let mut moved: i32 = number; @@ -162,6 +189,21 @@ pub struct p10_forward_in_template_A { #[offset(8)] pub moves: i32, } +impl CopyConstructible for p10_forward_in_template_A { + fn copy_constructor(this: &Ptr, other: Ptr) { + field!((*this), value).write(other.with(|__s| __s.value)); + field!((*this), copies).write((other.with(|__s| __s.copies) + 1)); + field!((*this), moves).write(0); + } +} +impl MoveConstructible for p10_forward_in_template_A { + fn move_constructor(this: &Ptr, other: Ptr) { + field!((*this), value).write(other.with(|__s| __s.value)); + field!((*this), copies).write(0); + field!((*this), moves).write((other.with(|__s| __s.moves) + 1)); + field!(other, value).write(0); + } +} impl Clone for p10_forward_in_template_A { fn clone(&self) -> Self { let __src: Value = @@ -228,6 +270,17 @@ pub struct p11_move_if_noexcept_NoexceptMove { #[offset(0)] pub value: i32, } +impl CopyConstructible for p11_move_if_noexcept_NoexceptMove { + fn copy_constructor(this: &Ptr, other: Ptr) { + field!((*this), value).write(other.with(|__s| __s.value)); + } +} +impl MoveConstructible for p11_move_if_noexcept_NoexceptMove { + fn move_constructor(this: &Ptr, other: Ptr) { + field!((*this), value).write(other.with(|__s| __s.value)); + field!(other, value).write(0); + } +} impl Clone for p11_move_if_noexcept_NoexceptMove { fn clone(&self) -> Self { let __src: Value = @@ -258,6 +311,17 @@ pub struct p11_move_if_noexcept_ThrowingMove { #[offset(0)] pub value: i32, } +impl CopyConstructible for p11_move_if_noexcept_ThrowingMove { + fn copy_constructor(this: &Ptr, other: Ptr) { + field!((*this), value).write(other.with(|__s| __s.value)); + } +} +impl MoveConstructible for p11_move_if_noexcept_ThrowingMove { + fn move_constructor(this: &Ptr, other: Ptr) { + field!((*this), value).write(other.with(|__s| __s.value)); + field!(other, value).write(0); + } +} impl Clone for p11_move_if_noexcept_ThrowingMove { fn clone(&self) -> Self { let __src: Value = @@ -325,21 +389,6 @@ impl p10_forward_in_template_AImpl for Ptr { field!((*self), moves).write(0); } } -impl CopyConstructible for p10_forward_in_template_A { - fn copy_constructor(this: &Ptr, other: Ptr) { - field!((*this), value).write(other.with(|__s| __s.value)); - field!((*this), copies).write((other.with(|__s| __s.copies) + 1)); - field!((*this), moves).write(0); - } -} -impl MoveConstructible for p10_forward_in_template_A { - fn move_constructor(this: &Ptr, other: Ptr) { - field!((*this), value).write(other.with(|__s| __s.value)); - field!((*this), copies).write(0); - field!((*this), moves).write((other.with(|__s| __s.moves) + 1)); - field!(other, value).write(0); - } -} pub trait p11_move_if_noexcept_NoexceptMoveImpl { fn construct(&self, value: i32); } @@ -348,17 +397,6 @@ impl p11_move_if_noexcept_NoexceptMoveImpl for Ptr, other: Ptr) { - field!((*this), value).write(other.with(|__s| __s.value)); - } -} -impl MoveConstructible for p11_move_if_noexcept_NoexceptMove { - fn move_constructor(this: &Ptr, other: Ptr) { - field!((*this), value).write(other.with(|__s| __s.value)); - field!(other, value).write(0); - } -} pub trait p11_move_if_noexcept_ThrowingMoveImpl { fn construct(&self, value: i32); } @@ -367,27 +405,6 @@ impl p11_move_if_noexcept_ThrowingMoveImpl for Ptr, other: Ptr) { - field!((*this), value).write(other.with(|__s| __s.value)); - } -} -impl MoveConstructible for p11_move_if_noexcept_ThrowingMove { - fn move_constructor(this: &Ptr, other: Ptr) { - field!((*this), value).write(other.with(|__s| __s.value)); - field!(other, value).write(0); - } -} -impl MoveConstructible for p6_forward_like_Holder { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), member).write({ - let __v: Value = - Rc::new(RefCell::new(::zero_init())); - MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, member) }); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }); - } -} pub trait p6_forward_like_MovableImpl { fn construct(&self, value: i32); } @@ -396,17 +413,6 @@ impl p6_forward_like_MovableImpl for Ptr { field!((*self), value).write(value); } } -impl CopyConstructible for p6_forward_like_Movable { - fn copy_constructor(this: &Ptr, other: Ptr) { - field!((*this), value).write(other.with(|__s| __s.value)); - } -} -impl MoveConstructible for p6_forward_like_Movable { - fn move_constructor(this: &Ptr, other: Ptr) { - field!((*this), value).write(other.with(|__s| __s.value)); - field!(other, value).write(0); - } -} pub trait p9_move_MovableImpl { fn construct(&self, value: i32); } @@ -415,10 +421,4 @@ impl p9_move_MovableImpl for Ptr { field!((*self), value).write(value); } } -impl MoveConstructible for p9_move_Movable { - fn move_constructor(this: &Ptr, other: Ptr) { - field!((*this), value).write(other.with(|__s| __s.value)); - field!(other, value).write(0); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/std/utilities/utility/out/refcount/forward.rs b/tests/std/utilities/utility/out/refcount/forward.rs index 97f0a0c4e7..09009aa3e1 100644 --- a/tests/std/utilities/utility/out/refcount/forward.rs +++ b/tests/std/utilities/utility/out/refcount/forward.rs @@ -63,6 +63,12 @@ pub struct p10_move_constructor_A { #[offset(0)] pub value: i32, } +impl MoveConstructible for p10_move_constructor_A { + fn move_constructor(this: &Ptr, other: Ptr) { + field!((*this), value).write(other.with(|__s| __s.value)); + field!(other, value).write(0); + } +} pub fn test_2() { let source: Value = Rc::new(RefCell::new({ let __v: Value = @@ -115,10 +121,4 @@ impl p10_move_constructor_AImpl for Ptr { field!((*self), value).write(value); } } -impl MoveConstructible for p10_move_constructor_A { - fn move_constructor(this: &Ptr, other: Ptr) { - field!((*this), value).write(other.with(|__s| __s.value)); - field!(other, value).write(0); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/array_of_noncopy_struct.rs b/tests/unit/out/refcount/array_of_noncopy_struct.rs index 4eab804d63..2209aae2d9 100644 --- a/tests/unit/out/refcount/array_of_noncopy_struct.rs +++ b/tests/unit/out/refcount/array_of_noncopy_struct.rs @@ -17,6 +17,21 @@ pub struct NonCopy { #[offset(24)] pub tag: i32, } +impl MoveConstructible for NonCopy { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), data).write(field!(_a0, data).with_mut(std::mem::take)); + field!((*this), tag).write({ (*_a0.upgrade().deref()).tag }); + } +} +impl MoveAssignable for NonCopy { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), data).with_mut(|__b0| { + (*__b0) = field!(_a0, data).with_mut(std::mem::take); + }); + field!((*this), tag).write({ (*_a0.upgrade().deref()).tag }); + return (*this).clone(); + } +} impl Default for NonCopy { fn default() -> Self { { @@ -45,19 +60,4 @@ fn main_0() -> i32 { assert!((arr[(2) as usize].data.len() == 0_usize)); return 0; } -impl MoveAssignable for NonCopy { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), data).with_mut(|__b0| { - (*__b0) = field!(_a0, data).with_mut(std::mem::take); - }); - field!((*this), tag).write({ (*_a0.upgrade().deref()).tag }); - return (*this).clone(); - } -} -impl MoveConstructible for NonCopy { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), data).write(field!(_a0, data).with_mut(std::mem::take)); - field!((*this), tag).write({ (*_a0.upgrade().deref()).tag }); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/assignment_single_eval.rs b/tests/unit/out/refcount/assignment_single_eval.rs index 2380a44db3..0f913bb7e9 100644 --- a/tests/unit/out/refcount/assignment_single_eval.rs +++ b/tests/unit/out/refcount/assignment_single_eval.rs @@ -2358,6 +2358,19 @@ pub struct Counts_59 { #[byte_size(24)] pub counts: Vec, } +impl MoveConstructible for Counts_59 { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), counts).write(field!(_a0, counts).with_mut(std::mem::take)); + } +} +impl MoveAssignable for Counts_59 { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), counts).with_mut(|__b0| { + (*__b0) = field!(_a0, counts).with_mut(std::mem::take); + }); + return (*this).clone(); + } +} #[derive( Copy, Clone, @@ -2732,19 +2745,6 @@ impl Default for Owner_63 { } } } -impl MoveAssignable for Counts_59 { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), counts).with_mut(|__b0| { - (*__b0) = field!(_a0, counts).with_mut(std::mem::take); - }); - return (*this).clone(); - } -} -impl MoveConstructible for Counts_59 { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), counts).write(field!(_a0, counts).with_mut(std::mem::take)); - } -} pub trait IndexedBindingImpl { fn get_1_0(&self) -> Ptr; } diff --git a/tests/unit/out/refcount/cast.rs b/tests/unit/out/refcount/cast.rs index d828894cc8..9b64cc288d 100644 --- a/tests/unit/out/refcount/cast.rs +++ b/tests/unit/out/refcount/cast.rs @@ -108,6 +108,21 @@ pub struct Bag { #[byte_size(24)] pub items: Vec, } +impl MoveConstructible for Bag { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), n).write({ (*_a0.upgrade().deref()).n }); + field!((*this), items).write(field!(_a0, items).with_mut(std::mem::take)); + } +} +impl MoveAssignable for Bag { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), n).write({ (*_a0.upgrade().deref()).n }); + field!((*this), items).with_mut(|__b0| { + (*__b0) = field!(_a0, items).with_mut(std::mem::take); + }); + return (*this).clone(); + } +} pub fn adjacent_arrays_0() { let a: Value> = Rc::new(RefCell::new(Box::new([1, 2, 3, 4]))); let b: Value> = Rc::new(RefCell::new(Box::new([5, 6, 7, 8]))); @@ -561,19 +576,4 @@ fn main_0() -> i32 { ({ bool_to_floating_10() }); return 0; } -impl MoveAssignable for Bag { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), n).write({ (*_a0.upgrade().deref()).n }); - field!((*this), items).with_mut(|__b0| { - (*__b0) = field!(_a0, items).with_mut(std::mem::take); - }); - return (*this).clone(); - } -} -impl MoveConstructible for Bag { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), n).write({ (*_a0.upgrade().deref()).n }); - field!((*this), items).write(field!(_a0, items).with_mut(std::mem::take)); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/class_templates.rs b/tests/unit/out/refcount/class_templates.rs index f28b39244f..a836ca815e 100644 --- a/tests/unit/out/refcount/class_templates.rs +++ b/tests/unit/out/refcount/class_templates.rs @@ -23,6 +23,19 @@ pub struct MyContainer_int_ { #[byte_size(24)] vec_: Vec, } +impl MoveConstructible for MyContainer_int_ { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), vec_).write(field!(_a0, vec_).with_mut(std::mem::take)); + } +} +impl MoveAssignable for MyContainer_int_ { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), vec_).with_mut(|__b0| { + (*__b0) = field!(_a0, vec_).with_mut(std::mem::take); + }); + return (*this).clone(); + } +} #[derive( Clone, Record, @@ -40,6 +53,19 @@ pub struct MyContainer_char_ { #[byte_size(24)] vec_: Vec, } +impl MoveConstructible for MyContainer_char_ { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), vec_).write(field!(_a0, vec_).with_mut(std::mem::take)); + } +} +impl MoveAssignable for MyContainer_char_ { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), vec_).with_mut(|__b0| { + (*__b0) = field!(_a0, vec_).with_mut(std::mem::take); + }); + return (*this).clone(); + } +} #[derive( Clone, Record, @@ -57,6 +83,19 @@ pub struct MyContainer_float_ { #[byte_size(24)] vec_: Vec, } +impl MoveConstructible for MyContainer_float_ { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), vec_).write(field!(_a0, vec_).with_mut(std::mem::take)); + } +} +impl MoveAssignable for MyContainer_float_ { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), vec_).with_mut(|__b0| { + (*__b0) = field!(_a0, vec_).with_mut(std::mem::take); + }); + return (*this).clone(); + } +} #[derive( Copy, Clone, @@ -394,19 +433,6 @@ impl MyContainer_char_Impl for Ptr { }; } } -impl MoveAssignable for MyContainer_char_ { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), vec_).with_mut(|__b0| { - (*__b0) = field!(_a0, vec_).with_mut(std::mem::take); - }); - return (*this).clone(); - } -} -impl MoveConstructible for MyContainer_char_ { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), vec_).write(field!(_a0, vec_).with_mut(std::mem::take)); - } -} pub trait MyContainer_float_Impl { fn empty(&self) -> bool; fn size(&self) -> usize; @@ -441,19 +467,6 @@ impl MyContainer_float_Impl for Ptr { }; } } -impl MoveAssignable for MyContainer_float_ { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), vec_).with_mut(|__b0| { - (*__b0) = field!(_a0, vec_).with_mut(std::mem::take); - }); - return (*this).clone(); - } -} -impl MoveConstructible for MyContainer_float_ { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), vec_).write(field!(_a0, vec_).with_mut(std::mem::take)); - } -} pub trait MyContainer_int_Impl { fn empty(&self) -> bool; fn size(&self) -> usize; @@ -488,19 +501,6 @@ impl MyContainer_int_Impl for Ptr { }; } } -impl MoveAssignable for MyContainer_int_ { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), vec_).with_mut(|__b0| { - (*__b0) = field!(_a0, vec_).with_mut(std::mem::take); - }); - return (*this).clone(); - } -} -impl MoveConstructible for MyContainer_int_ { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), vec_).write(field!(_a0, vec_).with_mut(std::mem::take)); - } -} pub trait Outer_int_Impl { fn with(&self, n: i32) -> Outer_int__Inner_int_; } diff --git a/tests/unit/out/refcount/container_element_receiver.rs b/tests/unit/out/refcount/container_element_receiver.rs index 85f38d7d25..8bbd973b9f 100644 --- a/tests/unit/out/refcount/container_element_receiver.rs +++ b/tests/unit/out/refcount/container_element_receiver.rs @@ -27,6 +27,12 @@ pub struct Holder { #[byte_size(24)] pub vec_: Vec, } +impl MoveConstructible for Holder { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), ref_).write(({ (*_a0.upgrade().deref()).ref_.clone() }).clone()); + field!((*this), vec_).write(field!(_a0, vec_).with_mut(std::mem::take)); + } +} pub fn pick_0(a: Ptr>, b: Ptr>, mut first: bool) -> Ptr> { return if first { (a).clone() } else { (b).clone() }; } @@ -143,10 +149,4 @@ fn main_0() -> i32 { assert!((({ sum_1(v.as_pointer(),) }) == 7)); return 0; } -impl MoveConstructible for Holder { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), ref_).write(({ (*_a0.upgrade().deref()).ref_.clone() }).clone()); - field!((*this), vec_).write(field!(_a0, vec_).with_mut(std::mem::take)); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/container_field_addr.rs b/tests/unit/out/refcount/container_field_addr.rs index 028f3422af..2967e9456e 100644 --- a/tests/unit/out/refcount/container_field_addr.rs +++ b/tests/unit/out/refcount/container_field_addr.rs @@ -25,6 +25,21 @@ pub struct S { #[byte_size(24)] pub v: Vec, } +impl MoveConstructible for S { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), tag).write({ (*_a0.upgrade().deref()).tag }); + field!((*this), v).write(field!(_a0, v).with_mut(std::mem::take)); + } +} +impl MoveAssignable for S { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), tag).write({ (*_a0.upgrade().deref()).tag }); + field!((*this), v).with_mut(|__b0| { + (*__b0) = field!(_a0, v).with_mut(std::mem::take); + }); + return (*this).clone(); + } +} pub fn add_0(mut v: Ptr>, mut k: i32) { { let a0_clone = k.clone(); @@ -61,19 +76,4 @@ fn main_0() -> i32 { heap.delete(); return 0; } -impl MoveAssignable for S { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), tag).write({ (*_a0.upgrade().deref()).tag }); - field!((*this), v).with_mut(|__b0| { - (*__b0) = field!(_a0, v).with_mut(std::mem::take); - }); - return (*this).clone(); - } -} -impl MoveConstructible for S { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), tag).write({ (*_a0.upgrade().deref()).tag }); - field!((*this), v).write(field!(_a0, v).with_mut(std::mem::take)); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/copy_assign.rs b/tests/unit/out/refcount/copy_assign.rs index e061f71757..71aece74fc 100644 --- a/tests/unit/out/refcount/copy_assign.rs +++ b/tests/unit/out/refcount/copy_assign.rs @@ -26,6 +26,22 @@ pub struct Partial { #[offset(4)] pub keep: i32, } +impl CopyConstructible for Partial { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + field!((*this), keep).write(o.with(|__s| __s.keep)); + } +} +impl CopyAssignable for Partial { + fn copy_assign(this: &Ptr, o: Ptr) -> Ptr { + if ((*this) == (o)) { + return (*this).clone(); + } + field!((*this), v).write(o.with(|__s| __s.v)); + (*assigns_0.with(Value::clone).borrow_mut()).prefix_inc(); + return (*this).clone(); + } +} impl Clone for Partial { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(Partial { @@ -84,6 +100,12 @@ pub struct RefQualified { #[offset(0)] pub mark: i32, } +impl CopyAssignable for RefQualified { + fn copy_assign(this: &Ptr, o: Ptr) -> Ptr { + field!((*this), mark).write((o.with(|__s| __s.mark) + 1)); + return (*this).clone(); + } +} impl Default for RefQualified { fn default() -> Self { { @@ -116,6 +138,26 @@ pub struct Holder { #[array_len(2)] pub arr: Box<[Partial]>, } +impl CopyAssignable for Holder { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + ({ CopyAssignable::copy_assign(&field_ptr!((*this), p), field_ptr!(_a0, p)) }); + { + let mut __i0: usize = 0_usize; + 'loop_: while (__i0 != 2_usize) { + 'for_body: { + ({ + CopyAssignable::copy_assign( + &array_field_ptr!((*this), arr).offset((__i0) as isize), + array_field_ptr!(_a0, arr).offset((__i0) as isize), + ) + }); + } + __i0.prefix_inc(); + } + } + return (*this).clone(); + } +} impl Default for Holder { fn default() -> Self { { @@ -148,6 +190,18 @@ pub struct CopyCounted { #[offset(0)] pub v: i32, } +impl CopyConstructible for CopyCounted { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + (*copies_1.with(Value::clone).borrow_mut()).prefix_inc(); + } +} +impl CopyAssignable for CopyCounted { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), v).write(_a0.with(|__s| __s.v)); + return (*this).clone(); + } +} impl Clone for CopyCounted { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(CopyCounted { v: self.v.clone() })); @@ -177,6 +231,17 @@ pub struct HasCopyCounted { #[array_len(2)] pub arr: Box<[CopyCounted]>, } +impl CopyAssignable for HasCopyCounted { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + ({ CopyAssignable::copy_assign(&field_ptr!((*this), c), field_ptr!(_a0, c)) }); + { + let mut __tmp_0 = { (array_field_ptr!((*this), arr)).to_any() }; + __tmp_0.memcpy(&(array_field_ptr!(_a0, arr)).to_any(), 8_usize); + (__tmp_0).clone() + }; + return (*this).clone(); + } +} impl Default for HasCopyCounted { fn default() -> Self { { @@ -400,49 +465,6 @@ impl CopyCountedImpl for Ptr { field!((*self), v).write(v); } } -impl CopyAssignable for CopyCounted { - fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), v).write(_a0.with(|__s| __s.v)); - return (*this).clone(); - } -} -impl CopyConstructible for CopyCounted { - fn copy_constructor(this: &Ptr, o: Ptr) { - field!((*this), v).write(o.with(|__s| __s.v)); - (*copies_1.with(Value::clone).borrow_mut()).prefix_inc(); - } -} -impl CopyAssignable for HasCopyCounted { - fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { - ({ CopyAssignable::copy_assign(&field_ptr!((*this), c), field_ptr!(_a0, c)) }); - { - let mut __tmp_0 = { (array_field_ptr!((*this), arr)).to_any() }; - __tmp_0.memcpy(&(array_field_ptr!(_a0, arr)).to_any(), 8_usize); - (__tmp_0).clone() - }; - return (*this).clone(); - } -} -impl CopyAssignable for Holder { - fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { - ({ CopyAssignable::copy_assign(&field_ptr!((*this), p), field_ptr!(_a0, p)) }); - { - let mut __i0: usize = 0_usize; - 'loop_: while (__i0 != 2_usize) { - 'for_body: { - ({ - CopyAssignable::copy_assign( - &array_field_ptr!((*this), arr).offset((__i0) as isize), - array_field_ptr!(_a0, arr).offset((__i0) as isize), - ) - }); - } - __i0.prefix_inc(); - } - } - return (*this).clone(); - } -} pub trait NonConstAssignImpl { fn construct(&self); fn operator_assign_2(&self, o: Ptr) -> Ptr; @@ -470,22 +492,6 @@ impl PartialImpl for Ptr { field!((*self), keep).write(keep); } } -impl CopyAssignable for Partial { - fn copy_assign(this: &Ptr, o: Ptr) -> Ptr { - if ((*this) == (o)) { - return (*this).clone(); - } - field!((*this), v).write(o.with(|__s| __s.v)); - (*assigns_0.with(Value::clone).borrow_mut()).prefix_inc(); - return (*this).clone(); - } -} -impl CopyConstructible for Partial { - fn copy_constructor(this: &Ptr, o: Ptr) { - field!((*this), v).write(o.with(|__s| __s.v)); - field!((*this), keep).write(o.with(|__s| __s.keep)); - } -} pub trait RefQualifiedImpl { fn construct(&self); } @@ -494,12 +500,6 @@ impl RefQualifiedImpl for Ptr { field!((*self), mark).write(0); } } -impl CopyAssignable for RefQualified { - fn copy_assign(this: &Ptr, o: Ptr) -> Ptr { - field!((*this), mark).write((o.with(|__s| __s.mark) + 1)); - return (*this).clone(); - } -} pub fn __cpp2rust_init_globals() { let _ = assigns_0.with(|_| ()); let _ = copies_1.with(|_| ()); diff --git a/tests/unit/out/refcount/copy_ctor.rs b/tests/unit/out/refcount/copy_ctor.rs index b84b15b1e1..936178be85 100644 --- a/tests/unit/out/refcount/copy_ctor.rs +++ b/tests/unit/out/refcount/copy_ctor.rs @@ -26,6 +26,18 @@ pub struct Counted { #[offset(0)] pub v: i32, } +impl CopyConstructible for Counted { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); + } +} +impl CopyAssignable for Counted { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), v).write(_a0.with(|__s| __s.v)); + return (*this).clone(); + } +} impl Clone for Counted { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(Counted { v: self.v.clone() })); @@ -49,6 +61,12 @@ pub struct NonConst { #[offset(0)] pub mark: i32, } +impl CopyAssignable for NonConst { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), mark).write(_a0.with(|__s| __s.mark)); + return (*this).clone(); + } +} impl Clone for NonConst { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(NonConst { @@ -87,6 +105,18 @@ pub struct Ignored { #[offset(0)] pub v: i32, } +impl CopyConstructible for Ignored { + fn copy_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), v).write(-1_i32); + (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); + } +} +impl CopyAssignable for Ignored { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), v).write(_a0.with(|__s| __s.v)); + return (*this).clone(); + } +} impl Clone for Ignored { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(Ignored { v: self.v.clone() })); @@ -116,6 +146,17 @@ pub struct Holder { #[array_len(2)] pub arr: Box<[Counted]>, } +impl CopyAssignable for Holder { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + ({ CopyAssignable::copy_assign(&field_ptr!((*this), c), field_ptr!(_a0, c)) }); + { + let mut __tmp_0 = { (array_field_ptr!((*this), arr)).to_any() }; + __tmp_0.memcpy(&(array_field_ptr!(_a0, arr)).to_any(), 8_usize); + (__tmp_0).clone() + }; + return (*this).clone(); + } +} impl Default for Holder { fn default() -> Self { { @@ -145,6 +186,16 @@ pub struct Box_int_ { #[offset(0)] pub val: i32, } +impl CopyConstructible for Box_int_ { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), val).write(o.with(|__s| __s.val)); + } +} +impl MoveConstructible for Box_int_ { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), val).write({ (*_a0.upgrade().deref()).val }); + } +} impl Clone for Box_int_ { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(Box_int_ { @@ -173,6 +224,15 @@ pub struct Owner { #[byte_size(4)] pub box_: Box_int_, } +impl MoveConstructible for Owner { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), box_).write({ + let __v: Value = Rc::new(RefCell::new(::zero_init())); + MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, box_) }); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }); + } +} #[derive( Record, ByteRepr, @@ -190,6 +250,18 @@ pub struct OutOfLine { #[offset(0)] pub v: i32, } +impl CopyConstructible for OutOfLine { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write((o.with(|__s| __s.v) + 100)); + (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); + } +} +impl CopyAssignable for OutOfLine { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), v).write(_a0.with(|__s| __s.v)); + return (*this).clone(); + } +} impl Clone for OutOfLine { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(OutOfLine { v: self.v.clone() })); @@ -206,6 +278,22 @@ pub struct Tracked { #[offset(0)] pub copied_from: i32, } +impl CopyConstructible for Tracked { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), copied_from).write(0); + field!(o, copied_from).with_mut(|__v| { + __v.prefix_inc(); + }); + } +} +impl CopyAssignable for Tracked { + fn copy_assign(this: &Ptr, o: Ptr) -> Ptr { + field!(o, copied_from).with_mut(|__v| { + __v.prefix_inc(); + }); + return (*this).clone(); + } +} impl Clone for Tracked { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(Tracked { @@ -416,16 +504,6 @@ impl Box_int_Impl for Ptr { field!((*self), val).write(v); } } -impl CopyConstructible for Box_int_ { - fn copy_constructor(this: &Ptr, o: Ptr) { - field!((*this), val).write(o.with(|__s| __s.val)); - } -} -impl MoveConstructible for Box_int_ { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), val).write({ (*_a0.upgrade().deref()).val }); - } -} pub trait CountedImpl { fn construct(&self, v: i32); } @@ -434,29 +512,6 @@ impl CountedImpl for Ptr { field!((*self), v).write(v); } } -impl CopyAssignable for Counted { - fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), v).write(_a0.with(|__s| __s.v)); - return (*this).clone(); - } -} -impl CopyConstructible for Counted { - fn copy_constructor(this: &Ptr, o: Ptr) { - field!((*this), v).write(o.with(|__s| __s.v)); - (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); - } -} -impl CopyAssignable for Holder { - fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { - ({ CopyAssignable::copy_assign(&field_ptr!((*this), c), field_ptr!(_a0, c)) }); - { - let mut __tmp_0 = { (array_field_ptr!((*this), arr)).to_any() }; - __tmp_0.memcpy(&(array_field_ptr!(_a0, arr)).to_any(), 8_usize); - (__tmp_0).clone() - }; - return (*this).clone(); - } -} pub trait IgnoredImpl { fn construct(&self, v: i32); } @@ -465,18 +520,6 @@ impl IgnoredImpl for Ptr { field!((*self), v).write(v); } } -impl CopyAssignable for Ignored { - fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), v).write(_a0.with(|__s| __s.v)); - return (*this).clone(); - } -} -impl CopyConstructible for Ignored { - fn copy_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), v).write(-1_i32); - (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); - } -} pub trait NonConstImpl { fn construct(&self); fn construct_1(&self, o: Ptr); @@ -493,12 +536,6 @@ impl NonConstImpl for Ptr { field!((*self), mark).write((o.with(|__s| __s.mark) + 10)); } } -impl CopyAssignable for NonConst { - fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), mark).write(_a0.with(|__s| __s.mark)); - return (*this).clone(); - } -} pub trait OutOfLineImpl { fn construct(&self, v: i32); } @@ -507,43 +544,6 @@ impl OutOfLineImpl for Ptr { field!((*self), v).write(v); } } -impl CopyAssignable for OutOfLine { - fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), v).write(_a0.with(|__s| __s.v)); - return (*this).clone(); - } -} -impl CopyConstructible for OutOfLine { - fn copy_constructor(this: &Ptr, o: Ptr) { - field!((*this), v).write((o.with(|__s| __s.v) + 100)); - (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); - } -} -impl MoveConstructible for Owner { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), box_).write({ - let __v: Value = Rc::new(RefCell::new(::zero_init())); - MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, box_) }); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }); - } -} -impl CopyAssignable for Tracked { - fn copy_assign(this: &Ptr, o: Ptr) -> Ptr { - field!(o, copied_from).with_mut(|__v| { - __v.prefix_inc(); - }); - return (*this).clone(); - } -} -impl CopyConstructible for Tracked { - fn copy_constructor(this: &Ptr, o: Ptr) { - field!((*this), copied_from).write(0); - field!(o, copied_from).with_mut(|__v| { - __v.prefix_inc(); - }); - } -} pub fn __cpp2rust_init_globals() { let _ = copies_0.with(|_| ()); } diff --git a/tests/unit/out/refcount/copy_move_defaulted.rs b/tests/unit/out/refcount/copy_move_defaulted.rs index a65f5bc724..f54c3bad76 100644 --- a/tests/unit/out/refcount/copy_move_defaulted.rs +++ b/tests/unit/out/refcount/copy_move_defaulted.rs @@ -108,6 +108,19 @@ pub struct DefaultCopyUserMove { #[offset(0)] pub v: i32, } +impl MoveConstructible for DefaultCopyUserMove { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + field!(o, v).write(0); + } +} +impl MoveAssignable for DefaultCopyUserMove { + fn move_assign(this: &Ptr, o: Ptr) -> Ptr { + field!((*this), v).write(o.with(|__s| __s.v)); + field!(o, v).write(0); + return (*this).clone(); + } +} #[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Default)] #[cpp_from(i32, construct, value)] #[byte_size(4)] @@ -115,6 +128,28 @@ pub struct UserCopyDefaultMove { #[offset(0)] pub v: i32, } +impl CopyConstructible for UserCopyDefaultMove { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write((o.with(|__s| __s.v) + 100)); + } +} +impl MoveConstructible for UserCopyDefaultMove { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), v).write({ (*_a0.upgrade().deref()).v }); + } +} +impl CopyAssignable for UserCopyDefaultMove { + fn copy_assign(this: &Ptr, o: Ptr) -> Ptr { + field!((*this), v).write((o.with(|__s| __s.v) + 100)); + return (*this).clone(); + } +} +impl MoveAssignable for UserCopyDefaultMove { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), v).write({ (*_a0.upgrade().deref()).v }); + return (*this).clone(); + } +} impl Clone for UserCopyDefaultMove { fn clone(&self) -> Self { let __src: Value = @@ -142,6 +177,33 @@ pub struct Buffer { #[array_len(2)] pub arr: Box<[i32]>, } +impl MoveConstructible for Buffer { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), data).write(field!(_a0, data).with_mut(std::mem::take)); + field!((*this), rows).write(field!(_a0, rows).with_mut(std::mem::take)); + field!((*this), n).write({ (*_a0.upgrade().deref()).n }); + field!((*this), arr).write(Box::new(std::array::from_fn::<_, 2, _>(|__i: usize| { + (*_a0.upgrade().deref()).arr[(__i) as usize] + }))); + } +} +impl MoveAssignable for Buffer { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), data).with_mut(|__b0| { + (*__b0) = field!(_a0, data).with_mut(std::mem::take); + }); + field!((*this), rows).with_mut(|__b0| { + (*__b0) = field!(_a0, rows).with_mut(std::mem::take); + }); + field!((*this), n).write({ (*_a0.upgrade().deref()).n }); + { + let mut __tmp_0 = { (array_field_ptr!((*this), arr)).to_any() }; + __tmp_0.memcpy(&(array_field_ptr!(_a0, arr)).to_any(), 8_usize); + (__tmp_0).clone() + }; + return (*this).clone(); + } +} impl Default for Buffer { fn default() -> Self { { ::zero_init() } @@ -163,6 +225,34 @@ pub struct Owner { #[byte_size(8)] pub p: Option>, } +impl MoveConstructible for Owner { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), data).write(field!(_a0, data).with_mut(std::mem::take)); + field!((*this), n).write({ (*_a0.upgrade().deref()).n }); + field!((*this), arr).write(Box::new(std::array::from_fn::<_, 2, _>(|__i: usize| { + (*_a0.upgrade().deref()).arr[(__i) as usize] + }))); + field!((*this), p) + .write(field!(_a0, p).with_mut(|__v: &mut Option>| __v.take())); + } +} +impl MoveAssignable for Owner { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), data).with_mut(|__b0| { + (*__b0) = field!(_a0, data).with_mut(std::mem::take); + }); + field!((*this), n).write({ (*_a0.upgrade().deref()).n }); + { + let mut __tmp_1 = { (array_field_ptr!((*this), arr)).to_any() }; + __tmp_1.memcpy(&(array_field_ptr!(_a0, arr)).to_any(), 8_usize); + (__tmp_1).clone() + }; + field!((*this), p).with_mut(|__b0| { + (*__b0) = field!(_a0, p).with_mut(|__v: &mut Option>| __v.take()); + }); + return (*this).clone(); + } +} impl Default for Owner { fn default() -> Self { { @@ -192,6 +282,19 @@ pub struct Copyable { #[byte_size(24)] pub data: Vec, } +impl MoveConstructible for Copyable { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), data).write(field!(_a0, data).with_mut(std::mem::take)); + } +} +impl MoveAssignable for Copyable { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), data).with_mut(|__b0| { + (*__b0) = field!(_a0, data).with_mut(std::mem::take); + }); + return (*this).clone(); + } +} #[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Destructible, Default)] #[cpp_from(i32, construct, value)] #[byte_size(32)] @@ -206,6 +309,24 @@ pub struct Holder { #[byte_size(8)] pub p: Option>, } +impl MoveConstructible for Holder { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), inner).write({ (*_a0.upgrade().deref()).inner }); + field!((*this), e).write({ (*_a0.upgrade().deref()).e.clone() }); + field!((*this), p) + .write(field!(_a0, p).with_mut(|__v: &mut Option>| __v.take())); + } +} +impl MoveAssignable for Holder { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), inner).write({ (*_a0.upgrade().deref()).inner }); + field!((*this), e).write({ (*_a0.upgrade().deref()).e.clone() }); + field!((*this), p).with_mut(|__b0| { + (*__b0) = field!(_a0, p).with_mut(|__v: &mut Option>| __v.take()); + }); + return (*this).clone(); + } +} pub fn same_0(a: Ptr, b: Ptr) -> bool { return ((({ a.with(|__s| __s.v) } == { b.with(|__s| __s.v) }) && ({ a.with(|__s| __s.inner.x) } == { b.with(|__s| __s.inner.x) })) @@ -555,46 +676,6 @@ impl BufferImpl for Ptr { }; } } -impl MoveAssignable for Buffer { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), data).with_mut(|__b0| { - (*__b0) = field!(_a0, data).with_mut(std::mem::take); - }); - field!((*this), rows).with_mut(|__b0| { - (*__b0) = field!(_a0, rows).with_mut(std::mem::take); - }); - field!((*this), n).write({ (*_a0.upgrade().deref()).n }); - { - let mut __tmp_0 = { (array_field_ptr!((*this), arr)).to_any() }; - __tmp_0.memcpy(&(array_field_ptr!(_a0, arr)).to_any(), 8_usize); - (__tmp_0).clone() - }; - return (*this).clone(); - } -} -impl MoveConstructible for Buffer { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), data).write(field!(_a0, data).with_mut(std::mem::take)); - field!((*this), rows).write(field!(_a0, rows).with_mut(std::mem::take)); - field!((*this), n).write({ (*_a0.upgrade().deref()).n }); - field!((*this), arr).write(Box::new(std::array::from_fn::<_, 2, _>(|__i: usize| { - (*_a0.upgrade().deref()).arr[(__i) as usize] - }))); - } -} -impl MoveAssignable for Copyable { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), data).with_mut(|__b0| { - (*__b0) = field!(_a0, data).with_mut(std::mem::take); - }); - return (*this).clone(); - } -} -impl MoveConstructible for Copyable { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), data).write(field!(_a0, data).with_mut(std::mem::take)); - } -} pub trait DefaultCopyUserMoveImpl { fn construct(&self, v: i32); } @@ -603,19 +684,6 @@ impl DefaultCopyUserMoveImpl for Ptr { field!((*self), v).write(v); } } -impl MoveAssignable for DefaultCopyUserMove { - fn move_assign(this: &Ptr, o: Ptr) -> Ptr { - field!((*this), v).write(o.with(|__s| __s.v)); - field!(o, v).write(0); - return (*this).clone(); - } -} -impl MoveConstructible for DefaultCopyUserMove { - fn move_constructor(this: &Ptr, o: Ptr) { - field!((*this), v).write(o.with(|__s| __s.v)); - field!(o, v).write(0); - } -} pub trait ExplicitImpl { fn construct(&self, v: i32); fn destructor(&self); @@ -646,52 +714,6 @@ impl HolderImpl for Ptr { Destructible::destroy(field_ptr!(self, e)); } } -impl MoveAssignable for Holder { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), inner).write({ (*_a0.upgrade().deref()).inner }); - field!((*this), e).write({ (*_a0.upgrade().deref()).e.clone() }); - field!((*this), p).with_mut(|__b0| { - (*__b0) = field!(_a0, p).with_mut(|__v: &mut Option>| __v.take()); - }); - return (*this).clone(); - } -} -impl MoveConstructible for Holder { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), inner).write({ (*_a0.upgrade().deref()).inner }); - field!((*this), e).write({ (*_a0.upgrade().deref()).e.clone() }); - field!((*this), p) - .write(field!(_a0, p).with_mut(|__v: &mut Option>| __v.take())); - } -} -impl MoveAssignable for Owner { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), data).with_mut(|__b0| { - (*__b0) = field!(_a0, data).with_mut(std::mem::take); - }); - field!((*this), n).write({ (*_a0.upgrade().deref()).n }); - { - let mut __tmp_1 = { (array_field_ptr!((*this), arr)).to_any() }; - __tmp_1.memcpy(&(array_field_ptr!(_a0, arr)).to_any(), 8_usize); - (__tmp_1).clone() - }; - field!((*this), p).with_mut(|__b0| { - (*__b0) = field!(_a0, p).with_mut(|__v: &mut Option>| __v.take()); - }); - return (*this).clone(); - } -} -impl MoveConstructible for Owner { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), data).write(field!(_a0, data).with_mut(std::mem::take)); - field!((*this), n).write({ (*_a0.upgrade().deref()).n }); - field!((*this), arr).write(Box::new(std::array::from_fn::<_, 2, _>(|__i: usize| { - (*_a0.upgrade().deref()).arr[(__i) as usize] - }))); - field!((*this), p) - .write(field!(_a0, p).with_mut(|__v: &mut Option>| __v.take())); - } -} pub trait UserCopyDefaultMoveImpl { fn construct(&self, v: i32); } @@ -700,26 +722,4 @@ impl UserCopyDefaultMoveImpl for Ptr { field!((*self), v).write(v); } } -impl CopyAssignable for UserCopyDefaultMove { - fn copy_assign(this: &Ptr, o: Ptr) -> Ptr { - field!((*this), v).write((o.with(|__s| __s.v) + 100)); - return (*this).clone(); - } -} -impl CopyConstructible for UserCopyDefaultMove { - fn copy_constructor(this: &Ptr, o: Ptr) { - field!((*this), v).write((o.with(|__s| __s.v) + 100)); - } -} -impl MoveAssignable for UserCopyDefaultMove { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), v).write({ (*_a0.upgrade().deref()).v }); - return (*this).clone(); - } -} -impl MoveConstructible for UserCopyDefaultMove { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), v).write({ (*_a0.upgrade().deref()).v }); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/copy_move_deleted.rs b/tests/unit/out/refcount/copy_move_deleted.rs index 1fe623fe58..c1f1497609 100644 --- a/tests/unit/out/refcount/copy_move_deleted.rs +++ b/tests/unit/out/refcount/copy_move_deleted.rs @@ -13,12 +13,38 @@ pub struct NoCopy { #[offset(0)] pub v: i32, } +impl MoveConstructible for NoCopy { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + field!(o, v).write(0); + } +} +impl MoveAssignable for NoCopy { + fn move_assign(this: &Ptr, o: Ptr) -> Ptr { + field!((*this), v).write(o.with(|__s| __s.v)); + field!(o, v).write(0); + return (*this).clone(); + } +} #[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg)] #[byte_size(4)] pub struct PrivateCopy { #[offset(0)] pub v: i32, } +impl MoveConstructible for PrivateCopy { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + field!(o, v).write(0); + } +} +impl MoveAssignable for PrivateCopy { + fn move_assign(this: &Ptr, o: Ptr) -> Ptr { + field!((*this), v).write(o.with(|__s| __s.v)); + field!(o, v).write(0); + return (*this).clone(); + } +} impl Default for PrivateCopy { fn default() -> Self { { @@ -56,6 +82,23 @@ pub struct Container { #[offset(4)] pub tag: i32, } +impl MoveConstructible for Container { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), inner).write({ + let __v: Value = Rc::new(RefCell::new(::zero_init())); + MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, inner) }); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }); + field!((*this), tag).write({ (*_a0.upgrade().deref()).tag }); + } +} +impl MoveAssignable for Container { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + ({ MoveAssignable::move_assign(&field_ptr!((*this), inner), field_ptr!(_a0, inner)) }); + field!((*this), tag).write({ (*_a0.upgrade().deref()).tag }); + return (*this).clone(); + } +} #[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Default)] #[byte_size(24)] pub struct VecHolder { @@ -63,6 +106,19 @@ pub struct VecHolder { #[byte_size(24)] pub items: Vec, } +impl MoveConstructible for VecHolder { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), items).write(field!(_a0, items).with_mut(std::mem::take)); + } +} +impl MoveAssignable for VecHolder { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), items).with_mut(|__b0| { + (*__b0) = field!(_a0, items).with_mut(std::mem::take); + }); + return (*this).clone(); + } +} pub fn bump_0(mut p: Ptr) { field!(p, v).with_mut(|__v| __v.postfix_inc()); } @@ -135,23 +191,6 @@ fn main_0() -> i32 { assert!((h2.items.len() == 0_usize)); return 0; } -impl MoveAssignable for Container { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - ({ MoveAssignable::move_assign(&field_ptr!((*this), inner), field_ptr!(_a0, inner)) }); - field!((*this), tag).write({ (*_a0.upgrade().deref()).tag }); - return (*this).clone(); - } -} -impl MoveConstructible for Container { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), inner).write({ - let __v: Value = Rc::new(RefCell::new(::zero_init())); - MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, inner) }); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }); - field!((*this), tag).write({ (*_a0.upgrade().deref()).tag }); - } -} pub trait ImmovableImpl { fn construct(&self); } @@ -168,19 +207,6 @@ impl NoCopyImpl for Ptr { field!((*self), v).write(v); } } -impl MoveAssignable for NoCopy { - fn move_assign(this: &Ptr, o: Ptr) -> Ptr { - field!((*this), v).write(o.with(|__s| __s.v)); - field!(o, v).write(0); - return (*this).clone(); - } -} -impl MoveConstructible for NoCopy { - fn move_constructor(this: &Ptr, o: Ptr) { - field!((*this), v).write(o.with(|__s| __s.v)); - field!(o, v).write(0); - } -} pub trait PrivateCopyImpl { fn copy_assign(&self, _a0: Ptr) -> Ptr { unimplemented!() @@ -192,30 +218,4 @@ impl PrivateCopyImpl for Ptr { field!((*self), v).write(0); } } -impl MoveAssignable for PrivateCopy { - fn move_assign(this: &Ptr, o: Ptr) -> Ptr { - field!((*this), v).write(o.with(|__s| __s.v)); - field!(o, v).write(0); - return (*this).clone(); - } -} -impl MoveConstructible for PrivateCopy { - fn move_constructor(this: &Ptr, o: Ptr) { - field!((*this), v).write(o.with(|__s| __s.v)); - field!(o, v).write(0); - } -} -impl MoveAssignable for VecHolder { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), items).with_mut(|__b0| { - (*__b0) = field!(_a0, items).with_mut(std::mem::take); - }); - return (*this).clone(); - } -} -impl MoveConstructible for VecHolder { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), items).write(field!(_a0, items).with_mut(std::mem::take)); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/field_method_receiver.rs b/tests/unit/out/refcount/field_method_receiver.rs index e003c4afd1..8c7046c6a8 100644 --- a/tests/unit/out/refcount/field_method_receiver.rs +++ b/tests/unit/out/refcount/field_method_receiver.rs @@ -43,6 +43,31 @@ pub struct S { #[byte_size(24)] pub v: Vec, } +impl MoveConstructible for S { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), tag).write({ (*_a0.upgrade().deref()).tag }); + field!((*this), c).write({ (*_a0.upgrade().deref()).c }); + field!((*this), arr).write(Box::new(std::array::from_fn::<_, 2, _>(|__i: usize| { + (*_a0.upgrade().deref()).arr[(__i) as usize] + }))); + field!((*this), v).write(field!(_a0, v).with_mut(std::mem::take)); + } +} +impl MoveAssignable for S { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), tag).write({ (*_a0.upgrade().deref()).tag }); + field!((*this), c).write({ (*_a0.upgrade().deref()).c }); + { + let mut __tmp_0 = { (array_field_ptr!((*this), arr)).to_any() }; + __tmp_0.memcpy(&(array_field_ptr!(_a0, arr)).to_any(), 8_usize); + (__tmp_0).clone() + }; + field!((*this), v).with_mut(|__b0| { + (*__b0) = field!(_a0, v).with_mut(std::mem::take); + }); + return (*this).clone(); + } +} impl Default for S { fn default() -> Self { { @@ -138,29 +163,4 @@ impl SImpl for Ptr { ({ CounterImpl::add(&field_ptr!((*self), c), (*self).with(|__s| __s.tag)) }); } } -impl MoveAssignable for S { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), tag).write({ (*_a0.upgrade().deref()).tag }); - field!((*this), c).write({ (*_a0.upgrade().deref()).c }); - { - let mut __tmp_0 = { (array_field_ptr!((*this), arr)).to_any() }; - __tmp_0.memcpy(&(array_field_ptr!(_a0, arr)).to_any(), 8_usize); - (__tmp_0).clone() - }; - field!((*this), v).with_mut(|__b0| { - (*__b0) = field!(_a0, v).with_mut(std::mem::take); - }); - return (*this).clone(); - } -} -impl MoveConstructible for S { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), tag).write({ (*_a0.upgrade().deref()).tag }); - field!((*this), c).write({ (*_a0.upgrade().deref()).c }); - field!((*this), arr).write(Box::new(std::array::from_fn::<_, 2, _>(|__i: usize| { - (*_a0.upgrade().deref()).arr[(__i) as usize] - }))); - field!((*this), v).write(field!(_a0, v).with_mut(std::mem::take)); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/field_pointers.rs b/tests/unit/out/refcount/field_pointers.rs index 8fa8c9f54e..3ac1b7921f 100644 --- a/tests/unit/out/refcount/field_pointers.rs +++ b/tests/unit/out/refcount/field_pointers.rs @@ -83,6 +83,41 @@ pub struct Outer { #[array_len(4)] pub buf: Box<[i32]>, } +impl MoveConstructible for Outer { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), x).write({ (*_a0.upgrade().deref()).x }); + field!((*this), inner).write({ (*_a0.upgrade().deref()).inner.clone() }); + field!((*this), items).write(Box::new(std::array::from_fn::<_, 3, _>(|__i: usize| { + ((*_a0.upgrade().deref()).items[(__i) as usize]).clone() + }))); + field!((*this), v).write(field!(_a0, v).with_mut(std::mem::take)); + field!((*this), cursor).write({ (*_a0.upgrade().deref()).cursor.clone() }); + field!((*this), buf).write(Box::new(std::array::from_fn::<_, 4, _>(|__i: usize| { + (*_a0.upgrade().deref()).buf[(__i) as usize] + }))); + } +} +impl MoveAssignable for Outer { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), x).write({ (*_a0.upgrade().deref()).x }); + field!((*this), inner).write({ (*_a0.upgrade().deref()).inner.clone() }); + { + let mut __tmp_0 = { (array_field_ptr!((*this), items)).to_any() }; + __tmp_0.memcpy(&(array_field_ptr!(_a0, items)).to_any(), 36_usize); + (__tmp_0).clone() + }; + field!((*this), v).with_mut(|__b0| { + (*__b0) = field!(_a0, v).with_mut(std::mem::take); + }); + field!((*this), cursor).write({ (*_a0.upgrade().deref()).cursor.clone() }); + { + let mut __tmp_1 = { (array_field_ptr!((*this), buf)).to_any() }; + __tmp_1.memcpy(&(array_field_ptr!(_a0, buf)).to_any(), 16_usize); + (__tmp_1).clone() + }; + return (*this).clone(); + } +} impl Default for Outer { fn default() -> Self { { @@ -258,39 +293,4 @@ impl OuterImpl for Ptr { }; } } -impl MoveAssignable for Outer { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), x).write({ (*_a0.upgrade().deref()).x }); - field!((*this), inner).write({ (*_a0.upgrade().deref()).inner.clone() }); - { - let mut __tmp_0 = { (array_field_ptr!((*this), items)).to_any() }; - __tmp_0.memcpy(&(array_field_ptr!(_a0, items)).to_any(), 36_usize); - (__tmp_0).clone() - }; - field!((*this), v).with_mut(|__b0| { - (*__b0) = field!(_a0, v).with_mut(std::mem::take); - }); - field!((*this), cursor).write({ (*_a0.upgrade().deref()).cursor.clone() }); - { - let mut __tmp_1 = { (array_field_ptr!((*this), buf)).to_any() }; - __tmp_1.memcpy(&(array_field_ptr!(_a0, buf)).to_any(), 16_usize); - (__tmp_1).clone() - }; - return (*this).clone(); - } -} -impl MoveConstructible for Outer { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), x).write({ (*_a0.upgrade().deref()).x }); - field!((*this), inner).write({ (*_a0.upgrade().deref()).inner.clone() }); - field!((*this), items).write(Box::new(std::array::from_fn::<_, 3, _>(|__i: usize| { - ((*_a0.upgrade().deref()).items[(__i) as usize]).clone() - }))); - field!((*this), v).write(field!(_a0, v).with_mut(std::mem::take)); - field!((*this), cursor).write({ (*_a0.upgrade().deref()).cursor.clone() }); - field!((*this), buf).write(Box::new(std::array::from_fn::<_, 4, _>(|__i: usize| { - (*_a0.upgrade().deref()).buf[(__i) as usize] - }))); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/fn_ptr_struct.rs b/tests/unit/out/refcount/fn_ptr_struct.rs index ad2b36fea2..26b75379cf 100644 --- a/tests/unit/out/refcount/fn_ptr_struct.rs +++ b/tests/unit/out/refcount/fn_ptr_struct.rs @@ -67,6 +67,12 @@ pub struct MoveOnly { #[offset(0)] pub data_: i32, } +impl MoveConstructible for MoveOnly { + fn move_constructor(this: &Ptr, x: Ptr) { + field!((*this), data_).write(x.with(|__s| __s.data_)); + field!(x, data_).write(0); + } +} pub fn make_move_only_2() -> MoveOnly { return { let __v: Value = Rc::new(RefCell::new(::zero_init())); @@ -143,10 +149,4 @@ impl MoveOnlyImpl for Ptr { return (*self).with(|__s| __s.data_); } } -impl MoveConstructible for MoveOnly { - fn move_constructor(this: &Ptr, x: Ptr) { - field!((*this), data_).write(x.with(|__s| __s.data_)); - field!(x, data_).write(0); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs b/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs index fc0af5ea1e..9ccc0f98d5 100644 --- a/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs +++ b/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs @@ -25,6 +25,21 @@ pub struct S { #[offset(24)] pub a: i32, } +impl MoveConstructible for S { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), v).write(field!(_a0, v).with_mut(std::mem::take)); + field!((*this), a).write({ (*_a0.upgrade().deref()).a }); + } +} +impl MoveAssignable for S { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), v).with_mut(|__b0| { + (*__b0) = field!(_a0, v).with_mut(std::mem::take); + }); + field!((*this), a).write({ (*_a0.upgrade().deref()).a }); + return (*this).clone(); + } +} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); @@ -44,19 +59,4 @@ fn main_0() -> i32 { } return 0; } -impl MoveAssignable for S { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), v).with_mut(|__b0| { - (*__b0) = field!(_a0, v).with_mut(std::mem::take); - }); - field!((*this), a).write({ (*_a0.upgrade().deref()).a }); - return (*this).clone(); - } -} -impl MoveConstructible for S { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), v).write(field!(_a0, v).with_mut(std::mem::take)); - field!((*this), a).write({ (*_a0.upgrade().deref()).a }); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/forward_basic.rs b/tests/unit/out/refcount/forward_basic.rs index c6cae169d0..0f8a80dc04 100644 --- a/tests/unit/out/refcount/forward_basic.rs +++ b/tests/unit/out/refcount/forward_basic.rs @@ -30,6 +30,21 @@ pub struct Tracked { #[offset(8)] pub moves: i32, } +impl CopyConstructible for Tracked { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + field!((*this), copies).write((o.with(|__s| __s.copies) + 1)); + field!((*this), moves).write(o.with(|__s| __s.moves)); + } +} +impl MoveConstructible for Tracked { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + field!((*this), copies).write(o.with(|__s| __s.copies)); + field!((*this), moves).write((o.with(|__s| __s.moves) + 1)); + field!(o, v).write(0); + } +} impl Clone for Tracked { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(Tracked { @@ -69,6 +84,15 @@ pub struct Holder { #[byte_size(12)] pub t: Tracked, } +impl MoveConstructible for Holder { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), t).write({ + let __v: Value = Rc::new(RefCell::new(::zero_init())); + MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, t) }); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }); + } +} pub fn forward_once_2(x: Ptr) -> Overload { return ({ chosen_overload_0((x).clone()) }); } @@ -184,15 +208,6 @@ impl HolderImpl for Ptr { }); } } -impl MoveConstructible for Holder { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), t).write({ - let __v: Value = Rc::new(RefCell::new(::zero_init())); - MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, t) }); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }); - } -} pub trait TrackedImpl { fn construct(&self, v: i32); } @@ -203,19 +218,4 @@ impl TrackedImpl for Ptr { field!((*self), moves).write(0); } } -impl CopyConstructible for Tracked { - fn copy_constructor(this: &Ptr, o: Ptr) { - field!((*this), v).write(o.with(|__s| __s.v)); - field!((*this), copies).write((o.with(|__s| __s.copies) + 1)); - field!((*this), moves).write(o.with(|__s| __s.moves)); - } -} -impl MoveConstructible for Tracked { - fn move_constructor(this: &Ptr, o: Ptr) { - field!((*this), v).write(o.with(|__s| __s.v)); - field!((*this), copies).write(o.with(|__s| __s.copies)); - field!((*this), moves).write((o.with(|__s| __s.moves) + 1)); - field!(o, v).write(0); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/forward_decltype.rs b/tests/unit/out/refcount/forward_decltype.rs index f29812b9c2..aae635d2da 100644 --- a/tests/unit/out/refcount/forward_decltype.rs +++ b/tests/unit/out/refcount/forward_decltype.rs @@ -30,6 +30,21 @@ pub struct Tracked { #[offset(8)] pub moves: i32, } +impl CopyConstructible for Tracked { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + field!((*this), copies).write((o.with(|__s| __s.copies) + 1)); + field!((*this), moves).write(o.with(|__s| __s.moves)); + } +} +impl MoveConstructible for Tracked { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + field!((*this), copies).write(o.with(|__s| __s.copies)); + field!((*this), moves).write((o.with(|__s| __s.moves) + 1)); + field!(o, v).write(0); + } +} impl Clone for Tracked { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(Tracked { @@ -140,19 +155,4 @@ impl TrackedImpl for Ptr { field!((*self), moves).write(0); } } -impl CopyConstructible for Tracked { - fn copy_constructor(this: &Ptr, o: Ptr) { - field!((*this), v).write(o.with(|__s| __s.v)); - field!((*this), copies).write((o.with(|__s| __s.copies) + 1)); - field!((*this), moves).write(o.with(|__s| __s.moves)); - } -} -impl MoveConstructible for Tracked { - fn move_constructor(this: &Ptr, o: Ptr) { - field!((*this), v).write(o.with(|__s| __s.v)); - field!((*this), copies).write(o.with(|__s| __s.copies)); - field!((*this), moves).write((o.with(|__s| __s.moves) + 1)); - field!(o, v).write(0); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/forward_explicit.rs b/tests/unit/out/refcount/forward_explicit.rs index 5ddb17a054..8697e9569d 100644 --- a/tests/unit/out/refcount/forward_explicit.rs +++ b/tests/unit/out/refcount/forward_explicit.rs @@ -32,6 +32,21 @@ pub struct Tracked { #[offset(8)] pub moves: i32, } +impl CopyConstructible for Tracked { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + field!((*this), copies).write((o.with(|__s| __s.copies) + 1)); + field!((*this), moves).write(o.with(|__s| __s.moves)); + } +} +impl MoveConstructible for Tracked { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + field!((*this), copies).write(o.with(|__s| __s.copies)); + field!((*this), moves).write((o.with(|__s| __s.moves) + 1)); + field!(o, v).write(0); + } +} impl Clone for Tracked { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(Tracked { @@ -137,19 +152,4 @@ impl TrackedImpl for Ptr { field!((*self), moves).write(0); } } -impl CopyConstructible for Tracked { - fn copy_constructor(this: &Ptr, o: Ptr) { - field!((*this), v).write(o.with(|__s| __s.v)); - field!((*this), copies).write((o.with(|__s| __s.copies) + 1)); - field!((*this), moves).write(o.with(|__s| __s.moves)); - } -} -impl MoveConstructible for Tracked { - fn move_constructor(this: &Ptr, o: Ptr) { - field!((*this), v).write(o.with(|__s| __s.v)); - field!((*this), copies).write(o.with(|__s| __s.copies)); - field!((*this), moves).write((o.with(|__s| __s.moves) + 1)); - field!(o, v).write(0); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/forward_pack.rs b/tests/unit/out/refcount/forward_pack.rs index a5d10372dd..650b06e1d8 100644 --- a/tests/unit/out/refcount/forward_pack.rs +++ b/tests/unit/out/refcount/forward_pack.rs @@ -32,6 +32,21 @@ pub struct Tracked { #[offset(8)] pub moves: i32, } +impl CopyConstructible for Tracked { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + field!((*this), copies).write((o.with(|__s| __s.copies) + 1)); + field!((*this), moves).write(o.with(|__s| __s.moves)); + } +} +impl MoveConstructible for Tracked { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + field!((*this), copies).write(o.with(|__s| __s.copies)); + field!((*this), moves).write((o.with(|__s| __s.moves) + 1)); + field!(o, v).write(0); + } +} impl Clone for Tracked { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(Tracked { @@ -113,6 +128,20 @@ pub struct Pair { #[byte_size(12)] pub b: Tracked, } +impl MoveConstructible for Pair { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), a).write({ + let __v: Value = Rc::new(RefCell::new(::zero_init())); + MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, a) }); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }); + field!((*this), b).write({ + let __v: Value = Rc::new(RefCell::new(::zero_init())); + MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, b) }); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }); + } +} pub fn forward_pack_into_ctor_8(args_0: Ptr, args_1: Ptr) -> Pair { return { let __v: Value = Rc::new(RefCell::new(::zero_init())); @@ -202,20 +231,6 @@ impl PairImpl for Ptr { }); } } -impl MoveConstructible for Pair { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), a).write({ - let __v: Value = Rc::new(RefCell::new(::zero_init())); - MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, a) }); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }); - field!((*this), b).write({ - let __v: Value = Rc::new(RefCell::new(::zero_init())); - MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, b) }); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }); - } -} pub trait TrackedImpl { fn construct(&self, v: i32); } @@ -226,19 +241,4 @@ impl TrackedImpl for Ptr { field!((*self), moves).write(0); } } -impl CopyConstructible for Tracked { - fn copy_constructor(this: &Ptr, o: Ptr) { - field!((*this), v).write(o.with(|__s| __s.v)); - field!((*this), copies).write((o.with(|__s| __s.copies) + 1)); - field!((*this), moves).write(o.with(|__s| __s.moves)); - } -} -impl MoveConstructible for Tracked { - fn move_constructor(this: &Ptr, o: Ptr) { - field!((*this), v).write(o.with(|__s| __s.v)); - field!((*this), copies).write(o.with(|__s| __s.copies)); - field!((*this), moves).write((o.with(|__s| __s.moves) + 1)); - field!(o, v).write(0); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/huffman.rs b/tests/unit/out/refcount/huffman.rs index 177e370aff..fcc396d414 100644 --- a/tests/unit/out/refcount/huffman.rs +++ b/tests/unit/out/refcount/huffman.rs @@ -68,6 +68,36 @@ pub struct MinHeap { #[byte_size(8)] pub alloc: Option>>, } +impl MoveConstructible for MinHeap { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), size).write({ (*_a0.upgrade().deref()).size }); + field!((*this), capacity).write({ (*_a0.upgrade().deref()).capacity }); + field!((*this), arr).write( + field!(_a0, arr) + .with_mut(|__v: &mut Option]>>>| __v.take()), + ); + field!((*this), next).write({ (*_a0.upgrade().deref()).next }); + field!((*this), alloc).write( + field!(_a0, alloc).with_mut(|__v: &mut Option>>| __v.take()), + ); + } +} +impl MoveAssignable for MinHeap { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), size).write({ (*_a0.upgrade().deref()).size }); + field!((*this), capacity).write({ (*_a0.upgrade().deref()).capacity }); + field!((*this), arr).with_mut(|__b0| { + (*__b0) = field!(_a0, arr) + .with_mut(|__v: &mut Option]>>>| __v.take()); + }); + field!((*this), next).write({ (*_a0.upgrade().deref()).next }); + field!((*this), alloc).with_mut(|__b0| { + (*__b0) = field!(_a0, alloc) + .with_mut(|__v: &mut Option>>| __v.take()); + }); + return (*this).clone(); + } +} pub fn AllocMinHeap_1(mut capacity: i32) -> Option> { let mut minHeap: Option> = Some(Rc::new(RefCell::new(MinHeap { size: 0, @@ -450,36 +480,6 @@ impl MinHeapImpl for Ptr { } } } -impl MoveAssignable for MinHeap { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), size).write({ (*_a0.upgrade().deref()).size }); - field!((*this), capacity).write({ (*_a0.upgrade().deref()).capacity }); - field!((*this), arr).with_mut(|__b0| { - (*__b0) = field!(_a0, arr) - .with_mut(|__v: &mut Option]>>>| __v.take()); - }); - field!((*this), next).write({ (*_a0.upgrade().deref()).next }); - field!((*this), alloc).with_mut(|__b0| { - (*__b0) = field!(_a0, alloc) - .with_mut(|__v: &mut Option>>| __v.take()); - }); - return (*this).clone(); - } -} -impl MoveConstructible for MinHeap { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), size).write({ (*_a0.upgrade().deref()).size }); - field!((*this), capacity).write({ (*_a0.upgrade().deref()).capacity }); - field!((*this), arr).write( - field!(_a0, arr) - .with_mut(|__v: &mut Option]>>>| __v.take()), - ); - field!((*this), next).write({ (*_a0.upgrade().deref()).next }); - field!((*this), alloc).write( - field!(_a0, alloc).with_mut(|__v: &mut Option>>| __v.take()), - ); - } -} pub trait MinHeapNodeImpl { fn IsLeaf(&self) -> bool; } diff --git a/tests/unit/out/refcount/implicit_autoref.rs b/tests/unit/out/refcount/implicit_autoref.rs index 9771d17a19..a50366e9ae 100644 --- a/tests/unit/out/refcount/implicit_autoref.rs +++ b/tests/unit/out/refcount/implicit_autoref.rs @@ -23,6 +23,19 @@ pub struct Holder { #[byte_size(24)] pub v: Vec, } +impl MoveConstructible for Holder { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), v).write(field!(_a0, v).with_mut(std::mem::take)); + } +} +impl MoveAssignable for Holder { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), v).with_mut(|__b0| { + (*__b0) = field!(_a0, v).with_mut(std::mem::take); + }); + return (*this).clone(); + } +} pub fn write_through_0(mut p: Ptr) { p.write(42); } @@ -72,17 +85,4 @@ fn main_0() -> i32 { assert!(((index!(p, 0_usize).read()) == 42)); return 0; } -impl MoveAssignable for Holder { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), v).with_mut(|__b0| { - (*__b0) = field!(_a0, v).with_mut(std::mem::take); - }); - return (*this).clone(); - } -} -impl MoveConstructible for Holder { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), v).write(field!(_a0, v).with_mut(std::mem::take)); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/inline_container_fields.rs b/tests/unit/out/refcount/inline_container_fields.rs index 9929980cf6..7ba51f59d0 100644 --- a/tests/unit/out/refcount/inline_container_fields.rs +++ b/tests/unit/out/refcount/inline_container_fields.rs @@ -21,6 +21,29 @@ pub struct Elem { #[byte_size(24)] pub coeffs: Vec, } +impl MoveConstructible for Elem { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), id).write({ (*_a0.upgrade().deref()).id }); + field!((*this), hist).write(Box::new(std::array::from_fn::<_, 4, _>(|__i: usize| { + (*_a0.upgrade().deref()).hist[(__i) as usize] + }))); + field!((*this), coeffs).write(field!(_a0, coeffs).with_mut(std::mem::take)); + } +} +impl MoveAssignable for Elem { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), id).write({ (*_a0.upgrade().deref()).id }); + { + let mut __tmp_0 = { (array_field_ptr!((*this), hist)).to_any() }; + __tmp_0.memcpy(&(array_field_ptr!(_a0, hist)).to_any(), 16_usize); + (__tmp_0).clone() + }; + field!((*this), coeffs).with_mut(|__b0| { + (*__b0) = field!(_a0, coeffs).with_mut(std::mem::take); + }); + return (*this).clone(); + } +} impl Default for Elem { fn default() -> Self { { @@ -54,6 +77,56 @@ pub struct State { #[byte_size(24)] pub rows: Vec>, } +impl MoveConstructible for State { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), count).write({ (*_a0.upgrade().deref()).count }); + field!((*this), grid).write(Box::new(std::array::from_fn::<_, 2, _>(|__i: usize| { + Box::<[_]>::from(std::array::from_fn::<_, 3, _>(|__i2: usize| { + (*_a0.upgrade().deref()).grid[(__i) as usize][(__i2) as usize] + })) + }))); + field!((*this), arr).write({ + let __v: Value> = + Rc::new(RefCell::new((0..3).map(|_| ::zero_init()).collect())); + let __p: Ptr = __v.decay(); + for __i in 0..3 { + MoveConstructible::move_constructor( + &__p.offset(__i), + field_ref!(_a0, arr).decay().offset(__i), + ); + } + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }); + field!((*this), elems).write(field!(_a0, elems).with_mut(std::mem::take)); + field!((*this), rows).write(field!(_a0, rows).with_mut(std::mem::take)); + } +} +impl MoveAssignable for State { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), count).write({ (*_a0.upgrade().deref()).count }); + { + let mut __tmp_1 = { (array_field_ptr!((*this), grid)).to_any() }; + __tmp_1.memcpy(&(array_field_ptr!(_a0, grid)).to_any(), 24_usize); + (__tmp_1).clone() + }; + { + for __i in 0..3 { + MoveAssignable::move_assign( + &field_ref!((*this), arr).as_pointer().decay().offset(__i), + field_ref!(_a0, arr).decay().offset(__i), + ); + } + field_ref!((*this), arr).as_pointer() + }; + field!((*this), elems).with_mut(|__b0| { + (*__b0) = field!(_a0, elems).with_mut(std::mem::take); + }); + field!((*this), rows).with_mut(|__b0| { + (*__b0) = field!(_a0, rows).with_mut(std::mem::take); + }); + return (*this).clone(); + } +} impl Default for State { fn default() -> Self { { @@ -137,6 +210,34 @@ pub struct Counted { #[offset(0)] pub v: i32, } +impl CopyConstructible for Counted { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + (*copies_2.with(Value::clone).borrow_mut()).prefix_inc(); + } +} +impl MoveConstructible for Counted { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + field!(o, v).write(-1_i32); + (*moves_3.with(Value::clone).borrow_mut()).prefix_inc(); + } +} +impl CopyAssignable for Counted { + fn copy_assign(this: &Ptr, o: Ptr) -> Ptr { + field!((*this), v).write(o.with(|__s| __s.v)); + (*copy_assigns_4.with(Value::clone).borrow_mut()).prefix_inc(); + return (*this).clone(); + } +} +impl MoveAssignable for Counted { + fn move_assign(this: &Ptr, o: Ptr) -> Ptr { + field!((*this), v).write(o.with(|__s| __s.v)); + field!(o, v).write(-1_i32); + (*move_assigns_5.with(Value::clone).borrow_mut()).prefix_inc(); + return (*this).clone(); + } +} impl Clone for Counted { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(Counted { v: self.v.clone() })); @@ -419,107 +520,6 @@ fn main_0() -> i32 { ); return 0; } -impl CopyAssignable for Counted { - fn copy_assign(this: &Ptr, o: Ptr) -> Ptr { - field!((*this), v).write(o.with(|__s| __s.v)); - (*copy_assigns_4.with(Value::clone).borrow_mut()).prefix_inc(); - return (*this).clone(); - } -} -impl CopyConstructible for Counted { - fn copy_constructor(this: &Ptr, o: Ptr) { - field!((*this), v).write(o.with(|__s| __s.v)); - (*copies_2.with(Value::clone).borrow_mut()).prefix_inc(); - } -} -impl MoveAssignable for Counted { - fn move_assign(this: &Ptr, o: Ptr) -> Ptr { - field!((*this), v).write(o.with(|__s| __s.v)); - field!(o, v).write(-1_i32); - (*move_assigns_5.with(Value::clone).borrow_mut()).prefix_inc(); - return (*this).clone(); - } -} -impl MoveConstructible for Counted { - fn move_constructor(this: &Ptr, o: Ptr) { - field!((*this), v).write(o.with(|__s| __s.v)); - field!(o, v).write(-1_i32); - (*moves_3.with(Value::clone).borrow_mut()).prefix_inc(); - } -} -impl MoveAssignable for Elem { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), id).write({ (*_a0.upgrade().deref()).id }); - { - let mut __tmp_0 = { (array_field_ptr!((*this), hist)).to_any() }; - __tmp_0.memcpy(&(array_field_ptr!(_a0, hist)).to_any(), 16_usize); - (__tmp_0).clone() - }; - field!((*this), coeffs).with_mut(|__b0| { - (*__b0) = field!(_a0, coeffs).with_mut(std::mem::take); - }); - return (*this).clone(); - } -} -impl MoveConstructible for Elem { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), id).write({ (*_a0.upgrade().deref()).id }); - field!((*this), hist).write(Box::new(std::array::from_fn::<_, 4, _>(|__i: usize| { - (*_a0.upgrade().deref()).hist[(__i) as usize] - }))); - field!((*this), coeffs).write(field!(_a0, coeffs).with_mut(std::mem::take)); - } -} -impl MoveAssignable for State { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), count).write({ (*_a0.upgrade().deref()).count }); - { - let mut __tmp_1 = { (array_field_ptr!((*this), grid)).to_any() }; - __tmp_1.memcpy(&(array_field_ptr!(_a0, grid)).to_any(), 24_usize); - (__tmp_1).clone() - }; - { - for __i in 0..3 { - MoveAssignable::move_assign( - &field_ref!((*this), arr).as_pointer().decay().offset(__i), - field_ref!(_a0, arr).decay().offset(__i), - ); - } - field_ref!((*this), arr).as_pointer() - }; - field!((*this), elems).with_mut(|__b0| { - (*__b0) = field!(_a0, elems).with_mut(std::mem::take); - }); - field!((*this), rows).with_mut(|__b0| { - (*__b0) = field!(_a0, rows).with_mut(std::mem::take); - }); - return (*this).clone(); - } -} -impl MoveConstructible for State { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), count).write({ (*_a0.upgrade().deref()).count }); - field!((*this), grid).write(Box::new(std::array::from_fn::<_, 2, _>(|__i: usize| { - Box::<[_]>::from(std::array::from_fn::<_, 3, _>(|__i2: usize| { - (*_a0.upgrade().deref()).grid[(__i) as usize][(__i2) as usize] - })) - }))); - field!((*this), arr).write({ - let __v: Value> = - Rc::new(RefCell::new((0..3).map(|_| ::zero_init()).collect())); - let __p: Ptr = __v.decay(); - for __i in 0..3 { - MoveConstructible::move_constructor( - &__p.offset(__i), - field_ref!(_a0, arr).decay().offset(__i), - ); - } - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }); - field!((*this), elems).write(field!(_a0, elems).with_mut(std::mem::take)); - field!((*this), rows).write(field!(_a0, rows).with_mut(std::mem::take)); - } -} pub fn __cpp2rust_init_globals() { let _ = copies_2.with(|_| ()); let _ = moves_3.with(|_| ()); diff --git a/tests/unit/out/refcount/kruskal.rs b/tests/unit/out/refcount/kruskal.rs index 6f1db27f21..0b0138d941 100644 --- a/tests/unit/out/refcount/kruskal.rs +++ b/tests/unit/out/refcount/kruskal.rs @@ -124,6 +124,28 @@ pub struct DisjointSet { #[offset(16)] pub n: i32, } +impl MoveConstructible for DisjointSet { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), rank) + .write(field!(_a0, rank).with_mut(|__v: &mut Option>>| __v.take())); + field!((*this), parent) + .write(field!(_a0, parent).with_mut(|__v: &mut Option>>| __v.take())); + field!((*this), n).write({ (*_a0.upgrade().deref()).n }); + } +} +impl MoveAssignable for DisjointSet { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), rank).with_mut(|__b0| { + (*__b0) = field!(_a0, rank).with_mut(|__v: &mut Option>>| __v.take()); + }); + field!((*this), parent).with_mut(|__b0| { + (*__b0) = + field!(_a0, parent).with_mut(|__v: &mut Option>>| __v.take()); + }); + field!((*this), n).write({ (*_a0.upgrade().deref()).n }); + return (*this).clone(); + } +} #[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Default)] #[byte_size(16)] pub struct Graph { @@ -135,6 +157,25 @@ pub struct Graph { #[offset(12)] pub E: i32, } +impl MoveConstructible for Graph { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), edges) + .write(field!(_a0, edges).with_mut(|__v: &mut Option>>| __v.take())); + field!((*this), V).write({ (*_a0.upgrade().deref()).V }); + field!((*this), E).write({ (*_a0.upgrade().deref()).E }); + } +} +impl MoveAssignable for Graph { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), edges).with_mut(|__b0| { + (*__b0) = + field!(_a0, edges).with_mut(|__v: &mut Option>>| __v.take()); + }); + field!((*this), V).write({ (*_a0.upgrade().deref()).V }); + field!((*this), E).write({ (*_a0.upgrade().deref()).E }); + return (*this).clone(); + } +} pub fn MSTKruskal_2(graph: Ptr) -> f64 { ({ quicksort_1(field_ptr!(graph, edges), 0, (graph.with(|__s| __s.E) - 1)) }); let set: Value = Rc::new(RefCell::new(DisjointSet { @@ -358,45 +399,4 @@ impl DisjointSetImpl for Ptr { } } } -impl MoveAssignable for DisjointSet { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), rank).with_mut(|__b0| { - (*__b0) = field!(_a0, rank).with_mut(|__v: &mut Option>>| __v.take()); - }); - field!((*this), parent).with_mut(|__b0| { - (*__b0) = - field!(_a0, parent).with_mut(|__v: &mut Option>>| __v.take()); - }); - field!((*this), n).write({ (*_a0.upgrade().deref()).n }); - return (*this).clone(); - } -} -impl MoveConstructible for DisjointSet { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), rank) - .write(field!(_a0, rank).with_mut(|__v: &mut Option>>| __v.take())); - field!((*this), parent) - .write(field!(_a0, parent).with_mut(|__v: &mut Option>>| __v.take())); - field!((*this), n).write({ (*_a0.upgrade().deref()).n }); - } -} -impl MoveAssignable for Graph { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), edges).with_mut(|__b0| { - (*__b0) = - field!(_a0, edges).with_mut(|__v: &mut Option>>| __v.take()); - }); - field!((*this), V).write({ (*_a0.upgrade().deref()).V }); - field!((*this), E).write({ (*_a0.upgrade().deref()).E }); - return (*this).clone(); - } -} -impl MoveConstructible for Graph { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), edges) - .write(field!(_a0, edges).with_mut(|__v: &mut Option>>| __v.take())); - field!((*this), V).write({ (*_a0.upgrade().deref()).V }); - field!((*this), E).write({ (*_a0.upgrade().deref()).E }); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/lambda_as_field.rs b/tests/unit/out/refcount/lambda_as_field.rs index 961ad581cb..bd696cbf4b 100644 --- a/tests/unit/out/refcount/lambda_as_field.rs +++ b/tests/unit/out/refcount/lambda_as_field.rs @@ -121,6 +121,12 @@ pub struct Moving__lambda_at_lambda_as_field_cpp_64_12__ { #[offset(4)] pub moves: i32, } +impl MoveConstructible for Moving__lambda_at_lambda_as_field_cpp_64_12__ { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), f).write((*o.upgrade().deref()).f.move_from()); + field!((*this), moves).write((o.with(|__s| __s.moves) + 1)); + } +} impl Default for Moving__lambda_at_lambda_as_field_cpp_64_12__ { fn default() -> Self { { ::zero_init() } @@ -321,12 +327,6 @@ impl Moving__lambda_at_lambda_as_field_cpp_64_12__Impl field!((*self), moves).write(0); } } -impl MoveConstructible for Moving__lambda_at_lambda_as_field_cpp_64_12__ { - fn move_constructor(this: &Ptr, o: Ptr) { - field!((*this), f).write((*o.upgrade().deref()).f.move_from()); - field!((*this), moves).write((o.with(|__s| __s.moves) + 1)); - } -} pub fn __cpp2rust_init_globals() { let _ = count_0.with(|_| ()); } diff --git a/tests/unit/out/refcount/lambda_capture_copy_ctor.rs b/tests/unit/out/refcount/lambda_capture_copy_ctor.rs index 46a79d1873..eabfded09f 100644 --- a/tests/unit/out/refcount/lambda_capture_copy_ctor.rs +++ b/tests/unit/out/refcount/lambda_capture_copy_ctor.rs @@ -14,6 +14,18 @@ pub struct Counted { #[offset(4)] pub moves: i32, } +impl CopyConstructible for Counted { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), copies).write((o.with(|__s| __s.copies) + 1)); + field!((*this), moves).write(o.with(|__s| __s.moves)); + } +} +impl MoveConstructible for Counted { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), copies).write(o.with(|__s| __s.copies)); + field!((*this), moves).write((o.with(|__s| __s.moves) + 1)); + } +} impl Clone for Counted { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(Counted { @@ -51,6 +63,12 @@ thread_local!( )] #[byte_size(1)] pub struct Dropped {} +impl CopyConstructible for Dropped { + fn copy_constructor(this: &Ptr, _a0: Ptr) {} +} +impl MoveConstructible for Dropped { + fn move_constructor(this: &Ptr, _a0: Ptr) {} +} impl Clone for Dropped { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(Dropped {})); @@ -222,18 +240,6 @@ impl CountedImpl for Ptr { field!((*self), moves).write(0); } } -impl CopyConstructible for Counted { - fn copy_constructor(this: &Ptr, o: Ptr) { - field!((*this), copies).write((o.with(|__s| __s.copies) + 1)); - field!((*this), moves).write(o.with(|__s| __s.moves)); - } -} -impl MoveConstructible for Counted { - fn move_constructor(this: &Ptr, o: Ptr) { - field!((*this), copies).write(o.with(|__s| __s.copies)); - field!((*this), moves).write((o.with(|__s| __s.moves) + 1)); - } -} pub trait DroppedImpl { fn construct(&self); fn destructor(&self); @@ -244,12 +250,6 @@ impl DroppedImpl for Ptr { (*drops_0.with(Value::clone).borrow_mut()).postfix_inc(); } } -impl CopyConstructible for Dropped { - fn copy_constructor(this: &Ptr, _a0: Ptr) {} -} -impl MoveConstructible for Dropped { - fn move_constructor(this: &Ptr, _a0: Ptr) {} -} pub fn __cpp2rust_init_globals() { let _ = drops_0.with(|_| ()); } diff --git a/tests/unit/out/refcount/lambda_move_only_capture.rs b/tests/unit/out/refcount/lambda_move_only_capture.rs index b5fd38ee0f..f43bde7dcf 100644 --- a/tests/unit/out/refcount/lambda_move_only_capture.rs +++ b/tests/unit/out/refcount/lambda_move_only_capture.rs @@ -14,6 +14,12 @@ pub struct Owner { #[byte_size(8)] pub p: Ptr, } +impl MoveConstructible for Owner { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), p).write(o.with(|__s| __s.p.clone())); + field!(o, p).write(Ptr::::null()); + } +} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); @@ -112,10 +118,4 @@ impl OwnerImpl for Ptr { ); } } -impl MoveConstructible for Owner { - fn move_constructor(this: &Ptr, o: Ptr) { - field!((*this), p).write(o.with(|__s| __s.p.clone())); - field!(o, p).write(Ptr::::null()); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/libc_struct_without_default.rs b/tests/unit/out/refcount/libc_struct_without_default.rs index 6e0f0f88c1..dcecf143ef 100644 --- a/tests/unit/out/refcount/libc_struct_without_default.rs +++ b/tests/unit/out/refcount/libc_struct_without_default.rs @@ -19,6 +19,40 @@ pub struct UserDefined { #[byte_size(24)] pub v: Vec, } +impl MoveConstructible for UserDefined { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), a).write({ + let __v: Value> = + Rc::new(RefCell::new((0..1).map(|_| ::zero_init()).collect())); + let __p: Ptr = __v.decay(); + for __i in 0..1 { + MoveConstructible::move_constructor( + &__p.offset(__i), + field_ref!(_a0, a).decay().offset(__i), + ); + } + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }); + field!((*this), v).write(field!(_a0, v).with_mut(std::mem::take)); + } +} +impl MoveAssignable for UserDefined { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + { + for __i in 0..1 { + MoveAssignable::move_assign( + &field_ref!((*this), a).as_pointer().decay().offset(__i), + field_ref!(_a0, a).decay().offset(__i), + ); + } + field_ref!((*this), a).as_pointer() + }; + field!((*this), v).with_mut(|__b0| { + (*__b0) = field!(_a0, v).with_mut(std::mem::take); + }); + return (*this).clone(); + } +} impl Default for UserDefined { fn default() -> Self { { @@ -90,38 +124,4 @@ fn main_0() -> i32 { assert!(((filt.addr.sa_family as i32) == 2)); return 0; } -impl MoveAssignable for UserDefined { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - { - for __i in 0..1 { - MoveAssignable::move_assign( - &field_ref!((*this), a).as_pointer().decay().offset(__i), - field_ref!(_a0, a).decay().offset(__i), - ); - } - field_ref!((*this), a).as_pointer() - }; - field!((*this), v).with_mut(|__b0| { - (*__b0) = field!(_a0, v).with_mut(std::mem::take); - }); - return (*this).clone(); - } -} -impl MoveConstructible for UserDefined { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), a).write({ - let __v: Value> = - Rc::new(RefCell::new((0..1).map(|_| ::zero_init()).collect())); - let __p: Ptr = __v.decay(); - for __i in 0..1 { - MoveConstructible::move_constructor( - &__p.offset(__i), - field_ref!(_a0, a).decay().offset(__i), - ); - } - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }); - field!((*this), v).write(field!(_a0, v).with_mut(std::mem::take)); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/map_key_copy_ctor.rs b/tests/unit/out/refcount/map_key_copy_ctor.rs index cb108c1eaa..5293c73cd8 100644 --- a/tests/unit/out/refcount/map_key_copy_ctor.rs +++ b/tests/unit/out/refcount/map_key_copy_ctor.rs @@ -32,6 +32,18 @@ pub struct Key { #[offset(0)] pub k: i32, } +impl CopyConstructible for Key { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), k).write(o.with(|__s| __s.k)); + (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); + } +} +impl MoveConstructible for Key { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), k).write(o.with(|__s| __s.k)); + (*moves_1.with(Value::clone).borrow_mut()).prefix_inc(); + } +} impl CppLess for Key { fn less(__lhs: &Ptr, __rhs: &Ptr) -> bool { KeyImpl::operator_lt(__lhs, __rhs.clone()) @@ -306,18 +318,6 @@ impl KeyImpl for Ptr { return ({ (*self).with(|__s| __s.k) } < { o.with(|__s| __s.k) }); } } -impl CopyConstructible for Key { - fn copy_constructor(this: &Ptr, o: Ptr) { - field!((*this), k).write(o.with(|__s| __s.k)); - (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); - } -} -impl MoveConstructible for Key { - fn move_constructor(this: &Ptr, o: Ptr) { - field!((*this), k).write(o.with(|__s| __s.k)); - (*moves_1.with(Value::clone).borrow_mut()).prefix_inc(); - } -} pub fn __cpp2rust_init_globals() { let _ = copies_0.with(|_| ()); let _ = moves_1.with(|_| ()); diff --git a/tests/unit/out/refcount/map_try_emplace.rs b/tests/unit/out/refcount/map_try_emplace.rs index ad55daf035..161cd1bac8 100644 --- a/tests/unit/out/refcount/map_try_emplace.rs +++ b/tests/unit/out/refcount/map_try_emplace.rs @@ -27,6 +27,19 @@ pub struct Item { #[offset(0)] pub value: i32, } +impl CopyConstructible for Item { + fn copy_constructor(this: &Ptr, other: Ptr) { + field!((*this), value).write(other.with(|__s| __s.value)); + (*copies_2.with(Value::clone).borrow_mut()).prefix_inc(); + } +} +impl MoveConstructible for Item { + fn move_constructor(this: &Ptr, other: Ptr) { + field!((*this), value).write(other.with(|__s| __s.value)); + (*moves_3.with(Value::clone).borrow_mut()).prefix_inc(); + field!(other, value).write(-1_i32); + } +} impl Clone for Item { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(Item { @@ -762,19 +775,6 @@ impl ItemImpl for Ptr { (*made_1.with(Value::clone).borrow_mut()).prefix_inc(); } } -impl CopyConstructible for Item { - fn copy_constructor(this: &Ptr, other: Ptr) { - field!((*this), value).write(other.with(|__s| __s.value)); - (*copies_2.with(Value::clone).borrow_mut()).prefix_inc(); - } -} -impl MoveConstructible for Item { - fn move_constructor(this: &Ptr, other: Ptr) { - field!((*this), value).write(other.with(|__s| __s.value)); - (*moves_3.with(Value::clone).borrow_mut()).prefix_inc(); - field!(other, value).write(-1_i32); - } -} pub trait RefItemImpl { fn construct_1(&self); fn construct_2(&self, counter: Ptr, amount: i32); diff --git a/tests/unit/out/refcount/map_try_emplace_lvalues.rs b/tests/unit/out/refcount/map_try_emplace_lvalues.rs index d2757625a5..e976b7b744 100644 --- a/tests/unit/out/refcount/map_try_emplace_lvalues.rs +++ b/tests/unit/out/refcount/map_try_emplace_lvalues.rs @@ -122,6 +122,20 @@ pub struct Owner { #[byte_size(8)] pub ptr: Option>, } +impl MoveConstructible for Owner { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), ptr) + .write(field!(_a0, ptr).with_mut(|__v: &mut Option>| __v.take())); + } +} +impl MoveAssignable for Owner { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), ptr).with_mut(|__b0| { + (*__b0) = field!(_a0, ptr).with_mut(|__v: &mut Option>| __v.take()); + }); + return (*this).clone(); + } +} impl Default for Owner { fn default() -> Self { { @@ -2494,20 +2508,6 @@ impl OwnerImpl for Ptr { return field_ptr!((*self).with(|__s| __s.ptr.clone()).as_pointer(), n); } } -impl MoveAssignable for Owner { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), ptr).with_mut(|__b0| { - (*__b0) = field!(_a0, ptr).with_mut(|__v: &mut Option>| __v.take()); - }); - return (*this).clone(); - } -} -impl MoveConstructible for Owner { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), ptr) - .write(field!(_a0, ptr).with_mut(|__v: &mut Option>| __v.take())); - } -} pub trait TemporaryImpl { fn construct(&self); } diff --git a/tests/unit/out/refcount/max.rs b/tests/unit/out/refcount/max.rs index 88e283b4b6..fc268c3828 100644 --- a/tests/unit/out/refcount/max.rs +++ b/tests/unit/out/refcount/max.rs @@ -37,6 +37,18 @@ pub struct Bag { #[offset(0)] pub n: i32, } +impl CopyConstructible for Bag { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), n).write(o.with(|__s| __s.n)); + (*calls_0.with(Value::clone).borrow_mut()).prefix_inc(); + } +} +impl CopyAssignable for Bag { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), n).write(_a0.with(|__s| __s.n)); + return (*this).clone(); + } +} impl CppLess for Bag { fn less(__lhs: &Ptr, __rhs: &Ptr) -> bool { operator_lt_4(__lhs.clone(), __rhs.clone()) @@ -223,18 +235,6 @@ impl BagImpl for Ptr { field!((*self), n).write(n); } } -impl CopyAssignable for Bag { - fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), n).write(_a0.with(|__s| __s.n)); - return (*this).clone(); - } -} -impl CopyConstructible for Bag { - fn copy_constructor(this: &Ptr, o: Ptr) { - field!((*this), n).write(o.with(|__s| __s.n)); - (*calls_0.with(Value::clone).borrow_mut()).prefix_inc(); - } -} pub fn __cpp2rust_init_globals() { let _ = calls_0.with(|_| ()); let _ = xs_1.with(|_| ()); diff --git a/tests/unit/out/refcount/move_assign.rs b/tests/unit/out/refcount/move_assign.rs index 947e784753..ecb69ffc79 100644 --- a/tests/unit/out/refcount/move_assign.rs +++ b/tests/unit/out/refcount/move_assign.rs @@ -13,6 +13,22 @@ pub struct MoveOnly { #[offset(0)] pub v: i32, } +impl MoveConstructible for MoveOnly { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + field!(o, v).write(0); + } +} +impl MoveAssignable for MoveOnly { + fn move_assign(this: &Ptr, o: Ptr) -> Ptr { + if ((*this) == (o)) { + return (*this).clone(); + } + field!((*this), v).write(o.with(|__s| __s.v)); + field!(o, v).write(0); + return (*this).clone(); + } +} #[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg)] #[byte_size(4)] pub struct ConstMoveAssign { @@ -168,20 +184,4 @@ impl MoveOnlyImpl for Ptr { field!((*self), v).write(v); } } -impl MoveAssignable for MoveOnly { - fn move_assign(this: &Ptr, o: Ptr) -> Ptr { - if ((*this) == (o)) { - return (*this).clone(); - } - field!((*this), v).write(o.with(|__s| __s.v)); - field!(o, v).write(0); - return (*this).clone(); - } -} -impl MoveConstructible for MoveOnly { - fn move_constructor(this: &Ptr, o: Ptr) { - field!((*this), v).write(o.with(|__s| __s.v)); - field!(o, v).write(0); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/move_ctor.rs b/tests/unit/out/refcount/move_ctor.rs index 9f8531c6b3..1d99b35f0c 100644 --- a/tests/unit/out/refcount/move_ctor.rs +++ b/tests/unit/out/refcount/move_ctor.rs @@ -13,6 +13,12 @@ pub struct MoveOnly { #[offset(0)] pub v: i32, } +impl MoveConstructible for MoveOnly { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + field!(o, v).write(0); + } +} #[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg)] #[byte_size(4)] pub struct ConstMove { @@ -51,6 +57,21 @@ pub struct ThrowingMove { #[offset(8)] pub moves: i32, } +impl CopyConstructible for ThrowingMove { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + field!((*this), copies).write((o.with(|__s| __s.copies) + 1)); + field!((*this), moves).write(o.with(|__s| __s.moves)); + } +} +impl MoveConstructible for ThrowingMove { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + field!((*this), copies).write(o.with(|__s| __s.copies)); + field!((*this), moves).write((o.with(|__s| __s.moves) + 1)); + field!(o, v).write(0); + } +} impl Clone for ThrowingMove { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(ThrowingMove { @@ -84,6 +105,21 @@ pub struct NoexceptMove { #[offset(8)] pub moves: i32, } +impl CopyConstructible for NoexceptMove { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + field!((*this), copies).write((o.with(|__s| __s.copies) + 1)); + field!((*this), moves).write(o.with(|__s| __s.moves)); + } +} +impl MoveConstructible for NoexceptMove { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + field!((*this), copies).write(o.with(|__s| __s.copies)); + field!((*this), moves).write((o.with(|__s| __s.moves) + 1)); + field!(o, v).write(0); + } +} impl Clone for NoexceptMove { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(NoexceptMove { @@ -275,12 +311,6 @@ impl MoveOnlyImpl for Ptr { field!((*self), v).write(v); } } -impl MoveConstructible for MoveOnly { - fn move_constructor(this: &Ptr, o: Ptr) { - field!((*this), v).write(o.with(|__s| __s.v)); - field!(o, v).write(0); - } -} pub trait NoexceptMoveImpl { fn construct(&self, v: i32); } @@ -291,21 +321,6 @@ impl NoexceptMoveImpl for Ptr { field!((*self), moves).write(0); } } -impl CopyConstructible for NoexceptMove { - fn copy_constructor(this: &Ptr, o: Ptr) { - field!((*this), v).write(o.with(|__s| __s.v)); - field!((*this), copies).write((o.with(|__s| __s.copies) + 1)); - field!((*this), moves).write(o.with(|__s| __s.moves)); - } -} -impl MoveConstructible for NoexceptMove { - fn move_constructor(this: &Ptr, o: Ptr) { - field!((*this), v).write(o.with(|__s| __s.v)); - field!((*this), copies).write(o.with(|__s| __s.copies)); - field!((*this), moves).write((o.with(|__s| __s.moves) + 1)); - field!(o, v).write(0); - } -} pub trait ThrowingMoveImpl { fn construct(&self, v: i32); } @@ -316,19 +331,4 @@ impl ThrowingMoveImpl for Ptr { field!((*self), moves).write(0); } } -impl CopyConstructible for ThrowingMove { - fn copy_constructor(this: &Ptr, o: Ptr) { - field!((*this), v).write(o.with(|__s| __s.v)); - field!((*this), copies).write((o.with(|__s| __s.copies) + 1)); - field!((*this), moves).write(o.with(|__s| __s.moves)); - } -} -impl MoveConstructible for ThrowingMove { - fn move_constructor(this: &Ptr, o: Ptr) { - field!((*this), v).write(o.with(|__s| __s.v)); - field!((*this), copies).write(o.with(|__s| __s.copies)); - field!((*this), moves).write((o.with(|__s| __s.moves) + 1)); - field!(o, v).write(0); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/move_this.rs b/tests/unit/out/refcount/move_this.rs index caac1e71ff..ec4ac6b5e7 100644 --- a/tests/unit/out/refcount/move_this.rs +++ b/tests/unit/out/refcount/move_this.rs @@ -23,6 +23,17 @@ pub struct Chain { #[offset(0)] pub v: i32, } +impl CopyConstructible for Chain { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write((o.with(|__s| __s.v) + 100)); + } +} +impl MoveConstructible for Chain { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write((o.with(|__s| __s.v) + 1)); + field!(o, v).write(0); + } +} impl Clone for Chain { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(Chain { v: self.v.clone() })); @@ -141,15 +152,4 @@ impl ChainImpl for Ptr { return (*self).clone(); } } -impl CopyConstructible for Chain { - fn copy_constructor(this: &Ptr, o: Ptr) { - field!((*this), v).write((o.with(|__s| __s.v) + 100)); - } -} -impl MoveConstructible for Chain { - fn move_constructor(this: &Ptr, o: Ptr) { - field!((*this), v).write((o.with(|__s| __s.v) + 1)); - field!(o, v).write(0); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/operator_comparison_noncopyable.rs b/tests/unit/out/refcount/operator_comparison_noncopyable.rs index 2dec5cb0ac..ca82519550 100644 --- a/tests/unit/out/refcount/operator_comparison_noncopyable.rs +++ b/tests/unit/out/refcount/operator_comparison_noncopyable.rs @@ -19,6 +19,11 @@ pub struct S { #[offset(0)] data_: i32, } +impl MoveConstructible for S { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), data_).write({ (*_a0.upgrade().deref()).data_ }); + } +} impl CppLess for S { fn less(__lhs: &Ptr, __rhs: &Ptr) -> bool { operator_lt_1(__lhs.clone(), __rhs.clone()) @@ -62,9 +67,4 @@ impl SImpl for Ptr { field!((*self), data_).write(data); } } -impl MoveConstructible for S { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), data_).write({ (*_a0.upgrade().deref()).data_ }); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/push_emplace_back.rs b/tests/unit/out/refcount/push_emplace_back.rs index 15a7b17381..50362c4314 100644 --- a/tests/unit/out/refcount/push_emplace_back.rs +++ b/tests/unit/out/refcount/push_emplace_back.rs @@ -67,6 +67,23 @@ pub struct JPEGData { #[byte_size(24)] pub app_data: Vec>, } +impl MoveConstructible for JPEGData { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), com_data).write(field!(_a0, com_data).with_mut(std::mem::take)); + field!((*this), app_data).write(field!(_a0, app_data).with_mut(std::mem::take)); + } +} +impl MoveAssignable for JPEGData { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), com_data).with_mut(|__b0| { + (*__b0) = field!(_a0, com_data).with_mut(std::mem::take); + }); + field!((*this), app_data).with_mut(|__b0| { + (*__b0) = field!(_a0, app_data).with_mut(std::mem::take); + }); + return (*this).clone(); + } +} pub fn push_param_0(mut dest: Ptr>>) { { let __a1 = Vec::new(); @@ -336,6 +353,27 @@ pub struct Bytes { #[array_len(3)] pub b: Box<[u8]>, } +impl MoveConstructible for Bytes { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), v).write(field!(_a0, v).with_mut(std::mem::take)); + field!((*this), b).write(Box::new(std::array::from_fn::<_, 3, _>(|__i: usize| { + (*_a0.upgrade().deref()).b[(__i) as usize] + }))); + } +} +impl MoveAssignable for Bytes { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), v).with_mut(|__b0| { + (*__b0) = field!(_a0, v).with_mut(std::mem::take); + }); + { + let mut __tmp_13 = { (array_field_ptr!((*this), b)).to_any() }; + __tmp_13.memcpy(&(array_field_ptr!(_a0, b)).to_any(), 3_usize); + (__tmp_13).clone() + }; + return (*this).clone(); + } +} impl Default for Bytes { fn default() -> Self { { @@ -678,27 +716,6 @@ fn main_0() -> i32 { ); return 0; } -impl MoveAssignable for Bytes { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), v).with_mut(|__b0| { - (*__b0) = field!(_a0, v).with_mut(std::mem::take); - }); - { - let mut __tmp_13 = { (array_field_ptr!((*this), b)).to_any() }; - __tmp_13.memcpy(&(array_field_ptr!(_a0, b)).to_any(), 3_usize); - (__tmp_13).clone() - }; - return (*this).clone(); - } -} -impl MoveConstructible for Bytes { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), v).write(field!(_a0, v).with_mut(std::mem::take)); - field!((*this), b).write(Box::new(std::array::from_fn::<_, 3, _>(|__i: usize| { - (*_a0.upgrade().deref()).b[(__i) as usize] - }))); - } -} pub trait CountedImpl { fn construct(&self, _a0: i32); } @@ -712,23 +729,6 @@ impl CountedImpl for Ptr { ); } } -impl MoveAssignable for JPEGData { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), com_data).with_mut(|__b0| { - (*__b0) = field!(_a0, com_data).with_mut(std::mem::take); - }); - field!((*this), app_data).with_mut(|__b0| { - (*__b0) = field!(_a0, app_data).with_mut(std::mem::take); - }); - return (*this).clone(); - } -} -impl MoveConstructible for JPEGData { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), com_data).write(field!(_a0, com_data).with_mut(std::mem::take)); - field!((*this), app_data).write(field!(_a0, app_data).with_mut(std::mem::take)); - } -} pub trait PairImpl { fn construct_2(&self); fn construct_1(&self, a: i32); diff --git a/tests/unit/out/refcount/rule_of_five.rs b/tests/unit/out/refcount/rule_of_five.rs index 04f1239558..18f775d606 100644 --- a/tests/unit/out/refcount/rule_of_five.rs +++ b/tests/unit/out/refcount/rule_of_five.rs @@ -26,6 +26,82 @@ pub struct Buffer { #[offset(16)] pub size: i32, } +impl CopyConstructible for Buffer { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), data).write((0..4).map(|_| 0_i32).collect::>()); + field!((*this), size).write(o.with(|__s| __s.size)); + { + let mut i: i32 = 0; + 'loop_: while (i < 4) { + 'for_body: { + array_elem!((*this), data, i).write((array_elem!(o, data, i).read())); + } + i.prefix_inc(); + } + } + (*alive_0.with(Value::clone).borrow_mut()).prefix_inc(); + (*copies_1.with(Value::clone).borrow_mut()).prefix_inc(); + } +} +impl MoveConstructible for Buffer { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), data).write((0..4).map(|_| 0_i32).collect::>()); + field!((*this), size).write(o.with(|__s| __s.size)); + { + let mut i: i32 = 0; + 'loop_: while (i < 4) { + 'for_body: { + array_elem!((*this), data, i).write((array_elem!(o, data, i).read())); + array_elem!(o, data, i).write(-1_i32); + } + i.prefix_inc(); + } + } + field!(o, size).write(0); + (*alive_0.with(Value::clone).borrow_mut()).prefix_inc(); + (*moves_2.with(Value::clone).borrow_mut()).prefix_inc(); + } +} +impl CopyAssignable for Buffer { + fn copy_assign(this: &Ptr, o: Ptr) -> Ptr { + if ((*this) == (o)) { + return (*this).clone(); + } + field!((*this), size).write(o.with(|__s| __s.size)); + { + let mut i: i32 = 0; + 'loop_: while (i < 4) { + 'for_body: { + array_elem!((*this), data, i).write((array_elem!(o, data, i).read())); + } + i.prefix_inc(); + } + } + (*copies_1.with(Value::clone).borrow_mut()).prefix_inc(); + return (*this).clone(); + } +} +impl MoveAssignable for Buffer { + fn move_assign(this: &Ptr, o: Ptr) -> Ptr { + if ((*this) == (o)) { + return (*this).clone(); + } + field!((*this), size).write(o.with(|__s| __s.size)); + { + let mut i: i32 = 0; + 'loop_: while (i < 4) { + 'for_body: { + array_elem!((*this), data, i).write((array_elem!(o, data, i).read())); + array_elem!(o, data, i).write(-1_i32); + } + i.prefix_inc(); + } + } + field!(o, size).write(0); + (*moves_2.with(Value::clone).borrow_mut()).prefix_inc(); + return (*this).clone(); + } +} impl Clone for Buffer { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(Buffer { @@ -141,82 +217,6 @@ impl BufferImpl for Ptr { (*alive_0.with(Value::clone).borrow_mut()).prefix_dec(); } } -impl CopyAssignable for Buffer { - fn copy_assign(this: &Ptr, o: Ptr) -> Ptr { - if ((*this) == (o)) { - return (*this).clone(); - } - field!((*this), size).write(o.with(|__s| __s.size)); - { - let mut i: i32 = 0; - 'loop_: while (i < 4) { - 'for_body: { - array_elem!((*this), data, i).write((array_elem!(o, data, i).read())); - } - i.prefix_inc(); - } - } - (*copies_1.with(Value::clone).borrow_mut()).prefix_inc(); - return (*this).clone(); - } -} -impl CopyConstructible for Buffer { - fn copy_constructor(this: &Ptr, o: Ptr) { - field!((*this), data).write((0..4).map(|_| 0_i32).collect::>()); - field!((*this), size).write(o.with(|__s| __s.size)); - { - let mut i: i32 = 0; - 'loop_: while (i < 4) { - 'for_body: { - array_elem!((*this), data, i).write((array_elem!(o, data, i).read())); - } - i.prefix_inc(); - } - } - (*alive_0.with(Value::clone).borrow_mut()).prefix_inc(); - (*copies_1.with(Value::clone).borrow_mut()).prefix_inc(); - } -} -impl MoveAssignable for Buffer { - fn move_assign(this: &Ptr, o: Ptr) -> Ptr { - if ((*this) == (o)) { - return (*this).clone(); - } - field!((*this), size).write(o.with(|__s| __s.size)); - { - let mut i: i32 = 0; - 'loop_: while (i < 4) { - 'for_body: { - array_elem!((*this), data, i).write((array_elem!(o, data, i).read())); - array_elem!(o, data, i).write(-1_i32); - } - i.prefix_inc(); - } - } - field!(o, size).write(0); - (*moves_2.with(Value::clone).borrow_mut()).prefix_inc(); - return (*this).clone(); - } -} -impl MoveConstructible for Buffer { - fn move_constructor(this: &Ptr, o: Ptr) { - field!((*this), data).write((0..4).map(|_| 0_i32).collect::>()); - field!((*this), size).write(o.with(|__s| __s.size)); - { - let mut i: i32 = 0; - 'loop_: while (i < 4) { - 'for_body: { - array_elem!((*this), data, i).write((array_elem!(o, data, i).read())); - array_elem!(o, data, i).write(-1_i32); - } - i.prefix_inc(); - } - } - field!(o, size).write(0); - (*alive_0.with(Value::clone).borrow_mut()).prefix_inc(); - (*moves_2.with(Value::clone).borrow_mut()).prefix_inc(); - } -} pub fn __cpp2rust_init_globals() { let _ = alive_0.with(|_| ()); let _ = copies_1.with(|_| ()); diff --git a/tests/unit/out/refcount/rule_of_three.rs b/tests/unit/out/refcount/rule_of_three.rs index 81884ecd78..832f39f4c7 100644 --- a/tests/unit/out/refcount/rule_of_three.rs +++ b/tests/unit/out/refcount/rule_of_three.rs @@ -33,6 +33,42 @@ pub struct Buffer { #[offset(16)] pub size: i32, } +impl CopyConstructible for Buffer { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), data).write((0..4).map(|_| 0_i32).collect::>()); + field!((*this), size).write(o.with(|__s| __s.size)); + { + let mut i: i32 = 0; + 'loop_: while (i < 4) { + 'for_body: { + array_elem!((*this), data, i).write((array_elem!(o, data, i).read())); + } + i.prefix_inc(); + } + } + (*alive_0.with(Value::clone).borrow_mut()).prefix_inc(); + (*copies_1.with(Value::clone).borrow_mut()).prefix_inc(); + } +} +impl CopyAssignable for Buffer { + fn copy_assign(this: &Ptr, o: Ptr) -> Ptr { + if ((*this) == (o)) { + return (*this).clone(); + } + field!((*this), size).write(o.with(|__s| __s.size)); + { + let mut i: i32 = 0; + 'loop_: while (i < 4) { + 'for_body: { + array_elem!((*this), data, i).write((array_elem!(o, data, i).read())); + } + i.prefix_inc(); + } + } + (*copies_1.with(Value::clone).borrow_mut()).prefix_inc(); + return (*this).clone(); + } +} impl Clone for Buffer { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(Buffer { @@ -145,42 +181,6 @@ impl BufferImpl for Ptr { (*alive_0.with(Value::clone).borrow_mut()).prefix_dec(); } } -impl CopyAssignable for Buffer { - fn copy_assign(this: &Ptr, o: Ptr) -> Ptr { - if ((*this) == (o)) { - return (*this).clone(); - } - field!((*this), size).write(o.with(|__s| __s.size)); - { - let mut i: i32 = 0; - 'loop_: while (i < 4) { - 'for_body: { - array_elem!((*this), data, i).write((array_elem!(o, data, i).read())); - } - i.prefix_inc(); - } - } - (*copies_1.with(Value::clone).borrow_mut()).prefix_inc(); - return (*this).clone(); - } -} -impl CopyConstructible for Buffer { - fn copy_constructor(this: &Ptr, o: Ptr) { - field!((*this), data).write((0..4).map(|_| 0_i32).collect::>()); - field!((*this), size).write(o.with(|__s| __s.size)); - { - let mut i: i32 = 0; - 'loop_: while (i < 4) { - 'for_body: { - array_elem!((*this), data, i).write((array_elem!(o, data, i).read())); - } - i.prefix_inc(); - } - } - (*alive_0.with(Value::clone).borrow_mut()).prefix_inc(); - (*copies_1.with(Value::clone).borrow_mut()).prefix_inc(); - } -} pub fn __cpp2rust_init_globals() { let _ = alive_0.with(|_| ()); let _ = copies_1.with(|_| ()); diff --git a/tests/unit/out/refcount/rvalue_rule_arg_move.rs b/tests/unit/out/refcount/rvalue_rule_arg_move.rs index c4a02cf356..936f98ecff 100644 --- a/tests/unit/out/refcount/rvalue_rule_arg_move.rs +++ b/tests/unit/out/refcount/rvalue_rule_arg_move.rs @@ -21,6 +21,24 @@ pub struct Elem { #[offset(0)] pub v: i32, } +impl CopyConstructible for Elem { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); + } +} +impl MoveConstructible for Elem { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + (*moves_1.with(Value::clone).borrow_mut()).prefix_inc(); + } +} +impl CopyAssignable for Elem { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), v).write(_a0.with(|__s| __s.v)); + return (*this).clone(); + } +} impl Clone for Elem { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(Elem { v: self.v.clone() })); @@ -86,24 +104,6 @@ impl ElemImpl for Ptr { field!((*self), v).write(v); } } -impl CopyAssignable for Elem { - fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), v).write(_a0.with(|__s| __s.v)); - return (*this).clone(); - } -} -impl CopyConstructible for Elem { - fn copy_constructor(this: &Ptr, o: Ptr) { - field!((*this), v).write(o.with(|__s| __s.v)); - (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); - } -} -impl MoveConstructible for Elem { - fn move_constructor(this: &Ptr, o: Ptr) { - field!((*this), v).write(o.with(|__s| __s.v)); - (*moves_1.with(Value::clone).borrow_mut()).prefix_inc(); - } -} pub fn __cpp2rust_init_globals() { let _ = copies_0.with(|_| ()); let _ = moves_1.with(|_| ()); diff --git a/tests/unit/out/refcount/sort_no_copy.rs b/tests/unit/out/refcount/sort_no_copy.rs index ac120137c8..022db88dcf 100644 --- a/tests/unit/out/refcount/sort_no_copy.rs +++ b/tests/unit/out/refcount/sort_no_copy.rs @@ -16,6 +16,30 @@ pub struct Tracked { #[offset(0)] pub v: i32, } +impl CopyConstructible for Tracked { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); + } +} +impl MoveConstructible for Tracked { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + } +} +impl CopyAssignable for Tracked { + fn copy_assign(this: &Ptr, o: Ptr) -> Ptr { + field!((*this), v).write(o.with(|__s| __s.v)); + (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); + return (*this).clone(); + } +} +impl MoveAssignable for Tracked { + fn move_assign(this: &Ptr, o: Ptr) -> Ptr { + field!((*this), v).write(o.with(|__s| __s.v)); + return (*this).clone(); + } +} impl CppLess for Tracked { fn less(__lhs: &Ptr, __rhs: &Ptr) -> bool { operator_lt_1(__lhs.clone(), __rhs.clone()) @@ -59,6 +83,17 @@ pub struct MoveOnly { #[offset(0)] pub v: i32, } +impl MoveConstructible for MoveOnly { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), v).write({ (*_a0.upgrade().deref()).v }); + } +} +impl MoveAssignable for MoveOnly { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), v).write({ (*_a0.upgrade().deref()).v }); + return (*this).clone(); + } +} impl CppLess for MoveOnly { fn less(__lhs: &Ptr, __rhs: &Ptr) -> bool { operator_lt_3(__lhs.clone(), __rhs.clone()) @@ -90,6 +125,19 @@ pub struct Bag { #[byte_size(24)] pub items: Vec, } +impl MoveConstructible for Bag { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), items).write(field!(_a0, items).with_mut(std::mem::take)); + } +} +impl MoveAssignable for Bag { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), items).with_mut(|__b0| { + (*__b0) = field!(_a0, items).with_mut(std::mem::take); + }); + return (*this).clone(); + } +} impl CppLess for Bag { fn less(__lhs: &Ptr, __rhs: &Ptr) -> bool { operator_lt_4(__lhs.clone(), __rhs.clone()) @@ -555,19 +603,6 @@ fn main_0() -> i32 { ); return copies_0.with(|rc| *rc.borrow()); } -impl MoveAssignable for Bag { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), items).with_mut(|__b0| { - (*__b0) = field!(_a0, items).with_mut(std::mem::take); - }); - return (*this).clone(); - } -} -impl MoveConstructible for Bag { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), items).write(field!(_a0, items).with_mut(std::mem::take)); - } -} pub trait MoveOnlyImpl { fn construct(&self, v: i32); } @@ -576,17 +611,6 @@ impl MoveOnlyImpl for Ptr { field!((*self), v).write(v); } } -impl MoveAssignable for MoveOnly { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), v).write({ (*_a0.upgrade().deref()).v }); - return (*this).clone(); - } -} -impl MoveConstructible for MoveOnly { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), v).write({ (*_a0.upgrade().deref()).v }); - } -} pub trait TrackedImpl { fn construct_2(&self); fn construct_1(&self, v: i32); @@ -599,30 +623,6 @@ impl TrackedImpl for Ptr { field!((*self), v).write(v); } } -impl CopyAssignable for Tracked { - fn copy_assign(this: &Ptr, o: Ptr) -> Ptr { - field!((*this), v).write(o.with(|__s| __s.v)); - (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); - return (*this).clone(); - } -} -impl CopyConstructible for Tracked { - fn copy_constructor(this: &Ptr, o: Ptr) { - field!((*this), v).write(o.with(|__s| __s.v)); - (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); - } -} -impl MoveAssignable for Tracked { - fn move_assign(this: &Ptr, o: Ptr) -> Ptr { - field!((*this), v).write(o.with(|__s| __s.v)); - return (*this).clone(); - } -} -impl MoveConstructible for Tracked { - fn move_constructor(this: &Ptr, o: Ptr) { - field!((*this), v).write(o.with(|__s| __s.v)); - } -} pub fn __cpp2rust_init_globals() { let _ = copies_0.with(|_| ()); } diff --git a/tests/unit/out/refcount/structured_binding_copy_ctor.rs b/tests/unit/out/refcount/structured_binding_copy_ctor.rs index baf5cd52dc..d90ef8dcc9 100644 --- a/tests/unit/out/refcount/structured_binding_copy_ctor.rs +++ b/tests/unit/out/refcount/structured_binding_copy_ctor.rs @@ -26,6 +26,20 @@ pub struct Counted { #[offset(4)] pub y: i32, } +impl CopyConstructible for Counted { + fn copy_constructor(this: &Ptr, other: Ptr) { + field!((*this), x).write((other.with(|__s| __s.x) * 2)); + field!((*this), y).write((other.with(|__s| __s.y) * 2)); + (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); + } +} +impl CopyAssignable for Counted { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), x).write(_a0.with(|__s| __s.x)); + field!((*this), y).write(_a0.with(|__s| __s.y)); + return (*this).clone(); + } +} impl Clone for Counted { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(Counted { @@ -84,20 +98,6 @@ impl CountedImpl for Ptr { field!((*self), y).write(y); } } -impl CopyAssignable for Counted { - fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), x).write(_a0.with(|__s| __s.x)); - field!((*this), y).write(_a0.with(|__s| __s.y)); - return (*this).clone(); - } -} -impl CopyConstructible for Counted { - fn copy_constructor(this: &Ptr, other: Ptr) { - field!((*this), x).write((other.with(|__s| __s.x) * 2)); - field!((*this), y).write((other.with(|__s| __s.y) * 2)); - (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); - } -} pub fn __cpp2rust_init_globals() { let _ = copies_0.with(|_| ()); } diff --git a/tests/unit/out/refcount/structured_binding_element_ctor.rs b/tests/unit/out/refcount/structured_binding_element_ctor.rs index 40dc29f789..c23cccac6d 100644 --- a/tests/unit/out/refcount/structured_binding_element_ctor.rs +++ b/tests/unit/out/refcount/structured_binding_element_ctor.rs @@ -29,6 +29,19 @@ pub struct Elem { #[offset(0)] pub v: i32, } +impl CopyConstructible for Elem { + fn copy_constructor(this: &Ptr, other: Ptr) { + field!((*this), v).write((other.with(|__s| __s.v) + 100)); + (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); + } +} +impl MoveConstructible for Elem { + fn move_constructor(this: &Ptr, other: Ptr) { + field!((*this), v).write((other.with(|__s| __s.v) + 1000)); + field!(other, v).write(-1_i32); + (*moves_1.with(Value::clone).borrow_mut()).prefix_inc(); + } +} impl Clone for Elem { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(Elem { v: self.v.clone() })); @@ -58,6 +71,20 @@ pub struct Two { #[byte_size(4)] pub b: Elem, } +impl MoveConstructible for Two { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), a).write({ + let __v: Value = Rc::new(RefCell::new(::zero_init())); + MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, a) }); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }); + field!((*this), b).write({ + let __v: Value = Rc::new(RefCell::new(::zero_init())); + MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, b) }); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }); + } +} pub fn make_two_2() -> Two { return Two { a: { @@ -148,33 +175,6 @@ impl ElemImpl for Ptr { field!((*self), v).write(v); } } -impl CopyConstructible for Elem { - fn copy_constructor(this: &Ptr, other: Ptr) { - field!((*this), v).write((other.with(|__s| __s.v) + 100)); - (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); - } -} -impl MoveConstructible for Elem { - fn move_constructor(this: &Ptr, other: Ptr) { - field!((*this), v).write((other.with(|__s| __s.v) + 1000)); - field!(other, v).write(-1_i32); - (*moves_1.with(Value::clone).borrow_mut()).prefix_inc(); - } -} -impl MoveConstructible for Two { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), a).write({ - let __v: Value = Rc::new(RefCell::new(::zero_init())); - MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, a) }); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }); - field!((*this), b).write({ - let __v: Value = Rc::new(RefCell::new(::zero_init())); - MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, b) }); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }); - } -} pub fn __cpp2rust_init_globals() { let _ = copies_0.with(|_| ()); let _ = moves_1.with(|_| ()); diff --git a/tests/unit/out/refcount/structured_binding_move_ctor.rs b/tests/unit/out/refcount/structured_binding_move_ctor.rs index f7dbdd9854..9caeed5b80 100644 --- a/tests/unit/out/refcount/structured_binding_move_ctor.rs +++ b/tests/unit/out/refcount/structured_binding_move_ctor.rs @@ -22,6 +22,22 @@ pub struct Movable { #[offset(4)] pub y: i32, } +impl CopyConstructible for Movable { + fn copy_constructor(this: &Ptr, other: Ptr) { + field!((*this), x).write(other.with(|__s| __s.x)); + field!((*this), y).write(other.with(|__s| __s.y)); + (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); + } +} +impl MoveConstructible for Movable { + fn move_constructor(this: &Ptr, other: Ptr) { + field!((*this), x).write(other.with(|__s| __s.x)); + field!((*this), y).write(other.with(|__s| __s.y)); + field!(other, x).write(0); + field!(other, y).write(0); + (*moves_1.with(Value::clone).borrow_mut()).prefix_inc(); + } +} impl Clone for Movable { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(Movable { @@ -53,6 +69,23 @@ pub struct Holder { #[byte_size(24)] pub ys: Vec, } +impl MoveConstructible for Holder { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), xs).write(field!(_a0, xs).with_mut(std::mem::take)); + field!((*this), ys).write(field!(_a0, ys).with_mut(std::mem::take)); + } +} +impl MoveAssignable for Holder { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), xs).with_mut(|__b0| { + (*__b0) = field!(_a0, xs).with_mut(std::mem::take); + }); + field!((*this), ys).with_mut(|__b0| { + (*__b0) = field!(_a0, ys).with_mut(std::mem::take); + }); + return (*this).clone(); + } +} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); @@ -99,23 +132,6 @@ impl HolderImpl for Ptr { }; } } -impl MoveAssignable for Holder { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), xs).with_mut(|__b0| { - (*__b0) = field!(_a0, xs).with_mut(std::mem::take); - }); - field!((*this), ys).with_mut(|__b0| { - (*__b0) = field!(_a0, ys).with_mut(std::mem::take); - }); - return (*this).clone(); - } -} -impl MoveConstructible for Holder { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), xs).write(field!(_a0, xs).with_mut(std::mem::take)); - field!((*this), ys).write(field!(_a0, ys).with_mut(std::mem::take)); - } -} pub trait MovableImpl { fn construct(&self, x: i32, y: i32); } @@ -125,22 +141,6 @@ impl MovableImpl for Ptr { field!((*self), y).write(y); } } -impl CopyConstructible for Movable { - fn copy_constructor(this: &Ptr, other: Ptr) { - field!((*this), x).write(other.with(|__s| __s.x)); - field!((*this), y).write(other.with(|__s| __s.y)); - (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); - } -} -impl MoveConstructible for Movable { - fn move_constructor(this: &Ptr, other: Ptr) { - field!((*this), x).write(other.with(|__s| __s.x)); - field!((*this), y).write(other.with(|__s| __s.y)); - field!(other, x).write(0); - field!(other, y).write(0); - (*moves_1.with(Value::clone).borrow_mut()).prefix_inc(); - } -} pub fn __cpp2rust_init_globals() { let _ = copies_0.with(|_| ()); let _ = moves_1.with(|_| ()); diff --git a/tests/unit/out/refcount/swap_map_no_copy.rs b/tests/unit/out/refcount/swap_map_no_copy.rs index d284cd1bee..a6b2494d1f 100644 --- a/tests/unit/out/refcount/swap_map_no_copy.rs +++ b/tests/unit/out/refcount/swap_map_no_copy.rs @@ -16,6 +16,30 @@ pub struct Tracked { #[offset(0)] pub v: i32, } +impl CopyConstructible for Tracked { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); + } +} +impl MoveConstructible for Tracked { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + } +} +impl CopyAssignable for Tracked { + fn copy_assign(this: &Ptr, o: Ptr) -> Ptr { + field!((*this), v).write(o.with(|__s| __s.v)); + (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); + return (*this).clone(); + } +} +impl MoveAssignable for Tracked { + fn move_assign(this: &Ptr, o: Ptr) -> Ptr { + field!((*this), v).write(o.with(|__s| __s.v)); + return (*this).clone(); + } +} impl Clone for Tracked { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(Tracked { v: self.v.clone() })); @@ -47,6 +71,34 @@ pub struct Pair { #[byte_size(4)] pub y: Tracked, } +impl MoveConstructible for Pair { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), x).write({ + let __v: Value = Rc::new(RefCell::new(::zero_init())); + MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, x) }); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }); + field!((*this), y).write({ + let __v: Value = Rc::new(RefCell::new(::zero_init())); + MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, y) }); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }); + } +} +impl CopyAssignable for Pair { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + ({ CopyAssignable::copy_assign(&field_ptr!((*this), x), field_ptr!(_a0, x)) }); + ({ CopyAssignable::copy_assign(&field_ptr!((*this), y), field_ptr!(_a0, y)) }); + return (*this).clone(); + } +} +impl MoveAssignable for Pair { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + ({ MoveAssignable::move_assign(&field_ptr!((*this), x), field_ptr!(_a0, x)) }); + ({ MoveAssignable::move_assign(&field_ptr!((*this), y), field_ptr!(_a0, y)) }); + return (*this).clone(); + } +} #[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyConstructible)] #[byte_size(16)] pub struct Arrays { @@ -59,6 +111,90 @@ pub struct Arrays { #[array_len(2)] pub b: Box<[Tracked]>, } +impl MoveConstructible for Arrays { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), a).write(Box::new(std::array::from_fn::<_, 2, _>(|__i: usize| { + let __v: Value = Rc::new(RefCell::new(::zero_init())); + MoveConstructible::move_constructor(&__v.as_pointer(), { + array_field_ptr!(_a0, a).offset(__i) + }); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }))); + field!((*this), b).write(Box::new(std::array::from_fn::<_, 2, _>(|__i: usize| { + let __v: Value = Rc::new(RefCell::new(::zero_init())); + MoveConstructible::move_constructor(&__v.as_pointer(), { + array_field_ptr!(_a0, b).offset(__i) + }); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }))); + } +} +impl CopyAssignable for Arrays { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + { + let mut __i0: usize = 0_usize; + 'loop_: while (__i0 != 2_usize) { + 'for_body: { + ({ + CopyAssignable::copy_assign( + &array_field_ptr!((*this), a).offset((__i0) as isize), + array_field_ptr!(_a0, a).offset((__i0) as isize), + ) + }); + } + __i0.prefix_inc(); + } + } + { + let mut __i0: usize = 0_usize; + 'loop_: while (__i0 != 2_usize) { + 'for_body: { + ({ + CopyAssignable::copy_assign( + &array_field_ptr!((*this), b).offset((__i0) as isize), + array_field_ptr!(_a0, b).offset((__i0) as isize), + ) + }); + } + __i0.prefix_inc(); + } + } + return (*this).clone(); + } +} +impl MoveAssignable for Arrays { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + { + let mut __i0: usize = 0_usize; + 'loop_: while (__i0 != 2_usize) { + 'for_body: { + ({ + MoveAssignable::move_assign( + &array_field_ptr!((*this), a).offset((__i0) as isize), + array_field_ptr!(_a0, a).offset((__i0) as isize), + ) + }); + } + __i0.prefix_inc(); + } + } + { + let mut __i0: usize = 0_usize; + 'loop_: while (__i0 != 2_usize) { + 'for_body: { + ({ + MoveAssignable::move_assign( + &array_field_ptr!((*this), b).offset((__i0) as isize), + array_field_ptr!(_a0, b).offset((__i0) as isize), + ) + }); + } + __i0.prefix_inc(); + } + } + return (*this).clone(); + } +} impl Default for Arrays { fn default() -> Self { { @@ -97,6 +233,19 @@ pub struct CopyOnly { #[offset(0)] pub v: i32, } +impl CopyConstructible for CopyOnly { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + (*copy_only_copies_1.with(Value::clone).borrow_mut()).prefix_inc(); + } +} +impl CopyAssignable for CopyOnly { + fn copy_assign(this: &Ptr, o: Ptr) -> Ptr { + field!((*this), v).write(o.with(|__s| __s.v)); + (*copy_only_copies_1.with(Value::clone).borrow_mut()).prefix_inc(); + return (*this).clone(); + } +} impl Clone for CopyOnly { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(CopyOnly { v: self.v.clone() })); @@ -127,6 +276,13 @@ pub struct CopyOnlyPair { #[byte_size(4)] pub y: CopyOnly, } +impl CopyAssignable for CopyOnlyPair { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + ({ CopyAssignable::copy_assign(&field_ptr!((*this), x), field_ptr!(_a0, x)) }); + ({ CopyAssignable::copy_assign(&field_ptr!((*this), y), field_ptr!(_a0, y)) }); + return (*this).clone(); + } +} thread_local!( pub static moves_3: Value = Rc::new(RefCell::new(0)); ); @@ -143,6 +299,34 @@ pub struct Moved { #[offset(0)] pub v: i32, } +impl CopyConstructible for Moved { + fn copy_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); + } +} +impl MoveConstructible for Moved { + fn move_constructor(this: &Ptr, o: Ptr) { + field!((*this), v).write(o.with(|__s| __s.v)); + field!(o, v).write(-1_i32); + (*moves_3.with(Value::clone).borrow_mut()).prefix_inc(); + } +} +impl CopyAssignable for Moved { + fn copy_assign(this: &Ptr, o: Ptr) -> Ptr { + field!((*this), v).write(o.with(|__s| __s.v)); + (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); + return (*this).clone(); + } +} +impl MoveAssignable for Moved { + fn move_assign(this: &Ptr, o: Ptr) -> Ptr { + field!((*this), v).write(o.with(|__s| __s.v)); + field!(o, v).write(-1_i32); + (*move_assigns_4.with(Value::clone).borrow_mut()).prefix_inc(); + return (*this).clone(); + } +} impl Clone for Moved { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(Moved { v: self.v.clone() })); @@ -171,6 +355,34 @@ pub struct MovedPair { #[byte_size(4)] pub y: Moved, } +impl MoveConstructible for MovedPair { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), x).write({ + let __v: Value = Rc::new(RefCell::new(::zero_init())); + MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, x) }); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }); + field!((*this), y).write({ + let __v: Value = Rc::new(RefCell::new(::zero_init())); + MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, y) }); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }); + } +} +impl CopyAssignable for MovedPair { + fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { + ({ CopyAssignable::copy_assign(&field_ptr!((*this), x), field_ptr!(_a0, x)) }); + ({ CopyAssignable::copy_assign(&field_ptr!((*this), y), field_ptr!(_a0, y)) }); + return (*this).clone(); + } +} +impl MoveAssignable for MovedPair { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + ({ MoveAssignable::move_assign(&field_ptr!((*this), x), field_ptr!(_a0, x)) }); + ({ MoveAssignable::move_assign(&field_ptr!((*this), y), field_ptr!(_a0, y)) }); + return (*this).clone(); + } +} pub fn swapped_once_6() -> bool { let mut ok: bool = ((moves_3.with(|rc| *rc.borrow()) == 1) && (move_assigns_4.with(|rc| *rc.borrow()) == 2)) @@ -195,6 +407,20 @@ pub struct Owner { #[byte_size(8)] pub p: Option>, } +impl MoveConstructible for Owner { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), p) + .write(field!(_a0, p).with_mut(|__v: &mut Option>| __v.take())); + } +} +impl MoveAssignable for Owner { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), p).with_mut(|__b0| { + (*__b0) = field!(_a0, p).with_mut(|__v: &mut Option>| __v.take()); + }); + return (*this).clone(); + } +} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); @@ -773,90 +999,6 @@ fn main_0() -> i32 { ); return copies_0.with(|rc| *rc.borrow()); } -impl CopyAssignable for Arrays { - fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { - { - let mut __i0: usize = 0_usize; - 'loop_: while (__i0 != 2_usize) { - 'for_body: { - ({ - CopyAssignable::copy_assign( - &array_field_ptr!((*this), a).offset((__i0) as isize), - array_field_ptr!(_a0, a).offset((__i0) as isize), - ) - }); - } - __i0.prefix_inc(); - } - } - { - let mut __i0: usize = 0_usize; - 'loop_: while (__i0 != 2_usize) { - 'for_body: { - ({ - CopyAssignable::copy_assign( - &array_field_ptr!((*this), b).offset((__i0) as isize), - array_field_ptr!(_a0, b).offset((__i0) as isize), - ) - }); - } - __i0.prefix_inc(); - } - } - return (*this).clone(); - } -} -impl MoveAssignable for Arrays { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - { - let mut __i0: usize = 0_usize; - 'loop_: while (__i0 != 2_usize) { - 'for_body: { - ({ - MoveAssignable::move_assign( - &array_field_ptr!((*this), a).offset((__i0) as isize), - array_field_ptr!(_a0, a).offset((__i0) as isize), - ) - }); - } - __i0.prefix_inc(); - } - } - { - let mut __i0: usize = 0_usize; - 'loop_: while (__i0 != 2_usize) { - 'for_body: { - ({ - MoveAssignable::move_assign( - &array_field_ptr!((*this), b).offset((__i0) as isize), - array_field_ptr!(_a0, b).offset((__i0) as isize), - ) - }); - } - __i0.prefix_inc(); - } - } - return (*this).clone(); - } -} -impl MoveConstructible for Arrays { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), a).write(Box::new(std::array::from_fn::<_, 2, _>(|__i: usize| { - let __v: Value = Rc::new(RefCell::new(::zero_init())); - MoveConstructible::move_constructor(&__v.as_pointer(), { - array_field_ptr!(_a0, a).offset(__i) - }); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }))); - field!((*this), b).write(Box::new(std::array::from_fn::<_, 2, _>(|__i: usize| { - let __v: Value = Rc::new(RefCell::new(::zero_init())); - MoveConstructible::move_constructor(&__v.as_pointer(), { - array_field_ptr!(_a0, b).offset(__i) - }); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }))); - } -} pub trait CopyOnlyImpl { fn construct(&self, v: i32); fn destructor(&self); @@ -869,19 +1011,6 @@ impl CopyOnlyImpl for Ptr { (*copy_only_dtors_2.with(Value::clone).borrow_mut()).prefix_inc(); } } -impl CopyAssignable for CopyOnly { - fn copy_assign(this: &Ptr, o: Ptr) -> Ptr { - field!((*this), v).write(o.with(|__s| __s.v)); - (*copy_only_copies_1.with(Value::clone).borrow_mut()).prefix_inc(); - return (*this).clone(); - } -} -impl CopyConstructible for CopyOnly { - fn copy_constructor(this: &Ptr, o: Ptr) { - field!((*this), v).write(o.with(|__s| __s.v)); - (*copy_only_copies_1.with(Value::clone).borrow_mut()).prefix_inc(); - } -} pub trait CopyOnlyPairImpl { fn destructor(&self); } @@ -891,13 +1020,6 @@ impl CopyOnlyPairImpl for Ptr { Destructible::destroy(field_ptr!(self, x)); } } -impl CopyAssignable for CopyOnlyPair { - fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { - ({ CopyAssignable::copy_assign(&field_ptr!((*this), x), field_ptr!(_a0, x)) }); - ({ CopyAssignable::copy_assign(&field_ptr!((*this), y), field_ptr!(_a0, y)) }); - return (*this).clone(); - } -} pub trait MovedImpl { fn construct(&self, v: i32); fn destructor(&self); @@ -910,34 +1032,6 @@ impl MovedImpl for Ptr { (*moved_dtors_5.with(Value::clone).borrow_mut()).prefix_inc(); } } -impl CopyAssignable for Moved { - fn copy_assign(this: &Ptr, o: Ptr) -> Ptr { - field!((*this), v).write(o.with(|__s| __s.v)); - (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); - return (*this).clone(); - } -} -impl CopyConstructible for Moved { - fn copy_constructor(this: &Ptr, o: Ptr) { - field!((*this), v).write(o.with(|__s| __s.v)); - (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); - } -} -impl MoveAssignable for Moved { - fn move_assign(this: &Ptr, o: Ptr) -> Ptr { - field!((*this), v).write(o.with(|__s| __s.v)); - field!(o, v).write(-1_i32); - (*move_assigns_4.with(Value::clone).borrow_mut()).prefix_inc(); - return (*this).clone(); - } -} -impl MoveConstructible for Moved { - fn move_constructor(this: &Ptr, o: Ptr) { - field!((*this), v).write(o.with(|__s| __s.v)); - field!(o, v).write(-1_i32); - (*moves_3.with(Value::clone).borrow_mut()).prefix_inc(); - } -} pub trait MovedPairImpl { fn destructor(&self); } @@ -947,76 +1041,6 @@ impl MovedPairImpl for Ptr { Destructible::destroy(field_ptr!(self, x)); } } -impl CopyAssignable for MovedPair { - fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { - ({ CopyAssignable::copy_assign(&field_ptr!((*this), x), field_ptr!(_a0, x)) }); - ({ CopyAssignable::copy_assign(&field_ptr!((*this), y), field_ptr!(_a0, y)) }); - return (*this).clone(); - } -} -impl MoveAssignable for MovedPair { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - ({ MoveAssignable::move_assign(&field_ptr!((*this), x), field_ptr!(_a0, x)) }); - ({ MoveAssignable::move_assign(&field_ptr!((*this), y), field_ptr!(_a0, y)) }); - return (*this).clone(); - } -} -impl MoveConstructible for MovedPair { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), x).write({ - let __v: Value = Rc::new(RefCell::new(::zero_init())); - MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, x) }); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }); - field!((*this), y).write({ - let __v: Value = Rc::new(RefCell::new(::zero_init())); - MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, y) }); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }); - } -} -impl MoveAssignable for Owner { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), p).with_mut(|__b0| { - (*__b0) = field!(_a0, p).with_mut(|__v: &mut Option>| __v.take()); - }); - return (*this).clone(); - } -} -impl MoveConstructible for Owner { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), p) - .write(field!(_a0, p).with_mut(|__v: &mut Option>| __v.take())); - } -} -impl CopyAssignable for Pair { - fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { - ({ CopyAssignable::copy_assign(&field_ptr!((*this), x), field_ptr!(_a0, x)) }); - ({ CopyAssignable::copy_assign(&field_ptr!((*this), y), field_ptr!(_a0, y)) }); - return (*this).clone(); - } -} -impl MoveAssignable for Pair { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - ({ MoveAssignable::move_assign(&field_ptr!((*this), x), field_ptr!(_a0, x)) }); - ({ MoveAssignable::move_assign(&field_ptr!((*this), y), field_ptr!(_a0, y)) }); - return (*this).clone(); - } -} -impl MoveConstructible for Pair { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), x).write({ - let __v: Value = Rc::new(RefCell::new(::zero_init())); - MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, x) }); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }); - field!((*this), y).write({ - let __v: Value = Rc::new(RefCell::new(::zero_init())); - MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, y) }); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }); - } -} pub trait TrackedImpl { fn construct_2(&self); fn construct_1(&self, v: i32); @@ -1029,30 +1053,6 @@ impl TrackedImpl for Ptr { field!((*self), v).write(v); } } -impl CopyAssignable for Tracked { - fn copy_assign(this: &Ptr, o: Ptr) -> Ptr { - field!((*this), v).write(o.with(|__s| __s.v)); - (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); - return (*this).clone(); - } -} -impl CopyConstructible for Tracked { - fn copy_constructor(this: &Ptr, o: Ptr) { - field!((*this), v).write(o.with(|__s| __s.v)); - (*copies_0.with(Value::clone).borrow_mut()).prefix_inc(); - } -} -impl MoveAssignable for Tracked { - fn move_assign(this: &Ptr, o: Ptr) -> Ptr { - field!((*this), v).write(o.with(|__s| __s.v)); - return (*this).clone(); - } -} -impl MoveConstructible for Tracked { - fn move_constructor(this: &Ptr, o: Ptr) { - field!((*this), v).write(o.with(|__s| __s.v)); - } -} pub fn __cpp2rust_init_globals() { let _ = copies_0.with(|_| ()); let _ = copy_only_copies_1.with(|_| ()); diff --git a/tests/unit/out/refcount/temporary_field_addr.rs b/tests/unit/out/refcount/temporary_field_addr.rs index 5841ecc65a..bb868bef2a 100644 --- a/tests/unit/out/refcount/temporary_field_addr.rs +++ b/tests/unit/out/refcount/temporary_field_addr.rs @@ -23,6 +23,19 @@ pub struct Inner { #[byte_size(24)] pub values: Vec, } +impl MoveConstructible for Inner { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), values).write(field!(_a0, values).with_mut(std::mem::take)); + } +} +impl MoveAssignable for Inner { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), values).with_mut(|__b0| { + (*__b0) = field!(_a0, values).with_mut(std::mem::take); + }); + return (*this).clone(); + } +} #[derive( Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyConstructible, CopyAssignable, )] @@ -39,6 +52,33 @@ pub struct Outer { #[array_len(8)] pub name: Box<[i8]>, } +impl MoveConstructible for Outer { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), values).write(field!(_a0, values).with_mut(std::mem::take)); + field!((*this), inner).write({ + let __v: Value = Rc::new(RefCell::new(::zero_init())); + MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, inner) }); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }); + field!((*this), name).write(Box::new(std::array::from_fn::<_, 8, _>(|__i: usize| { + (*_a0.upgrade().deref()).name[(__i) as usize] + }))); + } +} +impl MoveAssignable for Outer { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), values).with_mut(|__b0| { + (*__b0) = field!(_a0, values).with_mut(std::mem::take); + }); + ({ MoveAssignable::move_assign(&field_ptr!((*this), inner), field_ptr!(_a0, inner)) }); + { + let mut __tmp_0 = { (array_field_ptr!((*this), name)).to_any() }; + __tmp_0.memcpy(&(array_field_ptr!(_a0, name)).to_any(), 8_usize); + (__tmp_0).clone() + }; + return (*this).clone(); + } +} impl Default for Outer { fn default() -> Self { { @@ -136,44 +176,4 @@ fn main_0() -> i32 { ); return 0; } -impl MoveAssignable for Inner { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), values).with_mut(|__b0| { - (*__b0) = field!(_a0, values).with_mut(std::mem::take); - }); - return (*this).clone(); - } -} -impl MoveConstructible for Inner { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), values).write(field!(_a0, values).with_mut(std::mem::take)); - } -} -impl MoveAssignable for Outer { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), values).with_mut(|__b0| { - (*__b0) = field!(_a0, values).with_mut(std::mem::take); - }); - ({ MoveAssignable::move_assign(&field_ptr!((*this), inner), field_ptr!(_a0, inner)) }); - { - let mut __tmp_0 = { (array_field_ptr!((*this), name)).to_any() }; - __tmp_0.memcpy(&(array_field_ptr!(_a0, name)).to_any(), 8_usize); - (__tmp_0).clone() - }; - return (*this).clone(); - } -} -impl MoveConstructible for Outer { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), values).write(field!(_a0, values).with_mut(std::mem::take)); - field!((*this), inner).write({ - let __v: Value = Rc::new(RefCell::new(::zero_init())); - MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, inner) }); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }); - field!((*this), name).write(Box::new(std::array::from_fn::<_, 8, _>(|__i: usize| { - (*_a0.upgrade().deref()).name[(__i) as usize] - }))); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/temporary_field_ctor_arg.rs b/tests/unit/out/refcount/temporary_field_ctor_arg.rs index 53a527d7fc..5f0b647311 100644 --- a/tests/unit/out/refcount/temporary_field_ctor_arg.rs +++ b/tests/unit/out/refcount/temporary_field_ctor_arg.rs @@ -23,6 +23,19 @@ pub struct Outer { #[byte_size(24)] pub values: Vec, } +impl MoveConstructible for Outer { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), values).write(field!(_a0, values).with_mut(std::mem::take)); + } +} +impl MoveAssignable for Outer { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), values).with_mut(|__b0| { + (*__b0) = field!(_a0, values).with_mut(std::mem::take); + }); + return (*this).clone(); + } +} pub fn make_0() -> Outer { return Outer { values: Vec::from([1, 2, 3, 4]), @@ -74,17 +87,4 @@ impl HImpl for Ptr { field!((*self), last).write((index!(values, 3_usize).read())); } } -impl MoveAssignable for Outer { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), values).with_mut(|__b0| { - (*__b0) = field!(_a0, values).with_mut(std::mem::take); - }); - return (*this).clone(); - } -} -impl MoveConstructible for Outer { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), values).write(field!(_a0, values).with_mut(std::mem::take)); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/temporary_field_two_args.rs b/tests/unit/out/refcount/temporary_field_two_args.rs index 22ba39f065..f459f09cda 100644 --- a/tests/unit/out/refcount/temporary_field_two_args.rs +++ b/tests/unit/out/refcount/temporary_field_two_args.rs @@ -23,6 +23,19 @@ pub struct Inner { #[byte_size(24)] pub values: Vec, } +impl MoveConstructible for Inner { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), values).write(field!(_a0, values).with_mut(std::mem::take)); + } +} +impl MoveAssignable for Inner { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), values).with_mut(|__b0| { + (*__b0) = field!(_a0, values).with_mut(std::mem::take); + }); + return (*this).clone(); + } +} #[derive( Clone, Record, @@ -43,6 +56,25 @@ pub struct Outer { #[byte_size(24)] pub inner: Inner, } +impl MoveConstructible for Outer { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), values).write(field!(_a0, values).with_mut(std::mem::take)); + field!((*this), inner).write({ + let __v: Value = Rc::new(RefCell::new(::zero_init())); + MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, inner) }); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }); + } +} +impl MoveAssignable for Outer { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), values).with_mut(|__b0| { + (*__b0) = field!(_a0, values).with_mut(std::mem::take); + }); + ({ MoveAssignable::move_assign(&field_ptr!((*this), inner), field_ptr!(_a0, inner)) }); + return (*this).clone(); + } +} pub fn make_0() -> Outer { return Outer { values: Vec::from([1, 2, 3]), @@ -74,36 +106,4 @@ fn main_0() -> i32 { ); return 0; } -impl MoveAssignable for Inner { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), values).with_mut(|__b0| { - (*__b0) = field!(_a0, values).with_mut(std::mem::take); - }); - return (*this).clone(); - } -} -impl MoveConstructible for Inner { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), values).write(field!(_a0, values).with_mut(std::mem::take)); - } -} -impl MoveAssignable for Outer { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), values).with_mut(|__b0| { - (*__b0) = field!(_a0, values).with_mut(std::mem::take); - }); - ({ MoveAssignable::move_assign(&field_ptr!((*this), inner), field_ptr!(_a0, inner)) }); - return (*this).clone(); - } -} -impl MoveConstructible for Outer { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), values).write(field!(_a0, values).with_mut(std::mem::take)); - field!((*this), inner).write({ - let __v: Value = Rc::new(RefCell::new(::zero_init())); - MoveConstructible::move_constructor(&__v.as_pointer(), { field_ptr!(_a0, inner) }); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/typedef-anon-struct.rs b/tests/unit/out/refcount/typedef-anon-struct.rs index 9a555713b6..4692f3f5fd 100644 --- a/tests/unit/out/refcount/typedef-anon-struct.rs +++ b/tests/unit/out/refcount/typedef-anon-struct.rs @@ -44,6 +44,19 @@ pub struct Outer { #[byte_size(24)] pub runs: Vec, } +impl MoveConstructible for Outer { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), runs).write(field!(_a0, runs).with_mut(std::mem::take)); + } +} +impl MoveAssignable for Outer { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), runs).with_mut(|__b0| { + (*__b0) = field!(_a0, runs).with_mut(std::mem::take); + }); + return (*this).clone(); + } +} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); @@ -62,17 +75,4 @@ fn main_0() -> i32 { assert!((o.runs[0_usize].num_extra_zero_runs == 2)); return 0; } -impl MoveAssignable for Outer { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), runs).with_mut(|__b0| { - (*__b0) = field!(_a0, runs).with_mut(std::mem::take); - }); - return (*this).clone(); - } -} -impl MoveConstructible for Outer { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), runs).write(field!(_a0, runs).with_mut(std::mem::take)); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/unique_ptr.rs b/tests/unit/out/refcount/unique_ptr.rs index cecedb8631..65c0640c02 100644 --- a/tests/unit/out/refcount/unique_ptr.rs +++ b/tests/unit/out/refcount/unique_ptr.rs @@ -13,6 +13,20 @@ pub struct SafePointer { #[byte_size(8)] pub ptr: Option>, } +impl MoveConstructible for SafePointer { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), ptr) + .write(field!(_a0, ptr).with_mut(|__v: &mut Option>| __v.take())); + } +} +impl MoveAssignable for SafePointer { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), ptr).with_mut(|__b0| { + (*__b0) = field!(_a0, ptr).with_mut(|__v: &mut Option>| __v.take()); + }); + return (*this).clone(); + } +} #[derive( Copy, Clone, @@ -252,18 +266,4 @@ impl SafePointerImpl for Ptr { }); } } -impl MoveAssignable for SafePointer { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), ptr).with_mut(|__b0| { - (*__b0) = field!(_a0, ptr).with_mut(|__v: &mut Option>| __v.take()); - }); - return (*this).clone(); - } -} -impl MoveConstructible for SafePointer { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), ptr) - .write(field!(_a0, ptr).with_mut(|__v: &mut Option>| __v.take())); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/unique_ptr_const_deref.rs b/tests/unit/out/refcount/unique_ptr_const_deref.rs index c17113962c..87955a0a1e 100644 --- a/tests/unit/out/refcount/unique_ptr_const_deref.rs +++ b/tests/unit/out/refcount/unique_ptr_const_deref.rs @@ -13,6 +13,20 @@ pub struct Holder { #[byte_size(8)] pub val: Option>, } +impl MoveConstructible for Holder { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), val) + .write(field!(_a0, val).with_mut(|__v: &mut Option>| __v.take())); + } +} +impl MoveAssignable for Holder { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), val).with_mut(|__b0| { + (*__b0) = field!(_a0, val).with_mut(|__v: &mut Option>| __v.take()); + }); + return (*this).clone(); + } +} pub fn read_val_0(mut h: Ptr) -> i32 { return (h.with(|__s| __s.val.clone()).as_pointer().read()); } @@ -32,18 +46,4 @@ fn main_0() -> i32 { assert!((({ read_val_0((h.as_pointer()),) }) == 42)); return 0; } -impl MoveAssignable for Holder { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), val).with_mut(|__b0| { - (*__b0) = field!(_a0, val).with_mut(|__v: &mut Option>| __v.take()); - }); - return (*this).clone(); - } -} -impl MoveConstructible for Holder { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), val) - .write(field!(_a0, val).with_mut(|__v: &mut Option>| __v.take())); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/unique_ptr_field_reset.rs b/tests/unit/out/refcount/unique_ptr_field_reset.rs index b5fa6bc74f..5a0bf19fd1 100644 --- a/tests/unit/out/refcount/unique_ptr_field_reset.rs +++ b/tests/unit/out/refcount/unique_ptr_field_reset.rs @@ -34,6 +34,22 @@ pub struct Holder { #[offset(8)] pub n: i32, } +impl MoveConstructible for Holder { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), data) + .write(field!(_a0, data).with_mut(|__v: &mut Option>| __v.take())); + field!((*this), n).write({ (*_a0.upgrade().deref()).n }); + } +} +impl MoveAssignable for Holder { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), data).with_mut(|__b0| { + (*__b0) = field!(_a0, data).with_mut(|__v: &mut Option>| __v.take()); + }); + field!((*this), n).write({ (*_a0.upgrade().deref()).n }); + return (*this).clone(); + } +} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); @@ -82,20 +98,4 @@ impl HolderImpl for Ptr { }; } } -impl MoveAssignable for Holder { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), data).with_mut(|__b0| { - (*__b0) = field!(_a0, data).with_mut(|__v: &mut Option>| __v.take()); - }); - field!((*this), n).write({ (*_a0.upgrade().deref()).n }); - return (*this).clone(); - } -} -impl MoveConstructible for Holder { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), data) - .write(field!(_a0, data).with_mut(|__v: &mut Option>| __v.take())); - field!((*this), n).write({ (*_a0.upgrade().deref()).n }); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/unique_ptr_nested.rs b/tests/unit/out/refcount/unique_ptr_nested.rs index 9aa85ac092..a8bf9413be 100644 --- a/tests/unit/out/refcount/unique_ptr_nested.rs +++ b/tests/unit/out/refcount/unique_ptr_nested.rs @@ -34,6 +34,20 @@ pub struct Outer { #[byte_size(8)] pub inner: Option>, } +impl MoveConstructible for Outer { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), inner) + .write(field!(_a0, inner).with_mut(|__v: &mut Option>| __v.take())); + } +} +impl MoveAssignable for Outer { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), inner).with_mut(|__b0| { + (*__b0) = field!(_a0, inner).with_mut(|__v: &mut Option>| __v.take()); + }); + return (*this).clone(); + } +} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); @@ -61,18 +75,4 @@ fn main_0() -> i32 { assert!(((sum + (b.as_pointer().read())) == 135)); return 0; } -impl MoveAssignable for Outer { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), inner).with_mut(|__b0| { - (*__b0) = field!(_a0, inner).with_mut(|__v: &mut Option>| __v.take()); - }); - return (*this).clone(); - } -} -impl MoveConstructible for Outer { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), inner) - .write(field!(_a0, inner).with_mut(|__v: &mut Option>| __v.take())); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/vector.rs b/tests/unit/out/refcount/vector.rs index ccd42d5dc8..9588796e5e 100644 --- a/tests/unit/out/refcount/vector.rs +++ b/tests/unit/out/refcount/vector.rs @@ -46,6 +46,23 @@ pub struct Foo { #[byte_size(24)] pub b: Vec, } +impl MoveConstructible for Foo { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), a).write(field!(_a0, a).with_mut(std::mem::take)); + field!((*this), b).write(field!(_a0, b).with_mut(std::mem::take)); + } +} +impl MoveAssignable for Foo { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), a).with_mut(|__b0| { + (*__b0) = field!(_a0, a).with_mut(std::mem::take); + }); + field!((*this), b).with_mut(|__b0| { + (*__b0) = field!(_a0, b).with_mut(std::mem::take); + }); + return (*this).clone(); + } +} pub fn exchange_1(x: Ptr>, y: Ptr>) { x.swap_with(&(y).clone(), |__v| __v.with_mut(std::mem::take)); } @@ -631,21 +648,4 @@ fn main_0() -> i32 { ); return 0; } -impl MoveAssignable for Foo { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), a).with_mut(|__b0| { - (*__b0) = field!(_a0, a).with_mut(std::mem::take); - }); - field!((*this), b).with_mut(|__b0| { - (*__b0) = field!(_a0, b).with_mut(std::mem::take); - }); - return (*this).clone(); - } -} -impl MoveConstructible for Foo { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), a).write(field!(_a0, a).with_mut(std::mem::take)); - field!((*this), b).write(field!(_a0, b).with_mut(std::mem::take)); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/vector_subscript_direct.rs b/tests/unit/out/refcount/vector_subscript_direct.rs index 9cd15ba51b..84cfe0176c 100644 --- a/tests/unit/out/refcount/vector_subscript_direct.rs +++ b/tests/unit/out/refcount/vector_subscript_direct.rs @@ -47,6 +47,23 @@ pub struct Holder { #[byte_size(24)] pub points: Vec, } +impl MoveConstructible for Holder { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), values).write(field!(_a0, values).with_mut(std::mem::take)); + field!((*this), points).write(field!(_a0, points).with_mut(std::mem::take)); + } +} +impl MoveAssignable for Holder { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), values).with_mut(|__b0| { + (*__b0) = field!(_a0, values).with_mut(std::mem::take); + }); + field!((*this), points).with_mut(|__b0| { + (*__b0) = field!(_a0, points).with_mut(std::mem::take); + }); + return (*this).clone(); + } +} pub fn push_and_index_0(v: Ptr>) -> i32 { { let __a1 = 42; @@ -154,23 +171,6 @@ fn main_0() -> i32 { assert!(({ (*a.borrow())[1_usize] } == 10)); return 0; } -impl MoveAssignable for Holder { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), values).with_mut(|__b0| { - (*__b0) = field!(_a0, values).with_mut(std::mem::take); - }); - field!((*this), points).with_mut(|__b0| { - (*__b0) = field!(_a0, points).with_mut(std::mem::take); - }); - return (*this).clone(); - } -} -impl MoveConstructible for Holder { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), values).write(field!(_a0, values).with_mut(std::mem::take)); - field!((*this), points).write(field!(_a0, points).with_mut(std::mem::take)); - } -} pub trait PointImpl { fn sum(&self) -> i32; } diff --git a/tests/unit/out/refcount/void_cast.rs b/tests/unit/out/refcount/void_cast.rs index 65e7929971..ccae77007b 100644 --- a/tests/unit/out/refcount/void_cast.rs +++ b/tests/unit/out/refcount/void_cast.rs @@ -24,6 +24,19 @@ pub struct NonTrivial { #[byte_size(24)] pub data: Vec, } +impl MoveConstructible for NonTrivial { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), data).write(field!(_a0, data).with_mut(std::mem::take)); + } +} +impl MoveAssignable for NonTrivial { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), data).with_mut(|__b0| { + (*__b0) = field!(_a0, data).with_mut(std::mem::take); + }); + return (*this).clone(); + } +} pub fn unused_ref_param_1(x: Ptr) {} pub fn unused_ptr_param_2(mut p: Ptr) {} thread_local!( @@ -59,6 +72,20 @@ pub struct NonCopyable { #[byte_size(8)] pub value: Option>, } +impl MoveConstructible for NonCopyable { + fn move_constructor(this: &Ptr, _a0: Ptr) { + field!((*this), value) + .write(field!(_a0, value).with_mut(|__v: &mut Option>| __v.take())); + } +} +impl MoveAssignable for NonCopyable { + fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { + field!((*this), value).with_mut(|__b0| { + (*__b0) = field!(_a0, value).with_mut(|__v: &mut Option>| __v.take()); + }); + return (*this).clone(); + } +} pub fn unused_noncopyable_param_5(x: Ptr) {} pub fn main() { __cpp2rust_init_globals(); @@ -118,33 +145,6 @@ fn main_0() -> i32 { assert!((({ (*g.borrow()).value.clone() }.as_pointer().read()) == 9)); return 0; } -impl MoveAssignable for NonCopyable { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), value).with_mut(|__b0| { - (*__b0) = field!(_a0, value).with_mut(|__v: &mut Option>| __v.take()); - }); - return (*this).clone(); - } -} -impl MoveConstructible for NonCopyable { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), value) - .write(field!(_a0, value).with_mut(|__v: &mut Option>| __v.take())); - } -} -impl MoveAssignable for NonTrivial { - fn move_assign(this: &Ptr, _a0: Ptr) -> Ptr { - field!((*this), data).with_mut(|__b0| { - (*__b0) = field!(_a0, data).with_mut(std::mem::take); - }); - return (*this).clone(); - } -} -impl MoveConstructible for NonTrivial { - fn move_constructor(this: &Ptr, _a0: Ptr) { - field!((*this), data).write(field!(_a0, data).with_mut(std::mem::take)); - } -} pub fn __cpp2rust_init_globals() { let _ = side_effect_counter_3.with(|_| ()); } From 95b15d1df26fa9aa4efeb1b655800497ed09a332 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Mon, 30 Nov 2026 20:47:55 +0000 Subject: [PATCH 06/20] Add trait support in cpp2rust --- cpp2rust/converter/converter.cpp | 156 +++++++++--------- cpp2rust/converter/converter.h | 20 +-- cpp2rust/converter/converter_lib.cpp | 58 ++++++- cpp2rust/converter/converter_lib.h | 19 +++ .../converter/models/converter_refcount.cpp | 86 +++++----- .../converter/models/converter_refcount.h | 17 +- 6 files changed, 216 insertions(+), 140 deletions(-) diff --git a/cpp2rust/converter/converter.cpp b/cpp2rust/converter/converter.cpp index 9765771a79..b10bc5f907 100644 --- a/cpp2rust/converter/converter.cpp +++ b/cpp2rust/converter/converter.cpp @@ -1007,18 +1007,48 @@ void Converter::ConvertTemplateInstantiatedCtors(clang::CXXRecordDecl *decl) { } void Converter::ConvertLateInstantiatedMethods(clang::CXXRecordDecl *decl) { + auto predicate = [](clang::CXXMethodDecl *method) { + return IsEmittableMethod(method) && method->hasBody() && + !decl_ids_.contains(GetMethodID(method)); + }; ConvertCXXMethodDecls( decl, std::format("{} {}", keyword::kImpl, GetRecordName(decl)), - [](auto *method) { - return IsEmittableMethod(method) && method->hasBody() && - !decl_ids_.contains(GetMethodID(method)); - }); + predicate); + ConvertCopyOrMoveTraitImpls(decl, predicate); +} + +void Converter::ConvertCopyOrMoveTraitImpls( + const clang::CXXRecordDecl *decl, + bool (*predicate)(clang::CXXMethodDecl *)) { + ForEachMethod(decl, [&](clang::CXXMethodDecl *method) { + if (predicate(method) && GetCopyOrMoveTrait(method)) { + VisitCXXMethodDecl(method); + } + }); +} + +void Converter::ConvertCopyOrMoveTraitImpl(clang::CXXMethodDecl *method, + const CopyOrMoveTrait &trait) { + std::string body; + { + Buffer buf(*this); + ConvertCXXMethodDecl(method); + body = std::move(buf).str(); + } + if (body.empty()) { + return; + } + StrCat(keyword::kImpl, GetCopyOrMoveTraitName(trait), "for", + GetRecordName(method->getParent())); + PushBrace brace(*this); + StrCat(body); } void Converter::ConvertCXXRecordMethods(clang::CXXRecordDecl *decl) { ConvertCXXMethodDecls( decl, std::format("{} {}", keyword::kImpl, GetRecordName(decl)), IsEmittableMethod); + ConvertCopyOrMoveTraitImpls(decl, IsEmittableMethod); if (GetUserDefinedDestructor(decl) || !HasFieldsNeedingDestruction(decl)) { return; @@ -1168,6 +1198,10 @@ bool Converter::VisitCXXMethodDecl(clang::CXXMethodDecl *decl) { } ScopedValue push_fn(curr_function_, decl); + if (auto *trait = GetCopyOrMoveTrait(decl)) { + ConvertCopyOrMoveTraitImpl(decl, *trait); + return false; + } if (decl->isOutOfLine() && !decl->overridden_methods().empty()) { return ConvertOutOfLineVirtualMethod(decl); } @@ -1191,6 +1225,9 @@ std::string Converter::GetMethodName(const clang::CXXMethodDecl *decl) { if (clang::isa(decl)) { return kDestructorName; } + if (auto *trait = GetCopyOrMoveTrait(decl)) { + return trait->method; + } if (const char *name = GetCopyOrMoveName(decl); name && CanUseCopyOrMoveName(decl, name)) { return name; @@ -1227,7 +1264,7 @@ bool Converter::ConvertCXXMethodDecl(clang::CXXMethodDecl *decl) { return VisitCXXConstructorDecl(ctor); } - if (method_target_ == MethodTarget::ValueImpl && + if (method_target_ == MethodTarget::ValueImpl && !GetCopyOrMoveTrait(decl) && (decl->isStatic() || (!decl->isVirtual() && !decl->getParent()->isAbstract()))) { StrCat(AccessSpecifierAsString(decl->getAccess())); @@ -1260,6 +1297,9 @@ std::string Converter::GetSelfMaybeWithMut(const clang::CXXMethodDecl *decl) { } std::string Converter::GetCtorName(clang::CXXConstructorDecl *decl) { + if (auto *trait = GetCopyOrMoveTrait(decl)) { + return trait->method; + } if (decl->isCopyOrMoveConstructor()) { if (const char *name = GetCopyOrMoveName(decl); CanUseCopyOrMoveName(decl, name)) { @@ -1278,7 +1318,7 @@ bool Converter::VisitCXXConstructorDecl(clang::CXXConstructorDecl *decl) { } ScopedValue push_fn(curr_function_, decl); - if (method_target_ == MethodTarget::ValueImpl) { + if (method_target_ == MethodTarget::ValueImpl && !GetCopyOrMoveTrait(decl)) { StrCat(AccessSpecifierAsString(decl->getAccess())); } StrCat(keyword_unsafe_, keyword::kFn, GetCtorName(decl)); @@ -2456,9 +2496,17 @@ void Converter::ConvertGenericCallExpr(clang::CallExpr *expr) { } std::string Converter::GetUFCSName(const clang::CXXMethodDecl *method) const { + if (auto *trait = GetCopyOrMoveTrait(method)) { + return GetCopyOrMoveTraitName(*trait); + } return GetRecordName(method->getParent()); } +const char * +Converter::GetCopyOrMoveTraitName(const CopyOrMoveTrait &trait) const { + return trait.unsafe_name; +} + void Converter::ConvertUserOperatorCall(clang::CXXOperatorCallExpr *expr) { auto *callee = expr->getDirectCallee(); PushParen outer(*this); @@ -3904,8 +3952,7 @@ bool Converter::VisitMemberExpr(clang::MemberExpr *expr) { if (auto *method = clang::dyn_cast(member); method && IsMethodOnPtr(method) && !Mapper::Contains(ctx_, expr)) { SetUFCSReceiver(expr->getBase(), expr->isArrow(), method); - StrCat(GetRecordName(method->getParent()), token::kDoubleColon, - GetMethodName(method)); + StrCat(GetUFCSName(method), token::kDoubleColon, GetMethodName(method)); MarkFresh(); return false; } @@ -4440,6 +4487,9 @@ const char *Converter::GetConstructorWrite() const { std::string Converter::GetConstructorPath(const clang::CXXConstructorDecl *ctor) const { + if (auto *trait = GetCopyOrMoveTrait(ctor)) { + return GetCopyOrMoveTraitName(*trait); + } return GetRecordName(ctor->getParent()); } @@ -4964,7 +5014,10 @@ std::string Converter::GetRecordName(const clang::NamedDecl *decl) const { std::vector Converter::GetStructAttributes(const clang::RecordDecl *decl) { if (decl->isUnion()) { - return {"Copy", "Clone", "FnPtrArg", "VaArg", "ZeroInitializationUnsafe"}; + std::vector union_attrs = { + "Copy", "Clone", "FnPtrArg", "VaArg", "ZeroInitializationUnsafe"}; + AddCopyAndMoveDerives(decl, union_attrs); + return union_attrs; } std::vector struct_attrs; @@ -4983,27 +5036,17 @@ Converter::GetStructAttributes(const clang::RecordDecl *decl) { struct_attrs.emplace_back("FnPtrArg"); struct_attrs.emplace_back("ZeroInitializationUnsafe"); - if (HasMoveFromConstructor(decl)) { - struct_attrs.emplace_back("MoveCtorUnsafe"); - } - if (HasImplicitConversions(decl)) { struct_attrs.emplace_back("CppFromUnsafe"); } - if (HasCopyAssignOperator(decl)) { - struct_attrs.emplace_back("CopyAssignUnsafe"); - } - - if (HasMoveAssignOperator(decl)) { - struct_attrs.emplace_back("MoveAssignUnsafe"); - } - if (auto *cxx = clang::dyn_cast(decl); cxx && RecordNeedsDestruction(cxx)) { struct_attrs.emplace_back("DestructibleUnsafe"); } + AddCopyAndMoveDerives(decl, struct_attrs); + if (RecordDerivesDefault(decl)) { struct_attrs.emplace_back("Default"); } @@ -5248,7 +5291,7 @@ void Converter::ConvertCXXMethodDecls( bool (*predicate)(clang::CXXMethodDecl *)) { bool first = true; auto convert_method = [&](clang::CXXMethodDecl *method) { - if (predicate(method)) { + if (predicate(method) && !GetCopyOrMoveTrait(method)) { if (first) { StrCat(signature, token::kOpenCurlyBracket); first = false; @@ -5512,6 +5555,21 @@ void Converter::AddCloneTrait(const clang::RecordDecl *decl) { TakePlacementValue())); } +void Converter::AddCopyAndMoveDerives(const clang::RecordDecl *decl, + std::vector &attrs) { + if (!decl->isUnion() && !RecordImplementsClone(decl)) { + return; + } + auto *cxx = clang::dyn_cast(decl); + for (const auto &trait : kCopyOrMoveTraits) { + if (!cxx || llvm::none_of(cxx->methods(), [&](auto *method) { + return GetCopyOrMoveTrait(method) == &trait; + })) { + attrs.emplace_back(GetCopyOrMoveTraitName(trait)); + } + } +} + bool Converter::RecordImplementsClone(const clang::RecordDecl *decl) { return HasDefaultedCopyConstructor(decl) || GetUserDefinedCopyConstructor(decl) != nullptr; @@ -6458,39 +6516,6 @@ std::string Converter::ConvertGenericCall( assert(call_args.empty() && "default takes no arguments"); return GetUnboxedDefaultAsString(type); } - if (call.method == "move_ctor") { - assert(call_args.size() == 1 && "move_ctor takes one argument"); - auto *record = type->getAsCXXRecordDecl(); - if (record && (HasMoveFromConstructor(record) || - (!IsUserDefinedDecl(record) && - !record->hasTrivialMoveConstructor()))) { - return std::format("<{} as {}>::move_ctor({})", - GetUnboxedTypeAsString(type), GetMoveCtorTraitName(), - call_args[0]); - } - return ConvertPtrRead(type, call_args[0]); - } - if (call.method == "move_assign" || call.method == "copy_assign") { - assert(call_args.size() == 2 && "assignments take two arguments"); - bool is_move = call.method == "move_assign"; - auto *record = type->getAsCXXRecordDecl(); - if (record && is_move && HasMoveAssignOperator(record)) { - return ConvertPointeeMethodCall("move_assign", call_args[0], - call_args[1]); - } - if (record && HasCopyAssignOperator(record)) { - return ConvertPointeeMethodCall("copy_assign", call_args[0], - call_args[1]); - } - if (is_move && record && !IsUserDefinedDecl(record) && - !record->hasTrivialMoveAssignment()) { - return ConvertPtrWrite(call_args[0], - std::format("<{} as {}>::move_ctor({})", - GetUnboxedTypeAsString(type), - GetMoveCtorTraitName(), call_args[1])); - } - return ConvertPtrWrite(call_args[0], ConvertPtrRead(type, call_args[1])); - } if (call.method == "cpp_from" || call.method == "cpp_from_move") { assert(call_args.size() == 1 && "cpp_from takes one argument"); return ConvertConversion( @@ -6530,27 +6555,6 @@ const char *Converter::GetConversionTraitName() const { return "CppFromUnsafe"; } -std::string Converter::ConvertPtrRead(clang::QualType type, - const std::string &src) { - if (type->isScalarType()) { - return std::format("(*{})", src); - } - return std::format("(*{}).clone()", src); -} - -std::string Converter::ConvertPtrWrite(const std::string &dst, - const std::string &value) { - return std::format("*{} = {}", dst, value); -} - -std::string Converter::ConvertPointeeMethodCall(const char *method, - const std::string &dst, - const std::string &src) { - return std::format("(*{}).{}({})", dst, method, src); -} - -const char *Converter::GetMoveCtorTraitName() const { return "MoveCtorUnsafe"; } - std::string Converter::DerefPtrExpr(std::string_view ptr_expr, clang::QualType pointee_type) { return std::format("({}{})", GetPointerDerefPrefix(pointee_type), ptr_expr); diff --git a/cpp2rust/converter/converter.h b/cpp2rust/converter/converter.h index 8919834443..1bf1b0fe3e 100644 --- a/cpp2rust/converter/converter.h +++ b/cpp2rust/converter/converter.h @@ -358,17 +358,11 @@ class Converter : public clang::RecursiveASTVisitor { virtual const char *GetConversionTraitName() const; - virtual std::string ConvertPtrRead(clang::QualType type, - const std::string &src); + virtual const char * + GetCopyOrMoveTraitName(const CopyOrMoveTrait &trait) const; - virtual std::string ConvertPtrWrite(const std::string &dst, - const std::string &value); - - virtual std::string ConvertPointeeMethodCall(const char *method, - const std::string &dst, - const std::string &src); - - virtual const char *GetMoveCtorTraitName() const; + void AddCopyAndMoveDerives(const clang::RecordDecl *decl, + std::vector &attrs); virtual std::string DerefPtrExpr(std::string_view ptr_expr, clang::QualType pointee_type); @@ -892,6 +886,12 @@ class Converter : public clang::RecursiveASTVisitor { virtual void ConvertAbstractClass(clang::CXXRecordDecl *decl); + void ConvertCopyOrMoveTraitImpls(const clang::CXXRecordDecl *decl, + bool (*predicate)(clang::CXXMethodDecl *)); + + void ConvertCopyOrMoveTraitImpl(clang::CXXMethodDecl *method, + const CopyOrMoveTrait &trait); + void ConvertCXXMethodDecls(const clang::CXXRecordDecl *decl, const std::string_view signature, bool (*predicate)(clang::CXXMethodDecl *)); diff --git a/cpp2rust/converter/converter_lib.cpp b/cpp2rust/converter/converter_lib.cpp index 4672d9e507..40ebcf4b9c 100644 --- a/cpp2rust/converter/converter_lib.cpp +++ b/cpp2rust/converter/converter_lib.cpp @@ -602,6 +602,45 @@ bool CanUseCopyOrMoveName(const clang::CXXMethodDecl *decl, return is_unique_member && !HasMethodNamed(record, name); } +static bool IsTranslatedCopyAssignment(const clang::CXXMethodDecl *method); + +static bool IsTranslatedMoveAssignment(const clang::CXXMethodDecl *method); + +static bool IsTranslatedCopyOrMove(const clang::CXXMethodDecl *method) { + if (auto *ctor = clang::dyn_cast(method)) { + return IsConvertedConstructor(ctor) && ctor->hasBody(); + } + return method->isCopyAssignmentOperator() + ? IsTranslatedCopyAssignment(method) + : IsTranslatedMoveAssignment(method); +} + +const CopyOrMoveTrait *GetCopyOrMoveTrait(const clang::CXXMethodDecl *method) { + method = method->getCanonicalDecl(); + const char *name = GetCopyOrMoveName(method); + if (!name || method->isDeleted() || method->isVirtual() || + !CanUseCopyOrMoveName(method, name) || !IsTranslatedCopyOrMove(method)) { + return nullptr; + } + auto *ctor = clang::dyn_cast(method); + if (!ctor && !method->getReturnType()->isLValueReferenceType()) { + return nullptr; + } + auto param = method->getParamDecl(0)->getType(); + bool is_copy = + ctor ? ctor->isCopyConstructor() : method->isCopyAssignmentOperator(); + if (!param->isReferenceType() || + param.getNonReferenceType().isConstQualified() != is_copy) { + return nullptr; + } + for (const auto &trait : kCopyOrMoveTraits) { + if (trait.is_copy == is_copy && trait.is_assign == !ctor) { + return &trait; + } + } + return nullptr; +} + bool IsUserDefinedCopyConstructor(const clang::CXXConstructorDecl *ctor) { return ctor->isCopyConstructor() && ctor->isUserProvided() && IsUserDefinedDecl(ctor); @@ -730,7 +769,7 @@ static bool HasFieldWithMoveAssign(const clang::RecordDecl *decl) { return !record->hasTrivialMoveAssignment(); } return llvm::any_of(record->methods(), [](auto *method) { - return IsConvertibleMoveAssignment(method); + return IsTranslatedMoveAssignment(method); }); }); } @@ -742,11 +781,22 @@ static bool NeedsDefaultedMoveAssignment(const clang::CXXRecordDecl *decl) { bool IsConvertibleMoveAssignment(const clang::CXXMethodDecl *method) { auto *parent = method->getParent(); + if (!method->isMoveAssignmentOperator() || method->isUserProvided() || + method->isDeleted() || !method->hasBody() || + !IsConvertibleImplicitMemberParent(parent)) { + return false; + } + return NeedsDefaultedMoveAssignment(parent); +} + +static bool IsTranslatedMoveAssignment(const clang::CXXMethodDecl *method) { if (!method->isMoveAssignmentOperator() || method->isDeleted() || - !method->hasBody() || !IsConvertibleImplicitMemberParent(parent)) { + method->isVirtual()) { return false; } - return method->isUserProvided() || NeedsDefaultedMoveAssignment(parent); + return (method->isUserProvided() && IsUserDefinedDecl(method) && + method->hasBody()) || + IsConvertibleMoveAssignment(method); } static bool IsTranslatedCopyAssignment(const clang::CXXMethodDecl *method) { @@ -770,7 +820,7 @@ bool HasCopyAssignOperator(const clang::RecordDecl *decl) { bool HasMoveAssignOperator(const clang::RecordDecl *decl) { auto *cxx = clang::dyn_cast(decl); return cxx && llvm::any_of(cxx->methods(), [](auto *method) { - return IsConvertibleMoveAssignment(method) && !method->isVirtual() && + return IsTranslatedMoveAssignment(method) && CanUseCopyOrMoveName(method, "move_assign"); }); } diff --git a/cpp2rust/converter/converter_lib.h b/cpp2rust/converter/converter_lib.h index da432b5929..d8959f27bb 100644 --- a/cpp2rust/converter/converter_lib.h +++ b/cpp2rust/converter/converter_lib.h @@ -105,6 +105,25 @@ const char *GetCopyOrMoveName(const clang::CXXMethodDecl *method); bool CanUseCopyOrMoveName(const clang::CXXMethodDecl *decl, const std::string &name); +struct CopyOrMoveTrait { + const char *name; + const char *unsafe_name; + const char *method; + bool is_copy; + bool is_assign; +}; + +inline constexpr CopyOrMoveTrait kCopyOrMoveTraits[] = { + {"CopyConstructible", "CopyConstructibleUnsafe", "copy_constructor", true, + false}, + {"MoveConstructible", "MoveConstructibleUnsafe", "move_constructor", false, + false}, + {"CopyAssignable", "CopyAssignableUnsafe", "copy_assign", true, true}, + {"MoveAssignable", "MoveAssignableUnsafe", "move_assign", false, true}, +}; + +const CopyOrMoveTrait *GetCopyOrMoveTrait(const clang::CXXMethodDecl *method); + bool IsUserDefinedCopyConstructor(const clang::CXXConstructorDecl *ctor); bool IsConvertibleCopyOrMoveConstructor(const clang::CXXConstructorDecl *ctor); diff --git a/cpp2rust/converter/models/converter_refcount.cpp b/cpp2rust/converter/models/converter_refcount.cpp index 9bc5a22253..12bacd6115 100644 --- a/cpp2rust/converter/models/converter_refcount.cpp +++ b/cpp2rust/converter/models/converter_refcount.cpp @@ -846,6 +846,9 @@ void ConverterRefCount::EmitByteSizeAttr(const clang::RecordDecl *decl) { std::string ConverterRefCount::GetSelfMaybeWithMut(const clang::CXXMethodDecl *decl) { + if (GetCopyOrMoveTrait(decl)) { + return "this: &Ptr"; + } return NeedsMutAccess(decl, decl->getThisType()->getPointeeType()) ? "&mut self" : "&self"; @@ -1806,8 +1809,7 @@ bool ConverterRefCount::VisitMemberExpr(clang::MemberExpr *expr) { method && !known) { if (IsMethodOnPtr(method)) { SetUFCSReceiver(expr->getBase(), expr->isArrow(), method); - StrCat(TraitName(method->getParent()), token::kDoubleColon, - GetMethodName(method)); + StrCat(GetUFCSName(method), token::kDoubleColon, GetMethodName(method)); MarkFresh(); return false; } @@ -2326,7 +2328,9 @@ ConverterRefCount::GetStructAttributes(const clang::RecordDecl *decl) { std::vector attrs; if (decl->isUnion()) { - return {"VaArg", "FnPtrArg"}; + std::vector union_attrs = {"VaArg", "FnPtrArg"}; + AddCopyAndMoveDerives(decl, union_attrs); + return union_attrs; } if (RecordDerivesCopyTrait(decl)) { @@ -2348,27 +2352,17 @@ ConverterRefCount::GetStructAttributes(const clang::RecordDecl *decl) { } attrs.emplace_back("FnPtrArg"); - if (HasMoveFromConstructor(decl)) { - attrs.emplace_back("MoveCtor"); - } - if (HasImplicitConversions(decl)) { attrs.emplace_back("CppFrom"); } - if (HasCopyAssignOperator(decl)) { - attrs.emplace_back("CopyAssign"); - } - - if (HasMoveAssignOperator(decl)) { - attrs.emplace_back("MoveAssign"); - } - if (auto *cxx = clang::dyn_cast(decl); cxx && RecordNeedsDestruction(cxx)) { attrs.emplace_back("Destructible"); } + AddCopyAndMoveDerives(decl, attrs); + if (RecordDerivesDefault(decl)) { attrs.emplace_back("Default"); } @@ -2379,23 +2373,9 @@ const char *ConverterRefCount::GetConversionTraitName() const { return "CppFrom"; } -std::string ConverterRefCount::ConvertPtrRead(clang::QualType, - const std::string &src) { - return std::format("{}.read()", src); -} - -std::string ConverterRefCount::ConvertPtrWrite(const std::string &dst, - const std::string &value) { - return std::format("{}.write({})", dst, value); -} - -std::string ConverterRefCount::ConvertPointeeMethodCall( - const char *method, const std::string &dst, const std::string &src) { - return std::format("{}.{}({})", dst, method, src); -} - -const char *ConverterRefCount::GetMoveCtorTraitName() const { - return "MoveCtor"; +const char * +ConverterRefCount::GetCopyOrMoveTraitName(const CopyOrMoveTrait &trait) const { + return trait.name; } bool ConverterRefCount::TypeDerivesDefault(clang::QualType qual_type) { @@ -3597,6 +3577,16 @@ bool ConverterRefCount::ShouldConvertMethod(const clang::CXXMethodDecl *decl) { return Converter::ShouldConvertMethod(decl); } +// TODO: every trait on a Ptr should receive `this`. +bool ConverterRefCount::ReceivesThis() const { + auto *method = clang::dyn_cast_or_null(curr_function_); + return method && GetCopyOrMoveTrait(method); +} + +const char *ConverterRefCount::SelfName() const { + return ReceivesThis() ? "this" : keyword::kSelfValue; +} + bool ConverterRefCount::ThisIsRustPtr() const { auto *method = clang::dyn_cast_or_null(curr_function_); return method && (IsMethodOnPtr(method) || @@ -3614,7 +3604,7 @@ void ConverterRefCount::SetUFCSReceiver(clang::Expr *base, bool is_arrow, if (clang::isa(base->IgnoreParenImpCasts()) && !AsLambdaOperatorCall(curr_function_)) { if (ThisIsRustPtr()) { - ufcs_receiver_ = keyword::kSelfValue; + ufcs_receiver_ = SelfName(); } else { ufcs_receiver_ = token::kRef + ConvertPointer(base); } @@ -3637,6 +3627,9 @@ void ConverterRefCount::SetUFCSReceiver(clang::Expr *base, bool is_arrow, std::string ConverterRefCount::GetUFCSName(const clang::CXXMethodDecl *method) const { + if (auto *trait = GetCopyOrMoveTrait(method)) { + return GetCopyOrMoveTraitName(*trait); + } if (!IsMethodOnPtr(method)) { return GetRecordName(method->getParent()); } @@ -3679,6 +3672,9 @@ bool ConverterRefCount::ConvertOutOfLineMethod(clang::CXXMethodDecl *decl) { void ConverterRefCount::ConvertMethodOnPtrTraitDecl( clang::CXXMethodDecl *method) { + if (GetCopyOrMoveTrait(method)) { + return; + } Buffer buf(*this); { ScopedValue push_fn(curr_function_, method); @@ -3691,8 +3687,9 @@ void ConverterRefCount::ConvertMethodOnPtrTraitDecl( } void ConverterRefCount::ConvertMethodOnPtr(clang::CXXMethodDecl *method) { - if (!method->isThisDeclarationADefinition() && - !clang::isa(method)) { + if ((!method->isThisDeclarationADefinition() && + !clang::isa(method)) || + GetCopyOrMoveTrait(method)) { return; } Buffer buf(*this); @@ -3731,6 +3728,10 @@ void ConverterRefCount::ConvertLateInstantiatedMethods( ConvertMethodOnPtr(method); } }); + ConvertCopyOrMoveTraitImpls(decl, [](clang::CXXMethodDecl *method) { + return IsEmittableMethod(method) && method->hasBody() && + !decl_ids_.contains(GetMethodID(method)); + }); } void ConverterRefCount::ConvertCXXRecordMethods(clang::CXXRecordDecl *decl) { @@ -3755,6 +3756,7 @@ void ConverterRefCount::ConvertCXXRecordMethods(clang::CXXRecordDecl *decl) { ConvertMethodOnPtr(method); } }); + ConvertCopyOrMoveTraitImpls(decl, IsEmittableMethod); if (!GetUserDefinedDestructor(decl) && HasFieldsNeedingDestruction(decl)) { MethodsOnPtrFor(decl).trait.body += @@ -3774,20 +3776,26 @@ ConverterRefCount::DestroyMembers(const clang::CXXRecordDecl *decl) { return out; } -const char *ConverterRefCount::GetConstructorSelf() const { return "&self"; } +const char *ConverterRefCount::GetConstructorSelf() const { + return ReceivesThis() ? "this: &Ptr" : "&self"; +} std::string ConverterRefCount::ConvertConstructorFieldWrite(const std::string &field_name, const std::string &value) { - return std::format("field!((*self), {}).write({});", field_name, value); + return std::format("field!((*{}), {}).write({});", SelfName(), field_name, + value); } const char *ConverterRefCount::GetConstructorWrite() const { - return "self.write"; + return ReceivesThis() ? "this.write" : "self.write"; } std::string ConverterRefCount::GetConstructorPath( const clang::CXXConstructorDecl *ctor) const { + if (auto *trait = GetCopyOrMoveTrait(ctor)) { + return GetCopyOrMoveTraitName(*trait); + } return TraitName(ctor->getParent()); } @@ -3819,7 +3827,7 @@ bool ConverterRefCount::VisitCXXThisExpr( } return false; } - StrCat("(*", keyword::kSelfValue, ')'); + StrCat("(*", SelfName(), ')'); MarkNotFresh(); return false; } diff --git a/cpp2rust/converter/models/converter_refcount.h b/cpp2rust/converter/models/converter_refcount.h index 82df79596d..95d930ee18 100644 --- a/cpp2rust/converter/models/converter_refcount.h +++ b/cpp2rust/converter/models/converter_refcount.h @@ -431,6 +431,10 @@ class ConverterRefCount final : public Converter { MethodsOnPtr &MethodsOnPtrFor(const clang::CXXRecordDecl *decl); + bool ReceivesThis() const; + + const char *SelfName() const; + std::string DestroyMembers(const clang::CXXRecordDecl *decl) override; void EmitScopedDestructor(const clang::VarDecl *decl) override; @@ -526,17 +530,8 @@ class ConverterRefCount final : public Converter { const char *GetConversionTraitName() const override; - std::string ConvertPtrRead(clang::QualType type, - const std::string &src) override; - - std::string ConvertPtrWrite(const std::string &dst, - const std::string &value) override; - - std::string ConvertPointeeMethodCall(const char *method, - const std::string &dst, - const std::string &src) override; - - const char *GetMoveCtorTraitName() const override; + const char * + GetCopyOrMoveTraitName(const CopyOrMoveTrait &trait) const override; bool IsBoxedType(clang::QualType type); bool IsVecType(clang::QualType type); From 139aaf6fcc28d6db24e1c1ac60faf7f288dfed0b Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Mon, 30 Nov 2026 20:49:37 +0000 Subject: [PATCH 07/20] Add generic trait table --- cpp2rust/converter/converter.cpp | 30 +++++++++---------- cpp2rust/converter/converter.h | 5 ++-- cpp2rust/converter/converter_lib.cpp | 10 +++---- cpp2rust/converter/converter_lib.h | 22 +++++++------- .../converter/models/converter_refcount.cpp | 14 ++++----- .../converter/models/converter_refcount.h | 3 +- 6 files changed, 39 insertions(+), 45 deletions(-) diff --git a/cpp2rust/converter/converter.cpp b/cpp2rust/converter/converter.cpp index b10bc5f907..a966a3479c 100644 --- a/cpp2rust/converter/converter.cpp +++ b/cpp2rust/converter/converter.cpp @@ -1021,14 +1021,14 @@ void Converter::ConvertCopyOrMoveTraitImpls( const clang::CXXRecordDecl *decl, bool (*predicate)(clang::CXXMethodDecl *)) { ForEachMethod(decl, [&](clang::CXXMethodDecl *method) { - if (predicate(method) && GetCopyOrMoveTrait(method)) { + if (predicate(method) && GetRecordTrait(method)) { VisitCXXMethodDecl(method); } }); } void Converter::ConvertCopyOrMoveTraitImpl(clang::CXXMethodDecl *method, - const CopyOrMoveTrait &trait) { + const RecordTrait &trait) { std::string body; { Buffer buf(*this); @@ -1198,7 +1198,7 @@ bool Converter::VisitCXXMethodDecl(clang::CXXMethodDecl *decl) { } ScopedValue push_fn(curr_function_, decl); - if (auto *trait = GetCopyOrMoveTrait(decl)) { + if (auto *trait = GetRecordTrait(decl)) { ConvertCopyOrMoveTraitImpl(decl, *trait); return false; } @@ -1225,7 +1225,7 @@ std::string Converter::GetMethodName(const clang::CXXMethodDecl *decl) { if (clang::isa(decl)) { return kDestructorName; } - if (auto *trait = GetCopyOrMoveTrait(decl)) { + if (auto *trait = GetRecordTrait(decl)) { return trait->method; } if (const char *name = GetCopyOrMoveName(decl); @@ -1264,7 +1264,7 @@ bool Converter::ConvertCXXMethodDecl(clang::CXXMethodDecl *decl) { return VisitCXXConstructorDecl(ctor); } - if (method_target_ == MethodTarget::ValueImpl && !GetCopyOrMoveTrait(decl) && + if (method_target_ == MethodTarget::ValueImpl && !GetRecordTrait(decl) && (decl->isStatic() || (!decl->isVirtual() && !decl->getParent()->isAbstract()))) { StrCat(AccessSpecifierAsString(decl->getAccess())); @@ -1297,7 +1297,7 @@ std::string Converter::GetSelfMaybeWithMut(const clang::CXXMethodDecl *decl) { } std::string Converter::GetCtorName(clang::CXXConstructorDecl *decl) { - if (auto *trait = GetCopyOrMoveTrait(decl)) { + if (auto *trait = GetRecordTrait(decl)) { return trait->method; } if (decl->isCopyOrMoveConstructor()) { @@ -1318,7 +1318,7 @@ bool Converter::VisitCXXConstructorDecl(clang::CXXConstructorDecl *decl) { } ScopedValue push_fn(curr_function_, decl); - if (method_target_ == MethodTarget::ValueImpl && !GetCopyOrMoveTrait(decl)) { + if (method_target_ == MethodTarget::ValueImpl && !GetRecordTrait(decl)) { StrCat(AccessSpecifierAsString(decl->getAccess())); } StrCat(keyword_unsafe_, keyword::kFn, GetCtorName(decl)); @@ -2496,14 +2496,13 @@ void Converter::ConvertGenericCallExpr(clang::CallExpr *expr) { } std::string Converter::GetUFCSName(const clang::CXXMethodDecl *method) const { - if (auto *trait = GetCopyOrMoveTrait(method)) { + if (auto *trait = GetRecordTrait(method)) { return GetCopyOrMoveTraitName(*trait); } return GetRecordName(method->getParent()); } -const char * -Converter::GetCopyOrMoveTraitName(const CopyOrMoveTrait &trait) const { +const char *Converter::GetCopyOrMoveTraitName(const RecordTrait &trait) const { return trait.unsafe_name; } @@ -4487,7 +4486,7 @@ const char *Converter::GetConstructorWrite() const { std::string Converter::GetConstructorPath(const clang::CXXConstructorDecl *ctor) const { - if (auto *trait = GetCopyOrMoveTrait(ctor)) { + if (auto *trait = GetRecordTrait(ctor)) { return GetCopyOrMoveTraitName(*trait); } return GetRecordName(ctor->getParent()); @@ -5291,7 +5290,7 @@ void Converter::ConvertCXXMethodDecls( bool (*predicate)(clang::CXXMethodDecl *)) { bool first = true; auto convert_method = [&](clang::CXXMethodDecl *method) { - if (predicate(method) && !GetCopyOrMoveTrait(method)) { + if (predicate(method) && !GetRecordTrait(method)) { if (first) { StrCat(signature, token::kOpenCurlyBracket); first = false; @@ -5561,11 +5560,12 @@ void Converter::AddCopyAndMoveDerives(const clang::RecordDecl *decl, return; } auto *cxx = clang::dyn_cast(decl); - for (const auto &trait : kCopyOrMoveTraits) { + for (const auto *trait : {&kCopyConstructible, &kMoveConstructible, + &kCopyAssignable, &kMoveAssignable}) { if (!cxx || llvm::none_of(cxx->methods(), [&](auto *method) { - return GetCopyOrMoveTrait(method) == &trait; + return GetRecordTrait(method) == trait; })) { - attrs.emplace_back(GetCopyOrMoveTraitName(trait)); + attrs.emplace_back(GetCopyOrMoveTraitName(*trait)); } } } diff --git a/cpp2rust/converter/converter.h b/cpp2rust/converter/converter.h index 1bf1b0fe3e..4878f06c41 100644 --- a/cpp2rust/converter/converter.h +++ b/cpp2rust/converter/converter.h @@ -358,8 +358,7 @@ class Converter : public clang::RecursiveASTVisitor { virtual const char *GetConversionTraitName() const; - virtual const char * - GetCopyOrMoveTraitName(const CopyOrMoveTrait &trait) const; + virtual const char *GetCopyOrMoveTraitName(const RecordTrait &trait) const; void AddCopyAndMoveDerives(const clang::RecordDecl *decl, std::vector &attrs); @@ -890,7 +889,7 @@ class Converter : public clang::RecursiveASTVisitor { bool (*predicate)(clang::CXXMethodDecl *)); void ConvertCopyOrMoveTraitImpl(clang::CXXMethodDecl *method, - const CopyOrMoveTrait &trait); + const RecordTrait &trait); void ConvertCXXMethodDecls(const clang::CXXRecordDecl *decl, const std::string_view signature, diff --git a/cpp2rust/converter/converter_lib.cpp b/cpp2rust/converter/converter_lib.cpp index 40ebcf4b9c..a04dc69e55 100644 --- a/cpp2rust/converter/converter_lib.cpp +++ b/cpp2rust/converter/converter_lib.cpp @@ -615,7 +615,7 @@ static bool IsTranslatedCopyOrMove(const clang::CXXMethodDecl *method) { : IsTranslatedMoveAssignment(method); } -const CopyOrMoveTrait *GetCopyOrMoveTrait(const clang::CXXMethodDecl *method) { +const RecordTrait *GetRecordTrait(const clang::CXXMethodDecl *method) { method = method->getCanonicalDecl(); const char *name = GetCopyOrMoveName(method); if (!name || method->isDeleted() || method->isVirtual() || @@ -633,12 +633,10 @@ const CopyOrMoveTrait *GetCopyOrMoveTrait(const clang::CXXMethodDecl *method) { param.getNonReferenceType().isConstQualified() != is_copy) { return nullptr; } - for (const auto &trait : kCopyOrMoveTraits) { - if (trait.is_copy == is_copy && trait.is_assign == !ctor) { - return &trait; - } + if (ctor) { + return is_copy ? &kCopyConstructible : &kMoveConstructible; } - return nullptr; + return is_copy ? &kCopyAssignable : &kMoveAssignable; } bool IsUserDefinedCopyConstructor(const clang::CXXConstructorDecl *ctor) { diff --git a/cpp2rust/converter/converter_lib.h b/cpp2rust/converter/converter_lib.h index d8959f27bb..2f13f2644e 100644 --- a/cpp2rust/converter/converter_lib.h +++ b/cpp2rust/converter/converter_lib.h @@ -105,24 +105,22 @@ const char *GetCopyOrMoveName(const clang::CXXMethodDecl *method); bool CanUseCopyOrMoveName(const clang::CXXMethodDecl *decl, const std::string &name); -struct CopyOrMoveTrait { +struct RecordTrait { const char *name; const char *unsafe_name; const char *method; - bool is_copy; - bool is_assign; }; -inline constexpr CopyOrMoveTrait kCopyOrMoveTraits[] = { - {"CopyConstructible", "CopyConstructibleUnsafe", "copy_constructor", true, - false}, - {"MoveConstructible", "MoveConstructibleUnsafe", "move_constructor", false, - false}, - {"CopyAssignable", "CopyAssignableUnsafe", "copy_assign", true, true}, - {"MoveAssignable", "MoveAssignableUnsafe", "move_assign", false, true}, -}; +inline constexpr RecordTrait kCopyConstructible{ + "CopyConstructible", "CopyConstructibleUnsafe", "copy_constructor"}; +inline constexpr RecordTrait kMoveConstructible{ + "MoveConstructible", "MoveConstructibleUnsafe", "move_constructor"}; +inline constexpr RecordTrait kCopyAssignable{ + "CopyAssignable", "CopyAssignableUnsafe", "copy_assign"}; +inline constexpr RecordTrait kMoveAssignable{ + "MoveAssignable", "MoveAssignableUnsafe", "move_assign"}; -const CopyOrMoveTrait *GetCopyOrMoveTrait(const clang::CXXMethodDecl *method); +const RecordTrait *GetRecordTrait(const clang::CXXMethodDecl *method); bool IsUserDefinedCopyConstructor(const clang::CXXConstructorDecl *ctor); diff --git a/cpp2rust/converter/models/converter_refcount.cpp b/cpp2rust/converter/models/converter_refcount.cpp index 12bacd6115..e3864a0cff 100644 --- a/cpp2rust/converter/models/converter_refcount.cpp +++ b/cpp2rust/converter/models/converter_refcount.cpp @@ -846,7 +846,7 @@ void ConverterRefCount::EmitByteSizeAttr(const clang::RecordDecl *decl) { std::string ConverterRefCount::GetSelfMaybeWithMut(const clang::CXXMethodDecl *decl) { - if (GetCopyOrMoveTrait(decl)) { + if (GetRecordTrait(decl)) { return "this: &Ptr"; } return NeedsMutAccess(decl, decl->getThisType()->getPointeeType()) @@ -2374,7 +2374,7 @@ const char *ConverterRefCount::GetConversionTraitName() const { } const char * -ConverterRefCount::GetCopyOrMoveTraitName(const CopyOrMoveTrait &trait) const { +ConverterRefCount::GetCopyOrMoveTraitName(const RecordTrait &trait) const { return trait.name; } @@ -3580,7 +3580,7 @@ bool ConverterRefCount::ShouldConvertMethod(const clang::CXXMethodDecl *decl) { // TODO: every trait on a Ptr should receive `this`. bool ConverterRefCount::ReceivesThis() const { auto *method = clang::dyn_cast_or_null(curr_function_); - return method && GetCopyOrMoveTrait(method); + return method && GetRecordTrait(method); } const char *ConverterRefCount::SelfName() const { @@ -3627,7 +3627,7 @@ void ConverterRefCount::SetUFCSReceiver(clang::Expr *base, bool is_arrow, std::string ConverterRefCount::GetUFCSName(const clang::CXXMethodDecl *method) const { - if (auto *trait = GetCopyOrMoveTrait(method)) { + if (auto *trait = GetRecordTrait(method)) { return GetCopyOrMoveTraitName(*trait); } if (!IsMethodOnPtr(method)) { @@ -3672,7 +3672,7 @@ bool ConverterRefCount::ConvertOutOfLineMethod(clang::CXXMethodDecl *decl) { void ConverterRefCount::ConvertMethodOnPtrTraitDecl( clang::CXXMethodDecl *method) { - if (GetCopyOrMoveTrait(method)) { + if (GetRecordTrait(method)) { return; } Buffer buf(*this); @@ -3689,7 +3689,7 @@ void ConverterRefCount::ConvertMethodOnPtrTraitDecl( void ConverterRefCount::ConvertMethodOnPtr(clang::CXXMethodDecl *method) { if ((!method->isThisDeclarationADefinition() && !clang::isa(method)) || - GetCopyOrMoveTrait(method)) { + GetRecordTrait(method)) { return; } Buffer buf(*this); @@ -3793,7 +3793,7 @@ const char *ConverterRefCount::GetConstructorWrite() const { std::string ConverterRefCount::GetConstructorPath( const clang::CXXConstructorDecl *ctor) const { - if (auto *trait = GetCopyOrMoveTrait(ctor)) { + if (auto *trait = GetRecordTrait(ctor)) { return GetCopyOrMoveTraitName(*trait); } return TraitName(ctor->getParent()); diff --git a/cpp2rust/converter/models/converter_refcount.h b/cpp2rust/converter/models/converter_refcount.h index 95d930ee18..574a164bbf 100644 --- a/cpp2rust/converter/models/converter_refcount.h +++ b/cpp2rust/converter/models/converter_refcount.h @@ -530,8 +530,7 @@ class ConverterRefCount final : public Converter { const char *GetConversionTraitName() const override; - const char * - GetCopyOrMoveTraitName(const CopyOrMoveTrait &trait) const override; + const char *GetCopyOrMoveTraitName(const RecordTrait &trait) const override; bool IsBoxedType(clang::QualType type); bool IsVecType(clang::QualType type); From d11a015a707406d25ac9cf205dce041973ae0060 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Mon, 30 Nov 2026 21:11:34 +0000 Subject: [PATCH 08/20] Add Copyable supertrait --- cpp2rust/converter/converter.cpp | 18 +- cpp2rust/converter/converter_lib.h | 1 + libcc2rs-macros/src/constructor.rs | 18 +- libcc2rs-macros/src/lib.rs | 10 + libcc2rs/src/constructor.rs | 20 ++ libcc2rs/src/lib.rs | 12 +- rules/dirent/shim.rs | 20 +- rules/ifaddrs/shim.rs | 20 +- rules/ip/shim.rs | 33 +-- rules/netdb/shim.rs | 21 +- rules/poll/shim.rs | 21 +- rules/pwd/shim.rs | 21 +- rules/select/shim.rs | 4 +- rules/socket/shim.rs | 61 +--- rules/stat/shim.rs | 20 +- rules/termios/shim.rs | 28 +- rules/time/shim.rs | 47 +-- .../out/refcount/cross_tu_tag_collision.rs | 15 +- .../out/unsafe/cross_tu_tag_collision.rs | 13 +- .../out/refcount/friend_operator.rs | 15 +- .../out/unsafe/friend_operator.rs | 13 +- .../out/refcount/opaque_forward_decl.rs | 14 +- .../out/unsafe/opaque_forward_decl.rs | 13 +- .../refcount/out_of_line_methods_cross_tu.rs | 45 +-- .../unsafe/out_of_line_methods_cross_tu.rs | 39 +-- .../template_method_late_instantiation.rs | 14 +- .../template_method_late_instantiation.rs | 12 +- .../out/refcount/p14-class-in-two-files.rs | 28 +- .../out/unsafe/p14-class-in-two-files.rs | 24 +- .../p15-class-template-static-member.rs | 30 +- .../p15-class-template-static-member.rs | 26 +- .../out/refcount/p15-function-template.rs | 43 +-- .../out/unsafe/p15-function-template.rs | 37 +-- .../out/refcount/p15-inline-function.rs | 13 +- .../out/unsafe/p15-inline-function.rs | 11 +- .../out/refcount/p15-inline-variable.rs | 13 +- .../out/unsafe/p15-inline-variable.rs | 11 +- .../p16-default-argument-lambda-in-class.rs | 28 +- .../p16-default-argument-lambda-in-class.rs | 24 +- .../refcount/p16-lambda-in-inline-function.rs | 13 +- .../unsafe/p16-lambda-in-inline-function.rs | 11 +- .../basic.link/out/refcount/basic.link.rs | 139 +-------- .../basic/basic.link/out/unsafe/basic.link.rs | 123 +------- .../out/refcount/basic.scope.block.rs | 13 +- .../out/refcount/basic.scope.class.rs | 28 +- .../out/refcount/basic.scope.param.rs | 14 +- .../out/refcount/basic.scope.pdecl.rs | 27 +- .../out/refcount/basic.scope.scope.rs | 212 +------------- .../out/unsafe/basic.scope.block.rs | 11 +- .../out/unsafe/basic.scope.class.rs | 24 +- .../out/unsafe/basic.scope.param.rs | 12 +- .../out/unsafe/basic.scope.pdecl.rs | 25 +- .../out/unsafe/basic.scope.scope.rs | 189 +----------- .../out/refcount/basic.start.term-p1-exit.rs | 13 +- .../out/refcount/basic.start.term.rs | 56 +--- .../out/unsafe/basic.start.term-p1-exit.rs | 11 +- .../out/unsafe/basic.start.term.rs | 48 +-- .../out/refcount/basic.types.general.rs | 30 +- .../out/unsafe/basic.types.general.rs | 26 +- tests/std/basic/out/refcount/basic.def.odr.rs | 58 +--- tests/std/basic/out/unsafe/basic.def.odr.rs | 50 +--- .../out/refcount/class.base.init.rs | 14 +- .../class.init/out/unsafe/class.base.init.rs | 12 +- .../out/refcount/class.conv.ctor.rs | 14 +- .../class.conv/out/refcount/class.conv.fct.rs | 14 +- .../class.conv/out/unsafe/class.conv.ctor.rs | 12 +- .../class.conv/out/unsafe/class.conv.fct.rs | 12 +- .../class.mem/out/refcount/class.free.rs | 30 +- .../out/refcount/class.mem.general.rs | 28 +- .../class/class.mem/out/unsafe/class.free.rs | 26 +- .../class.mem/out/unsafe/class.mem.general.rs | 24 +- .../dcl.init.general-p6.2-padding-bits.rs | 45 +-- .../dcl.init/out/refcount/dcl.init.general.rs | 126 +------- .../dcl.init.general-p6.2-padding-bits.rs | 39 +-- .../dcl.init/out/unsafe/dcl.init.general.rs | 113 +------- .../dcl.meaning/out/refcount/dcl.array.rs | 15 +- .../out/refcount/dcl.fct.default.rs | 58 +--- .../dcl.meaning/out/refcount/dcl.mptr.rs | 72 +---- .../dcl.meaning/out/unsafe/dcl.array.rs | 13 +- .../dcl.meaning/out/unsafe/dcl.fct.default.rs | 50 +--- .../dcl.meaning/out/unsafe/dcl.mptr.rs | 64 +--- tests/std/expr/conv/out/refcount/conv.mem.rs | 15 +- tests/std/expr/conv/out/unsafe/conv.mem.rs | 13 +- .../expr.post/out/refcount/expr.const.cast.rs | 15 +- ...nterpret.cast-p10-result-is-unspecified.rs | 30 +- .../out/refcount/expr.reinterpret.cast.rs | 60 +--- .../expr.post/out/unsafe/expr.const.cast.rs | 13 +- ...nterpret.cast-p10-result-is-unspecified.rs | 26 +- .../out/unsafe/expr.reinterpret.cast.rs | 52 +--- .../expr.unary/out/refcount/expr.pre.incr.rs | 15 +- .../expr.unary/out/refcount/expr.unary.op.rs | 45 +-- .../expr.unary/out/unsafe/expr.pre.incr.rs | 13 +- .../expr.unary/out/unsafe/expr.unary.op.rs | 39 +-- .../expr.compound/out/refcount/expr.cond.rs | 15 +- .../expr.compound/out/refcount/expr.eq.rs | 57 +--- ...ptr.oper-p6-null-pointer-to-data-member.rs | 15 +- .../out/refcount/expr.mptr.oper.rs | 45 +-- .../expr.compound/out/unsafe/expr.cond.rs | 13 +- .../expr/expr.compound/out/unsafe/expr.eq.rs | 51 +--- ...ptr.oper-p6-null-pointer-to-data-member.rs | 13 +- .../out/unsafe/expr.mptr.oper.rs | 39 +-- .../expr.prim/out/refcount/expr.prim.this.rs | 27 +- .../expr.prim/out/unsafe/expr.prim.this.rs | 25 +- .../allocator.requirements.general.rs | 44 +-- .../unsafe/allocator.requirements.general.rs | 38 +-- .../stmt.iter/out/refcount/stmt.while.rs | 10 +- .../stmt.iter/out/unsafe/stmt.while.rs | 10 +- .../stmt.select/out/refcount/stmt.switch.rs | 5 +- .../stmt.select/out/unsafe/stmt.switch.rs | 5 +- tests/std/temp/out/refcount/temp.type.rs | 60 +--- tests/std/temp/out/unsafe/temp.type.rs | 52 +--- .../temp/temp.spec/out/refcount/temp.inst.rs | 14 +- .../temp/temp.spec/out/unsafe/temp.inst.rs | 12 +- .../utilities/utility/out/refcount/forward.rs | 15 +- .../utility/out/refcount/utility.as.const.rs | 15 +- .../utilities/utility/out/unsafe/forward.rs | 13 +- .../utility/out/unsafe/utility.as.const.rs | 13 +- tests/ub/out/refcount/ctor_ref_member.rs | 13 +- .../refcount/self_referencing_initializer.rs | 15 +- tests/ub/out/refcount/ub6.rs | 14 +- tests/ub/out/unsafe/ctor_ref_member.rs | 12 +- .../unsafe/self_referencing_initializer.rs | 13 +- tests/ub/out/unsafe/ub6.rs | 13 +- tests/unit/out/refcount/05_new.rs | 30 +- tests/unit/out/refcount/10_struct.rs | 70 +---- tests/unit/out/refcount/addr_of_global.rs | 29 +- tests/unit/out/refcount/anonymous-struct.rs | 135 +-------- tests/unit/out/refcount/anonymous-struct_c.rs | 135 +-------- tests/unit/out/refcount/anonymous_enum.rs | 30 +- tests/unit/out/refcount/anonymous_enum_c.rs | 30 +- tests/unit/out/refcount/any.rs | 15 +- tests/unit/out/refcount/array_const_init.rs | 28 +- tests/unit/out/refcount/array_field_addr.rs | 13 +- tests/unit/out/refcount/array_reference.rs | 15 +- tests/unit/out/refcount/as_const.rs | 15 +- tests/unit/out/refcount/assign_rhs_first.rs | 14 +- .../out/refcount/assignment_single_eval.rs | 274 ++---------------- tests/unit/out/refcount/bounded_struct_ptr.rs | 15 +- tests/unit/out/refcount/bst.rs | 14 +- tests/unit/out/refcount/c_struct.rs | 74 +---- tests/unit/out/refcount/cast.rs | 43 +-- .../refcount/cast_array_to_pointer_decay.rs | 13 +- tests/unit/out/refcount/class.rs | 60 +--- .../refcount/class_template_lazy_member.rs | 75 +---- tests/unit/out/refcount/class_templates.rs | 135 +-------- tests/unit/out/refcount/clone_vs_move.rs | 42 +-- tests/unit/out/refcount/comma_operator.rs | 15 +- tests/unit/out/refcount/complex_function.rs | 57 +--- .../out/refcount/compound_assign_paren.rs | 15 +- tests/unit/out/refcount/concepts.rs | 15 +- tests/unit/out/refcount/constexpr_function.rs | 30 +- tests/unit/out/refcount/constructor.rs | 20 +- .../conversion_operator_same_translation.rs | 28 +- tests/unit/out/refcount/copy_assign.rs | 14 +- .../unit/out/refcount/copy_move_defaulted.rs | 28 +- tests/unit/out/refcount/default.rs | 39 +-- .../refcount/default_function_arguments.rs | 30 +- tests/unit/out/refcount/default_in_statics.rs | 41 +-- tests/unit/out/refcount/delete_array_order.rs | 13 +- tests/unit/out/refcount/destructor.rs | 144 +-------- tests/unit/out/refcount/destructor_params.rs | 28 +- .../out/refcount/destructor_temporaries.rs | 26 +- tests/unit/out/refcount/doubly_linked_list.rs | 14 +- .../out/refcount/enum_default_in_static.rs | 15 +- tests/unit/out/refcount/enum_int_interop.rs | 14 +- tests/unit/out/refcount/enum_int_interop_c.rs | 14 +- .../unit/out/refcount/enum_underlying_type.rs | 14 +- tests/unit/out/refcount/exprs.rs | 29 +- tests/unit/out/refcount/fft.rs | 15 +- tests/unit/out/refcount/field_aliasing.rs | 42 +-- .../unit/out/refcount/field_array_elem_ptr.rs | 28 +- .../out/refcount/field_method_receiver.rs | 15 +- tests/unit/out/refcount/field_pointers.rs | 28 +- .../field_pointers_malloced_struct.rs | 15 +- .../field_reinterpret_write_through.rs | 28 +- tests/unit/out/refcount/find.rs | 15 +- .../refcount/first_field_ptr_covers_struct.rs | 30 +- .../out/refcount/first_member_downcast.rs | 30 +- .../refcount/flex_array_member_incomplete.rs | 13 +- .../flex_array_member_sibling_write.rs | 41 +-- tests/unit/out/refcount/fn_ptr.rs | 13 +- tests/unit/out/refcount/fn_ptr_cast.rs | 14 +- tests/unit/out/refcount/fn_ptr_stable_sort.rs | 15 +- tests/unit/out/refcount/fn_ptr_struct.rs | 29 +- .../unit/out/refcount/fn_ptr_typedef_cast.rs | 15 +- tests/unit/out/refcount/fn_ptr_vtable.rs | 14 +- tests/unit/out/refcount/fn_ref.rs | 14 +- .../unit/out/refcount/for_body_destructor.rs | 13 +- tests/unit/out/refcount/friend.rs | 60 +--- .../unit/out/refcount/function_overloading.rs | 15 +- .../out/refcount/global_call_temporaries.rs | 15 +- .../out/refcount/global_init_side_effect.rs | 14 +- .../out/refcount/global_non_const_init.rs | 43 +-- tests/unit/out/refcount/global_pointers.rs | 14 +- .../refcount/global_without_initializer.rs | 15 +- .../out/refcount/goto_aggregate_default.rs | 15 +- tests/unit/out/refcount/goto_cleanup.rs | 14 +- tests/unit/out/refcount/huffman.rs | 14 +- .../refcount/immutable-deref-on-func-call.rs | 15 +- .../refcount/in_class_field_initializer.rs | 42 +-- tests/unit/out/refcount/init.rs | 15 +- tests/unit/out/refcount/init_list.rs | 43 +-- tests/unit/out/refcount/kruskal.rs | 15 +- tests/unit/out/refcount/lambda_as_field.rs | 54 +--- tests/unit/out/refcount/lambda_capture_ref.rs | 15 +- .../out/refcount/lambda_capture_star_this.rs | 15 +- .../unit/out/refcount/lambda_capture_this.rs | 15 +- .../unit/out/refcount/lambda_capture_value.rs | 15 +- .../unit/out/refcount/lambda_decltype_type.rs | 26 +- .../refcount/lambda_generic_explicit_args.rs | 15 +- .../out/refcount/lambda_immediate_init.rs | 14 +- tests/unit/out/refcount/lambda_nested.rs | 15 +- .../unit/out/refcount/lambda_static_local.rs | 15 +- .../refcount/libc_struct_without_default.rs | 13 +- tests/unit/out/refcount/linked_list.rs | 14 +- .../refcount/local_anon_struct_collision.rs | 30 +- .../out/refcount/local_record_template.rs | 60 +--- tests/unit/out/refcount/map.rs | 14 +- tests/unit/out/refcount/map_key_identity.rs | 29 +- tests/unit/out/refcount/map_try_emplace.rs | 14 +- .../out/refcount/map_try_emplace_lvalues.rs | 55 +--- .../unit/out/refcount/memcpy_struct_bytes.rs | 15 +- .../out/refcount/memcpy_struct_layouts.rs | 73 +---- .../unit/out/refcount/memcpy_struct_struct.rs | 15 +- tests/unit/out/refcount/memset_struct_tail.rs | 13 +- tests/unit/out/refcount/nested_structs.rs | 90 +----- tests/unit/out/refcount/new.rs | 15 +- tests/unit/out/refcount/new_bst.rs | 14 +- tests/unit/out/refcount/new_struct.rs | 30 +- .../refcount/nttp_distinct_specializations.rs | 45 +-- tests/unit/out/refcount/offsetof.rs | 28 +- .../unit/out/refcount/opaque_forward_decl.rs | 14 +- tests/unit/out/refcount/opaque_record_copy.rs | 30 +- .../unit/out/refcount/opaque_then_defined.rs | 28 +- .../out/refcount/operator_arithmetic_free.rs | 15 +- .../refcount/operator_arithmetic_member.rs | 15 +- .../out/refcount/operator_bitwise_free.rs | 15 +- .../out/refcount/operator_bitwise_member.rs | 15 +- .../refcount/operator_comparison_defaulted.rs | 119 +------- .../out/refcount/operator_comparison_free.rs | 30 +- .../refcount/operator_comparison_member.rs | 15 +- .../out/refcount/operator_comparison_mixed.rs | 15 +- .../refcount/operator_comparison_nonbool.rs | 104 +------ .../operator_compound_assignment_free.rs | 15 +- .../operator_compound_assignment_member.rs | 15 +- tests/unit/out/refcount/operator_friend.rs | 105 +------ tests/unit/out/refcount/operator_less_than.rs | 15 +- .../out/refcount/operator_logical_free.rs | 15 +- .../out/refcount/operator_logical_member.rs | 15 +- .../refcount/operator_member_pointer_free.rs | 28 +- .../operator_member_pointer_member.rs | 43 +-- .../unit/out/refcount/operator_other_free.rs | 15 +- .../out/refcount/operator_other_member.rs | 29 +- tests/unit/out/refcount/operator_overloads.rs | 15 +- .../unit/out/refcount/operator_qualifiers.rs | 15 +- tests/unit/out/refcount/operator_three_way.rs | 15 +- tests/unit/out/refcount/operator_traits.rs | 75 +---- tests/unit/out/refcount/overload_mangling.rs | 45 +-- .../refcount/pair_converting_construction.rs | 142 +-------- tests/unit/out/refcount/pod.rs | 15 +- tests/unit/out/refcount/pointer_array.rs | 13 +- tests/unit/out/refcount/pointers.rs | 15 +- tests/unit/out/refcount/polymorphism.rs | 30 +- tests/unit/out/refcount/ptr_cast_init.rs | 30 +- tests/unit/out/refcount/push_emplace_back.rs | 72 +---- tests/unit/out/refcount/random.rs | 28 +- tests/unit/out/refcount/reference_wrapper.rs | 15 +- tests/unit/out/refcount/references.rs | 27 +- tests/unit/out/refcount/refs_as_args.rs | 15 +- .../out/refcount/reinterpret_cast_ptr_cmp.rs | 41 +-- .../out/refcount/reinterpret_cast_struct.rs | 15 +- .../reinterpret_cast_struct_to_struct.rs | 30 +- tests/unit/out/refcount/reserved_keywords.rs | 45 +-- tests/unit/out/refcount/return_move.rs | 28 +- tests/unit/out/refcount/rvalue_struct.rs | 15 +- .../scalar_builtin_construct_destruct.rs | 15 +- .../refcount/self_referencing_initializer.rs | 41 +-- .../unit/out/refcount/size_t_static_member.rs | 30 +- .../out/refcount/size_t_template_param.rs | 28 +- tests/unit/out/refcount/static_local.rs | 15 +- .../unit/out/refcount/static_var_in_class.rs | 30 +- tests/unit/out/refcount/stdcopy.rs | 14 +- tests/unit/out/refcount/strdup.rs | 14 +- .../out/refcount/string_literal_ptr_init.rs | 14 +- tests/unit/out/refcount/string_substr.rs | 14 +- .../out/refcount/struct_2d_array_field.rs | 13 +- tests/unit/out/refcount/struct_ctor.rs | 43 +-- .../unit/out/refcount/struct_default_ctor.rs | 56 +--- .../refcount/struct_member_array_adjacency.rs | 13 +- tests/unit/out/refcount/struct_ptr.rs | 15 +- .../refcount/structured_binding_range_for.rs | 15 +- .../out/refcount/structured_binding_ref.rs | 15 +- .../refcount/structured_binding_trivial.rs | 15 +- .../refcount/tag_vs_identifier_collision.rs | 99 +------ .../unit/out/refcount/template_default_arg.rs | 57 +--- .../out/refcount/template_static_member.rs | 75 +---- .../out/refcount/temporary_field_ctor_arg.rs | 14 +- tests/unit/out/refcount/this.rs | 27 +- .../unit/out/refcount/typedef-anon-struct.rs | 15 +- .../out/refcount/unary_expr_or_type_trait.rs | 15 +- tests/unit/out/refcount/unboxed_locals.rs | 29 +- tests/unit/out/refcount/unboxed_records.rs | 42 +-- .../out/refcount/union_addrof_external.rs | 39 +-- tests/unit/out/refcount/union_basic.rs | 48 +-- .../unit/out/refcount/union_cross_arm_cast.rs | 52 +--- .../out/refcount/union_field_alignment.rs | 26 +- .../out/refcount/union_flex_array_member.rs | 26 +- .../unit/out/refcount/union_memset_memcpy.rs | 52 +--- tests/unit/out/refcount/union_nested.rs | 65 +---- .../out/refcount/union_pointer_pun_address.rs | 41 +-- .../union_pointer_pun_writethrough.rs | 12 +- .../out/refcount/union_struct_dual_use.rs | 41 +-- .../out/refcount/union_tagged_many_arms.rs | 26 +- .../unit/out/refcount/union_tagged_simple.rs | 26 +- .../out/refcount/union_tagged_struct_arms.rs | 70 +---- .../refcount/union_void_ptr_sized_deref.rs | 26 +- tests/unit/out/refcount/unique_ptr.rs | 15 +- .../out/refcount/unique_ptr_field_reset.rs | 15 +- tests/unit/out/refcount/unique_ptr_nested.rs | 15 +- tests/unit/out/refcount/unique_ptr_struct.rs | 15 +- tests/unit/out/refcount/va_arg_mixed_types.rs | 15 +- .../out/refcount/va_arg_non_primitive_ptrs.rs | 14 +- tests/unit/out/refcount/va_arg_struct_ctx.rs | 27 +- tests/unit/out/refcount/va_arg_void_ptr.rs | 14 +- tests/unit/out/refcount/va_list_field.rs | 19 +- tests/unit/out/refcount/vector.rs | 15 +- .../out/refcount/vector_iter_range_ctor.rs | 28 +- .../out/refcount/vector_subscript_direct.rs | 15 +- .../out/refcount/vector_with_allocator.rs | 30 +- tests/unit/out/refcount/void_cast.rs | 15 +- tests/unit/out/unsafe/05_new.rs | 26 +- tests/unit/out/unsafe/10_struct.rs | 64 +--- tests/unit/out/unsafe/addr_of_global.rs | 26 +- tests/unit/out/unsafe/anonymous-struct.rs | 117 +------- tests/unit/out/unsafe/anonymous-struct_c.rs | 117 +------- tests/unit/out/unsafe/anonymous_enum.rs | 26 +- tests/unit/out/unsafe/anonymous_enum_c.rs | 26 +- tests/unit/out/unsafe/any.rs | 13 +- tests/unit/out/unsafe/array_const_init.rs | 26 +- tests/unit/out/unsafe/array_field_addr.rs | 13 +- tests/unit/out/unsafe/array_reference.rs | 13 +- tests/unit/out/unsafe/as_const.rs | 13 +- tests/unit/out/unsafe/assign_rhs_first.rs | 13 +- .../unit/out/unsafe/assignment_single_eval.rs | 247 ++-------------- tests/unit/out/unsafe/bounded_struct_ptr.rs | 13 +- tests/unit/out/unsafe/bst.rs | 13 +- tests/unit/out/unsafe/c_struct.rs | 65 +---- tests/unit/out/unsafe/cast.rs | 39 +-- .../out/unsafe/cast_array_to_pointer_decay.rs | 13 +- tests/unit/out/unsafe/class.rs | 52 +--- .../out/unsafe/class_template_lazy_member.rs | 65 +---- tests/unit/out/unsafe/class_templates.rs | 117 +------- tests/unit/out/unsafe/clone_vs_move.rs | 39 +-- tests/unit/out/unsafe/comma_operator.rs | 13 +- tests/unit/out/unsafe/complex_function.rs | 52 +--- .../unit/out/unsafe/compound_assign_paren.rs | 13 +- tests/unit/out/unsafe/concepts.rs | 13 +- tests/unit/out/unsafe/constexpr_function.rs | 26 +- tests/unit/out/unsafe/constructor.rs | 18 +- .../conversion_operator_same_translation.rs | 24 +- tests/unit/out/unsafe/copy_assign.rs | 12 +- tests/unit/out/unsafe/copy_move_defaulted.rs | 26 +- tests/unit/out/unsafe/default.rs | 38 +-- .../out/unsafe/default_function_arguments.rs | 26 +- tests/unit/out/unsafe/default_in_statics.rs | 39 +-- tests/unit/out/unsafe/delete_array_order.rs | 11 +- tests/unit/out/unsafe/destructor.rs | 121 +------- tests/unit/out/unsafe/destructor_params.rs | 24 +- .../unit/out/unsafe/destructor_temporaries.rs | 22 +- tests/unit/out/unsafe/doubly_linked_list.rs | 13 +- .../unit/out/unsafe/enum_default_in_static.rs | 13 +- tests/unit/out/unsafe/enum_int_interop.rs | 13 +- tests/unit/out/unsafe/enum_int_interop_c.rs | 13 +- tests/unit/out/unsafe/enum_underlying_type.rs | 12 +- tests/unit/out/unsafe/exprs.rs | 26 +- tests/unit/out/unsafe/fft.rs | 13 +- tests/unit/out/unsafe/field_aliasing.rs | 39 +-- tests/unit/out/unsafe/field_array_elem_ptr.rs | 26 +- .../unit/out/unsafe/field_method_receiver.rs | 13 +- tests/unit/out/unsafe/field_pointers.rs | 26 +- .../unsafe/field_pointers_malloced_struct.rs | 13 +- .../unsafe/field_reinterpret_write_through.rs | 26 +- tests/unit/out/unsafe/find.rs | 13 +- .../unsafe/first_field_ptr_covers_struct.rs | 26 +- .../unit/out/unsafe/first_member_downcast.rs | 26 +- .../unsafe/flex_array_member_incomplete.rs | 12 +- .../unsafe/flex_array_member_sibling_write.rs | 39 +-- tests/unit/out/unsafe/fn_ptr.rs | 12 +- tests/unit/out/unsafe/fn_ptr_cast.rs | 13 +- tests/unit/out/unsafe/fn_ptr_stable_sort.rs | 13 +- tests/unit/out/unsafe/fn_ptr_struct.rs | 26 +- tests/unit/out/unsafe/fn_ptr_typedef_cast.rs | 13 +- tests/unit/out/unsafe/fn_ptr_vtable.rs | 13 +- tests/unit/out/unsafe/fn_ref.rs | 13 +- tests/unit/out/unsafe/for_body_destructor.rs | 11 +- tests/unit/out/unsafe/friend.rs | 52 +--- tests/unit/out/unsafe/function_overloading.rs | 13 +- .../out/unsafe/global_call_temporaries.rs | 13 +- .../out/unsafe/global_init_side_effect.rs | 12 +- .../unit/out/unsafe/global_non_const_init.rs | 37 +-- tests/unit/out/unsafe/global_pointers.rs | 13 +- .../out/unsafe/global_without_initializer.rs | 13 +- .../unit/out/unsafe/goto_aggregate_default.rs | 13 +- tests/unit/out/unsafe/goto_cleanup.rs | 13 +- tests/unit/out/unsafe/huffman.rs | 13 +- .../unsafe/immutable-deref-on-func-call.rs | 13 +- .../out/unsafe/in_class_field_initializer.rs | 36 +-- tests/unit/out/unsafe/init.rs | 13 +- tests/unit/out/unsafe/init_list.rs | 37 +-- tests/unit/out/unsafe/kruskal.rs | 13 +- tests/unit/out/unsafe/lambda_as_field.rs | 46 +-- tests/unit/out/unsafe/lambda_capture_ref.rs | 13 +- .../out/unsafe/lambda_capture_star_this.rs | 13 +- tests/unit/out/unsafe/lambda_capture_this.rs | 13 +- tests/unit/out/unsafe/lambda_capture_value.rs | 13 +- tests/unit/out/unsafe/lambda_decltype_type.rs | 22 +- .../unsafe/lambda_generic_explicit_args.rs | 13 +- .../unit/out/unsafe/lambda_immediate_init.rs | 12 +- tests/unit/out/unsafe/lambda_nested.rs | 13 +- tests/unit/out/unsafe/lambda_static_local.rs | 13 +- .../out/unsafe/libc_struct_without_default.rs | 12 +- tests/unit/out/unsafe/linked_list.rs | 13 +- .../out/unsafe/local_anon_struct_collision.rs | 26 +- .../unit/out/unsafe/local_record_template.rs | 52 +--- tests/unit/out/unsafe/map.rs | 12 +- tests/unit/out/unsafe/map_key_identity.rs | 25 +- tests/unit/out/unsafe/map_try_emplace.rs | 12 +- .../out/unsafe/map_try_emplace_lvalues.rs | 50 +--- tests/unit/out/unsafe/memcpy_struct_bytes.rs | 13 +- .../unit/out/unsafe/memcpy_struct_layouts.rs | 65 +---- tests/unit/out/unsafe/memcpy_struct_struct.rs | 13 +- tests/unit/out/unsafe/memset_struct_tail.rs | 13 +- tests/unit/out/unsafe/nested_structs.rs | 78 +---- tests/unit/out/unsafe/new.rs | 13 +- tests/unit/out/unsafe/new_bst.rs | 13 +- tests/unit/out/unsafe/new_struct.rs | 26 +- .../unsafe/nttp_distinct_specializations.rs | 39 +-- tests/unit/out/unsafe/offsetof.rs | 25 +- tests/unit/out/unsafe/opaque_forward_decl.rs | 13 +- tests/unit/out/unsafe/opaque_record_copy.rs | 26 +- tests/unit/out/unsafe/opaque_then_defined.rs | 26 +- .../out/unsafe/operator_arithmetic_free.rs | 13 +- .../out/unsafe/operator_arithmetic_member.rs | 13 +- .../unit/out/unsafe/operator_bitwise_free.rs | 13 +- .../out/unsafe/operator_bitwise_member.rs | 13 +- .../unsafe/operator_comparison_defaulted.rs | 104 +------ .../out/unsafe/operator_comparison_free.rs | 26 +- .../out/unsafe/operator_comparison_member.rs | 13 +- .../out/unsafe/operator_comparison_mixed.rs | 13 +- .../out/unsafe/operator_comparison_nonbool.rs | 90 +----- .../operator_compound_assignment_free.rs | 13 +- .../operator_compound_assignment_member.rs | 13 +- tests/unit/out/unsafe/operator_friend.rs | 91 +----- tests/unit/out/unsafe/operator_less_than.rs | 13 +- .../unit/out/unsafe/operator_logical_free.rs | 13 +- .../out/unsafe/operator_logical_member.rs | 13 +- .../unsafe/operator_member_pointer_free.rs | 26 +- .../unsafe/operator_member_pointer_member.rs | 39 +-- tests/unit/out/unsafe/operator_other_free.rs | 13 +- .../unit/out/unsafe/operator_other_member.rs | 25 +- tests/unit/out/unsafe/operator_overloads.rs | 13 +- tests/unit/out/unsafe/operator_qualifiers.rs | 13 +- tests/unit/out/unsafe/operator_three_way.rs | 13 +- tests/unit/out/unsafe/operator_traits.rs | 65 +---- tests/unit/out/unsafe/overload_mangling.rs | 39 +-- .../unsafe/pair_converting_construction.rs | 122 +------- tests/unit/out/unsafe/pod.rs | 13 +- tests/unit/out/unsafe/pointer_array.rs | 13 +- tests/unit/out/unsafe/pointers.rs | 13 +- tests/unit/out/unsafe/polymorphism.rs | 26 +- tests/unit/out/unsafe/ptr_cast_init.rs | 26 +- tests/unit/out/unsafe/push_emplace_back.rs | 65 +---- tests/unit/out/unsafe/random.rs | 26 +- tests/unit/out/unsafe/reference_wrapper.rs | 13 +- tests/unit/out/unsafe/references.rs | 26 +- tests/unit/out/unsafe/refs_as_args.rs | 13 +- .../out/unsafe/reinterpret_cast_ptr_cmp.rs | 39 +-- .../out/unsafe/reinterpret_cast_struct.rs | 13 +- .../reinterpret_cast_struct_to_struct.rs | 26 +- tests/unit/out/unsafe/reserved_keywords.rs | 39 +-- tests/unit/out/unsafe/return_move.rs | 26 +- tests/unit/out/unsafe/rvalue_struct.rs | 13 +- .../scalar_builtin_construct_destruct.rs | 13 +- .../unsafe/self_referencing_initializer.rs | 38 +-- tests/unit/out/unsafe/size_t_static_member.rs | 26 +- .../unit/out/unsafe/size_t_template_param.rs | 24 +- tests/unit/out/unsafe/static_local.rs | 13 +- tests/unit/out/unsafe/static_var_in_class.rs | 26 +- tests/unit/out/unsafe/stdcopy.rs | 12 +- tests/unit/out/unsafe/strdup.rs | 13 +- .../out/unsafe/string_literal_ptr_init.rs | 13 +- tests/unit/out/unsafe/string_substr.rs | 13 +- .../unit/out/unsafe/struct_2d_array_field.rs | 13 +- tests/unit/out/unsafe/struct_ctor.rs | 37 +-- tests/unit/out/unsafe/struct_default_ctor.rs | 50 +--- .../unsafe/struct_member_array_adjacency.rs | 13 +- tests/unit/out/unsafe/struct_ptr.rs | 13 +- .../unsafe/structured_binding_range_for.rs | 13 +- .../unit/out/unsafe/structured_binding_ref.rs | 13 +- .../out/unsafe/structured_binding_trivial.rs | 13 +- .../out/unsafe/tag_vs_identifier_collision.rs | 89 +----- tests/unit/out/unsafe/template_default_arg.rs | 49 +--- .../unit/out/unsafe/template_static_member.rs | 65 +---- .../out/unsafe/temporary_field_ctor_arg.rs | 12 +- tests/unit/out/unsafe/this.rs | 24 +- tests/unit/out/unsafe/typedef-anon-struct.rs | 13 +- .../out/unsafe/unary_expr_or_type_trait.rs | 13 +- tests/unit/out/unsafe/unboxed_locals.rs | 25 +- tests/unit/out/unsafe/unboxed_records.rs | 38 +-- .../unit/out/unsafe/union_addrof_external.rs | 38 +-- tests/unit/out/unsafe/union_basic.rs | 48 +-- tests/unit/out/unsafe/union_cross_arm_cast.rs | 51 +--- .../unit/out/unsafe/union_field_alignment.rs | 25 +- .../out/unsafe/union_flex_array_member.rs | 25 +- tests/unit/out/unsafe/union_memset_memcpy.rs | 51 +--- tests/unit/out/unsafe/union_nested.rs | 63 +--- .../out/unsafe/union_pointer_pun_address.rs | 38 +-- .../unsafe/union_pointer_pun_writethrough.rs | 12 +- .../unit/out/unsafe/union_struct_dual_use.rs | 38 +-- .../unit/out/unsafe/union_tagged_many_arms.rs | 25 +- tests/unit/out/unsafe/union_tagged_simple.rs | 25 +- .../out/unsafe/union_tagged_struct_arms.rs | 64 +--- .../out/unsafe/union_void_ptr_sized_deref.rs | 25 +- tests/unit/out/unsafe/unique_ptr.rs | 13 +- .../unit/out/unsafe/unique_ptr_field_reset.rs | 13 +- tests/unit/out/unsafe/unique_ptr_nested.rs | 13 +- tests/unit/out/unsafe/unique_ptr_struct.rs | 13 +- tests/unit/out/unsafe/va_arg_mixed_types.rs | 13 +- .../out/unsafe/va_arg_non_primitive_ptrs.rs | 13 +- tests/unit/out/unsafe/va_arg_struct_ctx.rs | 25 +- tests/unit/out/unsafe/va_arg_void_ptr.rs | 13 +- tests/unit/out/unsafe/va_list_field.rs | 18 +- tests/unit/out/unsafe/vector.rs | 13 +- .../unit/out/unsafe/vector_iter_range_ctor.rs | 24 +- .../out/unsafe/vector_subscript_direct.rs | 13 +- .../unit/out/unsafe/vector_with_allocator.rs | 26 +- tests/unit/out/unsafe/void_cast.rs | 13 +- 537 files changed, 1277 insertions(+), 14827 deletions(-) diff --git a/cpp2rust/converter/converter.cpp b/cpp2rust/converter/converter.cpp index a966a3479c..5fdb80b985 100644 --- a/cpp2rust/converter/converter.cpp +++ b/cpp2rust/converter/converter.cpp @@ -5560,11 +5560,19 @@ void Converter::AddCopyAndMoveDerives(const clang::RecordDecl *decl, return; } auto *cxx = clang::dyn_cast(decl); - for (const auto *trait : {&kCopyConstructible, &kMoveConstructible, - &kCopyAssignable, &kMoveAssignable}) { - if (!cxx || llvm::none_of(cxx->methods(), [&](auto *method) { - return GetRecordTrait(method) == trait; - })) { + auto implements = [&](const RecordTrait *trait) { + return cxx && llvm::any_of(cxx->methods(), [&](auto *method) { + return GetRecordTrait(method) == trait; + }); + }; + const RecordTrait *traits[] = {&kCopyConstructible, &kMoveConstructible, + &kCopyAssignable, &kMoveAssignable}; + if (llvm::none_of(traits, implements)) { + attrs.emplace_back(GetCopyOrMoveTraitName(kCopyable)); + return; + } + for (const auto *trait : traits) { + if (!implements(trait)) { attrs.emplace_back(GetCopyOrMoveTraitName(*trait)); } } diff --git a/cpp2rust/converter/converter_lib.h b/cpp2rust/converter/converter_lib.h index 2f13f2644e..40f277d331 100644 --- a/cpp2rust/converter/converter_lib.h +++ b/cpp2rust/converter/converter_lib.h @@ -119,6 +119,7 @@ inline constexpr RecordTrait kCopyAssignable{ "CopyAssignable", "CopyAssignableUnsafe", "copy_assign"}; inline constexpr RecordTrait kMoveAssignable{ "MoveAssignable", "MoveAssignableUnsafe", "move_assign"}; +inline constexpr RecordTrait kCopyable{"Copyable", "CopyableUnsafe", nullptr}; const RecordTrait *GetRecordTrait(const clang::CXXMethodDecl *method); diff --git a/libcc2rs-macros/src/constructor.rs b/libcc2rs-macros/src/constructor.rs index bd2bfda66b..92ec57ac20 100644 --- a/libcc2rs-macros/src/constructor.rs +++ b/libcc2rs-macros/src/constructor.rs @@ -2,11 +2,28 @@ // Distributed under the MIT license that can be found in the LICENSE file. use proc_macro::TokenStream; +use proc_macro2::TokenStream as TokenStream2; use quote::{format_ident, quote}; use syn::{DeriveInput, parse_macro_input}; pub fn expand(input: TokenStream, op: &str, is_assign: bool, is_unsafe: bool) -> TokenStream { let input = parse_macro_input!(input as DeriveInput); + impl_trait(&input, op, is_assign, is_unsafe).into() +} + +pub fn expand_copyable(input: TokenStream, is_unsafe: bool) -> TokenStream { + let input = parse_macro_input!(input as DeriveInput); + let impls = [ + ("copy", false), + ("move", false), + ("copy", true), + ("move", true), + ] + .map(|(op, is_assign)| impl_trait(&input, op, is_assign, is_unsafe)); + quote!(#(#impls)*).into() +} + +fn impl_trait(input: &DeriveInput, op: &str, is_assign: bool, is_unsafe: bool) -> TokenStream2 { let name = &input.ident; let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl(); let is_move = op == "move"; @@ -71,5 +88,4 @@ pub fn expand(input: TokenStream, op: &str, is_assign: bool, is_unsafe: bool) -> } } } - .into() } diff --git a/libcc2rs-macros/src/lib.rs b/libcc2rs-macros/src/lib.rs index e053ee88f0..25ebfb598a 100644 --- a/libcc2rs-macros/src/lib.rs +++ b/libcc2rs-macros/src/lib.rs @@ -185,6 +185,16 @@ pub fn derive_copy_constructible_unsafe(input: TokenStream) -> TokenStream { constructor::expand(input, "copy", false, true) } +#[proc_macro_derive(Copyable)] +pub fn derive_copyable(input: TokenStream) -> TokenStream { + constructor::expand_copyable(input, false) +} + +#[proc_macro_derive(CopyableUnsafe)] +pub fn derive_copyable_unsafe(input: TokenStream) -> TokenStream { + constructor::expand_copyable(input, true) +} + #[proc_macro_derive(CopyAssignable)] pub fn derive_copy_assignable(input: TokenStream) -> TokenStream { constructor::expand(input, "copy", true, false) diff --git a/libcc2rs/src/constructor.rs b/libcc2rs/src/constructor.rs index 55e2564e0f..4598c86b39 100644 --- a/libcc2rs/src/constructor.rs +++ b/libcc2rs/src/constructor.rs @@ -26,6 +26,14 @@ pub trait MoveAssignable: Sized { fn move_assign(this: &Ptr, src: Ptr) -> Ptr; } +// std::copyable, without swappable. +pub trait Copyable: + CopyConstructible + MoveConstructible + CopyAssignable + MoveAssignable +{ +} + +impl Copyable for T {} + pub trait MoveConstructibleUnsafe { /// # Safety /// `src` must point to a live value. @@ -50,6 +58,18 @@ pub trait MoveAssignableUnsafe { unsafe fn move_assign(&mut self, src: *mut Self) -> *mut Self; } +// std::copyable, without swappable. +pub trait CopyableUnsafe: + CopyConstructibleUnsafe + MoveConstructibleUnsafe + CopyAssignableUnsafe + MoveAssignableUnsafe +{ +} + +impl< + T: CopyConstructibleUnsafe + MoveConstructibleUnsafe + CopyAssignableUnsafe + MoveAssignableUnsafe, +> CopyableUnsafe for T +{ +} + macro_rules! impl_copy_by_clone { ($(<$($param:ident),*> $ty:ty),* $(,)?) => {$( impl<$($param),*> $crate::CopyConstructible for $ty diff --git a/libcc2rs/src/lib.rs b/libcc2rs/src/lib.rs index 0658962159..e86fdd58ec 100644 --- a/libcc2rs/src/lib.rs +++ b/libcc2rs/src/lib.rs @@ -46,8 +46,9 @@ pub use capture::{Destructible, DestructibleUnsafe}; mod constructor; pub use constructor::{ - CopyAssignable, CopyAssignableUnsafe, CopyConstructible, CopyConstructibleUnsafe, - MoveAssignable, MoveAssignableUnsafe, MoveConstructible, MoveConstructibleUnsafe, + CopyAssignable, CopyAssignableUnsafe, CopyConstructible, CopyConstructibleUnsafe, Copyable, + CopyableUnsafe, MoveAssignable, MoveAssignableUnsafe, MoveConstructible, + MoveConstructibleUnsafe, }; mod cmp; @@ -111,7 +112,8 @@ pub use format::*; pub use libcc2rs_macros::{ ByteRepr, CopyAssignable, CopyAssignableUnsafe, CopyConstructible, CopyConstructibleUnsafe, - CppFrom, CppFromUnsafe, Destructible, DestructibleUnsafe, FnPtrArg, MoveAssignable, - MoveAssignableUnsafe, MoveConstructible, MoveConstructibleUnsafe, Record, VaArg, - ZeroInitialization, ZeroInitializationUnsafe, goto, goto_block, lambda, lambda_unsafe, switch, + Copyable, CopyableUnsafe, CppFrom, CppFromUnsafe, Destructible, DestructibleUnsafe, FnPtrArg, + MoveAssignable, MoveAssignableUnsafe, MoveConstructible, MoveConstructibleUnsafe, Record, + VaArg, ZeroInitialization, ZeroInitializationUnsafe, goto, goto_block, lambda, lambda_unsafe, + switch, }; diff --git a/rules/dirent/shim.rs b/rules/dirent/shim.rs index 93e35b8e28..4d028d63d1 100644 --- a/rules/dirent/shim.rs +++ b/rules/dirent/shim.rs @@ -1,23 +1,11 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use crate::{ - ByteRepr, CopyAssignable, CopyConstructible, MoveAssignable, MoveConstructible, Record, - ZeroInitialization, size_of_field, -}; +use crate::{ByteRepr, Copyable, Record, ZeroInitialization, size_of_field}; use std::cell::Cell; use std::mem::{offset_of, size_of}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, Copyable)] #[byte_size(size_of::<::libc::dirent>())] pub struct Dirent { #[offset(offset_of!(::libc::dirent, d_ino))] @@ -98,6 +86,4 @@ impl ByteRepr for CDir {} impl ByteRepr for ::libc::dirent {} -crate::constructor::impl_trivial_copy_move!( - ::libc::dirent, -); +crate::constructor::impl_trivial_copy_move!(::libc::dirent,); diff --git a/rules/ifaddrs/shim.rs b/rules/ifaddrs/shim.rs index 3b55023af1..5d687f470a 100644 --- a/rules/ifaddrs/shim.rs +++ b/rules/ifaddrs/shim.rs @@ -2,22 +2,12 @@ // Distributed under the MIT license that can be found in the LICENSE file. use crate::{ - ByteRepr, CopyAssignable, CopyConstructible, MoveAssignable, MoveConstructible, Ptr, Record, - Sockaddr, SockaddrIn, SockaddrIn6, SockaddrStorage, ZeroInitialization, + ByteRepr, Copyable, Ptr, Record, Sockaddr, SockaddrIn, SockaddrIn6, SockaddrStorage, + ZeroInitialization, }; use std::mem::{offset_of, size_of}; -#[derive( - Clone, - Default, - Record, - ByteRepr, - ZeroInitialization, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, Copyable)] #[byte_size(size_of::<::libc::ifaddrs>())] pub struct Ifaddrs { #[offset(offset_of!(::libc::ifaddrs, ifa_next))] @@ -68,6 +58,4 @@ impl Ifaddrs { impl ByteRepr for ::libc::ifaddrs {} -crate::constructor::impl_trivial_copy_move!( - ::libc::ifaddrs, -); +crate::constructor::impl_trivial_copy_move!(::libc::ifaddrs,); diff --git a/rules/ip/shim.rs b/rules/ip/shim.rs index f25f7d8c01..79f247441c 100644 --- a/rules/ip/shim.rs +++ b/rules/ip/shim.rs @@ -1,38 +1,16 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use crate::{ - ByteRepr, CopyAssignable, CopyConstructible, MoveAssignable, MoveConstructible, Ptr, Record, - ZeroInitialization, -}; +use crate::{ByteRepr, Copyable, Ptr, Record, ZeroInitialization}; -#[derive( - Clone, - Default, - Record, - ByteRepr, - ZeroInitialization, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, Copyable)] #[byte_size(4)] pub struct InAddr { #[offset(0)] pub s_addr: u32, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, Copyable)] #[byte_size(16)] pub struct In6Addr { #[offset(0)] @@ -58,7 +36,4 @@ impl Default for In6Addr { impl ByteRepr for ::libc::in_addr {} impl ByteRepr for ::libc::in6_addr {} -crate::constructor::impl_trivial_copy_move!( - ::libc::in_addr, - ::libc::in6_addr, -); +crate::constructor::impl_trivial_copy_move!(::libc::in_addr, ::libc::in6_addr,); diff --git a/rules/netdb/shim.rs b/rules/netdb/shim.rs index 164d13f75a..a8fea2c040 100644 --- a/rules/netdb/shim.rs +++ b/rules/netdb/shim.rs @@ -1,23 +1,10 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use crate::{ - ByteRepr, CopyAssignable, CopyConstructible, MoveAssignable, MoveConstructible, Ptr, Record, - Sockaddr, ZeroInitialization, -}; +use crate::{ByteRepr, Copyable, Ptr, Record, Sockaddr, ZeroInitialization}; use std::mem::{offset_of, size_of}; -#[derive( - Clone, - Default, - Record, - ByteRepr, - ZeroInitialization, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, Copyable)] #[byte_size(size_of::<::libc::addrinfo>())] pub struct Addrinfo { #[offset(offset_of!(::libc::addrinfo, ai_flags))] @@ -40,6 +27,4 @@ pub struct Addrinfo { impl ByteRepr for ::libc::addrinfo {} -crate::constructor::impl_trivial_copy_move!( - ::libc::addrinfo, -); +crate::constructor::impl_trivial_copy_move!(::libc::addrinfo,); diff --git a/rules/poll/shim.rs b/rules/poll/shim.rs index 27e8d0e12d..f48bb17add 100644 --- a/rules/poll/shim.rs +++ b/rules/poll/shim.rs @@ -1,23 +1,10 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use crate::{ - ByteRepr, CopyAssignable, CopyConstructible, MoveAssignable, MoveConstructible, Record, - ZeroInitialization, -}; +use crate::{ByteRepr, Copyable, Record, ZeroInitialization}; use std::mem::{offset_of, size_of}; -#[derive( - Clone, - Default, - Record, - ByteRepr, - ZeroInitialization, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, Copyable)] #[byte_size(size_of::<::libc::pollfd>())] pub struct Pollfd { #[offset(offset_of!(::libc::pollfd, fd))] @@ -30,6 +17,4 @@ pub struct Pollfd { impl ByteRepr for ::libc::pollfd {} -crate::constructor::impl_trivial_copy_move!( - ::libc::pollfd, -); +crate::constructor::impl_trivial_copy_move!(::libc::pollfd,); diff --git a/rules/pwd/shim.rs b/rules/pwd/shim.rs index db190c9fa8..27577246d9 100644 --- a/rules/pwd/shim.rs +++ b/rules/pwd/shim.rs @@ -1,23 +1,10 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use crate::{ - ByteRepr, CopyAssignable, CopyConstructible, MoveAssignable, MoveConstructible, Ptr, Record, - ZeroInitialization, -}; +use crate::{ByteRepr, Copyable, Ptr, Record, ZeroInitialization}; use std::mem::{offset_of, size_of}; -#[derive( - Clone, - Default, - Record, - ByteRepr, - ZeroInitialization, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, Copyable)] #[byte_size(size_of::<::libc::passwd>())] pub struct Passwd { #[offset(offset_of!(::libc::passwd, pw_name))] @@ -65,6 +52,4 @@ impl Passwd { impl ByteRepr for ::libc::passwd {} -crate::constructor::impl_trivial_copy_move!( - ::libc::passwd, -); +crate::constructor::impl_trivial_copy_move!(::libc::passwd,); diff --git a/rules/select/shim.rs b/rules/select/shim.rs index f43e2f387b..de31634b63 100644 --- a/rules/select/shim.rs +++ b/rules/select/shim.rs @@ -3,9 +3,9 @@ use std::collections::BTreeSet; -use crate::{CopyAssignable, CopyConstructible, MoveAssignable, MoveConstructible}; +use crate::Copyable; -#[derive(Clone, Default, CopyConstructible, MoveConstructible, CopyAssignable, MoveAssignable)] +#[derive(Clone, Default, Copyable)] pub struct CFdSet { fds: BTreeSet, } diff --git a/rules/socket/shim.rs b/rules/socket/shim.rs index dc9fc3318f..f8e2c21a91 100644 --- a/rules/socket/shim.rs +++ b/rules/socket/shim.rs @@ -1,22 +1,10 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use crate::{ - ByteRepr, CChar, CopyAssignable, CopyConstructible, In6Addr, InAddr, MoveAssignable, - MoveConstructible, Ptr, Record, ZeroInitialization, -}; +use crate::{ByteRepr, CChar, Copyable, In6Addr, InAddr, Ptr, Record, ZeroInitialization}; // The fields are at the offsets of the byte representation below. -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, Copyable)] #[byte_size(16)] pub struct Sockaddr { #[offset(0)] @@ -27,16 +15,7 @@ pub struct Sockaddr { pub sa_data: Box<[i8]>, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, Copyable)] #[byte_size(16)] pub struct SockaddrIn { #[offset(0)] @@ -51,17 +30,7 @@ pub struct SockaddrIn { pub sin_zero: Box<[u8]>, } -#[derive( - Clone, - Default, - Record, - ByteRepr, - ZeroInitialization, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, Copyable)] #[byte_size(28)] pub struct SockaddrIn6 { #[offset(0)] @@ -76,16 +45,7 @@ pub struct SockaddrIn6 { pub sin6_scope_id: u32, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, Copyable)] #[byte_size(110)] pub struct SockaddrUn { #[offset(0)] @@ -96,16 +56,7 @@ pub struct SockaddrUn { pub sun_path: Box<[i8]>, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, Copyable)] #[byte_size(128)] pub struct SockaddrStorage { #[offset(0)] diff --git a/rules/stat/shim.rs b/rules/stat/shim.rs index 679dd536f0..93cedc72e4 100644 --- a/rules/stat/shim.rs +++ b/rules/stat/shim.rs @@ -1,22 +1,10 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use crate::{ - ByteRepr, CopyAssignable, CopyConstructible, MoveAssignable, MoveConstructible, Record, - ZeroInitialization, -}; +use crate::{ByteRepr, Copyable, Record, ZeroInitialization}; use std::mem::{offset_of, size_of}; -#[derive( - Clone, - Default, - Record, - ZeroInitialization, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Default, Record, ZeroInitialization, Copyable)] // The fields have the sizes of those of libc::stat only in x86-64 Linux. #[cfg_attr( all(target_os = "linux", target_arch = "x86_64"), @@ -82,6 +70,4 @@ impl ByteRepr for Stat { impl ByteRepr for ::libc::stat {} -crate::constructor::impl_trivial_copy_move!( - ::libc::stat, -); +crate::constructor::impl_trivial_copy_move!(::libc::stat,); diff --git a/rules/termios/shim.rs b/rules/termios/shim.rs index 68cabc43ee..1ae3b751f8 100644 --- a/rules/termios/shim.rs +++ b/rules/termios/shim.rs @@ -1,22 +1,10 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use crate::{ - ByteRepr, CopyAssignable, CopyConstructible, MoveAssignable, MoveConstructible, Record, - ZeroInitialization, -}; +use crate::{ByteRepr, Copyable, Record, ZeroInitialization}; use std::mem::{offset_of, size_of}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, Copyable)] #[byte_size(size_of::<::libc::termios>())] pub struct Termios { #[offset(offset_of!(::libc::termios, c_iflag))] @@ -117,17 +105,7 @@ impl Termios { } } -#[derive( - Clone, - Default, - Record, - ByteRepr, - ZeroInitialization, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, Copyable)] #[byte_size(size_of::<::libc::winsize>())] pub struct Winsize { #[offset(offset_of!(::libc::winsize, ws_row))] diff --git a/rules/time/shim.rs b/rules/time/shim.rs index c4944884db..be2a7004f5 100644 --- a/rules/time/shim.rs +++ b/rules/time/shim.rs @@ -1,23 +1,10 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use crate::{ - ByteRepr, CopyAssignable, CopyConstructible, MoveAssignable, MoveConstructible, Ptr, Record, - ZeroInitialization, -}; +use crate::{ByteRepr, Copyable, Ptr, Record, ZeroInitialization}; use std::mem::{offset_of, size_of}; -#[derive( - Clone, - Default, - Record, - ByteRepr, - ZeroInitialization, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, Copyable)] #[byte_size(size_of::<::libc::tm>())] pub struct Tm { #[offset(offset_of!(::libc::tm, tm_sec))] @@ -78,17 +65,7 @@ impl Tm { } } -#[derive( - Clone, - Default, - Record, - ByteRepr, - ZeroInitialization, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, Copyable)] #[byte_size(size_of::<::libc::timeval>())] pub struct Timeval { #[offset(offset_of!(::libc::timeval, tv_sec))] @@ -97,17 +74,7 @@ pub struct Timeval { pub tv_usec: i64, } -#[derive( - Clone, - Default, - Record, - ByteRepr, - ZeroInitialization, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, Copyable)] #[byte_size(size_of::<::libc::timespec>())] pub struct Timespec { #[offset(offset_of!(::libc::timespec, tv_sec))] @@ -120,8 +87,4 @@ impl ByteRepr for ::libc::tm {} impl ByteRepr for ::libc::timeval {} impl ByteRepr for ::libc::timespec {} -crate::constructor::impl_trivial_copy_move!( - ::libc::tm, - ::libc::timeval, - ::libc::timespec, -); +crate::constructor::impl_trivial_copy_move!(::libc::tm, ::libc::timeval, ::libc::timespec,); diff --git a/tests/multi-file/cross_tu_tag_collision/out/refcount/cross_tu_tag_collision.rs b/tests/multi-file/cross_tu_tag_collision/out/refcount/cross_tu_tag_collision.rs index 44a32a76af..9f220ef70d 100644 --- a/tests/multi-file/cross_tu_tag_collision/out/refcount/cross_tu_tag_collision.rs +++ b/tests/multi-file/cross_tu_tag_collision/out/refcount/cross_tu_tag_collision.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct widget { #[offset(0)] diff --git a/tests/multi-file/cross_tu_tag_collision/out/unsafe/cross_tu_tag_collision.rs b/tests/multi-file/cross_tu_tag_collision/out/unsafe/cross_tu_tag_collision.rs index 52297a0ce2..21f1c830fb 100644 --- a/tests/multi-file/cross_tu_tag_collision/out/unsafe/cross_tu_tag_collision.rs +++ b/tests/multi-file/cross_tu_tag_collision/out/unsafe/cross_tu_tag_collision.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct widget { pub id: i32, } diff --git a/tests/multi-file/friend_operator/out/refcount/friend_operator.rs b/tests/multi-file/friend_operator/out/refcount/friend_operator.rs index 403923cdb6..4a3a726bf4 100644 --- a/tests/multi-file/friend_operator/out/refcount/friend_operator.rs +++ b/tests/multi-file/friend_operator/out/refcount/friend_operator.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct S { #[offset(0)] diff --git a/tests/multi-file/friend_operator/out/unsafe/friend_operator.rs b/tests/multi-file/friend_operator/out/unsafe/friend_operator.rs index b9d917bf1a..efead5d19f 100644 --- a/tests/multi-file/friend_operator/out/unsafe/friend_operator.rs +++ b/tests/multi-file/friend_operator/out/unsafe/friend_operator.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub a: i32, pub b: i32, diff --git a/tests/multi-file/opaque_forward_decl/out/refcount/opaque_forward_decl.rs b/tests/multi-file/opaque_forward_decl/out/refcount/opaque_forward_decl.rs index c444c98785..d9ef3a6a15 100644 --- a/tests/multi-file/opaque_forward_decl/out/refcount/opaque_forward_decl.rs +++ b/tests/multi-file/opaque_forward_decl/out/refcount/opaque_forward_decl.rs @@ -6,19 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct container { #[offset(0)] diff --git a/tests/multi-file/opaque_forward_decl/out/unsafe/opaque_forward_decl.rs b/tests/multi-file/opaque_forward_decl/out/unsafe/opaque_forward_decl.rs index de9b592708..f35c10253b 100644 --- a/tests/multi-file/opaque_forward_decl/out/unsafe/opaque_forward_decl.rs +++ b/tests/multi-file/opaque_forward_decl/out/unsafe/opaque_forward_decl.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct container { pub p: *mut opaque, pub x: i32, diff --git a/tests/multi-file/out_of_line_methods_cross_tu/out/refcount/out_of_line_methods_cross_tu.rs b/tests/multi-file/out_of_line_methods_cross_tu/out/refcount/out_of_line_methods_cross_tu.rs index 8ad001b459..30e932a145 100644 --- a/tests/multi-file/out_of_line_methods_cross_tu/out/refcount/out_of_line_methods_cross_tu.rs +++ b/tests/multi-file/out_of_line_methods_cross_tu/out/refcount/out_of_line_methods_cross_tu.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct S { #[offset(0)] @@ -28,39 +15,13 @@ pub struct S { pub trait Base { fn apply(&mut self, x: i32) -> i32; } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct Derived { #[offset(8)] pub factor: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Pair { #[offset(0)] diff --git a/tests/multi-file/out_of_line_methods_cross_tu/out/unsafe/out_of_line_methods_cross_tu.rs b/tests/multi-file/out_of_line_methods_cross_tu/out/unsafe/out_of_line_methods_cross_tu.rs index f3437d0e86..c961f6a2aa 100644 --- a/tests/multi-file/out_of_line_methods_cross_tu/out/unsafe/out_of_line_methods_cross_tu.rs +++ b/tests/multi-file/out_of_line_methods_cross_tu/out/unsafe/out_of_line_methods_cross_tu.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub v: i32, } @@ -31,35 +20,13 @@ pub unsafe trait Base { unsafe fn apply(&mut self, x: i32) -> i32; } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Derived { pub factor: i32, } impl Derived {} #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Pair { pub first: i32, pub second: i32, diff --git a/tests/multi-file/template_method_late_instantiation/out/refcount/template_method_late_instantiation.rs b/tests/multi-file/template_method_late_instantiation/out/refcount/template_method_late_instantiation.rs index 126d1c1281..d65154a999 100644 --- a/tests/multi-file/template_method_late_instantiation/out/refcount/template_method_late_instantiation.rs +++ b/tests/multi-file/template_method_late_instantiation/out/refcount/template_method_late_instantiation.rs @@ -6,19 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(4)] pub struct S_int_ { #[offset(0)] diff --git a/tests/multi-file/template_method_late_instantiation/out/unsafe/template_method_late_instantiation.rs b/tests/multi-file/template_method_late_instantiation/out/unsafe/template_method_late_instantiation.rs index dc6ab55110..bbd20e2f44 100644 --- a/tests/multi-file/template_method_late_instantiation/out/unsafe/template_method_late_instantiation.rs +++ b/tests/multi-file/template_method_late_instantiation/out/unsafe/template_method_late_instantiation.rs @@ -7,17 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct S_int_ { pub x: i32, } diff --git a/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/refcount/p14-class-in-two-files.rs b/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/refcount/p14-class-in-two-files.rs index 9a1d1866ae..d635b41804 100644 --- a/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/refcount/p14-class-in-two-files.rs +++ b/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/refcount/p14-class-in-two-files.rs @@ -88,18 +88,7 @@ impl Default for LifetimeTracked { } } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - Destructible, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, )] #[byte_size(4)] pub struct AssertsDtorCountAtExit { @@ -128,20 +117,7 @@ thread_local!( __static }; ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct HasInlineMembers {} impl HasInlineMembers { diff --git a/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/unsafe/p14-class-in-two-files.rs b/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/unsafe/p14-class-in-two-files.rs index b44e71819a..c18fa079b7 100644 --- a/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/unsafe/p14-class-in-two-files.rs +++ b/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/unsafe/p14-class-in-two-files.rs @@ -81,16 +81,7 @@ impl Default for LifetimeTracked { } #[repr(C)] #[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, )] pub struct AssertsDtorCountAtExit { pub expected: i32, @@ -129,18 +120,7 @@ pub static mut shared_5: std::cell::LazyCell = } }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct HasInlineMembers {} impl HasInlineMembers { pub unsafe fn instance() -> *mut LifetimeTracked { diff --git a/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/refcount/p15-class-template-static-member.rs b/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/refcount/p15-class-template-static-member.rs index 76437976ad..91adfc3d29 100644 --- a/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/refcount/p15-class-template-static-member.rs +++ b/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/refcount/p15-class-template-static-member.rs @@ -100,20 +100,7 @@ thread_local!( __static }; ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct HasStaticMember_int_ {} thread_local!( @@ -129,20 +116,7 @@ thread_local!( __static }; ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct HasStaticMember_long_ {} pub fn main() { diff --git a/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/unsafe/p15-class-template-static-member.rs b/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/unsafe/p15-class-template-static-member.rs index bba4804456..4f186b611c 100644 --- a/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/unsafe/p15-class-template-static-member.rs +++ b/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/unsafe/p15-class-template-static-member.rs @@ -96,18 +96,7 @@ pub static mut member_4: std::cell::LazyCell = } }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct HasStaticMember_int_ {} pub static mut member_5: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { @@ -126,18 +115,7 @@ pub static mut member_5: std::cell::LazyCell = } }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct HasStaticMember_long_ {} pub fn main() { unsafe { diff --git a/tests/std/basic/basic.def.odr/p15-function-template/out/refcount/p15-function-template.rs b/tests/std/basic/basic.def.odr/p15-function-template/out/refcount/p15-function-template.rs index 14ec4cccb5..e3a1c2cb55 100644 --- a/tests/std/basic/basic.def.odr/p15-function-template/out/refcount/p15-function-template.rs +++ b/tests/std/basic/basic.def.odr/p15-function-template/out/refcount/p15-function-template.rs @@ -88,18 +88,7 @@ impl Default for LifetimeTracked { } } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - Destructible, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, )] #[byte_size(4)] pub struct AssertsDtorCountAtExit { @@ -190,20 +179,7 @@ fn main_0() -> i32 { assert!((ctorCount_0.with(|rc| *rc.borrow()) == 4)); return 0; } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct S_14 {} pub fn count_18() -> i32 { @@ -234,20 +210,7 @@ pub fn b_count_long_17() -> i32 { pub fn b_count_local_15() -> i32 { return ({ count_18() }); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct S_21 {} pub trait AssertsDtorCountAtExitImpl { diff --git a/tests/std/basic/basic.def.odr/p15-function-template/out/unsafe/p15-function-template.rs b/tests/std/basic/basic.def.odr/p15-function-template/out/unsafe/p15-function-template.rs index 014b802f9e..02f5ab322c 100644 --- a/tests/std/basic/basic.def.odr/p15-function-template/out/unsafe/p15-function-template.rs +++ b/tests/std/basic/basic.def.odr/p15-function-template/out/unsafe/p15-function-template.rs @@ -81,16 +81,7 @@ impl Default for LifetimeTracked { } #[repr(C)] #[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, )] pub struct AssertsDtorCountAtExit { pub expected: i32, @@ -190,18 +181,7 @@ unsafe fn main_0() -> i32 { return 0; } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S_14 {} pub unsafe fn count_18() -> i32 { return (*(*std::cell::LazyCell::force_mut(&mut *&raw mut n_20)).prefix_inc()); @@ -232,18 +212,7 @@ pub unsafe fn b_count_local_15() -> i32 { return (unsafe { count_18() }); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S_21 {} pub unsafe fn __cpp2rust_init_globals() { std::cell::LazyCell::force(&*&raw const ctorCount_0); diff --git a/tests/std/basic/basic.def.odr/p15-inline-function/out/refcount/p15-inline-function.rs b/tests/std/basic/basic.def.odr/p15-inline-function/out/refcount/p15-inline-function.rs index 6eb3b7b1f9..5ff70ca6cf 100644 --- a/tests/std/basic/basic.def.odr/p15-inline-function/out/refcount/p15-inline-function.rs +++ b/tests/std/basic/basic.def.odr/p15-inline-function/out/refcount/p15-inline-function.rs @@ -88,18 +88,7 @@ impl Default for LifetimeTracked { } } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - Destructible, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, )] #[byte_size(4)] pub struct AssertsDtorCountAtExit { diff --git a/tests/std/basic/basic.def.odr/p15-inline-function/out/unsafe/p15-inline-function.rs b/tests/std/basic/basic.def.odr/p15-inline-function/out/unsafe/p15-inline-function.rs index dbcae21ff0..75e079fc7e 100644 --- a/tests/std/basic/basic.def.odr/p15-inline-function/out/unsafe/p15-inline-function.rs +++ b/tests/std/basic/basic.def.odr/p15-inline-function/out/unsafe/p15-inline-function.rs @@ -81,16 +81,7 @@ impl Default for LifetimeTracked { } #[repr(C)] #[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, )] pub struct AssertsDtorCountAtExit { pub expected: i32, diff --git a/tests/std/basic/basic.def.odr/p15-inline-variable/out/refcount/p15-inline-variable.rs b/tests/std/basic/basic.def.odr/p15-inline-variable/out/refcount/p15-inline-variable.rs index 5e033f6bfc..5109c0cba1 100644 --- a/tests/std/basic/basic.def.odr/p15-inline-variable/out/refcount/p15-inline-variable.rs +++ b/tests/std/basic/basic.def.odr/p15-inline-variable/out/refcount/p15-inline-variable.rs @@ -88,18 +88,7 @@ impl Default for LifetimeTracked { } } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - Destructible, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, )] #[byte_size(4)] pub struct AssertsDtorCountAtExit { diff --git a/tests/std/basic/basic.def.odr/p15-inline-variable/out/unsafe/p15-inline-variable.rs b/tests/std/basic/basic.def.odr/p15-inline-variable/out/unsafe/p15-inline-variable.rs index 1113e95331..131c993dfb 100644 --- a/tests/std/basic/basic.def.odr/p15-inline-variable/out/unsafe/p15-inline-variable.rs +++ b/tests/std/basic/basic.def.odr/p15-inline-variable/out/unsafe/p15-inline-variable.rs @@ -81,16 +81,7 @@ impl Default for LifetimeTracked { } #[repr(C)] #[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, )] pub struct AssertsDtorCountAtExit { pub expected: i32, diff --git a/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/refcount/p16-default-argument-lambda-in-class.rs b/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/refcount/p16-default-argument-lambda-in-class.rs index 0ee1b641ca..8792a2984b 100644 --- a/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/refcount/p16-default-argument-lambda-in-class.rs +++ b/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/refcount/p16-default-argument-lambda-in-class.rs @@ -88,38 +88,14 @@ impl Default for LifetimeTracked { } } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - Destructible, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, )] #[byte_size(4)] pub struct AssertsDtorCountAtExit { #[offset(0)] pub expected: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct X {} thread_local!( diff --git a/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/unsafe/p16-default-argument-lambda-in-class.rs b/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/unsafe/p16-default-argument-lambda-in-class.rs index 14cc3fcf13..f950e9629f 100644 --- a/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/unsafe/p16-default-argument-lambda-in-class.rs +++ b/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/unsafe/p16-default-argument-lambda-in-class.rs @@ -81,16 +81,7 @@ impl Default for LifetimeTracked { } #[repr(C)] #[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, )] pub struct AssertsDtorCountAtExit { pub expected: i32, @@ -101,18 +92,7 @@ impl AssertsDtorCountAtExit { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct X {} impl X { pub unsafe fn h(&mut self, mut cond: bool, mut p: Option) { diff --git a/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/refcount/p16-lambda-in-inline-function.rs b/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/refcount/p16-lambda-in-inline-function.rs index cb608757dd..c08331cec2 100644 --- a/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/refcount/p16-lambda-in-inline-function.rs +++ b/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/refcount/p16-lambda-in-inline-function.rs @@ -88,18 +88,7 @@ impl Default for LifetimeTracked { } } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - Destructible, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, )] #[byte_size(4)] pub struct AssertsDtorCountAtExit { diff --git a/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/unsafe/p16-lambda-in-inline-function.rs b/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/unsafe/p16-lambda-in-inline-function.rs index bf64a509d5..3fbb41d125 100644 --- a/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/unsafe/p16-lambda-in-inline-function.rs +++ b/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/unsafe/p16-lambda-in-inline-function.rs @@ -81,16 +81,7 @@ impl Default for LifetimeTracked { } #[repr(C)] #[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, )] pub struct AssertsDtorCountAtExit { pub expected: i32, diff --git a/tests/std/basic/basic.link/out/refcount/basic.link.rs b/tests/std/basic/basic.link/out/refcount/basic.link.rs index 5f95a00a73..7a2a6eb8a7 100644 --- a/tests/std/basic/basic.link/out/refcount/basic.link.rs +++ b/tests/std/basic/basic.link/out/refcount/basic.link.rs @@ -29,17 +29,7 @@ pub fn test_11() { assert!((ceiling_10.with(|rc| *rc.borrow()) == 40)); assert!(((ceiling_10.with(|v| v.as_pointer())) == ({ ceiling_address_in_b_12() }))); } -#[derive( - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - ByteRepr, - Clone, - ZeroInitialization, -)] +#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(4)] pub struct anon_13 { #[offset(0)] @@ -77,19 +67,7 @@ thread_local!( pub fn bump_18() -> i32 { return (*(*counter_17.with(Value::clone).borrow_mut()).prefix_inc()); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(4)] pub struct Record_19 { #[offset(0)] @@ -125,20 +103,7 @@ pub fn test_29() { level_28.with(|rc| *rc.borrow_mut() = 10); assert!((({ raise_30(1,) }) == 11)); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct Tally_31 {} thread_local!( @@ -150,20 +115,7 @@ pub fn test_33() { assert!((({ add_in_b_34(1,) }) == 102)); assert!((total_32.with(|rc| *rc.borrow()) == 11)); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct p5_members_of_class_with_external_linkage_Ledger {} pub fn test_36() { @@ -231,19 +183,7 @@ pub fn test_55() { assert!((({ second_key_plus_value_53() }) == 32)); assert!((({ key_in_b_56() }) == 400)); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(4)] pub struct Entry_52 { #[offset(0)] @@ -254,19 +194,7 @@ impl Default for Entry_52 { { Entry_52 { key: 1 } } } } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(8)] pub struct Entry_54 { #[offset(0)] @@ -338,17 +266,7 @@ thread_local!( pub fn ceiling_address_in_b_12() -> Ptr { return (ceiling_10.with(|v| v.as_pointer())); } -#[derive( - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - ByteRepr, - Clone, - ZeroInitialization, -)] +#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(4)] pub struct anon_62 { #[offset(0)] @@ -386,19 +304,7 @@ thread_local!( pub fn bump_64() -> i32 { return (*(*counter_63.with(Value::clone).borrow_mut()).prefix_inc()); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(16)] pub struct Record_65 { #[offset(0)] @@ -442,20 +348,7 @@ pub fn raise_30(mut by: i32) -> i32 { level_28.with(|rc| *rc.borrow_mut() += by); return level_28.with(|rc| *rc.borrow()); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct Tally_67 {} thread_local!( @@ -497,19 +390,7 @@ pub fn key_in_b_56() -> i32 { let mut entry: Entry_71 = ::default(); return (entry.key as i32); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(8)] pub struct Entry_71 { #[offset(0)] diff --git a/tests/std/basic/basic.link/out/unsafe/basic.link.rs b/tests/std/basic/basic.link/out/unsafe/basic.link.rs index f5200515a8..e1cf93455f 100644 --- a/tests/std/basic/basic.link/out/unsafe/basic.link.rs +++ b/tests/std/basic/basic.link/out/unsafe/basic.link.rs @@ -37,17 +37,7 @@ pub unsafe fn test_11() { ); } #[repr(C)] -#[derive( - Copy, - Clone, - FnPtrArg, - VaArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub union anon_13 { pub whole: i32, pub fraction: f32, @@ -70,17 +60,7 @@ pub unsafe fn bump_18() -> i32 { return (*(*std::cell::LazyCell::force_mut(&mut *&raw mut counter_17)).prefix_inc()); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct Record_19 { pub id: i32, } @@ -113,18 +93,7 @@ pub unsafe fn test_29() { assert!(((unsafe { raise_30(1,) }) == (11))); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Tally_31 {} impl Tally_31 { pub unsafe fn add(&mut self, mut amount: i32) -> i32 { @@ -140,18 +109,7 @@ pub unsafe fn test_33() { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut total_32)) == (11))); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p5_members_of_class_with_external_linkage_Ledger {} pub unsafe fn test_36() { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut balance_35)) == (50))); @@ -213,17 +171,7 @@ pub unsafe fn test_55() { assert!(((unsafe { key_in_b_56() }) == (400))); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct Entry_52 { pub key: i32, } @@ -233,17 +181,7 @@ impl Default for Entry_52 { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct Entry_54 { pub key: i32, pub value: i32, @@ -305,17 +243,7 @@ pub unsafe fn ceiling_address_in_b_12() -> *const i32 { return (&raw const (*std::cell::LazyCell::force_mut(&mut *&raw mut ceiling_10)) as *const i32); } #[repr(C)] -#[derive( - Copy, - Clone, - FnPtrArg, - VaArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub union anon_62 { pub whole: i32, pub fraction: f32, @@ -338,17 +266,7 @@ pub unsafe fn bump_64() -> i32 { return (*(*std::cell::LazyCell::force_mut(&mut *&raw mut counter_63)).prefix_inc()); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct Record_65 { pub id: i64, pub extra: i32, @@ -385,18 +303,7 @@ pub unsafe fn raise_30(mut by: i32) -> i32 { return (*std::cell::LazyCell::force_mut(&mut *&raw mut level_28)); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Tally_67 {} impl Tally_67 { pub unsafe fn add(&mut self, mut amount: i32) -> i32 { @@ -434,17 +341,7 @@ pub unsafe fn key_in_b_56() -> i32 { return (entry.key as i32); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct Entry_71 { pub key: i64, } diff --git a/tests/std/basic/basic.scope/out/refcount/basic.scope.block.rs b/tests/std/basic/basic.scope/out/refcount/basic.scope.block.rs index 43ffb9408c..36abd03dda 100644 --- a/tests/std/basic/basic.scope/out/refcount/basic.scope.block.rs +++ b/tests/std/basic/basic.scope/out/refcount/basic.scope.block.rs @@ -97,18 +97,7 @@ thread_local!( pub static dtorCount_6: Value = Rc::new(RefCell::new(0)); ); #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - Destructible, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, )] #[byte_size(4)] pub struct p1_1_condition_variable_visible_in_else_ConvertsToBool { diff --git a/tests/std/basic/basic.scope/out/refcount/basic.scope.class.rs b/tests/std/basic/basic.scope/out/refcount/basic.scope.class.rs index 9349e7baa0..d935f2bb45 100644 --- a/tests/std/basic/basic.scope/out/refcount/basic.scope.class.rs +++ b/tests/std/basic/basic.scope/out/refcount/basic.scope.class.rs @@ -9,19 +9,7 @@ use std::rc::{Rc, Weak}; thread_local!( pub static balance_0: Value = Rc::new(RefCell::new(50)); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(4)] pub struct p1_member_hides_namespace_variable_HasBalance { #[offset(0)] @@ -57,19 +45,7 @@ pub fn test_1() { thread_local!( pub static initial_2: Value = Rc::new(RefCell::new(100)); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(4)] pub struct p1_out_of_class_definition_is_in_class_scope_HasStaticTotal { #[offset(0)] diff --git a/tests/std/basic/basic.scope/out/refcount/basic.scope.param.rs b/tests/std/basic/basic.scope/out/refcount/basic.scope.param.rs index 3e024ac3a3..ee9602fff9 100644 --- a/tests/std/basic/basic.scope/out/refcount/basic.scope.param.rs +++ b/tests/std/basic/basic.scope/out/refcount/basic.scope.param.rs @@ -7,19 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, )] #[cpp_from(i32, construct, value)] #[byte_size(4)] diff --git a/tests/std/basic/basic.scope/out/refcount/basic.scope.pdecl.rs b/tests/std/basic/basic.scope/out/refcount/basic.scope.pdecl.rs index 4d40eb4dd4..f8ed232a0a 100644 --- a/tests/std/basic/basic.scope/out/refcount/basic.scope.pdecl.rs +++ b/tests/std/basic/basic.scope/out/refcount/basic.scope.pdecl.rs @@ -18,19 +18,7 @@ pub fn test_0() { } assert!((level == 5)); } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct p1_own_address_in_initializer_SelfLinked { #[offset(0)] @@ -85,18 +73,7 @@ pub fn test_3() { pub type anon_4 = u32; pub const anon_4_limit: anon_4 = 13; pub const anon_4_above: anon_4 = 14; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(8)] pub struct p9_func_declared_before_function_body_RecordsConstructorName { #[offset(0)] diff --git a/tests/std/basic/basic.scope/out/refcount/basic.scope.scope.rs b/tests/std/basic/basic.scope/out/refcount/basic.scope.scope.rs index cd35351468..1e1bb61730 100644 --- a/tests/std/basic/basic.scope/out/refcount/basic.scope.scope.rs +++ b/tests/std/basic/basic.scope/out/refcount/basic.scope.scope.rs @@ -44,20 +44,7 @@ pub const p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum_Size_small: p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum_Size = 3; pub const p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum_Size_large: p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum_Size = 8; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum {} pub fn test_5() { @@ -85,20 +72,7 @@ pub fn test_5() { thread_local!( pub static count_6: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct p2_12_class_name_in_own_scope_HasStaticCounter {} impl p2_12_class_name_in_own_scope_HasStaticCounter { @@ -114,17 +88,7 @@ pub fn test_7() { count_6.with(|rc| *rc.borrow_mut() = 6); assert!((count_6.with(|rc| *rc.borrow()) == 6)); } -#[derive( - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - ByteRepr, - Clone, - ZeroInitialization, -)] +#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(8)] pub struct anon_8 { #[offset(0)] @@ -150,17 +114,7 @@ impl Default for anon_8 { thread_local!( pub static anon_8: Value = Rc::new(RefCell::new(::default())); ); -#[derive( - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - ByteRepr, - Clone, - ZeroInitialization, -)] +#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(8)] pub struct anon_9 { #[offset(0)] @@ -183,19 +137,7 @@ impl Default for anon_9 { } } } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct p2_13_anonymous_union_members_in_parent_scope_HasAnonymousUnion { #[offset(0)] @@ -231,17 +173,7 @@ pub fn test_10() { anon_11::block_ratio(anon_11.as_pointer()).write(0.75_f64); assert!(((anon_11::block_ratio(anon_11.as_pointer()).read()) == 0.75_f64)); } -#[derive( - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - ByteRepr, - Clone, - ZeroInitialization, -)] +#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(8)] pub struct anon_11 { #[offset(0)] @@ -264,19 +196,7 @@ impl Default for anon_11 { } } } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(8)] pub struct p3_2_const_qualified_member_is_distinct_HasConstOverload { #[offset(0)] @@ -320,19 +240,7 @@ thread_local!( thread_local!( pub static rvalue_calls_14: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(4)] pub struct p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload { #[offset(0)] @@ -374,20 +282,7 @@ thread_local!( thread_local!( pub static rvalue_calls_17: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct p3_2_ref_qualified_members_are_distinct_HasRefQualifiedOverloads {} pub fn test_18() { @@ -425,19 +320,7 @@ pub fn test_18() { assert!((lvalue_calls_16.with(|rc| *rc.borrow()) == 1)); assert!((rvalue_calls_17.with(|rc| *rc.borrow()) == 2)); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(8)] pub struct p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload { #[offset(0)] @@ -484,20 +367,7 @@ thread_local!( thread_local!( pub static rvalue_calls_21: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct p3_4_ref_qualified_member_templates_are_distinct_HasRefQualifiedTemplateOverloads {} pub fn test_22() { @@ -527,40 +397,14 @@ pub fn test_22() { thread_local!( pub static friend_calls_23: Value = Rc::new(RefCell::new(0_i32)); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct p4_friend_definition_defines_earlier_friend_declaration_DeclaresFriend {} pub fn shared_friend_24() -> i32 { (*friend_calls_23.with(Value::clone).borrow_mut()).prefix_inc(); return 7; } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct p4_friend_definition_defines_earlier_friend_declaration_DefinesFriend {} pub fn test_25() { @@ -592,20 +436,7 @@ pub fn test_30() { thread_local!( pub static function_calls_31: Value = Rc::new(RefCell::new(0_i32)); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct p4_2_class_and_function_share_name_Reading { #[offset(0)] @@ -623,20 +454,7 @@ pub fn test_33() { assert!((({ Reading_32(reading.value,) }) == 5)); assert!((function_calls_31.with(|rc| *rc.borrow()) == 1)); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct p4_2_class_and_variable_share_name_Limit { #[offset(0)] diff --git a/tests/std/basic/basic.scope/out/unsafe/basic.scope.block.rs b/tests/std/basic/basic.scope/out/unsafe/basic.scope.block.rs index 54cde79104..0a7c19133a 100644 --- a/tests/std/basic/basic.scope/out/unsafe/basic.scope.block.rs +++ b/tests/std/basic/basic.scope/out/unsafe/basic.scope.block.rs @@ -86,16 +86,7 @@ pub static mut else_runs_5: std::cell::LazyCell = pub static mut dtorCount_6: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] #[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, )] pub struct p1_1_condition_variable_visible_in_else_ConvertsToBool { pub value: i32, diff --git a/tests/std/basic/basic.scope/out/unsafe/basic.scope.class.rs b/tests/std/basic/basic.scope/out/unsafe/basic.scope.class.rs index 134f0a879d..0817e8c856 100644 --- a/tests/std/basic/basic.scope/out/unsafe/basic.scope.class.rs +++ b/tests/std/basic/basic.scope/out/unsafe/basic.scope.class.rs @@ -8,17 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub static mut balance_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 50 }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct p1_member_hides_namespace_variable_HasBalance { pub balance: i32, } @@ -56,17 +46,7 @@ pub unsafe fn test_1() { } pub static mut initial_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 100 }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct p1_out_of_class_definition_is_in_class_scope_HasStaticTotal { pub held: i32, } diff --git a/tests/std/basic/basic.scope/out/unsafe/basic.scope.param.rs b/tests/std/basic/basic.scope/out/unsafe/basic.scope.param.rs index f60a1d70a2..a604ce0621 100644 --- a/tests/std/basic/basic.scope/out/unsafe/basic.scope.param.rs +++ b/tests/std/basic/basic.scope/out/unsafe/basic.scope.param.rs @@ -8,17 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, )] #[cpp_from(i32, construct, value)] pub struct p1_1_parameter_hides_member_in_constructor_HasMemberNamedLikeParameter { diff --git a/tests/std/basic/basic.scope/out/unsafe/basic.scope.pdecl.rs b/tests/std/basic/basic.scope/out/unsafe/basic.scope.pdecl.rs index 7f1678c14f..4896ad24fa 100644 --- a/tests/std/basic/basic.scope/out/unsafe/basic.scope.pdecl.rs +++ b/tests/std/basic/basic.scope/out/unsafe/basic.scope.pdecl.rs @@ -19,18 +19,7 @@ pub unsafe fn test_0() { assert!(((level) == (5))); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p1_own_address_in_initializer_SelfLinked { pub next: *mut p1_own_address_in_initializer_SelfLinked, pub value: i32, @@ -83,17 +72,7 @@ pub type anon_4 = u32; pub const anon_4_limit: anon_4 = 13; pub const anon_4_above: anon_4 = 14; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct p9_func_declared_before_function_body_RecordsConstructorName { pub name: *const libc::c_char, } diff --git a/tests/std/basic/basic.scope/out/unsafe/basic.scope.scope.rs b/tests/std/basic/basic.scope/out/unsafe/basic.scope.scope.rs index 9fe830f984..ae5fdc3d18 100644 --- a/tests/std/basic/basic.scope/out/unsafe/basic.scope.scope.rs +++ b/tests/std/basic/basic.scope/out/unsafe/basic.scope.scope.rs @@ -42,18 +42,7 @@ pub const p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum_Size_small: pub const p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum_Size_large: p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum_Size = 8; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum {} impl p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum { pub unsafe fn scale(&self, mut count: i32) -> i32 { @@ -80,18 +69,7 @@ pub unsafe fn test_5() { } pub static mut count_6: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p2_12_class_name_in_own_scope_HasStaticCounter {} impl p2_12_class_name_in_own_scope_HasStaticCounter { pub unsafe fn bump() { @@ -107,17 +85,7 @@ pub unsafe fn test_7() { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut count_6)) == (6))); } #[repr(C)] -#[derive( - Copy, - Clone, - FnPtrArg, - VaArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub union anon_8 { pub namespace_count: i32, pub namespace_ratio: f64, @@ -130,17 +98,7 @@ impl Default for anon_8 { pub static mut anon_8: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { ::default() }); #[repr(C)] -#[derive( - Copy, - Clone, - FnPtrArg, - VaArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub union anon_9 { pub member_count: i32, pub member_ratio: f64, @@ -151,18 +109,7 @@ impl Default for anon_9 { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p2_13_anonymous_union_members_in_parent_scope_HasAnonymousUnion { pub tag: i32, pub anon_9: anon_9, @@ -199,17 +146,7 @@ pub unsafe fn test_10() { assert!(((anon_11.block_ratio) == (0.75_f64))); } #[repr(C)] -#[derive( - Copy, - Clone, - FnPtrArg, - VaArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub union anon_11 { pub block_count: i32, pub block_ratio: f64, @@ -220,17 +157,7 @@ impl Default for anon_11 { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct p3_2_const_qualified_member_is_distinct_HasConstOverload { pub plain_calls: i32, pub const_calls: i32, @@ -278,17 +205,7 @@ pub static mut explicit_calls_13: std::cell::LazyCell = pub static mut rvalue_calls_14: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload { pub base: i32, } @@ -340,18 +257,7 @@ pub static mut lvalue_calls_16: std::cell::LazyCell = pub static mut rvalue_calls_17: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p3_2_ref_qualified_members_are_distinct_HasRefQualifiedOverloads {} impl p3_2_ref_qualified_members_are_distinct_HasRefQualifiedOverloads { pub unsafe fn get_1(&mut self) -> i32 { @@ -391,17 +297,7 @@ pub unsafe fn test_18() { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut rvalue_calls_17)) == (2))); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload { pub plain_calls: i32, pub const_calls: i32, @@ -457,18 +353,7 @@ pub static mut lvalue_calls_20: std::cell::LazyCell = pub static mut rvalue_calls_21: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p3_4_ref_qualified_member_templates_are_distinct_HasRefQualifiedTemplateOverloads {} impl p3_4_ref_qualified_member_templates_are_distinct_HasRefQualifiedTemplateOverloads { pub unsafe fn get_1_int(&mut self, mut value: i32) -> i32 { @@ -507,36 +392,14 @@ pub unsafe fn test_22() { pub static mut friend_calls_23: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0_i32 }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p4_friend_definition_defines_earlier_friend_declaration_DeclaresFriend {} pub unsafe fn shared_friend_24() -> i32 { (*std::cell::LazyCell::force_mut(&mut *&raw mut friend_calls_23)).prefix_inc(); return 7; } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p4_friend_definition_defines_earlier_friend_declaration_DefinesFriend {} pub unsafe fn test_25() { assert!(((unsafe { shared_friend_24() }) == (7))); @@ -565,18 +428,7 @@ pub unsafe fn test_30() { pub static mut function_calls_31: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0_i32 }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p4_2_class_and_function_share_name_Reading { pub value: i32, } @@ -593,18 +445,7 @@ pub unsafe fn test_33() { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut function_calls_31)) == (1))); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p4_2_class_and_variable_share_name_Limit { pub value: i32, } diff --git a/tests/std/basic/basic.start/out/refcount/basic.start.term-p1-exit.rs b/tests/std/basic/basic.start/out/refcount/basic.start.term-p1-exit.rs index 4961e3e839..01cb6f518d 100644 --- a/tests/std/basic/basic.start/out/refcount/basic.start.term-p1-exit.rs +++ b/tests/std/basic/basic.start/out/refcount/basic.start.term-p1-exit.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - Destructible, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, )] #[byte_size(4)] pub struct Tracker { diff --git a/tests/std/basic/basic.start/out/refcount/basic.start.term.rs b/tests/std/basic/basic.start/out/refcount/basic.start.term.rs index f32b391eb6..1b43ddf073 100644 --- a/tests/std/basic/basic.start/out/refcount/basic.start.term.rs +++ b/tests/std/basic/basic.start/out/refcount/basic.start.term.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - Destructible, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, )] #[byte_size(4)] pub struct Tracker { @@ -26,18 +15,7 @@ pub struct Tracker { pub tag: i32, } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - Destructible, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, )] #[byte_size(4)] pub struct HoldsTracker { @@ -45,20 +23,7 @@ pub struct HoldsTracker { #[byte_size(4)] pub member: Tracker, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct TriviallyDestructible { #[offset(0)] @@ -146,20 +111,7 @@ thread_local!( pub static trivial_9: Value = Rc::new(RefCell::new(TriviallyDestructible { value: 6 })); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct p3_reverse_completion_order_WithStaticMember {} thread_local!( diff --git a/tests/std/basic/basic.start/out/unsafe/basic.start.term-p1-exit.rs b/tests/std/basic/basic.start/out/unsafe/basic.start.term-p1-exit.rs index 7f3a3b533c..6de1b46967 100644 --- a/tests/std/basic/basic.start/out/unsafe/basic.start.term-p1-exit.rs +++ b/tests/std/basic/basic.start/out/unsafe/basic.start.term-p1-exit.rs @@ -8,16 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, )] pub struct Tracker { pub tag: i32, diff --git a/tests/std/basic/basic.start/out/unsafe/basic.start.term.rs b/tests/std/basic/basic.start/out/unsafe/basic.start.term.rs index decfa1dee2..fe201bbee7 100644 --- a/tests/std/basic/basic.start/out/unsafe/basic.start.term.rs +++ b/tests/std/basic/basic.start/out/unsafe/basic.start.term.rs @@ -8,16 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, )] pub struct Tracker { pub tag: i32, @@ -36,16 +27,7 @@ impl Tracker { } #[repr(C)] #[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, )] pub struct HoldsTracker { pub member: Tracker, @@ -56,18 +38,7 @@ impl HoldsTracker { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct TriviallyDestructible { pub value: i32, } @@ -165,18 +136,7 @@ pub static mut holder_8: std::cell::LazyCell = std::cell::LazyCell pub static mut trivial_9: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { TriviallyDestructible { value: 6 } }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p3_reverse_completion_order_WithStaticMember {} pub static mut member_10: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { { diff --git a/tests/std/basic/basic.types/out/refcount/basic.types.general.rs b/tests/std/basic/basic.types/out/refcount/basic.types.general.rs index 30c46c525c..fcb58faacc 100644 --- a/tests/std/basic/basic.types/out/refcount/basic.types.general.rs +++ b/tests/std/basic/basic.types/out/refcount/basic.types.general.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct p2_pointer_to_data_member_bytes_round_trip_HasTwoInts { #[offset(0)] @@ -82,20 +69,7 @@ pub fn test_0() { }; assert!(({ ((*null_pm.borrow()) == -1_isize) })); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct p3_pointer_to_data_member_bytes_copied_to_other_object_HasTwoInts { #[offset(0)] diff --git a/tests/std/basic/basic.types/out/unsafe/basic.types.general.rs b/tests/std/basic/basic.types/out/unsafe/basic.types.general.rs index a8ce54ab14..e07c4f58a9 100644 --- a/tests/std/basic/basic.types/out/unsafe/basic.types.general.rs +++ b/tests/std/basic/basic.types/out/unsafe/basic.types.general.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p2_pointer_to_data_member_bytes_round_trip_HasTwoInts { pub first: i32, pub second: i32, @@ -87,18 +76,7 @@ pub unsafe fn test_0() { assert!(((null_pm) == -1_isize)); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p3_pointer_to_data_member_bytes_copied_to_other_object_HasTwoInts { pub first: i32, pub second: i32, diff --git a/tests/std/basic/out/refcount/basic.def.odr.rs b/tests/std/basic/out/refcount/basic.def.odr.rs index cad3cca8cc..8f4be2f93d 100644 --- a/tests/std/basic/out/refcount/basic.def.odr.rs +++ b/tests/std/basic/out/refcount/basic.def.odr.rs @@ -276,20 +276,7 @@ thread_local!( pub trait p4_1_pure_virtual_without_definition_HasPureVirtual { fn f(&mut self); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct p4_1_pure_virtual_without_definition_OverridesPureVirtual {} pub fn test_11() { @@ -686,19 +673,7 @@ pub fn test_26() { thread_local!( pub static t_ctors_27: Value = Rc::new(RefCell::new(0_i32)); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(1)] pub struct p9_destructor_not_potentially_invoked_HasUndefinedDestructor {} impl Default for p9_destructor_not_potentially_invoked_HasUndefinedDestructor { @@ -770,19 +745,7 @@ pub fn test_31() { thread_local!( pub static m_ctors_32: Value = Rc::new(RefCell::new(0_i32)); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(1)] pub struct p9_unused_implicit_assignment_HasUndefinedCopyAssignment {} impl Default for p9_unused_implicit_assignment_HasUndefinedCopyAssignment { @@ -801,20 +764,7 @@ impl Default for p9_unused_implicit_assignment_HasUndefinedCopyAssignment { } } } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct p9_unused_implicit_assignment_HasMemberWithUndefinedCopyAssignment { #[offset(0)] diff --git a/tests/std/basic/out/unsafe/basic.def.odr.rs b/tests/std/basic/out/unsafe/basic.def.odr.rs index 0344dd5e7d..4c5c5e576e 100644 --- a/tests/std/basic/out/unsafe/basic.def.odr.rs +++ b/tests/std/basic/out/unsafe/basic.def.odr.rs @@ -247,18 +247,7 @@ pub unsafe trait p4_1_pure_virtual_without_definition_HasPureVirtual { unsafe fn f(&mut self); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p4_1_pure_virtual_without_definition_OverridesPureVirtual {} pub unsafe fn test_11() { let mut d: p4_1_pure_virtual_without_definition_OverridesPureVirtual = @@ -677,17 +666,7 @@ pub unsafe fn test_26() { } pub static mut t_ctors_27: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0_i32 }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct p9_destructor_not_potentially_invoked_HasUndefinedDestructor {} impl p9_destructor_not_potentially_invoked_HasUndefinedDestructor { pub unsafe fn construct(&mut self) { @@ -757,17 +736,7 @@ pub unsafe fn test_31() { } pub static mut m_ctors_32: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0_i32 }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct p9_unused_implicit_assignment_HasUndefinedCopyAssignment {} impl p9_unused_implicit_assignment_HasUndefinedCopyAssignment { pub unsafe fn construct(&mut self) { @@ -787,18 +756,7 @@ impl Default for p9_unused_implicit_assignment_HasUndefinedCopyAssignment { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p9_unused_implicit_assignment_HasMemberWithUndefinedCopyAssignment { pub m: p9_unused_implicit_assignment_HasUndefinedCopyAssignment, } diff --git a/tests/std/class/class.init/out/refcount/class.base.init.rs b/tests/std/class/class.init/out/refcount/class.base.init.rs index 31137b9550..b187800cb2 100644 --- a/tests/std/class/class.init/out/refcount/class.base.init.rs +++ b/tests/std/class/class.init/out/refcount/class.base.init.rs @@ -7,19 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, )] #[cpp_from(i32, construct, value)] #[byte_size(8)] diff --git a/tests/std/class/class.init/out/unsafe/class.base.init.rs b/tests/std/class/class.init/out/unsafe/class.base.init.rs index 85351a4133..4929dcb8a8 100644 --- a/tests/std/class/class.init/out/unsafe/class.base.init.rs +++ b/tests/std/class/class.init/out/unsafe/class.base.init.rs @@ -8,17 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, )] #[cpp_from(i32, construct, value)] pub struct p13_3_member_reads_earlier_member_Pair { diff --git a/tests/std/class/class.mem/class.conv/out/refcount/class.conv.ctor.rs b/tests/std/class/class.mem/class.conv/out/refcount/class.conv.ctor.rs index d585c2809e..ae1a474f86 100644 --- a/tests/std/class/class.mem/class.conv/out/refcount/class.conv.ctor.rs +++ b/tests/std/class/class.mem/class.conv/out/refcount/class.conv.ctor.rs @@ -7,19 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, )] #[cpp_from(i32, construct_2, value)] #[byte_size(4)] diff --git a/tests/std/class/class.mem/class.conv/out/refcount/class.conv.fct.rs b/tests/std/class/class.mem/class.conv/out/refcount/class.conv.fct.rs index 85728f61d5..70ea5595a8 100644 --- a/tests/std/class/class.mem/class.conv/out/refcount/class.conv.fct.rs +++ b/tests/std/class/class.mem/class.conv/out/refcount/class.conv.fct.rs @@ -7,19 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, )] #[cpp_into(i64, to_i64, mut_ptr)] #[byte_size(8)] diff --git a/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.ctor.rs b/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.ctor.rs index a482cea564..5d05bfa9d7 100644 --- a/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.ctor.rs +++ b/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.ctor.rs @@ -13,17 +13,7 @@ impl p1_template_constructor_from_own_type_Probe { } #[repr(C)] #[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, )] #[cpp_from(i32, construct_2, value)] pub struct p1_template_constructor_from_own_type_Probe { diff --git a/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.fct.rs b/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.fct.rs index 1b6b3dfc1c..55c1c91a29 100644 --- a/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.fct.rs +++ b/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.fct.rs @@ -8,17 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, )] #[cpp_into(i64, to_i64, mut_ptr)] pub struct p2_non_const_conversion_function_Gauge { diff --git a/tests/std/class/class.mem/out/refcount/class.free.rs b/tests/std/class/class.mem/out/refcount/class.free.rs index ec32b03c8f..bf08ba06f5 100644 --- a/tests/std/class/class.mem/out/refcount/class.free.rs +++ b/tests/std/class/class.mem/out/refcount/class.free.rs @@ -9,20 +9,7 @@ use std::rc::{Rc, Weak}; thread_local!( pub static allocations_0: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct p1_allocation_function_is_static_Allocates {} impl p1_allocation_function_is_static_Allocates { @@ -59,20 +46,7 @@ pub fn test_1() { thread_local!( pub static deallocations_2: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct p3_deallocation_function_is_static_Deallocates {} impl p3_deallocation_function_is_static_Deallocates { diff --git a/tests/std/class/class.mem/out/refcount/class.mem.general.rs b/tests/std/class/class.mem/out/refcount/class.mem.general.rs index 263fb84b66..ca7835a283 100644 --- a/tests/std/class/class.mem/out/refcount/class.mem.general.rs +++ b/tests/std/class/class.mem/out/refcount/class.mem.general.rs @@ -14,19 +14,7 @@ pub fn minimum_1() -> i32 { } pub type anon_2 = u32; pub const anon_2_reserve: anon_2 = 30; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(4)] pub struct p7_1_function_body_names_later_member_HasLaterMembers { #[offset(0)] @@ -55,19 +43,7 @@ thread_local!( thread_local!( pub static step_5: Value = Rc::new(RefCell::new(4)); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(4)] pub struct p7_2_default_argument_names_later_member_HasLaterStaticStep { #[offset(0)] diff --git a/tests/std/class/class.mem/out/unsafe/class.free.rs b/tests/std/class/class.mem/out/unsafe/class.free.rs index a13cc8e10f..fcde99ecea 100644 --- a/tests/std/class/class.mem/out/unsafe/class.free.rs +++ b/tests/std/class/class.mem/out/unsafe/class.free.rs @@ -8,18 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub static mut allocations_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p1_allocation_function_is_static_Allocates {} impl p1_allocation_function_is_static_Allocates { pub unsafe fn operator_new(mut size: usize) -> *mut ::libc::c_void { @@ -53,18 +42,7 @@ pub unsafe fn test_1() { pub static mut deallocations_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p3_deallocation_function_is_static_Deallocates {} impl p3_deallocation_function_is_static_Deallocates { pub unsafe fn operator_delete(mut ptr: *mut ::libc::c_void) { diff --git a/tests/std/class/class.mem/out/unsafe/class.mem.general.rs b/tests/std/class/class.mem/out/unsafe/class.mem.general.rs index 1a5cd1af5d..df4dbfc5a9 100644 --- a/tests/std/class/class.mem/out/unsafe/class.mem.general.rs +++ b/tests/std/class/class.mem/out/unsafe/class.mem.general.rs @@ -13,17 +13,7 @@ pub unsafe fn minimum_1() -> i32 { pub type anon_2 = u32; pub const anon_2_reserve: anon_2 = 30; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct p7_1_function_body_names_later_member_HasLaterMembers { pub stock: i32, } @@ -56,17 +46,7 @@ pub unsafe fn test_3() { pub static mut step_4: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 100 }); pub static mut step_5: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 4 }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct p7_2_default_argument_names_later_member_HasLaterStaticStep { pub total: i32, } diff --git a/tests/std/dcl.dcl/dcl.decl/dcl.init/out/refcount/dcl.init.general-p6.2-padding-bits.rs b/tests/std/dcl.dcl/dcl.decl/dcl.init/out/refcount/dcl.init.general-p6.2-padding-bits.rs index 80bb7920a3..073853a966 100644 --- a/tests/std/dcl.dcl/dcl.decl/dcl.init/out/refcount/dcl.init.general-p6.2-padding-bits.rs +++ b/tests/std/dcl.dcl/dcl.decl/dcl.init/out/refcount/dcl.init.general-p6.2-padding-bits.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct p6_2_zero_initialized_padding_Padded { #[offset(0)] @@ -27,20 +14,7 @@ pub struct p6_2_zero_initialized_padding_Padded { #[offset(4)] pub number: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct p6_2_zero_initialized_padding_TailPadded { #[offset(0)] @@ -48,20 +22,7 @@ pub struct p6_2_zero_initialized_padding_TailPadded { #[offset(4)] pub letter: i8, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct p6_2_zero_initialized_padding_HoldsPadded { #[offset(0)] diff --git a/tests/std/dcl.dcl/dcl.decl/dcl.init/out/refcount/dcl.init.general.rs b/tests/std/dcl.dcl/dcl.decl/dcl.init/out/refcount/dcl.init.general.rs index a796920386..8421d91e0f 100644 --- a/tests/std/dcl.dcl/dcl.decl/dcl.init/out/refcount/dcl.init.general.rs +++ b/tests/std/dcl.dcl/dcl.decl/dcl.init/out/refcount/dcl.init.general.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct p6_1_zero_initialized_pointer_to_member_HasTwoInts { #[offset(0)] @@ -27,19 +14,7 @@ pub struct p6_1_zero_initialized_pointer_to_member_HasTwoInts { #[offset(4)] pub second: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(8)] pub struct p6_1_zero_initialized_pointer_to_member_HoldsSelector { #[offset(0)] @@ -136,19 +111,7 @@ pub fn test_12() { thread_local!( static counter_11: Value = Rc::new(RefCell::new(0_i32)); ); -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(24)] pub struct p6_2_zero_initialized_class_Inner { #[offset(0)] @@ -159,18 +122,7 @@ pub struct p6_2_zero_initialized_class_Inner { #[byte_size(8)] pub pointer: Ptr, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(96)] pub struct p6_2_zero_initialized_class_Outer { #[offset(0)] @@ -241,17 +193,7 @@ pub fn test_15() { ({ check_14((heap_outer).clone()) }); heap_outer.delete(); } -#[derive( - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - ByteRepr, - Clone, - ZeroInitialization, -)] +#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(8)] pub struct p6_3_zero_initialized_union_Number { #[offset(0)] @@ -288,20 +230,7 @@ pub fn test_17() { Rc::new(RefCell::new(::default())); assert!(((p6_3_zero_initialized_union_Number::integer(value_number.as_pointer()).read()) == 0)); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct p6_4_zero_initialized_array_Pair { #[offset(0)] @@ -405,19 +334,7 @@ pub fn test_21() { } heap_numbers.delete(); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(8)] pub struct p9_1_2_zero_then_default_initialized_WithDefaultMember { #[offset(0)] @@ -435,19 +352,7 @@ impl Default for p9_1_2_zero_then_default_initialized_WithDefaultMember { } } } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(4)] pub struct p9_1_2_zero_then_default_initialized_LeavesMemberAlone { #[offset(0)] @@ -469,20 +374,7 @@ impl Default for p9_1_2_zero_then_default_initialized_LeavesMemberAlone { } } } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAlone { #[offset(0)] diff --git a/tests/std/dcl.dcl/dcl.decl/dcl.init/out/unsafe/dcl.init.general-p6.2-padding-bits.rs b/tests/std/dcl.dcl/dcl.decl/dcl.init/out/unsafe/dcl.init.general-p6.2-padding-bits.rs index da228c7854..a6a85380b8 100644 --- a/tests/std/dcl.dcl/dcl.decl/dcl.init/out/unsafe/dcl.init.general-p6.2-padding-bits.rs +++ b/tests/std/dcl.dcl/dcl.decl/dcl.init/out/unsafe/dcl.init.general-p6.2-padding-bits.rs @@ -7,52 +7,19 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p6_2_zero_initialized_padding_Padded { pub letter: libc::c_char, pub number: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p6_2_zero_initialized_padding_TailPadded { pub number: i32, pub letter: libc::c_char, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p6_2_zero_initialized_padding_HoldsPadded { pub letter: libc::c_char, pub inner: p6_2_zero_initialized_padding_Padded, diff --git a/tests/std/dcl.dcl/dcl.decl/dcl.init/out/unsafe/dcl.init.general.rs b/tests/std/dcl.dcl/dcl.decl/dcl.init/out/unsafe/dcl.init.general.rs index 620fc43354..fcf1ba56e1 100644 --- a/tests/std/dcl.dcl/dcl.decl/dcl.init/out/unsafe/dcl.init.general.rs +++ b/tests/std/dcl.dcl/dcl.decl/dcl.init/out/unsafe/dcl.init.general.rs @@ -7,34 +7,13 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p6_1_zero_initialized_pointer_to_member_HasTwoInts { pub first: i32, pub second: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct p6_1_zero_initialized_pointer_to_member_HoldsSelector { pub selector: isize, } @@ -128,36 +107,14 @@ pub unsafe fn test_12() { } static mut counter_11: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0_i32 }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p6_2_zero_initialized_class_Inner { pub number: i32, pub real: f64, pub pointer: *mut i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p6_2_zero_initialized_class_Outer { pub letter: libc::c_char, pub inner: p6_2_zero_initialized_class_Inner, @@ -209,17 +166,7 @@ pub unsafe fn test_15() { }; } #[repr(C)] -#[derive( - Copy, - Clone, - FnPtrArg, - VaArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub union p6_3_zero_initialized_union_Number { pub integer: i32, pub bytes: [libc::c_char; 8], @@ -238,18 +185,7 @@ pub unsafe fn test_17() { assert!(((value_number.integer) == (0))); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p6_4_zero_initialized_array_Pair { pub first: i32, pub second: i32, @@ -339,17 +275,7 @@ pub unsafe fn test_21() { }; } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct p9_1_2_zero_then_default_initialized_WithDefaultMember { pub zeroed: i32, pub five: i32, @@ -365,17 +291,7 @@ impl Default for p9_1_2_zero_then_default_initialized_WithDefaultMember { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct p9_1_2_zero_then_default_initialized_LeavesMemberAlone { pub untouched: i32, } @@ -397,18 +313,7 @@ impl Default for p9_1_2_zero_then_default_initialized_LeavesMemberAlone { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAlone { pub number: i32, pub member: p9_1_2_zero_then_default_initialized_LeavesMemberAlone, diff --git a/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/refcount/dcl.array.rs b/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/refcount/dcl.array.rs index 6b14b9bb2a..1f60d2d998 100644 --- a/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/refcount/dcl.array.rs +++ b/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/refcount/dcl.array.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(12)] pub struct p6_array_of_pointers_to_data_members_HasThreeInts { #[offset(0)] diff --git a/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/refcount/dcl.fct.default.rs b/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/refcount/dcl.fct.default.rs index d517a6241a..23dabaad45 100644 --- a/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/refcount/dcl.fct.default.rs +++ b/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/refcount/dcl.fct.default.rs @@ -54,19 +54,7 @@ thread_local!( thread_local!( pub static step_10: Value = Rc::new(RefCell::new(4)); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(4)] pub struct p9_static_member_hides_namespace_variable_HasStaticStep { #[offset(0)] @@ -117,20 +105,7 @@ pub fn count_default_13() -> i32 { pub fn combine_14(mut first: i32, mut second: i32) -> i32 { return ((first * 100) + second); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct p9_evaluated_each_time_called_Widget { @@ -157,19 +132,7 @@ thread_local!( ); pub type anon_16 = u32; pub const anon_16_kBonus: anon_16 = 5; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(4)] pub struct p9_evaluated_each_time_called_Account { #[offset(0)] @@ -258,20 +221,7 @@ pub fn test_17() { pub fn add_18(mut a: i32, mut b: i32) -> i32 { return (a + b); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct p9_not_part_of_the_type_Scale {} impl p9_not_part_of_the_type_Scale { diff --git a/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/refcount/dcl.mptr.rs b/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/refcount/dcl.mptr.rs index 64f4df743b..15c1da0e95 100644 --- a/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/refcount/dcl.mptr.rs +++ b/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/refcount/dcl.mptr.rs @@ -6,18 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(16)] pub struct p2_pointer_to_array_member_HasIntArray { #[offset(0)] @@ -51,20 +40,7 @@ pub fn test_0() { assert!(((array_elem!(obj.as_pointer(), elements, 1).read()) == 7)); assert!(({ (*obj.borrow()).before } == 1)); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct p2_pointer_to_data_member_HasTwoInts { #[offset(0)] @@ -92,20 +68,7 @@ pub fn test_1() { thread_local!( pub static pm_2: Value = Rc::new(RefCell::new(-1_isize)); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct p2_pointer_to_member_of_incomplete_class_CompletedLater { #[offset(0)] @@ -134,20 +97,7 @@ pub fn test_3() { == 4) ); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct p2_pointer_to_member_of_pointer_to_member_type_HasTwoInts { #[offset(0)] @@ -155,19 +105,7 @@ pub struct p2_pointer_to_member_of_pointer_to_member_type_HasTwoInts { #[offset(4)] pub second: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(8)] pub struct p2_pointer_to_member_of_pointer_to_member_type_HoldsSelector { #[offset(0)] diff --git a/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/unsafe/dcl.array.rs b/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/unsafe/dcl.array.rs index 2fd0de5220..dafd53c5da 100644 --- a/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/unsafe/dcl.array.rs +++ b/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/unsafe/dcl.array.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p6_array_of_pointers_to_data_members_HasThreeInts { pub first: i32, pub second: i32, diff --git a/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/unsafe/dcl.fct.default.rs b/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/unsafe/dcl.fct.default.rs index f16b206418..8aa3fc10ac 100644 --- a/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/unsafe/dcl.fct.default.rs +++ b/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/unsafe/dcl.fct.default.rs @@ -54,17 +54,7 @@ pub unsafe fn test_8() { pub static mut step_9: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 100 }); pub static mut step_10: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 4 }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct p9_static_member_hides_namespace_variable_HasStaticStep { pub total: i32, } @@ -115,18 +105,7 @@ pub unsafe fn combine_14(mut first: i32, mut second: i32) -> i32 { return (((first) * (100)) + (second)); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe)] #[cpp_from(i32, construct, value)] pub struct p9_evaluated_each_time_called_Widget { pub id: i32, @@ -154,17 +133,7 @@ static mut base_15: std::cell::LazyCell = std::cell::LazyCell::new(|| unsaf pub type anon_16 = u32; pub const anon_16_kBonus: anon_16 = 5; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct p9_evaluated_each_time_called_Account { pub balance: i32, } @@ -258,18 +227,7 @@ pub unsafe fn add_18(mut a: i32, mut b: i32) -> i32 { return ((a) + (b)); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p9_not_part_of_the_type_Scale {} impl p9_not_part_of_the_type_Scale { pub unsafe fn times(mut a: i32, mut b: i32) -> i32 { diff --git a/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/unsafe/dcl.mptr.rs b/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/unsafe/dcl.mptr.rs index da16258bbd..78bf32a7f7 100644 --- a/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/unsafe/dcl.mptr.rs +++ b/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/unsafe/dcl.mptr.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p2_pointer_to_array_member_HasIntArray { pub before: i32, pub elements: [i32; 3], @@ -49,18 +38,7 @@ pub unsafe fn test_0() { assert!(((obj.before) == (1))); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p2_pointer_to_data_member_HasTwoInts { pub first: i32, pub second: i32, @@ -98,18 +76,7 @@ pub unsafe fn test_1() { } pub static mut pm_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { -1_isize }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p2_pointer_to_member_of_incomplete_class_CompletedLater { pub first: i32, pub second: i32, @@ -133,34 +100,13 @@ pub unsafe fn test_3() { ); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p2_pointer_to_member_of_pointer_to_member_type_HasTwoInts { pub first: i32, pub second: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct p2_pointer_to_member_of_pointer_to_member_type_HoldsSelector { pub selector: isize, } diff --git a/tests/std/expr/conv/out/refcount/conv.mem.rs b/tests/std/expr/conv/out/refcount/conv.mem.rs index 1fce0c3544..3a5df9abe2 100644 --- a/tests/std/expr/conv/out/refcount/conv.mem.rs +++ b/tests/std/expr/conv/out/refcount/conv.mem.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct p1_null_distinct_from_first_member_HasTwoInts { #[offset(0)] diff --git a/tests/std/expr/conv/out/unsafe/conv.mem.rs b/tests/std/expr/conv/out/unsafe/conv.mem.rs index 6c8e75919f..675732b6f3 100644 --- a/tests/std/expr/conv/out/unsafe/conv.mem.rs +++ b/tests/std/expr/conv/out/unsafe/conv.mem.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p1_null_distinct_from_first_member_HasTwoInts { pub first: i32, pub second: i32, diff --git a/tests/std/expr/expr.compound/expr.post/out/refcount/expr.const.cast.rs b/tests/std/expr/expr.compound/expr.post/out/refcount/expr.const.cast.rs index ecfe5db627..68bab18c4e 100644 --- a/tests/std/expr/expr.compound/expr.post/out/refcount/expr.const.cast.rs +++ b/tests/std/expr/expr.compound/expr.post/out/refcount/expr.const.cast.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct p4_reference_const_cast_Pair { #[offset(0)] diff --git a/tests/std/expr/expr.compound/expr.post/out/refcount/expr.reinterpret.cast-p10-result-is-unspecified.rs b/tests/std/expr/expr.compound/expr.post/out/refcount/expr.reinterpret.cast-p10-result-is-unspecified.rs index f7c402c117..199dcabddb 100644 --- a/tests/std/expr/expr.compound/expr.post/out/refcount/expr.reinterpret.cast-p10-result-is-unspecified.rs +++ b/tests/std/expr/expr.compound/expr.post/out/refcount/expr.reinterpret.cast-p10-result-is-unspecified.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct HasTwoInts { #[offset(0)] @@ -27,20 +14,7 @@ pub struct HasTwoInts { #[offset(4)] pub second: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct AlsoHasTwoInts { #[offset(0)] diff --git a/tests/std/expr/expr.compound/expr.post/out/refcount/expr.reinterpret.cast.rs b/tests/std/expr/expr.compound/expr.post/out/refcount/expr.reinterpret.cast.rs index 3fa1510435..9834be37ee 100644 --- a/tests/std/expr/expr.compound/expr.post/out/refcount/expr.reinterpret.cast.rs +++ b/tests/std/expr/expr.compound/expr.post/out/refcount/expr.reinterpret.cast.rs @@ -16,20 +16,7 @@ pub fn test_0() { (*value.borrow_mut()) = 7; assert!((((converted.read()).read()) == 7)); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct p10_null_converts_to_null_HasTwoInts { #[offset(0)] @@ -37,20 +24,7 @@ pub struct p10_null_converts_to_null_HasTwoInts { #[offset(4)] pub second: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct p10_null_converts_to_null_HasChar { #[offset(0)] @@ -61,20 +35,7 @@ pub fn test_1() { let mut converted: isize = pm; assert!(((converted) == -1_isize)); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct p10_2_data_member_round_trip_HasTwoInts { #[offset(0)] @@ -82,20 +43,7 @@ pub struct p10_2_data_member_round_trip_HasTwoInts { #[offset(4)] pub second: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct p10_2_data_member_round_trip_HasChar { #[offset(0)] diff --git a/tests/std/expr/expr.compound/expr.post/out/unsafe/expr.const.cast.rs b/tests/std/expr/expr.compound/expr.post/out/unsafe/expr.const.cast.rs index c98da93adf..6d39cbb0c3 100644 --- a/tests/std/expr/expr.compound/expr.post/out/unsafe/expr.const.cast.rs +++ b/tests/std/expr/expr.compound/expr.post/out/unsafe/expr.const.cast.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p4_reference_const_cast_Pair { pub x: i32, } diff --git a/tests/std/expr/expr.compound/expr.post/out/unsafe/expr.reinterpret.cast-p10-result-is-unspecified.rs b/tests/std/expr/expr.compound/expr.post/out/unsafe/expr.reinterpret.cast-p10-result-is-unspecified.rs index e3c6978429..5eb7bdf714 100644 --- a/tests/std/expr/expr.compound/expr.post/out/unsafe/expr.reinterpret.cast-p10-result-is-unspecified.rs +++ b/tests/std/expr/expr.compound/expr.post/out/unsafe/expr.reinterpret.cast-p10-result-is-unspecified.rs @@ -7,35 +7,13 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct HasTwoInts { pub first: i32, pub second: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct AlsoHasTwoInts { pub first: i32, pub second: i32, diff --git a/tests/std/expr/expr.compound/expr.post/out/unsafe/expr.reinterpret.cast.rs b/tests/std/expr/expr.compound/expr.post/out/unsafe/expr.reinterpret.cast.rs index fee1aef260..77b5d79023 100644 --- a/tests/std/expr/expr.compound/expr.post/out/unsafe/expr.reinterpret.cast.rs +++ b/tests/std/expr/expr.compound/expr.post/out/unsafe/expr.reinterpret.cast.rs @@ -17,35 +17,13 @@ pub unsafe fn test_0() { assert!(((*(*converted)) == (7))); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p10_null_converts_to_null_HasTwoInts { pub first: i32, pub second: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p10_null_converts_to_null_HasChar { pub character: libc::c_char, } @@ -55,35 +33,13 @@ pub unsafe fn test_1() { assert!(((converted) == -1_isize)); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p10_2_data_member_round_trip_HasTwoInts { pub first: i32, pub second: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p10_2_data_member_round_trip_HasChar { pub character: libc::c_char, } diff --git a/tests/std/expr/expr.compound/expr.unary/out/refcount/expr.pre.incr.rs b/tests/std/expr/expr.compound/expr.unary/out/refcount/expr.pre.incr.rs index f3f438bd99..43d4cdf940 100644 --- a/tests/std/expr/expr.compound/expr.unary/out/refcount/expr.pre.incr.rs +++ b/tests/std/expr/expr.compound/expr.unary/out/refcount/expr.pre.incr.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct p1_result_is_updated_operand_Counter { #[offset(0)] diff --git a/tests/std/expr/expr.compound/expr.unary/out/refcount/expr.unary.op.rs b/tests/std/expr/expr.compound/expr.unary/out/refcount/expr.unary.op.rs index fe7284c3f2..8277652549 100644 --- a/tests/std/expr/expr.compound/expr.unary/out/refcount/expr.unary.op.rs +++ b/tests/std/expr/expr.compound/expr.unary/out/refcount/expr.unary.op.rs @@ -12,20 +12,7 @@ thread_local!( thread_local!( pub static calls_1: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct p3_2_static_member_is_ordinary_pointer_HasStaticMembers {} impl p3_2_static_member_is_ordinary_pointer_HasStaticMembers { @@ -43,20 +30,7 @@ pub fn test_2() { ({ function_pointer.call() }); assert!((calls_1.with(|rc| *rc.borrow()) == 1)); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct p3_2_explicit_object_member_is_ordinary_pointer_HasExplicitObjectMember { #[offset(0)] @@ -72,20 +46,7 @@ pub fn test_3() { (*object.borrow_mut()).base = 5; assert!((({ function_pointer.call(object.as_pointer(), 1,) }) == 6)); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct p4_parenthesized_qualified_id_is_object_pointer_TakesAddressOfOwnMember { #[offset(0)] diff --git a/tests/std/expr/expr.compound/expr.unary/out/unsafe/expr.pre.incr.rs b/tests/std/expr/expr.compound/expr.unary/out/unsafe/expr.pre.incr.rs index d2db15e6f6..c8520e28d3 100644 --- a/tests/std/expr/expr.compound/expr.unary/out/unsafe/expr.pre.incr.rs +++ b/tests/std/expr/expr.compound/expr.unary/out/unsafe/expr.pre.incr.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p1_result_is_updated_operand_Counter { pub n: i32, } diff --git a/tests/std/expr/expr.compound/expr.unary/out/unsafe/expr.unary.op.rs b/tests/std/expr/expr.compound/expr.unary/out/unsafe/expr.unary.op.rs index e66b0bf9f2..977d637a64 100644 --- a/tests/std/expr/expr.compound/expr.unary/out/unsafe/expr.unary.op.rs +++ b/tests/std/expr/expr.compound/expr.unary/out/unsafe/expr.unary.op.rs @@ -9,18 +9,7 @@ use std::rc::Rc; pub static mut shared_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 3 }); pub static mut calls_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p3_2_static_member_is_ordinary_pointer_HasStaticMembers {} impl p3_2_static_member_is_ordinary_pointer_HasStaticMembers { pub unsafe fn run() { @@ -39,18 +28,7 @@ pub unsafe fn test_2() { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut calls_1)) == (1))); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p3_2_explicit_object_member_is_ordinary_pointer_HasExplicitObjectMember { pub base: i32, } @@ -76,18 +54,7 @@ pub unsafe fn test_3() { assert!(((unsafe { (function_pointer).unwrap()(&object, 1,) }) == (6))); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p4_parenthesized_qualified_id_is_object_pointer_TakesAddressOfOwnMember { pub value: i32, } diff --git a/tests/std/expr/expr.compound/out/refcount/expr.cond.rs b/tests/std/expr/expr.compound/out/refcount/expr.cond.rs index f581300b98..c5145264e2 100644 --- a/tests/std/expr/expr.compound/out/refcount/expr.cond.rs +++ b/tests/std/expr/expr.compound/out/refcount/expr.cond.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct p7_4_pointer_to_member_and_null_HasTwoInts { #[offset(0)] diff --git a/tests/std/expr/expr.compound/out/refcount/expr.eq.rs b/tests/std/expr/expr.compound/out/refcount/expr.eq.rs index cc3d3351fb..54e5467a3e 100644 --- a/tests/std/expr/expr.compound/out/refcount/expr.eq.rs +++ b/tests/std/expr/expr.compound/out/refcount/expr.eq.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct p4_1_both_null_HasTwoInts { #[offset(0)] @@ -33,20 +20,7 @@ pub fn test_0() { assert!((first_null == second_null)); assert!(!(first_null != second_null)); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct p4_2_one_null_HasTwoInts { #[offset(0)] @@ -62,17 +36,7 @@ pub fn test_1() { assert!((null_pm != first_pm)); assert!(!(null_pm == first_pm)); } -#[derive( - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - ByteRepr, - Clone, - ZeroInitialization, -)] +#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(4)] pub struct p4_5_members_of_same_union_HasTwoIntMembers { #[offset(0)] @@ -101,20 +65,7 @@ pub fn test_2() { assert!((first_pm == second_pm)); assert!(!(first_pm != second_pm)); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct p4_6_data_members_HasTwoInts { #[offset(0)] diff --git a/tests/std/expr/expr.compound/out/refcount/expr.mptr.oper-p6-null-pointer-to-data-member.rs b/tests/std/expr/expr.compound/out/refcount/expr.mptr.oper-p6-null-pointer-to-data-member.rs index fb13927c1c..3654cc940e 100644 --- a/tests/std/expr/expr.compound/out/refcount/expr.mptr.oper-p6-null-pointer-to-data-member.rs +++ b/tests/std/expr/expr.compound/out/refcount/expr.mptr.oper-p6-null-pointer-to-data-member.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct HasTwoInts { #[offset(0)] diff --git a/tests/std/expr/expr.compound/out/refcount/expr.mptr.oper.rs b/tests/std/expr/expr.compound/out/refcount/expr.mptr.oper.rs index d5632635c8..66d2f5d2ab 100644 --- a/tests/std/expr/expr.compound/out/refcount/expr.mptr.oper.rs +++ b/tests/std/expr/expr.compound/out/refcount/expr.mptr.oper.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct p3_arrow_star_HasTwoInts { #[offset(0)] @@ -40,20 +27,7 @@ pub fn test_0() { assert!(({ (*obj.borrow()).first } == 3)); assert!((((p).member::(pm)) == ((p).member::(pm)))); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct p4_object_expression_sequenced_first_HasValue { #[offset(0)] @@ -95,20 +69,7 @@ pub fn test_7() { assert!((object_stamp_2.with(|rc| *rc.borrow()) == 1)); assert!((member_stamp_3.with(|rc| *rc.borrow()) == 2)); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct p6_data_member_of_lvalue_is_lvalue_HasTwoInts { #[offset(0)] diff --git a/tests/std/expr/expr.compound/out/unsafe/expr.cond.rs b/tests/std/expr/expr.compound/out/unsafe/expr.cond.rs index 7315cf5fb7..a207449eed 100644 --- a/tests/std/expr/expr.compound/out/unsafe/expr.cond.rs +++ b/tests/std/expr/expr.compound/out/unsafe/expr.cond.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p7_4_pointer_to_member_and_null_HasTwoInts { pub first: i32, pub second: i32, diff --git a/tests/std/expr/expr.compound/out/unsafe/expr.eq.rs b/tests/std/expr/expr.compound/out/unsafe/expr.eq.rs index 05141bb97c..fc445d96e9 100644 --- a/tests/std/expr/expr.compound/out/unsafe/expr.eq.rs +++ b/tests/std/expr/expr.compound/out/unsafe/expr.eq.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p4_1_both_null_HasTwoInts { pub first: i32, pub second: i32, @@ -30,18 +19,7 @@ pub unsafe fn test_0() { assert!(!((first_null) != (second_null))); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p4_2_one_null_HasTwoInts { pub first: i32, pub second: i32, @@ -55,17 +33,7 @@ pub unsafe fn test_1() { assert!(!((null_pm) == (first_pm))); } #[repr(C)] -#[derive( - Copy, - Clone, - FnPtrArg, - VaArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub union p4_5_members_of_same_union_HasTwoIntMembers { pub first: i32, pub second: i32, @@ -82,18 +50,7 @@ pub unsafe fn test_2() { assert!(!((first_pm) != (second_pm))); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p4_6_data_members_HasTwoInts { pub first: i32, pub second: i32, diff --git a/tests/std/expr/expr.compound/out/unsafe/expr.mptr.oper-p6-null-pointer-to-data-member.rs b/tests/std/expr/expr.compound/out/unsafe/expr.mptr.oper-p6-null-pointer-to-data-member.rs index b17076e0df..f3aaaccb69 100644 --- a/tests/std/expr/expr.compound/out/unsafe/expr.mptr.oper-p6-null-pointer-to-data-member.rs +++ b/tests/std/expr/expr.compound/out/unsafe/expr.mptr.oper-p6-null-pointer-to-data-member.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct HasTwoInts { pub first: i32, pub second: i32, diff --git a/tests/std/expr/expr.compound/out/unsafe/expr.mptr.oper.rs b/tests/std/expr/expr.compound/out/unsafe/expr.mptr.oper.rs index d1e033c3f2..b680038629 100644 --- a/tests/std/expr/expr.compound/out/unsafe/expr.mptr.oper.rs +++ b/tests/std/expr/expr.compound/out/unsafe/expr.mptr.oper.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p3_arrow_star_HasTwoInts { pub first: i32, pub second: i32, @@ -42,18 +31,7 @@ pub unsafe fn test_0() { ); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p4_object_expression_sequenced_first_HasValue { pub value: i32, } @@ -87,18 +65,7 @@ pub unsafe fn test_7() { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut member_stamp_3)) == (2))); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p6_data_member_of_lvalue_is_lvalue_HasTwoInts { pub first: i32, pub second: i32, diff --git a/tests/std/expr/expr.prim/out/refcount/expr.prim.this.rs b/tests/std/expr/expr.prim/out/refcount/expr.prim.this.rs index f47b872527..8d61468a61 100644 --- a/tests/std/expr/expr.prim/out/refcount/expr.prim.this.rs +++ b/tests/std/expr/expr.prim/out/refcount/expr.prim.this.rs @@ -6,19 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable)] #[cpp_from(i32, construct, value)] #[byte_size(16)] pub struct p1_default_member_initializer_names_object_Holder { @@ -44,18 +32,7 @@ pub fn test_0() { assert!((holder.value == 4)); } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, )] #[cpp_from(i32, construct, value)] #[byte_size(16)] diff --git a/tests/std/expr/expr.prim/out/unsafe/expr.prim.this.rs b/tests/std/expr/expr.prim/out/unsafe/expr.prim.this.rs index 1ce5670202..6de1136fa9 100644 --- a/tests/std/expr/expr.prim/out/unsafe/expr.prim.this.rs +++ b/tests/std/expr/expr.prim/out/unsafe/expr.prim.this.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe)] #[cpp_from(i32, construct, value)] pub struct p1_default_member_initializer_names_object_Holder { pub self_: *mut p1_default_member_initializer_names_object_Holder, @@ -49,17 +38,7 @@ pub unsafe fn test_0() { } #[repr(C)] #[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, )] #[cpp_from(i32, construct, value)] pub struct p1_mem_initializer_names_object_Holder { diff --git a/tests/std/library/requirements/utility.requirements/allocator.requirements/out/refcount/allocator.requirements.general.rs b/tests/std/library/requirements/utility.requirements/allocator.requirements/out/refcount/allocator.requirements.general.rs index 74cf888083..4f55762821 100644 --- a/tests/std/library/requirements/utility.requirements/allocator.requirements/out/refcount/allocator.requirements.general.rs +++ b/tests/std/library/requirements/utility.requirements/allocator.requirements/out/refcount/allocator.requirements.general.rs @@ -6,35 +6,10 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct p16_rebind_member_Alloc_std_pair_const_int__int___rebind_std_pair_const_int__int__ {} -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(4)] pub struct p16_rebind_member_Alloc_std_pair_const_int__int__ { #[offset(0)] @@ -68,20 +43,7 @@ pub fn test_0() { ); assert!(({ ((*n.borrow()).len() == 1_usize) })); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct p18_rebind_to_container_node_Alloc_std_pair_const_int__int__ {} pub fn test_1() { diff --git a/tests/std/library/requirements/utility.requirements/allocator.requirements/out/unsafe/allocator.requirements.general.rs b/tests/std/library/requirements/utility.requirements/allocator.requirements/out/unsafe/allocator.requirements.general.rs index 23272890a2..f75b0a720d 100644 --- a/tests/std/library/requirements/utility.requirements/allocator.requirements/out/unsafe/allocator.requirements.general.rs +++ b/tests/std/library/requirements/utility.requirements/allocator.requirements/out/unsafe/allocator.requirements.general.rs @@ -7,31 +7,10 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p16_rebind_member_Alloc_std_pair_const_int__int___rebind_std_pair_const_int__int__ {} #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct p16_rebind_member_Alloc_std_pair_const_int__int__ { pub id: i32, } @@ -51,18 +30,7 @@ pub unsafe fn test_0() { assert!(((n.len()) == (1_usize))); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p18_rebind_to_container_node_Alloc_std_pair_const_int__int__ {} pub unsafe fn test_1() { let mut m: UnsafeMap = UnsafeMap::new(); diff --git a/tests/std/stmt.stmt/stmt.iter/out/refcount/stmt.while.rs b/tests/std/stmt.stmt/stmt.iter/out/refcount/stmt.while.rs index c8a43add69..1ab5178144 100644 --- a/tests/std/stmt.stmt/stmt.iter/out/refcount/stmt.while.rs +++ b/tests/std/stmt.stmt/stmt.iter/out/refcount/stmt.while.rs @@ -21,10 +21,7 @@ thread_local!( FnPtrArg, CppFrom, Destructible, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, + Copyable, Default, )] #[cpp_from(i32, construct, value)] @@ -84,10 +81,7 @@ thread_local!( FnPtrArg, CppFrom, Destructible, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, + Copyable, Default, )] #[cpp_from(i32, construct, value)] diff --git a/tests/std/stmt.stmt/stmt.iter/out/unsafe/stmt.while.rs b/tests/std/stmt.stmt/stmt.iter/out/unsafe/stmt.while.rs index 2512419e85..b04d834948 100644 --- a/tests/std/stmt.stmt/stmt.iter/out/unsafe/stmt.while.rs +++ b/tests/std/stmt.stmt/stmt.iter/out/unsafe/stmt.while.rs @@ -16,10 +16,7 @@ pub static mut dtorCount_1: std::cell::LazyCell = std::cell::LazyCell::new( ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, + CopyableUnsafe, Default, )] #[cpp_from(i32, construct, value)] @@ -80,10 +77,7 @@ pub static mut dtorCount_4: std::cell::LazyCell = std::cell::LazyCell::new( ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, + CopyableUnsafe, Default, )] #[cpp_from(i32, construct, value)] diff --git a/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs b/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs index 3253db599e..28564c4d23 100644 --- a/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs +++ b/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs @@ -105,10 +105,7 @@ thread_local!( FnPtrArg, CppFrom, Destructible, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, + Copyable, Default, )] #[cpp_into(i32, to_i32)] diff --git a/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs b/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs index ca5209b401..c26c7f6dbe 100644 --- a/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs +++ b/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs @@ -92,10 +92,7 @@ pub static mut dtorCount_6: std::cell::LazyCell = std::cell::LazyCell::new( ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, + CopyableUnsafe, Default, )] #[cpp_into(i32, to_i32)] diff --git a/tests/std/temp/out/refcount/temp.type.rs b/tests/std/temp/out/refcount/temp.type.rs index 8ec5f0cb3c..fafd43ca48 100644 --- a/tests/std/temp/out/refcount/temp.type.rs +++ b/tests/std/temp/out/refcount/temp.type.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct p2_6_pointer_to_member_argument_HasTwoInts { #[offset(0)] @@ -30,60 +17,21 @@ pub struct p2_6_pointer_to_member_argument_HasTwoInts { thread_local!( pub static count_0: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct p2_6_pointer_to_member_argument_CountsPerMember_refp2_6_pointer_to_member_argument_HasTwoInts_first_ {} thread_local!( pub static count_1: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct p2_6_pointer_to_member_argument_CountsPerMember_refp2_6_pointer_to_member_argument_HasTwoInts_second_ {} thread_local!( pub static count_2: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct p2_6_pointer_to_member_argument_CountsPerMember_nullptr_ {} pub fn test_3() { diff --git a/tests/std/temp/out/unsafe/temp.type.rs b/tests/std/temp/out/unsafe/temp.type.rs index 7dcef77813..06a61aadc3 100644 --- a/tests/std/temp/out/unsafe/temp.type.rs +++ b/tests/std/temp/out/unsafe/temp.type.rs @@ -7,68 +7,24 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p2_6_pointer_to_member_argument_HasTwoInts { pub first: i32, pub second: i32, } pub static mut count_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p2_6_pointer_to_member_argument_CountsPerMember_refp2_6_pointer_to_member_argument_HasTwoInts_first_ {} pub static mut count_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p2_6_pointer_to_member_argument_CountsPerMember_refp2_6_pointer_to_member_argument_HasTwoInts_second_ {} pub static mut count_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p2_6_pointer_to_member_argument_CountsPerMember_nullptr_ {} pub unsafe fn test_3() { (*std::cell::LazyCell::force_mut(&mut *&raw mut count_0)).prefix_inc(); diff --git a/tests/std/temp/temp.spec/out/refcount/temp.inst.rs b/tests/std/temp/temp.spec/out/refcount/temp.inst.rs index 94fff10295..62151af01c 100644 --- a/tests/std/temp/temp.spec/out/refcount/temp.inst.rs +++ b/tests/std/temp/temp.spec/out/refcount/temp.inst.rs @@ -6,19 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(4)] pub struct p2_reference_does_not_instantiate_Member { #[offset(0)] diff --git a/tests/std/temp/temp.spec/out/unsafe/temp.inst.rs b/tests/std/temp/temp.spec/out/unsafe/temp.inst.rs index 7337b89ab9..05a30a775d 100644 --- a/tests/std/temp/temp.spec/out/unsafe/temp.inst.rs +++ b/tests/std/temp/temp.spec/out/unsafe/temp.inst.rs @@ -7,17 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct p2_reference_does_not_instantiate_Member { pub value: i32, } diff --git a/tests/std/utilities/utility/out/refcount/forward.rs b/tests/std/utilities/utility/out/refcount/forward.rs index 09009aa3e1..1aba0e1ce8 100644 --- a/tests/std/utilities/utility/out/refcount/forward.rs +++ b/tests/std/utilities/utility/out/refcount/forward.rs @@ -12,20 +12,7 @@ pub fn test_0() { assert!((target == 1)); assert!((source == 1)); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct p9_move_trivially_copyable_Point { #[offset(0)] diff --git a/tests/std/utilities/utility/out/refcount/utility.as.const.rs b/tests/std/utilities/utility/out/refcount/utility.as.const.rs index 1c5b7a6348..6fc2ef179c 100644 --- a/tests/std/utilities/utility/out/refcount/utility.as.const.rs +++ b/tests/std/utilities/utility/out/refcount/utility.as.const.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct p1_as_const_Counter { #[offset(0)] diff --git a/tests/std/utilities/utility/out/unsafe/forward.rs b/tests/std/utilities/utility/out/unsafe/forward.rs index c1c7cf609c..293c399b79 100644 --- a/tests/std/utilities/utility/out/unsafe/forward.rs +++ b/tests/std/utilities/utility/out/unsafe/forward.rs @@ -13,18 +13,7 @@ pub unsafe fn test_0() { assert!(((source) == (1))); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p9_move_trivially_copyable_Point { pub x: i32, pub y: i32, diff --git a/tests/std/utilities/utility/out/unsafe/utility.as.const.rs b/tests/std/utilities/utility/out/unsafe/utility.as.const.rs index 93766a2402..d55c5c52eb 100644 --- a/tests/std/utilities/utility/out/unsafe/utility.as.const.rs +++ b/tests/std/utilities/utility/out/unsafe/utility.as.const.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p1_as_const_Counter { pub value: i32, } diff --git a/tests/ub/out/refcount/ctor_ref_member.rs b/tests/ub/out/refcount/ctor_ref_member.rs index b454dd6b2b..bced5e5085 100644 --- a/tests/ub/out/refcount/ctor_ref_member.rs +++ b/tests/ub/out/refcount/ctor_ref_member.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, )] #[cpp_from(i32, construct, ptr)] #[byte_size(8)] diff --git a/tests/ub/out/refcount/self_referencing_initializer.rs b/tests/ub/out/refcount/self_referencing_initializer.rs index 061f44a7e7..24795e940a 100644 --- a/tests/ub/out/refcount/self_referencing_initializer.rs +++ b/tests/ub/out/refcount/self_referencing_initializer.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct pair { #[offset(0)] diff --git a/tests/ub/out/refcount/ub6.rs b/tests/ub/out/refcount/ub6.rs index e4140f07b0..ecffc37d20 100644 --- a/tests/ub/out/refcount/ub6.rs +++ b/tests/ub/out/refcount/ub6.rs @@ -6,19 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct Pair { #[offset(0)] diff --git a/tests/ub/out/unsafe/ctor_ref_member.rs b/tests/ub/out/unsafe/ctor_ref_member.rs index d0acb17763..40356b74ef 100644 --- a/tests/ub/out/unsafe/ctor_ref_member.rs +++ b/tests/ub/out/unsafe/ctor_ref_member.rs @@ -8,17 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, )] #[cpp_from(i32, construct, ptr)] pub struct S { diff --git a/tests/ub/out/unsafe/self_referencing_initializer.rs b/tests/ub/out/unsafe/self_referencing_initializer.rs index 20cdab0e43..91d0ca7546 100644 --- a/tests/ub/out/unsafe/self_referencing_initializer.rs +++ b/tests/ub/out/unsafe/self_referencing_initializer.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct pair { pub a: i32, pub b: i32, diff --git a/tests/ub/out/unsafe/ub6.rs b/tests/ub/out/unsafe/ub6.rs index b4456c9332..e5d176dd96 100644 --- a/tests/ub/out/unsafe/ub6.rs +++ b/tests/ub/out/unsafe/ub6.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Pair { pub x1: *mut i32, pub x2: *mut i32, diff --git a/tests/unit/out/refcount/05_new.rs b/tests/unit/out/refcount/05_new.rs index 779beee546..af231c3e50 100644 --- a/tests/unit/out/refcount/05_new.rs +++ b/tests/unit/out/refcount/05_new.rs @@ -6,36 +6,10 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct A {} -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct D {} pub fn main() { diff --git a/tests/unit/out/refcount/10_struct.rs b/tests/unit/out/refcount/10_struct.rs index d0cc6b3762..3386a00e03 100644 --- a/tests/unit/out/refcount/10_struct.rs +++ b/tests/unit/out/refcount/10_struct.rs @@ -6,19 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct GraphNode { #[offset(0)] @@ -27,19 +15,7 @@ pub struct GraphNode { #[byte_size(8)] pub next: Ptr, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct Graph { #[offset(0)] @@ -48,18 +24,7 @@ pub struct Graph { #[byte_size(8)] pub adj: Ptr>, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(8)] pub struct Partial { #[offset(0)] @@ -75,35 +40,10 @@ impl Default for Partial { } } } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct Declared {} -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/addr_of_global.rs b/tests/unit/out/refcount/addr_of_global.rs index 5996d1cc85..7281147b84 100644 --- a/tests/unit/out/refcount/addr_of_global.rs +++ b/tests/unit/out/refcount/addr_of_global.rs @@ -6,38 +6,13 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Inner { #[offset(0)] pub value: i32, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Outer { #[offset(0)] diff --git a/tests/unit/out/refcount/anonymous-struct.rs b/tests/unit/out/refcount/anonymous-struct.rs index ab7952ffbb..e5ef6a069f 100644 --- a/tests/unit/out/refcount/anonymous-struct.rs +++ b/tests/unit/out/refcount/anonymous-struct.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Outer_Named { #[offset(0)] @@ -27,20 +14,7 @@ pub struct Outer_Named { #[offset(4)] pub b: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct anon_0 { #[offset(0)] @@ -48,20 +22,7 @@ pub struct anon_0 { #[offset(4)] pub d: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct anon_1 { #[offset(0)] @@ -69,20 +30,7 @@ pub struct anon_1 { #[offset(4)] pub h: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct anon_2 { #[offset(0)] @@ -90,58 +38,19 @@ pub struct anon_2 { #[offset(4)] pub f: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct anon_4 { #[offset(0)] pub j: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct anon_5 { #[offset(0)] pub k: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(12)] pub struct anon_3 { #[offset(0)] @@ -153,20 +62,7 @@ pub struct anon_3 { #[byte_size(4)] pub anon_5: anon_5, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(44)] pub struct Outer { #[offset(0)] @@ -230,20 +126,7 @@ fn main_0() -> i32 { ); return 0; } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct anon_6 { #[offset(0)] diff --git a/tests/unit/out/refcount/anonymous-struct_c.rs b/tests/unit/out/refcount/anonymous-struct_c.rs index 4c9332faeb..a7c5bbf4e5 100644 --- a/tests/unit/out/refcount/anonymous-struct_c.rs +++ b/tests/unit/out/refcount/anonymous-struct_c.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Named { #[offset(0)] @@ -27,20 +14,7 @@ pub struct Named { #[offset(4)] pub b: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct anon_0 { #[offset(0)] @@ -48,20 +22,7 @@ pub struct anon_0 { #[offset(4)] pub d: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct anon_1 { #[offset(0)] @@ -69,20 +30,7 @@ pub struct anon_1 { #[offset(4)] pub h: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct anon_2 { #[offset(0)] @@ -90,58 +38,19 @@ pub struct anon_2 { #[offset(4)] pub f: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct anon_4 { #[offset(0)] pub j: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct anon_5 { #[offset(0)] pub k: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(12)] pub struct anon_3 { #[offset(0)] @@ -153,20 +62,7 @@ pub struct anon_3 { #[byte_size(4)] pub anon_5: anon_5, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(44)] pub struct Outer { #[offset(0)] @@ -236,20 +132,7 @@ fn main_0() -> i32 { ); return 0; } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct anon_6 { #[offset(0)] diff --git a/tests/unit/out/refcount/anonymous_enum.rs b/tests/unit/out/refcount/anonymous_enum.rs index 10b0ddeed9..e9bd25cbfd 100644 --- a/tests/unit/out/refcount/anonymous_enum.rs +++ b/tests/unit/out/refcount/anonymous_enum.rs @@ -12,20 +12,7 @@ pub const anon_0_FIRST_B: anon_0 = 1; pub type anon_1 = u32; pub const anon_1_SECOND_A: anon_1 = 0; pub const anon_1_SECOND_B: anon_1 = 1; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct S { #[offset(0)] @@ -37,20 +24,7 @@ pub const TdEnum_TD_B: TdEnum = 1; pub type anon_2 = u32; pub const anon_2_FIELD_A: anon_2 = 0; pub const anon_2_FIELD_B: anon_2 = 1; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct WithAnonField { #[offset(0)] diff --git a/tests/unit/out/refcount/anonymous_enum_c.rs b/tests/unit/out/refcount/anonymous_enum_c.rs index 729c307e80..b136e41810 100644 --- a/tests/unit/out/refcount/anonymous_enum_c.rs +++ b/tests/unit/out/refcount/anonymous_enum_c.rs @@ -12,20 +12,7 @@ pub const anon_0_FIRST_B: anon_0 = 1; pub type anon_1 = u32; pub const anon_1_SECOND_A: anon_1 = 0; pub const anon_1_SECOND_B: anon_1 = 1; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct S { #[offset(0)] @@ -37,20 +24,7 @@ pub const TdEnum_enum_TD_B: TdEnum_enum = 1; pub type anon_2 = u32; pub const anon_2_FIELD_A: anon_2 = 0; pub const anon_2_FIELD_B: anon_2 = 1; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct WithAnonField { #[offset(0)] diff --git a/tests/unit/out/refcount/any.rs b/tests/unit/out/refcount/any.rs index 2ae0880236..f75be0b727 100644 --- a/tests/unit/out/refcount/any.rs +++ b/tests/unit/out/refcount/any.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Point { #[offset(0)] diff --git a/tests/unit/out/refcount/array_const_init.rs b/tests/unit/out/refcount/array_const_init.rs index 18c1ad08d8..10578fb74b 100644 --- a/tests/unit/out/refcount/array_const_init.rs +++ b/tests/unit/out/refcount/array_const_init.rs @@ -6,18 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(20)] pub struct S { #[offset(0)] @@ -49,20 +38,7 @@ thread_local!( buf: Box::new([0; 4]), })); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct P { #[offset(0)] diff --git a/tests/unit/out/refcount/array_field_addr.rs b/tests/unit/out/refcount/array_field_addr.rs index 5ee1d4db1e..8e9d6138f2 100644 --- a/tests/unit/out/refcount/array_field_addr.rs +++ b/tests/unit/out/refcount/array_field_addr.rs @@ -6,18 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(12)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/array_reference.rs b/tests/unit/out/refcount/array_reference.rs index e6cddbad3c..386c7d3c6e 100644 --- a/tests/unit/out/refcount/array_reference.rs +++ b/tests/unit/out/refcount/array_reference.rs @@ -59,20 +59,7 @@ pub fn fill_and_sum_9(a: Ptr, mut v: i32, out: Ptr) { pub fn pick_10(s: Ptr) -> Ptr { return (s).clone(); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Point { #[offset(0)] diff --git a/tests/unit/out/refcount/as_const.rs b/tests/unit/out/refcount/as_const.rs index 21a4673f15..e4a43f07c3 100644 --- a/tests/unit/out/refcount/as_const.rs +++ b/tests/unit/out/refcount/as_const.rs @@ -9,20 +9,7 @@ use std::rc::{Rc, Weak}; pub type Overload = u32; pub const Overload_kMutableOverload: Overload = 1; pub const Overload_kConstOverload: Overload = 2; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/assign_rhs_first.rs b/tests/unit/out/refcount/assign_rhs_first.rs index f445b694ef..5bb95da148 100644 --- a/tests/unit/out/refcount/assign_rhs_first.rs +++ b/tests/unit/out/refcount/assign_rhs_first.rs @@ -15,19 +15,7 @@ pub fn advance_1() -> i32 { }); return 10; } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/assignment_single_eval.rs b/tests/unit/out/refcount/assignment_single_eval.rs index 0f913bb7e9..ba6986b900 100644 --- a/tests/unit/out/refcount/assignment_single_eval.rs +++ b/tests/unit/out/refcount/assignment_single_eval.rs @@ -810,57 +810,21 @@ pub fn test_reference_members_9() { (*other.borrow()) ); } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Slot_6 { #[offset(0)] #[byte_size(8)] pub value: Ptr, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Slot_8 { #[offset(0)] #[byte_size(8)] pub value: Ptr, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Slot_10 { #[offset(0)] @@ -925,19 +889,7 @@ pub fn test_pointer_elements_11() { }; printf!(b"pointer increments %d %d\n", (*index.borrow()), value); } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Holder_12 { #[offset(0)] @@ -971,19 +923,7 @@ pub fn test_reference_pointer_13() { (({ (result).clone() } == { (second.as_pointer()) }) as i32) ); } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Node_14 { #[offset(0)] @@ -1080,76 +1020,26 @@ pub fn test_reference_subfields_18() { ({ (*other.borrow()).value } as i32) ); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Index_16 { #[offset(0)] pub value: u32, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Slot_17 { #[offset(0)] #[byte_size(8)] pub ref_: Ptr, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(2)] pub struct Index_19 { #[offset(0)] pub value: i16, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Slot_20 { #[offset(0)] @@ -1191,39 +1081,13 @@ pub fn observe_global_23(mut assigned: i32) -> i32 { pub fn observe_24(mut assigned: i32, mut stored: Ptr) -> i32 { return ({ assigned } + { (stored.read()) }); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct GlobalRecord_Inner { #[offset(0)] pub value: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct GlobalRecord { #[offset(0)] @@ -1464,38 +1328,13 @@ thread_local!( thread_local!( static flag_31: Value = Rc::new(RefCell::new(false)); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Record_32 { #[offset(0)] pub value: i32, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Link_33 { #[offset(0)] @@ -1506,20 +1345,7 @@ thread_local!( pub static selected_values_34: Value> = Rc::new(RefCell::new(Box::new([0_u32, 20_u32, 30_u32]))); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct IndexedBinding {} pub fn test_binding_35() { @@ -1754,20 +1580,7 @@ thread_local!( Box::new([20_u32, 30_u32]), ]))); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(12)] pub struct IndexedMember { #[offset(0)] @@ -2128,19 +1941,7 @@ thread_local!( scoped_values_52.with(|v| v.decay()), ]))); ); -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct PointerSelector { #[offset(0)] @@ -2371,20 +2172,7 @@ impl MoveAssignable for Counts_59 { return (*this).clone(); } } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Pair_60 { #[offset(0)] @@ -2695,37 +2483,13 @@ fn main_0() -> i32 { ); return 0; } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Index_62 { #[offset(0)] pub value: i32, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(12)] pub struct Owner_63 { #[offset(0)] diff --git a/tests/unit/out/refcount/bounded_struct_ptr.rs b/tests/unit/out/refcount/bounded_struct_ptr.rs index 3c2b5ec6e5..1ffff7cdf6 100644 --- a/tests/unit/out/refcount/bounded_struct_ptr.rs +++ b/tests/unit/out/refcount/bounded_struct_ptr.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Foo { #[offset(0)] diff --git a/tests/unit/out/refcount/bst.rs b/tests/unit/out/refcount/bst.rs index a838f4dc6e..d88c6ddcbc 100644 --- a/tests/unit/out/refcount/bst.rs +++ b/tests/unit/out/refcount/bst.rs @@ -6,19 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(24)] pub struct node_t { #[offset(0)] diff --git a/tests/unit/out/refcount/c_struct.rs b/tests/unit/out/refcount/c_struct.rs index 84bf97a5ed..97422e04f7 100644 --- a/tests/unit/out/refcount/c_struct.rs +++ b/tests/unit/out/refcount/c_struct.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Point { #[offset(0)] @@ -27,20 +14,7 @@ pub struct Point { #[offset(4)] pub y: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct Line { #[offset(0)] @@ -50,19 +24,7 @@ pub struct Line { #[byte_size(8)] pub end: Point, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct Node { #[offset(0)] @@ -75,20 +37,7 @@ pub type Color = u32; pub const Color_RED: Color = 0; pub const Color_GREEN: Color = 1; pub const Color_BLUE: Color = 2; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Inner { #[offset(0)] @@ -96,20 +45,7 @@ pub struct Inner { #[offset(4)] pub b: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct Container { #[offset(0)] diff --git a/tests/unit/out/refcount/cast.rs b/tests/unit/out/refcount/cast.rs index 9b64cc288d..68f15593a2 100644 --- a/tests/unit/out/refcount/cast.rs +++ b/tests/unit/out/refcount/cast.rs @@ -10,20 +10,7 @@ pub type E = u32; pub const E_A: E = 0; pub const E_B: E = 1; pub const E_C: E = 2; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Pair { #[offset(0)] @@ -31,38 +18,14 @@ pub struct Pair { #[offset(4)] pub y: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(64)] #[byte_align(64)] pub struct Wide { #[offset(0)] pub c: i8, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(40)] pub struct Grid { #[offset(0)] diff --git a/tests/unit/out/refcount/cast_array_to_pointer_decay.rs b/tests/unit/out/refcount/cast_array_to_pointer_decay.rs index c94eb59c1f..69633bbe6a 100644 --- a/tests/unit/out/refcount/cast_array_to_pointer_decay.rs +++ b/tests/unit/out/refcount/cast_array_to_pointer_decay.rs @@ -16,18 +16,7 @@ pub fn strlen_1(mut s: Ptr) -> i32 { } return c; } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(12)] pub struct Row { #[offset(0)] diff --git a/tests/unit/out/refcount/class.rs b/tests/unit/out/refcount/class.rs index f805691032..897acfc8a1 100644 --- a/tests/unit/out/refcount/class.rs +++ b/tests/unit/out/refcount/class.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Pair { #[offset(0)] @@ -27,20 +14,7 @@ pub struct Pair { #[offset(4)] pub second: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct Route { #[offset(0)] @@ -49,20 +23,7 @@ pub struct Route { #[offset(8)] pub cost: f64, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Counter { #[offset(0)] @@ -75,20 +36,7 @@ impl CppEq for Counter { CounterImpl::operator_eq(__lhs, __rhs.clone()) } } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Tally { #[offset(0)] diff --git a/tests/unit/out/refcount/class_template_lazy_member.rs b/tests/unit/out/refcount/class_template_lazy_member.rs index b1a58db62e..574eafcca9 100644 --- a/tests/unit/out/refcount/class_template_lazy_member.rs +++ b/tests/unit/out/refcount/class_template_lazy_member.rs @@ -6,97 +6,32 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Point { #[offset(0)] pub x: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Box_int_ { #[offset(0)] pub val: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Box_Point_ { #[offset(0)] #[byte_size(4)] pub val: Point, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Deduced_int_ { #[offset(0)] pub val: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Deduced_Point_ { #[offset(0)] diff --git a/tests/unit/out/refcount/class_templates.rs b/tests/unit/out/refcount/class_templates.rs index a836ca815e..d1090687b1 100644 --- a/tests/unit/out/refcount/class_templates.rs +++ b/tests/unit/out/refcount/class_templates.rs @@ -96,20 +96,7 @@ impl MoveAssignable for MyContainer_float_ { return (*this).clone(); } } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(2)] pub struct Boxed_short_ { #[offset(0)] @@ -120,20 +107,7 @@ impl Boxed_short_ { return (((v as i32) + (v as i32)) as i16); } } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Boxed_int_ { #[offset(0)] @@ -144,20 +118,7 @@ impl Boxed_int_ { return (v + v); } } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Boxed_long_ { #[offset(0)] @@ -168,20 +129,7 @@ impl Boxed_long_ { return (v + v); } } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Outer_int__Inner_int_ { #[offset(0)] @@ -189,39 +137,13 @@ pub struct Outer_int__Inner_int_ { #[offset(4)] pub u: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Outer_int_ { #[offset(0)] pub v: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct Outer_long__Inner_int_ { #[offset(0)] @@ -229,20 +151,7 @@ pub struct Outer_long__Inner_int_ { #[offset(8)] pub u: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct Outer_long__Inner_char_ { #[offset(0)] @@ -250,39 +159,13 @@ pub struct Outer_long__Inner_char_ { #[offset(8)] pub u: i8, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Outer_long_ { #[offset(0)] pub v: i64, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Elem { #[offset(0)] diff --git a/tests/unit/out/refcount/clone_vs_move.rs b/tests/unit/out/refcount/clone_vs_move.rs index 9b727c6698..dea8feaf5d 100644 --- a/tests/unit/out/refcount/clone_vs_move.rs +++ b/tests/unit/out/refcount/clone_vs_move.rs @@ -6,37 +6,13 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Bar { #[offset(0)] pub w: i32, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(40)] pub struct Foo { #[offset(0)] @@ -68,19 +44,7 @@ impl Default for Foo { } } } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct Refs { #[offset(0)] diff --git a/tests/unit/out/refcount/comma_operator.rs b/tests/unit/out/refcount/comma_operator.rs index 1fff15389e..87ebed0964 100644 --- a/tests/unit/out/refcount/comma_operator.rs +++ b/tests/unit/out/refcount/comma_operator.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Pair { #[offset(0)] diff --git a/tests/unit/out/refcount/complex_function.rs b/tests/unit/out/refcount/complex_function.rs index 347689b15a..f2be8f7538 100644 --- a/tests/unit/out/refcount/complex_function.rs +++ b/tests/unit/out/refcount/complex_function.rs @@ -15,76 +15,27 @@ pub fn ptr_1(mut x: Ptr) -> Ptr { pub fn bar_2(x: Ptr) -> Ptr { return (x).clone(); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct X1 { #[offset(0)] pub v: i32, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct X2 { #[offset(0)] #[byte_size(8)] pub v: Ptr, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct X3 { #[offset(0)] #[byte_size(8)] pub v: Ptr, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct X4 { #[offset(0)] diff --git a/tests/unit/out/refcount/compound_assign_paren.rs b/tests/unit/out/refcount/compound_assign_paren.rs index f46ef5a654..879af437ad 100644 --- a/tests/unit/out/refcount/compound_assign_paren.rs +++ b/tests/unit/out/refcount/compound_assign_paren.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct Item { #[offset(0)] diff --git a/tests/unit/out/refcount/concepts.rs b/tests/unit/out/refcount/concepts.rs index 4b5f8ab2ea..2d507aa650 100644 --- a/tests/unit/out/refcount/concepts.rs +++ b/tests/unit/out/refcount/concepts.rs @@ -11,20 +11,7 @@ const _: () = assert!( (::std::mem::size_of::() == 4_usize), "sizeof(int) == 4" ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct Sized {} pub fn is_small_0() -> bool { diff --git a/tests/unit/out/refcount/constexpr_function.rs b/tests/unit/out/refcount/constexpr_function.rs index b8bc464459..74308900e4 100644 --- a/tests/unit/out/refcount/constexpr_function.rs +++ b/tests/unit/out/refcount/constexpr_function.rs @@ -21,20 +21,7 @@ pub fn scaled_2(mut x: i32) -> i32 { pub fn half_3(mut x: f64) -> f64 { return (x / 2_f64); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Flag { #[offset(0)] @@ -57,20 +44,7 @@ const _: () = assert!(true, "in_constant_context()"); pub fn imm_7(mut b: bool) -> bool { return b; } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct P { #[offset(0)] diff --git a/tests/unit/out/refcount/constructor.rs b/tests/unit/out/refcount/constructor.rs index ce1ada3201..7aa38b1d0e 100644 --- a/tests/unit/out/refcount/constructor.rs +++ b/tests/unit/out/refcount/constructor.rs @@ -18,10 +18,7 @@ thread_local!( FnPtrArg, CppFrom, Destructible, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, + Copyable, Default, )] #[cpp_from(i32, construct, value)] @@ -30,20 +27,7 @@ pub struct S { #[offset(0)] pub v: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable)] #[cpp_from(i32, construct_1, value)] #[byte_size(8)] pub struct Point { diff --git a/tests/unit/out/refcount/conversion_operator_same_translation.rs b/tests/unit/out/refcount/conversion_operator_same_translation.rs index dc71c33463..0b415e49e2 100644 --- a/tests/unit/out/refcount/conversion_operator_same_translation.rs +++ b/tests/unit/out/refcount/conversion_operator_same_translation.rs @@ -7,19 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, )] #[cpp_into(i8, to_i8)] #[cpp_into(u8, to_u8)] @@ -29,19 +17,7 @@ pub struct S { pub v: i32, } #[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, )] #[cpp_into(i64, to_i64_1)] #[byte_size(4)] diff --git a/tests/unit/out/refcount/copy_assign.rs b/tests/unit/out/refcount/copy_assign.rs index 71aece74fc..732fa7620b 100644 --- a/tests/unit/out/refcount/copy_assign.rs +++ b/tests/unit/out/refcount/copy_assign.rs @@ -53,19 +53,7 @@ impl Clone for Partial { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(4)] pub struct NonConstAssign { #[offset(0)] diff --git a/tests/unit/out/refcount/copy_move_defaulted.rs b/tests/unit/out/refcount/copy_move_defaulted.rs index f54c3bad76..dc141e2405 100644 --- a/tests/unit/out/refcount/copy_move_defaulted.rs +++ b/tests/unit/out/refcount/copy_move_defaulted.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Inner { #[offset(0)] @@ -55,18 +42,7 @@ impl Default for Explicit { { ::zero_init() } } } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(16)] pub struct Implicit { #[offset(0)] diff --git a/tests/unit/out/refcount/default.rs b/tests/unit/out/refcount/default.rs index 6173e72b5c..1c772ee03e 100644 --- a/tests/unit/out/refcount/default.rs +++ b/tests/unit/out/refcount/default.rs @@ -6,18 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(144)] pub struct Pointers { #[offset(0)] @@ -54,18 +43,7 @@ impl Default for Pointers { } } } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(440)] pub struct SmallArrays { #[offset(0)] @@ -100,18 +78,7 @@ impl Default for SmallArrays { } } } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(132)] pub struct BigArray { #[offset(0)] diff --git a/tests/unit/out/refcount/default_function_arguments.rs b/tests/unit/out/refcount/default_function_arguments.rs index 59e0534c86..5f2473d1cf 100644 --- a/tests/unit/out/refcount/default_function_arguments.rs +++ b/tests/unit/out/refcount/default_function_arguments.rs @@ -12,20 +12,7 @@ pub fn foo_0(mut a: i32, mut b: i32) -> i32 { pub fn baz_1(mut a: Ptr, mut b: Ptr) -> bool { return ({ a } == { b }); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct Bar { @@ -71,20 +58,7 @@ pub fn shifted_8(mut x: i32, mut y: i32) -> i32 { pub fn first_9(r: Ptr) -> i32 { return (elem!(r, 0).read()); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Holder_int_ { #[offset(0)] diff --git a/tests/unit/out/refcount/default_in_statics.rs b/tests/unit/out/refcount/default_in_statics.rs index 08fddb3f9d..dbab9f5808 100644 --- a/tests/unit/out/refcount/default_in_statics.rs +++ b/tests/unit/out/refcount/default_in_statics.rs @@ -6,19 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct Inner { #[offset(0)] @@ -27,18 +15,7 @@ pub struct Inner { #[byte_size(8)] pub name: Ptr, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(88)] pub struct Outer { #[offset(0)] @@ -84,19 +61,7 @@ impl Default for Outer { } } } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(40)] pub struct Foo { #[offset(0)] diff --git a/tests/unit/out/refcount/delete_array_order.rs b/tests/unit/out/refcount/delete_array_order.rs index 31ae70ed56..10231c0604 100644 --- a/tests/unit/out/refcount/delete_array_order.rs +++ b/tests/unit/out/refcount/delete_array_order.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - Destructible, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, )] #[byte_size(16)] pub struct Element { diff --git a/tests/unit/out/refcount/destructor.rs b/tests/unit/out/refcount/destructor.rs index 87e3924178..43cfaeecfb 100644 --- a/tests/unit/out/refcount/destructor.rs +++ b/tests/unit/out/refcount/destructor.rs @@ -10,34 +10,12 @@ thread_local!( pub static global_0: Value = Rc::new(RefCell::new(0)); ); #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - Destructible, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, )] #[byte_size(1)] pub struct S {} #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - Destructible, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, )] #[byte_size(1)] pub struct Defaulted { @@ -46,18 +24,7 @@ pub struct Defaulted { pub s: S, } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - Destructible, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, )] #[byte_size(1)] pub struct Middle { @@ -66,18 +33,7 @@ pub struct Middle { pub s: S, } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - Destructible, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, )] #[byte_size(1)] pub struct Outer { @@ -85,19 +41,7 @@ pub struct Outer { #[byte_size(1)] pub m: Middle, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - Destructible, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(3)] pub struct ArrayMember { #[offset(0)] @@ -115,18 +59,7 @@ impl Default for ArrayMember { } } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - Destructible, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, )] #[byte_size(1)] pub struct EmptyBody { @@ -135,18 +68,7 @@ pub struct EmptyBody { pub s: S, } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - Destructible, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, )] #[byte_size(1)] pub struct Templated_char_ { @@ -154,18 +76,7 @@ pub struct Templated_char_ { pub v: i8, } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - Destructible, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, )] #[byte_size(4)] pub struct Templated_int_ { @@ -173,18 +84,7 @@ pub struct Templated_int_ { pub v: i32, } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - Destructible, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, )] #[byte_size(4)] pub struct Copied { @@ -199,18 +99,7 @@ thread_local!( pub static order_count_2: Value = Rc::new(RefCell::new(0)); ); #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - Destructible, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, )] #[byte_size(4)] pub struct Tagged { @@ -218,18 +107,7 @@ pub struct Tagged { pub tag: i32, } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - Destructible, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, )] #[byte_size(20)] pub struct Ordered { diff --git a/tests/unit/out/refcount/destructor_params.rs b/tests/unit/out/refcount/destructor_params.rs index a6f18a0747..b43afdf342 100644 --- a/tests/unit/out/refcount/destructor_params.rs +++ b/tests/unit/out/refcount/destructor_params.rs @@ -13,18 +13,7 @@ thread_local!( pub static last_1: Value = Rc::new(RefCell::new(0)); ); #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - Destructible, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, )] #[byte_size(4)] pub struct S { @@ -40,20 +29,7 @@ pub fn with_default_3(s: S) -> i32 { let s: Value = Rc::new(RefCell::new(s)); return { (*s.borrow()).v }; } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Holder { #[offset(0)] diff --git a/tests/unit/out/refcount/destructor_temporaries.rs b/tests/unit/out/refcount/destructor_temporaries.rs index 569a667581..d575fec9a1 100644 --- a/tests/unit/out/refcount/destructor_temporaries.rs +++ b/tests/unit/out/refcount/destructor_temporaries.rs @@ -13,18 +13,7 @@ thread_local!( pub static last_1: Value = Rc::new(RefCell::new(0)); ); #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - Destructible, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, )] #[byte_size(4)] pub struct S { @@ -32,18 +21,7 @@ pub struct S { pub v: i32, } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - Destructible, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, )] #[byte_size(8)] pub struct Outer { diff --git a/tests/unit/out/refcount/doubly_linked_list.rs b/tests/unit/out/refcount/doubly_linked_list.rs index 3b5758e9ff..6f8fee4e55 100644 --- a/tests/unit/out/refcount/doubly_linked_list.rs +++ b/tests/unit/out/refcount/doubly_linked_list.rs @@ -6,19 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(24)] pub struct Node { #[offset(0)] diff --git a/tests/unit/out/refcount/enum_default_in_static.rs b/tests/unit/out/refcount/enum_default_in_static.rs index e3a1f27ea9..59f594d25d 100644 --- a/tests/unit/out/refcount/enum_default_in_static.rs +++ b/tests/unit/out/refcount/enum_default_in_static.rs @@ -10,20 +10,7 @@ pub type Mode = u32; pub const Mode_MODE_NONE: Mode = 0; pub const Mode_MODE_ONE: Mode = 1; pub const Mode_MODE_TWO: Mode = 2; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Config { #[offset(0)] diff --git a/tests/unit/out/refcount/enum_int_interop.rs b/tests/unit/out/refcount/enum_int_interop.rs index 5d673ceaf9..ef653721a9 100644 --- a/tests/unit/out/refcount/enum_int_interop.rs +++ b/tests/unit/out/refcount/enum_int_interop.rs @@ -19,19 +19,7 @@ pub type Tag = u32; pub const Tag_TAG_ZERO: Tag = 0; pub const Tag_TAG_ONE: Tag = 1; pub const Tag_TAG_TWO: Tag = 2; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct Entry { #[offset(0)] diff --git a/tests/unit/out/refcount/enum_int_interop_c.rs b/tests/unit/out/refcount/enum_int_interop_c.rs index 7bfee05e61..ea4d1f5b82 100644 --- a/tests/unit/out/refcount/enum_int_interop_c.rs +++ b/tests/unit/out/refcount/enum_int_interop_c.rs @@ -19,19 +19,7 @@ pub type Tag_enum = u32; pub const Tag_enum_TAG_ZERO: Tag_enum = 0; pub const Tag_enum_TAG_ONE: Tag_enum = 1; pub const Tag_enum_TAG_TWO: Tag_enum = 2; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct Entry { #[offset(0)] diff --git a/tests/unit/out/refcount/enum_underlying_type.rs b/tests/unit/out/refcount/enum_underlying_type.rs index 886c1dae96..3abf11fce9 100644 --- a/tests/unit/out/refcount/enum_underlying_type.rs +++ b/tests/unit/out/refcount/enum_underlying_type.rs @@ -25,19 +25,7 @@ pub type Scoped = i8; pub const Scoped_NEG: Scoped = -2; pub const Scoped_POS: Scoped = 2; pub type Empty = bool; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(1)] pub struct HoldsEmpty { #[offset(0)] diff --git a/tests/unit/out/refcount/exprs.rs b/tests/unit/out/refcount/exprs.rs index 1c16613cf6..c85afbfb5b 100644 --- a/tests/unit/out/refcount/exprs.rs +++ b/tests/unit/out/refcount/exprs.rs @@ -6,38 +6,13 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct X { #[offset(0)] pub x: i32, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct Y { #[offset(0)] diff --git a/tests/unit/out/refcount/fft.rs b/tests/unit/out/refcount/fft.rs index 9c8d70b8c8..bb87bb2b8b 100644 --- a/tests/unit/out/refcount/fft.rs +++ b/tests/unit/out/refcount/fft.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct Complex { #[offset(0)] diff --git a/tests/unit/out/refcount/field_aliasing.rs b/tests/unit/out/refcount/field_aliasing.rs index 281fc1e754..db3e1c1fc0 100644 --- a/tests/unit/out/refcount/field_aliasing.rs +++ b/tests/unit/out/refcount/field_aliasing.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct In { #[offset(0)] @@ -27,18 +14,7 @@ pub struct In { #[offset(4)] pub y: i32, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(32)] pub struct S { #[offset(0)] @@ -65,19 +41,7 @@ impl Default for S { } } } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct Node { #[offset(0)] diff --git a/tests/unit/out/refcount/field_array_elem_ptr.rs b/tests/unit/out/refcount/field_array_elem_ptr.rs index 5f5467ca87..14e0f76246 100644 --- a/tests/unit/out/refcount/field_array_elem_ptr.rs +++ b/tests/unit/out/refcount/field_array_elem_ptr.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Point { #[offset(0)] @@ -27,18 +14,7 @@ pub struct Point { #[offset(4)] pub y: i32, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(48)] pub struct Shape { #[offset(0)] diff --git a/tests/unit/out/refcount/field_method_receiver.rs b/tests/unit/out/refcount/field_method_receiver.rs index 8c7046c6a8..85bc8c30f8 100644 --- a/tests/unit/out/refcount/field_method_receiver.rs +++ b/tests/unit/out/refcount/field_method_receiver.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Counter { #[offset(0)] diff --git a/tests/unit/out/refcount/field_pointers.rs b/tests/unit/out/refcount/field_pointers.rs index 3ac1b7921f..7b50ae3260 100644 --- a/tests/unit/out/refcount/field_pointers.rs +++ b/tests/unit/out/refcount/field_pointers.rs @@ -6,18 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(12)] pub struct Inner { #[offset(0)] @@ -37,20 +26,7 @@ impl Default for Inner { } } } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Header { #[offset(0)] diff --git a/tests/unit/out/refcount/field_pointers_malloced_struct.rs b/tests/unit/out/refcount/field_pointers_malloced_struct.rs index 110b5f4d14..169801a381 100644 --- a/tests/unit/out/refcount/field_pointers_malloced_struct.rs +++ b/tests/unit/out/refcount/field_pointers_malloced_struct.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(12)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/field_reinterpret_write_through.rs b/tests/unit/out/refcount/field_reinterpret_write_through.rs index ead637bab7..a2acb2693c 100644 --- a/tests/unit/out/refcount/field_reinterpret_write_through.rs +++ b/tests/unit/out/refcount/field_reinterpret_write_through.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct In { #[offset(0)] @@ -27,18 +14,7 @@ pub struct In { #[offset(4)] pub b: i32, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(40)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/find.rs b/tests/unit/out/refcount/find.rs index 217d2b0d3f..0bbb72b2dd 100644 --- a/tests/unit/out/refcount/find.rs +++ b/tests/unit/out/refcount/find.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct P { #[offset(0)] diff --git a/tests/unit/out/refcount/first_field_ptr_covers_struct.rs b/tests/unit/out/refcount/first_field_ptr_covers_struct.rs index d2f0e08919..985618301b 100644 --- a/tests/unit/out/refcount/first_field_ptr_covers_struct.rs +++ b/tests/unit/out/refcount/first_field_ptr_covers_struct.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct In { #[offset(0)] @@ -27,20 +14,7 @@ pub struct In { #[offset(2)] pub b: i16, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(12)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/first_member_downcast.rs b/tests/unit/out/refcount/first_member_downcast.rs index df0a158b10..e6e7ab310b 100644 --- a/tests/unit/out/refcount/first_member_downcast.rs +++ b/tests/unit/out/refcount/first_member_downcast.rs @@ -6,39 +6,13 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct base { #[offset(0)] pub kind: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct derived { #[offset(0)] diff --git a/tests/unit/out/refcount/flex_array_member_incomplete.rs b/tests/unit/out/refcount/flex_array_member_incomplete.rs index 3a1ec71970..39b1d1818b 100644 --- a/tests/unit/out/refcount/flex_array_member_incomplete.rs +++ b/tests/unit/out/refcount/flex_array_member_incomplete.rs @@ -6,18 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(4)] pub struct F { #[offset(0)] diff --git a/tests/unit/out/refcount/flex_array_member_sibling_write.rs b/tests/unit/out/refcount/flex_array_member_sibling_write.rs index 79f16e6490..adaf0560a2 100644 --- a/tests/unit/out/refcount/flex_array_member_sibling_write.rs +++ b/tests/unit/out/refcount/flex_array_member_sibling_write.rs @@ -6,18 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(8)] pub struct S { #[offset(0)] @@ -37,20 +26,7 @@ impl Default for S { } } } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct E { #[offset(0)] @@ -58,18 +34,7 @@ pub struct E { #[offset(4)] pub w: i32, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(16)] pub struct T { #[offset(0)] diff --git a/tests/unit/out/refcount/fn_ptr.rs b/tests/unit/out/refcount/fn_ptr.rs index 557f0833d3..b530cfe295 100644 --- a/tests/unit/out/refcount/fn_ptr.rs +++ b/tests/unit/out/refcount/fn_ptr.rs @@ -29,18 +29,7 @@ pub fn identity_hash_6(mut v: bool) -> usize { return (v as usize); } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, )] #[cpp_from(FnPtr u64 > , construct, ptr)] #[byte_size(8)] diff --git a/tests/unit/out/refcount/fn_ptr_cast.rs b/tests/unit/out/refcount/fn_ptr_cast.rs index 9962b48bc6..25418a6675 100644 --- a/tests/unit/out/refcount/fn_ptr_cast.rs +++ b/tests/unit/out/refcount/fn_ptr_cast.rs @@ -24,19 +24,7 @@ pub fn test_double_cast_2() { assert!((({ fn2.call(5,) }) == 10)); assert!(({ (fn2).clone() } == { (fn_).clone() })); } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Command { #[offset(0)] diff --git a/tests/unit/out/refcount/fn_ptr_stable_sort.rs b/tests/unit/out/refcount/fn_ptr_stable_sort.rs index 314c801323..53aef0e58e 100644 --- a/tests/unit/out/refcount/fn_ptr_stable_sort.rs +++ b/tests/unit/out/refcount/fn_ptr_stable_sort.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Item { #[offset(0)] diff --git a/tests/unit/out/refcount/fn_ptr_struct.rs b/tests/unit/out/refcount/fn_ptr_struct.rs index 26b75379cf..27637f8686 100644 --- a/tests/unit/out/refcount/fn_ptr_struct.rs +++ b/tests/unit/out/refcount/fn_ptr_struct.rs @@ -6,19 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct Handler { #[offset(0)] @@ -33,20 +21,7 @@ pub fn double_it_0(mut x: i32) -> i32 { pub fn negate_1(mut x: i32) -> i32 { return -x; } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct S {} impl S { diff --git a/tests/unit/out/refcount/fn_ptr_typedef_cast.rs b/tests/unit/out/refcount/fn_ptr_typedef_cast.rs index 74431e2726..f9f96308ba 100644 --- a/tests/unit/out/refcount/fn_ptr_typedef_cast.rs +++ b/tests/unit/out/refcount/fn_ptr_typedef_cast.rs @@ -18,20 +18,7 @@ pub fn via_size_t_param_2(mut b: usize) -> u64 { pub fn via_size_t_return_3(mut b: u64) -> usize { return (b as usize); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct pair { #[offset(0)] diff --git a/tests/unit/out/refcount/fn_ptr_vtable.rs b/tests/unit/out/refcount/fn_ptr_vtable.rs index b04a669794..92d68b3f1a 100644 --- a/tests/unit/out/refcount/fn_ptr_vtable.rs +++ b/tests/unit/out/refcount/fn_ptr_vtable.rs @@ -6,19 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(24)] pub struct Vtable { #[offset(0)] diff --git a/tests/unit/out/refcount/fn_ref.rs b/tests/unit/out/refcount/fn_ref.rs index 084c702e2a..402c5dbe88 100644 --- a/tests/unit/out/refcount/fn_ref.rs +++ b/tests/unit/out/refcount/fn_ref.rs @@ -21,19 +21,7 @@ pub fn call_deduced_3(f: FnPtr i32>, mut x: i32) -> i32 { pub fn call_forwarded_4(f: FnPtr i32>, mut x: i32) -> i32 { return ({ f.call(x) }); } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Holder { #[offset(0)] diff --git a/tests/unit/out/refcount/for_body_destructor.rs b/tests/unit/out/refcount/for_body_destructor.rs index 9771b1d4fc..4d1665e304 100644 --- a/tests/unit/out/refcount/for_body_destructor.rs +++ b/tests/unit/out/refcount/for_body_destructor.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - Destructible, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, )] #[byte_size(4)] pub struct Guard { diff --git a/tests/unit/out/refcount/friend.rs b/tests/unit/out/refcount/friend.rs index ac847891a7..80aa6a46a9 100644 --- a/tests/unit/out/refcount/friend.rs +++ b/tests/unit/out/refcount/friend.rs @@ -18,20 +18,7 @@ pub fn scaled_2(v: Ptr, mut k: i32) -> i32 { pub fn scaled_3(v: Ptr, mut k: f64) -> f64 { return ({ (v.with(|__s| __s.x) as f64) } * { k }); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct V { #[offset(0)] @@ -45,20 +32,7 @@ impl CppEq for V { pub fn get_4(w: Ptr) -> i32 { return w.with(|__s| __s.x); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct W_int_ { #[offset(0)] @@ -67,39 +41,13 @@ pub struct W_int_ { pub fn get_5(w: Ptr) -> i64 { return w.with(|__s| __s.x); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct W_long_ { #[offset(0)] pub x: i64, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct D { #[offset(0)] diff --git a/tests/unit/out/refcount/function_overloading.rs b/tests/unit/out/refcount/function_overloading.rs index 588625513b..f37fe4ffdf 100644 --- a/tests/unit/out/refcount/function_overloading.rs +++ b/tests/unit/out/refcount/function_overloading.rs @@ -21,20 +21,7 @@ pub fn foo_3(mut x: Ptr, mut y: Ptr, z: Ptr) -> i32 { pub fn bar_4(x: Ptr) -> i32 { return (x.read()); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct Foo {} pub fn func_5(mut x: i32) -> i32 { diff --git a/tests/unit/out/refcount/global_call_temporaries.rs b/tests/unit/out/refcount/global_call_temporaries.rs index a64c64c5a2..bc4213a4e8 100644 --- a/tests/unit/out/refcount/global_call_temporaries.rs +++ b/tests/unit/out/refcount/global_call_temporaries.rs @@ -94,20 +94,7 @@ thread_local!( }) })); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Item { #[offset(0)] diff --git a/tests/unit/out/refcount/global_init_side_effect.rs b/tests/unit/out/refcount/global_init_side_effect.rs index 771ffa1bbb..36d7010c2a 100644 --- a/tests/unit/out/refcount/global_init_side_effect.rs +++ b/tests/unit/out/refcount/global_init_side_effect.rs @@ -10,19 +10,7 @@ thread_local!( pub static total_0: Value = Rc::new(RefCell::new(0)); ); #[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, )] #[cpp_from(i32, construct, value)] #[byte_size(1)] diff --git a/tests/unit/out/refcount/global_non_const_init.rs b/tests/unit/out/refcount/global_non_const_init.rs index e7758d6004..6a0e7051cd 100644 --- a/tests/unit/out/refcount/global_non_const_init.rs +++ b/tests/unit/out/refcount/global_non_const_init.rs @@ -32,19 +32,7 @@ thread_local!( pub static depends_on_call_6: Value = Rc::new(RefCell::new((from_call_5.with(|rc| *rc.borrow()) + 1))); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(4)] pub struct Ctor { #[offset(0)] @@ -89,20 +77,7 @@ thread_local!( Rc::try_unwrap(__v).ok().unwrap().into_inner() })); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct Holder {} thread_local!( @@ -121,19 +96,7 @@ thread_local!( Rc::try_unwrap(__v).ok().unwrap().into_inner() })); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(4)] pub struct Singleton { #[offset(0)] diff --git a/tests/unit/out/refcount/global_pointers.rs b/tests/unit/out/refcount/global_pointers.rs index c5df9f51e1..c22c5fdaef 100644 --- a/tests/unit/out/refcount/global_pointers.rs +++ b/tests/unit/out/refcount/global_pointers.rs @@ -6,19 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct Entry { #[offset(0)] diff --git a/tests/unit/out/refcount/global_without_initializer.rs b/tests/unit/out/refcount/global_without_initializer.rs index a671a1ce42..4a0ec06bc3 100644 --- a/tests/unit/out/refcount/global_without_initializer.rs +++ b/tests/unit/out/refcount/global_without_initializer.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/goto_aggregate_default.rs b/tests/unit/out/refcount/goto_aggregate_default.rs index 79ac884a1a..f52b28148b 100644 --- a/tests/unit/out/refcount/goto_aggregate_default.rs +++ b/tests/unit/out/refcount/goto_aggregate_default.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Point { #[offset(0)] diff --git a/tests/unit/out/refcount/goto_cleanup.rs b/tests/unit/out/refcount/goto_cleanup.rs index 4c97fc9bb6..b0a4f649f0 100644 --- a/tests/unit/out/refcount/goto_cleanup.rs +++ b/tests/unit/out/refcount/goto_cleanup.rs @@ -76,19 +76,7 @@ pub fn from_switch_2(mut n: i32) -> i32 { }); panic!("ub: non-void function does not return a value") } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct wrapper { #[offset(0)] diff --git a/tests/unit/out/refcount/huffman.rs b/tests/unit/out/refcount/huffman.rs index fcc396d414..d06efedd84 100644 --- a/tests/unit/out/refcount/huffman.rs +++ b/tests/unit/out/refcount/huffman.rs @@ -6,19 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(24)] pub struct MinHeapNode { #[offset(0)] diff --git a/tests/unit/out/refcount/immutable-deref-on-func-call.rs b/tests/unit/out/refcount/immutable-deref-on-func-call.rs index 7e41439672..8e7778a4cd 100644 --- a/tests/unit/out/refcount/immutable-deref-on-func-call.rs +++ b/tests/unit/out/refcount/immutable-deref-on-func-call.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Item { #[offset(0)] diff --git a/tests/unit/out/refcount/in_class_field_initializer.rs b/tests/unit/out/refcount/in_class_field_initializer.rs index bd20773e93..fc563b7534 100644 --- a/tests/unit/out/refcount/in_class_field_initializer.rs +++ b/tests/unit/out/refcount/in_class_field_initializer.rs @@ -6,19 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(8)] pub struct Inner { #[offset(0)] @@ -31,19 +19,7 @@ impl Default for Inner { { Inner { x: 3, y: 4 } } } } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(24)] pub struct S { #[offset(0)] @@ -69,19 +45,7 @@ impl Default for S { } } } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(8)] pub struct Boxed_int_ { #[offset(0)] diff --git a/tests/unit/out/refcount/init.rs b/tests/unit/out/refcount/init.rs index c18b857a91..dfa79e5525 100644 --- a/tests/unit/out/refcount/init.rs +++ b/tests/unit/out/refcount/init.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct X { #[offset(0)] diff --git a/tests/unit/out/refcount/init_list.rs b/tests/unit/out/refcount/init_list.rs index 87eb1b698e..5d90c0d7d7 100644 --- a/tests/unit/out/refcount/init_list.rs +++ b/tests/unit/out/refcount/init_list.rs @@ -9,20 +9,7 @@ use std::rc::{Rc, Weak}; pub fn f_0(list: Vec) { let list: Value> = Rc::new(RefCell::new(list)); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Pair { #[offset(0)] @@ -30,19 +17,7 @@ pub struct Pair { #[offset(4)] pub b: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(8)] pub struct Holder { #[offset(0)] @@ -61,19 +36,7 @@ impl Default for Holder { pub fn sum_1(p: Ptr) -> i32 { return ({ p.with(|__s| __s.a) } + { p.with(|__s| __s.b) }); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(4)] pub struct Seven { #[offset(0)] diff --git a/tests/unit/out/refcount/kruskal.rs b/tests/unit/out/refcount/kruskal.rs index 0b0138d941..e9eb65658a 100644 --- a/tests/unit/out/refcount/kruskal.rs +++ b/tests/unit/out/refcount/kruskal.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct Edge { #[offset(0)] diff --git a/tests/unit/out/refcount/lambda_as_field.rs b/tests/unit/out/refcount/lambda_as_field.rs index bd696cbf4b..b065f29b68 100644 --- a/tests/unit/out/refcount/lambda_as_field.rs +++ b/tests/unit/out/refcount/lambda_as_field.rs @@ -6,19 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - Destructible, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(1)] pub struct Guard__lambda_at_lambda_as_field_cpp_34_13__ { #[offset(0)] @@ -37,18 +25,7 @@ impl Default for Guard__lambda_at_lambda_as_field_cpp_34_13__ { } } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - Destructible, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, )] #[byte_size(8)] pub struct Guard__lambda_at_lambda_as_field_cpp_45_13__ { @@ -56,18 +33,7 @@ pub struct Guard__lambda_at_lambda_as_field_cpp_45_13__ { #[byte_size(8)] pub f: FnPtr, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(8)] pub struct Holder__lambda_at_lambda_as_field_cpp_39_12__ { #[offset(0)] @@ -90,19 +56,7 @@ impl Default for Holder__lambda_at_lambda_as_field_cpp_39_12__ { } } } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Holder__lambda_at_lambda_as_field_cpp_51_12__ { #[offset(0)] diff --git a/tests/unit/out/refcount/lambda_capture_ref.rs b/tests/unit/out/refcount/lambda_capture_ref.rs index 899d4798f7..822709ca3a 100644 --- a/tests/unit/out/refcount/lambda_capture_ref.rs +++ b/tests/unit/out/refcount/lambda_capture_ref.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/lambda_capture_star_this.rs b/tests/unit/out/refcount/lambda_capture_star_this.rs index 02520ff7d1..419ef201b5 100644 --- a/tests/unit/out/refcount/lambda_capture_star_this.rs +++ b/tests/unit/out/refcount/lambda_capture_star_this.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/lambda_capture_this.rs b/tests/unit/out/refcount/lambda_capture_this.rs index 4480b2a8ec..e8e3f1acb4 100644 --- a/tests/unit/out/refcount/lambda_capture_this.rs +++ b/tests/unit/out/refcount/lambda_capture_this.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/lambda_capture_value.rs b/tests/unit/out/refcount/lambda_capture_value.rs index a3bfd7c3e0..4bf6b69796 100644 --- a/tests/unit/out/refcount/lambda_capture_value.rs +++ b/tests/unit/out/refcount/lambda_capture_value.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/lambda_decltype_type.rs b/tests/unit/out/refcount/lambda_decltype_type.rs index d5648c025f..2174dc0d37 100644 --- a/tests/unit/out/refcount/lambda_decltype_type.rs +++ b/tests/unit/out/refcount/lambda_decltype_type.rs @@ -6,18 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(24)] pub struct Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { #[offset(0)] @@ -45,18 +34,7 @@ impl Default for Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { } } } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(24)] pub struct Sorted__lambda_at_lambda_decltype_type_cpp_19_23__ { #[offset(0)] diff --git a/tests/unit/out/refcount/lambda_generic_explicit_args.rs b/tests/unit/out/refcount/lambda_generic_explicit_args.rs index 22de36f6a7..492948022b 100644 --- a/tests/unit/out/refcount/lambda_generic_explicit_args.rs +++ b/tests/unit/out/refcount/lambda_generic_explicit_args.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Val { #[offset(0)] diff --git a/tests/unit/out/refcount/lambda_immediate_init.rs b/tests/unit/out/refcount/lambda_immediate_init.rs index a61e38ba16..21ea249a7d 100644 --- a/tests/unit/out/refcount/lambda_immediate_init.rs +++ b/tests/unit/out/refcount/lambda_immediate_init.rs @@ -9,19 +9,7 @@ use std::rc::{Rc, Weak}; pub fn pick_0(mut x: i32) -> i32 { return x; } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(8)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/lambda_nested.rs b/tests/unit/out/refcount/lambda_nested.rs index b0138f7796..7af0641263 100644 --- a/tests/unit/out/refcount/lambda_nested.rs +++ b/tests/unit/out/refcount/lambda_nested.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/lambda_static_local.rs b/tests/unit/out/refcount/lambda_static_local.rs index c2aad33903..be19023729 100644 --- a/tests/unit/out/refcount/lambda_static_local.rs +++ b/tests/unit/out/refcount/lambda_static_local.rs @@ -78,20 +78,7 @@ thread_local!( thread_local!( static calls_3: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct P_4 { #[offset(0)] diff --git a/tests/unit/out/refcount/libc_struct_without_default.rs b/tests/unit/out/refcount/libc_struct_without_default.rs index dcecf143ef..4f43e49bf5 100644 --- a/tests/unit/out/refcount/libc_struct_without_default.rs +++ b/tests/unit/out/refcount/libc_struct_without_default.rs @@ -63,18 +63,7 @@ impl Default for UserDefined { } } } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(16)] pub struct FieldIsLibcType { #[offset(0)] diff --git a/tests/unit/out/refcount/linked_list.rs b/tests/unit/out/refcount/linked_list.rs index e027995d7d..4bfdb59e58 100644 --- a/tests/unit/out/refcount/linked_list.rs +++ b/tests/unit/out/refcount/linked_list.rs @@ -6,19 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct Node { #[offset(0)] diff --git a/tests/unit/out/refcount/local_anon_struct_collision.rs b/tests/unit/out/refcount/local_anon_struct_collision.rs index 5b0c181b35..e8293dbd61 100644 --- a/tests/unit/out/refcount/local_anon_struct_collision.rs +++ b/tests/unit/out/refcount/local_anon_struct_collision.rs @@ -12,20 +12,7 @@ pub fn first_0() -> i32 { p.y = 2; return (p.x + p.y); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct anon_1 { #[offset(0)] @@ -39,20 +26,7 @@ pub fn second_2() -> i32 { q.b = 20_i64; return ((q.a + q.b) as i32); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct anon_3 { #[offset(0)] diff --git a/tests/unit/out/refcount/local_record_template.rs b/tests/unit/out/refcount/local_record_template.rs index f0695353b4..8a9e2dab20 100644 --- a/tests/unit/out/refcount/local_record_template.rs +++ b/tests/unit/out/refcount/local_record_template.rs @@ -29,39 +29,13 @@ pub fn wrap_10(mut v: i64) -> i32 { let mut l: Local_7 = Local_7 { x: v }; return ({ get_6(l) }); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Local_5 { #[offset(0)] pub x: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Local_7 { #[offset(0)] @@ -71,20 +45,7 @@ pub fn other_11() -> i32 { let mut l: Local_1 = Local_1 { x: 3_i64, y: 4_i64 }; return (({ get_0(l) }) + (l.y as i32)); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct Local_1 { #[offset(0)] @@ -105,20 +66,7 @@ fn main_0() -> i32 { assert!((({ wrap_10(6_i64,) }) == 6)); return 0; } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Local_3 { #[offset(0)] diff --git a/tests/unit/out/refcount/map.rs b/tests/unit/out/refcount/map.rs index e2f8bd6f6d..16636ffb66 100644 --- a/tests/unit/out/refcount/map.rs +++ b/tests/unit/out/refcount/map.rs @@ -12,19 +12,7 @@ pub fn foo_0(mut x: u32) { pub fn bar_1(x: Ptr) { x.write((x.read()).wrapping_add(1_u32)); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(8)] pub struct Point { #[offset(0)] diff --git a/tests/unit/out/refcount/map_key_identity.rs b/tests/unit/out/refcount/map_key_identity.rs index 02258d964d..1c4806b26d 100644 --- a/tests/unit/out/refcount/map_key_identity.rs +++ b/tests/unit/out/refcount/map_key_identity.rs @@ -9,20 +9,7 @@ use std::rc::{Rc, Weak}; thread_local!( pub static default_constructions_0: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Key { #[offset(0)] @@ -46,19 +33,7 @@ pub fn operator_lt_1(a: Ptr, b: Ptr) -> bool { pub fn operator_eq_2(a: Ptr, b: Ptr) -> bool { return ({ a.with(|__s| __s.identity) } == { b.with(|__s| __s.identity) }); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(4)] pub struct Mapped { #[offset(0)] diff --git a/tests/unit/out/refcount/map_try_emplace.rs b/tests/unit/out/refcount/map_try_emplace.rs index 161cd1bac8..a8d53a87a9 100644 --- a/tests/unit/out/refcount/map_try_emplace.rs +++ b/tests/unit/out/refcount/map_try_emplace.rs @@ -65,19 +65,7 @@ pub fn argument_4(item: Ptr) -> Ptr { (*calls_0.with(Value::clone).borrow_mut()).prefix_inc(); return (item).clone(); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(4)] pub struct RefItem { #[offset(0)] diff --git a/tests/unit/out/refcount/map_try_emplace_lvalues.rs b/tests/unit/out/refcount/map_try_emplace_lvalues.rs index e976b7b744..bd512e532c 100644 --- a/tests/unit/out/refcount/map_try_emplace_lvalues.rs +++ b/tests/unit/out/refcount/map_try_emplace_lvalues.rs @@ -12,19 +12,7 @@ thread_local!( thread_local!( pub static visits_1: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(4)] pub struct Item { #[offset(0)] @@ -54,18 +42,7 @@ pub fn place_3(n: Ptr) -> Ptr { thread_local!( pub static temporary_calls_4: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(12)] pub struct Temporary { #[offset(0)] @@ -86,19 +63,7 @@ impl Default for Temporary { } } } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(12)] pub struct Nested { #[offset(0)] @@ -158,19 +123,7 @@ impl Default for Noncopy { { Noncopy { n: 5 } } } } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable)] #[cpp_from(i32, construct_1, ptr)] #[byte_size(8)] pub struct Held { diff --git a/tests/unit/out/refcount/memcpy_struct_bytes.rs b/tests/unit/out/refcount/memcpy_struct_bytes.rs index 4772b3faa1..46d437bba3 100644 --- a/tests/unit/out/refcount/memcpy_struct_bytes.rs +++ b/tests/unit/out/refcount/memcpy_struct_bytes.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct point { #[offset(0)] diff --git a/tests/unit/out/refcount/memcpy_struct_layouts.rs b/tests/unit/out/refcount/memcpy_struct_layouts.rs index 8a6d5a2ac8..f0c1557b78 100644 --- a/tests/unit/out/refcount/memcpy_struct_layouts.rs +++ b/tests/unit/out/refcount/memcpy_struct_layouts.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct packed { #[offset(0)] @@ -31,20 +18,7 @@ pub struct packed { #[offset(6)] pub d: i16, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(12)] pub struct reordered { #[offset(0)] @@ -54,20 +28,7 @@ pub struct reordered { #[offset(8)] pub c: i8, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct tail { #[offset(0)] @@ -75,20 +36,7 @@ pub struct tail { #[offset(8)] pub b: f64, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(24)] pub struct nested { #[offset(0)] @@ -97,18 +45,7 @@ pub struct nested { #[offset(16)] pub c: i8, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(8)] pub struct array { #[offset(0)] diff --git a/tests/unit/out/refcount/memcpy_struct_struct.rs b/tests/unit/out/refcount/memcpy_struct_struct.rs index 413286fe0b..f7755f6d7e 100644 --- a/tests/unit/out/refcount/memcpy_struct_struct.rs +++ b/tests/unit/out/refcount/memcpy_struct_struct.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Entry { #[offset(0)] diff --git a/tests/unit/out/refcount/memset_struct_tail.rs b/tests/unit/out/refcount/memset_struct_tail.rs index 625af5d21b..3fe22a8794 100644 --- a/tests/unit/out/refcount/memset_struct_tail.rs +++ b/tests/unit/out/refcount/memset_struct_tail.rs @@ -6,18 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(32)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/nested_structs.rs b/tests/unit/out/refcount/nested_structs.rs index 43e3f935c2..25772e1e11 100644 --- a/tests/unit/out/refcount/nested_structs.rs +++ b/tests/unit/out/refcount/nested_structs.rs @@ -6,39 +6,13 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Level0_Level1_1_Level2_1_Level3_1 { #[offset(0)] pub x1: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Level0_Level1_1_Level2_1_Level3_2 { #[offset(0)] @@ -46,58 +20,19 @@ pub struct Level0_Level1_1_Level2_1_Level3_2 { #[offset(4)] pub x2: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Level0_Level1_1_Level2_1 { #[offset(0)] pub x1: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Level0_Level1_1 { #[offset(0)] pub x1: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Level0_Level1_2 { #[offset(0)] @@ -105,20 +40,7 @@ pub struct Level0_Level1_2 { #[offset(4)] pub x2: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct Level0 {} pub fn main() { diff --git a/tests/unit/out/refcount/new.rs b/tests/unit/out/refcount/new.rs index 36c83b4eab..b3ed2b3137 100644 --- a/tests/unit/out/refcount/new.rs +++ b/tests/unit/out/refcount/new.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Pair { #[offset(0)] diff --git a/tests/unit/out/refcount/new_bst.rs b/tests/unit/out/refcount/new_bst.rs index 26328c6bac..7f599d18c1 100644 --- a/tests/unit/out/refcount/new_bst.rs +++ b/tests/unit/out/refcount/new_bst.rs @@ -6,19 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(24)] pub struct node_t { #[offset(0)] diff --git a/tests/unit/out/refcount/new_struct.rs b/tests/unit/out/refcount/new_struct.rs index b78a9f3bad..07c06ee90a 100644 --- a/tests/unit/out/refcount/new_struct.rs +++ b/tests/unit/out/refcount/new_struct.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Pair { #[offset(0)] @@ -27,20 +14,7 @@ pub struct Pair { #[offset(4)] pub y: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct Triple { #[offset(0)] diff --git a/tests/unit/out/refcount/nttp_distinct_specializations.rs b/tests/unit/out/refcount/nttp_distinct_specializations.rs index a850b560b7..ba84d59bcb 100644 --- a/tests/unit/out/refcount/nttp_distinct_specializations.rs +++ b/tests/unit/out/refcount/nttp_distinct_specializations.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct S_2_ { #[offset(0)] @@ -27,39 +14,13 @@ pub struct S_2_ { #[offset(4)] pub w: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct S_1_ { #[offset(0)] pub v: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct S_3_ { #[offset(0)] diff --git a/tests/unit/out/refcount/offsetof.rs b/tests/unit/out/refcount/offsetof.rs index cde6a6d77d..e15b51c545 100644 --- a/tests/unit/out/refcount/offsetof.rs +++ b/tests/unit/out/refcount/offsetof.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(12)] pub struct Layout { #[offset(0)] @@ -29,18 +16,7 @@ pub struct Layout { #[offset(8)] pub c: u16, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(66)] pub struct Frame { #[offset(0)] diff --git a/tests/unit/out/refcount/opaque_forward_decl.rs b/tests/unit/out/refcount/opaque_forward_decl.rs index 5031ac50a8..6d98671f7c 100644 --- a/tests/unit/out/refcount/opaque_forward_decl.rs +++ b/tests/unit/out/refcount/opaque_forward_decl.rs @@ -6,19 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct container { #[offset(0)] diff --git a/tests/unit/out/refcount/opaque_record_copy.rs b/tests/unit/out/refcount/opaque_record_copy.rs index 725a1103e4..582ae62cd0 100644 --- a/tests/unit/out/refcount/opaque_record_copy.rs +++ b/tests/unit/out/refcount/opaque_record_copy.rs @@ -6,36 +6,10 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct Probe {} -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Wrapper_Probe_ { #[offset(0)] diff --git a/tests/unit/out/refcount/opaque_then_defined.rs b/tests/unit/out/refcount/opaque_then_defined.rs index b690b0bd63..cc73a24de7 100644 --- a/tests/unit/out/refcount/opaque_then_defined.rs +++ b/tests/unit/out/refcount/opaque_then_defined.rs @@ -6,19 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct list { #[offset(0)] @@ -27,19 +15,7 @@ pub struct list { #[offset(8)] pub size: i32, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct node { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_arithmetic_free.rs b/tests/unit/out/refcount/operator_arithmetic_free.rs index 4a96a06525..ac76f23327 100644 --- a/tests/unit/out/refcount/operator_arithmetic_free.rs +++ b/tests/unit/out/refcount/operator_arithmetic_free.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_arithmetic_member.rs b/tests/unit/out/refcount/operator_arithmetic_member.rs index 954ca4fd1b..7ef07f17a9 100644 --- a/tests/unit/out/refcount/operator_arithmetic_member.rs +++ b/tests/unit/out/refcount/operator_arithmetic_member.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_bitwise_free.rs b/tests/unit/out/refcount/operator_bitwise_free.rs index 8b92780cba..98fb3a69fd 100644 --- a/tests/unit/out/refcount/operator_bitwise_free.rs +++ b/tests/unit/out/refcount/operator_bitwise_free.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_bitwise_member.rs b/tests/unit/out/refcount/operator_bitwise_member.rs index 9d4779b2cf..ddf3703aa6 100644 --- a/tests/unit/out/refcount/operator_bitwise_member.rs +++ b/tests/unit/out/refcount/operator_bitwise_member.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_comparison_defaulted.rs b/tests/unit/out/refcount/operator_comparison_defaulted.rs index b48db17cdf..255d63070b 100644 --- a/tests/unit/out/refcount/operator_comparison_defaulted.rs +++ b/tests/unit/out/refcount/operator_comparison_defaulted.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Eq { #[offset(0)] @@ -32,20 +19,7 @@ impl CppEq for Eq { EqImpl::operator_eq(__lhs, __rhs.clone()) } } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Cmp { #[offset(0)] @@ -63,20 +37,7 @@ impl CppEq for Cmp { CmpImpl::operator_cmp(__lhs, __rhs.clone()) == std::cmp::Ordering::Equal } } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Both { #[offset(0)] @@ -92,20 +53,7 @@ impl CppEq for Both { BothImpl::operator_eq(__lhs, __rhs.clone()) } } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct OrdOnly { #[offset(0)] @@ -121,20 +69,7 @@ impl CppEq for OrdOnly { OrdOnlyImpl::operator_cmp(__lhs, __rhs.clone()) == std::cmp::Ordering::Equal } } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Inner { #[offset(0)] @@ -150,20 +85,7 @@ impl CppEq for Inner { InnerImpl::operator_cmp(__lhs, __rhs.clone()) == std::cmp::Ordering::Equal } } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Outer { #[offset(0)] @@ -182,20 +104,7 @@ impl CppEq for Outer { OuterImpl::operator_cmp(__lhs, __rhs.clone()) == std::cmp::Ordering::Equal } } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Secondary { #[offset(0)] @@ -211,19 +120,7 @@ impl CppEq for Secondary { SecondaryImpl::operator_eq(__lhs, __rhs.clone()) } } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct PtrMember { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_comparison_free.rs b/tests/unit/out/refcount/operator_comparison_free.rs index 5003d6c2d8..88031e2d09 100644 --- a/tests/unit/out/refcount/operator_comparison_free.rs +++ b/tests/unit/out/refcount/operator_comparison_free.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct S { #[offset(0)] @@ -59,20 +46,7 @@ pub fn operator_lt_6(a: Ptr, mut b: i32) -> bool { pub fn operator_lt_7(mut a: i32, b: Ptr) -> bool { return ({ a } < { b.with(|__s| __s.v) }); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct V { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_comparison_member.rs b/tests/unit/out/refcount/operator_comparison_member.rs index 074ebcb451..bf7d127387 100644 --- a/tests/unit/out/refcount/operator_comparison_member.rs +++ b/tests/unit/out/refcount/operator_comparison_member.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_comparison_mixed.rs b/tests/unit/out/refcount/operator_comparison_mixed.rs index 9cd74978db..223a953ab9 100644 --- a/tests/unit/out/refcount/operator_comparison_mixed.rs +++ b/tests/unit/out/refcount/operator_comparison_mixed.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_comparison_nonbool.rs b/tests/unit/out/refcount/operator_comparison_nonbool.rs index fd225343c3..2089962407 100644 --- a/tests/unit/out/refcount/operator_comparison_nonbool.rs +++ b/tests/unit/out/refcount/operator_comparison_nonbool.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct X { #[offset(0)] @@ -53,58 +40,19 @@ pub fn operator_le_4(mut a: X, mut b: X) -> i32 { pub fn operator_ge_5(mut a: X, mut b: X) -> i32 { return if (a.v >= b.v) { 7 } else { 0 }; } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Result { #[offset(0)] pub r: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Custom { #[offset(0)] pub v: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Mixed { #[offset(0)] @@ -121,19 +69,7 @@ impl CppEq for Mixed { } } #[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, )] #[cpp_into(bool, to_bool)] #[byte_size(1)] @@ -141,20 +77,7 @@ pub struct MyBool { #[offset(0)] pub value: bool, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Boolish { #[offset(0)] @@ -204,20 +127,7 @@ thread_local!( Rc::try_unwrap(__v).ok().unwrap().into_inner() })); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct RefInt { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_compound_assignment_free.rs b/tests/unit/out/refcount/operator_compound_assignment_free.rs index 5261bedcbf..bc0b01c00e 100644 --- a/tests/unit/out/refcount/operator_compound_assignment_free.rs +++ b/tests/unit/out/refcount/operator_compound_assignment_free.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_compound_assignment_member.rs b/tests/unit/out/refcount/operator_compound_assignment_member.rs index dba4e0ee85..9ca22ec6e9 100644 --- a/tests/unit/out/refcount/operator_compound_assignment_member.rs +++ b/tests/unit/out/refcount/operator_compound_assignment_member.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_friend.rs b/tests/unit/out/refcount/operator_friend.rs index 9c45d054bb..415a566ce9 100644 --- a/tests/unit/out/refcount/operator_friend.rs +++ b/tests/unit/out/refcount/operator_friend.rs @@ -10,20 +10,7 @@ pub fn operator_eq_0(_a0: Ptr, _a1: Ptr) -> bool { return ({ _a0.with(|__s| __s.a) } == { _a1.with(|__s| __s.a) }) && ({ _a0.with(|__s| __s.b) } == { _a1.with(|__s| __s.b) }); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Defaulted { #[offset(0)] @@ -51,20 +38,7 @@ pub fn operator_cmp_1(_a0: Ptr, _a1: Ptr) -> std::cm pub fn operator_eq_2(_a0: Ptr, _a1: Ptr) -> bool { return ({ _a0.with(|__s| __s.a) } == { _a1.with(|__s| __s.a) }); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct DefaultedOrd { #[offset(0)] @@ -91,20 +65,7 @@ pub fn operator_add_5(x: Ptr, y: Ptr) -> Inline { a: ({ x.with(|__s| __s.a) } + { y.with(|__s| __s.a) }), }; } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Inline { #[offset(0)] @@ -120,20 +81,7 @@ impl CppEq for Inline { operator_eq_3(__lhs.clone(), __rhs.clone()) } } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct OutOfLine { #[offset(0)] @@ -159,20 +107,7 @@ pub fn operator_lt_9(x: Ptr, y: Ptr) -> bool { pub fn operator_eq_10(x: Ptr, y: Ptr) -> bool { return ({ (x.with(|__s| __s.v) as i64) } == { y.with(|__s| __s.v) }); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Tmpl_int_ { #[offset(0)] @@ -188,20 +123,7 @@ impl CppEq for Tmpl_int_ { operator_eq_8(__lhs.clone(), __rhs.clone()) } } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Tmpl_long_ { #[offset(0)] @@ -210,20 +132,7 @@ pub struct Tmpl_long_ { pub fn operator_eq_11(_a0: Ptr, _a1: Ptr) -> bool { return ({ _a0.with(|__s| __s.v) } == { _a1.with(|__s| __s.v) }); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct TmplDefaulted_int_ { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_less_than.rs b/tests/unit/out/refcount/operator_less_than.rs index 5f7820506b..8855ee962f 100644 --- a/tests/unit/out/refcount/operator_less_than.rs +++ b/tests/unit/out/refcount/operator_less_than.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Pair { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_logical_free.rs b/tests/unit/out/refcount/operator_logical_free.rs index 98eb00a2a9..17b37fd64b 100644 --- a/tests/unit/out/refcount/operator_logical_free.rs +++ b/tests/unit/out/refcount/operator_logical_free.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_logical_member.rs b/tests/unit/out/refcount/operator_logical_member.rs index 9fb2f52bda..e648cb7fb6 100644 --- a/tests/unit/out/refcount/operator_logical_member.rs +++ b/tests/unit/out/refcount/operator_logical_member.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_member_pointer_free.rs b/tests/unit/out/refcount/operator_member_pointer_free.rs index 5536472703..d87578ecb9 100644 --- a/tests/unit/out/refcount/operator_member_pointer_free.rs +++ b/tests/unit/out/refcount/operator_member_pointer_free.rs @@ -6,37 +6,13 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Inner { #[offset(0)] pub x: i32, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(16)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_member_pointer_member.rs b/tests/unit/out/refcount/operator_member_pointer_member.rs index 3af4543655..1e85a8e90f 100644 --- a/tests/unit/out/refcount/operator_member_pointer_member.rs +++ b/tests/unit/out/refcount/operator_member_pointer_member.rs @@ -6,39 +6,13 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Inner { #[offset(0)] pub x: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct Table {} impl Table { @@ -49,18 +23,7 @@ impl Table { thread_local!( pub static table_0: Value> = Rc::new(RefCell::new(Box::new([7, 8, 9]))); ); -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(16)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_other_free.rs b/tests/unit/out/refcount/operator_other_free.rs index 0373f26a7a..e03adf9161 100644 --- a/tests/unit/out/refcount/operator_other_free.rs +++ b/tests/unit/out/refcount/operator_other_free.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_other_member.rs b/tests/unit/out/refcount/operator_other_member.rs index f7713d73fc..03269a4298 100644 --- a/tests/unit/out/refcount/operator_other_member.rs +++ b/tests/unit/out/refcount/operator_other_member.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct Static {} impl Static { @@ -28,19 +15,7 @@ impl Static { } } #[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, )] #[cpp_into(i32, to_i32)] #[byte_size(4)] diff --git a/tests/unit/out/refcount/operator_overloads.rs b/tests/unit/out/refcount/operator_overloads.rs index a363686ead..de5e30139e 100644 --- a/tests/unit/out/refcount/operator_overloads.rs +++ b/tests/unit/out/refcount/operator_overloads.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_qualifiers.rs b/tests/unit/out/refcount/operator_qualifiers.rs index 6a62ff4a20..363da1beb3 100644 --- a/tests/unit/out/refcount/operator_qualifiers.rs +++ b/tests/unit/out/refcount/operator_qualifiers.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_three_way.rs b/tests/unit/out/refcount/operator_three_way.rs index 3bafe107d9..d297d888bc 100644 --- a/tests/unit/out/refcount/operator_three_way.rs +++ b/tests/unit/out/refcount/operator_three_way.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_traits.rs b/tests/unit/out/refcount/operator_traits.rs index 8063037cdb..3559c0352f 100644 --- a/tests/unit/out/refcount/operator_traits.rs +++ b/tests/unit/out/refcount/operator_traits.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Lt { #[offset(0)] @@ -35,20 +22,7 @@ impl CppEq for Lt { !(LtImpl::operator_lt(__lhs, __rhs.clone())) && !(LtImpl::operator_lt(__rhs, __lhs.clone())) } } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Eq { #[offset(0)] @@ -59,20 +33,7 @@ impl CppEq for Eq { EqImpl::operator_eq(__lhs, __rhs.clone()) } } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Cmp { #[offset(0)] @@ -88,20 +49,7 @@ impl CppEq for Cmp { CmpImpl::operator_eq(__lhs, __rhs.clone()) } } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Free { #[offset(0)] @@ -123,20 +71,7 @@ pub fn operator_lt_0(a: Ptr, b: Ptr) -> bool { pub fn operator_eq_1(a: Ptr, b: Ptr) -> bool { return ({ a.with(|__s| __s.v) } == { b.with(|__s| __s.v) }); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Wrapped_int_ { #[offset(0)] diff --git a/tests/unit/out/refcount/overload_mangling.rs b/tests/unit/out/refcount/overload_mangling.rs index 2273b84403..884fb41d4b 100644 --- a/tests/unit/out/refcount/overload_mangling.rs +++ b/tests/unit/out/refcount/overload_mangling.rs @@ -19,55 +19,16 @@ pub fn add_1(mut p: Ptr, mut n: i32) { pub fn twice_2(mut n: i32) -> i32 { return (n * 2); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct Access_S_ {} -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct S { #[offset(0)] pub base: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Box_ { #[offset(0)] diff --git a/tests/unit/out/refcount/pair_converting_construction.rs b/tests/unit/out/refcount/pair_converting_construction.rs index 7326756827..ede9e4b4cf 100644 --- a/tests/unit/out/refcount/pair_converting_construction.rs +++ b/tests/unit/out/refcount/pair_converting_construction.rs @@ -7,19 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, )] #[cpp_from(i32, construct, value)] #[byte_size(4)] @@ -28,19 +16,7 @@ pub struct Celsius { pub degrees: i32, } #[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, )] #[cpp_into(i32, to_i32)] #[byte_size(4)] @@ -49,19 +25,7 @@ pub struct Meters { pub value: i32, } #[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, )] #[cpp_from(Celsius, construct, ptr)] #[byte_size(4)] @@ -70,19 +34,7 @@ pub struct Label { pub id: i32, } #[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, )] #[cpp_from(Celsius, construct_1, ptr)] #[cpp_from_move(Celsius, construct_2, ptr)] @@ -94,19 +46,7 @@ pub struct Owner { pub copied: i32, } #[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, )] #[cpp_from(Celsius, construct, value)] #[byte_size(4)] @@ -114,20 +54,7 @@ pub struct Holder { #[offset(0)] pub value: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct Fallback { @@ -145,39 +72,14 @@ impl Default for Fallback { } } } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Counter { #[offset(0)] pub hits: i32, } #[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, )] #[cpp_from(Counter, construct, mut_ptr)] #[byte_size(4)] @@ -186,19 +88,7 @@ pub struct Observer { pub seen: i32, } #[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, )] #[cpp_from(Celsius, construct, ptr)] #[byte_size(4)] @@ -207,19 +97,7 @@ pub struct Tag { pub code: i32, } #[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, )] #[cpp_from(Ptr< i8 > , construct, value)] #[byte_size(4)] diff --git a/tests/unit/out/refcount/pod.rs b/tests/unit/out/refcount/pod.rs index 23f5e50ee3..f4965c8e34 100644 --- a/tests/unit/out/refcount/pod.rs +++ b/tests/unit/out/refcount/pod.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(12)] pub struct POD { #[offset(0)] diff --git a/tests/unit/out/refcount/pointer_array.rs b/tests/unit/out/refcount/pointer_array.rs index 0273af457c..229ca5e981 100644 --- a/tests/unit/out/refcount/pointer_array.rs +++ b/tests/unit/out/refcount/pointer_array.rs @@ -6,18 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(24)] pub struct StackArray { #[offset(0)] diff --git a/tests/unit/out/refcount/pointers.rs b/tests/unit/out/refcount/pointers.rs index 24bba58442..fec0a64206 100644 --- a/tests/unit/out/refcount/pointers.rs +++ b/tests/unit/out/refcount/pointers.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Test { #[offset(0)] diff --git a/tests/unit/out/refcount/polymorphism.rs b/tests/unit/out/refcount/polymorphism.rs index 1b4a4188a3..a4e8c874de 100644 --- a/tests/unit/out/refcount/polymorphism.rs +++ b/tests/unit/out/refcount/polymorphism.rs @@ -9,36 +9,10 @@ use std::rc::{Rc, Weak}; pub trait Animal { fn bark(&self) -> bool; } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Dog {} -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Cat {} pub fn main() { diff --git a/tests/unit/out/refcount/ptr_cast_init.rs b/tests/unit/out/refcount/ptr_cast_init.rs index 7ec3cb2ed4..fefcae70b3 100644 --- a/tests/unit/out/refcount/ptr_cast_init.rs +++ b/tests/unit/out/refcount/ptr_cast_init.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct header { #[offset(0)] @@ -27,20 +14,7 @@ pub struct header { #[offset(4)] pub size: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct view { #[offset(0)] diff --git a/tests/unit/out/refcount/push_emplace_back.rs b/tests/unit/out/refcount/push_emplace_back.rs index 50362c4314..e02afffab9 100644 --- a/tests/unit/out/refcount/push_emplace_back.rs +++ b/tests/unit/out/refcount/push_emplace_back.rs @@ -6,38 +6,13 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Chunk { #[offset(0)] pub data: i32, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct Writer { #[offset(0)] @@ -158,20 +133,7 @@ pub fn self_ref_push_6(mut comps: Ptr>) { comps.with_mut(|__v: &mut Vec| __v.push(a0_clone)) }; } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable)] #[cpp_from(i32, construct_1, value)] #[byte_size(8)] pub struct Pair { @@ -402,18 +364,7 @@ pub fn emplace_from_element_14(mut v: Ptr>>) { v.with_mut(|__v: &mut Vec>| __v.push(__tmp_15)); }; } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(24)] pub struct Plain { #[offset(0)] @@ -446,20 +397,7 @@ thread_local!( pub static all_counted_16: Value>> = Rc::new(RefCell::new(Ptr::>::null())); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Counted { #[offset(0)] diff --git a/tests/unit/out/refcount/random.rs b/tests/unit/out/refcount/random.rs index bc71a9a03a..771ff49e92 100644 --- a/tests/unit/out/refcount/random.rs +++ b/tests/unit/out/refcount/random.rs @@ -6,18 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(72)] pub struct Pair { #[offset(0)] @@ -62,20 +51,7 @@ impl Default for Pair { pub fn zero_0() -> i32 { return 0; } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct X1 {} pub fn foo_1(mut x1: i32, x2: Ptr, mut x3: Ptr, p2: Ptr, mut p3: Ptr) {} diff --git a/tests/unit/out/refcount/reference_wrapper.rs b/tests/unit/out/refcount/reference_wrapper.rs index 740d028c37..eb1b3f6726 100644 --- a/tests/unit/out/refcount/reference_wrapper.rs +++ b/tests/unit/out/refcount/reference_wrapper.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Point { #[offset(0)] diff --git a/tests/unit/out/refcount/references.rs b/tests/unit/out/refcount/references.rs index c3428f7a2e..ce04a50816 100644 --- a/tests/unit/out/refcount/references.rs +++ b/tests/unit/out/refcount/references.rs @@ -6,18 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(16)] pub struct Pair { #[offset(0)] @@ -40,19 +29,7 @@ impl Default for Pair { } } } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct Nested { #[offset(0)] diff --git a/tests/unit/out/refcount/refs_as_args.rs b/tests/unit/out/refcount/refs_as_args.rs index d2c12bac93..622077c6ae 100644 --- a/tests/unit/out/refcount/refs_as_args.rs +++ b/tests/unit/out/refcount/refs_as_args.rs @@ -30,20 +30,7 @@ pub fn more_refs_0(x1: i32, x2: i32, r1: Ptr, r2: Ptr) { }; r1.write((rx2.read())); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Val { #[offset(0)] diff --git a/tests/unit/out/refcount/reinterpret_cast_ptr_cmp.rs b/tests/unit/out/refcount/reinterpret_cast_ptr_cmp.rs index 96edfc8562..2c4c8b88e2 100644 --- a/tests/unit/out/refcount/reinterpret_cast_ptr_cmp.rs +++ b/tests/unit/out/refcount/reinterpret_cast_ptr_cmp.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct S { #[offset(0)] @@ -27,18 +14,7 @@ pub struct S { #[offset(4)] pub y: i32, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(28)] pub struct W { #[offset(0)] @@ -58,18 +34,7 @@ impl Default for W { } } } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(32)] pub struct P { #[offset(0)] diff --git a/tests/unit/out/refcount/reinterpret_cast_struct.rs b/tests/unit/out/refcount/reinterpret_cast_struct.rs index 969bf1b61f..294f2de046 100644 --- a/tests/unit/out/refcount/reinterpret_cast_struct.rs +++ b/tests/unit/out/refcount/reinterpret_cast_struct.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Point { #[offset(0)] diff --git a/tests/unit/out/refcount/reinterpret_cast_struct_to_struct.rs b/tests/unit/out/refcount/reinterpret_cast_struct_to_struct.rs index 8e3f0aa6fa..f4c6f98c50 100644 --- a/tests/unit/out/refcount/reinterpret_cast_struct_to_struct.rs +++ b/tests/unit/out/refcount/reinterpret_cast_struct_to_struct.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Point { #[offset(0)] @@ -27,20 +14,7 @@ pub struct Point { #[offset(4)] pub y: u32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Pair { #[offset(0)] diff --git a/tests/unit/out/refcount/reserved_keywords.rs b/tests/unit/out/refcount/reserved_keywords.rs index 9290260779..5eaf9015dd 100644 --- a/tests/unit/out/refcount/reserved_keywords.rs +++ b/tests/unit/out/refcount/reserved_keywords.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(152)] pub struct S { #[offset(0)] @@ -99,39 +86,13 @@ pub struct S { #[offset(148)] pub vec_: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct type_ { #[offset(0)] pub v: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct loop_ { #[offset(0)] diff --git a/tests/unit/out/refcount/return_move.rs b/tests/unit/out/refcount/return_move.rs index 64a1adceeb..89d308e9c1 100644 --- a/tests/unit/out/refcount/return_move.rs +++ b/tests/unit/out/refcount/return_move.rs @@ -6,19 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct node { #[offset(0)] @@ -27,19 +15,7 @@ pub struct node { #[byte_size(8)] pub next: Ptr, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct pair_t { #[offset(0)] diff --git a/tests/unit/out/refcount/rvalue_struct.rs b/tests/unit/out/refcount/rvalue_struct.rs index 1a3fe64d2e..cae6d63f58 100644 --- a/tests/unit/out/refcount/rvalue_struct.rs +++ b/tests/unit/out/refcount/rvalue_struct.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/scalar_builtin_construct_destruct.rs b/tests/unit/out/refcount/scalar_builtin_construct_destruct.rs index 155b7bcd9c..5c66392ca3 100644 --- a/tests/unit/out/refcount/scalar_builtin_construct_destruct.rs +++ b/tests/unit/out/refcount/scalar_builtin_construct_destruct.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Pod { #[offset(0)] diff --git a/tests/unit/out/refcount/self_referencing_initializer.rs b/tests/unit/out/refcount/self_referencing_initializer.rs index 1dddcfe426..d4a60f4798 100644 --- a/tests/unit/out/refcount/self_referencing_initializer.rs +++ b/tests/unit/out/refcount/self_referencing_initializer.rs @@ -6,38 +6,14 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct list_head { #[offset(0)] #[byte_size(8)] pub next: Ptr, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct node { #[offset(0)] @@ -46,18 +22,7 @@ pub struct node { #[byte_size(8)] pub value_ptr: Ptr, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(16)] pub struct node_with_defaults { #[offset(0)] diff --git a/tests/unit/out/refcount/size_t_static_member.rs b/tests/unit/out/refcount/size_t_static_member.rs index 7e781b899f..7c5e1d52b7 100644 --- a/tests/unit/out/refcount/size_t_static_member.rs +++ b/tests/unit/out/refcount/size_t_static_member.rs @@ -9,39 +9,13 @@ use std::rc::{Rc, Weak}; thread_local!( pub static c_0: Value = Rc::new(RefCell::new(5_usize)); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct S {} thread_local!( pub static table_size_1: Value = Rc::new(RefCell::new(256_usize)); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct Table_char_ {} pub fn main() { diff --git a/tests/unit/out/refcount/size_t_template_param.rs b/tests/unit/out/refcount/size_t_template_param.rs index 76db83e3c6..d17cae2aab 100644 --- a/tests/unit/out/refcount/size_t_template_param.rs +++ b/tests/unit/out/refcount/size_t_template_param.rs @@ -11,19 +11,7 @@ pub fn array_ref_0(a: Ptr) -> u64 { return (elem!(a, (3_u64 as u64).wrapping_sub(1_u64)).read()); } #[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, )] #[cpp_from(Ptr< u64 > , construct, value)] #[byte_size(8)] @@ -32,19 +20,7 @@ pub struct PtrCtor_unsigned_long_ { pub v: u64, } #[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, )] #[cpp_from(u64, construct, ptr)] #[byte_size(8)] diff --git a/tests/unit/out/refcount/static_local.rs b/tests/unit/out/refcount/static_local.rs index c723620116..4501711810 100644 --- a/tests/unit/out/refcount/static_local.rs +++ b/tests/unit/out/refcount/static_local.rs @@ -33,20 +33,7 @@ pub fn from_local_class_6() -> i32 { thread_local!( static x_7: Value = Rc::new(RefCell::new(3)); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct S_8 {} pub fn main() { diff --git a/tests/unit/out/refcount/static_var_in_class.rs b/tests/unit/out/refcount/static_var_in_class.rs index 2801efac3b..ffc512cf90 100644 --- a/tests/unit/out/refcount/static_var_in_class.rs +++ b/tests/unit/out/refcount/static_var_in_class.rs @@ -9,20 +9,7 @@ use std::rc::{Rc, Weak}; thread_local!( static inner_const_0: Value = Rc::new(RefCell::new(1)); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct C {} thread_local!( @@ -30,20 +17,7 @@ thread_local!( ); pub type anon_3 = u32; pub const anon_3_kValue: anon_3 = 3; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct S {} impl S { diff --git a/tests/unit/out/refcount/stdcopy.rs b/tests/unit/out/refcount/stdcopy.rs index 37ad502264..9dbccf6d00 100644 --- a/tests/unit/out/refcount/stdcopy.rs +++ b/tests/unit/out/refcount/stdcopy.rs @@ -7,19 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, )] #[cpp_from(i32, construct, value)] #[byte_size(4)] diff --git a/tests/unit/out/refcount/strdup.rs b/tests/unit/out/refcount/strdup.rs index 29bb66ec9e..7caf4818ea 100644 --- a/tests/unit/out/refcount/strdup.rs +++ b/tests/unit/out/refcount/strdup.rs @@ -6,19 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct record { #[offset(0)] diff --git a/tests/unit/out/refcount/string_literal_ptr_init.rs b/tests/unit/out/refcount/string_literal_ptr_init.rs index 6421fb52fa..3b4142ca28 100644 --- a/tests/unit/out/refcount/string_literal_ptr_init.rs +++ b/tests/unit/out/refcount/string_literal_ptr_init.rs @@ -6,19 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(24)] pub struct label { #[offset(0)] diff --git a/tests/unit/out/refcount/string_substr.rs b/tests/unit/out/refcount/string_substr.rs index b2873d4c4f..11850d446c 100644 --- a/tests/unit/out/refcount/string_substr.rs +++ b/tests/unit/out/refcount/string_substr.rs @@ -6,19 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Text { #[offset(0)] diff --git a/tests/unit/out/refcount/struct_2d_array_field.rs b/tests/unit/out/refcount/struct_2d_array_field.rs index dc55374db6..3d1f30235f 100644 --- a/tests/unit/out/refcount/struct_2d_array_field.rs +++ b/tests/unit/out/refcount/struct_2d_array_field.rs @@ -6,18 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(40)] pub struct table { #[offset(0)] diff --git a/tests/unit/out/refcount/struct_ctor.rs b/tests/unit/out/refcount/struct_ctor.rs index 954baef67d..1170386126 100644 --- a/tests/unit/out/refcount/struct_ctor.rs +++ b/tests/unit/out/refcount/struct_ctor.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct StructWithCtor { #[offset(0)] @@ -31,19 +18,7 @@ pub fn foo_0(x: Ptr) -> Ptr { return (x).clone(); } #[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, )] #[cpp_from(i32, construct, value)] #[byte_size(4)] @@ -51,19 +26,7 @@ pub struct Value_ { #[offset(0)] pub v: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(8)] pub struct Ptr_ { #[offset(0)] diff --git a/tests/unit/out/refcount/struct_default_ctor.rs b/tests/unit/out/refcount/struct_default_ctor.rs index b424ef89d4..5c9b995f00 100644 --- a/tests/unit/out/refcount/struct_default_ctor.rs +++ b/tests/unit/out/refcount/struct_default_ctor.rs @@ -6,19 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(8)] pub struct S { #[offset(0)] @@ -37,37 +25,13 @@ impl Default for S { } } } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Declared { #[offset(0)] pub v: i32, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(16)] pub struct Holder { #[offset(0)] @@ -87,19 +51,7 @@ impl Default for Holder { thread_local!( pub static kInit_0: Value = Rc::new(RefCell::new(3)); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(4)] pub struct FromStatic { #[offset(0)] diff --git a/tests/unit/out/refcount/struct_member_array_adjacency.rs b/tests/unit/out/refcount/struct_member_array_adjacency.rs index 20f1ae7918..15478370e1 100644 --- a/tests/unit/out/refcount/struct_member_array_adjacency.rs +++ b/tests/unit/out/refcount/struct_member_array_adjacency.rs @@ -6,18 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(32)] pub struct pair { #[offset(0)] diff --git a/tests/unit/out/refcount/struct_ptr.rs b/tests/unit/out/refcount/struct_ptr.rs index 1f8f6c16c5..2507420182 100644 --- a/tests/unit/out/refcount/struct_ptr.rs +++ b/tests/unit/out/refcount/struct_ptr.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct XX { #[offset(0)] diff --git a/tests/unit/out/refcount/structured_binding_range_for.rs b/tests/unit/out/refcount/structured_binding_range_for.rs index fa8d1d288c..eb06fdb8d5 100644 --- a/tests/unit/out/refcount/structured_binding_range_for.rs +++ b/tests/unit/out/refcount/structured_binding_range_for.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Pair { #[offset(0)] diff --git a/tests/unit/out/refcount/structured_binding_ref.rs b/tests/unit/out/refcount/structured_binding_ref.rs index 6ddfa0d97b..b010b6d55f 100644 --- a/tests/unit/out/refcount/structured_binding_ref.rs +++ b/tests/unit/out/refcount/structured_binding_ref.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(12)] pub struct Triple { #[offset(0)] diff --git a/tests/unit/out/refcount/structured_binding_trivial.rs b/tests/unit/out/refcount/structured_binding_trivial.rs index 6866274183..ee0f7e0e40 100644 --- a/tests/unit/out/refcount/structured_binding_trivial.rs +++ b/tests/unit/out/refcount/structured_binding_trivial.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Pair { #[offset(0)] diff --git a/tests/unit/out/refcount/tag_vs_identifier_collision.rs b/tests/unit/out/refcount/tag_vs_identifier_collision.rs index efd9fabf1c..f6c95bbcba 100644 --- a/tests/unit/out/refcount/tag_vs_identifier_collision.rs +++ b/tests/unit/out/refcount/tag_vs_identifier_collision.rs @@ -10,20 +10,7 @@ pub type widget_enum = u32; pub const widget_enum_MODE_IDLE: widget_enum = 0; pub const widget_enum_MODE_ACTIVE: widget_enum = 1; pub const widget_enum_MODE_DONE: widget_enum = 2; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct widget { #[offset(0)] @@ -31,20 +18,7 @@ pub struct widget { #[offset(4)] pub mode: widget_enum, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct point_struct { #[offset(0)] @@ -52,17 +26,7 @@ pub struct point_struct { #[offset(4)] pub y: i32, } -#[derive( - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - ByteRepr, - Clone, - ZeroInitialization, -)] +#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(4)] pub struct point { #[offset(0)] @@ -85,17 +49,7 @@ impl Default for point { } } } -#[derive( - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - ByteRepr, - Clone, - ZeroInitialization, -)] +#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(4)] pub struct slot_union { #[offset(0)] @@ -121,59 +75,20 @@ impl Default for slot_union { pub type slot = u32; pub const slot_SLOT_A: slot = 0; pub const slot_SLOT_B: slot = 1; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Inner { #[offset(0)] pub tag_field: i32, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Outer { #[offset(0)] #[byte_size(4)] pub field: Inner, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Inner_struct { #[offset(0)] diff --git a/tests/unit/out/refcount/template_default_arg.rs b/tests/unit/out/refcount/template_default_arg.rs index fc390a4fb0..475548c202 100644 --- a/tests/unit/out/refcount/template_default_arg.rs +++ b/tests/unit/out/refcount/template_default_arg.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable)] #[cpp_from(i32, construct_1, value)] #[byte_size(4)] pub struct A { @@ -37,19 +24,7 @@ impl Default for A { } } } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(4)] pub struct B { #[offset(0)] @@ -67,19 +42,7 @@ impl Default for B { } } #[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, )] #[cpp_from(i32, construct, value)] #[byte_size(4)] @@ -100,19 +63,7 @@ pub fn always_given_3(mut x: NoDefault) -> i32 { return x.v; } #[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, )] #[cpp_from(i32, construct, value)] #[byte_size(4)] diff --git a/tests/unit/out/refcount/template_static_member.rs b/tests/unit/out/refcount/template_static_member.rs index 9e53a9d2b4..31a1749c3d 100644 --- a/tests/unit/out/refcount/template_static_member.rs +++ b/tests/unit/out/refcount/template_static_member.rs @@ -9,58 +9,19 @@ use std::rc::{Rc, Weak}; thread_local!( pub static s_0: Value = Rc::new(RefCell::new(55)); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct Static_int_ {} thread_local!( pub static s_1: Value = Rc::new(RefCell::new(55_i8)); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct Static_char_ {} thread_local!( pub static s_2: Value = Rc::new(RefCell::new(55_i64)); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct Static_long_ {} thread_local!( @@ -69,20 +30,7 @@ thread_local!( thread_local!( pub static hi_4: Value = Rc::new(RefCell::new(1)); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct Range_int_ {} thread_local!( @@ -91,20 +39,7 @@ thread_local!( thread_local!( pub static hi_6: Value = Rc::new(RefCell::new(2_i64)); ); -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct Range_long_ {} pub fn main() { diff --git a/tests/unit/out/refcount/temporary_field_ctor_arg.rs b/tests/unit/out/refcount/temporary_field_ctor_arg.rs index 5f0b647311..363bae465e 100644 --- a/tests/unit/out/refcount/temporary_field_ctor_arg.rs +++ b/tests/unit/out/refcount/temporary_field_ctor_arg.rs @@ -42,19 +42,7 @@ pub fn make_0() -> Outer { }; } #[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, )] #[cpp_from(Vec , construct, ptr)] #[byte_size(4)] diff --git a/tests/unit/out/refcount/this.rs b/tests/unit/out/refcount/this.rs index 74c18441e5..f2be93cf13 100644 --- a/tests/unit/out/refcount/this.rs +++ b/tests/unit/out/refcount/this.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, )] #[cpp_from(i32, construct_1, value)] #[byte_size(16)] @@ -33,19 +22,7 @@ pub fn bump_0(mut p: Ptr) { field!(p, a_).with_mut(|__v| __v.postfix_inc()); } #[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, )] #[cpp_from(i32, construct, value)] #[byte_size(4)] diff --git a/tests/unit/out/refcount/typedef-anon-struct.rs b/tests/unit/out/refcount/typedef-anon-struct.rs index 4692f3f5fd..891abd6e5a 100644 --- a/tests/unit/out/refcount/typedef-anon-struct.rs +++ b/tests/unit/out/refcount/typedef-anon-struct.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Outer_RunInfo { #[offset(0)] diff --git a/tests/unit/out/refcount/unary_expr_or_type_trait.rs b/tests/unit/out/refcount/unary_expr_or_type_trait.rs index d1b3c5b6af..2dc363d144 100644 --- a/tests/unit/out/refcount/unary_expr_or_type_trait.rs +++ b/tests/unit/out/refcount/unary_expr_or_type_trait.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/unboxed_locals.rs b/tests/unit/out/refcount/unboxed_locals.rs index 9ff991b9a6..03a468c059 100644 --- a/tests/unit/out/refcount/unboxed_locals.rs +++ b/tests/unit/out/refcount/unboxed_locals.rs @@ -14,20 +14,7 @@ pub fn inc_1(r: Ptr) { __v.prefix_inc(); }); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Pair { #[offset(0)] @@ -67,19 +54,7 @@ pub fn countdown_4(mut n: i32, mut step: i32) -> i32 { pub trait Shape { fn scale(&mut self, factor: i32) -> i32; } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(16)] pub struct Square { #[offset(8)] diff --git a/tests/unit/out/refcount/unboxed_records.rs b/tests/unit/out/refcount/unboxed_records.rs index 7135557fe1..602a77a6a7 100644 --- a/tests/unit/out/refcount/unboxed_records.rs +++ b/tests/unit/out/refcount/unboxed_records.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Inner { #[offset(0)] @@ -27,18 +14,7 @@ pub struct Inner { #[offset(4)] pub b: i32, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(48)] pub struct Cookie { #[offset(0)] @@ -70,19 +46,7 @@ impl Default for Cookie { } } } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(4)] pub struct Counter { #[offset(0)] diff --git a/tests/unit/out/refcount/union_addrof_external.rs b/tests/unit/out/refcount/union_addrof_external.rs index c9a51ee9d9..0f205401f5 100644 --- a/tests/unit/out/refcount/union_addrof_external.rs +++ b/tests/unit/out/refcount/union_addrof_external.rs @@ -6,18 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(16)] pub struct record { #[offset(0)] @@ -43,17 +32,7 @@ impl Default for record { } } } -#[derive( - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - ByteRepr, - Clone, - ZeroInitialization, -)] +#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(128)] pub struct anon_0 { #[offset(0)] @@ -76,19 +55,7 @@ impl Default for anon_0 { } } } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(128)] pub struct Container { #[offset(0)] diff --git a/tests/unit/out/refcount/union_basic.rs b/tests/unit/out/refcount/union_basic.rs index 537b2fd8fb..56840e48e1 100644 --- a/tests/unit/out/refcount/union_basic.rs +++ b/tests/unit/out/refcount/union_basic.rs @@ -6,17 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - ByteRepr, - Clone, - ZeroInitialization, -)] +#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(4)] pub struct basic { #[offset(0)] @@ -39,17 +29,7 @@ impl Default for basic { } } } -#[derive( - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - ByteRepr, - Clone, - ZeroInitialization, -)] +#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(1)] pub struct empty { #[offset(0)] @@ -65,17 +45,7 @@ impl Default for empty { } } } -#[derive( - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - ByteRepr, - Clone, - ZeroInitialization, -)] +#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(8)] pub struct underscores { #[offset(0)] @@ -153,17 +123,7 @@ fn main_0() -> i32 { assert!(((__ + ___) == 3)); return 0; } -#[derive( - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - ByteRepr, - Clone, - ZeroInitialization, -)] +#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(4)] pub struct anon_0 { #[offset(0)] diff --git a/tests/unit/out/refcount/union_cross_arm_cast.rs b/tests/unit/out/refcount/union_cross_arm_cast.rs index 584b4cfeba..0064139fbe 100644 --- a/tests/unit/out/refcount/union_cross_arm_cast.rs +++ b/tests/unit/out/refcount/union_cross_arm_cast.rs @@ -6,18 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(16)] pub struct shape_a { #[offset(0)] @@ -37,18 +26,7 @@ impl Default for shape_a { } } } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(28)] pub struct shape_b { #[offset(0)] @@ -77,17 +55,7 @@ impl Default for shape_b { } } } -#[derive( - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - ByteRepr, - Clone, - ZeroInitialization, -)] +#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(64)] pub struct anon_0 { #[offset(0)] @@ -113,19 +81,7 @@ impl Default for anon_0 { } } } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(68)] pub struct Container { #[offset(0)] diff --git a/tests/unit/out/refcount/union_field_alignment.rs b/tests/unit/out/refcount/union_field_alignment.rs index 8a5ae1ae95..03e61b7d6a 100644 --- a/tests/unit/out/refcount/union_field_alignment.rs +++ b/tests/unit/out/refcount/union_field_alignment.rs @@ -6,17 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - ByteRepr, - Clone, - ZeroInitialization, -)] +#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(8)] pub struct anon_0 { #[offset(0)] @@ -39,19 +29,7 @@ impl Default for anon_0 { } } } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct node { #[offset(0)] diff --git a/tests/unit/out/refcount/union_flex_array_member.rs b/tests/unit/out/refcount/union_flex_array_member.rs index c856bc448a..739650bfac 100644 --- a/tests/unit/out/refcount/union_flex_array_member.rs +++ b/tests/unit/out/refcount/union_flex_array_member.rs @@ -6,17 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - ByteRepr, - Clone, - ZeroInitialization, -)] +#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(8)] pub struct anon_0 { #[offset(0)] @@ -39,19 +29,7 @@ impl Default for anon_0 { } } } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(24)] pub struct node { #[offset(0)] diff --git a/tests/unit/out/refcount/union_memset_memcpy.rs b/tests/unit/out/refcount/union_memset_memcpy.rs index a3e0279bd0..f5fc86650f 100644 --- a/tests/unit/out/refcount/union_memset_memcpy.rs +++ b/tests/unit/out/refcount/union_memset_memcpy.rs @@ -6,18 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(16)] pub struct shape_a { #[offset(0)] @@ -37,18 +26,7 @@ impl Default for shape_a { } } } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(16)] pub struct shape_b { #[offset(0)] @@ -74,17 +52,7 @@ impl Default for shape_b { } } } -#[derive( - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - ByteRepr, - Clone, - ZeroInitialization, -)] +#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(256)] pub struct anon_0 { #[offset(0)] @@ -110,19 +78,7 @@ impl Default for anon_0 { } } } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(256)] pub struct Container { #[offset(0)] diff --git a/tests/unit/out/refcount/union_nested.rs b/tests/unit/out/refcount/union_nested.rs index 58a698d0f0..4e9624725f 100644 --- a/tests/unit/out/refcount/union_nested.rs +++ b/tests/unit/out/refcount/union_nested.rs @@ -6,18 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(16)] pub struct record { #[offset(0)] @@ -37,17 +26,7 @@ impl Default for record { } } } -#[derive( - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - ByteRepr, - Clone, - ZeroInitialization, -)] +#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(128)] pub struct anon_0 { #[offset(0)] @@ -70,36 +49,14 @@ impl Default for anon_0 { } } } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(128)] pub struct inner { #[offset(0)] #[byte_size(128)] pub view: anon_0, } -#[derive( - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - ByteRepr, - Clone, - ZeroInitialization, -)] +#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(128)] pub struct anon_1 { #[offset(0)] @@ -122,19 +79,7 @@ impl Default for anon_1 { } } } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(144)] pub struct Outer { #[offset(0)] diff --git a/tests/unit/out/refcount/union_pointer_pun_address.rs b/tests/unit/out/refcount/union_pointer_pun_address.rs index 3a1fbf56af..00cce6bf99 100644 --- a/tests/unit/out/refcount/union_pointer_pun_address.rs +++ b/tests/unit/out/refcount/union_pointer_pun_address.rs @@ -6,38 +6,13 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct node_a { #[offset(0)] pub n: i32, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct node_b { #[offset(0)] @@ -59,17 +34,7 @@ fn main_0() -> i32 { assert!(({ (out).to_any() } == { (a.as_pointer()).to_any() })); return 0; } -#[derive( - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - ByteRepr, - Clone, - ZeroInitialization, -)] +#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(8)] pub struct anon_0 { #[offset(0)] diff --git a/tests/unit/out/refcount/union_pointer_pun_writethrough.rs b/tests/unit/out/refcount/union_pointer_pun_writethrough.rs index cb03400c35..ddda9d5544 100644 --- a/tests/unit/out/refcount/union_pointer_pun_writethrough.rs +++ b/tests/unit/out/refcount/union_pointer_pun_writethrough.rs @@ -18,17 +18,7 @@ fn main_0() -> i32 { assert!(({ ((*x.borrow()) == 42_i64) })); return 0; } -#[derive( - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - ByteRepr, - Clone, - ZeroInitialization, -)] +#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(8)] pub struct anon_0 { #[offset(0)] diff --git a/tests/unit/out/refcount/union_struct_dual_use.rs b/tests/unit/out/refcount/union_struct_dual_use.rs index 102a01eaed..e417665f5c 100644 --- a/tests/unit/out/refcount/union_struct_dual_use.rs +++ b/tests/unit/out/refcount/union_struct_dual_use.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Inner { #[offset(0)] @@ -30,17 +17,7 @@ pub struct Inner { pub fn sum_inner_0(mut i: Ptr) -> i32 { return ({ i.with(|__s| __s.a) } + { i.with(|__s| __s.b) }); } -#[derive( - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - ByteRepr, - Clone, - ZeroInitialization, -)] +#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(16)] pub struct anon_1 { #[offset(0)] @@ -63,19 +40,7 @@ impl Default for anon_1 { } } } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct Outer { #[offset(0)] diff --git a/tests/unit/out/refcount/union_tagged_many_arms.rs b/tests/unit/out/refcount/union_tagged_many_arms.rs index ca32401bee..9f2ad0c864 100644 --- a/tests/unit/out/refcount/union_tagged_many_arms.rs +++ b/tests/unit/out/refcount/union_tagged_many_arms.rs @@ -12,17 +12,7 @@ pub const Tag_enum_T_NUM_U: Tag_enum = 1; pub const Tag_enum_T_TEXT: Tag_enum = 2; pub const Tag_enum_T_FLOAT: Tag_enum = 3; pub const Tag_enum_T_REF: Tag_enum = 4; -#[derive( - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - ByteRepr, - Clone, - ZeroInitialization, -)] +#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(8)] pub struct anon_0 { #[offset(0)] @@ -54,19 +44,7 @@ impl Default for anon_0 { } } } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct Slot { #[offset(0)] diff --git a/tests/unit/out/refcount/union_tagged_simple.rs b/tests/unit/out/refcount/union_tagged_simple.rs index fe01276861..cc96e94435 100644 --- a/tests/unit/out/refcount/union_tagged_simple.rs +++ b/tests/unit/out/refcount/union_tagged_simple.rs @@ -9,17 +9,7 @@ use std::rc::{Rc, Weak}; pub type Kind_enum = u32; pub const Kind_enum_KIND_NONE: Kind_enum = 0; pub const Kind_enum_KIND_DONE: Kind_enum = 1; -#[derive( - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - ByteRepr, - Clone, - ZeroInitialization, -)] +#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(8)] pub struct anon_0 { #[offset(0)] @@ -42,19 +32,7 @@ impl Default for anon_0 { } } } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(24)] pub struct Event { #[offset(0)] diff --git a/tests/unit/out/refcount/union_tagged_struct_arms.rs b/tests/unit/out/refcount/union_tagged_struct_arms.rs index 1b4a3c0be7..4fab46abac 100644 --- a/tests/unit/out/refcount/union_tagged_struct_arms.rs +++ b/tests/unit/out/refcount/union_tagged_struct_arms.rs @@ -10,19 +10,7 @@ pub type Choice_enum = u32; pub const Choice_enum_C_LIST: Choice_enum = 1; pub const Choice_enum_C_LETTERS: Choice_enum = 2; pub const Choice_enum_C_INTEGERS: Choice_enum = 3; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(24)] pub struct anon_1 { #[offset(0)] @@ -33,20 +21,7 @@ pub struct anon_1 { #[offset(16)] pub cursor: i64, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct anon_2 { #[offset(0)] @@ -58,20 +33,7 @@ pub struct anon_2 { #[offset(12)] pub step: u8, } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(40)] pub struct anon_3 { #[offset(0)] @@ -85,17 +47,7 @@ pub struct anon_3 { #[offset(32)] pub width: i32, } -#[derive( - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - ByteRepr, - Clone, - ZeroInitialization, -)] +#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(40)] pub struct anon_0 { #[offset(0)] @@ -121,19 +73,7 @@ impl Default for anon_0 { } } } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(48)] pub struct Branch { #[offset(0)] diff --git a/tests/unit/out/refcount/union_void_ptr_sized_deref.rs b/tests/unit/out/refcount/union_void_ptr_sized_deref.rs index 171ad64412..e2a805fc54 100644 --- a/tests/unit/out/refcount/union_void_ptr_sized_deref.rs +++ b/tests/unit/out/refcount/union_void_ptr_sized_deref.rs @@ -10,17 +10,7 @@ pub type Width_enum = u32; pub const Width_enum_W_64: Width_enum = 0; pub const Width_enum_W_32: Width_enum = 1; pub const Width_enum_W_16: Width_enum = 2; -#[derive( - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - ByteRepr, - Clone, - ZeroInitialization, -)] +#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(8)] pub struct anon_0 { #[offset(0)] @@ -49,19 +39,7 @@ impl Default for anon_0 { } } } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct Sink { #[offset(0)] diff --git a/tests/unit/out/refcount/unique_ptr.rs b/tests/unit/out/refcount/unique_ptr.rs index 65c0640c02..ba07ffd8fc 100644 --- a/tests/unit/out/refcount/unique_ptr.rs +++ b/tests/unit/out/refcount/unique_ptr.rs @@ -27,20 +27,7 @@ impl MoveAssignable for SafePointer { return (*this).clone(); } } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Pair { #[offset(0)] diff --git a/tests/unit/out/refcount/unique_ptr_field_reset.rs b/tests/unit/out/refcount/unique_ptr_field_reset.rs index 5a0bf19fd1..e1c2d7a06a 100644 --- a/tests/unit/out/refcount/unique_ptr_field_reset.rs +++ b/tests/unit/out/refcount/unique_ptr_field_reset.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Data { #[offset(0)] diff --git a/tests/unit/out/refcount/unique_ptr_nested.rs b/tests/unit/out/refcount/unique_ptr_nested.rs index a8bf9413be..f27cd620e4 100644 --- a/tests/unit/out/refcount/unique_ptr_nested.rs +++ b/tests/unit/out/refcount/unique_ptr_nested.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Inner { #[offset(0)] diff --git a/tests/unit/out/refcount/unique_ptr_struct.rs b/tests/unit/out/refcount/unique_ptr_struct.rs index 341e4cde7e..6bb65fda88 100644 --- a/tests/unit/out/refcount/unique_ptr_struct.rs +++ b/tests/unit/out/refcount/unique_ptr_struct.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Point { #[offset(0)] diff --git a/tests/unit/out/refcount/va_arg_mixed_types.rs b/tests/unit/out/refcount/va_arg_mixed_types.rs index 1c25468b4e..71f7e9978b 100644 --- a/tests/unit/out/refcount/va_arg_mixed_types.rs +++ b/tests/unit/out/refcount/va_arg_mixed_types.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct pair { #[offset(0)] diff --git a/tests/unit/out/refcount/va_arg_non_primitive_ptrs.rs b/tests/unit/out/refcount/va_arg_non_primitive_ptrs.rs index 857161256c..1982bb15fb 100644 --- a/tests/unit/out/refcount/va_arg_non_primitive_ptrs.rs +++ b/tests/unit/out/refcount/va_arg_non_primitive_ptrs.rs @@ -6,19 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct node { #[offset(0)] diff --git a/tests/unit/out/refcount/va_arg_struct_ctx.rs b/tests/unit/out/refcount/va_arg_struct_ctx.rs index a3d6765015..53276f195b 100644 --- a/tests/unit/out/refcount/va_arg_struct_ctx.rs +++ b/tests/unit/out/refcount/va_arg_struct_ctx.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct context { #[offset(0)] @@ -36,17 +23,7 @@ pub fn set_error_0(mut ctx: Ptr, fmt: Ptr, __args: Box<[VaArg]>) { field!(ctx, last_error).write((*ap.borrow_mut()).arg::()); } } -#[derive( - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - ByteRepr, - Clone, - ZeroInitialization, -)] +#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(8)] pub struct value { #[offset(0)] diff --git a/tests/unit/out/refcount/va_arg_void_ptr.rs b/tests/unit/out/refcount/va_arg_void_ptr.rs index 2b67f87af2..7a5b9ab5a3 100644 --- a/tests/unit/out/refcount/va_arg_void_ptr.rs +++ b/tests/unit/out/refcount/va_arg_void_ptr.rs @@ -6,19 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct registry { #[offset(0)] diff --git a/tests/unit/out/refcount/va_list_field.rs b/tests/unit/out/refcount/va_list_field.rs index 1ea33c79d7..4dec257d9d 100644 --- a/tests/unit/out/refcount/va_list_field.rs +++ b/tests/unit/out/refcount/va_list_field.rs @@ -39,10 +39,7 @@ pub fn sum_0(n: i32, __args: Box<[VaArg]>) -> i32 { FnPtrArg, CppFrom, Destructible, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, + Copyable, Default, )] #[cpp_from(Ptr , construct, mut_ptr)] @@ -74,19 +71,7 @@ pub fn sum_ptr_2(n: i32, __args: Box<[VaArg]>) -> i32 { }; return total; } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Cursor_3 { #[offset(0)] diff --git a/tests/unit/out/refcount/vector.rs b/tests/unit/out/refcount/vector.rs index 9588796e5e..bcac7061a5 100644 --- a/tests/unit/out/refcount/vector.rs +++ b/tests/unit/out/refcount/vector.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/vector_iter_range_ctor.rs b/tests/unit/out/refcount/vector_iter_range_ctor.rs index 013d2f0247..81a328fc08 100644 --- a/tests/unit/out/refcount/vector_iter_range_ctor.rs +++ b/tests/unit/out/refcount/vector_iter_range_ctor.rs @@ -7,19 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, )] #[cpp_from(i32, construct, value)] #[byte_size(4)] @@ -28,19 +16,7 @@ pub struct Degrees { pub value: i32, } #[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, )] #[cpp_into(i64, to_i64)] #[byte_size(4)] diff --git a/tests/unit/out/refcount/vector_subscript_direct.rs b/tests/unit/out/refcount/vector_subscript_direct.rs index 84cfe0176c..383e269e33 100644 --- a/tests/unit/out/refcount/vector_subscript_direct.rs +++ b/tests/unit/out/refcount/vector_subscript_direct.rs @@ -6,20 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Point { #[offset(0)] diff --git a/tests/unit/out/refcount/vector_with_allocator.rs b/tests/unit/out/refcount/vector_with_allocator.rs index 6f3f2309f1..9ef0bb4357 100644 --- a/tests/unit/out/refcount/vector_with_allocator.rs +++ b/tests/unit/out/refcount/vector_with_allocator.rs @@ -6,36 +6,10 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct TestAllocator_int_ {} -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct TestAllocator_double_ {} pub fn copy_0(mut copy_vector: Vec) {} diff --git a/tests/unit/out/refcount/void_cast.rs b/tests/unit/out/refcount/void_cast.rs index ccae77007b..b9594ddfc7 100644 --- a/tests/unit/out/refcount/void_cast.rs +++ b/tests/unit/out/refcount/void_cast.rs @@ -46,20 +46,7 @@ pub fn bump_and_return_4() -> i32 { (*side_effect_counter_3.with(Value::clone).borrow_mut()).prefix_inc(); return side_effect_counter_3.with(|rc| *rc.borrow()); } -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - CopyAssignable, - MoveAssignable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Holder { #[offset(0)] diff --git a/tests/unit/out/unsafe/05_new.rs b/tests/unit/out/unsafe/05_new.rs index 54dc9210a1..2bdfba5038 100644 --- a/tests/unit/out/unsafe/05_new.rs +++ b/tests/unit/out/unsafe/05_new.rs @@ -7,32 +7,10 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct A {} #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct D {} impl D { pub unsafe fn operator_call(&self, mut ptr: *const A) { diff --git a/tests/unit/out/unsafe/10_struct.rs b/tests/unit/out/unsafe/10_struct.rs index 804aefd999..114b5a2b4c 100644 --- a/tests/unit/out/unsafe/10_struct.rs +++ b/tests/unit/out/unsafe/10_struct.rs @@ -7,35 +7,13 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct GraphNode { pub dst: u32, pub next: *mut GraphNode, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Graph { pub V: u32, pub adj: *mut *mut GraphNode, @@ -53,17 +31,7 @@ impl Graph { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct Partial { pub p: *mut i32, } @@ -82,33 +50,11 @@ impl Default for Partial { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Declared {} impl Declared {} #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub i: i32, pub d: *mut Declared, diff --git a/tests/unit/out/unsafe/addr_of_global.rs b/tests/unit/out/unsafe/addr_of_global.rs index 20c2a4d111..d41f2d6634 100644 --- a/tests/unit/out/unsafe/addr_of_global.rs +++ b/tests/unit/out/unsafe/addr_of_global.rs @@ -7,34 +7,12 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Inner { pub value: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Outer { pub p: *mut Inner, } diff --git a/tests/unit/out/unsafe/anonymous-struct.rs b/tests/unit/out/unsafe/anonymous-struct.rs index deb80beada..ce9a32f506 100644 --- a/tests/unit/out/unsafe/anonymous-struct.rs +++ b/tests/unit/out/unsafe/anonymous-struct.rs @@ -7,136 +7,48 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Outer_Named { pub a: i32, pub b: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct anon_0 { pub c: i32, pub d: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct anon_1 { pub g: i32, pub h: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct anon_2 { pub e: i32, pub f: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct anon_4 { pub j: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct anon_5 { pub k: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct anon_3 { pub i: i32, pub inner_named: anon_4, pub anon_5: anon_5, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Outer { pub named: Outer_Named, pub anonymous_named_0: anon_0, @@ -192,18 +104,7 @@ unsafe fn main_0() -> i32 { return 0; } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct anon_6 { pub x: i32, pub z: i32, diff --git a/tests/unit/out/unsafe/anonymous-struct_c.rs b/tests/unit/out/unsafe/anonymous-struct_c.rs index 89fc5c8c89..c25e1d0e40 100644 --- a/tests/unit/out/unsafe/anonymous-struct_c.rs +++ b/tests/unit/out/unsafe/anonymous-struct_c.rs @@ -7,136 +7,48 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Named { pub a: i32, pub b: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct anon_0 { pub c: i32, pub d: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct anon_1 { pub g: i32, pub h: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct anon_2 { pub e: i32, pub f: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct anon_4 { pub j: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct anon_5 { pub k: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct anon_3 { pub i: i32, pub inner_named: anon_4, pub anon_5: anon_5, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Outer { pub named: Named, pub anon0: anon_0, @@ -198,18 +110,7 @@ unsafe fn main_0() -> i32 { return 0; } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct anon_6 { pub x: i32, pub z: i32, diff --git a/tests/unit/out/unsafe/anonymous_enum.rs b/tests/unit/out/unsafe/anonymous_enum.rs index f3ab7be9d8..89ab511c88 100644 --- a/tests/unit/out/unsafe/anonymous_enum.rs +++ b/tests/unit/out/unsafe/anonymous_enum.rs @@ -13,18 +13,7 @@ pub type anon_1 = u32; pub const anon_1_SECOND_A: anon_1 = 0; pub const anon_1_SECOND_B: anon_1 = 1; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub a: i32, } @@ -35,18 +24,7 @@ pub type anon_2 = u32; pub const anon_2_FIELD_A: anon_2 = 0; pub const anon_2_FIELD_B: anon_2 = 1; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct WithAnonField { pub a: i32, pub field: anon_2, diff --git a/tests/unit/out/unsafe/anonymous_enum_c.rs b/tests/unit/out/unsafe/anonymous_enum_c.rs index f7ce25d583..8d0154ceac 100644 --- a/tests/unit/out/unsafe/anonymous_enum_c.rs +++ b/tests/unit/out/unsafe/anonymous_enum_c.rs @@ -13,18 +13,7 @@ pub type anon_1 = u32; pub const anon_1_SECOND_A: anon_1 = 0; pub const anon_1_SECOND_B: anon_1 = 1; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub a: i32, } @@ -35,18 +24,7 @@ pub type anon_2 = u32; pub const anon_2_FIELD_A: anon_2 = 0; pub const anon_2_FIELD_B: anon_2 = 1; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct WithAnonField { pub a: i32, pub field: anon_2, diff --git a/tests/unit/out/unsafe/any.rs b/tests/unit/out/unsafe/any.rs index 17fecb59cf..bbdfe08b1c 100644 --- a/tests/unit/out/unsafe/any.rs +++ b/tests/unit/out/unsafe/any.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Point { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/array_const_init.rs b/tests/unit/out/unsafe/array_const_init.rs index e9aba73630..a63c6e47d7 100644 --- a/tests/unit/out/unsafe/array_const_init.rs +++ b/tests/unit/out/unsafe/array_const_init.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub head: i32, pub tail: [i32; 3], @@ -32,18 +21,7 @@ pub static mut s_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe } }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct P { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/array_field_addr.rs b/tests/unit/out/unsafe/array_field_addr.rs index d27713328b..5fb6cc8586 100644 --- a/tests/unit/out/unsafe/array_field_addr.rs +++ b/tests/unit/out/unsafe/array_field_addr.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub before: i32, pub mask: [u8; 4], diff --git a/tests/unit/out/unsafe/array_reference.rs b/tests/unit/out/unsafe/array_reference.rs index 1faf6a520a..d1ea821a1b 100644 --- a/tests/unit/out/unsafe/array_reference.rs +++ b/tests/unit/out/unsafe/array_reference.rs @@ -57,18 +57,7 @@ pub unsafe fn pick_10(s: *const [libc::c_char; 5]) -> *const [libc::c_char; 5] { return s; } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Point { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/as_const.rs b/tests/unit/out/unsafe/as_const.rs index 362cabc88d..9224dea60b 100644 --- a/tests/unit/out/unsafe/as_const.rs +++ b/tests/unit/out/unsafe/as_const.rs @@ -10,18 +10,7 @@ pub type Overload = u32; pub const Overload_kMutableOverload: Overload = 1; pub const Overload_kConstOverload: Overload = 2; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/assign_rhs_first.rs b/tests/unit/out/unsafe/assign_rhs_first.rs index d7c023133d..8f63ae9fbe 100644 --- a/tests/unit/out/unsafe/assign_rhs_first.rs +++ b/tests/unit/out/unsafe/assign_rhs_first.rs @@ -13,18 +13,7 @@ pub unsafe fn advance_1() -> i32 { return 10; } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub ptr: *mut i32, } diff --git a/tests/unit/out/unsafe/assignment_single_eval.rs b/tests/unit/out/unsafe/assignment_single_eval.rs index 6d0f234563..1610f8c14b 100644 --- a/tests/unit/out/unsafe/assignment_single_eval.rs +++ b/tests/unit/out/unsafe/assignment_single_eval.rs @@ -836,50 +836,17 @@ pub unsafe fn test_reference_members_9() { }); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Slot_6 { pub value: *mut u32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Slot_8 { pub value: *mut i16, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Slot_10 { pub value: *mut i32, } @@ -928,18 +895,7 @@ pub unsafe fn test_pointer_elements_11() { }); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Holder_12 { pub p: *mut i32, } @@ -965,18 +921,7 @@ pub unsafe fn test_reference_pointer_13() { }); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Node_14 { pub link: *mut *mut Node_14, } @@ -1049,66 +994,22 @@ pub unsafe fn test_reference_subfields_18() { }); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Index_16 { pub value: u32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Slot_17 { pub ref_: *mut Index_16, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Index_19 { pub value: i16, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Slot_20 { pub ref_: *mut Index_19, } @@ -1148,34 +1049,12 @@ pub unsafe fn observe_24(mut assigned: i32, mut stored: *const i32) -> i32 { return ((assigned) + (*stored)); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct GlobalRecord_Inner { pub value: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct GlobalRecord { pub inner: GlobalRecord_Inner, } @@ -1441,52 +1320,19 @@ pub unsafe fn test_borrows_29() { static mut promoted_30: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 10_i16 }); static mut flag_31: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { false }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Record_32 { pub value: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Link_33 { pub next: *mut Link_33, } pub static mut selected_values_34: std::cell::LazyCell<[u32; 3]> = std::cell::LazyCell::new(|| unsafe { [0_u32, 20_u32, 30_u32] }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct IndexedBinding {} impl IndexedBinding { pub unsafe fn get_1_0(&mut self) -> *mut u32 { @@ -1705,18 +1551,7 @@ pub static mut global_array_45: std::cell::LazyCell<[u32; 3]> = pub static mut global_rows_46: std::cell::LazyCell<[[u32; 2]; 2]> = std::cell::LazyCell::new(|| unsafe { [[0_u32, 10_u32], [20_u32, 30_u32]] }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct IndexedMember { pub key: i32, pub value: u32, @@ -1975,18 +1810,7 @@ pub static mut scoped_pointers_53: std::cell::LazyCell<[*mut u32; 1]> = [(*std::cell::LazyCell::force_mut(&mut *&raw mut scoped_values_52)).as_mut_ptr()] }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct PointerSelector { pub ptr: *mut u32, } @@ -2168,18 +1992,7 @@ impl MoveAssignableUnsafe for Counts_59 { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Pair_60 { pub u: u32, pub f: i32, @@ -2481,34 +2294,12 @@ unsafe fn main_0() -> i32 { return 0; } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Index_62 { pub value: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Owner_63 { pub values: [i32; 2], pub index: i32, diff --git a/tests/unit/out/unsafe/bounded_struct_ptr.rs b/tests/unit/out/unsafe/bounded_struct_ptr.rs index 399e35c883..4a4610166f 100644 --- a/tests/unit/out/unsafe/bounded_struct_ptr.rs +++ b/tests/unit/out/unsafe/bounded_struct_ptr.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Foo { pub x1: i32, pub x2: i32, diff --git a/tests/unit/out/unsafe/bst.rs b/tests/unit/out/unsafe/bst.rs index e3205ee94c..cf8ab546c4 100644 --- a/tests/unit/out/unsafe/bst.rs +++ b/tests/unit/out/unsafe/bst.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct node_t { pub left: *mut node_t, pub right: *mut node_t, diff --git a/tests/unit/out/unsafe/c_struct.rs b/tests/unit/out/unsafe/c_struct.rs index c175a0274b..ee060c757b 100644 --- a/tests/unit/out/unsafe/c_struct.rs +++ b/tests/unit/out/unsafe/c_struct.rs @@ -7,52 +7,19 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Point { pub x: i32, pub y: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Line { pub start: Point, pub end: Point, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Node { pub value: i32, pub next: *mut Node, @@ -62,35 +29,13 @@ pub const Color_RED: Color = 0; pub const Color_GREEN: Color = 1; pub const Color_BLUE: Color = 2; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Inner { pub a: i32, pub b: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Container { pub inner: Inner, pub color: Color, diff --git a/tests/unit/out/unsafe/cast.rs b/tests/unit/out/unsafe/cast.rs index adafc9da4c..fddc6b454f 100644 --- a/tests/unit/out/unsafe/cast.rs +++ b/tests/unit/out/unsafe/cast.rs @@ -11,51 +11,18 @@ pub const E_A: E = 0; pub const E_B: E = 1; pub const E_C: E = 2; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Pair { pub x: i32, pub y: i32, } #[repr(C, align(64))] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Wide { pub c: libc::c_char, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Grid { pub h: i32, pub row: [i32; 3], diff --git a/tests/unit/out/unsafe/cast_array_to_pointer_decay.rs b/tests/unit/out/unsafe/cast_array_to_pointer_decay.rs index 3e45101478..df2d7a704a 100644 --- a/tests/unit/out/unsafe/cast_array_to_pointer_decay.rs +++ b/tests/unit/out/unsafe/cast_array_to_pointer_decay.rs @@ -17,18 +17,7 @@ pub unsafe fn strlen_1(mut s: *mut libc::c_char) -> i32 { return c; } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Row { pub a: [i32; 3], } diff --git a/tests/unit/out/unsafe/class.rs b/tests/unit/out/unsafe/class.rs index 879d638811..26b36aab5b 100644 --- a/tests/unit/out/unsafe/class.rs +++ b/tests/unit/out/unsafe/class.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Pair { pub first: i32, pub second: i32, @@ -53,18 +42,7 @@ impl Pair { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Route { pub path: Pair, pub cost: f64, @@ -77,18 +55,7 @@ impl Route { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Counter { pub v: i32, pub calls: i32, @@ -110,18 +77,7 @@ impl std::cmp::PartialEq for Counter { } impl std::cmp::Eq for Counter {} #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Tally { pub calls: i32, } diff --git a/tests/unit/out/unsafe/class_template_lazy_member.rs b/tests/unit/out/unsafe/class_template_lazy_member.rs index 9d59135042..9ceceb005a 100644 --- a/tests/unit/out/unsafe/class_template_lazy_member.rs +++ b/tests/unit/out/unsafe/class_template_lazy_member.rs @@ -7,34 +7,12 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Point { pub x: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Box_int_ { pub val: i32, } @@ -44,18 +22,7 @@ impl Box_int_ { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Box_Point_ { pub val: Point, } @@ -65,18 +32,7 @@ impl Box_Point_ { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Deduced_int_ { pub val: i32, } @@ -86,18 +42,7 @@ impl Deduced_int_ { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Deduced_Point_ { pub val: Point, } diff --git a/tests/unit/out/unsafe/class_templates.rs b/tests/unit/out/unsafe/class_templates.rs index 51de4eb7bc..07e3a74d9e 100644 --- a/tests/unit/out/unsafe/class_templates.rs +++ b/tests/unit/out/unsafe/class_templates.rs @@ -157,18 +157,7 @@ impl MoveAssignableUnsafe for MyContainer_float_ { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Boxed_short_ { pub value: i16, } @@ -181,18 +170,7 @@ impl Boxed_short_ { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Boxed_int_ { pub value: i32, } @@ -205,18 +183,7 @@ impl Boxed_int_ { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Boxed_long_ { pub value: i64, } @@ -229,18 +196,7 @@ impl Boxed_long_ { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Outer_int__Inner_int_ { pub t: i32, pub u: i32, @@ -251,18 +207,7 @@ impl Outer_int__Inner_int_ { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Outer_int_ { pub v: i32, } @@ -272,18 +217,7 @@ impl Outer_int_ { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Outer_long__Inner_int_ { pub t: i64, pub u: i32, @@ -294,18 +228,7 @@ impl Outer_long__Inner_int_ { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Outer_long__Inner_char_ { pub t: i64, pub u: libc::c_char, @@ -316,18 +239,7 @@ impl Outer_long__Inner_char_ { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Outer_long_ { pub v: i64, } @@ -337,18 +249,7 @@ impl Outer_long_ { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Elem { pub i: i32, } diff --git a/tests/unit/out/unsafe/clone_vs_move.rs b/tests/unit/out/unsafe/clone_vs_move.rs index 0903a48590..7dd801b0df 100644 --- a/tests/unit/out/unsafe/clone_vs_move.rs +++ b/tests/unit/out/unsafe/clone_vs_move.rs @@ -7,34 +7,12 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Bar { pub w: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Foo { pub x: i32, pub y: *mut i32, @@ -43,18 +21,7 @@ pub struct Foo { pub bar: Bar, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Refs { pub a: *mut i32, pub b: *mut i32, diff --git a/tests/unit/out/unsafe/comma_operator.rs b/tests/unit/out/unsafe/comma_operator.rs index 1bb2992193..9985a3a795 100644 --- a/tests/unit/out/unsafe/comma_operator.rs +++ b/tests/unit/out/unsafe/comma_operator.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Pair { pub first: i32, pub second: i32, diff --git a/tests/unit/out/unsafe/complex_function.rs b/tests/unit/out/unsafe/complex_function.rs index 5d71f4df98..66e04458d2 100644 --- a/tests/unit/out/unsafe/complex_function.rs +++ b/tests/unit/out/unsafe/complex_function.rs @@ -16,34 +16,12 @@ pub unsafe fn bar_2(x: *mut i32) -> *mut i32 { return x; } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct X1 { pub v: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct X2 { pub v: *mut X1, } @@ -53,18 +31,7 @@ impl X2 { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct X3 { pub v: *mut X2, } @@ -74,18 +41,7 @@ impl X3 { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct X4 { pub v: X3, } diff --git a/tests/unit/out/unsafe/compound_assign_paren.rs b/tests/unit/out/unsafe/compound_assign_paren.rs index 481866e84e..b68a5e1f7a 100644 --- a/tests/unit/out/unsafe/compound_assign_paren.rs +++ b/tests/unit/out/unsafe/compound_assign_paren.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Item { pub flags: u8, } diff --git a/tests/unit/out/unsafe/concepts.rs b/tests/unit/out/unsafe/concepts.rs index 031506d596..a4de38cac7 100644 --- a/tests/unit/out/unsafe/concepts.rs +++ b/tests/unit/out/unsafe/concepts.rs @@ -12,18 +12,7 @@ const _: () = assert!( "sizeof(int) == 4" ); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Sized {} impl Sized { pub unsafe fn size(&mut self) -> i32 { diff --git a/tests/unit/out/unsafe/constexpr_function.rs b/tests/unit/out/unsafe/constexpr_function.rs index 67a2636574..e970188f44 100644 --- a/tests/unit/out/unsafe/constexpr_function.rs +++ b/tests/unit/out/unsafe/constexpr_function.rs @@ -22,18 +22,7 @@ pub unsafe fn half_3(mut x: f64) -> f64 { return ((x) / (2_f64)); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Flag { pub v: i32, } @@ -59,18 +48,7 @@ pub unsafe fn imm_7(mut b: bool) -> bool { return b; } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct P { pub v: i32, } diff --git a/tests/unit/out/unsafe/constructor.rs b/tests/unit/out/unsafe/constructor.rs index 56ad0535ed..2a0a5c70a0 100644 --- a/tests/unit/out/unsafe/constructor.rs +++ b/tests/unit/out/unsafe/constructor.rs @@ -15,10 +15,7 @@ pub static mut total_0: std::cell::LazyCell = std::cell::LazyCell::new(|| u ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, + CopyableUnsafe, Default, )] #[cpp_from(i32, construct, value)] @@ -45,18 +42,7 @@ impl S { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe)] #[cpp_from(i32, construct_1, value)] pub struct Point { pub x: i32, diff --git a/tests/unit/out/unsafe/conversion_operator_same_translation.rs b/tests/unit/out/unsafe/conversion_operator_same_translation.rs index 071ecdf5ef..e5c551acfb 100644 --- a/tests/unit/out/unsafe/conversion_operator_same_translation.rs +++ b/tests/unit/out/unsafe/conversion_operator_same_translation.rs @@ -8,17 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, )] #[cpp_into(libc::c_char, to_libcc_char)] #[cpp_into(u8, to_u8)] @@ -35,17 +25,7 @@ impl S { } #[repr(C)] #[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, )] #[cpp_into(i64, to_i64_1)] pub struct T { diff --git a/tests/unit/out/unsafe/copy_assign.rs b/tests/unit/out/unsafe/copy_assign.rs index 160e9ff630..cd9957e9ed 100644 --- a/tests/unit/out/unsafe/copy_assign.rs +++ b/tests/unit/out/unsafe/copy_assign.rs @@ -52,17 +52,7 @@ impl Clone for Partial { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct NonConstAssign { pub mark: i32, } diff --git a/tests/unit/out/unsafe/copy_move_defaulted.rs b/tests/unit/out/unsafe/copy_move_defaulted.rs index c3d71c5c65..f1a65bb058 100644 --- a/tests/unit/out/unsafe/copy_move_defaulted.rs +++ b/tests/unit/out/unsafe/copy_move_defaulted.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Inner { pub x: i32, } @@ -49,18 +38,7 @@ impl Explicit { pub unsafe fn destructor(&mut self) {} } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Implicit { pub v: i32, pub inner: Inner, diff --git a/tests/unit/out/unsafe/default.rs b/tests/unit/out/unsafe/default.rs index bb0ed7f3e8..ad506ea844 100644 --- a/tests/unit/out/unsafe/default.rs +++ b/tests/unit/out/unsafe/default.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Pointers { pub x1: *mut i32, pub x2: *const i32, @@ -27,18 +16,7 @@ pub struct Pointers { pub x5: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct SmallArrays { pub a: [i32; 32], pub f: Option i32>, @@ -46,17 +24,7 @@ pub struct SmallArrays { pub p: [Pointers; 2], } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct BigArray { pub a: [i32; 33], } diff --git a/tests/unit/out/unsafe/default_function_arguments.rs b/tests/unit/out/unsafe/default_function_arguments.rs index 218ca0ea87..3eb7e63b4d 100644 --- a/tests/unit/out/unsafe/default_function_arguments.rs +++ b/tests/unit/out/unsafe/default_function_arguments.rs @@ -13,18 +13,7 @@ pub unsafe fn baz_1(mut a: *mut i32, mut b: *mut i32) -> bool { return ((a) == (b)); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe)] #[cpp_from(i32, construct, value)] pub struct Bar { pub v: i32, @@ -72,18 +61,7 @@ pub unsafe fn first_9(r: *mut [i32; 3]) -> i32 { return (*r)[(0) as usize]; } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Holder_int_ { pub v: i32, } diff --git a/tests/unit/out/unsafe/default_in_statics.rs b/tests/unit/out/unsafe/default_in_statics.rs index 3f63e2518e..43f63ebb35 100644 --- a/tests/unit/out/unsafe/default_in_statics.rs +++ b/tests/unit/out/unsafe/default_in_statics.rs @@ -7,35 +7,13 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Inner { pub v: i32, pub name: *const libc::c_char, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Outer { pub p1: *mut i32, pub p2: *const i32, @@ -47,18 +25,7 @@ pub struct Outer { pub fn_: Option i32>, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Foo { pub s1: *const libc::c_char, pub s2: *const libc::c_char, diff --git a/tests/unit/out/unsafe/delete_array_order.rs b/tests/unit/out/unsafe/delete_array_order.rs index 3af1e439b8..b0a32d21ed 100644 --- a/tests/unit/out/unsafe/delete_array_order.rs +++ b/tests/unit/out/unsafe/delete_array_order.rs @@ -8,16 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, )] pub struct Element { pub id: i64, diff --git a/tests/unit/out/unsafe/destructor.rs b/tests/unit/out/unsafe/destructor.rs index 7e5c2d3379..058b1ada33 100644 --- a/tests/unit/out/unsafe/destructor.rs +++ b/tests/unit/out/unsafe/destructor.rs @@ -9,16 +9,7 @@ use std::rc::Rc; pub static mut global_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] #[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, )] pub struct S {} impl S { @@ -28,16 +19,7 @@ impl S { } #[repr(C)] #[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, )] pub struct Defaulted { pub s: S, @@ -49,16 +31,7 @@ impl Defaulted { } #[repr(C)] #[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, )] pub struct Middle { pub s: S, @@ -70,16 +43,7 @@ impl Middle { } #[repr(C)] #[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, )] pub struct Outer { pub m: Middle, @@ -91,16 +55,7 @@ impl Outer { } #[repr(C)] #[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, )] pub struct ArrayMember { pub items: [S; 3], @@ -112,16 +67,7 @@ impl ArrayMember { } #[repr(C)] #[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, )] pub struct EmptyBody { pub s: S, @@ -133,16 +79,7 @@ impl EmptyBody { } #[repr(C)] #[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, )] pub struct Templated_char_ { pub v: libc::c_char, @@ -156,16 +93,7 @@ impl Templated_char_ { } #[repr(C)] #[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, )] pub struct Templated_int_ { pub v: i32, @@ -179,16 +107,7 @@ impl Templated_int_ { } #[repr(C)] #[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, )] pub struct Copied { pub v: i32, @@ -203,16 +122,7 @@ pub static mut order_1: std::cell::LazyCell<[i32; 3]> = pub static mut order_count_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] #[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, )] pub struct Tagged { pub tag: i32, @@ -226,16 +136,7 @@ impl Tagged { } #[repr(C)] #[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, )] pub struct Ordered { pub first: Tagged, diff --git a/tests/unit/out/unsafe/destructor_params.rs b/tests/unit/out/unsafe/destructor_params.rs index 29d9ee4965..f6d5e8ee8f 100644 --- a/tests/unit/out/unsafe/destructor_params.rs +++ b/tests/unit/out/unsafe/destructor_params.rs @@ -10,16 +10,7 @@ pub static mut destroyed_0: std::cell::LazyCell = std::cell::LazyCell::new( pub static mut last_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] #[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, )] pub struct S { pub v: i32, @@ -38,18 +29,7 @@ pub unsafe fn with_default_3(mut s: S) -> i32 { return s.v; } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Holder { pub v: i32, } diff --git a/tests/unit/out/unsafe/destructor_temporaries.rs b/tests/unit/out/unsafe/destructor_temporaries.rs index 84122d3f6d..f92b55aabd 100644 --- a/tests/unit/out/unsafe/destructor_temporaries.rs +++ b/tests/unit/out/unsafe/destructor_temporaries.rs @@ -10,16 +10,7 @@ pub static mut destroyed_0: std::cell::LazyCell = std::cell::LazyCell::new( pub static mut last_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] #[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, )] pub struct S { pub v: i32, @@ -35,16 +26,7 @@ impl S { } #[repr(C)] #[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, )] pub struct Outer { pub inner: S, diff --git a/tests/unit/out/unsafe/doubly_linked_list.rs b/tests/unit/out/unsafe/doubly_linked_list.rs index fba16b50a9..5280f20795 100644 --- a/tests/unit/out/unsafe/doubly_linked_list.rs +++ b/tests/unit/out/unsafe/doubly_linked_list.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Node { pub val: i32, pub next: *mut Node, diff --git a/tests/unit/out/unsafe/enum_default_in_static.rs b/tests/unit/out/unsafe/enum_default_in_static.rs index 2318d55e74..2940999348 100644 --- a/tests/unit/out/unsafe/enum_default_in_static.rs +++ b/tests/unit/out/unsafe/enum_default_in_static.rs @@ -11,18 +11,7 @@ pub const Mode_MODE_NONE: Mode = 0; pub const Mode_MODE_ONE: Mode = 1; pub const Mode_MODE_TWO: Mode = 2; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Config { pub count: i32, pub mode: Mode, diff --git a/tests/unit/out/unsafe/enum_int_interop.rs b/tests/unit/out/unsafe/enum_int_interop.rs index 37429e688b..fb5cc1e834 100644 --- a/tests/unit/out/unsafe/enum_int_interop.rs +++ b/tests/unit/out/unsafe/enum_int_interop.rs @@ -20,18 +20,7 @@ pub const Tag_TAG_ZERO: Tag = 0; pub const Tag_TAG_ONE: Tag = 1; pub const Tag_TAG_TWO: Tag = 2; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Entry { pub name: *const libc::c_char, pub color: Color, diff --git a/tests/unit/out/unsafe/enum_int_interop_c.rs b/tests/unit/out/unsafe/enum_int_interop_c.rs index 263cb76cb5..a14c64b644 100644 --- a/tests/unit/out/unsafe/enum_int_interop_c.rs +++ b/tests/unit/out/unsafe/enum_int_interop_c.rs @@ -20,18 +20,7 @@ pub const Tag_enum_TAG_ZERO: Tag_enum = 0; pub const Tag_enum_TAG_ONE: Tag_enum = 1; pub const Tag_enum_TAG_TWO: Tag_enum = 2; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Entry { pub name: *const libc::c_char, pub color: Color, diff --git a/tests/unit/out/unsafe/enum_underlying_type.rs b/tests/unit/out/unsafe/enum_underlying_type.rs index bd1a9c8e8d..596209959f 100644 --- a/tests/unit/out/unsafe/enum_underlying_type.rs +++ b/tests/unit/out/unsafe/enum_underlying_type.rs @@ -26,17 +26,7 @@ pub const Scoped_NEG: Scoped = -2; pub const Scoped_POS: Scoped = 2; pub type Empty = bool; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct HoldsEmpty { pub e: Empty, } diff --git a/tests/unit/out/unsafe/exprs.rs b/tests/unit/out/unsafe/exprs.rs index 565af5e37e..d0790bd8e8 100644 --- a/tests/unit/out/unsafe/exprs.rs +++ b/tests/unit/out/unsafe/exprs.rs @@ -7,34 +7,12 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct X { pub x: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Y { pub x: X, pub p: *mut X, diff --git a/tests/unit/out/unsafe/fft.rs b/tests/unit/out/unsafe/fft.rs index 80dcecf559..5274c507c8 100644 --- a/tests/unit/out/unsafe/fft.rs +++ b/tests/unit/out/unsafe/fft.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Complex { pub re: f64, pub img: f64, diff --git a/tests/unit/out/unsafe/field_aliasing.rs b/tests/unit/out/unsafe/field_aliasing.rs index 1700c09a89..fa7e7ba4b8 100644 --- a/tests/unit/out/unsafe/field_aliasing.rs +++ b/tests/unit/out/unsafe/field_aliasing.rs @@ -7,35 +7,13 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct In { pub x: i32, pub y: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub in_: In, pub total: i32, @@ -43,18 +21,7 @@ pub struct S { pub arr: [i32; 4], } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Node { pub x: i32, pub self_: *mut Node, diff --git a/tests/unit/out/unsafe/field_array_elem_ptr.rs b/tests/unit/out/unsafe/field_array_elem_ptr.rs index ee14d97896..70b02a0bcf 100644 --- a/tests/unit/out/unsafe/field_array_elem_ptr.rs +++ b/tests/unit/out/unsafe/field_array_elem_ptr.rs @@ -7,35 +7,13 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Point { pub x: i32, pub y: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Shape { pub id: i32, pub coords: [i32; 4], diff --git a/tests/unit/out/unsafe/field_method_receiver.rs b/tests/unit/out/unsafe/field_method_receiver.rs index 48527ce857..c47aac6d61 100644 --- a/tests/unit/out/unsafe/field_method_receiver.rs +++ b/tests/unit/out/unsafe/field_method_receiver.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Counter { pub n: i32, } diff --git a/tests/unit/out/unsafe/field_pointers.rs b/tests/unit/out/unsafe/field_pointers.rs index 9dc0bc2696..c8de3a976e 100644 --- a/tests/unit/out/unsafe/field_pointers.rs +++ b/tests/unit/out/unsafe/field_pointers.rs @@ -7,35 +7,13 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Inner { pub a: i32, pub name: [libc::c_char; 8], } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Header { pub tag: i32, pub size: i16, diff --git a/tests/unit/out/unsafe/field_pointers_malloced_struct.rs b/tests/unit/out/unsafe/field_pointers_malloced_struct.rs index cb645af49b..58aed9d303 100644 --- a/tests/unit/out/unsafe/field_pointers_malloced_struct.rs +++ b/tests/unit/out/unsafe/field_pointers_malloced_struct.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub a: i32, pub b: i32, diff --git a/tests/unit/out/unsafe/field_reinterpret_write_through.rs b/tests/unit/out/unsafe/field_reinterpret_write_through.rs index e8631a5743..eea33efa9d 100644 --- a/tests/unit/out/unsafe/field_reinterpret_write_through.rs +++ b/tests/unit/out/unsafe/field_reinterpret_write_through.rs @@ -7,35 +7,13 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct In { pub a: i16, pub b: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub x: i32, pub in_: In, diff --git a/tests/unit/out/unsafe/find.rs b/tests/unit/out/unsafe/find.rs index 686457b5af..a4a9d612c7 100644 --- a/tests/unit/out/unsafe/find.rs +++ b/tests/unit/out/unsafe/find.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct P { pub x: i32, } diff --git a/tests/unit/out/unsafe/first_field_ptr_covers_struct.rs b/tests/unit/out/unsafe/first_field_ptr_covers_struct.rs index 609c5a41b8..3d6f3035b6 100644 --- a/tests/unit/out/unsafe/first_field_ptr_covers_struct.rs +++ b/tests/unit/out/unsafe/first_field_ptr_covers_struct.rs @@ -7,35 +7,13 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct In { pub a: i16, pub b: i16, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub x: i32, pub in_: In, diff --git a/tests/unit/out/unsafe/first_member_downcast.rs b/tests/unit/out/unsafe/first_member_downcast.rs index ddf30080c7..146a537085 100644 --- a/tests/unit/out/unsafe/first_member_downcast.rs +++ b/tests/unit/out/unsafe/first_member_downcast.rs @@ -7,34 +7,12 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct base { pub kind: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct derived { pub head: base, pub value: usize, diff --git a/tests/unit/out/unsafe/flex_array_member_incomplete.rs b/tests/unit/out/unsafe/flex_array_member_incomplete.rs index 2fc130a26a..de36f3fd61 100644 --- a/tests/unit/out/unsafe/flex_array_member_incomplete.rs +++ b/tests/unit/out/unsafe/flex_array_member_incomplete.rs @@ -7,17 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct F { pub n: i32, pub tail: [libc::c_char; 0], diff --git a/tests/unit/out/unsafe/flex_array_member_sibling_write.rs b/tests/unit/out/unsafe/flex_array_member_sibling_write.rs index 02ccc1de70..f4555e0a20 100644 --- a/tests/unit/out/unsafe/flex_array_member_sibling_write.rs +++ b/tests/unit/out/unsafe/flex_array_member_sibling_write.rs @@ -7,52 +7,19 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub n: i32, pub name: [libc::c_char; 1], } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct E { pub id: i32, pub w: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct T { pub n: i32, pub cap: i32, diff --git a/tests/unit/out/unsafe/fn_ptr.rs b/tests/unit/out/unsafe/fn_ptr.rs index e3474bcf37..f087600d19 100644 --- a/tests/unit/out/unsafe/fn_ptr.rs +++ b/tests/unit/out/unsafe/fn_ptr.rs @@ -33,17 +33,7 @@ pub unsafe fn identity_hash_6(mut v: bool) -> usize { } #[repr(C)] #[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, )] #[cpp_from(Option u64 > , construct, ptr)] pub struct HashHolder_unsigned_long__ptr__bool__ { diff --git a/tests/unit/out/unsafe/fn_ptr_cast.rs b/tests/unit/out/unsafe/fn_ptr_cast.rs index 73423fc5cd..e8e701d467 100644 --- a/tests/unit/out/unsafe/fn_ptr_cast.rs +++ b/tests/unit/out/unsafe/fn_ptr_cast.rs @@ -30,18 +30,7 @@ pub unsafe fn test_double_cast_2() { assert!(((fn2) == (fn_))); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Command { pub data: *mut ::libc::c_void, } diff --git a/tests/unit/out/unsafe/fn_ptr_stable_sort.rs b/tests/unit/out/unsafe/fn_ptr_stable_sort.rs index 7cb4fedf32..f5c540051e 100644 --- a/tests/unit/out/unsafe/fn_ptr_stable_sort.rs +++ b/tests/unit/out/unsafe/fn_ptr_stable_sort.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Item { pub key: i32, pub value: i32, diff --git a/tests/unit/out/unsafe/fn_ptr_struct.rs b/tests/unit/out/unsafe/fn_ptr_struct.rs index e5e6066e5a..bbb90e045f 100644 --- a/tests/unit/out/unsafe/fn_ptr_struct.rs +++ b/tests/unit/out/unsafe/fn_ptr_struct.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Handler { pub tag: i32, pub cb: Option i32>, @@ -30,18 +19,7 @@ pub unsafe fn negate_1(mut x: i32) -> i32 { return -x; } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S {} impl S { pub unsafe fn pick_1(mut x: i32) -> i32 { diff --git a/tests/unit/out/unsafe/fn_ptr_typedef_cast.rs b/tests/unit/out/unsafe/fn_ptr_typedef_cast.rs index 768b8a5311..5107f3d8d2 100644 --- a/tests/unit/out/unsafe/fn_ptr_typedef_cast.rs +++ b/tests/unit/out/unsafe/fn_ptr_typedef_cast.rs @@ -19,18 +19,7 @@ pub unsafe fn via_size_t_return_3(mut b: u64) -> usize { return (b as usize); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct pair { pub a: i32, pub b: i32, diff --git a/tests/unit/out/unsafe/fn_ptr_vtable.rs b/tests/unit/out/unsafe/fn_ptr_vtable.rs index cf75ca12da..c7726a2ee2 100644 --- a/tests/unit/out/unsafe/fn_ptr_vtable.rs +++ b/tests/unit/out/unsafe/fn_ptr_vtable.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Vtable { pub create: Option *mut ::libc::c_void>, pub get: Option i32>, diff --git a/tests/unit/out/unsafe/fn_ref.rs b/tests/unit/out/unsafe/fn_ref.rs index ab5509e068..dec5e0e1a9 100644 --- a/tests/unit/out/unsafe/fn_ref.rs +++ b/tests/unit/out/unsafe/fn_ref.rs @@ -22,18 +22,7 @@ pub unsafe fn call_forwarded_4(f: Option i32>, mut x: i32) -> return (unsafe { (f).unwrap()(x) }); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Holder { pub f: Option i32>, } diff --git a/tests/unit/out/unsafe/for_body_destructor.rs b/tests/unit/out/unsafe/for_body_destructor.rs index 681f90beda..f87d25e391 100644 --- a/tests/unit/out/unsafe/for_body_destructor.rs +++ b/tests/unit/out/unsafe/for_body_destructor.rs @@ -8,16 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, )] pub struct Guard { pub digit: i32, diff --git a/tests/unit/out/unsafe/friend.rs b/tests/unit/out/unsafe/friend.rs index 22676d35ce..029ebec7a3 100644 --- a/tests/unit/out/unsafe/friend.rs +++ b/tests/unit/out/unsafe/friend.rs @@ -19,18 +19,7 @@ pub unsafe fn scaled_3(v: *const V, mut k: f64) -> f64 { return (((*v).x as f64) * (k)); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct V { pub x: i32, } @@ -44,18 +33,7 @@ pub unsafe fn get_4(w: *const W_int_) -> i32 { return (*w).x; } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct W_int_ { pub x: i32, } @@ -63,34 +41,12 @@ pub unsafe fn get_5(w: *const W_long_) -> i64 { return (*w).x; } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct W_long_ { pub x: i64, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct D { pub x: i32, } diff --git a/tests/unit/out/unsafe/function_overloading.rs b/tests/unit/out/unsafe/function_overloading.rs index b88b101729..ec290da254 100644 --- a/tests/unit/out/unsafe/function_overloading.rs +++ b/tests/unit/out/unsafe/function_overloading.rs @@ -22,18 +22,7 @@ pub unsafe fn bar_4(x: *mut i32) -> i32 { return (*x); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Foo {} impl Foo { pub unsafe fn foo_1(&self) {} diff --git a/tests/unit/out/unsafe/global_call_temporaries.rs b/tests/unit/out/unsafe/global_call_temporaries.rs index 37ebf57a01..72a57be569 100644 --- a/tests/unit/out/unsafe/global_call_temporaries.rs +++ b/tests/unit/out/unsafe/global_call_temporaries.rs @@ -77,18 +77,7 @@ pub static mut call_assigned_6: std::cell::LazyCell = std::cell::LazyCell:: } }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Item { pub value: i32, } diff --git a/tests/unit/out/unsafe/global_init_side_effect.rs b/tests/unit/out/unsafe/global_init_side_effect.rs index 94926f0d17..9efbc0fe4c 100644 --- a/tests/unit/out/unsafe/global_init_side_effect.rs +++ b/tests/unit/out/unsafe/global_init_side_effect.rs @@ -9,17 +9,7 @@ use std::rc::Rc; pub static mut total_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] #[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, )] #[cpp_from(i32, construct, value)] pub struct S {} diff --git a/tests/unit/out/unsafe/global_non_const_init.rs b/tests/unit/out/unsafe/global_non_const_init.rs index 472ceda8f6..876b7a78f5 100644 --- a/tests/unit/out/unsafe/global_non_const_init.rs +++ b/tests/unit/out/unsafe/global_non_const_init.rs @@ -28,17 +28,7 @@ pub static mut depends_on_call_6: std::cell::LazyCell = std::cell::LazyCell ((*std::cell::LazyCell::force_mut(&mut *&raw mut from_call_5)) + (1)) }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct Ctor { pub v: i32, } @@ -91,18 +81,7 @@ pub static mut inline_member_11: std::cell::LazyCell = std::cell::LazyCell } }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Holder {} pub static mut member_10: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { (unsafe { next_0() }) }); @@ -120,17 +99,7 @@ static mut local_ctor_14: std::cell::LazyCell = std::cell::LazyCell::new(| } }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct Singleton { pub hits: i32, } diff --git a/tests/unit/out/unsafe/global_pointers.rs b/tests/unit/out/unsafe/global_pointers.rs index 84890d2b37..c81efa7c72 100644 --- a/tests/unit/out/unsafe/global_pointers.rs +++ b/tests/unit/out/unsafe/global_pointers.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Entry { pub name: *const libc::c_char, pub p: *mut i32, diff --git a/tests/unit/out/unsafe/global_without_initializer.rs b/tests/unit/out/unsafe/global_without_initializer.rs index a7bf1cbe44..a5382f5365 100644 --- a/tests/unit/out/unsafe/global_without_initializer.rs +++ b/tests/unit/out/unsafe/global_without_initializer.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub a: i32, } diff --git a/tests/unit/out/unsafe/goto_aggregate_default.rs b/tests/unit/out/unsafe/goto_aggregate_default.rs index ed5c60b4f4..49e0323437 100644 --- a/tests/unit/out/unsafe/goto_aggregate_default.rs +++ b/tests/unit/out/unsafe/goto_aggregate_default.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Point { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/goto_cleanup.rs b/tests/unit/out/unsafe/goto_cleanup.rs index 019821bafe..545f2f4266 100644 --- a/tests/unit/out/unsafe/goto_cleanup.rs +++ b/tests/unit/out/unsafe/goto_cleanup.rs @@ -77,18 +77,7 @@ pub unsafe fn from_switch_2(mut n: i32) -> i32 { panic!("ub: non-void function does not return a value") } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct wrapper { pub item: *mut i32, } diff --git a/tests/unit/out/unsafe/huffman.rs b/tests/unit/out/unsafe/huffman.rs index b56a78b8c0..a063be99f0 100644 --- a/tests/unit/out/unsafe/huffman.rs +++ b/tests/unit/out/unsafe/huffman.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct MinHeapNode { pub data: libc::c_char, pub freq: i32, diff --git a/tests/unit/out/unsafe/immutable-deref-on-func-call.rs b/tests/unit/out/unsafe/immutable-deref-on-func-call.rs index e26afcde51..b37d046705 100644 --- a/tests/unit/out/unsafe/immutable-deref-on-func-call.rs +++ b/tests/unit/out/unsafe/immutable-deref-on-func-call.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Item { pub value: i32, } diff --git a/tests/unit/out/unsafe/in_class_field_initializer.rs b/tests/unit/out/unsafe/in_class_field_initializer.rs index 813969db5f..34899a2f44 100644 --- a/tests/unit/out/unsafe/in_class_field_initializer.rs +++ b/tests/unit/out/unsafe/in_class_field_initializer.rs @@ -7,17 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct Inner { pub x: i32, pub y: i32, @@ -28,17 +18,7 @@ impl Default for Inner { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct S { pub a: i32, pub b: libc::c_char, @@ -58,17 +38,7 @@ impl Default for S { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct Boxed_int_ { pub v: i32, pub tag: i32, diff --git a/tests/unit/out/unsafe/init.rs b/tests/unit/out/unsafe/init.rs index a1f37d6af0..0a2e3caa48 100644 --- a/tests/unit/out/unsafe/init.rs +++ b/tests/unit/out/unsafe/init.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct X { pub x: i32, } diff --git a/tests/unit/out/unsafe/init_list.rs b/tests/unit/out/unsafe/init_list.rs index d33d3a7416..ba5f5d2858 100644 --- a/tests/unit/out/unsafe/init_list.rs +++ b/tests/unit/out/unsafe/init_list.rs @@ -8,34 +8,13 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub unsafe fn f_0(mut list: Vec) {} #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Pair { pub a: i32, pub b: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct Holder { pub p: Pair, } @@ -58,17 +37,7 @@ pub unsafe fn sum_1(p: *const Pair) -> i32 { return (((*p).a) + ((*p).b)); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct Seven { pub v: i32, } diff --git a/tests/unit/out/unsafe/kruskal.rs b/tests/unit/out/unsafe/kruskal.rs index 3451917a38..f014467304 100644 --- a/tests/unit/out/unsafe/kruskal.rs +++ b/tests/unit/out/unsafe/kruskal.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Edge { pub u: i32, pub v: i32, diff --git a/tests/unit/out/unsafe/lambda_as_field.rs b/tests/unit/out/unsafe/lambda_as_field.rs index 9801af2fb3..4dc83e2b13 100644 --- a/tests/unit/out/unsafe/lambda_as_field.rs +++ b/tests/unit/out/unsafe/lambda_as_field.rs @@ -7,17 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe)] pub struct Guard__lambda_at_lambda_as_field_cpp_34_13__ { pub f: FnPtr, } @@ -39,16 +29,7 @@ impl Default for Guard__lambda_at_lambda_as_field_cpp_34_13__ { } #[repr(C)] #[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, )] pub struct Guard__lambda_at_lambda_as_field_cpp_45_13__ { pub f: FnPtr, @@ -59,16 +40,7 @@ impl Guard__lambda_at_lambda_as_field_cpp_45_13__ { } } #[repr(C)] -#[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct Holder__lambda_at_lambda_as_field_cpp_39_12__ { pub f: FnPtr i32>, pub calls: i32, @@ -94,17 +66,7 @@ impl Default for Holder__lambda_at_lambda_as_field_cpp_39_12__ { } } #[repr(C)] -#[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Holder__lambda_at_lambda_as_field_cpp_51_12__ { pub f: FnPtr i32>, pub calls: i32, diff --git a/tests/unit/out/unsafe/lambda_capture_ref.rs b/tests/unit/out/unsafe/lambda_capture_ref.rs index 5b429d2c55..646dda93c0 100644 --- a/tests/unit/out/unsafe/lambda_capture_ref.rs +++ b/tests/unit/out/unsafe/lambda_capture_ref.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/lambda_capture_star_this.rs b/tests/unit/out/unsafe/lambda_capture_star_this.rs index 3c5453ec98..efc3851767 100644 --- a/tests/unit/out/unsafe/lambda_capture_star_this.rs +++ b/tests/unit/out/unsafe/lambda_capture_star_this.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub n: i32, } diff --git a/tests/unit/out/unsafe/lambda_capture_this.rs b/tests/unit/out/unsafe/lambda_capture_this.rs index 803c2125d7..74046c957e 100644 --- a/tests/unit/out/unsafe/lambda_capture_this.rs +++ b/tests/unit/out/unsafe/lambda_capture_this.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub n: i32, pub step: i32, diff --git a/tests/unit/out/unsafe/lambda_capture_value.rs b/tests/unit/out/unsafe/lambda_capture_value.rs index 3078dd26be..d78b853af5 100644 --- a/tests/unit/out/unsafe/lambda_capture_value.rs +++ b/tests/unit/out/unsafe/lambda_capture_value.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/lambda_decltype_type.rs b/tests/unit/out/unsafe/lambda_decltype_type.rs index fc95024c3e..078d4dd483 100644 --- a/tests/unit/out/unsafe/lambda_decltype_type.rs +++ b/tests/unit/out/unsafe/lambda_decltype_type.rs @@ -7,16 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { pub items: [i32; 4], pub size: i32, @@ -54,16 +45,7 @@ impl Default for Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { } } #[repr(C)] -#[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct Sorted__lambda_at_lambda_decltype_type_cpp_19_23__ { pub items: [i32; 4], pub size: i32, diff --git a/tests/unit/out/unsafe/lambda_generic_explicit_args.rs b/tests/unit/out/unsafe/lambda_generic_explicit_args.rs index 6ff8c417c3..dec74038d0 100644 --- a/tests/unit/out/unsafe/lambda_generic_explicit_args.rs +++ b/tests/unit/out/unsafe/lambda_generic_explicit_args.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Val { pub x: i32, } diff --git a/tests/unit/out/unsafe/lambda_immediate_init.rs b/tests/unit/out/unsafe/lambda_immediate_init.rs index 63aafc5499..342add8bf7 100644 --- a/tests/unit/out/unsafe/lambda_immediate_init.rs +++ b/tests/unit/out/unsafe/lambda_immediate_init.rs @@ -10,17 +10,7 @@ pub unsafe fn pick_0(mut x: i32) -> i32 { return x; } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct S { pub j: i32, pub k: i32, diff --git a/tests/unit/out/unsafe/lambda_nested.rs b/tests/unit/out/unsafe/lambda_nested.rs index f412980457..932e1103c5 100644 --- a/tests/unit/out/unsafe/lambda_nested.rs +++ b/tests/unit/out/unsafe/lambda_nested.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/lambda_static_local.rs b/tests/unit/out/unsafe/lambda_static_local.rs index e97f08ff16..76ed07741d 100644 --- a/tests/unit/out/unsafe/lambda_static_local.rs +++ b/tests/unit/out/unsafe/lambda_static_local.rs @@ -68,18 +68,7 @@ static mut n_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { static mut calls_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); static mut calls_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct P_4 { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/libc_struct_without_default.rs b/tests/unit/out/unsafe/libc_struct_without_default.rs index 6de0f7324f..7fc9b5cb94 100644 --- a/tests/unit/out/unsafe/libc_struct_without_default.rs +++ b/tests/unit/out/unsafe/libc_struct_without_default.rs @@ -44,17 +44,7 @@ impl Default for UserDefined { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct FieldIsLibcType { pub addr: libc::sockaddr, } diff --git a/tests/unit/out/unsafe/linked_list.rs b/tests/unit/out/unsafe/linked_list.rs index 47acde0be0..938989483e 100644 --- a/tests/unit/out/unsafe/linked_list.rs +++ b/tests/unit/out/unsafe/linked_list.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Node { pub val: i32, pub next: *mut Node, diff --git a/tests/unit/out/unsafe/local_anon_struct_collision.rs b/tests/unit/out/unsafe/local_anon_struct_collision.rs index 586b2251c0..2ae16f433a 100644 --- a/tests/unit/out/unsafe/local_anon_struct_collision.rs +++ b/tests/unit/out/unsafe/local_anon_struct_collision.rs @@ -13,18 +13,7 @@ pub unsafe fn first_0() -> i32 { return ((p.x) + (p.y)); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct anon_1 { pub x: i32, pub y: i32, @@ -36,18 +25,7 @@ pub unsafe fn second_2() -> i32 { return (((q.a) + (q.b)) as i32); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct anon_3 { pub a: i64, pub b: i64, diff --git a/tests/unit/out/unsafe/local_record_template.rs b/tests/unit/out/unsafe/local_record_template.rs index f9b0868d8e..d8281d97a4 100644 --- a/tests/unit/out/unsafe/local_record_template.rs +++ b/tests/unit/out/unsafe/local_record_template.rs @@ -30,34 +30,12 @@ pub unsafe fn wrap_10(mut v: i64) -> i32 { return (unsafe { get_6(l) }); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Local_5 { pub x: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Local_7 { pub x: i64, } @@ -66,18 +44,7 @@ pub unsafe fn other_11() -> i32 { return ((unsafe { get_0(l) }) + (l.y as i32)); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Local_1 { pub x: i64, pub y: i64, @@ -98,18 +65,7 @@ unsafe fn main_0() -> i32 { return 0; } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Local_3 { pub x: i32, } diff --git a/tests/unit/out/unsafe/map.rs b/tests/unit/out/unsafe/map.rs index cfcb2a6410..0830442c08 100644 --- a/tests/unit/out/unsafe/map.rs +++ b/tests/unit/out/unsafe/map.rs @@ -13,17 +13,7 @@ pub unsafe fn bar_1(x: *mut u32) { (*x) = (*x).wrapping_add(1_u32); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct Point { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/map_key_identity.rs b/tests/unit/out/unsafe/map_key_identity.rs index 0eedf808a1..b4c6ba0046 100644 --- a/tests/unit/out/unsafe/map_key_identity.rs +++ b/tests/unit/out/unsafe/map_key_identity.rs @@ -9,18 +9,7 @@ use std::rc::Rc; pub static mut default_constructions_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Key { pub order: i32, pub identity: i32, @@ -56,17 +45,7 @@ pub unsafe fn operator_eq_2(a: *const Key, b: *const Key) -> bool { return (((*a).identity) == ((*b).identity)); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct Mapped { pub value: i32, } diff --git a/tests/unit/out/unsafe/map_try_emplace.rs b/tests/unit/out/unsafe/map_try_emplace.rs index 4251253586..2b4249ee8e 100644 --- a/tests/unit/out/unsafe/map_try_emplace.rs +++ b/tests/unit/out/unsafe/map_try_emplace.rs @@ -70,17 +70,7 @@ pub unsafe fn argument_4(item: *mut Item) -> *mut Item { return item; } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct RefItem { pub value: i32, } diff --git a/tests/unit/out/unsafe/map_try_emplace_lvalues.rs b/tests/unit/out/unsafe/map_try_emplace_lvalues.rs index 2ef48c8a59..fbdc18a77f 100644 --- a/tests/unit/out/unsafe/map_try_emplace_lvalues.rs +++ b/tests/unit/out/unsafe/map_try_emplace_lvalues.rs @@ -9,17 +9,7 @@ use std::rc::Rc; pub static mut made_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut visits_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct Item { pub value: i32, } @@ -57,17 +47,7 @@ pub unsafe fn place_3(n: *mut i32) -> *mut i32 { pub static mut temporary_calls_4: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct Temporary { pub n: i32, pub data: [i32; 2], @@ -91,18 +71,7 @@ impl Default for Temporary { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Nested { pub inner: Temporary, } @@ -171,18 +140,7 @@ impl Default for Noncopy { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe)] #[cpp_from(i32, construct_1, ptr)] pub struct Held { pub ptr: *const i32, diff --git a/tests/unit/out/unsafe/memcpy_struct_bytes.rs b/tests/unit/out/unsafe/memcpy_struct_bytes.rs index 8e8f41e25b..29a4e51722 100644 --- a/tests/unit/out/unsafe/memcpy_struct_bytes.rs +++ b/tests/unit/out/unsafe/memcpy_struct_bytes.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct point { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/memcpy_struct_layouts.rs b/tests/unit/out/unsafe/memcpy_struct_layouts.rs index 35b7728086..bdb981b111 100644 --- a/tests/unit/out/unsafe/memcpy_struct_layouts.rs +++ b/tests/unit/out/unsafe/memcpy_struct_layouts.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct packed { pub a: i32, pub b: libc::c_char, @@ -26,70 +15,26 @@ pub struct packed { pub d: i16, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct reordered { pub a: libc::c_char, pub b: i32, pub c: libc::c_char, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct tail { pub a: libc::c_char, pub b: f64, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct nested { pub t: tail, pub c: libc::c_char, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct array { pub name: [libc::c_char; 3], pub x: i32, diff --git a/tests/unit/out/unsafe/memcpy_struct_struct.rs b/tests/unit/out/unsafe/memcpy_struct_struct.rs index d78d033759..899ce32932 100644 --- a/tests/unit/out/unsafe/memcpy_struct_struct.rs +++ b/tests/unit/out/unsafe/memcpy_struct_struct.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Entry { pub bits: u8, pub value: u16, diff --git a/tests/unit/out/unsafe/memset_struct_tail.rs b/tests/unit/out/unsafe/memset_struct_tail.rs index bc351f788c..26edaf197e 100644 --- a/tests/unit/out/unsafe/memset_struct_tail.rs +++ b/tests/unit/out/unsafe/memset_struct_tail.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub keep: i32, pub a: i32, diff --git a/tests/unit/out/unsafe/nested_structs.rs b/tests/unit/out/unsafe/nested_structs.rs index 988606062e..c5801dfb00 100644 --- a/tests/unit/out/unsafe/nested_structs.rs +++ b/tests/unit/out/unsafe/nested_structs.rs @@ -7,100 +7,34 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Level0_Level1_1_Level2_1_Level3_1 { pub x1: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Level0_Level1_1_Level2_1_Level3_2 { pub x1: i32, pub x2: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Level0_Level1_1_Level2_1 { pub x1: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Level0_Level1_1 { pub x1: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Level0_Level1_2 { pub x1: i32, pub x2: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Level0 {} pub fn main() { unsafe { diff --git a/tests/unit/out/unsafe/new.rs b/tests/unit/out/unsafe/new.rs index 46cb8bd238..88c99c4898 100644 --- a/tests/unit/out/unsafe/new.rs +++ b/tests/unit/out/unsafe/new.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Pair { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/new_bst.rs b/tests/unit/out/unsafe/new_bst.rs index 964e97a8a4..dab8706519 100644 --- a/tests/unit/out/unsafe/new_bst.rs +++ b/tests/unit/out/unsafe/new_bst.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct node_t { pub left: *mut node_t, pub right: *mut node_t, diff --git a/tests/unit/out/unsafe/new_struct.rs b/tests/unit/out/unsafe/new_struct.rs index e180c6c4cd..e17a949aba 100644 --- a/tests/unit/out/unsafe/new_struct.rs +++ b/tests/unit/out/unsafe/new_struct.rs @@ -7,35 +7,13 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Pair { pub x: i32, pub y: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Triple { pub a: i32, pub b: i32, diff --git a/tests/unit/out/unsafe/nttp_distinct_specializations.rs b/tests/unit/out/unsafe/nttp_distinct_specializations.rs index 022bbdc13d..f22b0557e3 100644 --- a/tests/unit/out/unsafe/nttp_distinct_specializations.rs +++ b/tests/unit/out/unsafe/nttp_distinct_specializations.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S_2_ { pub v: i32, pub w: i32, @@ -29,18 +18,7 @@ impl S_2_ { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S_1_ { pub v: i32, } @@ -50,18 +28,7 @@ impl S_1_ { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S_3_ { pub v: i32, } diff --git a/tests/unit/out/unsafe/offsetof.rs b/tests/unit/out/unsafe/offsetof.rs index 79770f687e..8c90e8e5ff 100644 --- a/tests/unit/out/unsafe/offsetof.rs +++ b/tests/unit/out/unsafe/offsetof.rs @@ -7,35 +7,14 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Layout { pub a: u8, pub b: u32, pub c: u16, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct Frame { pub tag: u16, pub body: [libc::c_char; 64], diff --git a/tests/unit/out/unsafe/opaque_forward_decl.rs b/tests/unit/out/unsafe/opaque_forward_decl.rs index 5dfc623f72..9c96c1fa9e 100644 --- a/tests/unit/out/unsafe/opaque_forward_decl.rs +++ b/tests/unit/out/unsafe/opaque_forward_decl.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct container { pub p: *mut opaque, pub x: i32, diff --git a/tests/unit/out/unsafe/opaque_record_copy.rs b/tests/unit/out/unsafe/opaque_record_copy.rs index c90f2fa8da..f1f2d924ae 100644 --- a/tests/unit/out/unsafe/opaque_record_copy.rs +++ b/tests/unit/out/unsafe/opaque_record_copy.rs @@ -7,32 +7,10 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Probe {} #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Wrapper_Probe_ { pub base_: Probe, pub tag: i32, diff --git a/tests/unit/out/unsafe/opaque_then_defined.rs b/tests/unit/out/unsafe/opaque_then_defined.rs index c49022dba3..d18e9a85b2 100644 --- a/tests/unit/out/unsafe/opaque_then_defined.rs +++ b/tests/unit/out/unsafe/opaque_then_defined.rs @@ -7,35 +7,13 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct list { pub head: *mut node, pub size: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct node { pub value: i32, pub next: *mut node, diff --git a/tests/unit/out/unsafe/operator_arithmetic_free.rs b/tests/unit/out/unsafe/operator_arithmetic_free.rs index cc1c18c0cf..a5a133ae98 100644 --- a/tests/unit/out/unsafe/operator_arithmetic_free.rs +++ b/tests/unit/out/unsafe/operator_arithmetic_free.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_arithmetic_member.rs b/tests/unit/out/unsafe/operator_arithmetic_member.rs index d1d32e4e85..d789a36122 100644 --- a/tests/unit/out/unsafe/operator_arithmetic_member.rs +++ b/tests/unit/out/unsafe/operator_arithmetic_member.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_bitwise_free.rs b/tests/unit/out/unsafe/operator_bitwise_free.rs index 8a899e7ca4..2c6875c304 100644 --- a/tests/unit/out/unsafe/operator_bitwise_free.rs +++ b/tests/unit/out/unsafe/operator_bitwise_free.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub v: u32, } diff --git a/tests/unit/out/unsafe/operator_bitwise_member.rs b/tests/unit/out/unsafe/operator_bitwise_member.rs index 12c59d82a7..3f7f52e7b2 100644 --- a/tests/unit/out/unsafe/operator_bitwise_member.rs +++ b/tests/unit/out/unsafe/operator_bitwise_member.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub v: u32, } diff --git a/tests/unit/out/unsafe/operator_comparison_defaulted.rs b/tests/unit/out/unsafe/operator_comparison_defaulted.rs index d980f46d8e..cdbc526fae 100644 --- a/tests/unit/out/unsafe/operator_comparison_defaulted.rs +++ b/tests/unit/out/unsafe/operator_comparison_defaulted.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Eq { pub a: i32, pub b: i32, @@ -36,18 +25,7 @@ impl std::cmp::PartialEq for Eq { } impl std::cmp::Eq for Eq {} #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Cmp { pub a: i32, pub b: i32, @@ -92,18 +70,7 @@ impl std::cmp::PartialEq for Cmp { } impl std::cmp::Eq for Cmp {} #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Both { pub a: i32, } @@ -139,18 +106,7 @@ impl std::cmp::PartialEq for Both { } impl std::cmp::Eq for Both {} #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct OrdOnly { pub a: i32, } @@ -183,18 +139,7 @@ impl std::cmp::PartialEq for OrdOnly { } impl std::cmp::Eq for OrdOnly {} #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Inner { pub x: i32, } @@ -230,18 +175,7 @@ impl std::cmp::PartialEq for Inner { } impl std::cmp::Eq for Inner {} #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Outer { pub i: Inner, pub y: i32, @@ -290,18 +224,7 @@ impl std::cmp::PartialEq for Outer { } impl std::cmp::Eq for Outer {} #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Secondary { pub a: i32, } @@ -348,18 +271,7 @@ impl std::cmp::PartialEq for Secondary { } impl std::cmp::Eq for Secondary {} #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct PtrMember { pub p: *mut i32, } diff --git a/tests/unit/out/unsafe/operator_comparison_free.rs b/tests/unit/out/unsafe/operator_comparison_free.rs index 13be95ca19..4f141f8951 100644 --- a/tests/unit/out/unsafe/operator_comparison_free.rs +++ b/tests/unit/out/unsafe/operator_comparison_free.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub v: i32, } @@ -71,18 +60,7 @@ pub unsafe fn operator_lt_7(mut a: i32, b: *const S) -> bool { return ((a) < ((*b).v)); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct V { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_comparison_member.rs b/tests/unit/out/unsafe/operator_comparison_member.rs index 84d166d588..d2f1a02589 100644 --- a/tests/unit/out/unsafe/operator_comparison_member.rs +++ b/tests/unit/out/unsafe/operator_comparison_member.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_comparison_mixed.rs b/tests/unit/out/unsafe/operator_comparison_mixed.rs index ec859c2b41..8b9759f676 100644 --- a/tests/unit/out/unsafe/operator_comparison_mixed.rs +++ b/tests/unit/out/unsafe/operator_comparison_mixed.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_comparison_nonbool.rs b/tests/unit/out/unsafe/operator_comparison_nonbool.rs index d9f6036013..b62679c9ac 100644 --- a/tests/unit/out/unsafe/operator_comparison_nonbool.rs +++ b/tests/unit/out/unsafe/operator_comparison_nonbool.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct X { pub v: i32, } @@ -65,34 +54,12 @@ pub unsafe fn operator_ge_5(mut a: X, mut b: X) -> i32 { return if ((a.v) >= (b.v)) { 7 } else { 0 }; } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Result { pub r: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Custom { pub v: i32, } @@ -104,18 +71,7 @@ impl Custom { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Mixed { pub v: i32, } @@ -158,17 +114,7 @@ impl std::cmp::PartialEq for Mixed { impl std::cmp::Eq for Mixed {} #[repr(C)] #[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, )] #[cpp_into(bool, to_bool)] pub struct MyBool { @@ -183,18 +129,7 @@ impl MyBool { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Boolish { pub v: i32, } @@ -269,18 +204,7 @@ pub static mut ref_true_8: std::cell::LazyCell = std::cell::LazyCell::n } }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct RefInt { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_compound_assignment_free.rs b/tests/unit/out/unsafe/operator_compound_assignment_free.rs index 0894e1cab6..0824c9924d 100644 --- a/tests/unit/out/unsafe/operator_compound_assignment_free.rs +++ b/tests/unit/out/unsafe/operator_compound_assignment_free.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub v: u32, } diff --git a/tests/unit/out/unsafe/operator_compound_assignment_member.rs b/tests/unit/out/unsafe/operator_compound_assignment_member.rs index 9b6d0d2985..100e10f5a3 100644 --- a/tests/unit/out/unsafe/operator_compound_assignment_member.rs +++ b/tests/unit/out/unsafe/operator_compound_assignment_member.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub v: u32, } diff --git a/tests/unit/out/unsafe/operator_friend.rs b/tests/unit/out/unsafe/operator_friend.rs index 50cc0b0795..3ba64a4c45 100644 --- a/tests/unit/out/unsafe/operator_friend.rs +++ b/tests/unit/out/unsafe/operator_friend.rs @@ -10,18 +10,7 @@ pub unsafe fn operator_eq_0(_a0: *const Defaulted, _a1: *const Defaulted) -> boo return (((*_a0).a) == ((*_a1).a)) && (((*_a0).b) == ((*_a1).b)); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Defaulted { pub a: i32, pub b: i32, @@ -48,18 +37,7 @@ pub unsafe fn operator_eq_2(_a0: *const DefaultedOrd, _a1: *const DefaultedOrd) return (((*_a0).a) == ((*_a1).a)); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct DefaultedOrd { pub a: i32, } @@ -91,18 +69,7 @@ pub unsafe fn operator_add_5(x: *const Inline, y: *const Inline) -> Inline { }; } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Inline { pub a: i32, } @@ -131,18 +98,7 @@ impl std::cmp::PartialEq for Inline { } impl std::cmp::Eq for Inline {} #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct OutOfLine { pub a: i32, } @@ -171,18 +127,7 @@ pub unsafe fn operator_eq_10(x: *const Tmpl_int_, y: *const Tmpl_long_) -> bool return (((*x).v as i64) == ((*y).v)); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Tmpl_int_ { pub v: i32, } @@ -211,18 +156,7 @@ impl std::cmp::PartialEq for Tmpl_int_ { } impl std::cmp::Eq for Tmpl_int_ {} #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Tmpl_long_ { pub v: i64, } @@ -233,18 +167,7 @@ pub unsafe fn operator_eq_11( return (((*_a0).v) == ((*_a1).v)); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct TmplDefaulted_int_ { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_less_than.rs b/tests/unit/out/unsafe/operator_less_than.rs index b92eb7b3d7..5970de3eac 100644 --- a/tests/unit/out/unsafe/operator_less_than.rs +++ b/tests/unit/out/unsafe/operator_less_than.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Pair { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/operator_logical_free.rs b/tests/unit/out/unsafe/operator_logical_free.rs index cc31b7b52b..e816bd7626 100644 --- a/tests/unit/out/unsafe/operator_logical_free.rs +++ b/tests/unit/out/unsafe/operator_logical_free.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_logical_member.rs b/tests/unit/out/unsafe/operator_logical_member.rs index 5a175a2189..41cff80dbb 100644 --- a/tests/unit/out/unsafe/operator_logical_member.rs +++ b/tests/unit/out/unsafe/operator_logical_member.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_member_pointer_free.rs b/tests/unit/out/unsafe/operator_member_pointer_free.rs index 93a51f40f2..878bcffe6a 100644 --- a/tests/unit/out/unsafe/operator_member_pointer_free.rs +++ b/tests/unit/out/unsafe/operator_member_pointer_free.rs @@ -7,34 +7,12 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Inner { pub x: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub data: [i32; 3], pub inner: Inner, diff --git a/tests/unit/out/unsafe/operator_member_pointer_member.rs b/tests/unit/out/unsafe/operator_member_pointer_member.rs index a5dfc26d8a..1fe5fcb357 100644 --- a/tests/unit/out/unsafe/operator_member_pointer_member.rs +++ b/tests/unit/out/unsafe/operator_member_pointer_member.rs @@ -7,34 +7,12 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Inner { pub x: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Table {} impl Table { pub unsafe fn operator_index(mut i: i32) -> *mut i32 { @@ -44,18 +22,7 @@ impl Table { pub static mut table_0: std::cell::LazyCell<[i32; 3]> = std::cell::LazyCell::new(|| unsafe { [7, 8, 9] }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub data: [i32; 3], pub inner: Inner, diff --git a/tests/unit/out/unsafe/operator_other_free.rs b/tests/unit/out/unsafe/operator_other_free.rs index 0b21ff3217..3954e1ceba 100644 --- a/tests/unit/out/unsafe/operator_other_free.rs +++ b/tests/unit/out/unsafe/operator_other_free.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_other_member.rs b/tests/unit/out/unsafe/operator_other_member.rs index 4d32dabead..d1651da5ac 100644 --- a/tests/unit/out/unsafe/operator_other_member.rs +++ b/tests/unit/out/unsafe/operator_other_member.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Static {} impl Static { pub unsafe fn operator_call(mut a: i32, mut b: i32) -> i32 { @@ -27,17 +16,7 @@ impl Static { } #[repr(C)] #[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, )] #[cpp_into(i32, to_i32)] pub struct S { diff --git a/tests/unit/out/unsafe/operator_overloads.rs b/tests/unit/out/unsafe/operator_overloads.rs index 704b1de6c1..1d47d6c67d 100644 --- a/tests/unit/out/unsafe/operator_overloads.rs +++ b/tests/unit/out/unsafe/operator_overloads.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_qualifiers.rs b/tests/unit/out/unsafe/operator_qualifiers.rs index e860530ebc..d35c4227aa 100644 --- a/tests/unit/out/unsafe/operator_qualifiers.rs +++ b/tests/unit/out/unsafe/operator_qualifiers.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_three_way.rs b/tests/unit/out/unsafe/operator_three_way.rs index f65f13b18e..73d7da6018 100644 --- a/tests/unit/out/unsafe/operator_three_way.rs +++ b/tests/unit/out/unsafe/operator_three_way.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_traits.rs b/tests/unit/out/unsafe/operator_traits.rs index 582791c6ee..e7acf1bc3c 100644 --- a/tests/unit/out/unsafe/operator_traits.rs +++ b/tests/unit/out/unsafe/operator_traits.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Lt { pub v: i32, } @@ -55,18 +44,7 @@ impl std::cmp::PartialEq for Lt { } impl std::cmp::Eq for Lt {} #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Eq { pub v: i32, } @@ -82,18 +60,7 @@ impl std::cmp::PartialEq for Eq { } impl std::cmp::Eq for Eq {} #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Cmp { pub v: i32, } @@ -122,18 +89,7 @@ impl std::cmp::PartialEq for Cmp { } impl std::cmp::Eq for Cmp {} #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Free { pub v: i32, } @@ -168,18 +124,7 @@ pub unsafe fn operator_eq_1(a: *const Free, b: *const Free) -> bool { return (((*a).v) == ((*b).v)); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Wrapped_int_ { pub v: i32, } diff --git a/tests/unit/out/unsafe/overload_mangling.rs b/tests/unit/out/unsafe/overload_mangling.rs index e1cd7b9390..8517c5b99e 100644 --- a/tests/unit/out/unsafe/overload_mangling.rs +++ b/tests/unit/out/unsafe/overload_mangling.rs @@ -16,18 +16,7 @@ pub unsafe fn twice_2(mut n: i32) -> i32 { return ((n) * (2)); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Access_S_ {} impl Access_S_ { pub unsafe fn get_1(&mut self, mut p: *mut S) -> i32 { @@ -44,18 +33,7 @@ impl Access_S_ { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub base: i32, } @@ -129,18 +107,7 @@ impl S { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Box_ { pub v: i32, } diff --git a/tests/unit/out/unsafe/pair_converting_construction.rs b/tests/unit/out/unsafe/pair_converting_construction.rs index d42b69c578..ec693a708e 100644 --- a/tests/unit/out/unsafe/pair_converting_construction.rs +++ b/tests/unit/out/unsafe/pair_converting_construction.rs @@ -8,17 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, )] #[cpp_from(i32, construct, value)] pub struct Celsius { @@ -31,17 +21,7 @@ impl Celsius { } #[repr(C)] #[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, )] #[cpp_into(i32, to_i32)] pub struct Meters { @@ -54,17 +34,7 @@ impl Meters { } #[repr(C)] #[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, )] #[cpp_from(Celsius, construct, ptr)] pub struct Label { @@ -77,17 +47,7 @@ impl Label { } #[repr(C)] #[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, )] #[cpp_from(Celsius, construct_1, ptr)] #[cpp_from_move(Celsius, construct_2, ptr)] @@ -107,17 +67,7 @@ impl Owner { } #[repr(C)] #[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, )] #[cpp_from(Celsius, construct, value)] pub struct Holder { @@ -129,18 +79,7 @@ impl Holder { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe)] #[cpp_from(i32, construct, value)] pub struct Fallback { pub value: i32, @@ -162,34 +101,13 @@ impl Default for Fallback { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Counter { pub hits: i32, } #[repr(C)] #[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, )] #[cpp_from(Counter, construct, mut_ptr)] pub struct Observer { @@ -208,17 +126,7 @@ impl Tag { } #[repr(C)] #[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, )] #[cpp_from(Celsius, construct, ptr)] pub struct Tag { @@ -226,17 +134,7 @@ pub struct Tag { } #[repr(C)] #[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, )] #[cpp_from(*const libc::c_char , construct, value)] pub struct Name { diff --git a/tests/unit/out/unsafe/pod.rs b/tests/unit/out/unsafe/pod.rs index de1a2a34a0..34689f2c9c 100644 --- a/tests/unit/out/unsafe/pod.rs +++ b/tests/unit/out/unsafe/pod.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct POD { pub x1: i32, pub x2: i32, diff --git a/tests/unit/out/unsafe/pointer_array.rs b/tests/unit/out/unsafe/pointer_array.rs index b384ba916d..c88b6d8f81 100644 --- a/tests/unit/out/unsafe/pointer_array.rs +++ b/tests/unit/out/unsafe/pointer_array.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct StackArray { pub arr: [*mut i32; 3], } diff --git a/tests/unit/out/unsafe/pointers.rs b/tests/unit/out/unsafe/pointers.rs index 4b8c2a8b49..43e868fa8a 100644 --- a/tests/unit/out/unsafe/pointers.rs +++ b/tests/unit/out/unsafe/pointers.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Test { pub x: i32, } diff --git a/tests/unit/out/unsafe/polymorphism.rs b/tests/unit/out/unsafe/polymorphism.rs index da0c53e34e..9ce091d5f3 100644 --- a/tests/unit/out/unsafe/polymorphism.rs +++ b/tests/unit/out/unsafe/polymorphism.rs @@ -10,32 +10,10 @@ pub unsafe trait Animal { unsafe fn bark(&self) -> bool; } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Dog {} #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Cat {} impl Cat { unsafe fn meow(&self) -> bool { diff --git a/tests/unit/out/unsafe/ptr_cast_init.rs b/tests/unit/out/unsafe/ptr_cast_init.rs index bf827f8f3c..2d9b922bff 100644 --- a/tests/unit/out/unsafe/ptr_cast_init.rs +++ b/tests/unit/out/unsafe/ptr_cast_init.rs @@ -7,35 +7,13 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct header { pub tag: i32, pub size: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct view { pub tag: i32, } diff --git a/tests/unit/out/unsafe/push_emplace_back.rs b/tests/unit/out/unsafe/push_emplace_back.rs index 3b4bb7081b..5a2ddf98f5 100644 --- a/tests/unit/out/unsafe/push_emplace_back.rs +++ b/tests/unit/out/unsafe/push_emplace_back.rs @@ -7,34 +7,12 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Chunk { pub data: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Writer { pub output: *mut Vec, pub chunk: Chunk, @@ -136,18 +114,7 @@ pub unsafe fn self_ref_push_6(mut comps: *mut Vec) { }; } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe)] #[cpp_from(i32, construct_1, value)] pub struct Pair { pub first: i32, @@ -300,18 +267,7 @@ pub unsafe fn emplace_from_element_14(mut v: *mut Vec>) { }); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Plain { pub a: i32, pub b: [f64; 2], @@ -326,18 +282,7 @@ pub unsafe fn emplace_plain_15(mut v: *mut Vec) { pub static mut all_counted_16: std::cell::LazyCell<*mut Vec> = std::cell::LazyCell::new(|| unsafe { std::ptr::null_mut() }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Counted { pub seen: usize, } diff --git a/tests/unit/out/unsafe/random.rs b/tests/unit/out/unsafe/random.rs index 16b125e40d..fc319c167a 100644 --- a/tests/unit/out/unsafe/random.rs +++ b/tests/unit/out/unsafe/random.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Pair { pub x: i32, pub y: i32, @@ -52,18 +41,7 @@ pub unsafe fn zero_0() -> i32 { return 0; } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct X1 {} pub unsafe fn foo_1(mut x1: i32, x2: *mut i32, mut x3: *mut i32, p2: *mut Pair, mut p3: *mut Pair) { } diff --git a/tests/unit/out/unsafe/reference_wrapper.rs b/tests/unit/out/unsafe/reference_wrapper.rs index d7a7cbb2b8..d57fa6cbd6 100644 --- a/tests/unit/out/unsafe/reference_wrapper.rs +++ b/tests/unit/out/unsafe/reference_wrapper.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Point { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/references.rs b/tests/unit/out/unsafe/references.rs index 18c384a8d2..a0dee4bba9 100644 --- a/tests/unit/out/unsafe/references.rs +++ b/tests/unit/out/unsafe/references.rs @@ -7,36 +7,14 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Pair { pub x: i32, pub y: i32, pub arr: [i32; 2], } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Nested { pub p: Pair, } diff --git a/tests/unit/out/unsafe/refs_as_args.rs b/tests/unit/out/unsafe/refs_as_args.rs index 962b87863a..d956f72b7e 100644 --- a/tests/unit/out/unsafe/refs_as_args.rs +++ b/tests/unit/out/unsafe/refs_as_args.rs @@ -18,18 +18,7 @@ pub unsafe fn more_refs_0(mut x1: i32, mut x2: i32, r1: *mut i32, r2: *const i32 (*r1) = (*rx2); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Val { pub x: i32, } diff --git a/tests/unit/out/unsafe/reinterpret_cast_ptr_cmp.rs b/tests/unit/out/unsafe/reinterpret_cast_ptr_cmp.rs index 5ac98d6b52..94b2dd39a3 100644 --- a/tests/unit/out/unsafe/reinterpret_cast_ptr_cmp.rs +++ b/tests/unit/out/unsafe/reinterpret_cast_ptr_cmp.rs @@ -7,52 +7,19 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub x: i32, pub y: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct W { pub h: i32, pub arr: [S; 3], } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct P { pub a: *mut i32, pub arr: [*mut i32; 3], diff --git a/tests/unit/out/unsafe/reinterpret_cast_struct.rs b/tests/unit/out/unsafe/reinterpret_cast_struct.rs index d0fcd3c68b..5b4a26a03b 100644 --- a/tests/unit/out/unsafe/reinterpret_cast_struct.rs +++ b/tests/unit/out/unsafe/reinterpret_cast_struct.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Point { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/reinterpret_cast_struct_to_struct.rs b/tests/unit/out/unsafe/reinterpret_cast_struct_to_struct.rs index 72500598c6..c66149ba7f 100644 --- a/tests/unit/out/unsafe/reinterpret_cast_struct_to_struct.rs +++ b/tests/unit/out/unsafe/reinterpret_cast_struct_to_struct.rs @@ -7,35 +7,13 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Point { pub x: u32, pub y: u32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Pair { pub first: u32, pub second: u32, diff --git a/tests/unit/out/unsafe/reserved_keywords.rs b/tests/unit/out/unsafe/reserved_keywords.rs index 102ee287e8..33cc38b036 100644 --- a/tests/unit/out/unsafe/reserved_keywords.rs +++ b/tests/unit/out/unsafe/reserved_keywords.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub as_: i32, pub async_: i32, @@ -60,34 +49,12 @@ pub struct S { pub vec_: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct type_ { pub v: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct loop_ { pub t: type_, } diff --git a/tests/unit/out/unsafe/return_move.rs b/tests/unit/out/unsafe/return_move.rs index 38b3016ad4..108c676409 100644 --- a/tests/unit/out/unsafe/return_move.rs +++ b/tests/unit/out/unsafe/return_move.rs @@ -7,35 +7,13 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct node { pub value: i32, pub next: *mut node, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct pair_t { pub a: i32, pub n: *mut node, diff --git a/tests/unit/out/unsafe/rvalue_struct.rs b/tests/unit/out/unsafe/rvalue_struct.rs index 06509535f4..f399667614 100644 --- a/tests/unit/out/unsafe/rvalue_struct.rs +++ b/tests/unit/out/unsafe/rvalue_struct.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub a: i32, pub b: i32, diff --git a/tests/unit/out/unsafe/scalar_builtin_construct_destruct.rs b/tests/unit/out/unsafe/scalar_builtin_construct_destruct.rs index 89cfbe56e6..df7502a789 100644 --- a/tests/unit/out/unsafe/scalar_builtin_construct_destruct.rs +++ b/tests/unit/out/unsafe/scalar_builtin_construct_destruct.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Pod { pub v: i32, } diff --git a/tests/unit/out/unsafe/self_referencing_initializer.rs b/tests/unit/out/unsafe/self_referencing_initializer.rs index 6d130f69ca..18e3907031 100644 --- a/tests/unit/out/unsafe/self_referencing_initializer.rs +++ b/tests/unit/out/unsafe/self_referencing_initializer.rs @@ -7,50 +7,18 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct list_head { pub next: *mut list_head, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct node { pub value: i32, pub value_ptr: *mut i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct node_with_defaults { pub next: *mut node_with_defaults, pub value: i32, diff --git a/tests/unit/out/unsafe/size_t_static_member.rs b/tests/unit/out/unsafe/size_t_static_member.rs index 22f0869f50..f14939a058 100644 --- a/tests/unit/out/unsafe/size_t_static_member.rs +++ b/tests/unit/out/unsafe/size_t_static_member.rs @@ -8,34 +8,12 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub static mut c_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 5_usize }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S {} pub static mut table_size_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 256_usize }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Table_char_ {} pub fn main() { unsafe { diff --git a/tests/unit/out/unsafe/size_t_template_param.rs b/tests/unit/out/unsafe/size_t_template_param.rs index 5c833f0413..603d6c8597 100644 --- a/tests/unit/out/unsafe/size_t_template_param.rs +++ b/tests/unit/out/unsafe/size_t_template_param.rs @@ -12,17 +12,7 @@ pub unsafe fn array_ref_0(a: *mut [u64; 3]) -> u64 { } #[repr(C)] #[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, )] #[cpp_from(*const u64 , construct, value)] pub struct PtrCtor_unsigned_long_ { @@ -35,17 +25,7 @@ impl PtrCtor_unsigned_long_ { } #[repr(C)] #[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, )] #[cpp_from(u64, construct, ptr)] pub struct RefCtor_unsigned_long_ { diff --git a/tests/unit/out/unsafe/static_local.rs b/tests/unit/out/unsafe/static_local.rs index 7430113d6c..cc490e3768 100644 --- a/tests/unit/out/unsafe/static_local.rs +++ b/tests/unit/out/unsafe/static_local.rs @@ -22,18 +22,7 @@ pub unsafe fn from_local_class_6() -> i32 { } static mut x_7: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 3 }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S_8 {} impl S_8 { pub unsafe fn get(&self) -> i32 { diff --git a/tests/unit/out/unsafe/static_var_in_class.rs b/tests/unit/out/unsafe/static_var_in_class.rs index b039adb0ae..7f5023a8ea 100644 --- a/tests/unit/out/unsafe/static_var_in_class.rs +++ b/tests/unit/out/unsafe/static_var_in_class.rs @@ -8,18 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; static mut inner_const_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 1 }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct C {} impl C { pub unsafe fn get(&mut self) -> i32 { @@ -30,18 +19,7 @@ pub static mut inner_const_1: std::cell::LazyCell = std::cell::LazyCell::ne pub type anon_3 = u32; pub const anon_3_kValue: anon_3 = 3; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S {} impl S { pub unsafe fn f() -> i32 { diff --git a/tests/unit/out/unsafe/stdcopy.rs b/tests/unit/out/unsafe/stdcopy.rs index ff6cc9c0ed..8cef708dc0 100644 --- a/tests/unit/out/unsafe/stdcopy.rs +++ b/tests/unit/out/unsafe/stdcopy.rs @@ -8,17 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, )] #[cpp_from(i32, construct, value)] pub struct Degrees { diff --git a/tests/unit/out/unsafe/strdup.rs b/tests/unit/out/unsafe/strdup.rs index c16cc7309d..0d10b728da 100644 --- a/tests/unit/out/unsafe/strdup.rs +++ b/tests/unit/out/unsafe/strdup.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct record { pub name: *mut libc::c_char, } diff --git a/tests/unit/out/unsafe/string_literal_ptr_init.rs b/tests/unit/out/unsafe/string_literal_ptr_init.rs index e125a7c07f..3288ac7036 100644 --- a/tests/unit/out/unsafe/string_literal_ptr_init.rs +++ b/tests/unit/out/unsafe/string_literal_ptr_init.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct label { pub name: *const libc::c_char, pub probe: Option i32>, diff --git a/tests/unit/out/unsafe/string_substr.rs b/tests/unit/out/unsafe/string_substr.rs index 255ce85c83..0c76c958c8 100644 --- a/tests/unit/out/unsafe/string_substr.rs +++ b/tests/unit/out/unsafe/string_substr.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Text { pub value: *mut Vec, } diff --git a/tests/unit/out/unsafe/struct_2d_array_field.rs b/tests/unit/out/unsafe/struct_2d_array_field.rs index c2e4f69519..f27e9b7151 100644 --- a/tests/unit/out/unsafe/struct_2d_array_field.rs +++ b/tests/unit/out/unsafe/struct_2d_array_field.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct table { pub rows: [[libc::c_char; 10]; 3], pub count: usize, diff --git a/tests/unit/out/unsafe/struct_ctor.rs b/tests/unit/out/unsafe/struct_ctor.rs index 9f727c63bd..48b6b0eed0 100644 --- a/tests/unit/out/unsafe/struct_ctor.rs +++ b/tests/unit/out/unsafe/struct_ctor.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct StructWithCtor { x1_: i32, x2_: i32, @@ -42,17 +31,7 @@ pub unsafe fn foo_0(x: *mut i32) -> *mut i32 { } #[repr(C)] #[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, )] #[cpp_from(i32, construct, value)] pub struct Value_ { @@ -64,17 +43,7 @@ impl Value_ { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct Ptr_ { pub v1: Value_, pub v2: Value_, diff --git a/tests/unit/out/unsafe/struct_default_ctor.rs b/tests/unit/out/unsafe/struct_default_ctor.rs index ca0dc49c5f..c3e8fddcac 100644 --- a/tests/unit/out/unsafe/struct_default_ctor.rs +++ b/tests/unit/out/unsafe/struct_default_ctor.rs @@ -7,17 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct S { pub a: i32, pub b: bool, @@ -40,51 +30,19 @@ impl Default for S { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Declared { pub v: i32, } impl Declared {} #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Holder { pub items: [S; 2], } pub static mut kInit_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 3 }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct FromStatic { pub v: i32, } diff --git a/tests/unit/out/unsafe/struct_member_array_adjacency.rs b/tests/unit/out/unsafe/struct_member_array_adjacency.rs index e2f4e04a66..277b27a2d3 100644 --- a/tests/unit/out/unsafe/struct_member_array_adjacency.rs +++ b/tests/unit/out/unsafe/struct_member_array_adjacency.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct pair { pub a: [i32; 4], pub b: [i32; 4], diff --git a/tests/unit/out/unsafe/struct_ptr.rs b/tests/unit/out/unsafe/struct_ptr.rs index 892919cb4f..fc1c71b81a 100644 --- a/tests/unit/out/unsafe/struct_ptr.rs +++ b/tests/unit/out/unsafe/struct_ptr.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct XX { pub x: i32, } diff --git a/tests/unit/out/unsafe/structured_binding_range_for.rs b/tests/unit/out/unsafe/structured_binding_range_for.rs index 0ac56b67ab..ae669cc725 100644 --- a/tests/unit/out/unsafe/structured_binding_range_for.rs +++ b/tests/unit/out/unsafe/structured_binding_range_for.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Pair { pub first: i32, pub second: i32, diff --git a/tests/unit/out/unsafe/structured_binding_ref.rs b/tests/unit/out/unsafe/structured_binding_ref.rs index 077982f137..44c820232f 100644 --- a/tests/unit/out/unsafe/structured_binding_ref.rs +++ b/tests/unit/out/unsafe/structured_binding_ref.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Triple { pub a: i32, pub b: bool, diff --git a/tests/unit/out/unsafe/structured_binding_trivial.rs b/tests/unit/out/unsafe/structured_binding_trivial.rs index c81ea16ee2..c095ef628e 100644 --- a/tests/unit/out/unsafe/structured_binding_trivial.rs +++ b/tests/unit/out/unsafe/structured_binding_trivial.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Pair { pub first: i32, pub second: i32, diff --git a/tests/unit/out/unsafe/tag_vs_identifier_collision.rs b/tests/unit/out/unsafe/tag_vs_identifier_collision.rs index 960b282eae..891720e11b 100644 --- a/tests/unit/out/unsafe/tag_vs_identifier_collision.rs +++ b/tests/unit/out/unsafe/tag_vs_identifier_collision.rs @@ -11,51 +11,19 @@ pub const widget_enum_MODE_IDLE: widget_enum = 0; pub const widget_enum_MODE_ACTIVE: widget_enum = 1; pub const widget_enum_MODE_DONE: widget_enum = 2; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct widget { pub id: i32, pub mode: widget_enum, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct point_struct { pub x: i32, pub y: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - FnPtrArg, - VaArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub union point { pub whole: i32, pub half: i16, @@ -66,17 +34,7 @@ impl Default for point { } } #[repr(C)] -#[derive( - Copy, - Clone, - FnPtrArg, - VaArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub union slot_union { pub i: i32, pub u: u32, @@ -90,50 +48,17 @@ pub type slot = u32; pub const slot_SLOT_A: slot = 0; pub const slot_SLOT_B: slot = 1; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Inner { pub tag_field: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Outer { pub field: Inner, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Inner_struct { pub typedef_field: i32, } diff --git a/tests/unit/out/unsafe/template_default_arg.rs b/tests/unit/out/unsafe/template_default_arg.rs index b5e50d6986..45e17aaae5 100644 --- a/tests/unit/out/unsafe/template_default_arg.rs +++ b/tests/unit/out/unsafe/template_default_arg.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe)] #[cpp_from(i32, construct_1, value)] pub struct A { pub v: i32, @@ -43,17 +32,7 @@ impl Default for A { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct B { pub v: i32, } @@ -75,17 +54,7 @@ impl Default for B { } #[repr(C)] #[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, )] #[cpp_from(i32, construct, value)] pub struct NoDefault { @@ -110,17 +79,7 @@ pub unsafe fn always_given_3(mut x: NoDefault) -> i32 { } #[repr(C)] #[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, )] #[cpp_from(i32, construct, value)] pub struct S_NoDefault_ { diff --git a/tests/unit/out/unsafe/template_static_member.rs b/tests/unit/out/unsafe/template_static_member.rs index 290f827e88..0db609551f 100644 --- a/tests/unit/out/unsafe/template_static_member.rs +++ b/tests/unit/out/unsafe/template_static_member.rs @@ -8,82 +8,27 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub static mut s_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 55 }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Static_int_ {} pub static mut s_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { (55 as libc::c_char) }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Static_char_ {} pub static mut s_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 55_i64 }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Static_long_ {} pub static mut lo_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { -1_i32 }); pub static mut hi_4: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 1 }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Range_int_ {} pub static mut lo_5: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { (-2_i32 as i64) }); pub static mut hi_6: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 2_i64 }); #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Range_long_ {} pub fn main() { unsafe { diff --git a/tests/unit/out/unsafe/temporary_field_ctor_arg.rs b/tests/unit/out/unsafe/temporary_field_ctor_arg.rs index 9b27f4719e..0e0f710774 100644 --- a/tests/unit/out/unsafe/temporary_field_ctor_arg.rs +++ b/tests/unit/out/unsafe/temporary_field_ctor_arg.rs @@ -39,17 +39,7 @@ pub unsafe fn make_0() -> Outer { } #[repr(C)] #[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, )] #[cpp_from(Vec , construct, ptr)] pub struct H { diff --git a/tests/unit/out/unsafe/this.rs b/tests/unit/out/unsafe/this.rs index e6d3e1445d..19b8a849a4 100644 --- a/tests/unit/out/unsafe/this.rs +++ b/tests/unit/out/unsafe/this.rs @@ -8,17 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, )] #[cpp_from(i32, construct_1, value)] pub struct S { @@ -114,17 +104,7 @@ pub unsafe fn bump_0(mut p: *mut S) { } #[repr(C)] #[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, )] #[cpp_from(i32, construct, value)] pub struct D { diff --git a/tests/unit/out/unsafe/typedef-anon-struct.rs b/tests/unit/out/unsafe/typedef-anon-struct.rs index d0ca058a5c..b37a5be404 100644 --- a/tests/unit/out/unsafe/typedef-anon-struct.rs +++ b/tests/unit/out/unsafe/typedef-anon-struct.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Outer_RunInfo { pub block_idx: i32, pub num_extra_zero_runs: i32, diff --git a/tests/unit/out/unsafe/unary_expr_or_type_trait.rs b/tests/unit/out/unsafe/unary_expr_or_type_trait.rs index 7688e810f0..15783857d2 100644 --- a/tests/unit/out/unsafe/unary_expr_or_type_trait.rs +++ b/tests/unit/out/unsafe/unary_expr_or_type_trait.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C, align(16))] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub c: libc::c_char, pub x: i64, diff --git a/tests/unit/out/unsafe/unboxed_locals.rs b/tests/unit/out/unsafe/unboxed_locals.rs index 240dd6f42d..6e43286da6 100644 --- a/tests/unit/out/unsafe/unboxed_locals.rs +++ b/tests/unit/out/unsafe/unboxed_locals.rs @@ -13,18 +13,7 @@ pub unsafe fn inc_1(r: *mut i32) { (*r).prefix_inc(); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Pair { pub first: i32, pub second: i32, @@ -62,17 +51,7 @@ pub unsafe trait Shape { unsafe fn scale(&mut self, factor: i32) -> i32; } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct Square { pub side: i32, } diff --git a/tests/unit/out/unsafe/unboxed_records.rs b/tests/unit/out/unsafe/unboxed_records.rs index dd244ca80f..a075e8bc84 100644 --- a/tests/unit/out/unsafe/unboxed_records.rs +++ b/tests/unit/out/unsafe/unboxed_records.rs @@ -7,35 +7,13 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Inner { pub a: i32, pub b: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Cookie { pub x: i32, pub data: *mut i32, @@ -44,17 +22,7 @@ pub struct Cookie { pub arr: [i32; 4], } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct Counter { pub n: i32, } diff --git a/tests/unit/out/unsafe/union_addrof_external.rs b/tests/unit/out/unsafe/union_addrof_external.rs index b0e921749e..e528547503 100644 --- a/tests/unit/out/unsafe/union_addrof_external.rs +++ b/tests/unit/out/unsafe/union_addrof_external.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct record { pub code: u16, pub lo: u16, @@ -26,17 +15,7 @@ pub struct record { pub pad: [libc::c_char; 8], } #[repr(C)] -#[derive( - Copy, - Clone, - FnPtrArg, - VaArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub union anon_0 { pub h: record, pub raw_: [libc::c_char; 128], @@ -47,18 +26,7 @@ impl Default for anon_0 { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Container { pub view: anon_0, } diff --git a/tests/unit/out/unsafe/union_basic.rs b/tests/unit/out/unsafe/union_basic.rs index 60040ba39d..bad81ff98b 100644 --- a/tests/unit/out/unsafe/union_basic.rs +++ b/tests/unit/out/unsafe/union_basic.rs @@ -7,17 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - FnPtrArg, - VaArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub union basic { pub i: i32, pub f: f32, @@ -28,17 +18,7 @@ impl Default for basic { } } #[repr(C)] -#[derive( - Copy, - Clone, - FnPtrArg, - VaArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub union empty { __empty: u8, } @@ -48,17 +28,7 @@ impl Default for empty { } } #[repr(C)] -#[derive( - Copy, - Clone, - FnPtrArg, - VaArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub union underscores { pub __: i32, pub ___: f64, @@ -121,17 +91,7 @@ unsafe fn main_0() -> i32 { return 0; } #[repr(C)] -#[derive( - Copy, - Clone, - FnPtrArg, - VaArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub union anon_0 { pub ai: i32, pub af: f32, diff --git a/tests/unit/out/unsafe/union_cross_arm_cast.rs b/tests/unit/out/unsafe/union_cross_arm_cast.rs index ccf6772e28..66cb544d2b 100644 --- a/tests/unit/out/unsafe/union_cross_arm_cast.rs +++ b/tests/unit/out/unsafe/union_cross_arm_cast.rs @@ -7,35 +7,13 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct shape_a { pub code: u16, pub pad: [libc::c_char; 14], } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct shape_b { pub code: u16, pub lo: u16, @@ -44,17 +22,7 @@ pub struct shape_b { pub tail: u32, } #[repr(C)] -#[derive( - Copy, - Clone, - FnPtrArg, - VaArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub union anon_0 { pub a: shape_a, pub b: shape_b, @@ -66,18 +34,7 @@ impl Default for anon_0 { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Container { pub len: u32, pub u: anon_0, diff --git a/tests/unit/out/unsafe/union_field_alignment.rs b/tests/unit/out/unsafe/union_field_alignment.rs index c1f961ad34..9ccd73525a 100644 --- a/tests/unit/out/unsafe/union_field_alignment.rs +++ b/tests/unit/out/unsafe/union_field_alignment.rs @@ -7,17 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - FnPtrArg, - VaArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub union anon_0 { pub bytes: [u8; 1], pub aligner: *mut ::libc::c_void, @@ -28,18 +18,7 @@ impl Default for anon_0 { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct node { pub next: *mut node, pub x: anon_0, diff --git a/tests/unit/out/unsafe/union_flex_array_member.rs b/tests/unit/out/unsafe/union_flex_array_member.rs index fd3182483a..cfd32ac686 100644 --- a/tests/unit/out/unsafe/union_flex_array_member.rs +++ b/tests/unit/out/unsafe/union_flex_array_member.rs @@ -7,17 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - FnPtrArg, - VaArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub union anon_0 { pub bytes: [u8; 1], pub aligner: *mut ::libc::c_void, @@ -28,18 +18,7 @@ impl Default for anon_0 { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct node { pub len: usize, pub pos: usize, diff --git a/tests/unit/out/unsafe/union_memset_memcpy.rs b/tests/unit/out/unsafe/union_memset_memcpy.rs index 1ffeb07004..f1159bfaec 100644 --- a/tests/unit/out/unsafe/union_memset_memcpy.rs +++ b/tests/unit/out/unsafe/union_memset_memcpy.rs @@ -7,35 +7,13 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct shape_a { pub code: u16, pub pad: [libc::c_char; 14], } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct shape_b { pub code: u16, pub lo: u16, @@ -43,17 +21,7 @@ pub struct shape_b { pub fill: [libc::c_char; 8], } #[repr(C)] -#[derive( - Copy, - Clone, - FnPtrArg, - VaArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub union anon_0 { pub a: shape_a, pub b: shape_b, @@ -65,18 +33,7 @@ impl Default for anon_0 { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Container { pub view: anon_0, } diff --git a/tests/unit/out/unsafe/union_nested.rs b/tests/unit/out/unsafe/union_nested.rs index 7bd85ab3e5..c4ed21041c 100644 --- a/tests/unit/out/unsafe/union_nested.rs +++ b/tests/unit/out/unsafe/union_nested.rs @@ -7,34 +7,13 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct record { pub code: u16, pub pad: [libc::c_char; 14], } #[repr(C)] -#[derive( - Copy, - Clone, - FnPtrArg, - VaArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub union anon_0 { pub h: record, pub raw_: [libc::c_char; 128], @@ -45,33 +24,12 @@ impl Default for anon_0 { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct inner { pub view: anon_0, } #[repr(C)] -#[derive( - Copy, - Clone, - FnPtrArg, - VaArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub union anon_1 { pub h: record, pub nested: inner, @@ -82,18 +40,7 @@ impl Default for anon_1 { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Outer { pub kind: i32, pub level: i32, diff --git a/tests/unit/out/unsafe/union_pointer_pun_address.rs b/tests/unit/out/unsafe/union_pointer_pun_address.rs index ac517bdb91..5077027082 100644 --- a/tests/unit/out/unsafe/union_pointer_pun_address.rs +++ b/tests/unit/out/unsafe/union_pointer_pun_address.rs @@ -7,34 +7,12 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct node_a { pub n: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct node_b { pub data: *mut ::libc::c_void, pub next: *mut node_b, @@ -54,17 +32,7 @@ unsafe fn main_0() -> i32 { return 0; } #[repr(C)] -#[derive( - Copy, - Clone, - FnPtrArg, - VaArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub union anon_0 { pub to_a: *mut node_a, pub to_b: *mut node_b, diff --git a/tests/unit/out/unsafe/union_pointer_pun_writethrough.rs b/tests/unit/out/unsafe/union_pointer_pun_writethrough.rs index d32f3e0f2e..9d90cadf05 100644 --- a/tests/unit/out/unsafe/union_pointer_pun_writethrough.rs +++ b/tests/unit/out/unsafe/union_pointer_pun_writethrough.rs @@ -21,17 +21,7 @@ unsafe fn main_0() -> i32 { return 0; } #[repr(C)] -#[derive( - Copy, - Clone, - FnPtrArg, - VaArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub union anon_0 { pub as_unsigned: *mut u64, pub as_signed: *mut i64, diff --git a/tests/unit/out/unsafe/union_struct_dual_use.rs b/tests/unit/out/unsafe/union_struct_dual_use.rs index fcb014f0eb..06895c1dbb 100644 --- a/tests/unit/out/unsafe/union_struct_dual_use.rs +++ b/tests/unit/out/unsafe/union_struct_dual_use.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Inner { pub a: i32, pub b: i32, @@ -27,17 +16,7 @@ pub unsafe fn sum_inner_0(mut i: *mut Inner) -> i32 { return (((*i).a) + ((*i).b)); } #[repr(C)] -#[derive( - Copy, - Clone, - FnPtrArg, - VaArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub union anon_1 { pub inner: Inner, pub raw_: [libc::c_char; 16], @@ -48,18 +27,7 @@ impl Default for anon_1 { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Outer { pub u: anon_1, } diff --git a/tests/unit/out/unsafe/union_tagged_many_arms.rs b/tests/unit/out/unsafe/union_tagged_many_arms.rs index 955eebc215..6bdb7e38e4 100644 --- a/tests/unit/out/unsafe/union_tagged_many_arms.rs +++ b/tests/unit/out/unsafe/union_tagged_many_arms.rs @@ -13,17 +13,7 @@ pub const Tag_enum_T_TEXT: Tag_enum = 2; pub const Tag_enum_T_FLOAT: Tag_enum = 3; pub const Tag_enum_T_REF: Tag_enum = 4; #[repr(C)] -#[derive( - Copy, - Clone, - FnPtrArg, - VaArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub union anon_0 { pub text: *const libc::c_char, pub handle: *mut ::libc::c_void, @@ -37,18 +27,7 @@ impl Default for anon_0 { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Slot { pub tag: Tag_enum, pub payload: anon_0, diff --git a/tests/unit/out/unsafe/union_tagged_simple.rs b/tests/unit/out/unsafe/union_tagged_simple.rs index 5b5d36a81c..0b26fca50a 100644 --- a/tests/unit/out/unsafe/union_tagged_simple.rs +++ b/tests/unit/out/unsafe/union_tagged_simple.rs @@ -10,17 +10,7 @@ pub type Kind_enum = u32; pub const Kind_enum_KIND_NONE: Kind_enum = 0; pub const Kind_enum_KIND_DONE: Kind_enum = 1; #[repr(C)] -#[derive( - Copy, - Clone, - FnPtrArg, - VaArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub union anon_0 { pub obj: *mut ::libc::c_void, pub code: i32, @@ -31,18 +21,7 @@ impl Default for anon_0 { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Event { pub kind: Kind_enum, pub handle: *mut ::libc::c_void, diff --git a/tests/unit/out/unsafe/union_tagged_struct_arms.rs b/tests/unit/out/unsafe/union_tagged_struct_arms.rs index 4b1d4e930e..604c7bf25d 100644 --- a/tests/unit/out/unsafe/union_tagged_struct_arms.rs +++ b/tests/unit/out/unsafe/union_tagged_struct_arms.rs @@ -11,36 +11,14 @@ pub const Choice_enum_C_LIST: Choice_enum = 1; pub const Choice_enum_C_LETTERS: Choice_enum = 2; pub const Choice_enum_C_INTEGERS: Choice_enum = 3; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct anon_1 { pub items: *mut *mut libc::c_char, pub count: i64, pub cursor: i64, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct anon_2 { pub lo: i32, pub hi: i32, @@ -48,18 +26,7 @@ pub struct anon_2 { pub step: u8, } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct anon_3 { pub lo: i64, pub hi: i64, @@ -68,17 +35,7 @@ pub struct anon_3 { pub width: i32, } #[repr(C)] -#[derive( - Copy, - Clone, - FnPtrArg, - VaArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub union anon_0 { pub list: anon_1, pub letters: anon_2, @@ -90,18 +47,7 @@ impl Default for anon_0 { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Branch { pub choice: Choice_enum, pub index: i32, diff --git a/tests/unit/out/unsafe/union_void_ptr_sized_deref.rs b/tests/unit/out/unsafe/union_void_ptr_sized_deref.rs index ec79d3e132..0f1ec7bf1a 100644 --- a/tests/unit/out/unsafe/union_void_ptr_sized_deref.rs +++ b/tests/unit/out/unsafe/union_void_ptr_sized_deref.rs @@ -11,17 +11,7 @@ pub const Width_enum_W_64: Width_enum = 0; pub const Width_enum_W_32: Width_enum = 1; pub const Width_enum_W_16: Width_enum = 2; #[repr(C)] -#[derive( - Copy, - Clone, - FnPtrArg, - VaArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub union anon_0 { pub text: *const libc::c_char, pub handle: *mut ::libc::c_void, @@ -34,18 +24,7 @@ impl Default for anon_0 { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Sink { pub width: Width_enum, pub out: anon_0, diff --git a/tests/unit/out/unsafe/unique_ptr.rs b/tests/unit/out/unsafe/unique_ptr.rs index 55dbd09aff..d0b8fca75e 100644 --- a/tests/unit/out/unsafe/unique_ptr.rs +++ b/tests/unit/out/unsafe/unique_ptr.rs @@ -34,18 +34,7 @@ impl MoveAssignableUnsafe for SafePointer { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Pair { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/unique_ptr_field_reset.rs b/tests/unit/out/unsafe/unique_ptr_field_reset.rs index 0d623841a3..a6da20a903 100644 --- a/tests/unit/out/unsafe/unique_ptr_field_reset.rs +++ b/tests/unit/out/unsafe/unique_ptr_field_reset.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Data { pub v: i32, } diff --git a/tests/unit/out/unsafe/unique_ptr_nested.rs b/tests/unit/out/unsafe/unique_ptr_nested.rs index 7edafe860c..9a60f9563d 100644 --- a/tests/unit/out/unsafe/unique_ptr_nested.rs +++ b/tests/unit/out/unsafe/unique_ptr_nested.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Inner { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/unique_ptr_struct.rs b/tests/unit/out/unsafe/unique_ptr_struct.rs index 15a975517a..89f55ddbe5 100644 --- a/tests/unit/out/unsafe/unique_ptr_struct.rs +++ b/tests/unit/out/unsafe/unique_ptr_struct.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Point { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/va_arg_mixed_types.rs b/tests/unit/out/unsafe/va_arg_mixed_types.rs index 7a48193d35..a576ddf435 100644 --- a/tests/unit/out/unsafe/va_arg_mixed_types.rs +++ b/tests/unit/out/unsafe/va_arg_mixed_types.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct pair { pub a: i32, pub b: i32, diff --git a/tests/unit/out/unsafe/va_arg_non_primitive_ptrs.rs b/tests/unit/out/unsafe/va_arg_non_primitive_ptrs.rs index 3f86b46ea4..a7acfb87fd 100644 --- a/tests/unit/out/unsafe/va_arg_non_primitive_ptrs.rs +++ b/tests/unit/out/unsafe/va_arg_non_primitive_ptrs.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct node { pub data: i32, pub next: *mut node, diff --git a/tests/unit/out/unsafe/va_arg_struct_ctx.rs b/tests/unit/out/unsafe/va_arg_struct_ctx.rs index ee076861cb..3b03e14b09 100644 --- a/tests/unit/out/unsafe/va_arg_struct_ctx.rs +++ b/tests/unit/out/unsafe/va_arg_struct_ctx.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct context { pub verbose: i32, pub last_error: i32, @@ -35,17 +24,7 @@ pub unsafe fn set_error_0( } } #[repr(C)] -#[derive( - Copy, - Clone, - FnPtrArg, - VaArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, -)] +#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub union value { pub i: i32, pub l: i64, diff --git a/tests/unit/out/unsafe/va_arg_void_ptr.rs b/tests/unit/out/unsafe/va_arg_void_ptr.rs index 9404400fe8..9244c8aecb 100644 --- a/tests/unit/out/unsafe/va_arg_void_ptr.rs +++ b/tests/unit/out/unsafe/va_arg_void_ptr.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct registry { pub slot: *mut ::libc::c_void, pub level: i64, diff --git a/tests/unit/out/unsafe/va_list_field.rs b/tests/unit/out/unsafe/va_list_field.rs index 0aa081a2f4..8121920242 100644 --- a/tests/unit/out/unsafe/va_list_field.rs +++ b/tests/unit/out/unsafe/va_list_field.rs @@ -37,10 +37,7 @@ pub unsafe fn sum_0(mut n: i32, __args: Box<[VaArg]>) -> i32 { ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, + CopyableUnsafe, Default, )] #[cpp_from(*const VaArg , construct, mut_ptr)] @@ -76,18 +73,7 @@ pub unsafe fn sum_ptr_2(mut n: i32, __args: Box<[VaArg]>) -> i32 { return total; } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Cursor_3 { pub ap: *mut *const VaArg, } diff --git a/tests/unit/out/unsafe/vector.rs b/tests/unit/out/unsafe/vector.rs index dfd4e95435..f168f2ec0e 100644 --- a/tests/unit/out/unsafe/vector.rs +++ b/tests/unit/out/unsafe/vector.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub x: i32, } diff --git a/tests/unit/out/unsafe/vector_iter_range_ctor.rs b/tests/unit/out/unsafe/vector_iter_range_ctor.rs index 9e16e89071..babc06d04c 100644 --- a/tests/unit/out/unsafe/vector_iter_range_ctor.rs +++ b/tests/unit/out/unsafe/vector_iter_range_ctor.rs @@ -8,17 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, )] #[cpp_from(i32, construct, value)] pub struct Degrees { @@ -31,17 +21,7 @@ impl Degrees { } #[repr(C)] #[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, )] #[cpp_into(i64, to_i64)] pub struct Reading { diff --git a/tests/unit/out/unsafe/vector_subscript_direct.rs b/tests/unit/out/unsafe/vector_subscript_direct.rs index 0bf29311f5..cea364392f 100644 --- a/tests/unit/out/unsafe/vector_subscript_direct.rs +++ b/tests/unit/out/unsafe/vector_subscript_direct.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Point { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/vector_with_allocator.rs b/tests/unit/out/unsafe/vector_with_allocator.rs index 11f49b822c..8b9361a9c1 100644 --- a/tests/unit/out/unsafe/vector_with_allocator.rs +++ b/tests/unit/out/unsafe/vector_with_allocator.rs @@ -7,18 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct TestAllocator_int_ {} impl TestAllocator_int_ { pub unsafe fn allocate(&mut self, mut n: usize) -> *mut i32 { @@ -38,18 +27,7 @@ impl TestAllocator_int_ { } } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct TestAllocator_double_ {} impl TestAllocator_double_ { pub unsafe fn allocate(&mut self, mut n: usize) -> *mut f64 { diff --git a/tests/unit/out/unsafe/void_cast.rs b/tests/unit/out/unsafe/void_cast.rs index 04ad7e27ae..b86a24832a 100644 --- a/tests/unit/out/unsafe/void_cast.rs +++ b/tests/unit/out/unsafe/void_cast.rs @@ -42,18 +42,7 @@ pub unsafe fn bump_and_return_4() -> i32 { return (*std::cell::LazyCell::force_mut(&mut *&raw mut side_effect_counter_3)); } #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Holder { pub field: i32, } From ac916ea00f93bb0e2598acc69bd6c31c0fc885ae Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Mon, 30 Nov 2026 21:16:30 +0000 Subject: [PATCH 09/20] Move special member implementations in shims --- libcc2rs/src/constructor.rs | 71 ++++++------------------------------- rules/map/shim.rs | 11 ++++++ rules/unique_ptr/shim.rs | 39 ++++++++++++++++++++ rules/vector/shim.rs | 3 ++ 4 files changed, 63 insertions(+), 61 deletions(-) diff --git a/libcc2rs/src/constructor.rs b/libcc2rs/src/constructor.rs index 4598c86b39..a278670bae 100644 --- a/libcc2rs/src/constructor.rs +++ b/libcc2rs/src/constructor.rs @@ -1,14 +1,11 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use std::collections::BTreeMap; - use crate::fn_ptr::{FnPtr, FnSig}; use crate::initialization::ZeroInitialization; -use crate::rc::{Ptr, Value}; +use crate::rc::Ptr; use crate::reinterpret::ByteRepr; use crate::void::AnyPtr; -use crate::{Map, UnsafeMap}; pub trait MoveConstructible: Sized { fn move_constructor(this: &Ptr, src: Ptr); @@ -170,28 +167,28 @@ pub(crate) use impl_trivial_copy_move; // The library types whose move leaves the source empty. macro_rules! impl_move_by_take { ($(<$($param:ident),*> $ty:ty),* $(,)?) => {$( - impl<$($param),*> MoveConstructible for $ty + impl<$($param),*> $crate::MoveConstructible for $ty where - $ty: Default + ByteRepr, + $ty: Default + $crate::ByteRepr, { - fn move_constructor(this: &Ptr, src: Ptr) { + fn move_constructor(this: &$crate::Ptr, src: $crate::Ptr) { let value = src.with_mut(std::mem::take); this.with_mut(|dst| *dst = value); } } - impl<$($param),*> MoveAssignable for $ty + impl<$($param),*> $crate::MoveAssignable for $ty where - $ty: Default + ByteRepr, + $ty: Default + $crate::ByteRepr, { - fn move_assign(this: &Ptr, src: Ptr) -> Ptr { + fn move_assign(this: &$crate::Ptr, src: $crate::Ptr) -> $crate::Ptr { let value = src.with_mut(std::mem::take); this.with_mut(|dst| *dst = value); this.clone() } } - impl<$($param),*> MoveConstructibleUnsafe for $ty + impl<$($param),*> $crate::MoveConstructibleUnsafe for $ty where $ty: Default, { @@ -200,7 +197,7 @@ macro_rules! impl_move_by_take { } } - impl<$($param),*> MoveAssignableUnsafe for $ty + impl<$($param),*> $crate::MoveAssignableUnsafe for $ty where $ty: Default, { @@ -211,6 +208,7 @@ macro_rules! impl_move_by_take { } )*}; } +pub(crate) use impl_move_by_take; impl_trivial_copy_move!( (), @@ -242,20 +240,6 @@ impl_trivial_copy_move!( (A, B), ); -impl_copy_by_clone!( - Vec, - BTreeMap, - Map, - UnsafeMap, -); - -impl_move_by_take!( - Vec, - BTreeMap, - Map, - UnsafeMap, -); - impl MoveConstructible for FnPtr { fn move_constructor(this: &Ptr, src: Ptr) { let value = src.with(FnPtr::move_from); @@ -361,41 +345,6 @@ impl CopyAssignable for Box<[T]> { } } -// unique_ptr. -impl MoveConstructible for Option> -where - Self: ByteRepr, -{ - fn move_constructor(this: &Ptr, src: Ptr) { - let value = src.with_mut(Option::take); - this.with_mut(|dst| *dst = value); - } -} - -impl MoveAssignable for Option> -where - Self: ByteRepr, -{ - fn move_assign(this: &Ptr, src: Ptr) -> Ptr { - let value = src.with_mut(Option::take); - this.with_mut(|dst| *dst = value); - this.clone() - } -} - -impl MoveConstructibleUnsafe for Option> { - unsafe fn move_constructor(&mut self, src: *mut Self) { - unsafe { std::ptr::write(self, (*src).take()) } - } -} - -impl MoveAssignableUnsafe for Option> { - unsafe fn move_assign(&mut self, src: *mut Self) -> *mut Self { - unsafe { *self = (*src).take() }; - self - } -} - impl MoveConstructibleUnsafe for [T; N] { unsafe fn move_constructor(&mut self, src: *mut Self) { let src = src as *mut T; diff --git a/rules/map/shim.rs b/rules/map/shim.rs index caaf12d995..7bdfb4edfb 100644 --- a/rules/map/shim.rs +++ b/rules/map/shim.rs @@ -604,3 +604,14 @@ impl Iterator for UnsafeMapRange { Some(self.cur.iter_post_inc()) } } + +crate::constructor::impl_copy_by_clone!( + BTreeMap, + Map, + UnsafeMap, +); +crate::constructor::impl_move_by_take!( + BTreeMap, + Map, + UnsafeMap, +); diff --git a/rules/unique_ptr/shim.rs b/rules/unique_ptr/shim.rs index 67808c7161..52b15597cc 100644 --- a/rules/unique_ptr/shim.rs +++ b/rules/unique_ptr/shim.rs @@ -1,4 +1,43 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. +use crate::{ + ByteRepr, MoveAssignable, MoveAssignableUnsafe, MoveConstructible, MoveConstructibleUnsafe, + Ptr, Value, +}; + pub trait CppArray {} + +impl MoveConstructible for Option> +where + Self: ByteRepr, +{ + fn move_constructor(this: &Ptr, src: Ptr) { + let value = src.with_mut(Option::take); + this.with_mut(|dst| *dst = value); + } +} + +impl MoveAssignable for Option> +where + Self: ByteRepr, +{ + fn move_assign(this: &Ptr, src: Ptr) -> Ptr { + let value = src.with_mut(Option::take); + this.with_mut(|dst| *dst = value); + this.clone() + } +} + +impl MoveConstructibleUnsafe for Option> { + unsafe fn move_constructor(&mut self, src: *mut Self) { + unsafe { std::ptr::write(self, (*src).take()) } + } +} + +impl MoveAssignableUnsafe for Option> { + unsafe fn move_assign(&mut self, src: *mut Self) -> *mut Self { + unsafe { *self = (*src).take() }; + self + } +} diff --git a/rules/vector/shim.rs b/rules/vector/shim.rs index 40c224d6eb..b0761950ad 100644 --- a/rules/vector/shim.rs +++ b/rules/vector/shim.rs @@ -14,3 +14,6 @@ impl FnPtrArg for Vec { record_from_repr(r) } } + +crate::constructor::impl_copy_by_clone!( Vec); +crate::constructor::impl_move_by_take!( Vec); From 8b0861ad6fe802c1617fb873576caa74e76d7ecb Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Mon, 30 Nov 2026 21:58:56 +0000 Subject: [PATCH 10/20] Add Swappable trait --- cpp2rust/converter/converter.cpp | 23 +- cpp2rust/converter/converter_lib.h | 1 + libcc2rs-macros/src/constructor.rs | 49 +++- libcc2rs-macros/src/lib.rs | 10 + libcc2rs/src/constructor.rs | 99 ++++++- libcc2rs/src/lib.rs | 10 +- libcc2rs/src/swap.rs | 271 +----------------- rules/algorithm/tgt_refcount.rs | 8 +- rules/algorithm/tgt_unsafe.rs | 8 +- rules/unique_ptr/shim.rs | 17 +- .../out/refcount/defaulted_move_cross_tu.rs | 3 +- .../out/refcount/p14-class-in-two-files.rs | 1 + .../p15-class-template-static-member.rs | 1 + .../out/refcount/p15-function-template.rs | 1 + .../out/refcount/p15-inline-function.rs | 1 + .../out/refcount/p15-inline-variable.rs | 1 + .../p16-default-argument-lambda-in-class.rs | 1 + .../refcount/p16-lambda-in-inline-function.rs | 1 + .../out/refcount/basic.scope.block.rs | 1 + .../out/unsafe/basic.scope.block.rs | 1 + tests/std/basic/out/refcount/basic.def.odr.rs | 6 + tests/std/basic/out/unsafe/basic.def.odr.rs | 6 + .../out/refcount/expr.mptr.oper.rs | 11 +- 23 files changed, 229 insertions(+), 302 deletions(-) diff --git a/cpp2rust/converter/converter.cpp b/cpp2rust/converter/converter.cpp index 5fdb80b985..6912737cd6 100644 --- a/cpp2rust/converter/converter.cpp +++ b/cpp2rust/converter/converter.cpp @@ -5556,9 +5556,6 @@ void Converter::AddCloneTrait(const clang::RecordDecl *decl) { void Converter::AddCopyAndMoveDerives(const clang::RecordDecl *decl, std::vector &attrs) { - if (!decl->isUnion() && !RecordImplementsClone(decl)) { - return; - } auto *cxx = clang::dyn_cast(decl); auto implements = [&](const RecordTrait *trait) { return cxx && llvm::any_of(cxx->methods(), [&](auto *method) { @@ -5567,15 +5564,21 @@ void Converter::AddCopyAndMoveDerives(const clang::RecordDecl *decl, }; const RecordTrait *traits[] = {&kCopyConstructible, &kMoveConstructible, &kCopyAssignable, &kMoveAssignable}; - if (llvm::none_of(traits, implements)) { - attrs.emplace_back(GetCopyOrMoveTraitName(kCopyable)); - return; - } - for (const auto *trait : traits) { - if (!implements(trait)) { - attrs.emplace_back(GetCopyOrMoveTraitName(*trait)); + if (decl->isUnion() || RecordImplementsClone(decl)) { + if (llvm::none_of(traits, implements)) { + attrs.emplace_back(GetCopyOrMoveTraitName(kCopyable)); + return; + } + for (const auto *trait : traits) { + if (!implements(trait)) { + attrs.emplace_back(GetCopyOrMoveTraitName(*trait)); + } } + } else if (!implements(&kMoveConstructible) || + !implements(&kMoveAssignable)) { + return; } + attrs.emplace_back(GetCopyOrMoveTraitName(kSwappable)); } bool Converter::RecordImplementsClone(const clang::RecordDecl *decl) { diff --git a/cpp2rust/converter/converter_lib.h b/cpp2rust/converter/converter_lib.h index 40f277d331..b7c4082cdc 100644 --- a/cpp2rust/converter/converter_lib.h +++ b/cpp2rust/converter/converter_lib.h @@ -119,6 +119,7 @@ inline constexpr RecordTrait kCopyAssignable{ "CopyAssignable", "CopyAssignableUnsafe", "copy_assign"}; inline constexpr RecordTrait kMoveAssignable{ "MoveAssignable", "MoveAssignableUnsafe", "move_assign"}; +inline constexpr RecordTrait kSwappable{"Swappable", "SwappableUnsafe", "swap"}; inline constexpr RecordTrait kCopyable{"Copyable", "CopyableUnsafe", nullptr}; const RecordTrait *GetRecordTrait(const clang::CXXMethodDecl *method); diff --git a/libcc2rs-macros/src/constructor.rs b/libcc2rs-macros/src/constructor.rs index 92ec57ac20..e91fb01296 100644 --- a/libcc2rs-macros/src/constructor.rs +++ b/libcc2rs-macros/src/constructor.rs @@ -20,7 +20,54 @@ pub fn expand_copyable(input: TokenStream, is_unsafe: bool) -> TokenStream { ("move", true), ] .map(|(op, is_assign)| impl_trait(&input, op, is_assign, is_unsafe)); - quote!(#(#impls)*).into() + let swap = impl_swap(&input, is_unsafe); + quote!(#(#impls)* #swap).into() +} + +pub fn expand_swappable(input: TokenStream, is_unsafe: bool) -> TokenStream { + let input = parse_macro_input!(input as DeriveInput); + impl_swap(&input, is_unsafe).into() +} + +// T tmp(std::move(a)); a = std::move(b); b = std::move(tmp); ~tmp +fn impl_swap(input: &DeriveInput, is_unsafe: bool) -> TokenStream2 { + let name = &input.ident; + let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl(); + if is_unsafe { + quote! { + impl #impl_generics ::libcc2rs::SwappableUnsafe for #name #ty_generics #where_clause { + unsafe fn swap(&mut self, other: *mut Self) { + use ::libcc2rs::__swap::{DestroyNoneUnsafe as _, DestroyWithDtorUnsafe as _}; + let mut tmp = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::libcc2rs::MoveConstructibleUnsafe::move_constructor( + &mut *tmp.as_mut_ptr(), + self, + ); + ::libcc2rs::MoveAssignableUnsafe::move_assign(self, other); + ::libcc2rs::MoveAssignableUnsafe::move_assign(&mut *other, tmp.as_mut_ptr()); + (&&::libcc2rs::__swap::DestroyUnsafe(tmp.as_mut_ptr())).destroy(); + } + } + } + } + } else { + quote! { + impl #impl_generics ::libcc2rs::Swappable for #name #ty_generics #where_clause { + fn swap(this: &::libcc2rs::Ptr, other: ::libcc2rs::Ptr) { + use ::libcc2rs::__swap::{DestroyNone as _, DestroyWithDtor as _}; + let tmp: ::libcc2rs::Value = ::std::rc::Rc::new(::std::cell::RefCell::new( + ::zero_init(), + )); + let tmp = ::libcc2rs::AsPointer::::as_pointer(&tmp); + ::libcc2rs::MoveConstructible::move_constructor(&tmp, this.clone()); + ::libcc2rs::MoveAssignable::move_assign(this, other.clone()); + ::libcc2rs::MoveAssignable::move_assign(&other, tmp.clone()); + (&&::libcc2rs::__swap::Destroy(&tmp)).destroy(); + } + } + } + } } fn impl_trait(input: &DeriveInput, op: &str, is_assign: bool, is_unsafe: bool) -> TokenStream2 { diff --git a/libcc2rs-macros/src/lib.rs b/libcc2rs-macros/src/lib.rs index 25ebfb598a..cc0171cea7 100644 --- a/libcc2rs-macros/src/lib.rs +++ b/libcc2rs-macros/src/lib.rs @@ -195,6 +195,16 @@ pub fn derive_copyable_unsafe(input: TokenStream) -> TokenStream { constructor::expand_copyable(input, true) } +#[proc_macro_derive(Swappable)] +pub fn derive_swappable(input: TokenStream) -> TokenStream { + constructor::expand_swappable(input, false) +} + +#[proc_macro_derive(SwappableUnsafe)] +pub fn derive_swappable_unsafe(input: TokenStream) -> TokenStream { + constructor::expand_swappable(input, true) +} + #[proc_macro_derive(CopyAssignable)] pub fn derive_copy_assignable(input: TokenStream) -> TokenStream { constructor::expand(input, "copy", true, false) diff --git a/libcc2rs/src/constructor.rs b/libcc2rs/src/constructor.rs index a278670bae..efeeb9e44b 100644 --- a/libcc2rs/src/constructor.rs +++ b/libcc2rs/src/constructor.rs @@ -23,13 +23,19 @@ pub trait MoveAssignable: Sized { fn move_assign(this: &Ptr, src: Ptr) -> Ptr; } -// std::copyable, without swappable. -pub trait Copyable: - CopyConstructible + MoveConstructible + CopyAssignable + MoveAssignable -{ +pub trait Swappable: Sized { + fn swap(this: &Ptr, other: Ptr); } -impl Copyable for T {} +// std::movable. +pub trait Movable: MoveConstructible + MoveAssignable + Swappable {} + +impl Movable for T {} + +// std::copyable. +pub trait Copyable: CopyConstructible + CopyAssignable + Movable {} + +impl Copyable for T {} pub trait MoveConstructibleUnsafe { /// # Safety @@ -55,17 +61,21 @@ pub trait MoveAssignableUnsafe { unsafe fn move_assign(&mut self, src: *mut Self) -> *mut Self; } -// std::copyable, without swappable. -pub trait CopyableUnsafe: - CopyConstructibleUnsafe + MoveConstructibleUnsafe + CopyAssignableUnsafe + MoveAssignableUnsafe -{ +pub trait SwappableUnsafe { + /// # Safety + /// `other` must point to a live value. + unsafe fn swap(&mut self, other: *mut Self); } -impl< - T: CopyConstructibleUnsafe + MoveConstructibleUnsafe + CopyAssignableUnsafe + MoveAssignableUnsafe, -> CopyableUnsafe for T -{ -} +// std::movable. +pub trait MovableUnsafe: MoveConstructibleUnsafe + MoveAssignableUnsafe + SwappableUnsafe {} + +impl MovableUnsafe for T {} + +// std::copyable. +pub trait CopyableUnsafe: CopyConstructibleUnsafe + CopyAssignableUnsafe + MovableUnsafe {} + +impl CopyableUnsafe for T {} macro_rules! impl_copy_by_clone { ($(<$($param:ident),*> $ty:ty),* $(,)?) => {$( @@ -149,6 +159,21 @@ macro_rules! impl_move_by_clone { self } } + + impl<$($param),*> $crate::Swappable for $ty + where + $ty: Clone + $crate::ByteRepr, + { + fn swap(this: &$crate::Ptr, other: $crate::Ptr) { + this.swap_with(&other, $crate::Ptr::read); + } + } + + impl<$($param),*> $crate::SwappableUnsafe for $ty { + unsafe fn swap(&mut self, other: *mut Self) { + unsafe { std::ptr::swap(self, other) } + } + } )*}; } pub(crate) use impl_move_by_clone; @@ -206,6 +231,21 @@ macro_rules! impl_move_by_take { self } } + + impl<$($param),*> $crate::Swappable for $ty + where + $ty: Default + $crate::ByteRepr, + { + fn swap(this: &$crate::Ptr, other: $crate::Ptr) { + this.swap_with(&other, |p| p.with_mut(std::mem::take)); + } + } + + impl<$($param),*> $crate::SwappableUnsafe for $ty { + unsafe fn swap(&mut self, other: *mut Self) { + unsafe { std::ptr::swap(self, other) } + } + } )*}; } pub(crate) use impl_move_by_take; @@ -268,6 +308,18 @@ impl CopyAssignable for FnPtr { } } +impl Swappable for FnPtr { + fn swap(this: &Ptr, other: Ptr) { + this.swap_with(&other, |p| p.with(FnPtr::move_from)); + } +} + +impl SwappableUnsafe for FnPtr { + unsafe fn swap(&mut self, other: *mut Self) { + unsafe { std::ptr::swap(self, other) } + } +} + impl MoveConstructibleUnsafe for FnPtr { unsafe fn move_constructor(&mut self, src: *mut Self) { unsafe { std::ptr::write(self, (*src).move_from()) } @@ -345,6 +397,25 @@ impl CopyAssignable for Box<[T]> { } } +impl Swappable for Box<[T]> { + fn swap(this: &Ptr, other: Ptr) { + let len = other.with(|elems| elems.len()); + let (dst, src) = (this.decay(), other.decay()); + for i in 0..len { + T::swap(&dst.offset(i), src.offset(i)); + } + } +} + +impl SwappableUnsafe for [T; N] { + unsafe fn swap(&mut self, other: *mut Self) { + let other = other as *mut T; + for (i, elem) in self.iter_mut().enumerate() { + unsafe { SwappableUnsafe::swap(elem, other.add(i)) } + } + } +} + impl MoveConstructibleUnsafe for [T; N] { unsafe fn move_constructor(&mut self, src: *mut Self) { let src = src as *mut T; diff --git a/libcc2rs/src/lib.rs b/libcc2rs/src/lib.rs index e86fdd58ec..a5a09a11a7 100644 --- a/libcc2rs/src/lib.rs +++ b/libcc2rs/src/lib.rs @@ -47,8 +47,8 @@ pub use capture::{Destructible, DestructibleUnsafe}; mod constructor; pub use constructor::{ CopyAssignable, CopyAssignableUnsafe, CopyConstructible, CopyConstructibleUnsafe, Copyable, - CopyableUnsafe, MoveAssignable, MoveAssignableUnsafe, MoveConstructible, - MoveConstructibleUnsafe, + CopyableUnsafe, Movable, MovableUnsafe, MoveAssignable, MoveAssignableUnsafe, + MoveConstructible, MoveConstructibleUnsafe, Swappable, SwappableUnsafe, }; mod cmp; @@ -61,7 +61,7 @@ mod initialization; pub use initialization::{ZeroInitialization, ZeroInitializationUnsafe}; mod swap; -// Used by cpp_swap! and cpp_swap_unsafe!. +// Used by cpp_move!, cpp_move_unsafe! and the Swappable derives. #[doc(hidden)] pub mod __swap { pub use crate::swap::*; @@ -114,6 +114,6 @@ pub use libcc2rs_macros::{ ByteRepr, CopyAssignable, CopyAssignableUnsafe, CopyConstructible, CopyConstructibleUnsafe, Copyable, CopyableUnsafe, CppFrom, CppFromUnsafe, Destructible, DestructibleUnsafe, FnPtrArg, MoveAssignable, MoveAssignableUnsafe, MoveConstructible, MoveConstructibleUnsafe, Record, - VaArg, ZeroInitialization, ZeroInitializationUnsafe, goto, goto_block, lambda, lambda_unsafe, - switch, + Swappable, SwappableUnsafe, VaArg, ZeroInitialization, ZeroInitializationUnsafe, goto, + goto_block, lambda, lambda_unsafe, switch, }; diff --git a/libcc2rs/src/swap.rs b/libcc2rs/src/swap.rs index b3b0d16111..dd22421925 100644 --- a/libcc2rs/src/swap.rs +++ b/libcc2rs/src/swap.rs @@ -1,30 +1,11 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -// std::swap, for the translation rules: cpp_swap!(a, b), or -// cpp_swap_unsafe!(a, b), swaps the values that a and b point to as C++ -// does: -// T tmp(std::move(a)); a = std::move(b); b = std::move(tmp); ~tmp -// Each step is done with the special member functions of the type that C++ -// picks, which may have side effects. The macros call -// `(&&&Construct(..)).construct()`, `(&&&&&Assign(..)).assign()` and -// `(&&Destroy(..)).destroy()`, and autoref specialization picks, among the -// impls below, the one with the most `&`s whose bounds the type satisfies: -// - the temporary is made with the move constructor (MoveConstructible), -// or else with the copy constructor (Clone); -// - a value is assigned with the move assignment operator (MoveAssignable), -// or else with the copy assignment operator (CopyAssignable), as C++ -// copies the types without one; the other types are assigned as a whole, -// by moving the value with the move constructor (MoveConstructible), or -// else by copying it (Clone); -// - the temporary is destroyed with the destructor, if any (Destructible). -// The values are accessed one at a time, so they may be in the same -// allocation, e.g., two fields of a struct. -// -// The types without any of those special members are only copied by C++, and -// so their values (or bytes, if reinterpreted) are swapped instead, without a -// temporary, as `(&&&&&Trivial(..)).trivial()` tells. The other steps are -// still compiled for them, and are unreachable if they can't be copied. +// cpp_move!(p), or cpp_move_unsafe!(p), constructs a value from the one that +// p points to as C++ does with T(std::move(*p)): with the move constructor +// (MoveConstructible), or else with the copy constructor (Clone), as picked +// by autoref specialization. Destroy destroys a temporary with its destructor, +// if any (Destructible). #![allow(private_bounds, clippy::missing_safety_doc)] @@ -32,64 +13,11 @@ use std::cell::RefCell; use std::rc::Rc; use crate::capture::{Destructible, DestructibleUnsafe}; -use crate::constructor::{ - CopyAssignable, CopyAssignableUnsafe, MoveAssignable, MoveAssignableUnsafe, MoveConstructible, - MoveConstructibleUnsafe, -}; +use crate::constructor::{MoveConstructible, MoveConstructibleUnsafe}; use crate::initialization::ZeroInitialization; use crate::rc::{AsPointer, Ptr, Value}; use crate::reinterpret::ByteRepr; -#[macro_export] -macro_rules! cpp_swap { - ($a:expr, $b:expr) => {{ - #[allow(unused_imports)] - use $crate::__swap::{ - AssignClone, AssignCopy, AssignMove, AssignMoveCtor, AssignNone, ConstructCopy, - ConstructMove, ConstructNone, DestroyNone, DestroyWithDtor, HasCopyAssign, - HasDestructor, HasMoveAssign, HasMoveCtor, HasNone, TakeClone, TakeNone, - }; - let __a = $a; - let __b = $b; - if (&&&&&$crate::__swap::Trivial(&__a)).trivial() { - __a.swap_with(&__b, (&&$crate::__swap::Take(&__a)).take()); - } else { - let __tmp = $crate::__swap::temporary((&&&$crate::__swap::Construct(&__a)).construct()); - let __tmp_ptr = $crate::__swap::pointer(&__tmp); - (&&&&&$crate::__swap::Assign(&__a, &__b)).assign(); - (&&&&&$crate::__swap::Assign(&__b, &__tmp_ptr)).assign(); - (&&$crate::__swap::Destroy(&__tmp_ptr)).destroy(); - } - }}; -} - -#[macro_export] -macro_rules! cpp_swap_unsafe { - ($a:expr, $b:expr) => {{ - #[allow(unused_imports)] - use $crate::__swap::{ - AssignCloneUnsafe, AssignCopyUnsafe, AssignMoveCtorUnsafe, AssignMoveUnsafe, - AssignNoneUnsafe, ConstructCopyUnsafe, ConstructMoveUnsafe, ConstructNoneUnsafe, - DestroyNoneUnsafe, DestroyWithDtorUnsafe, HasCopyAssignUnsafe, HasDestructorUnsafe, - HasMoveAssignUnsafe, HasMoveCtorUnsafe, HasNoneUnsafe, - }; - let __a: *mut _ = $a; - let __b: *mut _ = $b; - if (&&&&&$crate::__swap::TrivialUnsafe(&__a)).trivial() { - ::std::ptr::swap(__a, __b); - } else { - let mut __tmp = (&&&$crate::__swap::ConstructUnsafe(__a)).construct(); - let __tmp_ptr: *mut _ = &mut __tmp; - (&&&&&$crate::__swap::AssignUnsafe(__a, __b)).assign(); - (&&&&&$crate::__swap::AssignUnsafe(__b, __tmp_ptr)).assign(); - (&&$crate::__swap::DestroyUnsafe(__tmp_ptr)).destroy(); - } - }}; -} - -// cpp_move!(p), or cpp_move_unsafe!(p), constructs a value from the one that -// p points to as C++ does with T(std::move(*p)), like the temporary of the -// swap. #[macro_export] macro_rules! cpp_move { ($p:expr) => {{ @@ -108,84 +36,10 @@ macro_rules! cpp_move_unsafe { }}; } -// Whether the type has none of the special members that the swap calls. -macro_rules! trivial { - ($wrapper:ident, $ptr:ty, $none:ident, $($tr:ident: $bty:ty: $bound:ident for $recv:ty),*) => { - pub struct $wrapper<'a, T>(pub &'a $ptr); - $( - pub trait $tr { - fn trivial(self) -> bool; - } - - impl $tr for $recv - where - $bty: $bound, - { - fn trivial(self) -> bool { - false - } - } - )* - - pub trait $none { - fn trivial(self) -> bool; - } - - impl $none for &$wrapper<'_, T> { - fn trivial(self) -> bool { - true - } - } - }; -} - -trivial!(Trivial, Ptr, HasNone, - HasMoveCtor: T: MoveConstructible for &&&&&Trivial<'_, T>, - HasMoveAssign: T: MoveAssignable for &&&&Trivial<'_, T>, - HasCopyAssign: T: CopyAssignable for &&&Trivial<'_, T>, - HasDestructor: T: Destructible for &&Trivial<'_, T> -); - -trivial!(TrivialUnsafe, *mut T, HasNoneUnsafe, - HasMoveCtorUnsafe: T: MoveConstructibleUnsafe for &&&&&TrivialUnsafe<'_, T>, - HasMoveAssignUnsafe: T: MoveAssignableUnsafe for &&&&TrivialUnsafe<'_, T>, - HasCopyAssignUnsafe: T: CopyAssignableUnsafe for &&&TrivialUnsafe<'_, T>, - HasDestructorUnsafe: T: DestructibleUnsafe for &&TrivialUnsafe<'_, T> -); - #[cold] #[inline(never)] -fn not_swappable() -> ! { - panic!("std::swap of a type that can't be copied nor moved") -} - -// How Ptr::swap_with copies a value of a trivial type into a temporary, if -// it needs one. -pub struct Take<'a, T>(pub &'a Ptr); - -pub trait TakeClone { - fn take(self) -> fn(&Ptr) -> T; -} - -pub trait TakeNone { - fn take(self) -> fn(&Ptr) -> T; -} - -impl TakeClone for &&Take<'_, T> { - fn take(self) -> fn(&Ptr) -> T { - Ptr::read - } -} - -impl TakeNone for &Take<'_, T> { - fn take(self) -> fn(&Ptr) -> T { - |_| not_swappable() - } -} - -// The temporary of cpp_swap!, and a pointer to it. -pub fn temporary(value: T) -> Value { - Rc::new(RefCell::new(value)) +fn not_movable() -> ! { + panic!("move of a type that can't be copied nor moved") } pub fn pointer(value: &Value) -> Ptr { @@ -234,60 +88,7 @@ impl ConstructCopy for &&Construct<'_, T> { impl ConstructNone for &Construct<'_, T> { fn construct(self) -> T { - not_swappable() - } -} - -// Assigns the value that the second pointer points to to the first one. -pub struct Assign<'a, T>(pub &'a Ptr, pub &'a Ptr); - -pub trait AssignMove { - fn assign(self); -} - -pub trait AssignCopy { - fn assign(self); -} - -pub trait AssignMoveCtor { - fn assign(self); -} - -pub trait AssignClone { - fn assign(self); -} - -pub trait AssignNone { - fn assign(self); -} - -impl AssignMove for &&&&&Assign<'_, T> { - fn assign(self) { - T::move_assign(self.0, self.1.clone()); - } -} - -impl AssignCopy for &&&&Assign<'_, T> { - fn assign(self) { - T::copy_assign(self.0, self.1.clone()); - } -} - -impl AssignMoveCtor for &&&Assign<'_, T> { - fn assign(self) { - self.0.write(move_constructed(self.1)) - } -} - -impl AssignClone for &&Assign<'_, T> { - fn assign(self) { - self.0.write(self.1.read()) - } -} - -impl AssignNone for &Assign<'_, T> { - fn assign(self) { - not_swappable() + not_movable() } } @@ -339,59 +140,7 @@ impl ConstructCopyUnsafe for &&ConstructUnsafe { impl ConstructNoneUnsafe for &ConstructUnsafe { unsafe fn construct(self) -> T { - not_swappable() - } -} - -pub struct AssignUnsafe(pub *mut T, pub *mut T); - -pub trait AssignMoveUnsafe { - unsafe fn assign(self); -} - -pub trait AssignCopyUnsafe { - unsafe fn assign(self); -} - -pub trait AssignMoveCtorUnsafe { - unsafe fn assign(self); -} - -pub trait AssignCloneUnsafe { - unsafe fn assign(self); -} - -pub trait AssignNoneUnsafe { - unsafe fn assign(self); -} - -impl AssignMoveUnsafe for &&&&&AssignUnsafe { - unsafe fn assign(self) { - unsafe { (*self.0).move_assign(self.1) }; - } -} - -impl AssignCopyUnsafe for &&&&AssignUnsafe { - unsafe fn assign(self) { - unsafe { (*self.0).copy_assign(self.1) }; - } -} - -impl AssignMoveCtorUnsafe for &&&AssignUnsafe { - unsafe fn assign(self) { - unsafe { *self.0 = move_constructed_unsafe(self.1) } - } -} - -impl AssignCloneUnsafe for &&AssignUnsafe { - unsafe fn assign(self) { - unsafe { *self.0 = (*self.1).clone() } - } -} - -impl AssignNoneUnsafe for &AssignUnsafe { - unsafe fn assign(self) { - not_swappable() + not_movable() } } diff --git a/rules/algorithm/tgt_refcount.rs b/rules/algorithm/tgt_refcount.rs index b3f952d4ac..43b71bcc9f 100644 --- a/rules/algorithm/tgt_refcount.rs +++ b/rules/algorithm/tgt_refcount.rs @@ -76,8 +76,8 @@ fn f8, T2: CppLess>(a0: T1, a1: T1) -> T1 { __best } -fn f9(a0: Ptr, a1: Ptr) { - cpp_swap!(a0, a1) +fn f9(a0: Ptr, a1: Ptr) { + Swappable::swap(&a0, a1) } fn f10, T2: CppEq + Clone + ByteRepr>(a0: T1, a1: T1) -> T1 { @@ -147,11 +147,11 @@ fn f17(a0: Ptr, a1: Ptr) -> Ptr { if CppLess::less(&a0, &a1) { a1 } else { a0 } } -fn f18, T2: Clone + ByteRepr>(a0: T1, a1: T1) { +fn f18, T2: Swappable>(a0: T1, a1: T1) { let __n = a1.iter_distance(&a0); let __random = std::hash::RandomState::new(); for __i in (1..__n).rev() { let __j = (std::hash::BuildHasher::hash_one(&__random, __i) % (__i + 1) as u64) as isize; - cpp_swap!(a0.iter_at(__i), a0.iter_at(__j)); + Swappable::swap(&a0.iter_at(__i), a0.iter_at(__j)); } } diff --git a/rules/algorithm/tgt_unsafe.rs b/rules/algorithm/tgt_unsafe.rs index 3a4b31be1c..01d92aaa73 100644 --- a/rules/algorithm/tgt_unsafe.rs +++ b/rules/algorithm/tgt_unsafe.rs @@ -81,8 +81,8 @@ unsafe fn f8, T2: PartialOrd>(a0: T1, a1: T1) -> __best } -unsafe fn f9(a0: *mut T1, a1: *mut T1) { - cpp_swap_unsafe!(a0, a1) +unsafe fn f9(a0: *mut T1, a1: *mut T1) { + SwappableUnsafe::swap(&mut *(a0), a1) } unsafe fn f10, T2: PartialEq + Clone>(a0: T1, a1: T1) -> T1 { @@ -156,10 +156,10 @@ unsafe fn f17(a0: *const T1, a1: *const T1) -> *const T1 { if *__a < *__b { __b } else { __a } } -unsafe fn f18, T2>(a0: T1, a1: T1) { +unsafe fn f18, T2: SwappableUnsafe>(a0: T1, a1: T1) { let __n = a1.iter_distance(&a0); for __i in (1..__n).rev() { let __j = libc::rand() as isize % (__i + 1); - cpp_swap_unsafe!(a0.iter_at(__i), a0.iter_at(__j)); + SwappableUnsafe::swap(&mut *a0.iter_at(__i), a0.iter_at(__j)); } } diff --git a/rules/unique_ptr/shim.rs b/rules/unique_ptr/shim.rs index 52b15597cc..264aad2598 100644 --- a/rules/unique_ptr/shim.rs +++ b/rules/unique_ptr/shim.rs @@ -3,7 +3,7 @@ use crate::{ ByteRepr, MoveAssignable, MoveAssignableUnsafe, MoveConstructible, MoveConstructibleUnsafe, - Ptr, Value, + Ptr, Swappable, SwappableUnsafe, Value, }; pub trait CppArray {} @@ -41,3 +41,18 @@ impl MoveAssignableUnsafe for Option> { self } } + +impl Swappable for Option> +where + Self: ByteRepr, +{ + fn swap(this: &Ptr, other: Ptr) { + this.swap_with(&other, |p| p.with_mut(Option::take)); + } +} + +impl SwappableUnsafe for Option> { + unsafe fn swap(&mut self, other: *mut Self) { + unsafe { std::ptr::swap(self, other) } + } +} diff --git a/tests/multi-file/defaulted_move_cross_tu/out/refcount/defaulted_move_cross_tu.rs b/tests/multi-file/defaulted_move_cross_tu/out/refcount/defaulted_move_cross_tu.rs index 699e27548a..f26960cf22 100644 --- a/tests/multi-file/defaulted_move_cross_tu/out/refcount/defaulted_move_cross_tu.rs +++ b/tests/multi-file/defaulted_move_cross_tu/out/refcount/defaulted_move_cross_tu.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Swappable)] #[cpp_from(i32, construct, value)] #[byte_size(32)] pub struct S { @@ -53,6 +53,7 @@ impl Default for S { FnPtrArg, CopyConstructible, CopyAssignable, + Swappable, Default, )] #[byte_size(24)] diff --git a/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/refcount/p14-class-in-two-files.rs b/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/refcount/p14-class-in-two-files.rs index d635b41804..f9820a88a7 100644 --- a/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/refcount/p14-class-in-two-files.rs +++ b/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/refcount/p14-class-in-two-files.rs @@ -27,6 +27,7 @@ thread_local!( Destructible, MoveConstructible, MoveAssignable, + Swappable, )] #[byte_size(4)] pub struct LifetimeTracked { diff --git a/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/refcount/p15-class-template-static-member.rs b/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/refcount/p15-class-template-static-member.rs index 91adfc3d29..48c7a76842 100644 --- a/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/refcount/p15-class-template-static-member.rs +++ b/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/refcount/p15-class-template-static-member.rs @@ -27,6 +27,7 @@ thread_local!( Destructible, MoveConstructible, MoveAssignable, + Swappable, )] #[byte_size(4)] pub struct LifetimeTracked { diff --git a/tests/std/basic/basic.def.odr/p15-function-template/out/refcount/p15-function-template.rs b/tests/std/basic/basic.def.odr/p15-function-template/out/refcount/p15-function-template.rs index e3a1c2cb55..206c0c398b 100644 --- a/tests/std/basic/basic.def.odr/p15-function-template/out/refcount/p15-function-template.rs +++ b/tests/std/basic/basic.def.odr/p15-function-template/out/refcount/p15-function-template.rs @@ -27,6 +27,7 @@ thread_local!( Destructible, MoveConstructible, MoveAssignable, + Swappable, )] #[byte_size(4)] pub struct LifetimeTracked { diff --git a/tests/std/basic/basic.def.odr/p15-inline-function/out/refcount/p15-inline-function.rs b/tests/std/basic/basic.def.odr/p15-inline-function/out/refcount/p15-inline-function.rs index 5ff70ca6cf..aa33aae4ab 100644 --- a/tests/std/basic/basic.def.odr/p15-inline-function/out/refcount/p15-inline-function.rs +++ b/tests/std/basic/basic.def.odr/p15-inline-function/out/refcount/p15-inline-function.rs @@ -27,6 +27,7 @@ thread_local!( Destructible, MoveConstructible, MoveAssignable, + Swappable, )] #[byte_size(4)] pub struct LifetimeTracked { diff --git a/tests/std/basic/basic.def.odr/p15-inline-variable/out/refcount/p15-inline-variable.rs b/tests/std/basic/basic.def.odr/p15-inline-variable/out/refcount/p15-inline-variable.rs index 5109c0cba1..d4625ede86 100644 --- a/tests/std/basic/basic.def.odr/p15-inline-variable/out/refcount/p15-inline-variable.rs +++ b/tests/std/basic/basic.def.odr/p15-inline-variable/out/refcount/p15-inline-variable.rs @@ -27,6 +27,7 @@ thread_local!( Destructible, MoveConstructible, MoveAssignable, + Swappable, )] #[byte_size(4)] pub struct LifetimeTracked { diff --git a/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/refcount/p16-default-argument-lambda-in-class.rs b/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/refcount/p16-default-argument-lambda-in-class.rs index 8792a2984b..670c4a5a2b 100644 --- a/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/refcount/p16-default-argument-lambda-in-class.rs +++ b/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/refcount/p16-default-argument-lambda-in-class.rs @@ -27,6 +27,7 @@ thread_local!( Destructible, MoveConstructible, MoveAssignable, + Swappable, )] #[byte_size(4)] pub struct LifetimeTracked { diff --git a/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/refcount/p16-lambda-in-inline-function.rs b/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/refcount/p16-lambda-in-inline-function.rs index c08331cec2..d18f1a4ae5 100644 --- a/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/refcount/p16-lambda-in-inline-function.rs +++ b/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/refcount/p16-lambda-in-inline-function.rs @@ -27,6 +27,7 @@ thread_local!( Destructible, MoveConstructible, MoveAssignable, + Swappable, )] #[byte_size(4)] pub struct LifetimeTracked { diff --git a/tests/std/basic/basic.scope/out/refcount/basic.scope.block.rs b/tests/std/basic/basic.scope/out/refcount/basic.scope.block.rs index 36abd03dda..ea482e35a3 100644 --- a/tests/std/basic/basic.scope/out/refcount/basic.scope.block.rs +++ b/tests/std/basic/basic.scope/out/refcount/basic.scope.block.rs @@ -27,6 +27,7 @@ thread_local!( Destructible, MoveConstructible, MoveAssignable, + Swappable, )] #[byte_size(4)] pub struct LifetimeTracked { diff --git a/tests/std/basic/basic.scope/out/unsafe/basic.scope.block.rs b/tests/std/basic/basic.scope/out/unsafe/basic.scope.block.rs index 0a7c19133a..18e44a6e70 100644 --- a/tests/std/basic/basic.scope/out/unsafe/basic.scope.block.rs +++ b/tests/std/basic/basic.scope/out/unsafe/basic.scope.block.rs @@ -18,6 +18,7 @@ pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(| DestructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, )] pub struct LifetimeTracked { pub uses: i32, diff --git a/tests/std/basic/out/refcount/basic.def.odr.rs b/tests/std/basic/out/refcount/basic.def.odr.rs index 8f4be2f93d..6dd78c9dd9 100644 --- a/tests/std/basic/out/refcount/basic.def.odr.rs +++ b/tests/std/basic/out/refcount/basic.def.odr.rs @@ -18,6 +18,7 @@ thread_local!( CppFrom, MoveConstructible, MoveAssignable, + Swappable, Default, )] #[cpp_from(i32, construct, value)] @@ -73,6 +74,7 @@ thread_local!( Destructible, MoveConstructible, MoveAssignable, + Swappable, )] #[byte_size(4)] pub struct LifetimeTracked { @@ -409,6 +411,7 @@ thread_local!( CppFrom, MoveConstructible, MoveAssignable, + Swappable, Default, )] #[cpp_from(i32, construct, value)] @@ -495,6 +498,7 @@ pub fn test_19() { CopyConstructible, MoveConstructible, MoveAssignable, + Swappable, Default, )] #[byte_size(8)] @@ -559,6 +563,7 @@ pub fn test_20() { CopyConstructible, MoveConstructible, MoveAssignable, + Swappable, )] #[byte_size(8)] pub struct p7_member_access_captures_this_HasMemberUsedInLambda { @@ -617,6 +622,7 @@ pub fn test_22() { CopyConstructible, MoveConstructible, MoveAssignable, + Swappable, Default, )] #[byte_size(4)] diff --git a/tests/std/basic/out/unsafe/basic.def.odr.rs b/tests/std/basic/out/unsafe/basic.def.odr.rs index 4c5c5e576e..df47ba28ea 100644 --- a/tests/std/basic/out/unsafe/basic.def.odr.rs +++ b/tests/std/basic/out/unsafe/basic.def.odr.rs @@ -15,6 +15,7 @@ pub static mut copyCount_0: std::cell::LazyCell = std::cell::LazyCell::new( CppFromUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, Default, )] #[cpp_from(i32, construct, value)] @@ -62,6 +63,7 @@ pub static mut useCount_4: std::cell::LazyCell = std::cell::LazyCell::new(| DestructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, )] pub struct LifetimeTracked { pub uses: i32, @@ -378,6 +380,7 @@ pub static mut copies_18: std::cell::LazyCell = std::cell::LazyCell::new(|| CppFromUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, Default, )] #[cpp_from(i32, construct, value)] @@ -458,6 +461,7 @@ pub unsafe fn test_19() { CopyConstructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct p6_unevaluated_binding_needs_no_capture_HasTwoMembers { @@ -525,6 +529,7 @@ pub unsafe fn test_20() { CopyConstructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, )] pub struct p7_member_access_captures_this_HasMemberUsedInLambda { pub x: LifetimeTracked, @@ -599,6 +604,7 @@ pub unsafe fn test_22() { CopyConstructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda { diff --git a/tests/std/expr/expr.compound/out/refcount/expr.mptr.oper.rs b/tests/std/expr/expr.compound/out/refcount/expr.mptr.oper.rs index 66d2f5d2ab..fb7cd1bc9b 100644 --- a/tests/std/expr/expr.compound/out/refcount/expr.mptr.oper.rs +++ b/tests/std/expr/expr.compound/out/refcount/expr.mptr.oper.rs @@ -99,7 +99,15 @@ thread_local!( pub static moveCount_10: Value = Rc::new(RefCell::new(0)); ); #[derive( - Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyAssignable, MoveAssignable, Default, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyAssignable, + MoveAssignable, + Swappable, + Default, )] #[byte_size(1)] pub struct p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves {} @@ -141,6 +149,7 @@ impl Clone for p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves { CopyConstructible, CopyAssignable, MoveAssignable, + Swappable, Default, )] #[byte_size(1)] From ad0a4f043bc9936e98440de02103ac1485bb51d9 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Mon, 30 Nov 2026 22:01:26 +0000 Subject: [PATCH 11/20] Update tests --- .../out/unsafe/defaulted_move_cross_tu.rs | 3 +- .../out/unsafe/p14-class-in-two-files.rs | 1 + .../p15-class-template-static-member.rs | 1 + .../out/unsafe/p15-function-template.rs | 1 + .../out/unsafe/p15-inline-function.rs | 1 + .../out/unsafe/p15-inline-variable.rs | 1 + .../p16-default-argument-lambda-in-class.rs | 1 + .../unsafe/p16-lambda-in-inline-function.rs | 1 + .../out/unsafe/expr.mptr.oper.rs | 9 +- .../stmt.select/out/refcount/stmt.if.rs | 1 + .../stmt.select/out/refcount/stmt.switch.rs | 1 + .../stmt.select/out/unsafe/stmt.if.rs | 1 + .../stmt.select/out/unsafe/stmt.switch.rs | 1 + .../utility/out/refcount/forward-helpers.rs | 14 ++- .../utility/out/unsafe/forward-helpers.rs | 5 + .../out/refcount/array_of_noncopy_struct.rs | 10 +- .../out/refcount/assignment_single_eval.rs | 1 + tests/unit/out/refcount/cast.rs | 1 + tests/unit/out/refcount/class_templates.rs | 3 + .../refcount/container_element_receiver.rs | 1 + .../unit/out/refcount/container_field_addr.rs | 1 + tests/unit/out/refcount/copy_assign.rs | 5 + tests/unit/out/refcount/copy_ctor.rs | 16 ++- .../unit/out/refcount/copy_move_defaulted.rs | 13 ++- tests/unit/out/refcount/copy_move_deleted.rs | 8 +- .../refcount/elidable_iterator_copy_cxx11.rs | 2 +- .../out/refcount/field_method_receiver.rs | 10 +- tests/unit/out/refcount/field_pointers.rs | 10 +- .../refcount/foreach_disjoint_field_borrow.rs | 1 + tests/unit/out/refcount/forward_basic.rs | 2 + tests/unit/out/refcount/forward_decltype.rs | 1 + tests/unit/out/refcount/forward_explicit.rs | 1 + tests/unit/out/refcount/forward_pack.rs | 2 + tests/unit/out/refcount/huffman.rs | 2 +- tests/unit/out/refcount/implicit_autoref.rs | 1 + .../out/refcount/inline_container_fields.rs | 22 +++- tests/unit/out/refcount/kruskal.rs | 4 +- .../out/refcount/lambda_capture_copy_ctor.rs | 5 +- .../refcount/libc_struct_without_default.rs | 10 +- tests/unit/out/refcount/map_key_copy_ctor.rs | 1 + tests/unit/out/refcount/map_try_emplace.rs | 10 +- .../out/refcount/map_try_emplace_lvalues.rs | 2 +- tests/unit/out/refcount/max.rs | 1 + tests/unit/out/refcount/move_assign.rs | 2 +- tests/unit/out/refcount/move_ctor.rs | 2 + tests/unit/out/refcount/move_this.rs | 1 + tests/unit/out/refcount/push_emplace_back.rs | 11 +- tests/unit/out/refcount/rule_of_five.rs | 4 +- tests/unit/out/refcount/rule_of_three.rs | 1 + .../unit/out/refcount/rvalue_rule_arg_move.rs | 10 +- tests/unit/out/refcount/sort_no_copy.rs | 5 +- .../refcount/structured_binding_copy_ctor.rs | 1 + .../structured_binding_element_ctor.rs | 2 + .../refcount/structured_binding_move_ctor.rs | 11 +- tests/unit/out/refcount/swap_malloc.rs | 16 +-- tests/unit/out/refcount/swap_map_no_copy.rs | 106 ++++++++++-------- .../unit/out/refcount/temporary_field_addr.rs | 11 +- .../out/refcount/temporary_field_ctor_arg.rs | 1 + .../out/refcount/temporary_field_two_args.rs | 2 + .../unit/out/refcount/typedef-anon-struct.rs | 1 + tests/unit/out/refcount/unique_ptr.rs | 2 +- .../out/refcount/unique_ptr_const_deref.rs | 2 +- .../out/refcount/unique_ptr_field_reset.rs | 2 +- tests/unit/out/refcount/unique_ptr_nested.rs | 2 +- tests/unit/out/refcount/vector.rs | 1 + .../out/refcount/vector_subscript_direct.rs | 1 + tests/unit/out/refcount/void_cast.rs | 3 +- .../out/unsafe/array_of_noncopy_struct.rs | 8 +- .../unit/out/unsafe/assignment_single_eval.rs | 1 + tests/unit/out/unsafe/cast.rs | 1 + tests/unit/out/unsafe/class_templates.rs | 3 + .../out/unsafe/container_element_receiver.rs | 1 + tests/unit/out/unsafe/container_field_addr.rs | 1 + tests/unit/out/unsafe/copy_assign.rs | 5 + tests/unit/out/unsafe/copy_ctor.rs | 14 ++- tests/unit/out/unsafe/copy_move_defaulted.rs | 13 ++- tests/unit/out/unsafe/copy_move_deleted.rs | 8 +- .../unsafe/elidable_iterator_copy_cxx11.rs | 2 +- .../unit/out/unsafe/field_method_receiver.rs | 1 + tests/unit/out/unsafe/field_pointers.rs | 1 + .../unsafe/foreach_disjoint_field_borrow.rs | 1 + tests/unit/out/unsafe/forward_basic.rs | 2 + tests/unit/out/unsafe/forward_decltype.rs | 1 + tests/unit/out/unsafe/forward_explicit.rs | 1 + tests/unit/out/unsafe/forward_pack.rs | 2 + tests/unit/out/unsafe/huffman.rs | 2 +- tests/unit/out/unsafe/implicit_autoref.rs | 1 + .../out/unsafe/inline_container_fields.rs | 11 +- tests/unit/out/unsafe/kruskal.rs | 4 +- .../out/unsafe/lambda_capture_copy_ctor.rs | 10 +- .../out/unsafe/libc_struct_without_default.rs | 8 +- tests/unit/out/unsafe/map_key_copy_ctor.rs | 1 + tests/unit/out/unsafe/map_try_emplace.rs | 1 + .../out/unsafe/map_try_emplace_lvalues.rs | 2 +- tests/unit/out/unsafe/max.rs | 1 + tests/unit/out/unsafe/move_assign.rs | 2 +- tests/unit/out/unsafe/move_ctor.rs | 2 + tests/unit/out/unsafe/move_this.rs | 1 + tests/unit/out/unsafe/push_emplace_back.rs | 2 + tests/unit/out/unsafe/rule_of_five.rs | 10 +- tests/unit/out/unsafe/rule_of_three.rs | 1 + tests/unit/out/unsafe/rvalue_rule_arg_move.rs | 8 +- tests/unit/out/unsafe/sort_no_copy.rs | 5 +- .../unsafe/structured_binding_copy_ctor.rs | 1 + .../unsafe/structured_binding_element_ctor.rs | 2 + .../unsafe/structured_binding_move_ctor.rs | 9 +- tests/unit/out/unsafe/swap_malloc.rs | 22 ++-- tests/unit/out/unsafe/swap_map_no_copy.rs | 104 +++++++++++------ tests/unit/out/unsafe/temporary_field_addr.rs | 2 + .../out/unsafe/temporary_field_ctor_arg.rs | 1 + .../out/unsafe/temporary_field_two_args.rs | 2 + tests/unit/out/unsafe/typedef-anon-struct.rs | 1 + tests/unit/out/unsafe/unique_ptr.rs | 2 +- .../unit/out/unsafe/unique_ptr_const_deref.rs | 2 +- .../unit/out/unsafe/unique_ptr_field_reset.rs | 2 +- tests/unit/out/unsafe/unique_ptr_nested.rs | 2 +- tests/unit/out/unsafe/vector.rs | 1 + .../out/unsafe/vector_subscript_direct.rs | 1 + tests/unit/out/unsafe/void_cast.rs | 3 +- 119 files changed, 522 insertions(+), 161 deletions(-) diff --git a/tests/multi-file/defaulted_move_cross_tu/out/unsafe/defaulted_move_cross_tu.rs b/tests/multi-file/defaulted_move_cross_tu/out/unsafe/defaulted_move_cross_tu.rs index d866cb761e..bbe34f8ef0 100644 --- a/tests/multi-file/defaulted_move_cross_tu/out/unsafe/defaulted_move_cross_tu.rs +++ b/tests/multi-file/defaulted_move_cross_tu/out/unsafe/defaulted_move_cross_tu.rs @@ -7,7 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, SwappableUnsafe, Default)] #[cpp_from(i32, construct, value)] pub struct S { pub v: Vec, @@ -49,6 +49,7 @@ impl MoveAssignableUnsafe for S { ZeroInitializationUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct T { diff --git a/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/unsafe/p14-class-in-two-files.rs b/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/unsafe/p14-class-in-two-files.rs index c18fa079b7..aae76d21e3 100644 --- a/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/unsafe/p14-class-in-two-files.rs +++ b/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/unsafe/p14-class-in-two-files.rs @@ -18,6 +18,7 @@ pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(| DestructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, )] pub struct LifetimeTracked { pub uses: i32, diff --git a/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/unsafe/p15-class-template-static-member.rs b/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/unsafe/p15-class-template-static-member.rs index 4f186b611c..f68fc579a9 100644 --- a/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/unsafe/p15-class-template-static-member.rs +++ b/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/unsafe/p15-class-template-static-member.rs @@ -18,6 +18,7 @@ pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(| DestructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, )] pub struct LifetimeTracked { pub uses: i32, diff --git a/tests/std/basic/basic.def.odr/p15-function-template/out/unsafe/p15-function-template.rs b/tests/std/basic/basic.def.odr/p15-function-template/out/unsafe/p15-function-template.rs index 02f5ab322c..1a6c02b413 100644 --- a/tests/std/basic/basic.def.odr/p15-function-template/out/unsafe/p15-function-template.rs +++ b/tests/std/basic/basic.def.odr/p15-function-template/out/unsafe/p15-function-template.rs @@ -18,6 +18,7 @@ pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(| DestructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, )] pub struct LifetimeTracked { pub uses: i32, diff --git a/tests/std/basic/basic.def.odr/p15-inline-function/out/unsafe/p15-inline-function.rs b/tests/std/basic/basic.def.odr/p15-inline-function/out/unsafe/p15-inline-function.rs index 75e079fc7e..0410039888 100644 --- a/tests/std/basic/basic.def.odr/p15-inline-function/out/unsafe/p15-inline-function.rs +++ b/tests/std/basic/basic.def.odr/p15-inline-function/out/unsafe/p15-inline-function.rs @@ -18,6 +18,7 @@ pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(| DestructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, )] pub struct LifetimeTracked { pub uses: i32, diff --git a/tests/std/basic/basic.def.odr/p15-inline-variable/out/unsafe/p15-inline-variable.rs b/tests/std/basic/basic.def.odr/p15-inline-variable/out/unsafe/p15-inline-variable.rs index 131c993dfb..7d467d4886 100644 --- a/tests/std/basic/basic.def.odr/p15-inline-variable/out/unsafe/p15-inline-variable.rs +++ b/tests/std/basic/basic.def.odr/p15-inline-variable/out/unsafe/p15-inline-variable.rs @@ -18,6 +18,7 @@ pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(| DestructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, )] pub struct LifetimeTracked { pub uses: i32, diff --git a/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/unsafe/p16-default-argument-lambda-in-class.rs b/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/unsafe/p16-default-argument-lambda-in-class.rs index f950e9629f..5a6ea9c12a 100644 --- a/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/unsafe/p16-default-argument-lambda-in-class.rs +++ b/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/unsafe/p16-default-argument-lambda-in-class.rs @@ -18,6 +18,7 @@ pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(| DestructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, )] pub struct LifetimeTracked { pub uses: i32, diff --git a/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/unsafe/p16-lambda-in-inline-function.rs b/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/unsafe/p16-lambda-in-inline-function.rs index 3fbb41d125..ad625a88a6 100644 --- a/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/unsafe/p16-lambda-in-inline-function.rs +++ b/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/unsafe/p16-lambda-in-inline-function.rs @@ -18,6 +18,7 @@ pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(| DestructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, )] pub struct LifetimeTracked { pub uses: i32, diff --git a/tests/std/expr/expr.compound/out/unsafe/expr.mptr.oper.rs b/tests/std/expr/expr.compound/out/unsafe/expr.mptr.oper.rs index b680038629..fbf260bfda 100644 --- a/tests/std/expr/expr.compound/out/unsafe/expr.mptr.oper.rs +++ b/tests/std/expr/expr.compound/out/unsafe/expr.mptr.oper.rs @@ -95,7 +95,13 @@ pub static mut copyCount_9: std::cell::LazyCell = std::cell::LazyCell::new( pub static mut moveCount_10: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] #[derive( - VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, Default, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + SwappableUnsafe, + Default, )] pub struct p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves {} impl CopyConstructibleUnsafe for p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves { @@ -136,6 +142,7 @@ impl Clone for p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves { CopyConstructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct p6_data_member_of_rvalue_is_xvalue_HoldsCounted { diff --git a/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.if.rs b/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.if.rs index 32a097febb..a6d40f0b33 100644 --- a/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.if.rs +++ b/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.if.rs @@ -27,6 +27,7 @@ thread_local!( Destructible, MoveConstructible, MoveAssignable, + Swappable, )] #[byte_size(4)] pub struct LifetimeTracked { diff --git a/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs b/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs index 28564c4d23..c24737718c 100644 --- a/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs +++ b/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs @@ -27,6 +27,7 @@ thread_local!( Destructible, MoveConstructible, MoveAssignable, + Swappable, )] #[byte_size(4)] pub struct LifetimeTracked { diff --git a/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.if.rs b/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.if.rs index 1e279040bc..80aaad5c3a 100644 --- a/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.if.rs +++ b/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.if.rs @@ -18,6 +18,7 @@ pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(| DestructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, )] pub struct LifetimeTracked { pub uses: i32, diff --git a/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs b/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs index c26c7f6dbe..e8d11c2eb3 100644 --- a/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs +++ b/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs @@ -18,6 +18,7 @@ pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(| DestructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, )] pub struct LifetimeTracked { pub uses: i32, diff --git a/tests/std/utilities/utility/out/refcount/forward-helpers.rs b/tests/std/utilities/utility/out/refcount/forward-helpers.rs index 548fe4723f..7bc99537c4 100644 --- a/tests/std/utilities/utility/out/refcount/forward-helpers.rs +++ b/tests/std/utilities/utility/out/refcount/forward-helpers.rs @@ -23,6 +23,7 @@ pub fn test_0() { CppFrom, CopyAssignable, MoveAssignable, + Swappable, Default, )] #[cpp_from(i32, construct, value)] @@ -64,6 +65,7 @@ impl Clone for p6_forward_like_Movable { CopyConstructible, CopyAssignable, MoveAssignable, + Swappable, )] #[byte_size(4)] pub struct p6_forward_like_Holder { @@ -177,7 +179,15 @@ pub fn test_4() { ); } #[derive( - Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, CopyAssignable, MoveAssignable, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyAssignable, + MoveAssignable, + Swappable, )] #[cpp_from(i32, construct, value)] #[byte_size(12)] @@ -262,6 +272,7 @@ pub fn test_7() { CppFrom, CopyAssignable, MoveAssignable, + Swappable, Default, )] #[cpp_from(i32, construct, value)] @@ -303,6 +314,7 @@ impl Clone for p11_move_if_noexcept_NoexceptMove { CppFrom, CopyAssignable, MoveAssignable, + Swappable, Default, )] #[cpp_from(i32, construct, value)] diff --git a/tests/std/utilities/utility/out/unsafe/forward-helpers.rs b/tests/std/utilities/utility/out/unsafe/forward-helpers.rs index ea83ca0084..4b8ee7f936 100644 --- a/tests/std/utilities/utility/out/unsafe/forward-helpers.rs +++ b/tests/std/utilities/utility/out/unsafe/forward-helpers.rs @@ -22,6 +22,7 @@ pub unsafe fn test_0() { CppFromUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, Default, )] #[cpp_from(i32, construct, value)] @@ -65,6 +66,7 @@ impl Clone for p6_forward_like_Movable { CopyConstructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, )] pub struct p6_forward_like_Holder { pub member: p6_forward_like_Movable, @@ -178,6 +180,7 @@ pub unsafe fn test_4() { CppFromUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, )] #[cpp_from(i32, construct, value)] pub struct p10_forward_in_template_A { @@ -259,6 +262,7 @@ pub unsafe fn test_7() { CppFromUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, Default, )] #[cpp_from(i32, construct, value)] @@ -302,6 +306,7 @@ impl Clone for p11_move_if_noexcept_NoexceptMove { CppFromUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, Default, )] #[cpp_from(i32, construct, value)] diff --git a/tests/unit/out/refcount/array_of_noncopy_struct.rs b/tests/unit/out/refcount/array_of_noncopy_struct.rs index 2209aae2d9..e3875e2fc2 100644 --- a/tests/unit/out/refcount/array_of_noncopy_struct.rs +++ b/tests/unit/out/refcount/array_of_noncopy_struct.rs @@ -7,7 +7,15 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyConstructible, CopyAssignable, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + CopyAssignable, + Swappable, )] #[byte_size(32)] pub struct NonCopy { diff --git a/tests/unit/out/refcount/assignment_single_eval.rs b/tests/unit/out/refcount/assignment_single_eval.rs index ba6986b900..b04347daa9 100644 --- a/tests/unit/out/refcount/assignment_single_eval.rs +++ b/tests/unit/out/refcount/assignment_single_eval.rs @@ -2151,6 +2151,7 @@ pub fn test_stable_containers_58() { FnPtrArg, CopyConstructible, CopyAssignable, + Swappable, Default, )] #[byte_size(24)] diff --git a/tests/unit/out/refcount/cast.rs b/tests/unit/out/refcount/cast.rs index 68f15593a2..2be35da92e 100644 --- a/tests/unit/out/refcount/cast.rs +++ b/tests/unit/out/refcount/cast.rs @@ -61,6 +61,7 @@ impl Default for Grid { FnPtrArg, CopyConstructible, CopyAssignable, + Swappable, Default, )] #[byte_size(32)] diff --git a/tests/unit/out/refcount/class_templates.rs b/tests/unit/out/refcount/class_templates.rs index d1090687b1..217971dcfe 100644 --- a/tests/unit/out/refcount/class_templates.rs +++ b/tests/unit/out/refcount/class_templates.rs @@ -15,6 +15,7 @@ use std::rc::{Rc, Weak}; FnPtrArg, CopyConstructible, CopyAssignable, + Swappable, Default, )] #[byte_size(24)] @@ -45,6 +46,7 @@ impl MoveAssignable for MyContainer_int_ { FnPtrArg, CopyConstructible, CopyAssignable, + Swappable, Default, )] #[byte_size(24)] @@ -75,6 +77,7 @@ impl MoveAssignable for MyContainer_char_ { FnPtrArg, CopyConstructible, CopyAssignable, + Swappable, Default, )] #[byte_size(24)] diff --git a/tests/unit/out/refcount/container_element_receiver.rs b/tests/unit/out/refcount/container_element_receiver.rs index 8bbd973b9f..9e946ba2bb 100644 --- a/tests/unit/out/refcount/container_element_receiver.rs +++ b/tests/unit/out/refcount/container_element_receiver.rs @@ -16,6 +16,7 @@ use std::rc::{Rc, Weak}; CopyConstructible, CopyAssignable, MoveAssignable, + Swappable, Default, )] #[byte_size(32)] diff --git a/tests/unit/out/refcount/container_field_addr.rs b/tests/unit/out/refcount/container_field_addr.rs index 2967e9456e..73f8c3acc5 100644 --- a/tests/unit/out/refcount/container_field_addr.rs +++ b/tests/unit/out/refcount/container_field_addr.rs @@ -15,6 +15,7 @@ use std::rc::{Rc, Weak}; FnPtrArg, CopyConstructible, CopyAssignable, + Swappable, Default, )] #[byte_size(32)] diff --git a/tests/unit/out/refcount/copy_assign.rs b/tests/unit/out/refcount/copy_assign.rs index 732fa7620b..494a9541a3 100644 --- a/tests/unit/out/refcount/copy_assign.rs +++ b/tests/unit/out/refcount/copy_assign.rs @@ -17,6 +17,7 @@ thread_local!( FnPtrArg, MoveConstructible, MoveAssignable, + Swappable, Default, )] #[byte_size(8)] @@ -82,6 +83,7 @@ impl Default for NonConstAssign { CopyConstructible, MoveConstructible, MoveAssignable, + Swappable, )] #[byte_size(4)] pub struct RefQualified { @@ -115,6 +117,7 @@ impl Default for RefQualified { CopyConstructible, MoveConstructible, MoveAssignable, + Swappable, )] #[byte_size(24)] pub struct Holder { @@ -170,6 +173,7 @@ thread_local!( CppFrom, MoveConstructible, MoveAssignable, + Swappable, Default, )] #[cpp_from(i32, construct, value)] @@ -208,6 +212,7 @@ impl Clone for CopyCounted { CopyConstructible, MoveConstructible, MoveAssignable, + Swappable, )] #[byte_size(12)] pub struct HasCopyCounted { diff --git a/tests/unit/out/refcount/copy_ctor.rs b/tests/unit/out/refcount/copy_ctor.rs index 936178be85..cae3eed3e7 100644 --- a/tests/unit/out/refcount/copy_ctor.rs +++ b/tests/unit/out/refcount/copy_ctor.rs @@ -18,6 +18,7 @@ thread_local!( CppFrom, MoveConstructible, MoveAssignable, + Swappable, Default, )] #[cpp_from(i32, construct, value)] @@ -55,6 +56,7 @@ impl Clone for Counted { CopyConstructible, MoveConstructible, MoveAssignable, + Swappable, )] #[byte_size(4)] pub struct NonConst { @@ -97,6 +99,7 @@ impl Default for NonConst { CppFrom, MoveConstructible, MoveAssignable, + Swappable, Default, )] #[cpp_from(i32, construct, value)] @@ -135,6 +138,7 @@ impl Clone for Ignored { CopyConstructible, MoveConstructible, MoveAssignable, + Swappable, )] #[byte_size(12)] pub struct Holder { @@ -178,6 +182,7 @@ impl Default for Holder { CppFrom, CopyAssignable, MoveAssignable, + Swappable, Default, )] #[cpp_from(i32, construct, value)] @@ -216,6 +221,7 @@ impl Clone for Box_int_ { CopyConstructible, CopyAssignable, MoveAssignable, + Swappable, Default, )] #[byte_size(4)] @@ -242,6 +248,7 @@ impl MoveConstructible for Owner { CppFrom, MoveConstructible, MoveAssignable, + Swappable, Default, )] #[cpp_from(i32, construct, value)] @@ -271,7 +278,14 @@ impl Clone for OutOfLine { } } #[derive( - Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, MoveConstructible, MoveAssignable, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + MoveConstructible, + MoveAssignable, + Swappable, )] #[byte_size(4)] pub struct Tracked { diff --git a/tests/unit/out/refcount/copy_move_defaulted.rs b/tests/unit/out/refcount/copy_move_defaulted.rs index dc141e2405..25ecc71465 100644 --- a/tests/unit/out/refcount/copy_move_defaulted.rs +++ b/tests/unit/out/refcount/copy_move_defaulted.rs @@ -23,6 +23,7 @@ pub struct Inner { Destructible, CopyAssignable, MoveAssignable, + Swappable, )] #[cpp_from(i32, construct, value)] #[byte_size(16)] @@ -76,6 +77,7 @@ impl Default for Implicit { FnPtrArg, CppFrom, CopyAssignable, + Swappable, Default, )] #[cpp_from(i32, construct, value)] @@ -97,7 +99,7 @@ impl MoveAssignable for DefaultCopyUserMove { return (*this).clone(); } } -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Swappable, Default)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct UserCopyDefaultMove { @@ -136,7 +138,7 @@ impl Clone for UserCopyDefaultMove { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Swappable)] #[cpp_from(i32, construct, value)] #[byte_size(64)] pub struct Buffer { @@ -185,7 +187,7 @@ impl Default for Buffer { { ::zero_init() } } } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Swappable)] #[byte_size(48)] pub struct Owner { #[offset(0)] @@ -250,6 +252,7 @@ impl Default for Owner { FnPtrArg, CopyConstructible, CopyAssignable, + Swappable, Default, )] #[byte_size(24)] @@ -271,7 +274,9 @@ impl MoveAssignable for Copyable { return (*this).clone(); } } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Destructible, Default)] +#[derive( + Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Destructible, Swappable, Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(32)] pub struct Holder { diff --git a/tests/unit/out/refcount/copy_move_deleted.rs b/tests/unit/out/refcount/copy_move_deleted.rs index c1f1497609..d2c3f2a764 100644 --- a/tests/unit/out/refcount/copy_move_deleted.rs +++ b/tests/unit/out/refcount/copy_move_deleted.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Swappable, Default)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct NoCopy { @@ -26,7 +26,7 @@ impl MoveAssignable for NoCopy { return (*this).clone(); } } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Swappable)] #[byte_size(4)] pub struct PrivateCopy { #[offset(0)] @@ -73,7 +73,7 @@ impl Default for Immovable { } } } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Swappable, Default)] #[byte_size(8)] pub struct Container { #[offset(0)] @@ -99,7 +99,7 @@ impl MoveAssignable for Container { return (*this).clone(); } } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Swappable, Default)] #[byte_size(24)] pub struct VecHolder { #[offset(0)] diff --git a/tests/unit/out/refcount/elidable_iterator_copy_cxx11.rs b/tests/unit/out/refcount/elidable_iterator_copy_cxx11.rs index 2db8397828..144e6264c0 100644 --- a/tests/unit/out/refcount/elidable_iterator_copy_cxx11.rs +++ b/tests/unit/out/refcount/elidable_iterator_copy_cxx11.rs @@ -43,7 +43,7 @@ fn main_0() -> i32 { for __i in (1..__n).rev() { let __j = (std::hash::BuildHasher::hash_one(&__random, __i) % (__i + 1) as u64) as isize; - cpp_swap!(__tmp_3.iter_at(__i), __tmp_3.iter_at(__j)); + Swappable::swap(&__tmp_3.iter_at(__i), __tmp_3.iter_at(__j)); } }; { diff --git a/tests/unit/out/refcount/field_method_receiver.rs b/tests/unit/out/refcount/field_method_receiver.rs index 85bc8c30f8..22368ba7f8 100644 --- a/tests/unit/out/refcount/field_method_receiver.rs +++ b/tests/unit/out/refcount/field_method_receiver.rs @@ -13,7 +13,15 @@ pub struct Counter { pub n: i32, } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyConstructible, CopyAssignable, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + CopyAssignable, + Swappable, )] #[byte_size(40)] pub struct S { diff --git a/tests/unit/out/refcount/field_pointers.rs b/tests/unit/out/refcount/field_pointers.rs index 7b50ae3260..f80aa2fa93 100644 --- a/tests/unit/out/refcount/field_pointers.rs +++ b/tests/unit/out/refcount/field_pointers.rs @@ -35,7 +35,15 @@ pub struct Header { pub size: i16, } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyConstructible, CopyAssignable, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + CopyAssignable, + Swappable, )] #[byte_size(104)] pub struct Outer { diff --git a/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs b/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs index 9ccc0f98d5..ea8a1df522 100644 --- a/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs +++ b/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs @@ -15,6 +15,7 @@ use std::rc::{Rc, Weak}; FnPtrArg, CopyConstructible, CopyAssignable, + Swappable, Default, )] #[byte_size(32)] diff --git a/tests/unit/out/refcount/forward_basic.rs b/tests/unit/out/refcount/forward_basic.rs index 0f8a80dc04..ba8b8174da 100644 --- a/tests/unit/out/refcount/forward_basic.rs +++ b/tests/unit/out/refcount/forward_basic.rs @@ -18,6 +18,7 @@ pub const Overload_kRvalueOverload: Overload = 2; CppFrom, CopyAssignable, MoveAssignable, + Swappable, Default, )] #[cpp_from(i32, construct, value)] @@ -74,6 +75,7 @@ pub fn chosen_overload_1(_a0: Ptr) -> Overload { CopyConstructible, CopyAssignable, MoveAssignable, + Swappable, Default, )] #[cpp_from(Tracked, construct_1, mut_ptr)] diff --git a/tests/unit/out/refcount/forward_decltype.rs b/tests/unit/out/refcount/forward_decltype.rs index aae635d2da..3a2650ab31 100644 --- a/tests/unit/out/refcount/forward_decltype.rs +++ b/tests/unit/out/refcount/forward_decltype.rs @@ -18,6 +18,7 @@ pub const Overload_kRvalueOverload: Overload = 2; CppFrom, CopyAssignable, MoveAssignable, + Swappable, Default, )] #[cpp_from(i32, construct, value)] diff --git a/tests/unit/out/refcount/forward_explicit.rs b/tests/unit/out/refcount/forward_explicit.rs index 8697e9569d..57c84bbb89 100644 --- a/tests/unit/out/refcount/forward_explicit.rs +++ b/tests/unit/out/refcount/forward_explicit.rs @@ -20,6 +20,7 @@ pub const Overload_kIntRvalueOverload: Overload = 4; CppFrom, CopyAssignable, MoveAssignable, + Swappable, Default, )] #[cpp_from(i32, construct, value)] diff --git a/tests/unit/out/refcount/forward_pack.rs b/tests/unit/out/refcount/forward_pack.rs index 650b06e1d8..ebc800a707 100644 --- a/tests/unit/out/refcount/forward_pack.rs +++ b/tests/unit/out/refcount/forward_pack.rs @@ -20,6 +20,7 @@ pub const Overload_kIntRvalueOverload: Overload = 4; CppFrom, CopyAssignable, MoveAssignable, + Swappable, Default, )] #[cpp_from(i32, construct, value)] @@ -117,6 +118,7 @@ pub fn forward_pack_7( CopyConstructible, CopyAssignable, MoveAssignable, + Swappable, Default, )] #[byte_size(24)] diff --git a/tests/unit/out/refcount/huffman.rs b/tests/unit/out/refcount/huffman.rs index d06efedd84..cadcc8d3c0 100644 --- a/tests/unit/out/refcount/huffman.rs +++ b/tests/unit/out/refcount/huffman.rs @@ -40,7 +40,7 @@ pub fn Swap_0(a: Ptr, b: Ptr) { right: (t.right).clone(), }); } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Swappable, Default)] #[byte_size(32)] pub struct MinHeap { #[offset(0)] diff --git a/tests/unit/out/refcount/implicit_autoref.rs b/tests/unit/out/refcount/implicit_autoref.rs index a50366e9ae..345492a4e7 100644 --- a/tests/unit/out/refcount/implicit_autoref.rs +++ b/tests/unit/out/refcount/implicit_autoref.rs @@ -15,6 +15,7 @@ use std::rc::{Rc, Weak}; FnPtrArg, CopyConstructible, CopyAssignable, + Swappable, Default, )] #[byte_size(24)] diff --git a/tests/unit/out/refcount/inline_container_fields.rs b/tests/unit/out/refcount/inline_container_fields.rs index 7ba51f59d0..16887e5966 100644 --- a/tests/unit/out/refcount/inline_container_fields.rs +++ b/tests/unit/out/refcount/inline_container_fields.rs @@ -7,7 +7,15 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyConstructible, CopyAssignable, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + CopyAssignable, + Swappable, )] #[byte_size(48)] pub struct Elem { @@ -56,7 +64,15 @@ impl Default for Elem { } } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyConstructible, CopyAssignable, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + CopyAssignable, + Swappable, )] #[byte_size(88)] pub struct State { @@ -204,7 +220,7 @@ thread_local!( thread_local!( pub static move_assigns_5: Value = Rc::new(RefCell::new(0)); ); -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg)] +#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Swappable)] #[byte_size(4)] pub struct Counted { #[offset(0)] diff --git a/tests/unit/out/refcount/kruskal.rs b/tests/unit/out/refcount/kruskal.rs index e9eb65658a..b709a7ae8f 100644 --- a/tests/unit/out/refcount/kruskal.rs +++ b/tests/unit/out/refcount/kruskal.rs @@ -99,7 +99,7 @@ pub fn quicksort_1(arr: Ptr>>>, mut start: i32, mut end ({ quicksort_1((arr).clone(), start, (p - 1)) }); ({ quicksort_1((arr).clone(), (p + 1), end) }); } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Swappable, Default)] #[byte_size(24)] pub struct DisjointSet { #[offset(0)] @@ -133,7 +133,7 @@ impl MoveAssignable for DisjointSet { return (*this).clone(); } } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Swappable, Default)] #[byte_size(16)] pub struct Graph { #[offset(0)] diff --git a/tests/unit/out/refcount/lambda_capture_copy_ctor.rs b/tests/unit/out/refcount/lambda_capture_copy_ctor.rs index eabfded09f..0e4450a97a 100644 --- a/tests/unit/out/refcount/lambda_capture_copy_ctor.rs +++ b/tests/unit/out/refcount/lambda_capture_copy_ctor.rs @@ -6,7 +6,9 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyAssignable, MoveAssignable)] +#[derive( + Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyAssignable, MoveAssignable, Swappable, +)] #[byte_size(8)] pub struct Counted { #[offset(0)] @@ -60,6 +62,7 @@ thread_local!( Destructible, CopyAssignable, MoveAssignable, + Swappable, )] #[byte_size(1)] pub struct Dropped {} diff --git a/tests/unit/out/refcount/libc_struct_without_default.rs b/tests/unit/out/refcount/libc_struct_without_default.rs index 4f43e49bf5..64b3171264 100644 --- a/tests/unit/out/refcount/libc_struct_without_default.rs +++ b/tests/unit/out/refcount/libc_struct_without_default.rs @@ -7,7 +7,15 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyConstructible, CopyAssignable, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + CopyAssignable, + Swappable, )] #[byte_size(32)] pub struct UserDefined { diff --git a/tests/unit/out/refcount/map_key_copy_ctor.rs b/tests/unit/out/refcount/map_key_copy_ctor.rs index 5293c73cd8..7502c5dcc6 100644 --- a/tests/unit/out/refcount/map_key_copy_ctor.rs +++ b/tests/unit/out/refcount/map_key_copy_ctor.rs @@ -24,6 +24,7 @@ thread_local!( CppFrom, CopyAssignable, MoveAssignable, + Swappable, Default, )] #[cpp_from(i32, construct, value)] diff --git a/tests/unit/out/refcount/map_try_emplace.rs b/tests/unit/out/refcount/map_try_emplace.rs index a8d53a87a9..dd2a6e0d24 100644 --- a/tests/unit/out/refcount/map_try_emplace.rs +++ b/tests/unit/out/refcount/map_try_emplace.rs @@ -19,7 +19,15 @@ thread_local!( pub static moves_3: Value = Rc::new(RefCell::new(0)); ); #[derive( - Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, CopyAssignable, MoveAssignable, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + CopyAssignable, + MoveAssignable, + Swappable, )] #[cpp_from(i32, construct_1, value)] #[byte_size(4)] diff --git a/tests/unit/out/refcount/map_try_emplace_lvalues.rs b/tests/unit/out/refcount/map_try_emplace_lvalues.rs index bd512e532c..7937065cce 100644 --- a/tests/unit/out/refcount/map_try_emplace_lvalues.rs +++ b/tests/unit/out/refcount/map_try_emplace_lvalues.rs @@ -80,7 +80,7 @@ pub fn make_temporary_5() -> Temporary { pub fn make_nested_6() -> Nested { return ::default(); } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Swappable)] #[byte_size(8)] pub struct Owner { #[offset(0)] diff --git a/tests/unit/out/refcount/max.rs b/tests/unit/out/refcount/max.rs index fc268c3828..8c87cac03b 100644 --- a/tests/unit/out/refcount/max.rs +++ b/tests/unit/out/refcount/max.rs @@ -29,6 +29,7 @@ pub fn pick_3(mut i: i32) -> Ptr { CppFrom, MoveConstructible, MoveAssignable, + Swappable, Default, )] #[cpp_from(i32, construct, value)] diff --git a/tests/unit/out/refcount/move_assign.rs b/tests/unit/out/refcount/move_assign.rs index ecb69ffc79..f77a9a7565 100644 --- a/tests/unit/out/refcount/move_assign.rs +++ b/tests/unit/out/refcount/move_assign.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Swappable, Default)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct MoveOnly { diff --git a/tests/unit/out/refcount/move_ctor.rs b/tests/unit/out/refcount/move_ctor.rs index 1d99b35f0c..b7db265c19 100644 --- a/tests/unit/out/refcount/move_ctor.rs +++ b/tests/unit/out/refcount/move_ctor.rs @@ -45,6 +45,7 @@ impl Default for ConstMove { CppFrom, CopyAssignable, MoveAssignable, + Swappable, Default, )] #[cpp_from(i32, construct, value)] @@ -93,6 +94,7 @@ impl Clone for ThrowingMove { CppFrom, CopyAssignable, MoveAssignable, + Swappable, Default, )] #[cpp_from(i32, construct, value)] diff --git a/tests/unit/out/refcount/move_this.rs b/tests/unit/out/refcount/move_this.rs index ec4ac6b5e7..4dd99440e7 100644 --- a/tests/unit/out/refcount/move_this.rs +++ b/tests/unit/out/refcount/move_this.rs @@ -15,6 +15,7 @@ use std::rc::{Rc, Weak}; CppFrom, CopyAssignable, MoveAssignable, + Swappable, Default, )] #[cpp_from(i32, construct, value)] diff --git a/tests/unit/out/refcount/push_emplace_back.rs b/tests/unit/out/refcount/push_emplace_back.rs index e02afffab9..223d6a926a 100644 --- a/tests/unit/out/refcount/push_emplace_back.rs +++ b/tests/unit/out/refcount/push_emplace_back.rs @@ -31,6 +31,7 @@ pub struct Writer { FnPtrArg, CopyConstructible, CopyAssignable, + Swappable, Default, )] #[byte_size(48)] @@ -303,7 +304,15 @@ pub fn emplace_ref_self_read_13(values: Ptr>) -> Ptr { }; } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyConstructible, CopyAssignable, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + CopyAssignable, + Swappable, )] #[byte_size(32)] pub struct Bytes { diff --git a/tests/unit/out/refcount/rule_of_five.rs b/tests/unit/out/refcount/rule_of_five.rs index 18f775d606..9fa331c862 100644 --- a/tests/unit/out/refcount/rule_of_five.rs +++ b/tests/unit/out/refcount/rule_of_five.rs @@ -15,7 +15,9 @@ thread_local!( thread_local!( pub static moves_2: Value = Rc::new(RefCell::new(0)); ); -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Destructible)] +#[derive( + Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Destructible, Swappable, +)] #[cpp_from(i32, construct, value)] #[byte_size(20)] pub struct Buffer { diff --git a/tests/unit/out/refcount/rule_of_three.rs b/tests/unit/out/refcount/rule_of_three.rs index 832f39f4c7..2957c92f45 100644 --- a/tests/unit/out/refcount/rule_of_three.rs +++ b/tests/unit/out/refcount/rule_of_three.rs @@ -22,6 +22,7 @@ thread_local!( Destructible, MoveConstructible, MoveAssignable, + Swappable, )] #[cpp_from(i32, construct, value)] #[byte_size(20)] diff --git a/tests/unit/out/refcount/rvalue_rule_arg_move.rs b/tests/unit/out/refcount/rvalue_rule_arg_move.rs index 936f98ecff..d6b8e9ed1d 100644 --- a/tests/unit/out/refcount/rvalue_rule_arg_move.rs +++ b/tests/unit/out/refcount/rvalue_rule_arg_move.rs @@ -13,7 +13,15 @@ thread_local!( pub static moves_1: Value = Rc::new(RefCell::new(0)); ); #[derive( - Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, MoveAssignable, Default, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + MoveAssignable, + Swappable, + Default, )] #[cpp_from(i32, construct, value)] #[byte_size(4)] diff --git a/tests/unit/out/refcount/sort_no_copy.rs b/tests/unit/out/refcount/sort_no_copy.rs index 022db88dcf..785bb7b5ea 100644 --- a/tests/unit/out/refcount/sort_no_copy.rs +++ b/tests/unit/out/refcount/sort_no_copy.rs @@ -9,7 +9,7 @@ use std::rc::{Rc, Weak}; thread_local!( pub static copies_0: Value = Rc::new(RefCell::new(0)); ); -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom)] +#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Swappable)] #[cpp_from(i32, construct_1, value)] #[byte_size(4)] pub struct Tracked { @@ -76,7 +76,7 @@ pub fn operator_lt_1(a: Ptr, b: Ptr) -> bool { pub fn greater_2(a: Ptr, b: Ptr) -> bool { return ({ a.with(|__s| __s.v) } > { b.with(|__s| __s.v) }); } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Swappable, Default)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct MoveOnly { @@ -117,6 +117,7 @@ pub fn operator_lt_3(a: Ptr, b: Ptr) -> bool { FnPtrArg, CopyConstructible, CopyAssignable, + Swappable, Default, )] #[byte_size(24)] diff --git a/tests/unit/out/refcount/structured_binding_copy_ctor.rs b/tests/unit/out/refcount/structured_binding_copy_ctor.rs index d90ef8dcc9..875b5ee942 100644 --- a/tests/unit/out/refcount/structured_binding_copy_ctor.rs +++ b/tests/unit/out/refcount/structured_binding_copy_ctor.rs @@ -17,6 +17,7 @@ thread_local!( FnPtrArg, MoveConstructible, MoveAssignable, + Swappable, Default, )] #[byte_size(8)] diff --git a/tests/unit/out/refcount/structured_binding_element_ctor.rs b/tests/unit/out/refcount/structured_binding_element_ctor.rs index c23cccac6d..0ec2dc6d64 100644 --- a/tests/unit/out/refcount/structured_binding_element_ctor.rs +++ b/tests/unit/out/refcount/structured_binding_element_ctor.rs @@ -21,6 +21,7 @@ thread_local!( CppFrom, CopyAssignable, MoveAssignable, + Swappable, Default, )] #[cpp_from(i32, construct, value)] @@ -60,6 +61,7 @@ impl Clone for Elem { CopyConstructible, CopyAssignable, MoveAssignable, + Swappable, Default, )] #[byte_size(8)] diff --git a/tests/unit/out/refcount/structured_binding_move_ctor.rs b/tests/unit/out/refcount/structured_binding_move_ctor.rs index 9caeed5b80..120211f055 100644 --- a/tests/unit/out/refcount/structured_binding_move_ctor.rs +++ b/tests/unit/out/refcount/structured_binding_move_ctor.rs @@ -13,7 +13,15 @@ thread_local!( pub static moves_1: Value = Rc::new(RefCell::new(0)); ); #[derive( - Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyAssignable, MoveAssignable, Default, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyAssignable, + MoveAssignable, + Swappable, + Default, )] #[byte_size(8)] pub struct Movable { @@ -58,6 +66,7 @@ impl Clone for Movable { FnPtrArg, CopyConstructible, CopyAssignable, + Swappable, Default, )] #[byte_size(48)] diff --git a/tests/unit/out/refcount/swap_malloc.rs b/tests/unit/out/refcount/swap_malloc.rs index d153f5305b..f40b2a8bc5 100644 --- a/tests/unit/out/refcount/swap_malloc.rs +++ b/tests/unit/out/refcount/swap_malloc.rs @@ -17,31 +17,31 @@ fn main_0() -> i32 { elem!(buf, 0).write(1); elem!(buf, 1).write(2); elem!(buf, 2).write(3); - cpp_swap!(buf.offset((0) as isize), buf.offset((2) as isize)); + Swappable::swap(&buf.offset((0) as isize), buf.offset((2) as isize)); assert!( (((elem!(buf, 0).read()) == 3) && ((elem!(buf, 1).read()) == 2)) && ((elem!(buf, 2).read()) == 1) ); - cpp_swap!(buf.offset((1) as isize), buf.offset((1) as isize)); + Swappable::swap(&buf.offset((1) as isize), buf.offset((1) as isize)); assert!(((elem!(buf, 1).read()) == 2)); let local: Value = Rc::new(RefCell::new(4)); - cpp_swap!(buf.offset((1) as isize), local.as_pointer()); + Swappable::swap(&buf.offset((1) as isize), local.as_pointer()); assert!(({ ((elem!(buf, 1).read()) == 4) && ((*local.borrow()) == 2) })); let mut other: Ptr = libcc2rs::malloc_refcount(::std::mem::size_of::()).reinterpret_cast::(); other.write(5); - cpp_swap!((buf).clone(), (other).clone()); + Swappable::swap(&(buf).clone(), (other).clone()); assert!(((elem!(buf, 0).read()) == 5) && ((other.read()) == 3)); let mut bytes: Ptr = buf.reinterpret_cast::(); elem!(bytes, 0).write(170_u8); elem!(bytes, 4).write(187_u8); - cpp_swap!(bytes.offset((0) as isize), bytes.offset((4) as isize)); + Swappable::swap(&bytes.offset((0) as isize), bytes.offset((4) as isize)); assert!( (((elem!(bytes, 0).read()) as i32) == 187) && (((elem!(bytes, 4).read()) as i32) == 170) ); let words: Value> = Rc::new(RefCell::new(Box::new([16909060_u32, 84281096_u32]))); let mut halves: Ptr = words.decay().reinterpret_cast::(); - cpp_swap!(halves.offset((0) as isize), halves.offset((3) as isize)); + Swappable::swap(&halves.offset((0) as isize), halves.offset((3) as isize)); assert!( ({ ((*words.borrow())[(0) as usize] == 16909574_u32) @@ -52,7 +52,7 @@ fn main_0() -> i32 { let s2: Value = Rc::new(RefCell::new(2)); let sp: Value> = Rc::new(RefCell::new((s1.as_pointer()))); let sq: Value> = Rc::new(RefCell::new((s2.as_pointer()))); - cpp_swap!(sp.as_pointer(), sq.as_pointer()); + Swappable::swap(&sp.as_pointer(), sq.as_pointer()); assert!( ({ ({ (*sp.borrow()).clone() } == { (s2.as_pointer()) }) @@ -61,7 +61,7 @@ fn main_0() -> i32 { ); assert!(({ ((*s1.borrow()) == 1) && ((*s2.borrow()) == 2) })); let null_ptr: Value> = Rc::new(RefCell::new(Ptr::::null())); - cpp_swap!(null_ptr.as_pointer(), sp.as_pointer()); + Swappable::swap(&null_ptr.as_pointer(), sp.as_pointer()); assert!( ({ ({ (*null_ptr.borrow()).clone() } == { (s2.as_pointer()) }) diff --git a/tests/unit/out/refcount/swap_map_no_copy.rs b/tests/unit/out/refcount/swap_map_no_copy.rs index a6b2494d1f..1fd8ea5744 100644 --- a/tests/unit/out/refcount/swap_map_no_copy.rs +++ b/tests/unit/out/refcount/swap_map_no_copy.rs @@ -9,7 +9,7 @@ use std::rc::{Rc, Weak}; thread_local!( pub static copies_0: Value = Rc::new(RefCell::new(0)); ); -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom)] +#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Swappable)] #[cpp_from(i32, construct_1, value)] #[byte_size(4)] pub struct Tracked { @@ -60,7 +60,15 @@ impl Default for Tracked { } } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyConstructible, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + Swappable, + Default, )] #[byte_size(8)] pub struct Pair { @@ -99,7 +107,9 @@ impl MoveAssignable for Pair { return (*this).clone(); } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyConstructible)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyConstructible, Swappable, +)] #[byte_size(16)] pub struct Arrays { #[offset(0)] @@ -225,6 +235,7 @@ thread_local!( Destructible, MoveConstructible, MoveAssignable, + Swappable, Default, )] #[cpp_from(i32, construct, value)] @@ -265,6 +276,7 @@ impl Clone for CopyOnly { CopyConstructible, MoveConstructible, MoveAssignable, + Swappable, Default, )] #[byte_size(8)] @@ -292,7 +304,9 @@ thread_local!( thread_local!( pub static moved_dtors_5: Value = Rc::new(RefCell::new(0)); ); -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Destructible, Default)] +#[derive( + Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Destructible, Swappable, Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct Moved { @@ -344,6 +358,7 @@ impl Clone for Moved { FnPtrArg, Destructible, CopyConstructible, + Swappable, Default, )] #[byte_size(8)] @@ -400,7 +415,7 @@ pub fn swapped_once_6() -> bool { }); return ok; } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Swappable, Default)] #[byte_size(8)] pub struct Owner { #[offset(0)] @@ -436,7 +451,7 @@ fn main_0() -> i32 { TrackedImpl::construct_1(&__v.as_pointer(), { 2 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); - cpp_swap!(a.as_pointer(), b.as_pointer()); + Swappable::swap(&a.as_pointer(), b.as_pointer()); assert!(({ (*a.borrow()).v } == 2) && ({ (*b.borrow()).v } == 1)); assert!((copies_0.with(|rc| *rc.borrow()) == 0)); let m1: Value, Value)>> = Rc::new(RefCell::new(Map::new())); @@ -505,8 +520,8 @@ fn main_0() -> i32 { ) }); assert!((copies_0.with(|rc| *rc.borrow()) == 0)); - cpp_swap!( - match (Rc::new(RefCell::new(1)).as_pointer(),) { + Swappable::swap( + &match (Rc::new(RefCell::new(1)).as_pointer(),) { (__tmp_3,) => { ({ (*m1.borrow_mut()).subscript_move( @@ -527,7 +542,7 @@ fn main_0() -> i32 { ) }) } - } + }, ); assert!( (match (Rc::new(RefCell::new(1)).as_pointer(),) { @@ -558,7 +573,7 @@ fn main_0() -> i32 { == 10) ); assert!((copies_0.with(|rc| *rc.borrow()) == 0)); - cpp_swap!(m1.as_pointer(), m2.as_pointer()); + Swappable::swap(&m1.as_pointer(), m2.as_pointer()); assert!( ((*m1.borrow()).len() == 1_usize) && (match (Rc::new(RefCell::new(3)).as_pointer(),) { @@ -622,11 +637,11 @@ fn main_0() -> i32 { Rc::try_unwrap(__v).ok().unwrap().into_inner() }, ]))); - cpp_swap!(arr.decay().offset(0), arr.decay().offset(2)); + Swappable::swap(&arr.decay().offset(0), arr.decay().offset(2)); assert!( ({ (*arr.borrow())[(0) as usize].v } == 3) && ({ (*arr.borrow())[(2) as usize].v } == 1) ); - cpp_swap!(arr.decay().offset(1), arr.decay().offset(1)); + Swappable::swap(&arr.decay().offset(1), arr.decay().offset(1)); assert!(({ (*arr.borrow())[(1) as usize].v } == 2)); assert!((copies_0.with(|rc| *rc.borrow()) == 0)); let vec_: Value> = Rc::new(RefCell::new(Vec::new())); @@ -650,7 +665,7 @@ fn main_0() -> i32 { }; (*vec_.borrow_mut()).push(__tmp_11); }; - cpp_swap!(vec_.decay().offset(0_usize), vec_.decay().offset(1_usize)); + Swappable::swap(&vec_.decay().offset(0_usize), vec_.decay().offset(1_usize)); assert!(({ (*vec_.borrow())[0_usize].v } == 5) && ({ (*vec_.borrow())[1_usize].v } == 4)); assert!((copies_0.with(|rc| *rc.borrow()) == 0)); let pairs: Value> = Rc::new(RefCell::new(Box::new([ @@ -691,22 +706,25 @@ fn main_0() -> i32 { Rc::try_unwrap(__v).ok().unwrap().into_inner() }, })); - cpp_swap!( - field_ptr!(pairs.decay().offset(0), x), - field_ptr!(p.as_pointer(), y) + Swappable::swap( + &field_ptr!(pairs.decay().offset(0), x), + field_ptr!(p.as_pointer(), y), ); assert!(({ (*pairs.borrow())[(0) as usize].x.v } == 11) && ({ (*p.borrow()).y.v } == 6)); - cpp_swap!(pairs.decay().offset(0), pairs.decay().offset(1)); + Swappable::swap(&pairs.decay().offset(0), pairs.decay().offset(1)); assert!( ({ (*pairs.borrow())[(0) as usize].x.v } == 8) && ({ (*pairs.borrow())[(1) as usize].x.v } == 11) ); assert!((copies_0.with(|rc| *rc.borrow()) == 0)); - cpp_swap!(field_ptr!(p.as_pointer(), x), field_ptr!(p.as_pointer(), y)); + Swappable::swap( + &field_ptr!(p.as_pointer(), x), + field_ptr!(p.as_pointer(), y), + ); assert!(({ (*p.borrow()).x.v } == 6) && ({ (*p.borrow()).y.v } == 10)); - cpp_swap!( - field_ptr!(pairs.decay().offset(0), x), - field_ptr!(pairs.decay().offset(1), y) + Swappable::swap( + &field_ptr!(pairs.decay().offset(0), x), + field_ptr!(pairs.decay().offset(1), y), ); assert!( ({ (*pairs.borrow())[(0) as usize].x.v } == 7) @@ -716,17 +734,17 @@ fn main_0() -> i32 { let arrays: Value = Rc::new(RefCell::new(::default())); field!(array_elem!(arrays.as_pointer(), a, 0), v).write(1); field!(array_elem!(arrays.as_pointer(), b, 1), v).write(2); - cpp_swap!( - array_field_ptr!(arrays.as_pointer(), a).offset((0) as isize), - array_field_ptr!(arrays.as_pointer(), b).offset((1) as isize) + Swappable::swap( + &array_field_ptr!(arrays.as_pointer(), a).offset((0) as isize), + array_field_ptr!(arrays.as_pointer(), b).offset((1) as isize), ); assert!( (array_elem!(arrays.as_pointer(), a, 0).with(|__s| __s.v) == 2) && (array_elem!(arrays.as_pointer(), b, 1).with(|__s| __s.v) == 1) ); - cpp_swap!( - array_field_ptr!(arrays.as_pointer(), a).offset((0) as isize), - array_field_ptr!(arrays.as_pointer(), a).offset((1) as isize) + Swappable::swap( + &array_field_ptr!(arrays.as_pointer(), a).offset((0) as isize), + array_field_ptr!(arrays.as_pointer(), a).offset((1) as isize), ); assert!( (array_elem!(arrays.as_pointer(), a, 0).with(|__s| __s.v) == 0) @@ -768,15 +786,15 @@ fn main_0() -> i32 { __tmp_16.with_mut(|__v: &mut Vec| __v.push(__tmp_17)); } }; - cpp_swap!( - grid.decay().offset(0_usize).decay().offset(1_usize), - grid.decay().offset(1_usize).decay().offset(0_usize) + Swappable::swap( + &grid.decay().offset(0_usize).decay().offset(1_usize), + grid.decay().offset(1_usize).decay().offset(0_usize), ); assert!( (index!(elem!(grid.decay(), 0_usize), 1_usize).with(|__s| __s.v) == 3) && (index!(elem!(grid.decay(), 1_usize), 0_usize).with(|__s| __s.v) == 2) ); - cpp_swap!(grid.decay().offset(0_usize), grid.decay().offset(1_usize)); + Swappable::swap(&grid.decay().offset(0_usize), grid.decay().offset(1_usize)); assert!( ({ ((*grid.decay().offset(0_usize).upgrade().deref()).len() == 1_usize) @@ -831,7 +849,7 @@ fn main_0() -> i32 { _o.as_pointer(), ) }); - cpp_swap!(maps.decay().offset(0), maps.decay().offset(1)); + Swappable::swap(&maps.decay().offset(0), maps.decay().offset(1)); assert!( ((*maps.borrow())[(0) as usize].len() == 1_usize) && (match (Rc::new(RefCell::new(2)).as_pointer(),) { @@ -879,7 +897,7 @@ fn main_0() -> i32 { })); let _dtor_c2 = std::mem::DropGuard::new(c2.clone(), |__p| Destructible::destroy(__p.as_pointer())); - cpp_swap!(c1.as_pointer(), c2.as_pointer()); + Swappable::swap(&c1.as_pointer(), c2.as_pointer()); assert!(({ (*c1.borrow()).v } == 2) && ({ (*c2.borrow()).v } == 1)); assert!( (copy_only_copies_1.with(|rc| *rc.borrow()) == 3) @@ -899,9 +917,9 @@ fn main_0() -> i32 { })); let _dtor_cp = std::mem::DropGuard::new(cp.clone(), |__p| Destructible::destroy(__p.as_pointer())); - cpp_swap!( - field_ptr!(cp.as_pointer(), x), - field_ptr!(cp.as_pointer(), y) + Swappable::swap( + &field_ptr!(cp.as_pointer(), x), + field_ptr!(cp.as_pointer(), y), ); assert!(({ (*cp.borrow()).x.v } == 4) && ({ (*cp.borrow()).y.v } == 3)); assert!( @@ -920,7 +938,7 @@ fn main_0() -> i32 { Rc::try_unwrap(__v).ok().unwrap().into_inner() }, ]))); - cpp_swap!(carr.decay().offset(0), carr.decay().offset(1)); + Swappable::swap(&carr.decay().offset(0), carr.decay().offset(1)); assert!( ({ (*carr.borrow())[(0) as usize].v } == 6) && ({ (*carr.borrow())[(1) as usize].v } == 5) ); @@ -942,7 +960,7 @@ fn main_0() -> i32 { })); let _dtor_mv2 = std::mem::DropGuard::new(mv2.clone(), |__p| Destructible::destroy(__p.as_pointer())); - cpp_swap!(mv1.as_pointer(), mv2.as_pointer()); + Swappable::swap(&mv1.as_pointer(), mv2.as_pointer()); assert!(({ (*mv1.borrow()).v } == 2) && ({ (*mv2.borrow()).v } == 1)); assert!(({ swapped_once_6() })); let mp: Value = Rc::new(RefCell::new(MovedPair { @@ -959,9 +977,9 @@ fn main_0() -> i32 { })); let _dtor_mp = std::mem::DropGuard::new(mp.clone(), |__p| Destructible::destroy(__p.as_pointer())); - cpp_swap!( - field_ptr!(mp.as_pointer(), x), - field_ptr!(mp.as_pointer(), y) + Swappable::swap( + &field_ptr!(mp.as_pointer(), x), + field_ptr!(mp.as_pointer(), y), ); assert!(({ (*mp.borrow()).x.v } == 4) && ({ (*mp.borrow()).y.v } == 3)); assert!(({ swapped_once_6() })); @@ -977,12 +995,12 @@ fn main_0() -> i32 { Rc::try_unwrap(__v).ok().unwrap().into_inner() }, ]))); - cpp_swap!(marr.decay().offset(0), marr.decay().offset(1)); + Swappable::swap(&marr.decay().offset(0), marr.decay().offset(1)); assert!( ({ (*marr.borrow())[(0) as usize].v } == 6) && ({ (*marr.borrow())[(1) as usize].v } == 5) ); assert!(({ swapped_once_6() })); - cpp_swap!(mv1.as_pointer(), mv1.as_pointer()); + Swappable::swap(&mv1.as_pointer(), mv1.as_pointer()); assert!(({ (*mv1.borrow()).v } == 2)); assert!(({ swapped_once_6() })); assert!((copies_0.with(|rc| *rc.borrow()) == 0)); @@ -992,7 +1010,7 @@ fn main_0() -> i32 { let o2: Value = Rc::new(RefCell::new(Owner { p: Some(Rc::new(RefCell::new(2))), })); - cpp_swap!(o1.as_pointer(), o2.as_pointer()); + Swappable::swap(&o1.as_pointer(), o2.as_pointer()); assert!( (({ (*o1.borrow()).p.clone() }.as_pointer().read()) == 2) && (({ (*o2.borrow()).p.clone() }.as_pointer().read()) == 1) diff --git a/tests/unit/out/refcount/temporary_field_addr.rs b/tests/unit/out/refcount/temporary_field_addr.rs index bb868bef2a..21d50adeb8 100644 --- a/tests/unit/out/refcount/temporary_field_addr.rs +++ b/tests/unit/out/refcount/temporary_field_addr.rs @@ -15,6 +15,7 @@ use std::rc::{Rc, Weak}; FnPtrArg, CopyConstructible, CopyAssignable, + Swappable, Default, )] #[byte_size(24)] @@ -37,7 +38,15 @@ impl MoveAssignable for Inner { } } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyConstructible, CopyAssignable, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CopyConstructible, + CopyAssignable, + Swappable, )] #[byte_size(56)] pub struct Outer { diff --git a/tests/unit/out/refcount/temporary_field_ctor_arg.rs b/tests/unit/out/refcount/temporary_field_ctor_arg.rs index 363bae465e..9413cebbfd 100644 --- a/tests/unit/out/refcount/temporary_field_ctor_arg.rs +++ b/tests/unit/out/refcount/temporary_field_ctor_arg.rs @@ -15,6 +15,7 @@ use std::rc::{Rc, Weak}; FnPtrArg, CopyConstructible, CopyAssignable, + Swappable, Default, )] #[byte_size(24)] diff --git a/tests/unit/out/refcount/temporary_field_two_args.rs b/tests/unit/out/refcount/temporary_field_two_args.rs index f459f09cda..a0cacb7c33 100644 --- a/tests/unit/out/refcount/temporary_field_two_args.rs +++ b/tests/unit/out/refcount/temporary_field_two_args.rs @@ -15,6 +15,7 @@ use std::rc::{Rc, Weak}; FnPtrArg, CopyConstructible, CopyAssignable, + Swappable, Default, )] #[byte_size(24)] @@ -45,6 +46,7 @@ impl MoveAssignable for Inner { FnPtrArg, CopyConstructible, CopyAssignable, + Swappable, Default, )] #[byte_size(48)] diff --git a/tests/unit/out/refcount/typedef-anon-struct.rs b/tests/unit/out/refcount/typedef-anon-struct.rs index 891abd6e5a..e534eaa5e9 100644 --- a/tests/unit/out/refcount/typedef-anon-struct.rs +++ b/tests/unit/out/refcount/typedef-anon-struct.rs @@ -23,6 +23,7 @@ pub struct Outer_RunInfo { FnPtrArg, CopyConstructible, CopyAssignable, + Swappable, Default, )] #[byte_size(24)] diff --git a/tests/unit/out/refcount/unique_ptr.rs b/tests/unit/out/refcount/unique_ptr.rs index ba07ffd8fc..156102b44b 100644 --- a/tests/unit/out/refcount/unique_ptr.rs +++ b/tests/unit/out/refcount/unique_ptr.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Swappable, Default)] #[byte_size(8)] pub struct SafePointer { #[offset(0)] diff --git a/tests/unit/out/refcount/unique_ptr_const_deref.rs b/tests/unit/out/refcount/unique_ptr_const_deref.rs index 87955a0a1e..7796dbb19e 100644 --- a/tests/unit/out/refcount/unique_ptr_const_deref.rs +++ b/tests/unit/out/refcount/unique_ptr_const_deref.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Swappable, Default)] #[byte_size(8)] pub struct Holder { #[offset(0)] diff --git a/tests/unit/out/refcount/unique_ptr_field_reset.rs b/tests/unit/out/refcount/unique_ptr_field_reset.rs index e1c2d7a06a..86ba90bc9f 100644 --- a/tests/unit/out/refcount/unique_ptr_field_reset.rs +++ b/tests/unit/out/refcount/unique_ptr_field_reset.rs @@ -12,7 +12,7 @@ pub struct Data { #[offset(0)] pub v: i32, } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Swappable, Default)] #[byte_size(16)] pub struct Holder { #[offset(0)] diff --git a/tests/unit/out/refcount/unique_ptr_nested.rs b/tests/unit/out/refcount/unique_ptr_nested.rs index f27cd620e4..904c751ffb 100644 --- a/tests/unit/out/refcount/unique_ptr_nested.rs +++ b/tests/unit/out/refcount/unique_ptr_nested.rs @@ -14,7 +14,7 @@ pub struct Inner { #[offset(4)] pub y: i32, } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Swappable, Default)] #[byte_size(8)] pub struct Outer { #[offset(0)] diff --git a/tests/unit/out/refcount/vector.rs b/tests/unit/out/refcount/vector.rs index bcac7061a5..4688de476c 100644 --- a/tests/unit/out/refcount/vector.rs +++ b/tests/unit/out/refcount/vector.rs @@ -22,6 +22,7 @@ pub fn copy_0(mut copy_vector: Vec) {} FnPtrArg, CopyConstructible, CopyAssignable, + Swappable, Default, )] #[byte_size(48)] diff --git a/tests/unit/out/refcount/vector_subscript_direct.rs b/tests/unit/out/refcount/vector_subscript_direct.rs index 383e269e33..3a4cb936ff 100644 --- a/tests/unit/out/refcount/vector_subscript_direct.rs +++ b/tests/unit/out/refcount/vector_subscript_direct.rs @@ -23,6 +23,7 @@ pub struct Point { FnPtrArg, CopyConstructible, CopyAssignable, + Swappable, Default, )] #[byte_size(48)] diff --git a/tests/unit/out/refcount/void_cast.rs b/tests/unit/out/refcount/void_cast.rs index b9594ddfc7..0d1c381537 100644 --- a/tests/unit/out/refcount/void_cast.rs +++ b/tests/unit/out/refcount/void_cast.rs @@ -16,6 +16,7 @@ pub fn unused_param_0(mut x: i32) {} FnPtrArg, CopyConstructible, CopyAssignable, + Swappable, Default, )] #[byte_size(24)] @@ -52,7 +53,7 @@ pub struct Holder { #[offset(0)] pub field: i32, } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Swappable, Default)] #[byte_size(8)] pub struct NonCopyable { #[offset(0)] diff --git a/tests/unit/out/unsafe/array_of_noncopy_struct.rs b/tests/unit/out/unsafe/array_of_noncopy_struct.rs index 770659061b..6eea862628 100644 --- a/tests/unit/out/unsafe/array_of_noncopy_struct.rs +++ b/tests/unit/out/unsafe/array_of_noncopy_struct.rs @@ -8,7 +8,13 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + CopyAssignableUnsafe, + SwappableUnsafe, )] pub struct NonCopy { pub data: Vec, diff --git a/tests/unit/out/unsafe/assignment_single_eval.rs b/tests/unit/out/unsafe/assignment_single_eval.rs index 1610f8c14b..192f93e512 100644 --- a/tests/unit/out/unsafe/assignment_single_eval.rs +++ b/tests/unit/out/unsafe/assignment_single_eval.rs @@ -1973,6 +1973,7 @@ pub unsafe fn test_stable_containers_58() { ZeroInitializationUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct Counts_59 { diff --git a/tests/unit/out/unsafe/cast.rs b/tests/unit/out/unsafe/cast.rs index fddc6b454f..43f00a71ed 100644 --- a/tests/unit/out/unsafe/cast.rs +++ b/tests/unit/out/unsafe/cast.rs @@ -36,6 +36,7 @@ pub struct Grid { ZeroInitializationUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct Bag { diff --git a/tests/unit/out/unsafe/class_templates.rs b/tests/unit/out/unsafe/class_templates.rs index 07e3a74d9e..ebf90634ff 100644 --- a/tests/unit/out/unsafe/class_templates.rs +++ b/tests/unit/out/unsafe/class_templates.rs @@ -14,6 +14,7 @@ use std::rc::Rc; ZeroInitializationUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct MyContainer_int_ { @@ -64,6 +65,7 @@ impl MoveAssignableUnsafe for MyContainer_int_ { ZeroInitializationUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct MyContainer_char_ { @@ -114,6 +116,7 @@ impl MoveAssignableUnsafe for MyContainer_char_ { ZeroInitializationUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct MyContainer_float_ { diff --git a/tests/unit/out/unsafe/container_element_receiver.rs b/tests/unit/out/unsafe/container_element_receiver.rs index 02ff73af59..690994595f 100644 --- a/tests/unit/out/unsafe/container_element_receiver.rs +++ b/tests/unit/out/unsafe/container_element_receiver.rs @@ -15,6 +15,7 @@ use std::rc::Rc; CopyConstructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct Holder { diff --git a/tests/unit/out/unsafe/container_field_addr.rs b/tests/unit/out/unsafe/container_field_addr.rs index 64d0b37510..7d251d0652 100644 --- a/tests/unit/out/unsafe/container_field_addr.rs +++ b/tests/unit/out/unsafe/container_field_addr.rs @@ -14,6 +14,7 @@ use std::rc::Rc; ZeroInitializationUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct S { diff --git a/tests/unit/out/unsafe/copy_assign.rs b/tests/unit/out/unsafe/copy_assign.rs index cd9957e9ed..f391136942 100644 --- a/tests/unit/out/unsafe/copy_assign.rs +++ b/tests/unit/out/unsafe/copy_assign.rs @@ -14,6 +14,7 @@ pub static mut assigns_0: std::cell::LazyCell = std::cell::LazyCell::new(|| ZeroInitializationUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct Partial { @@ -90,6 +91,7 @@ impl Default for NonConstAssign { CopyConstructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, )] pub struct RefQualified { pub mark: i32, @@ -125,6 +127,7 @@ impl Default for RefQualified { CopyConstructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct Holder { @@ -161,6 +164,7 @@ pub static mut copies_1: std::cell::LazyCell = std::cell::LazyCell::new(|| CppFromUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, Default, )] #[cpp_from(i32, construct, value)] @@ -202,6 +206,7 @@ impl Clone for CopyCounted { CopyConstructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct HasCopyCounted { diff --git a/tests/unit/out/unsafe/copy_ctor.rs b/tests/unit/out/unsafe/copy_ctor.rs index d0b6f03e98..adabeb6559 100644 --- a/tests/unit/out/unsafe/copy_ctor.rs +++ b/tests/unit/out/unsafe/copy_ctor.rs @@ -15,6 +15,7 @@ pub static mut copies_0: std::cell::LazyCell = std::cell::LazyCell::new(|| CppFromUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, Default, )] #[cpp_from(i32, construct, value)] @@ -55,6 +56,7 @@ impl Clone for Counted { CopyConstructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, )] pub struct NonConst { pub mark: i32, @@ -104,6 +106,7 @@ impl Default for NonConst { CppFromUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, Default, )] #[cpp_from(i32, construct, value)] @@ -145,6 +148,7 @@ impl Clone for Ignored { CopyConstructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct Holder { @@ -176,6 +180,7 @@ impl CopyAssignableUnsafe for Holder { CppFromUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, Default, )] #[cpp_from(i32, construct, value)] @@ -215,6 +220,7 @@ impl Clone for Box_int_ { CopyConstructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct Owner { @@ -237,6 +243,7 @@ impl MoveConstructibleUnsafe for Owner { CppFromUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, Default, )] #[cpp_from(i32, construct, value)] @@ -271,7 +278,12 @@ impl Clone for OutOfLine { } #[repr(C)] #[derive( - VaArg, FnPtrArg, ZeroInitializationUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + MoveConstructibleUnsafe, + MoveAssignableUnsafe, + SwappableUnsafe, )] pub struct Tracked { pub copied_from: i32, diff --git a/tests/unit/out/unsafe/copy_move_defaulted.rs b/tests/unit/out/unsafe/copy_move_defaulted.rs index f1a65bb058..f94af02767 100644 --- a/tests/unit/out/unsafe/copy_move_defaulted.rs +++ b/tests/unit/out/unsafe/copy_move_defaulted.rs @@ -21,6 +21,7 @@ pub struct Inner { DestructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, Default, )] #[cpp_from(i32, construct, value)] @@ -53,6 +54,7 @@ pub struct Implicit { ZeroInitializationUnsafe, CppFromUnsafe, CopyAssignableUnsafe, + SwappableUnsafe, Default, )] #[cpp_from(i32, construct, value)] @@ -78,7 +80,7 @@ impl MoveAssignableUnsafe for DefaultCopyUserMove { } } #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, SwappableUnsafe, Default)] #[cpp_from(i32, construct, value)] pub struct UserCopyDefaultMove { pub v: i32, @@ -120,7 +122,7 @@ impl Clone for UserCopyDefaultMove { } } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, SwappableUnsafe, Default)] #[cpp_from(i32, construct, value)] pub struct Buffer { pub data: Vec, @@ -171,7 +173,7 @@ impl MoveAssignableUnsafe for Buffer { } } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, SwappableUnsafe, Default)] pub struct Owner { pub data: Vec, pub n: i32, @@ -216,6 +218,7 @@ impl MoveAssignableUnsafe for Owner { ZeroInitializationUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct Copyable { @@ -235,7 +238,9 @@ impl MoveAssignableUnsafe for Copyable { } } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, Default)] +#[derive( + FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, SwappableUnsafe, Default, +)] #[cpp_from(i32, construct, value)] pub struct Holder { pub inner: Inner, diff --git a/tests/unit/out/unsafe/copy_move_deleted.rs b/tests/unit/out/unsafe/copy_move_deleted.rs index b113919eb2..4419889b00 100644 --- a/tests/unit/out/unsafe/copy_move_deleted.rs +++ b/tests/unit/out/unsafe/copy_move_deleted.rs @@ -7,7 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, SwappableUnsafe, Default)] #[cpp_from(i32, construct, value)] pub struct NoCopy { pub v: i32, @@ -31,7 +31,7 @@ impl MoveAssignableUnsafe for NoCopy { } } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, SwappableUnsafe)] pub struct PrivateCopy { pub v: i32, } @@ -86,7 +86,7 @@ impl Default for Immovable { } } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, SwappableUnsafe, Default)] pub struct Container { pub inner: NoCopy, pub tag: i32, @@ -112,7 +112,7 @@ impl MoveAssignableUnsafe for Container { } } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, SwappableUnsafe, Default)] pub struct VecHolder { pub items: Vec, } diff --git a/tests/unit/out/unsafe/elidable_iterator_copy_cxx11.rs b/tests/unit/out/unsafe/elidable_iterator_copy_cxx11.rs index 1e87ab39ce..0a5d147cf5 100644 --- a/tests/unit/out/unsafe/elidable_iterator_copy_cxx11.rs +++ b/tests/unit/out/unsafe/elidable_iterator_copy_cxx11.rs @@ -38,7 +38,7 @@ unsafe fn main_0() -> i32 { let __n = v.end().iter_distance(&__tmp_2); for __i in (1..__n).rev() { let __j = libc::rand() as isize % (__i + 1); - cpp_swap_unsafe!(__tmp_2.iter_at(__i), __tmp_2.iter_at(__j)); + SwappableUnsafe::swap(&mut *__tmp_2.iter_at(__i), __tmp_2.iter_at(__j)); } }; { diff --git a/tests/unit/out/unsafe/field_method_receiver.rs b/tests/unit/out/unsafe/field_method_receiver.rs index c47aac6d61..e392c69865 100644 --- a/tests/unit/out/unsafe/field_method_receiver.rs +++ b/tests/unit/out/unsafe/field_method_receiver.rs @@ -34,6 +34,7 @@ impl Counter { ZeroInitializationUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct S { diff --git a/tests/unit/out/unsafe/field_pointers.rs b/tests/unit/out/unsafe/field_pointers.rs index c8de3a976e..65b492c43f 100644 --- a/tests/unit/out/unsafe/field_pointers.rs +++ b/tests/unit/out/unsafe/field_pointers.rs @@ -26,6 +26,7 @@ pub struct Header { ZeroInitializationUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct Outer { diff --git a/tests/unit/out/unsafe/foreach_disjoint_field_borrow.rs b/tests/unit/out/unsafe/foreach_disjoint_field_borrow.rs index 24771dd454..e7e5e12b3a 100644 --- a/tests/unit/out/unsafe/foreach_disjoint_field_borrow.rs +++ b/tests/unit/out/unsafe/foreach_disjoint_field_borrow.rs @@ -14,6 +14,7 @@ use std::rc::Rc; ZeroInitializationUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct S { diff --git a/tests/unit/out/unsafe/forward_basic.rs b/tests/unit/out/unsafe/forward_basic.rs index a13777820c..e90c2d9084 100644 --- a/tests/unit/out/unsafe/forward_basic.rs +++ b/tests/unit/out/unsafe/forward_basic.rs @@ -17,6 +17,7 @@ pub const Overload_kRvalueOverload: Overload = 2; CppFromUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, Default, )] #[cpp_from(i32, construct, value)] @@ -90,6 +91,7 @@ impl Holder { CopyConstructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, Default, )] #[cpp_from(Tracked, construct_1, mut_ptr)] diff --git a/tests/unit/out/unsafe/forward_decltype.rs b/tests/unit/out/unsafe/forward_decltype.rs index b9dd263cfb..ceb864cf0f 100644 --- a/tests/unit/out/unsafe/forward_decltype.rs +++ b/tests/unit/out/unsafe/forward_decltype.rs @@ -17,6 +17,7 @@ pub const Overload_kRvalueOverload: Overload = 2; CppFromUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, Default, )] #[cpp_from(i32, construct, value)] diff --git a/tests/unit/out/unsafe/forward_explicit.rs b/tests/unit/out/unsafe/forward_explicit.rs index 8f32ba673b..26bc14c328 100644 --- a/tests/unit/out/unsafe/forward_explicit.rs +++ b/tests/unit/out/unsafe/forward_explicit.rs @@ -19,6 +19,7 @@ pub const Overload_kIntRvalueOverload: Overload = 4; CppFromUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, Default, )] #[cpp_from(i32, construct, value)] diff --git a/tests/unit/out/unsafe/forward_pack.rs b/tests/unit/out/unsafe/forward_pack.rs index 8dd3c3084a..0577df8ec8 100644 --- a/tests/unit/out/unsafe/forward_pack.rs +++ b/tests/unit/out/unsafe/forward_pack.rs @@ -19,6 +19,7 @@ pub const Overload_kIntRvalueOverload: Overload = 4; CppFromUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, Default, )] #[cpp_from(i32, construct, value)] @@ -127,6 +128,7 @@ impl Pair { CopyConstructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct Pair { diff --git a/tests/unit/out/unsafe/huffman.rs b/tests/unit/out/unsafe/huffman.rs index a063be99f0..f0283a4a86 100644 --- a/tests/unit/out/unsafe/huffman.rs +++ b/tests/unit/out/unsafe/huffman.rs @@ -40,7 +40,7 @@ pub unsafe fn Swap_0(a: *mut MinHeapNode, b: *mut MinHeapNode) { }; } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, SwappableUnsafe, Default)] pub struct MinHeap { pub size: i32, pub capacity: i32, diff --git a/tests/unit/out/unsafe/implicit_autoref.rs b/tests/unit/out/unsafe/implicit_autoref.rs index 7ce5cc0cfb..b2eaf6d49e 100644 --- a/tests/unit/out/unsafe/implicit_autoref.rs +++ b/tests/unit/out/unsafe/implicit_autoref.rs @@ -14,6 +14,7 @@ use std::rc::Rc; ZeroInitializationUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct Holder { diff --git a/tests/unit/out/unsafe/inline_container_fields.rs b/tests/unit/out/unsafe/inline_container_fields.rs index 46da544ecd..4e6e2d1c20 100644 --- a/tests/unit/out/unsafe/inline_container_fields.rs +++ b/tests/unit/out/unsafe/inline_container_fields.rs @@ -14,6 +14,7 @@ use std::rc::Rc; ZeroInitializationUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct Elem { @@ -49,7 +50,13 @@ impl MoveAssignableUnsafe for Elem { } #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + CopyAssignableUnsafe, + SwappableUnsafe, )] pub struct State { pub count: i32, @@ -164,7 +171,7 @@ pub static mut moves_3: std::cell::LazyCell = std::cell::LazyCell::new(|| u pub static mut copy_assigns_4: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut move_assigns_5: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe)] +#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, SwappableUnsafe)] pub struct Counted { pub v: i32, } diff --git a/tests/unit/out/unsafe/kruskal.rs b/tests/unit/out/unsafe/kruskal.rs index f014467304..5bdd992925 100644 --- a/tests/unit/out/unsafe/kruskal.rs +++ b/tests/unit/out/unsafe/kruskal.rs @@ -164,7 +164,7 @@ pub unsafe fn quicksort_1(arr: *mut Option>, mut start: i32, mut end (unsafe { quicksort_1(arr, ((p) + (1)), end) }); } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, SwappableUnsafe, Default)] pub struct DisjointSet { pub rank: Option>, pub parent: Option>, @@ -295,7 +295,7 @@ impl MoveAssignableUnsafe for DisjointSet { } } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, SwappableUnsafe, Default)] pub struct Graph { pub edges: Option>, pub V: i32, diff --git a/tests/unit/out/unsafe/lambda_capture_copy_ctor.rs b/tests/unit/out/unsafe/lambda_capture_copy_ctor.rs index c1ec2bcc50..8f6d902745 100644 --- a/tests/unit/out/unsafe/lambda_capture_copy_ctor.rs +++ b/tests/unit/out/unsafe/lambda_capture_copy_ctor.rs @@ -7,7 +7,14 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + SwappableUnsafe, +)] pub struct Counted { pub copies: i32, pub moves: i32, @@ -59,6 +66,7 @@ pub static mut drops_0: std::cell::LazyCell = std::cell::LazyCell::new(|| u DestructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, )] pub struct Dropped {} impl Dropped { diff --git a/tests/unit/out/unsafe/libc_struct_without_default.rs b/tests/unit/out/unsafe/libc_struct_without_default.rs index 7fc9b5cb94..7c20358d5d 100644 --- a/tests/unit/out/unsafe/libc_struct_without_default.rs +++ b/tests/unit/out/unsafe/libc_struct_without_default.rs @@ -8,7 +8,13 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + CopyAssignableUnsafe, + SwappableUnsafe, )] pub struct UserDefined { pub a: [i32; 1], diff --git a/tests/unit/out/unsafe/map_key_copy_ctor.rs b/tests/unit/out/unsafe/map_key_copy_ctor.rs index eb907962e3..982b40a266 100644 --- a/tests/unit/out/unsafe/map_key_copy_ctor.rs +++ b/tests/unit/out/unsafe/map_key_copy_ctor.rs @@ -17,6 +17,7 @@ pub static mut made_2: std::cell::LazyCell = std::cell::LazyCell::new(|| un CppFromUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, Default, )] #[cpp_from(i32, construct, value)] diff --git a/tests/unit/out/unsafe/map_try_emplace.rs b/tests/unit/out/unsafe/map_try_emplace.rs index 2b4249ee8e..fd173149c3 100644 --- a/tests/unit/out/unsafe/map_try_emplace.rs +++ b/tests/unit/out/unsafe/map_try_emplace.rs @@ -18,6 +18,7 @@ pub static mut moves_3: std::cell::LazyCell = std::cell::LazyCell::new(|| u CppFromUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, )] #[cpp_from(i32, construct_1, value)] pub struct Item { diff --git a/tests/unit/out/unsafe/map_try_emplace_lvalues.rs b/tests/unit/out/unsafe/map_try_emplace_lvalues.rs index fbdc18a77f..70dd490123 100644 --- a/tests/unit/out/unsafe/map_try_emplace_lvalues.rs +++ b/tests/unit/out/unsafe/map_try_emplace_lvalues.rs @@ -86,7 +86,7 @@ pub unsafe fn make_nested_6() -> Nested { return ::default(); } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, SwappableUnsafe)] pub struct Owner { pub ptr: Option>, } diff --git a/tests/unit/out/unsafe/max.rs b/tests/unit/out/unsafe/max.rs index 4bc1060e1e..350a41feec 100644 --- a/tests/unit/out/unsafe/max.rs +++ b/tests/unit/out/unsafe/max.rs @@ -24,6 +24,7 @@ pub unsafe fn pick_3(mut i: i32) -> *mut i32 { CppFromUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, Default, )] #[cpp_from(i32, construct, value)] diff --git a/tests/unit/out/unsafe/move_assign.rs b/tests/unit/out/unsafe/move_assign.rs index ad32567771..7e0dccceb3 100644 --- a/tests/unit/out/unsafe/move_assign.rs +++ b/tests/unit/out/unsafe/move_assign.rs @@ -7,7 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, SwappableUnsafe, Default)] #[cpp_from(i32, construct, value)] pub struct MoveOnly { pub v: i32, diff --git a/tests/unit/out/unsafe/move_ctor.rs b/tests/unit/out/unsafe/move_ctor.rs index 7001eee52d..33c8966011 100644 --- a/tests/unit/out/unsafe/move_ctor.rs +++ b/tests/unit/out/unsafe/move_ctor.rs @@ -58,6 +58,7 @@ impl Default for ConstMove { CppFromUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, Default, )] #[cpp_from(i32, construct, value)] @@ -105,6 +106,7 @@ impl Clone for ThrowingMove { CppFromUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, Default, )] #[cpp_from(i32, construct, value)] diff --git a/tests/unit/out/unsafe/move_this.rs b/tests/unit/out/unsafe/move_this.rs index d64961f6f7..66913ae933 100644 --- a/tests/unit/out/unsafe/move_this.rs +++ b/tests/unit/out/unsafe/move_this.rs @@ -14,6 +14,7 @@ use std::rc::Rc; CppFromUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, Default, )] #[cpp_from(i32, construct, value)] diff --git a/tests/unit/out/unsafe/push_emplace_back.rs b/tests/unit/out/unsafe/push_emplace_back.rs index 5a2ddf98f5..791593ba0f 100644 --- a/tests/unit/out/unsafe/push_emplace_back.rs +++ b/tests/unit/out/unsafe/push_emplace_back.rs @@ -25,6 +25,7 @@ pub struct Writer { ZeroInitializationUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct JPEGData { @@ -225,6 +226,7 @@ pub unsafe fn emplace_ref_self_read_13(values: *mut Vec) -> *mut i64 { ZeroInitializationUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct Bytes { diff --git a/tests/unit/out/unsafe/rule_of_five.rs b/tests/unit/out/unsafe/rule_of_five.rs index e6785642ba..9e296f2b21 100644 --- a/tests/unit/out/unsafe/rule_of_five.rs +++ b/tests/unit/out/unsafe/rule_of_five.rs @@ -10,7 +10,15 @@ pub static mut alive_0: std::cell::LazyCell = std::cell::LazyCell::new(|| u pub static mut copies_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut moves_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, Default)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + SwappableUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct Buffer { pub data: [i32; 4], diff --git a/tests/unit/out/unsafe/rule_of_three.rs b/tests/unit/out/unsafe/rule_of_three.rs index 206cabd63b..d44d464b8f 100644 --- a/tests/unit/out/unsafe/rule_of_three.rs +++ b/tests/unit/out/unsafe/rule_of_three.rs @@ -17,6 +17,7 @@ pub static mut copies_1: std::cell::LazyCell = std::cell::LazyCell::new(|| DestructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, Default, )] #[cpp_from(i32, construct, value)] diff --git a/tests/unit/out/unsafe/rvalue_rule_arg_move.rs b/tests/unit/out/unsafe/rvalue_rule_arg_move.rs index 6f148213b5..5accffdc6b 100644 --- a/tests/unit/out/unsafe/rvalue_rule_arg_move.rs +++ b/tests/unit/out/unsafe/rvalue_rule_arg_move.rs @@ -10,7 +10,13 @@ pub static mut copies_0: std::cell::LazyCell = std::cell::LazyCell::new(|| pub static mut moves_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] #[derive( - VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, MoveAssignableUnsafe, Default, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + MoveAssignableUnsafe, + SwappableUnsafe, + Default, )] #[cpp_from(i32, construct, value)] pub struct Elem { diff --git a/tests/unit/out/unsafe/sort_no_copy.rs b/tests/unit/out/unsafe/sort_no_copy.rs index 2cf3500828..cecfde3d62 100644 --- a/tests/unit/out/unsafe/sort_no_copy.rs +++ b/tests/unit/out/unsafe/sort_no_copy.rs @@ -8,7 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub static mut copies_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe)] +#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, SwappableUnsafe)] #[cpp_from(i32, construct_1, value)] pub struct Tracked { pub v: i32, @@ -99,7 +99,7 @@ pub unsafe fn greater_2(a: *const Tracked, b: *const Tracked) -> bool { return (((*a).v) > ((*b).v)); } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, SwappableUnsafe, Default)] #[cpp_from(i32, construct, value)] pub struct MoveOnly { pub v: i32, @@ -158,6 +158,7 @@ pub unsafe fn operator_lt_3(a: *const MoveOnly, b: *const MoveOnly) -> bool { ZeroInitializationUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct Bag { diff --git a/tests/unit/out/unsafe/structured_binding_copy_ctor.rs b/tests/unit/out/unsafe/structured_binding_copy_ctor.rs index daf0cc190b..763aa5b3f7 100644 --- a/tests/unit/out/unsafe/structured_binding_copy_ctor.rs +++ b/tests/unit/out/unsafe/structured_binding_copy_ctor.rs @@ -14,6 +14,7 @@ pub static mut copies_0: std::cell::LazyCell = std::cell::LazyCell::new(|| ZeroInitializationUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct Counted { diff --git a/tests/unit/out/unsafe/structured_binding_element_ctor.rs b/tests/unit/out/unsafe/structured_binding_element_ctor.rs index f2925d8dd8..bdb27f7216 100644 --- a/tests/unit/out/unsafe/structured_binding_element_ctor.rs +++ b/tests/unit/out/unsafe/structured_binding_element_ctor.rs @@ -16,6 +16,7 @@ pub static mut moves_1: std::cell::LazyCell = std::cell::LazyCell::new(|| u CppFromUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, Default, )] #[cpp_from(i32, construct, value)] @@ -58,6 +59,7 @@ impl Clone for Elem { CopyConstructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct Two { diff --git a/tests/unit/out/unsafe/structured_binding_move_ctor.rs b/tests/unit/out/unsafe/structured_binding_move_ctor.rs index 24ebdad87d..111558642b 100644 --- a/tests/unit/out/unsafe/structured_binding_move_ctor.rs +++ b/tests/unit/out/unsafe/structured_binding_move_ctor.rs @@ -10,7 +10,13 @@ pub static mut copies_0: std::cell::LazyCell = std::cell::LazyCell::new(|| pub static mut moves_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] #[derive( - VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, Default, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyAssignableUnsafe, + MoveAssignableUnsafe, + SwappableUnsafe, + Default, )] pub struct Movable { pub x: i32, @@ -55,6 +61,7 @@ impl Clone for Movable { ZeroInitializationUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct Holder { diff --git a/tests/unit/out/unsafe/swap_malloc.rs b/tests/unit/out/unsafe/swap_malloc.rs index 9a58e43bed..4fe49969c9 100644 --- a/tests/unit/out/unsafe/swap_malloc.rs +++ b/tests/unit/out/unsafe/swap_malloc.rs @@ -19,41 +19,47 @@ unsafe fn main_0() -> i32 { (*buf.offset((0) as isize)) = 1; (*buf.offset((1) as isize)) = 2; (*buf.offset((2) as isize)) = 3; - cpp_swap_unsafe!(buf.offset((0) as isize), buf.offset((2) as isize)); + SwappableUnsafe::swap(&mut *(buf.offset((0) as isize)), buf.offset((2) as isize)); assert!( (((*buf.offset((0) as isize)) == (3)) && ((*buf.offset((1) as isize)) == (2))) && ((*buf.offset((2) as isize)) == (1)) ); - cpp_swap_unsafe!(buf.offset((1) as isize), buf.offset((1) as isize)); + SwappableUnsafe::swap(&mut *(buf.offset((1) as isize)), buf.offset((1) as isize)); assert!(((*buf.offset((1) as isize)) == (2))); let mut local: i32 = 4; - cpp_swap_unsafe!(buf.offset((1) as isize), &mut local); + SwappableUnsafe::swap(&mut *(buf.offset((1) as isize)), &mut local); assert!(((*buf.offset((1) as isize)) == (4)) && ((local) == (2))); let mut other: *mut i32 = ((libcc2rs::malloc_unsafe(::std::mem::size_of::())) as *mut i32); (*other) = 5; - cpp_swap_unsafe!(buf, other); + SwappableUnsafe::swap(&mut *(buf), other); assert!(((*buf.offset((0) as isize)) == (5)) && ((*other) == (3))); let mut bytes: *mut u8 = (buf as *mut u8); (*bytes.offset((0) as isize)) = 170_u8; (*bytes.offset((4) as isize)) = 187_u8; - cpp_swap_unsafe!(bytes.offset((0) as isize), bytes.offset((4) as isize)); + SwappableUnsafe::swap( + &mut *(bytes.offset((0) as isize)), + bytes.offset((4) as isize), + ); assert!( (((*bytes.offset((0) as isize)) as i32) == (187)) && (((*bytes.offset((4) as isize)) as i32) == (170)) ); let mut words: [u32; 2] = [16909060_u32, 84281096_u32]; let mut halves: *mut u16 = (words.as_mut_ptr() as *mut u16); - cpp_swap_unsafe!(halves.offset((0) as isize), halves.offset((3) as isize)); + SwappableUnsafe::swap( + &mut *(halves.offset((0) as isize)), + halves.offset((3) as isize), + ); assert!(((words[(0) as usize]) == (16909574_u32)) && ((words[(1) as usize]) == (50595592_u32))); let mut s1: i32 = 1; let mut s2: i32 = 2; let mut sp: *mut i32 = (&mut s1 as *mut i32); let mut sq: *mut i32 = (&mut s2 as *mut i32); - cpp_swap_unsafe!(&mut sp, &mut sq); + SwappableUnsafe::swap(&mut *(&mut sp), &mut sq); assert!(((sp) == (&mut s2 as *mut i32)) && ((sq) == (&mut s1 as *mut i32))); assert!(((s1) == (1)) && ((s2) == (2))); let mut null_ptr: *mut i32 = std::ptr::null_mut(); - cpp_swap_unsafe!(&mut null_ptr, &mut sp); + SwappableUnsafe::swap(&mut *(&mut null_ptr), &mut sp); assert!(((null_ptr) == (&mut s2 as *mut i32)) && ((sp).is_null())); libcc2rs::free_unsafe((other as *mut ::libc::c_void)); libcc2rs::free_unsafe((buf as *mut ::libc::c_void)); diff --git a/tests/unit/out/unsafe/swap_map_no_copy.rs b/tests/unit/out/unsafe/swap_map_no_copy.rs index 81f972290b..447bf87a3f 100644 --- a/tests/unit/out/unsafe/swap_map_no_copy.rs +++ b/tests/unit/out/unsafe/swap_map_no_copy.rs @@ -8,7 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub static mut copies_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe)] +#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, SwappableUnsafe)] #[cpp_from(i32, construct_1, value)] pub struct Tracked { pub v: i32, @@ -66,7 +66,15 @@ impl Default for Tracked { } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyConstructibleUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + SwappableUnsafe, + Default, +)] pub struct Pair { pub x: Tracked, pub y: Tracked, @@ -112,7 +120,15 @@ impl MoveAssignableUnsafe for Pair { } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyConstructibleUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CopyConstructibleUnsafe, + SwappableUnsafe, + Default, +)] pub struct Arrays { pub a: [Tracked; 2], pub b: [Tracked; 2], @@ -202,6 +218,7 @@ pub static mut copy_only_dtors_2: std::cell::LazyCell = DestructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, Default, )] #[cpp_from(i32, construct, value)] @@ -248,6 +265,7 @@ impl Clone for CopyOnly { CopyConstructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct CopyOnlyPair { @@ -277,7 +295,15 @@ pub static mut moves_3: std::cell::LazyCell = std::cell::LazyCell::new(|| u pub static mut move_assigns_4: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut moved_dtors_5: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, Default)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + SwappableUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct Moved { pub v: i32, @@ -335,6 +361,7 @@ impl Clone for Moved { ZeroInitializationUnsafe, DestructibleUnsafe, CopyConstructibleUnsafe, + SwappableUnsafe, Default, )] pub struct MovedPair { @@ -401,7 +428,7 @@ pub unsafe fn swapped_once_6() -> bool { return ok; } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, SwappableUnsafe, Default)] pub struct Owner { pub p: Option>, } @@ -435,7 +462,7 @@ unsafe fn main_0() -> i32 { Tracked::construct_1(&mut __v, { 2 }); __v }; - cpp_swap_unsafe!(&mut a, &mut b); + SwappableUnsafe::swap(&mut *(&mut a), &mut b); assert!(((a.v) == (2)) && ((b.v) == (1))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (0))); let mut m1: UnsafeMap = UnsafeMap::new(); @@ -474,9 +501,13 @@ unsafe fn main_0() -> i32 { ) }); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (0))); - cpp_swap_unsafe!( - &mut (*m1.subscript_move(&mut 1, |__k| cpp_move_unsafe!(__k), || ::default())), - &mut (*m1.subscript_move(&mut 2, |__k| cpp_move_unsafe!(__k), || ::default())) + SwappableUnsafe::swap( + &mut *(&mut (*m1.subscript_move( + &mut 1, + |__k| cpp_move_unsafe!(__k), + || ::default(), + ))), + &mut (*m1.subscript_move(&mut 2, |__k| cpp_move_unsafe!(__k), || ::default())), ); assert!( (((*m1.subscript_move(&mut 1, |__k| cpp_move_unsafe!(__k), || ::default())).v) @@ -489,7 +520,7 @@ unsafe fn main_0() -> i32 { .v) == (10)) ); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (0))); - cpp_swap_unsafe!(&mut m1, &mut m2); + SwappableUnsafe::swap(&mut *(&mut m1), &mut m2); assert!( ((m1.len()) == (1_usize)) && (((*m1.subscript_move( @@ -532,9 +563,9 @@ unsafe fn main_0() -> i32 { __v }, ]; - cpp_swap_unsafe!(&mut arr[(0) as usize], &mut arr[(2) as usize]); + SwappableUnsafe::swap(&mut *(&mut arr[(0) as usize]), &mut arr[(2) as usize]); assert!(((arr[(0) as usize].v) == (3)) && ((arr[(2) as usize].v) == (1))); - cpp_swap_unsafe!(&mut arr[(1) as usize], &mut arr[(1) as usize]); + SwappableUnsafe::swap(&mut *(&mut arr[(1) as usize]), &mut arr[(1) as usize]); assert!(((arr[(1) as usize].v) == (2))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (0))); let mut vec_: Vec = Vec::new(); @@ -548,7 +579,7 @@ unsafe fn main_0() -> i32 { Tracked::construct_1(&mut __v, { 5 }); __v }); - cpp_swap_unsafe!(&mut vec_[(0_usize)], &mut vec_[(1_usize)]); + SwappableUnsafe::swap(&mut *(&mut vec_[(0_usize)]), &mut vec_[(1_usize)]); assert!(((vec_[(0_usize)].v) == (5)) && ((vec_[(1_usize)].v) == (4))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (0))); let mut pairs: [Pair; 2] = [ @@ -589,22 +620,31 @@ unsafe fn main_0() -> i32 { __v }, }; - cpp_swap_unsafe!(&mut pairs[(0) as usize].x, &mut p.y); + SwappableUnsafe::swap(&mut *(&mut pairs[(0) as usize].x), &mut p.y); assert!(((pairs[(0) as usize].x.v) == (11)) && ((p.y.v) == (6))); - cpp_swap_unsafe!(&mut pairs[(0) as usize], &mut pairs[(1) as usize]); + SwappableUnsafe::swap(&mut *(&mut pairs[(0) as usize]), &mut pairs[(1) as usize]); assert!(((pairs[(0) as usize].x.v) == (8)) && ((pairs[(1) as usize].x.v) == (11))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (0))); - cpp_swap_unsafe!(&mut p.x, &mut p.y); + SwappableUnsafe::swap(&mut *(&mut p.x), &mut p.y); assert!(((p.x.v) == (6)) && ((p.y.v) == (10))); - cpp_swap_unsafe!(&mut pairs[(0) as usize].x, &mut pairs[(1) as usize].y); + SwappableUnsafe::swap( + &mut *(&mut pairs[(0) as usize].x), + &mut pairs[(1) as usize].y, + ); assert!(((pairs[(0) as usize].x.v) == (7)) && ((pairs[(1) as usize].y.v) == (8))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (0))); let mut arrays: Arrays = ::default(); arrays.a[(0) as usize].v = 1; arrays.b[(1) as usize].v = 2; - cpp_swap_unsafe!(&mut arrays.a[(0) as usize], &mut arrays.b[(1) as usize]); + SwappableUnsafe::swap( + &mut *(&mut arrays.a[(0) as usize]), + &mut arrays.b[(1) as usize], + ); assert!(((arrays.a[(0) as usize].v) == (2)) && ((arrays.b[(1) as usize].v) == (1))); - cpp_swap_unsafe!(&mut arrays.a[(0) as usize], &mut arrays.a[(1) as usize]); + SwappableUnsafe::swap( + &mut *(&mut arrays.a[(0) as usize]), + &mut arrays.a[(1) as usize], + ); assert!(((arrays.a[(0) as usize].v) == (0)) && ((arrays.a[(1) as usize].v) == (2))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (0))); let mut grid: Vec> = Vec::from_fn(2_usize, |_| Default::default()); @@ -623,12 +663,12 @@ unsafe fn main_0() -> i32 { Tracked::construct_1(&mut __v, { 3 }); __v }); - cpp_swap_unsafe!( - &mut grid[(0_usize)][(1_usize)], - &mut grid[(1_usize)][(0_usize)] + SwappableUnsafe::swap( + &mut *(&mut grid[(0_usize)][(1_usize)]), + &mut grid[(1_usize)][(0_usize)], ); assert!(((grid[(0_usize)][(1_usize)].v) == (3)) && ((grid[(1_usize)][(0_usize)].v) == (2))); - cpp_swap_unsafe!(&mut grid[(0_usize)], &mut grid[(1_usize)]); + SwappableUnsafe::swap(&mut *(&mut grid[(0_usize)]), &mut grid[(1_usize)]); assert!(((grid[(0_usize)].len()) == (1_usize)) && ((grid[(0_usize)][(0_usize)].v) == (2))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (0))); let mut maps: [UnsafeMap; 2] = @@ -663,7 +703,7 @@ unsafe fn main_0() -> i32 { &mut _o, ) }); - cpp_swap_unsafe!(&mut maps[(0) as usize], &mut maps[(1) as usize]); + SwappableUnsafe::swap(&mut *(&mut maps[(0) as usize]), &mut maps[(1) as usize]); assert!( ((maps[(0) as usize].len()) == (1_usize)) && (((*maps[(0) as usize].subscript_move( @@ -699,7 +739,7 @@ unsafe fn main_0() -> i32 { let _dtor_c2 = std::mem::DropGuard::new(&raw mut c2, |__p| unsafe { DestructibleUnsafe::destroy(__p) }); - cpp_swap_unsafe!(&mut c1, &mut c2); + SwappableUnsafe::swap(&mut *(&mut c1), &mut c2); assert!(((c1.v) == (2)) && ((c2.v) == (1))); assert!( ((*std::cell::LazyCell::force_mut(&mut *&raw mut copy_only_copies_1)) == (3)) @@ -720,7 +760,7 @@ unsafe fn main_0() -> i32 { let _dtor_cp = std::mem::DropGuard::new(&raw mut cp, |__p| unsafe { DestructibleUnsafe::destroy(__p) }); - cpp_swap_unsafe!(&mut cp.x, &mut cp.y); + SwappableUnsafe::swap(&mut *(&mut cp.x), &mut cp.y); assert!(((cp.x.v) == (4)) && ((cp.y.v) == (3))); assert!( ((*std::cell::LazyCell::force_mut(&mut *&raw mut copy_only_copies_1)) == (6)) @@ -738,7 +778,7 @@ unsafe fn main_0() -> i32 { __v }, ]; - cpp_swap_unsafe!(&mut carr[(0) as usize], &mut carr[(1) as usize]); + SwappableUnsafe::swap(&mut *(&mut carr[(0) as usize]), &mut carr[(1) as usize]); assert!(((carr[(0) as usize].v) == (6)) && ((carr[(1) as usize].v) == (5))); assert!( ((*std::cell::LazyCell::force_mut(&mut *&raw mut copy_only_copies_1)) == (9)) @@ -760,7 +800,7 @@ unsafe fn main_0() -> i32 { let _dtor_mv2 = std::mem::DropGuard::new(&raw mut mv2, |__p| unsafe { DestructibleUnsafe::destroy(__p) }); - cpp_swap_unsafe!(&mut mv1, &mut mv2); + SwappableUnsafe::swap(&mut *(&mut mv1), &mut mv2); assert!(((mv1.v) == (2)) && ((mv2.v) == (1))); assert!((unsafe { swapped_once_6() })); let mut mp: MovedPair = MovedPair { @@ -778,7 +818,7 @@ unsafe fn main_0() -> i32 { let _dtor_mp = std::mem::DropGuard::new(&raw mut mp, |__p| unsafe { DestructibleUnsafe::destroy(__p) }); - cpp_swap_unsafe!(&mut mp.x, &mut mp.y); + SwappableUnsafe::swap(&mut *(&mut mp.x), &mut mp.y); assert!(((mp.x.v) == (4)) && ((mp.y.v) == (3))); assert!((unsafe { swapped_once_6() })); let mut marr: [Moved; 2] = [ @@ -793,10 +833,10 @@ unsafe fn main_0() -> i32 { __v }, ]; - cpp_swap_unsafe!(&mut marr[(0) as usize], &mut marr[(1) as usize]); + SwappableUnsafe::swap(&mut *(&mut marr[(0) as usize]), &mut marr[(1) as usize]); assert!(((marr[(0) as usize].v) == (6)) && ((marr[(1) as usize].v) == (5))); assert!((unsafe { swapped_once_6() })); - cpp_swap_unsafe!(&mut mv1, &mut mv1); + SwappableUnsafe::swap(&mut *(&mut mv1), &mut mv1); assert!(((mv1.v) == (2))); assert!((unsafe { swapped_once_6() })); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (0))); @@ -806,7 +846,7 @@ unsafe fn main_0() -> i32 { let mut o2: Owner = Owner { p: Some(Box::new(2)), }; - cpp_swap_unsafe!(&mut o1, &mut o2); + SwappableUnsafe::swap(&mut *(&mut o1), &mut o2); assert!( ((*o1 .p diff --git a/tests/unit/out/unsafe/temporary_field_addr.rs b/tests/unit/out/unsafe/temporary_field_addr.rs index 3caba06085..a7be53cb30 100644 --- a/tests/unit/out/unsafe/temporary_field_addr.rs +++ b/tests/unit/out/unsafe/temporary_field_addr.rs @@ -14,6 +14,7 @@ use std::rc::Rc; ZeroInitializationUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct Inner { @@ -40,6 +41,7 @@ impl MoveAssignableUnsafe for Inner { ZeroInitializationUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct Outer { diff --git a/tests/unit/out/unsafe/temporary_field_ctor_arg.rs b/tests/unit/out/unsafe/temporary_field_ctor_arg.rs index 0e0f710774..ac4ba1414f 100644 --- a/tests/unit/out/unsafe/temporary_field_ctor_arg.rs +++ b/tests/unit/out/unsafe/temporary_field_ctor_arg.rs @@ -14,6 +14,7 @@ use std::rc::Rc; ZeroInitializationUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct Outer { diff --git a/tests/unit/out/unsafe/temporary_field_two_args.rs b/tests/unit/out/unsafe/temporary_field_two_args.rs index 67cee7bea9..c5bcc62331 100644 --- a/tests/unit/out/unsafe/temporary_field_two_args.rs +++ b/tests/unit/out/unsafe/temporary_field_two_args.rs @@ -14,6 +14,7 @@ use std::rc::Rc; ZeroInitializationUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct Inner { @@ -40,6 +41,7 @@ impl MoveAssignableUnsafe for Inner { ZeroInitializationUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct Outer { diff --git a/tests/unit/out/unsafe/typedef-anon-struct.rs b/tests/unit/out/unsafe/typedef-anon-struct.rs index b37a5be404..4e61224bc8 100644 --- a/tests/unit/out/unsafe/typedef-anon-struct.rs +++ b/tests/unit/out/unsafe/typedef-anon-struct.rs @@ -20,6 +20,7 @@ pub struct Outer_RunInfo { ZeroInitializationUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct Outer { diff --git a/tests/unit/out/unsafe/unique_ptr.rs b/tests/unit/out/unsafe/unique_ptr.rs index d0b8fca75e..9687543cd8 100644 --- a/tests/unit/out/unsafe/unique_ptr.rs +++ b/tests/unit/out/unsafe/unique_ptr.rs @@ -7,7 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, SwappableUnsafe, Default)] pub struct SafePointer { pub ptr: Option>, } diff --git a/tests/unit/out/unsafe/unique_ptr_const_deref.rs b/tests/unit/out/unsafe/unique_ptr_const_deref.rs index 53e417efaa..c7c2ba2ab4 100644 --- a/tests/unit/out/unsafe/unique_ptr_const_deref.rs +++ b/tests/unit/out/unsafe/unique_ptr_const_deref.rs @@ -7,7 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, SwappableUnsafe, Default)] pub struct Holder { pub val: Option>, } diff --git a/tests/unit/out/unsafe/unique_ptr_field_reset.rs b/tests/unit/out/unsafe/unique_ptr_field_reset.rs index a6da20a903..6473edc94d 100644 --- a/tests/unit/out/unsafe/unique_ptr_field_reset.rs +++ b/tests/unit/out/unsafe/unique_ptr_field_reset.rs @@ -12,7 +12,7 @@ pub struct Data { pub v: i32, } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, SwappableUnsafe, Default)] pub struct Holder { pub data: Option>, pub n: i32, diff --git a/tests/unit/out/unsafe/unique_ptr_nested.rs b/tests/unit/out/unsafe/unique_ptr_nested.rs index 9a60f9563d..ea3f608067 100644 --- a/tests/unit/out/unsafe/unique_ptr_nested.rs +++ b/tests/unit/out/unsafe/unique_ptr_nested.rs @@ -13,7 +13,7 @@ pub struct Inner { pub y: i32, } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, SwappableUnsafe, Default)] pub struct Outer { pub inner: Option>, } diff --git a/tests/unit/out/unsafe/vector.rs b/tests/unit/out/unsafe/vector.rs index f168f2ec0e..d200304600 100644 --- a/tests/unit/out/unsafe/vector.rs +++ b/tests/unit/out/unsafe/vector.rs @@ -20,6 +20,7 @@ pub unsafe fn copy_0(mut copy_vector: Vec) {} ZeroInitializationUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct Foo { diff --git a/tests/unit/out/unsafe/vector_subscript_direct.rs b/tests/unit/out/unsafe/vector_subscript_direct.rs index cea364392f..64a09a6ef8 100644 --- a/tests/unit/out/unsafe/vector_subscript_direct.rs +++ b/tests/unit/out/unsafe/vector_subscript_direct.rs @@ -25,6 +25,7 @@ impl Point { ZeroInitializationUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct Holder { diff --git a/tests/unit/out/unsafe/void_cast.rs b/tests/unit/out/unsafe/void_cast.rs index b86a24832a..6bac438c4e 100644 --- a/tests/unit/out/unsafe/void_cast.rs +++ b/tests/unit/out/unsafe/void_cast.rs @@ -15,6 +15,7 @@ pub unsafe fn unused_param_0(mut x: i32) {} ZeroInitializationUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, + SwappableUnsafe, Default, )] pub struct NonTrivial { @@ -47,7 +48,7 @@ pub struct Holder { pub field: i32, } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, SwappableUnsafe, Default)] pub struct NonCopyable { pub value: Option>, } From 1cc56231e446bf26eee6ce646b3eb1e9fc146976 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Mon, 30 Nov 2026 22:07:29 +0000 Subject: [PATCH 12/20] Add destructible on swappable --- libcc2rs-macros/src/constructor.rs | 6 ++-- libcc2rs-macros/src/destructor.rs | 8 ++---- libcc2rs-macros/src/lib.rs | 11 ++------ libcc2rs/src/capture.rs | 39 ++++++++++++-------------- libcc2rs/src/lib.rs | 2 +- libcc2rs/src/swap.rs | 44 +----------------------------- rules/dirent/shim.rs | 4 +-- rules/ifaddrs/shim.rs | 6 ++-- rules/ip/shim.rs | 6 ++-- rules/netdb/shim.rs | 4 +-- rules/poll/shim.rs | 4 +-- rules/pwd/shim.rs | 4 +-- rules/select/shim.rs | 4 +-- rules/socket/shim.rs | 14 ++++++---- rules/stat/shim.rs | 4 +-- rules/termios/shim.rs | 6 ++-- rules/time/shim.rs | 8 +++--- 17 files changed, 59 insertions(+), 115 deletions(-) diff --git a/libcc2rs-macros/src/constructor.rs b/libcc2rs-macros/src/constructor.rs index e91fb01296..7584c2d58e 100644 --- a/libcc2rs-macros/src/constructor.rs +++ b/libcc2rs-macros/src/constructor.rs @@ -37,7 +37,6 @@ fn impl_swap(input: &DeriveInput, is_unsafe: bool) -> TokenStream2 { quote! { impl #impl_generics ::libcc2rs::SwappableUnsafe for #name #ty_generics #where_clause { unsafe fn swap(&mut self, other: *mut Self) { - use ::libcc2rs::__swap::{DestroyNoneUnsafe as _, DestroyWithDtorUnsafe as _}; let mut tmp = ::std::mem::MaybeUninit::::uninit(); unsafe { ::libcc2rs::MoveConstructibleUnsafe::move_constructor( @@ -46,7 +45,7 @@ fn impl_swap(input: &DeriveInput, is_unsafe: bool) -> TokenStream2 { ); ::libcc2rs::MoveAssignableUnsafe::move_assign(self, other); ::libcc2rs::MoveAssignableUnsafe::move_assign(&mut *other, tmp.as_mut_ptr()); - (&&::libcc2rs::__swap::DestroyUnsafe(tmp.as_mut_ptr())).destroy(); + ::destroy(&mut *tmp.as_mut_ptr()); } } } @@ -55,7 +54,6 @@ fn impl_swap(input: &DeriveInput, is_unsafe: bool) -> TokenStream2 { quote! { impl #impl_generics ::libcc2rs::Swappable for #name #ty_generics #where_clause { fn swap(this: &::libcc2rs::Ptr, other: ::libcc2rs::Ptr) { - use ::libcc2rs::__swap::{DestroyNone as _, DestroyWithDtor as _}; let tmp: ::libcc2rs::Value = ::std::rc::Rc::new(::std::cell::RefCell::new( ::zero_init(), )); @@ -63,7 +61,7 @@ fn impl_swap(input: &DeriveInput, is_unsafe: bool) -> TokenStream2 { ::libcc2rs::MoveConstructible::move_constructor(&tmp, this.clone()); ::libcc2rs::MoveAssignable::move_assign(this, other.clone()); ::libcc2rs::MoveAssignable::move_assign(&other, tmp.clone()); - (&&::libcc2rs::__swap::Destroy(&tmp)).destroy(); + ::destroy(&tmp); } } } diff --git a/libcc2rs-macros/src/destructor.rs b/libcc2rs-macros/src/destructor.rs index a7a0ddbe42..49d9f955b7 100644 --- a/libcc2rs-macros/src/destructor.rs +++ b/libcc2rs-macros/src/destructor.rs @@ -12,17 +12,13 @@ pub fn expand(input: TokenStream, is_unsafe: bool) -> TokenStream { if is_unsafe { quote! { impl #impl_generics ::libcc2rs::DestructibleUnsafe for #name #ty_generics #where_clause { - unsafe fn destroy(p: *mut Self) { - unsafe { (*p).destructor() } - } + unsafe fn destroy(&mut self) {} } } } else { quote! { impl #impl_generics ::libcc2rs::Destructible for #name #ty_generics #where_clause { - fn destroy(p: ::libcc2rs::Ptr) { - p.destructor() - } + fn destroy(_: &::libcc2rs::Ptr) {} } } } diff --git a/libcc2rs-macros/src/lib.rs b/libcc2rs-macros/src/lib.rs index cc0171cea7..462d568957 100644 --- a/libcc2rs-macros/src/lib.rs +++ b/libcc2rs-macros/src/lib.rs @@ -235,15 +235,8 @@ pub fn derive_move_assignable_unsafe(input: TokenStream) -> TokenStream { constructor::expand(input, "move", true, true) } -// #[derive(Destructible)] -// pub struct S { ... } -// impl SImpl for Ptr { -// fn destructor(&self) { ... } -// } -// -// Implements libcc2rs::Destructible for S with its destructor, through which -// the translation destroys every object of type S. DestructibleUnsafe is the -// same for the unsafe model, whose destructor is a method of S. +// Implements libcc2rs::Destructible, or DestructibleUnsafe, for S with an +// empty destructor. #[proc_macro_derive(Destructible)] pub fn derive_destructible(input: TokenStream) -> TokenStream { diff --git a/libcc2rs/src/capture.rs b/libcc2rs/src/capture.rs index 6db6c7c344..af78508c1b 100644 --- a/libcc2rs/src/capture.rs +++ b/libcc2rs/src/capture.rs @@ -30,46 +30,43 @@ use crate::initialization::ZeroInitialization; use crate::rc::{AsPointer, Decay, Ptr, Value}; use crate::reinterpret::ByteRepr; -// The C++ destructor of a type, in the refcount model, for the types that -// have one. Records implement it with #[derive(Destructible)]. +// The C++ destructor of a type, in the refcount model. pub trait Destructible: Sized { - fn destroy(p: Ptr); + fn destroy(this: &Ptr); } -// The C++ destructor of a type, in the unsafe model. Records implement it -// with #[derive(DestructibleUnsafe)]. +// The C++ destructor of a type, in the unsafe model. pub trait DestructibleUnsafe: Sized { /// # Safety - /// `p` must point to a live value. - unsafe fn destroy(p: *mut Self); + /// `self` must be a live value. + unsafe fn destroy(&mut self); } impl Destructible for FnPtr { - fn destroy(p: Ptr) { - p.with(|f| f.destroy()) + fn destroy(this: &Ptr) { + this.with(|f| f.destroy()) } } impl DestructibleUnsafe for FnPtr { - unsafe fn destroy(p: *mut Self) { - unsafe { (*p).destroy() } + unsafe fn destroy(&mut self) { + FnPtr::destroy(self) } } impl Destructible for Box<[T]> { - fn destroy(p: Ptr) { - let elems = p.decay(); + fn destroy(this: &Ptr) { + let elems = this.decay(); for i in (0..elems.len()).rev() { - T::destroy(elems.offset(i)); + T::destroy(&elems.offset(i)); } } } impl DestructibleUnsafe for [T; N] { - unsafe fn destroy(p: *mut Self) { - let p = p as *mut T; - for i in (0..N).rev() { - unsafe { T::destroy(p.add(i)) } + unsafe fn destroy(&mut self) { + for elem in self.iter_mut().rev() { + unsafe { DestructibleUnsafe::destroy(elem) } } } } @@ -167,7 +164,7 @@ impl DestroyElems for &&Capture<'_, Value>> { fn destroy_capture(&self) { let p: Ptr = self.0.decay(); for i in (0..self.0.borrow().len()).rev() { - T::destroy(p.offset(i)); + T::destroy(&p.offset(i)); } } } @@ -178,7 +175,7 @@ pub trait DestroyWithDtor { impl DestroyWithDtor for &Capture<'_, Value> { fn destroy_capture(&self) { - T::destroy(AsPointer::::as_pointer(self.0)) + T::destroy(&AsPointer::::as_pointer(self.0)) } } @@ -268,7 +265,7 @@ pub trait DestroyWithDtorUnsafe { impl DestroyWithDtorUnsafe for &CaptureUnsafe { unsafe fn destroy_capture(&self) { - unsafe { T::destroy(self.0) } + unsafe { DestructibleUnsafe::destroy(&mut *self.0) } } } diff --git a/libcc2rs/src/lib.rs b/libcc2rs/src/lib.rs index a5a09a11a7..ba63bd6812 100644 --- a/libcc2rs/src/lib.rs +++ b/libcc2rs/src/lib.rs @@ -61,7 +61,7 @@ mod initialization; pub use initialization::{ZeroInitialization, ZeroInitializationUnsafe}; mod swap; -// Used by cpp_move!, cpp_move_unsafe! and the Swappable derives. +// Used by cpp_move! and cpp_move_unsafe!. #[doc(hidden)] pub mod __swap { pub use crate::swap::*; diff --git a/libcc2rs/src/swap.rs b/libcc2rs/src/swap.rs index dd22421925..611a95f6a4 100644 --- a/libcc2rs/src/swap.rs +++ b/libcc2rs/src/swap.rs @@ -4,15 +4,13 @@ // cpp_move!(p), or cpp_move_unsafe!(p), constructs a value from the one that // p points to as C++ does with T(std::move(*p)): with the move constructor // (MoveConstructible), or else with the copy constructor (Clone), as picked -// by autoref specialization. Destroy destroys a temporary with its destructor, -// if any (Destructible). +// by autoref specialization. #![allow(private_bounds, clippy::missing_safety_doc)] use std::cell::RefCell; use std::rc::Rc; -use crate::capture::{Destructible, DestructibleUnsafe}; use crate::constructor::{MoveConstructible, MoveConstructibleUnsafe}; use crate::initialization::ZeroInitialization; use crate::rc::{AsPointer, Ptr, Value}; @@ -92,26 +90,6 @@ impl ConstructNone for &Construct<'_, T> { } } -pub struct Destroy<'a, T>(pub &'a Ptr); - -pub trait DestroyWithDtor { - fn destroy(self); -} - -pub trait DestroyNone { - fn destroy(self); -} - -impl DestroyWithDtor for &&Destroy<'_, T> { - fn destroy(self) { - T::destroy(self.0.clone()) - } -} - -impl DestroyNone for &Destroy<'_, T> { - fn destroy(self) {} -} - pub struct ConstructUnsafe(pub *mut T); pub trait ConstructMoveUnsafe { @@ -143,23 +121,3 @@ impl ConstructNoneUnsafe for &ConstructUnsafe { not_movable() } } - -pub struct DestroyUnsafe(pub *mut T); - -pub trait DestroyWithDtorUnsafe { - unsafe fn destroy(self); -} - -pub trait DestroyNoneUnsafe { - unsafe fn destroy(self); -} - -impl DestroyWithDtorUnsafe for &&DestroyUnsafe { - unsafe fn destroy(self) { - unsafe { T::destroy(self.0) } - } -} - -impl DestroyNoneUnsafe for &DestroyUnsafe { - unsafe fn destroy(self) {} -} diff --git a/rules/dirent/shim.rs b/rules/dirent/shim.rs index 4d028d63d1..7c444620db 100644 --- a/rules/dirent/shim.rs +++ b/rules/dirent/shim.rs @@ -1,11 +1,11 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use crate::{ByteRepr, Copyable, Record, ZeroInitialization, size_of_field}; +use crate::{ByteRepr, Copyable, Destructible, Record, ZeroInitialization, size_of_field}; use std::cell::Cell; use std::mem::{offset_of, size_of}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, Copyable, Destructible)] #[byte_size(size_of::<::libc::dirent>())] pub struct Dirent { #[offset(offset_of!(::libc::dirent, d_ino))] diff --git a/rules/ifaddrs/shim.rs b/rules/ifaddrs/shim.rs index 5d687f470a..ed8e17bcd4 100644 --- a/rules/ifaddrs/shim.rs +++ b/rules/ifaddrs/shim.rs @@ -2,12 +2,12 @@ // Distributed under the MIT license that can be found in the LICENSE file. use crate::{ - ByteRepr, Copyable, Ptr, Record, Sockaddr, SockaddrIn, SockaddrIn6, SockaddrStorage, - ZeroInitialization, + ByteRepr, Copyable, Destructible, Ptr, Record, Sockaddr, SockaddrIn, SockaddrIn6, + SockaddrStorage, ZeroInitialization, }; use std::mem::{offset_of, size_of}; -#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, Copyable)] +#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, Copyable, Destructible)] #[byte_size(size_of::<::libc::ifaddrs>())] pub struct Ifaddrs { #[offset(offset_of!(::libc::ifaddrs, ifa_next))] diff --git a/rules/ip/shim.rs b/rules/ip/shim.rs index 79f247441c..65eb7d9fe7 100644 --- a/rules/ip/shim.rs +++ b/rules/ip/shim.rs @@ -1,16 +1,16 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use crate::{ByteRepr, Copyable, Ptr, Record, ZeroInitialization}; +use crate::{ByteRepr, Copyable, Destructible, Ptr, Record, ZeroInitialization}; -#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, Copyable)] +#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, Copyable, Destructible)] #[byte_size(4)] pub struct InAddr { #[offset(0)] pub s_addr: u32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, Copyable, Destructible)] #[byte_size(16)] pub struct In6Addr { #[offset(0)] diff --git a/rules/netdb/shim.rs b/rules/netdb/shim.rs index a8fea2c040..e83e2d8b49 100644 --- a/rules/netdb/shim.rs +++ b/rules/netdb/shim.rs @@ -1,10 +1,10 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use crate::{ByteRepr, Copyable, Ptr, Record, Sockaddr, ZeroInitialization}; +use crate::{ByteRepr, Copyable, Destructible, Ptr, Record, Sockaddr, ZeroInitialization}; use std::mem::{offset_of, size_of}; -#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, Copyable)] +#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, Copyable, Destructible)] #[byte_size(size_of::<::libc::addrinfo>())] pub struct Addrinfo { #[offset(offset_of!(::libc::addrinfo, ai_flags))] diff --git a/rules/poll/shim.rs b/rules/poll/shim.rs index f48bb17add..8a8a3dbe94 100644 --- a/rules/poll/shim.rs +++ b/rules/poll/shim.rs @@ -1,10 +1,10 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use crate::{ByteRepr, Copyable, Record, ZeroInitialization}; +use crate::{ByteRepr, Copyable, Destructible, Record, ZeroInitialization}; use std::mem::{offset_of, size_of}; -#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, Copyable)] +#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, Copyable, Destructible)] #[byte_size(size_of::<::libc::pollfd>())] pub struct Pollfd { #[offset(offset_of!(::libc::pollfd, fd))] diff --git a/rules/pwd/shim.rs b/rules/pwd/shim.rs index 27577246d9..7d5ee08abf 100644 --- a/rules/pwd/shim.rs +++ b/rules/pwd/shim.rs @@ -1,10 +1,10 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use crate::{ByteRepr, Copyable, Ptr, Record, ZeroInitialization}; +use crate::{ByteRepr, Copyable, Destructible, Ptr, Record, ZeroInitialization}; use std::mem::{offset_of, size_of}; -#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, Copyable)] +#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, Copyable, Destructible)] #[byte_size(size_of::<::libc::passwd>())] pub struct Passwd { #[offset(offset_of!(::libc::passwd, pw_name))] diff --git a/rules/select/shim.rs b/rules/select/shim.rs index de31634b63..12d904b086 100644 --- a/rules/select/shim.rs +++ b/rules/select/shim.rs @@ -3,9 +3,9 @@ use std::collections::BTreeSet; -use crate::Copyable; +use crate::{Copyable, Destructible}; -#[derive(Clone, Default, Copyable)] +#[derive(Clone, Default, Copyable, Destructible)] pub struct CFdSet { fds: BTreeSet, } diff --git a/rules/socket/shim.rs b/rules/socket/shim.rs index f8e2c21a91..baf2cc1242 100644 --- a/rules/socket/shim.rs +++ b/rules/socket/shim.rs @@ -1,10 +1,12 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use crate::{ByteRepr, CChar, Copyable, In6Addr, InAddr, Ptr, Record, ZeroInitialization}; +use crate::{ + ByteRepr, CChar, Copyable, Destructible, In6Addr, InAddr, Ptr, Record, ZeroInitialization, +}; // The fields are at the offsets of the byte representation below. -#[derive(Clone, Record, ByteRepr, ZeroInitialization, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, Copyable, Destructible)] #[byte_size(16)] pub struct Sockaddr { #[offset(0)] @@ -15,7 +17,7 @@ pub struct Sockaddr { pub sa_data: Box<[i8]>, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, Copyable, Destructible)] #[byte_size(16)] pub struct SockaddrIn { #[offset(0)] @@ -30,7 +32,7 @@ pub struct SockaddrIn { pub sin_zero: Box<[u8]>, } -#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, Copyable)] +#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, Copyable, Destructible)] #[byte_size(28)] pub struct SockaddrIn6 { #[offset(0)] @@ -45,7 +47,7 @@ pub struct SockaddrIn6 { pub sin6_scope_id: u32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, Copyable, Destructible)] #[byte_size(110)] pub struct SockaddrUn { #[offset(0)] @@ -56,7 +58,7 @@ pub struct SockaddrUn { pub sun_path: Box<[i8]>, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, Copyable, Destructible)] #[byte_size(128)] pub struct SockaddrStorage { #[offset(0)] diff --git a/rules/stat/shim.rs b/rules/stat/shim.rs index 93cedc72e4..84e5e1ba09 100644 --- a/rules/stat/shim.rs +++ b/rules/stat/shim.rs @@ -1,10 +1,10 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use crate::{ByteRepr, Copyable, Record, ZeroInitialization}; +use crate::{ByteRepr, Copyable, Destructible, Record, ZeroInitialization}; use std::mem::{offset_of, size_of}; -#[derive(Clone, Default, Record, ZeroInitialization, Copyable)] +#[derive(Clone, Default, Record, ZeroInitialization, Copyable, Destructible)] // The fields have the sizes of those of libc::stat only in x86-64 Linux. #[cfg_attr( all(target_os = "linux", target_arch = "x86_64"), diff --git a/rules/termios/shim.rs b/rules/termios/shim.rs index 1ae3b751f8..94d6b0bcea 100644 --- a/rules/termios/shim.rs +++ b/rules/termios/shim.rs @@ -1,10 +1,10 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use crate::{ByteRepr, Copyable, Record, ZeroInitialization}; +use crate::{ByteRepr, Copyable, Destructible, Record, ZeroInitialization}; use std::mem::{offset_of, size_of}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, Copyable, Destructible)] #[byte_size(size_of::<::libc::termios>())] pub struct Termios { #[offset(offset_of!(::libc::termios, c_iflag))] @@ -105,7 +105,7 @@ impl Termios { } } -#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, Copyable)] +#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, Copyable, Destructible)] #[byte_size(size_of::<::libc::winsize>())] pub struct Winsize { #[offset(offset_of!(::libc::winsize, ws_row))] diff --git a/rules/time/shim.rs b/rules/time/shim.rs index be2a7004f5..848c6f33e0 100644 --- a/rules/time/shim.rs +++ b/rules/time/shim.rs @@ -1,10 +1,10 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use crate::{ByteRepr, Copyable, Ptr, Record, ZeroInitialization}; +use crate::{ByteRepr, Copyable, Destructible, Ptr, Record, ZeroInitialization}; use std::mem::{offset_of, size_of}; -#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, Copyable)] +#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, Copyable, Destructible)] #[byte_size(size_of::<::libc::tm>())] pub struct Tm { #[offset(offset_of!(::libc::tm, tm_sec))] @@ -65,7 +65,7 @@ impl Tm { } } -#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, Copyable)] +#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, Copyable, Destructible)] #[byte_size(size_of::<::libc::timeval>())] pub struct Timeval { #[offset(offset_of!(::libc::timeval, tv_sec))] @@ -74,7 +74,7 @@ pub struct Timeval { pub tv_usec: i64, } -#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, Copyable)] +#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, Copyable, Destructible)] #[byte_size(size_of::<::libc::timespec>())] pub struct Timespec { #[offset(offset_of!(::libc::timespec, tv_sec))] From da51dae18b14e7eadebc26b671381ee2809d8965 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Mon, 30 Nov 2026 22:10:45 +0000 Subject: [PATCH 13/20] Update tests --- .../out/refcount/cross_tu_tag_collision.rs | 13 +- .../out/unsafe/cross_tu_tag_collision.rs | 11 +- .../out/refcount/defaulted_move_cross_tu.rs | 3 +- .../out/unsafe/defaulted_move_cross_tu.rs | 5 +- .../out/refcount/friend_operator.rs | 13 +- .../out/unsafe/friend_operator.rs | 11 +- .../out/refcount/opaque_forward_decl.rs | 4 +- .../out/unsafe/opaque_forward_decl.rs | 11 +- .../refcount/out_of_line_methods_cross_tu.rs | 43 +++- .../unsafe/out_of_line_methods_cross_tu.rs | 37 ++- .../template_method_late_instantiation.rs | 4 +- .../template_method_late_instantiation.rs | 4 +- .../out/refcount/p14-class-in-two-files.rs | 46 ++-- .../out/unsafe/p14-class-in-two-files.rs | 40 +-- .../p15-class-template-static-member.rs | 40 ++- .../p15-class-template-static-member.rs | 39 ++- .../out/refcount/p15-function-template.rs | 63 +++-- .../out/unsafe/p15-function-template.rs | 59 +++-- .../out/refcount/p15-inline-function.rs | 31 +-- .../out/unsafe/p15-inline-function.rs | 25 +- .../out/refcount/p15-inline-variable.rs | 31 +-- .../out/unsafe/p15-inline-variable.rs | 25 +- .../p16-default-argument-lambda-in-class.rs | 44 ++-- .../p16-default-argument-lambda-in-class.rs | 36 +-- .../refcount/p16-lambda-in-inline-function.rs | 31 +-- .../unsafe/p16-lambda-in-inline-function.rs | 25 +- .../basic.link/out/refcount/basic.link.rs | 63 ++++- .../basic/basic.link/out/unsafe/basic.link.rs | 61 ++++- .../out/refcount/basic.scope.block.rs | 39 ++- .../out/refcount/basic.scope.class.rs | 8 +- .../out/refcount/basic.scope.param.rs | 12 +- .../out/refcount/basic.scope.pdecl.rs | 6 +- .../out/refcount/basic.scope.scope.rs | 126 ++++++++-- .../out/unsafe/basic.scope.block.rs | 33 +-- .../out/unsafe/basic.scope.class.rs | 8 +- .../out/unsafe/basic.scope.param.rs | 10 +- .../out/unsafe/basic.scope.pdecl.rs | 15 +- .../out/unsafe/basic.scope.scope.rs | 123 +++++++-- .../out/refcount/basic.start.term-p1-exit.rs | 19 +- .../out/refcount/basic.start.term.rs | 74 +++--- .../out/unsafe/basic.start.term-p1-exit.rs | 16 +- .../out/unsafe/basic.start.term.rs | 72 +++--- .../out/refcount/basic.types.general.rs | 26 +- .../out/unsafe/basic.types.general.rs | 22 +- tests/std/basic/out/refcount/basic.def.odr.rs | 98 +++++--- tests/std/basic/out/unsafe/basic.def.odr.rs | 78 +++--- .../out/refcount/class.base.init.rs | 12 +- .../class.init/out/unsafe/class.base.init.rs | 10 +- .../out/refcount/class.conv.ctor.rs | 12 +- .../class.conv/out/refcount/class.conv.fct.rs | 12 +- .../class.conv/out/unsafe/class.conv.ctor.rs | 10 +- .../class.conv/out/unsafe/class.conv.fct.rs | 10 +- .../out/refcount/class.copy.ctor.rs | 2 +- .../class.ctor/out/unsafe/class.copy.ctor.rs | 2 +- .../class.mem/out/refcount/class.free.rs | 26 +- .../out/refcount/class.mem.general.rs | 8 +- .../class/class.mem/out/unsafe/class.free.rs | 22 +- .../class.mem/out/unsafe/class.mem.general.rs | 8 +- .../dcl.init.general-p6.2-padding-bits.rs | 39 ++- .../dcl.init/out/refcount/dcl.init.general.rs | 59 ++++- .../dcl.init.general-p6.2-padding-bits.rs | 33 ++- .../dcl.init/out/unsafe/dcl.init.general.rs | 71 +++++- .../dcl.meaning/out/refcount/dcl.array.rs | 13 +- .../out/refcount/dcl.fct.default.rs | 34 ++- .../dcl.meaning/out/refcount/dcl.mptr.rs | 45 +++- .../dcl.meaning/out/unsafe/dcl.array.rs | 11 +- .../dcl.meaning/out/unsafe/dcl.fct.default.rs | 30 ++- .../dcl.meaning/out/unsafe/dcl.mptr.rs | 48 +++- tests/std/expr/conv/out/refcount/conv.mem.rs | 13 +- tests/std/expr/conv/out/unsafe/conv.mem.rs | 11 +- .../expr.post/out/refcount/expr.const.cast.rs | 13 +- ...nterpret.cast-p10-result-is-unspecified.rs | 26 +- .../out/refcount/expr.reinterpret.cast.rs | 52 +++- .../expr.post/out/unsafe/expr.const.cast.rs | 11 +- ...nterpret.cast-p10-result-is-unspecified.rs | 22 +- .../out/unsafe/expr.reinterpret.cast.rs | 44 +++- .../expr.unary/out/refcount/expr.pre.incr.rs | 13 +- .../expr.unary/out/refcount/expr.unary.op.rs | 39 ++- .../expr.unary/out/unsafe/expr.pre.incr.rs | 11 +- .../expr.unary/out/unsafe/expr.unary.op.rs | 33 ++- .../expr.compound/out/refcount/expr.cond.rs | 13 +- .../expr.compound/out/refcount/expr.eq.rs | 41 ++- ...ptr.oper-p6-null-pointer-to-data-member.rs | 13 +- .../out/refcount/expr.mptr.oper.rs | 41 ++- .../expr.compound/out/unsafe/expr.cond.rs | 11 +- .../expr/expr.compound/out/unsafe/expr.eq.rs | 37 ++- ...ptr.oper-p6-null-pointer-to-data-member.rs | 11 +- .../out/unsafe/expr.mptr.oper.rs | 35 ++- .../expr.prim/out/refcount/expr.prim.this.rs | 15 +- .../expr.prim/out/unsafe/expr.prim.this.rs | 21 +- .../allocator.requirements.general.rs | 30 ++- .../unsafe/allocator.requirements.general.rs | 26 +- .../stmt.iter/out/refcount/stmt.while.rs | 44 ++-- .../stmt.iter/out/unsafe/stmt.while.rs | 38 ++- .../stmt.select/out/refcount/stmt.if.rs | 20 +- .../stmt.select/out/refcount/stmt.switch.rs | 37 ++- .../stmt.select/out/unsafe/stmt.if.rs | 13 +- .../stmt.select/out/unsafe/stmt.switch.rs | 26 +- tests/std/temp/out/refcount/temp.type.rs | 52 +++- tests/std/temp/out/unsafe/temp.type.rs | 44 +++- .../temp/temp.spec/out/refcount/temp.inst.rs | 6 +- .../temp/temp.spec/out/unsafe/temp.inst.rs | 6 +- .../utility/out/refcount/forward-helpers.rs | 7 +- .../utilities/utility/out/refcount/forward.rs | 15 +- .../utility/out/refcount/utility.as.const.rs | 13 +- .../utility/out/unsafe/forward-helpers.rs | 7 +- .../utilities/utility/out/unsafe/forward.rs | 13 +- .../utility/out/unsafe/utility.as.const.rs | 11 +- tests/ub/out/refcount/ctor_ref_member.rs | 11 +- .../refcount/self_referencing_initializer.rs | 13 +- tests/ub/out/refcount/ub6.rs | 4 +- tests/ub/out/unsafe/ctor_ref_member.rs | 10 +- .../unsafe/self_referencing_initializer.rs | 11 +- tests/ub/out/unsafe/ub6.rs | 11 +- tests/unit/out/refcount/05_new.rs | 26 +- tests/unit/out/refcount/10_struct.rs | 27 +- tests/unit/out/refcount/addr_of_global.rs | 17 +- tests/unit/out/refcount/anonymous-struct.rs | 117 ++++++++- tests/unit/out/refcount/anonymous-struct_c.rs | 117 ++++++++- tests/unit/out/refcount/anonymous_enum.rs | 26 +- tests/unit/out/refcount/anonymous_enum_c.rs | 26 +- tests/unit/out/refcount/any.rs | 13 +- tests/unit/out/refcount/array_const_init.rs | 15 +- tests/unit/out/refcount/array_field_addr.rs | 2 +- .../out/refcount/array_of_noncopy_struct.rs | 1 + tests/unit/out/refcount/array_reference.rs | 13 +- tests/unit/out/refcount/as_const.rs | 13 +- tests/unit/out/refcount/assign_rhs_first.rs | 4 +- .../out/refcount/assignment_single_eval.rs | 156 ++++++++++-- tests/unit/out/refcount/bounded_struct_ptr.rs | 13 +- tests/unit/out/refcount/bst.rs | 4 +- tests/unit/out/refcount/c_struct.rs | 56 ++++- tests/unit/out/refcount/cast.rs | 29 ++- .../refcount/cast_array_to_pointer_decay.rs | 2 +- tests/unit/out/refcount/class.rs | 52 +++- .../refcount/class_template_lazy_member.rs | 65 ++++- tests/unit/out/refcount/class_templates.rs | 120 ++++++++- tests/unit/out/refcount/clone_vs_move.rs | 19 +- tests/unit/out/refcount/comma_operator.rs | 13 +- tests/unit/out/refcount/complex_function.rs | 25 +- .../out/refcount/compound_assign_paren.rs | 13 +- tests/unit/out/refcount/concepts.rs | 13 +- tests/unit/out/refcount/constexpr_function.rs | 26 +- tests/unit/out/refcount/constructor.rs | 33 +-- .../refcount/container_element_receiver.rs | 1 + .../unit/out/refcount/container_field_addr.rs | 1 + .../conversion_operator_same_translation.rs | 24 +- tests/unit/out/refcount/copy_assign.rs | 9 +- tests/unit/out/refcount/copy_ctor.rs | 8 + .../unit/out/refcount/copy_move_defaulted.rs | 64 +++-- tests/unit/out/refcount/copy_move_deleted.rs | 12 +- tests/unit/out/refcount/default.rs | 6 +- .../refcount/default_function_arguments.rs | 26 +- tests/unit/out/refcount/default_in_statics.rs | 10 +- tests/unit/out/refcount/delete_array_order.rs | 27 +- tests/unit/out/refcount/destructor.rs | 237 +++++++----------- tests/unit/out/refcount/destructor_params.rs | 34 +-- .../out/refcount/destructor_temporaries.rs | 34 ++- tests/unit/out/refcount/doubly_linked_list.rs | 4 +- .../out/refcount/enum_default_in_static.rs | 13 +- tests/unit/out/refcount/enum_int_interop.rs | 4 +- tests/unit/out/refcount/enum_int_interop_c.rs | 4 +- .../unit/out/refcount/enum_underlying_type.rs | 4 +- tests/unit/out/refcount/exprs.rs | 17 +- tests/unit/out/refcount/fft.rs | 13 +- tests/unit/out/refcount/field_aliasing.rs | 19 +- .../unit/out/refcount/field_array_elem_ptr.rs | 15 +- .../out/refcount/field_method_receiver.rs | 14 +- tests/unit/out/refcount/field_pointers.rs | 16 +- .../field_pointers_malloced_struct.rs | 13 +- .../field_reinterpret_write_through.rs | 15 +- tests/unit/out/refcount/find.rs | 13 +- .../refcount/first_field_ptr_covers_struct.rs | 26 +- .../out/refcount/first_member_downcast.rs | 26 +- .../refcount/flex_array_member_incomplete.rs | 2 +- .../flex_array_member_sibling_write.rs | 17 +- tests/unit/out/refcount/fn_ptr.rs | 11 +- tests/unit/out/refcount/fn_ptr_cast.rs | 4 +- tests/unit/out/refcount/fn_ptr_stable_sort.rs | 13 +- tests/unit/out/refcount/fn_ptr_struct.rs | 19 +- .../unit/out/refcount/fn_ptr_typedef_cast.rs | 13 +- tests/unit/out/refcount/fn_ptr_vtable.rs | 4 +- tests/unit/out/refcount/fn_ref.rs | 4 +- .../unit/out/refcount/for_body_destructor.rs | 41 ++- .../refcount/foreach_disjoint_field_borrow.rs | 1 + tests/unit/out/refcount/forward_basic.rs | 2 + tests/unit/out/refcount/forward_decltype.rs | 1 + tests/unit/out/refcount/forward_explicit.rs | 1 + tests/unit/out/refcount/forward_pack.rs | 2 + tests/unit/out/refcount/friend.rs | 52 +++- .../unit/out/refcount/function_overloading.rs | 13 +- .../out/refcount/global_call_temporaries.rs | 13 +- .../out/refcount/global_init_side_effect.rs | 12 +- .../out/refcount/global_non_const_init.rs | 21 +- tests/unit/out/refcount/global_pointers.rs | 4 +- .../refcount/global_without_initializer.rs | 13 +- .../out/refcount/goto_aggregate_default.rs | 13 +- tests/unit/out/refcount/goto_cleanup.rs | 4 +- tests/unit/out/refcount/huffman.rs | 6 +- .../refcount/immutable-deref-on-func-call.rs | 13 +- tests/unit/out/refcount/implicit_autoref.rs | 1 + .../refcount/in_class_field_initializer.rs | 12 +- tests/unit/out/refcount/init.rs | 13 +- tests/unit/out/refcount/init_list.rs | 21 +- .../out/refcount/inline_container_fields.rs | 4 +- tests/unit/out/refcount/kruskal.rs | 17 +- tests/unit/out/refcount/lambda_as_field.rs | 48 ++-- .../out/refcount/lambda_capture_copy_ctor.rs | 47 ++-- tests/unit/out/refcount/lambda_capture_ref.rs | 13 +- .../out/refcount/lambda_capture_star_this.rs | 13 +- .../unit/out/refcount/lambda_capture_this.rs | 13 +- .../unit/out/refcount/lambda_capture_value.rs | 13 +- .../unit/out/refcount/lambda_decltype_type.rs | 4 +- .../refcount/lambda_generic_explicit_args.rs | 13 +- .../out/refcount/lambda_immediate_init.rs | 4 +- .../out/refcount/lambda_move_only_capture.rs | 23 +- tests/unit/out/refcount/lambda_nested.rs | 13 +- .../unit/out/refcount/lambda_static_local.rs | 13 +- .../refcount/libc_struct_without_default.rs | 3 +- tests/unit/out/refcount/linked_list.rs | 4 +- .../refcount/local_anon_struct_collision.rs | 26 +- .../out/refcount/local_record_template.rs | 52 +++- tests/unit/out/refcount/map.rs | 4 +- tests/unit/out/refcount/map_key_copy_ctor.rs | 1 + tests/unit/out/refcount/map_key_identity.rs | 17 +- tests/unit/out/refcount/map_try_emplace.rs | 5 +- .../out/refcount/map_try_emplace_lvalues.rs | 18 +- tests/unit/out/refcount/max.rs | 1 + .../unit/out/refcount/memcpy_struct_bytes.rs | 13 +- .../out/refcount/memcpy_struct_layouts.rs | 54 +++- .../unit/out/refcount/memcpy_struct_struct.rs | 13 +- tests/unit/out/refcount/memset_struct_tail.rs | 2 +- tests/unit/out/refcount/move_assign.rs | 6 +- tests/unit/out/refcount/move_ctor.rs | 6 +- tests/unit/out/refcount/move_this.rs | 1 + tests/unit/out/refcount/nested_structs.rs | 78 +++++- tests/unit/out/refcount/new.rs | 13 +- tests/unit/out/refcount/new_bst.rs | 4 +- tests/unit/out/refcount/new_struct.rs | 26 +- .../refcount/nttp_distinct_specializations.rs | 39 ++- tests/unit/out/refcount/offsetof.rs | 15 +- .../unit/out/refcount/opaque_forward_decl.rs | 4 +- tests/unit/out/refcount/opaque_record_copy.rs | 26 +- .../unit/out/refcount/opaque_then_defined.rs | 8 +- .../out/refcount/operator_arithmetic_free.rs | 13 +- .../refcount/operator_arithmetic_member.rs | 13 +- .../out/refcount/operator_bitwise_free.rs | 13 +- .../out/refcount/operator_bitwise_member.rs | 13 +- .../refcount/operator_comparison_defaulted.rs | 95 ++++++- .../out/refcount/operator_comparison_free.rs | 26 +- .../refcount/operator_comparison_member.rs | 13 +- .../out/refcount/operator_comparison_mixed.rs | 13 +- .../refcount/operator_comparison_nonbool.rs | 92 ++++++- .../operator_comparison_noncopyable.rs | 2 +- .../operator_compound_assignment_free.rs | 13 +- .../operator_compound_assignment_member.rs | 13 +- tests/unit/out/refcount/operator_friend.rs | 91 ++++++- tests/unit/out/refcount/operator_less_than.rs | 13 +- .../out/refcount/operator_logical_free.rs | 13 +- .../out/refcount/operator_logical_member.rs | 13 +- .../refcount/operator_member_pointer_free.rs | 15 +- .../operator_member_pointer_member.rs | 28 ++- .../unit/out/refcount/operator_other_free.rs | 13 +- .../out/refcount/operator_other_member.rs | 25 +- tests/unit/out/refcount/operator_overloads.rs | 13 +- .../unit/out/refcount/operator_qualifiers.rs | 13 +- tests/unit/out/refcount/operator_three_way.rs | 13 +- tests/unit/out/refcount/operator_traits.rs | 65 ++++- tests/unit/out/refcount/overload_mangling.rs | 39 ++- .../refcount/pair_converting_construction.rs | 122 ++++++++- tests/unit/out/refcount/pod.rs | 13 +- tests/unit/out/refcount/pointer_array.rs | 2 +- tests/unit/out/refcount/pointers.rs | 13 +- tests/unit/out/refcount/polymorphism.rs | 26 +- tests/unit/out/refcount/ptr_cast_init.rs | 26 +- tests/unit/out/refcount/push_emplace_back.rs | 47 +++- tests/unit/out/refcount/random.rs | 15 +- tests/unit/out/refcount/reference_wrapper.rs | 13 +- tests/unit/out/refcount/references.rs | 6 +- tests/unit/out/refcount/refs_as_args.rs | 13 +- .../out/refcount/reinterpret_cast_ptr_cmp.rs | 17 +- .../out/refcount/reinterpret_cast_struct.rs | 13 +- .../reinterpret_cast_struct_to_struct.rs | 26 +- tests/unit/out/refcount/reserved_keywords.rs | 39 ++- tests/unit/out/refcount/return_move.rs | 8 +- tests/unit/out/refcount/rule_of_five.rs | 23 +- tests/unit/out/refcount/rule_of_three.rs | 18 +- .../unit/out/refcount/rvalue_rule_arg_move.rs | 1 + tests/unit/out/refcount/rvalue_struct.rs | 13 +- .../scalar_builtin_construct_destruct.rs | 13 +- .../refcount/self_referencing_initializer.rs | 10 +- .../unit/out/refcount/size_t_static_member.rs | 26 +- .../out/refcount/size_t_template_param.rs | 24 +- tests/unit/out/refcount/sort_no_copy.rs | 9 +- tests/unit/out/refcount/static_local.rs | 13 +- .../unit/out/refcount/static_var_in_class.rs | 26 +- tests/unit/out/refcount/stdcopy.rs | 12 +- tests/unit/out/refcount/strdup.rs | 4 +- .../out/refcount/string_literal_ptr_init.rs | 4 +- tests/unit/out/refcount/string_substr.rs | 4 +- .../out/refcount/struct_2d_array_field.rs | 2 +- tests/unit/out/refcount/struct_ctor.rs | 29 ++- .../unit/out/refcount/struct_default_ctor.rs | 23 +- .../refcount/struct_member_array_adjacency.rs | 2 +- tests/unit/out/refcount/struct_ptr.rs | 13 +- .../refcount/structured_binding_copy_ctor.rs | 1 + .../structured_binding_element_ctor.rs | 2 + .../refcount/structured_binding_move_ctor.rs | 2 + .../refcount/structured_binding_range_for.rs | 13 +- .../out/refcount/structured_binding_ref.rs | 13 +- .../refcount/structured_binding_trivial.rs | 13 +- tests/unit/out/refcount/swap_map_no_copy.rs | 84 ++++--- .../refcount/tag_vs_identifier_collision.rs | 69 ++++- .../unit/out/refcount/template_default_arg.rs | 41 ++- .../out/refcount/template_static_member.rs | 65 ++++- .../unit/out/refcount/temporary_field_addr.rs | 2 + .../out/refcount/temporary_field_ctor_arg.rs | 13 +- .../out/refcount/temporary_field_two_args.rs | 2 + tests/unit/out/refcount/this.rs | 23 +- .../unit/out/refcount/typedef-anon-struct.rs | 14 +- .../out/refcount/unary_expr_or_type_trait.rs | 13 +- tests/unit/out/refcount/unboxed_locals.rs | 17 +- tests/unit/out/refcount/unboxed_records.rs | 19 +- .../out/refcount/union_addrof_external.rs | 8 +- tests/unit/out/refcount/union_basic.rs | 8 +- .../unit/out/refcount/union_cross_arm_cast.rs | 10 +- .../out/refcount/union_field_alignment.rs | 6 +- .../out/refcount/union_flex_array_member.rs | 6 +- .../unit/out/refcount/union_memset_memcpy.rs | 10 +- tests/unit/out/refcount/union_nested.rs | 14 +- .../out/refcount/union_pointer_pun_address.rs | 19 +- .../union_pointer_pun_writethrough.rs | 2 +- .../out/refcount/union_struct_dual_use.rs | 19 +- .../out/refcount/union_tagged_many_arms.rs | 6 +- .../unit/out/refcount/union_tagged_simple.rs | 6 +- .../out/refcount/union_tagged_struct_arms.rs | 36 ++- .../refcount/union_void_ptr_sized_deref.rs | 6 +- tests/unit/out/refcount/unique_ptr.rs | 15 +- .../out/refcount/unique_ptr_const_deref.rs | 2 +- .../out/refcount/unique_ptr_field_reset.rs | 15 +- tests/unit/out/refcount/unique_ptr_nested.rs | 15 +- tests/unit/out/refcount/unique_ptr_struct.rs | 13 +- tests/unit/out/refcount/va_arg_mixed_types.rs | 13 +- .../out/refcount/va_arg_non_primitive_ptrs.rs | 4 +- tests/unit/out/refcount/va_arg_struct_ctx.rs | 15 +- tests/unit/out/refcount/va_arg_void_ptr.rs | 4 +- tests/unit/out/refcount/va_list_field.rs | 29 +-- tests/unit/out/refcount/vector.rs | 14 +- .../out/refcount/vector_iter_range_ctor.rs | 24 +- .../out/refcount/vector_subscript_direct.rs | 14 +- .../out/refcount/vector_with_allocator.rs | 26 +- tests/unit/out/refcount/void_cast.rs | 16 +- tests/unit/out/unsafe/05_new.rs | 22 +- tests/unit/out/unsafe/10_struct.rs | 48 +++- tests/unit/out/unsafe/addr_of_global.rs | 22 +- tests/unit/out/unsafe/anonymous-struct.rs | 99 +++++++- tests/unit/out/unsafe/anonymous-struct_c.rs | 99 +++++++- tests/unit/out/unsafe/anonymous_enum.rs | 22 +- tests/unit/out/unsafe/anonymous_enum_c.rs | 22 +- tests/unit/out/unsafe/any.rs | 11 +- tests/unit/out/unsafe/array_const_init.rs | 22 +- tests/unit/out/unsafe/array_field_addr.rs | 11 +- .../out/unsafe/array_of_noncopy_struct.rs | 1 + tests/unit/out/unsafe/array_reference.rs | 11 +- tests/unit/out/unsafe/as_const.rs | 11 +- tests/unit/out/unsafe/assign_rhs_first.rs | 11 +- .../unit/out/unsafe/assignment_single_eval.rs | 210 ++++++++++++++-- tests/unit/out/unsafe/bounded_struct_ptr.rs | 11 +- tests/unit/out/unsafe/bst.rs | 11 +- tests/unit/out/unsafe/c_struct.rs | 55 +++- tests/unit/out/unsafe/cast.rs | 34 ++- .../out/unsafe/cast_array_to_pointer_decay.rs | 11 +- tests/unit/out/unsafe/class.rs | 44 +++- .../out/unsafe/class_template_lazy_member.rs | 55 +++- tests/unit/out/unsafe/class_templates.rs | 102 +++++++- tests/unit/out/unsafe/clone_vs_move.rs | 33 ++- tests/unit/out/unsafe/comma_operator.rs | 11 +- tests/unit/out/unsafe/complex_function.rs | 44 +++- .../unit/out/unsafe/compound_assign_paren.rs | 11 +- tests/unit/out/unsafe/concepts.rs | 11 +- tests/unit/out/unsafe/constexpr_function.rs | 22 +- tests/unit/out/unsafe/constructor.rs | 26 +- .../out/unsafe/container_element_receiver.rs | 1 + tests/unit/out/unsafe/container_field_addr.rs | 1 + .../conversion_operator_same_translation.rs | 20 +- tests/unit/out/unsafe/copy_assign.rs | 9 +- tests/unit/out/unsafe/copy_ctor.rs | 8 + tests/unit/out/unsafe/copy_move_defaulted.rs | 75 ++++-- tests/unit/out/unsafe/copy_move_deleted.rs | 12 +- tests/unit/out/unsafe/default.rs | 26 +- .../out/unsafe/default_function_arguments.rs | 22 +- tests/unit/out/unsafe/default_in_statics.rs | 33 ++- tests/unit/out/unsafe/delete_array_order.rs | 10 +- tests/unit/out/unsafe/destructor.rs | 128 ++++------ tests/unit/out/unsafe/destructor_params.rs | 21 +- .../unit/out/unsafe/destructor_temporaries.rs | 26 +- tests/unit/out/unsafe/doubly_linked_list.rs | 11 +- .../unit/out/unsafe/enum_default_in_static.rs | 11 +- tests/unit/out/unsafe/enum_int_interop.rs | 11 +- tests/unit/out/unsafe/enum_int_interop_c.rs | 11 +- tests/unit/out/unsafe/enum_underlying_type.rs | 4 +- tests/unit/out/unsafe/exprs.rs | 22 +- tests/unit/out/unsafe/fft.rs | 11 +- tests/unit/out/unsafe/field_aliasing.rs | 33 ++- tests/unit/out/unsafe/field_array_elem_ptr.rs | 22 +- .../unit/out/unsafe/field_method_receiver.rs | 12 +- tests/unit/out/unsafe/field_pointers.rs | 23 +- .../unsafe/field_pointers_malloced_struct.rs | 11 +- .../unsafe/field_reinterpret_write_through.rs | 22 +- tests/unit/out/unsafe/find.rs | 11 +- .../unsafe/first_field_ptr_covers_struct.rs | 22 +- .../unit/out/unsafe/first_member_downcast.rs | 22 +- .../unsafe/flex_array_member_incomplete.rs | 4 +- .../unsafe/flex_array_member_sibling_write.rs | 33 ++- tests/unit/out/unsafe/fn_ptr.rs | 10 +- tests/unit/out/unsafe/fn_ptr_cast.rs | 11 +- tests/unit/out/unsafe/fn_ptr_stable_sort.rs | 11 +- tests/unit/out/unsafe/fn_ptr_struct.rs | 24 +- tests/unit/out/unsafe/fn_ptr_typedef_cast.rs | 11 +- tests/unit/out/unsafe/fn_ptr_vtable.rs | 11 +- tests/unit/out/unsafe/fn_ref.rs | 11 +- tests/unit/out/unsafe/for_body_destructor.rs | 40 +-- .../unsafe/foreach_disjoint_field_borrow.rs | 1 + tests/unit/out/unsafe/forward_basic.rs | 2 + tests/unit/out/unsafe/forward_decltype.rs | 1 + tests/unit/out/unsafe/forward_explicit.rs | 1 + tests/unit/out/unsafe/forward_pack.rs | 2 + tests/unit/out/unsafe/friend.rs | 44 +++- tests/unit/out/unsafe/function_overloading.rs | 11 +- .../out/unsafe/global_call_temporaries.rs | 11 +- .../out/unsafe/global_init_side_effect.rs | 10 +- .../unit/out/unsafe/global_non_const_init.rs | 19 +- tests/unit/out/unsafe/global_pointers.rs | 11 +- .../out/unsafe/global_without_initializer.rs | 11 +- .../unit/out/unsafe/goto_aggregate_default.rs | 11 +- tests/unit/out/unsafe/goto_cleanup.rs | 11 +- tests/unit/out/unsafe/huffman.rs | 13 +- .../unsafe/immutable-deref-on-func-call.rs | 11 +- tests/unit/out/unsafe/implicit_autoref.rs | 1 + .../out/unsafe/in_class_field_initializer.rs | 12 +- tests/unit/out/unsafe/init.rs | 11 +- tests/unit/out/unsafe/init_list.rs | 19 +- .../out/unsafe/inline_container_fields.rs | 4 +- tests/unit/out/unsafe/kruskal.rs | 15 +- tests/unit/out/unsafe/lambda_as_field.rs | 26 +- .../out/unsafe/lambda_capture_copy_ctor.rs | 22 +- tests/unit/out/unsafe/lambda_capture_ref.rs | 11 +- .../out/unsafe/lambda_capture_star_this.rs | 11 +- tests/unit/out/unsafe/lambda_capture_this.rs | 11 +- tests/unit/out/unsafe/lambda_capture_value.rs | 11 +- tests/unit/out/unsafe/lambda_decltype_type.rs | 4 +- .../unsafe/lambda_generic_explicit_args.rs | 11 +- .../unit/out/unsafe/lambda_immediate_init.rs | 4 +- .../out/unsafe/lambda_move_only_capture.rs | 32 +-- tests/unit/out/unsafe/lambda_nested.rs | 11 +- tests/unit/out/unsafe/lambda_static_local.rs | 11 +- .../out/unsafe/libc_struct_without_default.rs | 5 +- tests/unit/out/unsafe/linked_list.rs | 11 +- .../out/unsafe/local_anon_struct_collision.rs | 22 +- .../unit/out/unsafe/local_record_template.rs | 44 +++- tests/unit/out/unsafe/map.rs | 4 +- tests/unit/out/unsafe/map_key_copy_ctor.rs | 1 + tests/unit/out/unsafe/map_key_identity.rs | 15 +- tests/unit/out/unsafe/map_try_emplace.rs | 5 +- .../out/unsafe/map_try_emplace_lvalues.rs | 34 ++- tests/unit/out/unsafe/max.rs | 1 + tests/unit/out/unsafe/memcpy_struct_bytes.rs | 11 +- .../unit/out/unsafe/memcpy_struct_layouts.rs | 55 +++- tests/unit/out/unsafe/memcpy_struct_struct.rs | 11 +- tests/unit/out/unsafe/memset_struct_tail.rs | 11 +- tests/unit/out/unsafe/move_assign.rs | 6 +- tests/unit/out/unsafe/move_ctor.rs | 6 +- tests/unit/out/unsafe/move_this.rs | 1 + tests/unit/out/unsafe/nested_structs.rs | 66 ++++- tests/unit/out/unsafe/new.rs | 11 +- tests/unit/out/unsafe/new_bst.rs | 11 +- tests/unit/out/unsafe/new_struct.rs | 22 +- .../unsafe/nttp_distinct_specializations.rs | 33 ++- tests/unit/out/unsafe/offsetof.rs | 15 +- tests/unit/out/unsafe/opaque_forward_decl.rs | 11 +- tests/unit/out/unsafe/opaque_record_copy.rs | 22 +- tests/unit/out/unsafe/opaque_then_defined.rs | 22 +- .../out/unsafe/operator_arithmetic_free.rs | 11 +- .../out/unsafe/operator_arithmetic_member.rs | 11 +- .../unit/out/unsafe/operator_bitwise_free.rs | 11 +- .../out/unsafe/operator_bitwise_member.rs | 11 +- .../unsafe/operator_comparison_defaulted.rs | 88 ++++++- .../out/unsafe/operator_comparison_free.rs | 22 +- .../out/unsafe/operator_comparison_member.rs | 11 +- .../out/unsafe/operator_comparison_mixed.rs | 11 +- .../out/unsafe/operator_comparison_nonbool.rs | 78 +++++- .../unsafe/operator_comparison_noncopyable.rs | 2 +- .../operator_compound_assignment_free.rs | 11 +- .../operator_compound_assignment_member.rs | 11 +- tests/unit/out/unsafe/operator_friend.rs | 77 +++++- tests/unit/out/unsafe/operator_less_than.rs | 11 +- .../unit/out/unsafe/operator_logical_free.rs | 11 +- .../out/unsafe/operator_logical_member.rs | 11 +- .../unsafe/operator_member_pointer_free.rs | 22 +- .../unsafe/operator_member_pointer_member.rs | 33 ++- tests/unit/out/unsafe/operator_other_free.rs | 11 +- .../unit/out/unsafe/operator_other_member.rs | 21 +- tests/unit/out/unsafe/operator_overloads.rs | 11 +- tests/unit/out/unsafe/operator_qualifiers.rs | 11 +- tests/unit/out/unsafe/operator_three_way.rs | 11 +- tests/unit/out/unsafe/operator_traits.rs | 55 +++- tests/unit/out/unsafe/overload_mangling.rs | 33 ++- .../unsafe/pair_converting_construction.rs | 102 +++++++- tests/unit/out/unsafe/pod.rs | 11 +- tests/unit/out/unsafe/pointer_array.rs | 11 +- tests/unit/out/unsafe/pointers.rs | 11 +- tests/unit/out/unsafe/polymorphism.rs | 22 +- tests/unit/out/unsafe/ptr_cast_init.rs | 22 +- tests/unit/out/unsafe/push_emplace_back.rs | 57 ++++- tests/unit/out/unsafe/random.rs | 22 +- tests/unit/out/unsafe/reference_wrapper.rs | 11 +- tests/unit/out/unsafe/references.rs | 22 +- tests/unit/out/unsafe/refs_as_args.rs | 11 +- .../out/unsafe/reinterpret_cast_ptr_cmp.rs | 33 ++- .../out/unsafe/reinterpret_cast_struct.rs | 11 +- .../reinterpret_cast_struct_to_struct.rs | 22 +- tests/unit/out/unsafe/reserved_keywords.rs | 33 ++- tests/unit/out/unsafe/return_move.rs | 22 +- tests/unit/out/unsafe/rule_of_five.rs | 24 +- tests/unit/out/unsafe/rule_of_three.rs | 13 +- tests/unit/out/unsafe/rvalue_rule_arg_move.rs | 1 + tests/unit/out/unsafe/rvalue_struct.rs | 11 +- .../scalar_builtin_construct_destruct.rs | 11 +- .../unsafe/self_referencing_initializer.rs | 26 +- tests/unit/out/unsafe/size_t_static_member.rs | 22 +- .../unit/out/unsafe/size_t_template_param.rs | 20 +- tests/unit/out/unsafe/sort_no_copy.rs | 9 +- tests/unit/out/unsafe/static_local.rs | 11 +- tests/unit/out/unsafe/static_var_in_class.rs | 22 +- tests/unit/out/unsafe/stdcopy.rs | 10 +- tests/unit/out/unsafe/strdup.rs | 11 +- .../out/unsafe/string_literal_ptr_init.rs | 11 +- tests/unit/out/unsafe/string_substr.rs | 11 +- .../unit/out/unsafe/struct_2d_array_field.rs | 11 +- tests/unit/out/unsafe/struct_ctor.rs | 25 +- tests/unit/out/unsafe/struct_default_ctor.rs | 30 ++- .../unsafe/struct_member_array_adjacency.rs | 11 +- tests/unit/out/unsafe/struct_ptr.rs | 11 +- .../unsafe/structured_binding_copy_ctor.rs | 1 + .../unsafe/structured_binding_element_ctor.rs | 2 + .../unsafe/structured_binding_move_ctor.rs | 2 + .../unsafe/structured_binding_range_for.rs | 11 +- .../unit/out/unsafe/structured_binding_ref.rs | 11 +- .../out/unsafe/structured_binding_trivial.rs | 11 +- tests/unit/out/unsafe/swap_map_no_copy.rs | 65 +++-- .../out/unsafe/tag_vs_identifier_collision.rs | 63 ++++- tests/unit/out/unsafe/template_default_arg.rs | 35 ++- .../unit/out/unsafe/template_static_member.rs | 55 +++- tests/unit/out/unsafe/temporary_field_addr.rs | 2 + .../out/unsafe/temporary_field_ctor_arg.rs | 11 +- .../out/unsafe/temporary_field_two_args.rs | 2 + tests/unit/out/unsafe/this.rs | 20 +- tests/unit/out/unsafe/typedef-anon-struct.rs | 12 +- .../out/unsafe/unary_expr_or_type_trait.rs | 11 +- tests/unit/out/unsafe/unboxed_locals.rs | 15 +- tests/unit/out/unsafe/unboxed_records.rs | 26 +- .../unit/out/unsafe/union_addrof_external.rs | 26 +- tests/unit/out/unsafe/union_basic.rs | 16 +- tests/unit/out/unsafe/union_cross_arm_cast.rs | 37 ++- .../unit/out/unsafe/union_field_alignment.rs | 15 +- .../out/unsafe/union_flex_array_member.rs | 15 +- tests/unit/out/unsafe/union_memset_memcpy.rs | 37 ++- tests/unit/out/unsafe/union_nested.rs | 41 ++- .../out/unsafe/union_pointer_pun_address.rs | 26 +- .../unsafe/union_pointer_pun_writethrough.rs | 4 +- .../unit/out/unsafe/union_struct_dual_use.rs | 26 +- .../unit/out/unsafe/union_tagged_many_arms.rs | 15 +- tests/unit/out/unsafe/union_tagged_simple.rs | 15 +- .../out/unsafe/union_tagged_struct_arms.rs | 48 +++- .../out/unsafe/union_void_ptr_sized_deref.rs | 15 +- tests/unit/out/unsafe/unique_ptr.rs | 13 +- .../unit/out/unsafe/unique_ptr_const_deref.rs | 2 +- .../unit/out/unsafe/unique_ptr_field_reset.rs | 13 +- tests/unit/out/unsafe/unique_ptr_nested.rs | 13 +- tests/unit/out/unsafe/unique_ptr_struct.rs | 11 +- tests/unit/out/unsafe/va_arg_mixed_types.rs | 11 +- .../out/unsafe/va_arg_non_primitive_ptrs.rs | 11 +- tests/unit/out/unsafe/va_arg_struct_ctx.rs | 15 +- tests/unit/out/unsafe/va_arg_void_ptr.rs | 11 +- tests/unit/out/unsafe/va_list_field.rs | 26 +- tests/unit/out/unsafe/vector.rs | 12 +- .../unit/out/unsafe/vector_iter_range_ctor.rs | 20 +- .../out/unsafe/vector_subscript_direct.rs | 12 +- .../unit/out/unsafe/vector_with_allocator.rs | 22 +- tests/unit/out/unsafe/void_cast.rs | 14 +- 590 files changed, 10696 insertions(+), 2318 deletions(-) diff --git a/tests/multi-file/cross_tu_tag_collision/out/refcount/cross_tu_tag_collision.rs b/tests/multi-file/cross_tu_tag_collision/out/refcount/cross_tu_tag_collision.rs index 9f220ef70d..19a771fe6d 100644 --- a/tests/multi-file/cross_tu_tag_collision/out/refcount/cross_tu_tag_collision.rs +++ b/tests/multi-file/cross_tu_tag_collision/out/refcount/cross_tu_tag_collision.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct widget { #[offset(0)] diff --git a/tests/multi-file/cross_tu_tag_collision/out/unsafe/cross_tu_tag_collision.rs b/tests/multi-file/cross_tu_tag_collision/out/unsafe/cross_tu_tag_collision.rs index 21f1c830fb..5433370a74 100644 --- a/tests/multi-file/cross_tu_tag_collision/out/unsafe/cross_tu_tag_collision.rs +++ b/tests/multi-file/cross_tu_tag_collision/out/unsafe/cross_tu_tag_collision.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct widget { pub id: i32, } diff --git a/tests/multi-file/defaulted_move_cross_tu/out/refcount/defaulted_move_cross_tu.rs b/tests/multi-file/defaulted_move_cross_tu/out/refcount/defaulted_move_cross_tu.rs index f26960cf22..cf7c28f4c6 100644 --- a/tests/multi-file/defaulted_move_cross_tu/out/refcount/defaulted_move_cross_tu.rs +++ b/tests/multi-file/defaulted_move_cross_tu/out/refcount/defaulted_move_cross_tu.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Swappable)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Destructible, Swappable)] #[cpp_from(i32, construct, value)] #[byte_size(32)] pub struct S { @@ -51,6 +51,7 @@ impl Default for S { ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, CopyAssignable, Swappable, diff --git a/tests/multi-file/defaulted_move_cross_tu/out/unsafe/defaulted_move_cross_tu.rs b/tests/multi-file/defaulted_move_cross_tu/out/unsafe/defaulted_move_cross_tu.rs index bbe34f8ef0..b2802b1dd2 100644 --- a/tests/multi-file/defaulted_move_cross_tu/out/unsafe/defaulted_move_cross_tu.rs +++ b/tests/multi-file/defaulted_move_cross_tu/out/unsafe/defaulted_move_cross_tu.rs @@ -7,7 +7,9 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, SwappableUnsafe, Default)] +#[derive( + FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, SwappableUnsafe, Default, +)] #[cpp_from(i32, construct, value)] pub struct S { pub v: Vec, @@ -47,6 +49,7 @@ impl MoveAssignableUnsafe for S { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, SwappableUnsafe, diff --git a/tests/multi-file/friend_operator/out/refcount/friend_operator.rs b/tests/multi-file/friend_operator/out/refcount/friend_operator.rs index 4a3a726bf4..5fea9b06fb 100644 --- a/tests/multi-file/friend_operator/out/refcount/friend_operator.rs +++ b/tests/multi-file/friend_operator/out/refcount/friend_operator.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct S { #[offset(0)] diff --git a/tests/multi-file/friend_operator/out/unsafe/friend_operator.rs b/tests/multi-file/friend_operator/out/unsafe/friend_operator.rs index efead5d19f..a200a83083 100644 --- a/tests/multi-file/friend_operator/out/unsafe/friend_operator.rs +++ b/tests/multi-file/friend_operator/out/unsafe/friend_operator.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub a: i32, pub b: i32, diff --git a/tests/multi-file/opaque_forward_decl/out/refcount/opaque_forward_decl.rs b/tests/multi-file/opaque_forward_decl/out/refcount/opaque_forward_decl.rs index d9ef3a6a15..9fe6482f96 100644 --- a/tests/multi-file/opaque_forward_decl/out/refcount/opaque_forward_decl.rs +++ b/tests/multi-file/opaque_forward_decl/out/refcount/opaque_forward_decl.rs @@ -6,7 +6,9 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(16)] pub struct container { #[offset(0)] diff --git a/tests/multi-file/opaque_forward_decl/out/unsafe/opaque_forward_decl.rs b/tests/multi-file/opaque_forward_decl/out/unsafe/opaque_forward_decl.rs index f35c10253b..c7a550cfd7 100644 --- a/tests/multi-file/opaque_forward_decl/out/unsafe/opaque_forward_decl.rs +++ b/tests/multi-file/opaque_forward_decl/out/unsafe/opaque_forward_decl.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct container { pub p: *mut opaque, pub x: i32, diff --git a/tests/multi-file/out_of_line_methods_cross_tu/out/refcount/out_of_line_methods_cross_tu.rs b/tests/multi-file/out_of_line_methods_cross_tu/out/refcount/out_of_line_methods_cross_tu.rs index 30e932a145..1212e72099 100644 --- a/tests/multi-file/out_of_line_methods_cross_tu/out/refcount/out_of_line_methods_cross_tu.rs +++ b/tests/multi-file/out_of_line_methods_cross_tu/out/refcount/out_of_line_methods_cross_tu.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] @@ -15,13 +26,35 @@ pub struct S { pub trait Base { fn apply(&mut self, x: i32) -> i32; } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(16)] pub struct Derived { #[offset(8)] pub factor: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Pair { #[offset(0)] @@ -62,6 +95,9 @@ fn main_0() -> i32 { return 0; } impl S {} +impl Destructible for S { + fn destroy(this: &Ptr) {} +} impl Derived {} pub fn pair_sum_1(mut p: Ptr) -> i32 { return ({ p.with(|__s| __s.first) } + { p.with(|__s| __s.second) }); @@ -103,7 +139,6 @@ impl SImpl for Ptr { fn construct(&self, mut x: i32) { field!((*self), v).write(x); } - fn destructor(&self) {} fn set(&self, mut x: i32) { field!((*self), v).write(x); } diff --git a/tests/multi-file/out_of_line_methods_cross_tu/out/unsafe/out_of_line_methods_cross_tu.rs b/tests/multi-file/out_of_line_methods_cross_tu/out/unsafe/out_of_line_methods_cross_tu.rs index c961f6a2aa..824aa06898 100644 --- a/tests/multi-file/out_of_line_methods_cross_tu/out/unsafe/out_of_line_methods_cross_tu.rs +++ b/tests/multi-file/out_of_line_methods_cross_tu/out/unsafe/out_of_line_methods_cross_tu.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub v: i32, } @@ -20,13 +29,31 @@ pub unsafe trait Base { unsafe fn apply(&mut self, x: i32) -> i32; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Derived { pub factor: i32, } impl Derived {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Pair { pub first: i32, pub second: i32, @@ -76,8 +103,8 @@ impl Derived { } } impl S {} -impl S { - pub unsafe fn destructor(&mut self) {} +impl DestructibleUnsafe for S { + unsafe fn destroy(&mut self) {} } impl S { pub unsafe fn set(&mut self, mut x: i32) { diff --git a/tests/multi-file/template_method_late_instantiation/out/refcount/template_method_late_instantiation.rs b/tests/multi-file/template_method_late_instantiation/out/refcount/template_method_late_instantiation.rs index d65154a999..9124bb3a3f 100644 --- a/tests/multi-file/template_method_late_instantiation/out/refcount/template_method_late_instantiation.rs +++ b/tests/multi-file/template_method_late_instantiation/out/refcount/template_method_late_instantiation.rs @@ -6,7 +6,9 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(4)] pub struct S_int_ { #[offset(0)] diff --git a/tests/multi-file/template_method_late_instantiation/out/unsafe/template_method_late_instantiation.rs b/tests/multi-file/template_method_late_instantiation/out/unsafe/template_method_late_instantiation.rs index bbd20e2f44..492d0f2a0b 100644 --- a/tests/multi-file/template_method_late_instantiation/out/unsafe/template_method_late_instantiation.rs +++ b/tests/multi-file/template_method_late_instantiation/out/unsafe/template_method_late_instantiation.rs @@ -7,7 +7,9 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct S_int_ { pub x: i32, } diff --git a/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/refcount/p14-class-in-two-files.rs b/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/refcount/p14-class-in-two-files.rs index f9820a88a7..9d873239d0 100644 --- a/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/refcount/p14-class-in-two-files.rs +++ b/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/refcount/p14-class-in-two-files.rs @@ -24,7 +24,6 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Destructible, MoveConstructible, MoveAssignable, Swappable, @@ -60,6 +59,11 @@ impl CopyConstructible for LifetimeTracked { (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); } } +impl Destructible for LifetimeTracked { + fn destroy(this: &Ptr) { + (*dtorCount_2.with(Value::clone).borrow_mut()).prefix_inc(); + } +} impl CopyAssignable for LifetimeTracked { fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { field!((*this), uses).write(_a0.with(|__s| __s.uses)); @@ -88,19 +92,22 @@ impl Default for LifetimeTracked { } } } -#[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct AssertsDtorCountAtExit { #[offset(0)] pub expected: i32, } +impl Destructible for AssertsDtorCountAtExit { + fn destroy(this: &Ptr) { + assert!((dtorCount_2.with(|rc| *rc.borrow()) == (*this).with(|__s| __s.expected))); + } +} thread_local!( pub static check_4: Value = { let __static = Rc::new(RefCell::new(AssertsDtorCountAtExit { expected: 2 })); libcc2rs::register_static_destructor(|| { - Destructible::destroy(check_4.with(Value::clone).as_pointer()) + Destructible::destroy(&check_4.with(Value::clone).as_pointer()) }); __static }; @@ -113,12 +120,23 @@ thread_local!( Rc::try_unwrap(__v).ok().unwrap().into_inner() })); libcc2rs::register_static_destructor(|| { - Destructible::destroy(shared_5.with(Value::clone).as_pointer()) + Destructible::destroy(&shared_5.with(Value::clone).as_pointer()) }); __static }; ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct HasInlineMembers {} impl HasInlineMembers { @@ -134,7 +152,7 @@ thread_local!( Rc::try_unwrap(__v).ok().unwrap().into_inner() })); libcc2rs::register_static_destructor(|| { - Destructible::destroy(local_6.with(Value::clone).as_pointer()) + Destructible::destroy(&local_6.with(Value::clone).as_pointer()) }); __static }; @@ -165,17 +183,8 @@ pub fn b_shared_address_8() -> Ptr { pub fn b_instance_address_9() -> Ptr { return ({ HasInlineMembers::instance() }); } -pub trait AssertsDtorCountAtExitImpl { - fn destructor(&self); -} -impl AssertsDtorCountAtExitImpl for Ptr { - fn destructor(&self) { - assert!((dtorCount_2.with(|rc| *rc.borrow()) == (*self).with(|__s| __s.expected))); - } -} pub trait LifetimeTrackedImpl { fn construct(&self); - fn destructor(&self); fn use_(&self); } impl LifetimeTrackedImpl for Ptr { @@ -183,9 +192,6 @@ impl LifetimeTrackedImpl for Ptr { field!((*self), uses).write(0); (*ctorCount_0.with(Value::clone).borrow_mut()).prefix_inc(); } - fn destructor(&self) { - (*dtorCount_2.with(Value::clone).borrow_mut()).prefix_inc(); - } fn use_(&self) { field!((*self), uses).with_mut(|__v| { __v.prefix_inc(); diff --git a/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/unsafe/p14-class-in-two-files.rs b/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/unsafe/p14-class-in-two-files.rs index aae76d21e3..7ca9fd4f41 100644 --- a/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/unsafe/p14-class-in-two-files.rs +++ b/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/unsafe/p14-class-in-two-files.rs @@ -15,7 +15,6 @@ pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(| VaArg, FnPtrArg, ZeroInitializationUnsafe, - DestructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -40,9 +39,6 @@ impl LifetimeTracked { (&raw mut self.uses).write(0); (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).prefix_inc(); } - pub unsafe fn destructor(&mut self) { - (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)).prefix_inc(); - } pub unsafe fn use_(&self) { (*(&raw const self.uses).cast_mut()).prefix_inc(); (*std::cell::LazyCell::force_mut(&mut *&raw mut useCount_3)).prefix_inc(); @@ -54,6 +50,11 @@ impl CopyConstructibleUnsafe for LifetimeTracked { (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)).prefix_inc(); } } +impl DestructibleUnsafe for LifetimeTracked { + unsafe fn destroy(&mut self) { + (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)).prefix_inc(); + } +} impl CopyAssignableUnsafe for LifetimeTracked { unsafe fn copy_assign(&mut self, _a0: *const LifetimeTracked) -> *mut LifetimeTracked { self.uses = (*_a0).uses; @@ -81,14 +82,12 @@ impl Default for LifetimeTracked { } } #[repr(C)] -#[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, -)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct AssertsDtorCountAtExit { pub expected: i32, } -impl AssertsDtorCountAtExit { - pub unsafe fn destructor(&mut self) { +impl DestructibleUnsafe for AssertsDtorCountAtExit { + unsafe fn destroy(&mut self) { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)) == (self.expected))); } } @@ -97,9 +96,7 @@ pub static mut check_4: std::cell::LazyCell = { let __static = AssertsDtorCountAtExit { expected: 2 }; libcc2rs::register_static_destructor(|| { - DestructibleUnsafe::destroy(&raw mut *std::cell::LazyCell::force_mut( - &mut *&raw mut check_4, - )) + DestructibleUnsafe::destroy(std::cell::LazyCell::force_mut(&mut *&raw mut check_4)) }); __static } @@ -113,15 +110,22 @@ pub static mut shared_5: std::cell::LazyCell = __v }; libcc2rs::register_static_destructor(|| { - DestructibleUnsafe::destroy(&raw mut *std::cell::LazyCell::force_mut( - &mut *&raw mut shared_5, - )) + DestructibleUnsafe::destroy(std::cell::LazyCell::force_mut(&mut *&raw mut shared_5)) }); __static } }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct HasInlineMembers {} impl HasInlineMembers { pub unsafe fn instance() -> *mut LifetimeTracked { @@ -136,9 +140,7 @@ static mut local_6: std::cell::LazyCell = std::cell::LazyCell:: __v }; libcc2rs::register_static_destructor(|| { - DestructibleUnsafe::destroy(&raw mut *std::cell::LazyCell::force_mut( - &mut *&raw mut local_6, - )) + DestructibleUnsafe::destroy(std::cell::LazyCell::force_mut(&mut *&raw mut local_6)) }); __static } diff --git a/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/refcount/p15-class-template-static-member.rs b/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/refcount/p15-class-template-static-member.rs index 48c7a76842..4cb01edec3 100644 --- a/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/refcount/p15-class-template-static-member.rs +++ b/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/refcount/p15-class-template-static-member.rs @@ -24,7 +24,6 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Destructible, MoveConstructible, MoveAssignable, Swappable, @@ -60,6 +59,11 @@ impl CopyConstructible for LifetimeTracked { (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); } } +impl Destructible for LifetimeTracked { + fn destroy(this: &Ptr) { + (*dtorCount_2.with(Value::clone).borrow_mut()).prefix_inc(); + } +} impl CopyAssignable for LifetimeTracked { fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { field!((*this), uses).write(_a0.with(|__s| __s.uses)); @@ -96,12 +100,23 @@ thread_local!( Rc::try_unwrap(__v).ok().unwrap().into_inner() })); libcc2rs::register_static_destructor(|| { - Destructible::destroy(member_4.with(Value::clone).as_pointer()) + Destructible::destroy(&member_4.with(Value::clone).as_pointer()) }); __static }; ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct HasStaticMember_int_ {} thread_local!( @@ -112,12 +127,23 @@ thread_local!( Rc::try_unwrap(__v).ok().unwrap().into_inner() })); libcc2rs::register_static_destructor(|| { - Destructible::destroy(member_5.with(Value::clone).as_pointer()) + Destructible::destroy(&member_5.with(Value::clone).as_pointer()) }); __static }; ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct HasStaticMember_long_ {} pub fn main() { @@ -146,7 +172,6 @@ pub fn b_int_address_8() -> Ptr { } pub trait LifetimeTrackedImpl { fn construct(&self); - fn destructor(&self); fn use_(&self); } impl LifetimeTrackedImpl for Ptr { @@ -154,9 +179,6 @@ impl LifetimeTrackedImpl for Ptr { field!((*self), uses).write(0); (*ctorCount_0.with(Value::clone).borrow_mut()).prefix_inc(); } - fn destructor(&self) { - (*dtorCount_2.with(Value::clone).borrow_mut()).prefix_inc(); - } fn use_(&self) { field!((*self), uses).with_mut(|__v| { __v.prefix_inc(); diff --git a/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/unsafe/p15-class-template-static-member.rs b/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/unsafe/p15-class-template-static-member.rs index f68fc579a9..be5eccce4e 100644 --- a/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/unsafe/p15-class-template-static-member.rs +++ b/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/unsafe/p15-class-template-static-member.rs @@ -15,7 +15,6 @@ pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(| VaArg, FnPtrArg, ZeroInitializationUnsafe, - DestructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -40,9 +39,6 @@ impl LifetimeTracked { (&raw mut self.uses).write(0); (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).prefix_inc(); } - pub unsafe fn destructor(&mut self) { - (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)).prefix_inc(); - } pub unsafe fn use_(&self) { (*(&raw const self.uses).cast_mut()).prefix_inc(); (*std::cell::LazyCell::force_mut(&mut *&raw mut useCount_3)).prefix_inc(); @@ -54,6 +50,11 @@ impl CopyConstructibleUnsafe for LifetimeTracked { (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)).prefix_inc(); } } +impl DestructibleUnsafe for LifetimeTracked { + unsafe fn destroy(&mut self) { + (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)).prefix_inc(); + } +} impl CopyAssignableUnsafe for LifetimeTracked { unsafe fn copy_assign(&mut self, _a0: *const LifetimeTracked) -> *mut LifetimeTracked { self.uses = (*_a0).uses; @@ -89,15 +90,22 @@ pub static mut member_4: std::cell::LazyCell = __v }; libcc2rs::register_static_destructor(|| { - DestructibleUnsafe::destroy(&raw mut *std::cell::LazyCell::force_mut( - &mut *&raw mut member_4, - )) + DestructibleUnsafe::destroy(std::cell::LazyCell::force_mut(&mut *&raw mut member_4)) }); __static } }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct HasStaticMember_int_ {} pub static mut member_5: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { @@ -108,15 +116,22 @@ pub static mut member_5: std::cell::LazyCell = __v }; libcc2rs::register_static_destructor(|| { - DestructibleUnsafe::destroy(&raw mut *std::cell::LazyCell::force_mut( - &mut *&raw mut member_5, - )) + DestructibleUnsafe::destroy(std::cell::LazyCell::force_mut(&mut *&raw mut member_5)) }); __static } }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct HasStaticMember_long_ {} pub fn main() { unsafe { diff --git a/tests/std/basic/basic.def.odr/p15-function-template/out/refcount/p15-function-template.rs b/tests/std/basic/basic.def.odr/p15-function-template/out/refcount/p15-function-template.rs index 206c0c398b..bf4923d6ad 100644 --- a/tests/std/basic/basic.def.odr/p15-function-template/out/refcount/p15-function-template.rs +++ b/tests/std/basic/basic.def.odr/p15-function-template/out/refcount/p15-function-template.rs @@ -24,7 +24,6 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Destructible, MoveConstructible, MoveAssignable, Swappable, @@ -60,6 +59,11 @@ impl CopyConstructible for LifetimeTracked { (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); } } +impl Destructible for LifetimeTracked { + fn destroy(this: &Ptr) { + (*dtorCount_2.with(Value::clone).borrow_mut()).prefix_inc(); + } +} impl CopyAssignable for LifetimeTracked { fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { field!((*this), uses).write(_a0.with(|__s| __s.uses)); @@ -88,14 +92,17 @@ impl Default for LifetimeTracked { } } } -#[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct AssertsDtorCountAtExit { #[offset(0)] pub expected: i32, } +impl Destructible for AssertsDtorCountAtExit { + fn destroy(this: &Ptr) { + assert!((dtorCount_2.with(|rc| *rc.borrow()) == (*this).with(|__s| __s.expected))); + } +} pub fn count_4() -> i32 { return (*(*n_6.with(Value::clone).borrow_mut()).prefix_inc()); } @@ -113,7 +120,7 @@ thread_local!( Rc::try_unwrap(__v).ok().unwrap().into_inner() })); libcc2rs::register_static_destructor(|| { - Destructible::destroy(t_5.with(Value::clone).as_pointer()) + Destructible::destroy(&t_5.with(Value::clone).as_pointer()) }); __static }; @@ -129,7 +136,7 @@ thread_local!( Rc::try_unwrap(__v).ok().unwrap().into_inner() })); libcc2rs::register_static_destructor(|| { - Destructible::destroy(t_8.with(Value::clone).as_pointer()) + Destructible::destroy(&t_8.with(Value::clone).as_pointer()) }); __static }; @@ -145,7 +152,7 @@ thread_local!( Rc::try_unwrap(__v).ok().unwrap().into_inner() })); libcc2rs::register_static_destructor(|| { - Destructible::destroy(t_11.with(Value::clone).as_pointer()) + Destructible::destroy(&t_11.with(Value::clone).as_pointer()) }); __static }; @@ -157,7 +164,7 @@ thread_local!( pub static check_13: Value = { let __static = Rc::new(RefCell::new(AssertsDtorCountAtExit { expected: 4 })); libcc2rs::register_static_destructor(|| { - Destructible::destroy(check_13.with(Value::clone).as_pointer()) + Destructible::destroy(&check_13.with(Value::clone).as_pointer()) }); __static }; @@ -180,7 +187,18 @@ fn main_0() -> i32 { assert!((ctorCount_0.with(|rc| *rc.borrow()) == 4)); return 0; } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct S_14 {} pub fn count_18() -> i32 { @@ -194,7 +212,7 @@ thread_local!( Rc::try_unwrap(__v).ok().unwrap().into_inner() })); libcc2rs::register_static_destructor(|| { - Destructible::destroy(t_19.with(Value::clone).as_pointer()) + Destructible::destroy(&t_19.with(Value::clone).as_pointer()) }); __static }; @@ -211,20 +229,22 @@ pub fn b_count_long_17() -> i32 { pub fn b_count_local_15() -> i32 { return ({ count_18() }); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct S_21 {} -pub trait AssertsDtorCountAtExitImpl { - fn destructor(&self); -} -impl AssertsDtorCountAtExitImpl for Ptr { - fn destructor(&self) { - assert!((dtorCount_2.with(|rc| *rc.borrow()) == (*self).with(|__s| __s.expected))); - } -} pub trait LifetimeTrackedImpl { fn construct(&self); - fn destructor(&self); fn use_(&self); } impl LifetimeTrackedImpl for Ptr { @@ -232,9 +252,6 @@ impl LifetimeTrackedImpl for Ptr { field!((*self), uses).write(0); (*ctorCount_0.with(Value::clone).borrow_mut()).prefix_inc(); } - fn destructor(&self) { - (*dtorCount_2.with(Value::clone).borrow_mut()).prefix_inc(); - } fn use_(&self) { field!((*self), uses).with_mut(|__v| { __v.prefix_inc(); diff --git a/tests/std/basic/basic.def.odr/p15-function-template/out/unsafe/p15-function-template.rs b/tests/std/basic/basic.def.odr/p15-function-template/out/unsafe/p15-function-template.rs index 1a6c02b413..ec9cd41b17 100644 --- a/tests/std/basic/basic.def.odr/p15-function-template/out/unsafe/p15-function-template.rs +++ b/tests/std/basic/basic.def.odr/p15-function-template/out/unsafe/p15-function-template.rs @@ -15,7 +15,6 @@ pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(| VaArg, FnPtrArg, ZeroInitializationUnsafe, - DestructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -40,9 +39,6 @@ impl LifetimeTracked { (&raw mut self.uses).write(0); (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).prefix_inc(); } - pub unsafe fn destructor(&mut self) { - (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)).prefix_inc(); - } pub unsafe fn use_(&self) { (*(&raw const self.uses).cast_mut()).prefix_inc(); (*std::cell::LazyCell::force_mut(&mut *&raw mut useCount_3)).prefix_inc(); @@ -54,6 +50,11 @@ impl CopyConstructibleUnsafe for LifetimeTracked { (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)).prefix_inc(); } } +impl DestructibleUnsafe for LifetimeTracked { + unsafe fn destroy(&mut self) { + (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)).prefix_inc(); + } +} impl CopyAssignableUnsafe for LifetimeTracked { unsafe fn copy_assign(&mut self, _a0: *const LifetimeTracked) -> *mut LifetimeTracked { self.uses = (*_a0).uses; @@ -81,14 +82,12 @@ impl Default for LifetimeTracked { } } #[repr(C)] -#[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, -)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct AssertsDtorCountAtExit { pub expected: i32, } -impl AssertsDtorCountAtExit { - pub unsafe fn destructor(&mut self) { +impl DestructibleUnsafe for AssertsDtorCountAtExit { + unsafe fn destroy(&mut self) { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)) == (self.expected))); } } @@ -109,9 +108,7 @@ static mut t_5: std::cell::LazyCell = std::cell::LazyCell::new( __v }; libcc2rs::register_static_destructor(|| { - DestructibleUnsafe::destroy(&raw mut *std::cell::LazyCell::force_mut( - &mut *&raw mut t_5, - )) + DestructibleUnsafe::destroy(std::cell::LazyCell::force_mut(&mut *&raw mut t_5)) }); __static } @@ -125,9 +122,7 @@ static mut t_8: std::cell::LazyCell = std::cell::LazyCell::new( __v }; libcc2rs::register_static_destructor(|| { - DestructibleUnsafe::destroy(&raw mut *std::cell::LazyCell::force_mut( - &mut *&raw mut t_8, - )) + DestructibleUnsafe::destroy(std::cell::LazyCell::force_mut(&mut *&raw mut t_8)) }); __static } @@ -141,9 +136,7 @@ static mut t_11: std::cell::LazyCell = std::cell::LazyCell::new __v }; libcc2rs::register_static_destructor(|| { - DestructibleUnsafe::destroy(&raw mut *std::cell::LazyCell::force_mut( - &mut *&raw mut t_11, - )) + DestructibleUnsafe::destroy(std::cell::LazyCell::force_mut(&mut *&raw mut t_11)) }); __static } @@ -154,9 +147,7 @@ pub static mut check_13: std::cell::LazyCell = { let __static = AssertsDtorCountAtExit { expected: 4 }; libcc2rs::register_static_destructor(|| { - DestructibleUnsafe::destroy(&raw mut *std::cell::LazyCell::force_mut( - &mut *&raw mut check_13, - )) + DestructibleUnsafe::destroy(std::cell::LazyCell::force_mut(&mut *&raw mut check_13)) }); __static } @@ -182,7 +173,16 @@ unsafe fn main_0() -> i32 { return 0; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S_14 {} pub unsafe fn count_18() -> i32 { return (*(*std::cell::LazyCell::force_mut(&mut *&raw mut n_20)).prefix_inc()); @@ -195,9 +195,7 @@ static mut t_19: std::cell::LazyCell = std::cell::LazyCell::new __v }; libcc2rs::register_static_destructor(|| { - DestructibleUnsafe::destroy(&raw mut *std::cell::LazyCell::force_mut( - &mut *&raw mut t_19, - )) + DestructibleUnsafe::destroy(std::cell::LazyCell::force_mut(&mut *&raw mut t_19)) }); __static } @@ -213,7 +211,16 @@ pub unsafe fn b_count_local_15() -> i32 { return (unsafe { count_18() }); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S_21 {} pub unsafe fn __cpp2rust_init_globals() { std::cell::LazyCell::force(&*&raw const ctorCount_0); diff --git a/tests/std/basic/basic.def.odr/p15-inline-function/out/refcount/p15-inline-function.rs b/tests/std/basic/basic.def.odr/p15-inline-function/out/refcount/p15-inline-function.rs index aa33aae4ab..529fca8b0b 100644 --- a/tests/std/basic/basic.def.odr/p15-inline-function/out/refcount/p15-inline-function.rs +++ b/tests/std/basic/basic.def.odr/p15-inline-function/out/refcount/p15-inline-function.rs @@ -24,7 +24,6 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Destructible, MoveConstructible, MoveAssignable, Swappable, @@ -60,6 +59,11 @@ impl CopyConstructible for LifetimeTracked { (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); } } +impl Destructible for LifetimeTracked { + fn destroy(this: &Ptr) { + (*dtorCount_2.with(Value::clone).borrow_mut()).prefix_inc(); + } +} impl CopyAssignable for LifetimeTracked { fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { field!((*this), uses).write(_a0.with(|__s| __s.uses)); @@ -88,14 +92,17 @@ impl Default for LifetimeTracked { } } } -#[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct AssertsDtorCountAtExit { #[offset(0)] pub expected: i32, } +impl Destructible for AssertsDtorCountAtExit { + fn destroy(this: &Ptr) { + assert!((dtorCount_2.with(|rc| *rc.borrow()) == (*this).with(|__s| __s.expected))); + } +} pub fn instance_4() -> Ptr { return t_5.with(|v| v.as_pointer()); } @@ -107,7 +114,7 @@ thread_local!( Rc::try_unwrap(__v).ok().unwrap().into_inner() })); libcc2rs::register_static_destructor(|| { - Destructible::destroy(t_5.with(Value::clone).as_pointer()) + Destructible::destroy(&t_5.with(Value::clone).as_pointer()) }); __static }; @@ -116,7 +123,7 @@ thread_local!( pub static check_6: Value = { let __static = Rc::new(RefCell::new(AssertsDtorCountAtExit { expected: 1 })); libcc2rs::register_static_destructor(|| { - Destructible::destroy(check_6.with(Value::clone).as_pointer()) + Destructible::destroy(&check_6.with(Value::clone).as_pointer()) }); __static }; @@ -143,17 +150,8 @@ pub fn b_use_7() { pub fn b_address_8() -> Ptr { return ({ instance_4() }); } -pub trait AssertsDtorCountAtExitImpl { - fn destructor(&self); -} -impl AssertsDtorCountAtExitImpl for Ptr { - fn destructor(&self) { - assert!((dtorCount_2.with(|rc| *rc.borrow()) == (*self).with(|__s| __s.expected))); - } -} pub trait LifetimeTrackedImpl { fn construct(&self); - fn destructor(&self); fn use_(&self); } impl LifetimeTrackedImpl for Ptr { @@ -161,9 +159,6 @@ impl LifetimeTrackedImpl for Ptr { field!((*self), uses).write(0); (*ctorCount_0.with(Value::clone).borrow_mut()).prefix_inc(); } - fn destructor(&self) { - (*dtorCount_2.with(Value::clone).borrow_mut()).prefix_inc(); - } fn use_(&self) { field!((*self), uses).with_mut(|__v| { __v.prefix_inc(); diff --git a/tests/std/basic/basic.def.odr/p15-inline-function/out/unsafe/p15-inline-function.rs b/tests/std/basic/basic.def.odr/p15-inline-function/out/unsafe/p15-inline-function.rs index 0410039888..d4406cf52c 100644 --- a/tests/std/basic/basic.def.odr/p15-inline-function/out/unsafe/p15-inline-function.rs +++ b/tests/std/basic/basic.def.odr/p15-inline-function/out/unsafe/p15-inline-function.rs @@ -15,7 +15,6 @@ pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(| VaArg, FnPtrArg, ZeroInitializationUnsafe, - DestructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -40,9 +39,6 @@ impl LifetimeTracked { (&raw mut self.uses).write(0); (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).prefix_inc(); } - pub unsafe fn destructor(&mut self) { - (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)).prefix_inc(); - } pub unsafe fn use_(&self) { (*(&raw const self.uses).cast_mut()).prefix_inc(); (*std::cell::LazyCell::force_mut(&mut *&raw mut useCount_3)).prefix_inc(); @@ -54,6 +50,11 @@ impl CopyConstructibleUnsafe for LifetimeTracked { (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)).prefix_inc(); } } +impl DestructibleUnsafe for LifetimeTracked { + unsafe fn destroy(&mut self) { + (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)).prefix_inc(); + } +} impl CopyAssignableUnsafe for LifetimeTracked { unsafe fn copy_assign(&mut self, _a0: *const LifetimeTracked) -> *mut LifetimeTracked { self.uses = (*_a0).uses; @@ -81,14 +82,12 @@ impl Default for LifetimeTracked { } } #[repr(C)] -#[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, -)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct AssertsDtorCountAtExit { pub expected: i32, } -impl AssertsDtorCountAtExit { - pub unsafe fn destructor(&mut self) { +impl DestructibleUnsafe for AssertsDtorCountAtExit { + unsafe fn destroy(&mut self) { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)) == (self.expected))); } } @@ -103,9 +102,7 @@ static mut t_5: std::cell::LazyCell = std::cell::LazyCell::new( __v }; libcc2rs::register_static_destructor(|| { - DestructibleUnsafe::destroy(&raw mut *std::cell::LazyCell::force_mut( - &mut *&raw mut t_5, - )) + DestructibleUnsafe::destroy(std::cell::LazyCell::force_mut(&mut *&raw mut t_5)) }); __static } @@ -115,9 +112,7 @@ pub static mut check_6: std::cell::LazyCell = { let __static = AssertsDtorCountAtExit { expected: 1 }; libcc2rs::register_static_destructor(|| { - DestructibleUnsafe::destroy(&raw mut *std::cell::LazyCell::force_mut( - &mut *&raw mut check_6, - )) + DestructibleUnsafe::destroy(std::cell::LazyCell::force_mut(&mut *&raw mut check_6)) }); __static } diff --git a/tests/std/basic/basic.def.odr/p15-inline-variable/out/refcount/p15-inline-variable.rs b/tests/std/basic/basic.def.odr/p15-inline-variable/out/refcount/p15-inline-variable.rs index d4625ede86..370f20db24 100644 --- a/tests/std/basic/basic.def.odr/p15-inline-variable/out/refcount/p15-inline-variable.rs +++ b/tests/std/basic/basic.def.odr/p15-inline-variable/out/refcount/p15-inline-variable.rs @@ -24,7 +24,6 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Destructible, MoveConstructible, MoveAssignable, Swappable, @@ -60,6 +59,11 @@ impl CopyConstructible for LifetimeTracked { (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); } } +impl Destructible for LifetimeTracked { + fn destroy(this: &Ptr) { + (*dtorCount_2.with(Value::clone).borrow_mut()).prefix_inc(); + } +} impl CopyAssignable for LifetimeTracked { fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { field!((*this), uses).write(_a0.with(|__s| __s.uses)); @@ -88,19 +92,22 @@ impl Default for LifetimeTracked { } } } -#[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct AssertsDtorCountAtExit { #[offset(0)] pub expected: i32, } +impl Destructible for AssertsDtorCountAtExit { + fn destroy(this: &Ptr) { + assert!((dtorCount_2.with(|rc| *rc.borrow()) == (*this).with(|__s| __s.expected))); + } +} thread_local!( pub static check_4: Value = { let __static = Rc::new(RefCell::new(AssertsDtorCountAtExit { expected: 1 })); libcc2rs::register_static_destructor(|| { - Destructible::destroy(check_4.with(Value::clone).as_pointer()) + Destructible::destroy(&check_4.with(Value::clone).as_pointer()) }); __static }; @@ -113,7 +120,7 @@ thread_local!( Rc::try_unwrap(__v).ok().unwrap().into_inner() })); libcc2rs::register_static_destructor(|| { - Destructible::destroy(shared_5.with(Value::clone).as_pointer()) + Destructible::destroy(&shared_5.with(Value::clone).as_pointer()) }); __static }; @@ -138,17 +145,8 @@ pub fn b_use_6() { pub fn b_address_7() -> Ptr { return (shared_5.with(|v| v.as_pointer())); } -pub trait AssertsDtorCountAtExitImpl { - fn destructor(&self); -} -impl AssertsDtorCountAtExitImpl for Ptr { - fn destructor(&self) { - assert!((dtorCount_2.with(|rc| *rc.borrow()) == (*self).with(|__s| __s.expected))); - } -} pub trait LifetimeTrackedImpl { fn construct(&self); - fn destructor(&self); fn use_(&self); } impl LifetimeTrackedImpl for Ptr { @@ -156,9 +154,6 @@ impl LifetimeTrackedImpl for Ptr { field!((*self), uses).write(0); (*ctorCount_0.with(Value::clone).borrow_mut()).prefix_inc(); } - fn destructor(&self) { - (*dtorCount_2.with(Value::clone).borrow_mut()).prefix_inc(); - } fn use_(&self) { field!((*self), uses).with_mut(|__v| { __v.prefix_inc(); diff --git a/tests/std/basic/basic.def.odr/p15-inline-variable/out/unsafe/p15-inline-variable.rs b/tests/std/basic/basic.def.odr/p15-inline-variable/out/unsafe/p15-inline-variable.rs index 7d467d4886..9fc8d83f3e 100644 --- a/tests/std/basic/basic.def.odr/p15-inline-variable/out/unsafe/p15-inline-variable.rs +++ b/tests/std/basic/basic.def.odr/p15-inline-variable/out/unsafe/p15-inline-variable.rs @@ -15,7 +15,6 @@ pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(| VaArg, FnPtrArg, ZeroInitializationUnsafe, - DestructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -40,9 +39,6 @@ impl LifetimeTracked { (&raw mut self.uses).write(0); (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).prefix_inc(); } - pub unsafe fn destructor(&mut self) { - (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)).prefix_inc(); - } pub unsafe fn use_(&self) { (*(&raw const self.uses).cast_mut()).prefix_inc(); (*std::cell::LazyCell::force_mut(&mut *&raw mut useCount_3)).prefix_inc(); @@ -54,6 +50,11 @@ impl CopyConstructibleUnsafe for LifetimeTracked { (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)).prefix_inc(); } } +impl DestructibleUnsafe for LifetimeTracked { + unsafe fn destroy(&mut self) { + (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)).prefix_inc(); + } +} impl CopyAssignableUnsafe for LifetimeTracked { unsafe fn copy_assign(&mut self, _a0: *const LifetimeTracked) -> *mut LifetimeTracked { self.uses = (*_a0).uses; @@ -81,14 +82,12 @@ impl Default for LifetimeTracked { } } #[repr(C)] -#[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, -)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct AssertsDtorCountAtExit { pub expected: i32, } -impl AssertsDtorCountAtExit { - pub unsafe fn destructor(&mut self) { +impl DestructibleUnsafe for AssertsDtorCountAtExit { + unsafe fn destroy(&mut self) { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)) == (self.expected))); } } @@ -97,9 +96,7 @@ pub static mut check_4: std::cell::LazyCell = { let __static = AssertsDtorCountAtExit { expected: 1 }; libcc2rs::register_static_destructor(|| { - DestructibleUnsafe::destroy(&raw mut *std::cell::LazyCell::force_mut( - &mut *&raw mut check_4, - )) + DestructibleUnsafe::destroy(std::cell::LazyCell::force_mut(&mut *&raw mut check_4)) }); __static } @@ -113,9 +110,7 @@ pub static mut shared_5: std::cell::LazyCell = __v }; libcc2rs::register_static_destructor(|| { - DestructibleUnsafe::destroy(&raw mut *std::cell::LazyCell::force_mut( - &mut *&raw mut shared_5, - )) + DestructibleUnsafe::destroy(std::cell::LazyCell::force_mut(&mut *&raw mut shared_5)) }); __static } diff --git a/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/refcount/p16-default-argument-lambda-in-class.rs b/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/refcount/p16-default-argument-lambda-in-class.rs index 670c4a5a2b..4ad7a9872c 100644 --- a/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/refcount/p16-default-argument-lambda-in-class.rs +++ b/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/refcount/p16-default-argument-lambda-in-class.rs @@ -24,7 +24,6 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Destructible, MoveConstructible, MoveAssignable, Swappable, @@ -60,6 +59,11 @@ impl CopyConstructible for LifetimeTracked { (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); } } +impl Destructible for LifetimeTracked { + fn destroy(this: &Ptr) { + (*dtorCount_2.with(Value::clone).borrow_mut()).prefix_inc(); + } +} impl CopyAssignable for LifetimeTracked { fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { field!((*this), uses).write(_a0.with(|__s| __s.uses)); @@ -88,15 +92,29 @@ impl Default for LifetimeTracked { } } } -#[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct AssertsDtorCountAtExit { #[offset(0)] pub expected: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +impl Destructible for AssertsDtorCountAtExit { + fn destroy(this: &Ptr) { + assert!((dtorCount_2.with(|rc| *rc.borrow()) == (*this).with(|__s| __s.expected))); + } +} +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct X {} thread_local!( @@ -107,7 +125,7 @@ thread_local!( Rc::try_unwrap(__v).ok().unwrap().into_inner() })); libcc2rs::register_static_destructor(|| { - Destructible::destroy(local_4.with(Value::clone).as_pointer()) + Destructible::destroy(&local_4.with(Value::clone).as_pointer()) }); __static }; @@ -116,7 +134,7 @@ thread_local!( pub static check_5: Value = { let __static = Rc::new(RefCell::new(AssertsDtorCountAtExit { expected: 1 })); libcc2rs::register_static_destructor(|| { - Destructible::destroy(check_5.with(Value::clone).as_pointer()) + Destructible::destroy(&check_5.with(Value::clone).as_pointer()) }); __static }; @@ -156,17 +174,8 @@ pub fn b_call_6() { ) }); } -pub trait AssertsDtorCountAtExitImpl { - fn destructor(&self); -} -impl AssertsDtorCountAtExitImpl for Ptr { - fn destructor(&self) { - assert!((dtorCount_2.with(|rc| *rc.borrow()) == (*self).with(|__s| __s.expected))); - } -} pub trait LifetimeTrackedImpl { fn construct(&self); - fn destructor(&self); fn use_(&self); } impl LifetimeTrackedImpl for Ptr { @@ -174,9 +183,6 @@ impl LifetimeTrackedImpl for Ptr { field!((*self), uses).write(0); (*ctorCount_0.with(Value::clone).borrow_mut()).prefix_inc(); } - fn destructor(&self) { - (*dtorCount_2.with(Value::clone).borrow_mut()).prefix_inc(); - } fn use_(&self) { field!((*self), uses).with_mut(|__v| { __v.prefix_inc(); diff --git a/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/unsafe/p16-default-argument-lambda-in-class.rs b/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/unsafe/p16-default-argument-lambda-in-class.rs index 5a6ea9c12a..d93fcd8416 100644 --- a/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/unsafe/p16-default-argument-lambda-in-class.rs +++ b/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/unsafe/p16-default-argument-lambda-in-class.rs @@ -15,7 +15,6 @@ pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(| VaArg, FnPtrArg, ZeroInitializationUnsafe, - DestructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -40,9 +39,6 @@ impl LifetimeTracked { (&raw mut self.uses).write(0); (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).prefix_inc(); } - pub unsafe fn destructor(&mut self) { - (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)).prefix_inc(); - } pub unsafe fn use_(&self) { (*(&raw const self.uses).cast_mut()).prefix_inc(); (*std::cell::LazyCell::force_mut(&mut *&raw mut useCount_3)).prefix_inc(); @@ -54,6 +50,11 @@ impl CopyConstructibleUnsafe for LifetimeTracked { (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)).prefix_inc(); } } +impl DestructibleUnsafe for LifetimeTracked { + unsafe fn destroy(&mut self) { + (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)).prefix_inc(); + } +} impl CopyAssignableUnsafe for LifetimeTracked { unsafe fn copy_assign(&mut self, _a0: *const LifetimeTracked) -> *mut LifetimeTracked { self.uses = (*_a0).uses; @@ -81,19 +82,26 @@ impl Default for LifetimeTracked { } } #[repr(C)] -#[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, -)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct AssertsDtorCountAtExit { pub expected: i32, } -impl AssertsDtorCountAtExit { - pub unsafe fn destructor(&mut self) { +impl DestructibleUnsafe for AssertsDtorCountAtExit { + unsafe fn destroy(&mut self) { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)) == (self.expected))); } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct X {} impl X { pub unsafe fn h(&mut self, mut cond: bool, mut p: Option) { @@ -124,9 +132,7 @@ static mut local_4: std::cell::LazyCell = std::cell::LazyCell:: __v }; libcc2rs::register_static_destructor(|| { - DestructibleUnsafe::destroy(&raw mut *std::cell::LazyCell::force_mut( - &mut *&raw mut local_4, - )) + DestructibleUnsafe::destroy(std::cell::LazyCell::force_mut(&mut *&raw mut local_4)) }); __static } @@ -136,9 +142,7 @@ pub static mut check_5: std::cell::LazyCell = { let __static = AssertsDtorCountAtExit { expected: 1 }; libcc2rs::register_static_destructor(|| { - DestructibleUnsafe::destroy(&raw mut *std::cell::LazyCell::force_mut( - &mut *&raw mut check_5, - )) + DestructibleUnsafe::destroy(std::cell::LazyCell::force_mut(&mut *&raw mut check_5)) }); __static } diff --git a/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/refcount/p16-lambda-in-inline-function.rs b/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/refcount/p16-lambda-in-inline-function.rs index d18f1a4ae5..85a3e08063 100644 --- a/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/refcount/p16-lambda-in-inline-function.rs +++ b/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/refcount/p16-lambda-in-inline-function.rs @@ -24,7 +24,6 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Destructible, MoveConstructible, MoveAssignable, Swappable, @@ -60,6 +59,11 @@ impl CopyConstructible for LifetimeTracked { (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); } } +impl Destructible for LifetimeTracked { + fn destroy(this: &Ptr) { + (*dtorCount_2.with(Value::clone).borrow_mut()).prefix_inc(); + } +} impl CopyAssignable for LifetimeTracked { fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { field!((*this), uses).write(_a0.with(|__s| __s.uses)); @@ -88,14 +92,17 @@ impl Default for LifetimeTracked { } } } -#[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct AssertsDtorCountAtExit { #[offset(0)] pub expected: i32, } +impl Destructible for AssertsDtorCountAtExit { + fn destroy(this: &Ptr) { + assert!((dtorCount_2.with(|rc| *rc.borrow()) == (*this).with(|__s| __s.expected))); + } +} pub fn f_4(mut cond: bool, mut p: FnPtr) { if cond { ({ @@ -118,7 +125,7 @@ thread_local!( Rc::try_unwrap(__v).ok().unwrap().into_inner() })); libcc2rs::register_static_destructor(|| { - Destructible::destroy(local_5.with(Value::clone).as_pointer()) + Destructible::destroy(&local_5.with(Value::clone).as_pointer()) }); __static }; @@ -127,7 +134,7 @@ thread_local!( pub static check_6: Value = { let __static = Rc::new(RefCell::new(AssertsDtorCountAtExit { expected: 1 })); libcc2rs::register_static_destructor(|| { - Destructible::destroy(check_6.with(Value::clone).as_pointer()) + Destructible::destroy(&check_6.with(Value::clone).as_pointer()) }); __static }; @@ -149,17 +156,8 @@ fn main_0() -> i32 { pub fn b_call_7() { ({ f_4(true, FnPtr::::null()) }); } -pub trait AssertsDtorCountAtExitImpl { - fn destructor(&self); -} -impl AssertsDtorCountAtExitImpl for Ptr { - fn destructor(&self) { - assert!((dtorCount_2.with(|rc| *rc.borrow()) == (*self).with(|__s| __s.expected))); - } -} pub trait LifetimeTrackedImpl { fn construct(&self); - fn destructor(&self); fn use_(&self); } impl LifetimeTrackedImpl for Ptr { @@ -167,9 +165,6 @@ impl LifetimeTrackedImpl for Ptr { field!((*self), uses).write(0); (*ctorCount_0.with(Value::clone).borrow_mut()).prefix_inc(); } - fn destructor(&self) { - (*dtorCount_2.with(Value::clone).borrow_mut()).prefix_inc(); - } fn use_(&self) { field!((*self), uses).with_mut(|__v| { __v.prefix_inc(); diff --git a/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/unsafe/p16-lambda-in-inline-function.rs b/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/unsafe/p16-lambda-in-inline-function.rs index ad625a88a6..9a11e45b05 100644 --- a/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/unsafe/p16-lambda-in-inline-function.rs +++ b/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/unsafe/p16-lambda-in-inline-function.rs @@ -15,7 +15,6 @@ pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(| VaArg, FnPtrArg, ZeroInitializationUnsafe, - DestructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -40,9 +39,6 @@ impl LifetimeTracked { (&raw mut self.uses).write(0); (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).prefix_inc(); } - pub unsafe fn destructor(&mut self) { - (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)).prefix_inc(); - } pub unsafe fn use_(&self) { (*(&raw const self.uses).cast_mut()).prefix_inc(); (*std::cell::LazyCell::force_mut(&mut *&raw mut useCount_3)).prefix_inc(); @@ -54,6 +50,11 @@ impl CopyConstructibleUnsafe for LifetimeTracked { (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)).prefix_inc(); } } +impl DestructibleUnsafe for LifetimeTracked { + unsafe fn destroy(&mut self) { + (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)).prefix_inc(); + } +} impl CopyAssignableUnsafe for LifetimeTracked { unsafe fn copy_assign(&mut self, _a0: *const LifetimeTracked) -> *mut LifetimeTracked { self.uses = (*_a0).uses; @@ -81,14 +82,12 @@ impl Default for LifetimeTracked { } } #[repr(C)] -#[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, -)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct AssertsDtorCountAtExit { pub expected: i32, } -impl AssertsDtorCountAtExit { - pub unsafe fn destructor(&mut self) { +impl DestructibleUnsafe for AssertsDtorCountAtExit { + unsafe fn destroy(&mut self) { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)) == (self.expected))); } } @@ -118,9 +117,7 @@ static mut local_5: std::cell::LazyCell = std::cell::LazyCell:: __v }; libcc2rs::register_static_destructor(|| { - DestructibleUnsafe::destroy(&raw mut *std::cell::LazyCell::force_mut( - &mut *&raw mut local_5, - )) + DestructibleUnsafe::destroy(std::cell::LazyCell::force_mut(&mut *&raw mut local_5)) }); __static } @@ -130,9 +127,7 @@ pub static mut check_6: std::cell::LazyCell = { let __static = AssertsDtorCountAtExit { expected: 1 }; libcc2rs::register_static_destructor(|| { - DestructibleUnsafe::destroy(&raw mut *std::cell::LazyCell::force_mut( - &mut *&raw mut check_6, - )) + DestructibleUnsafe::destroy(std::cell::LazyCell::force_mut(&mut *&raw mut check_6)) }); __static } diff --git a/tests/std/basic/basic.link/out/refcount/basic.link.rs b/tests/std/basic/basic.link/out/refcount/basic.link.rs index 7a2a6eb8a7..1dae912268 100644 --- a/tests/std/basic/basic.link/out/refcount/basic.link.rs +++ b/tests/std/basic/basic.link/out/refcount/basic.link.rs @@ -29,7 +29,7 @@ pub fn test_11() { assert!((ceiling_10.with(|rc| *rc.borrow()) == 40)); assert!(((ceiling_10.with(|v| v.as_pointer())) == ({ ceiling_address_in_b_12() }))); } -#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] +#[derive(VaArg, FnPtrArg, Destructible, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(4)] pub struct anon_13 { #[offset(0)] @@ -67,7 +67,9 @@ thread_local!( pub fn bump_18() -> i32 { return (*(*counter_17.with(Value::clone).borrow_mut()).prefix_inc()); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(4)] pub struct Record_19 { #[offset(0)] @@ -103,7 +105,18 @@ pub fn test_29() { level_28.with(|rc| *rc.borrow_mut() = 10); assert!((({ raise_30(1,) }) == 11)); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct Tally_31 {} thread_local!( @@ -115,7 +128,18 @@ pub fn test_33() { assert!((({ add_in_b_34(1,) }) == 102)); assert!((total_32.with(|rc| *rc.borrow()) == 11)); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct p5_members_of_class_with_external_linkage_Ledger {} pub fn test_36() { @@ -183,7 +207,9 @@ pub fn test_55() { assert!((({ second_key_plus_value_53() }) == 32)); assert!((({ key_in_b_56() }) == 400)); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(4)] pub struct Entry_52 { #[offset(0)] @@ -194,7 +220,9 @@ impl Default for Entry_52 { { Entry_52 { key: 1 } } } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(8)] pub struct Entry_54 { #[offset(0)] @@ -266,7 +294,7 @@ thread_local!( pub fn ceiling_address_in_b_12() -> Ptr { return (ceiling_10.with(|v| v.as_pointer())); } -#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] +#[derive(VaArg, FnPtrArg, Destructible, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(4)] pub struct anon_62 { #[offset(0)] @@ -304,7 +332,9 @@ thread_local!( pub fn bump_64() -> i32 { return (*(*counter_63.with(Value::clone).borrow_mut()).prefix_inc()); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(16)] pub struct Record_65 { #[offset(0)] @@ -348,7 +378,18 @@ pub fn raise_30(mut by: i32) -> i32 { level_28.with(|rc| *rc.borrow_mut() += by); return level_28.with(|rc| *rc.borrow()); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct Tally_67 {} thread_local!( @@ -390,7 +431,9 @@ pub fn key_in_b_56() -> i32 { let mut entry: Entry_71 = ::default(); return (entry.key as i32); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(8)] pub struct Entry_71 { #[offset(0)] diff --git a/tests/std/basic/basic.link/out/unsafe/basic.link.rs b/tests/std/basic/basic.link/out/unsafe/basic.link.rs index e1cf93455f..4109990271 100644 --- a/tests/std/basic/basic.link/out/unsafe/basic.link.rs +++ b/tests/std/basic/basic.link/out/unsafe/basic.link.rs @@ -37,7 +37,9 @@ pub unsafe fn test_11() { ); } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub union anon_13 { pub whole: i32, pub fraction: f32, @@ -60,7 +62,9 @@ pub unsafe fn bump_18() -> i32 { return (*(*std::cell::LazyCell::force_mut(&mut *&raw mut counter_17)).prefix_inc()); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct Record_19 { pub id: i32, } @@ -93,7 +97,16 @@ pub unsafe fn test_29() { assert!(((unsafe { raise_30(1,) }) == (11))); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Tally_31 {} impl Tally_31 { pub unsafe fn add(&mut self, mut amount: i32) -> i32 { @@ -109,7 +122,16 @@ pub unsafe fn test_33() { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut total_32)) == (11))); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p5_members_of_class_with_external_linkage_Ledger {} pub unsafe fn test_36() { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut balance_35)) == (50))); @@ -171,7 +193,9 @@ pub unsafe fn test_55() { assert!(((unsafe { key_in_b_56() }) == (400))); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct Entry_52 { pub key: i32, } @@ -181,7 +205,9 @@ impl Default for Entry_52 { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct Entry_54 { pub key: i32, pub value: i32, @@ -243,7 +269,9 @@ pub unsafe fn ceiling_address_in_b_12() -> *const i32 { return (&raw const (*std::cell::LazyCell::force_mut(&mut *&raw mut ceiling_10)) as *const i32); } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub union anon_62 { pub whole: i32, pub fraction: f32, @@ -266,7 +294,9 @@ pub unsafe fn bump_64() -> i32 { return (*(*std::cell::LazyCell::force_mut(&mut *&raw mut counter_63)).prefix_inc()); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct Record_65 { pub id: i64, pub extra: i32, @@ -303,7 +333,16 @@ pub unsafe fn raise_30(mut by: i32) -> i32 { return (*std::cell::LazyCell::force_mut(&mut *&raw mut level_28)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Tally_67 {} impl Tally_67 { pub unsafe fn add(&mut self, mut amount: i32) -> i32 { @@ -341,7 +380,9 @@ pub unsafe fn key_in_b_56() -> i32 { return (entry.key as i32); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct Entry_71 { pub key: i64, } diff --git a/tests/std/basic/basic.scope/out/refcount/basic.scope.block.rs b/tests/std/basic/basic.scope/out/refcount/basic.scope.block.rs index ea482e35a3..f5e9756c7f 100644 --- a/tests/std/basic/basic.scope/out/refcount/basic.scope.block.rs +++ b/tests/std/basic/basic.scope/out/refcount/basic.scope.block.rs @@ -24,7 +24,6 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Destructible, MoveConstructible, MoveAssignable, Swappable, @@ -60,6 +59,11 @@ impl CopyConstructible for LifetimeTracked { (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); } } +impl Destructible for LifetimeTracked { + fn destroy(this: &Ptr) { + (*dtorCount_2.with(Value::clone).borrow_mut()).prefix_inc(); + } +} impl CopyAssignable for LifetimeTracked { fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { field!((*this), uses).write(_a0.with(|__s| __s.uses)); @@ -97,21 +101,24 @@ thread_local!( thread_local!( pub static dtorCount_6: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct p1_1_condition_variable_visible_in_else_ConvertsToBool { #[offset(0)] pub value: i32, } +impl Destructible for p1_1_condition_variable_visible_in_else_ConvertsToBool { + fn destroy(this: &Ptr) { + (*dtorCount_6.with(Value::clone).borrow_mut()).prefix_inc(); + } +} pub fn test_7() { { let condition: Value = Rc::new( RefCell::new(p1_1_condition_variable_visible_in_else_ConvertsToBool { value: 0 }), ); let _dtor_condition = std::mem::DropGuard::new(condition.clone(), |__p| { - Destructible::destroy(__p.as_pointer()) + Destructible::destroy(&__p.as_pointer()) }); if ({ p1_1_condition_variable_visible_in_else_ConvertsToBoolImpl::to_bool( @@ -133,7 +140,7 @@ pub fn test_7() { RefCell::new(p1_1_condition_variable_visible_in_else_ConvertsToBool { value: 6 }), ); let _dtor_condition = std::mem::DropGuard::new(condition.clone(), |__p| { - Destructible::destroy(__p.as_pointer()) + Destructible::destroy(&__p.as_pointer()) }); if ({ p1_1_condition_variable_visible_in_else_ConvertsToBoolImpl::to_bool( @@ -177,7 +184,7 @@ pub fn test_9() { Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let _dtor_scoped = std::mem::DropGuard::new(scoped.clone(), |__p| { - Destructible::destroy(__p.as_pointer()) + Destructible::destroy(&__p.as_pointer()) }); assert!((ctorCount_0.with(|rc| *rc.borrow()) == 1)); { @@ -191,7 +198,7 @@ pub fn test_9() { Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let _dtor_scoped = std::mem::DropGuard::new(scoped.clone(), |__p| { - Destructible::destroy(__p.as_pointer()) + Destructible::destroy(&__p.as_pointer()) }); } index.prefix_inc(); @@ -206,7 +213,7 @@ pub fn test_9() { Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let _dtor_scoped = std::mem::DropGuard::new(scoped.clone(), |__p| { - Destructible::destroy(__p.as_pointer()) + Destructible::destroy(&__p.as_pointer()) }); } assert!((ctorCount_0.with(|rc| *rc.borrow()) == 5)); @@ -219,7 +226,7 @@ pub fn test_9() { Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let _dtor_scoped = std::mem::DropGuard::new(scoped.clone(), |__p| { - Destructible::destroy(__p.as_pointer()) + Destructible::destroy(&__p.as_pointer()) }); } assert!((ctorCount_0.with(|rc| *rc.borrow()) == 6)); @@ -255,7 +262,7 @@ pub fn test_11() { Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let _dtor_tracked = std::mem::DropGuard::new(tracked.clone(), |__p| { - Destructible::destroy(__p.as_pointer()) + Destructible::destroy(&__p.as_pointer()) }); { let tracked: Value = Rc::new(RefCell::new({ @@ -264,7 +271,7 @@ pub fn test_11() { Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let _dtor_tracked = std::mem::DropGuard::new(tracked.clone(), |__p| { - Destructible::destroy(__p.as_pointer()) + Destructible::destroy(&__p.as_pointer()) }); assert!((ctorCount_0.with(|rc| *rc.borrow()) == 2)); ({ LifetimeTrackedImpl::use_(&tracked.as_pointer()) }); @@ -353,7 +360,6 @@ fn main_0() -> i32 { } pub trait LifetimeTrackedImpl { fn construct(&self); - fn destructor(&self); fn use_(&self); } impl LifetimeTrackedImpl for Ptr { @@ -361,9 +367,6 @@ impl LifetimeTrackedImpl for Ptr { field!((*self), uses).write(0); (*ctorCount_0.with(Value::clone).borrow_mut()).prefix_inc(); } - fn destructor(&self) { - (*dtorCount_2.with(Value::clone).borrow_mut()).prefix_inc(); - } fn use_(&self) { field!((*self), uses).with_mut(|__v| { __v.prefix_inc(); @@ -373,7 +376,6 @@ impl LifetimeTrackedImpl for Ptr { } pub trait p1_1_condition_variable_visible_in_else_ConvertsToBoolImpl { fn to_bool(&self) -> bool; - fn destructor(&self); } impl p1_1_condition_variable_visible_in_else_ConvertsToBoolImpl for Ptr @@ -381,9 +383,6 @@ impl p1_1_condition_variable_visible_in_else_ConvertsToBoolImpl fn to_bool(&self) -> bool { return ((*self).with(|__s| __s.value) != 0); } - fn destructor(&self) { - (*dtorCount_6.with(Value::clone).borrow_mut()).prefix_inc(); - } } pub fn __cpp2rust_init_globals() { let _ = ctorCount_0.with(|_| ()); diff --git a/tests/std/basic/basic.scope/out/refcount/basic.scope.class.rs b/tests/std/basic/basic.scope/out/refcount/basic.scope.class.rs index d935f2bb45..737c83c38b 100644 --- a/tests/std/basic/basic.scope/out/refcount/basic.scope.class.rs +++ b/tests/std/basic/basic.scope/out/refcount/basic.scope.class.rs @@ -9,7 +9,9 @@ use std::rc::{Rc, Weak}; thread_local!( pub static balance_0: Value = Rc::new(RefCell::new(50)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(4)] pub struct p1_member_hides_namespace_variable_HasBalance { #[offset(0)] @@ -45,7 +47,9 @@ pub fn test_1() { thread_local!( pub static initial_2: Value = Rc::new(RefCell::new(100)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(4)] pub struct p1_out_of_class_definition_is_in_class_scope_HasStaticTotal { #[offset(0)] diff --git a/tests/std/basic/basic.scope/out/refcount/basic.scope.param.rs b/tests/std/basic/basic.scope/out/refcount/basic.scope.param.rs index ee9602fff9..36dca359ea 100644 --- a/tests/std/basic/basic.scope/out/refcount/basic.scope.param.rs +++ b/tests/std/basic/basic.scope/out/refcount/basic.scope.param.rs @@ -7,7 +7,17 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + Copyable, + Default, )] #[cpp_from(i32, construct, value)] #[byte_size(4)] diff --git a/tests/std/basic/basic.scope/out/refcount/basic.scope.pdecl.rs b/tests/std/basic/basic.scope/out/refcount/basic.scope.pdecl.rs index f8ed232a0a..c003ab74e9 100644 --- a/tests/std/basic/basic.scope/out/refcount/basic.scope.pdecl.rs +++ b/tests/std/basic/basic.scope/out/refcount/basic.scope.pdecl.rs @@ -18,7 +18,9 @@ pub fn test_0() { } assert!((level == 5)); } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(16)] pub struct p1_own_address_in_initializer_SelfLinked { #[offset(0)] @@ -73,7 +75,7 @@ pub fn test_3() { pub type anon_4 = u32; pub const anon_4_limit: anon_4 = 13; pub const anon_4_above: anon_4 = 14; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(8)] pub struct p9_func_declared_before_function_body_RecordsConstructorName { #[offset(0)] diff --git a/tests/std/basic/basic.scope/out/refcount/basic.scope.scope.rs b/tests/std/basic/basic.scope/out/refcount/basic.scope.scope.rs index 1e1bb61730..fe2c5213a7 100644 --- a/tests/std/basic/basic.scope/out/refcount/basic.scope.scope.rs +++ b/tests/std/basic/basic.scope/out/refcount/basic.scope.scope.rs @@ -44,7 +44,18 @@ pub const p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum_Size_small: p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum_Size = 3; pub const p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum_Size_large: p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum_Size = 8; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum {} pub fn test_5() { @@ -72,7 +83,18 @@ pub fn test_5() { thread_local!( pub static count_6: Value = Rc::new(RefCell::new(0)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct p2_12_class_name_in_own_scope_HasStaticCounter {} impl p2_12_class_name_in_own_scope_HasStaticCounter { @@ -88,7 +110,7 @@ pub fn test_7() { count_6.with(|rc| *rc.borrow_mut() = 6); assert!((count_6.with(|rc| *rc.borrow()) == 6)); } -#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] +#[derive(VaArg, FnPtrArg, Destructible, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(8)] pub struct anon_8 { #[offset(0)] @@ -114,7 +136,7 @@ impl Default for anon_8 { thread_local!( pub static anon_8: Value = Rc::new(RefCell::new(::default())); ); -#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] +#[derive(VaArg, FnPtrArg, Destructible, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(8)] pub struct anon_9 { #[offset(0)] @@ -137,7 +159,9 @@ impl Default for anon_9 { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(16)] pub struct p2_13_anonymous_union_members_in_parent_scope_HasAnonymousUnion { #[offset(0)] @@ -173,7 +197,7 @@ pub fn test_10() { anon_11::block_ratio(anon_11.as_pointer()).write(0.75_f64); assert!(((anon_11::block_ratio(anon_11.as_pointer()).read()) == 0.75_f64)); } -#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] +#[derive(VaArg, FnPtrArg, Destructible, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(8)] pub struct anon_11 { #[offset(0)] @@ -196,7 +220,9 @@ impl Default for anon_11 { } } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(8)] pub struct p3_2_const_qualified_member_is_distinct_HasConstOverload { #[offset(0)] @@ -240,7 +266,9 @@ thread_local!( thread_local!( pub static rvalue_calls_14: Value = Rc::new(RefCell::new(0)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(4)] pub struct p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload { #[offset(0)] @@ -282,7 +310,18 @@ thread_local!( thread_local!( pub static rvalue_calls_17: Value = Rc::new(RefCell::new(0)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct p3_2_ref_qualified_members_are_distinct_HasRefQualifiedOverloads {} pub fn test_18() { @@ -320,7 +359,9 @@ pub fn test_18() { assert!((lvalue_calls_16.with(|rc| *rc.borrow()) == 1)); assert!((rvalue_calls_17.with(|rc| *rc.borrow()) == 2)); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(8)] pub struct p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload { #[offset(0)] @@ -367,7 +408,18 @@ thread_local!( thread_local!( pub static rvalue_calls_21: Value = Rc::new(RefCell::new(0)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct p3_4_ref_qualified_member_templates_are_distinct_HasRefQualifiedTemplateOverloads {} pub fn test_22() { @@ -397,14 +449,36 @@ pub fn test_22() { thread_local!( pub static friend_calls_23: Value = Rc::new(RefCell::new(0_i32)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct p4_friend_definition_defines_earlier_friend_declaration_DeclaresFriend {} pub fn shared_friend_24() -> i32 { (*friend_calls_23.with(Value::clone).borrow_mut()).prefix_inc(); return 7; } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct p4_friend_definition_defines_earlier_friend_declaration_DefinesFriend {} pub fn test_25() { @@ -436,7 +510,18 @@ pub fn test_30() { thread_local!( pub static function_calls_31: Value = Rc::new(RefCell::new(0_i32)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct p4_2_class_and_function_share_name_Reading { #[offset(0)] @@ -454,7 +539,18 @@ pub fn test_33() { assert!((({ Reading_32(reading.value,) }) == 5)); assert!((function_calls_31.with(|rc| *rc.borrow()) == 1)); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct p4_2_class_and_variable_share_name_Limit { #[offset(0)] diff --git a/tests/std/basic/basic.scope/out/unsafe/basic.scope.block.rs b/tests/std/basic/basic.scope/out/unsafe/basic.scope.block.rs index 18e44a6e70..7e2f0d8c21 100644 --- a/tests/std/basic/basic.scope/out/unsafe/basic.scope.block.rs +++ b/tests/std/basic/basic.scope/out/unsafe/basic.scope.block.rs @@ -15,7 +15,6 @@ pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(| VaArg, FnPtrArg, ZeroInitializationUnsafe, - DestructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -40,9 +39,6 @@ impl LifetimeTracked { (&raw mut self.uses).write(0); (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).prefix_inc(); } - pub unsafe fn destructor(&mut self) { - (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)).prefix_inc(); - } pub unsafe fn use_(&self) { (*(&raw const self.uses).cast_mut()).prefix_inc(); (*std::cell::LazyCell::force_mut(&mut *&raw mut useCount_3)).prefix_inc(); @@ -54,6 +50,11 @@ impl CopyConstructibleUnsafe for LifetimeTracked { (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)).prefix_inc(); } } +impl DestructibleUnsafe for LifetimeTracked { + unsafe fn destroy(&mut self) { + (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)).prefix_inc(); + } +} impl CopyAssignableUnsafe for LifetimeTracked { unsafe fn copy_assign(&mut self, _a0: *const LifetimeTracked) -> *mut LifetimeTracked { self.uses = (*_a0).uses; @@ -86,9 +87,7 @@ pub static mut else_runs_5: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0_i32 }); pub static mut dtorCount_6: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, -)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct p1_1_condition_variable_visible_in_else_ConvertsToBool { pub value: i32, } @@ -96,7 +95,9 @@ impl p1_1_condition_variable_visible_in_else_ConvertsToBool { pub unsafe fn to_bool(&self) -> bool { return ((self.value) != (0)); } - pub unsafe fn destructor(&mut self) { +} +impl DestructibleUnsafe for p1_1_condition_variable_visible_in_else_ConvertsToBool { + unsafe fn destroy(&mut self) { (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_6)).prefix_inc(); } } @@ -105,7 +106,7 @@ pub unsafe fn test_7() { let mut condition: p1_1_condition_variable_visible_in_else_ConvertsToBool = p1_1_condition_variable_visible_in_else_ConvertsToBool { value: 0 }; let _dtor_condition = std::mem::DropGuard::new(&raw mut condition, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); if (unsafe { p1_1_condition_variable_visible_in_else_ConvertsToBool::to_bool(&condition) }) { @@ -123,7 +124,7 @@ pub unsafe fn test_7() { let mut condition: p1_1_condition_variable_visible_in_else_ConvertsToBool = p1_1_condition_variable_visible_in_else_ConvertsToBool { value: 6 }; let _dtor_condition = std::mem::DropGuard::new(&raw mut condition, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); if (unsafe { p1_1_condition_variable_visible_in_else_ConvertsToBool::to_bool(&condition) }) { @@ -164,7 +165,7 @@ pub unsafe fn test_9() { __v }; let _dtor_scoped = std::mem::DropGuard::new(&raw mut scoped, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)) == (1))); { @@ -177,7 +178,7 @@ pub unsafe fn test_9() { __v }; let _dtor_scoped = std::mem::DropGuard::new(&raw mut scoped, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); } index.prefix_inc(); @@ -192,7 +193,7 @@ pub unsafe fn test_9() { __v }; let _dtor_scoped = std::mem::DropGuard::new(&raw mut scoped, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); } assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)) == (5))); @@ -205,7 +206,7 @@ pub unsafe fn test_9() { __v }; let _dtor_scoped = std::mem::DropGuard::new(&raw mut scoped, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); } assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)) == (6))); @@ -237,7 +238,7 @@ pub unsafe fn test_11() { __v }; let _dtor_tracked = std::mem::DropGuard::new(&raw mut tracked, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); { let mut tracked: LifetimeTracked = { @@ -246,7 +247,7 @@ pub unsafe fn test_11() { __v }; let _dtor_tracked = std::mem::DropGuard::new(&raw mut tracked, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)) == (2))); (unsafe { LifetimeTracked::use_(&tracked) }); diff --git a/tests/std/basic/basic.scope/out/unsafe/basic.scope.class.rs b/tests/std/basic/basic.scope/out/unsafe/basic.scope.class.rs index 0817e8c856..cd37496ec4 100644 --- a/tests/std/basic/basic.scope/out/unsafe/basic.scope.class.rs +++ b/tests/std/basic/basic.scope/out/unsafe/basic.scope.class.rs @@ -8,7 +8,9 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub static mut balance_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 50 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct p1_member_hides_namespace_variable_HasBalance { pub balance: i32, } @@ -46,7 +48,9 @@ pub unsafe fn test_1() { } pub static mut initial_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 100 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct p1_out_of_class_definition_is_in_class_scope_HasStaticTotal { pub held: i32, } diff --git a/tests/std/basic/basic.scope/out/unsafe/basic.scope.param.rs b/tests/std/basic/basic.scope/out/unsafe/basic.scope.param.rs index a604ce0621..e75522bcdb 100644 --- a/tests/std/basic/basic.scope/out/unsafe/basic.scope.param.rs +++ b/tests/std/basic/basic.scope/out/unsafe/basic.scope.param.rs @@ -8,7 +8,15 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, )] #[cpp_from(i32, construct, value)] pub struct p1_1_parameter_hides_member_in_constructor_HasMemberNamedLikeParameter { diff --git a/tests/std/basic/basic.scope/out/unsafe/basic.scope.pdecl.rs b/tests/std/basic/basic.scope/out/unsafe/basic.scope.pdecl.rs index 4896ad24fa..46aaac1871 100644 --- a/tests/std/basic/basic.scope/out/unsafe/basic.scope.pdecl.rs +++ b/tests/std/basic/basic.scope/out/unsafe/basic.scope.pdecl.rs @@ -19,7 +19,16 @@ pub unsafe fn test_0() { assert!(((level) == (5))); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p1_own_address_in_initializer_SelfLinked { pub next: *mut p1_own_address_in_initializer_SelfLinked, pub value: i32, @@ -72,7 +81,9 @@ pub type anon_4 = u32; pub const anon_4_limit: anon_4 = 13; pub const anon_4_above: anon_4 = 14; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct p9_func_declared_before_function_body_RecordsConstructorName { pub name: *const libc::c_char, } diff --git a/tests/std/basic/basic.scope/out/unsafe/basic.scope.scope.rs b/tests/std/basic/basic.scope/out/unsafe/basic.scope.scope.rs index ae5fdc3d18..c149f64d3d 100644 --- a/tests/std/basic/basic.scope/out/unsafe/basic.scope.scope.rs +++ b/tests/std/basic/basic.scope/out/unsafe/basic.scope.scope.rs @@ -42,7 +42,16 @@ pub const p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum_Size_small: pub const p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum_Size_large: p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum_Size = 8; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum {} impl p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum { pub unsafe fn scale(&self, mut count: i32) -> i32 { @@ -69,7 +78,16 @@ pub unsafe fn test_5() { } pub static mut count_6: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p2_12_class_name_in_own_scope_HasStaticCounter {} impl p2_12_class_name_in_own_scope_HasStaticCounter { pub unsafe fn bump() { @@ -85,7 +103,9 @@ pub unsafe fn test_7() { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut count_6)) == (6))); } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub union anon_8 { pub namespace_count: i32, pub namespace_ratio: f64, @@ -98,7 +118,9 @@ impl Default for anon_8 { pub static mut anon_8: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { ::default() }); #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub union anon_9 { pub member_count: i32, pub member_ratio: f64, @@ -109,7 +131,16 @@ impl Default for anon_9 { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p2_13_anonymous_union_members_in_parent_scope_HasAnonymousUnion { pub tag: i32, pub anon_9: anon_9, @@ -146,7 +177,9 @@ pub unsafe fn test_10() { assert!(((anon_11.block_ratio) == (0.75_f64))); } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub union anon_11 { pub block_count: i32, pub block_ratio: f64, @@ -157,7 +190,9 @@ impl Default for anon_11 { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct p3_2_const_qualified_member_is_distinct_HasConstOverload { pub plain_calls: i32, pub const_calls: i32, @@ -205,7 +240,9 @@ pub static mut explicit_calls_13: std::cell::LazyCell = pub static mut rvalue_calls_14: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload { pub base: i32, } @@ -257,7 +294,16 @@ pub static mut lvalue_calls_16: std::cell::LazyCell = pub static mut rvalue_calls_17: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p3_2_ref_qualified_members_are_distinct_HasRefQualifiedOverloads {} impl p3_2_ref_qualified_members_are_distinct_HasRefQualifiedOverloads { pub unsafe fn get_1(&mut self) -> i32 { @@ -297,7 +343,9 @@ pub unsafe fn test_18() { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut rvalue_calls_17)) == (2))); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload { pub plain_calls: i32, pub const_calls: i32, @@ -353,7 +401,16 @@ pub static mut lvalue_calls_20: std::cell::LazyCell = pub static mut rvalue_calls_21: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p3_4_ref_qualified_member_templates_are_distinct_HasRefQualifiedTemplateOverloads {} impl p3_4_ref_qualified_member_templates_are_distinct_HasRefQualifiedTemplateOverloads { pub unsafe fn get_1_int(&mut self, mut value: i32) -> i32 { @@ -392,14 +449,32 @@ pub unsafe fn test_22() { pub static mut friend_calls_23: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0_i32 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p4_friend_definition_defines_earlier_friend_declaration_DeclaresFriend {} pub unsafe fn shared_friend_24() -> i32 { (*std::cell::LazyCell::force_mut(&mut *&raw mut friend_calls_23)).prefix_inc(); return 7; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p4_friend_definition_defines_earlier_friend_declaration_DefinesFriend {} pub unsafe fn test_25() { assert!(((unsafe { shared_friend_24() }) == (7))); @@ -428,7 +503,16 @@ pub unsafe fn test_30() { pub static mut function_calls_31: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0_i32 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p4_2_class_and_function_share_name_Reading { pub value: i32, } @@ -445,7 +529,16 @@ pub unsafe fn test_33() { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut function_calls_31)) == (1))); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p4_2_class_and_variable_share_name_Limit { pub value: i32, } diff --git a/tests/std/basic/basic.start/out/refcount/basic.start.term-p1-exit.rs b/tests/std/basic/basic.start/out/refcount/basic.start.term-p1-exit.rs index 01cb6f518d..aae0286b89 100644 --- a/tests/std/basic/basic.start/out/refcount/basic.start.term-p1-exit.rs +++ b/tests/std/basic/basic.start/out/refcount/basic.start.term-p1-exit.rs @@ -6,14 +6,17 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Tracker { #[offset(0)] pub tag: i32, } +impl Destructible for Tracker { + fn destroy(this: &Ptr) { + printf!(b"destroy %d\n", (*this).with(|__s| __s.tag)); + } +} thread_local!( pub static global_0: Value = { let __static = Rc::new(RefCell::new({ @@ -22,7 +25,7 @@ thread_local!( Rc::try_unwrap(__v).ok().unwrap().into_inner() })); libcc2rs::register_static_destructor(|| { - Destructible::destroy(global_0.with(Value::clone).as_pointer()) + Destructible::destroy(&global_0.with(Value::clone).as_pointer()) }); __static }; @@ -37,7 +40,7 @@ pub fn exit_from_nested_call_1() { Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let _dtor_automatic = std::mem::DropGuard::new(automatic.clone(), |__p| { - Destructible::destroy(__p.as_pointer()) + Destructible::destroy(&__p.as_pointer()) }); libcc2rs::cpp2rust_exit(0); } @@ -49,7 +52,7 @@ thread_local!( Rc::try_unwrap(__v).ok().unwrap().into_inner() })); libcc2rs::register_static_destructor(|| { - Destructible::destroy(local_static_2.with(Value::clone).as_pointer()) + Destructible::destroy(&local_static_2.with(Value::clone).as_pointer()) }); __static }; @@ -65,16 +68,12 @@ fn main_0() -> i32 { } pub trait TrackerImpl { fn construct(&self, tag: i32); - fn destructor(&self); } impl TrackerImpl for Ptr { fn construct(&self, mut tag: i32) { field!((*self), tag).write(tag); printf!(b"construct %d\n", tag); } - fn destructor(&self) { - printf!(b"destroy %d\n", (*self).with(|__s| __s.tag)); - } } pub fn __cpp2rust_init_globals() { let _ = global_0.with(|_| ()); diff --git a/tests/std/basic/basic.start/out/refcount/basic.start.term.rs b/tests/std/basic/basic.start/out/refcount/basic.start.term.rs index 1b43ddf073..13e325123a 100644 --- a/tests/std/basic/basic.start/out/refcount/basic.start.term.rs +++ b/tests/std/basic/basic.start/out/refcount/basic.start.term.rs @@ -6,24 +6,41 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Tracker { #[offset(0)] pub tag: i32, } -#[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, -)] +impl Destructible for Tracker { + fn destroy(this: &Ptr) { + printf!(b"destroy %d\n", (*this).with(|__s| __s.tag)); + } +} +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct HoldsTracker { #[offset(0)] #[byte_size(4)] pub member: Tracker, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +impl Destructible for HoldsTracker { + fn destroy(this: &Ptr) { + Destructible::destroy(&field_ptr!(this, member)); + } +} +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct TriviallyDestructible { #[offset(0)] @@ -37,7 +54,7 @@ thread_local!( Rc::try_unwrap(__v).ok().unwrap().into_inner() })); libcc2rs::register_static_destructor(|| { - Destructible::destroy(global_0.with(Value::clone).as_pointer()) + Destructible::destroy(&global_0.with(Value::clone).as_pointer()) }); __static }; @@ -56,7 +73,7 @@ thread_local!( Rc::try_unwrap(__v).ok().unwrap().into_inner() })); libcc2rs::register_static_destructor(|| { - Destructible::destroy(never_constructed_2.with(Value::clone).as_pointer()) + Destructible::destroy(&never_constructed_2.with(Value::clone).as_pointer()) }); __static }; @@ -72,7 +89,7 @@ thread_local!( Rc::try_unwrap(__v).ok().unwrap().into_inner() })); libcc2rs::register_static_destructor(|| { - Destructible::destroy(before_6.with(Value::clone).as_pointer()) + Destructible::destroy(&before_6.with(Value::clone).as_pointer()) }); __static }; @@ -87,7 +104,7 @@ thread_local!( Rc::try_unwrap(__v).ok().unwrap().into_inner() })); libcc2rs::register_static_destructor(|| { - Destructible::destroy(after_7.with(Value::clone).as_pointer()) + Destructible::destroy(&after_7.with(Value::clone).as_pointer()) }); __static }; @@ -102,7 +119,7 @@ thread_local!( }, })); libcc2rs::register_static_destructor(|| { - Destructible::destroy(holder_8.with(Value::clone).as_pointer()) + Destructible::destroy(&holder_8.with(Value::clone).as_pointer()) }); __static }; @@ -111,7 +128,18 @@ thread_local!( pub static trivial_9: Value = Rc::new(RefCell::new(TriviallyDestructible { value: 6 })); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct p3_reverse_completion_order_WithStaticMember {} thread_local!( @@ -122,7 +150,7 @@ thread_local!( Rc::try_unwrap(__v).ok().unwrap().into_inner() })); libcc2rs::register_static_destructor(|| { - Destructible::destroy(member_10.with(Value::clone).as_pointer()) + Destructible::destroy(&member_10.with(Value::clone).as_pointer()) }); __static }; @@ -142,7 +170,7 @@ thread_local!( } ))); libcc2rs::register_static_destructor(|| { - Destructible::destroy(capturing_11.with(Value::clone).as_pointer()) + Destructible::destroy(&capturing_11.with(Value::clone).as_pointer()) }); __static }; @@ -169,7 +197,7 @@ thread_local!( Rc::try_unwrap(__v).ok().unwrap().into_inner() })); libcc2rs::register_static_destructor(|| { - Destructible::destroy(during_init_5.with(Value::clone).as_pointer()) + Destructible::destroy(&during_init_5.with(Value::clone).as_pointer()) }); __static }; @@ -182,7 +210,7 @@ thread_local!( Rc::try_unwrap(__v).ok().unwrap().into_inner() })); libcc2rs::register_static_destructor(|| { - Destructible::destroy(during_main_13.with(Value::clone).as_pointer()) + Destructible::destroy(&during_main_13.with(Value::clone).as_pointer()) }); __static }; @@ -197,17 +225,8 @@ fn main_0() -> i32 { printf!(b"return from main\n"); return 0; } -pub trait HoldsTrackerImpl { - fn destructor(&self); -} -impl HoldsTrackerImpl for Ptr { - fn destructor(&self) { - Destructible::destroy(field_ptr!(self, member)); - } -} pub trait TrackerImpl { fn construct(&self, tag: i32); - fn destructor(&self); fn touch(&self); } impl TrackerImpl for Ptr { @@ -215,9 +234,6 @@ impl TrackerImpl for Ptr { field!((*self), tag).write(tag); printf!(b"construct %d\n", tag); } - fn destructor(&self) { - printf!(b"destroy %d\n", (*self).with(|__s| __s.tag)); - } fn touch(&self) { printf!(b"touch %d\n", (*self).with(|__s| __s.tag)); } diff --git a/tests/std/basic/basic.start/out/unsafe/basic.start.term-p1-exit.rs b/tests/std/basic/basic.start/out/unsafe/basic.start.term-p1-exit.rs index 6de1b46967..804d3d61d8 100644 --- a/tests/std/basic/basic.start/out/unsafe/basic.start.term-p1-exit.rs +++ b/tests/std/basic/basic.start/out/unsafe/basic.start.term-p1-exit.rs @@ -7,9 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, -)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Tracker { pub tag: i32, } @@ -18,7 +16,9 @@ impl Tracker { (&raw mut self.tag).write(tag); (unsafe { libc::printf(c"construct %d\n".as_ptr() as *const libc::c_char, (tag)) }); } - pub unsafe fn destructor(&mut self) { +} +impl DestructibleUnsafe for Tracker { + unsafe fn destroy(&mut self) { (unsafe { libc::printf(c"destroy %d\n".as_ptr() as *const libc::c_char, (self.tag)) }); } } @@ -30,9 +30,7 @@ pub static mut global_0: std::cell::LazyCell = std::cell::LazyCell::new __v }; libcc2rs::register_static_destructor(|| { - DestructibleUnsafe::destroy(&raw mut *std::cell::LazyCell::force_mut( - &mut *&raw mut global_0, - )) + DestructibleUnsafe::destroy(std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) }); __static } @@ -50,7 +48,7 @@ pub unsafe fn exit_from_nested_call_1() { __v }; let _dtor_automatic = std::mem::DropGuard::new(&raw mut automatic, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); libcc2rs::cpp2rust_exit(0); } @@ -62,7 +60,7 @@ static mut local_static_2: std::cell::LazyCell = std::cell::LazyCell::n __v }; libcc2rs::register_static_destructor(|| { - DestructibleUnsafe::destroy(&raw mut *std::cell::LazyCell::force_mut( + DestructibleUnsafe::destroy(std::cell::LazyCell::force_mut( &mut *&raw mut local_static_2, )) }); diff --git a/tests/std/basic/basic.start/out/unsafe/basic.start.term.rs b/tests/std/basic/basic.start/out/unsafe/basic.start.term.rs index fe201bbee7..dc180aaa8a 100644 --- a/tests/std/basic/basic.start/out/unsafe/basic.start.term.rs +++ b/tests/std/basic/basic.start/out/unsafe/basic.start.term.rs @@ -7,9 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, -)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Tracker { pub tag: i32, } @@ -18,27 +16,36 @@ impl Tracker { (&raw mut self.tag).write(tag); (unsafe { libc::printf(c"construct %d\n".as_ptr() as *const libc::c_char, (tag)) }); } - pub unsafe fn destructor(&mut self) { - (unsafe { libc::printf(c"destroy %d\n".as_ptr() as *const libc::c_char, (self.tag)) }); - } pub unsafe fn touch(&self) { (unsafe { libc::printf(c"touch %d\n".as_ptr() as *const libc::c_char, (self.tag)) }); } } +impl DestructibleUnsafe for Tracker { + unsafe fn destroy(&mut self) { + (unsafe { libc::printf(c"destroy %d\n".as_ptr() as *const libc::c_char, (self.tag)) }); + } +} #[repr(C)] -#[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, -)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct HoldsTracker { pub member: Tracker, } -impl HoldsTracker { - pub unsafe fn destructor(&mut self) { - DestructibleUnsafe::destroy(&raw mut self.member); +impl DestructibleUnsafe for HoldsTracker { + unsafe fn destroy(&mut self) { + DestructibleUnsafe::destroy(&mut self.member); } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct TriviallyDestructible { pub value: i32, } @@ -50,9 +57,7 @@ pub static mut global_0: std::cell::LazyCell = std::cell::LazyCell::new __v }; libcc2rs::register_static_destructor(|| { - DestructibleUnsafe::destroy(&raw mut *std::cell::LazyCell::force_mut( - &mut *&raw mut global_0, - )) + DestructibleUnsafe::destroy(std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) }); __static } @@ -74,7 +79,7 @@ static mut never_constructed_2: std::cell::LazyCell = __v }; libcc2rs::register_static_destructor(|| { - DestructibleUnsafe::destroy(&raw mut *std::cell::LazyCell::force_mut( + DestructibleUnsafe::destroy(std::cell::LazyCell::force_mut( &mut *&raw mut never_constructed_2, )) }); @@ -92,9 +97,7 @@ pub static mut before_6: std::cell::LazyCell = std::cell::LazyCell::new __v }; libcc2rs::register_static_destructor(|| { - DestructibleUnsafe::destroy(&raw mut *std::cell::LazyCell::force_mut( - &mut *&raw mut before_6, - )) + DestructibleUnsafe::destroy(std::cell::LazyCell::force_mut(&mut *&raw mut before_6)) }); __static } @@ -109,9 +112,7 @@ pub static mut after_7: std::cell::LazyCell = std::cell::LazyCell::new( __v }; libcc2rs::register_static_destructor(|| { - DestructibleUnsafe::destroy(&raw mut *std::cell::LazyCell::force_mut( - &mut *&raw mut after_7, - )) + DestructibleUnsafe::destroy(std::cell::LazyCell::force_mut(&mut *&raw mut after_7)) }); __static } @@ -126,9 +127,7 @@ pub static mut holder_8: std::cell::LazyCell = std::cell::LazyCell }, }; libcc2rs::register_static_destructor(|| { - DestructibleUnsafe::destroy(&raw mut *std::cell::LazyCell::force_mut( - &mut *&raw mut holder_8, - )) + DestructibleUnsafe::destroy(std::cell::LazyCell::force_mut(&mut *&raw mut holder_8)) }); __static } @@ -136,7 +135,16 @@ pub static mut holder_8: std::cell::LazyCell = std::cell::LazyCell pub static mut trivial_9: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { TriviallyDestructible { value: 6 } }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p3_reverse_completion_order_WithStaticMember {} pub static mut member_10: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { { @@ -146,9 +154,7 @@ pub static mut member_10: std::cell::LazyCell = std::cell::LazyCell::ne __v }; libcc2rs::register_static_destructor(|| { - DestructibleUnsafe::destroy(&raw mut *std::cell::LazyCell::force_mut( - &mut *&raw mut member_10, - )) + DestructibleUnsafe::destroy(std::cell::LazyCell::force_mut(&mut *&raw mut member_10)) }); __static } @@ -169,7 +175,7 @@ pub static mut capturing_11: std::cell::LazyCell i32>> = } ); libcc2rs::register_static_destructor(|| { - DestructibleUnsafe::destroy(&raw mut *std::cell::LazyCell::force_mut( + DestructibleUnsafe::destroy(std::cell::LazyCell::force_mut( &mut *&raw mut capturing_11, )) }); @@ -205,7 +211,7 @@ static mut during_init_5: std::cell::LazyCell = std::cell::LazyCell::ne __v }; libcc2rs::register_static_destructor(|| { - DestructibleUnsafe::destroy(&raw mut *std::cell::LazyCell::force_mut( + DestructibleUnsafe::destroy(std::cell::LazyCell::force_mut( &mut *&raw mut during_init_5, )) }); @@ -220,7 +226,7 @@ static mut during_main_13: std::cell::LazyCell = std::cell::LazyCell::n __v }; libcc2rs::register_static_destructor(|| { - DestructibleUnsafe::destroy(&raw mut *std::cell::LazyCell::force_mut( + DestructibleUnsafe::destroy(std::cell::LazyCell::force_mut( &mut *&raw mut during_main_13, )) }); diff --git a/tests/std/basic/basic.types/out/refcount/basic.types.general.rs b/tests/std/basic/basic.types/out/refcount/basic.types.general.rs index fcb58faacc..a3dc69da99 100644 --- a/tests/std/basic/basic.types/out/refcount/basic.types.general.rs +++ b/tests/std/basic/basic.types/out/refcount/basic.types.general.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct p2_pointer_to_data_member_bytes_round_trip_HasTwoInts { #[offset(0)] @@ -69,7 +80,18 @@ pub fn test_0() { }; assert!(({ ((*null_pm.borrow()) == -1_isize) })); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct p3_pointer_to_data_member_bytes_copied_to_other_object_HasTwoInts { #[offset(0)] diff --git a/tests/std/basic/basic.types/out/unsafe/basic.types.general.rs b/tests/std/basic/basic.types/out/unsafe/basic.types.general.rs index e07c4f58a9..db0fc740f3 100644 --- a/tests/std/basic/basic.types/out/unsafe/basic.types.general.rs +++ b/tests/std/basic/basic.types/out/unsafe/basic.types.general.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p2_pointer_to_data_member_bytes_round_trip_HasTwoInts { pub first: i32, pub second: i32, @@ -76,7 +85,16 @@ pub unsafe fn test_0() { assert!(((null_pm) == -1_isize)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p3_pointer_to_data_member_bytes_copied_to_other_object_HasTwoInts { pub first: i32, pub second: i32, diff --git a/tests/std/basic/out/refcount/basic.def.odr.rs b/tests/std/basic/out/refcount/basic.def.odr.rs index 6dd78c9dd9..0195376e43 100644 --- a/tests/std/basic/out/refcount/basic.def.odr.rs +++ b/tests/std/basic/out/refcount/basic.def.odr.rs @@ -16,6 +16,7 @@ thread_local!( VaArg, FnPtrArg, CppFrom, + Destructible, MoveConstructible, MoveAssignable, Swappable, @@ -71,7 +72,6 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Destructible, MoveConstructible, MoveAssignable, Swappable, @@ -107,6 +107,11 @@ impl CopyConstructible for LifetimeTracked { (*copyCount_2.with(Value::clone).borrow_mut()).prefix_inc(); } } +impl Destructible for LifetimeTracked { + fn destroy(this: &Ptr) { + (*dtorCount_3.with(Value::clone).borrow_mut()).prefix_inc(); + } +} impl CopyAssignable for LifetimeTracked { fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { field!((*this), uses).write(_a0.with(|__s| __s.uses)); @@ -278,7 +283,18 @@ thread_local!( pub trait p4_1_pure_virtual_without_definition_HasPureVirtual { fn f(&mut self); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct p4_1_pure_virtual_without_definition_OverridesPureVirtual {} pub fn test_11() { @@ -298,7 +314,7 @@ thread_local!( Rc::try_unwrap(__v).ok().unwrap().into_inner() })); libcc2rs::register_static_destructor(|| { - Destructible::destroy(global_12.with(Value::clone).as_pointer()) + Destructible::destroy(&global_12.with(Value::clone).as_pointer()) }); __static }; @@ -323,7 +339,7 @@ pub fn test_14() { Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let _dtor_t = - std::mem::DropGuard::new(t.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(t.clone(), |__p| Destructible::destroy(&__p.as_pointer())); let r: Ptr = t.as_pointer(); let f: Value> = Rc::new(RefCell::new(lambda!( { @@ -339,7 +355,7 @@ pub fn test_14() { } ))); let _dtor_f = - std::mem::DropGuard::new(f.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(f.clone(), |__p| Destructible::destroy(&__p.as_pointer())); assert!((copyCount_2.with(|rc| *rc.borrow()) == 1)); ({ (*f.borrow()).call() }); assert!((copyCount_2.with(|rc| *rc.borrow()) == 1)); @@ -409,6 +425,7 @@ thread_local!( VaArg, FnPtrArg, CppFrom, + Destructible, MoveConstructible, MoveAssignable, Swappable, @@ -494,7 +511,6 @@ pub fn test_19() { ZeroInitialization, VaArg, FnPtrArg, - Destructible, CopyConstructible, MoveConstructible, MoveAssignable, @@ -520,6 +536,12 @@ impl CopyAssignable for p6_unevaluated_binding_needs_no_capture_HasTwoMembers { return (*this).clone(); } } +impl Destructible for p6_unevaluated_binding_needs_no_capture_HasTwoMembers { + fn destroy(this: &Ptr) { + Destructible::destroy(&field_ptr!(this, b)); + Destructible::destroy(&field_ptr!(this, a)); + } +} pub fn test_20() { ({ LifetimeTracked::reset() }); let p: Value = Rc::new(RefCell::new( @@ -539,7 +561,7 @@ pub fn test_20() { }, )); let _dtor_p = - std::mem::DropGuard::new(p.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(p.clone(), |__p| Destructible::destroy(&__p.as_pointer())); let __decomp_21: Ptr = p.as_pointer(); let f: Value usize>> = Rc::new(RefCell::new(FnPtr:: usize>::new(|| -> usize { @@ -559,7 +581,6 @@ pub fn test_20() { ZeroInitialization, VaArg, FnPtrArg, - Destructible, CopyConstructible, MoveConstructible, MoveAssignable, @@ -583,6 +604,11 @@ impl CopyAssignable for p7_member_access_captures_this_HasMemberUsedInLambda { return (*this).clone(); } } +impl Destructible for p7_member_access_captures_this_HasMemberUsedInLambda { + fn destroy(this: &Ptr) { + Destructible::destroy(&field_ptr!(this, x)); + } +} impl Default for p7_member_access_captures_this_HasMemberUsedInLambda { fn default() -> Self { { @@ -599,7 +625,7 @@ pub fn test_22() { ::default(), )); let _dtor_c = - std::mem::DropGuard::new(c.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(c.clone(), |__p| Destructible::destroy(&__p.as_pointer())); let f: Value i32>> = Rc::new(RefCell::new( ({ p7_member_access_captures_this_HasMemberUsedInLambdaImpl::makeLambda(&c.as_pointer()) }), )); @@ -618,7 +644,6 @@ pub fn test_22() { ZeroInitialization, VaArg, FnPtrArg, - Destructible, CopyConstructible, MoveConstructible, MoveAssignable, @@ -640,13 +665,18 @@ impl CopyAssignable for p7_unevaluated_this_needs_no_capture_HasMemberUsedInLamb return (*this).clone(); } } +impl Destructible for p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda { + fn destroy(this: &Ptr) { + Destructible::destroy(&field_ptr!(this, x)); + } +} pub fn test_23() { ({ LifetimeTracked::reset() }); let c: Value = Rc::new( RefCell::new(::default()), ); let _dtor_c = - std::mem::DropGuard::new(c.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(c.clone(), |__p| Destructible::destroy(&__p.as_pointer())); let f: Value usize>> = Rc::new(RefCell::new( ({ p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambdaImpl::sizer(&c.as_pointer()) @@ -679,7 +709,9 @@ pub fn test_26() { thread_local!( pub static t_ctors_27: Value = Rc::new(RefCell::new(0_i32)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(1)] pub struct p9_destructor_not_potentially_invoked_HasUndefinedDestructor {} impl Default for p9_destructor_not_potentially_invoked_HasUndefinedDestructor { @@ -715,7 +747,7 @@ pub fn test_28() { thread_local!( pub static ctor_calls_29: Value = Rc::new(RefCell::new(0_i32)); ); -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible)] #[byte_size(4)] pub struct p9_unused_copy_constructor_HasUndefinedCopyCtor { #[offset(0)] @@ -751,7 +783,9 @@ pub fn test_31() { thread_local!( pub static m_ctors_32: Value = Rc::new(RefCell::new(0_i32)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(1)] pub struct p9_unused_implicit_assignment_HasUndefinedCopyAssignment {} impl Default for p9_unused_implicit_assignment_HasUndefinedCopyAssignment { @@ -770,7 +804,18 @@ impl Default for p9_unused_implicit_assignment_HasUndefinedCopyAssignment { } } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct p9_unused_implicit_assignment_HasMemberWithUndefinedCopyAssignment { #[offset(0)] @@ -925,7 +970,6 @@ impl HasConstexprCtorImpl for Ptr { } pub trait LifetimeTrackedImpl { fn construct(&self); - fn destructor(&self); fn use_(&self); } impl LifetimeTrackedImpl for Ptr { @@ -933,9 +977,6 @@ impl LifetimeTrackedImpl for Ptr { field!((*self), uses).write(0); (*ctorCount_1.with(Value::clone).borrow_mut()).prefix_inc(); } - fn destructor(&self) { - (*dtorCount_3.with(Value::clone).borrow_mut()).prefix_inc(); - } fn use_(&self) { field!((*self), uses).with_mut(|__v| { __v.prefix_inc(); @@ -954,20 +995,8 @@ impl p5_2_mutable_subobject_is_odr_used_HasMutableMemberImpl field!((*self), scratch).write(0); } } -pub trait p6_unevaluated_binding_needs_no_capture_HasTwoMembersImpl { - fn destructor(&self); -} -impl p6_unevaluated_binding_needs_no_capture_HasTwoMembersImpl - for Ptr -{ - fn destructor(&self) { - Destructible::destroy(field_ptr!(self, b)); - Destructible::destroy(field_ptr!(self, a)); - } -} pub trait p7_member_access_captures_this_HasMemberUsedInLambdaImpl { fn makeLambda(&self) -> FnPtr i32>; - fn destructor(&self); } impl p7_member_access_captures_this_HasMemberUsedInLambdaImpl for Ptr @@ -984,13 +1013,9 @@ impl p7_member_access_captures_this_HasMemberUsedInLambdaImpl } ); } - fn destructor(&self) { - Destructible::destroy(field_ptr!(self, x)); - } } pub trait p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambdaImpl { fn sizer(&self) -> FnPtr usize>; - fn destructor(&self); } impl p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambdaImpl for Ptr @@ -1002,9 +1027,6 @@ impl p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambdaImpl } }); } - fn destructor(&self) { - Destructible::destroy(field_ptr!(self, x)); - } } pub trait p9_destructor_not_potentially_invoked_HasUndefinedDestructorImpl { fn construct(&self); diff --git a/tests/std/basic/out/unsafe/basic.def.odr.rs b/tests/std/basic/out/unsafe/basic.def.odr.rs index df47ba28ea..efad10ac47 100644 --- a/tests/std/basic/out/unsafe/basic.def.odr.rs +++ b/tests/std/basic/out/unsafe/basic.def.odr.rs @@ -13,6 +13,7 @@ pub static mut copyCount_0: std::cell::LazyCell = std::cell::LazyCell::new( FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DestructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -60,7 +61,6 @@ pub static mut useCount_4: std::cell::LazyCell = std::cell::LazyCell::new(| VaArg, FnPtrArg, ZeroInitializationUnsafe, - DestructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -85,9 +85,6 @@ impl LifetimeTracked { (&raw mut self.uses).write(0); (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_1)).prefix_inc(); } - pub unsafe fn destructor(&mut self) { - (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_3)).prefix_inc(); - } pub unsafe fn use_(&self) { (*(&raw const self.uses).cast_mut()).prefix_inc(); (*std::cell::LazyCell::force_mut(&mut *&raw mut useCount_4)).prefix_inc(); @@ -99,6 +96,11 @@ impl CopyConstructibleUnsafe for LifetimeTracked { (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_2)).prefix_inc(); } } +impl DestructibleUnsafe for LifetimeTracked { + unsafe fn destroy(&mut self) { + (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_3)).prefix_inc(); + } +} impl CopyAssignableUnsafe for LifetimeTracked { unsafe fn copy_assign(&mut self, _a0: *const LifetimeTracked) -> *mut LifetimeTracked { self.uses = (*_a0).uses; @@ -249,7 +251,16 @@ pub unsafe trait p4_1_pure_virtual_without_definition_HasPureVirtual { unsafe fn f(&mut self); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p4_1_pure_virtual_without_definition_OverridesPureVirtual {} pub unsafe fn test_11() { let mut d: p4_1_pure_virtual_without_definition_OverridesPureVirtual = @@ -268,7 +279,7 @@ pub static mut global_12: std::cell::LazyCell = __v }; libcc2rs::register_static_destructor(|| { - DestructibleUnsafe::destroy(&raw mut *std::cell::LazyCell::force_mut( + DestructibleUnsafe::destroy(std::cell::LazyCell::force_mut( &mut *&raw mut global_12, )) }); @@ -297,7 +308,7 @@ pub unsafe fn test_14() { __v }; let _dtor_t = std::mem::DropGuard::new(&raw mut t, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); let r: *mut LifetimeTracked = &mut t; let mut f: FnPtr = lambda_unsafe!( @@ -313,7 +324,7 @@ pub unsafe fn test_14() { } ); let _dtor_f = std::mem::DropGuard::new(&raw mut f, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_2)) == (1))); (unsafe { f.call() }); @@ -378,6 +389,7 @@ pub static mut copies_18: std::cell::LazyCell = std::cell::LazyCell::new(|| FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DestructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -457,7 +469,6 @@ pub unsafe fn test_19() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DestructibleUnsafe, CopyConstructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, @@ -484,10 +495,10 @@ impl CopyAssignableUnsafe for p6_unevaluated_binding_needs_no_capture_HasTwoMemb return &mut (*(self as *mut p6_unevaluated_binding_needs_no_capture_HasTwoMembers)); } } -impl p6_unevaluated_binding_needs_no_capture_HasTwoMembers { - pub unsafe fn destructor(&mut self) { - DestructibleUnsafe::destroy(&raw mut self.b); - DestructibleUnsafe::destroy(&raw mut self.a); +impl DestructibleUnsafe for p6_unevaluated_binding_needs_no_capture_HasTwoMembers { + unsafe fn destroy(&mut self) { + DestructibleUnsafe::destroy(&mut self.b); + DestructibleUnsafe::destroy(&mut self.a); } } pub unsafe fn test_20() { @@ -506,7 +517,7 @@ pub unsafe fn test_20() { }, }; let _dtor_p = std::mem::DropGuard::new(&raw mut p, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); let __decomp_21: *mut p6_unevaluated_binding_needs_no_capture_HasTwoMembers = &mut p; let mut f: FnPtr usize> = FnPtr:: usize>::new(|| -> usize { @@ -525,7 +536,6 @@ pub unsafe fn test_20() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DestructibleUnsafe, CopyConstructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, @@ -562,9 +572,9 @@ impl CopyAssignableUnsafe for p7_member_access_captures_this_HasMemberUsedInLamb return &mut (*(self as *mut p7_member_access_captures_this_HasMemberUsedInLambda)); } } -impl p7_member_access_captures_this_HasMemberUsedInLambda { - pub unsafe fn destructor(&mut self) { - DestructibleUnsafe::destroy(&raw mut self.x); +impl DestructibleUnsafe for p7_member_access_captures_this_HasMemberUsedInLambda { + unsafe fn destroy(&mut self) { + DestructibleUnsafe::destroy(&mut self.x); } } impl Default for p7_member_access_captures_this_HasMemberUsedInLambda { @@ -582,7 +592,7 @@ pub unsafe fn test_22() { let mut c: p7_member_access_captures_this_HasMemberUsedInLambda = ::default(); let _dtor_c = std::mem::DropGuard::new(&raw mut c, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); let mut f: FnPtr i32> = (unsafe { p7_member_access_captures_this_HasMemberUsedInLambda::makeLambda(&mut c) }); @@ -600,7 +610,6 @@ pub unsafe fn test_22() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DestructibleUnsafe, CopyConstructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, @@ -631,9 +640,9 @@ impl CopyAssignableUnsafe for p7_unevaluated_this_needs_no_capture_HasMemberUsed return &mut (*(self as *mut p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda)); } } -impl p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda { - pub unsafe fn destructor(&mut self) { - DestructibleUnsafe::destroy(&raw mut self.x); +impl DestructibleUnsafe for p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda { + unsafe fn destroy(&mut self) { + DestructibleUnsafe::destroy(&mut self.x); } } pub unsafe fn test_23() { @@ -641,7 +650,7 @@ pub unsafe fn test_23() { let mut c: p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda = ::default(); let _dtor_c = std::mem::DropGuard::new(&raw mut c, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); let mut f: FnPtr usize> = (unsafe { p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda::sizer(&mut c) }); @@ -672,7 +681,9 @@ pub unsafe fn test_26() { } pub static mut t_ctors_27: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0_i32 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct p9_destructor_not_potentially_invoked_HasUndefinedDestructor {} impl p9_destructor_not_potentially_invoked_HasUndefinedDestructor { pub unsafe fn construct(&mut self) { @@ -705,7 +716,7 @@ pub unsafe fn test_28() { pub static mut ctor_calls_29: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0_i32 }); #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe)] pub struct p9_unused_copy_constructor_HasUndefinedCopyCtor { pub value: i32, } @@ -742,7 +753,9 @@ pub unsafe fn test_31() { } pub static mut m_ctors_32: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0_i32 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct p9_unused_implicit_assignment_HasUndefinedCopyAssignment {} impl p9_unused_implicit_assignment_HasUndefinedCopyAssignment { pub unsafe fn construct(&mut self) { @@ -762,7 +775,16 @@ impl Default for p9_unused_implicit_assignment_HasUndefinedCopyAssignment { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p9_unused_implicit_assignment_HasMemberWithUndefinedCopyAssignment { pub m: p9_unused_implicit_assignment_HasUndefinedCopyAssignment, } diff --git a/tests/std/class/class.init/out/refcount/class.base.init.rs b/tests/std/class/class.init/out/refcount/class.base.init.rs index b187800cb2..596e18bd29 100644 --- a/tests/std/class/class.init/out/refcount/class.base.init.rs +++ b/tests/std/class/class.init/out/refcount/class.base.init.rs @@ -7,7 +7,17 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + Copyable, + Default, )] #[cpp_from(i32, construct, value)] #[byte_size(8)] diff --git a/tests/std/class/class.init/out/unsafe/class.base.init.rs b/tests/std/class/class.init/out/unsafe/class.base.init.rs index 4929dcb8a8..38e8c31df3 100644 --- a/tests/std/class/class.init/out/unsafe/class.base.init.rs +++ b/tests/std/class/class.init/out/unsafe/class.base.init.rs @@ -8,7 +8,15 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, )] #[cpp_from(i32, construct, value)] pub struct p13_3_member_reads_earlier_member_Pair { diff --git a/tests/std/class/class.mem/class.conv/out/refcount/class.conv.ctor.rs b/tests/std/class/class.mem/class.conv/out/refcount/class.conv.ctor.rs index ae1a474f86..1f0581af39 100644 --- a/tests/std/class/class.mem/class.conv/out/refcount/class.conv.ctor.rs +++ b/tests/std/class/class.mem/class.conv/out/refcount/class.conv.ctor.rs @@ -7,7 +7,17 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + Copyable, + Default, )] #[cpp_from(i32, construct_2, value)] #[byte_size(4)] diff --git a/tests/std/class/class.mem/class.conv/out/refcount/class.conv.fct.rs b/tests/std/class/class.mem/class.conv/out/refcount/class.conv.fct.rs index 70ea5595a8..e8f37be34b 100644 --- a/tests/std/class/class.mem/class.conv/out/refcount/class.conv.fct.rs +++ b/tests/std/class/class.mem/class.conv/out/refcount/class.conv.fct.rs @@ -7,7 +7,17 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + Copyable, + Default, )] #[cpp_into(i64, to_i64, mut_ptr)] #[byte_size(8)] diff --git a/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.ctor.rs b/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.ctor.rs index 5d05bfa9d7..9712fbd1eb 100644 --- a/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.ctor.rs +++ b/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.ctor.rs @@ -13,7 +13,15 @@ impl p1_template_constructor_from_own_type_Probe { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, )] #[cpp_from(i32, construct_2, value)] pub struct p1_template_constructor_from_own_type_Probe { diff --git a/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.fct.rs b/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.fct.rs index 55c1c91a29..4bf4ef98d9 100644 --- a/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.fct.rs +++ b/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.fct.rs @@ -8,7 +8,15 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, )] #[cpp_into(i64, to_i64, mut_ptr)] pub struct p2_non_const_conversion_function_Gauge { diff --git a/tests/std/class/class.mem/class.ctor/out/refcount/class.copy.ctor.rs b/tests/std/class/class.mem/class.ctor/out/refcount/class.copy.ctor.rs index 4a2c5bcd44..93b69a534b 100644 --- a/tests/std/class/class.mem/class.ctor/out/refcount/class.copy.ctor.rs +++ b/tests/std/class/class.mem/class.ctor/out/refcount/class.copy.ctor.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Destructible, Default)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct p11_defaulted_move_constructor_is_trivial_MoveOnly { diff --git a/tests/std/class/class.mem/class.ctor/out/unsafe/class.copy.ctor.rs b/tests/std/class/class.mem/class.ctor/out/unsafe/class.copy.ctor.rs index 8bb6cd8454..99e2b4b45b 100644 --- a/tests/std/class/class.mem/class.ctor/out/unsafe/class.copy.ctor.rs +++ b/tests/std/class/class.mem/class.ctor/out/unsafe/class.copy.ctor.rs @@ -7,7 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, Default)] #[cpp_from(i32, construct, value)] pub struct p11_defaulted_move_constructor_is_trivial_MoveOnly { pub value: i32, diff --git a/tests/std/class/class.mem/out/refcount/class.free.rs b/tests/std/class/class.mem/out/refcount/class.free.rs index bf08ba06f5..2463097288 100644 --- a/tests/std/class/class.mem/out/refcount/class.free.rs +++ b/tests/std/class/class.mem/out/refcount/class.free.rs @@ -9,7 +9,18 @@ use std::rc::{Rc, Weak}; thread_local!( pub static allocations_0: Value = Rc::new(RefCell::new(0)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct p1_allocation_function_is_static_Allocates {} impl p1_allocation_function_is_static_Allocates { @@ -46,7 +57,18 @@ pub fn test_1() { thread_local!( pub static deallocations_2: Value = Rc::new(RefCell::new(0)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct p3_deallocation_function_is_static_Deallocates {} impl p3_deallocation_function_is_static_Deallocates { diff --git a/tests/std/class/class.mem/out/refcount/class.mem.general.rs b/tests/std/class/class.mem/out/refcount/class.mem.general.rs index ca7835a283..658334d06e 100644 --- a/tests/std/class/class.mem/out/refcount/class.mem.general.rs +++ b/tests/std/class/class.mem/out/refcount/class.mem.general.rs @@ -14,7 +14,9 @@ pub fn minimum_1() -> i32 { } pub type anon_2 = u32; pub const anon_2_reserve: anon_2 = 30; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(4)] pub struct p7_1_function_body_names_later_member_HasLaterMembers { #[offset(0)] @@ -43,7 +45,9 @@ thread_local!( thread_local!( pub static step_5: Value = Rc::new(RefCell::new(4)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(4)] pub struct p7_2_default_argument_names_later_member_HasLaterStaticStep { #[offset(0)] diff --git a/tests/std/class/class.mem/out/unsafe/class.free.rs b/tests/std/class/class.mem/out/unsafe/class.free.rs index fcde99ecea..38ed565fcf 100644 --- a/tests/std/class/class.mem/out/unsafe/class.free.rs +++ b/tests/std/class/class.mem/out/unsafe/class.free.rs @@ -8,7 +8,16 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub static mut allocations_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p1_allocation_function_is_static_Allocates {} impl p1_allocation_function_is_static_Allocates { pub unsafe fn operator_new(mut size: usize) -> *mut ::libc::c_void { @@ -42,7 +51,16 @@ pub unsafe fn test_1() { pub static mut deallocations_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p3_deallocation_function_is_static_Deallocates {} impl p3_deallocation_function_is_static_Deallocates { pub unsafe fn operator_delete(mut ptr: *mut ::libc::c_void) { diff --git a/tests/std/class/class.mem/out/unsafe/class.mem.general.rs b/tests/std/class/class.mem/out/unsafe/class.mem.general.rs index df4dbfc5a9..1c483add84 100644 --- a/tests/std/class/class.mem/out/unsafe/class.mem.general.rs +++ b/tests/std/class/class.mem/out/unsafe/class.mem.general.rs @@ -13,7 +13,9 @@ pub unsafe fn minimum_1() -> i32 { pub type anon_2 = u32; pub const anon_2_reserve: anon_2 = 30; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct p7_1_function_body_names_later_member_HasLaterMembers { pub stock: i32, } @@ -46,7 +48,9 @@ pub unsafe fn test_3() { pub static mut step_4: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 100 }); pub static mut step_5: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 4 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct p7_2_default_argument_names_later_member_HasLaterStaticStep { pub total: i32, } diff --git a/tests/std/dcl.dcl/dcl.decl/dcl.init/out/refcount/dcl.init.general-p6.2-padding-bits.rs b/tests/std/dcl.dcl/dcl.decl/dcl.init/out/refcount/dcl.init.general-p6.2-padding-bits.rs index 073853a966..429b3a97c5 100644 --- a/tests/std/dcl.dcl/dcl.decl/dcl.init/out/refcount/dcl.init.general-p6.2-padding-bits.rs +++ b/tests/std/dcl.dcl/dcl.decl/dcl.init/out/refcount/dcl.init.general-p6.2-padding-bits.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct p6_2_zero_initialized_padding_Padded { #[offset(0)] @@ -14,7 +25,18 @@ pub struct p6_2_zero_initialized_padding_Padded { #[offset(4)] pub number: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct p6_2_zero_initialized_padding_TailPadded { #[offset(0)] @@ -22,7 +44,18 @@ pub struct p6_2_zero_initialized_padding_TailPadded { #[offset(4)] pub letter: i8, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(16)] pub struct p6_2_zero_initialized_padding_HoldsPadded { #[offset(0)] diff --git a/tests/std/dcl.dcl/dcl.decl/dcl.init/out/refcount/dcl.init.general.rs b/tests/std/dcl.dcl/dcl.decl/dcl.init/out/refcount/dcl.init.general.rs index 8421d91e0f..443be25b98 100644 --- a/tests/std/dcl.dcl/dcl.decl/dcl.init/out/refcount/dcl.init.general.rs +++ b/tests/std/dcl.dcl/dcl.decl/dcl.init/out/refcount/dcl.init.general.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct p6_1_zero_initialized_pointer_to_member_HasTwoInts { #[offset(0)] @@ -14,7 +25,9 @@ pub struct p6_1_zero_initialized_pointer_to_member_HasTwoInts { #[offset(4)] pub second: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(8)] pub struct p6_1_zero_initialized_pointer_to_member_HoldsSelector { #[offset(0)] @@ -111,7 +124,9 @@ pub fn test_12() { thread_local!( static counter_11: Value = Rc::new(RefCell::new(0_i32)); ); -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(24)] pub struct p6_2_zero_initialized_class_Inner { #[offset(0)] @@ -122,7 +137,7 @@ pub struct p6_2_zero_initialized_class_Inner { #[byte_size(8)] pub pointer: Ptr, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(96)] pub struct p6_2_zero_initialized_class_Outer { #[offset(0)] @@ -193,7 +208,7 @@ pub fn test_15() { ({ check_14((heap_outer).clone()) }); heap_outer.delete(); } -#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] +#[derive(VaArg, FnPtrArg, Destructible, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(8)] pub struct p6_3_zero_initialized_union_Number { #[offset(0)] @@ -230,7 +245,18 @@ pub fn test_17() { Rc::new(RefCell::new(::default())); assert!(((p6_3_zero_initialized_union_Number::integer(value_number.as_pointer()).read()) == 0)); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct p6_4_zero_initialized_array_Pair { #[offset(0)] @@ -334,7 +360,9 @@ pub fn test_21() { } heap_numbers.delete(); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(8)] pub struct p9_1_2_zero_then_default_initialized_WithDefaultMember { #[offset(0)] @@ -352,7 +380,9 @@ impl Default for p9_1_2_zero_then_default_initialized_WithDefaultMember { } } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(4)] pub struct p9_1_2_zero_then_default_initialized_LeavesMemberAlone { #[offset(0)] @@ -374,7 +404,18 @@ impl Default for p9_1_2_zero_then_default_initialized_LeavesMemberAlone { } } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAlone { #[offset(0)] diff --git a/tests/std/dcl.dcl/dcl.decl/dcl.init/out/unsafe/dcl.init.general-p6.2-padding-bits.rs b/tests/std/dcl.dcl/dcl.decl/dcl.init/out/unsafe/dcl.init.general-p6.2-padding-bits.rs index a6a85380b8..36f49890f4 100644 --- a/tests/std/dcl.dcl/dcl.decl/dcl.init/out/unsafe/dcl.init.general-p6.2-padding-bits.rs +++ b/tests/std/dcl.dcl/dcl.decl/dcl.init/out/unsafe/dcl.init.general-p6.2-padding-bits.rs @@ -7,19 +7,46 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p6_2_zero_initialized_padding_Padded { pub letter: libc::c_char, pub number: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p6_2_zero_initialized_padding_TailPadded { pub number: i32, pub letter: libc::c_char, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p6_2_zero_initialized_padding_HoldsPadded { pub letter: libc::c_char, pub inner: p6_2_zero_initialized_padding_Padded, diff --git a/tests/std/dcl.dcl/dcl.decl/dcl.init/out/unsafe/dcl.init.general.rs b/tests/std/dcl.dcl/dcl.decl/dcl.init/out/unsafe/dcl.init.general.rs index fcf1ba56e1..0257a1f952 100644 --- a/tests/std/dcl.dcl/dcl.decl/dcl.init/out/unsafe/dcl.init.general.rs +++ b/tests/std/dcl.dcl/dcl.decl/dcl.init/out/unsafe/dcl.init.general.rs @@ -7,13 +7,24 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p6_1_zero_initialized_pointer_to_member_HasTwoInts { pub first: i32, pub second: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct p6_1_zero_initialized_pointer_to_member_HoldsSelector { pub selector: isize, } @@ -107,14 +118,32 @@ pub unsafe fn test_12() { } static mut counter_11: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0_i32 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p6_2_zero_initialized_class_Inner { pub number: i32, pub real: f64, pub pointer: *mut i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p6_2_zero_initialized_class_Outer { pub letter: libc::c_char, pub inner: p6_2_zero_initialized_class_Inner, @@ -166,7 +195,9 @@ pub unsafe fn test_15() { }; } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub union p6_3_zero_initialized_union_Number { pub integer: i32, pub bytes: [libc::c_char; 8], @@ -185,7 +216,16 @@ pub unsafe fn test_17() { assert!(((value_number.integer) == (0))); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p6_4_zero_initialized_array_Pair { pub first: i32, pub second: i32, @@ -275,7 +315,9 @@ pub unsafe fn test_21() { }; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct p9_1_2_zero_then_default_initialized_WithDefaultMember { pub zeroed: i32, pub five: i32, @@ -291,7 +333,9 @@ impl Default for p9_1_2_zero_then_default_initialized_WithDefaultMember { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct p9_1_2_zero_then_default_initialized_LeavesMemberAlone { pub untouched: i32, } @@ -313,7 +357,16 @@ impl Default for p9_1_2_zero_then_default_initialized_LeavesMemberAlone { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAlone { pub number: i32, pub member: p9_1_2_zero_then_default_initialized_LeavesMemberAlone, diff --git a/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/refcount/dcl.array.rs b/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/refcount/dcl.array.rs index 1f60d2d998..f62ffefefc 100644 --- a/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/refcount/dcl.array.rs +++ b/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/refcount/dcl.array.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(12)] pub struct p6_array_of_pointers_to_data_members_HasThreeInts { #[offset(0)] diff --git a/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/refcount/dcl.fct.default.rs b/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/refcount/dcl.fct.default.rs index 23dabaad45..20106a5a08 100644 --- a/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/refcount/dcl.fct.default.rs +++ b/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/refcount/dcl.fct.default.rs @@ -54,7 +54,9 @@ thread_local!( thread_local!( pub static step_10: Value = Rc::new(RefCell::new(4)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(4)] pub struct p9_static_member_hides_namespace_variable_HasStaticStep { #[offset(0)] @@ -105,7 +107,18 @@ pub fn count_default_13() -> i32 { pub fn combine_14(mut first: i32, mut second: i32) -> i32 { return ((first * 100) + second); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + Copyable, +)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct p9_evaluated_each_time_called_Widget { @@ -132,7 +145,9 @@ thread_local!( ); pub type anon_16 = u32; pub const anon_16_kBonus: anon_16 = 5; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(4)] pub struct p9_evaluated_each_time_called_Account { #[offset(0)] @@ -221,7 +236,18 @@ pub fn test_17() { pub fn add_18(mut a: i32, mut b: i32) -> i32 { return (a + b); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct p9_not_part_of_the_type_Scale {} impl p9_not_part_of_the_type_Scale { diff --git a/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/refcount/dcl.mptr.rs b/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/refcount/dcl.mptr.rs index 15c1da0e95..b55a188bb1 100644 --- a/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/refcount/dcl.mptr.rs +++ b/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/refcount/dcl.mptr.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(16)] pub struct p2_pointer_to_array_member_HasIntArray { #[offset(0)] @@ -40,7 +40,18 @@ pub fn test_0() { assert!(((array_elem!(obj.as_pointer(), elements, 1).read()) == 7)); assert!(({ (*obj.borrow()).before } == 1)); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct p2_pointer_to_data_member_HasTwoInts { #[offset(0)] @@ -68,7 +79,18 @@ pub fn test_1() { thread_local!( pub static pm_2: Value = Rc::new(RefCell::new(-1_isize)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct p2_pointer_to_member_of_incomplete_class_CompletedLater { #[offset(0)] @@ -97,7 +119,18 @@ pub fn test_3() { == 4) ); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct p2_pointer_to_member_of_pointer_to_member_type_HasTwoInts { #[offset(0)] @@ -105,7 +138,9 @@ pub struct p2_pointer_to_member_of_pointer_to_member_type_HasTwoInts { #[offset(4)] pub second: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(8)] pub struct p2_pointer_to_member_of_pointer_to_member_type_HoldsSelector { #[offset(0)] diff --git a/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/unsafe/dcl.array.rs b/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/unsafe/dcl.array.rs index dafd53c5da..fb656d70fc 100644 --- a/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/unsafe/dcl.array.rs +++ b/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/unsafe/dcl.array.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p6_array_of_pointers_to_data_members_HasThreeInts { pub first: i32, pub second: i32, diff --git a/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/unsafe/dcl.fct.default.rs b/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/unsafe/dcl.fct.default.rs index 8aa3fc10ac..416419691f 100644 --- a/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/unsafe/dcl.fct.default.rs +++ b/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/unsafe/dcl.fct.default.rs @@ -54,7 +54,9 @@ pub unsafe fn test_8() { pub static mut step_9: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 100 }); pub static mut step_10: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 4 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct p9_static_member_hides_namespace_variable_HasStaticStep { pub total: i32, } @@ -105,7 +107,16 @@ pub unsafe fn combine_14(mut first: i32, mut second: i32) -> i32 { return (((first) * (100)) + (second)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, +)] #[cpp_from(i32, construct, value)] pub struct p9_evaluated_each_time_called_Widget { pub id: i32, @@ -133,7 +144,9 @@ static mut base_15: std::cell::LazyCell = std::cell::LazyCell::new(|| unsaf pub type anon_16 = u32; pub const anon_16_kBonus: anon_16 = 5; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct p9_evaluated_each_time_called_Account { pub balance: i32, } @@ -227,7 +240,16 @@ pub unsafe fn add_18(mut a: i32, mut b: i32) -> i32 { return ((a) + (b)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p9_not_part_of_the_type_Scale {} impl p9_not_part_of_the_type_Scale { pub unsafe fn times(mut a: i32, mut b: i32) -> i32 { diff --git a/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/unsafe/dcl.mptr.rs b/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/unsafe/dcl.mptr.rs index 78bf32a7f7..323a5e53dd 100644 --- a/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/unsafe/dcl.mptr.rs +++ b/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/unsafe/dcl.mptr.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p2_pointer_to_array_member_HasIntArray { pub before: i32, pub elements: [i32; 3], @@ -38,7 +47,16 @@ pub unsafe fn test_0() { assert!(((obj.before) == (1))); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p2_pointer_to_data_member_HasTwoInts { pub first: i32, pub second: i32, @@ -76,7 +94,16 @@ pub unsafe fn test_1() { } pub static mut pm_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { -1_isize }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p2_pointer_to_member_of_incomplete_class_CompletedLater { pub first: i32, pub second: i32, @@ -100,13 +127,24 @@ pub unsafe fn test_3() { ); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p2_pointer_to_member_of_pointer_to_member_type_HasTwoInts { pub first: i32, pub second: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct p2_pointer_to_member_of_pointer_to_member_type_HoldsSelector { pub selector: isize, } diff --git a/tests/std/expr/conv/out/refcount/conv.mem.rs b/tests/std/expr/conv/out/refcount/conv.mem.rs index 3a5df9abe2..e4244a961a 100644 --- a/tests/std/expr/conv/out/refcount/conv.mem.rs +++ b/tests/std/expr/conv/out/refcount/conv.mem.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct p1_null_distinct_from_first_member_HasTwoInts { #[offset(0)] diff --git a/tests/std/expr/conv/out/unsafe/conv.mem.rs b/tests/std/expr/conv/out/unsafe/conv.mem.rs index 675732b6f3..203929dd10 100644 --- a/tests/std/expr/conv/out/unsafe/conv.mem.rs +++ b/tests/std/expr/conv/out/unsafe/conv.mem.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p1_null_distinct_from_first_member_HasTwoInts { pub first: i32, pub second: i32, diff --git a/tests/std/expr/expr.compound/expr.post/out/refcount/expr.const.cast.rs b/tests/std/expr/expr.compound/expr.post/out/refcount/expr.const.cast.rs index 68bab18c4e..dc1677da4e 100644 --- a/tests/std/expr/expr.compound/expr.post/out/refcount/expr.const.cast.rs +++ b/tests/std/expr/expr.compound/expr.post/out/refcount/expr.const.cast.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct p4_reference_const_cast_Pair { #[offset(0)] diff --git a/tests/std/expr/expr.compound/expr.post/out/refcount/expr.reinterpret.cast-p10-result-is-unspecified.rs b/tests/std/expr/expr.compound/expr.post/out/refcount/expr.reinterpret.cast-p10-result-is-unspecified.rs index 199dcabddb..904ef402d2 100644 --- a/tests/std/expr/expr.compound/expr.post/out/refcount/expr.reinterpret.cast-p10-result-is-unspecified.rs +++ b/tests/std/expr/expr.compound/expr.post/out/refcount/expr.reinterpret.cast-p10-result-is-unspecified.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct HasTwoInts { #[offset(0)] @@ -14,7 +25,18 @@ pub struct HasTwoInts { #[offset(4)] pub second: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct AlsoHasTwoInts { #[offset(0)] diff --git a/tests/std/expr/expr.compound/expr.post/out/refcount/expr.reinterpret.cast.rs b/tests/std/expr/expr.compound/expr.post/out/refcount/expr.reinterpret.cast.rs index 9834be37ee..9d03378a52 100644 --- a/tests/std/expr/expr.compound/expr.post/out/refcount/expr.reinterpret.cast.rs +++ b/tests/std/expr/expr.compound/expr.post/out/refcount/expr.reinterpret.cast.rs @@ -16,7 +16,18 @@ pub fn test_0() { (*value.borrow_mut()) = 7; assert!((((converted.read()).read()) == 7)); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct p10_null_converts_to_null_HasTwoInts { #[offset(0)] @@ -24,7 +35,18 @@ pub struct p10_null_converts_to_null_HasTwoInts { #[offset(4)] pub second: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct p10_null_converts_to_null_HasChar { #[offset(0)] @@ -35,7 +57,18 @@ pub fn test_1() { let mut converted: isize = pm; assert!(((converted) == -1_isize)); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct p10_2_data_member_round_trip_HasTwoInts { #[offset(0)] @@ -43,7 +76,18 @@ pub struct p10_2_data_member_round_trip_HasTwoInts { #[offset(4)] pub second: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct p10_2_data_member_round_trip_HasChar { #[offset(0)] diff --git a/tests/std/expr/expr.compound/expr.post/out/unsafe/expr.const.cast.rs b/tests/std/expr/expr.compound/expr.post/out/unsafe/expr.const.cast.rs index 6d39cbb0c3..1df476df5c 100644 --- a/tests/std/expr/expr.compound/expr.post/out/unsafe/expr.const.cast.rs +++ b/tests/std/expr/expr.compound/expr.post/out/unsafe/expr.const.cast.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p4_reference_const_cast_Pair { pub x: i32, } diff --git a/tests/std/expr/expr.compound/expr.post/out/unsafe/expr.reinterpret.cast-p10-result-is-unspecified.rs b/tests/std/expr/expr.compound/expr.post/out/unsafe/expr.reinterpret.cast-p10-result-is-unspecified.rs index 5eb7bdf714..ce31f7bc5f 100644 --- a/tests/std/expr/expr.compound/expr.post/out/unsafe/expr.reinterpret.cast-p10-result-is-unspecified.rs +++ b/tests/std/expr/expr.compound/expr.post/out/unsafe/expr.reinterpret.cast-p10-result-is-unspecified.rs @@ -7,13 +7,31 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct HasTwoInts { pub first: i32, pub second: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct AlsoHasTwoInts { pub first: i32, pub second: i32, diff --git a/tests/std/expr/expr.compound/expr.post/out/unsafe/expr.reinterpret.cast.rs b/tests/std/expr/expr.compound/expr.post/out/unsafe/expr.reinterpret.cast.rs index 77b5d79023..343354726f 100644 --- a/tests/std/expr/expr.compound/expr.post/out/unsafe/expr.reinterpret.cast.rs +++ b/tests/std/expr/expr.compound/expr.post/out/unsafe/expr.reinterpret.cast.rs @@ -17,13 +17,31 @@ pub unsafe fn test_0() { assert!(((*(*converted)) == (7))); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p10_null_converts_to_null_HasTwoInts { pub first: i32, pub second: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p10_null_converts_to_null_HasChar { pub character: libc::c_char, } @@ -33,13 +51,31 @@ pub unsafe fn test_1() { assert!(((converted) == -1_isize)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p10_2_data_member_round_trip_HasTwoInts { pub first: i32, pub second: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p10_2_data_member_round_trip_HasChar { pub character: libc::c_char, } diff --git a/tests/std/expr/expr.compound/expr.unary/out/refcount/expr.pre.incr.rs b/tests/std/expr/expr.compound/expr.unary/out/refcount/expr.pre.incr.rs index 43d4cdf940..84324b3a78 100644 --- a/tests/std/expr/expr.compound/expr.unary/out/refcount/expr.pre.incr.rs +++ b/tests/std/expr/expr.compound/expr.unary/out/refcount/expr.pre.incr.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct p1_result_is_updated_operand_Counter { #[offset(0)] diff --git a/tests/std/expr/expr.compound/expr.unary/out/refcount/expr.unary.op.rs b/tests/std/expr/expr.compound/expr.unary/out/refcount/expr.unary.op.rs index 8277652549..e74703caa0 100644 --- a/tests/std/expr/expr.compound/expr.unary/out/refcount/expr.unary.op.rs +++ b/tests/std/expr/expr.compound/expr.unary/out/refcount/expr.unary.op.rs @@ -12,7 +12,18 @@ thread_local!( thread_local!( pub static calls_1: Value = Rc::new(RefCell::new(0)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct p3_2_static_member_is_ordinary_pointer_HasStaticMembers {} impl p3_2_static_member_is_ordinary_pointer_HasStaticMembers { @@ -30,7 +41,18 @@ pub fn test_2() { ({ function_pointer.call() }); assert!((calls_1.with(|rc| *rc.borrow()) == 1)); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct p3_2_explicit_object_member_is_ordinary_pointer_HasExplicitObjectMember { #[offset(0)] @@ -46,7 +68,18 @@ pub fn test_3() { (*object.borrow_mut()).base = 5; assert!((({ function_pointer.call(object.as_pointer(), 1,) }) == 6)); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct p4_parenthesized_qualified_id_is_object_pointer_TakesAddressOfOwnMember { #[offset(0)] diff --git a/tests/std/expr/expr.compound/expr.unary/out/unsafe/expr.pre.incr.rs b/tests/std/expr/expr.compound/expr.unary/out/unsafe/expr.pre.incr.rs index c8520e28d3..7d9a6d05ed 100644 --- a/tests/std/expr/expr.compound/expr.unary/out/unsafe/expr.pre.incr.rs +++ b/tests/std/expr/expr.compound/expr.unary/out/unsafe/expr.pre.incr.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p1_result_is_updated_operand_Counter { pub n: i32, } diff --git a/tests/std/expr/expr.compound/expr.unary/out/unsafe/expr.unary.op.rs b/tests/std/expr/expr.compound/expr.unary/out/unsafe/expr.unary.op.rs index 977d637a64..fb74001edb 100644 --- a/tests/std/expr/expr.compound/expr.unary/out/unsafe/expr.unary.op.rs +++ b/tests/std/expr/expr.compound/expr.unary/out/unsafe/expr.unary.op.rs @@ -9,7 +9,16 @@ use std::rc::Rc; pub static mut shared_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 3 }); pub static mut calls_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p3_2_static_member_is_ordinary_pointer_HasStaticMembers {} impl p3_2_static_member_is_ordinary_pointer_HasStaticMembers { pub unsafe fn run() { @@ -28,7 +37,16 @@ pub unsafe fn test_2() { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut calls_1)) == (1))); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p3_2_explicit_object_member_is_ordinary_pointer_HasExplicitObjectMember { pub base: i32, } @@ -54,7 +72,16 @@ pub unsafe fn test_3() { assert!(((unsafe { (function_pointer).unwrap()(&object, 1,) }) == (6))); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p4_parenthesized_qualified_id_is_object_pointer_TakesAddressOfOwnMember { pub value: i32, } diff --git a/tests/std/expr/expr.compound/out/refcount/expr.cond.rs b/tests/std/expr/expr.compound/out/refcount/expr.cond.rs index c5145264e2..306f13b18e 100644 --- a/tests/std/expr/expr.compound/out/refcount/expr.cond.rs +++ b/tests/std/expr/expr.compound/out/refcount/expr.cond.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct p7_4_pointer_to_member_and_null_HasTwoInts { #[offset(0)] diff --git a/tests/std/expr/expr.compound/out/refcount/expr.eq.rs b/tests/std/expr/expr.compound/out/refcount/expr.eq.rs index 54e5467a3e..ee222e9dcf 100644 --- a/tests/std/expr/expr.compound/out/refcount/expr.eq.rs +++ b/tests/std/expr/expr.compound/out/refcount/expr.eq.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct p4_1_both_null_HasTwoInts { #[offset(0)] @@ -20,7 +31,18 @@ pub fn test_0() { assert!((first_null == second_null)); assert!(!(first_null != second_null)); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct p4_2_one_null_HasTwoInts { #[offset(0)] @@ -36,7 +58,7 @@ pub fn test_1() { assert!((null_pm != first_pm)); assert!(!(null_pm == first_pm)); } -#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] +#[derive(VaArg, FnPtrArg, Destructible, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(4)] pub struct p4_5_members_of_same_union_HasTwoIntMembers { #[offset(0)] @@ -65,7 +87,18 @@ pub fn test_2() { assert!((first_pm == second_pm)); assert!(!(first_pm != second_pm)); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct p4_6_data_members_HasTwoInts { #[offset(0)] diff --git a/tests/std/expr/expr.compound/out/refcount/expr.mptr.oper-p6-null-pointer-to-data-member.rs b/tests/std/expr/expr.compound/out/refcount/expr.mptr.oper-p6-null-pointer-to-data-member.rs index 3654cc940e..f44da5d369 100644 --- a/tests/std/expr/expr.compound/out/refcount/expr.mptr.oper-p6-null-pointer-to-data-member.rs +++ b/tests/std/expr/expr.compound/out/refcount/expr.mptr.oper-p6-null-pointer-to-data-member.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct HasTwoInts { #[offset(0)] diff --git a/tests/std/expr/expr.compound/out/refcount/expr.mptr.oper.rs b/tests/std/expr/expr.compound/out/refcount/expr.mptr.oper.rs index fb7cd1bc9b..ebfd834ff9 100644 --- a/tests/std/expr/expr.compound/out/refcount/expr.mptr.oper.rs +++ b/tests/std/expr/expr.compound/out/refcount/expr.mptr.oper.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct p3_arrow_star_HasTwoInts { #[offset(0)] @@ -27,7 +38,18 @@ pub fn test_0() { assert!(({ (*obj.borrow()).first } == 3)); assert!((((p).member::(pm)) == ((p).member::(pm)))); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct p4_object_expression_sequenced_first_HasValue { #[offset(0)] @@ -69,7 +91,18 @@ pub fn test_7() { assert!((object_stamp_2.with(|rc| *rc.borrow()) == 1)); assert!((member_stamp_3.with(|rc| *rc.borrow()) == 2)); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct p6_data_member_of_lvalue_is_lvalue_HasTwoInts { #[offset(0)] @@ -104,6 +137,7 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyAssignable, MoveAssignable, Swappable, @@ -146,6 +180,7 @@ impl Clone for p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves { ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, CopyAssignable, MoveAssignable, diff --git a/tests/std/expr/expr.compound/out/unsafe/expr.cond.rs b/tests/std/expr/expr.compound/out/unsafe/expr.cond.rs index a207449eed..c75bd283b4 100644 --- a/tests/std/expr/expr.compound/out/unsafe/expr.cond.rs +++ b/tests/std/expr/expr.compound/out/unsafe/expr.cond.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p7_4_pointer_to_member_and_null_HasTwoInts { pub first: i32, pub second: i32, diff --git a/tests/std/expr/expr.compound/out/unsafe/expr.eq.rs b/tests/std/expr/expr.compound/out/unsafe/expr.eq.rs index fc445d96e9..dc14f74efd 100644 --- a/tests/std/expr/expr.compound/out/unsafe/expr.eq.rs +++ b/tests/std/expr/expr.compound/out/unsafe/expr.eq.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p4_1_both_null_HasTwoInts { pub first: i32, pub second: i32, @@ -19,7 +28,16 @@ pub unsafe fn test_0() { assert!(!((first_null) != (second_null))); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p4_2_one_null_HasTwoInts { pub first: i32, pub second: i32, @@ -33,7 +51,9 @@ pub unsafe fn test_1() { assert!(!((null_pm) == (first_pm))); } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub union p4_5_members_of_same_union_HasTwoIntMembers { pub first: i32, pub second: i32, @@ -50,7 +70,16 @@ pub unsafe fn test_2() { assert!(!((first_pm) != (second_pm))); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p4_6_data_members_HasTwoInts { pub first: i32, pub second: i32, diff --git a/tests/std/expr/expr.compound/out/unsafe/expr.mptr.oper-p6-null-pointer-to-data-member.rs b/tests/std/expr/expr.compound/out/unsafe/expr.mptr.oper-p6-null-pointer-to-data-member.rs index f3aaaccb69..c52cd320d1 100644 --- a/tests/std/expr/expr.compound/out/unsafe/expr.mptr.oper-p6-null-pointer-to-data-member.rs +++ b/tests/std/expr/expr.compound/out/unsafe/expr.mptr.oper-p6-null-pointer-to-data-member.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct HasTwoInts { pub first: i32, pub second: i32, diff --git a/tests/std/expr/expr.compound/out/unsafe/expr.mptr.oper.rs b/tests/std/expr/expr.compound/out/unsafe/expr.mptr.oper.rs index fbf260bfda..a565cb70ea 100644 --- a/tests/std/expr/expr.compound/out/unsafe/expr.mptr.oper.rs +++ b/tests/std/expr/expr.compound/out/unsafe/expr.mptr.oper.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p3_arrow_star_HasTwoInts { pub first: i32, pub second: i32, @@ -31,7 +40,16 @@ pub unsafe fn test_0() { ); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p4_object_expression_sequenced_first_HasValue { pub value: i32, } @@ -65,7 +83,16 @@ pub unsafe fn test_7() { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut member_stamp_3)) == (2))); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p6_data_member_of_lvalue_is_lvalue_HasTwoInts { pub first: i32, pub second: i32, @@ -98,6 +125,7 @@ pub static mut moveCount_10: std::cell::LazyCell = std::cell::LazyCell::new VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -139,6 +167,7 @@ impl Clone for p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, diff --git a/tests/std/expr/expr.prim/out/refcount/expr.prim.this.rs b/tests/std/expr/expr.prim/out/refcount/expr.prim.this.rs index 8d61468a61..649629304e 100644 --- a/tests/std/expr/expr.prim/out/refcount/expr.prim.this.rs +++ b/tests/std/expr/expr.prim/out/refcount/expr.prim.this.rs @@ -6,7 +6,9 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Destructible, Copyable, +)] #[cpp_from(i32, construct, value)] #[byte_size(16)] pub struct p1_default_member_initializer_names_object_Holder { @@ -32,7 +34,16 @@ pub fn test_0() { assert!((holder.value == 4)); } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + Copyable, + Default, )] #[cpp_from(i32, construct, value)] #[byte_size(16)] diff --git a/tests/std/expr/expr.prim/out/unsafe/expr.prim.this.rs b/tests/std/expr/expr.prim/out/unsafe/expr.prim.this.rs index 6de1136fa9..47bc9597e7 100644 --- a/tests/std/expr/expr.prim/out/unsafe/expr.prim.this.rs +++ b/tests/std/expr/expr.prim/out/unsafe/expr.prim.this.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, +)] #[cpp_from(i32, construct, value)] pub struct p1_default_member_initializer_names_object_Holder { pub self_: *mut p1_default_member_initializer_names_object_Holder, @@ -38,7 +47,15 @@ pub unsafe fn test_0() { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, )] #[cpp_from(i32, construct, value)] pub struct p1_mem_initializer_names_object_Holder { diff --git a/tests/std/library/requirements/utility.requirements/allocator.requirements/out/refcount/allocator.requirements.general.rs b/tests/std/library/requirements/utility.requirements/allocator.requirements/out/refcount/allocator.requirements.general.rs index 4f55762821..1dec3736c0 100644 --- a/tests/std/library/requirements/utility.requirements/allocator.requirements/out/refcount/allocator.requirements.general.rs +++ b/tests/std/library/requirements/utility.requirements/allocator.requirements/out/refcount/allocator.requirements.general.rs @@ -6,10 +6,23 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct p16_rebind_member_Alloc_std_pair_const_int__int___rebind_std_pair_const_int__int__ {} -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(4)] pub struct p16_rebind_member_Alloc_std_pair_const_int__int__ { #[offset(0)] @@ -43,7 +56,18 @@ pub fn test_0() { ); assert!(({ ((*n.borrow()).len() == 1_usize) })); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct p18_rebind_to_container_node_Alloc_std_pair_const_int__int__ {} pub fn test_1() { diff --git a/tests/std/library/requirements/utility.requirements/allocator.requirements/out/unsafe/allocator.requirements.general.rs b/tests/std/library/requirements/utility.requirements/allocator.requirements/out/unsafe/allocator.requirements.general.rs index f75b0a720d..2368ba1774 100644 --- a/tests/std/library/requirements/utility.requirements/allocator.requirements/out/unsafe/allocator.requirements.general.rs +++ b/tests/std/library/requirements/utility.requirements/allocator.requirements/out/unsafe/allocator.requirements.general.rs @@ -7,10 +7,21 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p16_rebind_member_Alloc_std_pair_const_int__int___rebind_std_pair_const_int__int__ {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct p16_rebind_member_Alloc_std_pair_const_int__int__ { pub id: i32, } @@ -30,7 +41,16 @@ pub unsafe fn test_0() { assert!(((n.len()) == (1_usize))); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p18_rebind_to_container_node_Alloc_std_pair_const_int__int__ {} pub unsafe fn test_1() { let mut m: UnsafeMap = UnsafeMap::new(); diff --git a/tests/std/stmt.stmt/stmt.iter/out/refcount/stmt.while.rs b/tests/std/stmt.stmt/stmt.iter/out/refcount/stmt.while.rs index 1ab5178144..c5d95fb531 100644 --- a/tests/std/stmt.stmt/stmt.iter/out/refcount/stmt.while.rs +++ b/tests/std/stmt.stmt/stmt.iter/out/refcount/stmt.while.rs @@ -13,16 +13,7 @@ thread_local!( pub static dtorCount_1: Value = Rc::new(RefCell::new(0)); ); #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - Destructible, - Copyable, - Default, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, )] #[cpp_from(i32, construct, value)] #[byte_size(4)] @@ -30,6 +21,11 @@ pub struct p2_condition_variable_created_each_iteration_ConvertsToBool { #[offset(0)] pub value: i32, } +impl Destructible for p2_condition_variable_created_each_iteration_ConvertsToBool { + fn destroy(this: &Ptr) { + (*dtorCount_1.with(Value::clone).borrow_mut()).prefix_inc(); + } +} pub fn test_2() { let mut remaining: i32 = 2; let mut iterations: i32 = 0; @@ -47,7 +43,7 @@ pub fn test_2() { Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let _dtor_condition = std::mem::DropGuard::new(condition.clone(), |__p| { - Destructible::destroy(__p.as_pointer()) + Destructible::destroy(&__p.as_pointer()) }); if !({ p2_condition_variable_created_each_iteration_ConvertsToBoolImpl::to_bool( @@ -73,16 +69,7 @@ thread_local!( pub static dtorCount_4: Value = Rc::new(RefCell::new(0)); ); #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - Destructible, - Copyable, - Default, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, )] #[cpp_from(i32, construct, value)] #[byte_size(4)] @@ -90,6 +77,11 @@ pub struct p2_continue_destroys_condition_variable_ConvertsToBool { #[offset(0)] pub value: i32, } +impl Destructible for p2_continue_destroys_condition_variable_ConvertsToBool { + fn destroy(this: &Ptr) { + (*dtorCount_4.with(Value::clone).borrow_mut()).prefix_inc(); + } +} pub fn test_5() { let mut remaining: i32 = 3; let mut continued: i32 = 0; @@ -108,7 +100,7 @@ pub fn test_5() { Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let _dtor_condition = std::mem::DropGuard::new(condition.clone(), |__p| { - Destructible::destroy(__p.as_pointer()) + Destructible::destroy(&__p.as_pointer()) }); if !({ p2_continue_destroys_condition_variable_ConvertsToBoolImpl::to_bool( @@ -144,7 +136,6 @@ fn main_0() -> i32 { } pub trait p2_condition_variable_created_each_iteration_ConvertsToBoolImpl { fn construct(&self, value: i32); - fn destructor(&self); fn to_bool(&self) -> bool; } impl p2_condition_variable_created_each_iteration_ConvertsToBoolImpl @@ -154,16 +145,12 @@ impl p2_condition_variable_created_each_iteration_ConvertsToBoolImpl field!((*self), value).write(value); (*ctorCount_0.with(Value::clone).borrow_mut()).prefix_inc(); } - fn destructor(&self) { - (*dtorCount_1.with(Value::clone).borrow_mut()).prefix_inc(); - } fn to_bool(&self) -> bool { return ((*self).with(|__s| __s.value) != 0); } } pub trait p2_continue_destroys_condition_variable_ConvertsToBoolImpl { fn construct(&self, value: i32); - fn destructor(&self); fn to_bool(&self) -> bool; } impl p2_continue_destroys_condition_variable_ConvertsToBoolImpl @@ -173,9 +160,6 @@ impl p2_continue_destroys_condition_variable_ConvertsToBoolImpl field!((*self), value).write(value); (*ctorCount_3.with(Value::clone).borrow_mut()).prefix_inc(); } - fn destructor(&self) { - (*dtorCount_4.with(Value::clone).borrow_mut()).prefix_inc(); - } fn to_bool(&self) -> bool { return ((*self).with(|__s| __s.value) != 0); } diff --git a/tests/std/stmt.stmt/stmt.iter/out/unsafe/stmt.while.rs b/tests/std/stmt.stmt/stmt.iter/out/unsafe/stmt.while.rs index b04d834948..3cc778ea4d 100644 --- a/tests/std/stmt.stmt/stmt.iter/out/unsafe/stmt.while.rs +++ b/tests/std/stmt.stmt/stmt.iter/out/unsafe/stmt.while.rs @@ -10,14 +10,7 @@ pub static mut ctorCount_0: std::cell::LazyCell = std::cell::LazyCell::new( pub static mut dtorCount_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] #[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - DestructibleUnsafe, - CopyableUnsafe, - Default, + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, )] #[cpp_from(i32, construct, value)] pub struct p2_condition_variable_created_each_iteration_ConvertsToBool { @@ -28,13 +21,15 @@ impl p2_condition_variable_created_each_iteration_ConvertsToBool { (&raw mut self.value).write(value); (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).prefix_inc(); } - pub unsafe fn destructor(&mut self) { - (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_1)).prefix_inc(); - } pub unsafe fn to_bool(&self) -> bool { return ((self.value) != (0)); } } +impl DestructibleUnsafe for p2_condition_variable_created_each_iteration_ConvertsToBool { + unsafe fn destroy(&mut self) { + (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_1)).prefix_inc(); + } +} pub unsafe fn test_2() { let mut remaining: i32 = 2; let mut iterations: i32 = 0; @@ -48,7 +43,7 @@ pub unsafe fn test_2() { __v }; let _dtor_condition = std::mem::DropGuard::new(&raw mut condition, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); if !(unsafe { p2_condition_variable_created_each_iteration_ConvertsToBool::to_bool(&condition) @@ -71,14 +66,7 @@ pub static mut ctorCount_3: std::cell::LazyCell = std::cell::LazyCell::new( pub static mut dtorCount_4: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] #[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - DestructibleUnsafe, - CopyableUnsafe, - Default, + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, )] #[cpp_from(i32, construct, value)] pub struct p2_continue_destroys_condition_variable_ConvertsToBool { @@ -89,13 +77,15 @@ impl p2_continue_destroys_condition_variable_ConvertsToBool { (&raw mut self.value).write(value); (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_3)).prefix_inc(); } - pub unsafe fn destructor(&mut self) { - (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_4)).prefix_inc(); - } pub unsafe fn to_bool(&self) -> bool { return ((self.value) != (0)); } } +impl DestructibleUnsafe for p2_continue_destroys_condition_variable_ConvertsToBool { + unsafe fn destroy(&mut self) { + (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_4)).prefix_inc(); + } +} pub unsafe fn test_5() { let mut remaining: i32 = 3; let mut continued: i32 = 0; @@ -110,7 +100,7 @@ pub unsafe fn test_5() { __v }; let _dtor_condition = std::mem::DropGuard::new(&raw mut condition, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); if !(unsafe { p2_continue_destroys_condition_variable_ConvertsToBool::to_bool(&condition) }) { diff --git a/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.if.rs b/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.if.rs index a6d40f0b33..6da958ea78 100644 --- a/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.if.rs +++ b/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.if.rs @@ -24,7 +24,6 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Destructible, MoveConstructible, MoveAssignable, Swappable, @@ -60,6 +59,11 @@ impl CopyConstructible for LifetimeTracked { (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); } } +impl Destructible for LifetimeTracked { + fn destroy(this: &Ptr) { + (*dtorCount_2.with(Value::clone).borrow_mut()).prefix_inc(); + } +} impl CopyAssignable for LifetimeTracked { fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { field!((*this), uses).write(_a0.with(|__s| __s.uses)); @@ -103,8 +107,9 @@ pub fn test_6() { LifetimeTrackedImpl::construct(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); - let _dtor_guard = - std::mem::DropGuard::new(guard.clone(), |__p| Destructible::destroy(__p.as_pointer())); + let _dtor_guard = std::mem::DropGuard::new(guard.clone(), |__p| { + Destructible::destroy(&__p.as_pointer()) + }); let mut choice: i32 = 0; if (choice != 0) { (*then_runs_4.with(Value::clone).borrow_mut()).prefix_inc(); @@ -125,8 +130,9 @@ pub fn test_6() { LifetimeTrackedImpl::construct(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); - let _dtor_guard = - std::mem::DropGuard::new(guard.clone(), |__p| Destructible::destroy(__p.as_pointer())); + let _dtor_guard = std::mem::DropGuard::new(guard.clone(), |__p| { + Destructible::destroy(&__p.as_pointer()) + }); let mut choice: i32 = 4; if (choice != 0) { (*then_runs_4.with(Value::clone).borrow_mut()).prefix_inc(); @@ -222,7 +228,6 @@ fn main_0() -> i32 { } pub trait LifetimeTrackedImpl { fn construct(&self); - fn destructor(&self); fn use_(&self); } impl LifetimeTrackedImpl for Ptr { @@ -230,9 +235,6 @@ impl LifetimeTrackedImpl for Ptr { field!((*self), uses).write(0); (*ctorCount_0.with(Value::clone).borrow_mut()).prefix_inc(); } - fn destructor(&self) { - (*dtorCount_2.with(Value::clone).borrow_mut()).prefix_inc(); - } fn use_(&self) { field!((*self), uses).with_mut(|__v| { __v.prefix_inc(); diff --git a/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs b/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs index c24737718c..f841ae81c2 100644 --- a/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs +++ b/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs @@ -24,7 +24,6 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Destructible, MoveConstructible, MoveAssignable, Swappable, @@ -60,6 +59,11 @@ impl CopyConstructible for LifetimeTracked { (*copyCount_1.with(Value::clone).borrow_mut()).prefix_inc(); } } +impl Destructible for LifetimeTracked { + fn destroy(this: &Ptr) { + (*dtorCount_2.with(Value::clone).borrow_mut()).prefix_inc(); + } +} impl CopyAssignable for LifetimeTracked { fn copy_assign(this: &Ptr, _a0: Ptr) -> Ptr { field!((*this), uses).write(_a0.with(|__s| __s.uses)); @@ -98,16 +102,7 @@ thread_local!( pub static dtorCount_6: Value = Rc::new(RefCell::new(0)); ); #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - Destructible, - Copyable, - Default, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, )] #[cpp_into(i32, to_i32)] #[byte_size(4)] @@ -115,6 +110,11 @@ pub struct p2_condition_variable_lives_for_whole_statement_ConvertsToInt { #[offset(0)] pub value: i32, } +impl Destructible for p2_condition_variable_lives_for_whole_statement_ConvertsToInt { + fn destroy(this: &Ptr) { + (*dtorCount_6.with(Value::clone).borrow_mut()).prefix_inc(); + } +} pub fn test_7() { { let selector: Value = @@ -122,7 +122,7 @@ pub fn test_7() { p2_condition_variable_lives_for_whole_statement_ConvertsToInt { value: 2 }, )); let _dtor_selector = std::mem::DropGuard::new(selector.clone(), |__p| { - Destructible::destroy(__p.as_pointer()) + Destructible::destroy(&__p.as_pointer()) }); 'switch: { match { @@ -164,8 +164,9 @@ pub fn test_10() { LifetimeTrackedImpl::construct(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); - let _dtor_guard = - std::mem::DropGuard::new(guard.clone(), |__p| Destructible::destroy(__p.as_pointer())); + let _dtor_guard = std::mem::DropGuard::new(guard.clone(), |__p| { + Destructible::destroy(&__p.as_pointer()) + }); let mut selector: i32 = 2; 'switch: { match { selector } { @@ -238,7 +239,6 @@ fn main_0() -> i32 { } pub trait LifetimeTrackedImpl { fn construct(&self); - fn destructor(&self); fn use_(&self); } impl LifetimeTrackedImpl for Ptr { @@ -246,9 +246,6 @@ impl LifetimeTrackedImpl for Ptr { field!((*self), uses).write(0); (*ctorCount_0.with(Value::clone).borrow_mut()).prefix_inc(); } - fn destructor(&self) { - (*dtorCount_2.with(Value::clone).borrow_mut()).prefix_inc(); - } fn use_(&self) { field!((*self), uses).with_mut(|__v| { __v.prefix_inc(); @@ -258,7 +255,6 @@ impl LifetimeTrackedImpl for Ptr { } pub trait p2_condition_variable_lives_for_whole_statement_ConvertsToIntImpl { fn to_i32(&self) -> i32; - fn destructor(&self); } impl p2_condition_variable_lives_for_whole_statement_ConvertsToIntImpl for Ptr @@ -266,9 +262,6 @@ impl p2_condition_variable_lives_for_whole_statement_ConvertsToIntImpl fn to_i32(&self) -> i32 { return (*self).with(|__s| __s.value); } - fn destructor(&self) { - (*dtorCount_6.with(Value::clone).borrow_mut()).prefix_inc(); - } } pub fn __cpp2rust_init_globals() { let _ = ctorCount_0.with(|_| ()); diff --git a/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.if.rs b/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.if.rs index 80aaad5c3a..4a43889a19 100644 --- a/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.if.rs +++ b/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.if.rs @@ -15,7 +15,6 @@ pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(| VaArg, FnPtrArg, ZeroInitializationUnsafe, - DestructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -40,9 +39,6 @@ impl LifetimeTracked { (&raw mut self.uses).write(0); (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).prefix_inc(); } - pub unsafe fn destructor(&mut self) { - (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)).prefix_inc(); - } pub unsafe fn use_(&self) { (*(&raw const self.uses).cast_mut()).prefix_inc(); (*std::cell::LazyCell::force_mut(&mut *&raw mut useCount_3)).prefix_inc(); @@ -54,6 +50,11 @@ impl CopyConstructibleUnsafe for LifetimeTracked { (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)).prefix_inc(); } } +impl DestructibleUnsafe for LifetimeTracked { + unsafe fn destroy(&mut self) { + (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)).prefix_inc(); + } +} impl CopyAssignableUnsafe for LifetimeTracked { unsafe fn copy_assign(&mut self, _a0: *const LifetimeTracked) -> *mut LifetimeTracked { self.uses = (*_a0).uses; @@ -94,7 +95,7 @@ pub unsafe fn test_6() { __v }; let _dtor_guard = std::mem::DropGuard::new(&raw mut guard, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); let mut choice: i32 = 0; if (choice != 0) { @@ -117,7 +118,7 @@ pub unsafe fn test_6() { __v }; let _dtor_guard = std::mem::DropGuard::new(&raw mut guard, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); let mut choice: i32 = 4; if (choice != 0) { diff --git a/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs b/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs index e8d11c2eb3..c2918d06a3 100644 --- a/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs +++ b/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs @@ -15,7 +15,6 @@ pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(| VaArg, FnPtrArg, ZeroInitializationUnsafe, - DestructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -40,9 +39,6 @@ impl LifetimeTracked { (&raw mut self.uses).write(0); (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).prefix_inc(); } - pub unsafe fn destructor(&mut self) { - (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)).prefix_inc(); - } pub unsafe fn use_(&self) { (*(&raw const self.uses).cast_mut()).prefix_inc(); (*std::cell::LazyCell::force_mut(&mut *&raw mut useCount_3)).prefix_inc(); @@ -54,6 +50,11 @@ impl CopyConstructibleUnsafe for LifetimeTracked { (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)).prefix_inc(); } } +impl DestructibleUnsafe for LifetimeTracked { + unsafe fn destroy(&mut self) { + (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)).prefix_inc(); + } +} impl CopyAssignableUnsafe for LifetimeTracked { unsafe fn copy_assign(&mut self, _a0: *const LifetimeTracked) -> *mut LifetimeTracked { self.uses = (*_a0).uses; @@ -87,14 +88,7 @@ pub static mut other_case_runs_5: std::cell::LazyCell = pub static mut dtorCount_6: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] #[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - DestructibleUnsafe, - CopyableUnsafe, - Default, + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, )] #[cpp_into(i32, to_i32)] pub struct p2_condition_variable_lives_for_whole_statement_ConvertsToInt { @@ -104,7 +98,9 @@ impl p2_condition_variable_lives_for_whole_statement_ConvertsToInt { pub unsafe fn to_i32(&self) -> i32 { return self.value; } - pub unsafe fn destructor(&mut self) { +} +impl DestructibleUnsafe for p2_condition_variable_lives_for_whole_statement_ConvertsToInt { + unsafe fn destroy(&mut self) { (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_6)).prefix_inc(); } } @@ -113,7 +109,7 @@ pub unsafe fn test_7() { let mut selector: p2_condition_variable_lives_for_whole_statement_ConvertsToInt = p2_condition_variable_lives_for_whole_statement_ConvertsToInt { value: 2 }; let _dtor_selector = std::mem::DropGuard::new(&raw mut selector, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); 'switch: { match { @@ -154,7 +150,7 @@ pub unsafe fn test_10() { __v }; let _dtor_guard = std::mem::DropGuard::new(&raw mut guard, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); let mut selector: i32 = 2; 'switch: { diff --git a/tests/std/temp/out/refcount/temp.type.rs b/tests/std/temp/out/refcount/temp.type.rs index fafd43ca48..a8738251f0 100644 --- a/tests/std/temp/out/refcount/temp.type.rs +++ b/tests/std/temp/out/refcount/temp.type.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct p2_6_pointer_to_member_argument_HasTwoInts { #[offset(0)] @@ -17,21 +28,54 @@ pub struct p2_6_pointer_to_member_argument_HasTwoInts { thread_local!( pub static count_0: Value = Rc::new(RefCell::new(0)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct p2_6_pointer_to_member_argument_CountsPerMember_refp2_6_pointer_to_member_argument_HasTwoInts_first_ {} thread_local!( pub static count_1: Value = Rc::new(RefCell::new(0)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct p2_6_pointer_to_member_argument_CountsPerMember_refp2_6_pointer_to_member_argument_HasTwoInts_second_ {} thread_local!( pub static count_2: Value = Rc::new(RefCell::new(0)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct p2_6_pointer_to_member_argument_CountsPerMember_nullptr_ {} pub fn test_3() { diff --git a/tests/std/temp/out/unsafe/temp.type.rs b/tests/std/temp/out/unsafe/temp.type.rs index 06a61aadc3..49a9571e4a 100644 --- a/tests/std/temp/out/unsafe/temp.type.rs +++ b/tests/std/temp/out/unsafe/temp.type.rs @@ -7,24 +7,60 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p2_6_pointer_to_member_argument_HasTwoInts { pub first: i32, pub second: i32, } pub static mut count_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p2_6_pointer_to_member_argument_CountsPerMember_refp2_6_pointer_to_member_argument_HasTwoInts_first_ {} pub static mut count_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p2_6_pointer_to_member_argument_CountsPerMember_refp2_6_pointer_to_member_argument_HasTwoInts_second_ {} pub static mut count_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p2_6_pointer_to_member_argument_CountsPerMember_nullptr_ {} pub unsafe fn test_3() { (*std::cell::LazyCell::force_mut(&mut *&raw mut count_0)).prefix_inc(); diff --git a/tests/std/temp/temp.spec/out/refcount/temp.inst.rs b/tests/std/temp/temp.spec/out/refcount/temp.inst.rs index 62151af01c..816a67c4a4 100644 --- a/tests/std/temp/temp.spec/out/refcount/temp.inst.rs +++ b/tests/std/temp/temp.spec/out/refcount/temp.inst.rs @@ -6,7 +6,9 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(4)] pub struct p2_reference_does_not_instantiate_Member { #[offset(0)] @@ -17,7 +19,7 @@ impl Default for p2_reference_does_not_instantiate_Member { { p2_reference_does_not_instantiate_Member { value: 1 } } } } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Default)] #[byte_size(4)] pub struct p2_reference_does_not_instantiate_Holder { #[offset(0)] diff --git a/tests/std/temp/temp.spec/out/unsafe/temp.inst.rs b/tests/std/temp/temp.spec/out/unsafe/temp.inst.rs index 05a30a775d..c3983b5c7c 100644 --- a/tests/std/temp/temp.spec/out/unsafe/temp.inst.rs +++ b/tests/std/temp/temp.spec/out/unsafe/temp.inst.rs @@ -7,7 +7,9 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct p2_reference_does_not_instantiate_Member { pub value: i32, } @@ -25,7 +27,7 @@ impl Default for p2_reference_does_not_instantiate_Member { } } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, Default)] pub struct p2_reference_does_not_instantiate_Holder { pub member: p2_reference_does_not_instantiate_Member, } diff --git a/tests/std/utilities/utility/out/refcount/forward-helpers.rs b/tests/std/utilities/utility/out/refcount/forward-helpers.rs index 7bc99537c4..9a3935df25 100644 --- a/tests/std/utilities/utility/out/refcount/forward-helpers.rs +++ b/tests/std/utilities/utility/out/refcount/forward-helpers.rs @@ -21,6 +21,7 @@ pub fn test_0() { VaArg, FnPtrArg, CppFrom, + Destructible, CopyAssignable, MoveAssignable, Swappable, @@ -62,6 +63,7 @@ impl Clone for p6_forward_like_Movable { ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, CopyAssignable, MoveAssignable, @@ -121,7 +123,7 @@ pub fn test_3() { let mut moved: p6_forward_like_Movable = ({ take_2(holder.as_pointer()) }); assert!((moved.value == 1) && ({ (*holder.borrow()).member.value } == 0)); } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Destructible, Default)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct p9_move_Movable { @@ -185,6 +187,7 @@ pub fn test_4() { VaArg, FnPtrArg, CppFrom, + Destructible, CopyAssignable, MoveAssignable, Swappable, @@ -270,6 +273,7 @@ pub fn test_7() { VaArg, FnPtrArg, CppFrom, + Destructible, CopyAssignable, MoveAssignable, Swappable, @@ -312,6 +316,7 @@ impl Clone for p11_move_if_noexcept_NoexceptMove { VaArg, FnPtrArg, CppFrom, + Destructible, CopyAssignable, MoveAssignable, Swappable, diff --git a/tests/std/utilities/utility/out/refcount/forward.rs b/tests/std/utilities/utility/out/refcount/forward.rs index 1aba0e1ce8..eb803d192b 100644 --- a/tests/std/utilities/utility/out/refcount/forward.rs +++ b/tests/std/utilities/utility/out/refcount/forward.rs @@ -12,7 +12,18 @@ pub fn test_0() { assert!((target == 1)); assert!((source == 1)); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct p9_move_trivially_copyable_Point { #[offset(0)] @@ -43,7 +54,7 @@ pub fn test_1() { assert!((points[0_usize].x == 5) && (points[0_usize].y == 6)); assert!((element.x == 5) && (element.y == 6)); } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Destructible, Default)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct p10_move_constructor_A { diff --git a/tests/std/utilities/utility/out/refcount/utility.as.const.rs b/tests/std/utilities/utility/out/refcount/utility.as.const.rs index 6fc2ef179c..0574c8d526 100644 --- a/tests/std/utilities/utility/out/refcount/utility.as.const.rs +++ b/tests/std/utilities/utility/out/refcount/utility.as.const.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct p1_as_const_Counter { #[offset(0)] diff --git a/tests/std/utilities/utility/out/unsafe/forward-helpers.rs b/tests/std/utilities/utility/out/unsafe/forward-helpers.rs index 4b8ee7f936..65e0a3cf43 100644 --- a/tests/std/utilities/utility/out/unsafe/forward-helpers.rs +++ b/tests/std/utilities/utility/out/unsafe/forward-helpers.rs @@ -20,6 +20,7 @@ pub unsafe fn test_0() { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DestructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -63,6 +64,7 @@ impl Clone for p6_forward_like_Movable { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, @@ -115,7 +117,7 @@ pub unsafe fn test_3() { assert!(((moved.value) == (1)) && ((holder.member.value) == (0))); } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, Default)] #[cpp_from(i32, construct, value)] pub struct p9_move_Movable { pub value: i32, @@ -178,6 +180,7 @@ pub unsafe fn test_4() { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DestructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -260,6 +263,7 @@ pub unsafe fn test_7() { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DestructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -304,6 +308,7 @@ impl Clone for p11_move_if_noexcept_NoexceptMove { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DestructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, diff --git a/tests/std/utilities/utility/out/unsafe/forward.rs b/tests/std/utilities/utility/out/unsafe/forward.rs index 293c399b79..8dd407cf36 100644 --- a/tests/std/utilities/utility/out/unsafe/forward.rs +++ b/tests/std/utilities/utility/out/unsafe/forward.rs @@ -13,7 +13,16 @@ pub unsafe fn test_0() { assert!(((source) == (1))); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p9_move_trivially_copyable_Point { pub x: i32, pub y: i32, @@ -42,7 +51,7 @@ pub unsafe fn test_1() { assert!(((element.x) == (5)) && ((element.y) == (6))); } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, Default)] #[cpp_from(i32, construct, value)] pub struct p10_move_constructor_A { pub value: i32, diff --git a/tests/std/utilities/utility/out/unsafe/utility.as.const.rs b/tests/std/utilities/utility/out/unsafe/utility.as.const.rs index d55c5c52eb..f200448202 100644 --- a/tests/std/utilities/utility/out/unsafe/utility.as.const.rs +++ b/tests/std/utilities/utility/out/unsafe/utility.as.const.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct p1_as_const_Counter { pub value: i32, } diff --git a/tests/ub/out/refcount/ctor_ref_member.rs b/tests/ub/out/refcount/ctor_ref_member.rs index bced5e5085..9e8d47522d 100644 --- a/tests/ub/out/refcount/ctor_ref_member.rs +++ b/tests/ub/out/refcount/ctor_ref_member.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + Copyable, + Default, )] #[cpp_from(i32, construct, ptr)] #[byte_size(8)] diff --git a/tests/ub/out/refcount/self_referencing_initializer.rs b/tests/ub/out/refcount/self_referencing_initializer.rs index 24795e940a..b0edecb22b 100644 --- a/tests/ub/out/refcount/self_referencing_initializer.rs +++ b/tests/ub/out/refcount/self_referencing_initializer.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct pair { #[offset(0)] diff --git a/tests/ub/out/refcount/ub6.rs b/tests/ub/out/refcount/ub6.rs index ecffc37d20..1a84b35490 100644 --- a/tests/ub/out/refcount/ub6.rs +++ b/tests/ub/out/refcount/ub6.rs @@ -6,7 +6,9 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(16)] pub struct Pair { #[offset(0)] diff --git a/tests/ub/out/unsafe/ctor_ref_member.rs b/tests/ub/out/unsafe/ctor_ref_member.rs index 40356b74ef..f94bb1e471 100644 --- a/tests/ub/out/unsafe/ctor_ref_member.rs +++ b/tests/ub/out/unsafe/ctor_ref_member.rs @@ -8,7 +8,15 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, )] #[cpp_from(i32, construct, ptr)] pub struct S { diff --git a/tests/ub/out/unsafe/self_referencing_initializer.rs b/tests/ub/out/unsafe/self_referencing_initializer.rs index 91d0ca7546..137783f696 100644 --- a/tests/ub/out/unsafe/self_referencing_initializer.rs +++ b/tests/ub/out/unsafe/self_referencing_initializer.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct pair { pub a: i32, pub b: i32, diff --git a/tests/ub/out/unsafe/ub6.rs b/tests/ub/out/unsafe/ub6.rs index e5d176dd96..0c250640dc 100644 --- a/tests/ub/out/unsafe/ub6.rs +++ b/tests/ub/out/unsafe/ub6.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Pair { pub x1: *mut i32, pub x2: *mut i32, diff --git a/tests/unit/out/refcount/05_new.rs b/tests/unit/out/refcount/05_new.rs index af231c3e50..793b504939 100644 --- a/tests/unit/out/refcount/05_new.rs +++ b/tests/unit/out/refcount/05_new.rs @@ -6,10 +6,32 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct A {} -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct D {} pub fn main() { diff --git a/tests/unit/out/refcount/10_struct.rs b/tests/unit/out/refcount/10_struct.rs index 3386a00e03..4c6fed88d3 100644 --- a/tests/unit/out/refcount/10_struct.rs +++ b/tests/unit/out/refcount/10_struct.rs @@ -6,7 +6,9 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(16)] pub struct GraphNode { #[offset(0)] @@ -15,7 +17,9 @@ pub struct GraphNode { #[byte_size(8)] pub next: Ptr, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(16)] pub struct Graph { #[offset(0)] @@ -24,7 +28,7 @@ pub struct Graph { #[byte_size(8)] pub adj: Ptr>, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(8)] pub struct Partial { #[offset(0)] @@ -40,10 +44,23 @@ impl Default for Partial { } } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct Declared {} -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(16)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/addr_of_global.rs b/tests/unit/out/refcount/addr_of_global.rs index 7281147b84..9f9960c025 100644 --- a/tests/unit/out/refcount/addr_of_global.rs +++ b/tests/unit/out/refcount/addr_of_global.rs @@ -6,13 +6,26 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Inner { #[offset(0)] pub value: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(8)] pub struct Outer { #[offset(0)] diff --git a/tests/unit/out/refcount/anonymous-struct.rs b/tests/unit/out/refcount/anonymous-struct.rs index e5ef6a069f..5a0a49c95e 100644 --- a/tests/unit/out/refcount/anonymous-struct.rs +++ b/tests/unit/out/refcount/anonymous-struct.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Outer_Named { #[offset(0)] @@ -14,7 +25,18 @@ pub struct Outer_Named { #[offset(4)] pub b: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct anon_0 { #[offset(0)] @@ -22,7 +44,18 @@ pub struct anon_0 { #[offset(4)] pub d: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct anon_1 { #[offset(0)] @@ -30,7 +63,18 @@ pub struct anon_1 { #[offset(4)] pub h: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct anon_2 { #[offset(0)] @@ -38,19 +82,52 @@ pub struct anon_2 { #[offset(4)] pub f: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct anon_4 { #[offset(0)] pub j: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct anon_5 { #[offset(0)] pub k: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(12)] pub struct anon_3 { #[offset(0)] @@ -62,7 +139,18 @@ pub struct anon_3 { #[byte_size(4)] pub anon_5: anon_5, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(44)] pub struct Outer { #[offset(0)] @@ -126,7 +214,18 @@ fn main_0() -> i32 { ); return 0; } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct anon_6 { #[offset(0)] diff --git a/tests/unit/out/refcount/anonymous-struct_c.rs b/tests/unit/out/refcount/anonymous-struct_c.rs index a7c5bbf4e5..921e980c12 100644 --- a/tests/unit/out/refcount/anonymous-struct_c.rs +++ b/tests/unit/out/refcount/anonymous-struct_c.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Named { #[offset(0)] @@ -14,7 +25,18 @@ pub struct Named { #[offset(4)] pub b: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct anon_0 { #[offset(0)] @@ -22,7 +44,18 @@ pub struct anon_0 { #[offset(4)] pub d: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct anon_1 { #[offset(0)] @@ -30,7 +63,18 @@ pub struct anon_1 { #[offset(4)] pub h: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct anon_2 { #[offset(0)] @@ -38,19 +82,52 @@ pub struct anon_2 { #[offset(4)] pub f: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct anon_4 { #[offset(0)] pub j: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct anon_5 { #[offset(0)] pub k: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(12)] pub struct anon_3 { #[offset(0)] @@ -62,7 +139,18 @@ pub struct anon_3 { #[byte_size(4)] pub anon_5: anon_5, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(44)] pub struct Outer { #[offset(0)] @@ -132,7 +220,18 @@ fn main_0() -> i32 { ); return 0; } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct anon_6 { #[offset(0)] diff --git a/tests/unit/out/refcount/anonymous_enum.rs b/tests/unit/out/refcount/anonymous_enum.rs index e9bd25cbfd..ef1717ec58 100644 --- a/tests/unit/out/refcount/anonymous_enum.rs +++ b/tests/unit/out/refcount/anonymous_enum.rs @@ -12,7 +12,18 @@ pub const anon_0_FIRST_B: anon_0 = 1; pub type anon_1 = u32; pub const anon_1_SECOND_A: anon_1 = 0; pub const anon_1_SECOND_B: anon_1 = 1; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] @@ -24,7 +35,18 @@ pub const TdEnum_TD_B: TdEnum = 1; pub type anon_2 = u32; pub const anon_2_FIELD_A: anon_2 = 0; pub const anon_2_FIELD_B: anon_2 = 1; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct WithAnonField { #[offset(0)] diff --git a/tests/unit/out/refcount/anonymous_enum_c.rs b/tests/unit/out/refcount/anonymous_enum_c.rs index b136e41810..d1186dbcf0 100644 --- a/tests/unit/out/refcount/anonymous_enum_c.rs +++ b/tests/unit/out/refcount/anonymous_enum_c.rs @@ -12,7 +12,18 @@ pub const anon_0_FIRST_B: anon_0 = 1; pub type anon_1 = u32; pub const anon_1_SECOND_A: anon_1 = 0; pub const anon_1_SECOND_B: anon_1 = 1; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] @@ -24,7 +35,18 @@ pub const TdEnum_enum_TD_B: TdEnum_enum = 1; pub type anon_2 = u32; pub const anon_2_FIELD_A: anon_2 = 0; pub const anon_2_FIELD_B: anon_2 = 1; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct WithAnonField { #[offset(0)] diff --git a/tests/unit/out/refcount/any.rs b/tests/unit/out/refcount/any.rs index f75be0b727..a2df3aa89f 100644 --- a/tests/unit/out/refcount/any.rs +++ b/tests/unit/out/refcount/any.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Point { #[offset(0)] diff --git a/tests/unit/out/refcount/array_const_init.rs b/tests/unit/out/refcount/array_const_init.rs index 10578fb74b..a560c3fc15 100644 --- a/tests/unit/out/refcount/array_const_init.rs +++ b/tests/unit/out/refcount/array_const_init.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(20)] pub struct S { #[offset(0)] @@ -38,7 +38,18 @@ thread_local!( buf: Box::new([0; 4]), })); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct P { #[offset(0)] diff --git a/tests/unit/out/refcount/array_field_addr.rs b/tests/unit/out/refcount/array_field_addr.rs index 8e9d6138f2..6b227c8f37 100644 --- a/tests/unit/out/refcount/array_field_addr.rs +++ b/tests/unit/out/refcount/array_field_addr.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(12)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/array_of_noncopy_struct.rs b/tests/unit/out/refcount/array_of_noncopy_struct.rs index e3875e2fc2..2b054fa8bd 100644 --- a/tests/unit/out/refcount/array_of_noncopy_struct.rs +++ b/tests/unit/out/refcount/array_of_noncopy_struct.rs @@ -13,6 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, CopyAssignable, Swappable, diff --git a/tests/unit/out/refcount/array_reference.rs b/tests/unit/out/refcount/array_reference.rs index 386c7d3c6e..4dce815b9a 100644 --- a/tests/unit/out/refcount/array_reference.rs +++ b/tests/unit/out/refcount/array_reference.rs @@ -59,7 +59,18 @@ pub fn fill_and_sum_9(a: Ptr, mut v: i32, out: Ptr) { pub fn pick_10(s: Ptr) -> Ptr { return (s).clone(); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Point { #[offset(0)] diff --git a/tests/unit/out/refcount/as_const.rs b/tests/unit/out/refcount/as_const.rs index e4a43f07c3..38ecf0399f 100644 --- a/tests/unit/out/refcount/as_const.rs +++ b/tests/unit/out/refcount/as_const.rs @@ -9,7 +9,18 @@ use std::rc::{Rc, Weak}; pub type Overload = u32; pub const Overload_kMutableOverload: Overload = 1; pub const Overload_kConstOverload: Overload = 2; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/assign_rhs_first.rs b/tests/unit/out/refcount/assign_rhs_first.rs index 5bb95da148..8fa7ae2c2d 100644 --- a/tests/unit/out/refcount/assign_rhs_first.rs +++ b/tests/unit/out/refcount/assign_rhs_first.rs @@ -15,7 +15,9 @@ pub fn advance_1() -> i32 { }); return 10; } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(8)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/assignment_single_eval.rs b/tests/unit/out/refcount/assignment_single_eval.rs index b04347daa9..666bc99c36 100644 --- a/tests/unit/out/refcount/assignment_single_eval.rs +++ b/tests/unit/out/refcount/assignment_single_eval.rs @@ -810,21 +810,27 @@ pub fn test_reference_members_9() { (*other.borrow()) ); } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(8)] pub struct Slot_6 { #[offset(0)] #[byte_size(8)] pub value: Ptr, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(8)] pub struct Slot_8 { #[offset(0)] #[byte_size(8)] pub value: Ptr, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(8)] pub struct Slot_10 { #[offset(0)] @@ -889,7 +895,9 @@ pub fn test_pointer_elements_11() { }; printf!(b"pointer increments %d %d\n", (*index.borrow()), value); } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(8)] pub struct Holder_12 { #[offset(0)] @@ -923,7 +931,9 @@ pub fn test_reference_pointer_13() { (({ (result).clone() } == { (second.as_pointer()) }) as i32) ); } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(8)] pub struct Node_14 { #[offset(0)] @@ -1020,26 +1030,52 @@ pub fn test_reference_subfields_18() { ({ (*other.borrow()).value } as i32) ); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Index_16 { #[offset(0)] pub value: u32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(8)] pub struct Slot_17 { #[offset(0)] #[byte_size(8)] pub ref_: Ptr, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(2)] pub struct Index_19 { #[offset(0)] pub value: i16, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(8)] pub struct Slot_20 { #[offset(0)] @@ -1081,13 +1117,35 @@ pub fn observe_global_23(mut assigned: i32) -> i32 { pub fn observe_24(mut assigned: i32, mut stored: Ptr) -> i32 { return ({ assigned } + { (stored.read()) }); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct GlobalRecord_Inner { #[offset(0)] pub value: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct GlobalRecord { #[offset(0)] @@ -1328,13 +1386,26 @@ thread_local!( thread_local!( static flag_31: Value = Rc::new(RefCell::new(false)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Record_32 { #[offset(0)] pub value: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(8)] pub struct Link_33 { #[offset(0)] @@ -1345,7 +1416,18 @@ thread_local!( pub static selected_values_34: Value> = Rc::new(RefCell::new(Box::new([0_u32, 20_u32, 30_u32]))); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct IndexedBinding {} pub fn test_binding_35() { @@ -1580,7 +1662,18 @@ thread_local!( Box::new([20_u32, 30_u32]), ]))); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(12)] pub struct IndexedMember { #[offset(0)] @@ -1941,7 +2034,9 @@ thread_local!( scoped_values_52.with(|v| v.decay()), ]))); ); -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(8)] pub struct PointerSelector { #[offset(0)] @@ -2149,6 +2244,7 @@ pub fn test_stable_containers_58() { ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, CopyAssignable, Swappable, @@ -2173,7 +2269,18 @@ impl MoveAssignable for Counts_59 { return (*this).clone(); } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Pair_60 { #[offset(0)] @@ -2484,13 +2591,24 @@ fn main_0() -> i32 { ); return 0; } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Index_62 { #[offset(0)] pub value: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(12)] pub struct Owner_63 { #[offset(0)] diff --git a/tests/unit/out/refcount/bounded_struct_ptr.rs b/tests/unit/out/refcount/bounded_struct_ptr.rs index 1ffff7cdf6..13d8b24e3a 100644 --- a/tests/unit/out/refcount/bounded_struct_ptr.rs +++ b/tests/unit/out/refcount/bounded_struct_ptr.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Foo { #[offset(0)] diff --git a/tests/unit/out/refcount/bst.rs b/tests/unit/out/refcount/bst.rs index d88c6ddcbc..3706c10845 100644 --- a/tests/unit/out/refcount/bst.rs +++ b/tests/unit/out/refcount/bst.rs @@ -6,7 +6,9 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(24)] pub struct node_t { #[offset(0)] diff --git a/tests/unit/out/refcount/c_struct.rs b/tests/unit/out/refcount/c_struct.rs index 97422e04f7..5eaa76cdbe 100644 --- a/tests/unit/out/refcount/c_struct.rs +++ b/tests/unit/out/refcount/c_struct.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Point { #[offset(0)] @@ -14,7 +25,18 @@ pub struct Point { #[offset(4)] pub y: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(16)] pub struct Line { #[offset(0)] @@ -24,7 +46,9 @@ pub struct Line { #[byte_size(8)] pub end: Point, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(16)] pub struct Node { #[offset(0)] @@ -37,7 +61,18 @@ pub type Color = u32; pub const Color_RED: Color = 0; pub const Color_GREEN: Color = 1; pub const Color_BLUE: Color = 2; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Inner { #[offset(0)] @@ -45,7 +80,18 @@ pub struct Inner { #[offset(4)] pub b: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(16)] pub struct Container { #[offset(0)] diff --git a/tests/unit/out/refcount/cast.rs b/tests/unit/out/refcount/cast.rs index 2be35da92e..a5c5c64723 100644 --- a/tests/unit/out/refcount/cast.rs +++ b/tests/unit/out/refcount/cast.rs @@ -10,7 +10,18 @@ pub type E = u32; pub const E_A: E = 0; pub const E_B: E = 1; pub const E_C: E = 2; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Pair { #[offset(0)] @@ -18,14 +29,25 @@ pub struct Pair { #[offset(4)] pub y: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(64)] #[byte_align(64)] pub struct Wide { #[offset(0)] pub c: i8, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(40)] pub struct Grid { #[offset(0)] @@ -59,6 +81,7 @@ impl Default for Grid { ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, CopyAssignable, Swappable, diff --git a/tests/unit/out/refcount/cast_array_to_pointer_decay.rs b/tests/unit/out/refcount/cast_array_to_pointer_decay.rs index 69633bbe6a..cd4f406bc9 100644 --- a/tests/unit/out/refcount/cast_array_to_pointer_decay.rs +++ b/tests/unit/out/refcount/cast_array_to_pointer_decay.rs @@ -16,7 +16,7 @@ pub fn strlen_1(mut s: Ptr) -> i32 { } return c; } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(12)] pub struct Row { #[offset(0)] diff --git a/tests/unit/out/refcount/class.rs b/tests/unit/out/refcount/class.rs index 897acfc8a1..e948e0bf4e 100644 --- a/tests/unit/out/refcount/class.rs +++ b/tests/unit/out/refcount/class.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Pair { #[offset(0)] @@ -14,7 +25,18 @@ pub struct Pair { #[offset(4)] pub second: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(16)] pub struct Route { #[offset(0)] @@ -23,7 +45,18 @@ pub struct Route { #[offset(8)] pub cost: f64, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Counter { #[offset(0)] @@ -36,7 +69,18 @@ impl CppEq for Counter { CounterImpl::operator_eq(__lhs, __rhs.clone()) } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Tally { #[offset(0)] diff --git a/tests/unit/out/refcount/class_template_lazy_member.rs b/tests/unit/out/refcount/class_template_lazy_member.rs index 574eafcca9..60b36ae596 100644 --- a/tests/unit/out/refcount/class_template_lazy_member.rs +++ b/tests/unit/out/refcount/class_template_lazy_member.rs @@ -6,32 +6,87 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Point { #[offset(0)] pub x: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Box_int_ { #[offset(0)] pub val: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Box_Point_ { #[offset(0)] #[byte_size(4)] pub val: Point, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Deduced_int_ { #[offset(0)] pub val: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Deduced_Point_ { #[offset(0)] diff --git a/tests/unit/out/refcount/class_templates.rs b/tests/unit/out/refcount/class_templates.rs index 217971dcfe..93d59d3042 100644 --- a/tests/unit/out/refcount/class_templates.rs +++ b/tests/unit/out/refcount/class_templates.rs @@ -13,6 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, CopyAssignable, Swappable, @@ -44,6 +45,7 @@ impl MoveAssignable for MyContainer_int_ { ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, CopyAssignable, Swappable, @@ -75,6 +77,7 @@ impl MoveAssignable for MyContainer_char_ { ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, CopyAssignable, Swappable, @@ -99,7 +102,18 @@ impl MoveAssignable for MyContainer_float_ { return (*this).clone(); } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(2)] pub struct Boxed_short_ { #[offset(0)] @@ -110,7 +124,18 @@ impl Boxed_short_ { return (((v as i32) + (v as i32)) as i16); } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Boxed_int_ { #[offset(0)] @@ -121,7 +146,18 @@ impl Boxed_int_ { return (v + v); } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Boxed_long_ { #[offset(0)] @@ -132,7 +168,18 @@ impl Boxed_long_ { return (v + v); } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Outer_int__Inner_int_ { #[offset(0)] @@ -140,13 +187,35 @@ pub struct Outer_int__Inner_int_ { #[offset(4)] pub u: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Outer_int_ { #[offset(0)] pub v: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(16)] pub struct Outer_long__Inner_int_ { #[offset(0)] @@ -154,7 +223,18 @@ pub struct Outer_long__Inner_int_ { #[offset(8)] pub u: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(16)] pub struct Outer_long__Inner_char_ { #[offset(0)] @@ -162,13 +242,35 @@ pub struct Outer_long__Inner_char_ { #[offset(8)] pub u: i8, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Outer_long_ { #[offset(0)] pub v: i64, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Elem { #[offset(0)] diff --git a/tests/unit/out/refcount/clone_vs_move.rs b/tests/unit/out/refcount/clone_vs_move.rs index dea8feaf5d..aeb644242d 100644 --- a/tests/unit/out/refcount/clone_vs_move.rs +++ b/tests/unit/out/refcount/clone_vs_move.rs @@ -6,13 +6,24 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Bar { #[offset(0)] pub w: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(40)] pub struct Foo { #[offset(0)] @@ -44,7 +55,9 @@ impl Default for Foo { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(16)] pub struct Refs { #[offset(0)] diff --git a/tests/unit/out/refcount/comma_operator.rs b/tests/unit/out/refcount/comma_operator.rs index 87ebed0964..ee89c19b30 100644 --- a/tests/unit/out/refcount/comma_operator.rs +++ b/tests/unit/out/refcount/comma_operator.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Pair { #[offset(0)] diff --git a/tests/unit/out/refcount/complex_function.rs b/tests/unit/out/refcount/complex_function.rs index f2be8f7538..dd96d702c7 100644 --- a/tests/unit/out/refcount/complex_function.rs +++ b/tests/unit/out/refcount/complex_function.rs @@ -15,27 +15,44 @@ pub fn ptr_1(mut x: Ptr) -> Ptr { pub fn bar_2(x: Ptr) -> Ptr { return (x).clone(); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct X1 { #[offset(0)] pub v: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(8)] pub struct X2 { #[offset(0)] #[byte_size(8)] pub v: Ptr, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(8)] pub struct X3 { #[offset(0)] #[byte_size(8)] pub v: Ptr, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(8)] pub struct X4 { #[offset(0)] diff --git a/tests/unit/out/refcount/compound_assign_paren.rs b/tests/unit/out/refcount/compound_assign_paren.rs index 879af437ad..8654df7d11 100644 --- a/tests/unit/out/refcount/compound_assign_paren.rs +++ b/tests/unit/out/refcount/compound_assign_paren.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct Item { #[offset(0)] diff --git a/tests/unit/out/refcount/concepts.rs b/tests/unit/out/refcount/concepts.rs index 2d507aa650..46439f3a75 100644 --- a/tests/unit/out/refcount/concepts.rs +++ b/tests/unit/out/refcount/concepts.rs @@ -11,7 +11,18 @@ const _: () = assert!( (::std::mem::size_of::() == 4_usize), "sizeof(int) == 4" ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct Sized {} pub fn is_small_0() -> bool { diff --git a/tests/unit/out/refcount/constexpr_function.rs b/tests/unit/out/refcount/constexpr_function.rs index 74308900e4..baebd31e6c 100644 --- a/tests/unit/out/refcount/constexpr_function.rs +++ b/tests/unit/out/refcount/constexpr_function.rs @@ -21,7 +21,18 @@ pub fn scaled_2(mut x: i32) -> i32 { pub fn half_3(mut x: f64) -> f64 { return (x / 2_f64); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Flag { #[offset(0)] @@ -44,7 +55,18 @@ const _: () = assert!(true, "in_constant_context()"); pub fn imm_7(mut b: bool) -> bool { return b; } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct P { #[offset(0)] diff --git a/tests/unit/out/refcount/constructor.rs b/tests/unit/out/refcount/constructor.rs index 7aa38b1d0e..2f9412585b 100644 --- a/tests/unit/out/refcount/constructor.rs +++ b/tests/unit/out/refcount/constructor.rs @@ -10,6 +10,23 @@ thread_local!( pub static total_0: Value = Rc::new(RefCell::new(0)); ); #[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, +)] +#[cpp_from(i32, construct, value)] +#[byte_size(4)] +pub struct S { + #[offset(0)] + pub v: i32, +} +impl Destructible for S { + fn destroy(this: &Ptr) { + ({ SImpl::mut_method(this) }); + let __rhs = ({ SImpl::const_method(this) }); + total_0.with(|rc| *rc.borrow_mut() += __rhs); + } +} +#[derive( + Copy, Clone, Record, ByteRepr, @@ -19,15 +36,7 @@ thread_local!( CppFrom, Destructible, Copyable, - Default, )] -#[cpp_from(i32, construct, value)] -#[byte_size(4)] -pub struct S { - #[offset(0)] - pub v: i32, -} -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable)] #[cpp_from(i32, construct_1, value)] #[byte_size(8)] pub struct Point { @@ -59,7 +68,7 @@ fn main_0() -> i32 { Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let _dtor_s = - std::mem::DropGuard::new(s.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(s.clone(), |__p| Destructible::destroy(&__p.as_pointer())); assert!(({ (*s.borrow()).v } == 4)); assert!((total_0.with(|rc| *rc.borrow()) == 8)); } @@ -115,7 +124,6 @@ pub trait SImpl { fn const_method(&self) -> i32; fn mut_method(&self); fn construct(&self, init: i32); - fn destructor(&self); } impl SImpl for Ptr { fn const_method(&self) -> i32 { @@ -132,11 +140,6 @@ impl SImpl for Ptr { let __rhs = ({ SImpl::const_method(self) }); total_0.with(|rc| *rc.borrow_mut() += __rhs); } - fn destructor(&self) { - ({ SImpl::mut_method(self) }); - let __rhs = ({ SImpl::const_method(self) }); - total_0.with(|rc| *rc.borrow_mut() += __rhs); - } } pub fn __cpp2rust_init_globals() { let _ = total_0.with(|_| ()); diff --git a/tests/unit/out/refcount/container_element_receiver.rs b/tests/unit/out/refcount/container_element_receiver.rs index 9e946ba2bb..fa3e629895 100644 --- a/tests/unit/out/refcount/container_element_receiver.rs +++ b/tests/unit/out/refcount/container_element_receiver.rs @@ -13,6 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, CopyAssignable, MoveAssignable, diff --git a/tests/unit/out/refcount/container_field_addr.rs b/tests/unit/out/refcount/container_field_addr.rs index 73f8c3acc5..f30668cbab 100644 --- a/tests/unit/out/refcount/container_field_addr.rs +++ b/tests/unit/out/refcount/container_field_addr.rs @@ -13,6 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, CopyAssignable, Swappable, diff --git a/tests/unit/out/refcount/conversion_operator_same_translation.rs b/tests/unit/out/refcount/conversion_operator_same_translation.rs index 0b415e49e2..78690ac1f7 100644 --- a/tests/unit/out/refcount/conversion_operator_same_translation.rs +++ b/tests/unit/out/refcount/conversion_operator_same_translation.rs @@ -7,7 +7,17 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + Copyable, + Default, )] #[cpp_into(i8, to_i8)] #[cpp_into(u8, to_u8)] @@ -17,7 +27,17 @@ pub struct S { pub v: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + Copyable, + Default, )] #[cpp_into(i64, to_i64_1)] #[byte_size(4)] diff --git a/tests/unit/out/refcount/copy_assign.rs b/tests/unit/out/refcount/copy_assign.rs index 494a9541a3..4c7343f280 100644 --- a/tests/unit/out/refcount/copy_assign.rs +++ b/tests/unit/out/refcount/copy_assign.rs @@ -15,6 +15,7 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, + Destructible, MoveConstructible, MoveAssignable, Swappable, @@ -54,7 +55,9 @@ impl Clone for Partial { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(4)] pub struct NonConstAssign { #[offset(0)] @@ -80,6 +83,7 @@ impl Default for NonConstAssign { ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, MoveConstructible, MoveAssignable, @@ -114,6 +118,7 @@ impl Default for RefQualified { ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, MoveConstructible, MoveAssignable, @@ -171,6 +176,7 @@ thread_local!( VaArg, FnPtrArg, CppFrom, + Destructible, MoveConstructible, MoveAssignable, Swappable, @@ -209,6 +215,7 @@ impl Clone for CopyCounted { ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, MoveConstructible, MoveAssignable, diff --git a/tests/unit/out/refcount/copy_ctor.rs b/tests/unit/out/refcount/copy_ctor.rs index cae3eed3e7..b098b628c5 100644 --- a/tests/unit/out/refcount/copy_ctor.rs +++ b/tests/unit/out/refcount/copy_ctor.rs @@ -16,6 +16,7 @@ thread_local!( VaArg, FnPtrArg, CppFrom, + Destructible, MoveConstructible, MoveAssignable, Swappable, @@ -53,6 +54,7 @@ impl Clone for Counted { ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, MoveConstructible, MoveAssignable, @@ -97,6 +99,7 @@ impl Default for NonConst { VaArg, FnPtrArg, CppFrom, + Destructible, MoveConstructible, MoveAssignable, Swappable, @@ -135,6 +138,7 @@ impl Clone for Ignored { ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, MoveConstructible, MoveAssignable, @@ -180,6 +184,7 @@ impl Default for Holder { VaArg, FnPtrArg, CppFrom, + Destructible, CopyAssignable, MoveAssignable, Swappable, @@ -218,6 +223,7 @@ impl Clone for Box_int_ { ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, CopyAssignable, MoveAssignable, @@ -246,6 +252,7 @@ impl MoveConstructible for Owner { VaArg, FnPtrArg, CppFrom, + Destructible, MoveConstructible, MoveAssignable, Swappable, @@ -283,6 +290,7 @@ impl Clone for OutOfLine { ZeroInitialization, VaArg, FnPtrArg, + Destructible, MoveConstructible, MoveAssignable, Swappable, diff --git a/tests/unit/out/refcount/copy_move_defaulted.rs b/tests/unit/out/refcount/copy_move_defaulted.rs index 25ecc71465..714ed96a1e 100644 --- a/tests/unit/out/refcount/copy_move_defaulted.rs +++ b/tests/unit/out/refcount/copy_move_defaulted.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Inner { #[offset(0)] @@ -20,7 +31,6 @@ pub struct Inner { VaArg, FnPtrArg, CppFrom, - Destructible, CopyAssignable, MoveAssignable, Swappable, @@ -38,12 +48,15 @@ pub struct Explicit { #[array_len(2)] pub arr: Box<[i32]>, } +impl Destructible for Explicit { + fn destroy(this: &Ptr) {} +} impl Default for Explicit { fn default() -> Self { { ::zero_init() } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(16)] pub struct Implicit { #[offset(0)] @@ -76,6 +89,7 @@ impl Default for Implicit { VaArg, FnPtrArg, CppFrom, + Destructible, CopyAssignable, Swappable, Default, @@ -99,7 +113,9 @@ impl MoveAssignable for DefaultCopyUserMove { return (*this).clone(); } } -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Swappable, Default)] +#[derive( + Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Destructible, Swappable, Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct UserCopyDefaultMove { @@ -138,7 +154,7 @@ impl Clone for UserCopyDefaultMove { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Swappable)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Destructible, Swappable)] #[cpp_from(i32, construct, value)] #[byte_size(64)] pub struct Buffer { @@ -187,7 +203,7 @@ impl Default for Buffer { { ::zero_init() } } } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Swappable)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Swappable)] #[byte_size(48)] pub struct Owner { #[offset(0)] @@ -250,6 +266,7 @@ impl Default for Owner { ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, CopyAssignable, Swappable, @@ -274,9 +291,7 @@ impl MoveAssignable for Copyable { return (*this).clone(); } } -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Destructible, Swappable, Default, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Swappable, Default)] #[cpp_from(i32, construct, value)] #[byte_size(32)] pub struct Holder { @@ -308,6 +323,11 @@ impl MoveAssignable for Holder { return (*this).clone(); } } +impl Destructible for Holder { + fn destroy(this: &Ptr) { + Destructible::destroy(&field_ptr!(this, e)); + } +} pub fn same_0(a: Ptr, b: Ptr) -> bool { return ((({ a.with(|__s| __s.v) } == { b.with(|__s| __s.v) }) && ({ a.with(|__s| __s.inner.x) } == { b.with(|__s| __s.inner.x) })) @@ -325,16 +345,16 @@ fn main_0() -> i32 { Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let _dtor_a = - std::mem::DropGuard::new(a.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(a.clone(), |__p| Destructible::destroy(&__p.as_pointer())); let b: Value = Rc::new(RefCell::new((*a.borrow()).clone())); let _dtor_b = - std::mem::DropGuard::new(b.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(b.clone(), |__p| Destructible::destroy(&__p.as_pointer())); let c: Value = Rc::new(RefCell::new((*a.borrow()).clone())); let _dtor_c = - std::mem::DropGuard::new(c.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(c.clone(), |__p| Destructible::destroy(&__p.as_pointer())); let d: Value = Rc::new(RefCell::new((*a.borrow()).clone())); let _dtor_d = - std::mem::DropGuard::new(d.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(d.clone(), |__p| Destructible::destroy(&__p.as_pointer())); assert!( (({ same_0(b.as_pointer(), a.as_pointer(),) }) && ({ same_0(c.as_pointer(), a.as_pointer(),) })) @@ -346,14 +366,14 @@ fn main_0() -> i32 { Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let _dtor_e = - std::mem::DropGuard::new(e.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(e.clone(), |__p| Destructible::destroy(&__p.as_pointer())); let f: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); ExplicitImpl::construct(&__v.as_pointer(), { 3 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let _dtor_f = - std::mem::DropGuard::new(f.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(f.clone(), |__p| Destructible::destroy(&__p.as_pointer())); (*e.borrow_mut()) = (*b.borrow()).clone(); (*f.borrow_mut()) = (*c.borrow()).clone(); assert!( @@ -366,7 +386,7 @@ fn main_0() -> i32 { Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let _dtor_g = - std::mem::DropGuard::new(g.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(g.clone(), |__p| Destructible::destroy(&__p.as_pointer())); let __rhs = { (*e.borrow_mut()) = (*f.borrow()).clone(); (*e.borrow()).clone() @@ -609,7 +629,7 @@ fn main_0() -> i32 { Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let _dtor_h1 = - std::mem::DropGuard::new(h1.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(h1.clone(), |__p| Destructible::destroy(&__p.as_pointer())); { let _p: Ptr<_> = Ptr::alloc(9); field_ptr!(h1.as_pointer(), p).write(_p.to_owned_opt()) @@ -620,7 +640,7 @@ fn main_0() -> i32 { Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let _dtor_h2 = - std::mem::DropGuard::new(h2.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(h2.clone(), |__p| Destructible::destroy(&__p.as_pointer())); assert!( ((({ (*h2.borrow()).inner.x } == 4) && ({ (*h2.borrow()).e.v } == 4)) && (({ (*h2.borrow()).p.clone() }.as_pointer().read()) == 9)) @@ -632,7 +652,7 @@ fn main_0() -> i32 { Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let _dtor_h3 = - std::mem::DropGuard::new(h3.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(h3.clone(), |__p| Destructible::destroy(&__p.as_pointer())); ({ MoveAssignable::move_assign(&h3.as_pointer(), h2.as_pointer()) }); assert!( ((({ (*h3.borrow()).inner.x } == 4) @@ -667,7 +687,6 @@ impl DefaultCopyUserMoveImpl for Ptr { } pub trait ExplicitImpl { fn construct(&self, v: i32); - fn destructor(&self); } impl ExplicitImpl for Ptr { fn construct(&self, mut v: i32) { @@ -675,11 +694,9 @@ impl ExplicitImpl for Ptr { field!((*self), inner).write(Inner { x: (v * 10) }); field!((*self), arr).write(Box::new([v, (v + 1)])); } - fn destructor(&self) {} } pub trait HolderImpl { fn construct(&self, v: i32); - fn destructor(&self); } impl HolderImpl for Ptr { fn construct(&self, mut v: i32) { @@ -691,9 +708,6 @@ impl HolderImpl for Ptr { }); field!((*self), p).write(None); } - fn destructor(&self) { - Destructible::destroy(field_ptr!(self, e)); - } } pub trait UserCopyDefaultMoveImpl { fn construct(&self, v: i32); diff --git a/tests/unit/out/refcount/copy_move_deleted.rs b/tests/unit/out/refcount/copy_move_deleted.rs index d2c3f2a764..b245261e5b 100644 --- a/tests/unit/out/refcount/copy_move_deleted.rs +++ b/tests/unit/out/refcount/copy_move_deleted.rs @@ -6,7 +6,9 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Swappable, Default)] +#[derive( + Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Destructible, Swappable, Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct NoCopy { @@ -26,7 +28,7 @@ impl MoveAssignable for NoCopy { return (*this).clone(); } } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Swappable)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Swappable)] #[byte_size(4)] pub struct PrivateCopy { #[offset(0)] @@ -56,7 +58,7 @@ impl Default for PrivateCopy { } } } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible)] #[byte_size(4)] pub struct Immovable { #[offset(0)] @@ -73,7 +75,7 @@ impl Default for Immovable { } } } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Swappable, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Swappable, Default)] #[byte_size(8)] pub struct Container { #[offset(0)] @@ -99,7 +101,7 @@ impl MoveAssignable for Container { return (*this).clone(); } } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Swappable, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Swappable, Default)] #[byte_size(24)] pub struct VecHolder { #[offset(0)] diff --git a/tests/unit/out/refcount/default.rs b/tests/unit/out/refcount/default.rs index 1c772ee03e..10ee070fdd 100644 --- a/tests/unit/out/refcount/default.rs +++ b/tests/unit/out/refcount/default.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(144)] pub struct Pointers { #[offset(0)] @@ -43,7 +43,7 @@ impl Default for Pointers { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(440)] pub struct SmallArrays { #[offset(0)] @@ -78,7 +78,7 @@ impl Default for SmallArrays { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(132)] pub struct BigArray { #[offset(0)] diff --git a/tests/unit/out/refcount/default_function_arguments.rs b/tests/unit/out/refcount/default_function_arguments.rs index 5f2473d1cf..8c572b8024 100644 --- a/tests/unit/out/refcount/default_function_arguments.rs +++ b/tests/unit/out/refcount/default_function_arguments.rs @@ -12,7 +12,18 @@ pub fn foo_0(mut a: i32, mut b: i32) -> i32 { pub fn baz_1(mut a: Ptr, mut b: Ptr) -> bool { return ({ a } == { b }); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + Copyable, +)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct Bar { @@ -58,7 +69,18 @@ pub fn shifted_8(mut x: i32, mut y: i32) -> i32 { pub fn first_9(r: Ptr) -> i32 { return (elem!(r, 0).read()); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Holder_int_ { #[offset(0)] diff --git a/tests/unit/out/refcount/default_in_statics.rs b/tests/unit/out/refcount/default_in_statics.rs index dbab9f5808..0c8459ddbd 100644 --- a/tests/unit/out/refcount/default_in_statics.rs +++ b/tests/unit/out/refcount/default_in_statics.rs @@ -6,7 +6,9 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(16)] pub struct Inner { #[offset(0)] @@ -15,7 +17,7 @@ pub struct Inner { #[byte_size(8)] pub name: Ptr, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(88)] pub struct Outer { #[offset(0)] @@ -61,7 +63,9 @@ impl Default for Outer { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(40)] pub struct Foo { #[offset(0)] diff --git a/tests/unit/out/refcount/delete_array_order.rs b/tests/unit/out/refcount/delete_array_order.rs index 10231c0604..fae54fc406 100644 --- a/tests/unit/out/refcount/delete_array_order.rs +++ b/tests/unit/out/refcount/delete_array_order.rs @@ -6,9 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(16)] pub struct Element { #[offset(0)] @@ -16,6 +14,15 @@ pub struct Element { #[offset(8)] pub value: i64, } +impl Destructible for Element { + fn destroy(this: &Ptr) { + printf!( + b"%ld:%ld ", + (*this).with(|__s| __s.id), + (*this).with(|__s| __s.value) + ); + } +} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); @@ -38,23 +45,11 @@ fn main_0() -> i32 { { let __p = a; for __i in (0..__p.len()).rev() { - Destructible::destroy(__p.offset(__i as isize)); + Destructible::destroy(&__p.offset(__i as isize)); } __p.delete(); }; printf!(b"\n"); return 0; } -pub trait ElementImpl { - fn destructor(&self); -} -impl ElementImpl for Ptr { - fn destructor(&self) { - printf!( - b"%ld:%ld ", - (*self).with(|__s| __s.id), - (*self).with(|__s| __s.value) - ); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/destructor.rs b/tests/unit/out/refcount/destructor.rs index 43cfaeecfb..8f71a9300c 100644 --- a/tests/unit/out/refcount/destructor.rs +++ b/tests/unit/out/refcount/destructor.rs @@ -9,39 +9,51 @@ use std::rc::{Rc, Weak}; thread_local!( pub static global_0: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct S {} -#[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, -)] +impl Destructible for S { + fn destroy(this: &Ptr) { + (*global_0.with(Value::clone).borrow_mut()).postfix_inc(); + } +} +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct Defaulted { #[offset(0)] #[byte_size(1)] pub s: S, } -#[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, -)] +impl Destructible for Defaulted { + fn destroy(this: &Ptr) { + Destructible::destroy(&field_ptr!(this, s)); + } +} +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct Middle { #[offset(0)] #[byte_size(1)] pub s: S, } -#[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, -)] +impl Destructible for Middle { + fn destroy(this: &Ptr) { + Destructible::destroy(&field_ptr!(this, s)); + } +} +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct Outer { #[offset(0)] #[byte_size(1)] pub m: Middle, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] +impl Destructible for Outer { + fn destroy(this: &Ptr) { + Destructible::destroy(&field_ptr!(this, m)); + } +} +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(3)] pub struct ArrayMember { #[offset(0)] @@ -49,6 +61,11 @@ pub struct ArrayMember { #[array_len(3)] pub items: Box<[S]>, } +impl Destructible for ArrayMember { + fn destroy(this: &Ptr) { + Destructible::destroy(&field_ptr!(this, items)); + } +} impl Default for ArrayMember { fn default() -> Self { { @@ -58,39 +75,61 @@ impl Default for ArrayMember { } } } -#[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct EmptyBody { #[offset(0)] #[byte_size(1)] pub s: S, } -#[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, -)] +impl Destructible for EmptyBody { + fn destroy(this: &Ptr) { + Destructible::destroy(&field_ptr!(this, s)); + } +} +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(1)] pub struct Templated_char_ { #[offset(0)] pub v: i8, } -#[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, -)] +impl Destructible for Templated_char_ { + fn destroy(this: &Ptr) { + global_0.with(|rc| { + *rc.borrow_mut() = { + ((global_0.with(|rc| *rc.borrow()) as usize) + .wrapping_add((::std::mem::size_of::() as usize))) as i32 + } + }); + } +} +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Templated_int_ { #[offset(0)] pub v: i32, } -#[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, -)] +impl Destructible for Templated_int_ { + fn destroy(this: &Ptr) { + global_0.with(|rc| { + *rc.borrow_mut() = { + ((global_0.with(|rc| *rc.borrow()) as usize) + .wrapping_add((::std::mem::size_of::() as usize))) as i32 + } + }); + } +} +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Copied { #[offset(0)] pub v: i32, } +impl Destructible for Copied { + fn destroy(this: &Ptr) { + (*global_0.with(Value::clone).borrow_mut()).postfix_inc(); + } +} thread_local!( pub static order_1: Value> = Rc::new(RefCell::new((0..3).map(|_| 0_i32).collect::>())); @@ -98,17 +137,20 @@ thread_local!( thread_local!( pub static order_count_2: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Tagged { #[offset(0)] pub tag: i32, } -#[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, -)] +impl Destructible for Tagged { + fn destroy(this: &Ptr) { + (*order_1.with(Value::clone).borrow_mut()) + [((*order_count_2.with(Value::clone).borrow_mut()).postfix_inc()) as usize] = + (*this).with(|__s| __s.tag); + } +} +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(20)] pub struct Ordered { #[offset(0)] @@ -125,6 +167,13 @@ pub struct Ordered { #[byte_size(4)] pub third: Tagged, } +impl Destructible for Ordered { + fn destroy(this: &Ptr) { + Destructible::destroy(&field_ptr!(this, third)); + Destructible::destroy(&field_ptr!(this, second)); + Destructible::destroy(&field_ptr!(this, first)); + } +} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); @@ -133,55 +182,55 @@ fn main_0() -> i32 { { let s: Value = Rc::new(RefCell::new(::default())); let _dtor_s = - std::mem::DropGuard::new(s.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(s.clone(), |__p| Destructible::destroy(&__p.as_pointer())); } assert!((global_0.with(|rc| *rc.borrow()) == 1)); { let s: Value = Rc::new(RefCell::new(::default())); let _dtor_s = - std::mem::DropGuard::new(s.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(s.clone(), |__p| Destructible::destroy(&__p.as_pointer())); } assert!((global_0.with(|rc| *rc.borrow()) == 2)); { let d: Value = Rc::new(RefCell::new(::default())); let _dtor_d = - std::mem::DropGuard::new(d.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(d.clone(), |__p| Destructible::destroy(&__p.as_pointer())); } assert!((global_0.with(|rc| *rc.borrow()) == 3)); { let o: Value = Rc::new(RefCell::new(::default())); let _dtor_o = - std::mem::DropGuard::new(o.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(o.clone(), |__p| Destructible::destroy(&__p.as_pointer())); } assert!((global_0.with(|rc| *rc.borrow()) == 4)); { let am: Value = Rc::new(RefCell::new(::default())); let _dtor_am = - std::mem::DropGuard::new(am.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(am.clone(), |__p| Destructible::destroy(&__p.as_pointer())); } assert!((global_0.with(|rc| *rc.borrow()) == 7)); { let e: Value = Rc::new(RefCell::new(::default())); let _dtor_e = - std::mem::DropGuard::new(e.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(e.clone(), |__p| Destructible::destroy(&__p.as_pointer())); } assert!((global_0.with(|rc| *rc.borrow()) == 8)); { let tc: Value = Rc::new(RefCell::new(::default())); let _dtor_tc = - std::mem::DropGuard::new(tc.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(tc.clone(), |__p| Destructible::destroy(&__p.as_pointer())); let ti: Value = Rc::new(RefCell::new(::default())); let _dtor_ti = - std::mem::DropGuard::new(ti.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(ti.clone(), |__p| Destructible::destroy(&__p.as_pointer())); } assert!((global_0.with(|rc| *rc.borrow()) == 13)); { let a: Value = Rc::new(RefCell::new(Copied { v: 5 })); let _dtor_a = - std::mem::DropGuard::new(a.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(a.clone(), |__p| Destructible::destroy(&__p.as_pointer())); let b: Value = Rc::new(RefCell::new((*a.borrow()).clone())); let _dtor_b = - std::mem::DropGuard::new(b.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(b.clone(), |__p| Destructible::destroy(&__p.as_pointer())); assert!(({ (*b.borrow()).v } == 5)); } assert!((global_0.with(|rc| *rc.borrow()) == 15)); @@ -194,7 +243,7 @@ fn main_0() -> i32 { third: Tagged { tag: 3 }, })); let _dtor_o = - std::mem::DropGuard::new(o.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(o.clone(), |__p| Destructible::destroy(&__p.as_pointer())); } assert!((order_count_2.with(|rc| *rc.borrow()) == 3)); assert!( @@ -219,113 +268,11 @@ fn main_0() -> i32 { { let cs: Value = Rc::new(RefCell::new(::default())); let _dtor_cs = - std::mem::DropGuard::new(cs.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(cs.clone(), |__p| Destructible::destroy(&__p.as_pointer())); } assert!((global_0.with(|rc| *rc.borrow()) == (before + 1))); return 0; } -pub trait ArrayMemberImpl { - fn destructor(&self); -} -impl ArrayMemberImpl for Ptr { - fn destructor(&self) { - Destructible::destroy(field_ptr!(self, items)); - } -} -pub trait CopiedImpl { - fn destructor(&self); -} -impl CopiedImpl for Ptr { - fn destructor(&self) { - (*global_0.with(Value::clone).borrow_mut()).postfix_inc(); - } -} -pub trait DefaultedImpl { - fn destructor(&self); -} -impl DefaultedImpl for Ptr { - fn destructor(&self) { - Destructible::destroy(field_ptr!(self, s)); - } -} -pub trait EmptyBodyImpl { - fn destructor(&self); -} -impl EmptyBodyImpl for Ptr { - fn destructor(&self) { - Destructible::destroy(field_ptr!(self, s)); - } -} -pub trait MiddleImpl { - fn destructor(&self); -} -impl MiddleImpl for Ptr { - fn destructor(&self) { - Destructible::destroy(field_ptr!(self, s)); - } -} -pub trait OrderedImpl { - fn destructor(&self); -} -impl OrderedImpl for Ptr { - fn destructor(&self) { - Destructible::destroy(field_ptr!(self, third)); - Destructible::destroy(field_ptr!(self, second)); - Destructible::destroy(field_ptr!(self, first)); - } -} -pub trait OuterImpl { - fn destructor(&self); -} -impl OuterImpl for Ptr { - fn destructor(&self) { - Destructible::destroy(field_ptr!(self, m)); - } -} -pub trait SImpl { - fn destructor(&self); -} -impl SImpl for Ptr { - fn destructor(&self) { - (*global_0.with(Value::clone).borrow_mut()).postfix_inc(); - } -} -pub trait TaggedImpl { - fn destructor(&self); -} -impl TaggedImpl for Ptr { - fn destructor(&self) { - (*order_1.with(Value::clone).borrow_mut()) - [((*order_count_2.with(Value::clone).borrow_mut()).postfix_inc()) as usize] = - (*self).with(|__s| __s.tag); - } -} -pub trait Templated_char_Impl { - fn destructor(&self); -} -impl Templated_char_Impl for Ptr { - fn destructor(&self) { - global_0.with(|rc| { - *rc.borrow_mut() = { - ((global_0.with(|rc| *rc.borrow()) as usize) - .wrapping_add((::std::mem::size_of::() as usize))) as i32 - } - }); - } -} -pub trait Templated_int_Impl { - fn destructor(&self); -} -impl Templated_int_Impl for Ptr { - fn destructor(&self) { - global_0.with(|rc| { - *rc.borrow_mut() = { - ((global_0.with(|rc| *rc.borrow()) as usize) - .wrapping_add((::std::mem::size_of::() as usize))) as i32 - } - }); - } -} pub fn __cpp2rust_init_globals() { let _ = global_0.with(|_| ()); let _ = order_1.with(|_| ()); diff --git a/tests/unit/out/refcount/destructor_params.rs b/tests/unit/out/refcount/destructor_params.rs index b43afdf342..bdeac71267 100644 --- a/tests/unit/out/refcount/destructor_params.rs +++ b/tests/unit/out/refcount/destructor_params.rs @@ -12,14 +12,18 @@ thread_local!( thread_local!( pub static last_1: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct S { #[offset(0)] pub v: i32, } +impl Destructible for S { + fn destroy(this: &Ptr) { + (*destroyed_0.with(Value::clone).borrow_mut()).postfix_inc(); + last_1.with(|rc| *rc.borrow_mut() = (*this).with(|__s| __s.v)); + } +} pub fn by_value_2(s: S) -> i32 { let s: Value = Rc::new(RefCell::new(s)); assert!((destroyed_0.with(|rc| *rc.borrow()) == 0)); @@ -29,7 +33,18 @@ pub fn with_default_3(s: S) -> i32 { let s: Value = Rc::new(RefCell::new(s)); return { (*s.borrow()).v }; } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Holder { #[offset(0)] @@ -43,7 +58,7 @@ fn main_0() -> i32 { { let s: Value = Rc::new(RefCell::new(S { v: 1 })); let _dtor_s = - std::mem::DropGuard::new(s.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(s.clone(), |__p| Destructible::destroy(&__p.as_pointer())); assert!((({ by_value_2({ (*s.borrow()).clone() },) }) == 1)); assert!( (destroyed_0.with(|rc| *rc.borrow()) == 1) && (last_1.with(|rc| *rc.borrow()) == 1) @@ -88,15 +103,6 @@ impl HolderImpl for Ptr { return ((*self).with(|__s| __s.v) + { (*s.borrow()).v }); } } -pub trait SImpl { - fn destructor(&self); -} -impl SImpl for Ptr { - fn destructor(&self) { - (*destroyed_0.with(Value::clone).borrow_mut()).postfix_inc(); - last_1.with(|rc| *rc.borrow_mut() = (*self).with(|__s| __s.v)); - } -} pub fn __cpp2rust_init_globals() { let _ = destroyed_0.with(|_| ()); let _ = last_1.with(|_| ()); diff --git a/tests/unit/out/refcount/destructor_temporaries.rs b/tests/unit/out/refcount/destructor_temporaries.rs index d575fec9a1..c25682cce1 100644 --- a/tests/unit/out/refcount/destructor_temporaries.rs +++ b/tests/unit/out/refcount/destructor_temporaries.rs @@ -12,17 +12,19 @@ thread_local!( thread_local!( pub static last_1: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct S { #[offset(0)] pub v: i32, } -#[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, -)] +impl Destructible for S { + fn destroy(this: &Ptr) { + (*destroyed_0.with(Value::clone).borrow_mut()).postfix_inc(); + last_1.with(|rc| *rc.borrow_mut() = (*this).with(|__s| __s.v)); + } +} +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Outer { #[offset(0)] @@ -31,6 +33,11 @@ pub struct Outer { #[offset(4)] pub w: i32, } +impl Destructible for Outer { + fn destroy(this: &Ptr) { + Destructible::destroy(&field_ptr!(this, inner)); + } +} pub fn make_2(mut v: i32) -> S { return S { v: v }; } @@ -120,7 +127,7 @@ fn main_0() -> i32 { { let s: Value = Rc::new(RefCell::new(S { v: 12 })); let _dtor_s = - std::mem::DropGuard::new(s.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(s.clone(), |__p| Destructible::destroy(&__p.as_pointer())); let __rhs = ({ make_2(13) }); (*s.borrow_mut()) = __rhs; assert!( @@ -131,23 +138,10 @@ fn main_0() -> i32 { assert!((destroyed_0.with(|rc| *rc.borrow()) == 2) && (last_1.with(|rc| *rc.borrow()) == 13)); return 0; } -pub trait OuterImpl { - fn destructor(&self); -} -impl OuterImpl for Ptr { - fn destructor(&self) { - Destructible::destroy(field_ptr!(self, inner)); - } -} pub trait SImpl { - fn destructor(&self); fn get(&self) -> i32; } impl SImpl for Ptr { - fn destructor(&self) { - (*destroyed_0.with(Value::clone).borrow_mut()).postfix_inc(); - last_1.with(|rc| *rc.borrow_mut() = (*self).with(|__s| __s.v)); - } fn get(&self) -> i32 { return (*self).with(|__s| __s.v); } diff --git a/tests/unit/out/refcount/doubly_linked_list.rs b/tests/unit/out/refcount/doubly_linked_list.rs index 6f8fee4e55..2f8d9f12dc 100644 --- a/tests/unit/out/refcount/doubly_linked_list.rs +++ b/tests/unit/out/refcount/doubly_linked_list.rs @@ -6,7 +6,9 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(24)] pub struct Node { #[offset(0)] diff --git a/tests/unit/out/refcount/enum_default_in_static.rs b/tests/unit/out/refcount/enum_default_in_static.rs index 59f594d25d..0c83cd09dc 100644 --- a/tests/unit/out/refcount/enum_default_in_static.rs +++ b/tests/unit/out/refcount/enum_default_in_static.rs @@ -10,7 +10,18 @@ pub type Mode = u32; pub const Mode_MODE_NONE: Mode = 0; pub const Mode_MODE_ONE: Mode = 1; pub const Mode_MODE_TWO: Mode = 2; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Config { #[offset(0)] diff --git a/tests/unit/out/refcount/enum_int_interop.rs b/tests/unit/out/refcount/enum_int_interop.rs index ef653721a9..65ea7203a7 100644 --- a/tests/unit/out/refcount/enum_int_interop.rs +++ b/tests/unit/out/refcount/enum_int_interop.rs @@ -19,7 +19,9 @@ pub type Tag = u32; pub const Tag_TAG_ZERO: Tag = 0; pub const Tag_TAG_ONE: Tag = 1; pub const Tag_TAG_TWO: Tag = 2; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(16)] pub struct Entry { #[offset(0)] diff --git a/tests/unit/out/refcount/enum_int_interop_c.rs b/tests/unit/out/refcount/enum_int_interop_c.rs index ea4d1f5b82..88326b8ab0 100644 --- a/tests/unit/out/refcount/enum_int_interop_c.rs +++ b/tests/unit/out/refcount/enum_int_interop_c.rs @@ -19,7 +19,9 @@ pub type Tag_enum = u32; pub const Tag_enum_TAG_ZERO: Tag_enum = 0; pub const Tag_enum_TAG_ONE: Tag_enum = 1; pub const Tag_enum_TAG_TWO: Tag_enum = 2; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(16)] pub struct Entry { #[offset(0)] diff --git a/tests/unit/out/refcount/enum_underlying_type.rs b/tests/unit/out/refcount/enum_underlying_type.rs index 3abf11fce9..289812f810 100644 --- a/tests/unit/out/refcount/enum_underlying_type.rs +++ b/tests/unit/out/refcount/enum_underlying_type.rs @@ -25,7 +25,9 @@ pub type Scoped = i8; pub const Scoped_NEG: Scoped = -2; pub const Scoped_POS: Scoped = 2; pub type Empty = bool; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(1)] pub struct HoldsEmpty { #[offset(0)] diff --git a/tests/unit/out/refcount/exprs.rs b/tests/unit/out/refcount/exprs.rs index c85afbfb5b..fbd6ae2577 100644 --- a/tests/unit/out/refcount/exprs.rs +++ b/tests/unit/out/refcount/exprs.rs @@ -6,13 +6,26 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct X { #[offset(0)] pub x: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(16)] pub struct Y { #[offset(0)] diff --git a/tests/unit/out/refcount/fft.rs b/tests/unit/out/refcount/fft.rs index bb87bb2b8b..d2b9250904 100644 --- a/tests/unit/out/refcount/fft.rs +++ b/tests/unit/out/refcount/fft.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(16)] pub struct Complex { #[offset(0)] diff --git a/tests/unit/out/refcount/field_aliasing.rs b/tests/unit/out/refcount/field_aliasing.rs index db3e1c1fc0..76304864d6 100644 --- a/tests/unit/out/refcount/field_aliasing.rs +++ b/tests/unit/out/refcount/field_aliasing.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct In { #[offset(0)] @@ -14,7 +25,7 @@ pub struct In { #[offset(4)] pub y: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(32)] pub struct S { #[offset(0)] @@ -41,7 +52,9 @@ impl Default for S { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(16)] pub struct Node { #[offset(0)] diff --git a/tests/unit/out/refcount/field_array_elem_ptr.rs b/tests/unit/out/refcount/field_array_elem_ptr.rs index 14e0f76246..ce1212d113 100644 --- a/tests/unit/out/refcount/field_array_elem_ptr.rs +++ b/tests/unit/out/refcount/field_array_elem_ptr.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Point { #[offset(0)] @@ -14,7 +25,7 @@ pub struct Point { #[offset(4)] pub y: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(48)] pub struct Shape { #[offset(0)] diff --git a/tests/unit/out/refcount/field_method_receiver.rs b/tests/unit/out/refcount/field_method_receiver.rs index 22368ba7f8..fa79395ec9 100644 --- a/tests/unit/out/refcount/field_method_receiver.rs +++ b/tests/unit/out/refcount/field_method_receiver.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Counter { #[offset(0)] @@ -19,6 +30,7 @@ pub struct Counter { ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, CopyAssignable, Swappable, diff --git a/tests/unit/out/refcount/field_pointers.rs b/tests/unit/out/refcount/field_pointers.rs index f80aa2fa93..a786847e46 100644 --- a/tests/unit/out/refcount/field_pointers.rs +++ b/tests/unit/out/refcount/field_pointers.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(12)] pub struct Inner { #[offset(0)] @@ -26,7 +26,18 @@ impl Default for Inner { } } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Header { #[offset(0)] @@ -41,6 +52,7 @@ pub struct Header { ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, CopyAssignable, Swappable, diff --git a/tests/unit/out/refcount/field_pointers_malloced_struct.rs b/tests/unit/out/refcount/field_pointers_malloced_struct.rs index 169801a381..7841b69904 100644 --- a/tests/unit/out/refcount/field_pointers_malloced_struct.rs +++ b/tests/unit/out/refcount/field_pointers_malloced_struct.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(12)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/field_reinterpret_write_through.rs b/tests/unit/out/refcount/field_reinterpret_write_through.rs index a2acb2693c..5118789f6b 100644 --- a/tests/unit/out/refcount/field_reinterpret_write_through.rs +++ b/tests/unit/out/refcount/field_reinterpret_write_through.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct In { #[offset(0)] @@ -14,7 +25,7 @@ pub struct In { #[offset(4)] pub b: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(40)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/find.rs b/tests/unit/out/refcount/find.rs index 0bbb72b2dd..9ffe9bbeb8 100644 --- a/tests/unit/out/refcount/find.rs +++ b/tests/unit/out/refcount/find.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct P { #[offset(0)] diff --git a/tests/unit/out/refcount/first_field_ptr_covers_struct.rs b/tests/unit/out/refcount/first_field_ptr_covers_struct.rs index 985618301b..856f139bd7 100644 --- a/tests/unit/out/refcount/first_field_ptr_covers_struct.rs +++ b/tests/unit/out/refcount/first_field_ptr_covers_struct.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct In { #[offset(0)] @@ -14,7 +25,18 @@ pub struct In { #[offset(2)] pub b: i16, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(12)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/first_member_downcast.rs b/tests/unit/out/refcount/first_member_downcast.rs index e6e7ab310b..195568f94f 100644 --- a/tests/unit/out/refcount/first_member_downcast.rs +++ b/tests/unit/out/refcount/first_member_downcast.rs @@ -6,13 +6,35 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct base { #[offset(0)] pub kind: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(16)] pub struct derived { #[offset(0)] diff --git a/tests/unit/out/refcount/flex_array_member_incomplete.rs b/tests/unit/out/refcount/flex_array_member_incomplete.rs index 39b1d1818b..f1cd55656c 100644 --- a/tests/unit/out/refcount/flex_array_member_incomplete.rs +++ b/tests/unit/out/refcount/flex_array_member_incomplete.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(4)] pub struct F { #[offset(0)] diff --git a/tests/unit/out/refcount/flex_array_member_sibling_write.rs b/tests/unit/out/refcount/flex_array_member_sibling_write.rs index adaf0560a2..fb2308cf26 100644 --- a/tests/unit/out/refcount/flex_array_member_sibling_write.rs +++ b/tests/unit/out/refcount/flex_array_member_sibling_write.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(8)] pub struct S { #[offset(0)] @@ -26,7 +26,18 @@ impl Default for S { } } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct E { #[offset(0)] @@ -34,7 +45,7 @@ pub struct E { #[offset(4)] pub w: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(16)] pub struct T { #[offset(0)] diff --git a/tests/unit/out/refcount/fn_ptr.rs b/tests/unit/out/refcount/fn_ptr.rs index b530cfe295..8b4fab1644 100644 --- a/tests/unit/out/refcount/fn_ptr.rs +++ b/tests/unit/out/refcount/fn_ptr.rs @@ -29,7 +29,16 @@ pub fn identity_hash_6(mut v: bool) -> usize { return (v as usize); } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + Copyable, + Default, )] #[cpp_from(FnPtr u64 > , construct, ptr)] #[byte_size(8)] diff --git a/tests/unit/out/refcount/fn_ptr_cast.rs b/tests/unit/out/refcount/fn_ptr_cast.rs index 25418a6675..4795535e3a 100644 --- a/tests/unit/out/refcount/fn_ptr_cast.rs +++ b/tests/unit/out/refcount/fn_ptr_cast.rs @@ -24,7 +24,9 @@ pub fn test_double_cast_2() { assert!((({ fn2.call(5,) }) == 10)); assert!(({ (fn2).clone() } == { (fn_).clone() })); } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(8)] pub struct Command { #[offset(0)] diff --git a/tests/unit/out/refcount/fn_ptr_stable_sort.rs b/tests/unit/out/refcount/fn_ptr_stable_sort.rs index 53aef0e58e..fd8cbc9470 100644 --- a/tests/unit/out/refcount/fn_ptr_stable_sort.rs +++ b/tests/unit/out/refcount/fn_ptr_stable_sort.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Item { #[offset(0)] diff --git a/tests/unit/out/refcount/fn_ptr_struct.rs b/tests/unit/out/refcount/fn_ptr_struct.rs index 27637f8686..5b5a84f3c8 100644 --- a/tests/unit/out/refcount/fn_ptr_struct.rs +++ b/tests/unit/out/refcount/fn_ptr_struct.rs @@ -6,7 +6,9 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(16)] pub struct Handler { #[offset(0)] @@ -21,7 +23,18 @@ pub fn double_it_0(mut x: i32) -> i32 { pub fn negate_1(mut x: i32) -> i32 { return -x; } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct S {} impl S { @@ -35,7 +48,7 @@ impl S { return (x + 3); } } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Destructible, Default)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct MoveOnly { diff --git a/tests/unit/out/refcount/fn_ptr_typedef_cast.rs b/tests/unit/out/refcount/fn_ptr_typedef_cast.rs index f9f96308ba..b8085c2601 100644 --- a/tests/unit/out/refcount/fn_ptr_typedef_cast.rs +++ b/tests/unit/out/refcount/fn_ptr_typedef_cast.rs @@ -18,7 +18,18 @@ pub fn via_size_t_param_2(mut b: usize) -> u64 { pub fn via_size_t_return_3(mut b: u64) -> usize { return (b as usize); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct pair { #[offset(0)] diff --git a/tests/unit/out/refcount/fn_ptr_vtable.rs b/tests/unit/out/refcount/fn_ptr_vtable.rs index 92d68b3f1a..1e96ee5819 100644 --- a/tests/unit/out/refcount/fn_ptr_vtable.rs +++ b/tests/unit/out/refcount/fn_ptr_vtable.rs @@ -6,7 +6,9 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(24)] pub struct Vtable { #[offset(0)] diff --git a/tests/unit/out/refcount/fn_ref.rs b/tests/unit/out/refcount/fn_ref.rs index 402c5dbe88..bc8234aaf6 100644 --- a/tests/unit/out/refcount/fn_ref.rs +++ b/tests/unit/out/refcount/fn_ref.rs @@ -21,7 +21,9 @@ pub fn call_deduced_3(f: FnPtr i32>, mut x: i32) -> i32 { pub fn call_forwarded_4(f: FnPtr i32>, mut x: i32) -> i32 { return ({ f.call(x) }); } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(8)] pub struct Holder { #[offset(0)] diff --git a/tests/unit/out/refcount/for_body_destructor.rs b/tests/unit/out/refcount/for_body_destructor.rs index 4d1665e304..c0b9801e5b 100644 --- a/tests/unit/out/refcount/for_body_destructor.rs +++ b/tests/unit/out/refcount/for_body_destructor.rs @@ -6,14 +6,17 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct Guard { #[offset(0)] pub digit: i32, } +impl Destructible for Guard { + fn destroy(this: &Ptr) { + printf!(b"%d ", (*this).with(|__s| __s.digit)); + } +} pub fn step_0(i: Ptr) { printf!(b"9 "); i.with_mut(|__v| { @@ -32,11 +35,11 @@ fn main_0() -> i32 { 'for_body: { let first: Value = Rc::new(RefCell::new(Guard { digit: 1 })); let _dtor_first = std::mem::DropGuard::new(first.clone(), |__p| { - Destructible::destroy(__p.as_pointer()) + Destructible::destroy(&__p.as_pointer()) }); let second: Value = Rc::new(RefCell::new(Guard { digit: 2 })); let _dtor_second = std::mem::DropGuard::new(second.clone(), |__p| { - Destructible::destroy(__p.as_pointer()) + Destructible::destroy(&__p.as_pointer()) }); if ((*i.borrow()) == 0) { break 'for_body; @@ -52,7 +55,7 @@ fn main_0() -> i32 { 'for_body: { let g: Value = Rc::new(RefCell::new(Guard { digit: 3 })); let _dtor_g = std::mem::DropGuard::new(g.clone(), |__p| { - Destructible::destroy(__p.as_pointer()) + Destructible::destroy(&__p.as_pointer()) }); break 'loop_; } @@ -66,7 +69,7 @@ fn main_0() -> i32 { 'for_body: { let outer: Value = Rc::new(RefCell::new(Guard { digit: 4 })); let _dtor_outer = std::mem::DropGuard::new(outer.clone(), |__p| { - Destructible::destroy(__p.as_pointer()) + Destructible::destroy(&__p.as_pointer()) }); { let j: Value = Rc::new(RefCell::new(0)); @@ -74,7 +77,7 @@ fn main_0() -> i32 { 'for_body: { let inner: Value = Rc::new(RefCell::new(Guard { digit: 5 })); let _dtor_inner = std::mem::DropGuard::new(inner.clone(), |__p| { - Destructible::destroy(__p.as_pointer()) + Destructible::destroy(&__p.as_pointer()) }); if ((*j.borrow()) == 0) { break 'for_body; @@ -96,13 +99,13 @@ fn main_0() -> i32 { 'for_body: { let outer: Value = Rc::new(RefCell::new(Guard { digit: 4 })); let _dtor_outer = std::mem::DropGuard::new(outer.clone(), |__p| { - Destructible::destroy(__p.as_pointer()) + Destructible::destroy(&__p.as_pointer()) }); let mut j: i32 = 0; 'loop_: while ((*j.prefix_inc()) < 3) { let inner: Value = Rc::new(RefCell::new(Guard { digit: 5 })); let _dtor_inner = std::mem::DropGuard::new(inner.clone(), |__p| { - Destructible::destroy(__p.as_pointer()) + Destructible::destroy(&__p.as_pointer()) }); if (j == 1) { continue 'loop_; @@ -114,7 +117,7 @@ fn main_0() -> i32 { __do_while = false; let inner: Value = Rc::new(RefCell::new(Guard { digit: 6 })); let _dtor_inner = std::mem::DropGuard::new(inner.clone(), |__p| { - Destructible::destroy(__p.as_pointer()) + Destructible::destroy(&__p.as_pointer()) }); continue 'loop_; } @@ -125,7 +128,7 @@ fn main_0() -> i32 { let mut value: i32 = (value.read()); let inner: Value = Rc::new(RefCell::new(Guard { digit: value })); let _dtor_inner = std::mem::DropGuard::new(inner.clone(), |__p| { - Destructible::destroy(__p.as_pointer()) + Destructible::destroy(&__p.as_pointer()) }); if (value == 1) { continue 'loop_; @@ -143,7 +146,7 @@ fn main_0() -> i32 { 'loop_: loop { let condition: Value = Rc::new(RefCell::new(Guard { digit: i })); let _dtor_condition = std::mem::DropGuard::new(condition.clone(), |__p| { - Destructible::destroy(__p.as_pointer()) + Destructible::destroy(&__p.as_pointer()) }); if !({ GuardImpl::to_bool(&condition.as_pointer()) }) { break; @@ -151,7 +154,7 @@ fn main_0() -> i32 { 'for_body: { let body: Value = Rc::new(RefCell::new(Guard { digit: 4 })); let _dtor_body = std::mem::DropGuard::new(body.clone(), |__p| { - Destructible::destroy(__p.as_pointer()) + Destructible::destroy(&__p.as_pointer()) }); if (i == 2) { break 'for_body; @@ -168,12 +171,12 @@ fn main_0() -> i32 { { let init: Value = Rc::new(RefCell::new(Guard { digit: 5 })); let _dtor_init = - std::mem::DropGuard::new(init.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(init.clone(), |__p| Destructible::destroy(&__p.as_pointer())); 'loop_: while ((*i.borrow()) < 2) { 'for_body: { let body: Value = Rc::new(RefCell::new(Guard { digit: 6 })); let _dtor_body = std::mem::DropGuard::new(body.clone(), |__p| { - Destructible::destroy(__p.as_pointer()) + Destructible::destroy(&__p.as_pointer()) }); } ({ step_0(i.as_pointer()) }); @@ -187,7 +190,7 @@ fn main_0() -> i32 { digit: (*j.prefix_inc()), })); let _dtor_g = - std::mem::DropGuard::new(g.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(g.clone(), |__p| Destructible::destroy(&__p.as_pointer())); continue 'loop_; } } @@ -195,13 +198,9 @@ fn main_0() -> i32 { return 0; } pub trait GuardImpl { - fn destructor(&self); fn to_bool(&self) -> bool; } impl GuardImpl for Ptr { - fn destructor(&self) { - printf!(b"%d ", (*self).with(|__s| __s.digit)); - } fn to_bool(&self) -> bool { return ((*self).with(|__s| __s.digit) != 0); } diff --git a/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs b/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs index ea8a1df522..418f5f7166 100644 --- a/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs +++ b/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs @@ -13,6 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, CopyAssignable, Swappable, diff --git a/tests/unit/out/refcount/forward_basic.rs b/tests/unit/out/refcount/forward_basic.rs index ba8b8174da..9a48c48c83 100644 --- a/tests/unit/out/refcount/forward_basic.rs +++ b/tests/unit/out/refcount/forward_basic.rs @@ -16,6 +16,7 @@ pub const Overload_kRvalueOverload: Overload = 2; VaArg, FnPtrArg, CppFrom, + Destructible, CopyAssignable, MoveAssignable, Swappable, @@ -72,6 +73,7 @@ pub fn chosen_overload_1(_a0: Ptr) -> Overload { VaArg, FnPtrArg, CppFrom, + Destructible, CopyConstructible, CopyAssignable, MoveAssignable, diff --git a/tests/unit/out/refcount/forward_decltype.rs b/tests/unit/out/refcount/forward_decltype.rs index 3a2650ab31..80fe8d509e 100644 --- a/tests/unit/out/refcount/forward_decltype.rs +++ b/tests/unit/out/refcount/forward_decltype.rs @@ -16,6 +16,7 @@ pub const Overload_kRvalueOverload: Overload = 2; VaArg, FnPtrArg, CppFrom, + Destructible, CopyAssignable, MoveAssignable, Swappable, diff --git a/tests/unit/out/refcount/forward_explicit.rs b/tests/unit/out/refcount/forward_explicit.rs index 57c84bbb89..18f19eb42e 100644 --- a/tests/unit/out/refcount/forward_explicit.rs +++ b/tests/unit/out/refcount/forward_explicit.rs @@ -18,6 +18,7 @@ pub const Overload_kIntRvalueOverload: Overload = 4; VaArg, FnPtrArg, CppFrom, + Destructible, CopyAssignable, MoveAssignable, Swappable, diff --git a/tests/unit/out/refcount/forward_pack.rs b/tests/unit/out/refcount/forward_pack.rs index ebc800a707..42d2c2f8d6 100644 --- a/tests/unit/out/refcount/forward_pack.rs +++ b/tests/unit/out/refcount/forward_pack.rs @@ -18,6 +18,7 @@ pub const Overload_kIntRvalueOverload: Overload = 4; VaArg, FnPtrArg, CppFrom, + Destructible, CopyAssignable, MoveAssignable, Swappable, @@ -115,6 +116,7 @@ pub fn forward_pack_7( ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, CopyAssignable, MoveAssignable, diff --git a/tests/unit/out/refcount/friend.rs b/tests/unit/out/refcount/friend.rs index 80aa6a46a9..f7d2a25091 100644 --- a/tests/unit/out/refcount/friend.rs +++ b/tests/unit/out/refcount/friend.rs @@ -18,7 +18,18 @@ pub fn scaled_2(v: Ptr, mut k: i32) -> i32 { pub fn scaled_3(v: Ptr, mut k: f64) -> f64 { return ({ (v.with(|__s| __s.x) as f64) } * { k }); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct V { #[offset(0)] @@ -32,7 +43,18 @@ impl CppEq for V { pub fn get_4(w: Ptr) -> i32 { return w.with(|__s| __s.x); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct W_int_ { #[offset(0)] @@ -41,13 +63,35 @@ pub struct W_int_ { pub fn get_5(w: Ptr) -> i64 { return w.with(|__s| __s.x); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct W_long_ { #[offset(0)] pub x: i64, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct D { #[offset(0)] diff --git a/tests/unit/out/refcount/function_overloading.rs b/tests/unit/out/refcount/function_overloading.rs index f37fe4ffdf..b1ab134eb2 100644 --- a/tests/unit/out/refcount/function_overloading.rs +++ b/tests/unit/out/refcount/function_overloading.rs @@ -21,7 +21,18 @@ pub fn foo_3(mut x: Ptr, mut y: Ptr, z: Ptr) -> i32 { pub fn bar_4(x: Ptr) -> i32 { return (x.read()); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct Foo {} pub fn func_5(mut x: i32) -> i32 { diff --git a/tests/unit/out/refcount/global_call_temporaries.rs b/tests/unit/out/refcount/global_call_temporaries.rs index bc4213a4e8..3b8182691d 100644 --- a/tests/unit/out/refcount/global_call_temporaries.rs +++ b/tests/unit/out/refcount/global_call_temporaries.rs @@ -94,7 +94,18 @@ thread_local!( }) })); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Item { #[offset(0)] diff --git a/tests/unit/out/refcount/global_init_side_effect.rs b/tests/unit/out/refcount/global_init_side_effect.rs index 36d7010c2a..04c40e3b04 100644 --- a/tests/unit/out/refcount/global_init_side_effect.rs +++ b/tests/unit/out/refcount/global_init_side_effect.rs @@ -10,7 +10,17 @@ thread_local!( pub static total_0: Value = Rc::new(RefCell::new(0)); ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + Copyable, + Default, )] #[cpp_from(i32, construct, value)] #[byte_size(1)] diff --git a/tests/unit/out/refcount/global_non_const_init.rs b/tests/unit/out/refcount/global_non_const_init.rs index 6a0e7051cd..5fcb3f2525 100644 --- a/tests/unit/out/refcount/global_non_const_init.rs +++ b/tests/unit/out/refcount/global_non_const_init.rs @@ -32,7 +32,9 @@ thread_local!( pub static depends_on_call_6: Value = Rc::new(RefCell::new((from_call_5.with(|rc| *rc.borrow()) + 1))); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(4)] pub struct Ctor { #[offset(0)] @@ -77,7 +79,18 @@ thread_local!( Rc::try_unwrap(__v).ok().unwrap().into_inner() })); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct Holder {} thread_local!( @@ -96,7 +109,9 @@ thread_local!( Rc::try_unwrap(__v).ok().unwrap().into_inner() })); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(4)] pub struct Singleton { #[offset(0)] diff --git a/tests/unit/out/refcount/global_pointers.rs b/tests/unit/out/refcount/global_pointers.rs index c22c5fdaef..e6e5d870c6 100644 --- a/tests/unit/out/refcount/global_pointers.rs +++ b/tests/unit/out/refcount/global_pointers.rs @@ -6,7 +6,9 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(16)] pub struct Entry { #[offset(0)] diff --git a/tests/unit/out/refcount/global_without_initializer.rs b/tests/unit/out/refcount/global_without_initializer.rs index 4a0ec06bc3..3a0b902f95 100644 --- a/tests/unit/out/refcount/global_without_initializer.rs +++ b/tests/unit/out/refcount/global_without_initializer.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/goto_aggregate_default.rs b/tests/unit/out/refcount/goto_aggregate_default.rs index f52b28148b..1bd3ed041f 100644 --- a/tests/unit/out/refcount/goto_aggregate_default.rs +++ b/tests/unit/out/refcount/goto_aggregate_default.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Point { #[offset(0)] diff --git a/tests/unit/out/refcount/goto_cleanup.rs b/tests/unit/out/refcount/goto_cleanup.rs index b0a4f649f0..6c7b2e00f7 100644 --- a/tests/unit/out/refcount/goto_cleanup.rs +++ b/tests/unit/out/refcount/goto_cleanup.rs @@ -76,7 +76,9 @@ pub fn from_switch_2(mut n: i32) -> i32 { }); panic!("ub: non-void function does not return a value") } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(8)] pub struct wrapper { #[offset(0)] diff --git a/tests/unit/out/refcount/huffman.rs b/tests/unit/out/refcount/huffman.rs index cadcc8d3c0..55d16100fc 100644 --- a/tests/unit/out/refcount/huffman.rs +++ b/tests/unit/out/refcount/huffman.rs @@ -6,7 +6,9 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(24)] pub struct MinHeapNode { #[offset(0)] @@ -40,7 +42,7 @@ pub fn Swap_0(a: Ptr, b: Ptr) { right: (t.right).clone(), }); } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Swappable, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Swappable, Default)] #[byte_size(32)] pub struct MinHeap { #[offset(0)] diff --git a/tests/unit/out/refcount/immutable-deref-on-func-call.rs b/tests/unit/out/refcount/immutable-deref-on-func-call.rs index 8e7778a4cd..60f2c6aa0d 100644 --- a/tests/unit/out/refcount/immutable-deref-on-func-call.rs +++ b/tests/unit/out/refcount/immutable-deref-on-func-call.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Item { #[offset(0)] diff --git a/tests/unit/out/refcount/implicit_autoref.rs b/tests/unit/out/refcount/implicit_autoref.rs index 345492a4e7..bfd881dba1 100644 --- a/tests/unit/out/refcount/implicit_autoref.rs +++ b/tests/unit/out/refcount/implicit_autoref.rs @@ -13,6 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, CopyAssignable, Swappable, diff --git a/tests/unit/out/refcount/in_class_field_initializer.rs b/tests/unit/out/refcount/in_class_field_initializer.rs index fc563b7534..891a7a9dbf 100644 --- a/tests/unit/out/refcount/in_class_field_initializer.rs +++ b/tests/unit/out/refcount/in_class_field_initializer.rs @@ -6,7 +6,9 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(8)] pub struct Inner { #[offset(0)] @@ -19,7 +21,9 @@ impl Default for Inner { { Inner { x: 3, y: 4 } } } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(24)] pub struct S { #[offset(0)] @@ -45,7 +49,9 @@ impl Default for S { } } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(8)] pub struct Boxed_int_ { #[offset(0)] diff --git a/tests/unit/out/refcount/init.rs b/tests/unit/out/refcount/init.rs index dfa79e5525..35e6480e8f 100644 --- a/tests/unit/out/refcount/init.rs +++ b/tests/unit/out/refcount/init.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct X { #[offset(0)] diff --git a/tests/unit/out/refcount/init_list.rs b/tests/unit/out/refcount/init_list.rs index 5d90c0d7d7..97cc998466 100644 --- a/tests/unit/out/refcount/init_list.rs +++ b/tests/unit/out/refcount/init_list.rs @@ -9,7 +9,18 @@ use std::rc::{Rc, Weak}; pub fn f_0(list: Vec) { let list: Value> = Rc::new(RefCell::new(list)); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Pair { #[offset(0)] @@ -17,7 +28,9 @@ pub struct Pair { #[offset(4)] pub b: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(8)] pub struct Holder { #[offset(0)] @@ -36,7 +49,9 @@ impl Default for Holder { pub fn sum_1(p: Ptr) -> i32 { return ({ p.with(|__s| __s.a) } + { p.with(|__s| __s.b) }); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(4)] pub struct Seven { #[offset(0)] diff --git a/tests/unit/out/refcount/inline_container_fields.rs b/tests/unit/out/refcount/inline_container_fields.rs index 16887e5966..23cd250573 100644 --- a/tests/unit/out/refcount/inline_container_fields.rs +++ b/tests/unit/out/refcount/inline_container_fields.rs @@ -13,6 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, CopyAssignable, Swappable, @@ -70,6 +71,7 @@ impl Default for Elem { ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, CopyAssignable, Swappable, @@ -220,7 +222,7 @@ thread_local!( thread_local!( pub static move_assigns_5: Value = Rc::new(RefCell::new(0)); ); -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Swappable)] +#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Swappable)] #[byte_size(4)] pub struct Counted { #[offset(0)] diff --git a/tests/unit/out/refcount/kruskal.rs b/tests/unit/out/refcount/kruskal.rs index b709a7ae8f..005368c8f3 100644 --- a/tests/unit/out/refcount/kruskal.rs +++ b/tests/unit/out/refcount/kruskal.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(16)] pub struct Edge { #[offset(0)] @@ -99,7 +110,7 @@ pub fn quicksort_1(arr: Ptr>>>, mut start: i32, mut end ({ quicksort_1((arr).clone(), start, (p - 1)) }); ({ quicksort_1((arr).clone(), (p + 1), end) }); } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Swappable, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Swappable, Default)] #[byte_size(24)] pub struct DisjointSet { #[offset(0)] @@ -133,7 +144,7 @@ impl MoveAssignable for DisjointSet { return (*this).clone(); } } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Swappable, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Swappable, Default)] #[byte_size(16)] pub struct Graph { #[offset(0)] diff --git a/tests/unit/out/refcount/lambda_as_field.rs b/tests/unit/out/refcount/lambda_as_field.rs index b065f29b68..fad6f544a2 100644 --- a/tests/unit/out/refcount/lambda_as_field.rs +++ b/tests/unit/out/refcount/lambda_as_field.rs @@ -6,13 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(1)] pub struct Guard__lambda_at_lambda_as_field_cpp_34_13__ { #[offset(0)] #[byte_size(1)] pub f: FnPtr, } +impl Destructible for Guard__lambda_at_lambda_as_field_cpp_34_13__ { + fn destroy(this: &Ptr) { + ({ (*(*this).upgrade().deref()).f.call() }); + } +} impl Default for Guard__lambda_at_lambda_as_field_cpp_34_13__ { fn default() -> Self { { @@ -24,16 +29,19 @@ impl Default for Guard__lambda_at_lambda_as_field_cpp_34_13__ { } } } -#[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(8)] pub struct Guard__lambda_at_lambda_as_field_cpp_45_13__ { #[offset(0)] #[byte_size(8)] pub f: FnPtr, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +impl Destructible for Guard__lambda_at_lambda_as_field_cpp_45_13__ { + fn destroy(this: &Ptr) { + ({ (*(*this).upgrade().deref()).f.call() }); + } +} +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(8)] pub struct Holder__lambda_at_lambda_as_field_cpp_39_12__ { #[offset(0)] @@ -56,7 +64,9 @@ impl Default for Holder__lambda_at_lambda_as_field_cpp_39_12__ { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(8)] pub struct Holder__lambda_at_lambda_as_field_cpp_51_12__ { #[offset(0)] @@ -65,7 +75,7 @@ pub struct Holder__lambda_at_lambda_as_field_cpp_51_12__ { #[offset(4)] pub calls: i32, } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Destructible)] #[cpp_from(FnPtr i32 > , construct, value)] #[byte_size(8)] pub struct Moving__lambda_at_lambda_as_field_cpp_64_12__ { @@ -126,7 +136,7 @@ fn main_0() -> i32 { }), })); let _dtor_g = - std::mem::DropGuard::new(g.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(g.clone(), |__p| Destructible::destroy(&__p.as_pointer())); assert!((count_0.with(|rc| *rc.borrow()) == 0)); } assert!((count_0.with(|rc| *rc.borrow()) == 1)); @@ -158,7 +168,7 @@ fn main_0() -> i32 { ), })); let _dtor_g = - std::mem::DropGuard::new(g.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(g.clone(), |__p| Destructible::destroy(&__p.as_pointer())); assert!(({ ((*cleaned.borrow()) == 0) })); } assert!(({ ((*cleaned.borrow()) == 1) })); @@ -227,26 +237,6 @@ fn main_0() -> i32 { assert!(({ (*m2.borrow()).moves } == 1)); return 0; } -pub trait Guard__lambda_at_lambda_as_field_cpp_34_13__Impl { - fn destructor(&self); -} -impl Guard__lambda_at_lambda_as_field_cpp_34_13__Impl - for Ptr -{ - fn destructor(&self) { - ({ (*(*self).upgrade().deref()).f.call() }); - } -} -pub trait Guard__lambda_at_lambda_as_field_cpp_45_13__Impl { - fn destructor(&self); -} -impl Guard__lambda_at_lambda_as_field_cpp_45_13__Impl - for Ptr -{ - fn destructor(&self) { - ({ (*(*self).upgrade().deref()).f.call() }); - } -} pub trait Holder__lambda_at_lambda_as_field_cpp_39_12__Impl { fn call(&self, x: i32) -> i32; } diff --git a/tests/unit/out/refcount/lambda_capture_copy_ctor.rs b/tests/unit/out/refcount/lambda_capture_copy_ctor.rs index 0e4450a97a..fa5779da44 100644 --- a/tests/unit/out/refcount/lambda_capture_copy_ctor.rs +++ b/tests/unit/out/refcount/lambda_capture_copy_ctor.rs @@ -7,7 +7,15 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyAssignable, MoveAssignable, Swappable, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + CopyAssignable, + MoveAssignable, + Swappable, )] #[byte_size(8)] pub struct Counted { @@ -54,15 +62,7 @@ thread_local!( pub static drops_0: Value = Rc::new(RefCell::new(0)); ); #[derive( - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - Destructible, - CopyAssignable, - MoveAssignable, - Swappable, + Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyAssignable, MoveAssignable, Swappable, )] #[byte_size(1)] pub struct Dropped {} @@ -72,6 +72,11 @@ impl CopyConstructible for Dropped { impl MoveConstructible for Dropped { fn move_constructor(this: &Ptr, _a0: Ptr) {} } +impl Destructible for Dropped { + fn destroy(this: &Ptr) { + (*drops_0.with(Value::clone).borrow_mut()).postfix_inc(); + } +} impl Clone for Dropped { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(Dropped {})); @@ -184,10 +189,10 @@ fn main_0() -> i32 { || {} ))); let _dtor_m = - std::mem::DropGuard::new(m.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(m.clone(), |__p| Destructible::destroy(&__p.as_pointer())); let m2: Value> = Rc::new(RefCell::new((*m.borrow()).move_from())); let _dtor_m2 = - std::mem::DropGuard::new(m2.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(m2.clone(), |__p| Destructible::destroy(&__p.as_pointer())); } assert!((drops_0.with(|rc| *rc.borrow()) == 2)); { @@ -202,10 +207,10 @@ fn main_0() -> i32 { || {} ))); let _dtor_k = - std::mem::DropGuard::new(k.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(k.clone(), |__p| Destructible::destroy(&__p.as_pointer())); let k2: Value> = Rc::new(RefCell::new((*k.borrow()).copy_from())); let _dtor_k2 = - std::mem::DropGuard::new(k2.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(k2.clone(), |__p| Destructible::destroy(&__p.as_pointer())); } assert!((drops_0.with(|rc| *rc.borrow()) == 4)); { @@ -219,8 +224,9 @@ fn main_0() -> i32 { }, || {} ))); - let _dtor_inner = - std::mem::DropGuard::new(inner.clone(), |__p| Destructible::destroy(__p.as_pointer())); + let _dtor_inner = std::mem::DropGuard::new(inner.clone(), |__p| { + Destructible::destroy(&__p.as_pointer()) + }); let outer: Value> = Rc::new(RefCell::new(lambda!( { let inner: Value> = @@ -228,8 +234,9 @@ fn main_0() -> i32 { }, || {} ))); - let _dtor_outer = - std::mem::DropGuard::new(outer.clone(), |__p| Destructible::destroy(__p.as_pointer())); + let _dtor_outer = std::mem::DropGuard::new(outer.clone(), |__p| { + Destructible::destroy(&__p.as_pointer()) + }); } assert!((drops_0.with(|rc| *rc.borrow()) == 6)); return 0; @@ -245,13 +252,9 @@ impl CountedImpl for Ptr { } pub trait DroppedImpl { fn construct(&self); - fn destructor(&self); } impl DroppedImpl for Ptr { fn construct(&self) {} - fn destructor(&self) { - (*drops_0.with(Value::clone).borrow_mut()).postfix_inc(); - } } pub fn __cpp2rust_init_globals() { let _ = drops_0.with(|_| ()); diff --git a/tests/unit/out/refcount/lambda_capture_ref.rs b/tests/unit/out/refcount/lambda_capture_ref.rs index 822709ca3a..708c81ee8f 100644 --- a/tests/unit/out/refcount/lambda_capture_ref.rs +++ b/tests/unit/out/refcount/lambda_capture_ref.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/lambda_capture_star_this.rs b/tests/unit/out/refcount/lambda_capture_star_this.rs index 419ef201b5..5ac4e1d755 100644 --- a/tests/unit/out/refcount/lambda_capture_star_this.rs +++ b/tests/unit/out/refcount/lambda_capture_star_this.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/lambda_capture_this.rs b/tests/unit/out/refcount/lambda_capture_this.rs index e8e3f1acb4..6dcc0d3a5d 100644 --- a/tests/unit/out/refcount/lambda_capture_this.rs +++ b/tests/unit/out/refcount/lambda_capture_this.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/lambda_capture_value.rs b/tests/unit/out/refcount/lambda_capture_value.rs index 4bf6b69796..dd7ba0095a 100644 --- a/tests/unit/out/refcount/lambda_capture_value.rs +++ b/tests/unit/out/refcount/lambda_capture_value.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/lambda_decltype_type.rs b/tests/unit/out/refcount/lambda_decltype_type.rs index 2174dc0d37..caf6c587fe 100644 --- a/tests/unit/out/refcount/lambda_decltype_type.rs +++ b/tests/unit/out/refcount/lambda_decltype_type.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(24)] pub struct Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { #[offset(0)] @@ -34,7 +34,7 @@ impl Default for Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(24)] pub struct Sorted__lambda_at_lambda_decltype_type_cpp_19_23__ { #[offset(0)] diff --git a/tests/unit/out/refcount/lambda_generic_explicit_args.rs b/tests/unit/out/refcount/lambda_generic_explicit_args.rs index 492948022b..4bab369ba4 100644 --- a/tests/unit/out/refcount/lambda_generic_explicit_args.rs +++ b/tests/unit/out/refcount/lambda_generic_explicit_args.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Val { #[offset(0)] diff --git a/tests/unit/out/refcount/lambda_immediate_init.rs b/tests/unit/out/refcount/lambda_immediate_init.rs index 21ea249a7d..ddbfd8875f 100644 --- a/tests/unit/out/refcount/lambda_immediate_init.rs +++ b/tests/unit/out/refcount/lambda_immediate_init.rs @@ -9,7 +9,9 @@ use std::rc::{Rc, Weak}; pub fn pick_0(mut x: i32) -> i32 { return x; } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(8)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/lambda_move_only_capture.rs b/tests/unit/out/refcount/lambda_move_only_capture.rs index f43bde7dcf..55e497a35c 100644 --- a/tests/unit/out/refcount/lambda_move_only_capture.rs +++ b/tests/unit/out/refcount/lambda_move_only_capture.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Destructible, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Default)] #[cpp_from(i32, construct, value)] #[byte_size(8)] pub struct Owner { @@ -20,6 +20,11 @@ impl MoveConstructible for Owner { field!(o, p).write(Ptr::::null()); } } +impl Destructible for Owner { + fn destroy(this: &Ptr) { + (*this).with(|__s| __s.p.clone()).delete(); + } +} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); @@ -31,7 +36,7 @@ fn main_0() -> i32 { Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let _dtor_o = - std::mem::DropGuard::new(o.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(o.clone(), |__p| Destructible::destroy(&__p.as_pointer())); let f: Value i32>> = Rc::new(RefCell::new(lambda!( { let h: Value = Rc::new(RefCell::new({ @@ -45,12 +50,12 @@ fn main_0() -> i32 { } ))); let _dtor_f = - std::mem::DropGuard::new(f.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(f.clone(), |__p| Destructible::destroy(&__p.as_pointer())); assert!(({ (*o.borrow()).p.clone() }).is_null()); assert!(({ (({ (*f.borrow()).call() }) == 5) })); let g: Value i32>> = Rc::new(RefCell::new((*f.borrow()).move_from())); let _dtor_g = - std::mem::DropGuard::new(g.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(g.clone(), |__p| Destructible::destroy(&__p.as_pointer())); assert!(({ (({ (*g.borrow()).call() }) == 5) })); let total: Value = Rc::new(RefCell::new(0)); let consume: Value> = Rc::new(RefCell::new(lambda!( @@ -71,7 +76,7 @@ fn main_0() -> i32 { } ))); let _dtor_consume = std::mem::DropGuard::new(consume.clone(), |__p| { - Destructible::destroy(__p.as_pointer()) + Destructible::destroy(&__p.as_pointer()) }); ({ (*consume.borrow()).call() }); ({ (*consume.borrow()).call() }); @@ -82,27 +87,23 @@ fn main_0() -> i32 { Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let _dtor_o2 = - std::mem::DropGuard::new(o2.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(o2.clone(), |__p| Destructible::destroy(&__p.as_pointer())); let t: Value i32>> = Rc::new(RefCell::new(({ OwnerImpl::take(&o2.as_pointer()) }))); let _dtor_t = - std::mem::DropGuard::new(t.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(t.clone(), |__p| Destructible::destroy(&__p.as_pointer())); assert!(({ (*o2.borrow()).p.clone() }).is_null()); assert!(({ (({ (*t.borrow()).call() }) == 9) })); return 0; } pub trait OwnerImpl { fn construct(&self, v: i32); - fn destructor(&self); fn take(&self) -> FnPtr i32>; } impl OwnerImpl for Ptr { fn construct(&self, mut v: i32) { field!((*self), p).write(Ptr::alloc(v)); } - fn destructor(&self) { - (*self).with(|__s| __s.p.clone()).delete(); - } fn take(&self) -> FnPtr i32> { return lambda!( { diff --git a/tests/unit/out/refcount/lambda_nested.rs b/tests/unit/out/refcount/lambda_nested.rs index 7af0641263..86099a1d5d 100644 --- a/tests/unit/out/refcount/lambda_nested.rs +++ b/tests/unit/out/refcount/lambda_nested.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/lambda_static_local.rs b/tests/unit/out/refcount/lambda_static_local.rs index be19023729..19e5be804d 100644 --- a/tests/unit/out/refcount/lambda_static_local.rs +++ b/tests/unit/out/refcount/lambda_static_local.rs @@ -78,7 +78,18 @@ thread_local!( thread_local!( static calls_3: Value = Rc::new(RefCell::new(0)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct P_4 { #[offset(0)] diff --git a/tests/unit/out/refcount/libc_struct_without_default.rs b/tests/unit/out/refcount/libc_struct_without_default.rs index 64b3171264..5b317af604 100644 --- a/tests/unit/out/refcount/libc_struct_without_default.rs +++ b/tests/unit/out/refcount/libc_struct_without_default.rs @@ -13,6 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, CopyAssignable, Swappable, @@ -71,7 +72,7 @@ impl Default for UserDefined { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(16)] pub struct FieldIsLibcType { #[offset(0)] diff --git a/tests/unit/out/refcount/linked_list.rs b/tests/unit/out/refcount/linked_list.rs index 4bfdb59e58..ff42063ca8 100644 --- a/tests/unit/out/refcount/linked_list.rs +++ b/tests/unit/out/refcount/linked_list.rs @@ -6,7 +6,9 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(16)] pub struct Node { #[offset(0)] diff --git a/tests/unit/out/refcount/local_anon_struct_collision.rs b/tests/unit/out/refcount/local_anon_struct_collision.rs index e8293dbd61..160a144651 100644 --- a/tests/unit/out/refcount/local_anon_struct_collision.rs +++ b/tests/unit/out/refcount/local_anon_struct_collision.rs @@ -12,7 +12,18 @@ pub fn first_0() -> i32 { p.y = 2; return (p.x + p.y); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct anon_1 { #[offset(0)] @@ -26,7 +37,18 @@ pub fn second_2() -> i32 { q.b = 20_i64; return ((q.a + q.b) as i32); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(16)] pub struct anon_3 { #[offset(0)] diff --git a/tests/unit/out/refcount/local_record_template.rs b/tests/unit/out/refcount/local_record_template.rs index 8a9e2dab20..74cf1465ee 100644 --- a/tests/unit/out/refcount/local_record_template.rs +++ b/tests/unit/out/refcount/local_record_template.rs @@ -29,13 +29,35 @@ pub fn wrap_10(mut v: i64) -> i32 { let mut l: Local_7 = Local_7 { x: v }; return ({ get_6(l) }); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Local_5 { #[offset(0)] pub x: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Local_7 { #[offset(0)] @@ -45,7 +67,18 @@ pub fn other_11() -> i32 { let mut l: Local_1 = Local_1 { x: 3_i64, y: 4_i64 }; return (({ get_0(l) }) + (l.y as i32)); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(16)] pub struct Local_1 { #[offset(0)] @@ -66,7 +99,18 @@ fn main_0() -> i32 { assert!((({ wrap_10(6_i64,) }) == 6)); return 0; } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Local_3 { #[offset(0)] diff --git a/tests/unit/out/refcount/map.rs b/tests/unit/out/refcount/map.rs index 16636ffb66..94bb6dd99b 100644 --- a/tests/unit/out/refcount/map.rs +++ b/tests/unit/out/refcount/map.rs @@ -12,7 +12,9 @@ pub fn foo_0(mut x: u32) { pub fn bar_1(x: Ptr) { x.write((x.read()).wrapping_add(1_u32)); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(8)] pub struct Point { #[offset(0)] diff --git a/tests/unit/out/refcount/map_key_copy_ctor.rs b/tests/unit/out/refcount/map_key_copy_ctor.rs index 7502c5dcc6..17e56d6648 100644 --- a/tests/unit/out/refcount/map_key_copy_ctor.rs +++ b/tests/unit/out/refcount/map_key_copy_ctor.rs @@ -22,6 +22,7 @@ thread_local!( VaArg, FnPtrArg, CppFrom, + Destructible, CopyAssignable, MoveAssignable, Swappable, diff --git a/tests/unit/out/refcount/map_key_identity.rs b/tests/unit/out/refcount/map_key_identity.rs index 1c4806b26d..0ec9a86cb1 100644 --- a/tests/unit/out/refcount/map_key_identity.rs +++ b/tests/unit/out/refcount/map_key_identity.rs @@ -9,7 +9,18 @@ use std::rc::{Rc, Weak}; thread_local!( pub static default_constructions_0: Value = Rc::new(RefCell::new(0)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Key { #[offset(0)] @@ -33,7 +44,9 @@ pub fn operator_lt_1(a: Ptr, b: Ptr) -> bool { pub fn operator_eq_2(a: Ptr, b: Ptr) -> bool { return ({ a.with(|__s| __s.identity) } == { b.with(|__s| __s.identity) }); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(4)] pub struct Mapped { #[offset(0)] diff --git a/tests/unit/out/refcount/map_try_emplace.rs b/tests/unit/out/refcount/map_try_emplace.rs index dd2a6e0d24..d46c318386 100644 --- a/tests/unit/out/refcount/map_try_emplace.rs +++ b/tests/unit/out/refcount/map_try_emplace.rs @@ -25,6 +25,7 @@ thread_local!( VaArg, FnPtrArg, CppFrom, + Destructible, CopyAssignable, MoveAssignable, Swappable, @@ -73,7 +74,9 @@ pub fn argument_4(item: Ptr) -> Ptr { (*calls_0.with(Value::clone).borrow_mut()).prefix_inc(); return (item).clone(); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(4)] pub struct RefItem { #[offset(0)] diff --git a/tests/unit/out/refcount/map_try_emplace_lvalues.rs b/tests/unit/out/refcount/map_try_emplace_lvalues.rs index 7937065cce..643221e4b6 100644 --- a/tests/unit/out/refcount/map_try_emplace_lvalues.rs +++ b/tests/unit/out/refcount/map_try_emplace_lvalues.rs @@ -12,7 +12,9 @@ thread_local!( thread_local!( pub static visits_1: Value = Rc::new(RefCell::new(0)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(4)] pub struct Item { #[offset(0)] @@ -42,7 +44,7 @@ pub fn place_3(n: Ptr) -> Ptr { thread_local!( pub static temporary_calls_4: Value = Rc::new(RefCell::new(0)); ); -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(12)] pub struct Temporary { #[offset(0)] @@ -63,7 +65,9 @@ impl Default for Temporary { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(12)] pub struct Nested { #[offset(0)] @@ -80,7 +84,7 @@ pub fn make_temporary_5() -> Temporary { pub fn make_nested_6() -> Nested { return ::default(); } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Swappable)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Swappable)] #[byte_size(8)] pub struct Owner { #[offset(0)] @@ -112,7 +116,7 @@ impl Default for Owner { } } } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible)] #[byte_size(4)] pub struct Noncopy { #[offset(0)] @@ -123,7 +127,9 @@ impl Default for Noncopy { { Noncopy { n: 5 } } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Destructible, Copyable, +)] #[cpp_from(i32, construct_1, ptr)] #[byte_size(8)] pub struct Held { diff --git a/tests/unit/out/refcount/max.rs b/tests/unit/out/refcount/max.rs index 8c87cac03b..5a18960f6d 100644 --- a/tests/unit/out/refcount/max.rs +++ b/tests/unit/out/refcount/max.rs @@ -27,6 +27,7 @@ pub fn pick_3(mut i: i32) -> Ptr { VaArg, FnPtrArg, CppFrom, + Destructible, MoveConstructible, MoveAssignable, Swappable, diff --git a/tests/unit/out/refcount/memcpy_struct_bytes.rs b/tests/unit/out/refcount/memcpy_struct_bytes.rs index 46d437bba3..91d682ee59 100644 --- a/tests/unit/out/refcount/memcpy_struct_bytes.rs +++ b/tests/unit/out/refcount/memcpy_struct_bytes.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct point { #[offset(0)] diff --git a/tests/unit/out/refcount/memcpy_struct_layouts.rs b/tests/unit/out/refcount/memcpy_struct_layouts.rs index f0c1557b78..7775a6e873 100644 --- a/tests/unit/out/refcount/memcpy_struct_layouts.rs +++ b/tests/unit/out/refcount/memcpy_struct_layouts.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct packed { #[offset(0)] @@ -18,7 +29,18 @@ pub struct packed { #[offset(6)] pub d: i16, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(12)] pub struct reordered { #[offset(0)] @@ -28,7 +50,18 @@ pub struct reordered { #[offset(8)] pub c: i8, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(16)] pub struct tail { #[offset(0)] @@ -36,7 +69,18 @@ pub struct tail { #[offset(8)] pub b: f64, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(24)] pub struct nested { #[offset(0)] @@ -45,7 +89,7 @@ pub struct nested { #[offset(16)] pub c: i8, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(8)] pub struct array { #[offset(0)] diff --git a/tests/unit/out/refcount/memcpy_struct_struct.rs b/tests/unit/out/refcount/memcpy_struct_struct.rs index f7755f6d7e..830e7b3bbb 100644 --- a/tests/unit/out/refcount/memcpy_struct_struct.rs +++ b/tests/unit/out/refcount/memcpy_struct_struct.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Entry { #[offset(0)] diff --git a/tests/unit/out/refcount/memset_struct_tail.rs b/tests/unit/out/refcount/memset_struct_tail.rs index 3fe22a8794..f153f64372 100644 --- a/tests/unit/out/refcount/memset_struct_tail.rs +++ b/tests/unit/out/refcount/memset_struct_tail.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(32)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/move_assign.rs b/tests/unit/out/refcount/move_assign.rs index f77a9a7565..f9573b331e 100644 --- a/tests/unit/out/refcount/move_assign.rs +++ b/tests/unit/out/refcount/move_assign.rs @@ -6,7 +6,9 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Swappable, Default)] +#[derive( + Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Destructible, Swappable, Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct MoveOnly { @@ -29,7 +31,7 @@ impl MoveAssignable for MoveOnly { return (*this).clone(); } } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible)] #[byte_size(4)] pub struct ConstMoveAssign { #[offset(0)] diff --git a/tests/unit/out/refcount/move_ctor.rs b/tests/unit/out/refcount/move_ctor.rs index b7db265c19..08ef3312ce 100644 --- a/tests/unit/out/refcount/move_ctor.rs +++ b/tests/unit/out/refcount/move_ctor.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Destructible, Default)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct MoveOnly { @@ -19,7 +19,7 @@ impl MoveConstructible for MoveOnly { field!(o, v).write(0); } } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible)] #[byte_size(4)] pub struct ConstMove { #[offset(0)] @@ -43,6 +43,7 @@ impl Default for ConstMove { VaArg, FnPtrArg, CppFrom, + Destructible, CopyAssignable, MoveAssignable, Swappable, @@ -92,6 +93,7 @@ impl Clone for ThrowingMove { VaArg, FnPtrArg, CppFrom, + Destructible, CopyAssignable, MoveAssignable, Swappable, diff --git a/tests/unit/out/refcount/move_this.rs b/tests/unit/out/refcount/move_this.rs index 4dd99440e7..c104778360 100644 --- a/tests/unit/out/refcount/move_this.rs +++ b/tests/unit/out/refcount/move_this.rs @@ -13,6 +13,7 @@ use std::rc::{Rc, Weak}; VaArg, FnPtrArg, CppFrom, + Destructible, CopyAssignable, MoveAssignable, Swappable, diff --git a/tests/unit/out/refcount/nested_structs.rs b/tests/unit/out/refcount/nested_structs.rs index 25772e1e11..0a458a2036 100644 --- a/tests/unit/out/refcount/nested_structs.rs +++ b/tests/unit/out/refcount/nested_structs.rs @@ -6,13 +6,35 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Level0_Level1_1_Level2_1_Level3_1 { #[offset(0)] pub x1: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Level0_Level1_1_Level2_1_Level3_2 { #[offset(0)] @@ -20,19 +42,52 @@ pub struct Level0_Level1_1_Level2_1_Level3_2 { #[offset(4)] pub x2: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Level0_Level1_1_Level2_1 { #[offset(0)] pub x1: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Level0_Level1_1 { #[offset(0)] pub x1: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Level0_Level1_2 { #[offset(0)] @@ -40,7 +95,18 @@ pub struct Level0_Level1_2 { #[offset(4)] pub x2: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct Level0 {} pub fn main() { diff --git a/tests/unit/out/refcount/new.rs b/tests/unit/out/refcount/new.rs index b3ed2b3137..221cae51ee 100644 --- a/tests/unit/out/refcount/new.rs +++ b/tests/unit/out/refcount/new.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Pair { #[offset(0)] diff --git a/tests/unit/out/refcount/new_bst.rs b/tests/unit/out/refcount/new_bst.rs index 7f599d18c1..858cab58f3 100644 --- a/tests/unit/out/refcount/new_bst.rs +++ b/tests/unit/out/refcount/new_bst.rs @@ -6,7 +6,9 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(24)] pub struct node_t { #[offset(0)] diff --git a/tests/unit/out/refcount/new_struct.rs b/tests/unit/out/refcount/new_struct.rs index 07c06ee90a..4cc30a0eb4 100644 --- a/tests/unit/out/refcount/new_struct.rs +++ b/tests/unit/out/refcount/new_struct.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Pair { #[offset(0)] @@ -14,7 +25,18 @@ pub struct Pair { #[offset(4)] pub y: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(16)] pub struct Triple { #[offset(0)] diff --git a/tests/unit/out/refcount/nttp_distinct_specializations.rs b/tests/unit/out/refcount/nttp_distinct_specializations.rs index ba84d59bcb..b5dc29044c 100644 --- a/tests/unit/out/refcount/nttp_distinct_specializations.rs +++ b/tests/unit/out/refcount/nttp_distinct_specializations.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct S_2_ { #[offset(0)] @@ -14,13 +25,35 @@ pub struct S_2_ { #[offset(4)] pub w: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct S_1_ { #[offset(0)] pub v: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct S_3_ { #[offset(0)] diff --git a/tests/unit/out/refcount/offsetof.rs b/tests/unit/out/refcount/offsetof.rs index e15b51c545..36994ff6b2 100644 --- a/tests/unit/out/refcount/offsetof.rs +++ b/tests/unit/out/refcount/offsetof.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(12)] pub struct Layout { #[offset(0)] @@ -16,7 +27,7 @@ pub struct Layout { #[offset(8)] pub c: u16, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(66)] pub struct Frame { #[offset(0)] diff --git a/tests/unit/out/refcount/opaque_forward_decl.rs b/tests/unit/out/refcount/opaque_forward_decl.rs index 6d98671f7c..8cf372314e 100644 --- a/tests/unit/out/refcount/opaque_forward_decl.rs +++ b/tests/unit/out/refcount/opaque_forward_decl.rs @@ -6,7 +6,9 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(16)] pub struct container { #[offset(0)] diff --git a/tests/unit/out/refcount/opaque_record_copy.rs b/tests/unit/out/refcount/opaque_record_copy.rs index 582ae62cd0..895fb5a3d3 100644 --- a/tests/unit/out/refcount/opaque_record_copy.rs +++ b/tests/unit/out/refcount/opaque_record_copy.rs @@ -6,10 +6,32 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct Probe {} -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Wrapper_Probe_ { #[offset(0)] diff --git a/tests/unit/out/refcount/opaque_then_defined.rs b/tests/unit/out/refcount/opaque_then_defined.rs index cc73a24de7..2431b3fa76 100644 --- a/tests/unit/out/refcount/opaque_then_defined.rs +++ b/tests/unit/out/refcount/opaque_then_defined.rs @@ -6,7 +6,9 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(16)] pub struct list { #[offset(0)] @@ -15,7 +17,9 @@ pub struct list { #[offset(8)] pub size: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(16)] pub struct node { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_arithmetic_free.rs b/tests/unit/out/refcount/operator_arithmetic_free.rs index ac76f23327..0e6fc29041 100644 --- a/tests/unit/out/refcount/operator_arithmetic_free.rs +++ b/tests/unit/out/refcount/operator_arithmetic_free.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_arithmetic_member.rs b/tests/unit/out/refcount/operator_arithmetic_member.rs index 7ef07f17a9..e6cfbe1295 100644 --- a/tests/unit/out/refcount/operator_arithmetic_member.rs +++ b/tests/unit/out/refcount/operator_arithmetic_member.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_bitwise_free.rs b/tests/unit/out/refcount/operator_bitwise_free.rs index 98fb3a69fd..6e924fec5e 100644 --- a/tests/unit/out/refcount/operator_bitwise_free.rs +++ b/tests/unit/out/refcount/operator_bitwise_free.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_bitwise_member.rs b/tests/unit/out/refcount/operator_bitwise_member.rs index ddf3703aa6..87bf27bf14 100644 --- a/tests/unit/out/refcount/operator_bitwise_member.rs +++ b/tests/unit/out/refcount/operator_bitwise_member.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_comparison_defaulted.rs b/tests/unit/out/refcount/operator_comparison_defaulted.rs index 255d63070b..24c07de6a9 100644 --- a/tests/unit/out/refcount/operator_comparison_defaulted.rs +++ b/tests/unit/out/refcount/operator_comparison_defaulted.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Eq { #[offset(0)] @@ -19,7 +30,18 @@ impl CppEq for Eq { EqImpl::operator_eq(__lhs, __rhs.clone()) } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Cmp { #[offset(0)] @@ -37,7 +59,18 @@ impl CppEq for Cmp { CmpImpl::operator_cmp(__lhs, __rhs.clone()) == std::cmp::Ordering::Equal } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Both { #[offset(0)] @@ -53,7 +86,18 @@ impl CppEq for Both { BothImpl::operator_eq(__lhs, __rhs.clone()) } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct OrdOnly { #[offset(0)] @@ -69,7 +113,18 @@ impl CppEq for OrdOnly { OrdOnlyImpl::operator_cmp(__lhs, __rhs.clone()) == std::cmp::Ordering::Equal } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Inner { #[offset(0)] @@ -85,7 +140,18 @@ impl CppEq for Inner { InnerImpl::operator_cmp(__lhs, __rhs.clone()) == std::cmp::Ordering::Equal } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Outer { #[offset(0)] @@ -104,7 +170,18 @@ impl CppEq for Outer { OuterImpl::operator_cmp(__lhs, __rhs.clone()) == std::cmp::Ordering::Equal } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Secondary { #[offset(0)] @@ -120,7 +197,9 @@ impl CppEq for Secondary { SecondaryImpl::operator_eq(__lhs, __rhs.clone()) } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(8)] pub struct PtrMember { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_comparison_free.rs b/tests/unit/out/refcount/operator_comparison_free.rs index 88031e2d09..f71a6e8aee 100644 --- a/tests/unit/out/refcount/operator_comparison_free.rs +++ b/tests/unit/out/refcount/operator_comparison_free.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] @@ -46,7 +57,18 @@ pub fn operator_lt_6(a: Ptr, mut b: i32) -> bool { pub fn operator_lt_7(mut a: i32, b: Ptr) -> bool { return ({ a } < { b.with(|__s| __s.v) }); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct V { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_comparison_member.rs b/tests/unit/out/refcount/operator_comparison_member.rs index bf7d127387..05666dc49e 100644 --- a/tests/unit/out/refcount/operator_comparison_member.rs +++ b/tests/unit/out/refcount/operator_comparison_member.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_comparison_mixed.rs b/tests/unit/out/refcount/operator_comparison_mixed.rs index 223a953ab9..471115e727 100644 --- a/tests/unit/out/refcount/operator_comparison_mixed.rs +++ b/tests/unit/out/refcount/operator_comparison_mixed.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_comparison_nonbool.rs b/tests/unit/out/refcount/operator_comparison_nonbool.rs index 2089962407..3ce340e94a 100644 --- a/tests/unit/out/refcount/operator_comparison_nonbool.rs +++ b/tests/unit/out/refcount/operator_comparison_nonbool.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct X { #[offset(0)] @@ -40,19 +51,52 @@ pub fn operator_le_4(mut a: X, mut b: X) -> i32 { pub fn operator_ge_5(mut a: X, mut b: X) -> i32 { return if (a.v >= b.v) { 7 } else { 0 }; } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Result { #[offset(0)] pub r: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Custom { #[offset(0)] pub v: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Mixed { #[offset(0)] @@ -69,7 +113,17 @@ impl CppEq for Mixed { } } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + Copyable, + Default, )] #[cpp_into(bool, to_bool)] #[byte_size(1)] @@ -77,7 +131,18 @@ pub struct MyBool { #[offset(0)] pub value: bool, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Boolish { #[offset(0)] @@ -113,7 +178,7 @@ pub fn operator_lt_6(mut a: Boolish, mut b: Boolish) -> MyBool { Rc::try_unwrap(__v).ok().unwrap().into_inner() }; } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Destructible, Default)] #[cpp_into(bool, to_bool)] #[byte_size(1)] pub struct RefBool { @@ -127,7 +192,18 @@ thread_local!( Rc::try_unwrap(__v).ok().unwrap().into_inner() })); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct RefInt { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_comparison_noncopyable.rs b/tests/unit/out/refcount/operator_comparison_noncopyable.rs index ca82519550..c47a3d7af4 100644 --- a/tests/unit/out/refcount/operator_comparison_noncopyable.rs +++ b/tests/unit/out/refcount/operator_comparison_noncopyable.rs @@ -12,7 +12,7 @@ pub fn operator_eq_0(x: Ptr, y: Ptr) -> bool { pub fn operator_lt_1(x: Ptr, y: Ptr) -> bool { return ({ x.with(|__s| __s.data_) } < { y.with(|__s| __s.data_) }); } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Destructible, Default)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct S { diff --git a/tests/unit/out/refcount/operator_compound_assignment_free.rs b/tests/unit/out/refcount/operator_compound_assignment_free.rs index bc0b01c00e..56b85f7015 100644 --- a/tests/unit/out/refcount/operator_compound_assignment_free.rs +++ b/tests/unit/out/refcount/operator_compound_assignment_free.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_compound_assignment_member.rs b/tests/unit/out/refcount/operator_compound_assignment_member.rs index 9ca22ec6e9..2617630e38 100644 --- a/tests/unit/out/refcount/operator_compound_assignment_member.rs +++ b/tests/unit/out/refcount/operator_compound_assignment_member.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_friend.rs b/tests/unit/out/refcount/operator_friend.rs index 415a566ce9..c39d0b434a 100644 --- a/tests/unit/out/refcount/operator_friend.rs +++ b/tests/unit/out/refcount/operator_friend.rs @@ -10,7 +10,18 @@ pub fn operator_eq_0(_a0: Ptr, _a1: Ptr) -> bool { return ({ _a0.with(|__s| __s.a) } == { _a1.with(|__s| __s.a) }) && ({ _a0.with(|__s| __s.b) } == { _a1.with(|__s| __s.b) }); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Defaulted { #[offset(0)] @@ -38,7 +49,18 @@ pub fn operator_cmp_1(_a0: Ptr, _a1: Ptr) -> std::cm pub fn operator_eq_2(_a0: Ptr, _a1: Ptr) -> bool { return ({ _a0.with(|__s| __s.a) } == { _a1.with(|__s| __s.a) }); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct DefaultedOrd { #[offset(0)] @@ -65,7 +87,18 @@ pub fn operator_add_5(x: Ptr, y: Ptr) -> Inline { a: ({ x.with(|__s| __s.a) } + { y.with(|__s| __s.a) }), }; } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Inline { #[offset(0)] @@ -81,7 +114,18 @@ impl CppEq for Inline { operator_eq_3(__lhs.clone(), __rhs.clone()) } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct OutOfLine { #[offset(0)] @@ -107,7 +151,18 @@ pub fn operator_lt_9(x: Ptr, y: Ptr) -> bool { pub fn operator_eq_10(x: Ptr, y: Ptr) -> bool { return ({ (x.with(|__s| __s.v) as i64) } == { y.with(|__s| __s.v) }); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Tmpl_int_ { #[offset(0)] @@ -123,7 +178,18 @@ impl CppEq for Tmpl_int_ { operator_eq_8(__lhs.clone(), __rhs.clone()) } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Tmpl_long_ { #[offset(0)] @@ -132,7 +198,18 @@ pub struct Tmpl_long_ { pub fn operator_eq_11(_a0: Ptr, _a1: Ptr) -> bool { return ({ _a0.with(|__s| __s.v) } == { _a1.with(|__s| __s.v) }); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct TmplDefaulted_int_ { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_less_than.rs b/tests/unit/out/refcount/operator_less_than.rs index 8855ee962f..5eeef3d0d0 100644 --- a/tests/unit/out/refcount/operator_less_than.rs +++ b/tests/unit/out/refcount/operator_less_than.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Pair { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_logical_free.rs b/tests/unit/out/refcount/operator_logical_free.rs index 17b37fd64b..48c1b5c6bc 100644 --- a/tests/unit/out/refcount/operator_logical_free.rs +++ b/tests/unit/out/refcount/operator_logical_free.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_logical_member.rs b/tests/unit/out/refcount/operator_logical_member.rs index e648cb7fb6..5345dbd5f5 100644 --- a/tests/unit/out/refcount/operator_logical_member.rs +++ b/tests/unit/out/refcount/operator_logical_member.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_member_pointer_free.rs b/tests/unit/out/refcount/operator_member_pointer_free.rs index d87578ecb9..2c66cb5afb 100644 --- a/tests/unit/out/refcount/operator_member_pointer_free.rs +++ b/tests/unit/out/refcount/operator_member_pointer_free.rs @@ -6,13 +6,24 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Inner { #[offset(0)] pub x: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(16)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_member_pointer_member.rs b/tests/unit/out/refcount/operator_member_pointer_member.rs index 1e85a8e90f..86d4510d24 100644 --- a/tests/unit/out/refcount/operator_member_pointer_member.rs +++ b/tests/unit/out/refcount/operator_member_pointer_member.rs @@ -6,13 +6,35 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Inner { #[offset(0)] pub x: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct Table {} impl Table { @@ -23,7 +45,7 @@ impl Table { thread_local!( pub static table_0: Value> = Rc::new(RefCell::new(Box::new([7, 8, 9]))); ); -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(16)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_other_free.rs b/tests/unit/out/refcount/operator_other_free.rs index e03adf9161..409ab783e2 100644 --- a/tests/unit/out/refcount/operator_other_free.rs +++ b/tests/unit/out/refcount/operator_other_free.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_other_member.rs b/tests/unit/out/refcount/operator_other_member.rs index 03269a4298..6fcd805ee8 100644 --- a/tests/unit/out/refcount/operator_other_member.rs +++ b/tests/unit/out/refcount/operator_other_member.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct Static {} impl Static { @@ -15,7 +26,17 @@ impl Static { } } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + Copyable, + Default, )] #[cpp_into(i32, to_i32)] #[byte_size(4)] diff --git a/tests/unit/out/refcount/operator_overloads.rs b/tests/unit/out/refcount/operator_overloads.rs index de5e30139e..8846356ec0 100644 --- a/tests/unit/out/refcount/operator_overloads.rs +++ b/tests/unit/out/refcount/operator_overloads.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_qualifiers.rs b/tests/unit/out/refcount/operator_qualifiers.rs index 363da1beb3..1f63235bb0 100644 --- a/tests/unit/out/refcount/operator_qualifiers.rs +++ b/tests/unit/out/refcount/operator_qualifiers.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_three_way.rs b/tests/unit/out/refcount/operator_three_way.rs index d297d888bc..1483c52297 100644 --- a/tests/unit/out/refcount/operator_three_way.rs +++ b/tests/unit/out/refcount/operator_three_way.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_traits.rs b/tests/unit/out/refcount/operator_traits.rs index 3559c0352f..6ad9644827 100644 --- a/tests/unit/out/refcount/operator_traits.rs +++ b/tests/unit/out/refcount/operator_traits.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Lt { #[offset(0)] @@ -22,7 +33,18 @@ impl CppEq for Lt { !(LtImpl::operator_lt(__lhs, __rhs.clone())) && !(LtImpl::operator_lt(__rhs, __lhs.clone())) } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Eq { #[offset(0)] @@ -33,7 +55,18 @@ impl CppEq for Eq { EqImpl::operator_eq(__lhs, __rhs.clone()) } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Cmp { #[offset(0)] @@ -49,7 +82,18 @@ impl CppEq for Cmp { CmpImpl::operator_eq(__lhs, __rhs.clone()) } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Free { #[offset(0)] @@ -71,7 +115,18 @@ pub fn operator_lt_0(a: Ptr, b: Ptr) -> bool { pub fn operator_eq_1(a: Ptr, b: Ptr) -> bool { return ({ a.with(|__s| __s.v) } == { b.with(|__s| __s.v) }); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Wrapped_int_ { #[offset(0)] diff --git a/tests/unit/out/refcount/overload_mangling.rs b/tests/unit/out/refcount/overload_mangling.rs index 884fb41d4b..8d5fc58c8d 100644 --- a/tests/unit/out/refcount/overload_mangling.rs +++ b/tests/unit/out/refcount/overload_mangling.rs @@ -19,16 +19,49 @@ pub fn add_1(mut p: Ptr, mut n: i32) { pub fn twice_2(mut n: i32) -> i32 { return (n * 2); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct Access_S_ {} -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] pub base: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Box_ { #[offset(0)] diff --git a/tests/unit/out/refcount/pair_converting_construction.rs b/tests/unit/out/refcount/pair_converting_construction.rs index ede9e4b4cf..31fd836459 100644 --- a/tests/unit/out/refcount/pair_converting_construction.rs +++ b/tests/unit/out/refcount/pair_converting_construction.rs @@ -7,7 +7,17 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + Copyable, + Default, )] #[cpp_from(i32, construct, value)] #[byte_size(4)] @@ -16,7 +26,17 @@ pub struct Celsius { pub degrees: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + Copyable, + Default, )] #[cpp_into(i32, to_i32)] #[byte_size(4)] @@ -25,7 +45,17 @@ pub struct Meters { pub value: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + Copyable, + Default, )] #[cpp_from(Celsius, construct, ptr)] #[byte_size(4)] @@ -34,7 +64,17 @@ pub struct Label { pub id: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + Copyable, + Default, )] #[cpp_from(Celsius, construct_1, ptr)] #[cpp_from_move(Celsius, construct_2, ptr)] @@ -46,7 +86,17 @@ pub struct Owner { pub copied: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + Copyable, + Default, )] #[cpp_from(Celsius, construct, value)] #[byte_size(4)] @@ -54,7 +104,18 @@ pub struct Holder { #[offset(0)] pub value: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + Copyable, +)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct Fallback { @@ -72,14 +133,35 @@ impl Default for Fallback { } } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Counter { #[offset(0)] pub hits: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + Copyable, + Default, )] #[cpp_from(Counter, construct, mut_ptr)] #[byte_size(4)] @@ -88,7 +170,17 @@ pub struct Observer { pub seen: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + Copyable, + Default, )] #[cpp_from(Celsius, construct, ptr)] #[byte_size(4)] @@ -97,7 +189,17 @@ pub struct Tag { pub code: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + Copyable, + Default, )] #[cpp_from(Ptr< i8 > , construct, value)] #[byte_size(4)] diff --git a/tests/unit/out/refcount/pod.rs b/tests/unit/out/refcount/pod.rs index f4965c8e34..93604057df 100644 --- a/tests/unit/out/refcount/pod.rs +++ b/tests/unit/out/refcount/pod.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(12)] pub struct POD { #[offset(0)] diff --git a/tests/unit/out/refcount/pointer_array.rs b/tests/unit/out/refcount/pointer_array.rs index 229ca5e981..5a6f756a60 100644 --- a/tests/unit/out/refcount/pointer_array.rs +++ b/tests/unit/out/refcount/pointer_array.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(24)] pub struct StackArray { #[offset(0)] diff --git a/tests/unit/out/refcount/pointers.rs b/tests/unit/out/refcount/pointers.rs index fec0a64206..00b9e937ac 100644 --- a/tests/unit/out/refcount/pointers.rs +++ b/tests/unit/out/refcount/pointers.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Test { #[offset(0)] diff --git a/tests/unit/out/refcount/polymorphism.rs b/tests/unit/out/refcount/polymorphism.rs index a4e8c874de..cfdc0c2ddf 100644 --- a/tests/unit/out/refcount/polymorphism.rs +++ b/tests/unit/out/refcount/polymorphism.rs @@ -9,10 +9,32 @@ use std::rc::{Rc, Weak}; pub trait Animal { fn bark(&self) -> bool; } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Dog {} -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Cat {} pub fn main() { diff --git a/tests/unit/out/refcount/ptr_cast_init.rs b/tests/unit/out/refcount/ptr_cast_init.rs index fefcae70b3..73cfebcf5f 100644 --- a/tests/unit/out/refcount/ptr_cast_init.rs +++ b/tests/unit/out/refcount/ptr_cast_init.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct header { #[offset(0)] @@ -14,7 +25,18 @@ pub struct header { #[offset(4)] pub size: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct view { #[offset(0)] diff --git a/tests/unit/out/refcount/push_emplace_back.rs b/tests/unit/out/refcount/push_emplace_back.rs index 223d6a926a..fdcef4e945 100644 --- a/tests/unit/out/refcount/push_emplace_back.rs +++ b/tests/unit/out/refcount/push_emplace_back.rs @@ -6,13 +6,26 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Chunk { #[offset(0)] pub data: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(16)] pub struct Writer { #[offset(0)] @@ -29,6 +42,7 @@ pub struct Writer { ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, CopyAssignable, Swappable, @@ -134,7 +148,18 @@ pub fn self_ref_push_6(mut comps: Ptr>) { comps.with_mut(|__v: &mut Vec| __v.push(a0_clone)) }; } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + Copyable, +)] #[cpp_from(i32, construct_1, value)] #[byte_size(8)] pub struct Pair { @@ -310,6 +335,7 @@ pub fn emplace_ref_self_read_13(values: Ptr>) -> Ptr { ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, CopyAssignable, Swappable, @@ -373,7 +399,7 @@ pub fn emplace_from_element_14(mut v: Ptr>>) { v.with_mut(|__v: &mut Vec>| __v.push(__tmp_15)); }; } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(24)] pub struct Plain { #[offset(0)] @@ -406,7 +432,18 @@ thread_local!( pub static all_counted_16: Value>> = Rc::new(RefCell::new(Ptr::>::null())); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Counted { #[offset(0)] diff --git a/tests/unit/out/refcount/random.rs b/tests/unit/out/refcount/random.rs index 771ff49e92..2ffcd7de94 100644 --- a/tests/unit/out/refcount/random.rs +++ b/tests/unit/out/refcount/random.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(72)] pub struct Pair { #[offset(0)] @@ -51,7 +51,18 @@ impl Default for Pair { pub fn zero_0() -> i32 { return 0; } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct X1 {} pub fn foo_1(mut x1: i32, x2: Ptr, mut x3: Ptr, p2: Ptr, mut p3: Ptr) {} diff --git a/tests/unit/out/refcount/reference_wrapper.rs b/tests/unit/out/refcount/reference_wrapper.rs index eb1b3f6726..a04c1d154d 100644 --- a/tests/unit/out/refcount/reference_wrapper.rs +++ b/tests/unit/out/refcount/reference_wrapper.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Point { #[offset(0)] diff --git a/tests/unit/out/refcount/references.rs b/tests/unit/out/refcount/references.rs index ce04a50816..6ff278f0e7 100644 --- a/tests/unit/out/refcount/references.rs +++ b/tests/unit/out/refcount/references.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(16)] pub struct Pair { #[offset(0)] @@ -29,7 +29,9 @@ impl Default for Pair { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(16)] pub struct Nested { #[offset(0)] diff --git a/tests/unit/out/refcount/refs_as_args.rs b/tests/unit/out/refcount/refs_as_args.rs index 622077c6ae..b2dfbc5d6a 100644 --- a/tests/unit/out/refcount/refs_as_args.rs +++ b/tests/unit/out/refcount/refs_as_args.rs @@ -30,7 +30,18 @@ pub fn more_refs_0(x1: i32, x2: i32, r1: Ptr, r2: Ptr) { }; r1.write((rx2.read())); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Val { #[offset(0)] diff --git a/tests/unit/out/refcount/reinterpret_cast_ptr_cmp.rs b/tests/unit/out/refcount/reinterpret_cast_ptr_cmp.rs index 2c4c8b88e2..efe2391dbf 100644 --- a/tests/unit/out/refcount/reinterpret_cast_ptr_cmp.rs +++ b/tests/unit/out/refcount/reinterpret_cast_ptr_cmp.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct S { #[offset(0)] @@ -14,7 +25,7 @@ pub struct S { #[offset(4)] pub y: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(28)] pub struct W { #[offset(0)] @@ -34,7 +45,7 @@ impl Default for W { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(32)] pub struct P { #[offset(0)] diff --git a/tests/unit/out/refcount/reinterpret_cast_struct.rs b/tests/unit/out/refcount/reinterpret_cast_struct.rs index 294f2de046..9d25cc866c 100644 --- a/tests/unit/out/refcount/reinterpret_cast_struct.rs +++ b/tests/unit/out/refcount/reinterpret_cast_struct.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Point { #[offset(0)] diff --git a/tests/unit/out/refcount/reinterpret_cast_struct_to_struct.rs b/tests/unit/out/refcount/reinterpret_cast_struct_to_struct.rs index f4c6f98c50..2e5f87afc4 100644 --- a/tests/unit/out/refcount/reinterpret_cast_struct_to_struct.rs +++ b/tests/unit/out/refcount/reinterpret_cast_struct_to_struct.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Point { #[offset(0)] @@ -14,7 +25,18 @@ pub struct Point { #[offset(4)] pub y: u32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Pair { #[offset(0)] diff --git a/tests/unit/out/refcount/reserved_keywords.rs b/tests/unit/out/refcount/reserved_keywords.rs index 5eaf9015dd..fcc83ace8d 100644 --- a/tests/unit/out/refcount/reserved_keywords.rs +++ b/tests/unit/out/refcount/reserved_keywords.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(152)] pub struct S { #[offset(0)] @@ -86,13 +97,35 @@ pub struct S { #[offset(148)] pub vec_: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct type_ { #[offset(0)] pub v: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct loop_ { #[offset(0)] diff --git a/tests/unit/out/refcount/return_move.rs b/tests/unit/out/refcount/return_move.rs index 89d308e9c1..6efac38e6b 100644 --- a/tests/unit/out/refcount/return_move.rs +++ b/tests/unit/out/refcount/return_move.rs @@ -6,7 +6,9 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(16)] pub struct node { #[offset(0)] @@ -15,7 +17,9 @@ pub struct node { #[byte_size(8)] pub next: Ptr, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(16)] pub struct pair_t { #[offset(0)] diff --git a/tests/unit/out/refcount/rule_of_five.rs b/tests/unit/out/refcount/rule_of_five.rs index 9fa331c862..0998c8c2a5 100644 --- a/tests/unit/out/refcount/rule_of_five.rs +++ b/tests/unit/out/refcount/rule_of_five.rs @@ -15,9 +15,7 @@ thread_local!( thread_local!( pub static moves_2: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Destructible, Swappable, -)] +#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Swappable)] #[cpp_from(i32, construct, value)] #[byte_size(20)] pub struct Buffer { @@ -28,6 +26,11 @@ pub struct Buffer { #[offset(16)] pub size: i32, } +impl Destructible for Buffer { + fn destroy(this: &Ptr) { + (*alive_0.with(Value::clone).borrow_mut()).prefix_dec(); + } +} impl CopyConstructible for Buffer { fn copy_constructor(this: &Ptr, o: Ptr) { field!((*this), data).write((0..4).map(|_| 0_i32).collect::>()); @@ -127,7 +130,7 @@ pub fn make_3(mut size: i32) -> Buffer { Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let _dtor_b = - std::mem::DropGuard::new(b.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(b.clone(), |__p| Destructible::destroy(&__p.as_pointer())); return { let __v: Value = Rc::new(RefCell::new(::zero_init())); MoveConstructible::move_constructor(&__v.as_pointer(), { b.as_pointer() }); @@ -146,14 +149,14 @@ fn main_0() -> i32 { Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let _dtor_a = - std::mem::DropGuard::new(a.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(a.clone(), |__p| Destructible::destroy(&__p.as_pointer())); let b: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); CopyConstructible::copy_constructor(&__v.as_pointer(), { a.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let _dtor_b = - std::mem::DropGuard::new(b.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(b.clone(), |__p| Destructible::destroy(&__p.as_pointer())); assert!( ((alive_0.with(|rc| *rc.borrow()) == 2) && (copies_1.with(|rc| *rc.borrow()) == 1)) && (moves_2.with(|rc| *rc.borrow()) == 0) @@ -166,7 +169,7 @@ fn main_0() -> i32 { Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let _dtor_c = - std::mem::DropGuard::new(c.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(c.clone(), |__p| Destructible::destroy(&__p.as_pointer())); assert!((alive_0.with(|rc| *rc.borrow()) == 3) && (moves_2.with(|rc| *rc.borrow()) == 1)); assert!( ({ (*a.borrow()).size } == 0) @@ -177,7 +180,7 @@ fn main_0() -> i32 { ); let d: Value = Rc::new(RefCell::new(({ make_3(2) }))); let _dtor_d = - std::mem::DropGuard::new(d.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(d.clone(), |__p| Destructible::destroy(&__p.as_pointer())); assert!(({ (*d.borrow()).size } == 2) && (moves_2.with(|rc| *rc.borrow()) == 2)); ({ CopyAssignable::copy_assign(&d.as_pointer(), b.as_pointer()) }); assert!( @@ -198,7 +201,6 @@ fn main_0() -> i32 { } pub trait BufferImpl { fn construct(&self, size: i32); - fn destructor(&self); } impl BufferImpl for Ptr { fn construct(&self, mut size: i32) { @@ -215,9 +217,6 @@ impl BufferImpl for Ptr { } (*alive_0.with(Value::clone).borrow_mut()).prefix_inc(); } - fn destructor(&self) { - (*alive_0.with(Value::clone).borrow_mut()).prefix_dec(); - } } pub fn __cpp2rust_init_globals() { let _ = alive_0.with(|_| ()); diff --git a/tests/unit/out/refcount/rule_of_three.rs b/tests/unit/out/refcount/rule_of_three.rs index 2957c92f45..42496b8975 100644 --- a/tests/unit/out/refcount/rule_of_three.rs +++ b/tests/unit/out/refcount/rule_of_three.rs @@ -19,7 +19,6 @@ thread_local!( VaArg, FnPtrArg, CppFrom, - Destructible, MoveConstructible, MoveAssignable, Swappable, @@ -34,6 +33,11 @@ pub struct Buffer { #[offset(16)] pub size: i32, } +impl Destructible for Buffer { + fn destroy(this: &Ptr) { + (*alive_0.with(Value::clone).borrow_mut()).prefix_dec(); + } +} impl CopyConstructible for Buffer { fn copy_constructor(this: &Ptr, o: Ptr) { field!((*this), data).write((0..4).map(|_| 0_i32).collect::>()); @@ -111,14 +115,14 @@ fn main_0() -> i32 { Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let _dtor_a = - std::mem::DropGuard::new(a.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(a.clone(), |__p| Destructible::destroy(&__p.as_pointer())); let b: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); CopyConstructible::copy_constructor(&__v.as_pointer(), { a.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let _dtor_b = - std::mem::DropGuard::new(b.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(b.clone(), |__p| Destructible::destroy(&__p.as_pointer())); assert!((alive_0.with(|rc| *rc.borrow()) == 2) && (copies_1.with(|rc| *rc.borrow()) == 1)); array_elem!(b.as_pointer(), data, 0).write(100); assert!(((array_elem!(a.as_pointer(), data, 0).read()) == 0)); @@ -128,7 +132,7 @@ fn main_0() -> i32 { Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let _dtor_c = - std::mem::DropGuard::new(c.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(c.clone(), |__p| Destructible::destroy(&__p.as_pointer())); ({ CopyAssignable::copy_assign(&c.as_pointer(), a.as_pointer()) }); assert!( ({ (*c.borrow()).size } == 4) && ((array_elem!(c.as_pointer(), data, 3).read()) == 3) @@ -144,7 +148,7 @@ fn main_0() -> i32 { Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let _dtor_d = - std::mem::DropGuard::new(d.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(d.clone(), |__p| Destructible::destroy(&__p.as_pointer())); assert!((alive_0.with(|rc| *rc.borrow()) == 4) && (copies_1.with(|rc| *rc.borrow()) == 3)); assert!( ({ (*a.borrow()).size } == 4) && ((array_elem!(a.as_pointer(), data, 3).read()) == 3) @@ -161,7 +165,6 @@ fn main_0() -> i32 { } pub trait BufferImpl { fn construct(&self, size: i32); - fn destructor(&self); } impl BufferImpl for Ptr { fn construct(&self, mut size: i32) { @@ -178,9 +181,6 @@ impl BufferImpl for Ptr { } (*alive_0.with(Value::clone).borrow_mut()).prefix_inc(); } - fn destructor(&self) { - (*alive_0.with(Value::clone).borrow_mut()).prefix_dec(); - } } pub fn __cpp2rust_init_globals() { let _ = alive_0.with(|_| ()); diff --git a/tests/unit/out/refcount/rvalue_rule_arg_move.rs b/tests/unit/out/refcount/rvalue_rule_arg_move.rs index d6b8e9ed1d..c9a4113809 100644 --- a/tests/unit/out/refcount/rvalue_rule_arg_move.rs +++ b/tests/unit/out/refcount/rvalue_rule_arg_move.rs @@ -19,6 +19,7 @@ thread_local!( VaArg, FnPtrArg, CppFrom, + Destructible, MoveAssignable, Swappable, Default, diff --git a/tests/unit/out/refcount/rvalue_struct.rs b/tests/unit/out/refcount/rvalue_struct.rs index cae6d63f58..d6ec68ea12 100644 --- a/tests/unit/out/refcount/rvalue_struct.rs +++ b/tests/unit/out/refcount/rvalue_struct.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/scalar_builtin_construct_destruct.rs b/tests/unit/out/refcount/scalar_builtin_construct_destruct.rs index 5c66392ca3..ed4aea1f54 100644 --- a/tests/unit/out/refcount/scalar_builtin_construct_destruct.rs +++ b/tests/unit/out/refcount/scalar_builtin_construct_destruct.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Pod { #[offset(0)] diff --git a/tests/unit/out/refcount/self_referencing_initializer.rs b/tests/unit/out/refcount/self_referencing_initializer.rs index d4a60f4798..1d66d96e9a 100644 --- a/tests/unit/out/refcount/self_referencing_initializer.rs +++ b/tests/unit/out/refcount/self_referencing_initializer.rs @@ -6,14 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(8)] pub struct list_head { #[offset(0)] #[byte_size(8)] pub next: Ptr, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(16)] pub struct node { #[offset(0)] @@ -22,7 +26,7 @@ pub struct node { #[byte_size(8)] pub value_ptr: Ptr, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(16)] pub struct node_with_defaults { #[offset(0)] diff --git a/tests/unit/out/refcount/size_t_static_member.rs b/tests/unit/out/refcount/size_t_static_member.rs index 7c5e1d52b7..770ab41197 100644 --- a/tests/unit/out/refcount/size_t_static_member.rs +++ b/tests/unit/out/refcount/size_t_static_member.rs @@ -9,13 +9,35 @@ use std::rc::{Rc, Weak}; thread_local!( pub static c_0: Value = Rc::new(RefCell::new(5_usize)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct S {} thread_local!( pub static table_size_1: Value = Rc::new(RefCell::new(256_usize)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct Table_char_ {} pub fn main() { diff --git a/tests/unit/out/refcount/size_t_template_param.rs b/tests/unit/out/refcount/size_t_template_param.rs index d17cae2aab..4df9bccb72 100644 --- a/tests/unit/out/refcount/size_t_template_param.rs +++ b/tests/unit/out/refcount/size_t_template_param.rs @@ -11,7 +11,17 @@ pub fn array_ref_0(a: Ptr) -> u64 { return (elem!(a, (3_u64 as u64).wrapping_sub(1_u64)).read()); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + Copyable, + Default, )] #[cpp_from(Ptr< u64 > , construct, value)] #[byte_size(8)] @@ -20,7 +30,17 @@ pub struct PtrCtor_unsigned_long_ { pub v: u64, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + Copyable, + Default, )] #[cpp_from(u64, construct, ptr)] #[byte_size(8)] diff --git a/tests/unit/out/refcount/sort_no_copy.rs b/tests/unit/out/refcount/sort_no_copy.rs index 785bb7b5ea..be37c3749a 100644 --- a/tests/unit/out/refcount/sort_no_copy.rs +++ b/tests/unit/out/refcount/sort_no_copy.rs @@ -9,7 +9,9 @@ use std::rc::{Rc, Weak}; thread_local!( pub static copies_0: Value = Rc::new(RefCell::new(0)); ); -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Swappable)] +#[derive( + Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Destructible, Swappable, +)] #[cpp_from(i32, construct_1, value)] #[byte_size(4)] pub struct Tracked { @@ -76,7 +78,9 @@ pub fn operator_lt_1(a: Ptr, b: Ptr) -> bool { pub fn greater_2(a: Ptr, b: Ptr) -> bool { return ({ a.with(|__s| __s.v) } > { b.with(|__s| __s.v) }); } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Swappable, Default)] +#[derive( + Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Destructible, Swappable, Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct MoveOnly { @@ -115,6 +119,7 @@ pub fn operator_lt_3(a: Ptr, b: Ptr) -> bool { ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, CopyAssignable, Swappable, diff --git a/tests/unit/out/refcount/static_local.rs b/tests/unit/out/refcount/static_local.rs index 4501711810..3ed175144e 100644 --- a/tests/unit/out/refcount/static_local.rs +++ b/tests/unit/out/refcount/static_local.rs @@ -33,7 +33,18 @@ pub fn from_local_class_6() -> i32 { thread_local!( static x_7: Value = Rc::new(RefCell::new(3)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct S_8 {} pub fn main() { diff --git a/tests/unit/out/refcount/static_var_in_class.rs b/tests/unit/out/refcount/static_var_in_class.rs index ffc512cf90..8d391a6b1b 100644 --- a/tests/unit/out/refcount/static_var_in_class.rs +++ b/tests/unit/out/refcount/static_var_in_class.rs @@ -9,7 +9,18 @@ use std::rc::{Rc, Weak}; thread_local!( static inner_const_0: Value = Rc::new(RefCell::new(1)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct C {} thread_local!( @@ -17,7 +28,18 @@ thread_local!( ); pub type anon_3 = u32; pub const anon_3_kValue: anon_3 = 3; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct S {} impl S { diff --git a/tests/unit/out/refcount/stdcopy.rs b/tests/unit/out/refcount/stdcopy.rs index 9dbccf6d00..6d528d4b26 100644 --- a/tests/unit/out/refcount/stdcopy.rs +++ b/tests/unit/out/refcount/stdcopy.rs @@ -7,7 +7,17 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + Copyable, + Default, )] #[cpp_from(i32, construct, value)] #[byte_size(4)] diff --git a/tests/unit/out/refcount/strdup.rs b/tests/unit/out/refcount/strdup.rs index 7caf4818ea..9b7f36ba1c 100644 --- a/tests/unit/out/refcount/strdup.rs +++ b/tests/unit/out/refcount/strdup.rs @@ -6,7 +6,9 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(8)] pub struct record { #[offset(0)] diff --git a/tests/unit/out/refcount/string_literal_ptr_init.rs b/tests/unit/out/refcount/string_literal_ptr_init.rs index 3b4142ca28..a9db369bff 100644 --- a/tests/unit/out/refcount/string_literal_ptr_init.rs +++ b/tests/unit/out/refcount/string_literal_ptr_init.rs @@ -6,7 +6,9 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(24)] pub struct label { #[offset(0)] diff --git a/tests/unit/out/refcount/string_substr.rs b/tests/unit/out/refcount/string_substr.rs index 11850d446c..9654157b5f 100644 --- a/tests/unit/out/refcount/string_substr.rs +++ b/tests/unit/out/refcount/string_substr.rs @@ -6,7 +6,9 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(8)] pub struct Text { #[offset(0)] diff --git a/tests/unit/out/refcount/struct_2d_array_field.rs b/tests/unit/out/refcount/struct_2d_array_field.rs index 3d1f30235f..8d55fa4e4c 100644 --- a/tests/unit/out/refcount/struct_2d_array_field.rs +++ b/tests/unit/out/refcount/struct_2d_array_field.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(40)] pub struct table { #[offset(0)] diff --git a/tests/unit/out/refcount/struct_ctor.rs b/tests/unit/out/refcount/struct_ctor.rs index 1170386126..6d9217fe9a 100644 --- a/tests/unit/out/refcount/struct_ctor.rs +++ b/tests/unit/out/refcount/struct_ctor.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct StructWithCtor { #[offset(0)] @@ -18,7 +29,17 @@ pub fn foo_0(x: Ptr) -> Ptr { return (x).clone(); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + Copyable, + Default, )] #[cpp_from(i32, construct, value)] #[byte_size(4)] @@ -26,7 +47,9 @@ pub struct Value_ { #[offset(0)] pub v: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(8)] pub struct Ptr_ { #[offset(0)] diff --git a/tests/unit/out/refcount/struct_default_ctor.rs b/tests/unit/out/refcount/struct_default_ctor.rs index 5c9b995f00..02999b4f04 100644 --- a/tests/unit/out/refcount/struct_default_ctor.rs +++ b/tests/unit/out/refcount/struct_default_ctor.rs @@ -6,7 +6,9 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(8)] pub struct S { #[offset(0)] @@ -25,13 +27,24 @@ impl Default for S { } } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Declared { #[offset(0)] pub v: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(16)] pub struct Holder { #[offset(0)] @@ -51,7 +64,9 @@ impl Default for Holder { thread_local!( pub static kInit_0: Value = Rc::new(RefCell::new(3)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(4)] pub struct FromStatic { #[offset(0)] diff --git a/tests/unit/out/refcount/struct_member_array_adjacency.rs b/tests/unit/out/refcount/struct_member_array_adjacency.rs index 15478370e1..0f42dbdec4 100644 --- a/tests/unit/out/refcount/struct_member_array_adjacency.rs +++ b/tests/unit/out/refcount/struct_member_array_adjacency.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(32)] pub struct pair { #[offset(0)] diff --git a/tests/unit/out/refcount/struct_ptr.rs b/tests/unit/out/refcount/struct_ptr.rs index 2507420182..645a01d1e2 100644 --- a/tests/unit/out/refcount/struct_ptr.rs +++ b/tests/unit/out/refcount/struct_ptr.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct XX { #[offset(0)] diff --git a/tests/unit/out/refcount/structured_binding_copy_ctor.rs b/tests/unit/out/refcount/structured_binding_copy_ctor.rs index 875b5ee942..64219f955c 100644 --- a/tests/unit/out/refcount/structured_binding_copy_ctor.rs +++ b/tests/unit/out/refcount/structured_binding_copy_ctor.rs @@ -15,6 +15,7 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, + Destructible, MoveConstructible, MoveAssignable, Swappable, diff --git a/tests/unit/out/refcount/structured_binding_element_ctor.rs b/tests/unit/out/refcount/structured_binding_element_ctor.rs index 0ec2dc6d64..c604e9ece0 100644 --- a/tests/unit/out/refcount/structured_binding_element_ctor.rs +++ b/tests/unit/out/refcount/structured_binding_element_ctor.rs @@ -19,6 +19,7 @@ thread_local!( VaArg, FnPtrArg, CppFrom, + Destructible, CopyAssignable, MoveAssignable, Swappable, @@ -58,6 +59,7 @@ impl Clone for Elem { ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, CopyAssignable, MoveAssignable, diff --git a/tests/unit/out/refcount/structured_binding_move_ctor.rs b/tests/unit/out/refcount/structured_binding_move_ctor.rs index 120211f055..9343853cc3 100644 --- a/tests/unit/out/refcount/structured_binding_move_ctor.rs +++ b/tests/unit/out/refcount/structured_binding_move_ctor.rs @@ -18,6 +18,7 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyAssignable, MoveAssignable, Swappable, @@ -64,6 +65,7 @@ impl Clone for Movable { ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, CopyAssignable, Swappable, diff --git a/tests/unit/out/refcount/structured_binding_range_for.rs b/tests/unit/out/refcount/structured_binding_range_for.rs index eb06fdb8d5..7569d20585 100644 --- a/tests/unit/out/refcount/structured_binding_range_for.rs +++ b/tests/unit/out/refcount/structured_binding_range_for.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Pair { #[offset(0)] diff --git a/tests/unit/out/refcount/structured_binding_ref.rs b/tests/unit/out/refcount/structured_binding_ref.rs index b010b6d55f..6e61003ae0 100644 --- a/tests/unit/out/refcount/structured_binding_ref.rs +++ b/tests/unit/out/refcount/structured_binding_ref.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(12)] pub struct Triple { #[offset(0)] diff --git a/tests/unit/out/refcount/structured_binding_trivial.rs b/tests/unit/out/refcount/structured_binding_trivial.rs index ee0f7e0e40..49f6ed7177 100644 --- a/tests/unit/out/refcount/structured_binding_trivial.rs +++ b/tests/unit/out/refcount/structured_binding_trivial.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Pair { #[offset(0)] diff --git a/tests/unit/out/refcount/swap_map_no_copy.rs b/tests/unit/out/refcount/swap_map_no_copy.rs index 1fd8ea5744..88a42d3bb0 100644 --- a/tests/unit/out/refcount/swap_map_no_copy.rs +++ b/tests/unit/out/refcount/swap_map_no_copy.rs @@ -9,7 +9,9 @@ use std::rc::{Rc, Weak}; thread_local!( pub static copies_0: Value = Rc::new(RefCell::new(0)); ); -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Swappable)] +#[derive( + Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Destructible, Swappable, +)] #[cpp_from(i32, construct_1, value)] #[byte_size(4)] pub struct Tracked { @@ -66,6 +68,7 @@ impl Default for Tracked { ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, Swappable, Default, @@ -108,7 +111,15 @@ impl MoveAssignable for Pair { } } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyConstructible, Swappable, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + CopyConstructible, + Swappable, )] #[byte_size(16)] pub struct Arrays { @@ -232,7 +243,6 @@ thread_local!( VaArg, FnPtrArg, CppFrom, - Destructible, MoveConstructible, MoveAssignable, Swappable, @@ -250,6 +260,11 @@ impl CopyConstructible for CopyOnly { (*copy_only_copies_1.with(Value::clone).borrow_mut()).prefix_inc(); } } +impl Destructible for CopyOnly { + fn destroy(this: &Ptr) { + (*copy_only_dtors_2.with(Value::clone).borrow_mut()).prefix_inc(); + } +} impl CopyAssignable for CopyOnly { fn copy_assign(this: &Ptr, o: Ptr) -> Ptr { field!((*this), v).write(o.with(|__s| __s.v)); @@ -272,7 +287,6 @@ impl Clone for CopyOnly { ZeroInitialization, VaArg, FnPtrArg, - Destructible, CopyConstructible, MoveConstructible, MoveAssignable, @@ -295,6 +309,12 @@ impl CopyAssignable for CopyOnlyPair { return (*this).clone(); } } +impl Destructible for CopyOnlyPair { + fn destroy(this: &Ptr) { + Destructible::destroy(&field_ptr!(this, y)); + Destructible::destroy(&field_ptr!(this, x)); + } +} thread_local!( pub static moves_3: Value = Rc::new(RefCell::new(0)); ); @@ -304,9 +324,7 @@ thread_local!( thread_local!( pub static moved_dtors_5: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Destructible, Swappable, Default, -)] +#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Swappable, Default)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct Moved { @@ -341,6 +359,11 @@ impl MoveAssignable for Moved { return (*this).clone(); } } +impl Destructible for Moved { + fn destroy(this: &Ptr) { + (*moved_dtors_5.with(Value::clone).borrow_mut()).prefix_inc(); + } +} impl Clone for Moved { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(Moved { v: self.v.clone() })); @@ -356,7 +379,6 @@ impl Clone for Moved { ZeroInitialization, VaArg, FnPtrArg, - Destructible, CopyConstructible, Swappable, Default, @@ -398,6 +420,12 @@ impl MoveAssignable for MovedPair { return (*this).clone(); } } +impl Destructible for MovedPair { + fn destroy(this: &Ptr) { + Destructible::destroy(&field_ptr!(this, y)); + Destructible::destroy(&field_ptr!(this, x)); + } +} pub fn swapped_once_6() -> bool { let mut ok: bool = ((moves_3.with(|rc| *rc.borrow()) == 1) && (move_assigns_4.with(|rc| *rc.borrow()) == 2)) @@ -415,7 +443,7 @@ pub fn swapped_once_6() -> bool { }); return ok; } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Swappable, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Swappable, Default)] #[byte_size(8)] pub struct Owner { #[offset(0)] @@ -889,14 +917,14 @@ fn main_0() -> i32 { Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let _dtor_c1 = - std::mem::DropGuard::new(c1.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(c1.clone(), |__p| Destructible::destroy(&__p.as_pointer())); let c2: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); CopyOnlyImpl::construct(&__v.as_pointer(), { 2 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let _dtor_c2 = - std::mem::DropGuard::new(c2.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(c2.clone(), |__p| Destructible::destroy(&__p.as_pointer())); Swappable::swap(&c1.as_pointer(), c2.as_pointer()); assert!(({ (*c1.borrow()).v } == 2) && ({ (*c2.borrow()).v } == 1)); assert!( @@ -916,7 +944,7 @@ fn main_0() -> i32 { }, })); let _dtor_cp = - std::mem::DropGuard::new(cp.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(cp.clone(), |__p| Destructible::destroy(&__p.as_pointer())); Swappable::swap( &field_ptr!(cp.as_pointer(), x), field_ptr!(cp.as_pointer(), y), @@ -952,14 +980,14 @@ fn main_0() -> i32 { Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let _dtor_mv1 = - std::mem::DropGuard::new(mv1.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(mv1.clone(), |__p| Destructible::destroy(&__p.as_pointer())); let mv2: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); MovedImpl::construct(&__v.as_pointer(), { 2 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); let _dtor_mv2 = - std::mem::DropGuard::new(mv2.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(mv2.clone(), |__p| Destructible::destroy(&__p.as_pointer())); Swappable::swap(&mv1.as_pointer(), mv2.as_pointer()); assert!(({ (*mv1.borrow()).v } == 2) && ({ (*mv2.borrow()).v } == 1)); assert!(({ swapped_once_6() })); @@ -976,7 +1004,7 @@ fn main_0() -> i32 { }, })); let _dtor_mp = - std::mem::DropGuard::new(mp.clone(), |__p| Destructible::destroy(__p.as_pointer())); + std::mem::DropGuard::new(mp.clone(), |__p| Destructible::destroy(&__p.as_pointer())); Swappable::swap( &field_ptr!(mp.as_pointer(), x), field_ptr!(mp.as_pointer(), y), @@ -1019,45 +1047,19 @@ fn main_0() -> i32 { } pub trait CopyOnlyImpl { fn construct(&self, v: i32); - fn destructor(&self); } impl CopyOnlyImpl for Ptr { fn construct(&self, mut v: i32) { field!((*self), v).write(v); } - fn destructor(&self) { - (*copy_only_dtors_2.with(Value::clone).borrow_mut()).prefix_inc(); - } -} -pub trait CopyOnlyPairImpl { - fn destructor(&self); -} -impl CopyOnlyPairImpl for Ptr { - fn destructor(&self) { - Destructible::destroy(field_ptr!(self, y)); - Destructible::destroy(field_ptr!(self, x)); - } } pub trait MovedImpl { fn construct(&self, v: i32); - fn destructor(&self); } impl MovedImpl for Ptr { fn construct(&self, mut v: i32) { field!((*self), v).write(v); } - fn destructor(&self) { - (*moved_dtors_5.with(Value::clone).borrow_mut()).prefix_inc(); - } -} -pub trait MovedPairImpl { - fn destructor(&self); -} -impl MovedPairImpl for Ptr { - fn destructor(&self) { - Destructible::destroy(field_ptr!(self, y)); - Destructible::destroy(field_ptr!(self, x)); - } } pub trait TrackedImpl { fn construct_2(&self); diff --git a/tests/unit/out/refcount/tag_vs_identifier_collision.rs b/tests/unit/out/refcount/tag_vs_identifier_collision.rs index f6c95bbcba..626a554da7 100644 --- a/tests/unit/out/refcount/tag_vs_identifier_collision.rs +++ b/tests/unit/out/refcount/tag_vs_identifier_collision.rs @@ -10,7 +10,18 @@ pub type widget_enum = u32; pub const widget_enum_MODE_IDLE: widget_enum = 0; pub const widget_enum_MODE_ACTIVE: widget_enum = 1; pub const widget_enum_MODE_DONE: widget_enum = 2; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct widget { #[offset(0)] @@ -18,7 +29,18 @@ pub struct widget { #[offset(4)] pub mode: widget_enum, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct point_struct { #[offset(0)] @@ -26,7 +48,7 @@ pub struct point_struct { #[offset(4)] pub y: i32, } -#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] +#[derive(VaArg, FnPtrArg, Destructible, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(4)] pub struct point { #[offset(0)] @@ -49,7 +71,7 @@ impl Default for point { } } } -#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] +#[derive(VaArg, FnPtrArg, Destructible, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(4)] pub struct slot_union { #[offset(0)] @@ -75,20 +97,53 @@ impl Default for slot_union { pub type slot = u32; pub const slot_SLOT_A: slot = 0; pub const slot_SLOT_B: slot = 1; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Inner { #[offset(0)] pub tag_field: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Outer { #[offset(0)] #[byte_size(4)] pub field: Inner, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Inner_struct { #[offset(0)] diff --git a/tests/unit/out/refcount/template_default_arg.rs b/tests/unit/out/refcount/template_default_arg.rs index 475548c202..28573901f9 100644 --- a/tests/unit/out/refcount/template_default_arg.rs +++ b/tests/unit/out/refcount/template_default_arg.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + Copyable, +)] #[cpp_from(i32, construct_1, value)] #[byte_size(4)] pub struct A { @@ -24,7 +35,9 @@ impl Default for A { } } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(4)] pub struct B { #[offset(0)] @@ -42,7 +55,17 @@ impl Default for B { } } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + Copyable, + Default, )] #[cpp_from(i32, construct, value)] #[byte_size(4)] @@ -63,7 +86,17 @@ pub fn always_given_3(mut x: NoDefault) -> i32 { return x.v; } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + Copyable, + Default, )] #[cpp_from(i32, construct, value)] #[byte_size(4)] diff --git a/tests/unit/out/refcount/template_static_member.rs b/tests/unit/out/refcount/template_static_member.rs index 31a1749c3d..94e9f890ae 100644 --- a/tests/unit/out/refcount/template_static_member.rs +++ b/tests/unit/out/refcount/template_static_member.rs @@ -9,19 +9,52 @@ use std::rc::{Rc, Weak}; thread_local!( pub static s_0: Value = Rc::new(RefCell::new(55)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct Static_int_ {} thread_local!( pub static s_1: Value = Rc::new(RefCell::new(55_i8)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct Static_char_ {} thread_local!( pub static s_2: Value = Rc::new(RefCell::new(55_i64)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct Static_long_ {} thread_local!( @@ -30,7 +63,18 @@ thread_local!( thread_local!( pub static hi_4: Value = Rc::new(RefCell::new(1)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct Range_int_ {} thread_local!( @@ -39,7 +83,18 @@ thread_local!( thread_local!( pub static hi_6: Value = Rc::new(RefCell::new(2_i64)); ); -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct Range_long_ {} pub fn main() { diff --git a/tests/unit/out/refcount/temporary_field_addr.rs b/tests/unit/out/refcount/temporary_field_addr.rs index 21d50adeb8..6313a4469c 100644 --- a/tests/unit/out/refcount/temporary_field_addr.rs +++ b/tests/unit/out/refcount/temporary_field_addr.rs @@ -13,6 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, CopyAssignable, Swappable, @@ -44,6 +45,7 @@ impl MoveAssignable for Inner { ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, CopyAssignable, Swappable, diff --git a/tests/unit/out/refcount/temporary_field_ctor_arg.rs b/tests/unit/out/refcount/temporary_field_ctor_arg.rs index 9413cebbfd..c669df6d1c 100644 --- a/tests/unit/out/refcount/temporary_field_ctor_arg.rs +++ b/tests/unit/out/refcount/temporary_field_ctor_arg.rs @@ -13,6 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, CopyAssignable, Swappable, @@ -43,7 +44,17 @@ pub fn make_0() -> Outer { }; } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + Copyable, + Default, )] #[cpp_from(Vec , construct, ptr)] #[byte_size(4)] diff --git a/tests/unit/out/refcount/temporary_field_two_args.rs b/tests/unit/out/refcount/temporary_field_two_args.rs index a0cacb7c33..ff14405a7b 100644 --- a/tests/unit/out/refcount/temporary_field_two_args.rs +++ b/tests/unit/out/refcount/temporary_field_two_args.rs @@ -13,6 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, CopyAssignable, Swappable, @@ -44,6 +45,7 @@ impl MoveAssignable for Inner { ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, CopyAssignable, Swappable, diff --git a/tests/unit/out/refcount/this.rs b/tests/unit/out/refcount/this.rs index f2be93cf13..8d9858b108 100644 --- a/tests/unit/out/refcount/this.rs +++ b/tests/unit/out/refcount/this.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + Copyable, + Default, )] #[cpp_from(i32, construct_1, value)] #[byte_size(16)] @@ -22,7 +31,17 @@ pub fn bump_0(mut p: Ptr) { field!(p, a_).with_mut(|__v| __v.postfix_inc()); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + Copyable, + Default, )] #[cpp_from(i32, construct, value)] #[byte_size(4)] diff --git a/tests/unit/out/refcount/typedef-anon-struct.rs b/tests/unit/out/refcount/typedef-anon-struct.rs index e534eaa5e9..4c87ec7f37 100644 --- a/tests/unit/out/refcount/typedef-anon-struct.rs +++ b/tests/unit/out/refcount/typedef-anon-struct.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Outer_RunInfo { #[offset(0)] @@ -21,6 +32,7 @@ pub struct Outer_RunInfo { ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, CopyAssignable, Swappable, diff --git a/tests/unit/out/refcount/unary_expr_or_type_trait.rs b/tests/unit/out/refcount/unary_expr_or_type_trait.rs index 2dc363d144..3b5fb0661b 100644 --- a/tests/unit/out/refcount/unary_expr_or_type_trait.rs +++ b/tests/unit/out/refcount/unary_expr_or_type_trait.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(16)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/unboxed_locals.rs b/tests/unit/out/refcount/unboxed_locals.rs index 03a468c059..ff2b8f3c91 100644 --- a/tests/unit/out/refcount/unboxed_locals.rs +++ b/tests/unit/out/refcount/unboxed_locals.rs @@ -14,7 +14,18 @@ pub fn inc_1(r: Ptr) { __v.prefix_inc(); }); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Pair { #[offset(0)] @@ -54,7 +65,9 @@ pub fn countdown_4(mut n: i32, mut step: i32) -> i32 { pub trait Shape { fn scale(&mut self, factor: i32) -> i32; } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(16)] pub struct Square { #[offset(8)] diff --git a/tests/unit/out/refcount/unboxed_records.rs b/tests/unit/out/refcount/unboxed_records.rs index 602a77a6a7..ddb769339e 100644 --- a/tests/unit/out/refcount/unboxed_records.rs +++ b/tests/unit/out/refcount/unboxed_records.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Inner { #[offset(0)] @@ -14,7 +25,7 @@ pub struct Inner { #[offset(4)] pub b: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(48)] pub struct Cookie { #[offset(0)] @@ -46,7 +57,9 @@ impl Default for Cookie { } } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive( + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, +)] #[byte_size(4)] pub struct Counter { #[offset(0)] diff --git a/tests/unit/out/refcount/union_addrof_external.rs b/tests/unit/out/refcount/union_addrof_external.rs index 0f205401f5..ca4c741423 100644 --- a/tests/unit/out/refcount/union_addrof_external.rs +++ b/tests/unit/out/refcount/union_addrof_external.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(16)] pub struct record { #[offset(0)] @@ -32,7 +32,7 @@ impl Default for record { } } } -#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] +#[derive(VaArg, FnPtrArg, Destructible, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(128)] pub struct anon_0 { #[offset(0)] @@ -55,7 +55,9 @@ impl Default for anon_0 { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(128)] pub struct Container { #[offset(0)] diff --git a/tests/unit/out/refcount/union_basic.rs b/tests/unit/out/refcount/union_basic.rs index 56840e48e1..f2c09a44d4 100644 --- a/tests/unit/out/refcount/union_basic.rs +++ b/tests/unit/out/refcount/union_basic.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] +#[derive(VaArg, FnPtrArg, Destructible, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(4)] pub struct basic { #[offset(0)] @@ -29,7 +29,7 @@ impl Default for basic { } } } -#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] +#[derive(VaArg, FnPtrArg, Destructible, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(1)] pub struct empty { #[offset(0)] @@ -45,7 +45,7 @@ impl Default for empty { } } } -#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] +#[derive(VaArg, FnPtrArg, Destructible, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(8)] pub struct underscores { #[offset(0)] @@ -123,7 +123,7 @@ fn main_0() -> i32 { assert!(((__ + ___) == 3)); return 0; } -#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] +#[derive(VaArg, FnPtrArg, Destructible, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(4)] pub struct anon_0 { #[offset(0)] diff --git a/tests/unit/out/refcount/union_cross_arm_cast.rs b/tests/unit/out/refcount/union_cross_arm_cast.rs index 0064139fbe..a6ff07790f 100644 --- a/tests/unit/out/refcount/union_cross_arm_cast.rs +++ b/tests/unit/out/refcount/union_cross_arm_cast.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(16)] pub struct shape_a { #[offset(0)] @@ -26,7 +26,7 @@ impl Default for shape_a { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(28)] pub struct shape_b { #[offset(0)] @@ -55,7 +55,7 @@ impl Default for shape_b { } } } -#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] +#[derive(VaArg, FnPtrArg, Destructible, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(64)] pub struct anon_0 { #[offset(0)] @@ -81,7 +81,9 @@ impl Default for anon_0 { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(68)] pub struct Container { #[offset(0)] diff --git a/tests/unit/out/refcount/union_field_alignment.rs b/tests/unit/out/refcount/union_field_alignment.rs index 03e61b7d6a..e689bccc26 100644 --- a/tests/unit/out/refcount/union_field_alignment.rs +++ b/tests/unit/out/refcount/union_field_alignment.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] +#[derive(VaArg, FnPtrArg, Destructible, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(8)] pub struct anon_0 { #[offset(0)] @@ -29,7 +29,9 @@ impl Default for anon_0 { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(16)] pub struct node { #[offset(0)] diff --git a/tests/unit/out/refcount/union_flex_array_member.rs b/tests/unit/out/refcount/union_flex_array_member.rs index 739650bfac..c7414be3fd 100644 --- a/tests/unit/out/refcount/union_flex_array_member.rs +++ b/tests/unit/out/refcount/union_flex_array_member.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] +#[derive(VaArg, FnPtrArg, Destructible, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(8)] pub struct anon_0 { #[offset(0)] @@ -29,7 +29,9 @@ impl Default for anon_0 { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(24)] pub struct node { #[offset(0)] diff --git a/tests/unit/out/refcount/union_memset_memcpy.rs b/tests/unit/out/refcount/union_memset_memcpy.rs index f5fc86650f..514f11afab 100644 --- a/tests/unit/out/refcount/union_memset_memcpy.rs +++ b/tests/unit/out/refcount/union_memset_memcpy.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(16)] pub struct shape_a { #[offset(0)] @@ -26,7 +26,7 @@ impl Default for shape_a { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(16)] pub struct shape_b { #[offset(0)] @@ -52,7 +52,7 @@ impl Default for shape_b { } } } -#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] +#[derive(VaArg, FnPtrArg, Destructible, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(256)] pub struct anon_0 { #[offset(0)] @@ -78,7 +78,9 @@ impl Default for anon_0 { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(256)] pub struct Container { #[offset(0)] diff --git a/tests/unit/out/refcount/union_nested.rs b/tests/unit/out/refcount/union_nested.rs index 4e9624725f..807644bd3f 100644 --- a/tests/unit/out/refcount/union_nested.rs +++ b/tests/unit/out/refcount/union_nested.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable)] #[byte_size(16)] pub struct record { #[offset(0)] @@ -26,7 +26,7 @@ impl Default for record { } } } -#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] +#[derive(VaArg, FnPtrArg, Destructible, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(128)] pub struct anon_0 { #[offset(0)] @@ -49,14 +49,16 @@ impl Default for anon_0 { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(128)] pub struct inner { #[offset(0)] #[byte_size(128)] pub view: anon_0, } -#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] +#[derive(VaArg, FnPtrArg, Destructible, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(128)] pub struct anon_1 { #[offset(0)] @@ -79,7 +81,9 @@ impl Default for anon_1 { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(144)] pub struct Outer { #[offset(0)] diff --git a/tests/unit/out/refcount/union_pointer_pun_address.rs b/tests/unit/out/refcount/union_pointer_pun_address.rs index 00cce6bf99..b1833bf0fd 100644 --- a/tests/unit/out/refcount/union_pointer_pun_address.rs +++ b/tests/unit/out/refcount/union_pointer_pun_address.rs @@ -6,13 +6,26 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct node_a { #[offset(0)] pub n: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(16)] pub struct node_b { #[offset(0)] @@ -34,7 +47,7 @@ fn main_0() -> i32 { assert!(({ (out).to_any() } == { (a.as_pointer()).to_any() })); return 0; } -#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] +#[derive(VaArg, FnPtrArg, Destructible, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(8)] pub struct anon_0 { #[offset(0)] diff --git a/tests/unit/out/refcount/union_pointer_pun_writethrough.rs b/tests/unit/out/refcount/union_pointer_pun_writethrough.rs index ddda9d5544..8d229bf8d2 100644 --- a/tests/unit/out/refcount/union_pointer_pun_writethrough.rs +++ b/tests/unit/out/refcount/union_pointer_pun_writethrough.rs @@ -18,7 +18,7 @@ fn main_0() -> i32 { assert!(({ ((*x.borrow()) == 42_i64) })); return 0; } -#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] +#[derive(VaArg, FnPtrArg, Destructible, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(8)] pub struct anon_0 { #[offset(0)] diff --git a/tests/unit/out/refcount/union_struct_dual_use.rs b/tests/unit/out/refcount/union_struct_dual_use.rs index e417665f5c..d366f54ebc 100644 --- a/tests/unit/out/refcount/union_struct_dual_use.rs +++ b/tests/unit/out/refcount/union_struct_dual_use.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Inner { #[offset(0)] @@ -17,7 +28,7 @@ pub struct Inner { pub fn sum_inner_0(mut i: Ptr) -> i32 { return ({ i.with(|__s| __s.a) } + { i.with(|__s| __s.b) }); } -#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] +#[derive(VaArg, FnPtrArg, Destructible, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(16)] pub struct anon_1 { #[offset(0)] @@ -40,7 +51,9 @@ impl Default for anon_1 { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(16)] pub struct Outer { #[offset(0)] diff --git a/tests/unit/out/refcount/union_tagged_many_arms.rs b/tests/unit/out/refcount/union_tagged_many_arms.rs index 9f2ad0c864..1e70242f07 100644 --- a/tests/unit/out/refcount/union_tagged_many_arms.rs +++ b/tests/unit/out/refcount/union_tagged_many_arms.rs @@ -12,7 +12,7 @@ pub const Tag_enum_T_NUM_U: Tag_enum = 1; pub const Tag_enum_T_TEXT: Tag_enum = 2; pub const Tag_enum_T_FLOAT: Tag_enum = 3; pub const Tag_enum_T_REF: Tag_enum = 4; -#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] +#[derive(VaArg, FnPtrArg, Destructible, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(8)] pub struct anon_0 { #[offset(0)] @@ -44,7 +44,9 @@ impl Default for anon_0 { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(16)] pub struct Slot { #[offset(0)] diff --git a/tests/unit/out/refcount/union_tagged_simple.rs b/tests/unit/out/refcount/union_tagged_simple.rs index cc96e94435..fe497f915f 100644 --- a/tests/unit/out/refcount/union_tagged_simple.rs +++ b/tests/unit/out/refcount/union_tagged_simple.rs @@ -9,7 +9,7 @@ use std::rc::{Rc, Weak}; pub type Kind_enum = u32; pub const Kind_enum_KIND_NONE: Kind_enum = 0; pub const Kind_enum_KIND_DONE: Kind_enum = 1; -#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] +#[derive(VaArg, FnPtrArg, Destructible, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(8)] pub struct anon_0 { #[offset(0)] @@ -32,7 +32,9 @@ impl Default for anon_0 { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(24)] pub struct Event { #[offset(0)] diff --git a/tests/unit/out/refcount/union_tagged_struct_arms.rs b/tests/unit/out/refcount/union_tagged_struct_arms.rs index 4fab46abac..4003a5d6a0 100644 --- a/tests/unit/out/refcount/union_tagged_struct_arms.rs +++ b/tests/unit/out/refcount/union_tagged_struct_arms.rs @@ -10,7 +10,9 @@ pub type Choice_enum = u32; pub const Choice_enum_C_LIST: Choice_enum = 1; pub const Choice_enum_C_LETTERS: Choice_enum = 2; pub const Choice_enum_C_INTEGERS: Choice_enum = 3; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(24)] pub struct anon_1 { #[offset(0)] @@ -21,7 +23,18 @@ pub struct anon_1 { #[offset(16)] pub cursor: i64, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(16)] pub struct anon_2 { #[offset(0)] @@ -33,7 +46,18 @@ pub struct anon_2 { #[offset(12)] pub step: u8, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(40)] pub struct anon_3 { #[offset(0)] @@ -47,7 +71,7 @@ pub struct anon_3 { #[offset(32)] pub width: i32, } -#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] +#[derive(VaArg, FnPtrArg, Destructible, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(40)] pub struct anon_0 { #[offset(0)] @@ -73,7 +97,9 @@ impl Default for anon_0 { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(48)] pub struct Branch { #[offset(0)] diff --git a/tests/unit/out/refcount/union_void_ptr_sized_deref.rs b/tests/unit/out/refcount/union_void_ptr_sized_deref.rs index e2a805fc54..93289f2704 100644 --- a/tests/unit/out/refcount/union_void_ptr_sized_deref.rs +++ b/tests/unit/out/refcount/union_void_ptr_sized_deref.rs @@ -10,7 +10,7 @@ pub type Width_enum = u32; pub const Width_enum_W_64: Width_enum = 0; pub const Width_enum_W_32: Width_enum = 1; pub const Width_enum_W_16: Width_enum = 2; -#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] +#[derive(VaArg, FnPtrArg, Destructible, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(8)] pub struct anon_0 { #[offset(0)] @@ -39,7 +39,9 @@ impl Default for anon_0 { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(16)] pub struct Sink { #[offset(0)] diff --git a/tests/unit/out/refcount/unique_ptr.rs b/tests/unit/out/refcount/unique_ptr.rs index 156102b44b..d1763fad44 100644 --- a/tests/unit/out/refcount/unique_ptr.rs +++ b/tests/unit/out/refcount/unique_ptr.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Swappable, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Swappable, Default)] #[byte_size(8)] pub struct SafePointer { #[offset(0)] @@ -27,7 +27,18 @@ impl MoveAssignable for SafePointer { return (*this).clone(); } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Pair { #[offset(0)] diff --git a/tests/unit/out/refcount/unique_ptr_const_deref.rs b/tests/unit/out/refcount/unique_ptr_const_deref.rs index 7796dbb19e..8bd495f361 100644 --- a/tests/unit/out/refcount/unique_ptr_const_deref.rs +++ b/tests/unit/out/refcount/unique_ptr_const_deref.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Swappable, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Swappable, Default)] #[byte_size(8)] pub struct Holder { #[offset(0)] diff --git a/tests/unit/out/refcount/unique_ptr_field_reset.rs b/tests/unit/out/refcount/unique_ptr_field_reset.rs index 86ba90bc9f..89efc85aa4 100644 --- a/tests/unit/out/refcount/unique_ptr_field_reset.rs +++ b/tests/unit/out/refcount/unique_ptr_field_reset.rs @@ -6,13 +6,24 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Data { #[offset(0)] pub v: i32, } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Swappable, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Swappable, Default)] #[byte_size(16)] pub struct Holder { #[offset(0)] diff --git a/tests/unit/out/refcount/unique_ptr_nested.rs b/tests/unit/out/refcount/unique_ptr_nested.rs index 904c751ffb..3b92b3c090 100644 --- a/tests/unit/out/refcount/unique_ptr_nested.rs +++ b/tests/unit/out/refcount/unique_ptr_nested.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Inner { #[offset(0)] @@ -14,7 +25,7 @@ pub struct Inner { #[offset(4)] pub y: i32, } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Swappable, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Swappable, Default)] #[byte_size(8)] pub struct Outer { #[offset(0)] diff --git a/tests/unit/out/refcount/unique_ptr_struct.rs b/tests/unit/out/refcount/unique_ptr_struct.rs index 6bb65fda88..5a0ddaa844 100644 --- a/tests/unit/out/refcount/unique_ptr_struct.rs +++ b/tests/unit/out/refcount/unique_ptr_struct.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Point { #[offset(0)] diff --git a/tests/unit/out/refcount/va_arg_mixed_types.rs b/tests/unit/out/refcount/va_arg_mixed_types.rs index 71f7e9978b..904f4e39b6 100644 --- a/tests/unit/out/refcount/va_arg_mixed_types.rs +++ b/tests/unit/out/refcount/va_arg_mixed_types.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct pair { #[offset(0)] diff --git a/tests/unit/out/refcount/va_arg_non_primitive_ptrs.rs b/tests/unit/out/refcount/va_arg_non_primitive_ptrs.rs index 1982bb15fb..3a648b500c 100644 --- a/tests/unit/out/refcount/va_arg_non_primitive_ptrs.rs +++ b/tests/unit/out/refcount/va_arg_non_primitive_ptrs.rs @@ -6,7 +6,9 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(16)] pub struct node { #[offset(0)] diff --git a/tests/unit/out/refcount/va_arg_struct_ctx.rs b/tests/unit/out/refcount/va_arg_struct_ctx.rs index 53276f195b..22299d2d3c 100644 --- a/tests/unit/out/refcount/va_arg_struct_ctx.rs +++ b/tests/unit/out/refcount/va_arg_struct_ctx.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct context { #[offset(0)] @@ -23,7 +34,7 @@ pub fn set_error_0(mut ctx: Ptr, fmt: Ptr, __args: Box<[VaArg]>) { field!(ctx, last_error).write((*ap.borrow_mut()).arg::()); } } -#[derive(VaArg, FnPtrArg, Copyable, ByteRepr, Clone, ZeroInitialization)] +#[derive(VaArg, FnPtrArg, Destructible, Copyable, ByteRepr, Clone, ZeroInitialization)] #[byte_size(8)] pub struct value { #[offset(0)] diff --git a/tests/unit/out/refcount/va_arg_void_ptr.rs b/tests/unit/out/refcount/va_arg_void_ptr.rs index 7a5b9ab5a3..77278d4a99 100644 --- a/tests/unit/out/refcount/va_arg_void_ptr.rs +++ b/tests/unit/out/refcount/va_arg_void_ptr.rs @@ -6,7 +6,9 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(16)] pub struct registry { #[offset(0)] diff --git a/tests/unit/out/refcount/va_list_field.rs b/tests/unit/out/refcount/va_list_field.rs index 4dec257d9d..d07dd3fdf2 100644 --- a/tests/unit/out/refcount/va_list_field.rs +++ b/tests/unit/out/refcount/va_list_field.rs @@ -16,8 +16,9 @@ pub fn sum_0(n: i32, __args: Box<[VaArg]>) -> i32 { Guard_1Impl::construct(&__v.as_pointer(), { ap.as_pointer() }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); - let _dtor_guard = - std::mem::DropGuard::new(guard.clone(), |__p| Destructible::destroy(__p.as_pointer())); + let _dtor_guard = std::mem::DropGuard::new(guard.clone(), |__p| { + Destructible::destroy(&__p.as_pointer()) + }); let mut total: i32 = 0; { let mut i: i32 = 0; @@ -31,16 +32,7 @@ pub fn sum_0(n: i32, __args: Box<[VaArg]>) -> i32 { return total; } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - Destructible, - Copyable, - Default, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, )] #[cpp_from(Ptr , construct, mut_ptr)] #[byte_size(16)] @@ -51,6 +43,11 @@ pub struct Guard_1 { #[offset(8)] pub active: bool, } +impl Destructible for Guard_1 { + fn destroy(this: &Ptr) { + if (*this).with(|__s| __s.active) {} + } +} pub fn sum_ptr_2(n: i32, __args: Box<[VaArg]>) -> i32 { let __args: Value> = Rc::new(RefCell::new(__args.into())); let n: Value = Rc::new(RefCell::new(n)); @@ -71,7 +68,9 @@ pub fn sum_ptr_2(n: i32, __args: Box<[VaArg]>) -> i32 { }; return total; } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, Default, +)] #[byte_size(8)] pub struct Cursor_3 { #[offset(0)] @@ -89,15 +88,11 @@ fn main_0() -> i32 { } pub trait Guard_1Impl { fn construct(&self, val: Ptr>); - fn destructor(&self); } impl Guard_1Impl for Ptr { fn construct(&self, val: Ptr>) { field!((*self), ap).write((val).clone()); field!((*self), active).write(true); } - fn destructor(&self) { - if (*self).with(|__s| __s.active) {} - } } pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/vector.rs b/tests/unit/out/refcount/vector.rs index 4688de476c..65d72f38d9 100644 --- a/tests/unit/out/refcount/vector.rs +++ b/tests/unit/out/refcount/vector.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct S { #[offset(0)] @@ -20,6 +31,7 @@ pub fn copy_0(mut copy_vector: Vec) {} ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, CopyAssignable, Swappable, diff --git a/tests/unit/out/refcount/vector_iter_range_ctor.rs b/tests/unit/out/refcount/vector_iter_range_ctor.rs index 81a328fc08..be0a3c3fb5 100644 --- a/tests/unit/out/refcount/vector_iter_range_ctor.rs +++ b/tests/unit/out/refcount/vector_iter_range_ctor.rs @@ -7,7 +7,17 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + Copyable, + Default, )] #[cpp_from(i32, construct, value)] #[byte_size(4)] @@ -16,7 +26,17 @@ pub struct Degrees { pub value: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + Destructible, + Copyable, + Default, )] #[cpp_into(i64, to_i64)] #[byte_size(4)] diff --git a/tests/unit/out/refcount/vector_subscript_direct.rs b/tests/unit/out/refcount/vector_subscript_direct.rs index 3a4cb936ff..baece71457 100644 --- a/tests/unit/out/refcount/vector_subscript_direct.rs +++ b/tests/unit/out/refcount/vector_subscript_direct.rs @@ -6,7 +6,18 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Point { #[offset(0)] @@ -21,6 +32,7 @@ pub struct Point { ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, CopyAssignable, Swappable, diff --git a/tests/unit/out/refcount/vector_with_allocator.rs b/tests/unit/out/refcount/vector_with_allocator.rs index 9ef0bb4357..95579428e4 100644 --- a/tests/unit/out/refcount/vector_with_allocator.rs +++ b/tests/unit/out/refcount/vector_with_allocator.rs @@ -6,10 +6,32 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct TestAllocator_int_ {} -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(1)] pub struct TestAllocator_double_ {} pub fn copy_0(mut copy_vector: Vec) {} diff --git a/tests/unit/out/refcount/void_cast.rs b/tests/unit/out/refcount/void_cast.rs index 0d1c381537..b7588b2501 100644 --- a/tests/unit/out/refcount/void_cast.rs +++ b/tests/unit/out/refcount/void_cast.rs @@ -14,6 +14,7 @@ pub fn unused_param_0(mut x: i32) {} ZeroInitialization, VaArg, FnPtrArg, + Destructible, CopyConstructible, CopyAssignable, Swappable, @@ -47,13 +48,24 @@ pub fn bump_and_return_4() -> i32 { (*side_effect_counter_3.with(Value::clone).borrow_mut()).prefix_inc(); return side_effect_counter_3.with(|rc| *rc.borrow()); } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + Copyable, + Default, +)] #[byte_size(4)] pub struct Holder { #[offset(0)] pub field: i32, } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Swappable, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Swappable, Default)] #[byte_size(8)] pub struct NonCopyable { #[offset(0)] diff --git a/tests/unit/out/unsafe/05_new.rs b/tests/unit/out/unsafe/05_new.rs index 2bdfba5038..e184846aad 100644 --- a/tests/unit/out/unsafe/05_new.rs +++ b/tests/unit/out/unsafe/05_new.rs @@ -7,10 +7,28 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct A {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct D {} impl D { pub unsafe fn operator_call(&self, mut ptr: *const A) { diff --git a/tests/unit/out/unsafe/10_struct.rs b/tests/unit/out/unsafe/10_struct.rs index 114b5a2b4c..d0671ada1d 100644 --- a/tests/unit/out/unsafe/10_struct.rs +++ b/tests/unit/out/unsafe/10_struct.rs @@ -7,13 +7,31 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct GraphNode { pub dst: u32, pub next: *mut GraphNode, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Graph { pub V: u32, pub adj: *mut *mut GraphNode, @@ -31,7 +49,9 @@ impl Graph { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct Partial { pub p: *mut i32, } @@ -50,11 +70,29 @@ impl Default for Partial { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Declared {} impl Declared {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub i: i32, pub d: *mut Declared, diff --git a/tests/unit/out/unsafe/addr_of_global.rs b/tests/unit/out/unsafe/addr_of_global.rs index d41f2d6634..6bf331e8f7 100644 --- a/tests/unit/out/unsafe/addr_of_global.rs +++ b/tests/unit/out/unsafe/addr_of_global.rs @@ -7,12 +7,30 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Inner { pub value: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Outer { pub p: *mut Inner, } diff --git a/tests/unit/out/unsafe/anonymous-struct.rs b/tests/unit/out/unsafe/anonymous-struct.rs index ce9a32f506..fce183f9a2 100644 --- a/tests/unit/out/unsafe/anonymous-struct.rs +++ b/tests/unit/out/unsafe/anonymous-struct.rs @@ -7,48 +7,120 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Outer_Named { pub a: i32, pub b: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct anon_0 { pub c: i32, pub d: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct anon_1 { pub g: i32, pub h: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct anon_2 { pub e: i32, pub f: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct anon_4 { pub j: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct anon_5 { pub k: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct anon_3 { pub i: i32, pub inner_named: anon_4, pub anon_5: anon_5, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Outer { pub named: Outer_Named, pub anonymous_named_0: anon_0, @@ -104,7 +176,16 @@ unsafe fn main_0() -> i32 { return 0; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct anon_6 { pub x: i32, pub z: i32, diff --git a/tests/unit/out/unsafe/anonymous-struct_c.rs b/tests/unit/out/unsafe/anonymous-struct_c.rs index c25e1d0e40..509da3b233 100644 --- a/tests/unit/out/unsafe/anonymous-struct_c.rs +++ b/tests/unit/out/unsafe/anonymous-struct_c.rs @@ -7,48 +7,120 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Named { pub a: i32, pub b: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct anon_0 { pub c: i32, pub d: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct anon_1 { pub g: i32, pub h: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct anon_2 { pub e: i32, pub f: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct anon_4 { pub j: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct anon_5 { pub k: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct anon_3 { pub i: i32, pub inner_named: anon_4, pub anon_5: anon_5, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Outer { pub named: Named, pub anon0: anon_0, @@ -110,7 +182,16 @@ unsafe fn main_0() -> i32 { return 0; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct anon_6 { pub x: i32, pub z: i32, diff --git a/tests/unit/out/unsafe/anonymous_enum.rs b/tests/unit/out/unsafe/anonymous_enum.rs index 89ab511c88..066af2d3ed 100644 --- a/tests/unit/out/unsafe/anonymous_enum.rs +++ b/tests/unit/out/unsafe/anonymous_enum.rs @@ -13,7 +13,16 @@ pub type anon_1 = u32; pub const anon_1_SECOND_A: anon_1 = 0; pub const anon_1_SECOND_B: anon_1 = 1; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub a: i32, } @@ -24,7 +33,16 @@ pub type anon_2 = u32; pub const anon_2_FIELD_A: anon_2 = 0; pub const anon_2_FIELD_B: anon_2 = 1; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct WithAnonField { pub a: i32, pub field: anon_2, diff --git a/tests/unit/out/unsafe/anonymous_enum_c.rs b/tests/unit/out/unsafe/anonymous_enum_c.rs index 8d0154ceac..f8ddc173e8 100644 --- a/tests/unit/out/unsafe/anonymous_enum_c.rs +++ b/tests/unit/out/unsafe/anonymous_enum_c.rs @@ -13,7 +13,16 @@ pub type anon_1 = u32; pub const anon_1_SECOND_A: anon_1 = 0; pub const anon_1_SECOND_B: anon_1 = 1; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub a: i32, } @@ -24,7 +33,16 @@ pub type anon_2 = u32; pub const anon_2_FIELD_A: anon_2 = 0; pub const anon_2_FIELD_B: anon_2 = 1; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct WithAnonField { pub a: i32, pub field: anon_2, diff --git a/tests/unit/out/unsafe/any.rs b/tests/unit/out/unsafe/any.rs index bbdfe08b1c..48c87082b1 100644 --- a/tests/unit/out/unsafe/any.rs +++ b/tests/unit/out/unsafe/any.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Point { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/array_const_init.rs b/tests/unit/out/unsafe/array_const_init.rs index a63c6e47d7..fc0bfe4233 100644 --- a/tests/unit/out/unsafe/array_const_init.rs +++ b/tests/unit/out/unsafe/array_const_init.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub head: i32, pub tail: [i32; 3], @@ -21,7 +30,16 @@ pub static mut s_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe } }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct P { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/array_field_addr.rs b/tests/unit/out/unsafe/array_field_addr.rs index 5fb6cc8586..ab89391816 100644 --- a/tests/unit/out/unsafe/array_field_addr.rs +++ b/tests/unit/out/unsafe/array_field_addr.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub before: i32, pub mask: [u8; 4], diff --git a/tests/unit/out/unsafe/array_of_noncopy_struct.rs b/tests/unit/out/unsafe/array_of_noncopy_struct.rs index 6eea862628..bf01f02a4a 100644 --- a/tests/unit/out/unsafe/array_of_noncopy_struct.rs +++ b/tests/unit/out/unsafe/array_of_noncopy_struct.rs @@ -12,6 +12,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, SwappableUnsafe, diff --git a/tests/unit/out/unsafe/array_reference.rs b/tests/unit/out/unsafe/array_reference.rs index d1ea821a1b..c0873c5a6e 100644 --- a/tests/unit/out/unsafe/array_reference.rs +++ b/tests/unit/out/unsafe/array_reference.rs @@ -57,7 +57,16 @@ pub unsafe fn pick_10(s: *const [libc::c_char; 5]) -> *const [libc::c_char; 5] { return s; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Point { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/as_const.rs b/tests/unit/out/unsafe/as_const.rs index 9224dea60b..33d7afa5ea 100644 --- a/tests/unit/out/unsafe/as_const.rs +++ b/tests/unit/out/unsafe/as_const.rs @@ -10,7 +10,16 @@ pub type Overload = u32; pub const Overload_kMutableOverload: Overload = 1; pub const Overload_kConstOverload: Overload = 2; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/assign_rhs_first.rs b/tests/unit/out/unsafe/assign_rhs_first.rs index 8f63ae9fbe..44907d339d 100644 --- a/tests/unit/out/unsafe/assign_rhs_first.rs +++ b/tests/unit/out/unsafe/assign_rhs_first.rs @@ -13,7 +13,16 @@ pub unsafe fn advance_1() -> i32 { return 10; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub ptr: *mut i32, } diff --git a/tests/unit/out/unsafe/assignment_single_eval.rs b/tests/unit/out/unsafe/assignment_single_eval.rs index 192f93e512..a8c7275f99 100644 --- a/tests/unit/out/unsafe/assignment_single_eval.rs +++ b/tests/unit/out/unsafe/assignment_single_eval.rs @@ -836,17 +836,44 @@ pub unsafe fn test_reference_members_9() { }); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Slot_6 { pub value: *mut u32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Slot_8 { pub value: *mut i16, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Slot_10 { pub value: *mut i32, } @@ -895,7 +922,16 @@ pub unsafe fn test_pointer_elements_11() { }); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Holder_12 { pub p: *mut i32, } @@ -921,7 +957,16 @@ pub unsafe fn test_reference_pointer_13() { }); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Node_14 { pub link: *mut *mut Node_14, } @@ -994,22 +1039,58 @@ pub unsafe fn test_reference_subfields_18() { }); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Index_16 { pub value: u32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Slot_17 { pub ref_: *mut Index_16, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Index_19 { pub value: i16, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Slot_20 { pub ref_: *mut Index_19, } @@ -1049,12 +1130,30 @@ pub unsafe fn observe_24(mut assigned: i32, mut stored: *const i32) -> i32 { return ((assigned) + (*stored)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct GlobalRecord_Inner { pub value: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct GlobalRecord { pub inner: GlobalRecord_Inner, } @@ -1320,19 +1419,46 @@ pub unsafe fn test_borrows_29() { static mut promoted_30: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 10_i16 }); static mut flag_31: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { false }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Record_32 { pub value: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Link_33 { pub next: *mut Link_33, } pub static mut selected_values_34: std::cell::LazyCell<[u32; 3]> = std::cell::LazyCell::new(|| unsafe { [0_u32, 20_u32, 30_u32] }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct IndexedBinding {} impl IndexedBinding { pub unsafe fn get_1_0(&mut self) -> *mut u32 { @@ -1551,7 +1677,16 @@ pub static mut global_array_45: std::cell::LazyCell<[u32; 3]> = pub static mut global_rows_46: std::cell::LazyCell<[[u32; 2]; 2]> = std::cell::LazyCell::new(|| unsafe { [[0_u32, 10_u32], [20_u32, 30_u32]] }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct IndexedMember { pub key: i32, pub value: u32, @@ -1810,7 +1945,16 @@ pub static mut scoped_pointers_53: std::cell::LazyCell<[*mut u32; 1]> = [(*std::cell::LazyCell::force_mut(&mut *&raw mut scoped_values_52)).as_mut_ptr()] }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct PointerSelector { pub ptr: *mut u32, } @@ -1971,6 +2115,7 @@ pub unsafe fn test_stable_containers_58() { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, SwappableUnsafe, @@ -1993,7 +2138,16 @@ impl MoveAssignableUnsafe for Counts_59 { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Pair_60 { pub u: u32, pub f: i32, @@ -2295,12 +2449,30 @@ unsafe fn main_0() -> i32 { return 0; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Index_62 { pub value: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Owner_63 { pub values: [i32; 2], pub index: i32, diff --git a/tests/unit/out/unsafe/bounded_struct_ptr.rs b/tests/unit/out/unsafe/bounded_struct_ptr.rs index 4a4610166f..a56c5e762a 100644 --- a/tests/unit/out/unsafe/bounded_struct_ptr.rs +++ b/tests/unit/out/unsafe/bounded_struct_ptr.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Foo { pub x1: i32, pub x2: i32, diff --git a/tests/unit/out/unsafe/bst.rs b/tests/unit/out/unsafe/bst.rs index cf8ab546c4..dd9688cb32 100644 --- a/tests/unit/out/unsafe/bst.rs +++ b/tests/unit/out/unsafe/bst.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct node_t { pub left: *mut node_t, pub right: *mut node_t, diff --git a/tests/unit/out/unsafe/c_struct.rs b/tests/unit/out/unsafe/c_struct.rs index ee060c757b..3e10ddfb2d 100644 --- a/tests/unit/out/unsafe/c_struct.rs +++ b/tests/unit/out/unsafe/c_struct.rs @@ -7,19 +7,46 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Point { pub x: i32, pub y: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Line { pub start: Point, pub end: Point, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Node { pub value: i32, pub next: *mut Node, @@ -29,13 +56,31 @@ pub const Color_RED: Color = 0; pub const Color_GREEN: Color = 1; pub const Color_BLUE: Color = 2; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Inner { pub a: i32, pub b: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Container { pub inner: Inner, pub color: Color, diff --git a/tests/unit/out/unsafe/cast.rs b/tests/unit/out/unsafe/cast.rs index 43f00a71ed..101f126452 100644 --- a/tests/unit/out/unsafe/cast.rs +++ b/tests/unit/out/unsafe/cast.rs @@ -11,18 +11,45 @@ pub const E_A: E = 0; pub const E_B: E = 1; pub const E_C: E = 2; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Pair { pub x: i32, pub y: i32, } #[repr(C, align(64))] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Wide { pub c: libc::c_char, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Grid { pub h: i32, pub row: [i32; 3], @@ -34,6 +61,7 @@ pub struct Grid { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, SwappableUnsafe, diff --git a/tests/unit/out/unsafe/cast_array_to_pointer_decay.rs b/tests/unit/out/unsafe/cast_array_to_pointer_decay.rs index df2d7a704a..d8caf25784 100644 --- a/tests/unit/out/unsafe/cast_array_to_pointer_decay.rs +++ b/tests/unit/out/unsafe/cast_array_to_pointer_decay.rs @@ -17,7 +17,16 @@ pub unsafe fn strlen_1(mut s: *mut libc::c_char) -> i32 { return c; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Row { pub a: [i32; 3], } diff --git a/tests/unit/out/unsafe/class.rs b/tests/unit/out/unsafe/class.rs index 26b36aab5b..95d24f2b3d 100644 --- a/tests/unit/out/unsafe/class.rs +++ b/tests/unit/out/unsafe/class.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Pair { pub first: i32, pub second: i32, @@ -42,7 +51,16 @@ impl Pair { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Route { pub path: Pair, pub cost: f64, @@ -55,7 +73,16 @@ impl Route { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Counter { pub v: i32, pub calls: i32, @@ -77,7 +104,16 @@ impl std::cmp::PartialEq for Counter { } impl std::cmp::Eq for Counter {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Tally { pub calls: i32, } diff --git a/tests/unit/out/unsafe/class_template_lazy_member.rs b/tests/unit/out/unsafe/class_template_lazy_member.rs index 9ceceb005a..66317dfa2f 100644 --- a/tests/unit/out/unsafe/class_template_lazy_member.rs +++ b/tests/unit/out/unsafe/class_template_lazy_member.rs @@ -7,12 +7,30 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Point { pub x: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Box_int_ { pub val: i32, } @@ -22,7 +40,16 @@ impl Box_int_ { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Box_Point_ { pub val: Point, } @@ -32,7 +59,16 @@ impl Box_Point_ { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Deduced_int_ { pub val: i32, } @@ -42,7 +78,16 @@ impl Deduced_int_ { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Deduced_Point_ { pub val: Point, } diff --git a/tests/unit/out/unsafe/class_templates.rs b/tests/unit/out/unsafe/class_templates.rs index ebf90634ff..7e0ca915b3 100644 --- a/tests/unit/out/unsafe/class_templates.rs +++ b/tests/unit/out/unsafe/class_templates.rs @@ -12,6 +12,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, SwappableUnsafe, @@ -63,6 +64,7 @@ impl MoveAssignableUnsafe for MyContainer_int_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, SwappableUnsafe, @@ -114,6 +116,7 @@ impl MoveAssignableUnsafe for MyContainer_char_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, SwappableUnsafe, @@ -160,7 +163,16 @@ impl MoveAssignableUnsafe for MyContainer_float_ { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Boxed_short_ { pub value: i16, } @@ -173,7 +185,16 @@ impl Boxed_short_ { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Boxed_int_ { pub value: i32, } @@ -186,7 +207,16 @@ impl Boxed_int_ { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Boxed_long_ { pub value: i64, } @@ -199,7 +229,16 @@ impl Boxed_long_ { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Outer_int__Inner_int_ { pub t: i32, pub u: i32, @@ -210,7 +249,16 @@ impl Outer_int__Inner_int_ { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Outer_int_ { pub v: i32, } @@ -220,7 +268,16 @@ impl Outer_int_ { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Outer_long__Inner_int_ { pub t: i64, pub u: i32, @@ -231,7 +288,16 @@ impl Outer_long__Inner_int_ { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Outer_long__Inner_char_ { pub t: i64, pub u: libc::c_char, @@ -242,7 +308,16 @@ impl Outer_long__Inner_char_ { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Outer_long_ { pub v: i64, } @@ -252,7 +327,16 @@ impl Outer_long_ { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Elem { pub i: i32, } diff --git a/tests/unit/out/unsafe/clone_vs_move.rs b/tests/unit/out/unsafe/clone_vs_move.rs index 7dd801b0df..ed780956b4 100644 --- a/tests/unit/out/unsafe/clone_vs_move.rs +++ b/tests/unit/out/unsafe/clone_vs_move.rs @@ -7,12 +7,30 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Bar { pub w: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Foo { pub x: i32, pub y: *mut i32, @@ -21,7 +39,16 @@ pub struct Foo { pub bar: Bar, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Refs { pub a: *mut i32, pub b: *mut i32, diff --git a/tests/unit/out/unsafe/comma_operator.rs b/tests/unit/out/unsafe/comma_operator.rs index 9985a3a795..b13c468668 100644 --- a/tests/unit/out/unsafe/comma_operator.rs +++ b/tests/unit/out/unsafe/comma_operator.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Pair { pub first: i32, pub second: i32, diff --git a/tests/unit/out/unsafe/complex_function.rs b/tests/unit/out/unsafe/complex_function.rs index 66e04458d2..affaad74ec 100644 --- a/tests/unit/out/unsafe/complex_function.rs +++ b/tests/unit/out/unsafe/complex_function.rs @@ -16,12 +16,30 @@ pub unsafe fn bar_2(x: *mut i32) -> *mut i32 { return x; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct X1 { pub v: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct X2 { pub v: *mut X1, } @@ -31,7 +49,16 @@ impl X2 { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct X3 { pub v: *mut X2, } @@ -41,7 +68,16 @@ impl X3 { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct X4 { pub v: X3, } diff --git a/tests/unit/out/unsafe/compound_assign_paren.rs b/tests/unit/out/unsafe/compound_assign_paren.rs index b68a5e1f7a..be193150cb 100644 --- a/tests/unit/out/unsafe/compound_assign_paren.rs +++ b/tests/unit/out/unsafe/compound_assign_paren.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Item { pub flags: u8, } diff --git a/tests/unit/out/unsafe/concepts.rs b/tests/unit/out/unsafe/concepts.rs index a4de38cac7..c8a2276495 100644 --- a/tests/unit/out/unsafe/concepts.rs +++ b/tests/unit/out/unsafe/concepts.rs @@ -12,7 +12,16 @@ const _: () = assert!( "sizeof(int) == 4" ); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Sized {} impl Sized { pub unsafe fn size(&mut self) -> i32 { diff --git a/tests/unit/out/unsafe/constexpr_function.rs b/tests/unit/out/unsafe/constexpr_function.rs index e970188f44..af01c711a5 100644 --- a/tests/unit/out/unsafe/constexpr_function.rs +++ b/tests/unit/out/unsafe/constexpr_function.rs @@ -22,7 +22,16 @@ pub unsafe fn half_3(mut x: f64) -> f64 { return ((x) / (2_f64)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Flag { pub v: i32, } @@ -48,7 +57,16 @@ pub unsafe fn imm_7(mut b: bool) -> bool { return b; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct P { pub v: i32, } diff --git a/tests/unit/out/unsafe/constructor.rs b/tests/unit/out/unsafe/constructor.rs index 2a0a5c70a0..30366ce9d6 100644 --- a/tests/unit/out/unsafe/constructor.rs +++ b/tests/unit/out/unsafe/constructor.rs @@ -9,14 +9,7 @@ use std::rc::Rc; pub static mut total_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] #[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - DestructibleUnsafe, - CopyableUnsafe, - Default, + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, )] #[cpp_from(i32, construct, value)] pub struct S { @@ -35,14 +28,25 @@ impl S { (*std::cell::LazyCell::force_mut(&mut *&raw mut total_0)) += (unsafe { S::const_method(self) }); } - pub unsafe fn destructor(&mut self) { +} +impl DestructibleUnsafe for S { + unsafe fn destroy(&mut self) { (unsafe { S::mut_method(self) }); (*std::cell::LazyCell::force_mut(&mut *&raw mut total_0)) += (unsafe { S::const_method(self) }); } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, +)] #[cpp_from(i32, construct_1, value)] pub struct Point { pub x: i32, @@ -95,7 +99,7 @@ unsafe fn main_0() -> i32 { __v }; let _dtor_s = std::mem::DropGuard::new(&raw mut s, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); assert!(((s.v) == (4))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut total_0)) == (8))); diff --git a/tests/unit/out/unsafe/container_element_receiver.rs b/tests/unit/out/unsafe/container_element_receiver.rs index 690994595f..c0c76f6f33 100644 --- a/tests/unit/out/unsafe/container_element_receiver.rs +++ b/tests/unit/out/unsafe/container_element_receiver.rs @@ -12,6 +12,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, diff --git a/tests/unit/out/unsafe/container_field_addr.rs b/tests/unit/out/unsafe/container_field_addr.rs index 7d251d0652..db9675e061 100644 --- a/tests/unit/out/unsafe/container_field_addr.rs +++ b/tests/unit/out/unsafe/container_field_addr.rs @@ -12,6 +12,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, SwappableUnsafe, diff --git a/tests/unit/out/unsafe/conversion_operator_same_translation.rs b/tests/unit/out/unsafe/conversion_operator_same_translation.rs index e5c551acfb..69fdad1457 100644 --- a/tests/unit/out/unsafe/conversion_operator_same_translation.rs +++ b/tests/unit/out/unsafe/conversion_operator_same_translation.rs @@ -8,7 +8,15 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, )] #[cpp_into(libc::c_char, to_libcc_char)] #[cpp_into(u8, to_u8)] @@ -25,7 +33,15 @@ impl S { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, )] #[cpp_into(i64, to_i64_1)] pub struct T { diff --git a/tests/unit/out/unsafe/copy_assign.rs b/tests/unit/out/unsafe/copy_assign.rs index f391136942..e78d4ea445 100644 --- a/tests/unit/out/unsafe/copy_assign.rs +++ b/tests/unit/out/unsafe/copy_assign.rs @@ -12,6 +12,7 @@ pub static mut assigns_0: std::cell::LazyCell = std::cell::LazyCell::new(|| VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -53,7 +54,9 @@ impl Clone for Partial { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct NonConstAssign { pub mark: i32, } @@ -88,6 +91,7 @@ impl Default for NonConstAssign { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, @@ -124,6 +128,7 @@ impl Default for RefQualified { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, @@ -162,6 +167,7 @@ pub static mut copies_1: std::cell::LazyCell = std::cell::LazyCell::new(|| FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DestructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -203,6 +209,7 @@ impl Clone for CopyCounted { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, diff --git a/tests/unit/out/unsafe/copy_ctor.rs b/tests/unit/out/unsafe/copy_ctor.rs index adabeb6559..f868ede301 100644 --- a/tests/unit/out/unsafe/copy_ctor.rs +++ b/tests/unit/out/unsafe/copy_ctor.rs @@ -13,6 +13,7 @@ pub static mut copies_0: std::cell::LazyCell = std::cell::LazyCell::new(|| FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DestructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -53,6 +54,7 @@ impl Clone for Counted { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, @@ -104,6 +106,7 @@ impl Default for NonConst { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DestructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -145,6 +148,7 @@ impl Clone for Ignored { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, @@ -178,6 +182,7 @@ impl CopyAssignableUnsafe for Holder { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DestructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -217,6 +222,7 @@ impl Clone for Box_int_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, @@ -241,6 +247,7 @@ impl MoveConstructibleUnsafe for Owner { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DestructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -281,6 +288,7 @@ impl Clone for OutOfLine { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, SwappableUnsafe, diff --git a/tests/unit/out/unsafe/copy_move_defaulted.rs b/tests/unit/out/unsafe/copy_move_defaulted.rs index f94af02767..dad754d0b4 100644 --- a/tests/unit/out/unsafe/copy_move_defaulted.rs +++ b/tests/unit/out/unsafe/copy_move_defaulted.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Inner { pub x: i32, } @@ -18,7 +27,6 @@ pub struct Inner { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DestructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -36,10 +44,21 @@ impl Explicit { (&raw mut self.inner).write(Inner { x: ((v) * (10)) }); (&raw mut self.arr).write([v, ((v) + (1))]); } - pub unsafe fn destructor(&mut self) {} +} +impl DestructibleUnsafe for Explicit { + unsafe fn destroy(&mut self) {} } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Implicit { pub v: i32, pub inner: Inner, @@ -53,6 +72,7 @@ pub struct Implicit { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DestructibleUnsafe, CopyAssignableUnsafe, SwappableUnsafe, Default, @@ -80,7 +100,15 @@ impl MoveAssignableUnsafe for DefaultCopyUserMove { } } #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, SwappableUnsafe, Default)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + SwappableUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct UserCopyDefaultMove { pub v: i32, @@ -122,7 +150,9 @@ impl Clone for UserCopyDefaultMove { } } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, SwappableUnsafe, Default)] +#[derive( + FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, SwappableUnsafe, Default, +)] #[cpp_from(i32, construct, value)] pub struct Buffer { pub data: Vec, @@ -173,7 +203,7 @@ impl MoveAssignableUnsafe for Buffer { } } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, SwappableUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, SwappableUnsafe, Default)] pub struct Owner { pub data: Vec, pub n: i32, @@ -216,6 +246,7 @@ impl MoveAssignableUnsafe for Owner { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, SwappableUnsafe, @@ -238,9 +269,7 @@ impl MoveAssignableUnsafe for Copyable { } } #[repr(C)] -#[derive( - FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, SwappableUnsafe, Default, -)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, SwappableUnsafe, Default)] #[cpp_from(i32, construct, value)] pub struct Holder { pub inner: Inner, @@ -275,9 +304,9 @@ impl MoveAssignableUnsafe for Holder { return &mut (*(self as *mut Holder)); } } -impl Holder { - pub unsafe fn destructor(&mut self) { - DestructibleUnsafe::destroy(&raw mut self.e); +impl DestructibleUnsafe for Holder { + unsafe fn destroy(&mut self) { + DestructibleUnsafe::destroy(&mut self.e); } } pub unsafe fn same_0(a: *const Explicit, b: *const Explicit) -> bool { @@ -298,19 +327,19 @@ unsafe fn main_0() -> i32 { __v }; let _dtor_a = std::mem::DropGuard::new(&raw mut a, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); let mut b: Explicit = a.clone(); let _dtor_b = std::mem::DropGuard::new(&raw mut b, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); let mut c: Explicit = a.clone(); let _dtor_c = std::mem::DropGuard::new(&raw mut c, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); let mut d: Explicit = a.clone(); let _dtor_d = std::mem::DropGuard::new(&raw mut d, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); assert!( ((unsafe { same_0(&b, &a,) }) && (unsafe { same_0(&c, &a,) })) @@ -322,7 +351,7 @@ unsafe fn main_0() -> i32 { __v }; let _dtor_e = std::mem::DropGuard::new(&raw mut e, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); let mut f: Explicit = { let mut __v: Explicit = ::zero_init(); @@ -330,7 +359,7 @@ unsafe fn main_0() -> i32 { __v }; let _dtor_f = std::mem::DropGuard::new(&raw mut f, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); e = (b).clone(); f = (c).clone(); @@ -341,7 +370,7 @@ unsafe fn main_0() -> i32 { __v }; let _dtor_g = std::mem::DropGuard::new(&raw mut g, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); g = { e = (f).clone(); @@ -558,7 +587,7 @@ unsafe fn main_0() -> i32 { __v }; let _dtor_h1 = std::mem::DropGuard::new(&raw mut h1, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); { let _a0: *mut i32 = (Box::leak(Box::new(9)) as *mut i32); @@ -574,7 +603,7 @@ unsafe fn main_0() -> i32 { __v }; let _dtor_h2 = std::mem::DropGuard::new(&raw mut h2, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); assert!( ((((h2.inner.x) == (4)) && ((h2.e.v) == (4))) @@ -595,7 +624,7 @@ unsafe fn main_0() -> i32 { __v }; let _dtor_h3 = std::mem::DropGuard::new(&raw mut h3, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); (unsafe { MoveAssignableUnsafe::move_assign(&mut h3, &mut h2) }); assert!( diff --git a/tests/unit/out/unsafe/copy_move_deleted.rs b/tests/unit/out/unsafe/copy_move_deleted.rs index 4419889b00..4a78de75c0 100644 --- a/tests/unit/out/unsafe/copy_move_deleted.rs +++ b/tests/unit/out/unsafe/copy_move_deleted.rs @@ -7,7 +7,9 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, SwappableUnsafe, Default)] +#[derive( + FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, SwappableUnsafe, Default, +)] #[cpp_from(i32, construct, value)] pub struct NoCopy { pub v: i32, @@ -31,7 +33,7 @@ impl MoveAssignableUnsafe for NoCopy { } } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, SwappableUnsafe)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, SwappableUnsafe)] pub struct PrivateCopy { pub v: i32, } @@ -65,7 +67,7 @@ impl Default for PrivateCopy { } } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe)] pub struct Immovable { pub v: i32, } @@ -86,7 +88,7 @@ impl Default for Immovable { } } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, SwappableUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, SwappableUnsafe, Default)] pub struct Container { pub inner: NoCopy, pub tag: i32, @@ -112,7 +114,7 @@ impl MoveAssignableUnsafe for Container { } } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, SwappableUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, SwappableUnsafe, Default)] pub struct VecHolder { pub items: Vec, } diff --git a/tests/unit/out/unsafe/default.rs b/tests/unit/out/unsafe/default.rs index ad506ea844..db86e237ca 100644 --- a/tests/unit/out/unsafe/default.rs +++ b/tests/unit/out/unsafe/default.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Pointers { pub x1: *mut i32, pub x2: *const i32, @@ -16,7 +25,16 @@ pub struct Pointers { pub x5: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct SmallArrays { pub a: [i32; 32], pub f: Option i32>, @@ -24,7 +42,9 @@ pub struct SmallArrays { pub p: [Pointers; 2], } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct BigArray { pub a: [i32; 33], } diff --git a/tests/unit/out/unsafe/default_function_arguments.rs b/tests/unit/out/unsafe/default_function_arguments.rs index 3eb7e63b4d..6c3937e6d5 100644 --- a/tests/unit/out/unsafe/default_function_arguments.rs +++ b/tests/unit/out/unsafe/default_function_arguments.rs @@ -13,7 +13,16 @@ pub unsafe fn baz_1(mut a: *mut i32, mut b: *mut i32) -> bool { return ((a) == (b)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, +)] #[cpp_from(i32, construct, value)] pub struct Bar { pub v: i32, @@ -61,7 +70,16 @@ pub unsafe fn first_9(r: *mut [i32; 3]) -> i32 { return (*r)[(0) as usize]; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Holder_int_ { pub v: i32, } diff --git a/tests/unit/out/unsafe/default_in_statics.rs b/tests/unit/out/unsafe/default_in_statics.rs index 43f63ebb35..254bc6e763 100644 --- a/tests/unit/out/unsafe/default_in_statics.rs +++ b/tests/unit/out/unsafe/default_in_statics.rs @@ -7,13 +7,31 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Inner { pub v: i32, pub name: *const libc::c_char, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Outer { pub p1: *mut i32, pub p2: *const i32, @@ -25,7 +43,16 @@ pub struct Outer { pub fn_: Option i32>, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Foo { pub s1: *const libc::c_char, pub s2: *const libc::c_char, diff --git a/tests/unit/out/unsafe/delete_array_order.rs b/tests/unit/out/unsafe/delete_array_order.rs index b0a32d21ed..6b2da5ceed 100644 --- a/tests/unit/out/unsafe/delete_array_order.rs +++ b/tests/unit/out/unsafe/delete_array_order.rs @@ -7,15 +7,13 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, -)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Element { pub id: i64, pub value: i64, } -impl Element { - pub unsafe fn destructor(&mut self) { +impl DestructibleUnsafe for Element { + unsafe fn destroy(&mut self) { (unsafe { libc::printf( c"%ld:%ld ".as_ptr() as *const libc::c_char, @@ -54,7 +52,7 @@ unsafe fn main_0() -> i32 { / ::std::mem::size_of::()) .rev() { - DestructibleUnsafe::destroy(__p.add(__i)); + DestructibleUnsafe::destroy(&mut *__p.add(__i)); } ::std::mem::drop(Box::from_raw(::std::slice::from_raw_parts_mut( __p, diff --git a/tests/unit/out/unsafe/destructor.rs b/tests/unit/out/unsafe/destructor.rs index 058b1ada33..ec163db750 100644 --- a/tests/unit/out/unsafe/destructor.rs +++ b/tests/unit/out/unsafe/destructor.rs @@ -8,112 +8,94 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub static mut global_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, -)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S {} -impl S { - pub unsafe fn destructor(&mut self) { +impl DestructibleUnsafe for S { + unsafe fn destroy(&mut self) { (*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)).postfix_inc(); } } #[repr(C)] -#[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, -)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Defaulted { pub s: S, } -impl Defaulted { - pub unsafe fn destructor(&mut self) { - DestructibleUnsafe::destroy(&raw mut self.s); +impl DestructibleUnsafe for Defaulted { + unsafe fn destroy(&mut self) { + DestructibleUnsafe::destroy(&mut self.s); } } #[repr(C)] -#[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, -)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Middle { pub s: S, } -impl Middle { - pub unsafe fn destructor(&mut self) { - DestructibleUnsafe::destroy(&raw mut self.s); +impl DestructibleUnsafe for Middle { + unsafe fn destroy(&mut self) { + DestructibleUnsafe::destroy(&mut self.s); } } #[repr(C)] -#[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, -)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Outer { pub m: Middle, } -impl Outer { - pub unsafe fn destructor(&mut self) { - DestructibleUnsafe::destroy(&raw mut self.m); +impl DestructibleUnsafe for Outer { + unsafe fn destroy(&mut self) { + DestructibleUnsafe::destroy(&mut self.m); } } #[repr(C)] -#[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, -)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct ArrayMember { pub items: [S; 3], } -impl ArrayMember { - pub unsafe fn destructor(&mut self) { - DestructibleUnsafe::destroy(&raw mut self.items); +impl DestructibleUnsafe for ArrayMember { + unsafe fn destroy(&mut self) { + DestructibleUnsafe::destroy(&mut self.items); } } #[repr(C)] -#[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, -)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct EmptyBody { pub s: S, } -impl EmptyBody { - pub unsafe fn destructor(&mut self) { - DestructibleUnsafe::destroy(&raw mut self.s); +impl DestructibleUnsafe for EmptyBody { + unsafe fn destroy(&mut self) { + DestructibleUnsafe::destroy(&mut self.s); } } #[repr(C)] -#[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, -)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Templated_char_ { pub v: libc::c_char, } -impl Templated_char_ { - pub unsafe fn destructor(&mut self) { +impl DestructibleUnsafe for Templated_char_ { + unsafe fn destroy(&mut self) { (*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) = (((*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) as usize) .wrapping_add((::std::mem::size_of::() as usize))) as i32; } } #[repr(C)] -#[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, -)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Templated_int_ { pub v: i32, } -impl Templated_int_ { - pub unsafe fn destructor(&mut self) { +impl DestructibleUnsafe for Templated_int_ { + unsafe fn destroy(&mut self) { (*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) = (((*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) as usize) .wrapping_add((::std::mem::size_of::() as usize))) as i32; } } #[repr(C)] -#[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, -)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Copied { pub v: i32, } -impl Copied { - pub unsafe fn destructor(&mut self) { +impl DestructibleUnsafe for Copied { + unsafe fn destroy(&mut self) { (*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)).postfix_inc(); } } @@ -121,23 +103,19 @@ pub static mut order_1: std::cell::LazyCell<[i32; 3]> = std::cell::LazyCell::new(|| unsafe { [0_i32; 3] }); pub static mut order_count_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, -)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Tagged { pub tag: i32, } -impl Tagged { - pub unsafe fn destructor(&mut self) { +impl DestructibleUnsafe for Tagged { + unsafe fn destroy(&mut self) { (*std::cell::LazyCell::force_mut(&mut *&raw mut order_1)) [((*std::cell::LazyCell::force_mut(&mut *&raw mut order_count_2)).postfix_inc()) as usize] = self.tag; } } #[repr(C)] -#[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, -)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Ordered { pub first: Tagged, pub dummy1: i32, @@ -145,11 +123,11 @@ pub struct Ordered { pub dummy2: i32, pub third: Tagged, } -impl Ordered { - pub unsafe fn destructor(&mut self) { - DestructibleUnsafe::destroy(&raw mut self.third); - DestructibleUnsafe::destroy(&raw mut self.second); - DestructibleUnsafe::destroy(&raw mut self.first); +impl DestructibleUnsafe for Ordered { + unsafe fn destroy(&mut self) { + DestructibleUnsafe::destroy(&mut self.third); + DestructibleUnsafe::destroy(&mut self.second); + DestructibleUnsafe::destroy(&mut self.first); } } pub fn main() { @@ -162,64 +140,64 @@ unsafe fn main_0() -> i32 { { let mut s: S = ::default(); let _dtor_s = std::mem::DropGuard::new(&raw mut s, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); } assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) == (1))); { let mut s: S = ::default(); let _dtor_s = std::mem::DropGuard::new(&raw mut s, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); } assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) == (2))); { let mut d: Defaulted = ::default(); let _dtor_d = std::mem::DropGuard::new(&raw mut d, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); } assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) == (3))); { let mut o: Outer = ::default(); let _dtor_o = std::mem::DropGuard::new(&raw mut o, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); } assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) == (4))); { let mut am: ArrayMember = ::default(); let _dtor_am = std::mem::DropGuard::new(&raw mut am, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); } assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) == (7))); { let mut e: EmptyBody = ::default(); let _dtor_e = std::mem::DropGuard::new(&raw mut e, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); } assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) == (8))); { let mut tc: Templated_char_ = ::default(); let _dtor_tc = std::mem::DropGuard::new(&raw mut tc, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); let mut ti: Templated_int_ = ::default(); let _dtor_ti = std::mem::DropGuard::new(&raw mut ti, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); } assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) == (13))); { let mut a: Copied = Copied { v: 5 }; let _dtor_a = std::mem::DropGuard::new(&raw mut a, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); let mut b: Copied = a.clone(); let _dtor_b = std::mem::DropGuard::new(&raw mut b, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); assert!(((b.v) == (5))); } @@ -233,7 +211,7 @@ unsafe fn main_0() -> i32 { third: Tagged { tag: 3 }, }; let _dtor_o = std::mem::DropGuard::new(&raw mut o, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); } assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut order_count_2)) == (3))); @@ -244,7 +222,7 @@ unsafe fn main_0() -> i32 { { let mut cs: S = ::default(); let _dtor_cs = std::mem::DropGuard::new(&raw mut cs, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); } assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) == ((before) + (1)))); diff --git a/tests/unit/out/unsafe/destructor_params.rs b/tests/unit/out/unsafe/destructor_params.rs index f6d5e8ee8f..8bf2d17cc3 100644 --- a/tests/unit/out/unsafe/destructor_params.rs +++ b/tests/unit/out/unsafe/destructor_params.rs @@ -9,14 +9,12 @@ use std::rc::Rc; pub static mut destroyed_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut last_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, -)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub v: i32, } -impl S { - pub unsafe fn destructor(&mut self) { +impl DestructibleUnsafe for S { + unsafe fn destroy(&mut self) { (*std::cell::LazyCell::force_mut(&mut *&raw mut destroyed_0)).postfix_inc(); (*std::cell::LazyCell::force_mut(&mut *&raw mut last_1)) = self.v; } @@ -29,7 +27,16 @@ pub unsafe fn with_default_3(mut s: S) -> i32 { return s.v; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Holder { pub v: i32, } @@ -51,7 +58,7 @@ unsafe fn main_0() -> i32 { { let mut s: S = S { v: 1 }; let _dtor_s = std::mem::DropGuard::new(&raw mut s, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); assert!(((unsafe { by_value_2(s.clone(),) }) == (1))); assert!( diff --git a/tests/unit/out/unsafe/destructor_temporaries.rs b/tests/unit/out/unsafe/destructor_temporaries.rs index f92b55aabd..69037a770c 100644 --- a/tests/unit/out/unsafe/destructor_temporaries.rs +++ b/tests/unit/out/unsafe/destructor_temporaries.rs @@ -9,32 +9,30 @@ use std::rc::Rc; pub static mut destroyed_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut last_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, -)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub v: i32, } impl S { - pub unsafe fn destructor(&mut self) { - (*std::cell::LazyCell::force_mut(&mut *&raw mut destroyed_0)).postfix_inc(); - (*std::cell::LazyCell::force_mut(&mut *&raw mut last_1)) = self.v; - } pub unsafe fn get(&self) -> i32 { return self.v; } } +impl DestructibleUnsafe for S { + unsafe fn destroy(&mut self) { + (*std::cell::LazyCell::force_mut(&mut *&raw mut destroyed_0)).postfix_inc(); + (*std::cell::LazyCell::force_mut(&mut *&raw mut last_1)) = self.v; + } +} #[repr(C)] -#[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, -)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Outer { pub inner: S, pub w: i32, } -impl Outer { - pub unsafe fn destructor(&mut self) { - DestructibleUnsafe::destroy(&raw mut self.inner); +impl DestructibleUnsafe for Outer { + unsafe fn destroy(&mut self) { + DestructibleUnsafe::destroy(&mut self.inner); } } pub unsafe fn make_2(mut v: i32) -> S { @@ -138,7 +136,7 @@ unsafe fn main_0() -> i32 { { let mut s: S = S { v: 12 }; let _dtor_s = std::mem::DropGuard::new(&raw mut s, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); s = (unsafe { make_2(13) }); assert!( diff --git a/tests/unit/out/unsafe/doubly_linked_list.rs b/tests/unit/out/unsafe/doubly_linked_list.rs index 5280f20795..1cce38f8cb 100644 --- a/tests/unit/out/unsafe/doubly_linked_list.rs +++ b/tests/unit/out/unsafe/doubly_linked_list.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Node { pub val: i32, pub next: *mut Node, diff --git a/tests/unit/out/unsafe/enum_default_in_static.rs b/tests/unit/out/unsafe/enum_default_in_static.rs index 2940999348..0bd954a6ce 100644 --- a/tests/unit/out/unsafe/enum_default_in_static.rs +++ b/tests/unit/out/unsafe/enum_default_in_static.rs @@ -11,7 +11,16 @@ pub const Mode_MODE_NONE: Mode = 0; pub const Mode_MODE_ONE: Mode = 1; pub const Mode_MODE_TWO: Mode = 2; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Config { pub count: i32, pub mode: Mode, diff --git a/tests/unit/out/unsafe/enum_int_interop.rs b/tests/unit/out/unsafe/enum_int_interop.rs index fb5cc1e834..b079413208 100644 --- a/tests/unit/out/unsafe/enum_int_interop.rs +++ b/tests/unit/out/unsafe/enum_int_interop.rs @@ -20,7 +20,16 @@ pub const Tag_TAG_ZERO: Tag = 0; pub const Tag_TAG_ONE: Tag = 1; pub const Tag_TAG_TWO: Tag = 2; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Entry { pub name: *const libc::c_char, pub color: Color, diff --git a/tests/unit/out/unsafe/enum_int_interop_c.rs b/tests/unit/out/unsafe/enum_int_interop_c.rs index a14c64b644..c28d97772b 100644 --- a/tests/unit/out/unsafe/enum_int_interop_c.rs +++ b/tests/unit/out/unsafe/enum_int_interop_c.rs @@ -20,7 +20,16 @@ pub const Tag_enum_TAG_ZERO: Tag_enum = 0; pub const Tag_enum_TAG_ONE: Tag_enum = 1; pub const Tag_enum_TAG_TWO: Tag_enum = 2; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Entry { pub name: *const libc::c_char, pub color: Color, diff --git a/tests/unit/out/unsafe/enum_underlying_type.rs b/tests/unit/out/unsafe/enum_underlying_type.rs index 596209959f..d957cd98ed 100644 --- a/tests/unit/out/unsafe/enum_underlying_type.rs +++ b/tests/unit/out/unsafe/enum_underlying_type.rs @@ -26,7 +26,9 @@ pub const Scoped_NEG: Scoped = -2; pub const Scoped_POS: Scoped = 2; pub type Empty = bool; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct HoldsEmpty { pub e: Empty, } diff --git a/tests/unit/out/unsafe/exprs.rs b/tests/unit/out/unsafe/exprs.rs index d0790bd8e8..61e152ca29 100644 --- a/tests/unit/out/unsafe/exprs.rs +++ b/tests/unit/out/unsafe/exprs.rs @@ -7,12 +7,30 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct X { pub x: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Y { pub x: X, pub p: *mut X, diff --git a/tests/unit/out/unsafe/fft.rs b/tests/unit/out/unsafe/fft.rs index 5274c507c8..788a6c6834 100644 --- a/tests/unit/out/unsafe/fft.rs +++ b/tests/unit/out/unsafe/fft.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Complex { pub re: f64, pub img: f64, diff --git a/tests/unit/out/unsafe/field_aliasing.rs b/tests/unit/out/unsafe/field_aliasing.rs index fa7e7ba4b8..6f02452a3b 100644 --- a/tests/unit/out/unsafe/field_aliasing.rs +++ b/tests/unit/out/unsafe/field_aliasing.rs @@ -7,13 +7,31 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct In { pub x: i32, pub y: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub in_: In, pub total: i32, @@ -21,7 +39,16 @@ pub struct S { pub arr: [i32; 4], } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Node { pub x: i32, pub self_: *mut Node, diff --git a/tests/unit/out/unsafe/field_array_elem_ptr.rs b/tests/unit/out/unsafe/field_array_elem_ptr.rs index 70b02a0bcf..a9674c8fee 100644 --- a/tests/unit/out/unsafe/field_array_elem_ptr.rs +++ b/tests/unit/out/unsafe/field_array_elem_ptr.rs @@ -7,13 +7,31 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Point { pub x: i32, pub y: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Shape { pub id: i32, pub coords: [i32; 4], diff --git a/tests/unit/out/unsafe/field_method_receiver.rs b/tests/unit/out/unsafe/field_method_receiver.rs index e392c69865..7215004943 100644 --- a/tests/unit/out/unsafe/field_method_receiver.rs +++ b/tests/unit/out/unsafe/field_method_receiver.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Counter { pub n: i32, } @@ -32,6 +41,7 @@ impl Counter { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, SwappableUnsafe, diff --git a/tests/unit/out/unsafe/field_pointers.rs b/tests/unit/out/unsafe/field_pointers.rs index 65b492c43f..2682f5e01d 100644 --- a/tests/unit/out/unsafe/field_pointers.rs +++ b/tests/unit/out/unsafe/field_pointers.rs @@ -7,13 +7,31 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Inner { pub a: i32, pub name: [libc::c_char; 8], } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Header { pub tag: i32, pub size: i16, @@ -24,6 +42,7 @@ pub struct Header { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, SwappableUnsafe, diff --git a/tests/unit/out/unsafe/field_pointers_malloced_struct.rs b/tests/unit/out/unsafe/field_pointers_malloced_struct.rs index 58aed9d303..8b21831780 100644 --- a/tests/unit/out/unsafe/field_pointers_malloced_struct.rs +++ b/tests/unit/out/unsafe/field_pointers_malloced_struct.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub a: i32, pub b: i32, diff --git a/tests/unit/out/unsafe/field_reinterpret_write_through.rs b/tests/unit/out/unsafe/field_reinterpret_write_through.rs index eea33efa9d..70ebbf27a0 100644 --- a/tests/unit/out/unsafe/field_reinterpret_write_through.rs +++ b/tests/unit/out/unsafe/field_reinterpret_write_through.rs @@ -7,13 +7,31 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct In { pub a: i16, pub b: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub x: i32, pub in_: In, diff --git a/tests/unit/out/unsafe/find.rs b/tests/unit/out/unsafe/find.rs index a4a9d612c7..d4e2d4d9e7 100644 --- a/tests/unit/out/unsafe/find.rs +++ b/tests/unit/out/unsafe/find.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct P { pub x: i32, } diff --git a/tests/unit/out/unsafe/first_field_ptr_covers_struct.rs b/tests/unit/out/unsafe/first_field_ptr_covers_struct.rs index 3d6f3035b6..43a7044886 100644 --- a/tests/unit/out/unsafe/first_field_ptr_covers_struct.rs +++ b/tests/unit/out/unsafe/first_field_ptr_covers_struct.rs @@ -7,13 +7,31 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct In { pub a: i16, pub b: i16, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub x: i32, pub in_: In, diff --git a/tests/unit/out/unsafe/first_member_downcast.rs b/tests/unit/out/unsafe/first_member_downcast.rs index 146a537085..66c8c06c7f 100644 --- a/tests/unit/out/unsafe/first_member_downcast.rs +++ b/tests/unit/out/unsafe/first_member_downcast.rs @@ -7,12 +7,30 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct base { pub kind: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct derived { pub head: base, pub value: usize, diff --git a/tests/unit/out/unsafe/flex_array_member_incomplete.rs b/tests/unit/out/unsafe/flex_array_member_incomplete.rs index de36f3fd61..d6858e1859 100644 --- a/tests/unit/out/unsafe/flex_array_member_incomplete.rs +++ b/tests/unit/out/unsafe/flex_array_member_incomplete.rs @@ -7,7 +7,9 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct F { pub n: i32, pub tail: [libc::c_char; 0], diff --git a/tests/unit/out/unsafe/flex_array_member_sibling_write.rs b/tests/unit/out/unsafe/flex_array_member_sibling_write.rs index f4555e0a20..47fc857aa4 100644 --- a/tests/unit/out/unsafe/flex_array_member_sibling_write.rs +++ b/tests/unit/out/unsafe/flex_array_member_sibling_write.rs @@ -7,19 +7,46 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub n: i32, pub name: [libc::c_char; 1], } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct E { pub id: i32, pub w: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct T { pub n: i32, pub cap: i32, diff --git a/tests/unit/out/unsafe/fn_ptr.rs b/tests/unit/out/unsafe/fn_ptr.rs index f087600d19..0bdabf1fc8 100644 --- a/tests/unit/out/unsafe/fn_ptr.rs +++ b/tests/unit/out/unsafe/fn_ptr.rs @@ -33,7 +33,15 @@ pub unsafe fn identity_hash_6(mut v: bool) -> usize { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, )] #[cpp_from(Option u64 > , construct, ptr)] pub struct HashHolder_unsigned_long__ptr__bool__ { diff --git a/tests/unit/out/unsafe/fn_ptr_cast.rs b/tests/unit/out/unsafe/fn_ptr_cast.rs index e8e701d467..aa381b191f 100644 --- a/tests/unit/out/unsafe/fn_ptr_cast.rs +++ b/tests/unit/out/unsafe/fn_ptr_cast.rs @@ -30,7 +30,16 @@ pub unsafe fn test_double_cast_2() { assert!(((fn2) == (fn_))); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Command { pub data: *mut ::libc::c_void, } diff --git a/tests/unit/out/unsafe/fn_ptr_stable_sort.rs b/tests/unit/out/unsafe/fn_ptr_stable_sort.rs index f5c540051e..d32ebd39f3 100644 --- a/tests/unit/out/unsafe/fn_ptr_stable_sort.rs +++ b/tests/unit/out/unsafe/fn_ptr_stable_sort.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Item { pub key: i32, pub value: i32, diff --git a/tests/unit/out/unsafe/fn_ptr_struct.rs b/tests/unit/out/unsafe/fn_ptr_struct.rs index bbb90e045f..db38c500b5 100644 --- a/tests/unit/out/unsafe/fn_ptr_struct.rs +++ b/tests/unit/out/unsafe/fn_ptr_struct.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Handler { pub tag: i32, pub cb: Option i32>, @@ -19,7 +28,16 @@ pub unsafe fn negate_1(mut x: i32) -> i32 { return -x; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S {} impl S { pub unsafe fn pick_1(mut x: i32) -> i32 { @@ -33,7 +51,7 @@ impl S { } } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, Default)] #[cpp_from(i32, construct, value)] pub struct MoveOnly { pub data_: i32, diff --git a/tests/unit/out/unsafe/fn_ptr_typedef_cast.rs b/tests/unit/out/unsafe/fn_ptr_typedef_cast.rs index 5107f3d8d2..4591740e50 100644 --- a/tests/unit/out/unsafe/fn_ptr_typedef_cast.rs +++ b/tests/unit/out/unsafe/fn_ptr_typedef_cast.rs @@ -19,7 +19,16 @@ pub unsafe fn via_size_t_return_3(mut b: u64) -> usize { return (b as usize); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct pair { pub a: i32, pub b: i32, diff --git a/tests/unit/out/unsafe/fn_ptr_vtable.rs b/tests/unit/out/unsafe/fn_ptr_vtable.rs index c7726a2ee2..3d73178885 100644 --- a/tests/unit/out/unsafe/fn_ptr_vtable.rs +++ b/tests/unit/out/unsafe/fn_ptr_vtable.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Vtable { pub create: Option *mut ::libc::c_void>, pub get: Option i32>, diff --git a/tests/unit/out/unsafe/fn_ref.rs b/tests/unit/out/unsafe/fn_ref.rs index dec5e0e1a9..cc3c0559cb 100644 --- a/tests/unit/out/unsafe/fn_ref.rs +++ b/tests/unit/out/unsafe/fn_ref.rs @@ -22,7 +22,16 @@ pub unsafe fn call_forwarded_4(f: Option i32>, mut x: i32) -> return (unsafe { (f).unwrap()(x) }); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Holder { pub f: Option i32>, } diff --git a/tests/unit/out/unsafe/for_body_destructor.rs b/tests/unit/out/unsafe/for_body_destructor.rs index f87d25e391..37f709250a 100644 --- a/tests/unit/out/unsafe/for_body_destructor.rs +++ b/tests/unit/out/unsafe/for_body_destructor.rs @@ -7,20 +7,20 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, -)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Guard { pub digit: i32, } impl Guard { - pub unsafe fn destructor(&mut self) { - (unsafe { libc::printf(c"%d ".as_ptr() as *const libc::c_char, (self.digit)) }); - } pub unsafe fn to_bool(&self) -> bool { return ((self.digit) != (0)); } } +impl DestructibleUnsafe for Guard { + unsafe fn destroy(&mut self) { + (unsafe { libc::printf(c"%d ".as_ptr() as *const libc::c_char, (self.digit)) }); + } +} pub unsafe fn step_0(i: *mut i32) { (unsafe { libc::printf(c"9 ".as_ptr() as *const libc::c_char) }); (*i).prefix_inc(); @@ -39,11 +39,11 @@ unsafe fn main_0() -> i32 { 'for_body: { let mut first: Guard = Guard { digit: 1 }; let _dtor_first = std::mem::DropGuard::new(&raw mut first, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); let mut second: Guard = Guard { digit: 2 }; let _dtor_second = std::mem::DropGuard::new(&raw mut second, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); if ((i) == (0)) { break 'for_body; @@ -59,7 +59,7 @@ unsafe fn main_0() -> i32 { 'for_body: { let mut g: Guard = Guard { digit: 3 }; let _dtor_g = std::mem::DropGuard::new(&raw mut g, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); break 'loop_; } @@ -73,7 +73,7 @@ unsafe fn main_0() -> i32 { 'for_body: { let mut outer: Guard = Guard { digit: 4 }; let _dtor_outer = std::mem::DropGuard::new(&raw mut outer, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); { let mut j: i32 = 0; @@ -82,7 +82,7 @@ unsafe fn main_0() -> i32 { let mut inner: Guard = Guard { digit: 5 }; let _dtor_inner = std::mem::DropGuard::new(&raw mut inner, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); if ((j) == (0)) { break 'for_body; @@ -104,13 +104,13 @@ unsafe fn main_0() -> i32 { 'for_body: { let mut outer: Guard = Guard { digit: 4 }; let _dtor_outer = std::mem::DropGuard::new(&raw mut outer, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); let mut j: i32 = 0; 'loop_: while ((*j.prefix_inc()) < (3)) { let mut inner: Guard = Guard { digit: 5 }; let _dtor_inner = std::mem::DropGuard::new(&raw mut inner, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); if ((j) == (1)) { continue 'loop_; @@ -122,7 +122,7 @@ unsafe fn main_0() -> i32 { __do_while = false; let mut inner: Guard = Guard { digit: 6 }; let _dtor_inner = std::mem::DropGuard::new(&raw mut inner, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); continue 'loop_; } @@ -134,7 +134,7 @@ unsafe fn main_0() -> i32 { let mut value: i32 = (*value); let mut inner: Guard = Guard { digit: value }; let _dtor_inner = std::mem::DropGuard::new(&raw mut inner, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); if ((value) == (1)) { continue 'loop_; @@ -152,7 +152,7 @@ unsafe fn main_0() -> i32 { 'loop_: loop { let mut condition: Guard = Guard { digit: i }; let _dtor_condition = std::mem::DropGuard::new(&raw mut condition, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); if !(unsafe { Guard::to_bool(&condition) }) { break; @@ -160,7 +160,7 @@ unsafe fn main_0() -> i32 { 'for_body: { let mut body: Guard = Guard { digit: 4 }; let _dtor_body = std::mem::DropGuard::new(&raw mut body, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); if ((i) == (2)) { break 'for_body; @@ -179,13 +179,13 @@ unsafe fn main_0() -> i32 { { let mut init: Guard = Guard { digit: 5 }; let _dtor_init = std::mem::DropGuard::new(&raw mut init, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); 'loop_: while ((i) < (2)) { 'for_body: { let mut body: Guard = Guard { digit: 6 }; let _dtor_body = std::mem::DropGuard::new(&raw mut body, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); } (unsafe { step_0(&mut i) }); @@ -199,7 +199,7 @@ unsafe fn main_0() -> i32 { digit: (*j.prefix_inc()), }; let _dtor_g = std::mem::DropGuard::new(&raw mut g, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); continue 'loop_; } diff --git a/tests/unit/out/unsafe/foreach_disjoint_field_borrow.rs b/tests/unit/out/unsafe/foreach_disjoint_field_borrow.rs index e7e5e12b3a..c5b7d9789d 100644 --- a/tests/unit/out/unsafe/foreach_disjoint_field_borrow.rs +++ b/tests/unit/out/unsafe/foreach_disjoint_field_borrow.rs @@ -12,6 +12,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, SwappableUnsafe, diff --git a/tests/unit/out/unsafe/forward_basic.rs b/tests/unit/out/unsafe/forward_basic.rs index e90c2d9084..983c52f2d5 100644 --- a/tests/unit/out/unsafe/forward_basic.rs +++ b/tests/unit/out/unsafe/forward_basic.rs @@ -15,6 +15,7 @@ pub const Overload_kRvalueOverload: Overload = 2; FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DestructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -88,6 +89,7 @@ impl Holder { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, diff --git a/tests/unit/out/unsafe/forward_decltype.rs b/tests/unit/out/unsafe/forward_decltype.rs index ceb864cf0f..35cdfddfe4 100644 --- a/tests/unit/out/unsafe/forward_decltype.rs +++ b/tests/unit/out/unsafe/forward_decltype.rs @@ -15,6 +15,7 @@ pub const Overload_kRvalueOverload: Overload = 2; FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DestructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, diff --git a/tests/unit/out/unsafe/forward_explicit.rs b/tests/unit/out/unsafe/forward_explicit.rs index 26bc14c328..7a6a29b33c 100644 --- a/tests/unit/out/unsafe/forward_explicit.rs +++ b/tests/unit/out/unsafe/forward_explicit.rs @@ -17,6 +17,7 @@ pub const Overload_kIntRvalueOverload: Overload = 4; FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DestructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, diff --git a/tests/unit/out/unsafe/forward_pack.rs b/tests/unit/out/unsafe/forward_pack.rs index 0577df8ec8..b1caea64b6 100644 --- a/tests/unit/out/unsafe/forward_pack.rs +++ b/tests/unit/out/unsafe/forward_pack.rs @@ -17,6 +17,7 @@ pub const Overload_kIntRvalueOverload: Overload = 4; FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DestructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -125,6 +126,7 @@ impl Pair { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, diff --git a/tests/unit/out/unsafe/friend.rs b/tests/unit/out/unsafe/friend.rs index 029ebec7a3..2cf436a218 100644 --- a/tests/unit/out/unsafe/friend.rs +++ b/tests/unit/out/unsafe/friend.rs @@ -19,7 +19,16 @@ pub unsafe fn scaled_3(v: *const V, mut k: f64) -> f64 { return (((*v).x as f64) * (k)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct V { pub x: i32, } @@ -33,7 +42,16 @@ pub unsafe fn get_4(w: *const W_int_) -> i32 { return (*w).x; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct W_int_ { pub x: i32, } @@ -41,12 +59,30 @@ pub unsafe fn get_5(w: *const W_long_) -> i64 { return (*w).x; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct W_long_ { pub x: i64, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct D { pub x: i32, } diff --git a/tests/unit/out/unsafe/function_overloading.rs b/tests/unit/out/unsafe/function_overloading.rs index ec290da254..c8b7a2de0a 100644 --- a/tests/unit/out/unsafe/function_overloading.rs +++ b/tests/unit/out/unsafe/function_overloading.rs @@ -22,7 +22,16 @@ pub unsafe fn bar_4(x: *mut i32) -> i32 { return (*x); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Foo {} impl Foo { pub unsafe fn foo_1(&self) {} diff --git a/tests/unit/out/unsafe/global_call_temporaries.rs b/tests/unit/out/unsafe/global_call_temporaries.rs index 72a57be569..7dec1b2bac 100644 --- a/tests/unit/out/unsafe/global_call_temporaries.rs +++ b/tests/unit/out/unsafe/global_call_temporaries.rs @@ -77,7 +77,16 @@ pub static mut call_assigned_6: std::cell::LazyCell = std::cell::LazyCell:: } }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Item { pub value: i32, } diff --git a/tests/unit/out/unsafe/global_init_side_effect.rs b/tests/unit/out/unsafe/global_init_side_effect.rs index 9efbc0fe4c..fcc5912e85 100644 --- a/tests/unit/out/unsafe/global_init_side_effect.rs +++ b/tests/unit/out/unsafe/global_init_side_effect.rs @@ -9,7 +9,15 @@ use std::rc::Rc; pub static mut total_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, )] #[cpp_from(i32, construct, value)] pub struct S {} diff --git a/tests/unit/out/unsafe/global_non_const_init.rs b/tests/unit/out/unsafe/global_non_const_init.rs index 876b7a78f5..beb3c2869a 100644 --- a/tests/unit/out/unsafe/global_non_const_init.rs +++ b/tests/unit/out/unsafe/global_non_const_init.rs @@ -28,7 +28,9 @@ pub static mut depends_on_call_6: std::cell::LazyCell = std::cell::LazyCell ((*std::cell::LazyCell::force_mut(&mut *&raw mut from_call_5)) + (1)) }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct Ctor { pub v: i32, } @@ -81,7 +83,16 @@ pub static mut inline_member_11: std::cell::LazyCell = std::cell::LazyCell } }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Holder {} pub static mut member_10: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { (unsafe { next_0() }) }); @@ -99,7 +110,9 @@ static mut local_ctor_14: std::cell::LazyCell = std::cell::LazyCell::new(| } }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct Singleton { pub hits: i32, } diff --git a/tests/unit/out/unsafe/global_pointers.rs b/tests/unit/out/unsafe/global_pointers.rs index c81efa7c72..c2a842b5a2 100644 --- a/tests/unit/out/unsafe/global_pointers.rs +++ b/tests/unit/out/unsafe/global_pointers.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Entry { pub name: *const libc::c_char, pub p: *mut i32, diff --git a/tests/unit/out/unsafe/global_without_initializer.rs b/tests/unit/out/unsafe/global_without_initializer.rs index a5382f5365..b79958bf2d 100644 --- a/tests/unit/out/unsafe/global_without_initializer.rs +++ b/tests/unit/out/unsafe/global_without_initializer.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub a: i32, } diff --git a/tests/unit/out/unsafe/goto_aggregate_default.rs b/tests/unit/out/unsafe/goto_aggregate_default.rs index 49e0323437..9101602a1a 100644 --- a/tests/unit/out/unsafe/goto_aggregate_default.rs +++ b/tests/unit/out/unsafe/goto_aggregate_default.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Point { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/goto_cleanup.rs b/tests/unit/out/unsafe/goto_cleanup.rs index 545f2f4266..2712123684 100644 --- a/tests/unit/out/unsafe/goto_cleanup.rs +++ b/tests/unit/out/unsafe/goto_cleanup.rs @@ -77,7 +77,16 @@ pub unsafe fn from_switch_2(mut n: i32) -> i32 { panic!("ub: non-void function does not return a value") } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct wrapper { pub item: *mut i32, } diff --git a/tests/unit/out/unsafe/huffman.rs b/tests/unit/out/unsafe/huffman.rs index f0283a4a86..61ba808320 100644 --- a/tests/unit/out/unsafe/huffman.rs +++ b/tests/unit/out/unsafe/huffman.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct MinHeapNode { pub data: libc::c_char, pub freq: i32, @@ -40,7 +49,7 @@ pub unsafe fn Swap_0(a: *mut MinHeapNode, b: *mut MinHeapNode) { }; } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, SwappableUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, SwappableUnsafe, Default)] pub struct MinHeap { pub size: i32, pub capacity: i32, diff --git a/tests/unit/out/unsafe/immutable-deref-on-func-call.rs b/tests/unit/out/unsafe/immutable-deref-on-func-call.rs index b37d046705..a5a31f3f8c 100644 --- a/tests/unit/out/unsafe/immutable-deref-on-func-call.rs +++ b/tests/unit/out/unsafe/immutable-deref-on-func-call.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Item { pub value: i32, } diff --git a/tests/unit/out/unsafe/implicit_autoref.rs b/tests/unit/out/unsafe/implicit_autoref.rs index b2eaf6d49e..ba3999f8da 100644 --- a/tests/unit/out/unsafe/implicit_autoref.rs +++ b/tests/unit/out/unsafe/implicit_autoref.rs @@ -12,6 +12,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, SwappableUnsafe, diff --git a/tests/unit/out/unsafe/in_class_field_initializer.rs b/tests/unit/out/unsafe/in_class_field_initializer.rs index 34899a2f44..765346e6e6 100644 --- a/tests/unit/out/unsafe/in_class_field_initializer.rs +++ b/tests/unit/out/unsafe/in_class_field_initializer.rs @@ -7,7 +7,9 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct Inner { pub x: i32, pub y: i32, @@ -18,7 +20,9 @@ impl Default for Inner { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct S { pub a: i32, pub b: libc::c_char, @@ -38,7 +42,9 @@ impl Default for S { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct Boxed_int_ { pub v: i32, pub tag: i32, diff --git a/tests/unit/out/unsafe/init.rs b/tests/unit/out/unsafe/init.rs index 0a2e3caa48..725246c345 100644 --- a/tests/unit/out/unsafe/init.rs +++ b/tests/unit/out/unsafe/init.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct X { pub x: i32, } diff --git a/tests/unit/out/unsafe/init_list.rs b/tests/unit/out/unsafe/init_list.rs index ba5f5d2858..72295a1bee 100644 --- a/tests/unit/out/unsafe/init_list.rs +++ b/tests/unit/out/unsafe/init_list.rs @@ -8,13 +8,24 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub unsafe fn f_0(mut list: Vec) {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Pair { pub a: i32, pub b: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct Holder { pub p: Pair, } @@ -37,7 +48,9 @@ pub unsafe fn sum_1(p: *const Pair) -> i32 { return (((*p).a) + ((*p).b)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct Seven { pub v: i32, } diff --git a/tests/unit/out/unsafe/inline_container_fields.rs b/tests/unit/out/unsafe/inline_container_fields.rs index 4e6e2d1c20..cc1ebc032a 100644 --- a/tests/unit/out/unsafe/inline_container_fields.rs +++ b/tests/unit/out/unsafe/inline_container_fields.rs @@ -12,6 +12,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, SwappableUnsafe, @@ -54,6 +55,7 @@ impl MoveAssignableUnsafe for Elem { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, SwappableUnsafe, @@ -171,7 +173,7 @@ pub static mut moves_3: std::cell::LazyCell = std::cell::LazyCell::new(|| u pub static mut copy_assigns_4: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut move_assigns_5: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, SwappableUnsafe)] +#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, SwappableUnsafe)] pub struct Counted { pub v: i32, } diff --git a/tests/unit/out/unsafe/kruskal.rs b/tests/unit/out/unsafe/kruskal.rs index 5bdd992925..76ae5d42e0 100644 --- a/tests/unit/out/unsafe/kruskal.rs +++ b/tests/unit/out/unsafe/kruskal.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Edge { pub u: i32, pub v: i32, @@ -164,7 +173,7 @@ pub unsafe fn quicksort_1(arr: *mut Option>, mut start: i32, mut end (unsafe { quicksort_1(arr, ((p) + (1)), end) }); } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, SwappableUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, SwappableUnsafe, Default)] pub struct DisjointSet { pub rank: Option>, pub parent: Option>, @@ -295,7 +304,7 @@ impl MoveAssignableUnsafe for DisjointSet { } } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, SwappableUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, SwappableUnsafe, Default)] pub struct Graph { pub edges: Option>, pub V: i32, diff --git a/tests/unit/out/unsafe/lambda_as_field.rs b/tests/unit/out/unsafe/lambda_as_field.rs index 4dc83e2b13..f7a11ca47a 100644 --- a/tests/unit/out/unsafe/lambda_as_field.rs +++ b/tests/unit/out/unsafe/lambda_as_field.rs @@ -7,12 +7,12 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct Guard__lambda_at_lambda_as_field_cpp_34_13__ { pub f: FnPtr, } -impl Guard__lambda_at_lambda_as_field_cpp_34_13__ { - pub unsafe fn destructor(&mut self) { +impl DestructibleUnsafe for Guard__lambda_at_lambda_as_field_cpp_34_13__ { + unsafe fn destroy(&mut self) { (unsafe { self.f.call() }); } } @@ -28,19 +28,17 @@ impl Default for Guard__lambda_at_lambda_as_field_cpp_34_13__ { } } #[repr(C)] -#[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, -)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct Guard__lambda_at_lambda_as_field_cpp_45_13__ { pub f: FnPtr, } -impl Guard__lambda_at_lambda_as_field_cpp_45_13__ { - pub unsafe fn destructor(&mut self) { +impl DestructibleUnsafe for Guard__lambda_at_lambda_as_field_cpp_45_13__ { + unsafe fn destroy(&mut self) { (unsafe { self.f.call() }); } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe)] pub struct Holder__lambda_at_lambda_as_field_cpp_39_12__ { pub f: FnPtr i32>, pub calls: i32, @@ -66,7 +64,9 @@ impl Default for Holder__lambda_at_lambda_as_field_cpp_39_12__ { } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, Default, +)] pub struct Holder__lambda_at_lambda_as_field_cpp_51_12__ { pub f: FnPtr i32>, pub calls: i32, @@ -78,7 +78,7 @@ impl Holder__lambda_at_lambda_as_field_cpp_51_12__ { } } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe)] #[cpp_from(FnPtr i32 > , construct, value)] pub struct Moving__lambda_at_lambda_as_field_cpp_64_12__ { pub f: FnPtr i32>, @@ -137,7 +137,7 @@ unsafe fn main_0() -> i32 { }), }; let _dtor_g = std::mem::DropGuard::new(&raw mut g, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut count_0)) == (0))); } @@ -167,7 +167,7 @@ unsafe fn main_0() -> i32 { ), }; let _dtor_g = std::mem::DropGuard::new(&raw mut g, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); assert!(((cleaned) == (0))); } diff --git a/tests/unit/out/unsafe/lambda_capture_copy_ctor.rs b/tests/unit/out/unsafe/lambda_capture_copy_ctor.rs index 8f6d902745..fbe1ed3d28 100644 --- a/tests/unit/out/unsafe/lambda_capture_copy_ctor.rs +++ b/tests/unit/out/unsafe/lambda_capture_copy_ctor.rs @@ -11,6 +11,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -63,7 +64,6 @@ pub static mut drops_0: std::cell::LazyCell = std::cell::LazyCell::new(|| u VaArg, FnPtrArg, ZeroInitializationUnsafe, - DestructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -71,9 +71,6 @@ pub static mut drops_0: std::cell::LazyCell = std::cell::LazyCell::new(|| u pub struct Dropped {} impl Dropped { pub unsafe fn construct(&mut self) {} - pub unsafe fn destructor(&mut self) { - (*std::cell::LazyCell::force_mut(&mut *&raw mut drops_0)).postfix_inc(); - } } impl CopyConstructibleUnsafe for Dropped { unsafe fn copy_constructor(&mut self, _a0: *const Dropped) {} @@ -81,6 +78,11 @@ impl CopyConstructibleUnsafe for Dropped { impl MoveConstructibleUnsafe for Dropped { unsafe fn move_constructor(&mut self, _a0: *mut Dropped) {} } +impl DestructibleUnsafe for Dropped { + unsafe fn destroy(&mut self) { + (*std::cell::LazyCell::force_mut(&mut *&raw mut drops_0)).postfix_inc(); + } +} impl Clone for Dropped { fn clone(&self) -> Self { unsafe { @@ -186,11 +188,11 @@ unsafe fn main_0() -> i32 { || {} ); let _dtor_m = std::mem::DropGuard::new(&raw mut m, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); let mut m2: FnPtr = m.move_from(); let _dtor_m2 = std::mem::DropGuard::new(&raw mut m2, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); } assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut drops_0)) == (2))); @@ -206,11 +208,11 @@ unsafe fn main_0() -> i32 { || {} ); let _dtor_k = std::mem::DropGuard::new(&raw mut k, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); let mut k2: FnPtr = k.copy_from(); let _dtor_k2 = std::mem::DropGuard::new(&raw mut k2, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); } assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut drops_0)) == (4))); @@ -226,7 +228,7 @@ unsafe fn main_0() -> i32 { || {} ); let _dtor_inner = std::mem::DropGuard::new(&raw mut inner, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); let mut outer: FnPtr = lambda_unsafe!( { @@ -235,7 +237,7 @@ unsafe fn main_0() -> i32 { || {} ); let _dtor_outer = std::mem::DropGuard::new(&raw mut outer, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); } assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut drops_0)) == (6))); diff --git a/tests/unit/out/unsafe/lambda_capture_ref.rs b/tests/unit/out/unsafe/lambda_capture_ref.rs index 646dda93c0..1685860930 100644 --- a/tests/unit/out/unsafe/lambda_capture_ref.rs +++ b/tests/unit/out/unsafe/lambda_capture_ref.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/lambda_capture_star_this.rs b/tests/unit/out/unsafe/lambda_capture_star_this.rs index efc3851767..dae883e98c 100644 --- a/tests/unit/out/unsafe/lambda_capture_star_this.rs +++ b/tests/unit/out/unsafe/lambda_capture_star_this.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub n: i32, } diff --git a/tests/unit/out/unsafe/lambda_capture_this.rs b/tests/unit/out/unsafe/lambda_capture_this.rs index 74046c957e..5aa1013497 100644 --- a/tests/unit/out/unsafe/lambda_capture_this.rs +++ b/tests/unit/out/unsafe/lambda_capture_this.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub n: i32, pub step: i32, diff --git a/tests/unit/out/unsafe/lambda_capture_value.rs b/tests/unit/out/unsafe/lambda_capture_value.rs index d78b853af5..b6083ad486 100644 --- a/tests/unit/out/unsafe/lambda_capture_value.rs +++ b/tests/unit/out/unsafe/lambda_capture_value.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/lambda_decltype_type.rs b/tests/unit/out/unsafe/lambda_decltype_type.rs index 078d4dd483..9ea037c436 100644 --- a/tests/unit/out/unsafe/lambda_decltype_type.rs +++ b/tests/unit/out/unsafe/lambda_decltype_type.rs @@ -7,7 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe)] pub struct Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { pub items: [i32; 4], pub size: i32, @@ -45,7 +45,7 @@ impl Default for Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe)] pub struct Sorted__lambda_at_lambda_decltype_type_cpp_19_23__ { pub items: [i32; 4], pub size: i32, diff --git a/tests/unit/out/unsafe/lambda_generic_explicit_args.rs b/tests/unit/out/unsafe/lambda_generic_explicit_args.rs index dec74038d0..76d3641c9a 100644 --- a/tests/unit/out/unsafe/lambda_generic_explicit_args.rs +++ b/tests/unit/out/unsafe/lambda_generic_explicit_args.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Val { pub x: i32, } diff --git a/tests/unit/out/unsafe/lambda_immediate_init.rs b/tests/unit/out/unsafe/lambda_immediate_init.rs index 342add8bf7..5b07f0316b 100644 --- a/tests/unit/out/unsafe/lambda_immediate_init.rs +++ b/tests/unit/out/unsafe/lambda_immediate_init.rs @@ -10,7 +10,9 @@ pub unsafe fn pick_0(mut x: i32) -> i32 { return x; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct S { pub j: i32, pub k: i32, diff --git a/tests/unit/out/unsafe/lambda_move_only_capture.rs b/tests/unit/out/unsafe/lambda_move_only_capture.rs index a380ac74ac..5002c46ca7 100644 --- a/tests/unit/out/unsafe/lambda_move_only_capture.rs +++ b/tests/unit/out/unsafe/lambda_move_only_capture.rs @@ -7,7 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] #[cpp_from(i32, construct, value)] pub struct Owner { pub p: *mut i32, @@ -16,14 +16,6 @@ impl Owner { pub unsafe fn construct(&mut self, mut v: i32) { (&raw mut self.p).write((Box::leak(Box::new(v)) as *mut i32)); } - pub unsafe fn destructor(&mut self) { - { - let __p = self.p; - if !__p.is_null() { - ::std::mem::drop(Box::from_raw(__p)) - } - }; - } pub unsafe fn take(&mut self) -> FnPtr i32> { return lambda_unsafe!( { @@ -47,6 +39,16 @@ impl MoveConstructibleUnsafe for Owner { (*o).p = std::ptr::null_mut(); } } +impl DestructibleUnsafe for Owner { + unsafe fn destroy(&mut self) { + { + let __p = self.p; + if !__p.is_null() { + ::std::mem::drop(Box::from_raw(__p)) + } + }; + } +} pub fn main() { unsafe { __cpp2rust_init_globals(); @@ -60,7 +62,7 @@ unsafe fn main_0() -> i32 { __v }; let _dtor_o = std::mem::DropGuard::new(&raw mut o, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); let mut f: FnPtr i32> = lambda_unsafe!( { @@ -75,13 +77,13 @@ unsafe fn main_0() -> i32 { } ); let _dtor_f = std::mem::DropGuard::new(&raw mut f, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); assert!((o.p).is_null()); assert!(((unsafe { f.call() }) == (5))); let mut g: FnPtr i32> = f.move_from(); let _dtor_g = std::mem::DropGuard::new(&raw mut g, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); assert!(((unsafe { g.call() }) == (5))); let mut total: i32 = 0; @@ -100,7 +102,7 @@ unsafe fn main_0() -> i32 { } ); let _dtor_consume = std::mem::DropGuard::new(&raw mut consume, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); (unsafe { consume.call() }); (unsafe { consume.call() }); @@ -111,11 +113,11 @@ unsafe fn main_0() -> i32 { __v }; let _dtor_o2 = std::mem::DropGuard::new(&raw mut o2, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); let mut t: FnPtr i32> = (unsafe { Owner::take(&mut o2) }); let _dtor_t = std::mem::DropGuard::new(&raw mut t, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); assert!((o2.p).is_null()); assert!(((unsafe { t.call() }) == (9))); diff --git a/tests/unit/out/unsafe/lambda_nested.rs b/tests/unit/out/unsafe/lambda_nested.rs index 932e1103c5..2a114684a1 100644 --- a/tests/unit/out/unsafe/lambda_nested.rs +++ b/tests/unit/out/unsafe/lambda_nested.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/lambda_static_local.rs b/tests/unit/out/unsafe/lambda_static_local.rs index 76ed07741d..3509967e9d 100644 --- a/tests/unit/out/unsafe/lambda_static_local.rs +++ b/tests/unit/out/unsafe/lambda_static_local.rs @@ -68,7 +68,16 @@ static mut n_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { static mut calls_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); static mut calls_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct P_4 { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/libc_struct_without_default.rs b/tests/unit/out/unsafe/libc_struct_without_default.rs index 7c20358d5d..b549b89754 100644 --- a/tests/unit/out/unsafe/libc_struct_without_default.rs +++ b/tests/unit/out/unsafe/libc_struct_without_default.rs @@ -12,6 +12,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, SwappableUnsafe, @@ -50,7 +51,9 @@ impl Default for UserDefined { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct FieldIsLibcType { pub addr: libc::sockaddr, } diff --git a/tests/unit/out/unsafe/linked_list.rs b/tests/unit/out/unsafe/linked_list.rs index 938989483e..371dd6530f 100644 --- a/tests/unit/out/unsafe/linked_list.rs +++ b/tests/unit/out/unsafe/linked_list.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Node { pub val: i32, pub next: *mut Node, diff --git a/tests/unit/out/unsafe/local_anon_struct_collision.rs b/tests/unit/out/unsafe/local_anon_struct_collision.rs index 2ae16f433a..b144e4e780 100644 --- a/tests/unit/out/unsafe/local_anon_struct_collision.rs +++ b/tests/unit/out/unsafe/local_anon_struct_collision.rs @@ -13,7 +13,16 @@ pub unsafe fn first_0() -> i32 { return ((p.x) + (p.y)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct anon_1 { pub x: i32, pub y: i32, @@ -25,7 +34,16 @@ pub unsafe fn second_2() -> i32 { return (((q.a) + (q.b)) as i32); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct anon_3 { pub a: i64, pub b: i64, diff --git a/tests/unit/out/unsafe/local_record_template.rs b/tests/unit/out/unsafe/local_record_template.rs index d8281d97a4..79539375cd 100644 --- a/tests/unit/out/unsafe/local_record_template.rs +++ b/tests/unit/out/unsafe/local_record_template.rs @@ -30,12 +30,30 @@ pub unsafe fn wrap_10(mut v: i64) -> i32 { return (unsafe { get_6(l) }); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Local_5 { pub x: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Local_7 { pub x: i64, } @@ -44,7 +62,16 @@ pub unsafe fn other_11() -> i32 { return ((unsafe { get_0(l) }) + (l.y as i32)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Local_1 { pub x: i64, pub y: i64, @@ -65,7 +92,16 @@ unsafe fn main_0() -> i32 { return 0; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Local_3 { pub x: i32, } diff --git a/tests/unit/out/unsafe/map.rs b/tests/unit/out/unsafe/map.rs index 0830442c08..dbbd091e90 100644 --- a/tests/unit/out/unsafe/map.rs +++ b/tests/unit/out/unsafe/map.rs @@ -13,7 +13,9 @@ pub unsafe fn bar_1(x: *mut u32) { (*x) = (*x).wrapping_add(1_u32); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct Point { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/map_key_copy_ctor.rs b/tests/unit/out/unsafe/map_key_copy_ctor.rs index 982b40a266..72eaf9eb27 100644 --- a/tests/unit/out/unsafe/map_key_copy_ctor.rs +++ b/tests/unit/out/unsafe/map_key_copy_ctor.rs @@ -15,6 +15,7 @@ pub static mut made_2: std::cell::LazyCell = std::cell::LazyCell::new(|| un FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DestructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, diff --git a/tests/unit/out/unsafe/map_key_identity.rs b/tests/unit/out/unsafe/map_key_identity.rs index b4c6ba0046..824fd3e5e7 100644 --- a/tests/unit/out/unsafe/map_key_identity.rs +++ b/tests/unit/out/unsafe/map_key_identity.rs @@ -9,7 +9,16 @@ use std::rc::Rc; pub static mut default_constructions_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Key { pub order: i32, pub identity: i32, @@ -45,7 +54,9 @@ pub unsafe fn operator_eq_2(a: *const Key, b: *const Key) -> bool { return (((*a).identity) == ((*b).identity)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct Mapped { pub value: i32, } diff --git a/tests/unit/out/unsafe/map_try_emplace.rs b/tests/unit/out/unsafe/map_try_emplace.rs index fd173149c3..124713c4ee 100644 --- a/tests/unit/out/unsafe/map_try_emplace.rs +++ b/tests/unit/out/unsafe/map_try_emplace.rs @@ -16,6 +16,7 @@ pub static mut moves_3: std::cell::LazyCell = std::cell::LazyCell::new(|| u FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DestructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -71,7 +72,9 @@ pub unsafe fn argument_4(item: *mut Item) -> *mut Item { return item; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct RefItem { pub value: i32, } diff --git a/tests/unit/out/unsafe/map_try_emplace_lvalues.rs b/tests/unit/out/unsafe/map_try_emplace_lvalues.rs index 70dd490123..a5ba9bb38f 100644 --- a/tests/unit/out/unsafe/map_try_emplace_lvalues.rs +++ b/tests/unit/out/unsafe/map_try_emplace_lvalues.rs @@ -9,7 +9,9 @@ use std::rc::Rc; pub static mut made_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut visits_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct Item { pub value: i32, } @@ -47,7 +49,9 @@ pub unsafe fn place_3(n: *mut i32) -> *mut i32 { pub static mut temporary_calls_4: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct Temporary { pub n: i32, pub data: [i32; 2], @@ -71,7 +75,16 @@ impl Default for Temporary { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Nested { pub inner: Temporary, } @@ -86,7 +99,7 @@ pub unsafe fn make_nested_6() -> Nested { return ::default(); } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, SwappableUnsafe)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, SwappableUnsafe)] pub struct Owner { pub ptr: Option>, } @@ -130,7 +143,7 @@ impl Default for Owner { } } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe)] pub struct Noncopy { pub n: i32, } @@ -140,7 +153,16 @@ impl Default for Noncopy { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, +)] #[cpp_from(i32, construct_1, ptr)] pub struct Held { pub ptr: *const i32, diff --git a/tests/unit/out/unsafe/max.rs b/tests/unit/out/unsafe/max.rs index 350a41feec..0fd691256f 100644 --- a/tests/unit/out/unsafe/max.rs +++ b/tests/unit/out/unsafe/max.rs @@ -22,6 +22,7 @@ pub unsafe fn pick_3(mut i: i32) -> *mut i32 { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DestructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, SwappableUnsafe, diff --git a/tests/unit/out/unsafe/memcpy_struct_bytes.rs b/tests/unit/out/unsafe/memcpy_struct_bytes.rs index 29a4e51722..e8fd1940fd 100644 --- a/tests/unit/out/unsafe/memcpy_struct_bytes.rs +++ b/tests/unit/out/unsafe/memcpy_struct_bytes.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct point { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/memcpy_struct_layouts.rs b/tests/unit/out/unsafe/memcpy_struct_layouts.rs index bdb981b111..6ed39f84e4 100644 --- a/tests/unit/out/unsafe/memcpy_struct_layouts.rs +++ b/tests/unit/out/unsafe/memcpy_struct_layouts.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct packed { pub a: i32, pub b: libc::c_char, @@ -15,26 +24,62 @@ pub struct packed { pub d: i16, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct reordered { pub a: libc::c_char, pub b: i32, pub c: libc::c_char, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct tail { pub a: libc::c_char, pub b: f64, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct nested { pub t: tail, pub c: libc::c_char, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct array { pub name: [libc::c_char; 3], pub x: i32, diff --git a/tests/unit/out/unsafe/memcpy_struct_struct.rs b/tests/unit/out/unsafe/memcpy_struct_struct.rs index 899ce32932..d58f77c503 100644 --- a/tests/unit/out/unsafe/memcpy_struct_struct.rs +++ b/tests/unit/out/unsafe/memcpy_struct_struct.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Entry { pub bits: u8, pub value: u16, diff --git a/tests/unit/out/unsafe/memset_struct_tail.rs b/tests/unit/out/unsafe/memset_struct_tail.rs index 26edaf197e..84ea69f2e4 100644 --- a/tests/unit/out/unsafe/memset_struct_tail.rs +++ b/tests/unit/out/unsafe/memset_struct_tail.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub keep: i32, pub a: i32, diff --git a/tests/unit/out/unsafe/move_assign.rs b/tests/unit/out/unsafe/move_assign.rs index 7e0dccceb3..28aef3b3a6 100644 --- a/tests/unit/out/unsafe/move_assign.rs +++ b/tests/unit/out/unsafe/move_assign.rs @@ -7,7 +7,9 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, SwappableUnsafe, Default)] +#[derive( + FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, SwappableUnsafe, Default, +)] #[cpp_from(i32, construct, value)] pub struct MoveOnly { pub v: i32, @@ -34,7 +36,7 @@ impl MoveAssignableUnsafe for MoveOnly { } } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe)] pub struct ConstMoveAssign { pub mark: i32, } diff --git a/tests/unit/out/unsafe/move_ctor.rs b/tests/unit/out/unsafe/move_ctor.rs index 33c8966011..334a41f233 100644 --- a/tests/unit/out/unsafe/move_ctor.rs +++ b/tests/unit/out/unsafe/move_ctor.rs @@ -7,7 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, Default)] #[cpp_from(i32, construct, value)] pub struct MoveOnly { pub v: i32, @@ -24,7 +24,7 @@ impl MoveConstructibleUnsafe for MoveOnly { } } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe)] pub struct ConstMove { pub mark: i32, } @@ -56,6 +56,7 @@ impl Default for ConstMove { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DestructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -104,6 +105,7 @@ impl Clone for ThrowingMove { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DestructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, diff --git a/tests/unit/out/unsafe/move_this.rs b/tests/unit/out/unsafe/move_this.rs index 66913ae933..729785a2af 100644 --- a/tests/unit/out/unsafe/move_this.rs +++ b/tests/unit/out/unsafe/move_this.rs @@ -12,6 +12,7 @@ use std::rc::Rc; FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DestructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, diff --git a/tests/unit/out/unsafe/nested_structs.rs b/tests/unit/out/unsafe/nested_structs.rs index c5801dfb00..176d47dca7 100644 --- a/tests/unit/out/unsafe/nested_structs.rs +++ b/tests/unit/out/unsafe/nested_structs.rs @@ -7,34 +7,88 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Level0_Level1_1_Level2_1_Level3_1 { pub x1: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Level0_Level1_1_Level2_1_Level3_2 { pub x1: i32, pub x2: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Level0_Level1_1_Level2_1 { pub x1: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Level0_Level1_1 { pub x1: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Level0_Level1_2 { pub x1: i32, pub x2: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Level0 {} pub fn main() { unsafe { diff --git a/tests/unit/out/unsafe/new.rs b/tests/unit/out/unsafe/new.rs index 88c99c4898..fffe780a13 100644 --- a/tests/unit/out/unsafe/new.rs +++ b/tests/unit/out/unsafe/new.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Pair { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/new_bst.rs b/tests/unit/out/unsafe/new_bst.rs index dab8706519..34e337a77f 100644 --- a/tests/unit/out/unsafe/new_bst.rs +++ b/tests/unit/out/unsafe/new_bst.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct node_t { pub left: *mut node_t, pub right: *mut node_t, diff --git a/tests/unit/out/unsafe/new_struct.rs b/tests/unit/out/unsafe/new_struct.rs index e17a949aba..1ef439b45e 100644 --- a/tests/unit/out/unsafe/new_struct.rs +++ b/tests/unit/out/unsafe/new_struct.rs @@ -7,13 +7,31 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Pair { pub x: i32, pub y: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Triple { pub a: i32, pub b: i32, diff --git a/tests/unit/out/unsafe/nttp_distinct_specializations.rs b/tests/unit/out/unsafe/nttp_distinct_specializations.rs index f22b0557e3..3b054d4c42 100644 --- a/tests/unit/out/unsafe/nttp_distinct_specializations.rs +++ b/tests/unit/out/unsafe/nttp_distinct_specializations.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S_2_ { pub v: i32, pub w: i32, @@ -18,7 +27,16 @@ impl S_2_ { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S_1_ { pub v: i32, } @@ -28,7 +46,16 @@ impl S_1_ { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S_3_ { pub v: i32, } diff --git a/tests/unit/out/unsafe/offsetof.rs b/tests/unit/out/unsafe/offsetof.rs index 8c90e8e5ff..733562f72d 100644 --- a/tests/unit/out/unsafe/offsetof.rs +++ b/tests/unit/out/unsafe/offsetof.rs @@ -7,14 +7,25 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Layout { pub a: u8, pub b: u32, pub c: u16, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct Frame { pub tag: u16, pub body: [libc::c_char; 64], diff --git a/tests/unit/out/unsafe/opaque_forward_decl.rs b/tests/unit/out/unsafe/opaque_forward_decl.rs index 9c96c1fa9e..e83c379a67 100644 --- a/tests/unit/out/unsafe/opaque_forward_decl.rs +++ b/tests/unit/out/unsafe/opaque_forward_decl.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct container { pub p: *mut opaque, pub x: i32, diff --git a/tests/unit/out/unsafe/opaque_record_copy.rs b/tests/unit/out/unsafe/opaque_record_copy.rs index f1f2d924ae..339738a10d 100644 --- a/tests/unit/out/unsafe/opaque_record_copy.rs +++ b/tests/unit/out/unsafe/opaque_record_copy.rs @@ -7,10 +7,28 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Probe {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Wrapper_Probe_ { pub base_: Probe, pub tag: i32, diff --git a/tests/unit/out/unsafe/opaque_then_defined.rs b/tests/unit/out/unsafe/opaque_then_defined.rs index d18e9a85b2..6cbb61093d 100644 --- a/tests/unit/out/unsafe/opaque_then_defined.rs +++ b/tests/unit/out/unsafe/opaque_then_defined.rs @@ -7,13 +7,31 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct list { pub head: *mut node, pub size: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct node { pub value: i32, pub next: *mut node, diff --git a/tests/unit/out/unsafe/operator_arithmetic_free.rs b/tests/unit/out/unsafe/operator_arithmetic_free.rs index a5a133ae98..897ff4c9a1 100644 --- a/tests/unit/out/unsafe/operator_arithmetic_free.rs +++ b/tests/unit/out/unsafe/operator_arithmetic_free.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_arithmetic_member.rs b/tests/unit/out/unsafe/operator_arithmetic_member.rs index d789a36122..b05bb0adab 100644 --- a/tests/unit/out/unsafe/operator_arithmetic_member.rs +++ b/tests/unit/out/unsafe/operator_arithmetic_member.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_bitwise_free.rs b/tests/unit/out/unsafe/operator_bitwise_free.rs index 2c6875c304..97df16f7a3 100644 --- a/tests/unit/out/unsafe/operator_bitwise_free.rs +++ b/tests/unit/out/unsafe/operator_bitwise_free.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub v: u32, } diff --git a/tests/unit/out/unsafe/operator_bitwise_member.rs b/tests/unit/out/unsafe/operator_bitwise_member.rs index 3f7f52e7b2..a220c433db 100644 --- a/tests/unit/out/unsafe/operator_bitwise_member.rs +++ b/tests/unit/out/unsafe/operator_bitwise_member.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub v: u32, } diff --git a/tests/unit/out/unsafe/operator_comparison_defaulted.rs b/tests/unit/out/unsafe/operator_comparison_defaulted.rs index cdbc526fae..0eb9295006 100644 --- a/tests/unit/out/unsafe/operator_comparison_defaulted.rs +++ b/tests/unit/out/unsafe/operator_comparison_defaulted.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Eq { pub a: i32, pub b: i32, @@ -25,7 +34,16 @@ impl std::cmp::PartialEq for Eq { } impl std::cmp::Eq for Eq {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Cmp { pub a: i32, pub b: i32, @@ -70,7 +88,16 @@ impl std::cmp::PartialEq for Cmp { } impl std::cmp::Eq for Cmp {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Both { pub a: i32, } @@ -106,7 +133,16 @@ impl std::cmp::PartialEq for Both { } impl std::cmp::Eq for Both {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct OrdOnly { pub a: i32, } @@ -139,7 +175,16 @@ impl std::cmp::PartialEq for OrdOnly { } impl std::cmp::Eq for OrdOnly {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Inner { pub x: i32, } @@ -175,7 +220,16 @@ impl std::cmp::PartialEq for Inner { } impl std::cmp::Eq for Inner {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Outer { pub i: Inner, pub y: i32, @@ -224,7 +278,16 @@ impl std::cmp::PartialEq for Outer { } impl std::cmp::Eq for Outer {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Secondary { pub a: i32, } @@ -271,7 +334,16 @@ impl std::cmp::PartialEq for Secondary { } impl std::cmp::Eq for Secondary {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct PtrMember { pub p: *mut i32, } diff --git a/tests/unit/out/unsafe/operator_comparison_free.rs b/tests/unit/out/unsafe/operator_comparison_free.rs index 4f141f8951..8ea736c45d 100644 --- a/tests/unit/out/unsafe/operator_comparison_free.rs +++ b/tests/unit/out/unsafe/operator_comparison_free.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub v: i32, } @@ -60,7 +69,16 @@ pub unsafe fn operator_lt_7(mut a: i32, b: *const S) -> bool { return ((a) < ((*b).v)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct V { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_comparison_member.rs b/tests/unit/out/unsafe/operator_comparison_member.rs index d2f1a02589..ec6e818099 100644 --- a/tests/unit/out/unsafe/operator_comparison_member.rs +++ b/tests/unit/out/unsafe/operator_comparison_member.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_comparison_mixed.rs b/tests/unit/out/unsafe/operator_comparison_mixed.rs index 8b9759f676..042b17fc02 100644 --- a/tests/unit/out/unsafe/operator_comparison_mixed.rs +++ b/tests/unit/out/unsafe/operator_comparison_mixed.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_comparison_nonbool.rs b/tests/unit/out/unsafe/operator_comparison_nonbool.rs index b62679c9ac..f65487b612 100644 --- a/tests/unit/out/unsafe/operator_comparison_nonbool.rs +++ b/tests/unit/out/unsafe/operator_comparison_nonbool.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct X { pub v: i32, } @@ -54,12 +63,30 @@ pub unsafe fn operator_ge_5(mut a: X, mut b: X) -> i32 { return if ((a.v) >= (b.v)) { 7 } else { 0 }; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Result { pub r: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Custom { pub v: i32, } @@ -71,7 +98,16 @@ impl Custom { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Mixed { pub v: i32, } @@ -114,7 +150,15 @@ impl std::cmp::PartialEq for Mixed { impl std::cmp::Eq for Mixed {} #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, )] #[cpp_into(bool, to_bool)] pub struct MyBool { @@ -129,7 +173,16 @@ impl MyBool { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Boolish { pub v: i32, } @@ -183,7 +236,7 @@ pub unsafe fn operator_lt_6(mut a: Boolish, mut b: Boolish) -> MyBool { }; } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, Default)] #[cpp_into(bool, to_bool)] pub struct RefBool { pub value: bool, @@ -204,7 +257,16 @@ pub static mut ref_true_8: std::cell::LazyCell = std::cell::LazyCell::n } }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct RefInt { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_comparison_noncopyable.rs b/tests/unit/out/unsafe/operator_comparison_noncopyable.rs index 8d446736a8..ffdc06d91e 100644 --- a/tests/unit/out/unsafe/operator_comparison_noncopyable.rs +++ b/tests/unit/out/unsafe/operator_comparison_noncopyable.rs @@ -13,7 +13,7 @@ pub unsafe fn operator_lt_1(x: *const S, y: *const S) -> bool { return (((*x).data_) < ((*y).data_)); } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, Default)] #[cpp_from(i32, construct, value)] pub struct S { data_: i32, diff --git a/tests/unit/out/unsafe/operator_compound_assignment_free.rs b/tests/unit/out/unsafe/operator_compound_assignment_free.rs index 0824c9924d..483871891e 100644 --- a/tests/unit/out/unsafe/operator_compound_assignment_free.rs +++ b/tests/unit/out/unsafe/operator_compound_assignment_free.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub v: u32, } diff --git a/tests/unit/out/unsafe/operator_compound_assignment_member.rs b/tests/unit/out/unsafe/operator_compound_assignment_member.rs index 100e10f5a3..91febb12b4 100644 --- a/tests/unit/out/unsafe/operator_compound_assignment_member.rs +++ b/tests/unit/out/unsafe/operator_compound_assignment_member.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub v: u32, } diff --git a/tests/unit/out/unsafe/operator_friend.rs b/tests/unit/out/unsafe/operator_friend.rs index 3ba64a4c45..7799dce798 100644 --- a/tests/unit/out/unsafe/operator_friend.rs +++ b/tests/unit/out/unsafe/operator_friend.rs @@ -10,7 +10,16 @@ pub unsafe fn operator_eq_0(_a0: *const Defaulted, _a1: *const Defaulted) -> boo return (((*_a0).a) == ((*_a1).a)) && (((*_a0).b) == ((*_a1).b)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Defaulted { pub a: i32, pub b: i32, @@ -37,7 +46,16 @@ pub unsafe fn operator_eq_2(_a0: *const DefaultedOrd, _a1: *const DefaultedOrd) return (((*_a0).a) == ((*_a1).a)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct DefaultedOrd { pub a: i32, } @@ -69,7 +87,16 @@ pub unsafe fn operator_add_5(x: *const Inline, y: *const Inline) -> Inline { }; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Inline { pub a: i32, } @@ -98,7 +125,16 @@ impl std::cmp::PartialEq for Inline { } impl std::cmp::Eq for Inline {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct OutOfLine { pub a: i32, } @@ -127,7 +163,16 @@ pub unsafe fn operator_eq_10(x: *const Tmpl_int_, y: *const Tmpl_long_) -> bool return (((*x).v as i64) == ((*y).v)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Tmpl_int_ { pub v: i32, } @@ -156,7 +201,16 @@ impl std::cmp::PartialEq for Tmpl_int_ { } impl std::cmp::Eq for Tmpl_int_ {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Tmpl_long_ { pub v: i64, } @@ -167,7 +221,16 @@ pub unsafe fn operator_eq_11( return (((*_a0).v) == ((*_a1).v)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct TmplDefaulted_int_ { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_less_than.rs b/tests/unit/out/unsafe/operator_less_than.rs index 5970de3eac..ba57f1cc2f 100644 --- a/tests/unit/out/unsafe/operator_less_than.rs +++ b/tests/unit/out/unsafe/operator_less_than.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Pair { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/operator_logical_free.rs b/tests/unit/out/unsafe/operator_logical_free.rs index e816bd7626..0ae987db8a 100644 --- a/tests/unit/out/unsafe/operator_logical_free.rs +++ b/tests/unit/out/unsafe/operator_logical_free.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_logical_member.rs b/tests/unit/out/unsafe/operator_logical_member.rs index 41cff80dbb..6657800073 100644 --- a/tests/unit/out/unsafe/operator_logical_member.rs +++ b/tests/unit/out/unsafe/operator_logical_member.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_member_pointer_free.rs b/tests/unit/out/unsafe/operator_member_pointer_free.rs index 878bcffe6a..2d63c460e4 100644 --- a/tests/unit/out/unsafe/operator_member_pointer_free.rs +++ b/tests/unit/out/unsafe/operator_member_pointer_free.rs @@ -7,12 +7,30 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Inner { pub x: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub data: [i32; 3], pub inner: Inner, diff --git a/tests/unit/out/unsafe/operator_member_pointer_member.rs b/tests/unit/out/unsafe/operator_member_pointer_member.rs index 1fe5fcb357..2310c2c8a1 100644 --- a/tests/unit/out/unsafe/operator_member_pointer_member.rs +++ b/tests/unit/out/unsafe/operator_member_pointer_member.rs @@ -7,12 +7,30 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Inner { pub x: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Table {} impl Table { pub unsafe fn operator_index(mut i: i32) -> *mut i32 { @@ -22,7 +40,16 @@ impl Table { pub static mut table_0: std::cell::LazyCell<[i32; 3]> = std::cell::LazyCell::new(|| unsafe { [7, 8, 9] }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub data: [i32; 3], pub inner: Inner, diff --git a/tests/unit/out/unsafe/operator_other_free.rs b/tests/unit/out/unsafe/operator_other_free.rs index 3954e1ceba..ebcd624688 100644 --- a/tests/unit/out/unsafe/operator_other_free.rs +++ b/tests/unit/out/unsafe/operator_other_free.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_other_member.rs b/tests/unit/out/unsafe/operator_other_member.rs index d1651da5ac..1b6bd43fb8 100644 --- a/tests/unit/out/unsafe/operator_other_member.rs +++ b/tests/unit/out/unsafe/operator_other_member.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Static {} impl Static { pub unsafe fn operator_call(mut a: i32, mut b: i32) -> i32 { @@ -16,7 +25,15 @@ impl Static { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, )] #[cpp_into(i32, to_i32)] pub struct S { diff --git a/tests/unit/out/unsafe/operator_overloads.rs b/tests/unit/out/unsafe/operator_overloads.rs index 1d47d6c67d..363ea990d4 100644 --- a/tests/unit/out/unsafe/operator_overloads.rs +++ b/tests/unit/out/unsafe/operator_overloads.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_qualifiers.rs b/tests/unit/out/unsafe/operator_qualifiers.rs index d35c4227aa..8504bc5024 100644 --- a/tests/unit/out/unsafe/operator_qualifiers.rs +++ b/tests/unit/out/unsafe/operator_qualifiers.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_three_way.rs b/tests/unit/out/unsafe/operator_three_way.rs index 73d7da6018..f2671b3d7e 100644 --- a/tests/unit/out/unsafe/operator_three_way.rs +++ b/tests/unit/out/unsafe/operator_three_way.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/operator_traits.rs b/tests/unit/out/unsafe/operator_traits.rs index e7acf1bc3c..b5b860a20d 100644 --- a/tests/unit/out/unsafe/operator_traits.rs +++ b/tests/unit/out/unsafe/operator_traits.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Lt { pub v: i32, } @@ -44,7 +53,16 @@ impl std::cmp::PartialEq for Lt { } impl std::cmp::Eq for Lt {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Eq { pub v: i32, } @@ -60,7 +78,16 @@ impl std::cmp::PartialEq for Eq { } impl std::cmp::Eq for Eq {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Cmp { pub v: i32, } @@ -89,7 +116,16 @@ impl std::cmp::PartialEq for Cmp { } impl std::cmp::Eq for Cmp {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Free { pub v: i32, } @@ -124,7 +160,16 @@ pub unsafe fn operator_eq_1(a: *const Free, b: *const Free) -> bool { return (((*a).v) == ((*b).v)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Wrapped_int_ { pub v: i32, } diff --git a/tests/unit/out/unsafe/overload_mangling.rs b/tests/unit/out/unsafe/overload_mangling.rs index 8517c5b99e..c9317a9a21 100644 --- a/tests/unit/out/unsafe/overload_mangling.rs +++ b/tests/unit/out/unsafe/overload_mangling.rs @@ -16,7 +16,16 @@ pub unsafe fn twice_2(mut n: i32) -> i32 { return ((n) * (2)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Access_S_ {} impl Access_S_ { pub unsafe fn get_1(&mut self, mut p: *mut S) -> i32 { @@ -33,7 +42,16 @@ impl Access_S_ { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub base: i32, } @@ -107,7 +125,16 @@ impl S { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Box_ { pub v: i32, } diff --git a/tests/unit/out/unsafe/pair_converting_construction.rs b/tests/unit/out/unsafe/pair_converting_construction.rs index ec693a708e..62ae92a309 100644 --- a/tests/unit/out/unsafe/pair_converting_construction.rs +++ b/tests/unit/out/unsafe/pair_converting_construction.rs @@ -8,7 +8,15 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, )] #[cpp_from(i32, construct, value)] pub struct Celsius { @@ -21,7 +29,15 @@ impl Celsius { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, )] #[cpp_into(i32, to_i32)] pub struct Meters { @@ -34,7 +50,15 @@ impl Meters { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, )] #[cpp_from(Celsius, construct, ptr)] pub struct Label { @@ -47,7 +71,15 @@ impl Label { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, )] #[cpp_from(Celsius, construct_1, ptr)] #[cpp_from_move(Celsius, construct_2, ptr)] @@ -67,7 +99,15 @@ impl Owner { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, )] #[cpp_from(Celsius, construct, value)] pub struct Holder { @@ -79,7 +119,16 @@ impl Holder { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, +)] #[cpp_from(i32, construct, value)] pub struct Fallback { pub value: i32, @@ -101,13 +150,30 @@ impl Default for Fallback { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Counter { pub hits: i32, } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, )] #[cpp_from(Counter, construct, mut_ptr)] pub struct Observer { @@ -126,7 +192,15 @@ impl Tag { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, )] #[cpp_from(Celsius, construct, ptr)] pub struct Tag { @@ -134,7 +208,15 @@ pub struct Tag { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, )] #[cpp_from(*const libc::c_char , construct, value)] pub struct Name { diff --git a/tests/unit/out/unsafe/pod.rs b/tests/unit/out/unsafe/pod.rs index 34689f2c9c..9ee5ea9f79 100644 --- a/tests/unit/out/unsafe/pod.rs +++ b/tests/unit/out/unsafe/pod.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct POD { pub x1: i32, pub x2: i32, diff --git a/tests/unit/out/unsafe/pointer_array.rs b/tests/unit/out/unsafe/pointer_array.rs index c88b6d8f81..fa1f3cc073 100644 --- a/tests/unit/out/unsafe/pointer_array.rs +++ b/tests/unit/out/unsafe/pointer_array.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct StackArray { pub arr: [*mut i32; 3], } diff --git a/tests/unit/out/unsafe/pointers.rs b/tests/unit/out/unsafe/pointers.rs index 43e868fa8a..be4c591924 100644 --- a/tests/unit/out/unsafe/pointers.rs +++ b/tests/unit/out/unsafe/pointers.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Test { pub x: i32, } diff --git a/tests/unit/out/unsafe/polymorphism.rs b/tests/unit/out/unsafe/polymorphism.rs index 9ce091d5f3..5cd87101e7 100644 --- a/tests/unit/out/unsafe/polymorphism.rs +++ b/tests/unit/out/unsafe/polymorphism.rs @@ -10,10 +10,28 @@ pub unsafe trait Animal { unsafe fn bark(&self) -> bool; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Dog {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Cat {} impl Cat { unsafe fn meow(&self) -> bool { diff --git a/tests/unit/out/unsafe/ptr_cast_init.rs b/tests/unit/out/unsafe/ptr_cast_init.rs index 2d9b922bff..b2e14fe6b1 100644 --- a/tests/unit/out/unsafe/ptr_cast_init.rs +++ b/tests/unit/out/unsafe/ptr_cast_init.rs @@ -7,13 +7,31 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct header { pub tag: i32, pub size: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct view { pub tag: i32, } diff --git a/tests/unit/out/unsafe/push_emplace_back.rs b/tests/unit/out/unsafe/push_emplace_back.rs index 791593ba0f..097e56f511 100644 --- a/tests/unit/out/unsafe/push_emplace_back.rs +++ b/tests/unit/out/unsafe/push_emplace_back.rs @@ -7,12 +7,30 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Chunk { pub data: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Writer { pub output: *mut Vec, pub chunk: Chunk, @@ -23,6 +41,7 @@ pub struct Writer { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, SwappableUnsafe, @@ -115,7 +134,16 @@ pub unsafe fn self_ref_push_6(mut comps: *mut Vec) { }; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, +)] #[cpp_from(i32, construct_1, value)] pub struct Pair { pub first: i32, @@ -224,6 +252,7 @@ pub unsafe fn emplace_ref_self_read_13(values: *mut Vec) -> *mut i64 { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, SwappableUnsafe, @@ -269,7 +298,16 @@ pub unsafe fn emplace_from_element_14(mut v: *mut Vec>) { }); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Plain { pub a: i32, pub b: [f64; 2], @@ -284,7 +322,16 @@ pub unsafe fn emplace_plain_15(mut v: *mut Vec) { pub static mut all_counted_16: std::cell::LazyCell<*mut Vec> = std::cell::LazyCell::new(|| unsafe { std::ptr::null_mut() }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Counted { pub seen: usize, } diff --git a/tests/unit/out/unsafe/random.rs b/tests/unit/out/unsafe/random.rs index fc319c167a..eab06ff22a 100644 --- a/tests/unit/out/unsafe/random.rs +++ b/tests/unit/out/unsafe/random.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Pair { pub x: i32, pub y: i32, @@ -41,7 +50,16 @@ pub unsafe fn zero_0() -> i32 { return 0; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct X1 {} pub unsafe fn foo_1(mut x1: i32, x2: *mut i32, mut x3: *mut i32, p2: *mut Pair, mut p3: *mut Pair) { } diff --git a/tests/unit/out/unsafe/reference_wrapper.rs b/tests/unit/out/unsafe/reference_wrapper.rs index d57fa6cbd6..9f3e3ed9fd 100644 --- a/tests/unit/out/unsafe/reference_wrapper.rs +++ b/tests/unit/out/unsafe/reference_wrapper.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Point { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/references.rs b/tests/unit/out/unsafe/references.rs index a0dee4bba9..af6126c6a7 100644 --- a/tests/unit/out/unsafe/references.rs +++ b/tests/unit/out/unsafe/references.rs @@ -7,14 +7,32 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Pair { pub x: i32, pub y: i32, pub arr: [i32; 2], } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Nested { pub p: Pair, } diff --git a/tests/unit/out/unsafe/refs_as_args.rs b/tests/unit/out/unsafe/refs_as_args.rs index d956f72b7e..2f7fd2c9dc 100644 --- a/tests/unit/out/unsafe/refs_as_args.rs +++ b/tests/unit/out/unsafe/refs_as_args.rs @@ -18,7 +18,16 @@ pub unsafe fn more_refs_0(mut x1: i32, mut x2: i32, r1: *mut i32, r2: *const i32 (*r1) = (*rx2); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Val { pub x: i32, } diff --git a/tests/unit/out/unsafe/reinterpret_cast_ptr_cmp.rs b/tests/unit/out/unsafe/reinterpret_cast_ptr_cmp.rs index 94b2dd39a3..fa19cfabc8 100644 --- a/tests/unit/out/unsafe/reinterpret_cast_ptr_cmp.rs +++ b/tests/unit/out/unsafe/reinterpret_cast_ptr_cmp.rs @@ -7,19 +7,46 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub x: i32, pub y: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct W { pub h: i32, pub arr: [S; 3], } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct P { pub a: *mut i32, pub arr: [*mut i32; 3], diff --git a/tests/unit/out/unsafe/reinterpret_cast_struct.rs b/tests/unit/out/unsafe/reinterpret_cast_struct.rs index 5b4a26a03b..795706815f 100644 --- a/tests/unit/out/unsafe/reinterpret_cast_struct.rs +++ b/tests/unit/out/unsafe/reinterpret_cast_struct.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Point { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/reinterpret_cast_struct_to_struct.rs b/tests/unit/out/unsafe/reinterpret_cast_struct_to_struct.rs index c66149ba7f..98b5c7d4f7 100644 --- a/tests/unit/out/unsafe/reinterpret_cast_struct_to_struct.rs +++ b/tests/unit/out/unsafe/reinterpret_cast_struct_to_struct.rs @@ -7,13 +7,31 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Point { pub x: u32, pub y: u32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Pair { pub first: u32, pub second: u32, diff --git a/tests/unit/out/unsafe/reserved_keywords.rs b/tests/unit/out/unsafe/reserved_keywords.rs index 33cc38b036..2a022c5622 100644 --- a/tests/unit/out/unsafe/reserved_keywords.rs +++ b/tests/unit/out/unsafe/reserved_keywords.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub as_: i32, pub async_: i32, @@ -49,12 +58,30 @@ pub struct S { pub vec_: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct type_ { pub v: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct loop_ { pub t: type_, } diff --git a/tests/unit/out/unsafe/return_move.rs b/tests/unit/out/unsafe/return_move.rs index 108c676409..1f16547898 100644 --- a/tests/unit/out/unsafe/return_move.rs +++ b/tests/unit/out/unsafe/return_move.rs @@ -7,13 +7,31 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct node { pub value: i32, pub next: *mut node, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct pair_t { pub a: i32, pub n: *mut node, diff --git a/tests/unit/out/unsafe/rule_of_five.rs b/tests/unit/out/unsafe/rule_of_five.rs index 9e296f2b21..cb1ce53e1c 100644 --- a/tests/unit/out/unsafe/rule_of_five.rs +++ b/tests/unit/out/unsafe/rule_of_five.rs @@ -10,15 +10,7 @@ pub static mut alive_0: std::cell::LazyCell = std::cell::LazyCell::new(|| u pub static mut copies_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut moves_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - DestructibleUnsafe, - SwappableUnsafe, - Default, -)] +#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, SwappableUnsafe, Default)] #[cpp_from(i32, construct, value)] pub struct Buffer { pub data: [i32; 4], @@ -39,7 +31,9 @@ impl Buffer { } (*std::cell::LazyCell::force_mut(&mut *&raw mut alive_0)).prefix_inc(); } - pub unsafe fn destructor(&mut self) { +} +impl DestructibleUnsafe for Buffer { + unsafe fn destroy(&mut self) { (*std::cell::LazyCell::force_mut(&mut *&raw mut alive_0)).prefix_dec(); } } @@ -135,7 +129,7 @@ pub unsafe fn make_3(mut size: i32) -> Buffer { __v }; let _dtor_b = std::mem::DropGuard::new(&raw mut b, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); return { let mut __v: Buffer = ::zero_init(); @@ -157,7 +151,7 @@ unsafe fn main_0() -> i32 { __v }; let _dtor_a = std::mem::DropGuard::new(&raw mut a, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); let mut b: Buffer = { let mut __v: Buffer = ::zero_init(); @@ -165,7 +159,7 @@ unsafe fn main_0() -> i32 { __v }; let _dtor_b = std::mem::DropGuard::new(&raw mut b, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); assert!( (((*std::cell::LazyCell::force_mut(&mut *&raw mut alive_0)) == (2)) @@ -180,7 +174,7 @@ unsafe fn main_0() -> i32 { __v }; let _dtor_c = std::mem::DropGuard::new(&raw mut c, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); assert!( ((*std::cell::LazyCell::force_mut(&mut *&raw mut alive_0)) == (3)) @@ -190,7 +184,7 @@ unsafe fn main_0() -> i32 { assert!(((c.size) == (4)) && ((c.data[(3) as usize]) == (3))); let mut d: Buffer = (unsafe { make_3(2) }); let _dtor_d = std::mem::DropGuard::new(&raw mut d, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); assert!( ((d.size) == (2)) && ((*std::cell::LazyCell::force_mut(&mut *&raw mut moves_2)) == (2)) diff --git a/tests/unit/out/unsafe/rule_of_three.rs b/tests/unit/out/unsafe/rule_of_three.rs index d44d464b8f..f7450613a8 100644 --- a/tests/unit/out/unsafe/rule_of_three.rs +++ b/tests/unit/out/unsafe/rule_of_three.rs @@ -14,7 +14,6 @@ pub static mut copies_1: std::cell::LazyCell = std::cell::LazyCell::new(|| FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DestructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -40,7 +39,9 @@ impl Buffer { } (*std::cell::LazyCell::force_mut(&mut *&raw mut alive_0)).prefix_inc(); } - pub unsafe fn destructor(&mut self) { +} +impl DestructibleUnsafe for Buffer { + unsafe fn destroy(&mut self) { (*std::cell::LazyCell::force_mut(&mut *&raw mut alive_0)).prefix_dec(); } } @@ -116,7 +117,7 @@ unsafe fn main_0() -> i32 { __v }; let _dtor_a = std::mem::DropGuard::new(&raw mut a, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); let mut b: Buffer = { let mut __v: Buffer = ::zero_init(); @@ -124,7 +125,7 @@ unsafe fn main_0() -> i32 { __v }; let _dtor_b = std::mem::DropGuard::new(&raw mut b, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); assert!( ((*std::cell::LazyCell::force_mut(&mut *&raw mut alive_0)) == (2)) @@ -138,7 +139,7 @@ unsafe fn main_0() -> i32 { __v }; let _dtor_c = std::mem::DropGuard::new(&raw mut c, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); (unsafe { CopyAssignableUnsafe::copy_assign(&mut c, &a) }); assert!(((c.size) == (4)) && ((c.data[(3) as usize]) == (3))); @@ -159,7 +160,7 @@ unsafe fn main_0() -> i32 { __v }; let _dtor_d = std::mem::DropGuard::new(&raw mut d, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); assert!( ((*std::cell::LazyCell::force_mut(&mut *&raw mut alive_0)) == (4)) diff --git a/tests/unit/out/unsafe/rvalue_rule_arg_move.rs b/tests/unit/out/unsafe/rvalue_rule_arg_move.rs index 5accffdc6b..c5e110fb42 100644 --- a/tests/unit/out/unsafe/rvalue_rule_arg_move.rs +++ b/tests/unit/out/unsafe/rvalue_rule_arg_move.rs @@ -14,6 +14,7 @@ pub static mut moves_1: std::cell::LazyCell = std::cell::LazyCell::new(|| u FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DestructibleUnsafe, MoveAssignableUnsafe, SwappableUnsafe, Default, diff --git a/tests/unit/out/unsafe/rvalue_struct.rs b/tests/unit/out/unsafe/rvalue_struct.rs index f399667614..9dc4a5dc38 100644 --- a/tests/unit/out/unsafe/rvalue_struct.rs +++ b/tests/unit/out/unsafe/rvalue_struct.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub a: i32, pub b: i32, diff --git a/tests/unit/out/unsafe/scalar_builtin_construct_destruct.rs b/tests/unit/out/unsafe/scalar_builtin_construct_destruct.rs index df7502a789..757edd3664 100644 --- a/tests/unit/out/unsafe/scalar_builtin_construct_destruct.rs +++ b/tests/unit/out/unsafe/scalar_builtin_construct_destruct.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Pod { pub v: i32, } diff --git a/tests/unit/out/unsafe/self_referencing_initializer.rs b/tests/unit/out/unsafe/self_referencing_initializer.rs index 18e3907031..9b6fe56f36 100644 --- a/tests/unit/out/unsafe/self_referencing_initializer.rs +++ b/tests/unit/out/unsafe/self_referencing_initializer.rs @@ -7,18 +7,38 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct list_head { pub next: *mut list_head, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct node { pub value: i32, pub value_ptr: *mut i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct node_with_defaults { pub next: *mut node_with_defaults, pub value: i32, diff --git a/tests/unit/out/unsafe/size_t_static_member.rs b/tests/unit/out/unsafe/size_t_static_member.rs index f14939a058..0b70647185 100644 --- a/tests/unit/out/unsafe/size_t_static_member.rs +++ b/tests/unit/out/unsafe/size_t_static_member.rs @@ -8,12 +8,30 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub static mut c_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 5_usize }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S {} pub static mut table_size_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 256_usize }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Table_char_ {} pub fn main() { unsafe { diff --git a/tests/unit/out/unsafe/size_t_template_param.rs b/tests/unit/out/unsafe/size_t_template_param.rs index 603d6c8597..e20a098cfb 100644 --- a/tests/unit/out/unsafe/size_t_template_param.rs +++ b/tests/unit/out/unsafe/size_t_template_param.rs @@ -12,7 +12,15 @@ pub unsafe fn array_ref_0(a: *mut [u64; 3]) -> u64 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, )] #[cpp_from(*const u64 , construct, value)] pub struct PtrCtor_unsigned_long_ { @@ -25,7 +33,15 @@ impl PtrCtor_unsigned_long_ { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, )] #[cpp_from(u64, construct, ptr)] pub struct RefCtor_unsigned_long_ { diff --git a/tests/unit/out/unsafe/sort_no_copy.rs b/tests/unit/out/unsafe/sort_no_copy.rs index cecfde3d62..95f7ffc5eb 100644 --- a/tests/unit/out/unsafe/sort_no_copy.rs +++ b/tests/unit/out/unsafe/sort_no_copy.rs @@ -8,7 +8,9 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub static mut copies_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, SwappableUnsafe)] +#[derive( + VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, SwappableUnsafe, +)] #[cpp_from(i32, construct_1, value)] pub struct Tracked { pub v: i32, @@ -99,7 +101,9 @@ pub unsafe fn greater_2(a: *const Tracked, b: *const Tracked) -> bool { return (((*a).v) > ((*b).v)); } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, SwappableUnsafe, Default)] +#[derive( + FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, SwappableUnsafe, Default, +)] #[cpp_from(i32, construct, value)] pub struct MoveOnly { pub v: i32, @@ -156,6 +160,7 @@ pub unsafe fn operator_lt_3(a: *const MoveOnly, b: *const MoveOnly) -> bool { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, SwappableUnsafe, diff --git a/tests/unit/out/unsafe/static_local.rs b/tests/unit/out/unsafe/static_local.rs index cc490e3768..b466c9f317 100644 --- a/tests/unit/out/unsafe/static_local.rs +++ b/tests/unit/out/unsafe/static_local.rs @@ -22,7 +22,16 @@ pub unsafe fn from_local_class_6() -> i32 { } static mut x_7: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 3 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S_8 {} impl S_8 { pub unsafe fn get(&self) -> i32 { diff --git a/tests/unit/out/unsafe/static_var_in_class.rs b/tests/unit/out/unsafe/static_var_in_class.rs index 7f5023a8ea..de33e44eb5 100644 --- a/tests/unit/out/unsafe/static_var_in_class.rs +++ b/tests/unit/out/unsafe/static_var_in_class.rs @@ -8,7 +8,16 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; static mut inner_const_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 1 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct C {} impl C { pub unsafe fn get(&mut self) -> i32 { @@ -19,7 +28,16 @@ pub static mut inner_const_1: std::cell::LazyCell = std::cell::LazyCell::ne pub type anon_3 = u32; pub const anon_3_kValue: anon_3 = 3; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S {} impl S { pub unsafe fn f() -> i32 { diff --git a/tests/unit/out/unsafe/stdcopy.rs b/tests/unit/out/unsafe/stdcopy.rs index 8cef708dc0..4a0b3d3449 100644 --- a/tests/unit/out/unsafe/stdcopy.rs +++ b/tests/unit/out/unsafe/stdcopy.rs @@ -8,7 +8,15 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, )] #[cpp_from(i32, construct, value)] pub struct Degrees { diff --git a/tests/unit/out/unsafe/strdup.rs b/tests/unit/out/unsafe/strdup.rs index 0d10b728da..3eb8a6b96e 100644 --- a/tests/unit/out/unsafe/strdup.rs +++ b/tests/unit/out/unsafe/strdup.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct record { pub name: *mut libc::c_char, } diff --git a/tests/unit/out/unsafe/string_literal_ptr_init.rs b/tests/unit/out/unsafe/string_literal_ptr_init.rs index 3288ac7036..0c5d83689c 100644 --- a/tests/unit/out/unsafe/string_literal_ptr_init.rs +++ b/tests/unit/out/unsafe/string_literal_ptr_init.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct label { pub name: *const libc::c_char, pub probe: Option i32>, diff --git a/tests/unit/out/unsafe/string_substr.rs b/tests/unit/out/unsafe/string_substr.rs index 0c76c958c8..932647e8a4 100644 --- a/tests/unit/out/unsafe/string_substr.rs +++ b/tests/unit/out/unsafe/string_substr.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Text { pub value: *mut Vec, } diff --git a/tests/unit/out/unsafe/struct_2d_array_field.rs b/tests/unit/out/unsafe/struct_2d_array_field.rs index f27e9b7151..2e5488765e 100644 --- a/tests/unit/out/unsafe/struct_2d_array_field.rs +++ b/tests/unit/out/unsafe/struct_2d_array_field.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct table { pub rows: [[libc::c_char; 10]; 3], pub count: usize, diff --git a/tests/unit/out/unsafe/struct_ctor.rs b/tests/unit/out/unsafe/struct_ctor.rs index 48b6b0eed0..d8b4510ff5 100644 --- a/tests/unit/out/unsafe/struct_ctor.rs +++ b/tests/unit/out/unsafe/struct_ctor.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct StructWithCtor { x1_: i32, x2_: i32, @@ -31,7 +40,15 @@ pub unsafe fn foo_0(x: *mut i32) -> *mut i32 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, )] #[cpp_from(i32, construct, value)] pub struct Value_ { @@ -43,7 +60,9 @@ impl Value_ { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct Ptr_ { pub v1: Value_, pub v2: Value_, diff --git a/tests/unit/out/unsafe/struct_default_ctor.rs b/tests/unit/out/unsafe/struct_default_ctor.rs index c3e8fddcac..c02baa62a2 100644 --- a/tests/unit/out/unsafe/struct_default_ctor.rs +++ b/tests/unit/out/unsafe/struct_default_ctor.rs @@ -7,7 +7,9 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct S { pub a: i32, pub b: bool, @@ -30,19 +32,39 @@ impl Default for S { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Declared { pub v: i32, } impl Declared {} #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Holder { pub items: [S; 2], } pub static mut kInit_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 3 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct FromStatic { pub v: i32, } diff --git a/tests/unit/out/unsafe/struct_member_array_adjacency.rs b/tests/unit/out/unsafe/struct_member_array_adjacency.rs index 277b27a2d3..019d55c669 100644 --- a/tests/unit/out/unsafe/struct_member_array_adjacency.rs +++ b/tests/unit/out/unsafe/struct_member_array_adjacency.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct pair { pub a: [i32; 4], pub b: [i32; 4], diff --git a/tests/unit/out/unsafe/struct_ptr.rs b/tests/unit/out/unsafe/struct_ptr.rs index fc1c71b81a..3cdf384bb2 100644 --- a/tests/unit/out/unsafe/struct_ptr.rs +++ b/tests/unit/out/unsafe/struct_ptr.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct XX { pub x: i32, } diff --git a/tests/unit/out/unsafe/structured_binding_copy_ctor.rs b/tests/unit/out/unsafe/structured_binding_copy_ctor.rs index 763aa5b3f7..dad184bedf 100644 --- a/tests/unit/out/unsafe/structured_binding_copy_ctor.rs +++ b/tests/unit/out/unsafe/structured_binding_copy_ctor.rs @@ -12,6 +12,7 @@ pub static mut copies_0: std::cell::LazyCell = std::cell::LazyCell::new(|| VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, SwappableUnsafe, diff --git a/tests/unit/out/unsafe/structured_binding_element_ctor.rs b/tests/unit/out/unsafe/structured_binding_element_ctor.rs index bdb27f7216..02cd72c6ee 100644 --- a/tests/unit/out/unsafe/structured_binding_element_ctor.rs +++ b/tests/unit/out/unsafe/structured_binding_element_ctor.rs @@ -14,6 +14,7 @@ pub static mut moves_1: std::cell::LazyCell = std::cell::LazyCell::new(|| u FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DestructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -56,6 +57,7 @@ impl Clone for Elem { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, diff --git a/tests/unit/out/unsafe/structured_binding_move_ctor.rs b/tests/unit/out/unsafe/structured_binding_move_ctor.rs index 111558642b..0d554ad015 100644 --- a/tests/unit/out/unsafe/structured_binding_move_ctor.rs +++ b/tests/unit/out/unsafe/structured_binding_move_ctor.rs @@ -13,6 +13,7 @@ pub static mut moves_1: std::cell::LazyCell = std::cell::LazyCell::new(|| u VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -59,6 +60,7 @@ impl Clone for Movable { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, SwappableUnsafe, diff --git a/tests/unit/out/unsafe/structured_binding_range_for.rs b/tests/unit/out/unsafe/structured_binding_range_for.rs index ae669cc725..fc845b2d96 100644 --- a/tests/unit/out/unsafe/structured_binding_range_for.rs +++ b/tests/unit/out/unsafe/structured_binding_range_for.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Pair { pub first: i32, pub second: i32, diff --git a/tests/unit/out/unsafe/structured_binding_ref.rs b/tests/unit/out/unsafe/structured_binding_ref.rs index 44c820232f..86de454fa1 100644 --- a/tests/unit/out/unsafe/structured_binding_ref.rs +++ b/tests/unit/out/unsafe/structured_binding_ref.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Triple { pub a: i32, pub b: bool, diff --git a/tests/unit/out/unsafe/structured_binding_trivial.rs b/tests/unit/out/unsafe/structured_binding_trivial.rs index c095ef628e..e295e8c2fe 100644 --- a/tests/unit/out/unsafe/structured_binding_trivial.rs +++ b/tests/unit/out/unsafe/structured_binding_trivial.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Pair { pub first: i32, pub second: i32, diff --git a/tests/unit/out/unsafe/swap_map_no_copy.rs b/tests/unit/out/unsafe/swap_map_no_copy.rs index 447bf87a3f..6a89f43e3d 100644 --- a/tests/unit/out/unsafe/swap_map_no_copy.rs +++ b/tests/unit/out/unsafe/swap_map_no_copy.rs @@ -8,7 +8,9 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub static mut copies_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, SwappableUnsafe)] +#[derive( + VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, SwappableUnsafe, +)] #[cpp_from(i32, construct_1, value)] pub struct Tracked { pub v: i32, @@ -71,6 +73,7 @@ impl Default for Tracked { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, SwappableUnsafe, Default, @@ -125,6 +128,7 @@ impl MoveAssignableUnsafe for Pair { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, SwappableUnsafe, Default, @@ -215,7 +219,6 @@ pub static mut copy_only_dtors_2: std::cell::LazyCell = FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DestructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -229,9 +232,6 @@ impl CopyOnly { pub unsafe fn construct(&mut self, mut v: i32) { (&raw mut self.v).write(v); } - pub unsafe fn destructor(&mut self) { - (*std::cell::LazyCell::force_mut(&mut *&raw mut copy_only_dtors_2)).prefix_inc(); - } } impl CopyConstructibleUnsafe for CopyOnly { unsafe fn copy_constructor(&mut self, o: *const CopyOnly) { @@ -239,6 +239,11 @@ impl CopyConstructibleUnsafe for CopyOnly { (*std::cell::LazyCell::force_mut(&mut *&raw mut copy_only_copies_1)).prefix_inc(); } } +impl DestructibleUnsafe for CopyOnly { + unsafe fn destroy(&mut self) { + (*std::cell::LazyCell::force_mut(&mut *&raw mut copy_only_dtors_2)).prefix_inc(); + } +} impl CopyAssignableUnsafe for CopyOnly { unsafe fn copy_assign(&mut self, o: *const CopyOnly) -> *mut CopyOnly { self.v = (*o).v; @@ -261,7 +266,6 @@ impl Clone for CopyOnly { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DestructibleUnsafe, CopyConstructibleUnsafe, MoveConstructibleUnsafe, MoveAssignableUnsafe, @@ -285,25 +289,17 @@ impl CopyAssignableUnsafe for CopyOnlyPair { return &mut (*(self as *mut CopyOnlyPair)); } } -impl CopyOnlyPair { - pub unsafe fn destructor(&mut self) { - DestructibleUnsafe::destroy(&raw mut self.y); - DestructibleUnsafe::destroy(&raw mut self.x); +impl DestructibleUnsafe for CopyOnlyPair { + unsafe fn destroy(&mut self) { + DestructibleUnsafe::destroy(&mut self.y); + DestructibleUnsafe::destroy(&mut self.x); } } pub static mut moves_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut move_assigns_4: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut moved_dtors_5: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - DestructibleUnsafe, - SwappableUnsafe, - Default, -)] +#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, SwappableUnsafe, Default)] #[cpp_from(i32, construct, value)] pub struct Moved { pub v: i32, @@ -312,9 +308,6 @@ impl Moved { pub unsafe fn construct(&mut self, mut v: i32) { (&raw mut self.v).write(v); } - pub unsafe fn destructor(&mut self) { - (*std::cell::LazyCell::force_mut(&mut *&raw mut moved_dtors_5)).prefix_inc(); - } } impl CopyConstructibleUnsafe for Moved { unsafe fn copy_constructor(&mut self, o: *const Moved) { @@ -344,6 +337,11 @@ impl MoveAssignableUnsafe for Moved { return &mut (*(self as *mut Moved)); } } +impl DestructibleUnsafe for Moved { + unsafe fn destroy(&mut self) { + (*std::cell::LazyCell::force_mut(&mut *&raw mut moved_dtors_5)).prefix_inc(); + } +} impl Clone for Moved { fn clone(&self) -> Self { unsafe { @@ -359,7 +357,6 @@ impl Clone for Moved { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DestructibleUnsafe, CopyConstructibleUnsafe, SwappableUnsafe, Default, @@ -408,10 +405,10 @@ impl MoveAssignableUnsafe for MovedPair { return &mut (*(self as *mut MovedPair)); } } -impl MovedPair { - pub unsafe fn destructor(&mut self) { - DestructibleUnsafe::destroy(&raw mut self.y); - DestructibleUnsafe::destroy(&raw mut self.x); +impl DestructibleUnsafe for MovedPair { + unsafe fn destroy(&mut self) { + DestructibleUnsafe::destroy(&mut self.y); + DestructibleUnsafe::destroy(&mut self.x); } } pub unsafe fn swapped_once_6() -> bool { @@ -428,7 +425,7 @@ pub unsafe fn swapped_once_6() -> bool { return ok; } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, SwappableUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, SwappableUnsafe, Default)] pub struct Owner { pub p: Option>, } @@ -729,7 +726,7 @@ unsafe fn main_0() -> i32 { __v }; let _dtor_c1 = std::mem::DropGuard::new(&raw mut c1, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); let mut c2: CopyOnly = { let mut __v: CopyOnly = ::zero_init(); @@ -737,7 +734,7 @@ unsafe fn main_0() -> i32 { __v }; let _dtor_c2 = std::mem::DropGuard::new(&raw mut c2, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); SwappableUnsafe::swap(&mut *(&mut c1), &mut c2); assert!(((c1.v) == (2)) && ((c2.v) == (1))); @@ -758,7 +755,7 @@ unsafe fn main_0() -> i32 { }, }; let _dtor_cp = std::mem::DropGuard::new(&raw mut cp, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); SwappableUnsafe::swap(&mut *(&mut cp.x), &mut cp.y); assert!(((cp.x.v) == (4)) && ((cp.y.v) == (3))); @@ -790,7 +787,7 @@ unsafe fn main_0() -> i32 { __v }; let _dtor_mv1 = std::mem::DropGuard::new(&raw mut mv1, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); let mut mv2: Moved = { let mut __v: Moved = ::zero_init(); @@ -798,7 +795,7 @@ unsafe fn main_0() -> i32 { __v }; let _dtor_mv2 = std::mem::DropGuard::new(&raw mut mv2, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); SwappableUnsafe::swap(&mut *(&mut mv1), &mut mv2); assert!(((mv1.v) == (2)) && ((mv2.v) == (1))); @@ -816,7 +813,7 @@ unsafe fn main_0() -> i32 { }, }; let _dtor_mp = std::mem::DropGuard::new(&raw mut mp, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); SwappableUnsafe::swap(&mut *(&mut mp.x), &mut mp.y); assert!(((mp.x.v) == (4)) && ((mp.y.v) == (3))); diff --git a/tests/unit/out/unsafe/tag_vs_identifier_collision.rs b/tests/unit/out/unsafe/tag_vs_identifier_collision.rs index 891720e11b..0a102a8f47 100644 --- a/tests/unit/out/unsafe/tag_vs_identifier_collision.rs +++ b/tests/unit/out/unsafe/tag_vs_identifier_collision.rs @@ -11,19 +11,39 @@ pub const widget_enum_MODE_IDLE: widget_enum = 0; pub const widget_enum_MODE_ACTIVE: widget_enum = 1; pub const widget_enum_MODE_DONE: widget_enum = 2; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct widget { pub id: i32, pub mode: widget_enum, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct point_struct { pub x: i32, pub y: i32, } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub union point { pub whole: i32, pub half: i16, @@ -34,7 +54,9 @@ impl Default for point { } } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub union slot_union { pub i: i32, pub u: u32, @@ -48,17 +70,44 @@ pub type slot = u32; pub const slot_SLOT_A: slot = 0; pub const slot_SLOT_B: slot = 1; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Inner { pub tag_field: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Outer { pub field: Inner, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Inner_struct { pub typedef_field: i32, } diff --git a/tests/unit/out/unsafe/template_default_arg.rs b/tests/unit/out/unsafe/template_default_arg.rs index 45e17aaae5..95c9bfd0b5 100644 --- a/tests/unit/out/unsafe/template_default_arg.rs +++ b/tests/unit/out/unsafe/template_default_arg.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, +)] #[cpp_from(i32, construct_1, value)] pub struct A { pub v: i32, @@ -32,7 +41,9 @@ impl Default for A { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct B { pub v: i32, } @@ -54,7 +65,15 @@ impl Default for B { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, )] #[cpp_from(i32, construct, value)] pub struct NoDefault { @@ -79,7 +98,15 @@ pub unsafe fn always_given_3(mut x: NoDefault) -> i32 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, )] #[cpp_from(i32, construct, value)] pub struct S_NoDefault_ { diff --git a/tests/unit/out/unsafe/template_static_member.rs b/tests/unit/out/unsafe/template_static_member.rs index 0db609551f..efa4c745bc 100644 --- a/tests/unit/out/unsafe/template_static_member.rs +++ b/tests/unit/out/unsafe/template_static_member.rs @@ -8,27 +8,72 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub static mut s_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 55 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Static_int_ {} pub static mut s_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { (55 as libc::c_char) }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Static_char_ {} pub static mut s_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 55_i64 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Static_long_ {} pub static mut lo_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { -1_i32 }); pub static mut hi_4: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 1 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Range_int_ {} pub static mut lo_5: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { (-2_i32 as i64) }); pub static mut hi_6: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 2_i64 }); #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Range_long_ {} pub fn main() { unsafe { diff --git a/tests/unit/out/unsafe/temporary_field_addr.rs b/tests/unit/out/unsafe/temporary_field_addr.rs index a7be53cb30..fa1bbe7181 100644 --- a/tests/unit/out/unsafe/temporary_field_addr.rs +++ b/tests/unit/out/unsafe/temporary_field_addr.rs @@ -12,6 +12,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, SwappableUnsafe, @@ -39,6 +40,7 @@ impl MoveAssignableUnsafe for Inner { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, SwappableUnsafe, diff --git a/tests/unit/out/unsafe/temporary_field_ctor_arg.rs b/tests/unit/out/unsafe/temporary_field_ctor_arg.rs index ac4ba1414f..448aadef5e 100644 --- a/tests/unit/out/unsafe/temporary_field_ctor_arg.rs +++ b/tests/unit/out/unsafe/temporary_field_ctor_arg.rs @@ -12,6 +12,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, SwappableUnsafe, @@ -40,7 +41,15 @@ pub unsafe fn make_0() -> Outer { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, )] #[cpp_from(Vec , construct, ptr)] pub struct H { diff --git a/tests/unit/out/unsafe/temporary_field_two_args.rs b/tests/unit/out/unsafe/temporary_field_two_args.rs index c5bcc62331..9a2671bde2 100644 --- a/tests/unit/out/unsafe/temporary_field_two_args.rs +++ b/tests/unit/out/unsafe/temporary_field_two_args.rs @@ -12,6 +12,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, SwappableUnsafe, @@ -39,6 +40,7 @@ impl MoveAssignableUnsafe for Inner { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, SwappableUnsafe, diff --git a/tests/unit/out/unsafe/this.rs b/tests/unit/out/unsafe/this.rs index 19b8a849a4..99d47f6dd3 100644 --- a/tests/unit/out/unsafe/this.rs +++ b/tests/unit/out/unsafe/this.rs @@ -8,7 +8,15 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, )] #[cpp_from(i32, construct_1, value)] pub struct S { @@ -104,7 +112,15 @@ pub unsafe fn bump_0(mut p: *mut S) { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, )] #[cpp_from(i32, construct, value)] pub struct D { diff --git a/tests/unit/out/unsafe/typedef-anon-struct.rs b/tests/unit/out/unsafe/typedef-anon-struct.rs index 4e61224bc8..9809d326d9 100644 --- a/tests/unit/out/unsafe/typedef-anon-struct.rs +++ b/tests/unit/out/unsafe/typedef-anon-struct.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Outer_RunInfo { pub block_idx: i32, pub num_extra_zero_runs: i32, @@ -18,6 +27,7 @@ pub struct Outer_RunInfo { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, SwappableUnsafe, diff --git a/tests/unit/out/unsafe/unary_expr_or_type_trait.rs b/tests/unit/out/unsafe/unary_expr_or_type_trait.rs index 15783857d2..9e636e2ad0 100644 --- a/tests/unit/out/unsafe/unary_expr_or_type_trait.rs +++ b/tests/unit/out/unsafe/unary_expr_or_type_trait.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C, align(16))] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub c: libc::c_char, pub x: i64, diff --git a/tests/unit/out/unsafe/unboxed_locals.rs b/tests/unit/out/unsafe/unboxed_locals.rs index 6e43286da6..bdaa13d7f4 100644 --- a/tests/unit/out/unsafe/unboxed_locals.rs +++ b/tests/unit/out/unsafe/unboxed_locals.rs @@ -13,7 +13,16 @@ pub unsafe fn inc_1(r: *mut i32) { (*r).prefix_inc(); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Pair { pub first: i32, pub second: i32, @@ -51,7 +60,9 @@ pub unsafe trait Shape { unsafe fn scale(&mut self, factor: i32) -> i32; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct Square { pub side: i32, } diff --git a/tests/unit/out/unsafe/unboxed_records.rs b/tests/unit/out/unsafe/unboxed_records.rs index a075e8bc84..b2ff9a2a4a 100644 --- a/tests/unit/out/unsafe/unboxed_records.rs +++ b/tests/unit/out/unsafe/unboxed_records.rs @@ -7,13 +7,31 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Inner { pub a: i32, pub b: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Cookie { pub x: i32, pub data: *mut i32, @@ -22,7 +40,9 @@ pub struct Cookie { pub arr: [i32; 4], } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub struct Counter { pub n: i32, } diff --git a/tests/unit/out/unsafe/union_addrof_external.rs b/tests/unit/out/unsafe/union_addrof_external.rs index e528547503..583405c164 100644 --- a/tests/unit/out/unsafe/union_addrof_external.rs +++ b/tests/unit/out/unsafe/union_addrof_external.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct record { pub code: u16, pub lo: u16, @@ -15,7 +24,9 @@ pub struct record { pub pad: [libc::c_char; 8], } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub union anon_0 { pub h: record, pub raw_: [libc::c_char; 128], @@ -26,7 +37,16 @@ impl Default for anon_0 { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Container { pub view: anon_0, } diff --git a/tests/unit/out/unsafe/union_basic.rs b/tests/unit/out/unsafe/union_basic.rs index bad81ff98b..5e3631b289 100644 --- a/tests/unit/out/unsafe/union_basic.rs +++ b/tests/unit/out/unsafe/union_basic.rs @@ -7,7 +7,9 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub union basic { pub i: i32, pub f: f32, @@ -18,7 +20,9 @@ impl Default for basic { } } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub union empty { __empty: u8, } @@ -28,7 +32,9 @@ impl Default for empty { } } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub union underscores { pub __: i32, pub ___: f64, @@ -91,7 +97,9 @@ unsafe fn main_0() -> i32 { return 0; } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub union anon_0 { pub ai: i32, pub af: f32, diff --git a/tests/unit/out/unsafe/union_cross_arm_cast.rs b/tests/unit/out/unsafe/union_cross_arm_cast.rs index 66cb544d2b..95cbe7c41b 100644 --- a/tests/unit/out/unsafe/union_cross_arm_cast.rs +++ b/tests/unit/out/unsafe/union_cross_arm_cast.rs @@ -7,13 +7,31 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct shape_a { pub code: u16, pub pad: [libc::c_char; 14], } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct shape_b { pub code: u16, pub lo: u16, @@ -22,7 +40,9 @@ pub struct shape_b { pub tail: u32, } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub union anon_0 { pub a: shape_a, pub b: shape_b, @@ -34,7 +54,16 @@ impl Default for anon_0 { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Container { pub len: u32, pub u: anon_0, diff --git a/tests/unit/out/unsafe/union_field_alignment.rs b/tests/unit/out/unsafe/union_field_alignment.rs index 9ccd73525a..b5eabbc966 100644 --- a/tests/unit/out/unsafe/union_field_alignment.rs +++ b/tests/unit/out/unsafe/union_field_alignment.rs @@ -7,7 +7,9 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub union anon_0 { pub bytes: [u8; 1], pub aligner: *mut ::libc::c_void, @@ -18,7 +20,16 @@ impl Default for anon_0 { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct node { pub next: *mut node, pub x: anon_0, diff --git a/tests/unit/out/unsafe/union_flex_array_member.rs b/tests/unit/out/unsafe/union_flex_array_member.rs index cfd32ac686..036b79f72e 100644 --- a/tests/unit/out/unsafe/union_flex_array_member.rs +++ b/tests/unit/out/unsafe/union_flex_array_member.rs @@ -7,7 +7,9 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub union anon_0 { pub bytes: [u8; 1], pub aligner: *mut ::libc::c_void, @@ -18,7 +20,16 @@ impl Default for anon_0 { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct node { pub len: usize, pub pos: usize, diff --git a/tests/unit/out/unsafe/union_memset_memcpy.rs b/tests/unit/out/unsafe/union_memset_memcpy.rs index f1159bfaec..863410f1d5 100644 --- a/tests/unit/out/unsafe/union_memset_memcpy.rs +++ b/tests/unit/out/unsafe/union_memset_memcpy.rs @@ -7,13 +7,31 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct shape_a { pub code: u16, pub pad: [libc::c_char; 14], } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct shape_b { pub code: u16, pub lo: u16, @@ -21,7 +39,9 @@ pub struct shape_b { pub fill: [libc::c_char; 8], } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub union anon_0 { pub a: shape_a, pub b: shape_b, @@ -33,7 +53,16 @@ impl Default for anon_0 { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Container { pub view: anon_0, } diff --git a/tests/unit/out/unsafe/union_nested.rs b/tests/unit/out/unsafe/union_nested.rs index c4ed21041c..da8865c764 100644 --- a/tests/unit/out/unsafe/union_nested.rs +++ b/tests/unit/out/unsafe/union_nested.rs @@ -7,13 +7,24 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct record { pub code: u16, pub pad: [libc::c_char; 14], } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub union anon_0 { pub h: record, pub raw_: [libc::c_char; 128], @@ -24,12 +35,23 @@ impl Default for anon_0 { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct inner { pub view: anon_0, } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub union anon_1 { pub h: record, pub nested: inner, @@ -40,7 +62,16 @@ impl Default for anon_1 { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Outer { pub kind: i32, pub level: i32, diff --git a/tests/unit/out/unsafe/union_pointer_pun_address.rs b/tests/unit/out/unsafe/union_pointer_pun_address.rs index 5077027082..e5dc87af40 100644 --- a/tests/unit/out/unsafe/union_pointer_pun_address.rs +++ b/tests/unit/out/unsafe/union_pointer_pun_address.rs @@ -7,12 +7,30 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct node_a { pub n: i32, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct node_b { pub data: *mut ::libc::c_void, pub next: *mut node_b, @@ -32,7 +50,9 @@ unsafe fn main_0() -> i32 { return 0; } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub union anon_0 { pub to_a: *mut node_a, pub to_b: *mut node_b, diff --git a/tests/unit/out/unsafe/union_pointer_pun_writethrough.rs b/tests/unit/out/unsafe/union_pointer_pun_writethrough.rs index 9d90cadf05..55c72a4cf7 100644 --- a/tests/unit/out/unsafe/union_pointer_pun_writethrough.rs +++ b/tests/unit/out/unsafe/union_pointer_pun_writethrough.rs @@ -21,7 +21,9 @@ unsafe fn main_0() -> i32 { return 0; } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub union anon_0 { pub as_unsigned: *mut u64, pub as_signed: *mut i64, diff --git a/tests/unit/out/unsafe/union_struct_dual_use.rs b/tests/unit/out/unsafe/union_struct_dual_use.rs index 06895c1dbb..f1e97f226b 100644 --- a/tests/unit/out/unsafe/union_struct_dual_use.rs +++ b/tests/unit/out/unsafe/union_struct_dual_use.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Inner { pub a: i32, pub b: i32, @@ -16,7 +25,9 @@ pub unsafe fn sum_inner_0(mut i: *mut Inner) -> i32 { return (((*i).a) + ((*i).b)); } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub union anon_1 { pub inner: Inner, pub raw_: [libc::c_char; 16], @@ -27,7 +38,16 @@ impl Default for anon_1 { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Outer { pub u: anon_1, } diff --git a/tests/unit/out/unsafe/union_tagged_many_arms.rs b/tests/unit/out/unsafe/union_tagged_many_arms.rs index 6bdb7e38e4..680550d074 100644 --- a/tests/unit/out/unsafe/union_tagged_many_arms.rs +++ b/tests/unit/out/unsafe/union_tagged_many_arms.rs @@ -13,7 +13,9 @@ pub const Tag_enum_T_TEXT: Tag_enum = 2; pub const Tag_enum_T_FLOAT: Tag_enum = 3; pub const Tag_enum_T_REF: Tag_enum = 4; #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub union anon_0 { pub text: *const libc::c_char, pub handle: *mut ::libc::c_void, @@ -27,7 +29,16 @@ impl Default for anon_0 { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Slot { pub tag: Tag_enum, pub payload: anon_0, diff --git a/tests/unit/out/unsafe/union_tagged_simple.rs b/tests/unit/out/unsafe/union_tagged_simple.rs index 0b26fca50a..3bca5d919b 100644 --- a/tests/unit/out/unsafe/union_tagged_simple.rs +++ b/tests/unit/out/unsafe/union_tagged_simple.rs @@ -10,7 +10,9 @@ pub type Kind_enum = u32; pub const Kind_enum_KIND_NONE: Kind_enum = 0; pub const Kind_enum_KIND_DONE: Kind_enum = 1; #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub union anon_0 { pub obj: *mut ::libc::c_void, pub code: i32, @@ -21,7 +23,16 @@ impl Default for anon_0 { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Event { pub kind: Kind_enum, pub handle: *mut ::libc::c_void, diff --git a/tests/unit/out/unsafe/union_tagged_struct_arms.rs b/tests/unit/out/unsafe/union_tagged_struct_arms.rs index 604c7bf25d..c361a1f66d 100644 --- a/tests/unit/out/unsafe/union_tagged_struct_arms.rs +++ b/tests/unit/out/unsafe/union_tagged_struct_arms.rs @@ -11,14 +11,32 @@ pub const Choice_enum_C_LIST: Choice_enum = 1; pub const Choice_enum_C_LETTERS: Choice_enum = 2; pub const Choice_enum_C_INTEGERS: Choice_enum = 3; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct anon_1 { pub items: *mut *mut libc::c_char, pub count: i64, pub cursor: i64, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct anon_2 { pub lo: i32, pub hi: i32, @@ -26,7 +44,16 @@ pub struct anon_2 { pub step: u8, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct anon_3 { pub lo: i64, pub hi: i64, @@ -35,7 +62,9 @@ pub struct anon_3 { pub width: i32, } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub union anon_0 { pub list: anon_1, pub letters: anon_2, @@ -47,7 +76,16 @@ impl Default for anon_0 { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Branch { pub choice: Choice_enum, pub index: i32, diff --git a/tests/unit/out/unsafe/union_void_ptr_sized_deref.rs b/tests/unit/out/unsafe/union_void_ptr_sized_deref.rs index 0f1ec7bf1a..551333dd54 100644 --- a/tests/unit/out/unsafe/union_void_ptr_sized_deref.rs +++ b/tests/unit/out/unsafe/union_void_ptr_sized_deref.rs @@ -11,7 +11,9 @@ pub const Width_enum_W_64: Width_enum = 0; pub const Width_enum_W_32: Width_enum = 1; pub const Width_enum_W_16: Width_enum = 2; #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub union anon_0 { pub text: *const libc::c_char, pub handle: *mut ::libc::c_void, @@ -24,7 +26,16 @@ impl Default for anon_0 { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Sink { pub width: Width_enum, pub out: anon_0, diff --git a/tests/unit/out/unsafe/unique_ptr.rs b/tests/unit/out/unsafe/unique_ptr.rs index 9687543cd8..d735d89549 100644 --- a/tests/unit/out/unsafe/unique_ptr.rs +++ b/tests/unit/out/unsafe/unique_ptr.rs @@ -7,7 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, SwappableUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, SwappableUnsafe, Default)] pub struct SafePointer { pub ptr: Option>, } @@ -34,7 +34,16 @@ impl MoveAssignableUnsafe for SafePointer { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Pair { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/unique_ptr_const_deref.rs b/tests/unit/out/unsafe/unique_ptr_const_deref.rs index c7c2ba2ab4..efbfe8a11b 100644 --- a/tests/unit/out/unsafe/unique_ptr_const_deref.rs +++ b/tests/unit/out/unsafe/unique_ptr_const_deref.rs @@ -7,7 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, SwappableUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, SwappableUnsafe, Default)] pub struct Holder { pub val: Option>, } diff --git a/tests/unit/out/unsafe/unique_ptr_field_reset.rs b/tests/unit/out/unsafe/unique_ptr_field_reset.rs index 6473edc94d..ffeb336c96 100644 --- a/tests/unit/out/unsafe/unique_ptr_field_reset.rs +++ b/tests/unit/out/unsafe/unique_ptr_field_reset.rs @@ -7,12 +7,21 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Data { pub v: i32, } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, SwappableUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, SwappableUnsafe, Default)] pub struct Holder { pub data: Option>, pub n: i32, diff --git a/tests/unit/out/unsafe/unique_ptr_nested.rs b/tests/unit/out/unsafe/unique_ptr_nested.rs index ea3f608067..0ffcf9c17e 100644 --- a/tests/unit/out/unsafe/unique_ptr_nested.rs +++ b/tests/unit/out/unsafe/unique_ptr_nested.rs @@ -7,13 +7,22 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Inner { pub x: i32, pub y: i32, } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, SwappableUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, SwappableUnsafe, Default)] pub struct Outer { pub inner: Option>, } diff --git a/tests/unit/out/unsafe/unique_ptr_struct.rs b/tests/unit/out/unsafe/unique_ptr_struct.rs index 89f55ddbe5..4cd3a36d1f 100644 --- a/tests/unit/out/unsafe/unique_ptr_struct.rs +++ b/tests/unit/out/unsafe/unique_ptr_struct.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Point { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/va_arg_mixed_types.rs b/tests/unit/out/unsafe/va_arg_mixed_types.rs index a576ddf435..e25e9b87f5 100644 --- a/tests/unit/out/unsafe/va_arg_mixed_types.rs +++ b/tests/unit/out/unsafe/va_arg_mixed_types.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct pair { pub a: i32, pub b: i32, diff --git a/tests/unit/out/unsafe/va_arg_non_primitive_ptrs.rs b/tests/unit/out/unsafe/va_arg_non_primitive_ptrs.rs index a7acfb87fd..17717a61e9 100644 --- a/tests/unit/out/unsafe/va_arg_non_primitive_ptrs.rs +++ b/tests/unit/out/unsafe/va_arg_non_primitive_ptrs.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct node { pub data: i32, pub next: *mut node, diff --git a/tests/unit/out/unsafe/va_arg_struct_ctx.rs b/tests/unit/out/unsafe/va_arg_struct_ctx.rs index 3b03e14b09..f14ad832d4 100644 --- a/tests/unit/out/unsafe/va_arg_struct_ctx.rs +++ b/tests/unit/out/unsafe/va_arg_struct_ctx.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct context { pub verbose: i32, pub last_error: i32, @@ -24,7 +33,9 @@ pub unsafe fn set_error_0( } } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, CopyableUnsafe)] +#[derive( + Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, +)] pub union value { pub i: i32, pub l: i64, diff --git a/tests/unit/out/unsafe/va_arg_void_ptr.rs b/tests/unit/out/unsafe/va_arg_void_ptr.rs index 9244c8aecb..bf9c3ae583 100644 --- a/tests/unit/out/unsafe/va_arg_void_ptr.rs +++ b/tests/unit/out/unsafe/va_arg_void_ptr.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct registry { pub slot: *mut ::libc::c_void, pub level: i64, diff --git a/tests/unit/out/unsafe/va_list_field.rs b/tests/unit/out/unsafe/va_list_field.rs index 8121920242..b74f5dff58 100644 --- a/tests/unit/out/unsafe/va_list_field.rs +++ b/tests/unit/out/unsafe/va_list_field.rs @@ -15,7 +15,7 @@ pub unsafe fn sum_0(mut n: i32, __args: Box<[VaArg]>) -> i32 { __v }; let _dtor_guard = std::mem::DropGuard::new(&raw mut guard, |__p| unsafe { - DestructibleUnsafe::destroy(__p) + DestructibleUnsafe::destroy(&mut *__p) }); let mut total: i32 = 0; { @@ -31,14 +31,7 @@ pub unsafe fn sum_0(mut n: i32, __args: Box<[VaArg]>) -> i32 { } #[repr(C)] #[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - DestructibleUnsafe, - CopyableUnsafe, - Default, + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, )] #[cpp_from(*const VaArg , construct, mut_ptr)] pub struct Guard_1 { @@ -50,7 +43,9 @@ impl Guard_1 { (&raw mut self.ap).write(val); (&raw mut self.active).write(true); } - pub unsafe fn destructor(&mut self) { +} +impl DestructibleUnsafe for Guard_1 { + unsafe fn destroy(&mut self) { if self.active {} } } @@ -73,7 +68,16 @@ pub unsafe fn sum_ptr_2(mut n: i32, __args: Box<[VaArg]>) -> i32 { return total; } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Cursor_3 { pub ap: *mut *const VaArg, } diff --git a/tests/unit/out/unsafe/vector.rs b/tests/unit/out/unsafe/vector.rs index d200304600..7672f5eb13 100644 --- a/tests/unit/out/unsafe/vector.rs +++ b/tests/unit/out/unsafe/vector.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct S { pub x: i32, } @@ -18,6 +27,7 @@ pub unsafe fn copy_0(mut copy_vector: Vec) {} VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, SwappableUnsafe, diff --git a/tests/unit/out/unsafe/vector_iter_range_ctor.rs b/tests/unit/out/unsafe/vector_iter_range_ctor.rs index babc06d04c..fef414e705 100644 --- a/tests/unit/out/unsafe/vector_iter_range_ctor.rs +++ b/tests/unit/out/unsafe/vector_iter_range_ctor.rs @@ -8,7 +8,15 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, )] #[cpp_from(i32, construct, value)] pub struct Degrees { @@ -21,7 +29,15 @@ impl Degrees { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, )] #[cpp_into(i64, to_i64)] pub struct Reading { diff --git a/tests/unit/out/unsafe/vector_subscript_direct.rs b/tests/unit/out/unsafe/vector_subscript_direct.rs index 64a09a6ef8..e0e15e8862 100644 --- a/tests/unit/out/unsafe/vector_subscript_direct.rs +++ b/tests/unit/out/unsafe/vector_subscript_direct.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Point { pub x: i32, pub y: i32, @@ -23,6 +32,7 @@ impl Point { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, SwappableUnsafe, diff --git a/tests/unit/out/unsafe/vector_with_allocator.rs b/tests/unit/out/unsafe/vector_with_allocator.rs index 8b9361a9c1..50ea8fd8a7 100644 --- a/tests/unit/out/unsafe/vector_with_allocator.rs +++ b/tests/unit/out/unsafe/vector_with_allocator.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct TestAllocator_int_ {} impl TestAllocator_int_ { pub unsafe fn allocate(&mut self, mut n: usize) -> *mut i32 { @@ -27,7 +36,16 @@ impl TestAllocator_int_ { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct TestAllocator_double_ {} impl TestAllocator_double_ { pub unsafe fn allocate(&mut self, mut n: usize) -> *mut f64 { diff --git a/tests/unit/out/unsafe/void_cast.rs b/tests/unit/out/unsafe/void_cast.rs index 6bac438c4e..c07411af9a 100644 --- a/tests/unit/out/unsafe/void_cast.rs +++ b/tests/unit/out/unsafe/void_cast.rs @@ -13,6 +13,7 @@ pub unsafe fn unused_param_0(mut x: i32) {} VaArg, FnPtrArg, ZeroInitializationUnsafe, + DestructibleUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, SwappableUnsafe, @@ -43,12 +44,21 @@ pub unsafe fn bump_and_return_4() -> i32 { return (*std::cell::LazyCell::force_mut(&mut *&raw mut side_effect_counter_3)); } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Holder { pub field: i32, } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, SwappableUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, SwappableUnsafe, Default)] pub struct NonCopyable { pub value: Option>, } From 414cd3d7035764855d6f5de063a76e882d18ce01 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Mon, 30 Nov 2026 22:11:25 +0000 Subject: [PATCH 14/20] ADd destructible on movable --- libcc2rs/src/constructor.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/libcc2rs/src/constructor.rs b/libcc2rs/src/constructor.rs index efeeb9e44b..9e157e590e 100644 --- a/libcc2rs/src/constructor.rs +++ b/libcc2rs/src/constructor.rs @@ -1,6 +1,7 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. +use crate::capture::{Destructible, DestructibleUnsafe}; use crate::fn_ptr::{FnPtr, FnSig}; use crate::initialization::ZeroInitialization; use crate::rc::Ptr; @@ -28,9 +29,9 @@ pub trait Swappable: Sized { } // std::movable. -pub trait Movable: MoveConstructible + MoveAssignable + Swappable {} +pub trait Movable: MoveConstructible + MoveAssignable + Swappable + Destructible {} -impl Movable for T {} +impl Movable for T {} // std::copyable. pub trait Copyable: CopyConstructible + CopyAssignable + Movable {} @@ -68,9 +69,15 @@ pub trait SwappableUnsafe { } // std::movable. -pub trait MovableUnsafe: MoveConstructibleUnsafe + MoveAssignableUnsafe + SwappableUnsafe {} +pub trait MovableUnsafe: + MoveConstructibleUnsafe + MoveAssignableUnsafe + SwappableUnsafe + DestructibleUnsafe +{ +} -impl MovableUnsafe for T {} +impl + MovableUnsafe for T +{ +} // std::copyable. pub trait CopyableUnsafe: CopyConstructibleUnsafe + CopyAssignableUnsafe + MovableUnsafe {} From bc30d5c6015a55b3cf8dca690010f60c8ffbf1e2 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Mon, 30 Nov 2026 22:15:51 +0000 Subject: [PATCH 15/20] Derive destructor trait for empty destructors --- cpp2rust/converter/converter.cpp | 50 +++++++++---------- cpp2rust/converter/converter_lib.cpp | 40 +++++++++++++-- cpp2rust/converter/converter_lib.h | 6 +++ .../converter/models/converter_refcount.cpp | 23 ++++----- 4 files changed, 73 insertions(+), 46 deletions(-) diff --git a/cpp2rust/converter/converter.cpp b/cpp2rust/converter/converter.cpp index 6912737cd6..90ad31628a 100644 --- a/cpp2rust/converter/converter.cpp +++ b/cpp2rust/converter/converter.cpp @@ -753,8 +753,8 @@ bool Converter::VarTypeNeedsDestructor(clang::QualType type) const { } std::string Converter::StaticDestructorCall(const clang::VarDecl *decl) { - return std::format("DestructibleUnsafe::destroy(&raw mut " - "*std::cell::LazyCell::force_mut(&mut *&raw mut {}))", + return std::format("DestructibleUnsafe::destroy(" + "std::cell::LazyCell::force_mut(&mut *&raw mut {}))", GetNamedDeclAsString(decl)); } @@ -762,10 +762,11 @@ void Converter::EmitScopedDestructor(const clang::VarDecl *decl) { if (!NeedsScopedDestructor(decl)) { return; } - StrCat(token::kSemiColon, - std::format("let _dtor_{0} = std::mem::DropGuard::new(&raw mut {0}, " - "|__p| unsafe {{ DestructibleUnsafe::destroy(__p) }})", - GetNamedDeclAsString(decl))); + StrCat( + token::kSemiColon, + std::format("let _dtor_{0} = std::mem::DropGuard::new(&raw mut {0}, " + "|__p| unsafe {{ DestructibleUnsafe::destroy(&mut *__p) }})", + GetNamedDeclAsString(decl))); } bool Converter::RecordDerivesDefault(const clang::RecordDecl *decl) { @@ -1049,24 +1050,13 @@ void Converter::ConvertCXXRecordMethods(clang::CXXRecordDecl *decl) { decl, std::format("{} {}", keyword::kImpl, GetRecordName(decl)), IsEmittableMethod); ConvertCopyOrMoveTraitImpls(decl, IsEmittableMethod); - - if (GetUserDefinedDestructor(decl) || !HasFieldsNeedingDestruction(decl)) { - return; - } - StrCat(keyword::kImpl, GetRecordName(decl)); - PushBrace impl_brace(*this); - StrCat(keyword::kPub, keyword_unsafe_, keyword::kFn, kDestructorName, - "(&mut self)"); - PushBrace fn_brace(*this); - StrCat(DestroyMembers(decl)); } std::string Converter::DestroyMembers(const clang::CXXRecordDecl *decl) { std::string out; for (auto *field : FieldsToDestroy(decl)) { auto name = GetNamedDeclAsString(field); - out += - std::format("DestructibleUnsafe::destroy(&raw mut self.{});\n", name); + out += std::format("DestructibleUnsafe::destroy(&mut self.{});\n", name); } return out; } @@ -1222,12 +1212,12 @@ bool Converter::ConvertOutOfLineMethod(clang::CXXMethodDecl *decl) { } std::string Converter::GetMethodName(const clang::CXXMethodDecl *decl) { - if (clang::isa(decl)) { - return kDestructorName; - } if (auto *trait = GetRecordTrait(decl)) { return trait->method; } + if (clang::isa(decl)) { + return kDestructorName; + } if (const char *name = GetCopyOrMoveName(decl); name && CanUseCopyOrMoveName(decl, name)) { return name; @@ -4415,10 +4405,10 @@ bool Converter::VisitCXXDeleteExpr(clang::CXXDeleteExpr *expr) { StrCat( std::format("for __i in (0..libcc2rs::malloc_usable_size(__p as *mut " "::libc::c_void) / ::std::mem::size_of::<{0}>()).rev() {{ " - "DestructibleUnsafe::destroy(__p.add(__i)); }}", + "DestructibleUnsafe::destroy(&mut *__p.add(__i)); }}", record_name)); } else { - StrCat("DestructibleUnsafe::destroy(__p)", token::kSemiColon); + StrCat("DestructibleUnsafe::destroy(&mut *__p)", token::kSemiColon); } EmitDeallocation(expr, "__p"); return false; @@ -5013,8 +5003,12 @@ std::string Converter::GetRecordName(const clang::NamedDecl *decl) const { std::vector Converter::GetStructAttributes(const clang::RecordDecl *decl) { if (decl->isUnion()) { - std::vector union_attrs = { - "Copy", "Clone", "FnPtrArg", "VaArg", "ZeroInitializationUnsafe"}; + std::vector union_attrs = {"Copy", + "Clone", + "FnPtrArg", + "VaArg", + "ZeroInitializationUnsafe", + "DestructibleUnsafe"}; AddCopyAndMoveDerives(decl, union_attrs); return union_attrs; } @@ -5040,7 +5034,8 @@ Converter::GetStructAttributes(const clang::RecordDecl *decl) { } if (auto *cxx = clang::dyn_cast(decl); - cxx && RecordNeedsDestruction(cxx)) { + !cxx || + (!HasUserProvidedDestructor(cxx) && !HasFieldsNeedingDestruction(cxx))) { struct_attrs.emplace_back("DestructibleUnsafe"); } @@ -5323,7 +5318,8 @@ void Converter::ConvertVirtualMethods(clang::CXXRecordDecl *decl) { bool any = false; Buffer buf(*this); for (auto *method : decl->methods()) { - if (!method->isImplicit() && method->isVirtual()) { + if (!method->isImplicit() && method->isVirtual() && + !GetRecordTrait(method)) { any = true; VisitCXXMethodDecl(method); } diff --git a/cpp2rust/converter/converter_lib.cpp b/cpp2rust/converter/converter_lib.cpp index a04dc69e55..8005d271b6 100644 --- a/cpp2rust/converter/converter_lib.cpp +++ b/cpp2rust/converter/converter_lib.cpp @@ -608,7 +608,7 @@ static bool IsTranslatedMoveAssignment(const clang::CXXMethodDecl *method); static bool IsTranslatedCopyOrMove(const clang::CXXMethodDecl *method) { if (auto *ctor = clang::dyn_cast(method)) { - return IsConvertedConstructor(ctor) && ctor->hasBody(); + return IsConvertibleCopyOrMoveConstructor(ctor); } return method->isCopyAssignmentOperator() ? IsTranslatedCopyAssignment(method) @@ -617,6 +617,11 @@ static bool IsTranslatedCopyOrMove(const clang::CXXMethodDecl *method) { const RecordTrait *GetRecordTrait(const clang::CXXMethodDecl *method) { method = method->getCanonicalDecl(); + if (auto *dtor = clang::dyn_cast(method)) { + return IsConvertedDestructor(dtor) && !dtor->getParent()->isAbstract() + ? &kDestructible + : nullptr; + } const char *name = GetCopyOrMoveName(method); if (!name || method->isDeleted() || method->isVirtual() || !CanUseCopyOrMoveName(method, name) || !IsTranslatedCopyOrMove(method)) { @@ -964,8 +969,8 @@ bool IsConvertibleCXXRecordDecl(const clang::CXXRecordDecl *decl) { } bool IsConvertibleCXXMethodDecl(const clang::CXXMethodDecl *decl) { - if (llvm::isa(decl)) { - return GetUserDefinedDestructor(decl->getParent()) != nullptr; + if (auto *dtor = llvm::dyn_cast(decl)) { + return IsConvertedDestructor(dtor); } return !decl->isImplicit() || IsComparisonOperator(decl) || IsConvertibleImplicitMember(decl); @@ -1802,6 +1807,24 @@ GetUserDefinedDestructor(const clang::CXXRecordDecl *decl) { return dtor; } +bool IsConvertedDestructor(const clang::CXXDestructorDecl *dtor) { + auto *parent = dtor->getParent(); + if (auto *user = GetUserDefinedDestructor(parent)) { + return user->getCanonicalDecl() == dtor->getCanonicalDecl(); + } + return !dtor->isUserProvided() && !dtor->isDeleted() && dtor->hasBody() && + IsUserDefinedDecl(parent) && HasFieldsNeedingDestruction(parent); +} + +bool HasUserProvidedDestructor(const clang::CXXRecordDecl *decl) { + auto *dtor = decl->getDestructor(); + if (!IsUserDefinedDecl(decl) || !dtor || !dtor->isUserProvided()) { + return false; + } + auto *definition = dtor->getDefinition(); + return !definition || !definition->isDefaulted(); +} + bool TypeNeedsDestruction(clang::QualType type) { if (type->isArrayType()) { type = clang::QualType(type->getBaseElementTypeUnsafe(), 0); @@ -1908,6 +1931,13 @@ void DefineImplicitMembers(clang::Sema &sema, clang::CXXRecordDecl *decl) { }); } } + if (auto *dtor = decl->getDestructor(); + dtor && !dtor->isUserProvided() && + !dtor->doesThisDeclarationHaveABody() && !dtor->isDeleted() && + HasFieldsNeedingDestruction(decl)) { + define(dtor, + [&] { sema.DefineImplicitDestructor(decl->getLocation(), dtor); }); + } for (auto *method : decl->methods()) { if (method->isMoveAssignmentOperator() && !method->isUserProvided() && !method->doesThisDeclarationHaveABody() && !method->isDeleted() && @@ -1952,8 +1982,8 @@ bool IsEmittableMethod(clang::CXXMethodDecl *method) { if (method->isDeleted()) { return false; } - if (clang::isa(method)) { - return GetUserDefinedDestructor(method->getParent()) && + if (auto *dtor = clang::dyn_cast(method)) { + return IsConvertedDestructor(dtor) && method->isThisDeclarationADefinition(); } // Virtual methods go into the base trait impl diff --git a/cpp2rust/converter/converter_lib.h b/cpp2rust/converter/converter_lib.h index b7c4082cdc..6774919326 100644 --- a/cpp2rust/converter/converter_lib.h +++ b/cpp2rust/converter/converter_lib.h @@ -120,6 +120,8 @@ inline constexpr RecordTrait kCopyAssignable{ inline constexpr RecordTrait kMoveAssignable{ "MoveAssignable", "MoveAssignableUnsafe", "move_assign"}; inline constexpr RecordTrait kSwappable{"Swappable", "SwappableUnsafe", "swap"}; +inline constexpr RecordTrait kDestructible{"Destructible", "DestructibleUnsafe", + "destroy"}; inline constexpr RecordTrait kCopyable{"Copyable", "CopyableUnsafe", nullptr}; const RecordTrait *GetRecordTrait(const clang::CXXMethodDecl *method); @@ -307,6 +309,10 @@ bool IsSameTypeComparison(const clang::FunctionDecl *fn, clang::CXXDestructorDecl * GetUserDefinedDestructor(const clang::CXXRecordDecl *decl); +bool IsConvertedDestructor(const clang::CXXDestructorDecl *dtor); + +bool HasUserProvidedDestructor(const clang::CXXRecordDecl *decl); + bool TypeNeedsDestruction(clang::QualType type); bool HasFieldsNeedingDestruction(const clang::CXXRecordDecl *decl); diff --git a/cpp2rust/converter/models/converter_refcount.cpp b/cpp2rust/converter/models/converter_refcount.cpp index e3864a0cff..41277504b8 100644 --- a/cpp2rust/converter/models/converter_refcount.cpp +++ b/cpp2rust/converter/models/converter_refcount.cpp @@ -984,14 +984,14 @@ void ConverterRefCount::EmitScopedDestructor(const clang::VarDecl *decl) { } StrCat(token::kSemiColon, std::format("let _dtor_{0} = std::mem::DropGuard::new({0}.clone(), " - "|__p| Destructible::destroy(__p.as_pointer()))", + "|__p| Destructible::destroy(&__p.as_pointer()))", GetNamedDeclAsString(decl))); } std::string ConverterRefCount::StaticDestructorCall(const clang::VarDecl *decl) { return std::format( - "Destructible::destroy({}.with(Value::clone).as_pointer())", + "Destructible::destroy(&{}.with(Value::clone).as_pointer())", GetNamedDeclAsString(decl)); } @@ -2085,9 +2085,9 @@ bool ConverterRefCount::VisitCXXDeleteExpr(clang::CXXDeleteExpr *expr) { token::kSemiColon); if (expr->isArrayForm()) { StrCat("for __i in (0..__p.len()).rev() { " - "Destructible::destroy(__p.offset(__i as isize)); }"); + "Destructible::destroy(&__p.offset(__i as isize)); }"); } else { - StrCat("Destructible::destroy(__p.clone());"); + StrCat("Destructible::destroy(&__p);"); } StrCat("__p.delete();"); return false; @@ -2328,7 +2328,8 @@ ConverterRefCount::GetStructAttributes(const clang::RecordDecl *decl) { std::vector attrs; if (decl->isUnion()) { - std::vector union_attrs = {"VaArg", "FnPtrArg"}; + std::vector union_attrs = {"VaArg", "FnPtrArg", + "Destructible"}; AddCopyAndMoveDerives(decl, union_attrs); return union_attrs; } @@ -2357,7 +2358,8 @@ ConverterRefCount::GetStructAttributes(const clang::RecordDecl *decl) { } if (auto *cxx = clang::dyn_cast(decl); - cxx && RecordNeedsDestruction(cxx)) { + !cxx || + (!HasUserProvidedDestructor(cxx) && !HasFieldsNeedingDestruction(cxx))) { attrs.emplace_back("Destructible"); } @@ -3757,20 +3759,13 @@ void ConverterRefCount::ConvertCXXRecordMethods(clang::CXXRecordDecl *decl) { } }); ConvertCopyOrMoveTraitImpls(decl, IsEmittableMethod); - - if (!GetUserDefinedDestructor(decl) && HasFieldsNeedingDestruction(decl)) { - MethodsOnPtrFor(decl).trait.body += - std::format("fn {}(&self);\n", kDestructorName); - MethodsOnPtrFor(decl).impl.body += std::format( - "fn {}(&self) {{ {} }}\n", kDestructorName, DestroyMembers(decl)); - } } std::string ConverterRefCount::DestroyMembers(const clang::CXXRecordDecl *decl) { std::string out; for (auto *field : FieldsToDestroy(decl)) { - out += std::format("Destructible::destroy(field_ptr!(self, {}));\n", + out += std::format("Destructible::destroy(&field_ptr!(this, {}));\n", GetNamedDeclAsString(field)); } return out; From 07965b1461c9dff6b17bf88df498982695cbb3b6 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Mon, 30 Nov 2026 22:16:02 +0000 Subject: [PATCH 16/20] Fix aliasing error --- rules/algorithm/tgt_unsafe.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rules/algorithm/tgt_unsafe.rs b/rules/algorithm/tgt_unsafe.rs index 01d92aaa73..9bdfe6a5e6 100644 --- a/rules/algorithm/tgt_unsafe.rs +++ b/rules/algorithm/tgt_unsafe.rs @@ -82,7 +82,9 @@ unsafe fn f8, T2: PartialOrd>(a0: T1, a1: T1) -> } unsafe fn f9(a0: *mut T1, a1: *mut T1) { - SwappableUnsafe::swap(&mut *(a0), a1) + let __a: *mut T1 = a0; + let __b: *mut T1 = a1; + SwappableUnsafe::swap(&mut *__a, __b) } unsafe fn f10, T2: PartialEq + Clone>(a0: T1, a1: T1) -> T1 { From 869847f81fe8cdb9ddcd345336162078ed9ce4f5 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Mon, 30 Nov 2026 22:21:37 +0000 Subject: [PATCH 17/20] Fix derive of destructible --- .../converter/models/converter_refcount.cpp | 2 +- .../refcount/out_of_line_methods_cross_tu.rs | 13 +- .../unsafe/out_of_line_methods_cross_tu.rs | 11 +- tests/std/basic/out/refcount/basic.def.odr.rs | 36 ++-- tests/std/basic/out/unsafe/basic.def.odr.rs | 36 ++-- .../unit/out/refcount/copy_move_defaulted.rs | 14 +- tests/unit/out/unsafe/copy_move_defaulted.rs | 11 +- tests/unit/out/unsafe/swap_malloc.rs | 54 ++++-- tests/unit/out/unsafe/swap_map_no_copy.rs | 159 +++++++++++++----- 9 files changed, 198 insertions(+), 138 deletions(-) diff --git a/cpp2rust/converter/models/converter_refcount.cpp b/cpp2rust/converter/models/converter_refcount.cpp index 41277504b8..1366c3e995 100644 --- a/cpp2rust/converter/models/converter_refcount.cpp +++ b/cpp2rust/converter/models/converter_refcount.cpp @@ -3574,7 +3574,7 @@ std::string ConverterRefCount::ConvertPointeeType(clang::QualType ptr_type) { bool ConverterRefCount::ShouldConvertMethod(const clang::CXXMethodDecl *decl) { if (clang::isa(decl)) { - return IsMethodOnPtr(decl); + return GetRecordTrait(decl) != nullptr; } return Converter::ShouldConvertMethod(decl); } diff --git a/tests/multi-file/out_of_line_methods_cross_tu/out/refcount/out_of_line_methods_cross_tu.rs b/tests/multi-file/out_of_line_methods_cross_tu/out/refcount/out_of_line_methods_cross_tu.rs index 1212e72099..45d1c8f147 100644 --- a/tests/multi-file/out_of_line_methods_cross_tu/out/refcount/out_of_line_methods_cross_tu.rs +++ b/tests/multi-file/out_of_line_methods_cross_tu/out/refcount/out_of_line_methods_cross_tu.rs @@ -6,18 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - Destructible, - Copyable, - Default, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/multi-file/out_of_line_methods_cross_tu/out/unsafe/out_of_line_methods_cross_tu.rs b/tests/multi-file/out_of_line_methods_cross_tu/out/unsafe/out_of_line_methods_cross_tu.rs index 824aa06898..f017cf1376 100644 --- a/tests/multi-file/out_of_line_methods_cross_tu/out/unsafe/out_of_line_methods_cross_tu.rs +++ b/tests/multi-file/out_of_line_methods_cross_tu/out/unsafe/out_of_line_methods_cross_tu.rs @@ -7,16 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - CopyableUnsafe, - Default, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] pub struct S { pub v: i32, } diff --git a/tests/std/basic/out/refcount/basic.def.odr.rs b/tests/std/basic/out/refcount/basic.def.odr.rs index 0195376e43..65a72c4497 100644 --- a/tests/std/basic/out/refcount/basic.def.odr.rs +++ b/tests/std/basic/out/refcount/basic.def.odr.rs @@ -526,6 +526,12 @@ pub struct p6_unevaluated_binding_needs_no_capture_HasTwoMembers { #[byte_size(4)] pub b: LifetimeTracked, } +impl Destructible for p6_unevaluated_binding_needs_no_capture_HasTwoMembers { + fn destroy(this: &Ptr) { + Destructible::destroy(&field_ptr!(this, b)); + Destructible::destroy(&field_ptr!(this, a)); + } +} impl CopyAssignable for p6_unevaluated_binding_needs_no_capture_HasTwoMembers { fn copy_assign( this: &Ptr, @@ -536,12 +542,6 @@ impl CopyAssignable for p6_unevaluated_binding_needs_no_capture_HasTwoMembers { return (*this).clone(); } } -impl Destructible for p6_unevaluated_binding_needs_no_capture_HasTwoMembers { - fn destroy(this: &Ptr) { - Destructible::destroy(&field_ptr!(this, b)); - Destructible::destroy(&field_ptr!(this, a)); - } -} pub fn test_20() { ({ LifetimeTracked::reset() }); let p: Value = Rc::new(RefCell::new( @@ -594,6 +594,11 @@ pub struct p7_member_access_captures_this_HasMemberUsedInLambda { #[offset(4)] pub n: i32, } +impl Destructible for p7_member_access_captures_this_HasMemberUsedInLambda { + fn destroy(this: &Ptr) { + Destructible::destroy(&field_ptr!(this, x)); + } +} impl CopyAssignable for p7_member_access_captures_this_HasMemberUsedInLambda { fn copy_assign( this: &Ptr, @@ -604,11 +609,6 @@ impl CopyAssignable for p7_member_access_captures_this_HasMemberUsedInLambda { return (*this).clone(); } } -impl Destructible for p7_member_access_captures_this_HasMemberUsedInLambda { - fn destroy(this: &Ptr) { - Destructible::destroy(&field_ptr!(this, x)); - } -} impl Default for p7_member_access_captures_this_HasMemberUsedInLambda { fn default() -> Self { { @@ -656,6 +656,11 @@ pub struct p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda { #[byte_size(4)] pub x: LifetimeTracked, } +impl Destructible for p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda { + fn destroy(this: &Ptr) { + Destructible::destroy(&field_ptr!(this, x)); + } +} impl CopyAssignable for p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda { fn copy_assign( this: &Ptr, @@ -665,11 +670,6 @@ impl CopyAssignable for p7_unevaluated_this_needs_no_capture_HasMemberUsedInLamb return (*this).clone(); } } -impl Destructible for p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda { - fn destroy(this: &Ptr) { - Destructible::destroy(&field_ptr!(this, x)); - } -} pub fn test_23() { ({ LifetimeTracked::reset() }); let c: Value = Rc::new( @@ -709,9 +709,7 @@ pub fn test_26() { thread_local!( pub static t_ctors_27: Value = Rc::new(RefCell::new(0_i32)); ); -#[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, -)] +#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable)] #[byte_size(1)] pub struct p9_destructor_not_potentially_invoked_HasUndefinedDestructor {} impl Default for p9_destructor_not_potentially_invoked_HasUndefinedDestructor { diff --git a/tests/std/basic/out/unsafe/basic.def.odr.rs b/tests/std/basic/out/unsafe/basic.def.odr.rs index efad10ac47..47d9501fcc 100644 --- a/tests/std/basic/out/unsafe/basic.def.odr.rs +++ b/tests/std/basic/out/unsafe/basic.def.odr.rs @@ -479,6 +479,12 @@ pub struct p6_unevaluated_binding_needs_no_capture_HasTwoMembers { pub a: LifetimeTracked, pub b: LifetimeTracked, } +impl DestructibleUnsafe for p6_unevaluated_binding_needs_no_capture_HasTwoMembers { + unsafe fn destroy(&mut self) { + DestructibleUnsafe::destroy(&mut self.b); + DestructibleUnsafe::destroy(&mut self.a); + } +} impl CopyAssignableUnsafe for p6_unevaluated_binding_needs_no_capture_HasTwoMembers { unsafe fn copy_assign( &mut self, @@ -495,12 +501,6 @@ impl CopyAssignableUnsafe for p6_unevaluated_binding_needs_no_capture_HasTwoMemb return &mut (*(self as *mut p6_unevaluated_binding_needs_no_capture_HasTwoMembers)); } } -impl DestructibleUnsafe for p6_unevaluated_binding_needs_no_capture_HasTwoMembers { - unsafe fn destroy(&mut self) { - DestructibleUnsafe::destroy(&mut self.b); - DestructibleUnsafe::destroy(&mut self.a); - } -} pub unsafe fn test_20() { (unsafe { LifetimeTracked::reset() }); let mut p: p6_unevaluated_binding_needs_no_capture_HasTwoMembers = @@ -559,6 +559,11 @@ impl p7_member_access_captures_this_HasMemberUsedInLambda { ); } } +impl DestructibleUnsafe for p7_member_access_captures_this_HasMemberUsedInLambda { + unsafe fn destroy(&mut self) { + DestructibleUnsafe::destroy(&mut self.x); + } +} impl CopyAssignableUnsafe for p7_member_access_captures_this_HasMemberUsedInLambda { unsafe fn copy_assign( &mut self, @@ -572,11 +577,6 @@ impl CopyAssignableUnsafe for p7_member_access_captures_this_HasMemberUsedInLamb return &mut (*(self as *mut p7_member_access_captures_this_HasMemberUsedInLambda)); } } -impl DestructibleUnsafe for p7_member_access_captures_this_HasMemberUsedInLambda { - unsafe fn destroy(&mut self) { - DestructibleUnsafe::destroy(&mut self.x); - } -} impl Default for p7_member_access_captures_this_HasMemberUsedInLambda { fn default() -> Self { unsafe { @@ -628,6 +628,11 @@ impl p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda { }); } } +impl DestructibleUnsafe for p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda { + unsafe fn destroy(&mut self) { + DestructibleUnsafe::destroy(&mut self.x); + } +} impl CopyAssignableUnsafe for p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda { unsafe fn copy_assign( &mut self, @@ -640,11 +645,6 @@ impl CopyAssignableUnsafe for p7_unevaluated_this_needs_no_capture_HasMemberUsed return &mut (*(self as *mut p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda)); } } -impl DestructibleUnsafe for p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda { - unsafe fn destroy(&mut self) { - DestructibleUnsafe::destroy(&mut self.x); - } -} pub unsafe fn test_23() { (unsafe { LifetimeTracked::reset() }); let mut c: p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda = @@ -681,9 +681,7 @@ pub unsafe fn test_26() { } pub static mut t_ctors_27: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0_i32 }); #[repr(C)] -#[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, -)] +#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe)] pub struct p9_destructor_not_potentially_invoked_HasUndefinedDestructor {} impl p9_destructor_not_potentially_invoked_HasUndefinedDestructor { pub unsafe fn construct(&mut self) { diff --git a/tests/unit/out/refcount/copy_move_defaulted.rs b/tests/unit/out/refcount/copy_move_defaulted.rs index 714ed96a1e..ae94d0c5e3 100644 --- a/tests/unit/out/refcount/copy_move_defaulted.rs +++ b/tests/unit/out/refcount/copy_move_defaulted.rs @@ -23,18 +23,7 @@ pub struct Inner { #[offset(0)] pub x: i32, } -#[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - CopyAssignable, - MoveAssignable, - Swappable, -)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable)] #[cpp_from(i32, construct, value)] #[byte_size(16)] pub struct Explicit { @@ -90,6 +79,7 @@ impl Default for Implicit { FnPtrArg, CppFrom, Destructible, + CopyConstructible, CopyAssignable, Swappable, Default, diff --git a/tests/unit/out/unsafe/copy_move_defaulted.rs b/tests/unit/out/unsafe/copy_move_defaulted.rs index dad754d0b4..d2300550dd 100644 --- a/tests/unit/out/unsafe/copy_move_defaulted.rs +++ b/tests/unit/out/unsafe/copy_move_defaulted.rs @@ -22,15 +22,7 @@ pub struct Inner { } #[repr(C)] #[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - CopyAssignableUnsafe, - MoveAssignableUnsafe, - SwappableUnsafe, - Default, + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, )] #[cpp_from(i32, construct, value)] pub struct Explicit { @@ -73,6 +65,7 @@ pub struct Implicit { ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, + CopyConstructibleUnsafe, CopyAssignableUnsafe, SwappableUnsafe, Default, diff --git a/tests/unit/out/unsafe/swap_malloc.rs b/tests/unit/out/unsafe/swap_malloc.rs index 4fe49969c9..651cd66930 100644 --- a/tests/unit/out/unsafe/swap_malloc.rs +++ b/tests/unit/out/unsafe/swap_malloc.rs @@ -19,47 +19,73 @@ unsafe fn main_0() -> i32 { (*buf.offset((0) as isize)) = 1; (*buf.offset((1) as isize)) = 2; (*buf.offset((2) as isize)) = 3; - SwappableUnsafe::swap(&mut *(buf.offset((0) as isize)), buf.offset((2) as isize)); + { + let __a: *mut i32 = buf.offset((0) as isize); + let __b: *mut i32 = buf.offset((2) as isize); + SwappableUnsafe::swap(&mut *__a, __b) + }; assert!( (((*buf.offset((0) as isize)) == (3)) && ((*buf.offset((1) as isize)) == (2))) && ((*buf.offset((2) as isize)) == (1)) ); - SwappableUnsafe::swap(&mut *(buf.offset((1) as isize)), buf.offset((1) as isize)); + { + let __a: *mut i32 = buf.offset((1) as isize); + let __b: *mut i32 = buf.offset((1) as isize); + SwappableUnsafe::swap(&mut *__a, __b) + }; assert!(((*buf.offset((1) as isize)) == (2))); let mut local: i32 = 4; - SwappableUnsafe::swap(&mut *(buf.offset((1) as isize)), &mut local); + { + let __a: *mut i32 = buf.offset((1) as isize); + let __b: *mut i32 = &mut local; + SwappableUnsafe::swap(&mut *__a, __b) + }; assert!(((*buf.offset((1) as isize)) == (4)) && ((local) == (2))); let mut other: *mut i32 = ((libcc2rs::malloc_unsafe(::std::mem::size_of::())) as *mut i32); (*other) = 5; - SwappableUnsafe::swap(&mut *(buf), other); + { + let __a: *mut i32 = buf; + let __b: *mut i32 = other; + SwappableUnsafe::swap(&mut *__a, __b) + }; assert!(((*buf.offset((0) as isize)) == (5)) && ((*other) == (3))); let mut bytes: *mut u8 = (buf as *mut u8); (*bytes.offset((0) as isize)) = 170_u8; (*bytes.offset((4) as isize)) = 187_u8; - SwappableUnsafe::swap( - &mut *(bytes.offset((0) as isize)), - bytes.offset((4) as isize), - ); + { + let __a: *mut u8 = bytes.offset((0) as isize); + let __b: *mut u8 = bytes.offset((4) as isize); + SwappableUnsafe::swap(&mut *__a, __b) + }; assert!( (((*bytes.offset((0) as isize)) as i32) == (187)) && (((*bytes.offset((4) as isize)) as i32) == (170)) ); let mut words: [u32; 2] = [16909060_u32, 84281096_u32]; let mut halves: *mut u16 = (words.as_mut_ptr() as *mut u16); - SwappableUnsafe::swap( - &mut *(halves.offset((0) as isize)), - halves.offset((3) as isize), - ); + { + let __a: *mut u16 = halves.offset((0) as isize); + let __b: *mut u16 = halves.offset((3) as isize); + SwappableUnsafe::swap(&mut *__a, __b) + }; assert!(((words[(0) as usize]) == (16909574_u32)) && ((words[(1) as usize]) == (50595592_u32))); let mut s1: i32 = 1; let mut s2: i32 = 2; let mut sp: *mut i32 = (&mut s1 as *mut i32); let mut sq: *mut i32 = (&mut s2 as *mut i32); - SwappableUnsafe::swap(&mut *(&mut sp), &mut sq); + { + let __a: *mut *mut i32 = &mut sp; + let __b: *mut *mut i32 = &mut sq; + SwappableUnsafe::swap(&mut *__a, __b) + }; assert!(((sp) == (&mut s2 as *mut i32)) && ((sq) == (&mut s1 as *mut i32))); assert!(((s1) == (1)) && ((s2) == (2))); let mut null_ptr: *mut i32 = std::ptr::null_mut(); - SwappableUnsafe::swap(&mut *(&mut null_ptr), &mut sp); + { + let __a: *mut *mut i32 = &mut null_ptr; + let __b: *mut *mut i32 = &mut sp; + SwappableUnsafe::swap(&mut *__a, __b) + }; assert!(((null_ptr) == (&mut s2 as *mut i32)) && ((sp).is_null())); libcc2rs::free_unsafe((other as *mut ::libc::c_void)); libcc2rs::free_unsafe((buf as *mut ::libc::c_void)); diff --git a/tests/unit/out/unsafe/swap_map_no_copy.rs b/tests/unit/out/unsafe/swap_map_no_copy.rs index 6a89f43e3d..9718b3382c 100644 --- a/tests/unit/out/unsafe/swap_map_no_copy.rs +++ b/tests/unit/out/unsafe/swap_map_no_copy.rs @@ -459,7 +459,11 @@ unsafe fn main_0() -> i32 { Tracked::construct_1(&mut __v, { 2 }); __v }; - SwappableUnsafe::swap(&mut *(&mut a), &mut b); + { + let __a: *mut Tracked = &mut a; + let __b: *mut Tracked = &mut b; + SwappableUnsafe::swap(&mut *__a, __b) + }; assert!(((a.v) == (2)) && ((b.v) == (1))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (0))); let mut m1: UnsafeMap = UnsafeMap::new(); @@ -498,14 +502,13 @@ unsafe fn main_0() -> i32 { ) }); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (0))); - SwappableUnsafe::swap( - &mut *(&mut (*m1.subscript_move( - &mut 1, - |__k| cpp_move_unsafe!(__k), - || ::default(), - ))), - &mut (*m1.subscript_move(&mut 2, |__k| cpp_move_unsafe!(__k), || ::default())), - ); + { + let __a: *mut Tracked = + &mut (*m1.subscript_move(&mut 1, |__k| cpp_move_unsafe!(__k), || ::default())); + let __b: *mut Tracked = + &mut (*m1.subscript_move(&mut 2, |__k| cpp_move_unsafe!(__k), || ::default())); + SwappableUnsafe::swap(&mut *__a, __b) + }; assert!( (((*m1.subscript_move(&mut 1, |__k| cpp_move_unsafe!(__k), || ::default())).v) == (20)) @@ -517,7 +520,11 @@ unsafe fn main_0() -> i32 { .v) == (10)) ); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (0))); - SwappableUnsafe::swap(&mut *(&mut m1), &mut m2); + { + let __a: *mut UnsafeMap = &mut m1; + let __b: *mut UnsafeMap = &mut m2; + SwappableUnsafe::swap(&mut *__a, __b) + }; assert!( ((m1.len()) == (1_usize)) && (((*m1.subscript_move( @@ -560,9 +567,17 @@ unsafe fn main_0() -> i32 { __v }, ]; - SwappableUnsafe::swap(&mut *(&mut arr[(0) as usize]), &mut arr[(2) as usize]); + { + let __a: *mut Tracked = &mut arr[(0) as usize]; + let __b: *mut Tracked = &mut arr[(2) as usize]; + SwappableUnsafe::swap(&mut *__a, __b) + }; assert!(((arr[(0) as usize].v) == (3)) && ((arr[(2) as usize].v) == (1))); - SwappableUnsafe::swap(&mut *(&mut arr[(1) as usize]), &mut arr[(1) as usize]); + { + let __a: *mut Tracked = &mut arr[(1) as usize]; + let __b: *mut Tracked = &mut arr[(1) as usize]; + SwappableUnsafe::swap(&mut *__a, __b) + }; assert!(((arr[(1) as usize].v) == (2))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (0))); let mut vec_: Vec = Vec::new(); @@ -576,7 +591,11 @@ unsafe fn main_0() -> i32 { Tracked::construct_1(&mut __v, { 5 }); __v }); - SwappableUnsafe::swap(&mut *(&mut vec_[(0_usize)]), &mut vec_[(1_usize)]); + { + let __a: *mut Tracked = &mut vec_[(0_usize)]; + let __b: *mut Tracked = &mut vec_[(1_usize)]; + SwappableUnsafe::swap(&mut *__a, __b) + }; assert!(((vec_[(0_usize)].v) == (5)) && ((vec_[(1_usize)].v) == (4))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (0))); let mut pairs: [Pair; 2] = [ @@ -617,31 +636,46 @@ unsafe fn main_0() -> i32 { __v }, }; - SwappableUnsafe::swap(&mut *(&mut pairs[(0) as usize].x), &mut p.y); + { + let __a: *mut Tracked = &mut pairs[(0) as usize].x; + let __b: *mut Tracked = &mut p.y; + SwappableUnsafe::swap(&mut *__a, __b) + }; assert!(((pairs[(0) as usize].x.v) == (11)) && ((p.y.v) == (6))); - SwappableUnsafe::swap(&mut *(&mut pairs[(0) as usize]), &mut pairs[(1) as usize]); + { + let __a: *mut Pair = &mut pairs[(0) as usize]; + let __b: *mut Pair = &mut pairs[(1) as usize]; + SwappableUnsafe::swap(&mut *__a, __b) + }; assert!(((pairs[(0) as usize].x.v) == (8)) && ((pairs[(1) as usize].x.v) == (11))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (0))); - SwappableUnsafe::swap(&mut *(&mut p.x), &mut p.y); + { + let __a: *mut Tracked = &mut p.x; + let __b: *mut Tracked = &mut p.y; + SwappableUnsafe::swap(&mut *__a, __b) + }; assert!(((p.x.v) == (6)) && ((p.y.v) == (10))); - SwappableUnsafe::swap( - &mut *(&mut pairs[(0) as usize].x), - &mut pairs[(1) as usize].y, - ); + { + let __a: *mut Tracked = &mut pairs[(0) as usize].x; + let __b: *mut Tracked = &mut pairs[(1) as usize].y; + SwappableUnsafe::swap(&mut *__a, __b) + }; assert!(((pairs[(0) as usize].x.v) == (7)) && ((pairs[(1) as usize].y.v) == (8))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (0))); let mut arrays: Arrays = ::default(); arrays.a[(0) as usize].v = 1; arrays.b[(1) as usize].v = 2; - SwappableUnsafe::swap( - &mut *(&mut arrays.a[(0) as usize]), - &mut arrays.b[(1) as usize], - ); + { + let __a: *mut Tracked = &mut arrays.a[(0) as usize]; + let __b: *mut Tracked = &mut arrays.b[(1) as usize]; + SwappableUnsafe::swap(&mut *__a, __b) + }; assert!(((arrays.a[(0) as usize].v) == (2)) && ((arrays.b[(1) as usize].v) == (1))); - SwappableUnsafe::swap( - &mut *(&mut arrays.a[(0) as usize]), - &mut arrays.a[(1) as usize], - ); + { + let __a: *mut Tracked = &mut arrays.a[(0) as usize]; + let __b: *mut Tracked = &mut arrays.a[(1) as usize]; + SwappableUnsafe::swap(&mut *__a, __b) + }; assert!(((arrays.a[(0) as usize].v) == (0)) && ((arrays.a[(1) as usize].v) == (2))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (0))); let mut grid: Vec> = Vec::from_fn(2_usize, |_| Default::default()); @@ -660,12 +694,17 @@ unsafe fn main_0() -> i32 { Tracked::construct_1(&mut __v, { 3 }); __v }); - SwappableUnsafe::swap( - &mut *(&mut grid[(0_usize)][(1_usize)]), - &mut grid[(1_usize)][(0_usize)], - ); + { + let __a: *mut Tracked = &mut grid[(0_usize)][(1_usize)]; + let __b: *mut Tracked = &mut grid[(1_usize)][(0_usize)]; + SwappableUnsafe::swap(&mut *__a, __b) + }; assert!(((grid[(0_usize)][(1_usize)].v) == (3)) && ((grid[(1_usize)][(0_usize)].v) == (2))); - SwappableUnsafe::swap(&mut *(&mut grid[(0_usize)]), &mut grid[(1_usize)]); + { + let __a: *mut Vec = &mut grid[(0_usize)]; + let __b: *mut Vec = &mut grid[(1_usize)]; + SwappableUnsafe::swap(&mut *__a, __b) + }; assert!(((grid[(0_usize)].len()) == (1_usize)) && ((grid[(0_usize)][(0_usize)].v) == (2))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (0))); let mut maps: [UnsafeMap; 2] = @@ -700,7 +739,11 @@ unsafe fn main_0() -> i32 { &mut _o, ) }); - SwappableUnsafe::swap(&mut *(&mut maps[(0) as usize]), &mut maps[(1) as usize]); + { + let __a: *mut UnsafeMap = &mut maps[(0) as usize]; + let __b: *mut UnsafeMap = &mut maps[(1) as usize]; + SwappableUnsafe::swap(&mut *__a, __b) + }; assert!( ((maps[(0) as usize].len()) == (1_usize)) && (((*maps[(0) as usize].subscript_move( @@ -736,7 +779,11 @@ unsafe fn main_0() -> i32 { let _dtor_c2 = std::mem::DropGuard::new(&raw mut c2, |__p| unsafe { DestructibleUnsafe::destroy(&mut *__p) }); - SwappableUnsafe::swap(&mut *(&mut c1), &mut c2); + { + let __a: *mut CopyOnly = &mut c1; + let __b: *mut CopyOnly = &mut c2; + SwappableUnsafe::swap(&mut *__a, __b) + }; assert!(((c1.v) == (2)) && ((c2.v) == (1))); assert!( ((*std::cell::LazyCell::force_mut(&mut *&raw mut copy_only_copies_1)) == (3)) @@ -757,7 +804,11 @@ unsafe fn main_0() -> i32 { let _dtor_cp = std::mem::DropGuard::new(&raw mut cp, |__p| unsafe { DestructibleUnsafe::destroy(&mut *__p) }); - SwappableUnsafe::swap(&mut *(&mut cp.x), &mut cp.y); + { + let __a: *mut CopyOnly = &mut cp.x; + let __b: *mut CopyOnly = &mut cp.y; + SwappableUnsafe::swap(&mut *__a, __b) + }; assert!(((cp.x.v) == (4)) && ((cp.y.v) == (3))); assert!( ((*std::cell::LazyCell::force_mut(&mut *&raw mut copy_only_copies_1)) == (6)) @@ -775,7 +826,11 @@ unsafe fn main_0() -> i32 { __v }, ]; - SwappableUnsafe::swap(&mut *(&mut carr[(0) as usize]), &mut carr[(1) as usize]); + { + let __a: *mut CopyOnly = &mut carr[(0) as usize]; + let __b: *mut CopyOnly = &mut carr[(1) as usize]; + SwappableUnsafe::swap(&mut *__a, __b) + }; assert!(((carr[(0) as usize].v) == (6)) && ((carr[(1) as usize].v) == (5))); assert!( ((*std::cell::LazyCell::force_mut(&mut *&raw mut copy_only_copies_1)) == (9)) @@ -797,7 +852,11 @@ unsafe fn main_0() -> i32 { let _dtor_mv2 = std::mem::DropGuard::new(&raw mut mv2, |__p| unsafe { DestructibleUnsafe::destroy(&mut *__p) }); - SwappableUnsafe::swap(&mut *(&mut mv1), &mut mv2); + { + let __a: *mut Moved = &mut mv1; + let __b: *mut Moved = &mut mv2; + SwappableUnsafe::swap(&mut *__a, __b) + }; assert!(((mv1.v) == (2)) && ((mv2.v) == (1))); assert!((unsafe { swapped_once_6() })); let mut mp: MovedPair = MovedPair { @@ -815,7 +874,11 @@ unsafe fn main_0() -> i32 { let _dtor_mp = std::mem::DropGuard::new(&raw mut mp, |__p| unsafe { DestructibleUnsafe::destroy(&mut *__p) }); - SwappableUnsafe::swap(&mut *(&mut mp.x), &mut mp.y); + { + let __a: *mut Moved = &mut mp.x; + let __b: *mut Moved = &mut mp.y; + SwappableUnsafe::swap(&mut *__a, __b) + }; assert!(((mp.x.v) == (4)) && ((mp.y.v) == (3))); assert!((unsafe { swapped_once_6() })); let mut marr: [Moved; 2] = [ @@ -830,10 +893,18 @@ unsafe fn main_0() -> i32 { __v }, ]; - SwappableUnsafe::swap(&mut *(&mut marr[(0) as usize]), &mut marr[(1) as usize]); + { + let __a: *mut Moved = &mut marr[(0) as usize]; + let __b: *mut Moved = &mut marr[(1) as usize]; + SwappableUnsafe::swap(&mut *__a, __b) + }; assert!(((marr[(0) as usize].v) == (6)) && ((marr[(1) as usize].v) == (5))); assert!((unsafe { swapped_once_6() })); - SwappableUnsafe::swap(&mut *(&mut mv1), &mut mv1); + { + let __a: *mut Moved = &mut mv1; + let __b: *mut Moved = &mut mv1; + SwappableUnsafe::swap(&mut *__a, __b) + }; assert!(((mv1.v) == (2))); assert!((unsafe { swapped_once_6() })); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (0))); @@ -843,7 +914,11 @@ unsafe fn main_0() -> i32 { let mut o2: Owner = Owner { p: Some(Box::new(2)), }; - SwappableUnsafe::swap(&mut *(&mut o1), &mut o2); + { + let __a: *mut Owner = &mut o1; + let __b: *mut Owner = &mut o2; + SwappableUnsafe::swap(&mut *__a, __b) + }; assert!( ((*o1 .p From 72286c49e266510ee9b8a251085e12a60bf441ce Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Mon, 30 Nov 2026 22:34:59 +0000 Subject: [PATCH 18/20] Add unreachable impl for declared but not defined traits --- cpp2rust/converter/converter.cpp | 41 +++++++++++++++--- cpp2rust/converter/converter.h | 7 +++ cpp2rust/converter/converter_lib.cpp | 27 ++++++++---- cpp2rust/converter/converter_lib.h | 34 +++++++++++---- .../converter/models/converter_refcount.cpp | 4 +- cpp2rust/cpp2rust_lib.cpp | 2 + libcc2rs-macros/src/constructor.rs | 1 - libcc2rs-macros/src/lib.rs | 3 -- libcc2rs/src/constructor.rs | 5 --- .../refcount/out_of_line_methods_cross_tu.rs | 3 -- tests/std/basic/out/refcount/basic.def.odr.rs | 43 ++++++++++++++----- tests/std/basic/out/unsafe/basic.def.odr.rs | 32 +++++++++++++- tests/unit/out/refcount/copy_move_deleted.rs | 13 ++++-- tests/unit/out/unsafe/copy_move_deleted.rs | 10 +++++ 14 files changed, 171 insertions(+), 54 deletions(-) diff --git a/cpp2rust/converter/converter.cpp b/cpp2rust/converter/converter.cpp index 90ad31628a..86cf61efdc 100644 --- a/cpp2rust/converter/converter.cpp +++ b/cpp2rust/converter/converter.cpp @@ -34,6 +34,10 @@ std::unordered_set Converter::globals_; std::vector Converter::global_inits_; Converter::RecordIndex Converter::record_decls_; std::map Converter::virtual_methods_; +std::map> + Converter::declared_record_traits_; +std::set> + Converter::converted_record_traits_; void Converter::EmitFilePreamble() { StrCat(R"( @@ -62,6 +66,31 @@ void Converter::EmitVirtualMethods(std::string &out) { } } +void Converter::EmitUndefinedRecordTraits(Model model, std::string &out) { + bool is_unsafe = model == Model::kUnsafe; + for (const auto &[record, traits] : declared_record_traits_) { + for (const auto &[name, trait] : traits) { + if (converted_record_traits_.contains({record, name})) { + continue; + } + out += std::format( + "impl {} for {} {{ {} {{ unreachable!(\"{}::{} is never defined\") " + "}} }}\n", + is_unsafe ? trait->unsafe_name : trait->name, record, + is_unsafe ? trait->unsafe_signature : trait->signature, record, + trait->method); + } + } +} + +void Converter::DeclareRecordTraits(const clang::CXXRecordDecl *decl) { + for (auto *method : decl->methods()) { + if (auto *trait = GetRecordTrait(method)) { + declared_record_traits_[GetRecordName(decl)].emplace(trait->name, trait); + } + } +} + std::string Converter::ForceGlobalInit(const clang::VarDecl *decl) { return std::format("std::cell::LazyCell::force(&*&raw const {});", GetNamedDeclAsString(decl)); @@ -992,6 +1021,7 @@ void Converter::EmitRustStructOrUnion(clang::RecordDecl *decl) { ConvertCXXRecordMethods(cxx); ConvertVirtualMethods(cxx); AddOrdTrait(cxx); + DeclareRecordTraits(cxx); } AddCloneTrait(decl); AddDefaultTrait(decl); @@ -1039,6 +1069,8 @@ void Converter::ConvertCopyOrMoveTraitImpl(clang::CXXMethodDecl *method, if (body.empty()) { return; } + converted_record_traits_.emplace(GetRecordName(method->getParent()), + trait.name); StrCat(keyword::kImpl, GetCopyOrMoveTraitName(trait), "for", GetRecordName(method->getParent())); PushBrace brace(*this); @@ -5033,9 +5065,7 @@ Converter::GetStructAttributes(const clang::RecordDecl *decl) { struct_attrs.emplace_back("CppFromUnsafe"); } - if (auto *cxx = clang::dyn_cast(decl); - !cxx || - (!HasUserProvidedDestructor(cxx) && !HasFieldsNeedingDestruction(cxx))) { + if (!ImplementsRecordTrait(decl, kDestructible)) { struct_attrs.emplace_back("DestructibleUnsafe"); } @@ -5552,11 +5582,8 @@ void Converter::AddCloneTrait(const clang::RecordDecl *decl) { void Converter::AddCopyAndMoveDerives(const clang::RecordDecl *decl, std::vector &attrs) { - auto *cxx = clang::dyn_cast(decl); auto implements = [&](const RecordTrait *trait) { - return cxx && llvm::any_of(cxx->methods(), [&](auto *method) { - return GetRecordTrait(method) == trait; - }); + return ImplementsRecordTrait(decl, *trait); }; const RecordTrait *traits[] = {&kCopyConstructible, &kMoveConstructible, &kCopyAssignable, &kMoveAssignable}; diff --git a/cpp2rust/converter/converter.h b/cpp2rust/converter/converter.h index 4878f06c41..61afaa0057 100644 --- a/cpp2rust/converter/converter.h +++ b/cpp2rust/converter/converter.h @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -108,6 +109,7 @@ class Converter : public clang::RecursiveASTVisitor { static void EmitGlobalInits(Model model, std::string &out); static void EmitVirtualMethods(std::string &out); + static void EmitUndefinedRecordTraits(Model model, std::string &out); virtual bool VisitBuiltinType(clang::BuiltinType *type); @@ -1270,6 +1272,11 @@ class Converter : public clang::RecursiveASTVisitor { std::string body; }; static std::map virtual_methods_; + static std::map> + declared_record_traits_; + static std::set> converted_record_traits_; + + void DeclareRecordTraits(const clang::CXXRecordDecl *decl); static void EmitDeferredBlock(const DeferredBlock &block, std::string &out); diff --git a/cpp2rust/converter/converter_lib.cpp b/cpp2rust/converter/converter_lib.cpp index 8005d271b6..458905b55d 100644 --- a/cpp2rust/converter/converter_lib.cpp +++ b/cpp2rust/converter/converter_lib.cpp @@ -615,16 +615,26 @@ static bool IsTranslatedCopyOrMove(const clang::CXXMethodDecl *method) { : IsTranslatedMoveAssignment(method); } +static bool IsUserWrittenMember(const clang::CXXMethodDecl *method) { + if (!method->isUserProvided() || !IsUserDefinedDecl(method)) { + return false; + } + auto *definition = method->getDefinition(); + return !definition || !definition->isDefaulted(); +} + const RecordTrait *GetRecordTrait(const clang::CXXMethodDecl *method) { method = method->getCanonicalDecl(); if (auto *dtor = clang::dyn_cast(method)) { - return IsConvertedDestructor(dtor) && !dtor->getParent()->isAbstract() + return (IsUserWrittenMember(dtor) || IsConvertedDestructor(dtor)) && + !dtor->getParent()->isAbstract() ? &kDestructible : nullptr; } const char *name = GetCopyOrMoveName(method); if (!name || method->isDeleted() || method->isVirtual() || - !CanUseCopyOrMoveName(method, name) || !IsTranslatedCopyOrMove(method)) { + !CanUseCopyOrMoveName(method, name) || + (!IsUserWrittenMember(method) && !IsTranslatedCopyOrMove(method))) { return nullptr; } auto *ctor = clang::dyn_cast(method); @@ -1816,13 +1826,12 @@ bool IsConvertedDestructor(const clang::CXXDestructorDecl *dtor) { IsUserDefinedDecl(parent) && HasFieldsNeedingDestruction(parent); } -bool HasUserProvidedDestructor(const clang::CXXRecordDecl *decl) { - auto *dtor = decl->getDestructor(); - if (!IsUserDefinedDecl(decl) || !dtor || !dtor->isUserProvided()) { - return false; - } - auto *definition = dtor->getDefinition(); - return !definition || !definition->isDefaulted(); +bool ImplementsRecordTrait(const clang::RecordDecl *decl, + const RecordTrait &trait) { + auto *cxx = clang::dyn_cast(decl); + return cxx && llvm::any_of(cxx->methods(), [&](auto *method) { + return GetRecordTrait(method) == &trait; + }); } bool TypeNeedsDestruction(clang::QualType type) { diff --git a/cpp2rust/converter/converter_lib.h b/cpp2rust/converter/converter_lib.h index 6774919326..ead5bdc13b 100644 --- a/cpp2rust/converter/converter_lib.h +++ b/cpp2rust/converter/converter_lib.h @@ -109,20 +109,35 @@ struct RecordTrait { const char *name; const char *unsafe_name; const char *method; + const char *signature; + const char *unsafe_signature; }; inline constexpr RecordTrait kCopyConstructible{ - "CopyConstructible", "CopyConstructibleUnsafe", "copy_constructor"}; + "CopyConstructible", "CopyConstructibleUnsafe", "copy_constructor", + "fn copy_constructor(_: &Ptr, _: Ptr)", + "unsafe fn copy_constructor(&mut self, _: *const Self)"}; inline constexpr RecordTrait kMoveConstructible{ - "MoveConstructible", "MoveConstructibleUnsafe", "move_constructor"}; + "MoveConstructible", "MoveConstructibleUnsafe", "move_constructor", + "fn move_constructor(_: &Ptr, _: Ptr)", + "unsafe fn move_constructor(&mut self, _: *mut Self)"}; inline constexpr RecordTrait kCopyAssignable{ - "CopyAssignable", "CopyAssignableUnsafe", "copy_assign"}; + "CopyAssignable", "CopyAssignableUnsafe", "copy_assign", + "fn copy_assign(_: &Ptr, _: Ptr) -> Ptr", + "unsafe fn copy_assign(&mut self, _: *const Self) -> *mut Self"}; inline constexpr RecordTrait kMoveAssignable{ - "MoveAssignable", "MoveAssignableUnsafe", "move_assign"}; -inline constexpr RecordTrait kSwappable{"Swappable", "SwappableUnsafe", "swap"}; -inline constexpr RecordTrait kDestructible{"Destructible", "DestructibleUnsafe", - "destroy"}; -inline constexpr RecordTrait kCopyable{"Copyable", "CopyableUnsafe", nullptr}; + "MoveAssignable", "MoveAssignableUnsafe", "move_assign", + "fn move_assign(_: &Ptr, _: Ptr) -> Ptr", + "unsafe fn move_assign(&mut self, _: *mut Self) -> *mut Self"}; +inline constexpr RecordTrait kSwappable{ + "Swappable", "SwappableUnsafe", "swap", + "fn swap(_: &Ptr, _: Ptr)", + "unsafe fn swap(&mut self, _: *mut Self)"}; +inline constexpr RecordTrait kDestructible{ + "Destructible", "DestructibleUnsafe", "destroy", + "fn destroy(_: &Ptr)", "unsafe fn destroy(&mut self)"}; +inline constexpr RecordTrait kCopyable{"Copyable", "CopyableUnsafe", nullptr, + nullptr, nullptr}; const RecordTrait *GetRecordTrait(const clang::CXXMethodDecl *method); @@ -311,7 +326,8 @@ GetUserDefinedDestructor(const clang::CXXRecordDecl *decl); bool IsConvertedDestructor(const clang::CXXDestructorDecl *dtor); -bool HasUserProvidedDestructor(const clang::CXXRecordDecl *decl); +bool ImplementsRecordTrait(const clang::RecordDecl *decl, + const RecordTrait &trait); bool TypeNeedsDestruction(clang::QualType type); diff --git a/cpp2rust/converter/models/converter_refcount.cpp b/cpp2rust/converter/models/converter_refcount.cpp index 1366c3e995..ad7de51b79 100644 --- a/cpp2rust/converter/models/converter_refcount.cpp +++ b/cpp2rust/converter/models/converter_refcount.cpp @@ -2357,9 +2357,7 @@ ConverterRefCount::GetStructAttributes(const clang::RecordDecl *decl) { attrs.emplace_back("CppFrom"); } - if (auto *cxx = clang::dyn_cast(decl); - !cxx || - (!HasUserProvidedDestructor(cxx) && !HasFieldsNeedingDestruction(cxx))) { + if (!ImplementsRecordTrait(decl, kDestructible)) { attrs.emplace_back("Destructible"); } diff --git a/cpp2rust/cpp2rust_lib.cpp b/cpp2rust/cpp2rust_lib.cpp index ddf4539109..4196e5af85 100644 --- a/cpp2rust/cpp2rust_lib.cpp +++ b/cpp2rust/cpp2rust_lib.cpp @@ -33,6 +33,7 @@ std::string TranspileSrc(std::string_view cc_code, Model model, filename.ends_with(".c") ? CLANG_C_COMPILER : CLANG_CXX_COMPILER); Converter::EmitOpaqueRecords(model, rs_code); Converter::EmitVirtualMethods(rs_code); + Converter::EmitUndefinedRecordTraits(model, rs_code); if (model == Model::kRefCount) { ConverterRefCount::EmitMethodsOnPtr(rs_code); } @@ -78,6 +79,7 @@ std::string TranspileDir(std::string_view build_dir, Model model, Tool.run(&factory); Converter::EmitOpaqueRecords(model, rs_code); Converter::EmitVirtualMethods(rs_code); + Converter::EmitUndefinedRecordTraits(model, rs_code); if (model == Model::kRefCount) { ConverterRefCount::EmitMethodsOnPtr(rs_code); } diff --git a/libcc2rs-macros/src/constructor.rs b/libcc2rs-macros/src/constructor.rs index 7584c2d58e..cbe68c03ea 100644 --- a/libcc2rs-macros/src/constructor.rs +++ b/libcc2rs-macros/src/constructor.rs @@ -29,7 +29,6 @@ pub fn expand_swappable(input: TokenStream, is_unsafe: bool) -> TokenStream { impl_swap(&input, is_unsafe).into() } -// T tmp(std::move(a)); a = std::move(b); b = std::move(tmp); ~tmp fn impl_swap(input: &DeriveInput, is_unsafe: bool) -> TokenStream2 { let name = &input.ident; let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl(); diff --git a/libcc2rs-macros/src/lib.rs b/libcc2rs-macros/src/lib.rs index 462d568957..cb66472cec 100644 --- a/libcc2rs-macros/src/lib.rs +++ b/libcc2rs-macros/src/lib.rs @@ -235,9 +235,6 @@ pub fn derive_move_assignable_unsafe(input: TokenStream) -> TokenStream { constructor::expand(input, "move", true, true) } -// Implements libcc2rs::Destructible, or DestructibleUnsafe, for S with an -// empty destructor. - #[proc_macro_derive(Destructible)] pub fn derive_destructible(input: TokenStream) -> TokenStream { destructor::expand(input, false) diff --git a/libcc2rs/src/constructor.rs b/libcc2rs/src/constructor.rs index 9e157e590e..b5069521d8 100644 --- a/libcc2rs/src/constructor.rs +++ b/libcc2rs/src/constructor.rs @@ -28,12 +28,10 @@ pub trait Swappable: Sized { fn swap(this: &Ptr, other: Ptr); } -// std::movable. pub trait Movable: MoveConstructible + MoveAssignable + Swappable + Destructible {} impl Movable for T {} -// std::copyable. pub trait Copyable: CopyConstructible + CopyAssignable + Movable {} impl Copyable for T {} @@ -68,7 +66,6 @@ pub trait SwappableUnsafe { unsafe fn swap(&mut self, other: *mut Self); } -// std::movable. pub trait MovableUnsafe: MoveConstructibleUnsafe + MoveAssignableUnsafe + SwappableUnsafe + DestructibleUnsafe { @@ -79,7 +76,6 @@ impl CopyableUnsafe for T {} @@ -353,7 +349,6 @@ impl CopyAssignableUnsafe for FnPtr { } } -// C arrays, element by element. fn construct_elems( this: &Ptr>, src: &Ptr>, diff --git a/tests/multi-file/out_of_line_methods_cross_tu/out/refcount/out_of_line_methods_cross_tu.rs b/tests/multi-file/out_of_line_methods_cross_tu/out/refcount/out_of_line_methods_cross_tu.rs index 45d1c8f147..6f84502602 100644 --- a/tests/multi-file/out_of_line_methods_cross_tu/out/refcount/out_of_line_methods_cross_tu.rs +++ b/tests/multi-file/out_of_line_methods_cross_tu/out/refcount/out_of_line_methods_cross_tu.rs @@ -110,9 +110,6 @@ pub trait SImpl { fn construct(&self, mut x: i32) { unimplemented!() } - fn destructor(&self) { - unimplemented!() - } fn get(&self) -> i32; fn set(&self, mut x: i32) { unimplemented!() diff --git a/tests/std/basic/out/refcount/basic.def.odr.rs b/tests/std/basic/out/refcount/basic.def.odr.rs index 65a72c4497..ed32392b2e 100644 --- a/tests/std/basic/out/refcount/basic.def.odr.rs +++ b/tests/std/basic/out/refcount/basic.def.odr.rs @@ -782,7 +782,18 @@ thread_local!( pub static m_ctors_32: Value = Rc::new(RefCell::new(0_i32)); ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + CopyConstructible, + MoveConstructible, + MoveAssignable, + Swappable, )] #[byte_size(1)] pub struct p9_unused_implicit_assignment_HasUndefinedCopyAssignment {} @@ -958,6 +969,27 @@ impl p4_1_pure_virtual_without_definition_HasPureVirtual (*derived_calls_10.with(Value::clone).borrow_mut()).prefix_inc(); } } +impl Destructible for p9_destructor_not_potentially_invoked_HasUndefinedDestructor { + fn destroy(_: &Ptr) { + unreachable!( + "p9_destructor_not_potentially_invoked_HasUndefinedDestructor::destroy is never defined" + ) + } +} +impl CopyConstructible for p9_unused_copy_constructor_HasUndefinedCopyCtor { + fn copy_constructor(_: &Ptr, _: Ptr) { + unreachable!( + "p9_unused_copy_constructor_HasUndefinedCopyCtor::copy_constructor is never defined" + ) + } +} +impl CopyAssignable for p9_unused_implicit_assignment_HasUndefinedCopyAssignment { + fn copy_assign(_: &Ptr, _: Ptr) -> Ptr { + unreachable!( + "p9_unused_implicit_assignment_HasUndefinedCopyAssignment::copy_assign is never defined" + ) + } +} pub trait HasConstexprCtorImpl { fn construct(&self, v: i32); } @@ -1028,9 +1060,6 @@ impl p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambdaImpl } pub trait p9_destructor_not_potentially_invoked_HasUndefinedDestructorImpl { fn construct(&self); - fn destructor(&self) { - unimplemented!() - } } impl p9_destructor_not_potentially_invoked_HasUndefinedDestructorImpl for Ptr @@ -1052,12 +1081,6 @@ impl p9_unused_copy_constructor_HasUndefinedCopyCtorImpl } pub trait p9_unused_implicit_assignment_HasUndefinedCopyAssignmentImpl { fn construct(&self); - fn copy_assign( - &self, - _a0: Ptr, - ) -> Ptr { - unimplemented!() - } } impl p9_unused_implicit_assignment_HasUndefinedCopyAssignmentImpl for Ptr diff --git a/tests/std/basic/out/unsafe/basic.def.odr.rs b/tests/std/basic/out/unsafe/basic.def.odr.rs index 47d9501fcc..3c196b40dc 100644 --- a/tests/std/basic/out/unsafe/basic.def.odr.rs +++ b/tests/std/basic/out/unsafe/basic.def.odr.rs @@ -752,7 +752,16 @@ pub unsafe fn test_31() { pub static mut m_ctors_32: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0_i32 }); #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + CopyConstructibleUnsafe, + MoveConstructibleUnsafe, + MoveAssignableUnsafe, + SwappableUnsafe, )] pub struct p9_unused_implicit_assignment_HasUndefinedCopyAssignment {} impl p9_unused_implicit_assignment_HasUndefinedCopyAssignment { @@ -911,6 +920,27 @@ unsafe impl p4_1_pure_virtual_without_definition_HasPureVirtual (*std::cell::LazyCell::force_mut(&mut *&raw mut derived_calls_10)).prefix_inc(); } } +impl DestructibleUnsafe for p9_destructor_not_potentially_invoked_HasUndefinedDestructor { + unsafe fn destroy(&mut self) { + unreachable!( + "p9_destructor_not_potentially_invoked_HasUndefinedDestructor::destroy is never defined" + ) + } +} +impl CopyConstructibleUnsafe for p9_unused_copy_constructor_HasUndefinedCopyCtor { + unsafe fn copy_constructor(&mut self, _: *const Self) { + unreachable!( + "p9_unused_copy_constructor_HasUndefinedCopyCtor::copy_constructor is never defined" + ) + } +} +impl CopyAssignableUnsafe for p9_unused_implicit_assignment_HasUndefinedCopyAssignment { + unsafe fn copy_assign(&mut self, _: *const Self) -> *mut Self { + unreachable!( + "p9_unused_implicit_assignment_HasUndefinedCopyAssignment::copy_assign is never defined" + ) + } +} pub unsafe fn __cpp2rust_init_globals() { std::cell::LazyCell::force(&*&raw const copyCount_0); std::cell::LazyCell::force(&*&raw const ctorCount_1); diff --git a/tests/unit/out/refcount/copy_move_deleted.rs b/tests/unit/out/refcount/copy_move_deleted.rs index b245261e5b..eb16520b9a 100644 --- a/tests/unit/out/refcount/copy_move_deleted.rs +++ b/tests/unit/out/refcount/copy_move_deleted.rs @@ -193,6 +193,16 @@ fn main_0() -> i32 { assert!((h2.items.len() == 0_usize)); return 0; } +impl CopyAssignable for PrivateCopy { + fn copy_assign(_: &Ptr, _: Ptr) -> Ptr { + unreachable!("PrivateCopy::copy_assign is never defined") + } +} +impl CopyConstructible for PrivateCopy { + fn copy_constructor(_: &Ptr, _: Ptr) { + unreachable!("PrivateCopy::copy_constructor is never defined") + } +} pub trait ImmovableImpl { fn construct(&self); } @@ -210,9 +220,6 @@ impl NoCopyImpl for Ptr { } } pub trait PrivateCopyImpl { - fn copy_assign(&self, _a0: Ptr) -> Ptr { - unimplemented!() - } fn construct(&self); } impl PrivateCopyImpl for Ptr { diff --git a/tests/unit/out/unsafe/copy_move_deleted.rs b/tests/unit/out/unsafe/copy_move_deleted.rs index 4a78de75c0..5d6bf31be6 100644 --- a/tests/unit/out/unsafe/copy_move_deleted.rs +++ b/tests/unit/out/unsafe/copy_move_deleted.rs @@ -205,4 +205,14 @@ unsafe fn main_0() -> i32 { assert!(((h2.items.len()) == (0_usize))); return 0; } +impl CopyAssignableUnsafe for PrivateCopy { + unsafe fn copy_assign(&mut self, _: *const Self) -> *mut Self { + unreachable!("PrivateCopy::copy_assign is never defined") + } +} +impl CopyConstructibleUnsafe for PrivateCopy { + unsafe fn copy_constructor(&mut self, _: *const Self) { + unreachable!("PrivateCopy::copy_constructor is never defined") + } +} pub unsafe fn __cpp2rust_init_globals() {} From d907c4d8ebd5c48b7d95a4069ddc819a06c4f901 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Mon, 30 Nov 2026 22:38:20 +0000 Subject: [PATCH 19/20] Derive movable --- cpp2rust/converter/converter.cpp | 36 +++++++---- cpp2rust/converter/converter_lib.h | 2 + libcc2rs-macros/src/constructor.rs | 8 +++ libcc2rs-macros/src/lib.rs | 10 +++ libcc2rs/src/lib.rs | 6 +- .../out/refcount/p14-class-in-two-files.rs | 11 +--- .../out/unsafe/p14-class-in-two-files.rs | 9 +-- .../p15-class-template-static-member.rs | 11 +--- .../p15-class-template-static-member.rs | 9 +-- .../out/refcount/p15-function-template.rs | 11 +--- .../out/unsafe/p15-function-template.rs | 9 +-- .../out/refcount/p15-inline-function.rs | 11 +--- .../out/unsafe/p15-inline-function.rs | 9 +-- .../out/refcount/p15-inline-variable.rs | 11 +--- .../out/unsafe/p15-inline-variable.rs | 9 +-- .../p16-default-argument-lambda-in-class.rs | 11 +--- .../p16-default-argument-lambda-in-class.rs | 9 +-- .../refcount/p16-lambda-in-inline-function.rs | 11 +--- .../unsafe/p16-lambda-in-inline-function.rs | 9 +-- .../out/refcount/basic.scope.block.rs | 11 +--- .../out/unsafe/basic.scope.block.rs | 9 +-- tests/std/basic/out/refcount/basic.def.odr.rs | 58 +++-------------- tests/std/basic/out/unsafe/basic.def.odr.rs | 38 +++-------- .../stmt.select/out/refcount/stmt.if.rs | 11 +--- .../stmt.select/out/refcount/stmt.switch.rs | 11 +--- .../stmt.select/out/unsafe/stmt.if.rs | 9 +-- .../stmt.select/out/unsafe/stmt.switch.rs | 9 +-- tests/unit/out/refcount/copy_assign.rs | 37 ++--------- tests/unit/out/refcount/copy_ctor.rs | 63 ++----------------- tests/unit/out/refcount/max.rs | 12 +--- tests/unit/out/refcount/rule_of_three.rs | 12 +--- .../refcount/structured_binding_copy_ctor.rs | 13 +--- tests/unit/out/refcount/swap_map_no_copy.rs | 17 +---- tests/unit/out/unsafe/copy_assign.rs | 27 ++------ tests/unit/out/unsafe/copy_ctor.rs | 30 ++------- tests/unit/out/unsafe/max.rs | 4 +- tests/unit/out/unsafe/rule_of_three.rs | 11 +--- .../unsafe/structured_binding_copy_ctor.rs | 11 +--- tests/unit/out/unsafe/swap_map_no_copy.rs | 15 +---- 39 files changed, 114 insertions(+), 496 deletions(-) diff --git a/cpp2rust/converter/converter.cpp b/cpp2rust/converter/converter.cpp index 86cf61efdc..c564fa71ad 100644 --- a/cpp2rust/converter/converter.cpp +++ b/cpp2rust/converter/converter.cpp @@ -5585,23 +5585,37 @@ void Converter::AddCopyAndMoveDerives(const clang::RecordDecl *decl, auto implements = [&](const RecordTrait *trait) { return ImplementsRecordTrait(decl, *trait); }; - const RecordTrait *traits[] = {&kCopyConstructible, &kMoveConstructible, - &kCopyAssignable, &kMoveAssignable}; - if (decl->isUnion() || RecordImplementsClone(decl)) { - if (llvm::none_of(traits, implements)) { - attrs.emplace_back(GetCopyOrMoveTraitName(kCopyable)); - return; - } - for (const auto *trait : traits) { + const RecordTrait *copy[] = {&kCopyConstructible, &kCopyAssignable}; + const RecordTrait *move[] = {&kMoveConstructible, &kMoveAssignable}; + bool copies = decl->isUnion() || RecordImplementsClone(decl); + bool writes_move = llvm::any_of(move, implements); + if (copies && !writes_move && llvm::none_of(copy, implements)) { + attrs.emplace_back(GetCopyOrMoveTraitName(kCopyable)); + return; + } + if (copies) { + for (const auto *trait : copy) { if (!implements(trait)) { attrs.emplace_back(GetCopyOrMoveTraitName(*trait)); } } - } else if (!implements(&kMoveConstructible) || - !implements(&kMoveAssignable)) { + } + if (!writes_move) { + if (copies) { + attrs.emplace_back(GetCopyOrMoveTraitName(kMovable)); + } return; } - attrs.emplace_back(GetCopyOrMoveTraitName(kSwappable)); + if (copies) { + for (const auto *trait : move) { + if (!implements(trait)) { + attrs.emplace_back(GetCopyOrMoveTraitName(*trait)); + } + } + } + if (copies || llvm::all_of(move, implements)) { + attrs.emplace_back(GetCopyOrMoveTraitName(kSwappable)); + } } bool Converter::RecordImplementsClone(const clang::RecordDecl *decl) { diff --git a/cpp2rust/converter/converter_lib.h b/cpp2rust/converter/converter_lib.h index ead5bdc13b..515f6637d7 100644 --- a/cpp2rust/converter/converter_lib.h +++ b/cpp2rust/converter/converter_lib.h @@ -136,6 +136,8 @@ inline constexpr RecordTrait kSwappable{ inline constexpr RecordTrait kDestructible{ "Destructible", "DestructibleUnsafe", "destroy", "fn destroy(_: &Ptr)", "unsafe fn destroy(&mut self)"}; +inline constexpr RecordTrait kMovable{"Movable", "MovableUnsafe", nullptr, + nullptr, nullptr}; inline constexpr RecordTrait kCopyable{"Copyable", "CopyableUnsafe", nullptr, nullptr, nullptr}; diff --git a/libcc2rs-macros/src/constructor.rs b/libcc2rs-macros/src/constructor.rs index cbe68c03ea..58745b4cd9 100644 --- a/libcc2rs-macros/src/constructor.rs +++ b/libcc2rs-macros/src/constructor.rs @@ -24,6 +24,14 @@ pub fn expand_copyable(input: TokenStream, is_unsafe: bool) -> TokenStream { quote!(#(#impls)* #swap).into() } +pub fn expand_movable(input: TokenStream, is_unsafe: bool) -> TokenStream { + let input = parse_macro_input!(input as DeriveInput); + let impls = [("move", false), ("move", true)] + .map(|(op, is_assign)| impl_trait(&input, op, is_assign, is_unsafe)); + let swap = impl_swap(&input, is_unsafe); + quote!(#(#impls)* #swap).into() +} + pub fn expand_swappable(input: TokenStream, is_unsafe: bool) -> TokenStream { let input = parse_macro_input!(input as DeriveInput); impl_swap(&input, is_unsafe).into() diff --git a/libcc2rs-macros/src/lib.rs b/libcc2rs-macros/src/lib.rs index cb66472cec..e530b0e9dd 100644 --- a/libcc2rs-macros/src/lib.rs +++ b/libcc2rs-macros/src/lib.rs @@ -195,6 +195,16 @@ pub fn derive_copyable_unsafe(input: TokenStream) -> TokenStream { constructor::expand_copyable(input, true) } +#[proc_macro_derive(Movable)] +pub fn derive_movable(input: TokenStream) -> TokenStream { + constructor::expand_movable(input, false) +} + +#[proc_macro_derive(MovableUnsafe)] +pub fn derive_movable_unsafe(input: TokenStream) -> TokenStream { + constructor::expand_movable(input, true) +} + #[proc_macro_derive(Swappable)] pub fn derive_swappable(input: TokenStream) -> TokenStream { constructor::expand_swappable(input, false) diff --git a/libcc2rs/src/lib.rs b/libcc2rs/src/lib.rs index ba63bd6812..40dccb5361 100644 --- a/libcc2rs/src/lib.rs +++ b/libcc2rs/src/lib.rs @@ -113,7 +113,7 @@ pub use format::*; pub use libcc2rs_macros::{ ByteRepr, CopyAssignable, CopyAssignableUnsafe, CopyConstructible, CopyConstructibleUnsafe, Copyable, CopyableUnsafe, CppFrom, CppFromUnsafe, Destructible, DestructibleUnsafe, FnPtrArg, - MoveAssignable, MoveAssignableUnsafe, MoveConstructible, MoveConstructibleUnsafe, Record, - Swappable, SwappableUnsafe, VaArg, ZeroInitialization, ZeroInitializationUnsafe, goto, - goto_block, lambda, lambda_unsafe, switch, + Movable, MovableUnsafe, MoveAssignable, MoveAssignableUnsafe, MoveConstructible, + MoveConstructibleUnsafe, Record, Swappable, SwappableUnsafe, VaArg, ZeroInitialization, + ZeroInitializationUnsafe, goto, goto_block, lambda, lambda_unsafe, switch, }; diff --git a/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/refcount/p14-class-in-two-files.rs b/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/refcount/p14-class-in-two-files.rs index 9d873239d0..3e06ae1365 100644 --- a/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/refcount/p14-class-in-two-files.rs +++ b/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/refcount/p14-class-in-two-files.rs @@ -18,16 +18,7 @@ thread_local!( thread_local!( pub static useCount_3: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - MoveConstructible, - MoveAssignable, - Swappable, -)] +#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Movable)] #[byte_size(4)] pub struct LifetimeTracked { #[offset(0)] diff --git a/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/unsafe/p14-class-in-two-files.rs b/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/unsafe/p14-class-in-two-files.rs index 7ca9fd4f41..a19412d26f 100644 --- a/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/unsafe/p14-class-in-two-files.rs +++ b/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/unsafe/p14-class-in-two-files.rs @@ -11,14 +11,7 @@ pub static mut copyCount_1: std::cell::LazyCell = std::cell::LazyCell::new( pub static mut dtorCount_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - MoveConstructibleUnsafe, - MoveAssignableUnsafe, - SwappableUnsafe, -)] +#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, MovableUnsafe)] pub struct LifetimeTracked { pub uses: i32, } diff --git a/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/refcount/p15-class-template-static-member.rs b/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/refcount/p15-class-template-static-member.rs index 4cb01edec3..00512df143 100644 --- a/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/refcount/p15-class-template-static-member.rs +++ b/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/refcount/p15-class-template-static-member.rs @@ -18,16 +18,7 @@ thread_local!( thread_local!( pub static useCount_3: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - MoveConstructible, - MoveAssignable, - Swappable, -)] +#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Movable)] #[byte_size(4)] pub struct LifetimeTracked { #[offset(0)] diff --git a/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/unsafe/p15-class-template-static-member.rs b/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/unsafe/p15-class-template-static-member.rs index be5eccce4e..ed6754b990 100644 --- a/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/unsafe/p15-class-template-static-member.rs +++ b/tests/std/basic/basic.def.odr/p15-class-template-static-member/out/unsafe/p15-class-template-static-member.rs @@ -11,14 +11,7 @@ pub static mut copyCount_1: std::cell::LazyCell = std::cell::LazyCell::new( pub static mut dtorCount_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - MoveConstructibleUnsafe, - MoveAssignableUnsafe, - SwappableUnsafe, -)] +#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, MovableUnsafe)] pub struct LifetimeTracked { pub uses: i32, } diff --git a/tests/std/basic/basic.def.odr/p15-function-template/out/refcount/p15-function-template.rs b/tests/std/basic/basic.def.odr/p15-function-template/out/refcount/p15-function-template.rs index bf4923d6ad..59ba114c3f 100644 --- a/tests/std/basic/basic.def.odr/p15-function-template/out/refcount/p15-function-template.rs +++ b/tests/std/basic/basic.def.odr/p15-function-template/out/refcount/p15-function-template.rs @@ -18,16 +18,7 @@ thread_local!( thread_local!( pub static useCount_3: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - MoveConstructible, - MoveAssignable, - Swappable, -)] +#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Movable)] #[byte_size(4)] pub struct LifetimeTracked { #[offset(0)] diff --git a/tests/std/basic/basic.def.odr/p15-function-template/out/unsafe/p15-function-template.rs b/tests/std/basic/basic.def.odr/p15-function-template/out/unsafe/p15-function-template.rs index ec9cd41b17..846ade9d3d 100644 --- a/tests/std/basic/basic.def.odr/p15-function-template/out/unsafe/p15-function-template.rs +++ b/tests/std/basic/basic.def.odr/p15-function-template/out/unsafe/p15-function-template.rs @@ -11,14 +11,7 @@ pub static mut copyCount_1: std::cell::LazyCell = std::cell::LazyCell::new( pub static mut dtorCount_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - MoveConstructibleUnsafe, - MoveAssignableUnsafe, - SwappableUnsafe, -)] +#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, MovableUnsafe)] pub struct LifetimeTracked { pub uses: i32, } diff --git a/tests/std/basic/basic.def.odr/p15-inline-function/out/refcount/p15-inline-function.rs b/tests/std/basic/basic.def.odr/p15-inline-function/out/refcount/p15-inline-function.rs index 529fca8b0b..a5c622605e 100644 --- a/tests/std/basic/basic.def.odr/p15-inline-function/out/refcount/p15-inline-function.rs +++ b/tests/std/basic/basic.def.odr/p15-inline-function/out/refcount/p15-inline-function.rs @@ -18,16 +18,7 @@ thread_local!( thread_local!( pub static useCount_3: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - MoveConstructible, - MoveAssignable, - Swappable, -)] +#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Movable)] #[byte_size(4)] pub struct LifetimeTracked { #[offset(0)] diff --git a/tests/std/basic/basic.def.odr/p15-inline-function/out/unsafe/p15-inline-function.rs b/tests/std/basic/basic.def.odr/p15-inline-function/out/unsafe/p15-inline-function.rs index d4406cf52c..7cb48fd99d 100644 --- a/tests/std/basic/basic.def.odr/p15-inline-function/out/unsafe/p15-inline-function.rs +++ b/tests/std/basic/basic.def.odr/p15-inline-function/out/unsafe/p15-inline-function.rs @@ -11,14 +11,7 @@ pub static mut copyCount_1: std::cell::LazyCell = std::cell::LazyCell::new( pub static mut dtorCount_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - MoveConstructibleUnsafe, - MoveAssignableUnsafe, - SwappableUnsafe, -)] +#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, MovableUnsafe)] pub struct LifetimeTracked { pub uses: i32, } diff --git a/tests/std/basic/basic.def.odr/p15-inline-variable/out/refcount/p15-inline-variable.rs b/tests/std/basic/basic.def.odr/p15-inline-variable/out/refcount/p15-inline-variable.rs index 370f20db24..e7f8a72e48 100644 --- a/tests/std/basic/basic.def.odr/p15-inline-variable/out/refcount/p15-inline-variable.rs +++ b/tests/std/basic/basic.def.odr/p15-inline-variable/out/refcount/p15-inline-variable.rs @@ -18,16 +18,7 @@ thread_local!( thread_local!( pub static useCount_3: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - MoveConstructible, - MoveAssignable, - Swappable, -)] +#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Movable)] #[byte_size(4)] pub struct LifetimeTracked { #[offset(0)] diff --git a/tests/std/basic/basic.def.odr/p15-inline-variable/out/unsafe/p15-inline-variable.rs b/tests/std/basic/basic.def.odr/p15-inline-variable/out/unsafe/p15-inline-variable.rs index 9fc8d83f3e..9a88ea3956 100644 --- a/tests/std/basic/basic.def.odr/p15-inline-variable/out/unsafe/p15-inline-variable.rs +++ b/tests/std/basic/basic.def.odr/p15-inline-variable/out/unsafe/p15-inline-variable.rs @@ -11,14 +11,7 @@ pub static mut copyCount_1: std::cell::LazyCell = std::cell::LazyCell::new( pub static mut dtorCount_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - MoveConstructibleUnsafe, - MoveAssignableUnsafe, - SwappableUnsafe, -)] +#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, MovableUnsafe)] pub struct LifetimeTracked { pub uses: i32, } diff --git a/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/refcount/p16-default-argument-lambda-in-class.rs b/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/refcount/p16-default-argument-lambda-in-class.rs index 4ad7a9872c..30103664db 100644 --- a/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/refcount/p16-default-argument-lambda-in-class.rs +++ b/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/refcount/p16-default-argument-lambda-in-class.rs @@ -18,16 +18,7 @@ thread_local!( thread_local!( pub static useCount_3: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - MoveConstructible, - MoveAssignable, - Swappable, -)] +#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Movable)] #[byte_size(4)] pub struct LifetimeTracked { #[offset(0)] diff --git a/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/unsafe/p16-default-argument-lambda-in-class.rs b/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/unsafe/p16-default-argument-lambda-in-class.rs index d93fcd8416..8044442031 100644 --- a/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/unsafe/p16-default-argument-lambda-in-class.rs +++ b/tests/std/basic/basic.def.odr/p16-default-argument-lambda-in-class/out/unsafe/p16-default-argument-lambda-in-class.rs @@ -11,14 +11,7 @@ pub static mut copyCount_1: std::cell::LazyCell = std::cell::LazyCell::new( pub static mut dtorCount_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - MoveConstructibleUnsafe, - MoveAssignableUnsafe, - SwappableUnsafe, -)] +#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, MovableUnsafe)] pub struct LifetimeTracked { pub uses: i32, } diff --git a/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/refcount/p16-lambda-in-inline-function.rs b/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/refcount/p16-lambda-in-inline-function.rs index 85a3e08063..900d5daf58 100644 --- a/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/refcount/p16-lambda-in-inline-function.rs +++ b/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/refcount/p16-lambda-in-inline-function.rs @@ -18,16 +18,7 @@ thread_local!( thread_local!( pub static useCount_3: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - MoveConstructible, - MoveAssignable, - Swappable, -)] +#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Movable)] #[byte_size(4)] pub struct LifetimeTracked { #[offset(0)] diff --git a/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/unsafe/p16-lambda-in-inline-function.rs b/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/unsafe/p16-lambda-in-inline-function.rs index 9a11e45b05..439b3df6e7 100644 --- a/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/unsafe/p16-lambda-in-inline-function.rs +++ b/tests/std/basic/basic.def.odr/p16-lambda-in-inline-function/out/unsafe/p16-lambda-in-inline-function.rs @@ -11,14 +11,7 @@ pub static mut copyCount_1: std::cell::LazyCell = std::cell::LazyCell::new( pub static mut dtorCount_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - MoveConstructibleUnsafe, - MoveAssignableUnsafe, - SwappableUnsafe, -)] +#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, MovableUnsafe)] pub struct LifetimeTracked { pub uses: i32, } diff --git a/tests/std/basic/basic.scope/out/refcount/basic.scope.block.rs b/tests/std/basic/basic.scope/out/refcount/basic.scope.block.rs index f5e9756c7f..a55c4e14ce 100644 --- a/tests/std/basic/basic.scope/out/refcount/basic.scope.block.rs +++ b/tests/std/basic/basic.scope/out/refcount/basic.scope.block.rs @@ -18,16 +18,7 @@ thread_local!( thread_local!( pub static useCount_3: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - MoveConstructible, - MoveAssignable, - Swappable, -)] +#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Movable)] #[byte_size(4)] pub struct LifetimeTracked { #[offset(0)] diff --git a/tests/std/basic/basic.scope/out/unsafe/basic.scope.block.rs b/tests/std/basic/basic.scope/out/unsafe/basic.scope.block.rs index 7e2f0d8c21..cbf81df578 100644 --- a/tests/std/basic/basic.scope/out/unsafe/basic.scope.block.rs +++ b/tests/std/basic/basic.scope/out/unsafe/basic.scope.block.rs @@ -11,14 +11,7 @@ pub static mut copyCount_1: std::cell::LazyCell = std::cell::LazyCell::new( pub static mut dtorCount_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - MoveConstructibleUnsafe, - MoveAssignableUnsafe, - SwappableUnsafe, -)] +#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, MovableUnsafe)] pub struct LifetimeTracked { pub uses: i32, } diff --git a/tests/std/basic/out/refcount/basic.def.odr.rs b/tests/std/basic/out/refcount/basic.def.odr.rs index ed32392b2e..630c9c4417 100644 --- a/tests/std/basic/out/refcount/basic.def.odr.rs +++ b/tests/std/basic/out/refcount/basic.def.odr.rs @@ -10,17 +10,7 @@ thread_local!( pub static copyCount_0: Value = Rc::new(RefCell::new(0)); ); #[derive( - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - Destructible, - MoveConstructible, - MoveAssignable, - Swappable, - Default, + Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Destructible, Movable, Default, )] #[cpp_from(i32, construct, value)] #[byte_size(4)] @@ -66,16 +56,7 @@ thread_local!( thread_local!( pub static useCount_4: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - MoveConstructible, - MoveAssignable, - Swappable, -)] +#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Movable)] #[byte_size(4)] pub struct LifetimeTracked { #[offset(0)] @@ -419,17 +400,7 @@ thread_local!( pub static copies_18: Value = Rc::new(RefCell::new(0_i32)); ); #[derive( - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - Destructible, - MoveConstructible, - MoveAssignable, - Swappable, - Default, + Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Destructible, Movable, Default, )] #[cpp_from(i32, construct, value)] #[byte_size(8)] @@ -512,9 +483,7 @@ pub fn test_19() { VaArg, FnPtrArg, CopyConstructible, - MoveConstructible, - MoveAssignable, - Swappable, + Movable, Default, )] #[byte_size(8)] @@ -575,16 +544,7 @@ pub fn test_20() { assert!((useCount_4.with(|rc| *rc.borrow()) == 0)); } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CopyConstructible, - MoveConstructible, - MoveAssignable, - Swappable, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CopyConstructible, Movable, )] #[byte_size(8)] pub struct p7_member_access_captures_this_HasMemberUsedInLambda { @@ -645,9 +605,7 @@ pub fn test_22() { VaArg, FnPtrArg, CopyConstructible, - MoveConstructible, - MoveAssignable, - Swappable, + Movable, Default, )] #[byte_size(4)] @@ -791,9 +749,7 @@ thread_local!( FnPtrArg, Destructible, CopyConstructible, - MoveConstructible, - MoveAssignable, - Swappable, + Movable, )] #[byte_size(1)] pub struct p9_unused_implicit_assignment_HasUndefinedCopyAssignment {} diff --git a/tests/std/basic/out/unsafe/basic.def.odr.rs b/tests/std/basic/out/unsafe/basic.def.odr.rs index 3c196b40dc..b00c56c4a9 100644 --- a/tests/std/basic/out/unsafe/basic.def.odr.rs +++ b/tests/std/basic/out/unsafe/basic.def.odr.rs @@ -14,9 +14,7 @@ pub static mut copyCount_0: std::cell::LazyCell = std::cell::LazyCell::new( ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, - MoveConstructibleUnsafe, - MoveAssignableUnsafe, - SwappableUnsafe, + MovableUnsafe, Default, )] #[cpp_from(i32, construct, value)] @@ -57,14 +55,7 @@ pub static mut copyCount_2: std::cell::LazyCell = std::cell::LazyCell::new( pub static mut dtorCount_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut useCount_4: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - MoveConstructibleUnsafe, - MoveAssignableUnsafe, - SwappableUnsafe, -)] +#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, MovableUnsafe)] pub struct LifetimeTracked { pub uses: i32, } @@ -390,9 +381,7 @@ pub static mut copies_18: std::cell::LazyCell = std::cell::LazyCell::new(|| ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, - MoveConstructibleUnsafe, - MoveAssignableUnsafe, - SwappableUnsafe, + MovableUnsafe, Default, )] #[cpp_from(i32, construct, value)] @@ -470,9 +459,7 @@ pub unsafe fn test_19() { FnPtrArg, ZeroInitializationUnsafe, CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - MoveAssignableUnsafe, - SwappableUnsafe, + MovableUnsafe, Default, )] pub struct p6_unevaluated_binding_needs_no_capture_HasTwoMembers { @@ -532,14 +519,7 @@ pub unsafe fn test_20() { } #[repr(C)] #[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - MoveAssignableUnsafe, - SwappableUnsafe, + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyConstructibleUnsafe, MovableUnsafe, )] pub struct p7_member_access_captures_this_HasMemberUsedInLambda { pub x: LifetimeTracked, @@ -611,9 +591,7 @@ pub unsafe fn test_22() { FnPtrArg, ZeroInitializationUnsafe, CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - MoveAssignableUnsafe, - SwappableUnsafe, + MovableUnsafe, Default, )] pub struct p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda { @@ -759,9 +737,7 @@ pub static mut m_ctors_32: std::cell::LazyCell = std::cell::LazyCell::new(| ZeroInitializationUnsafe, DestructibleUnsafe, CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - MoveAssignableUnsafe, - SwappableUnsafe, + MovableUnsafe, )] pub struct p9_unused_implicit_assignment_HasUndefinedCopyAssignment {} impl p9_unused_implicit_assignment_HasUndefinedCopyAssignment { diff --git a/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.if.rs b/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.if.rs index 6da958ea78..6c811cd0f4 100644 --- a/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.if.rs +++ b/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.if.rs @@ -18,16 +18,7 @@ thread_local!( thread_local!( pub static useCount_3: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - MoveConstructible, - MoveAssignable, - Swappable, -)] +#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Movable)] #[byte_size(4)] pub struct LifetimeTracked { #[offset(0)] diff --git a/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs b/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs index f841ae81c2..6ca3a182b8 100644 --- a/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs +++ b/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs @@ -18,16 +18,7 @@ thread_local!( thread_local!( pub static useCount_3: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - MoveConstructible, - MoveAssignable, - Swappable, -)] +#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Movable)] #[byte_size(4)] pub struct LifetimeTracked { #[offset(0)] diff --git a/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.if.rs b/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.if.rs index 4a43889a19..4390692e96 100644 --- a/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.if.rs +++ b/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.if.rs @@ -11,14 +11,7 @@ pub static mut copyCount_1: std::cell::LazyCell = std::cell::LazyCell::new( pub static mut dtorCount_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - MoveConstructibleUnsafe, - MoveAssignableUnsafe, - SwappableUnsafe, -)] +#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, MovableUnsafe)] pub struct LifetimeTracked { pub uses: i32, } diff --git a/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs b/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs index c2918d06a3..d612c4f475 100644 --- a/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs +++ b/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs @@ -11,14 +11,7 @@ pub static mut copyCount_1: std::cell::LazyCell = std::cell::LazyCell::new( pub static mut dtorCount_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut useCount_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - MoveConstructibleUnsafe, - MoveAssignableUnsafe, - SwappableUnsafe, -)] +#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, MovableUnsafe)] pub struct LifetimeTracked { pub uses: i32, } diff --git a/tests/unit/out/refcount/copy_assign.rs b/tests/unit/out/refcount/copy_assign.rs index 4c7343f280..98b0f51f46 100644 --- a/tests/unit/out/refcount/copy_assign.rs +++ b/tests/unit/out/refcount/copy_assign.rs @@ -9,18 +9,7 @@ use std::rc::{Rc, Weak}; thread_local!( pub static assigns_0: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - Destructible, - MoveConstructible, - MoveAssignable, - Swappable, - Default, -)] +#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Movable, Default)] #[byte_size(8)] pub struct Partial { #[offset(0)] @@ -85,9 +74,7 @@ impl Default for NonConstAssign { FnPtrArg, Destructible, CopyConstructible, - MoveConstructible, - MoveAssignable, - Swappable, + Movable, )] #[byte_size(4)] pub struct RefQualified { @@ -120,9 +107,7 @@ impl Default for RefQualified { FnPtrArg, Destructible, CopyConstructible, - MoveConstructible, - MoveAssignable, - Swappable, + Movable, )] #[byte_size(24)] pub struct Holder { @@ -170,17 +155,7 @@ thread_local!( pub static copies_1: Value = Rc::new(RefCell::new(0)); ); #[derive( - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - Destructible, - MoveConstructible, - MoveAssignable, - Swappable, - Default, + Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Destructible, Movable, Default, )] #[cpp_from(i32, construct, value)] #[byte_size(4)] @@ -217,9 +192,7 @@ impl Clone for CopyCounted { FnPtrArg, Destructible, CopyConstructible, - MoveConstructible, - MoveAssignable, - Swappable, + Movable, )] #[byte_size(12)] pub struct HasCopyCounted { diff --git a/tests/unit/out/refcount/copy_ctor.rs b/tests/unit/out/refcount/copy_ctor.rs index b098b628c5..9c9ed0b670 100644 --- a/tests/unit/out/refcount/copy_ctor.rs +++ b/tests/unit/out/refcount/copy_ctor.rs @@ -10,17 +10,7 @@ thread_local!( pub static copies_0: Value = Rc::new(RefCell::new(0)); ); #[derive( - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - Destructible, - MoveConstructible, - MoveAssignable, - Swappable, - Default, + Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Destructible, Movable, Default, )] #[cpp_from(i32, construct, value)] #[byte_size(4)] @@ -49,16 +39,7 @@ impl Clone for Counted { } } #[derive( - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - Destructible, - CopyConstructible, - MoveConstructible, - MoveAssignable, - Swappable, + Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, CopyConstructible, Movable, )] #[byte_size(4)] pub struct NonConst { @@ -93,17 +74,7 @@ impl Default for NonConst { } } #[derive( - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - Destructible, - MoveConstructible, - MoveAssignable, - Swappable, - Default, + Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Destructible, Movable, Default, )] #[cpp_from(i32, construct, value)] #[byte_size(4)] @@ -140,9 +111,7 @@ impl Clone for Ignored { FnPtrArg, Destructible, CopyConstructible, - MoveConstructible, - MoveAssignable, - Swappable, + Movable, )] #[byte_size(12)] pub struct Holder { @@ -246,17 +215,7 @@ impl MoveConstructible for Owner { } } #[derive( - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - Destructible, - MoveConstructible, - MoveAssignable, - Swappable, - Default, + Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Destructible, Movable, Default, )] #[cpp_from(i32, construct, value)] #[byte_size(4)] @@ -284,17 +243,7 @@ impl Clone for OutOfLine { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } -#[derive( - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - Destructible, - MoveConstructible, - MoveAssignable, - Swappable, -)] +#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Movable)] #[byte_size(4)] pub struct Tracked { #[offset(0)] diff --git a/tests/unit/out/refcount/max.rs b/tests/unit/out/refcount/max.rs index 5a18960f6d..4d9b73ac1d 100644 --- a/tests/unit/out/refcount/max.rs +++ b/tests/unit/out/refcount/max.rs @@ -21,17 +21,7 @@ pub fn pick_3(mut i: i32) -> Ptr { return xs_1.with(|v| v.decay()).offset(i); } #[derive( - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - Destructible, - MoveConstructible, - MoveAssignable, - Swappable, - Default, + Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Destructible, Movable, Default, )] #[cpp_from(i32, construct, value)] #[byte_size(4)] diff --git a/tests/unit/out/refcount/rule_of_three.rs b/tests/unit/out/refcount/rule_of_three.rs index 42496b8975..9a27222ee3 100644 --- a/tests/unit/out/refcount/rule_of_three.rs +++ b/tests/unit/out/refcount/rule_of_three.rs @@ -12,17 +12,7 @@ thread_local!( thread_local!( pub static copies_1: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - MoveConstructible, - MoveAssignable, - Swappable, -)] +#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Movable)] #[cpp_from(i32, construct, value)] #[byte_size(20)] pub struct Buffer { diff --git a/tests/unit/out/refcount/structured_binding_copy_ctor.rs b/tests/unit/out/refcount/structured_binding_copy_ctor.rs index 64219f955c..34fa568b56 100644 --- a/tests/unit/out/refcount/structured_binding_copy_ctor.rs +++ b/tests/unit/out/refcount/structured_binding_copy_ctor.rs @@ -9,18 +9,7 @@ use std::rc::{Rc, Weak}; thread_local!( pub static copies_0: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - Destructible, - MoveConstructible, - MoveAssignable, - Swappable, - Default, -)] +#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Movable, Default)] #[byte_size(8)] pub struct Counted { #[offset(0)] diff --git a/tests/unit/out/refcount/swap_map_no_copy.rs b/tests/unit/out/refcount/swap_map_no_copy.rs index 88a42d3bb0..a6d469ae37 100644 --- a/tests/unit/out/refcount/swap_map_no_copy.rs +++ b/tests/unit/out/refcount/swap_map_no_copy.rs @@ -236,18 +236,7 @@ thread_local!( thread_local!( pub static copy_only_dtors_2: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - CppFrom, - MoveConstructible, - MoveAssignable, - Swappable, - Default, -)] +#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Movable, Default)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct CopyOnly { @@ -288,9 +277,7 @@ impl Clone for CopyOnly { VaArg, FnPtrArg, CopyConstructible, - MoveConstructible, - MoveAssignable, - Swappable, + Movable, Default, )] #[byte_size(8)] diff --git a/tests/unit/out/unsafe/copy_assign.rs b/tests/unit/out/unsafe/copy_assign.rs index e78d4ea445..9eed7b4959 100644 --- a/tests/unit/out/unsafe/copy_assign.rs +++ b/tests/unit/out/unsafe/copy_assign.rs @@ -8,16 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub static mut assigns_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - MoveConstructibleUnsafe, - MoveAssignableUnsafe, - SwappableUnsafe, - Default, -)] +#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, MovableUnsafe, Default)] pub struct Partial { pub v: i32, pub keep: i32, @@ -93,9 +84,7 @@ impl Default for NonConstAssign { ZeroInitializationUnsafe, DestructibleUnsafe, CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - MoveAssignableUnsafe, - SwappableUnsafe, + MovableUnsafe, )] pub struct RefQualified { pub mark: i32, @@ -130,9 +119,7 @@ impl Default for RefQualified { ZeroInitializationUnsafe, DestructibleUnsafe, CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - MoveAssignableUnsafe, - SwappableUnsafe, + MovableUnsafe, Default, )] pub struct Holder { @@ -168,9 +155,7 @@ pub static mut copies_1: std::cell::LazyCell = std::cell::LazyCell::new(|| ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, - MoveConstructibleUnsafe, - MoveAssignableUnsafe, - SwappableUnsafe, + MovableUnsafe, Default, )] #[cpp_from(i32, construct, value)] @@ -211,9 +196,7 @@ impl Clone for CopyCounted { ZeroInitializationUnsafe, DestructibleUnsafe, CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - MoveAssignableUnsafe, - SwappableUnsafe, + MovableUnsafe, Default, )] pub struct HasCopyCounted { diff --git a/tests/unit/out/unsafe/copy_ctor.rs b/tests/unit/out/unsafe/copy_ctor.rs index f868ede301..622619e864 100644 --- a/tests/unit/out/unsafe/copy_ctor.rs +++ b/tests/unit/out/unsafe/copy_ctor.rs @@ -14,9 +14,7 @@ pub static mut copies_0: std::cell::LazyCell = std::cell::LazyCell::new(|| ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, - MoveConstructibleUnsafe, - MoveAssignableUnsafe, - SwappableUnsafe, + MovableUnsafe, Default, )] #[cpp_from(i32, construct, value)] @@ -56,9 +54,7 @@ impl Clone for Counted { ZeroInitializationUnsafe, DestructibleUnsafe, CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - MoveAssignableUnsafe, - SwappableUnsafe, + MovableUnsafe, )] pub struct NonConst { pub mark: i32, @@ -107,9 +103,7 @@ impl Default for NonConst { ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, - MoveConstructibleUnsafe, - MoveAssignableUnsafe, - SwappableUnsafe, + MovableUnsafe, Default, )] #[cpp_from(i32, construct, value)] @@ -150,9 +144,7 @@ impl Clone for Ignored { ZeroInitializationUnsafe, DestructibleUnsafe, CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - MoveAssignableUnsafe, - SwappableUnsafe, + MovableUnsafe, Default, )] pub struct Holder { @@ -248,9 +240,7 @@ impl MoveConstructibleUnsafe for Owner { ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, - MoveConstructibleUnsafe, - MoveAssignableUnsafe, - SwappableUnsafe, + MovableUnsafe, Default, )] #[cpp_from(i32, construct, value)] @@ -284,15 +274,7 @@ impl Clone for OutOfLine { } } #[repr(C)] -#[derive( - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - MoveConstructibleUnsafe, - MoveAssignableUnsafe, - SwappableUnsafe, -)] +#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, MovableUnsafe)] pub struct Tracked { pub copied_from: i32, } diff --git a/tests/unit/out/unsafe/max.rs b/tests/unit/out/unsafe/max.rs index 0fd691256f..04d843a1e7 100644 --- a/tests/unit/out/unsafe/max.rs +++ b/tests/unit/out/unsafe/max.rs @@ -23,9 +23,7 @@ pub unsafe fn pick_3(mut i: i32) -> *mut i32 { ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, - MoveConstructibleUnsafe, - MoveAssignableUnsafe, - SwappableUnsafe, + MovableUnsafe, Default, )] #[cpp_from(i32, construct, value)] diff --git a/tests/unit/out/unsafe/rule_of_three.rs b/tests/unit/out/unsafe/rule_of_three.rs index f7450613a8..34ff42dd06 100644 --- a/tests/unit/out/unsafe/rule_of_three.rs +++ b/tests/unit/out/unsafe/rule_of_three.rs @@ -9,16 +9,7 @@ use std::rc::Rc; pub static mut alive_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut copies_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - MoveConstructibleUnsafe, - MoveAssignableUnsafe, - SwappableUnsafe, - Default, -)] +#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, MovableUnsafe, Default)] #[cpp_from(i32, construct, value)] pub struct Buffer { pub data: [i32; 4], diff --git a/tests/unit/out/unsafe/structured_binding_copy_ctor.rs b/tests/unit/out/unsafe/structured_binding_copy_ctor.rs index dad184bedf..42fb42ce66 100644 --- a/tests/unit/out/unsafe/structured_binding_copy_ctor.rs +++ b/tests/unit/out/unsafe/structured_binding_copy_ctor.rs @@ -8,16 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub static mut copies_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - MoveConstructibleUnsafe, - MoveAssignableUnsafe, - SwappableUnsafe, - Default, -)] +#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, MovableUnsafe, Default)] pub struct Counted { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/swap_map_no_copy.rs b/tests/unit/out/unsafe/swap_map_no_copy.rs index 9718b3382c..d70df0d482 100644 --- a/tests/unit/out/unsafe/swap_map_no_copy.rs +++ b/tests/unit/out/unsafe/swap_map_no_copy.rs @@ -214,16 +214,7 @@ pub static mut copy_only_copies_1: std::cell::LazyCell = pub static mut copy_only_dtors_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - MoveConstructibleUnsafe, - MoveAssignableUnsafe, - SwappableUnsafe, - Default, -)] +#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, MovableUnsafe, Default)] #[cpp_from(i32, construct, value)] pub struct CopyOnly { pub v: i32, @@ -267,9 +258,7 @@ impl Clone for CopyOnly { FnPtrArg, ZeroInitializationUnsafe, CopyConstructibleUnsafe, - MoveConstructibleUnsafe, - MoveAssignableUnsafe, - SwappableUnsafe, + MovableUnsafe, Default, )] pub struct CopyOnlyPair { From 464223b9acb308bb6b71683a72c990fa6e35c271 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Mon, 30 Nov 2026 22:51:31 +0000 Subject: [PATCH 20/20] Move swap_by_move in libcc2rs --- libcc2rs-macros/src/constructor.rs | 20 ++---------------- libcc2rs/src/lib.rs | 1 + libcc2rs/src/swap.rs | 34 +++++++++++++++++++++++++++++- 3 files changed, 36 insertions(+), 19 deletions(-) diff --git a/libcc2rs-macros/src/constructor.rs b/libcc2rs-macros/src/constructor.rs index 58745b4cd9..712a782cf7 100644 --- a/libcc2rs-macros/src/constructor.rs +++ b/libcc2rs-macros/src/constructor.rs @@ -44,16 +44,7 @@ fn impl_swap(input: &DeriveInput, is_unsafe: bool) -> TokenStream2 { quote! { impl #impl_generics ::libcc2rs::SwappableUnsafe for #name #ty_generics #where_clause { unsafe fn swap(&mut self, other: *mut Self) { - let mut tmp = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::libcc2rs::MoveConstructibleUnsafe::move_constructor( - &mut *tmp.as_mut_ptr(), - self, - ); - ::libcc2rs::MoveAssignableUnsafe::move_assign(self, other); - ::libcc2rs::MoveAssignableUnsafe::move_assign(&mut *other, tmp.as_mut_ptr()); - ::destroy(&mut *tmp.as_mut_ptr()); - } + unsafe { ::libcc2rs::swap_by_move_unsafe(self, other) } } } } @@ -61,14 +52,7 @@ fn impl_swap(input: &DeriveInput, is_unsafe: bool) -> TokenStream2 { quote! { impl #impl_generics ::libcc2rs::Swappable for #name #ty_generics #where_clause { fn swap(this: &::libcc2rs::Ptr, other: ::libcc2rs::Ptr) { - let tmp: ::libcc2rs::Value = ::std::rc::Rc::new(::std::cell::RefCell::new( - ::zero_init(), - )); - let tmp = ::libcc2rs::AsPointer::::as_pointer(&tmp); - ::libcc2rs::MoveConstructible::move_constructor(&tmp, this.clone()); - ::libcc2rs::MoveAssignable::move_assign(this, other.clone()); - ::libcc2rs::MoveAssignable::move_assign(&other, tmp.clone()); - ::destroy(&tmp); + ::libcc2rs::swap_by_move(this, other) } } } diff --git a/libcc2rs/src/lib.rs b/libcc2rs/src/lib.rs index 40dccb5361..d90f1969e9 100644 --- a/libcc2rs/src/lib.rs +++ b/libcc2rs/src/lib.rs @@ -61,6 +61,7 @@ mod initialization; pub use initialization::{ZeroInitialization, ZeroInitializationUnsafe}; mod swap; +pub use swap::{swap_by_move, swap_by_move_unsafe}; // Used by cpp_move! and cpp_move_unsafe!. #[doc(hidden)] pub mod __swap { diff --git a/libcc2rs/src/swap.rs b/libcc2rs/src/swap.rs index 611a95f6a4..5406b81667 100644 --- a/libcc2rs/src/swap.rs +++ b/libcc2rs/src/swap.rs @@ -9,9 +9,13 @@ #![allow(private_bounds, clippy::missing_safety_doc)] use std::cell::RefCell; +use std::mem::MaybeUninit; use std::rc::Rc; -use crate::constructor::{MoveConstructible, MoveConstructibleUnsafe}; +use crate::capture::{Destructible, DestructibleUnsafe}; +use crate::constructor::{ + MoveAssignable, MoveAssignableUnsafe, MoveConstructible, MoveConstructibleUnsafe, +}; use crate::initialization::ZeroInitialization; use crate::rc::{AsPointer, Ptr, Value}; use crate::reinterpret::ByteRepr; @@ -121,3 +125,31 @@ impl ConstructNoneUnsafe for &ConstructUnsafe { not_movable() } } + +pub fn swap_by_move(this: &Ptr, other: Ptr) +where + T: MoveConstructible + MoveAssignable + Destructible + ZeroInitialization, +{ + let storage: Value = Rc::new(RefCell::new(T::zero_init())); + let tmp = AsPointer::::as_pointer(&storage); + T::move_constructor(&tmp, this.clone()); + T::move_assign(this, other.clone()); + T::move_assign(&other, tmp.clone()); + T::destroy(&tmp); +} + +/// # Safety +/// `other` must point to a live value. +pub unsafe fn swap_by_move_unsafe(this: &mut T, other: *mut T) +where + T: MoveConstructibleUnsafe + MoveAssignableUnsafe + DestructibleUnsafe, +{ + let this: *mut T = this; + let mut tmp = MaybeUninit::::uninit(); + unsafe { + MoveConstructibleUnsafe::move_constructor(&mut *tmp.as_mut_ptr(), this); + MoveAssignableUnsafe::move_assign(&mut *this, other); + MoveAssignableUnsafe::move_assign(&mut *other, tmp.as_mut_ptr()); + DestructibleUnsafe::destroy(&mut *tmp.as_mut_ptr()); + } +}