From 835d0e3765db106e3b91139e341c1d0db62ddfaa Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Wed, 2 Dec 2026 12:41:09 +0000 Subject: [PATCH 01/13] Update tests --- .../out/refcount/cross_tu_tag_collision.rs | 11 +- .../out/unsafe/cross_tu_tag_collision.rs | 9 +- .../out/refcount/defaulted_move_cross_tu.rs | 24 +- .../out/unsafe/defaulted_move_cross_tu.rs | 14 +- .../out/refcount/friend_operator.rs | 11 +- .../out/unsafe/friend_operator.rs | 9 +- .../out/refcount/opaque_forward_decl.rs | 10 +- .../out/unsafe/opaque_forward_decl.rs | 9 +- .../refcount/out_of_line_methods_cross_tu.rs | 17 +- .../unsafe/out_of_line_methods_cross_tu.rs | 15 +- .../template_method_late_instantiation.rs | 14 +- .../template_method_late_instantiation.rs | 13 +- .../out/refcount/p14-class-in-two-files.rs | 19 +- .../out/unsafe/p14-class-in-two-files.rs | 17 +- .../p15-class-template-static-member.rs | 29 ++- .../p15-class-template-static-member.rs | 25 +- .../out/refcount/p15-function-template.rs | 30 ++- .../out/unsafe/p15-function-template.rs | 26 ++- .../out/refcount/p15-inline-function.rs | 8 + .../out/unsafe/p15-inline-function.rs | 8 + .../out/refcount/p15-inline-variable.rs | 8 + .../out/unsafe/p15-inline-variable.rs | 8 + .../p16-default-argument-lambda-in-class.rs | 19 +- .../p16-default-argument-lambda-in-class.rs | 17 +- .../refcount/p16-lambda-in-inline-function.rs | 8 + .../unsafe/p16-lambda-in-inline-function.rs | 8 + .../basic.link/out/refcount/basic.link.rs | 143 ++++++++++-- .../basic/basic.link/out/unsafe/basic.link.rs | 124 +++++++++- .../out/refcount/basic.scope.block.rs | 8 + .../out/refcount/basic.scope.class.rs | 30 ++- .../out/refcount/basic.scope.param.rs | 1 + .../out/refcount/basic.scope.pdecl.rs | 17 +- .../out/refcount/basic.scope.scope.rs | 180 +++++++++++++-- .../out/unsafe/basic.scope.block.rs | 8 + .../out/unsafe/basic.scope.class.rs | 28 ++- .../out/unsafe/basic.scope.param.rs | 1 + .../out/unsafe/basic.scope.pdecl.rs | 16 +- .../out/unsafe/basic.scope.scope.rs | 174 ++++++++++++-- .../out/refcount/basic.start.term-p1-exit.rs | 1 + .../out/refcount/basic.start.term.rs | 24 +- .../out/unsafe/basic.start.term-p1-exit.rs | 1 + .../out/unsafe/basic.start.term.rs | 20 +- .../out/refcount/basic.types.general.rs | 22 +- .../out/unsafe/basic.types.general.rs | 18 +- tests/std/basic/out/refcount/basic.def.odr.rs | 61 +++++ tests/std/basic/out/unsafe/basic.def.odr.rs | 63 +++++ .../out/refcount/class.base.init.rs | 1 + .../class.init/out/unsafe/class.base.init.rs | 1 + .../out/refcount/class.conv.ctor.rs | 1 + .../class.conv/out/refcount/class.conv.fct.rs | 1 + .../class.conv/out/unsafe/class.conv.ctor.rs | 1 + .../class.conv/out/unsafe/class.conv.fct.rs | 1 + .../out/refcount/class.copy.ctor.rs | 10 +- .../class.ctor/out/unsafe/class.copy.ctor.rs | 8 +- .../class.mem/out/refcount/class.free.rs | 22 +- .../out/refcount/class.mem.general.rs | 30 ++- .../class/class.mem/out/unsafe/class.free.rs | 18 +- .../class.mem/out/unsafe/class.mem.general.rs | 26 ++- .../dcl.init.general-p6.2-padding-bits.rs | 33 ++- .../dcl.init/out/refcount/dcl.init.general.rs | 108 ++++++++- .../dcl.init.general-p6.2-padding-bits.rs | 27 ++- .../dcl.init/out/unsafe/dcl.init.general.rs | 97 +++++++- .../dcl.meaning/out/refcount/dcl.array.rs | 11 +- .../out/refcount/dcl.fct.default.rs | 46 +++- .../dcl.meaning/out/refcount/dcl.mptr.rs | 56 ++++- .../dcl.meaning/out/unsafe/dcl.array.rs | 9 +- .../dcl.meaning/out/unsafe/dcl.fct.default.rs | 44 +++- .../dcl.meaning/out/unsafe/dcl.mptr.rs | 46 +++- tests/std/expr/conv/out/refcount/conv.mem.rs | 11 +- tests/std/expr/conv/out/unsafe/conv.mem.rs | 9 +- .../expr.post/out/refcount/expr.const.cast.rs | 11 +- ...nterpret.cast-p10-result-is-unspecified.rs | 22 +- .../out/refcount/expr.reinterpret.cast.rs | 44 +++- .../expr.post/out/unsafe/expr.const.cast.rs | 9 +- ...nterpret.cast-p10-result-is-unspecified.rs | 18 +- .../out/unsafe/expr.reinterpret.cast.rs | 36 ++- .../expr.unary/out/refcount/expr.pre.incr.rs | 11 +- .../expr.unary/out/refcount/expr.unary.op.rs | 33 ++- .../expr.unary/out/unsafe/expr.pre.incr.rs | 9 +- .../expr.unary/out/unsafe/expr.unary.op.rs | 27 ++- .../expr.compound/out/refcount/expr.cond.rs | 11 +- .../expr.compound/out/refcount/expr.eq.rs | 37 ++- ...ptr.oper-p6-null-pointer-to-data-member.rs | 11 +- .../out/refcount/expr.mptr.oper.rs | 35 ++- .../expr.compound/out/unsafe/expr.cond.rs | 9 +- .../expr/expr.compound/out/unsafe/expr.eq.rs | 37 ++- ...ptr.oper-p6-null-pointer-to-data-member.rs | 9 +- .../out/unsafe/expr.mptr.oper.rs | 29 ++- .../expr.prim/out/refcount/expr.prim.this.rs | 11 +- .../expr.prim/out/unsafe/expr.prim.this.rs | 10 +- .../allocator.requirements.general.rs | 33 ++- .../unsafe/allocator.requirements.general.rs | 30 ++- .../stmt.iter/out/refcount/stmt.while.rs | 2 + .../stmt.iter/out/unsafe/stmt.while.rs | 2 + .../stmt.select/out/refcount/stmt.if.rs | 7 + .../stmt.select/out/refcount/stmt.switch.rs | 8 + .../stmt.select/out/unsafe/stmt.if.rs | 7 + .../stmt.select/out/unsafe/stmt.switch.rs | 8 + tests/std/temp/out/refcount/temp.type.rs | 44 +++- tests/std/temp/out/unsafe/temp.type.rs | 36 ++- .../temp/temp.spec/out/refcount/temp.inst.rs | 44 +++- .../temp/temp.spec/out/unsafe/temp.inst.rs | 27 ++- .../utility/out/refcount/forward-helpers.rs | 22 +- .../utilities/utility/out/refcount/forward.rs | 22 +- .../utility/out/refcount/utility.as.const.rs | 11 +- .../utility/out/unsafe/forward-helpers.rs | 20 +- .../utilities/utility/out/unsafe/forward.rs | 18 +- .../utility/out/unsafe/utility.as.const.rs | 9 +- tests/ub/out/refcount/ctor_ref_member.rs | 1 + .../refcount/self_referencing_initializer.rs | 11 +- tests/ub/out/refcount/ub6.rs | 10 +- tests/ub/out/unsafe/ctor_ref_member.rs | 1 + .../unsafe/self_referencing_initializer.rs | 9 +- tests/ub/out/unsafe/ub6.rs | 9 +- tests/unit/out/refcount/05_new.rs | 22 +- tests/unit/out/refcount/10_struct.rs | 63 ++++- tests/unit/out/refcount/addr_of_global.rs | 21 +- tests/unit/out/refcount/anonymous-struct.rs | 99 +++++++- tests/unit/out/refcount/anonymous-struct_c.rs | 99 +++++++- tests/unit/out/refcount/anonymous_enum.rs | 22 +- tests/unit/out/refcount/anonymous_enum_c.rs | 22 +- tests/unit/out/refcount/any.rs | 11 +- tests/unit/out/refcount/array_const_init.rs | 22 +- tests/unit/out/refcount/array_field_addr.rs | 11 +- .../out/refcount/array_of_noncopy_struct.rs | 22 +- tests/unit/out/refcount/array_reference.rs | 11 +- tests/unit/out/refcount/as_const.rs | 11 +- tests/unit/out/refcount/assign_rhs_first.rs | 10 +- .../out/refcount/assignment_single_eval.rs | 215 ++++++++++++++++-- tests/unit/out/refcount/bounded_struct_ptr.rs | 11 +- tests/unit/out/refcount/bst.rs | 10 +- tests/unit/out/refcount/c_struct.rs | 54 ++++- tests/unit/out/refcount/cast.rs | 52 ++++- .../refcount/cast_array_to_pointer_decay.rs | 11 +- tests/unit/out/refcount/class.rs | 44 +++- .../refcount/class_template_lazy_member.rs | 55 ++++- tests/unit/out/refcount/class_templates.rs | 141 +++++++++++- tests/unit/out/refcount/clone_vs_move.rs | 32 ++- tests/unit/out/refcount/comma_operator.rs | 11 +- tests/unit/out/refcount/complex_function.rs | 41 +++- .../out/refcount/compound_assign_paren.rs | 11 +- tests/unit/out/refcount/concepts.rs | 11 +- tests/unit/out/refcount/constexpr_function.rs | 22 +- tests/unit/out/refcount/constructor.rs | 8 + .../refcount/container_element_receiver.rs | 1 + .../unit/out/refcount/container_field_addr.rs | 25 +- .../conversion_operator_same_translation.rs | 2 + tests/unit/out/refcount/copy_assign.rs | 52 ++++- tests/unit/out/refcount/copy_ctor.rs | 34 ++- .../unit/out/refcount/copy_move_defaulted.rs | 210 +++++++++++++++-- tests/unit/out/refcount/copy_move_deleted.rs | 52 ++++- tests/unit/out/refcount/default.rs | 33 ++- .../refcount/default_function_arguments.rs | 18 +- tests/unit/out/refcount/default_in_statics.rs | 31 ++- tests/unit/out/refcount/delete_array_order.rs | 1 + tests/unit/out/refcount/destructor.rs | 11 + tests/unit/out/refcount/destructor_params.rs | 12 +- .../out/refcount/destructor_temporaries.rs | 2 + tests/unit/out/refcount/doubly_linked_list.rs | 10 +- .../out/refcount/enum_default_in_static.rs | 11 +- tests/unit/out/refcount/enum_int_interop.rs | 10 +- tests/unit/out/refcount/enum_int_interop_c.rs | 10 +- .../unit/out/refcount/enum_underlying_type.rs | 22 +- tests/unit/out/refcount/exprs.rs | 21 +- tests/unit/out/refcount/fft.rs | 11 +- tests/unit/out/refcount/field_aliasing.rs | 32 ++- .../unit/out/refcount/field_array_elem_ptr.rs | 22 +- .../out/refcount/field_method_receiver.rs | 29 ++- tests/unit/out/refcount/field_pointers.rs | 38 +++- .../field_pointers_malloced_struct.rs | 11 +- .../field_reinterpret_write_through.rs | 22 +- tests/unit/out/refcount/find.rs | 11 +- .../refcount/first_field_ptr_covers_struct.rs | 22 +- .../out/refcount/first_member_downcast.rs | 22 +- .../refcount/flex_array_member_incomplete.rs | 11 +- .../flex_array_member_sibling_write.rs | 33 ++- tests/unit/out/refcount/fn_ptr.rs | 1 + tests/unit/out/refcount/fn_ptr_cast.rs | 10 +- tests/unit/out/refcount/fn_ptr_stable_sort.rs | 11 +- tests/unit/out/refcount/fn_ptr_struct.rs | 32 ++- .../unit/out/refcount/fn_ptr_typedef_cast.rs | 11 +- tests/unit/out/refcount/fn_ptr_vtable.rs | 10 +- tests/unit/out/refcount/fn_ref.rs | 10 +- .../unit/out/refcount/for_body_destructor.rs | 1 + .../refcount/foreach_disjoint_field_borrow.rs | 19 +- 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 | 44 +++- .../unit/out/refcount/function_overloading.rs | 11 +- .../out/refcount/global_call_temporaries.rs | 11 +- .../out/refcount/global_init_side_effect.rs | 1 + .../out/refcount/global_non_const_init.rs | 25 +- tests/unit/out/refcount/global_pointers.rs | 10 +- .../refcount/global_without_initializer.rs | 11 +- .../out/refcount/goto_aggregate_default.rs | 11 +- tests/unit/out/refcount/goto_cleanup.rs | 10 +- tests/unit/out/refcount/huffman.rs | 25 +- .../refcount/immutable-deref-on-func-call.rs | 11 +- tests/unit/out/refcount/implicit_autoref.rs | 18 +- .../refcount/in_class_field_initializer.rs | 61 ++++- tests/unit/out/refcount/init.rs | 11 +- tests/unit/out/refcount/init_list.rs | 40 +++- .../out/refcount/inline_container_fields.rs | 57 +++++ tests/unit/out/refcount/kruskal.rs | 41 +++- tests/unit/out/refcount/lambda_as_field.rs | 38 +++- .../out/refcount/lambda_capture_copy_ctor.rs | 14 ++ tests/unit/out/refcount/lambda_capture_ref.rs | 11 +- .../out/refcount/lambda_capture_star_this.rs | 11 +- .../unit/out/refcount/lambda_capture_this.rs | 11 +- .../unit/out/refcount/lambda_capture_value.rs | 11 +- .../unit/out/refcount/lambda_decltype_type.rs | 44 +++- .../refcount/lambda_generic_explicit_args.rs | 11 +- .../out/refcount/lambda_immediate_init.rs | 30 ++- .../out/refcount/lambda_move_only_capture.rs | 4 +- tests/unit/out/refcount/lambda_nested.rs | 11 +- .../unit/out/refcount/lambda_static_local.rs | 11 +- .../refcount/libc_struct_without_default.rs | 32 ++- tests/unit/out/refcount/linked_list.rs | 10 +- .../refcount/local_anon_struct_collision.rs | 22 +- .../out/refcount/local_record_template.rs | 44 +++- tests/unit/out/refcount/map.rs | 7 + tests/unit/out/refcount/map_key_copy_ctor.rs | 1 + tests/unit/out/refcount/map_key_identity.rs | 18 +- tests/unit/out/refcount/map_try_emplace.rs | 14 ++ .../out/refcount/map_try_emplace_lvalues.rs | 66 +++++- tests/unit/out/refcount/max.rs | 1 + .../unit/out/refcount/memcpy_struct_bytes.rs | 11 +- .../out/refcount/memcpy_struct_layouts.rs | 55 ++++- .../unit/out/refcount/memcpy_struct_struct.rs | 11 +- tests/unit/out/refcount/memset_struct_tail.rs | 11 +- tests/unit/out/refcount/move_assign.rs | 17 +- tests/unit/out/refcount/move_ctor.rs | 20 +- tests/unit/out/refcount/move_this.rs | 1 + tests/unit/out/refcount/nested_structs.rs | 66 +++++- tests/unit/out/refcount/new.rs | 11 +- tests/unit/out/refcount/new_bst.rs | 10 +- tests/unit/out/refcount/new_struct.rs | 22 +- .../refcount/nttp_distinct_specializations.rs | 33 ++- tests/unit/out/refcount/offsetof.rs | 22 +- .../unit/out/refcount/opaque_forward_decl.rs | 10 +- tests/unit/out/refcount/opaque_record_copy.rs | 22 +- .../unit/out/refcount/opaque_then_defined.rs | 20 +- .../out/refcount/operator_arithmetic_free.rs | 11 +- .../refcount/operator_arithmetic_member.rs | 11 +- .../out/refcount/operator_bitwise_free.rs | 11 +- .../out/refcount/operator_bitwise_member.rs | 11 +- .../refcount/operator_comparison_defaulted.rs | 87 ++++++- .../out/refcount/operator_comparison_free.rs | 22 +- .../refcount/operator_comparison_member.rs | 11 +- .../out/refcount/operator_comparison_mixed.rs | 11 +- .../refcount/operator_comparison_nonbool.rs | 78 ++++++- .../operator_comparison_noncopyable.rs | 10 +- .../operator_compound_assignment_free.rs | 11 +- .../operator_compound_assignment_member.rs | 11 +- tests/unit/out/refcount/operator_friend.rs | 77 ++++++- tests/unit/out/refcount/operator_less_than.rs | 11 +- .../out/refcount/operator_logical_free.rs | 11 +- .../out/refcount/operator_logical_member.rs | 11 +- .../refcount/operator_member_pointer_free.rs | 22 +- .../operator_member_pointer_member.rs | 33 ++- .../unit/out/refcount/operator_other_free.rs | 11 +- .../out/refcount/operator_other_member.rs | 12 +- tests/unit/out/refcount/operator_overloads.rs | 11 +- .../unit/out/refcount/operator_qualifiers.rs | 11 +- tests/unit/out/refcount/operator_three_way.rs | 11 +- tests/unit/out/refcount/operator_traits.rs | 55 ++++- tests/unit/out/refcount/overload_mangling.rs | 33 ++- .../refcount/pair_converting_construction.rs | 26 ++- tests/unit/out/refcount/pod.rs | 11 +- tests/unit/out/refcount/pointer_array.rs | 11 +- tests/unit/out/refcount/pointers.rs | 11 +- tests/unit/out/refcount/polymorphism.rs | 2 + tests/unit/out/refcount/ptr_cast_init.rs | 22 +- tests/unit/out/refcount/push_emplace_back.rs | 85 ++++++- tests/unit/out/refcount/random.rs | 22 +- tests/unit/out/refcount/reference_wrapper.rs | 11 +- tests/unit/out/refcount/references.rs | 21 +- tests/unit/out/refcount/refs_as_args.rs | 11 +- .../out/refcount/reinterpret_cast_ptr_cmp.rs | 33 ++- .../out/refcount/reinterpret_cast_struct.rs | 11 +- .../reinterpret_cast_struct_to_struct.rs | 22 +- tests/unit/out/refcount/reserved_keywords.rs | 33 ++- tests/unit/out/refcount/return_move.rs | 20 +- tests/unit/out/refcount/rule_of_five.rs | 4 +- tests/unit/out/refcount/rule_of_three.rs | 4 +- .../unit/out/refcount/rvalue_rule_arg_move.rs | 1 + tests/unit/out/refcount/rvalue_struct.rs | 11 +- .../scalar_builtin_construct_destruct.rs | 11 +- .../refcount/self_referencing_initializer.rs | 36 ++- .../unit/out/refcount/size_t_static_member.rs | 22 +- .../out/refcount/size_t_template_param.rs | 2 + tests/unit/out/refcount/sort_no_copy.rs | 33 ++- tests/unit/out/refcount/static_local.rs | 11 +- .../unit/out/refcount/static_var_in_class.rs | 22 +- tests/unit/out/refcount/stdcopy.rs | 1 + tests/unit/out/refcount/strdup.rs | 10 +- .../out/refcount/string_literal_ptr_init.rs | 10 +- tests/unit/out/refcount/string_substr.rs | 10 +- .../out/refcount/struct_2d_array_field.rs | 11 +- tests/unit/out/refcount/struct_ctor.rs | 19 +- .../unit/out/refcount/struct_default_ctor.rs | 52 ++++- .../refcount/struct_member_array_adjacency.rs | 11 +- tests/unit/out/refcount/struct_ptr.rs | 11 +- .../refcount/structured_binding_copy_ctor.rs | 1 + .../structured_binding_element_ctor.rs | 2 + .../refcount/structured_binding_move_ctor.rs | 13 ++ .../refcount/structured_binding_range_for.rs | 11 +- .../out/refcount/structured_binding_ref.rs | 11 +- .../refcount/structured_binding_trivial.rs | 11 +- tests/unit/out/refcount/swap_map_no_copy.rs | 82 ++++++- .../refcount/tag_vs_identifier_collision.rs | 63 ++++- .../unit/out/refcount/template_default_arg.rs | 16 ++ .../out/refcount/template_static_member.rs | 55 ++++- .../unit/out/refcount/temporary_field_addr.rs | 32 +++ .../out/refcount/temporary_field_ctor_arg.rs | 16 ++ .../out/refcount/temporary_field_two_args.rs | 31 +++ tests/unit/out/refcount/this.rs | 2 + .../unit/out/refcount/typedef-anon-struct.rs | 37 ++- .../out/refcount/unary_expr_or_type_trait.rs | 11 +- tests/unit/out/refcount/unboxed_locals.rs | 22 +- tests/unit/out/refcount/unboxed_records.rs | 36 ++- .../out/refcount/union_addrof_external.rs | 25 +- tests/unit/out/refcount/union_basic.rs | 16 +- .../unit/out/refcount/union_cross_arm_cast.rs | 36 ++- .../out/refcount/union_field_alignment.rs | 14 +- .../out/refcount/union_flex_array_member.rs | 14 +- .../unit/out/refcount/union_memset_memcpy.rs | 36 ++- tests/unit/out/refcount/union_nested.rs | 39 +++- .../out/refcount/union_pointer_pun_address.rs | 25 +- .../union_pointer_pun_writethrough.rs | 4 +- .../out/refcount/union_struct_dual_use.rs | 25 +- .../out/refcount/union_tagged_many_arms.rs | 14 +- .../unit/out/refcount/union_tagged_simple.rs | 14 +- .../out/refcount/union_tagged_struct_arms.rs | 46 +++- .../refcount/union_void_ptr_sized_deref.rs | 14 +- tests/unit/out/refcount/unique_ptr.rs | 22 +- .../out/refcount/unique_ptr_const_deref.rs | 18 +- .../out/refcount/unique_ptr_field_reset.rs | 26 ++- tests/unit/out/refcount/unique_ptr_nested.rs | 26 ++- tests/unit/out/refcount/unique_ptr_struct.rs | 11 +- tests/unit/out/refcount/va_arg_mixed_types.rs | 11 +- .../out/refcount/va_arg_non_primitive_ptrs.rs | 10 +- tests/unit/out/refcount/va_arg_struct_ctx.rs | 15 +- tests/unit/out/refcount/va_arg_void_ptr.rs | 10 +- tests/unit/out/refcount/va_list_field.rs | 21 +- tests/unit/out/refcount/vector.rs | 31 ++- .../out/refcount/vector_iter_range_ctor.rs | 2 + .../out/refcount/vector_subscript_direct.rs | 30 ++- .../out/refcount/vector_with_allocator.rs | 22 +- tests/unit/out/refcount/void_cast.rs | 44 +++- tests/unit/out/unsafe/05_new.rs | 18 +- tests/unit/out/unsafe/10_struct.rs | 53 ++++- tests/unit/out/unsafe/addr_of_global.rs | 18 +- tests/unit/out/unsafe/anonymous-struct.rs | 81 ++++++- tests/unit/out/unsafe/anonymous-struct_c.rs | 81 ++++++- tests/unit/out/unsafe/anonymous_enum.rs | 18 +- tests/unit/out/unsafe/anonymous_enum_c.rs | 18 +- tests/unit/out/unsafe/any.rs | 9 +- tests/unit/out/unsafe/array_const_init.rs | 18 +- tests/unit/out/unsafe/array_field_addr.rs | 9 +- .../out/unsafe/array_of_noncopy_struct.rs | 19 +- tests/unit/out/unsafe/array_reference.rs | 9 +- tests/unit/out/unsafe/as_const.rs | 9 +- tests/unit/out/unsafe/assign_rhs_first.rs | 9 +- .../unit/out/unsafe/assignment_single_eval.rs | 183 +++++++++++++-- tests/unit/out/unsafe/bounded_struct_ptr.rs | 9 +- tests/unit/out/unsafe/bst.rs | 9 +- tests/unit/out/unsafe/c_struct.rs | 45 +++- tests/unit/out/unsafe/cast.rs | 43 +++- .../out/unsafe/cast_array_to_pointer_decay.rs | 9 +- tests/unit/out/unsafe/class.rs | 36 ++- .../out/unsafe/class_template_lazy_member.rs | 45 +++- tests/unit/out/unsafe/class_templates.rs | 120 +++++++++- tests/unit/out/unsafe/clone_vs_move.rs | 27 ++- tests/unit/out/unsafe/comma_operator.rs | 9 +- tests/unit/out/unsafe/complex_function.rs | 36 ++- .../unit/out/unsafe/compound_assign_paren.rs | 9 +- tests/unit/out/unsafe/concepts.rs | 9 +- tests/unit/out/unsafe/constexpr_function.rs | 18 +- tests/unit/out/unsafe/constructor.rs | 8 + .../out/unsafe/container_element_receiver.rs | 1 + tests/unit/out/unsafe/container_field_addr.rs | 22 +- .../conversion_operator_same_translation.rs | 2 + tests/unit/out/unsafe/copy_assign.rs | 45 +++- tests/unit/out/unsafe/copy_ctor.rs | 31 ++- tests/unit/out/unsafe/copy_move_defaulted.rs | 176 ++++++++++++-- tests/unit/out/unsafe/copy_move_deleted.rs | 38 +++- tests/unit/out/unsafe/default.rs | 28 ++- .../out/unsafe/default_function_arguments.rs | 16 +- tests/unit/out/unsafe/default_in_statics.rs | 27 ++- tests/unit/out/unsafe/delete_array_order.rs | 1 + tests/unit/out/unsafe/destructor.rs | 11 + tests/unit/out/unsafe/destructor_params.rs | 10 +- .../unit/out/unsafe/destructor_temporaries.rs | 2 + tests/unit/out/unsafe/doubly_linked_list.rs | 9 +- .../unit/out/unsafe/enum_default_in_static.rs | 9 +- tests/unit/out/unsafe/enum_int_interop.rs | 9 +- tests/unit/out/unsafe/enum_int_interop_c.rs | 9 +- tests/unit/out/unsafe/enum_underlying_type.rs | 15 +- tests/unit/out/unsafe/exprs.rs | 18 +- tests/unit/out/unsafe/fft.rs | 9 +- tests/unit/out/unsafe/field_aliasing.rs | 27 ++- tests/unit/out/unsafe/field_array_elem_ptr.rs | 18 +- .../unit/out/unsafe/field_method_receiver.rs | 22 +- tests/unit/out/unsafe/field_pointers.rs | 33 ++- .../unsafe/field_pointers_malloced_struct.rs | 9 +- .../unsafe/field_reinterpret_write_through.rs | 18 +- tests/unit/out/unsafe/find.rs | 9 +- .../unsafe/first_field_ptr_covers_struct.rs | 18 +- .../unit/out/unsafe/first_member_downcast.rs | 18 +- .../unsafe/flex_array_member_incomplete.rs | 10 +- .../unsafe/flex_array_member_sibling_write.rs | 27 ++- tests/unit/out/unsafe/fn_ptr.rs | 1 + tests/unit/out/unsafe/fn_ptr_cast.rs | 9 +- tests/unit/out/unsafe/fn_ptr_stable_sort.rs | 9 +- tests/unit/out/unsafe/fn_ptr_struct.rs | 27 ++- tests/unit/out/unsafe/fn_ptr_typedef_cast.rs | 9 +- tests/unit/out/unsafe/fn_ptr_vtable.rs | 9 +- tests/unit/out/unsafe/fn_ref.rs | 9 +- tests/unit/out/unsafe/for_body_destructor.rs | 1 + .../unsafe/foreach_disjoint_field_borrow.rs | 16 +- 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 | 36 ++- tests/unit/out/unsafe/function_overloading.rs | 9 +- .../out/unsafe/global_call_temporaries.rs | 9 +- .../out/unsafe/global_init_side_effect.rs | 1 + .../unit/out/unsafe/global_non_const_init.rs | 23 +- tests/unit/out/unsafe/global_pointers.rs | 9 +- .../out/unsafe/global_without_initializer.rs | 9 +- .../unit/out/unsafe/goto_aggregate_default.rs | 9 +- tests/unit/out/unsafe/goto_cleanup.rs | 9 +- tests/unit/out/unsafe/huffman.rs | 23 +- .../unsafe/immutable-deref-on-func-call.rs | 9 +- tests/unit/out/unsafe/implicit_autoref.rs | 15 +- .../out/unsafe/in_class_field_initializer.rs | 41 +++- tests/unit/out/unsafe/init.rs | 9 +- tests/unit/out/unsafe/init_list.rs | 34 ++- .../out/unsafe/inline_container_fields.rs | 42 ++++ tests/unit/out/unsafe/kruskal.rs | 35 ++- tests/unit/out/unsafe/lambda_as_field.rs | 38 +++- .../out/unsafe/lambda_capture_copy_ctor.rs | 14 ++ tests/unit/out/unsafe/lambda_capture_ref.rs | 9 +- .../out/unsafe/lambda_capture_star_this.rs | 9 +- tests/unit/out/unsafe/lambda_capture_this.rs | 9 +- tests/unit/out/unsafe/lambda_capture_value.rs | 9 +- tests/unit/out/unsafe/lambda_decltype_type.rs | 42 +++- .../unsafe/lambda_generic_explicit_args.rs | 9 +- .../unit/out/unsafe/lambda_immediate_init.rs | 25 +- .../out/unsafe/lambda_move_only_capture.rs | 4 +- tests/unit/out/unsafe/lambda_nested.rs | 9 +- tests/unit/out/unsafe/lambda_static_local.rs | 9 +- .../out/unsafe/libc_struct_without_default.rs | 26 ++- tests/unit/out/unsafe/linked_list.rs | 9 +- .../out/unsafe/local_anon_struct_collision.rs | 18 +- .../unit/out/unsafe/local_record_template.rs | 36 ++- tests/unit/out/unsafe/map.rs | 7 + tests/unit/out/unsafe/map_key_copy_ctor.rs | 1 + tests/unit/out/unsafe/map_key_identity.rs | 16 +- tests/unit/out/unsafe/map_try_emplace.rs | 14 ++ .../out/unsafe/map_try_emplace_lvalues.rs | 59 ++++- tests/unit/out/unsafe/max.rs | 1 + tests/unit/out/unsafe/memcpy_struct_bytes.rs | 9 +- .../unit/out/unsafe/memcpy_struct_layouts.rs | 45 +++- tests/unit/out/unsafe/memcpy_struct_struct.rs | 9 +- tests/unit/out/unsafe/memset_struct_tail.rs | 9 +- tests/unit/out/unsafe/move_assign.rs | 15 +- tests/unit/out/unsafe/move_ctor.rs | 18 +- tests/unit/out/unsafe/move_this.rs | 1 + tests/unit/out/unsafe/nested_structs.rs | 54 ++++- tests/unit/out/unsafe/new.rs | 9 +- tests/unit/out/unsafe/new_bst.rs | 9 +- tests/unit/out/unsafe/new_struct.rs | 18 +- .../unsafe/nttp_distinct_specializations.rs | 27 ++- tests/unit/out/unsafe/offsetof.rs | 19 +- tests/unit/out/unsafe/opaque_forward_decl.rs | 9 +- tests/unit/out/unsafe/opaque_record_copy.rs | 18 +- tests/unit/out/unsafe/opaque_then_defined.rs | 18 +- .../out/unsafe/operator_arithmetic_free.rs | 9 +- .../out/unsafe/operator_arithmetic_member.rs | 9 +- .../unit/out/unsafe/operator_bitwise_free.rs | 9 +- .../out/unsafe/operator_bitwise_member.rs | 9 +- .../unsafe/operator_comparison_defaulted.rs | 72 +++++- .../out/unsafe/operator_comparison_free.rs | 18 +- .../out/unsafe/operator_comparison_member.rs | 9 +- .../out/unsafe/operator_comparison_mixed.rs | 9 +- .../out/unsafe/operator_comparison_nonbool.rs | 64 +++++- .../unsafe/operator_comparison_noncopyable.rs | 8 +- .../operator_compound_assignment_free.rs | 9 +- .../operator_compound_assignment_member.rs | 9 +- tests/unit/out/unsafe/operator_friend.rs | 63 ++++- tests/unit/out/unsafe/operator_less_than.rs | 9 +- .../unit/out/unsafe/operator_logical_free.rs | 9 +- .../out/unsafe/operator_logical_member.rs | 9 +- .../unsafe/operator_member_pointer_free.rs | 18 +- .../unsafe/operator_member_pointer_member.rs | 27 ++- tests/unit/out/unsafe/operator_other_free.rs | 9 +- .../unit/out/unsafe/operator_other_member.rs | 10 +- tests/unit/out/unsafe/operator_overloads.rs | 9 +- tests/unit/out/unsafe/operator_qualifiers.rs | 9 +- tests/unit/out/unsafe/operator_three_way.rs | 9 +- tests/unit/out/unsafe/operator_traits.rs | 45 +++- tests/unit/out/unsafe/overload_mangling.rs | 27 ++- .../unsafe/pair_converting_construction.rs | 24 +- tests/unit/out/unsafe/pod.rs | 9 +- tests/unit/out/unsafe/pointer_array.rs | 9 +- tests/unit/out/unsafe/pointers.rs | 9 +- tests/unit/out/unsafe/polymorphism.rs | 2 + tests/unit/out/unsafe/ptr_cast_init.rs | 18 +- tests/unit/out/unsafe/push_emplace_back.rs | 72 +++++- tests/unit/out/unsafe/random.rs | 18 +- tests/unit/out/unsafe/reference_wrapper.rs | 9 +- tests/unit/out/unsafe/references.rs | 18 +- tests/unit/out/unsafe/refs_as_args.rs | 9 +- .../out/unsafe/reinterpret_cast_ptr_cmp.rs | 27 ++- .../out/unsafe/reinterpret_cast_struct.rs | 9 +- .../reinterpret_cast_struct_to_struct.rs | 18 +- tests/unit/out/unsafe/reserved_keywords.rs | 27 ++- tests/unit/out/unsafe/return_move.rs | 18 +- tests/unit/out/unsafe/rule_of_five.rs | 10 +- tests/unit/out/unsafe/rule_of_three.rs | 10 +- tests/unit/out/unsafe/rvalue_rule_arg_move.rs | 1 + tests/unit/out/unsafe/rvalue_struct.rs | 9 +- .../scalar_builtin_construct_destruct.rs | 9 +- .../unsafe/self_referencing_initializer.rs | 31 ++- tests/unit/out/unsafe/size_t_static_member.rs | 18 +- .../unit/out/unsafe/size_t_template_param.rs | 2 + tests/unit/out/unsafe/sort_no_copy.rs | 26 ++- tests/unit/out/unsafe/static_local.rs | 9 +- tests/unit/out/unsafe/static_var_in_class.rs | 18 +- tests/unit/out/unsafe/stdcopy.rs | 1 + tests/unit/out/unsafe/strdup.rs | 9 +- .../out/unsafe/string_literal_ptr_init.rs | 9 +- tests/unit/out/unsafe/string_substr.rs | 9 +- .../unit/out/unsafe/struct_2d_array_field.rs | 9 +- tests/unit/out/unsafe/struct_ctor.rs | 17 +- tests/unit/out/unsafe/struct_default_ctor.rs | 44 +++- .../unsafe/struct_member_array_adjacency.rs | 9 +- tests/unit/out/unsafe/struct_ptr.rs | 9 +- .../unsafe/structured_binding_copy_ctor.rs | 1 + .../unsafe/structured_binding_element_ctor.rs | 2 + .../unsafe/structured_binding_move_ctor.rs | 12 + .../unsafe/structured_binding_range_for.rs | 9 +- .../unit/out/unsafe/structured_binding_ref.rs | 9 +- .../out/unsafe/structured_binding_trivial.rs | 9 +- tests/unit/out/unsafe/swap_map_no_copy.rs | 72 +++++- .../out/unsafe/tag_vs_identifier_collision.rs | 65 +++++- tests/unit/out/unsafe/template_default_arg.rs | 16 ++ .../unit/out/unsafe/template_static_member.rs | 45 +++- tests/unit/out/unsafe/temporary_field_addr.rs | 26 +++ .../out/unsafe/temporary_field_ctor_arg.rs | 13 ++ .../out/unsafe/temporary_field_two_args.rs | 25 ++ tests/unit/out/unsafe/this.rs | 2 + tests/unit/out/unsafe/typedef-anon-struct.rs | 24 +- .../out/unsafe/unary_expr_or_type_trait.rs | 9 +- tests/unit/out/unsafe/unboxed_locals.rs | 18 +- tests/unit/out/unsafe/unboxed_records.rs | 31 ++- .../unit/out/unsafe/union_addrof_external.rs | 28 ++- tests/unit/out/unsafe/union_basic.rs | 40 +++- tests/unit/out/unsafe/union_cross_arm_cast.rs | 37 ++- .../unit/out/unsafe/union_field_alignment.rs | 19 +- .../out/unsafe/union_flex_array_member.rs | 19 +- tests/unit/out/unsafe/union_memset_memcpy.rs | 37 ++- tests/unit/out/unsafe/union_nested.rs | 47 +++- .../out/unsafe/union_pointer_pun_address.rs | 28 ++- .../unsafe/union_pointer_pun_writethrough.rs | 10 +- .../unit/out/unsafe/union_struct_dual_use.rs | 28 ++- .../unit/out/unsafe/union_tagged_many_arms.rs | 19 +- tests/unit/out/unsafe/union_tagged_simple.rs | 19 +- .../out/unsafe/union_tagged_struct_arms.rs | 46 +++- .../out/unsafe/union_void_ptr_sized_deref.rs | 19 +- tests/unit/out/unsafe/unique_ptr.rs | 19 +- .../unit/out/unsafe/unique_ptr_const_deref.rs | 15 +- .../unit/out/unsafe/unique_ptr_field_reset.rs | 23 +- tests/unit/out/unsafe/unique_ptr_nested.rs | 21 +- tests/unit/out/unsafe/unique_ptr_struct.rs | 9 +- tests/unit/out/unsafe/va_arg_mixed_types.rs | 9 +- .../out/unsafe/va_arg_non_primitive_ptrs.rs | 9 +- tests/unit/out/unsafe/va_arg_struct_ctx.rs | 19 +- tests/unit/out/unsafe/va_arg_void_ptr.rs | 9 +- tests/unit/out/unsafe/va_list_field.rs | 18 +- tests/unit/out/unsafe/vector.rs | 26 ++- .../unit/out/unsafe/vector_iter_range_ctor.rs | 2 + .../out/unsafe/vector_subscript_direct.rs | 25 +- .../unit/out/unsafe/vector_with_allocator.rs | 18 +- tests/unit/out/unsafe/void_cast.rs | 36 ++- 590 files changed, 12040 insertions(+), 1147 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 70ce781b92..2ff45ea821 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 @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct widget { 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 81ce74dc03..2f0394ae47 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 @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 21ff4464c1..934ef84c52 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 @@ -7,7 +7,15 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Destructible, Memberwise, Swappable, + Record, + ByteRepr, + ZeroInitialization, + FnPtrArg, + CppFrom, + Destructible, + DefaultConstructible, + Memberwise, + Swappable, )] #[memberwise(move_constructor, move_assign)] #[cpp_from(i32, construct, value)] @@ -46,6 +54,13 @@ pub struct T { #[byte_size(24)] pub v: Vec, } +impl DefaultConstructible for T { + fn default_constructor(this: &Ptr) { + { + TImpl::construct_1(this); + } + } +} pub fn sum_0(s: Ptr) -> i32 { return ({ ({ (((*s.upgrade().deref()).v.len()) as i32) } + { (array_elem!(s, n, 0).read()) }) @@ -79,7 +94,8 @@ pub fn shuffle_1(mut x: i32) -> i32 { let t: Value = Rc::new(RefCell::new(T { v: Vec::from([1]) })); let u: Value = Rc::new(RefCell::new(::zero_init())); MoveConstructible::move_constructor(&u.as_pointer(), { t.as_pointer() }); - let w: Value = Rc::new(RefCell::new(::default())); + let w: Value = Rc::new(RefCell::new(::zero_init())); + TImpl::construct_1(&w.as_pointer()); ({ MoveAssignable::move_assign(&w.as_pointer(), u.as_pointer()) }); assert!( ((({ TImpl::size(&t.as_pointer(),) }) == 0) && (({ TImpl::size(&u.as_pointer(),) }) == 0)) @@ -98,10 +114,14 @@ impl SImpl for Ptr { } pub trait TImpl { fn size(&self) -> i32; + fn construct_1(&self); } impl TImpl for Ptr { fn size(&self) -> i32 { return (((*(*self).upgrade().deref()).v.len()) as i32); } + fn construct_1(&self) { + field!((*self), v).write(Vec::new()); + } } 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 fc9d2f15e6..0b9dfcf93a 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 @@ -12,6 +12,7 @@ use std::rc::Rc; ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, SwappableUnsafe, Default, @@ -48,6 +49,16 @@ impl T { pub unsafe fn size(&self) -> i32 { return ((self.v.len()) as i32); } + pub unsafe fn construct_1(&mut self) { + (&raw mut self.v).write(Vec::new()); + } +} +impl DefaultConstructibleUnsafe for T { + unsafe fn default_constructor(&mut self) { + unsafe { + T::construct_1(&mut *self); + } + } } pub unsafe fn sum_0(s: *const S) -> i32 { return (((((*s).v.len()) as i32) + ((*s).n[(0) as usize])) + ((*s).n[(1) as usize])); @@ -82,7 +93,8 @@ pub unsafe fn shuffle_1(mut x: i32) -> i32 { let mut t: T = T { v: Vec::from([1]) }; let mut u: T = ::zero_init(); MoveConstructibleUnsafe::move_constructor(&mut u, { &mut t }); - let mut w: T = ::default(); + let mut w: T = ::zero_init(); + T::construct_1(&mut w); (unsafe { MoveAssignableUnsafe::move_assign(&mut w, &mut u) }); assert!( (((unsafe { T::size(&t,) }) == (0)) && ((unsafe { T::size(&u,) }) == (0))) 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 5a6904297e..9e742a44d9 100644 --- a/tests/multi-file/friend_operator/out/refcount/friend_operator.rs +++ b/tests/multi-file/friend_operator/out/refcount/friend_operator.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct S { 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 a4b028e173..69fd6cb896 100644 --- a/tests/multi-file/friend_operator/out/unsafe/friend_operator.rs +++ b/tests/multi-file/friend_operator/out/unsafe/friend_operator.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct S { pub a: 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 f9cfd7c604..f25a835f7f 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 @@ -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, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct container { 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 9b0aa0cf07..56fb7240a8 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 @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct container { pub p: *mut opaque, 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 ec2e9aa614..d430a37c9c 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 @@ -13,6 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, + DefaultConstructible, Memberwise, CopyConstructible, Movable, @@ -24,7 +25,9 @@ pub struct S { #[offset(0)] pub v: i32, } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Default)] +#[derive( + Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, DefaultConstructible, Default, +)] #[byte_size(4)] pub struct M { #[offset(0)] @@ -42,6 +45,7 @@ pub trait Base { VaArg, FnPtrArg, Destructible, + DefaultConstructible, Copyable, Default, )] @@ -51,7 +55,16 @@ pub struct Derived { pub factor: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Pair { 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 1b9a4ef84b..fc2f5e5a5d 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 @@ -12,6 +12,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, @@ -27,7 +28,9 @@ impl S { } } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, Default)] +#[derive( + FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, DefaultConstructibleUnsafe, Default, +)] pub struct M { pub v: i32, } @@ -43,6 +46,7 @@ pub unsafe trait Base { FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, CopyableUnsafe, Default, )] @@ -52,7 +56,14 @@ pub struct Derived { impl Derived {} #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Pair { pub first: 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 0c6a4af038..03370fce30 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 @@ -12,6 +12,13 @@ pub struct S_int_ { #[offset(0)] pub x: i32, } +impl DefaultConstructible for S_int_ { + fn default_constructor(this: &Ptr) { + { + S_int_Impl::construct_1(this); + } + } +} impl Default for S_int_ { fn default() -> Self { { S_int_ { x: 0 } } @@ -22,7 +29,8 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let p: Value = Rc::new(RefCell::new(::default())); + let p: Value = Rc::new(RefCell::new(::zero_init())); + S_int_Impl::construct_1(&p.as_pointer()); ({ S_int_Impl::set(&p.as_pointer(), 3) }); assert!((({ f_0((p.as_pointer()),) }) == 3)); return 0; @@ -35,11 +43,15 @@ pub trait S_int_Impl { fn get(&self) -> i32 { unimplemented!() } + fn construct_1(&self); } impl S_int_Impl for Ptr { fn set(&self, mut v: i32) { field!((*self), x).write(v); } + fn construct_1(&self) { + field!((*self), x).write(0); + } fn get(&self) -> i32 { return (*self).with(|__s| __s.x); } 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 cfa1a21e68..0edc9fed0c 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 @@ -15,6 +15,16 @@ impl S_int_ { pub unsafe fn set(&mut self, mut v: i32) { self.x = v; } + pub unsafe fn construct_1(&mut self) { + (&raw mut self.x).write(0); + } +} +impl DefaultConstructibleUnsafe for S_int_ { + unsafe fn default_constructor(&mut self) { + unsafe { + S_int_::construct_1(&mut *self); + } + } } impl Default for S_int_ { fn default() -> Self { @@ -28,7 +38,8 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut p: S_int_ = ::default(); + let mut p: S_int_ = ::zero_init(); + S_int_::construct_1(&mut p); (unsafe { S_int_::set(&mut p, 3) }); assert!(((unsafe { f_0((&mut p as *mut S_int_),) }) == (3))); return 0; 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 f1e0b0a9ac..1b0cc37e8c 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 @@ -66,6 +66,13 @@ impl Clone for LifetimeTracked { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } +impl DefaultConstructible for LifetimeTracked { + fn default_constructor(this: &Ptr) { + { + LifetimeTrackedImpl::construct(this); + } + } +} impl Default for LifetimeTracked { fn default() -> Self { { @@ -85,6 +92,7 @@ impl Default for LifetimeTracked { ZeroInitialization, VaArg, FnPtrArg, + DefaultConstructible, Memberwise, CopyConstructible, Movable, @@ -124,7 +132,16 @@ thread_local!( }; ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct 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 4acf156250..28e9bf3de6 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 @@ -58,6 +58,13 @@ impl Clone for LifetimeTracked { } } } +impl DefaultConstructibleUnsafe for LifetimeTracked { + unsafe fn default_constructor(&mut self) { + unsafe { + LifetimeTracked::construct(&mut *self); + } + } +} impl Default for LifetimeTracked { fn default() -> Self { unsafe { @@ -75,6 +82,7 @@ impl Default for LifetimeTracked { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, @@ -115,7 +123,14 @@ pub static mut shared_5: std::cell::LazyCell = }); #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct HasInlineMembers {} impl HasInlineMembers { 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 cb1d7b0b33..7899fdd3b9 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 @@ -66,6 +66,13 @@ impl Clone for LifetimeTracked { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } +impl DefaultConstructible for LifetimeTracked { + fn default_constructor(this: &Ptr) { + { + LifetimeTrackedImpl::construct(this); + } + } +} impl Default for LifetimeTracked { fn default() -> Self { { @@ -92,7 +99,16 @@ thread_local!( }; ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct HasStaticMember_int_ {} @@ -110,7 +126,16 @@ thread_local!( }; ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct HasStaticMember_long_ {} 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 4f9c613945..34723b507b 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 @@ -58,6 +58,13 @@ impl Clone for LifetimeTracked { } } } +impl DefaultConstructibleUnsafe for LifetimeTracked { + unsafe fn default_constructor(&mut self) { + unsafe { + LifetimeTracked::construct(&mut *self); + } + } +} impl Default for LifetimeTracked { fn default() -> Self { unsafe { @@ -85,7 +92,14 @@ pub static mut member_4: std::cell::LazyCell = }); #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct HasStaticMember_int_ {} pub static mut member_5: std::cell::LazyCell = @@ -104,7 +118,14 @@ pub static mut member_5: std::cell::LazyCell = }); #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct HasStaticMember_long_ {} pub fn main() { 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 9f01a7d5fd..2f991637b6 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 @@ -66,6 +66,13 @@ impl Clone for LifetimeTracked { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } +impl DefaultConstructible for LifetimeTracked { + fn default_constructor(this: &Ptr) { + { + LifetimeTrackedImpl::construct(this); + } + } +} impl Default for LifetimeTracked { fn default() -> Self { { @@ -85,6 +92,7 @@ impl Default for LifetimeTracked { ZeroInitialization, VaArg, FnPtrArg, + DefaultConstructible, Memberwise, CopyConstructible, Movable, @@ -186,7 +194,16 @@ fn main_0() -> i32 { return 0; } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct S_14 {} @@ -219,7 +236,16 @@ pub fn b_count_local_15() -> i32 { return ({ count_18() }); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct S_21 {} 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 6be3fc1d68..38f21a50d2 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 @@ -58,6 +58,13 @@ impl Clone for LifetimeTracked { } } } +impl DefaultConstructibleUnsafe for LifetimeTracked { + unsafe fn default_constructor(&mut self) { + unsafe { + LifetimeTracked::construct(&mut *self); + } + } +} impl Default for LifetimeTracked { fn default() -> Self { unsafe { @@ -75,6 +82,7 @@ impl Default for LifetimeTracked { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, @@ -172,7 +180,14 @@ unsafe fn main_0() -> i32 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct S_14 {} pub unsafe fn count_18() -> i32 { @@ -203,7 +218,14 @@ pub unsafe fn b_count_local_15() -> i32 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct S_21 {} pub unsafe fn __cpp2rust_init_globals() { 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 21dd819328..51af8a0b32 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 @@ -66,6 +66,13 @@ impl Clone for LifetimeTracked { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } +impl DefaultConstructible for LifetimeTracked { + fn default_constructor(this: &Ptr) { + { + LifetimeTrackedImpl::construct(this); + } + } +} impl Default for LifetimeTracked { fn default() -> Self { { @@ -85,6 +92,7 @@ impl Default for LifetimeTracked { ZeroInitialization, VaArg, FnPtrArg, + DefaultConstructible, Memberwise, CopyConstructible, Movable, 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 5b69c600e5..ffa52931a5 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 @@ -58,6 +58,13 @@ impl Clone for LifetimeTracked { } } } +impl DefaultConstructibleUnsafe for LifetimeTracked { + unsafe fn default_constructor(&mut self) { + unsafe { + LifetimeTracked::construct(&mut *self); + } + } +} impl Default for LifetimeTracked { fn default() -> Self { unsafe { @@ -75,6 +82,7 @@ impl Default for LifetimeTracked { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, 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 2325ffd6e3..6665a3cab5 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 @@ -66,6 +66,13 @@ impl Clone for LifetimeTracked { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } +impl DefaultConstructible for LifetimeTracked { + fn default_constructor(this: &Ptr) { + { + LifetimeTrackedImpl::construct(this); + } + } +} impl Default for LifetimeTracked { fn default() -> Self { { @@ -85,6 +92,7 @@ impl Default for LifetimeTracked { ZeroInitialization, VaArg, FnPtrArg, + DefaultConstructible, Memberwise, CopyConstructible, Movable, 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 b7906a551a..5ad038b95e 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 @@ -58,6 +58,13 @@ impl Clone for LifetimeTracked { } } } +impl DefaultConstructibleUnsafe for LifetimeTracked { + unsafe fn default_constructor(&mut self) { + unsafe { + LifetimeTracked::construct(&mut *self); + } + } +} impl Default for LifetimeTracked { fn default() -> Self { unsafe { @@ -75,6 +82,7 @@ impl Default for LifetimeTracked { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, 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 a443bd6e03..22ed9c3830 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 @@ -66,6 +66,13 @@ impl Clone for LifetimeTracked { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } +impl DefaultConstructible for LifetimeTracked { + fn default_constructor(this: &Ptr) { + { + LifetimeTrackedImpl::construct(this); + } + } +} impl Default for LifetimeTracked { fn default() -> Self { { @@ -85,6 +92,7 @@ impl Default for LifetimeTracked { ZeroInitialization, VaArg, FnPtrArg, + DefaultConstructible, Memberwise, CopyConstructible, Movable, @@ -102,7 +110,16 @@ impl Destructible for AssertsDtorCountAtExit { } } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct X {} 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 bac67f99e0..d978b37d13 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 @@ -58,6 +58,13 @@ impl Clone for LifetimeTracked { } } } +impl DefaultConstructibleUnsafe for LifetimeTracked { + unsafe fn default_constructor(&mut self) { + unsafe { + LifetimeTracked::construct(&mut *self); + } + } +} impl Default for LifetimeTracked { fn default() -> Self { unsafe { @@ -75,6 +82,7 @@ impl Default for LifetimeTracked { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, @@ -91,7 +99,14 @@ impl DestructibleUnsafe for AssertsDtorCountAtExit { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct X {} impl X { 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 1f3ed0b777..5ac131b701 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 @@ -66,6 +66,13 @@ impl Clone for LifetimeTracked { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } +impl DefaultConstructible for LifetimeTracked { + fn default_constructor(this: &Ptr) { + { + LifetimeTrackedImpl::construct(this); + } + } +} impl Default for LifetimeTracked { fn default() -> Self { { @@ -85,6 +92,7 @@ impl Default for LifetimeTracked { ZeroInitialization, VaArg, FnPtrArg, + DefaultConstructible, Memberwise, CopyConstructible, Movable, 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 6e9beddd62..b50e4fd3d8 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 @@ -58,6 +58,13 @@ impl Clone for LifetimeTracked { } } } +impl DefaultConstructibleUnsafe for LifetimeTracked { + unsafe fn default_constructor(&mut self) { + unsafe { + LifetimeTracked::construct(&mut *self); + } + } +} impl Default for LifetimeTracked { fn default() -> Self { unsafe { @@ -75,6 +82,7 @@ impl Default for LifetimeTracked { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, 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 1b51239747..73faaa229a 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,9 @@ 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, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, +)] #[byte_size(4)] pub struct anon_13 { #[offset(0)] @@ -73,6 +75,13 @@ pub struct Record_19 { #[offset(0)] pub id: i32, } +impl DefaultConstructible for Record_19 { + fn default_constructor(this: &Ptr) { + { + Record_19Impl::construct_1(this); + } + } +} impl Default for Record_19 { fn default() -> Self { { Record_19 { id: 100 } } @@ -85,8 +94,9 @@ pub fn test_21() { assert!((({ bump_18() }) == 2)); assert!((({ bump_in_b_22() }) == 51)); assert!((counter_17.with(|rc| *rc.borrow()) == 2)); - let mut record: Record_19 = ::default(); - assert!((record.id == 100)); + let record: Value = Rc::new(RefCell::new(::zero_init())); + Record_19Impl::construct_1(&record.as_pointer()); + assert!(({ (*record.borrow()).id } == 100)); assert!((({ record_id_in_b_23() }) == 200)); assert!((depth_20.with(|rc| *rc.borrow()) == 3)); assert!((({ depth_in_b_24() }) == 4)); @@ -104,7 +114,16 @@ pub fn test_29() { assert!((({ raise_30(1,) }) == 11)); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct Tally_31 {} @@ -118,7 +137,16 @@ pub fn test_33() { assert!((total_32.with(|rc| *rc.borrow()) == 11)); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct p5_members_of_class_with_external_linkage_Ledger {} @@ -175,12 +203,14 @@ thread_local!( static count_48: Value = Rc::new(RefCell::new(1)); ); pub fn first_key_51() -> i32 { - let mut entry: Entry_52 = ::default(); - return entry.key; + let entry: Value = Rc::new(RefCell::new(::zero_init())); + Entry_52Impl::construct_1(&entry.as_pointer()); + return { (*entry.borrow()).key }; } pub fn second_key_plus_value_53() -> i32 { - let mut entry: Entry_54 = ::default(); - return (entry.key + entry.value); + let entry: Value = Rc::new(RefCell::new(::zero_init())); + Entry_54Impl::construct_1(&entry.as_pointer()); + return ({ (*entry.borrow()).key } + { (*entry.borrow()).value }); } pub fn test_55() { assert!((({ first_key_51() }) == 1)); @@ -193,6 +223,13 @@ pub struct Entry_52 { #[offset(0)] pub key: i32, } +impl DefaultConstructible for Entry_52 { + fn default_constructor(this: &Ptr) { + { + Entry_52Impl::construct_1(this); + } + } +} impl Default for Entry_52 { fn default() -> Self { { Entry_52 { key: 1 } } @@ -206,6 +243,13 @@ pub struct Entry_54 { #[offset(4)] pub value: i32, } +impl DefaultConstructible for Entry_54 { + fn default_constructor(this: &Ptr) { + { + Entry_54Impl::construct_1(this); + } + } +} impl Default for Entry_54 { fn default() -> Self { { Entry_54 { key: 2, value: 30 } } @@ -270,7 +314,9 @@ thread_local!( pub fn ceiling_address_in_b_12() -> Ptr { return (ceiling_10.with(|v| v.as_pointer())); } -#[derive(VaArg, FnPtrArg, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, +)] #[byte_size(4)] pub struct anon_62 { #[offset(0)] @@ -316,6 +362,13 @@ pub struct Record_65 { #[offset(8)] pub extra: i32, } +impl DefaultConstructible for Record_65 { + fn default_constructor(this: &Ptr) { + { + Record_65Impl::construct_1(this); + } + } +} impl Default for Record_65 { fn default() -> Self { { @@ -333,8 +386,9 @@ pub fn bump_in_b_22() -> i32 { return ({ bump_64() }); } pub fn record_id_in_b_23() -> i32 { - let mut record: Record_65 = ::default(); - return (record.id as i32); + let record: Value = Rc::new(RefCell::new(::zero_init())); + Record_65Impl::construct_1(&record.as_pointer()); + return ({ (*record.borrow()).id } as i32); } pub fn depth_in_b_24() -> i32 { return depth_66.with(|rc| *rc.borrow()); @@ -353,7 +407,16 @@ pub fn raise_30(mut by: i32) -> i32 { return level_28.with(|rc| *rc.borrow()); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct Tally_67 {} @@ -393,8 +456,9 @@ thread_local!( static count_70: Value = Rc::new(RefCell::new(0)); ); pub fn key_in_b_56() -> i32 { - let mut entry: Entry_71 = ::default(); - return (entry.key as i32); + let entry: Value = Rc::new(RefCell::new(::zero_init())); + Entry_71Impl::construct_1(&entry.as_pointer()); + return ({ (*entry.borrow()).key } as i32); } #[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable)] #[byte_size(8)] @@ -402,6 +466,13 @@ pub struct Entry_71 { #[offset(0)] pub key: i64, } +impl DefaultConstructible for Entry_71 { + fn default_constructor(this: &Ptr) { + { + Entry_71Impl::construct_1(this); + } + } +} impl Default for Entry_71 { fn default() -> Self { { Entry_71 { key: 400_i64 } } @@ -422,6 +493,48 @@ pub fn table_sum_in_b_59() -> i32 { table_57.with(|rc| rc.borrow()[__idx0]) })); } +pub trait Entry_52Impl { + fn construct_1(&self); +} +impl Entry_52Impl for Ptr { + fn construct_1(&self) { + field!((*self), key).write(1); + } +} +pub trait Entry_54Impl { + fn construct_1(&self); +} +impl Entry_54Impl for Ptr { + fn construct_1(&self) { + field!((*self), key).write(2); + field!((*self), value).write(30); + } +} +pub trait Entry_71Impl { + fn construct_1(&self); +} +impl Entry_71Impl for Ptr { + fn construct_1(&self) { + field!((*self), key).write(400_i64); + } +} +pub trait Record_19Impl { + fn construct_1(&self); +} +impl Record_19Impl for Ptr { + fn construct_1(&self) { + field!((*self), id).write(100); + } +} +pub trait Record_65Impl { + fn construct_1(&self); +} +impl Record_65Impl for Ptr { + fn construct_1(&self) { + field!((*self), id).write(200_i64); + field!((*self), extra).write(1); + } +} pub trait Tally_31Impl { fn add(&self, amount: i32) -> i32; } 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 bc7bda2b28..ba5cfb1869 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,15 @@ pub unsafe fn test_11() { ); } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, +)] pub union anon_13 { pub whole: i32, pub fraction: f32, @@ -64,6 +72,18 @@ pub unsafe fn bump_18() -> i32 { pub struct Record_19 { pub id: i32, } +impl Record_19 { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.id).write(100); + } +} +impl DefaultConstructibleUnsafe for Record_19 { + unsafe fn default_constructor(&mut self) { + unsafe { + Record_19::construct_1(&mut *self); + } + } +} impl Default for Record_19 { fn default() -> Self { unsafe { Record_19 { id: 100 } } @@ -74,7 +94,8 @@ pub unsafe fn test_21() { assert!(((unsafe { bump_18() }) == (2))); assert!(((unsafe { bump_in_b_22() }) == (51))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut counter_17)) == (2))); - let mut record: Record_19 = ::default(); + let mut record: Record_19 = ::zero_init(); + Record_19::construct_1(&mut record); assert!(((record.id) == (100))); assert!(((unsafe { record_id_in_b_23() }) == (200))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut depth_20)) == (3))); @@ -94,7 +115,14 @@ pub unsafe fn test_29() { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Tally_31 {} impl Tally_31 { @@ -112,7 +140,14 @@ pub unsafe fn test_33() { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p5_members_of_class_with_external_linkage_Ledger {} pub unsafe fn test_36() { @@ -162,11 +197,13 @@ pub unsafe fn test_49() { static mut count_46: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); static mut count_48: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 1 }); pub unsafe fn first_key_51() -> i32 { - let mut entry: Entry_52 = ::default(); + let mut entry: Entry_52 = ::zero_init(); + Entry_52::construct_1(&mut entry); return entry.key; } pub unsafe fn second_key_plus_value_53() -> i32 { - let mut entry: Entry_54 = ::default(); + let mut entry: Entry_54 = ::zero_init(); + Entry_54::construct_1(&mut entry); return ((entry.key) + (entry.value)); } pub unsafe fn test_55() { @@ -179,6 +216,18 @@ pub unsafe fn test_55() { pub struct Entry_52 { pub key: i32, } +impl Entry_52 { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.key).write(1); + } +} +impl DefaultConstructibleUnsafe for Entry_52 { + unsafe fn default_constructor(&mut self) { + unsafe { + Entry_52::construct_1(&mut *self); + } + } +} impl Default for Entry_52 { fn default() -> Self { unsafe { Entry_52 { key: 1 } } @@ -190,6 +239,19 @@ pub struct Entry_54 { pub key: i32, pub value: i32, } +impl Entry_54 { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.key).write(2); + (&raw mut self.value).write(30); + } +} +impl DefaultConstructibleUnsafe for Entry_54 { + unsafe fn default_constructor(&mut self) { + unsafe { + Entry_54::construct_1(&mut *self); + } + } +} impl Default for Entry_54 { fn default() -> Self { unsafe { Entry_54 { key: 2, value: 30 } } @@ -247,7 +309,15 @@ 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, TriviallyCopyableUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, +)] pub union anon_62 { pub whole: i32, pub fraction: f32, @@ -275,6 +345,19 @@ pub struct Record_65 { pub id: i64, pub extra: i32, } +impl Record_65 { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.id).write(200_i64); + (&raw mut self.extra).write(1); + } +} +impl DefaultConstructibleUnsafe for Record_65 { + unsafe fn default_constructor(&mut self) { + unsafe { + Record_65::construct_1(&mut *self); + } + } +} impl Default for Record_65 { fn default() -> Self { unsafe { @@ -290,7 +373,8 @@ pub unsafe fn bump_in_b_22() -> i32 { return (unsafe { bump_64() }); } pub unsafe fn record_id_in_b_23() -> i32 { - let mut record: Record_65 = ::default(); + let mut record: Record_65 = ::zero_init(); + Record_65::construct_1(&mut record); return (record.id as i32); } pub unsafe fn depth_in_b_24() -> i32 { @@ -308,7 +392,14 @@ pub unsafe fn raise_30(mut by: i32) -> i32 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Tally_67 {} impl Tally_67 { @@ -343,7 +434,8 @@ pub unsafe fn next_in_b_50() -> i32 { } static mut count_70: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub unsafe fn key_in_b_56() -> i32 { - let mut entry: Entry_71 = ::default(); + let mut entry: Entry_71 = ::zero_init(); + Entry_71::construct_1(&mut entry); return (entry.key as i32); } #[repr(C)] @@ -351,6 +443,18 @@ pub unsafe fn key_in_b_56() -> i32 { pub struct Entry_71 { pub key: i64, } +impl Entry_71 { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.key).write(400_i64); + } +} +impl DefaultConstructibleUnsafe for Entry_71 { + unsafe fn default_constructor(&mut self) { + unsafe { + Entry_71::construct_1(&mut *self); + } + } +} impl Default for Entry_71 { fn default() -> Self { unsafe { Entry_71 { key: 400_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 5bad7e7bfd..8cdcd7cbcb 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 @@ -66,6 +66,13 @@ impl Clone for LifetimeTracked { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } +impl DefaultConstructible for LifetimeTracked { + fn default_constructor(this: &Ptr) { + { + LifetimeTrackedImpl::construct(this); + } + } +} impl Default for LifetimeTracked { fn default() -> Self { { @@ -94,6 +101,7 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, + DefaultConstructible, Memberwise, CopyConstructible, Movable, 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 d0dd2aadb7..494a5a4b6b 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 @@ -15,6 +15,13 @@ pub struct p1_member_hides_namespace_variable_HasBalance { #[offset(0)] pub balance: i32, } +impl DefaultConstructible for p1_member_hides_namespace_variable_HasBalance { + fn default_constructor(this: &Ptr) { + { + p1_member_hides_namespace_variable_HasBalanceImpl::construct_1(this); + } + } +} impl Default for p1_member_hides_namespace_variable_HasBalance { fn default() -> Self { { p1_member_hides_namespace_variable_HasBalance { balance: 7 } } @@ -22,8 +29,9 @@ impl Default for p1_member_hides_namespace_variable_HasBalance { } pub fn test_1() { let object: Value = Rc::new(RefCell::new( - ::default(), + ::zero_init(), )); + p1_member_hides_namespace_variable_HasBalanceImpl::construct_1(&object.as_pointer()); assert!( (({ p1_member_hides_namespace_variable_HasBalanceImpl::deposit(&object.as_pointer(), 3) @@ -51,6 +59,13 @@ pub struct p1_out_of_class_definition_is_in_class_scope_HasStaticTotal { #[offset(0)] pub held: i32, } +impl DefaultConstructible for p1_out_of_class_definition_is_in_class_scope_HasStaticTotal { + fn default_constructor(this: &Ptr) { + { + p1_out_of_class_definition_is_in_class_scope_HasStaticTotalImpl::construct_1(this); + } + } +} impl Default for p1_out_of_class_definition_is_in_class_scope_HasStaticTotal { fn default() -> Self { { p1_out_of_class_definition_is_in_class_scope_HasStaticTotal { held: 1 } } @@ -65,7 +80,10 @@ thread_local!( pub fn test_5() { assert!((total_4.with(|rc| *rc.borrow()) == 7)); let object: Value = Rc::new( - RefCell::new(::default()), + RefCell::new(::zero_init()), + ); + p1_out_of_class_definition_is_in_class_scope_HasStaticTotalImpl::construct_1( + &object.as_pointer(), ); assert!( (({ @@ -91,6 +109,7 @@ fn main_0() -> i32 { pub trait p1_member_hides_namespace_variable_HasBalanceImpl { fn deposit(&self, amount: i32) -> i32; fn deposit_globally(&self, amount: i32) -> i32; + fn construct_1(&self); } impl p1_member_hides_namespace_variable_HasBalanceImpl for Ptr @@ -105,13 +124,20 @@ impl p1_member_hides_namespace_variable_HasBalanceImpl balance_0.with(|rc| *rc.borrow_mut() += amount); return balance_0.with(|rc| *rc.borrow()); } + fn construct_1(&self) { + field!((*self), balance).write(7); + } } pub trait p1_out_of_class_definition_is_in_class_scope_HasStaticTotalImpl { fn add(&self, amount: i32) -> i32; + fn construct_1(&self); } impl p1_out_of_class_definition_is_in_class_scope_HasStaticTotalImpl for Ptr { + fn construct_1(&self) { + field!((*self), held).write(1); + } fn add(&self, mut amount: i32) -> i32 { { field!((*self), held).with_mut(|__v| *__v = *__v + amount) 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 c8ba3af145..078329d176 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 @@ -15,6 +15,7 @@ use std::rc::{Rc, Weak}; VaArg, FnPtrArg, CppFrom, + DefaultConstructible, TriviallyCopyable, Default, )] 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 50d4f24248..d8c51cb590 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 @@ -19,7 +19,15 @@ pub fn test_0() { assert!((level == 5)); } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct p1_own_address_in_initializer_SelfLinked { @@ -82,6 +90,13 @@ pub struct p9_func_declared_before_function_body_RecordsConstructorName { #[byte_size(8)] pub name: Ptr, } +impl DefaultConstructible for p9_func_declared_before_function_body_RecordsConstructorName { + fn default_constructor(this: &Ptr) { + { + p9_func_declared_before_function_body_RecordsConstructorNameImpl::construct(this); + } + } +} impl Default for p9_func_declared_before_function_body_RecordsConstructorName { fn default() -> Self { { 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 0aecd9eb4b..8a00075bba 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 @@ -45,7 +45,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; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum {} @@ -75,7 +84,16 @@ thread_local!( pub static count_6: Value = Rc::new(RefCell::new(0)); ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct p2_12_class_name_in_own_scope_HasStaticCounter {} @@ -92,7 +110,9 @@ pub fn test_7() { count_6.with(|rc| *rc.borrow_mut() = 6); assert!((count_6.with(|rc| *rc.borrow()) == 6)); } -#[derive(VaArg, FnPtrArg, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, +)] #[byte_size(8)] pub struct anon_8 { #[offset(0)] @@ -118,7 +138,9 @@ impl Default for anon_8 { thread_local!( pub static anon_8: Value = Rc::new(RefCell::new(::default())); ); -#[derive(VaArg, FnPtrArg, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, +)] #[byte_size(8)] pub struct anon_9 { #[offset(0)] @@ -142,7 +164,15 @@ impl Default for anon_9 { } } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct p2_13_anonymous_union_members_in_parent_scope_HasAnonymousUnion { @@ -179,7 +209,9 @@ 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, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, +)] #[byte_size(8)] pub struct anon_11 { #[offset(0)] @@ -210,6 +242,13 @@ pub struct p3_2_const_qualified_member_is_distinct_HasConstOverload { #[offset(4)] pub const_calls: i32, } +impl DefaultConstructible for p3_2_const_qualified_member_is_distinct_HasConstOverload { + fn default_constructor(this: &Ptr) { + { + p3_2_const_qualified_member_is_distinct_HasConstOverloadImpl::construct_1(this); + } + } +} impl Default for p3_2_const_qualified_member_is_distinct_HasConstOverload { fn default() -> Self { { @@ -222,8 +261,9 @@ impl Default for p3_2_const_qualified_member_is_distinct_HasConstOverload { } pub fn test_12() { let object: Value = Rc::new( - RefCell::new(::default()), + RefCell::new(::zero_init()), ); + p3_2_const_qualified_member_is_distinct_HasConstOverloadImpl::construct_1(&object.as_pointer()); let view: Ptr = object.as_pointer(); assert!( (({ @@ -252,6 +292,15 @@ pub struct p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjec #[offset(0)] pub base: i32, } +impl DefaultConstructible + for p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload +{ + fn default_constructor(this: &Ptr) { + { + p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverloadImpl :: construct_1 ( this , ) ; + } + } +} impl Default for p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload { fn default() -> Self { { @@ -265,8 +314,12 @@ pub fn test_15() { let object: Value< p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload, > = Rc::new(RefCell::new( - ::default(), + ::zero_init( + ), )); + p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverloadImpl::construct_1( + &object.as_pointer(), + ); assert!( (({ as p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverloadImpl>::pick_1 ( object .as_pointer() , 1 , ) @@ -274,11 +327,14 @@ pub fn test_15() { ); assert!((explicit_calls_13.with(|rc| *rc.borrow()) == 1)); assert!((rvalue_calls_14.with(|rc| *rc.borrow()) == 0)); - assert!( - (({ - p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverloadImpl :: pick_2 ( &Rc::new(RefCell::new(::default() )).as_pointer() , 2 , ) - }) == 112) - ); + { + let __tmp_0: Value = Rc::new(RefCell::new(::zero_init())); + assert!( + (({ + p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverloadImpl :: pick_2 ( &{ p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverloadImpl :: construct_1 ( &__tmp_0.as_pointer() , ) ; __tmp_0.as_pointer() } , 2 , ) + }) == 112) + ) + }; assert!((explicit_calls_13.with(|rc| *rc.borrow()) == 1)); assert!((rvalue_calls_14.with(|rc| *rc.borrow()) == 1)); } @@ -289,7 +345,16 @@ thread_local!( pub static rvalue_calls_17: Value = Rc::new(RefCell::new(0)); ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct p3_2_ref_qualified_members_are_distinct_HasRefQualifiedOverloads {} @@ -336,6 +401,15 @@ pub struct p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOv #[offset(4)] pub const_calls: i32, } +impl DefaultConstructible + for p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload +{ + fn default_constructor(this: &Ptr) { + { + p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverloadImpl :: construct_1 ( this , ) ; + } + } +} impl Default for p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload { fn default() -> Self { { @@ -347,11 +421,10 @@ impl Default for p3_4_const_qualified_member_templates_are_distinct_HasConstTemp } } pub fn test_19() { - let object: Value = - Rc::new(RefCell::new( - ::default( - ), - )); + let object: Value = Rc::new(RefCell::new(::zero_init())); + p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverloadImpl::construct_1( + &object.as_pointer(), + ); let view: Ptr = object.as_pointer(); assert!( @@ -376,7 +449,16 @@ thread_local!( pub static rvalue_calls_21: Value = Rc::new(RefCell::new(0)); ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct p3_4_ref_qualified_member_templates_are_distinct_HasRefQualifiedTemplateOverloads {} @@ -408,7 +490,16 @@ thread_local!( pub static friend_calls_23: Value = Rc::new(RefCell::new(0_i32)); ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct p4_friend_definition_defines_earlier_friend_declaration_DeclaresFriend {} @@ -417,7 +508,16 @@ pub fn shared_friend_24() -> i32 { return 7; } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct p4_friend_definition_defines_earlier_friend_declaration_DefinesFriend {} @@ -451,7 +551,16 @@ thread_local!( pub static function_calls_31: Value = Rc::new(RefCell::new(0_i32)); ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct p4_2_class_and_function_share_name_Reading { @@ -471,7 +580,16 @@ pub fn test_33() { assert!((function_calls_31.with(|rc| *rc.borrow()) == 1)); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct p4_2_class_and_variable_share_name_Limit { @@ -672,6 +790,7 @@ impl p2_13_anonymous_union_members_in_parent_scope_HasAnonymousUnionImpl pub trait p3_2_const_qualified_member_is_distinct_HasConstOverloadImpl { fn get_1(&self) -> i32; fn get_2(&self) -> i32; + fn construct_1(&self); } impl p3_2_const_qualified_member_is_distinct_HasConstOverloadImpl for Ptr @@ -688,6 +807,10 @@ impl p3_2_const_qualified_member_is_distinct_HasConstOverloadImpl }); return 2; } + fn construct_1(&self) { + field!((*self), plain_calls).write(0); + field!((*self), const_calls).write(0); + } } pub trait p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverloadImpl { fn pick_1( @@ -695,6 +818,7 @@ pub trait p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObject amount: i32, ) -> i32; fn pick_2(&self, amount: i32) -> i32; + fn construct_1(&self); } impl p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverloadImpl for Ptr @@ -710,6 +834,9 @@ impl p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverl (*rvalue_calls_14.with(Value::clone).borrow_mut()).prefix_inc(); return (((*self).with(|__s| __s.base) + amount) + 100); } + fn construct_1(&self) { + field!((*self), base).write(10); + } } pub trait p3_2_ref_qualified_members_are_distinct_HasRefQualifiedOverloadsImpl { fn get_1(&self) -> i32; @@ -728,12 +855,17 @@ impl p3_2_ref_qualified_members_are_distinct_HasRefQualifiedOverloadsImpl } } pub trait p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverloadImpl { + fn construct_1(&self); fn get_1_int(&self, value: i32) -> i32; fn get_2_int(&self, value: i32) -> i32; } impl p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverloadImpl for Ptr { + fn construct_1(&self) { + field!((*self), plain_calls).write(0); + field!((*self), const_calls).write(0); + } fn get_1_int(&self, mut value: i32) -> i32 { field!((*self), plain_calls).with_mut(|__v| { __v.prefix_inc(); 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 eba6486995..a3af1efa1e 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 @@ -58,6 +58,13 @@ impl Clone for LifetimeTracked { } } } +impl DefaultConstructibleUnsafe for LifetimeTracked { + unsafe fn default_constructor(&mut self) { + unsafe { + LifetimeTracked::construct(&mut *self); + } + } +} impl Default for LifetimeTracked { fn default() -> Self { unsafe { @@ -80,6 +87,7 @@ pub static mut dtorCount_6: std::cell::LazyCell = std::cell::LazyCell::new( VaArg, FnPtrArg, ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, 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 fe8350df27..0b1e1e3c87 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 @@ -21,6 +21,16 @@ impl p1_member_hides_namespace_variable_HasBalance { (*std::cell::LazyCell::force_mut(&mut *&raw mut balance_0)) += amount; return (*std::cell::LazyCell::force_mut(&mut *&raw mut balance_0)); } + pub unsafe fn construct_1(&mut self) { + (&raw mut self.balance).write(7); + } +} +impl DefaultConstructibleUnsafe for p1_member_hides_namespace_variable_HasBalance { + unsafe fn default_constructor(&mut self) { + unsafe { + p1_member_hides_namespace_variable_HasBalance::construct_1(&mut *self); + } + } } impl Default for p1_member_hides_namespace_variable_HasBalance { fn default() -> Self { @@ -29,7 +39,8 @@ impl Default for p1_member_hides_namespace_variable_HasBalance { } pub unsafe fn test_1() { let mut object: p1_member_hides_namespace_variable_HasBalance = - ::default(); + ::zero_init(); + p1_member_hides_namespace_variable_HasBalance::construct_1(&mut object); assert!( ((unsafe { p1_member_hides_namespace_variable_HasBalance::deposit(&mut object, 3,) }) == (10)) @@ -50,6 +61,18 @@ pub static mut initial_2: std::cell::LazyCell = std::cell::LazyCell::new(|| pub struct p1_out_of_class_definition_is_in_class_scope_HasStaticTotal { pub held: i32, } +impl p1_out_of_class_definition_is_in_class_scope_HasStaticTotal { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.held).write(1); + } +} +impl DefaultConstructibleUnsafe for p1_out_of_class_definition_is_in_class_scope_HasStaticTotal { + unsafe fn default_constructor(&mut self) { + unsafe { + p1_out_of_class_definition_is_in_class_scope_HasStaticTotal::construct_1(&mut *self); + } + } +} impl Default for p1_out_of_class_definition_is_in_class_scope_HasStaticTotal { fn default() -> Self { unsafe { p1_out_of_class_definition_is_in_class_scope_HasStaticTotal { held: 1 } } @@ -70,7 +93,8 @@ impl p1_out_of_class_definition_is_in_class_scope_HasStaticTotal { pub unsafe fn test_5() { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut total_4)) == (7))); let mut object: p1_out_of_class_definition_is_in_class_scope_HasStaticTotal = - ::default(); + ::zero_init(); + p1_out_of_class_definition_is_in_class_scope_HasStaticTotal::construct_1(&mut object); assert!( ((unsafe { p1_out_of_class_definition_is_in_class_scope_HasStaticTotal::add(&mut object, 4) 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 539106be6d..b2090157bf 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 @@ -14,6 +14,7 @@ use std::rc::Rc; FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] 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 3bfb70a4e9..c6511a0471 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 @@ -20,7 +20,14 @@ pub unsafe fn test_0() { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p1_own_address_in_initializer_SelfLinked { pub next: *mut p1_own_address_in_initializer_SelfLinked, @@ -84,6 +91,13 @@ impl p9_func_declared_before_function_body_RecordsConstructorName { assert!(((self.name) == (c"RecordsConstructorName".as_ptr()))); } } +impl DefaultConstructibleUnsafe for p9_func_declared_before_function_body_RecordsConstructorName { + unsafe fn default_constructor(&mut self) { + unsafe { + p9_func_declared_before_function_body_RecordsConstructorName::construct(&mut *self); + } + } +} impl Default for p9_func_declared_before_function_body_RecordsConstructorName { fn default() -> Self { unsafe { 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 e1c5504da8..d13d1cedeb 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 @@ -43,7 +43,14 @@ 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, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum {} impl p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum { @@ -72,7 +79,14 @@ 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, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p2_12_class_name_in_own_scope_HasStaticCounter {} impl p2_12_class_name_in_own_scope_HasStaticCounter { @@ -89,7 +103,15 @@ 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, TriviallyCopyableUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, +)] pub union anon_8 { pub namespace_count: i32, pub namespace_ratio: f64, @@ -102,7 +124,15 @@ 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, TriviallyCopyableUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, +)] pub union anon_9 { pub member_count: i32, pub member_ratio: f64, @@ -114,7 +144,14 @@ impl Default for anon_9 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p2_13_anonymous_union_members_in_parent_scope_HasAnonymousUnion { pub tag: i32, @@ -152,7 +189,15 @@ pub unsafe fn test_10() { assert!(((anon_11.block_ratio) == (0.75_f64))); } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, +)] pub union anon_11 { pub block_count: i32, pub block_ratio: f64, @@ -177,6 +222,17 @@ impl p3_2_const_qualified_member_is_distinct_HasConstOverload { (*(&raw const self.const_calls).cast_mut()).prefix_inc(); return 2; } + pub unsafe fn construct_1(&mut self) { + (&raw mut self.plain_calls).write(0); + (&raw mut self.const_calls).write(0); + } +} +impl DefaultConstructibleUnsafe for p3_2_const_qualified_member_is_distinct_HasConstOverload { + unsafe fn default_constructor(&mut self) { + unsafe { + p3_2_const_qualified_member_is_distinct_HasConstOverload::construct_1(&mut *self); + } + } } impl Default for p3_2_const_qualified_member_is_distinct_HasConstOverload { fn default() -> Self { @@ -190,7 +246,8 @@ impl Default for p3_2_const_qualified_member_is_distinct_HasConstOverload { } pub unsafe fn test_12() { let mut object: p3_2_const_qualified_member_is_distinct_HasConstOverload = - ::default(); + ::zero_init(); + p3_2_const_qualified_member_is_distinct_HasConstOverload::construct_1(&mut object); let view: *const p3_2_const_qualified_member_is_distinct_HasConstOverload = &object; assert!( ((unsafe { @@ -227,6 +284,18 @@ impl p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverl (*std::cell::LazyCell::force_mut(&mut *&raw mut rvalue_calls_14)).prefix_inc(); return (((self.base) + (amount)) + (100)); } + pub unsafe fn construct_1(&mut self) { + (&raw mut self.base).write(10); + } +} +impl DefaultConstructibleUnsafe + for p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload +{ + unsafe fn default_constructor(&mut self) { + unsafe { + p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload :: construct_1 ( &mut *self , ) ; + } + } } impl Default for p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload { fn default() -> Self { @@ -239,7 +308,11 @@ impl Default for p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplici } pub unsafe fn test_15() { let mut object: p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload = - ::default(); + ::zero_init( + ); + p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload::construct_1( + &mut object, + ); assert!( ((unsafe { p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload::pick_1( @@ -250,11 +323,14 @@ pub unsafe fn test_15() { ); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut explicit_calls_13)) == (1))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut rvalue_calls_14)) == (0))); - assert!( - ((unsafe { - p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload :: pick_2 ( &mut ::default() , 2 , ) - }) == (112)) - ); + { + let mut __tmp_0: p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload = ::zero_init(); + assert!( + ((unsafe { + p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload :: pick_2 ( &mut (*{ p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload :: construct_1 ( &mut __tmp_0 , ) ; & mut __tmp_0 } ) , 2 , ) + }) == (112)) + ) + }; assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut explicit_calls_13)) == (1))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut rvalue_calls_14)) == (1))); } @@ -264,7 +340,14 @@ pub static mut rvalue_calls_17: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p3_2_ref_qualified_members_are_distinct_HasRefQualifiedOverloads {} impl p3_2_ref_qualified_members_are_distinct_HasRefQualifiedOverloads { @@ -311,6 +394,10 @@ pub struct p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOv pub const_calls: i32, } impl p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.plain_calls).write(0); + (&raw mut self.const_calls).write(0); + } pub unsafe fn get_1_int(&mut self, mut value: i32) -> i32 { self.plain_calls.prefix_inc(); return ((value) + (1)); @@ -320,6 +407,15 @@ impl p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload return ((value) + (2)); } } +impl DefaultConstructibleUnsafe + for p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload +{ + unsafe fn default_constructor(&mut self) { + unsafe { + p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload :: construct_1 ( &mut *self , ) ; + } + } +} impl Default for p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload { fn default() -> Self { unsafe { @@ -332,7 +428,10 @@ impl Default for p3_4_const_qualified_member_templates_are_distinct_HasConstTemp } pub unsafe fn test_19() { let mut object: p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload = - ::default(); + ::zero_init(); + p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload::construct_1( + &mut object, + ); let view: *const p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload = &object; assert!( @@ -362,7 +461,14 @@ pub static mut rvalue_calls_21: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p3_4_ref_qualified_member_templates_are_distinct_HasRefQualifiedTemplateOverloads {} impl p3_4_ref_qualified_member_templates_are_distinct_HasRefQualifiedTemplateOverloads { @@ -403,7 +509,14 @@ pub static mut friend_calls_23: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0_i32 }); #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p4_friend_definition_defines_earlier_friend_declaration_DeclaresFriend {} pub unsafe fn shared_friend_24() -> i32 { @@ -412,7 +525,14 @@ pub unsafe fn shared_friend_24() -> i32 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p4_friend_definition_defines_earlier_friend_declaration_DefinesFriend {} pub unsafe fn test_25() { @@ -443,7 +563,14 @@ pub static mut function_calls_31: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0_i32 }); #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p4_2_class_and_function_share_name_Reading { pub value: i32, @@ -462,7 +589,14 @@ pub unsafe fn test_33() { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 51361a8071..087ead97f1 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 @@ -13,6 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, + DefaultConstructible, Memberwise, CopyConstructible, Movable, 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 09852599a6..07c73281f0 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 @@ -13,6 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, + DefaultConstructible, Memberwise, CopyConstructible, Movable, @@ -37,6 +38,7 @@ impl Destructible for Tracker { VaArg, FnPtrArg, Destructible, + DefaultConstructible, Memberwise, CopyConstructible, MoveConstructible, @@ -52,7 +54,16 @@ pub struct HoldsTracker { pub member: Tracker, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct TriviallyDestructible { @@ -142,7 +153,16 @@ thread_local!( Rc::new(RefCell::new(TriviallyDestructible { value: 6 })); ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct p3_reverse_completion_order_WithStaticMember {} 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 813791e127..8aaf462ed0 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 @@ -12,6 +12,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, 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 b1b60eb5ef..992363dd2f 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 @@ -12,6 +12,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, @@ -42,6 +43,7 @@ impl DestructibleUnsafe for Tracker { FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MoveConstructibleUnsafe, @@ -55,7 +57,14 @@ pub struct HoldsTracker { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct TriviallyDestructible { pub value: i32, @@ -147,7 +156,14 @@ pub static mut trivial_9: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { TriviallyDestructible { value: 6 } }); #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 c5524401a6..3ec7f2af61 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 @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct p2_pointer_to_data_member_bytes_round_trip_HasTwoInts { @@ -72,7 +81,16 @@ pub fn test_0() { assert!(({ ((*null_pm.borrow()) == -1_isize) })); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct p3_pointer_to_data_member_bytes_copied_to_other_object_HasTwoInts { 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 ad9e65e93e..11729441e8 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 @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p2_pointer_to_data_member_bytes_round_trip_HasTwoInts { pub first: i32, @@ -79,7 +86,14 @@ pub unsafe fn test_0() { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p3_pointer_to_data_member_bytes_copied_to_other_object_HasTwoInts { pub first: i32, diff --git a/tests/std/basic/out/refcount/basic.def.odr.rs b/tests/std/basic/out/refcount/basic.def.odr.rs index ab4ef21e25..2679a8ed5e 100644 --- a/tests/std/basic/out/refcount/basic.def.odr.rs +++ b/tests/std/basic/out/refcount/basic.def.odr.rs @@ -17,6 +17,7 @@ thread_local!( FnPtrArg, CppFrom, Destructible, + DefaultConstructible, Memberwise, Movable, Default, @@ -108,6 +109,13 @@ impl Clone for LifetimeTracked { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } +impl DefaultConstructible for LifetimeTracked { + fn default_constructor(this: &Ptr) { + { + LifetimeTrackedImpl::construct(this); + } + } +} impl Default for LifetimeTracked { fn default() -> Self { { @@ -262,6 +270,7 @@ pub trait p4_1_pure_virtual_without_definition_HasPureVirtual { VaArg, FnPtrArg, Destructible, + DefaultConstructible, Copyable, Default, )] @@ -386,6 +395,7 @@ thread_local!( FnPtrArg, CppFrom, Destructible, + DefaultConstructible, Memberwise, Movable, Default, @@ -474,6 +484,13 @@ pub struct p6_unevaluated_binding_needs_no_capture_HasTwoMembers { #[destroy] pub b: LifetimeTracked, } +impl DefaultConstructible for p6_unevaluated_binding_needs_no_capture_HasTwoMembers { + fn default_constructor(this: &Ptr) { + { + p6_unevaluated_binding_needs_no_capture_HasTwoMembersImpl::construct_1(this); + } + } +} pub fn test_20() { ({ LifetimeTracked::reset() }); let p: Value = Rc::new(RefCell::new( @@ -528,6 +545,13 @@ pub struct p7_member_access_captures_this_HasMemberUsedInLambda { #[offset(4)] pub n: i32, } +impl DefaultConstructible for p7_member_access_captures_this_HasMemberUsedInLambda { + fn default_constructor(this: &Ptr) { + { + p7_member_access_captures_this_HasMemberUsedInLambdaImpl::construct_1(this); + } + } +} impl Default for p7_member_access_captures_this_HasMemberUsedInLambda { fn default() -> Self { { @@ -578,6 +602,13 @@ pub struct p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda { #[destroy] pub x: LifetimeTracked, } +impl DefaultConstructible for p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda { + fn default_constructor(this: &Ptr) { + { + p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambdaImpl::construct_1(this); + } + } +} pub fn test_23() { ({ LifetimeTracked::reset() }); let c: Value = Rc::new( @@ -632,6 +663,13 @@ thread_local!( #[memberwise(copy_assign)] #[byte_size(1)] pub struct p9_destructor_not_potentially_invoked_HasUndefinedDestructor {} +impl DefaultConstructible for p9_destructor_not_potentially_invoked_HasUndefinedDestructor { + fn default_constructor(this: &Ptr) { + { + p9_destructor_not_potentially_invoked_HasUndefinedDestructorImpl::construct(this); + } + } +} impl Default for p9_destructor_not_potentially_invoked_HasUndefinedDestructor { fn default() -> Self { { @@ -677,6 +715,13 @@ pub struct p9_unused_copy_constructor_HasUndefinedCopyCtor { #[offset(0)] pub value: i32, } +impl DefaultConstructible for p9_unused_copy_constructor_HasUndefinedCopyCtor { + fn default_constructor(this: &Ptr) { + { + p9_unused_copy_constructor_HasUndefinedCopyCtorImpl::construct(this); + } + } +} impl Default for p9_unused_copy_constructor_HasUndefinedCopyCtor { fn default() -> Self { { @@ -718,6 +763,13 @@ thread_local!( )] #[byte_size(1)] pub struct p9_unused_implicit_assignment_HasUndefinedCopyAssignment {} +impl DefaultConstructible for p9_unused_implicit_assignment_HasUndefinedCopyAssignment { + fn default_constructor(this: &Ptr) { + { + p9_unused_implicit_assignment_HasUndefinedCopyAssignmentImpl::construct(this); + } + } +} impl Default for p9_unused_implicit_assignment_HasUndefinedCopyAssignment { fn default() -> Self { { @@ -756,6 +808,15 @@ pub struct p9_unused_implicit_assignment_HasMemberWithUndefinedCopyAssignment { #[byte_size(1)] pub m: p9_unused_implicit_assignment_HasUndefinedCopyAssignment, } +impl DefaultConstructible for p9_unused_implicit_assignment_HasMemberWithUndefinedCopyAssignment { + fn default_constructor(this: &Ptr) { + { + p9_unused_implicit_assignment_HasMemberWithUndefinedCopyAssignmentImpl::construct_1( + this, + ); + } + } +} pub fn test_33() { let a: Value = Rc::new(RefCell::new( diff --git a/tests/std/basic/out/unsafe/basic.def.odr.rs b/tests/std/basic/out/unsafe/basic.def.odr.rs index b244e81774..4995652b78 100644 --- a/tests/std/basic/out/unsafe/basic.def.odr.rs +++ b/tests/std/basic/out/unsafe/basic.def.odr.rs @@ -14,6 +14,7 @@ pub static mut copyCount_0: std::cell::LazyCell = std::cell::LazyCell::new( ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, MovableUnsafe, Default, @@ -98,6 +99,13 @@ impl Clone for LifetimeTracked { } } } +impl DefaultConstructibleUnsafe for LifetimeTracked { + unsafe fn default_constructor(&mut self) { + unsafe { + LifetimeTracked::construct(&mut *self); + } + } +} impl Default for LifetimeTracked { fn default() -> Self { unsafe { @@ -228,6 +236,7 @@ pub unsafe trait p4_1_pure_virtual_without_definition_HasPureVirtual { FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, CopyableUnsafe, Default, )] @@ -351,6 +360,7 @@ pub static mut copies_18: std::cell::LazyCell = std::cell::LazyCell::new(|| ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, MovableUnsafe, Default, @@ -436,6 +446,13 @@ impl p6_unevaluated_binding_needs_no_capture_HasTwoMembers { LifetimeTracked::construct(&mut self.b); } } +impl DefaultConstructibleUnsafe for p6_unevaluated_binding_needs_no_capture_HasTwoMembers { + unsafe fn default_constructor(&mut self) { + unsafe { + p6_unevaluated_binding_needs_no_capture_HasTwoMembers::construct_1(&mut *self); + } + } +} pub unsafe fn test_20() { (unsafe { LifetimeTracked::reset() }); let mut p: p6_unevaluated_binding_needs_no_capture_HasTwoMembers = @@ -500,6 +517,13 @@ impl p7_member_access_captures_this_HasMemberUsedInLambda { (&raw mut self.n).write(1); } } +impl DefaultConstructibleUnsafe for p7_member_access_captures_this_HasMemberUsedInLambda { + unsafe fn default_constructor(&mut self) { + unsafe { + p7_member_access_captures_this_HasMemberUsedInLambda::construct_1(&mut *self); + } + } +} impl Default for p7_member_access_captures_this_HasMemberUsedInLambda { fn default() -> Self { unsafe { @@ -557,6 +581,13 @@ impl p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda { LifetimeTracked::construct(&mut self.x); } } +impl DefaultConstructibleUnsafe for p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda { + unsafe fn default_constructor(&mut self) { + unsafe { + p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda::construct_1(&mut *self); + } + } +} pub unsafe fn test_23() { (unsafe { LifetimeTracked::reset() }); let mut c: p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda = @@ -610,6 +641,13 @@ impl p9_destructor_not_potentially_invoked_HasUndefinedDestructor { (*std::cell::LazyCell::force_mut(&mut *&raw mut t_ctors_27)).prefix_inc(); } } +impl DefaultConstructibleUnsafe for p9_destructor_not_potentially_invoked_HasUndefinedDestructor { + unsafe fn default_constructor(&mut self) { + unsafe { + p9_destructor_not_potentially_invoked_HasUndefinedDestructor::construct(&mut *self); + } + } +} impl Default for p9_destructor_not_potentially_invoked_HasUndefinedDestructor { fn default() -> Self { unsafe { @@ -654,6 +692,13 @@ impl p9_unused_copy_constructor_HasUndefinedCopyCtor { (*std::cell::LazyCell::force_mut(&mut *&raw mut ctor_calls_29)).prefix_inc(); } } +impl DefaultConstructibleUnsafe for p9_unused_copy_constructor_HasUndefinedCopyCtor { + unsafe fn default_constructor(&mut self) { + unsafe { + p9_unused_copy_constructor_HasUndefinedCopyCtor::construct(&mut *self); + } + } +} impl Default for p9_unused_copy_constructor_HasUndefinedCopyCtor { fn default() -> Self { unsafe { @@ -694,6 +739,13 @@ impl p9_unused_implicit_assignment_HasUndefinedCopyAssignment { (*std::cell::LazyCell::force_mut(&mut *&raw mut m_ctors_32)).prefix_inc(); } } +impl DefaultConstructibleUnsafe for p9_unused_implicit_assignment_HasUndefinedCopyAssignment { + unsafe fn default_constructor(&mut self) { + unsafe { + p9_unused_implicit_assignment_HasUndefinedCopyAssignment::construct(&mut *self); + } + } +} impl Default for p9_unused_implicit_assignment_HasUndefinedCopyAssignment { fn default() -> Self { unsafe { @@ -729,6 +781,17 @@ impl p9_unused_implicit_assignment_HasMemberWithUndefinedCopyAssignment { p9_unused_implicit_assignment_HasUndefinedCopyAssignment::construct(&mut self.m); } } +impl DefaultConstructibleUnsafe + for p9_unused_implicit_assignment_HasMemberWithUndefinedCopyAssignment +{ + unsafe fn default_constructor(&mut self) { + unsafe { + p9_unused_implicit_assignment_HasMemberWithUndefinedCopyAssignment::construct_1( + &mut *self, + ); + } + } +} pub unsafe fn test_33() { let mut a: p9_unused_implicit_assignment_HasMemberWithUndefinedCopyAssignment = ::zero_init(); 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 4bbd0595b0..46af7099a6 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 @@ -15,6 +15,7 @@ use std::rc::{Rc, Weak}; VaArg, FnPtrArg, CppFrom, + DefaultConstructible, TriviallyCopyable, Default, )] 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 6d9d473641..549325885a 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 @@ -14,6 +14,7 @@ use std::rc::Rc; FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] 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 7c57795151..4ac43d08f9 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 @@ -15,6 +15,7 @@ use std::rc::{Rc, Weak}; VaArg, FnPtrArg, CppFrom, + DefaultConstructible, TriviallyCopyable, Default, )] 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 a342e525ff..fc3c5585bc 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 @@ -15,6 +15,7 @@ use std::rc::{Rc, Weak}; VaArg, FnPtrArg, CppFrom, + DefaultConstructible, TriviallyCopyable, Default, )] 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 69d9479e89..603547e872 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 @@ -19,6 +19,7 @@ impl p1_template_constructor_from_own_type_Probe { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] 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 2593310235..5249cbdbd8 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 @@ -14,6 +14,7 @@ use std::rc::Rc; FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] 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 b191ca0178..5b8fe3a3cd 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 @@ -7,7 +7,15 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Destructible, Memberwise, Default, + Record, + ByteRepr, + ZeroInitialization, + FnPtrArg, + CppFrom, + Destructible, + DefaultConstructible, + Memberwise, + Default, )] #[memberwise(move_constructor)] #[cpp_from(i32, construct, value)] 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 984ab8f9a1..722b42639b 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 @@ -8,7 +8,13 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, MemberwiseUnsafe, Default, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + DefaultConstructibleUnsafe, + MemberwiseUnsafe, + Default, )] #[memberwise(move_constructor)] #[cpp_from(i32, construct, value)] 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 a146bd27b8..9f4cca8f1d 100644 --- a/tests/std/class/class.mem/out/refcount/class.free.rs +++ b/tests/std/class/class.mem/out/refcount/class.free.rs @@ -10,7 +10,16 @@ thread_local!( pub static allocations_0: Value = Rc::new(RefCell::new(0)); ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct p1_allocation_function_is_static_Allocates {} @@ -49,7 +58,16 @@ thread_local!( pub static deallocations_2: Value = Rc::new(RefCell::new(0)); ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct 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 410c047517..5191033a54 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 @@ -20,6 +20,13 @@ pub struct p7_1_function_body_names_later_member_HasLaterMembers { #[offset(0)] pub stock: i32, } +impl DefaultConstructible for p7_1_function_body_names_later_member_HasLaterMembers { + fn default_constructor(this: &Ptr) { + { + p7_1_function_body_names_later_member_HasLaterMembersImpl::construct_1(this); + } + } +} impl Default for p7_1_function_body_names_later_member_HasLaterMembers { fn default() -> Self { { p7_1_function_body_names_later_member_HasLaterMembers { stock: 9 } } @@ -27,8 +34,9 @@ impl Default for p7_1_function_body_names_later_member_HasLaterMembers { } pub fn test_3() { let object: Value = Rc::new( - RefCell::new(::default()), + RefCell::new(::zero_init()), ); + p7_1_function_body_names_later_member_HasLaterMembersImpl::construct_1(&object.as_pointer()); assert!( (({ p7_1_function_body_names_later_member_HasLaterMembersImpl::take(&object.as_pointer(), 3) @@ -49,6 +57,13 @@ pub struct p7_2_default_argument_names_later_member_HasLaterStaticStep { #[offset(0)] pub total: i32, } +impl DefaultConstructible for p7_2_default_argument_names_later_member_HasLaterStaticStep { + fn default_constructor(this: &Ptr) { + { + p7_2_default_argument_names_later_member_HasLaterStaticStepImpl::construct_1(this); + } + } +} impl Default for p7_2_default_argument_names_later_member_HasLaterStaticStep { fn default() -> Self { { p7_2_default_argument_names_later_member_HasLaterStaticStep { total: 1 } } @@ -56,7 +71,10 @@ impl Default for p7_2_default_argument_names_later_member_HasLaterStaticStep { } pub fn test_6() { let object: Value = Rc::new( - RefCell::new(::default()), + RefCell::new(::zero_init()), + ); + p7_2_default_argument_names_later_member_HasLaterStaticStepImpl::construct_1( + &object.as_pointer(), ); assert!( (({ @@ -88,6 +106,7 @@ fn main_0() -> i32 { pub trait p7_1_function_body_names_later_member_HasLaterMembersImpl { fn take(&self, amount: i32) -> i32; fn minimum(&self) -> i32; + fn construct_1(&self); } impl p7_1_function_body_names_later_member_HasLaterMembersImpl for Ptr @@ -103,9 +122,13 @@ impl p7_1_function_body_names_later_member_HasLaterMembersImpl fn minimum(&self) -> i32 { return 2; } + fn construct_1(&self) { + field!((*self), stock).write(9); + } } pub trait p7_2_default_argument_names_later_member_HasLaterStaticStepImpl { fn advance(&self, amount: i32) -> i32; + fn construct_1(&self); } impl p7_2_default_argument_names_later_member_HasLaterStaticStepImpl for Ptr @@ -116,6 +139,9 @@ impl p7_2_default_argument_names_later_member_HasLaterStaticStepImpl }; return (*self).with(|__s| __s.total); } + fn construct_1(&self) { + field!((*self), total).write(1); + } } pub fn __cpp2rust_init_globals() { let _ = stock_0.with(|_| ()); 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 100772f4b3..ae1a8a1abe 100644 --- a/tests/std/class/class.mem/out/unsafe/class.free.rs +++ b/tests/std/class/class.mem/out/unsafe/class.free.rs @@ -9,7 +9,14 @@ 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, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p1_allocation_function_is_static_Allocates {} impl p1_allocation_function_is_static_Allocates { @@ -45,7 +52,14 @@ pub static mut deallocations_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p3_deallocation_function_is_static_Deallocates {} impl p3_deallocation_function_is_static_Deallocates { 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 caab392d1f..48f6d90fba 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 @@ -27,6 +27,16 @@ impl p7_1_function_body_names_later_member_HasLaterMembers { pub unsafe fn minimum(&self) -> i32 { return 2; } + pub unsafe fn construct_1(&mut self) { + (&raw mut self.stock).write(9); + } +} +impl DefaultConstructibleUnsafe for p7_1_function_body_names_later_member_HasLaterMembers { + unsafe fn default_constructor(&mut self) { + unsafe { + p7_1_function_body_names_later_member_HasLaterMembers::construct_1(&mut *self); + } + } } impl Default for p7_1_function_body_names_later_member_HasLaterMembers { fn default() -> Self { @@ -35,7 +45,8 @@ impl Default for p7_1_function_body_names_later_member_HasLaterMembers { } pub unsafe fn test_3() { let mut object: p7_1_function_body_names_later_member_HasLaterMembers = - ::default(); + ::zero_init(); + p7_1_function_body_names_later_member_HasLaterMembers::construct_1(&mut object); assert!( ((unsafe { p7_1_function_body_names_later_member_HasLaterMembers::take(&mut object, 3,) }) == (38)) @@ -55,6 +66,16 @@ impl p7_2_default_argument_names_later_member_HasLaterStaticStep { self.total += amount; return self.total; } + pub unsafe fn construct_1(&mut self) { + (&raw mut self.total).write(1); + } +} +impl DefaultConstructibleUnsafe for p7_2_default_argument_names_later_member_HasLaterStaticStep { + unsafe fn default_constructor(&mut self) { + unsafe { + p7_2_default_argument_names_later_member_HasLaterStaticStep::construct_1(&mut *self); + } + } } impl Default for p7_2_default_argument_names_later_member_HasLaterStaticStep { fn default() -> Self { @@ -63,7 +84,8 @@ impl Default for p7_2_default_argument_names_later_member_HasLaterStaticStep { } pub unsafe fn test_6() { let mut object: p7_2_default_argument_names_later_member_HasLaterStaticStep = - ::default(); + ::zero_init(); + p7_2_default_argument_names_later_member_HasLaterStaticStep::construct_1(&mut object); assert!( ((unsafe { p7_2_default_argument_names_later_member_HasLaterStaticStep::advance( 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 2a5d03885c..d868770c6c 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 @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct p6_2_zero_initialized_padding_Padded { @@ -17,7 +26,16 @@ pub struct p6_2_zero_initialized_padding_Padded { pub number: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct p6_2_zero_initialized_padding_TailPadded { @@ -27,7 +45,16 @@ pub struct p6_2_zero_initialized_padding_TailPadded { pub letter: i8, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct p6_2_zero_initialized_padding_HoldsPadded { 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 d93c00cb5b..ec9a99b4ab 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 @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct p6_1_zero_initialized_pointer_to_member_HasTwoInts { @@ -16,7 +25,17 @@ pub struct p6_1_zero_initialized_pointer_to_member_HasTwoInts { #[offset(4)] pub second: i32, } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[byte_size(8)] pub struct p6_1_zero_initialized_pointer_to_member_HoldsSelector { #[offset(0)] @@ -114,7 +133,15 @@ thread_local!( static counter_11: Value = Rc::new(RefCell::new(0_i32)); ); #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(24)] pub struct p6_2_zero_initialized_class_Inner { @@ -126,7 +153,16 @@ pub struct p6_2_zero_initialized_class_Inner { #[byte_size(8)] pub pointer: Ptr, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[byte_size(96)] pub struct p6_2_zero_initialized_class_Outer { #[offset(0)] @@ -197,7 +233,9 @@ pub fn test_15() { ({ check_14((heap_outer).clone()) }); heap_outer.delete(); } -#[derive(VaArg, FnPtrArg, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, +)] #[byte_size(8)] pub struct p6_3_zero_initialized_union_Number { #[offset(0)] @@ -235,7 +273,16 @@ pub fn test_17() { assert!(((p6_3_zero_initialized_union_Number::integer(value_number.as_pointer()).read()) == 0)); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct p6_4_zero_initialized_array_Pair { @@ -348,6 +395,13 @@ pub struct p9_1_2_zero_then_default_initialized_WithDefaultMember { #[offset(4)] pub five: i32, } +impl DefaultConstructible for p9_1_2_zero_then_default_initialized_WithDefaultMember { + fn default_constructor(this: &Ptr) { + { + p9_1_2_zero_then_default_initialized_WithDefaultMemberImpl::construct_1(this); + } + } +} impl Default for p9_1_2_zero_then_default_initialized_WithDefaultMember { fn default() -> Self { { @@ -364,6 +418,13 @@ pub struct p9_1_2_zero_then_default_initialized_LeavesMemberAlone { #[offset(0)] pub untouched: i32, } +impl DefaultConstructible for p9_1_2_zero_then_default_initialized_LeavesMemberAlone { + fn default_constructor(this: &Ptr) { + { + p9_1_2_zero_then_default_initialized_LeavesMemberAloneImpl::construct(this); + } + } +} impl Default for p9_1_2_zero_then_default_initialized_LeavesMemberAlone { fn default() -> Self { { @@ -391,13 +452,25 @@ pub struct p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAlone { #[byte_size(4)] pub member: p9_1_2_zero_then_default_initialized_LeavesMemberAlone, } +impl DefaultConstructible for p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAlone { + fn default_constructor(this: &Ptr) { + { + p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAloneImpl::construct_1(this); + } + } +} pub fn test_22() { - let mut value: p9_1_2_zero_then_default_initialized_WithDefaultMember = - ::default(); - assert!((value.zeroed == 0)); - assert!((value.five == 5)); - let mut heap: Ptr = - Ptr::alloc(::default()); + let value: Value = Rc::new( + RefCell::new(::zero_init()), + ); + p9_1_2_zero_then_default_initialized_WithDefaultMemberImpl::construct_1(&value.as_pointer()); + assert!(({ (*value.borrow()).zeroed } == 0)); + assert!(({ (*value.borrow()).five } == 5)); + let mut heap: Ptr = { + let __p = Ptr::alloc(::zero_init()); + p9_1_2_zero_then_default_initialized_WithDefaultMemberImpl::construct_1(&__p); + __p + }; assert!((heap.with(|__s| __s.zeroed) == 0)); assert!((heap.with(|__s| __s.five) == 5)); heap.delete(); @@ -455,6 +528,17 @@ impl p9_1_2_zero_then_default_initialized_LeavesMemberAloneImpl field!((*self), untouched).write(0_i32); } } +pub trait p9_1_2_zero_then_default_initialized_WithDefaultMemberImpl { + fn construct_1(&self); +} +impl p9_1_2_zero_then_default_initialized_WithDefaultMemberImpl + for Ptr +{ + fn construct_1(&self) { + field!((*self), zeroed).write(0_i32); + field!((*self), five).write(5); + } +} pub fn __cpp2rust_init_globals() { let _ = static_pm_0.with(|_| ()); let _ = static_int_2.with(|_| ()); 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 b929604cbe..2f2c8d6706 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 @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p6_2_zero_initialized_padding_Padded { pub letter: libc::c_char, @@ -16,7 +23,14 @@ pub struct p6_2_zero_initialized_padding_Padded { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p6_2_zero_initialized_padding_TailPadded { pub number: i32, @@ -24,7 +38,14 @@ pub struct p6_2_zero_initialized_padding_TailPadded { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p6_2_zero_initialized_padding_HoldsPadded { pub letter: libc::c_char, 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 2f81b8a6b5..d2fc531ec7 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 @@ -8,14 +8,29 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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, TriviallyCopyableUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, +)] pub struct p6_1_zero_initialized_pointer_to_member_HoldsSelector { pub selector: isize, } @@ -110,7 +125,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, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p6_2_zero_initialized_class_Inner { pub number: i32, @@ -119,7 +141,14 @@ pub struct p6_2_zero_initialized_class_Inner { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p6_2_zero_initialized_class_Outer { pub letter: libc::c_char, @@ -172,7 +201,15 @@ pub unsafe fn test_15() { }; } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, +)] pub union p6_3_zero_initialized_union_Number { pub integer: i32, pub bytes: [libc::c_char; 8], @@ -192,7 +229,14 @@ pub unsafe fn test_17() { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p6_4_zero_initialized_array_Pair { pub first: i32, @@ -288,6 +332,19 @@ pub struct p9_1_2_zero_then_default_initialized_WithDefaultMember { pub zeroed: i32, pub five: i32, } +impl p9_1_2_zero_then_default_initialized_WithDefaultMember { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.zeroed).write(0_i32); + (&raw mut self.five).write(5); + } +} +impl DefaultConstructibleUnsafe for p9_1_2_zero_then_default_initialized_WithDefaultMember { + unsafe fn default_constructor(&mut self) { + unsafe { + p9_1_2_zero_then_default_initialized_WithDefaultMember::construct_1(&mut *self); + } + } +} impl Default for p9_1_2_zero_then_default_initialized_WithDefaultMember { fn default() -> Self { unsafe { @@ -308,6 +365,13 @@ impl p9_1_2_zero_then_default_initialized_LeavesMemberAlone { (&raw mut self.untouched).write(0_i32); } } +impl DefaultConstructibleUnsafe for p9_1_2_zero_then_default_initialized_LeavesMemberAlone { + unsafe fn default_constructor(&mut self) { + unsafe { + p9_1_2_zero_then_default_initialized_LeavesMemberAlone::construct(&mut *self); + } + } +} impl Default for p9_1_2_zero_then_default_initialized_LeavesMemberAlone { fn default() -> Self { unsafe { @@ -334,15 +398,26 @@ impl p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAlone { p9_1_2_zero_then_default_initialized_LeavesMemberAlone::construct(&mut self.member); } } +impl DefaultConstructibleUnsafe for p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAlone { + unsafe fn default_constructor(&mut self) { + unsafe { + p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAlone::construct_1(&mut *self); + } + } +} pub unsafe fn test_22() { let mut value: p9_1_2_zero_then_default_initialized_WithDefaultMember = - ::default(); + ::zero_init(); + p9_1_2_zero_then_default_initialized_WithDefaultMember::construct_1(&mut value); assert!(((value.zeroed) == (0))); assert!(((value.five) == (5))); - let mut heap: *mut p9_1_2_zero_then_default_initialized_WithDefaultMember = (Box::leak( - Box::new(::default()), - ) - as *mut p9_1_2_zero_then_default_initialized_WithDefaultMember); + let mut heap: *mut p9_1_2_zero_then_default_initialized_WithDefaultMember = { + let __p: *mut p9_1_2_zero_then_default_initialized_WithDefaultMember = Box::leak(Box::new( + ::zero_init(), + )); + p9_1_2_zero_then_default_initialized_WithDefaultMember::construct_1(&mut *__p); + __p + }; assert!((((*heap).zeroed) == (0))); assert!((((*heap).five) == (5))); { 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 9c6861d953..a352955573 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 @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(12)] pub struct p6_array_of_pointers_to_data_members_HasThreeInts { 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 3c3fa06825..a3c41d59d2 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 @@ -60,6 +60,13 @@ pub struct p9_static_member_hides_namespace_variable_HasStaticStep { #[offset(0)] pub total: i32, } +impl DefaultConstructible for p9_static_member_hides_namespace_variable_HasStaticStep { + fn default_constructor(this: &Ptr) { + { + p9_static_member_hides_namespace_variable_HasStaticStepImpl::construct_1(this); + } + } +} impl Default for p9_static_member_hides_namespace_variable_HasStaticStep { fn default() -> Self { { p9_static_member_hides_namespace_variable_HasStaticStep { total: 1 } } @@ -67,8 +74,9 @@ impl Default for p9_static_member_hides_namespace_variable_HasStaticStep { } pub fn test_11() { let object: Value = Rc::new( - RefCell::new(::default()), + RefCell::new(::zero_init()), ); + p9_static_member_hides_namespace_variable_HasStaticStepImpl::construct_1(&object.as_pointer()); assert!( (({ p9_static_member_hides_namespace_variable_HasStaticStepImpl::advance( @@ -114,6 +122,13 @@ pub struct p9_evaluated_each_time_called_Widget { #[offset(0)] pub id: i32, } +impl DefaultConstructible for p9_evaluated_each_time_called_Widget { + fn default_constructor(this: &Ptr) { + { + p9_evaluated_each_time_called_WidgetImpl::construct(this, { ({ count_default_13() }) }); + } + } +} impl Default for p9_evaluated_each_time_called_Widget { fn default() -> Self { { @@ -148,6 +163,13 @@ impl p9_evaluated_each_time_called_Account { base_15.with(|rc| *rc.borrow_mut() = value); } } +impl DefaultConstructible for p9_evaluated_each_time_called_Account { + fn default_constructor(this: &Ptr) { + { + p9_evaluated_each_time_called_AccountImpl::construct_1(this); + } + } +} impl Default for p9_evaluated_each_time_called_Account { fn default() -> Self { { p9_evaluated_each_time_called_Account { balance: 0 } } @@ -184,8 +206,9 @@ pub fn test_17() { assert!(({ (*c.borrow()).id } == 5)); assert!((defaults_evaluated_12.with(|rc| *rc.borrow()) == 5)); let account: Value = Rc::new(RefCell::new( - ::default(), + ::zero_init(), )); + p9_evaluated_each_time_called_AccountImpl::construct_1(&account.as_pointer()); assert!( (({ p9_evaluated_each_time_called_AccountImpl::deposit( @@ -215,7 +238,16 @@ pub fn add_18(mut a: i32, mut b: i32) -> i32 { return (a + b); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct p9_not_part_of_the_type_Scale {} @@ -290,6 +322,7 @@ fn main_0() -> i32 { } pub trait p9_evaluated_each_time_called_AccountImpl { fn deposit(&self, amount: i32) -> i32; + fn construct_1(&self); } impl p9_evaluated_each_time_called_AccountImpl for Ptr { fn deposit(&self, mut amount: i32) -> i32 { @@ -298,6 +331,9 @@ impl p9_evaluated_each_time_called_AccountImpl for Ptr i32; + fn construct_1(&self); } impl p9_static_member_hides_namespace_variable_HasStaticStepImpl for Ptr @@ -319,6 +356,9 @@ impl p9_static_member_hides_namespace_variable_HasStaticStepImpl }; return (*self).with(|__s| __s.total); } + fn construct_1(&self) { + field!((*self), total).write(1); + } } pub fn __cpp2rust_init_globals() { let _ = scaled_calls_0.with(|_| ()); 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 271a27fe01..899f714087 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,16 @@ 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, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[byte_size(16)] pub struct p2_pointer_to_array_member_HasIntArray { #[offset(0)] @@ -41,7 +50,16 @@ pub fn test_0() { assert!(({ (*obj.borrow()).before } == 1)); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct p2_pointer_to_data_member_HasTwoInts { @@ -71,7 +89,16 @@ thread_local!( pub static pm_2: Value = Rc::new(RefCell::new(-1_isize)); ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct p2_pointer_to_member_of_incomplete_class_CompletedLater { @@ -102,7 +129,16 @@ pub fn test_3() { ); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct p2_pointer_to_member_of_pointer_to_member_type_HasTwoInts { @@ -111,7 +147,17 @@ 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, TriviallyCopyable)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[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 85b7ec1a0c..e7a70db643 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 @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p6_array_of_pointers_to_data_members_HasThreeInts { pub first: 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 36b4738747..10f62ed91a 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 @@ -63,6 +63,16 @@ impl p9_static_member_hides_namespace_variable_HasStaticStep { self.total += amount; return self.total; } + pub unsafe fn construct_1(&mut self) { + (&raw mut self.total).write(1); + } +} +impl DefaultConstructibleUnsafe for p9_static_member_hides_namespace_variable_HasStaticStep { + unsafe fn default_constructor(&mut self) { + unsafe { + p9_static_member_hides_namespace_variable_HasStaticStep::construct_1(&mut *self); + } + } } impl Default for p9_static_member_hides_namespace_variable_HasStaticStep { fn default() -> Self { @@ -71,7 +81,8 @@ impl Default for p9_static_member_hides_namespace_variable_HasStaticStep { } pub unsafe fn test_11() { let mut object: p9_static_member_hides_namespace_variable_HasStaticStep = - ::default(); + ::zero_init(); + p9_static_member_hides_namespace_variable_HasStaticStep::construct_1(&mut object); assert!( ((unsafe { p9_static_member_hides_namespace_variable_HasStaticStep::advance( @@ -117,6 +128,15 @@ impl p9_evaluated_each_time_called_Widget { (&raw mut self.id).write(id); } } +impl DefaultConstructibleUnsafe for p9_evaluated_each_time_called_Widget { + unsafe fn default_constructor(&mut self) { + unsafe { + p9_evaluated_each_time_called_Widget::construct(&mut *self, { + (unsafe { count_default_13() }) + }); + } + } +} impl Default for p9_evaluated_each_time_called_Widget { fn default() -> Self { unsafe { @@ -150,6 +170,16 @@ impl p9_evaluated_each_time_called_Account { pub unsafe fn set_base(mut value: i32) { (*std::cell::LazyCell::force_mut(&mut *&raw mut base_15)) = value; } + pub unsafe fn construct_1(&mut self) { + (&raw mut self.balance).write(0); + } +} +impl DefaultConstructibleUnsafe for p9_evaluated_each_time_called_Account { + unsafe fn default_constructor(&mut self) { + unsafe { + p9_evaluated_each_time_called_Account::construct_1(&mut *self); + } + } } impl Default for p9_evaluated_each_time_called_Account { fn default() -> Self { @@ -182,7 +212,8 @@ pub unsafe fn test_17() { assert!(((c.id) == (5))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut defaults_evaluated_12)) == (5))); let mut account: p9_evaluated_each_time_called_Account = - ::default(); + ::zero_init(); + p9_evaluated_each_time_called_Account::construct_1(&mut account); assert!( ((unsafe { p9_evaluated_each_time_called_Account::deposit( @@ -217,7 +248,14 @@ pub unsafe fn add_18(mut a: i32, mut b: i32) -> i32 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] 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/unsafe/dcl.mptr.rs b/tests/std/dcl.dcl/dcl.decl/dcl.meaning/out/unsafe/dcl.mptr.rs index 18c61cc2fe..e4546ce994 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 @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p2_pointer_to_array_member_HasIntArray { pub before: i32, @@ -41,7 +48,14 @@ pub unsafe fn test_0() { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p2_pointer_to_data_member_HasTwoInts { pub first: i32, @@ -81,7 +95,14 @@ 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, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p2_pointer_to_member_of_incomplete_class_CompletedLater { pub first: i32, @@ -107,14 +128,29 @@ pub unsafe fn test_3() { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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, TriviallyCopyableUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, +)] 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 202d47048e..644ed4f0f2 100644 --- a/tests/std/expr/conv/out/refcount/conv.mem.rs +++ b/tests/std/expr/conv/out/refcount/conv.mem.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct p1_null_distinct_from_first_member_HasTwoInts { diff --git a/tests/std/expr/conv/out/unsafe/conv.mem.rs b/tests/std/expr/conv/out/unsafe/conv.mem.rs index d3311733de..17b3ab2791 100644 --- a/tests/std/expr/conv/out/unsafe/conv.mem.rs +++ b/tests/std/expr/conv/out/unsafe/conv.mem.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p1_null_distinct_from_first_member_HasTwoInts { pub first: 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 fa51d3ea05..6eabe95687 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 @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct p4_reference_const_cast_Pair { 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 0ab850df8b..494a0d9202 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 @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct HasTwoInts { @@ -17,7 +26,16 @@ pub struct HasTwoInts { pub second: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct AlsoHasTwoInts { 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 c65e529aba..00a14a5e2a 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 @@ -17,7 +17,16 @@ pub fn test_0() { assert!((((converted.read()).read()) == 7)); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct p10_null_converts_to_null_HasTwoInts { @@ -27,7 +36,16 @@ pub struct p10_null_converts_to_null_HasTwoInts { pub second: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct p10_null_converts_to_null_HasChar { @@ -40,7 +58,16 @@ pub fn test_1() { assert!(((converted) == -1_isize)); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct p10_2_data_member_round_trip_HasTwoInts { @@ -50,7 +77,16 @@ pub struct p10_2_data_member_round_trip_HasTwoInts { pub second: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct p10_2_data_member_round_trip_HasChar { 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 d72d679fb2..2ec3a4632e 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 @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 65184ac4c7..3c761eb2e9 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 @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct HasTwoInts { pub first: i32, @@ -16,7 +23,14 @@ pub struct HasTwoInts { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct AlsoHasTwoInts { pub first: 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 0e85f5b1d4..8d1a31724b 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 @@ -18,7 +18,14 @@ pub unsafe fn test_0() { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p10_null_converts_to_null_HasTwoInts { pub first: i32, @@ -26,7 +33,14 @@ pub struct p10_null_converts_to_null_HasTwoInts { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p10_null_converts_to_null_HasChar { pub character: libc::c_char, @@ -38,7 +52,14 @@ pub unsafe fn test_1() { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p10_2_data_member_round_trip_HasTwoInts { pub first: i32, @@ -46,7 +67,14 @@ pub struct p10_2_data_member_round_trip_HasTwoInts { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 b078a4b6ef..a20f54def6 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 @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct p1_result_is_updated_operand_Counter { 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 13231d9f2f..3bd52a9bf2 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 @@ -13,7 +13,16 @@ thread_local!( pub static calls_1: Value = Rc::new(RefCell::new(0)); ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct p3_2_static_member_is_ordinary_pointer_HasStaticMembers {} @@ -33,7 +42,16 @@ pub fn test_2() { assert!((calls_1.with(|rc| *rc.borrow()) == 1)); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct p3_2_explicit_object_member_is_ordinary_pointer_HasExplicitObjectMember { @@ -51,7 +69,16 @@ pub fn test_3() { assert!((({ function_pointer.call(object.as_pointer(), 1,) }) == 6)); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct p4_parenthesized_qualified_id_is_object_pointer_TakesAddressOfOwnMember { 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 4744f7e936..f3ed68283c 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 @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 d79d26d005..f49718692a 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 @@ -10,7 +10,14 @@ pub static mut shared_0: std::cell::LazyCell = std::cell::LazyCell::new(|| pub static mut calls_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p3_2_static_member_is_ordinary_pointer_HasStaticMembers {} impl p3_2_static_member_is_ordinary_pointer_HasStaticMembers { @@ -31,7 +38,14 @@ pub unsafe fn test_2() { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p3_2_explicit_object_member_is_ordinary_pointer_HasExplicitObjectMember { pub base: i32, @@ -59,7 +73,14 @@ pub unsafe fn test_3() { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 8dec3dac8e..18f20a8a90 100644 --- a/tests/std/expr/expr.compound/out/refcount/expr.cond.rs +++ b/tests/std/expr/expr.compound/out/refcount/expr.cond.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct p7_4_pointer_to_member_and_null_HasTwoInts { 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 e6c1918807..83480e6cc4 100644 --- a/tests/std/expr/expr.compound/out/refcount/expr.eq.rs +++ b/tests/std/expr/expr.compound/out/refcount/expr.eq.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct p4_1_both_null_HasTwoInts { @@ -23,7 +32,16 @@ pub fn test_0() { assert!(!(first_null != second_null)); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct p4_2_one_null_HasTwoInts { @@ -40,7 +58,9 @@ pub fn test_1() { assert!((null_pm != first_pm)); assert!(!(null_pm == first_pm)); } -#[derive(VaArg, FnPtrArg, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, +)] #[byte_size(4)] pub struct p4_5_members_of_same_union_HasTwoIntMembers { #[offset(0)] @@ -70,7 +90,16 @@ pub fn test_2() { assert!(!(first_pm != second_pm)); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct p4_6_data_members_HasTwoInts { 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 6b5d7fe003..be37d63477 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 @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct HasTwoInts { 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 0b63569205..aa0fe9ce9b 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 @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct p3_arrow_star_HasTwoInts { @@ -30,7 +39,16 @@ pub fn test_0() { assert!((((p).member::(pm)) == ((p).member::(pm)))); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct p4_object_expression_sequenced_first_HasValue { @@ -74,7 +92,16 @@ pub fn test_7() { assert!((member_stamp_3.with(|rc| *rc.borrow()) == 2)); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct p6_data_member_of_lvalue_is_lvalue_HasTwoInts { @@ -111,6 +138,7 @@ thread_local!( VaArg, FnPtrArg, Destructible, + DefaultConstructible, CopyAssignable, MoveAssignable, Swappable, @@ -154,6 +182,7 @@ impl Clone for p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves { VaArg, FnPtrArg, Destructible, + DefaultConstructible, Memberwise, 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 4663247295..10e3d66892 100644 --- a/tests/std/expr/expr.compound/out/unsafe/expr.cond.rs +++ b/tests/std/expr/expr.compound/out/unsafe/expr.cond.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p7_4_pointer_to_member_and_null_HasTwoInts { pub first: 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 9bd05e74e7..3b4925d01d 100644 --- a/tests/std/expr/expr.compound/out/unsafe/expr.eq.rs +++ b/tests/std/expr/expr.compound/out/unsafe/expr.eq.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p4_1_both_null_HasTwoInts { pub first: i32, @@ -22,7 +29,14 @@ pub unsafe fn test_0() { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p4_2_one_null_HasTwoInts { pub first: i32, @@ -37,7 +51,15 @@ pub unsafe fn test_1() { assert!(!((null_pm) == (first_pm))); } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, +)] pub union p4_5_members_of_same_union_HasTwoIntMembers { pub first: i32, pub second: i32, @@ -55,7 +77,14 @@ pub unsafe fn test_2() { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p4_6_data_members_HasTwoInts { pub first: 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 0ccbfbc21f..65eb30e323 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 @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct HasTwoInts { pub first: 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 7b774d73ec..27d45db986 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 @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p3_arrow_star_HasTwoInts { pub first: i32, @@ -34,7 +41,14 @@ pub unsafe fn test_0() { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p4_object_expression_sequenced_first_HasValue { pub value: i32, @@ -70,7 +84,14 @@ pub unsafe fn test_7() { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p6_data_member_of_lvalue_is_lvalue_HasTwoInts { pub first: i32, @@ -105,6 +126,7 @@ pub static mut moveCount_10: std::cell::LazyCell = std::cell::LazyCell::new FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -147,6 +169,7 @@ impl Clone for p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves { FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, 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 2e54a73cc6..e81ffa1ea9 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 @@ -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, CppFrom, TriviallyCopyable, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + DefaultConstructible, + TriviallyCopyable, )] #[cpp_from(i32, construct, value)] #[byte_size(16)] @@ -38,6 +46,7 @@ pub fn test_0() { VaArg, FnPtrArg, CppFrom, + DefaultConstructible, TriviallyCopyable, Default, )] 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 f354f67d38..a35dd69c28 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 @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, TriviallyCopyableUnsafe, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, )] #[cpp_from(i32, construct, value)] pub struct p1_default_member_initializer_names_object_Holder { @@ -43,6 +50,7 @@ pub unsafe fn test_0() { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] 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 e5ee0965ec..230bf27b03 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 @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct p16_rebind_member_Alloc_std_pair_const_int__int___rebind_std_pair_const_int__int__ {} @@ -17,6 +26,13 @@ pub struct p16_rebind_member_Alloc_std_pair_const_int__int__ { #[offset(0)] pub id: i32, } +impl DefaultConstructible for p16_rebind_member_Alloc_std_pair_const_int__int__ { + fn default_constructor(this: &Ptr) { + { + p16_rebind_member_Alloc_std_pair_const_int__int__Impl::construct(this); + } + } +} impl Default for p16_rebind_member_Alloc_std_pair_const_int__int__ { fn default() -> Self { { p16_rebind_member_Alloc_std_pair_const_int__int__ { id: 0 } } @@ -46,7 +62,16 @@ pub fn test_0() { assert!(({ ((*n.borrow()).len() == 1_usize) })); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct p18_rebind_to_container_node_Alloc_std_pair_const_int__int__ {} @@ -79,6 +104,7 @@ fn main_0() -> i32 { return 0; } pub trait p16_rebind_member_Alloc_std_pair_const_int__int__Impl { + fn construct(&self); fn allocate(&self, mut n: usize) -> Ptr<(Value, Value)> { unimplemented!() } @@ -89,6 +115,9 @@ pub trait p16_rebind_member_Alloc_std_pair_const_int__int__Impl { impl p16_rebind_member_Alloc_std_pair_const_int__int__Impl for Ptr { + fn construct(&self) { + field!((*self), id).write(0); + } } pub trait p18_rebind_to_container_node_Alloc_std_pair_const_int__int__Impl { fn allocate(&self, mut n: usize) -> Ptr<(Value, Value)> { 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 b6827e40a8..3786566e29 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 @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p16_rebind_member_Alloc_std_pair_const_int__int___rebind_std_pair_const_int__int__ {} #[repr(C)] @@ -16,6 +23,18 @@ pub struct p16_rebind_member_Alloc_std_pair_const_int__int___rebind_std_pair_con pub struct p16_rebind_member_Alloc_std_pair_const_int__int__ { pub id: i32, } +impl p16_rebind_member_Alloc_std_pair_const_int__int__ { + pub unsafe fn construct(&mut self) { + (&raw mut self.id).write(0); + } +} +impl DefaultConstructibleUnsafe for p16_rebind_member_Alloc_std_pair_const_int__int__ { + unsafe fn default_constructor(&mut self) { + unsafe { + p16_rebind_member_Alloc_std_pair_const_int__int__::construct(&mut *self); + } + } +} impl Default for p16_rebind_member_Alloc_std_pair_const_int__int__ { fn default() -> Self { unsafe { p16_rebind_member_Alloc_std_pair_const_int__int__ { id: 0 } } @@ -47,7 +66,14 @@ pub unsafe fn test_0() { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p18_rebind_to_container_node_Alloc_std_pair_const_int__int__ {} pub unsafe fn test_1() { 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 30f24bee61..46a518858d 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 @@ -20,6 +20,7 @@ thread_local!( VaArg, FnPtrArg, CppFrom, + DefaultConstructible, Memberwise, CopyConstructible, Movable, @@ -83,6 +84,7 @@ thread_local!( VaArg, FnPtrArg, CppFrom, + DefaultConstructible, Memberwise, CopyConstructible, Movable, 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 28f9e59dc9..6f86e43faa 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 @@ -15,6 +15,7 @@ pub static mut dtorCount_1: std::cell::LazyCell = std::cell::LazyCell::new( FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, @@ -77,6 +78,7 @@ pub static mut dtorCount_4: std::cell::LazyCell = std::cell::LazyCell::new( FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, 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 d29735ec5e..f9dcfd4d89 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 @@ -66,6 +66,13 @@ impl Clone for LifetimeTracked { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } +impl DefaultConstructible for LifetimeTracked { + fn default_constructor(this: &Ptr) { + { + LifetimeTrackedImpl::construct(this); + } + } +} impl Default for LifetimeTracked { fn default() -> Self { { 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 bd0627b35e..8b8d518169 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 @@ -66,6 +66,13 @@ impl Clone for LifetimeTracked { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } +impl DefaultConstructible for LifetimeTracked { + fn default_constructor(this: &Ptr) { + { + LifetimeTrackedImpl::construct(this); + } + } +} impl Default for LifetimeTracked { fn default() -> Self { { @@ -95,6 +102,7 @@ thread_local!( VaArg, FnPtrArg, CppFrom, + DefaultConstructible, Memberwise, CopyConstructible, Movable, 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 4c1c31a43f..07bb6234a0 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 @@ -58,6 +58,13 @@ impl Clone for LifetimeTracked { } } } +impl DefaultConstructibleUnsafe for LifetimeTracked { + unsafe fn default_constructor(&mut self) { + unsafe { + LifetimeTracked::construct(&mut *self); + } + } +} impl Default for LifetimeTracked { fn default() -> Self { unsafe { 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 9e73cb1f6e..b1c965e4ee 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 @@ -58,6 +58,13 @@ impl Clone for LifetimeTracked { } } } +impl DefaultConstructibleUnsafe for LifetimeTracked { + unsafe fn default_constructor(&mut self) { + unsafe { + LifetimeTracked::construct(&mut *self); + } + } +} impl Default for LifetimeTracked { fn default() -> Self { unsafe { @@ -81,6 +88,7 @@ pub static mut dtorCount_6: std::cell::LazyCell = std::cell::LazyCell::new( FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, diff --git a/tests/std/temp/out/refcount/temp.type.rs b/tests/std/temp/out/refcount/temp.type.rs index c79f313bee..e2587de149 100644 --- a/tests/std/temp/out/refcount/temp.type.rs +++ b/tests/std/temp/out/refcount/temp.type.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct p2_6_pointer_to_member_argument_HasTwoInts { @@ -20,7 +29,16 @@ thread_local!( pub static count_0: Value = Rc::new(RefCell::new(0)); ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct p2_6_pointer_to_member_argument_CountsPerMember_refp2_6_pointer_to_member_argument_HasTwoInts_first_ @@ -29,7 +47,16 @@ thread_local!( pub static count_1: Value = Rc::new(RefCell::new(0)); ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct p2_6_pointer_to_member_argument_CountsPerMember_refp2_6_pointer_to_member_argument_HasTwoInts_second_ @@ -38,7 +65,16 @@ thread_local!( pub static count_2: Value = Rc::new(RefCell::new(0)); ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct p2_6_pointer_to_member_argument_CountsPerMember_nullptr_ {} diff --git a/tests/std/temp/out/unsafe/temp.type.rs b/tests/std/temp/out/unsafe/temp.type.rs index bea9cdbfc9..0759585309 100644 --- a/tests/std/temp/out/unsafe/temp.type.rs +++ b/tests/std/temp/out/unsafe/temp.type.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p2_6_pointer_to_member_argument_HasTwoInts { pub first: i32, @@ -17,21 +24,42 @@ pub struct p2_6_pointer_to_member_argument_HasTwoInts { pub static mut count_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p2_6_pointer_to_member_argument_CountsPerMember_nullptr_ {} pub unsafe fn test_3() { 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 a0c1d9cc91..1d21441178 100644 --- a/tests/std/temp/temp.spec/out/refcount/temp.inst.rs +++ b/tests/std/temp/temp.spec/out/refcount/temp.inst.rs @@ -12,6 +12,13 @@ pub struct p2_reference_does_not_instantiate_Member { #[offset(0)] pub value: i32, } +impl DefaultConstructible for p2_reference_does_not_instantiate_Member { + fn default_constructor(this: &Ptr) { + { + p2_reference_does_not_instantiate_MemberImpl::construct_1(this); + } + } +} impl Default for p2_reference_does_not_instantiate_Member { fn default() -> Self { { p2_reference_does_not_instantiate_Member { value: 1 } } @@ -25,12 +32,21 @@ pub struct p2_reference_does_not_instantiate_Holder { #[byte_size(4)] pub member: p2_reference_does_not_instantiate_Member, } +impl DefaultConstructible for p2_reference_does_not_instantiate_Holder { + fn default_constructor(this: &Ptr) { + { + p2_reference_does_not_instantiate_HolderImpl::construct_1(this); + } + } +} pub fn test_0() { - let mut holder: p2_reference_does_not_instantiate_Holder = - ::default(); - assert!((holder.member.value == 1)); - holder.member.value = 3; - assert!((holder.member.value == 3)); + let holder: Value = Rc::new(RefCell::new( + ::zero_init(), + )); + p2_reference_does_not_instantiate_HolderImpl::construct_1(&holder.as_pointer()); + assert!(({ (*holder.borrow()).member.value } == 1)); + (*holder.borrow_mut()).member.value = 3; + assert!(({ (*holder.borrow()).member.value } == 3)); } pub fn main() { __cpp2rust_init_globals(); @@ -43,13 +59,27 @@ 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 construct_1(&self); +} +impl p2_reference_does_not_instantiate_HolderImpl + for Ptr +{ + fn construct_1(&self) { + p2_reference_does_not_instantiate_MemberImpl::construct_1(&field_ptr!(self, member)); + } +} pub trait p2_reference_does_not_instantiate_MemberImpl { - fn construct_1(&self, _a0: Ptr); + fn construct_1(&self); + fn construct_2(&self, _a0: Ptr); } impl p2_reference_does_not_instantiate_MemberImpl for Ptr { - fn construct_1(&self, _a0: Ptr) { + fn construct_1(&self) { + field!((*self), value).write(1); + } + fn construct_2(&self, _a0: Ptr) { field!((*self), value).write(2); } } 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 6bc1120aca..f994f2ee06 100644 --- a/tests/std/temp/temp.spec/out/unsafe/temp.inst.rs +++ b/tests/std/temp/temp.spec/out/unsafe/temp.inst.rs @@ -12,13 +12,23 @@ pub struct p2_reference_does_not_instantiate_Member { pub value: i32, } impl p2_reference_does_not_instantiate_Member { - pub unsafe fn construct_1( + pub unsafe fn construct_1(&mut self) { + (&raw mut self.value).write(1); + } + pub unsafe fn construct_2( &mut self, _a0: *const p2_reference_does_not_instantiate_Wrapper_int_, ) { (&raw mut self.value).write(2); } } +impl DefaultConstructibleUnsafe for p2_reference_does_not_instantiate_Member { + unsafe fn default_constructor(&mut self) { + unsafe { + p2_reference_does_not_instantiate_Member::construct_1(&mut *self); + } + } +} impl Default for p2_reference_does_not_instantiate_Member { fn default() -> Self { unsafe { p2_reference_does_not_instantiate_Member { value: 1 } } @@ -30,9 +40,22 @@ impl Default for p2_reference_does_not_instantiate_Member { 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 construct_1(&mut self) { + p2_reference_does_not_instantiate_Member::construct_1(&mut self.member); + } +} +impl DefaultConstructibleUnsafe for p2_reference_does_not_instantiate_Holder { + unsafe fn default_constructor(&mut self) { + unsafe { + p2_reference_does_not_instantiate_Holder::construct_1(&mut *self); + } + } +} pub unsafe fn test_0() { let mut holder: p2_reference_does_not_instantiate_Holder = - ::default(); + ::zero_init(); + p2_reference_does_not_instantiate_Holder::construct_1(&mut holder); assert!(((holder.member.value) == (1))); holder.member.value = 3; assert!(((holder.member.value) == (3))); diff --git a/tests/std/utilities/utility/out/refcount/forward-helpers.rs b/tests/std/utilities/utility/out/refcount/forward-helpers.rs index aca3d2f6e6..249cfa6f7a 100644 --- a/tests/std/utilities/utility/out/refcount/forward-helpers.rs +++ b/tests/std/utilities/utility/out/refcount/forward-helpers.rs @@ -22,6 +22,7 @@ pub fn test_0() { FnPtrArg, CppFrom, Destructible, + DefaultConstructible, CopyAssignable, MoveAssignable, Swappable, @@ -76,6 +77,13 @@ pub struct p6_forward_like_Holder { #[byte_size(4)] pub member: p6_forward_like_Movable, } +impl DefaultConstructible for p6_forward_like_Holder { + fn default_constructor(this: &Ptr) { + { + p6_forward_like_HolderImpl::construct_1(this); + } + } +} impl Default for p6_forward_like_Holder { fn default() -> Self { { @@ -111,7 +119,16 @@ pub fn test_3() { ({ take_2(Ptr::clone(&moved.as_pointer()), holder.as_pointer()) }); assert!(({ (*moved.borrow()).value } == 1) && ({ (*holder.borrow()).member.value } == 0)); } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Destructible, Default)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + FnPtrArg, + CppFrom, + Destructible, + DefaultConstructible, + Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct p9_move_Movable { @@ -170,6 +187,7 @@ pub fn test_4() { FnPtrArg, CppFrom, Destructible, + DefaultConstructible, CopyAssignable, MoveAssignable, Swappable, @@ -255,6 +273,7 @@ pub fn test_7() { FnPtrArg, CppFrom, Destructible, + DefaultConstructible, CopyAssignable, MoveAssignable, Swappable, @@ -298,6 +317,7 @@ impl Clone for p11_move_if_noexcept_NoexceptMove { FnPtrArg, CppFrom, Destructible, + DefaultConstructible, CopyAssignable, MoveAssignable, Swappable, diff --git a/tests/std/utilities/utility/out/refcount/forward.rs b/tests/std/utilities/utility/out/refcount/forward.rs index 7f4e4d2d44..90330e7314 100644 --- a/tests/std/utilities/utility/out/refcount/forward.rs +++ b/tests/std/utilities/utility/out/refcount/forward.rs @@ -13,7 +13,16 @@ pub fn test_0() { assert!((source == 1)); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct p9_move_trivially_copyable_Point { @@ -45,7 +54,16 @@ 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, Destructible, Default)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + FnPtrArg, + CppFrom, + Destructible, + DefaultConstructible, + 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 78beb98f85..fe8fd7363a 100644 --- a/tests/std/utilities/utility/out/refcount/utility.as.const.rs +++ b/tests/std/utilities/utility/out/refcount/utility.as.const.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct p1_as_const_Counter { diff --git a/tests/std/utilities/utility/out/unsafe/forward-helpers.rs b/tests/std/utilities/utility/out/unsafe/forward-helpers.rs index 02d80b3f2f..18d458428b 100644 --- a/tests/std/utilities/utility/out/unsafe/forward-helpers.rs +++ b/tests/std/utilities/utility/out/unsafe/forward-helpers.rs @@ -21,6 +21,7 @@ pub unsafe fn test_0() { ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -79,6 +80,13 @@ impl p6_forward_like_Holder { p6_forward_like_Movable::construct(&mut self.member, { 1 }); } } +impl DefaultConstructibleUnsafe for p6_forward_like_Holder { + unsafe fn default_constructor(&mut self) { + unsafe { + p6_forward_like_Holder::construct_1(&mut *self); + } + } +} impl Default for p6_forward_like_Holder { fn default() -> Self { unsafe { @@ -111,7 +119,14 @@ pub unsafe fn test_3() { assert!(((moved.value) == (1)) && ((holder.member.value) == (0))); } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, Default)] +#[derive( + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + DefaultConstructibleUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct p9_move_Movable { pub value: i32, @@ -169,6 +184,7 @@ pub unsafe fn test_4() { ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -245,6 +261,7 @@ pub unsafe fn test_7() { ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -290,6 +307,7 @@ impl Clone for p11_move_if_noexcept_NoexceptMove { ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, diff --git a/tests/std/utilities/utility/out/unsafe/forward.rs b/tests/std/utilities/utility/out/unsafe/forward.rs index 77931edff5..4704b9ce79 100644 --- a/tests/std/utilities/utility/out/unsafe/forward.rs +++ b/tests/std/utilities/utility/out/unsafe/forward.rs @@ -14,7 +14,14 @@ pub unsafe fn test_0() { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct p9_move_trivially_copyable_Point { pub x: i32, @@ -44,7 +51,14 @@ pub unsafe fn test_1() { assert!(((element.x) == (5)) && ((element.y) == (6))); } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, Default)] +#[derive( + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + DefaultConstructibleUnsafe, + 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 57fe1a564b..a2bad17073 100644 --- a/tests/std/utilities/utility/out/unsafe/utility.as.const.rs +++ b/tests/std/utilities/utility/out/unsafe/utility.as.const.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 1c7a1b5590..68dafd7f6b 100644 --- a/tests/ub/out/refcount/ctor_ref_member.rs +++ b/tests/ub/out/refcount/ctor_ref_member.rs @@ -14,6 +14,7 @@ use std::rc::{Rc, Weak}; VaArg, FnPtrArg, CppFrom, + DefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/ub/out/refcount/self_referencing_initializer.rs b/tests/ub/out/refcount/self_referencing_initializer.rs index 13bfba46d5..f44c5f8da7 100644 --- a/tests/ub/out/refcount/self_referencing_initializer.rs +++ b/tests/ub/out/refcount/self_referencing_initializer.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct pair { diff --git a/tests/ub/out/refcount/ub6.rs b/tests/ub/out/refcount/ub6.rs index 56fd4f0be5..314431bf19 100644 --- a/tests/ub/out/refcount/ub6.rs +++ b/tests/ub/out/refcount/ub6.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, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct Pair { diff --git a/tests/ub/out/unsafe/ctor_ref_member.rs b/tests/ub/out/unsafe/ctor_ref_member.rs index 0e0e52e6f6..c6052fc7b8 100644 --- a/tests/ub/out/unsafe/ctor_ref_member.rs +++ b/tests/ub/out/unsafe/ctor_ref_member.rs @@ -14,6 +14,7 @@ use std::rc::Rc; FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/ub/out/unsafe/self_referencing_initializer.rs b/tests/ub/out/unsafe/self_referencing_initializer.rs index 3a8b2f231e..a553ac42ea 100644 --- a/tests/ub/out/unsafe/self_referencing_initializer.rs +++ b/tests/ub/out/unsafe/self_referencing_initializer.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct pair { pub a: i32, diff --git a/tests/ub/out/unsafe/ub6.rs b/tests/ub/out/unsafe/ub6.rs index f06685299d..68dfc47a12 100644 --- a/tests/ub/out/unsafe/ub6.rs +++ b/tests/ub/out/unsafe/ub6.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Pair { pub x1: *mut i32, diff --git a/tests/unit/out/refcount/05_new.rs b/tests/unit/out/refcount/05_new.rs index 924b7edc4d..825932b94c 100644 --- a/tests/unit/out/refcount/05_new.rs +++ b/tests/unit/out/refcount/05_new.rs @@ -7,12 +7,30 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct A {} #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct D {} diff --git a/tests/unit/out/refcount/10_struct.rs b/tests/unit/out/refcount/10_struct.rs index f51b0bce8c..b8dcd64be3 100644 --- a/tests/unit/out/refcount/10_struct.rs +++ b/tests/unit/out/refcount/10_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, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct GraphNode { @@ -18,7 +26,15 @@ pub struct GraphNode { pub next: Ptr, } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct Graph { @@ -35,6 +51,13 @@ pub struct Partial { #[byte_size(8)] pub p: Ptr, } +impl DefaultConstructible for Partial { + fn default_constructor(this: &Ptr) { + { + PartialImpl::construct_1(this); + } + } +} impl Default for Partial { fn default() -> Self { { @@ -45,12 +68,29 @@ impl Default for Partial { } } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct Declared {} #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct S { @@ -71,12 +111,13 @@ fn main_0() -> i32 { }; let arr: Value> = Rc::new(RefCell::new(Box::new([3, 1, 4]))); let it: Value = Rc::new(RefCell::new(::zero_init())); - PartialImpl::construct_1(&it.as_pointer(), { arr.decay() }); + PartialImpl::construct_2(&it.as_pointer(), { arr.decay() }); if ({ { (*it.borrow()).p.clone() } } != { arr.decay() }) { return 1; } - let mut def: Partial = ::default(); - if !((def.p).is_null()) { + let def: Value = Rc::new(RefCell::new(::zero_init())); + PartialImpl::construct_1(&def.as_pointer()); + if !(({ (*def.borrow()).p.clone() }).is_null()) { return 1; } let mut s: S = S { @@ -110,7 +151,8 @@ impl GraphImpl for Ptr { } } pub trait PartialImpl { - fn construct_1(&self, q: Ptr); + fn construct_1(&self); + fn construct_2(&self, q: Ptr); fn get(&self) -> Ptr { unimplemented!() } @@ -122,7 +164,10 @@ pub trait PartialImpl { } } impl PartialImpl for Ptr { - fn construct_1(&self, mut q: Ptr) { + fn construct_1(&self) { + field!((*self), p).write(Ptr::::null()); + } + fn construct_2(&self, mut q: Ptr) { field!((*self), p).write((q).clone()); } } diff --git a/tests/unit/out/refcount/addr_of_global.rs b/tests/unit/out/refcount/addr_of_global.rs index 5b4397813b..325660b7a0 100644 --- a/tests/unit/out/refcount/addr_of_global.rs +++ b/tests/unit/out/refcount/addr_of_global.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Inner { @@ -15,7 +24,15 @@ pub struct Inner { pub value: i32, } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Outer { diff --git a/tests/unit/out/refcount/anonymous-struct.rs b/tests/unit/out/refcount/anonymous-struct.rs index 8ace8a102f..158fe314f6 100644 --- a/tests/unit/out/refcount/anonymous-struct.rs +++ b/tests/unit/out/refcount/anonymous-struct.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Outer_Named { @@ -17,7 +26,16 @@ pub struct Outer_Named { pub b: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct anon_0 { @@ -27,7 +45,16 @@ pub struct anon_0 { pub d: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct anon_1 { @@ -37,7 +64,16 @@ pub struct anon_1 { pub h: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct anon_2 { @@ -47,7 +83,16 @@ pub struct anon_2 { pub f: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct anon_4 { @@ -55,7 +100,16 @@ pub struct anon_4 { pub j: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct anon_5 { @@ -63,7 +117,16 @@ pub struct anon_5 { pub k: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(12)] pub struct anon_3 { @@ -77,7 +140,16 @@ pub struct anon_3 { pub anon_5: anon_5, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(44)] pub struct Outer { @@ -143,7 +215,16 @@ fn main_0() -> i32 { return 0; } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct anon_6 { diff --git a/tests/unit/out/refcount/anonymous-struct_c.rs b/tests/unit/out/refcount/anonymous-struct_c.rs index 9d1ab67c4b..61904445eb 100644 --- a/tests/unit/out/refcount/anonymous-struct_c.rs +++ b/tests/unit/out/refcount/anonymous-struct_c.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Named { @@ -17,7 +26,16 @@ pub struct Named { pub b: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct anon_0 { @@ -27,7 +45,16 @@ pub struct anon_0 { pub d: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct anon_1 { @@ -37,7 +64,16 @@ pub struct anon_1 { pub h: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct anon_2 { @@ -47,7 +83,16 @@ pub struct anon_2 { pub f: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct anon_4 { @@ -55,7 +100,16 @@ pub struct anon_4 { pub j: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct anon_5 { @@ -63,7 +117,16 @@ pub struct anon_5 { pub k: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(12)] pub struct anon_3 { @@ -77,7 +140,16 @@ pub struct anon_3 { pub anon_5: anon_5, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(44)] pub struct Outer { @@ -149,7 +221,16 @@ fn main_0() -> i32 { return 0; } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct anon_6 { diff --git a/tests/unit/out/refcount/anonymous_enum.rs b/tests/unit/out/refcount/anonymous_enum.rs index 26ed8c8e5e..d808c6d2ff 100644 --- a/tests/unit/out/refcount/anonymous_enum.rs +++ b/tests/unit/out/refcount/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; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct S { @@ -27,7 +36,16 @@ 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, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct WithAnonField { diff --git a/tests/unit/out/refcount/anonymous_enum_c.rs b/tests/unit/out/refcount/anonymous_enum_c.rs index dafdff28c1..8cdbc3b327 100644 --- a/tests/unit/out/refcount/anonymous_enum_c.rs +++ b/tests/unit/out/refcount/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; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct S { @@ -27,7 +36,16 @@ 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, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct WithAnonField { diff --git a/tests/unit/out/refcount/any.rs b/tests/unit/out/refcount/any.rs index 5270704b76..5cf0a6d7bc 100644 --- a/tests/unit/out/refcount/any.rs +++ b/tests/unit/out/refcount/any.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Point { diff --git a/tests/unit/out/refcount/array_const_init.rs b/tests/unit/out/refcount/array_const_init.rs index 2422bc4a53..bf800dd702 100644 --- a/tests/unit/out/refcount/array_const_init.rs +++ b/tests/unit/out/refcount/array_const_init.rs @@ -6,7 +6,16 @@ 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, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[byte_size(20)] pub struct S { #[offset(0)] @@ -39,7 +48,16 @@ thread_local!( })); ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct P { diff --git a/tests/unit/out/refcount/array_field_addr.rs b/tests/unit/out/refcount/array_field_addr.rs index 4786cf7a8d..d75a2d2621 100644 --- a/tests/unit/out/refcount/array_field_addr.rs +++ b/tests/unit/out/refcount/array_field_addr.rs @@ -6,7 +6,16 @@ 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, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[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 317bcf9bd7..f3c414bc24 100644 --- a/tests/unit/out/refcount/array_of_noncopy_struct.rs +++ b/tests/unit/out/refcount/array_of_noncopy_struct.rs @@ -27,6 +27,13 @@ pub struct NonCopy { #[offset(24)] pub tag: i32, } +impl DefaultConstructible for NonCopy { + fn default_constructor(this: &Ptr) { + { + NonCopyImpl::construct_1(this); + } + } +} impl Default for NonCopy { fn default() -> Self { { @@ -42,7 +49,11 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let mut arr: [NonCopy; 3] = std::array::from_fn::<_, 3, _>(|_| ::default()); + let mut arr: [NonCopy; 3] = std::array::from_fn::<_, 3, _>(|_| { + let __v: Value = Rc::new(RefCell::new(::zero_init())); + NonCopyImpl::construct_1(&__v.as_pointer()); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }); arr[(0) as usize].tag = 7; { let __a1 = 42; @@ -55,4 +66,13 @@ fn main_0() -> i32 { assert!((arr[(2) as usize].data.len() == 0_usize)); return 0; } +pub trait NonCopyImpl { + fn construct_1(&self); +} +impl NonCopyImpl for Ptr { + fn construct_1(&self) { + field!((*self), data).write(Vec::new()); + field!((*self), tag).write(0); + } +} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/array_reference.rs b/tests/unit/out/refcount/array_reference.rs index 722a013a49..72b41e9565 100644 --- a/tests/unit/out/refcount/array_reference.rs +++ b/tests/unit/out/refcount/array_reference.rs @@ -60,7 +60,16 @@ pub fn pick_10(s: Ptr) -> Ptr { return (s).clone(); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Point { diff --git a/tests/unit/out/refcount/as_const.rs b/tests/unit/out/refcount/as_const.rs index a8fdec8e55..61fc9aa4e6 100644 --- a/tests/unit/out/refcount/as_const.rs +++ b/tests/unit/out/refcount/as_const.rs @@ -10,7 +10,16 @@ pub type Overload = u32; pub const Overload_kMutableOverload: Overload = 1; pub const Overload_kConstOverload: Overload = 2; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct S { diff --git a/tests/unit/out/refcount/assign_rhs_first.rs b/tests/unit/out/refcount/assign_rhs_first.rs index c332364203..92a13669d6 100644 --- a/tests/unit/out/refcount/assign_rhs_first.rs +++ b/tests/unit/out/refcount/assign_rhs_first.rs @@ -16,7 +16,15 @@ pub fn advance_1() -> i32 { return 10; } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct S { diff --git a/tests/unit/out/refcount/assignment_single_eval.rs b/tests/unit/out/refcount/assignment_single_eval.rs index b5289ad4b8..1d68e30dd8 100644 --- a/tests/unit/out/refcount/assignment_single_eval.rs +++ b/tests/unit/out/refcount/assignment_single_eval.rs @@ -811,7 +811,15 @@ pub fn test_reference_members_9() { ); } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Slot_6 { @@ -820,7 +828,15 @@ pub struct Slot_6 { pub value: Ptr, } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Slot_8 { @@ -829,7 +845,15 @@ pub struct Slot_8 { pub value: Ptr, } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Slot_10 { @@ -896,7 +920,15 @@ pub fn test_pointer_elements_11() { printf!(b"pointer increments %d %d\n", (*index.borrow()), value); } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Holder_12 { @@ -932,7 +964,15 @@ pub fn test_reference_pointer_13() { ); } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Node_14 { @@ -1031,7 +1071,16 @@ pub fn test_reference_subfields_18() { ); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Index_16 { @@ -1039,7 +1088,15 @@ pub struct Index_16 { pub value: u32, } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Slot_17 { @@ -1048,7 +1105,16 @@ pub struct Slot_17 { pub ref_: Ptr, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(2)] pub struct Index_19 { @@ -1056,7 +1122,15 @@ pub struct Index_19 { pub value: i16, } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Slot_20 { @@ -1100,7 +1174,16 @@ pub fn observe_24(mut assigned: i32, mut stored: Ptr) -> i32 { return ({ assigned } + { (stored.read()) }); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct GlobalRecord_Inner { @@ -1108,7 +1191,16 @@ pub struct GlobalRecord_Inner { pub value: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct GlobalRecord { @@ -1351,7 +1443,16 @@ thread_local!( static flag_31: Value = Rc::new(RefCell::new(false)); ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Record_32 { @@ -1359,7 +1460,15 @@ pub struct Record_32 { pub value: i32, } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Link_33 { @@ -1372,7 +1481,16 @@ thread_local!( Rc::new(RefCell::new(Box::new([0_u32, 20_u32, 30_u32]))); ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct IndexedBinding {} @@ -1609,7 +1727,16 @@ thread_local!( ]))); ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(12)] pub struct IndexedMember { @@ -1972,7 +2099,15 @@ thread_local!( ]))); ); #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct PointerSelector { @@ -2194,8 +2329,24 @@ pub struct Counts_59 { #[byte_size(24)] pub counts: Vec, } +impl DefaultConstructible for Counts_59 { + fn default_constructor(this: &Ptr) { + { + Counts_59Impl::construct_1(this); + } + } +} #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Pair_60 { @@ -2508,14 +2659,32 @@ fn main_0() -> i32 { return 0; } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Index_62 { #[offset(0)] pub value: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[byte_size(12)] pub struct Owner_63 { #[offset(0)] @@ -2535,6 +2704,14 @@ impl Default for Owner_63 { } } } +pub trait Counts_59Impl { + fn construct_1(&self); +} +impl Counts_59Impl for Ptr { + fn construct_1(&self) { + field!((*self), counts).write(Vec::new()); + } +} pub trait IndexedBindingImpl { fn get_1_0(&self) -> Ptr; } diff --git a/tests/unit/out/refcount/bounded_struct_ptr.rs b/tests/unit/out/refcount/bounded_struct_ptr.rs index 3de5649ccc..49fb64a8d3 100644 --- a/tests/unit/out/refcount/bounded_struct_ptr.rs +++ b/tests/unit/out/refcount/bounded_struct_ptr.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Foo { diff --git a/tests/unit/out/refcount/bst.rs b/tests/unit/out/refcount/bst.rs index 8095021ce7..5f31e8f754 100644 --- a/tests/unit/out/refcount/bst.rs +++ b/tests/unit/out/refcount/bst.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, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(24)] pub struct node_t { diff --git a/tests/unit/out/refcount/c_struct.rs b/tests/unit/out/refcount/c_struct.rs index 1101707966..2d690adb0d 100644 --- a/tests/unit/out/refcount/c_struct.rs +++ b/tests/unit/out/refcount/c_struct.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Point { @@ -17,7 +26,16 @@ pub struct Point { pub y: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct Line { @@ -29,7 +47,15 @@ pub struct Line { pub end: Point, } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct Node { @@ -44,7 +70,16 @@ 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, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Inner { @@ -54,7 +89,16 @@ pub struct Inner { pub b: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct Container { diff --git a/tests/unit/out/refcount/cast.rs b/tests/unit/out/refcount/cast.rs index ee1fe2634e..1aae79711e 100644 --- a/tests/unit/out/refcount/cast.rs +++ b/tests/unit/out/refcount/cast.rs @@ -11,7 +11,16 @@ 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, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Pair { @@ -21,7 +30,16 @@ pub struct Pair { pub y: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(64)] #[byte_align(64)] @@ -29,7 +47,16 @@ pub struct Wide { #[offset(0)] pub c: i8, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[byte_size(40)] pub struct Grid { #[offset(0)] @@ -78,6 +105,13 @@ pub struct Bag { #[byte_size(24)] pub items: Vec, } +impl DefaultConstructible for Bag { + fn default_constructor(this: &Ptr) { + { + BagImpl::construct_1(this); + } + } +} 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]))); @@ -347,7 +381,8 @@ pub fn nested_5() { assert!(({ ((*m.borrow())[(1) as usize][(1) as usize] == 42) })); assert!(({ (pm).clone() } == { (m.decay().offset(1).decay().offset(1)) })); assert!(({ (pm).clone() } < { (m.decay().offset(2).decay().offset(0)) })); - let b: Value = Rc::new(RefCell::new(::default())); + let b: Value = Rc::new(RefCell::new(::zero_init())); + BagImpl::construct_1(&b.as_pointer()); if 4_usize > (*b.borrow()).items.capacity() as usize { let len_0 = (*b.borrow()).items.len(); (*b.borrow_mut()) @@ -531,4 +566,13 @@ fn main_0() -> i32 { ({ bool_to_floating_10() }); return 0; } +pub trait BagImpl { + fn construct_1(&self); +} +impl BagImpl for Ptr { + fn construct_1(&self) { + field!((*self), n).write(0_i32); + field!((*self), items).write(Vec::new()); + } +} 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 65684a8a4a..0229f2700e 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,16 @@ pub fn strlen_1(mut s: Ptr) -> i32 { } return c; } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[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 c0017c288d..eac68f8b7f 100644 --- a/tests/unit/out/refcount/class.rs +++ b/tests/unit/out/refcount/class.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Pair { @@ -17,7 +26,16 @@ pub struct Pair { pub second: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct Route { @@ -28,7 +46,16 @@ pub struct Route { pub cost: f64, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Counter { @@ -43,7 +70,16 @@ impl CppEq for Counter { } } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Tally { diff --git a/tests/unit/out/refcount/class_template_lazy_member.rs b/tests/unit/out/refcount/class_template_lazy_member.rs index e5730e47cf..83de1e5182 100644 --- a/tests/unit/out/refcount/class_template_lazy_member.rs +++ b/tests/unit/out/refcount/class_template_lazy_member.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Point { @@ -15,7 +24,16 @@ pub struct Point { pub x: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Box_int_ { @@ -23,7 +41,16 @@ pub struct Box_int_ { pub val: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Box_Point_ { @@ -32,7 +59,16 @@ pub struct Box_Point_ { pub val: Point, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Deduced_int_ { @@ -40,7 +76,16 @@ pub struct Deduced_int_ { pub val: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Deduced_Point_ { diff --git a/tests/unit/out/refcount/class_templates.rs b/tests/unit/out/refcount/class_templates.rs index e0e8c740e3..a16fe7368c 100644 --- a/tests/unit/out/refcount/class_templates.rs +++ b/tests/unit/out/refcount/class_templates.rs @@ -26,6 +26,13 @@ pub struct MyContainer_int_ { #[byte_size(24)] vec_: Vec, } +impl DefaultConstructible for MyContainer_int_ { + fn default_constructor(this: &Ptr) { + { + MyContainer_int_Impl::construct_1(this); + } + } +} #[derive( Clone, Record, @@ -46,6 +53,13 @@ pub struct MyContainer_char_ { #[byte_size(24)] vec_: Vec, } +impl DefaultConstructible for MyContainer_char_ { + fn default_constructor(this: &Ptr) { + { + MyContainer_char_Impl::construct_1(this); + } + } +} #[derive( Clone, Record, @@ -66,8 +80,24 @@ pub struct MyContainer_float_ { #[byte_size(24)] vec_: Vec, } +impl DefaultConstructible for MyContainer_float_ { + fn default_constructor(this: &Ptr) { + { + MyContainer_float_Impl::construct_1(this); + } + } +} #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(2)] pub struct Boxed_short_ { @@ -80,7 +110,16 @@ impl Boxed_short_ { } } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Boxed_int_ { @@ -93,7 +132,16 @@ impl Boxed_int_ { } } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Boxed_long_ { @@ -106,7 +154,16 @@ impl Boxed_long_ { } } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Outer_int__Inner_int_ { @@ -116,7 +173,16 @@ pub struct Outer_int__Inner_int_ { pub u: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Outer_int_ { @@ -124,7 +190,16 @@ pub struct Outer_int_ { pub v: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct Outer_long__Inner_int_ { @@ -134,7 +209,16 @@ pub struct Outer_long__Inner_int_ { pub u: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct Outer_long__Inner_char_ { @@ -144,7 +228,16 @@ pub struct Outer_long__Inner_char_ { pub u: i8, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Outer_long_ { @@ -152,7 +245,16 @@ pub struct Outer_long_ { pub v: i64, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Elem { @@ -206,7 +308,8 @@ fn main_0() -> i32 { assert!((({ Boxed_long_::twice(10_i64,) }) == 20_i64)); let bl: Value = Rc::new(RefCell::new(Boxed_long_ { value: 7_i64 })); assert!((({ Boxed_long_Impl::plus(&bl.as_pointer(), 1_i64,) }) == 8_i64)); - let imc: Value = Rc::new(RefCell::new(::default())); + let imc: Value = Rc::new(RefCell::new(::zero_init())); + MyContainer_int_Impl::construct_1(&imc.as_pointer()); assert!(({ MyContainer_int_Impl::empty(&imc.as_pointer(),) })); ({ let _item: Value = Rc::new(RefCell::new(1)); @@ -218,7 +321,8 @@ fn main_0() -> i32 { ); ({ MyContainer_int_Impl::pop_back(&imc.as_pointer()) }); assert!(({ MyContainer_int_Impl::empty(&imc.as_pointer(),) })); - let cmc: Value = Rc::new(RefCell::new(::default())); + let cmc: Value = Rc::new(RefCell::new(::zero_init())); + MyContainer_char_Impl::construct_1(&cmc.as_pointer()); assert!(({ MyContainer_char_Impl::empty(&cmc.as_pointer(),) })); ({ let _item: Value = Rc::new(RefCell::new(('a' as i8))); @@ -231,7 +335,8 @@ fn main_0() -> i32 { ); ({ MyContainer_char_Impl::pop_back(&cmc.as_pointer()) }); assert!(({ MyContainer_char_Impl::empty(&cmc.as_pointer(),) })); - let fmc: Value = Rc::new(RefCell::new(::default())); + let fmc: Value = Rc::new(RefCell::new(::zero_init())); + MyContainer_float_Impl::construct_1(&fmc.as_pointer()); assert!(({ MyContainer_float_Impl::empty(&fmc.as_pointer(),) })); ({ let _item: Value = Rc::new(RefCell::new((1_f64 as f32))); @@ -279,6 +384,7 @@ pub trait MyContainer_char_Impl { fn back_4(&self) -> Ptr; fn pop_back(&self); fn push_back(&self, item: Ptr); + fn construct_1(&self); } impl MyContainer_char_Impl for Ptr { fn empty(&self) -> bool { @@ -303,6 +409,9 @@ impl MyContainer_char_Impl for Ptr { field!((*self), vec_).with_mut(|__v: &mut Vec| __v.push(a0_clone)) }; } + fn construct_1(&self) { + field!((*self), vec_).write(Vec::new()); + } } pub trait MyContainer_float_Impl { fn empty(&self) -> bool; @@ -313,6 +422,7 @@ pub trait MyContainer_float_Impl { fn back_4(&self) -> Ptr; fn pop_back(&self); fn push_back(&self, item: Ptr); + fn construct_1(&self); } impl MyContainer_float_Impl for Ptr { fn empty(&self) -> bool { @@ -337,6 +447,9 @@ impl MyContainer_float_Impl for Ptr { field!((*self), vec_).with_mut(|__v: &mut Vec| __v.push(a0_clone)) }; } + fn construct_1(&self) { + field!((*self), vec_).write(Vec::new()); + } } pub trait MyContainer_int_Impl { fn empty(&self) -> bool; @@ -347,6 +460,7 @@ pub trait MyContainer_int_Impl { fn back_4(&self) -> Ptr; fn pop_back(&self); fn push_back(&self, item: Ptr); + fn construct_1(&self); } impl MyContainer_int_Impl for Ptr { fn empty(&self) -> bool { @@ -371,6 +485,9 @@ impl MyContainer_int_Impl for Ptr { field!((*self), vec_).with_mut(|__v: &mut Vec| __v.push(a0_clone)) }; } + fn construct_1(&self) { + field!((*self), vec_).write(Vec::new()); + } } pub trait Outer_int_Impl { fn with(&self, n: i32) -> Outer_int__Inner_int_; diff --git a/tests/unit/out/refcount/clone_vs_move.rs b/tests/unit/out/refcount/clone_vs_move.rs index 8ff26fa496..5fbb67ca6c 100644 --- a/tests/unit/out/refcount/clone_vs_move.rs +++ b/tests/unit/out/refcount/clone_vs_move.rs @@ -7,14 +7,32 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Bar { #[offset(0)] pub w: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[byte_size(40)] pub struct Foo { #[offset(0)] @@ -47,7 +65,15 @@ impl Default for Foo { } } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct Refs { diff --git a/tests/unit/out/refcount/comma_operator.rs b/tests/unit/out/refcount/comma_operator.rs index 01cfc91200..9f04a89f1a 100644 --- a/tests/unit/out/refcount/comma_operator.rs +++ b/tests/unit/out/refcount/comma_operator.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Pair { diff --git a/tests/unit/out/refcount/complex_function.rs b/tests/unit/out/refcount/complex_function.rs index 17ef61eafd..f160bcf747 100644 --- a/tests/unit/out/refcount/complex_function.rs +++ b/tests/unit/out/refcount/complex_function.rs @@ -16,7 +16,16 @@ pub fn bar_2(x: Ptr) -> Ptr { return (x).clone(); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct X1 { @@ -24,7 +33,15 @@ pub struct X1 { pub v: i32, } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct X2 { @@ -33,7 +50,15 @@ pub struct X2 { pub v: Ptr, } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct X3 { @@ -42,7 +67,15 @@ pub struct X3 { pub v: Ptr, } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct X4 { diff --git a/tests/unit/out/refcount/compound_assign_paren.rs b/tests/unit/out/refcount/compound_assign_paren.rs index b044d3da66..fb0440b491 100644 --- a/tests/unit/out/refcount/compound_assign_paren.rs +++ b/tests/unit/out/refcount/compound_assign_paren.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct Item { diff --git a/tests/unit/out/refcount/concepts.rs b/tests/unit/out/refcount/concepts.rs index 3791914faf..21314c993a 100644 --- a/tests/unit/out/refcount/concepts.rs +++ b/tests/unit/out/refcount/concepts.rs @@ -12,7 +12,16 @@ const _: () = assert!( "sizeof(int) == 4" ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct Sized {} diff --git a/tests/unit/out/refcount/constexpr_function.rs b/tests/unit/out/refcount/constexpr_function.rs index abcf1d334c..6b606f0d63 100644 --- a/tests/unit/out/refcount/constexpr_function.rs +++ b/tests/unit/out/refcount/constexpr_function.rs @@ -22,7 +22,16 @@ pub fn half_3(mut x: f64) -> f64 { return (x / 2_f64); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Flag { @@ -47,7 +56,16 @@ pub fn imm_7(mut b: bool) -> bool { return b; } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct P { diff --git a/tests/unit/out/refcount/constructor.rs b/tests/unit/out/refcount/constructor.rs index 8cf4c9c971..24cb0340e7 100644 --- a/tests/unit/out/refcount/constructor.rs +++ b/tests/unit/out/refcount/constructor.rs @@ -17,6 +17,7 @@ thread_local!( VaArg, FnPtrArg, CppFrom, + DefaultConstructible, Memberwise, CopyConstructible, Movable, @@ -47,6 +48,13 @@ pub struct Point { #[offset(4)] pub y: i32, } +impl DefaultConstructible for Point { + fn default_constructor(this: &Ptr) { + { + PointImpl::construct_3(this); + } + } +} impl Default for Point { fn default() -> Self { { diff --git a/tests/unit/out/refcount/container_element_receiver.rs b/tests/unit/out/refcount/container_element_receiver.rs index eee650b6ab..0c10054ba6 100644 --- a/tests/unit/out/refcount/container_element_receiver.rs +++ b/tests/unit/out/refcount/container_element_receiver.rs @@ -14,6 +14,7 @@ use std::rc::{Rc, Weak}; VaArg, FnPtrArg, Destructible, + DefaultConstructible, Memberwise, CopyConstructible, CopyAssignable, diff --git a/tests/unit/out/refcount/container_field_addr.rs b/tests/unit/out/refcount/container_field_addr.rs index 6c59f17525..cb9fee17db 100644 --- a/tests/unit/out/refcount/container_field_addr.rs +++ b/tests/unit/out/refcount/container_field_addr.rs @@ -28,6 +28,13 @@ pub struct S { #[byte_size(24)] pub v: Vec, } +impl DefaultConstructible for S { + fn default_constructor(this: &Ptr) { + { + SImpl::construct_1(this); + } + } +} pub fn add_0(mut v: Ptr>, mut k: i32) { { let a0_clone = k.clone(); @@ -55,13 +62,27 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let local: Value = Rc::new(RefCell::new(::default())); + let local: Value = Rc::new(RefCell::new(::zero_init())); + SImpl::construct_1(&local.as_pointer()); (*local.borrow_mut()).tag = 7; ({ run_1((local.as_pointer())) }); - let mut heap: Ptr = Ptr::alloc(::default()); + let mut heap: Ptr = { + let __p = Ptr::alloc(::zero_init()); + SImpl::construct_1(&__p); + __p + }; field!(heap, tag).write(7); ({ run_1((heap).clone()) }); heap.delete(); return 0; } +pub trait SImpl { + fn construct_1(&self); +} +impl SImpl for Ptr { + fn construct_1(&self) { + field!((*self), tag).write(0_i32); + field!((*self), v).write(Vec::new()); + } +} 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 d066554edb..62abe35571 100644 --- a/tests/unit/out/refcount/conversion_operator_same_translation.rs +++ b/tests/unit/out/refcount/conversion_operator_same_translation.rs @@ -15,6 +15,7 @@ use std::rc::{Rc, Weak}; VaArg, FnPtrArg, CppFrom, + DefaultConstructible, TriviallyCopyable, Default, )] @@ -34,6 +35,7 @@ pub struct S { VaArg, FnPtrArg, CppFrom, + DefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/copy_assign.rs b/tests/unit/out/refcount/copy_assign.rs index faf50d7ac0..0008da9867 100644 --- a/tests/unit/out/refcount/copy_assign.rs +++ b/tests/unit/out/refcount/copy_assign.rs @@ -9,7 +9,17 @@ use std::rc::{Rc, Weak}; thread_local!( pub static assigns_0: Value = Rc::new(RefCell::new(0)); ); -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Movable, Default)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + DefaultConstructible, + Movable, + Default, +)] #[byte_size(8)] pub struct Partial { #[offset(0)] @@ -52,6 +62,13 @@ pub struct NonConstAssign { #[offset(0)] pub mark: i32, } +impl DefaultConstructible for NonConstAssign { + fn default_constructor(this: &Ptr) { + { + NonConstAssignImpl::construct(this); + } + } +} impl Default for NonConstAssign { fn default() -> Self { { @@ -87,6 +104,13 @@ impl CopyAssignable for RefQualified { return (*this).clone(); } } +impl DefaultConstructible for RefQualified { + fn default_constructor(this: &Ptr) { + { + RefQualifiedImpl::construct(this); + } + } +} impl Default for RefQualified { fn default() -> Self { { @@ -106,6 +130,7 @@ impl Default for RefQualified { VaArg, FnPtrArg, Destructible, + DefaultConstructible, Memberwise, MoveConstructible, Swappable, @@ -144,6 +169,7 @@ thread_local!( FnPtrArg, CppFrom, Destructible, + DefaultConstructible, Memberwise, Movable, Default, @@ -177,6 +203,7 @@ impl Clone for CopyCounted { VaArg, FnPtrArg, Destructible, + DefaultConstructible, Memberwise, MoveConstructible, Swappable, @@ -233,6 +260,13 @@ impl CopyAssignable for ExplicitOperatorCall { return (*this).clone(); } } +impl DefaultConstructible for ExplicitOperatorCall { + fn default_constructor(this: &Ptr) { + { + ExplicitOperatorCallImpl::construct_1(this); + } + } +} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); @@ -398,8 +432,12 @@ fn main_0() -> i32 { && (array_elem!(hc1.as_pointer(), arr, 1).with(|__s| __s.v) == 6) ); assert!((copies_1.with(|rc| *rc.borrow()) == 0)); - let e1: Value = Rc::new(RefCell::new(::default())); - let e2: Value = Rc::new(RefCell::new(::default())); + let e1: Value = + Rc::new(RefCell::new(::zero_init())); + ExplicitOperatorCallImpl::construct_1(&e1.as_pointer()); + let e2: Value = + Rc::new(RefCell::new(::zero_init())); + ExplicitOperatorCallImpl::construct_1(&e2.as_pointer()); { let __a1 = 5; (*e1.borrow_mut()).w.push(__a1) @@ -422,6 +460,14 @@ impl CopyCountedImpl for Ptr { field!((*self), v).write(v); } } +pub trait ExplicitOperatorCallImpl { + fn construct_1(&self); +} +impl ExplicitOperatorCallImpl for Ptr { + fn construct_1(&self) { + field!((*self), w).write(Vec::new()); + } +} pub trait NonConstAssignImpl { fn construct(&self); fn operator_assign_2(&self, o: Ptr) -> Ptr; diff --git a/tests/unit/out/refcount/copy_ctor.rs b/tests/unit/out/refcount/copy_ctor.rs index 474c83257c..97b89c1c4e 100644 --- a/tests/unit/out/refcount/copy_ctor.rs +++ b/tests/unit/out/refcount/copy_ctor.rs @@ -17,6 +17,7 @@ thread_local!( FnPtrArg, CppFrom, Destructible, + DefaultConstructible, Memberwise, Movable, Default, @@ -69,6 +70,13 @@ impl Clone for NonConst { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } +impl DefaultConstructible for NonConst { + fn default_constructor(this: &Ptr) { + { + NonConstImpl::construct(this); + } + } +} impl Default for NonConst { fn default() -> Self { { @@ -88,6 +96,7 @@ impl Default for NonConst { FnPtrArg, CppFrom, Destructible, + DefaultConstructible, Memberwise, Movable, Default, @@ -121,6 +130,7 @@ impl Clone for Ignored { VaArg, FnPtrArg, Destructible, + DefaultConstructible, Memberwise, MoveConstructible, Swappable, @@ -156,6 +166,7 @@ impl Default for Holder { FnPtrArg, CppFrom, Destructible, + DefaultConstructible, Memberwise, CopyAssignable, MoveAssignable, @@ -192,6 +203,7 @@ impl Clone for Box_int_ { VaArg, FnPtrArg, Destructible, + DefaultConstructible, Memberwise, CopyAssignable, MoveAssignable, @@ -213,6 +225,7 @@ pub struct Owner { FnPtrArg, CppFrom, Destructible, + DefaultConstructible, Memberwise, Movable, Default, @@ -270,6 +283,13 @@ impl Clone for Tracked { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } +impl DefaultConstructible for Tracked { + fn default_constructor(this: &Ptr) { + { + TrackedImpl::construct(this); + } + } +} impl Default for Tracked { fn default() -> Self { { Tracked { copied_from: 0 } } @@ -396,12 +416,14 @@ fn main_0() -> i32 { NonConstImpl::construct_2(&n2.as_pointer(), { cn.as_pointer() }); assert!(({ (*n1.borrow()).mark } == 1)); assert!(({ (*n2.borrow()).mark } == 10)); - let t1: Value = Rc::new(RefCell::new(::default())); + let t1: Value = Rc::new(RefCell::new(::zero_init())); + TrackedImpl::construct(&t1.as_pointer()); let t2: Value = Rc::new(RefCell::new(::zero_init())); CopyConstructible::copy_constructor(&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 ct: Value = Rc::new(RefCell::new(::zero_init())); + TrackedImpl::construct(&ct.as_pointer()); let t3: Value = Rc::new(RefCell::new(::zero_init())); CopyConstructible::copy_constructor(&t3.as_pointer(), { ct.as_pointer() }); ({ touch_1((ct.as_pointer())) }); @@ -456,6 +478,14 @@ impl OutOfLineImpl for Ptr { field!((*self), v).write(v); } } +pub trait TrackedImpl { + fn construct(&self); +} +impl TrackedImpl for Ptr { + fn construct(&self) { + field!((*self), copied_from).write(0); + } +} 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 c009ee5638..1b045e0ad9 100644 --- a/tests/unit/out/refcount/copy_move_defaulted.rs +++ b/tests/unit/out/refcount/copy_move_defaulted.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Inner { @@ -22,6 +31,7 @@ pub struct Inner { VaArg, FnPtrArg, CppFrom, + DefaultConstructible, Memberwise, CopyConstructible, MoveConstructible, @@ -49,7 +59,16 @@ impl Default for Explicit { { ::zero_init() } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[byte_size(16)] pub struct Implicit { #[offset(0)] @@ -83,6 +102,7 @@ impl Default for Implicit { FnPtrArg, CppFrom, Destructible, + DefaultConstructible, Memberwise, CopyConstructible, Swappable, @@ -116,6 +136,7 @@ impl MoveAssignable for DefaultCopyUserMove { FnPtrArg, CppFrom, Destructible, + DefaultConstructible, Memberwise, Swappable, Default, @@ -149,7 +170,15 @@ impl Clone for UserCopyDefaultMove { } } #[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Destructible, Memberwise, Swappable, + Record, + ByteRepr, + ZeroInitialization, + FnPtrArg, + CppFrom, + Destructible, + DefaultConstructible, + Memberwise, + Swappable, )] #[memberwise(move_constructor, move_assign)] #[cpp_from(i32, construct, value)] @@ -190,6 +219,13 @@ pub struct Owner { #[byte_size(8)] pub p: Option>, } +impl DefaultConstructible for Owner { + fn default_constructor(this: &Ptr) { + { + OwnerImpl::construct_1(this); + } + } +} impl Default for Owner { fn default() -> Self { { @@ -222,6 +258,13 @@ pub struct Copyable { #[byte_size(24)] pub data: Vec, } +impl DefaultConstructible for Copyable { + fn default_constructor(this: &Ptr) { + { + CopyableImpl::construct_1(this); + } + } +} #[derive( Record, ByteRepr, @@ -229,6 +272,7 @@ pub struct Copyable { FnPtrArg, CppFrom, Destructible, + DefaultConstructible, Memberwise, Swappable, Default, @@ -273,6 +317,13 @@ impl MoveAssignable for SeesThis { return (*this).clone(); } } +impl DefaultConstructible for SeesThis { + fn default_constructor(this: &Ptr) { + { + SeesThisImpl::construct_1(this); + } + } +} impl Default for SeesThis { fn default() -> Self { { @@ -293,6 +344,13 @@ pub struct HasSeesThis { #[byte_size(24)] pub v: Vec, } +impl DefaultConstructible for HasSeesThis { + fn default_constructor(this: &Ptr) { + { + HasSeesThisImpl::construct_1(this); + } + } +} #[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Swappable)] #[byte_size(8)] pub struct Counted_int_ { @@ -314,6 +372,13 @@ impl MoveAssignable for Counted_int_ { return (*this).clone(); } } +impl DefaultConstructible for Counted_int_ { + fn default_constructor(this: &Ptr) { + { + Counted_int_Impl::construct(this); + } + } +} impl Default for Counted_int_ { fn default() -> Self { { Counted_int_ { v: 0_i32, moves: 0 } } @@ -332,6 +397,13 @@ pub struct HasCounted { #[byte_size(24)] pub w: Vec, } +impl DefaultConstructible for HasCounted { + fn default_constructor(this: &Ptr) { + { + HasCountedImpl::construct_1(this); + } + } +} #[derive( Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Destructible, Swappable, )] @@ -377,6 +449,13 @@ impl Clone for CtorSeesThis { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } +impl DefaultConstructible for CtorSeesThis { + fn default_constructor(this: &Ptr) { + { + CtorSeesThisImpl::construct_2(this); + } + } +} impl Default for CtorSeesThis { fn default() -> Self { { @@ -410,6 +489,13 @@ pub struct HasCtorSeesThis { #[byte_size(24)] pub v: Vec, } +impl DefaultConstructible for HasCtorSeesThis { + fn default_constructor(this: &Ptr) { + { + HasCtorSeesThisImpl::construct_1(this); + } + } +} #[derive( Clone, Record, @@ -431,6 +517,13 @@ pub struct InitsCtorSeesThis { #[byte_size(16)] pub y: CtorSeesThis, } +impl DefaultConstructible for InitsCtorSeesThis { + fn default_constructor(this: &Ptr) { + { + InitsCtorSeesThisImpl::construct(this); + } + } +} impl Default for InitsCtorSeesThis { fn default() -> Self { { @@ -476,6 +569,13 @@ impl Clone for OutOfLineDefaulted { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } +impl DefaultConstructible for OutOfLineDefaulted { + fn default_constructor(this: &Ptr) { + { + OutOfLineDefaultedImpl::construct(this); + } + } +} impl Default for OutOfLineDefaulted { fn default() -> Self { { @@ -501,6 +601,13 @@ pub struct OutOfLineAssign { #[byte_size(24)] pub w: Vec, } +impl DefaultConstructible for OutOfLineAssign { + fn default_constructor(this: &Ptr) { + { + OutOfLineAssignImpl::construct_1(this); + } + } +} impl Default for OutOfLineAssign { fn default() -> Self { { @@ -712,7 +819,8 @@ fn main_0() -> i32 { && ((*bufs.borrow())[0_usize].data.is_empty()) }) ); - let o1: Value = Rc::new(RefCell::new(::default())); + let o1: Value = Rc::new(RefCell::new(::zero_init())); + OwnerImpl::construct_1(&o1.as_pointer()); { let __a1 = 5; (*o1.borrow_mut()).data.push(__a1) @@ -739,7 +847,8 @@ fn main_0() -> i32 { && (({ (*o1.borrow()).p.clone() }.as_pointer()).is_null()) }) ); - let o3: Value = Rc::new(RefCell::new(::default())); + let o3: Value = Rc::new(RefCell::new(::zero_init())); + OwnerImpl::construct_1(&o3.as_pointer()); ({ MoveAssignable::move_assign(&o3.as_pointer(), o2.as_pointer()) }); assert!( ((({ (*o3.borrow()).n } == 5) @@ -761,7 +870,8 @@ fn main_0() -> i32 { MoveConstructible::move_constructor(&c3.as_pointer(), { c1.as_pointer() }); 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())); + let c4: Value = Rc::new(RefCell::new(::zero_init())); + CopyableImpl::construct_1(&c4.as_pointer()); ({ MoveAssignable::move_assign(&c4.as_pointer(), c3.as_pointer()) }); assert!( ({ @@ -797,18 +907,23 @@ fn main_0() -> i32 { && (({ (*h3.borrow()).p.clone() }.as_pointer().read()) == 9)) && (({ (*h2.borrow()).p.clone() }.as_pointer()).is_null()) ); - let t1: Value = Rc::new(RefCell::new(::default())); - let t2: Value = Rc::new(RefCell::new(::default())); - let t3: Value = Rc::new(RefCell::new(::default())); + let t1: Value = Rc::new(RefCell::new(::zero_init())); + HasSeesThisImpl::construct_1(&t1.as_pointer()); + let t2: Value = Rc::new(RefCell::new(::zero_init())); + HasSeesThisImpl::construct_1(&t2.as_pointer()); + let t3: Value = Rc::new(RefCell::new(::zero_init())); + HasSeesThisImpl::construct_1(&t3.as_pointer()); ({ MoveAssignable::move_assign(&t2.as_pointer(), t1.as_pointer()) }); assert!(({ { (*t2.borrow()).s.self_.clone() } } == { (field_ptr!(t2.as_pointer(), s)) })); ({ CopyAssignable::copy_assign(&t3.as_pointer(), t2.as_pointer()) }); assert!(({ { (*t3.borrow()).s.self_.clone() } } == { (field_ptr!(t3.as_pointer(), s)) })); - let k1: Value = Rc::new(RefCell::new(::default())); + let k1: Value = Rc::new(RefCell::new(::zero_init())); + HasCountedImpl::construct_1(&k1.as_pointer()); let k2: Value = Rc::new(RefCell::new(::zero_init())); MoveConstructible::move_constructor(&k2.as_pointer(), { k1.as_pointer() }); assert!(({ (*k2.borrow()).c.moves } == 1)); - let k3: Value = Rc::new(RefCell::new(::default())); + let k3: Value = Rc::new(RefCell::new(::zero_init())); + HasCountedImpl::construct_1(&k3.as_pointer()); ({ MoveAssignable::move_assign(&k3.as_pointer(), k2.as_pointer()) }); assert!(({ (*k3.borrow()).c.moves } == 2)); { @@ -871,9 +986,12 @@ fn main_0() -> i32 { ({ (*o2.borrow()).v } == 2) && ({ { (*o2.borrow()).x.self_.clone() } } == { (field_ptr!(o2.as_pointer(), x)) }) ); - let a1: Value = Rc::new(RefCell::new(::default())); - let a2: Value = Rc::new(RefCell::new(::default())); - let a3: Value = Rc::new(RefCell::new(::default())); + let a1: Value = Rc::new(RefCell::new(::zero_init())); + OutOfLineAssignImpl::construct_1(&a1.as_pointer()); + let a2: Value = Rc::new(RefCell::new(::zero_init())); + OutOfLineAssignImpl::construct_1(&a2.as_pointer()); + let a3: Value = Rc::new(RefCell::new(::zero_init())); + OutOfLineAssignImpl::construct_1(&a3.as_pointer()); (*a1.borrow_mut()).v = 3; { let __a1 = 4; @@ -917,6 +1035,23 @@ impl BufferImpl for Ptr { }; } } +pub trait CopyableImpl { + fn construct_1(&self); +} +impl CopyableImpl for Ptr { + fn construct_1(&self) { + field!((*self), data).write(Vec::new()); + } +} +pub trait Counted_int_Impl { + fn construct(&self); +} +impl Counted_int_Impl for Ptr { + fn construct(&self) { + field!((*self), v).write(0_i32); + field!((*self), moves).write(0); + } +} pub trait CtorSeesThisImpl { fn construct_2(&self); fn construct_1(&self, id: i32); @@ -949,6 +1084,15 @@ impl ExplicitImpl for Ptr { field!((*self), arr).write(Box::new([v, (v + 1)])); } } +pub trait HasCountedImpl { + fn construct_1(&self); +} +impl HasCountedImpl for Ptr { + fn construct_1(&self) { + Counted_int_Impl::construct(&field_ptr!(self, c)); + field!((*self), w).write(Vec::new()); + } +} pub trait HasCtorSeesThisImpl { fn construct_1(&self); } @@ -958,6 +1102,15 @@ impl HasCtorSeesThisImpl for Ptr { field!((*self), v).write(Vec::new()); } } +pub trait HasSeesThisImpl { + fn construct_1(&self); +} +impl HasSeesThisImpl for Ptr { + fn construct_1(&self) { + SeesThisImpl::construct_1(&field_ptr!(self, s)); + field!((*self), v).write(Vec::new()); + } +} pub trait HolderImpl { fn construct(&self, v: i32); } @@ -977,6 +1130,16 @@ impl InitsCtorSeesThisImpl for Ptr { CtorSeesThisImpl::construct_1(&field_ptr!(self, y), { 2 }); } } +pub trait OutOfLineAssignImpl { + fn construct_1(&self); +} +impl OutOfLineAssignImpl for Ptr { + fn construct_1(&self) { + SeesThisImpl::construct_1(&field_ptr!(self, s)); + field!((*self), v).write(1); + field!((*self), w).write(Vec::new()); + } +} pub trait OutOfLineDefaultedImpl { fn construct(&self); } @@ -986,6 +1149,25 @@ impl OutOfLineDefaultedImpl for Ptr { field!((*self), v).write(1); } } +pub trait OwnerImpl { + fn construct_1(&self); +} +impl OwnerImpl for Ptr { + fn construct_1(&self) { + field!((*self), data).write(Vec::new()); + field!((*self), n).write(0_i32); + field!((*self), arr).write((0..2).map(|_| 0_i32).collect::>()); + field!((*self), p).write(None); + } +} +pub trait SeesThisImpl { + fn construct_1(&self); +} +impl SeesThisImpl for Ptr { + fn construct_1(&self) { + field!((*self), self_).write(Ptr::::null()); + } +} 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 9f41453527..3aaca65469 100644 --- a/tests/unit/out/refcount/copy_move_deleted.rs +++ b/tests/unit/out/refcount/copy_move_deleted.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, FnPtrArg, CppFrom, Destructible, Swappable, Default, + Record, + ByteRepr, + ZeroInitialization, + FnPtrArg, + CppFrom, + Destructible, + DefaultConstructible, + Swappable, + Default, )] #[cpp_from(i32, construct, value)] #[byte_size(4)] @@ -47,6 +55,13 @@ impl MoveAssignable for PrivateCopy { return (*this).clone(); } } +impl DefaultConstructible for PrivateCopy { + fn default_constructor(this: &Ptr) { + { + PrivateCopyImpl::construct(this); + } + } +} impl Default for PrivateCopy { fn default() -> Self { { @@ -64,6 +79,13 @@ pub struct Immovable { #[offset(0)] pub v: i32, } +impl DefaultConstructible for Immovable { + fn default_constructor(this: &Ptr) { + { + ImmovableImpl::construct(this); + } + } +} impl Default for Immovable { fn default() -> Self { { @@ -76,7 +98,15 @@ impl Default for Immovable { } } #[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Swappable, Default, + Record, + ByteRepr, + ZeroInitialization, + FnPtrArg, + Destructible, + DefaultConstructible, + Memberwise, + Swappable, + Default, )] #[memberwise(move_constructor, move_assign)] #[byte_size(8)] @@ -97,6 +127,13 @@ pub struct VecHolder { #[byte_size(24)] pub items: Vec, } +impl DefaultConstructible for VecHolder { + fn default_constructor(this: &Ptr) { + { + VecHolderImpl::construct_1(this); + } + } +} pub fn bump_0(mut p: Ptr) { field!(p, v).with_mut(|__v| __v.postfix_inc()); } @@ -145,7 +182,8 @@ fn main_0() -> i32 { (({ (*d.borrow()).inner.v } == 6) && ({ (*d.borrow()).tag } == 7)) && ({ (*c.borrow()).inner.v } == 0) ); - let h: Value = Rc::new(RefCell::new(::default())); + let h: Value = Rc::new(RefCell::new(::zero_init())); + VecHolderImpl::construct_1(&h.as_pointer()); let h2: Value = Rc::new(RefCell::new(::zero_init())); MoveConstructible::move_constructor(&h2.as_pointer(), { h.as_pointer() }); assert!(({ ((*h2.borrow()).items.len() == 0_usize) })); @@ -185,4 +223,12 @@ impl PrivateCopyImpl for Ptr { field!((*self), v).write(0); } } +pub trait VecHolderImpl { + fn construct_1(&self); +} +impl VecHolderImpl for Ptr { + fn construct_1(&self) { + field!((*self), items).write(Vec::new()); + } +} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/default.rs b/tests/unit/out/refcount/default.rs index 9e96eabb62..8525663eef 100644 --- a/tests/unit/out/refcount/default.rs +++ b/tests/unit/out/refcount/default.rs @@ -6,7 +6,16 @@ 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, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[byte_size(144)] pub struct Pointers { #[offset(0)] @@ -43,7 +52,16 @@ impl Default for Pointers { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[byte_size(440)] pub struct SmallArrays { #[offset(0)] @@ -78,7 +96,16 @@ impl Default for SmallArrays { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[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 01c5c1d526..e1a0921c83 100644 --- a/tests/unit/out/refcount/default_function_arguments.rs +++ b/tests/unit/out/refcount/default_function_arguments.rs @@ -21,6 +21,13 @@ pub struct Bar { #[offset(0)] pub v: i32, } +impl DefaultConstructible for Bar { + fn default_constructor(this: &Ptr) { + { + BarImpl::construct(this, { 1 }); + } + } +} impl Default for Bar { fn default() -> Self { { @@ -61,7 +68,16 @@ pub fn first_9(r: Ptr) -> i32 { return (elem!(r, 0).read()); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Holder_int_ { diff --git a/tests/unit/out/refcount/default_in_statics.rs b/tests/unit/out/refcount/default_in_statics.rs index abf994b3ed..2e3fd971b0 100644 --- a/tests/unit/out/refcount/default_in_statics.rs +++ b/tests/unit/out/refcount/default_in_statics.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, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct Inner { @@ -17,7 +25,16 @@ pub struct Inner { #[byte_size(8)] pub name: Ptr, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[byte_size(88)] pub struct Outer { #[offset(0)] @@ -64,7 +81,15 @@ impl Default for Outer { } } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(40)] pub struct Foo { diff --git a/tests/unit/out/refcount/delete_array_order.rs b/tests/unit/out/refcount/delete_array_order.rs index aad2b0276c..a52965372c 100644 --- a/tests/unit/out/refcount/delete_array_order.rs +++ b/tests/unit/out/refcount/delete_array_order.rs @@ -13,6 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, + DefaultConstructible, Memberwise, CopyConstructible, Movable, diff --git a/tests/unit/out/refcount/destructor.rs b/tests/unit/out/refcount/destructor.rs index 67481c16d8..165f47cec7 100644 --- a/tests/unit/out/refcount/destructor.rs +++ b/tests/unit/out/refcount/destructor.rs @@ -16,6 +16,7 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, + DefaultConstructible, Memberwise, CopyConstructible, Movable, @@ -37,6 +38,7 @@ impl Destructible for S { VaArg, FnPtrArg, Destructible, + DefaultConstructible, Memberwise, CopyConstructible, Movable, @@ -58,6 +60,7 @@ pub struct Defaulted { VaArg, FnPtrArg, Destructible, + DefaultConstructible, Memberwise, CopyConstructible, MoveConstructible, @@ -80,6 +83,7 @@ pub struct Middle { VaArg, FnPtrArg, Destructible, + DefaultConstructible, Memberwise, CopyConstructible, MoveConstructible, @@ -102,6 +106,7 @@ pub struct Outer { VaArg, FnPtrArg, Destructible, + DefaultConstructible, Memberwise, CopyConstructible, MoveConstructible, @@ -132,6 +137,7 @@ impl Default for ArrayMember { ZeroInitialization, VaArg, FnPtrArg, + DefaultConstructible, Memberwise, CopyConstructible, Movable, @@ -156,6 +162,7 @@ impl Destructible for EmptyBody { ZeroInitialization, VaArg, FnPtrArg, + DefaultConstructible, Memberwise, CopyConstructible, Movable, @@ -184,6 +191,7 @@ impl Destructible for Templated_char_ { ZeroInitialization, VaArg, FnPtrArg, + DefaultConstructible, Memberwise, CopyConstructible, Movable, @@ -212,6 +220,7 @@ impl Destructible for Templated_int_ { ZeroInitialization, VaArg, FnPtrArg, + DefaultConstructible, Memberwise, CopyConstructible, Movable, @@ -242,6 +251,7 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, + DefaultConstructible, Memberwise, CopyConstructible, Movable, @@ -268,6 +278,7 @@ impl Destructible for Tagged { VaArg, FnPtrArg, Destructible, + DefaultConstructible, Memberwise, CopyConstructible, MoveConstructible, diff --git a/tests/unit/out/refcount/destructor_params.rs b/tests/unit/out/refcount/destructor_params.rs index a6a970b680..1850b9c3e2 100644 --- a/tests/unit/out/refcount/destructor_params.rs +++ b/tests/unit/out/refcount/destructor_params.rs @@ -19,6 +19,7 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, + DefaultConstructible, Memberwise, CopyConstructible, Movable, @@ -46,7 +47,16 @@ pub fn with_default_3(s: S) -> i32 { return { (*s.borrow()).v }; } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Holder { diff --git a/tests/unit/out/refcount/destructor_temporaries.rs b/tests/unit/out/refcount/destructor_temporaries.rs index a6852ad4f4..14cb4a6600 100644 --- a/tests/unit/out/refcount/destructor_temporaries.rs +++ b/tests/unit/out/refcount/destructor_temporaries.rs @@ -19,6 +19,7 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, + DefaultConstructible, Memberwise, CopyConstructible, Movable, @@ -44,6 +45,7 @@ impl Destructible for S { VaArg, FnPtrArg, Destructible, + DefaultConstructible, Memberwise, CopyConstructible, MoveConstructible, diff --git a/tests/unit/out/refcount/doubly_linked_list.rs b/tests/unit/out/refcount/doubly_linked_list.rs index 63273e8129..6354f2a64e 100644 --- a/tests/unit/out/refcount/doubly_linked_list.rs +++ b/tests/unit/out/refcount/doubly_linked_list.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, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(24)] pub struct Node { diff --git a/tests/unit/out/refcount/enum_default_in_static.rs b/tests/unit/out/refcount/enum_default_in_static.rs index 86f5e7d381..1fce4caaae 100644 --- a/tests/unit/out/refcount/enum_default_in_static.rs +++ b/tests/unit/out/refcount/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; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Config { diff --git a/tests/unit/out/refcount/enum_int_interop.rs b/tests/unit/out/refcount/enum_int_interop.rs index 829a40e61e..93ff893eb2 100644 --- a/tests/unit/out/refcount/enum_int_interop.rs +++ b/tests/unit/out/refcount/enum_int_interop.rs @@ -20,7 +20,15 @@ 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, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct Entry { diff --git a/tests/unit/out/refcount/enum_int_interop_c.rs b/tests/unit/out/refcount/enum_int_interop_c.rs index 42305144b2..b184c231b0 100644 --- a/tests/unit/out/refcount/enum_int_interop_c.rs +++ b/tests/unit/out/refcount/enum_int_interop_c.rs @@ -20,7 +20,15 @@ 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, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct Entry { diff --git a/tests/unit/out/refcount/enum_underlying_type.rs b/tests/unit/out/refcount/enum_underlying_type.rs index 44956ab035..603aae5610 100644 --- a/tests/unit/out/refcount/enum_underlying_type.rs +++ b/tests/unit/out/refcount/enum_underlying_type.rs @@ -31,6 +31,13 @@ pub struct HoldsEmpty { #[offset(0)] pub e: Empty, } +impl DefaultConstructible for HoldsEmpty { + fn default_constructor(this: &Ptr) { + { + HoldsEmptyImpl::construct_1(this); + } + } +} impl Default for HoldsEmpty { fn default() -> Self { { @@ -71,10 +78,19 @@ fn main_0() -> i32 { let mut sc: Scoped = Scoped_NEG; assert!(((sc as i32) == -2_i32)); assert!((((Scoped_POS as i8) as i32) == 2)); - let mut he: HoldsEmpty = ::default(); - assert!(!(he.e)); + let he: Value = Rc::new(RefCell::new(::zero_init())); + HoldsEmptyImpl::construct_1(&he.as_pointer()); + assert!(!({ (*he.borrow()).e })); let mut ev: Empty = ::default(); - assert!(((ev as i32) == (he.e as i32))); + assert!(((ev as i32) == ({ (*he.borrow()).e } as i32))); return 0; } +pub trait HoldsEmptyImpl { + fn construct_1(&self); +} +impl HoldsEmptyImpl for Ptr { + fn construct_1(&self) { + field!((*self), e).write(::default()); + } +} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/exprs.rs b/tests/unit/out/refcount/exprs.rs index d032496993..db71fa3715 100644 --- a/tests/unit/out/refcount/exprs.rs +++ b/tests/unit/out/refcount/exprs.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct X { @@ -15,7 +24,15 @@ pub struct X { pub x: i32, } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct Y { diff --git a/tests/unit/out/refcount/fft.rs b/tests/unit/out/refcount/fft.rs index 0c940fbdac..5062f26861 100644 --- a/tests/unit/out/refcount/fft.rs +++ b/tests/unit/out/refcount/fft.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct Complex { diff --git a/tests/unit/out/refcount/field_aliasing.rs b/tests/unit/out/refcount/field_aliasing.rs index f4137d0e56..c5e34dc158 100644 --- a/tests/unit/out/refcount/field_aliasing.rs +++ b/tests/unit/out/refcount/field_aliasing.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct In { @@ -16,7 +25,16 @@ pub struct In { #[offset(4)] pub y: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[byte_size(32)] pub struct S { #[offset(0)] @@ -44,7 +62,15 @@ impl Default for S { } } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct Node { diff --git a/tests/unit/out/refcount/field_array_elem_ptr.rs b/tests/unit/out/refcount/field_array_elem_ptr.rs index 9127c29598..d7afa27d5a 100644 --- a/tests/unit/out/refcount/field_array_elem_ptr.rs +++ b/tests/unit/out/refcount/field_array_elem_ptr.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Point { @@ -16,7 +25,16 @@ pub struct Point { #[offset(4)] pub y: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[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 d41c773bed..f208012e53 100644 --- a/tests/unit/out/refcount/field_method_receiver.rs +++ b/tests/unit/out/refcount/field_method_receiver.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Counter { @@ -42,6 +51,13 @@ pub struct S { #[byte_size(24)] pub v: Vec, } +impl DefaultConstructible for S { + fn default_constructor(this: &Ptr) { + { + SImpl::construct_1(this); + } + } +} impl Default for S { fn default() -> Self { { @@ -131,10 +147,21 @@ impl CounterImpl for Ptr { } pub trait SImpl { fn bump(&self); + fn construct_1(&self); } impl SImpl for Ptr { fn bump(&self) { ({ CounterImpl::add(&field_ptr!((*self), c), (*self).with(|__s| __s.tag)) }); } + fn construct_1(&self) { + field!((*self), tag).write(0_i32); + field!((*self), c).write(::default()); + field!((*self), arr).write( + (0..2) + .map(|_| ::default()) + .collect::>(), + ); + field!((*self), v).write(Vec::new()); + } } pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/field_pointers.rs b/tests/unit/out/refcount/field_pointers.rs index a92ec2bf84..44fb5c6208 100644 --- a/tests/unit/out/refcount/field_pointers.rs +++ b/tests/unit/out/refcount/field_pointers.rs @@ -6,7 +6,16 @@ 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, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[byte_size(12)] pub struct Inner { #[offset(0)] @@ -27,7 +36,16 @@ impl Default for Inner { } } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Header { @@ -71,6 +89,13 @@ pub struct Outer { #[array_len(4)] pub buf: Box<[i32]>, } +impl DefaultConstructible for Outer { + fn default_constructor(this: &Ptr) { + { + OuterImpl::construct_1(this); + } + } +} impl Default for Outer { fn default() -> Self { { @@ -226,6 +251,7 @@ pub trait OuterImpl { fn next(&self) -> i32; fn sum(&self) -> i32; fn push(&self, k: i32); + fn construct_1(&self); } impl OuterImpl for Ptr { fn next(&self) -> i32 { @@ -245,5 +271,13 @@ impl OuterImpl for Ptr { field!((*self), v).with_mut(|__v: &mut Vec| __v.push(__a1)) }; } + fn construct_1(&self) { + field!((*self), x).write(0_i32); + field!((*self), inner).write(::default()); + field!((*self), items).write((0..3).map(|_| ::default()).collect::>()); + field!((*self), v).write(Vec::new()); + field!((*self), cursor).write(Ptr::::null()); + field!((*self), buf).write((0..4).map(|_| 0_i32).collect::>()); + } } 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 4116a4be0d..e3534b6121 100644 --- a/tests/unit/out/refcount/field_pointers_malloced_struct.rs +++ b/tests/unit/out/refcount/field_pointers_malloced_struct.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(12)] pub struct S { diff --git a/tests/unit/out/refcount/field_reinterpret_write_through.rs b/tests/unit/out/refcount/field_reinterpret_write_through.rs index 63f42705c9..2892ee7979 100644 --- a/tests/unit/out/refcount/field_reinterpret_write_through.rs +++ b/tests/unit/out/refcount/field_reinterpret_write_through.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct In { @@ -16,7 +25,16 @@ pub struct In { #[offset(4)] pub b: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[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 6127f973e3..770723db7b 100644 --- a/tests/unit/out/refcount/find.rs +++ b/tests/unit/out/refcount/find.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct P { 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 1b46246e21..f72fa26cdc 100644 --- a/tests/unit/out/refcount/first_field_ptr_covers_struct.rs +++ b/tests/unit/out/refcount/first_field_ptr_covers_struct.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct In { @@ -17,7 +26,16 @@ pub struct In { pub b: i16, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(12)] pub struct S { diff --git a/tests/unit/out/refcount/first_member_downcast.rs b/tests/unit/out/refcount/first_member_downcast.rs index 5a666356f0..1dd39b621a 100644 --- a/tests/unit/out/refcount/first_member_downcast.rs +++ b/tests/unit/out/refcount/first_member_downcast.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct base { @@ -15,7 +24,16 @@ pub struct base { pub kind: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct derived { diff --git a/tests/unit/out/refcount/flex_array_member_incomplete.rs b/tests/unit/out/refcount/flex_array_member_incomplete.rs index ddbc62be30..d198e534f1 100644 --- a/tests/unit/out/refcount/flex_array_member_incomplete.rs +++ b/tests/unit/out/refcount/flex_array_member_incomplete.rs @@ -6,7 +6,16 @@ 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, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[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 4adacb075a..b91871a943 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,16 @@ 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, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[byte_size(8)] pub struct S { #[offset(0)] @@ -27,7 +36,16 @@ impl Default for S { } } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct E { @@ -36,7 +54,16 @@ pub struct E { #[offset(4)] pub w: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[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 701d0c6524..12e5956a60 100644 --- a/tests/unit/out/refcount/fn_ptr.rs +++ b/tests/unit/out/refcount/fn_ptr.rs @@ -36,6 +36,7 @@ pub fn identity_hash_6(mut v: bool) -> usize { VaArg, FnPtrArg, CppFrom, + DefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/fn_ptr_cast.rs b/tests/unit/out/refcount/fn_ptr_cast.rs index 4dc050e5b3..779ef32c2b 100644 --- a/tests/unit/out/refcount/fn_ptr_cast.rs +++ b/tests/unit/out/refcount/fn_ptr_cast.rs @@ -25,7 +25,15 @@ pub fn test_double_cast_2() { assert!(({ (fn2).clone() } == { (fn_).clone() })); } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Command { diff --git a/tests/unit/out/refcount/fn_ptr_stable_sort.rs b/tests/unit/out/refcount/fn_ptr_stable_sort.rs index 37e1c2b3b5..aa8da0b587 100644 --- a/tests/unit/out/refcount/fn_ptr_stable_sort.rs +++ b/tests/unit/out/refcount/fn_ptr_stable_sort.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Item { diff --git a/tests/unit/out/refcount/fn_ptr_struct.rs b/tests/unit/out/refcount/fn_ptr_struct.rs index 6002dc10e4..5c8f81cb2f 100644 --- a/tests/unit/out/refcount/fn_ptr_struct.rs +++ b/tests/unit/out/refcount/fn_ptr_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, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct Handler { @@ -24,7 +32,16 @@ pub fn negate_1(mut x: i32) -> i32 { return -x; } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct S {} @@ -39,7 +56,16 @@ impl S { return (x + 3); } } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Destructible, Default)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + FnPtrArg, + CppFrom, + Destructible, + DefaultConstructible, + 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 c65724388e..963bfce500 100644 --- a/tests/unit/out/refcount/fn_ptr_typedef_cast.rs +++ b/tests/unit/out/refcount/fn_ptr_typedef_cast.rs @@ -19,7 +19,16 @@ pub fn via_size_t_return_3(mut b: u64) -> usize { return (b as usize); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct pair { diff --git a/tests/unit/out/refcount/fn_ptr_vtable.rs b/tests/unit/out/refcount/fn_ptr_vtable.rs index 191b4b8b12..2fe9e11060 100644 --- a/tests/unit/out/refcount/fn_ptr_vtable.rs +++ b/tests/unit/out/refcount/fn_ptr_vtable.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, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(24)] pub struct Vtable { diff --git a/tests/unit/out/refcount/fn_ref.rs b/tests/unit/out/refcount/fn_ref.rs index cf5f330954..34fc55cf52 100644 --- a/tests/unit/out/refcount/fn_ref.rs +++ b/tests/unit/out/refcount/fn_ref.rs @@ -22,7 +22,15 @@ pub fn call_forwarded_4(f: FnPtr i32>, mut x: i32) -> i32 { return ({ f.call(x) }); } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Holder { diff --git a/tests/unit/out/refcount/for_body_destructor.rs b/tests/unit/out/refcount/for_body_destructor.rs index a9fa542be7..0e8fc6ea03 100644 --- a/tests/unit/out/refcount/for_body_destructor.rs +++ b/tests/unit/out/refcount/for_body_destructor.rs @@ -13,6 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, + DefaultConstructible, Memberwise, CopyConstructible, Movable, diff --git a/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs b/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs index f11222b3c3..6fbfc5bf05 100644 --- a/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs +++ b/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs @@ -28,12 +28,20 @@ pub struct S { #[offset(24)] pub a: i32, } +impl DefaultConstructible for S { + fn default_constructor(this: &Ptr) { + { + SImpl::construct_1(this); + } + } +} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let s: Value = Rc::new(RefCell::new(::default())); + let s: Value = Rc::new(RefCell::new(::zero_init())); + SImpl::construct_1(&s.as_pointer()); { let __a1 = 1; (*s.borrow_mut()).v.push(__a1) @@ -47,4 +55,13 @@ fn main_0() -> i32 { } return 0; } +pub trait SImpl { + fn construct_1(&self); +} +impl SImpl for Ptr { + fn construct_1(&self) { + field!((*self), v).write(Vec::new()); + field!((*self), a).write(0_i32); + } +} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/forward_basic.rs b/tests/unit/out/refcount/forward_basic.rs index 05b14668b6..5f7c92379d 100644 --- a/tests/unit/out/refcount/forward_basic.rs +++ b/tests/unit/out/refcount/forward_basic.rs @@ -17,6 +17,7 @@ pub const Overload_kRvalueOverload: Overload = 2; FnPtrArg, CppFrom, Destructible, + DefaultConstructible, CopyAssignable, MoveAssignable, Swappable, @@ -74,6 +75,7 @@ pub fn chosen_overload_1(_a0: Ptr) -> Overload { FnPtrArg, CppFrom, Destructible, + DefaultConstructible, Memberwise, CopyAssignable, MoveAssignable, diff --git a/tests/unit/out/refcount/forward_decltype.rs b/tests/unit/out/refcount/forward_decltype.rs index b59e3838aa..5dcc88106c 100644 --- a/tests/unit/out/refcount/forward_decltype.rs +++ b/tests/unit/out/refcount/forward_decltype.rs @@ -17,6 +17,7 @@ pub const Overload_kRvalueOverload: Overload = 2; FnPtrArg, CppFrom, Destructible, + DefaultConstructible, CopyAssignable, MoveAssignable, Swappable, diff --git a/tests/unit/out/refcount/forward_explicit.rs b/tests/unit/out/refcount/forward_explicit.rs index b26735659d..65611bf290 100644 --- a/tests/unit/out/refcount/forward_explicit.rs +++ b/tests/unit/out/refcount/forward_explicit.rs @@ -19,6 +19,7 @@ pub const Overload_kIntRvalueOverload: Overload = 4; FnPtrArg, CppFrom, Destructible, + DefaultConstructible, CopyAssignable, MoveAssignable, Swappable, diff --git a/tests/unit/out/refcount/forward_pack.rs b/tests/unit/out/refcount/forward_pack.rs index 78e555afc0..bc4f10db30 100644 --- a/tests/unit/out/refcount/forward_pack.rs +++ b/tests/unit/out/refcount/forward_pack.rs @@ -19,6 +19,7 @@ pub const Overload_kIntRvalueOverload: Overload = 4; FnPtrArg, CppFrom, Destructible, + DefaultConstructible, CopyAssignable, MoveAssignable, Swappable, @@ -117,6 +118,7 @@ pub fn forward_pack_7( VaArg, FnPtrArg, Destructible, + DefaultConstructible, Memberwise, CopyAssignable, MoveAssignable, diff --git a/tests/unit/out/refcount/friend.rs b/tests/unit/out/refcount/friend.rs index 815a0be998..7a0f68285e 100644 --- a/tests/unit/out/refcount/friend.rs +++ b/tests/unit/out/refcount/friend.rs @@ -19,7 +19,16 @@ 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, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct V { @@ -35,7 +44,16 @@ pub fn get_4(w: Ptr) -> i32 { return w.with(|__s| __s.x); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct W_int_ { @@ -46,7 +64,16 @@ pub fn get_5(w: Ptr) -> i64 { return w.with(|__s| __s.x); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct W_long_ { @@ -54,7 +81,16 @@ pub struct W_long_ { pub x: i64, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct D { diff --git a/tests/unit/out/refcount/function_overloading.rs b/tests/unit/out/refcount/function_overloading.rs index 6cc0887eb8..2aac587de4 100644 --- a/tests/unit/out/refcount/function_overloading.rs +++ b/tests/unit/out/refcount/function_overloading.rs @@ -22,7 +22,16 @@ pub fn bar_4(x: Ptr) -> i32 { return (x.read()); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct Foo {} diff --git a/tests/unit/out/refcount/global_call_temporaries.rs b/tests/unit/out/refcount/global_call_temporaries.rs index 8a0fd53eb7..1f7213625a 100644 --- a/tests/unit/out/refcount/global_call_temporaries.rs +++ b/tests/unit/out/refcount/global_call_temporaries.rs @@ -95,7 +95,16 @@ thread_local!( })); ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Item { diff --git a/tests/unit/out/refcount/global_init_side_effect.rs b/tests/unit/out/refcount/global_init_side_effect.rs index e93ba19d93..3372d4a4cb 100644 --- a/tests/unit/out/refcount/global_init_side_effect.rs +++ b/tests/unit/out/refcount/global_init_side_effect.rs @@ -18,6 +18,7 @@ thread_local!( VaArg, FnPtrArg, CppFrom, + DefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/global_non_const_init.rs b/tests/unit/out/refcount/global_non_const_init.rs index b9ca793e92..7d5484777a 100644 --- a/tests/unit/out/refcount/global_non_const_init.rs +++ b/tests/unit/out/refcount/global_non_const_init.rs @@ -38,6 +38,13 @@ pub struct Ctor { #[offset(0)] pub v: i32, } +impl DefaultConstructible for Ctor { + fn default_constructor(this: &Ptr) { + { + CtorImpl::construct_1(this); + } + } +} impl Default for Ctor { fn default() -> Self { { @@ -78,7 +85,16 @@ thread_local!( })); ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct Holder {} @@ -109,6 +125,13 @@ impl Singleton { return s_15.with(|v| v.as_pointer()); } } +impl DefaultConstructible for Singleton { + fn default_constructor(this: &Ptr) { + { + SingletonImpl::construct(this); + } + } +} impl Default for Singleton { fn default() -> Self { { diff --git a/tests/unit/out/refcount/global_pointers.rs b/tests/unit/out/refcount/global_pointers.rs index 7a522bc748..687fb4e9b4 100644 --- a/tests/unit/out/refcount/global_pointers.rs +++ b/tests/unit/out/refcount/global_pointers.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, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct Entry { diff --git a/tests/unit/out/refcount/global_without_initializer.rs b/tests/unit/out/refcount/global_without_initializer.rs index b2b979c7da..698c33abfe 100644 --- a/tests/unit/out/refcount/global_without_initializer.rs +++ b/tests/unit/out/refcount/global_without_initializer.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct S { diff --git a/tests/unit/out/refcount/goto_aggregate_default.rs b/tests/unit/out/refcount/goto_aggregate_default.rs index b8386b1071..e984cdbab1 100644 --- a/tests/unit/out/refcount/goto_aggregate_default.rs +++ b/tests/unit/out/refcount/goto_aggregate_default.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Point { diff --git a/tests/unit/out/refcount/goto_cleanup.rs b/tests/unit/out/refcount/goto_cleanup.rs index e367f14245..7745133aaa 100644 --- a/tests/unit/out/refcount/goto_cleanup.rs +++ b/tests/unit/out/refcount/goto_cleanup.rs @@ -77,7 +77,15 @@ 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, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct wrapper { diff --git a/tests/unit/out/refcount/huffman.rs b/tests/unit/out/refcount/huffman.rs index 3331ded53d..a710ae792c 100644 --- a/tests/unit/out/refcount/huffman.rs +++ b/tests/unit/out/refcount/huffman.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, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(24)] pub struct MinHeapNode { @@ -61,6 +69,13 @@ pub struct MinHeap { #[byte_size(8)] pub alloc: Option>>, } +impl DefaultConstructible for MinHeap { + fn default_constructor(this: &Ptr) { + { + MinHeapImpl::construct_1(this); + } + } +} pub fn AllocMinHeap_1(mut capacity: i32) -> Option> { let mut minHeap: Option> = Some(Rc::new(RefCell::new(MinHeap { size: 0, @@ -277,6 +292,7 @@ pub trait MinHeapImpl { freq: Ptr>>>, n: i32, ); + fn construct_1(&self); } impl MinHeapImpl for Ptr { fn Alloc(&self, mut data: i8, mut freq: i32) -> Ptr { @@ -442,6 +458,13 @@ impl MinHeapImpl for Ptr { } } } + fn construct_1(&self) { + field!((*self), size).write(0_i32); + field!((*self), capacity).write(0_i32); + field!((*self), arr).write(None); + field!((*self), next).write(0_i32); + field!((*self), alloc).write(None); + } } pub trait MinHeapNodeImpl { fn IsLeaf(&self) -> bool; 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 f91f095afb..81b6299b52 100644 --- a/tests/unit/out/refcount/immutable-deref-on-func-call.rs +++ b/tests/unit/out/refcount/immutable-deref-on-func-call.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Item { diff --git a/tests/unit/out/refcount/implicit_autoref.rs b/tests/unit/out/refcount/implicit_autoref.rs index 0ea580ff68..b72b549e06 100644 --- a/tests/unit/out/refcount/implicit_autoref.rs +++ b/tests/unit/out/refcount/implicit_autoref.rs @@ -26,6 +26,13 @@ pub struct Holder { #[byte_size(24)] pub v: Vec, } +impl DefaultConstructible for Holder { + fn default_constructor(this: &Ptr) { + { + HolderImpl::construct_1(this); + } + } +} pub fn write_through_0(mut p: Ptr) { p.write(42); } @@ -46,7 +53,8 @@ fn main_0() -> i32 { let mut p: Ptr> = (v.as_pointer()); let mut a: i32 = (index!(p, 0_usize).read()); index!(p, 1_usize).write(30); - let h: Value = Rc::new(RefCell::new(::default())); + let h: Value = Rc::new(RefCell::new(::zero_init())); + HolderImpl::construct_1(&h.as_pointer()); { let __a1 = 40; (*h.borrow_mut()).v.push(__a1) @@ -75,4 +83,12 @@ fn main_0() -> i32 { assert!(((index!(p, 0_usize).read()) == 42)); return 0; } +pub trait HolderImpl { + fn construct_1(&self); +} +impl HolderImpl for Ptr { + fn construct_1(&self) { + field!((*self), v).write(Vec::new()); + } +} 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 a37982771b..a714669f83 100644 --- a/tests/unit/out/refcount/in_class_field_initializer.rs +++ b/tests/unit/out/refcount/in_class_field_initializer.rs @@ -14,6 +14,13 @@ pub struct Inner { #[offset(4)] pub y: i32, } +impl DefaultConstructible for Inner { + fn default_constructor(this: &Ptr) { + { + InnerImpl::construct_1(this); + } + } +} impl Default for Inner { fn default() -> Self { { Inner { x: 3, y: 4 } } @@ -33,6 +40,13 @@ pub struct S { #[byte_size(8)] pub d: Inner, } +impl DefaultConstructible for S { + fn default_constructor(this: &Ptr) { + { + SImpl::construct_1(this); + } + } +} impl Default for S { fn default() -> Self { { @@ -45,7 +59,17 @@ impl Default for S { } } } -#[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable)] +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[byte_size(8)] pub struct Boxed_int_ { #[offset(0)] @@ -63,13 +87,14 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let mut s: S = ::default(); - assert!((s.a == 1)); - assert!(((s.b as i32) == 2)); - assert!((s.c.x == 3)); - assert!((s.c.y == 4)); - assert!((s.d.x == 3)); - assert!((s.d.y == 4)); + let s: Value = Rc::new(RefCell::new(::zero_init())); + SImpl::construct_1(&s.as_pointer()); + assert!(({ (*s.borrow()).a } == 1)); + assert!((({ (*s.borrow()).b } as i32) == 2)); + assert!(({ (*s.borrow()).c.x } == 3)); + assert!(({ (*s.borrow()).c.y } == 4)); + assert!(({ (*s.borrow()).d.x } == 3)); + assert!(({ (*s.borrow()).d.y } == 4)); let boxed: Value = Rc::new(RefCell::new(::zero_init())); Boxed_int_Impl::construct(&boxed.as_pointer(), { 5 }, { 9 }); assert!(({ (*boxed.borrow()).v } == 5)); @@ -85,4 +110,24 @@ impl Boxed_int_Impl for Ptr { field!((*self), tag).write(t); } } +pub trait InnerImpl { + fn construct_1(&self); +} +impl InnerImpl for Ptr { + fn construct_1(&self) { + field!((*self), x).write(3); + field!((*self), y).write(4); + } +} +pub trait SImpl { + fn construct_1(&self); +} +impl SImpl for Ptr { + fn construct_1(&self) { + field!((*self), a).write(1); + field!((*self), b).write(2_i8); + field!((*self), c).write(::default()); + InnerImpl::construct_1(&field_ptr!(self, d)); + } +} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/init.rs b/tests/unit/out/refcount/init.rs index e0b31f7990..89f9be2d87 100644 --- a/tests/unit/out/refcount/init.rs +++ b/tests/unit/out/refcount/init.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct X { diff --git a/tests/unit/out/refcount/init_list.rs b/tests/unit/out/refcount/init_list.rs index 10c1f8308c..5804dd5f32 100644 --- a/tests/unit/out/refcount/init_list.rs +++ b/tests/unit/out/refcount/init_list.rs @@ -10,7 +10,16 @@ pub fn f_0(list: Vec) { let list: Value> = Rc::new(RefCell::new(list)); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Pair { @@ -26,6 +35,13 @@ pub struct Holder { #[byte_size(8)] pub p: Pair, } +impl DefaultConstructible for Holder { + fn default_constructor(this: &Ptr) { + { + HolderImpl::construct_1(this); + } + } +} impl Default for Holder { fn default() -> Self { { @@ -44,6 +60,13 @@ pub struct Seven { #[offset(0)] pub v: i32, } +impl DefaultConstructible for Seven { + fn default_constructor(this: &Ptr) { + { + SevenImpl::construct_1(this); + } + } +} impl Default for Seven { fn default() -> Self { { Seven { v: 7 } } @@ -62,7 +85,8 @@ fn main_0() -> i32 { let mut vec_: Vec = Vec::from([1, 2, 3]); ({ f_0(Vec::from([1, 2, 3, 4])) }); let p: Value = Rc::new(RefCell::new(Pair { a: 1, b: 2 })); - let h: Value = Rc::new(RefCell::new(::default())); + let h: Value = Rc::new(RefCell::new(::zero_init())); + HolderImpl::construct_1(&h.as_pointer()); ({ HolderImpl::operator_assign_1(&h.as_pointer(), p.as_pointer()) }); assert!(({ (*h.borrow()).p.a } == 1) && ({ (*h.borrow()).p.b } == 2)); assert!((({ sum_1(p.as_pointer(),) }) == 3)); @@ -80,11 +104,23 @@ fn main_0() -> i32 { } pub trait HolderImpl { fn operator_assign_1(&self, o: Ptr) -> Ptr; + fn construct_1(&self); } impl HolderImpl for Ptr { fn operator_assign_1(&self, o: Ptr) -> Ptr { field!((*self), p).write({ (*o.upgrade().deref()) }); return (*self).clone(); } + fn construct_1(&self) { + field!((*self), p).write(Pair { a: 0, b: 0 }); + } +} +pub trait SevenImpl { + fn construct_1(&self); +} +impl SevenImpl for Ptr { + fn construct_1(&self) { + field!((*self), v).write(7); + } } 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 3cd1dc735a..f26a59a08b 100644 --- a/tests/unit/out/refcount/inline_container_fields.rs +++ b/tests/unit/out/refcount/inline_container_fields.rs @@ -31,6 +31,13 @@ pub struct Elem { #[byte_size(24)] pub coeffs: Vec, } +impl DefaultConstructible for Elem { + fn default_constructor(this: &Ptr) { + { + ElemImpl::construct_1(this); + } + } +} impl Default for Elem { fn default() -> Self { { @@ -74,6 +81,13 @@ pub struct State { #[byte_size(24)] pub rows: Vec>, } +impl DefaultConstructible for State { + fn default_constructor(this: &Ptr) { + { + StateImpl::construct_1(this); + } + } +} impl Default for State { fn default() -> Self { { @@ -193,6 +207,13 @@ impl Clone for Counted { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } +impl DefaultConstructible for Counted { + fn default_constructor(this: &Ptr) { + { + CountedImpl::construct(this); + } + } +} impl Default for Counted { fn default() -> Self { { Counted { v: 0 } } @@ -466,6 +487,42 @@ fn main_0() -> i32 { ); return 0; } +pub trait CountedImpl { + fn construct(&self); +} +impl CountedImpl for Ptr { + fn construct(&self) { + field!((*self), v).write(0); + } +} +pub trait ElemImpl { + fn construct_1(&self); +} +impl ElemImpl for Ptr { + fn construct_1(&self) { + field!((*self), id).write(0_i32); + field!((*self), hist).write((0..4).map(|_| 0_i32).collect::>()); + field!((*self), coeffs).write(Vec::new()); + } +} +pub trait StateImpl { + fn construct_1(&self); +} +impl StateImpl for Ptr { + fn construct_1(&self) { + field!((*self), count).write(0_i32); + field!((*self), grid).write( + (0..2) + .map(|_| (0..3).map(|_| 0_i32).collect::>()) + .collect::]>>(), + ); + field!((*self), arr).write(Box::<[i32]>::from(std::array::from_fn::<_, 3, _>(|_| { + 0_i32 + }))); + field!((*self), elems).write(Vec::new()); + field!((*self), rows).write(Vec::new()); + } +} 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 abccf8af04..af97726dca 100644 --- a/tests/unit/out/refcount/kruskal.rs +++ b/tests/unit/out/refcount/kruskal.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct Edge { @@ -116,6 +125,13 @@ pub struct DisjointSet { #[offset(16)] pub n: i32, } +impl DefaultConstructible for DisjointSet { + fn default_constructor(this: &Ptr) { + { + DisjointSetImpl::construct_1(this); + } + } +} #[derive( Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Swappable, Default, )] @@ -130,6 +146,13 @@ pub struct Graph { #[offset(12)] pub E: i32, } +impl DefaultConstructible for Graph { + fn default_constructor(this: &Ptr) { + { + GraphImpl::construct_1(this); + } + } +} 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 { @@ -242,6 +265,7 @@ pub trait DisjointSetImpl { fn makeSet(&self); fn find(&self, x: i32) -> i32; fn merge(&self, x: i32, y: i32); + fn construct_1(&self); } impl DisjointSetImpl for Ptr { fn makeSet(&self) { @@ -352,5 +376,20 @@ impl DisjointSetImpl for Ptr { ); } } + fn construct_1(&self) { + field!((*self), rank).write(None); + field!((*self), parent).write(None); + field!((*self), n).write(0_i32); + } +} +pub trait GraphImpl { + fn construct_1(&self); +} +impl GraphImpl for Ptr { + fn construct_1(&self) { + field!((*self), edges).write(None); + field!((*self), V).write(0_i32); + field!((*self), E).write(0_i32); + } } 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 ca3165a8b4..6b2d5258a2 100644 --- a/tests/unit/out/refcount/lambda_as_field.rs +++ b/tests/unit/out/refcount/lambda_as_field.rs @@ -13,6 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, + DefaultConstructible, Memberwise, CopyConstructible, Movable, @@ -40,7 +41,17 @@ impl Default for Guard__lambda_at_lambda_as_field_cpp_34_13__ { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Copyable, Default)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + Copyable, + Default, +)] #[byte_size(8)] pub struct Guard__lambda_at_lambda_as_field_cpp_45_13__ { #[offset(0)] @@ -52,7 +63,16 @@ impl Destructible for Guard__lambda_at_lambda_as_field_cpp_45_13__ { ({ (*(*this).upgrade().deref()).f.call() }); } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[byte_size(8)] pub struct Holder__lambda_at_lambda_as_field_cpp_39_12__ { #[offset(0)] @@ -76,7 +96,15 @@ impl Default for Holder__lambda_at_lambda_as_field_cpp_39_12__ { } } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Holder__lambda_at_lambda_as_field_cpp_51_12__ { @@ -86,7 +114,9 @@ pub struct Holder__lambda_at_lambda_as_field_cpp_51_12__ { #[offset(4)] pub calls: i32, } -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Destructible)] +#[derive( + Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Destructible, DefaultConstructible, +)] #[cpp_from(FnPtr i32 > , construct, value)] #[byte_size(8)] pub struct Moving__lambda_at_lambda_as_field_cpp_64_12__ { diff --git a/tests/unit/out/refcount/lambda_capture_copy_ctor.rs b/tests/unit/out/refcount/lambda_capture_copy_ctor.rs index 8dca0a91ce..fcab8b6ae8 100644 --- a/tests/unit/out/refcount/lambda_capture_copy_ctor.rs +++ b/tests/unit/out/refcount/lambda_capture_copy_ctor.rs @@ -47,6 +47,13 @@ impl Clone for Counted { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } +impl DefaultConstructible for Counted { + fn default_constructor(this: &Ptr) { + { + CountedImpl::construct(this); + } + } +} impl Default for Counted { fn default() -> Self { { @@ -85,6 +92,13 @@ impl Clone for Dropped { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } +impl DefaultConstructible for Dropped { + fn default_constructor(this: &Ptr) { + { + DroppedImpl::construct(this); + } + } +} impl Default for Dropped { fn default() -> Self { { diff --git a/tests/unit/out/refcount/lambda_capture_ref.rs b/tests/unit/out/refcount/lambda_capture_ref.rs index 03a59eddea..c3a99303f2 100644 --- a/tests/unit/out/refcount/lambda_capture_ref.rs +++ b/tests/unit/out/refcount/lambda_capture_ref.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct S { diff --git a/tests/unit/out/refcount/lambda_capture_star_this.rs b/tests/unit/out/refcount/lambda_capture_star_this.rs index e17b5a6ada..edeff6ad5e 100644 --- a/tests/unit/out/refcount/lambda_capture_star_this.rs +++ b/tests/unit/out/refcount/lambda_capture_star_this.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct S { diff --git a/tests/unit/out/refcount/lambda_capture_this.rs b/tests/unit/out/refcount/lambda_capture_this.rs index 70ec2ff7c7..a4555e1b08 100644 --- a/tests/unit/out/refcount/lambda_capture_this.rs +++ b/tests/unit/out/refcount/lambda_capture_this.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct S { diff --git a/tests/unit/out/refcount/lambda_capture_value.rs b/tests/unit/out/refcount/lambda_capture_value.rs index ace3ed41d7..2ec6f7b430 100644 --- a/tests/unit/out/refcount/lambda_capture_value.rs +++ b/tests/unit/out/refcount/lambda_capture_value.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct S { diff --git a/tests/unit/out/refcount/lambda_decltype_type.rs b/tests/unit/out/refcount/lambda_decltype_type.rs index d3eaefb6e1..026656e22d 100644 --- a/tests/unit/out/refcount/lambda_decltype_type.rs +++ b/tests/unit/out/refcount/lambda_decltype_type.rs @@ -19,6 +19,13 @@ pub struct Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { #[byte_size(1)] pub cmp: FnPtr bool>, } +impl DefaultConstructible for Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { + fn default_constructor(this: &Ptr) { + { + Sorted__lambda_at_lambda_decltype_type_cpp_22_18__Impl::construct_1(this); + } + } +} impl Default for Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { fn default() -> Self { { @@ -47,6 +54,13 @@ pub struct Sorted__lambda_at_lambda_decltype_type_cpp_19_23__ { #[byte_size(1)] pub cmp: FnPtr bool>, } +impl DefaultConstructible for Sorted__lambda_at_lambda_decltype_type_cpp_19_23__ { + fn default_constructor(this: &Ptr) { + { + Sorted__lambda_at_lambda_decltype_type_cpp_19_23__Impl::construct_1(this); + } + } +} impl Default for Sorted__lambda_at_lambda_decltype_type_cpp_19_23__ { fn default() -> Self { { @@ -76,8 +90,9 @@ fn main_0() -> i32 { }, ))); let desc: Value = Rc::new(RefCell::new( - ::default(), + ::zero_init(), )); + Sorted__lambda_at_lambda_decltype_type_cpp_22_18__Impl::construct_1(&desc.as_pointer()); ({ Sorted__lambda_at_lambda_decltype_type_cpp_22_18__Impl::insert(&desc.as_pointer(), 2) }); ({ Sorted__lambda_at_lambda_decltype_type_cpp_22_18__Impl::insert(&desc.as_pointer(), 7) }); ({ Sorted__lambda_at_lambda_decltype_type_cpp_22_18__Impl::insert(&desc.as_pointer(), 4) }); @@ -85,8 +100,9 @@ fn main_0() -> i32 { assert!(((array_elem!(desc.as_pointer(), items, 1).read()) == 4)); assert!(((array_elem!(desc.as_pointer(), items, 2).read()) == 2)); let asc: Value = Rc::new(RefCell::new( - ::default(), + ::zero_init(), )); + Sorted__lambda_at_lambda_decltype_type_cpp_19_23__Impl::construct_1(&asc.as_pointer()); ({ Sorted__lambda_at_lambda_decltype_type_cpp_19_23__Impl::insert(&asc.as_pointer(), 2) }); ({ Sorted__lambda_at_lambda_decltype_type_cpp_19_23__Impl::insert(&asc.as_pointer(), 7) }); ({ Sorted__lambda_at_lambda_decltype_type_cpp_19_23__Impl::insert(&asc.as_pointer(), 4) }); @@ -126,6 +142,7 @@ fn main_0() -> i32 { } pub trait Sorted__lambda_at_lambda_decltype_type_cpp_19_23__Impl { fn insert(&self, v: i32); + fn construct_1(&self); } impl Sorted__lambda_at_lambda_decltype_type_cpp_19_23__Impl for Ptr @@ -145,9 +162,21 @@ impl Sorted__lambda_at_lambda_decltype_type_cpp_19_23__Impl array_elem!((*self), items, i).write(v); field!((*self), size).with_mut(|__v| __v.postfix_inc()); } + fn construct_1(&self) { + field!((*self), items).write((0..4).map(|_| 0_i32).collect::>()); + field!((*self), size).write(0); + field!((*self), cmp).write(FnPtr:: bool>::new( + |mut a: i32, mut b: i32| -> bool { + { + return (a < b); + } + }, + )); + } } pub trait Sorted__lambda_at_lambda_decltype_type_cpp_22_18__Impl { fn insert(&self, v: i32); + fn construct_1(&self); } impl Sorted__lambda_at_lambda_decltype_type_cpp_22_18__Impl for Ptr @@ -167,5 +196,16 @@ impl Sorted__lambda_at_lambda_decltype_type_cpp_22_18__Impl array_elem!((*self), items, i).write(v); field!((*self), size).with_mut(|__v| __v.postfix_inc()); } + fn construct_1(&self) { + field!((*self), items).write((0..4).map(|_| 0_i32).collect::>()); + field!((*self), size).write(0); + field!((*self), cmp).write(FnPtr:: bool>::new( + |mut a: i32, mut b: i32| -> bool { + { + return (a > b); + } + }, + )); + } } pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/lambda_generic_explicit_args.rs b/tests/unit/out/refcount/lambda_generic_explicit_args.rs index 25f78269c9..97fd3c0b4e 100644 --- a/tests/unit/out/refcount/lambda_generic_explicit_args.rs +++ b/tests/unit/out/refcount/lambda_generic_explicit_args.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Val { diff --git a/tests/unit/out/refcount/lambda_immediate_init.rs b/tests/unit/out/refcount/lambda_immediate_init.rs index 37c42aa45d..c4b489743f 100644 --- a/tests/unit/out/refcount/lambda_immediate_init.rs +++ b/tests/unit/out/refcount/lambda_immediate_init.rs @@ -17,6 +17,13 @@ pub struct S { #[offset(4)] pub k: i32, } +impl DefaultConstructible for S { + fn default_constructor(this: &Ptr) { + { + SImpl::construct_1(this); + } + } +} impl Default for S { fn default() -> Self { { @@ -76,8 +83,9 @@ fn main_0() -> i32 { }) == 237) ); assert!((({ pick_0(1,) }) == 1)); - let mut s: S = ::default(); - assert!((s.k == 4)); + let s: Value = Rc::new(RefCell::new(::zero_init())); + SImpl::construct_1(&s.as_pointer()); + assert!(({ (*s.borrow()).k } == 4)); assert!((g_1.with(|rc| *rc.borrow()) == 10)); let a: Value = Rc::new(RefCell::new(2)); let mut c: i32 = ({ @@ -96,6 +104,24 @@ fn main_0() -> i32 { assert!(({ ((*a.borrow()) == 3) })); return 0; } +pub trait SImpl { + fn construct_1(&self); +} +impl SImpl for Ptr { + fn construct_1(&self) { + field!((*self), j).write(10); + field!((*self), k).write( + (({ + FnPtr:: i32>::new(|| -> i32 { + { + return 3; + } + }) + .call() + }) + 1), + ); + } +} pub fn __cpp2rust_init_globals() { let _ = g_1.with(|_| ()); } diff --git a/tests/unit/out/refcount/lambda_move_only_capture.rs b/tests/unit/out/refcount/lambda_move_only_capture.rs index ca29059d5e..34a860c1c9 100644 --- a/tests/unit/out/refcount/lambda_move_only_capture.rs +++ b/tests/unit/out/refcount/lambda_move_only_capture.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, Default)] +#[derive( + Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, DefaultConstructible, Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(8)] pub struct Owner { diff --git a/tests/unit/out/refcount/lambda_nested.rs b/tests/unit/out/refcount/lambda_nested.rs index c53b4e3e1d..1ad661608f 100644 --- a/tests/unit/out/refcount/lambda_nested.rs +++ b/tests/unit/out/refcount/lambda_nested.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct S { diff --git a/tests/unit/out/refcount/lambda_static_local.rs b/tests/unit/out/refcount/lambda_static_local.rs index b790203e59..944d9f7aee 100644 --- a/tests/unit/out/refcount/lambda_static_local.rs +++ b/tests/unit/out/refcount/lambda_static_local.rs @@ -79,7 +79,16 @@ thread_local!( static calls_3: Value = Rc::new(RefCell::new(0)); ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct P_4 { diff --git a/tests/unit/out/refcount/libc_struct_without_default.rs b/tests/unit/out/refcount/libc_struct_without_default.rs index a737d339ac..2bc803ebfb 100644 --- a/tests/unit/out/refcount/libc_struct_without_default.rs +++ b/tests/unit/out/refcount/libc_struct_without_default.rs @@ -29,6 +29,13 @@ pub struct UserDefined { #[byte_size(24)] pub v: Vec, } +impl DefaultConstructible for UserDefined { + fn default_constructor(this: &Ptr) { + { + UserDefinedImpl::construct_1(this); + } + } +} impl Default for UserDefined { fn default() -> Self { { @@ -39,7 +46,16 @@ impl Default for UserDefined { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[byte_size(16)] pub struct FieldIsLibcType { #[offset(0)] @@ -80,7 +96,8 @@ fn main_0() -> i32 { let st: Value = Rc::new(RefCell::new(Default::default())); (*st.borrow_mut()).st_size = (1024 as ::libc::off_t); assert!(({ (*st.borrow()).st_size } == (1024 as ::libc::off_t))); - let ud: Value = Rc::new(RefCell::new(::default())); + let ud: Value = Rc::new(RefCell::new(::zero_init())); + UserDefinedImpl::construct_1(&ud.as_pointer()); elem!(field_ref!(ud.as_pointer(), a).decay(), 0_usize).write(3); assert!(((elem!(field_ref!(ud.as_pointer(), a).decay(), 0_usize).read()) == 3)); assert!(({ ((*ud.borrow()).v.len() == 0_usize) })); @@ -89,4 +106,15 @@ fn main_0() -> i32 { assert!(((filt.addr.sa_family as i32) == 2)); return 0; } +pub trait UserDefinedImpl { + fn construct_1(&self); +} +impl UserDefinedImpl for Ptr { + fn construct_1(&self) { + field!((*self), a).write(Box::<[i32]>::from(std::array::from_fn::<_, 1, _>(|_| { + 0_i32 + }))); + field!((*self), v).write(Vec::new()); + } +} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/linked_list.rs b/tests/unit/out/refcount/linked_list.rs index aa9f18a58f..82ddbb713d 100644 --- a/tests/unit/out/refcount/linked_list.rs +++ b/tests/unit/out/refcount/linked_list.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, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct Node { diff --git a/tests/unit/out/refcount/local_anon_struct_collision.rs b/tests/unit/out/refcount/local_anon_struct_collision.rs index 227c717c4b..c220df8663 100644 --- a/tests/unit/out/refcount/local_anon_struct_collision.rs +++ b/tests/unit/out/refcount/local_anon_struct_collision.rs @@ -13,7 +13,16 @@ pub fn first_0() -> i32 { return (p.x + p.y); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct anon_1 { @@ -29,7 +38,16 @@ pub fn second_2() -> i32 { return ((q.a + q.b) as i32); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct anon_3 { diff --git a/tests/unit/out/refcount/local_record_template.rs b/tests/unit/out/refcount/local_record_template.rs index acee33e9c7..64b84258ce 100644 --- a/tests/unit/out/refcount/local_record_template.rs +++ b/tests/unit/out/refcount/local_record_template.rs @@ -30,7 +30,16 @@ pub fn wrap_10(mut v: i64) -> i32 { return ({ get_6(l) }); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Local_5 { @@ -38,7 +47,16 @@ pub struct Local_5 { pub x: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Local_7 { @@ -50,7 +68,16 @@ pub fn other_11() -> i32 { return (({ get_0(l) }) + (l.y as i32)); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct Local_1 { @@ -73,7 +100,16 @@ fn main_0() -> i32 { return 0; } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Local_3 { diff --git a/tests/unit/out/refcount/map.rs b/tests/unit/out/refcount/map.rs index ef7e401489..07299b8ecd 100644 --- a/tests/unit/out/refcount/map.rs +++ b/tests/unit/out/refcount/map.rs @@ -23,6 +23,13 @@ pub struct Point { #[offset(4)] pub y: i32, } +impl DefaultConstructible for Point { + fn default_constructor(this: &Ptr) { + { + PointImpl::construct_1(this); + } + } +} impl Default for Point { fn default() -> Self { { diff --git a/tests/unit/out/refcount/map_key_copy_ctor.rs b/tests/unit/out/refcount/map_key_copy_ctor.rs index a49155dea2..2b01d56ed8 100644 --- a/tests/unit/out/refcount/map_key_copy_ctor.rs +++ b/tests/unit/out/refcount/map_key_copy_ctor.rs @@ -23,6 +23,7 @@ thread_local!( FnPtrArg, CppFrom, Destructible, + DefaultConstructible, CopyAssignable, MoveAssignable, Swappable, diff --git a/tests/unit/out/refcount/map_key_identity.rs b/tests/unit/out/refcount/map_key_identity.rs index b717fbb0ae..8c667383c7 100644 --- a/tests/unit/out/refcount/map_key_identity.rs +++ b/tests/unit/out/refcount/map_key_identity.rs @@ -10,7 +10,16 @@ thread_local!( pub static default_constructions_0: Value = Rc::new(RefCell::new(0)); ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Key { @@ -41,6 +50,13 @@ pub struct Mapped { #[offset(0)] pub value: i32, } +impl DefaultConstructible for Mapped { + fn default_constructor(this: &Ptr) { + { + MappedImpl::construct(this); + } + } +} impl Default for Mapped { fn default() -> Self { { diff --git a/tests/unit/out/refcount/map_try_emplace.rs b/tests/unit/out/refcount/map_try_emplace.rs index 1a85374413..0656a3bca4 100644 --- a/tests/unit/out/refcount/map_try_emplace.rs +++ b/tests/unit/out/refcount/map_try_emplace.rs @@ -59,6 +59,13 @@ impl Clone for Item { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } +impl DefaultConstructible for Item { + fn default_constructor(this: &Ptr) { + { + ItemImpl::construct_2(this); + } + } +} impl Default for Item { fn default() -> Self { { @@ -80,6 +87,13 @@ pub struct RefItem { #[offset(0)] pub value: i32, } +impl DefaultConstructible for RefItem { + fn default_constructor(this: &Ptr) { + { + RefItemImpl::construct_1(this); + } + } +} impl Default for RefItem { fn default() -> Self { { diff --git a/tests/unit/out/refcount/map_try_emplace_lvalues.rs b/tests/unit/out/refcount/map_try_emplace_lvalues.rs index 26fca55954..d22753101a 100644 --- a/tests/unit/out/refcount/map_try_emplace_lvalues.rs +++ b/tests/unit/out/refcount/map_try_emplace_lvalues.rs @@ -18,6 +18,13 @@ pub struct Item { #[offset(0)] pub value: i32, } +impl DefaultConstructible for Item { + fn default_constructor(this: &Ptr) { + { + ItemImpl::construct_1(this); + } + } +} impl Default for Item { fn default() -> Self { { @@ -52,6 +59,13 @@ pub struct Temporary { #[array_len(2)] pub data: Box<[i32]>, } +impl DefaultConstructible for Temporary { + fn default_constructor(this: &Ptr) { + { + TemporaryImpl::construct(this); + } + } +} impl Default for Temporary { fn default() -> Self { { @@ -72,6 +86,13 @@ pub struct Nested { #[byte_size(12)] pub inner: Temporary, } +impl DefaultConstructible for Nested { + fn default_constructor(this: &Ptr) { + { + NestedImpl::construct_1(this); + } + } +} pub fn make_temporary_5() -> Temporary { return { let __v: Value = Rc::new(RefCell::new(::zero_init())); @@ -94,6 +115,13 @@ pub struct Owner { #[byte_size(8)] pub ptr: Option>, } +impl DefaultConstructible for Owner { + fn default_constructor(this: &Ptr) { + { + OwnerImpl::construct(this); + } + } +} impl Default for Owner { fn default() -> Self { { @@ -111,6 +139,13 @@ pub struct Noncopy { #[offset(0)] pub n: i32, } +impl DefaultConstructible for Noncopy { + fn default_constructor(this: &Ptr) { + { + NoncopyImpl::construct(this); + } + } +} impl Default for Noncopy { fn default() -> Self { { Noncopy { n: 5 } } @@ -126,6 +161,13 @@ pub struct Held { #[byte_size(8)] pub ptr: Ptr, } +impl DefaultConstructible for Held { + fn default_constructor(this: &Ptr) { + { + HeldImpl::construct_2(this); + } + } +} impl Default for Held { fn default() -> Self { { @@ -2255,9 +2297,11 @@ fn main_0() -> i32 { )> = Rc::new(RefCell::new({ let __tmp_111: Value>>; match ({ - __tmp_111 = Rc::new(RefCell::new(Some(Rc::new(RefCell::new( - ::default(), - ))))); + __tmp_111 = Rc::new(RefCell::new(Some(Rc::new(RefCell::new({ + let __v: Value = Rc::new(RefCell::new(::zero_init())); + NoncopyImpl::construct(&__v.as_pointer()); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }))))); __tmp_111.as_pointer() },) { @@ -2293,9 +2337,11 @@ fn main_0() -> i32 { )> = Rc::new(RefCell::new({ let __tmp_113: Value>>; match ({ - __tmp_113 = Rc::new(RefCell::new(Some(Rc::new(RefCell::new( - ::default(), - ))))); + __tmp_113 = Rc::new(RefCell::new(Some(Rc::new(RefCell::new({ + let __v: Value = Rc::new(RefCell::new(::zero_init())); + NoncopyImpl::construct(&__v.as_pointer()); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }))))); __tmp_113.as_pointer() },) { @@ -2489,6 +2535,14 @@ impl NestedImpl for Ptr { TemporaryImpl::construct(&field_ptr!(self, inner)); } } +pub trait NoncopyImpl { + fn construct(&self); +} +impl NoncopyImpl for Ptr { + fn construct(&self) { + field!((*self), n).write(5); + } +} pub trait OwnerImpl { fn construct(&self); fn value(&self) -> Ptr; diff --git a/tests/unit/out/refcount/max.rs b/tests/unit/out/refcount/max.rs index b811066a87..830c407178 100644 --- a/tests/unit/out/refcount/max.rs +++ b/tests/unit/out/refcount/max.rs @@ -28,6 +28,7 @@ pub fn pick_3(mut i: i32) -> Ptr { FnPtrArg, CppFrom, Destructible, + DefaultConstructible, Memberwise, Movable, Default, diff --git a/tests/unit/out/refcount/memcpy_struct_bytes.rs b/tests/unit/out/refcount/memcpy_struct_bytes.rs index e473748993..a17c0002b2 100644 --- a/tests/unit/out/refcount/memcpy_struct_bytes.rs +++ b/tests/unit/out/refcount/memcpy_struct_bytes.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct point { diff --git a/tests/unit/out/refcount/memcpy_struct_layouts.rs b/tests/unit/out/refcount/memcpy_struct_layouts.rs index 847ea58c9a..d253e81e37 100644 --- a/tests/unit/out/refcount/memcpy_struct_layouts.rs +++ b/tests/unit/out/refcount/memcpy_struct_layouts.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct packed { @@ -21,7 +30,16 @@ pub struct packed { pub d: i16, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(12)] pub struct reordered { @@ -33,7 +51,16 @@ pub struct reordered { pub c: i8, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct tail { @@ -43,7 +70,16 @@ pub struct tail { pub b: f64, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(24)] pub struct nested { @@ -53,7 +89,16 @@ pub struct nested { #[offset(16)] pub c: i8, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[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 d85880c2b9..42b1f1190e 100644 --- a/tests/unit/out/refcount/memcpy_struct_struct.rs +++ b/tests/unit/out/refcount/memcpy_struct_struct.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Entry { diff --git a/tests/unit/out/refcount/memset_struct_tail.rs b/tests/unit/out/refcount/memset_struct_tail.rs index f035b8b1dc..fd9b7a8c19 100644 --- a/tests/unit/out/refcount/memset_struct_tail.rs +++ b/tests/unit/out/refcount/memset_struct_tail.rs @@ -6,7 +6,16 @@ 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, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[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 7cb0d1c522..248918836a 100644 --- a/tests/unit/out/refcount/move_assign.rs +++ b/tests/unit/out/refcount/move_assign.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, FnPtrArg, CppFrom, Destructible, Swappable, Default, + Record, + ByteRepr, + ZeroInitialization, + FnPtrArg, + CppFrom, + Destructible, + DefaultConstructible, + Swappable, + Default, )] #[cpp_from(i32, construct, value)] #[byte_size(4)] @@ -37,6 +45,13 @@ pub struct ConstMoveAssign { #[offset(0)] pub mark: i32, } +impl DefaultConstructible for ConstMoveAssign { + fn default_constructor(this: &Ptr) { + { + ConstMoveAssignImpl::construct(this); + } + } +} impl Default for ConstMoveAssign { fn default() -> Self { { diff --git a/tests/unit/out/refcount/move_ctor.rs b/tests/unit/out/refcount/move_ctor.rs index 12cd305b33..595e027b6c 100644 --- a/tests/unit/out/refcount/move_ctor.rs +++ b/tests/unit/out/refcount/move_ctor.rs @@ -6,7 +6,16 @@ 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, + Destructible, + DefaultConstructible, + Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct MoveOnly { @@ -25,6 +34,13 @@ pub struct ConstMove { #[offset(0)] pub mark: i32, } +impl DefaultConstructible for ConstMove { + fn default_constructor(this: &Ptr) { + { + ConstMoveImpl::construct(this); + } + } +} impl Default for ConstMove { fn default() -> Self { { @@ -44,6 +60,7 @@ impl Default for ConstMove { FnPtrArg, CppFrom, Destructible, + DefaultConstructible, CopyAssignable, MoveAssignable, Swappable, @@ -94,6 +111,7 @@ impl Clone for ThrowingMove { FnPtrArg, CppFrom, Destructible, + DefaultConstructible, CopyAssignable, MoveAssignable, Swappable, diff --git a/tests/unit/out/refcount/move_this.rs b/tests/unit/out/refcount/move_this.rs index b6a984a28a..968d5f3b03 100644 --- a/tests/unit/out/refcount/move_this.rs +++ b/tests/unit/out/refcount/move_this.rs @@ -14,6 +14,7 @@ use std::rc::{Rc, Weak}; FnPtrArg, CppFrom, Destructible, + DefaultConstructible, CopyAssignable, MoveAssignable, Swappable, diff --git a/tests/unit/out/refcount/nested_structs.rs b/tests/unit/out/refcount/nested_structs.rs index 9be477ba18..694e8c96ce 100644 --- a/tests/unit/out/refcount/nested_structs.rs +++ b/tests/unit/out/refcount/nested_structs.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Level0_Level1_1_Level2_1_Level3_1 { @@ -15,7 +24,16 @@ pub struct Level0_Level1_1_Level2_1_Level3_1 { pub x1: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Level0_Level1_1_Level2_1_Level3_2 { @@ -25,7 +43,16 @@ pub struct Level0_Level1_1_Level2_1_Level3_2 { pub x2: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Level0_Level1_1_Level2_1 { @@ -33,7 +60,16 @@ pub struct Level0_Level1_1_Level2_1 { pub x1: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Level0_Level1_1 { @@ -41,7 +77,16 @@ pub struct Level0_Level1_1 { pub x1: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Level0_Level1_2 { @@ -51,7 +96,16 @@ pub struct Level0_Level1_2 { pub x2: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct Level0 {} diff --git a/tests/unit/out/refcount/new.rs b/tests/unit/out/refcount/new.rs index 9565136037..076ef1ecf0 100644 --- a/tests/unit/out/refcount/new.rs +++ b/tests/unit/out/refcount/new.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Pair { diff --git a/tests/unit/out/refcount/new_bst.rs b/tests/unit/out/refcount/new_bst.rs index 6ceb595ab8..749feb2c24 100644 --- a/tests/unit/out/refcount/new_bst.rs +++ b/tests/unit/out/refcount/new_bst.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, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(24)] pub struct node_t { diff --git a/tests/unit/out/refcount/new_struct.rs b/tests/unit/out/refcount/new_struct.rs index ff32f5d11a..395ba97173 100644 --- a/tests/unit/out/refcount/new_struct.rs +++ b/tests/unit/out/refcount/new_struct.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Pair { @@ -17,7 +26,16 @@ pub struct Pair { pub y: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct Triple { diff --git a/tests/unit/out/refcount/nttp_distinct_specializations.rs b/tests/unit/out/refcount/nttp_distinct_specializations.rs index 4534577fd0..3a844a9b26 100644 --- a/tests/unit/out/refcount/nttp_distinct_specializations.rs +++ b/tests/unit/out/refcount/nttp_distinct_specializations.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct S_2_ { @@ -17,7 +26,16 @@ pub struct S_2_ { pub w: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct S_1_ { @@ -25,7 +43,16 @@ pub struct S_1_ { pub v: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct S_3_ { diff --git a/tests/unit/out/refcount/offsetof.rs b/tests/unit/out/refcount/offsetof.rs index c5ef2ed022..9e6a562889 100644 --- a/tests/unit/out/refcount/offsetof.rs +++ b/tests/unit/out/refcount/offsetof.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(12)] pub struct Layout { @@ -18,7 +27,16 @@ pub struct Layout { #[offset(8)] pub c: u16, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[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 69f6fbb662..f74fb93a8e 100644 --- a/tests/unit/out/refcount/opaque_forward_decl.rs +++ b/tests/unit/out/refcount/opaque_forward_decl.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, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct container { diff --git a/tests/unit/out/refcount/opaque_record_copy.rs b/tests/unit/out/refcount/opaque_record_copy.rs index 51bc05f6ab..449fef34ff 100644 --- a/tests/unit/out/refcount/opaque_record_copy.rs +++ b/tests/unit/out/refcount/opaque_record_copy.rs @@ -7,12 +7,30 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct Probe {} #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Wrapper_Probe_ { diff --git a/tests/unit/out/refcount/opaque_then_defined.rs b/tests/unit/out/refcount/opaque_then_defined.rs index 663c006b0b..fb876af679 100644 --- a/tests/unit/out/refcount/opaque_then_defined.rs +++ b/tests/unit/out/refcount/opaque_then_defined.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, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct list { @@ -18,7 +26,15 @@ pub struct list { pub size: i32, } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct node { diff --git a/tests/unit/out/refcount/operator_arithmetic_free.rs b/tests/unit/out/refcount/operator_arithmetic_free.rs index 54150ce7d4..1484bf75e9 100644 --- a/tests/unit/out/refcount/operator_arithmetic_free.rs +++ b/tests/unit/out/refcount/operator_arithmetic_free.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct S { diff --git a/tests/unit/out/refcount/operator_arithmetic_member.rs b/tests/unit/out/refcount/operator_arithmetic_member.rs index 7b57426f42..d2f53fd792 100644 --- a/tests/unit/out/refcount/operator_arithmetic_member.rs +++ b/tests/unit/out/refcount/operator_arithmetic_member.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct S { diff --git a/tests/unit/out/refcount/operator_bitwise_free.rs b/tests/unit/out/refcount/operator_bitwise_free.rs index 25087efa40..35751e1776 100644 --- a/tests/unit/out/refcount/operator_bitwise_free.rs +++ b/tests/unit/out/refcount/operator_bitwise_free.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct S { diff --git a/tests/unit/out/refcount/operator_bitwise_member.rs b/tests/unit/out/refcount/operator_bitwise_member.rs index f4b723a73e..a89486e3b2 100644 --- a/tests/unit/out/refcount/operator_bitwise_member.rs +++ b/tests/unit/out/refcount/operator_bitwise_member.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct S { diff --git a/tests/unit/out/refcount/operator_comparison_defaulted.rs b/tests/unit/out/refcount/operator_comparison_defaulted.rs index 1d684c95c8..8ff9674d42 100644 --- a/tests/unit/out/refcount/operator_comparison_defaulted.rs +++ b/tests/unit/out/refcount/operator_comparison_defaulted.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Eq { @@ -22,7 +31,16 @@ impl CppEq for Eq { } } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Cmp { @@ -42,7 +60,16 @@ impl CppEq for Cmp { } } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Both { @@ -60,7 +87,16 @@ impl CppEq for Both { } } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct OrdOnly { @@ -78,7 +114,16 @@ impl CppEq for OrdOnly { } } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Inner { @@ -96,7 +141,16 @@ impl CppEq for Inner { } } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Outer { @@ -117,7 +171,16 @@ impl CppEq for Outer { } } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Secondary { @@ -135,7 +198,15 @@ impl CppEq for Secondary { } } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct PtrMember { diff --git a/tests/unit/out/refcount/operator_comparison_free.rs b/tests/unit/out/refcount/operator_comparison_free.rs index 8fc0a8ac09..59c84cf1fe 100644 --- a/tests/unit/out/refcount/operator_comparison_free.rs +++ b/tests/unit/out/refcount/operator_comparison_free.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct S { @@ -49,7 +58,16 @@ 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, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct V { diff --git a/tests/unit/out/refcount/operator_comparison_member.rs b/tests/unit/out/refcount/operator_comparison_member.rs index f9742e1b8d..10855feb83 100644 --- a/tests/unit/out/refcount/operator_comparison_member.rs +++ b/tests/unit/out/refcount/operator_comparison_member.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct S { diff --git a/tests/unit/out/refcount/operator_comparison_mixed.rs b/tests/unit/out/refcount/operator_comparison_mixed.rs index 4ef2c1a398..d3a8d5b638 100644 --- a/tests/unit/out/refcount/operator_comparison_mixed.rs +++ b/tests/unit/out/refcount/operator_comparison_mixed.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct S { diff --git a/tests/unit/out/refcount/operator_comparison_nonbool.rs b/tests/unit/out/refcount/operator_comparison_nonbool.rs index 0327803602..6d2821eb4b 100644 --- a/tests/unit/out/refcount/operator_comparison_nonbool.rs +++ b/tests/unit/out/refcount/operator_comparison_nonbool.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct X { @@ -43,7 +52,16 @@ 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, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Result { @@ -51,7 +69,16 @@ pub struct Result { pub r: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Custom { @@ -59,7 +86,16 @@ pub struct Custom { pub v: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Mixed { @@ -85,6 +121,7 @@ impl CppEq for Mixed { VaArg, FnPtrArg, CppFrom, + DefaultConstructible, TriviallyCopyable, Default, )] @@ -95,7 +132,16 @@ pub struct MyBool { pub value: bool, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Boolish { @@ -132,7 +178,16 @@ 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, Destructible, Default)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + FnPtrArg, + CppFrom, + Destructible, + DefaultConstructible, + Default, +)] #[cpp_into(bool, to_bool)] #[byte_size(1)] pub struct RefBool { @@ -147,7 +202,16 @@ thread_local!( })); ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct RefInt { diff --git a/tests/unit/out/refcount/operator_comparison_noncopyable.rs b/tests/unit/out/refcount/operator_comparison_noncopyable.rs index 97de158656..7e72a50725 100644 --- a/tests/unit/out/refcount/operator_comparison_noncopyable.rs +++ b/tests/unit/out/refcount/operator_comparison_noncopyable.rs @@ -13,7 +13,15 @@ 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, Destructible, Memberwise, Default, + Record, + ByteRepr, + ZeroInitialization, + FnPtrArg, + CppFrom, + Destructible, + DefaultConstructible, + Memberwise, + Default, )] #[memberwise(move_constructor)] #[cpp_from(i32, construct, value)] diff --git a/tests/unit/out/refcount/operator_compound_assignment_free.rs b/tests/unit/out/refcount/operator_compound_assignment_free.rs index 34d5b53645..385ca1b84c 100644 --- a/tests/unit/out/refcount/operator_compound_assignment_free.rs +++ b/tests/unit/out/refcount/operator_compound_assignment_free.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct S { diff --git a/tests/unit/out/refcount/operator_compound_assignment_member.rs b/tests/unit/out/refcount/operator_compound_assignment_member.rs index 030449d785..20e985bd60 100644 --- a/tests/unit/out/refcount/operator_compound_assignment_member.rs +++ b/tests/unit/out/refcount/operator_compound_assignment_member.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct S { diff --git a/tests/unit/out/refcount/operator_friend.rs b/tests/unit/out/refcount/operator_friend.rs index 1d05674604..f14907d44e 100644 --- a/tests/unit/out/refcount/operator_friend.rs +++ b/tests/unit/out/refcount/operator_friend.rs @@ -11,7 +11,16 @@ pub fn operator_eq_0(_a0: Ptr, _a1: Ptr) -> bool { && ({ _a0.with(|__s| __s.b) } == { _a1.with(|__s| __s.b) }); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Defaulted { @@ -41,7 +50,16 @@ 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, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct DefaultedOrd { @@ -70,7 +88,16 @@ pub fn operator_add_5(x: Ptr, y: Ptr) -> Inline { }; } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Inline { @@ -88,7 +115,16 @@ impl CppEq for Inline { } } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct OutOfLine { @@ -116,7 +152,16 @@ 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, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Tmpl_int_ { @@ -134,7 +179,16 @@ impl CppEq for Tmpl_int_ { } } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Tmpl_long_ { @@ -145,7 +199,16 @@ pub fn operator_eq_11(_a0: Ptr, _a1: Ptr return ({ _a0.with(|__s| __s.v) } == { _a1.with(|__s| __s.v) }); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct TmplDefaulted_int_ { diff --git a/tests/unit/out/refcount/operator_less_than.rs b/tests/unit/out/refcount/operator_less_than.rs index 6ed2c5b32a..ce6b237224 100644 --- a/tests/unit/out/refcount/operator_less_than.rs +++ b/tests/unit/out/refcount/operator_less_than.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Pair { diff --git a/tests/unit/out/refcount/operator_logical_free.rs b/tests/unit/out/refcount/operator_logical_free.rs index 86afec9078..e5f6760ac8 100644 --- a/tests/unit/out/refcount/operator_logical_free.rs +++ b/tests/unit/out/refcount/operator_logical_free.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct S { diff --git a/tests/unit/out/refcount/operator_logical_member.rs b/tests/unit/out/refcount/operator_logical_member.rs index e14b6cdbeb..e80efaa8a9 100644 --- a/tests/unit/out/refcount/operator_logical_member.rs +++ b/tests/unit/out/refcount/operator_logical_member.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct S { diff --git a/tests/unit/out/refcount/operator_member_pointer_free.rs b/tests/unit/out/refcount/operator_member_pointer_free.rs index e99e28946e..aec0e548f1 100644 --- a/tests/unit/out/refcount/operator_member_pointer_free.rs +++ b/tests/unit/out/refcount/operator_member_pointer_free.rs @@ -7,14 +7,32 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Inner { #[offset(0)] pub x: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[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 74ac91c329..f0106f3348 100644 --- a/tests/unit/out/refcount/operator_member_pointer_member.rs +++ b/tests/unit/out/refcount/operator_member_pointer_member.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Inner { @@ -15,7 +24,16 @@ pub struct Inner { pub x: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct Table {} @@ -27,7 +45,16 @@ 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, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[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 dc4a505226..8cf19de228 100644 --- a/tests/unit/out/refcount/operator_other_free.rs +++ b/tests/unit/out/refcount/operator_other_free.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct S { diff --git a/tests/unit/out/refcount/operator_other_member.rs b/tests/unit/out/refcount/operator_other_member.rs index 8622fd65b6..46db70d48e 100644 --- a/tests/unit/out/refcount/operator_other_member.rs +++ b/tests/unit/out/refcount/operator_other_member.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct Static {} @@ -25,6 +34,7 @@ impl Static { VaArg, FnPtrArg, CppFrom, + DefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/operator_overloads.rs b/tests/unit/out/refcount/operator_overloads.rs index 7e97765d20..f87daf5951 100644 --- a/tests/unit/out/refcount/operator_overloads.rs +++ b/tests/unit/out/refcount/operator_overloads.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct S { diff --git a/tests/unit/out/refcount/operator_qualifiers.rs b/tests/unit/out/refcount/operator_qualifiers.rs index 25080aa83f..32782605b0 100644 --- a/tests/unit/out/refcount/operator_qualifiers.rs +++ b/tests/unit/out/refcount/operator_qualifiers.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct S { diff --git a/tests/unit/out/refcount/operator_three_way.rs b/tests/unit/out/refcount/operator_three_way.rs index 53c88f7262..74050dc4ef 100644 --- a/tests/unit/out/refcount/operator_three_way.rs +++ b/tests/unit/out/refcount/operator_three_way.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct S { diff --git a/tests/unit/out/refcount/operator_traits.rs b/tests/unit/out/refcount/operator_traits.rs index 61480deea5..fb77202334 100644 --- a/tests/unit/out/refcount/operator_traits.rs +++ b/tests/unit/out/refcount/operator_traits.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Lt { @@ -25,7 +34,16 @@ impl CppEq for Lt { } } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Eq { @@ -38,7 +56,16 @@ impl CppEq for Eq { } } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Cmp { @@ -56,7 +83,16 @@ impl CppEq for Cmp { } } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Free { @@ -80,7 +116,16 @@ 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, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Wrapped_int_ { diff --git a/tests/unit/out/refcount/overload_mangling.rs b/tests/unit/out/refcount/overload_mangling.rs index f4c4bca522..ed62777669 100644 --- a/tests/unit/out/refcount/overload_mangling.rs +++ b/tests/unit/out/refcount/overload_mangling.rs @@ -20,12 +20,30 @@ pub fn twice_2(mut n: i32) -> i32 { return (n * 2); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct Access_S_ {} #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct S { @@ -33,7 +51,16 @@ pub struct S { pub base: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Box_ { diff --git a/tests/unit/out/refcount/pair_converting_construction.rs b/tests/unit/out/refcount/pair_converting_construction.rs index d9be805f1e..7bd5381049 100644 --- a/tests/unit/out/refcount/pair_converting_construction.rs +++ b/tests/unit/out/refcount/pair_converting_construction.rs @@ -15,6 +15,7 @@ use std::rc::{Rc, Weak}; VaArg, FnPtrArg, CppFrom, + DefaultConstructible, TriviallyCopyable, Default, )] @@ -33,6 +34,7 @@ pub struct Celsius { VaArg, FnPtrArg, CppFrom, + DefaultConstructible, TriviallyCopyable, Default, )] @@ -51,6 +53,7 @@ pub struct Meters { VaArg, FnPtrArg, CppFrom, + DefaultConstructible, TriviallyCopyable, Default, )] @@ -69,6 +72,7 @@ pub struct Label { VaArg, FnPtrArg, CppFrom, + DefaultConstructible, TriviallyCopyable, Default, )] @@ -90,6 +94,7 @@ pub struct Owner { VaArg, FnPtrArg, CppFrom, + DefaultConstructible, TriviallyCopyable, Default, )] @@ -108,6 +113,13 @@ pub struct Fallback { #[offset(0)] pub value: i32, } +impl DefaultConstructible for Fallback { + fn default_constructor(this: &Ptr) { + { + FallbackImpl::construct(this, { -1_i32 }); + } + } +} impl Default for Fallback { fn default() -> Self { { @@ -120,7 +132,16 @@ impl Default for Fallback { } } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Counter { @@ -136,6 +157,7 @@ pub struct Counter { VaArg, FnPtrArg, CppFrom, + DefaultConstructible, TriviallyCopyable, Default, )] @@ -154,6 +176,7 @@ pub struct Observer { VaArg, FnPtrArg, CppFrom, + DefaultConstructible, TriviallyCopyable, Default, )] @@ -172,6 +195,7 @@ pub struct Tag { VaArg, FnPtrArg, CppFrom, + DefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/pod.rs b/tests/unit/out/refcount/pod.rs index 63da4a0c34..434a2d3018 100644 --- a/tests/unit/out/refcount/pod.rs +++ b/tests/unit/out/refcount/pod.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(12)] pub struct POD { diff --git a/tests/unit/out/refcount/pointer_array.rs b/tests/unit/out/refcount/pointer_array.rs index ece5f0abce..a0dedd7f47 100644 --- a/tests/unit/out/refcount/pointer_array.rs +++ b/tests/unit/out/refcount/pointer_array.rs @@ -6,7 +6,16 @@ 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, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[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 88962e5de8..ab49adeaba 100644 --- a/tests/unit/out/refcount/pointers.rs +++ b/tests/unit/out/refcount/pointers.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Test { diff --git a/tests/unit/out/refcount/polymorphism.rs b/tests/unit/out/refcount/polymorphism.rs index cfdc0c2ddf..1279cef6a2 100644 --- a/tests/unit/out/refcount/polymorphism.rs +++ b/tests/unit/out/refcount/polymorphism.rs @@ -18,6 +18,7 @@ pub trait Animal { VaArg, FnPtrArg, Destructible, + DefaultConstructible, Copyable, Default, )] @@ -32,6 +33,7 @@ pub struct Dog {} VaArg, FnPtrArg, Destructible, + DefaultConstructible, Copyable, Default, )] diff --git a/tests/unit/out/refcount/ptr_cast_init.rs b/tests/unit/out/refcount/ptr_cast_init.rs index efd5f6ae43..7a2abd438e 100644 --- a/tests/unit/out/refcount/ptr_cast_init.rs +++ b/tests/unit/out/refcount/ptr_cast_init.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct header { @@ -17,7 +26,16 @@ pub struct header { pub size: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct view { diff --git a/tests/unit/out/refcount/push_emplace_back.rs b/tests/unit/out/refcount/push_emplace_back.rs index 3492f11f05..b107b08edf 100644 --- a/tests/unit/out/refcount/push_emplace_back.rs +++ b/tests/unit/out/refcount/push_emplace_back.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Chunk { @@ -15,7 +24,15 @@ pub struct Chunk { pub data: i32, } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct Writer { @@ -49,6 +66,13 @@ pub struct JPEGData { #[byte_size(24)] pub app_data: Vec>, } +impl DefaultConstructible for JPEGData { + fn default_constructor(this: &Ptr) { + { + JPEGDataImpl::construct_1(this); + } + } +} pub fn push_param_0(mut dest: Ptr>>) { { let __a1 = Vec::new(); @@ -134,6 +158,13 @@ pub struct Pair { #[offset(4)] pub second: i32, } +impl DefaultConstructible for Pair { + fn default_constructor(this: &Ptr) { + { + PairImpl::construct_2(this); + } + } +} impl Default for Pair { fn default() -> Self { { @@ -317,6 +348,13 @@ pub struct Bytes { #[array_len(3)] pub b: Box<[u8]>, } +impl DefaultConstructible for Bytes { + fn default_constructor(this: &Ptr) { + { + BytesImpl::construct_1(this); + } + } +} impl Default for Bytes { fn default() -> Self { { @@ -345,7 +383,16 @@ pub fn emplace_from_element_14(mut v: Ptr>>) { v.with_mut(|__v: &mut Vec>| __v.push(__tmp_14)); }; } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[byte_size(24)] pub struct Plain { #[offset(0)] @@ -379,7 +426,16 @@ thread_local!( Rc::new(RefCell::new(Ptr::>::null())); ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Counted { @@ -427,7 +483,8 @@ fn main_0() -> i32 { ({ push_param_0((vecs.as_pointer())) }); assert!(({ ((*vecs.borrow()).len() == 1_usize) })); assert!(({ (*vecs.decay().offset(0_usize).upgrade().deref()).is_empty() })); - let jpg: Value = Rc::new(RefCell::new(::default())); + let jpg: Value = Rc::new(RefCell::new(::zero_init())); + JPEGDataImpl::construct_1(&jpg.as_pointer()); ({ push_local_from_field_1((jpg.as_pointer()), true) }); assert!(({ ((*jpg.borrow()).com_data.len() == 1_usize) })); assert!( @@ -637,6 +694,15 @@ fn main_0() -> i32 { ); return 0; } +pub trait BytesImpl { + fn construct_1(&self); +} +impl BytesImpl for Ptr { + fn construct_1(&self) { + field!((*self), v).write(Vec::new()); + field!((*self), b).write((0..3).map(|_| 0_u8).collect::>()); + } +} pub trait CountedImpl { fn construct(&self, _a0: i32); } @@ -650,6 +716,15 @@ impl CountedImpl for Ptr { ); } } +pub trait JPEGDataImpl { + fn construct_1(&self); +} +impl JPEGDataImpl for Ptr { + fn construct_1(&self) { + field!((*self), com_data).write(Vec::new()); + field!((*self), app_data).write(Vec::new()); + } +} pub trait PairImpl { fn construct_2(&self); fn construct_1(&self, a: i32); diff --git a/tests/unit/out/refcount/random.rs b/tests/unit/out/refcount/random.rs index 93ae6f283a..ae5f74865b 100644 --- a/tests/unit/out/refcount/random.rs +++ b/tests/unit/out/refcount/random.rs @@ -6,7 +6,16 @@ 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, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[byte_size(72)] pub struct Pair { #[offset(0)] @@ -52,7 +61,16 @@ pub fn zero_0() -> i32 { return 0; } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct X1 {} diff --git a/tests/unit/out/refcount/reference_wrapper.rs b/tests/unit/out/refcount/reference_wrapper.rs index 65381cce47..896d96f41d 100644 --- a/tests/unit/out/refcount/reference_wrapper.rs +++ b/tests/unit/out/refcount/reference_wrapper.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Point { diff --git a/tests/unit/out/refcount/references.rs b/tests/unit/out/refcount/references.rs index c51ad1dbe1..16ff50cd10 100644 --- a/tests/unit/out/refcount/references.rs +++ b/tests/unit/out/refcount/references.rs @@ -6,7 +6,16 @@ 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, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[byte_size(16)] pub struct Pair { #[offset(0)] @@ -30,7 +39,15 @@ impl Default for Pair { } } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct Nested { diff --git a/tests/unit/out/refcount/refs_as_args.rs b/tests/unit/out/refcount/refs_as_args.rs index 8f7383be46..41a465be15 100644 --- a/tests/unit/out/refcount/refs_as_args.rs +++ b/tests/unit/out/refcount/refs_as_args.rs @@ -31,7 +31,16 @@ 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, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Val { diff --git a/tests/unit/out/refcount/reinterpret_cast_ptr_cmp.rs b/tests/unit/out/refcount/reinterpret_cast_ptr_cmp.rs index e777777307..b8de211ecd 100644 --- a/tests/unit/out/refcount/reinterpret_cast_ptr_cmp.rs +++ b/tests/unit/out/refcount/reinterpret_cast_ptr_cmp.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct S { @@ -16,7 +25,16 @@ pub struct S { #[offset(4)] pub y: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[byte_size(28)] pub struct W { #[offset(0)] @@ -36,7 +54,16 @@ impl Default for W { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[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 a0c237aba6..7fb62cc45b 100644 --- a/tests/unit/out/refcount/reinterpret_cast_struct.rs +++ b/tests/unit/out/refcount/reinterpret_cast_struct.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Point { 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 2b4b15d4d6..4a98041e13 100644 --- a/tests/unit/out/refcount/reinterpret_cast_struct_to_struct.rs +++ b/tests/unit/out/refcount/reinterpret_cast_struct_to_struct.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Point { @@ -17,7 +26,16 @@ pub struct Point { pub y: u32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Pair { diff --git a/tests/unit/out/refcount/reserved_keywords.rs b/tests/unit/out/refcount/reserved_keywords.rs index 61a59e4e1f..f8e4a94062 100644 --- a/tests/unit/out/refcount/reserved_keywords.rs +++ b/tests/unit/out/refcount/reserved_keywords.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(152)] pub struct S { @@ -89,7 +98,16 @@ pub struct S { pub vec_: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct type_ { @@ -97,7 +115,16 @@ pub struct type_ { pub v: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct loop_ { diff --git a/tests/unit/out/refcount/return_move.rs b/tests/unit/out/refcount/return_move.rs index c1b76be829..e933c1c3fc 100644 --- a/tests/unit/out/refcount/return_move.rs +++ b/tests/unit/out/refcount/return_move.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, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct node { @@ -18,7 +26,15 @@ pub struct node { pub next: Ptr, } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct pair_t { diff --git a/tests/unit/out/refcount/rule_of_five.rs b/tests/unit/out/refcount/rule_of_five.rs index 885150a4b1..5b11cd1931 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, Swappable)] +#[derive( + Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, DefaultConstructible, 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 e6f864e501..691ec25d70 100644 --- a/tests/unit/out/refcount/rule_of_three.rs +++ b/tests/unit/out/refcount/rule_of_three.rs @@ -12,7 +12,9 @@ thread_local!( thread_local!( pub static copies_1: Value = Rc::new(RefCell::new(0)); ); -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Movable)] +#[derive( + Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, DefaultConstructible, Movable, +)] #[cpp_from(i32, construct, value)] #[byte_size(20)] pub struct Buffer { diff --git a/tests/unit/out/refcount/rvalue_rule_arg_move.rs b/tests/unit/out/refcount/rvalue_rule_arg_move.rs index 266a6f3e7a..51d10c8c5c 100644 --- a/tests/unit/out/refcount/rvalue_rule_arg_move.rs +++ b/tests/unit/out/refcount/rvalue_rule_arg_move.rs @@ -20,6 +20,7 @@ thread_local!( FnPtrArg, CppFrom, Destructible, + DefaultConstructible, Memberwise, Swappable, Default, diff --git a/tests/unit/out/refcount/rvalue_struct.rs b/tests/unit/out/refcount/rvalue_struct.rs index 7815aa553a..fd5ad5584b 100644 --- a/tests/unit/out/refcount/rvalue_struct.rs +++ b/tests/unit/out/refcount/rvalue_struct.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct S { diff --git a/tests/unit/out/refcount/scalar_builtin_construct_destruct.rs b/tests/unit/out/refcount/scalar_builtin_construct_destruct.rs index 67b99a300a..1359aaf06b 100644 --- a/tests/unit/out/refcount/scalar_builtin_construct_destruct.rs +++ b/tests/unit/out/refcount/scalar_builtin_construct_destruct.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Pod { diff --git a/tests/unit/out/refcount/self_referencing_initializer.rs b/tests/unit/out/refcount/self_referencing_initializer.rs index cc26e02cc3..0480959140 100644 --- a/tests/unit/out/refcount/self_referencing_initializer.rs +++ b/tests/unit/out/refcount/self_referencing_initializer.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, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct list_head { @@ -16,7 +24,15 @@ pub struct list_head { pub next: Ptr, } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct node { @@ -35,6 +51,13 @@ pub struct node_with_defaults { #[offset(8)] pub value: i32, } +impl DefaultConstructible for node_with_defaults { + fn default_constructor(this: &Ptr) { + { + node_with_defaultsImpl::construct_1(this); + } + } +} impl Default for node_with_defaults { fn default() -> Self { { @@ -98,4 +121,13 @@ fn main_0() -> i32 { assert!((size == ::std::mem::size_of::())); return 0; } +pub trait node_with_defaultsImpl { + fn construct_1(&self); +} +impl node_with_defaultsImpl for Ptr { + fn construct_1(&self) { + field!((*self), next).write(Ptr::::null()); + field!((*self), value).write(3); + } +} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/size_t_static_member.rs b/tests/unit/out/refcount/size_t_static_member.rs index 38685d971b..039ab43e6c 100644 --- a/tests/unit/out/refcount/size_t_static_member.rs +++ b/tests/unit/out/refcount/size_t_static_member.rs @@ -10,7 +10,16 @@ thread_local!( pub static c_0: Value = Rc::new(RefCell::new(5_usize)); ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct S {} @@ -18,7 +27,16 @@ thread_local!( pub static table_size_1: Value = Rc::new(RefCell::new(256_usize)); ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct Table_char_ {} diff --git a/tests/unit/out/refcount/size_t_template_param.rs b/tests/unit/out/refcount/size_t_template_param.rs index 44017a11ce..2a88bbef95 100644 --- a/tests/unit/out/refcount/size_t_template_param.rs +++ b/tests/unit/out/refcount/size_t_template_param.rs @@ -19,6 +19,7 @@ pub fn array_ref_0(a: Ptr) -> u64 { VaArg, FnPtrArg, CppFrom, + DefaultConstructible, TriviallyCopyable, Default, )] @@ -37,6 +38,7 @@ pub struct PtrCtor_unsigned_long_ { VaArg, FnPtrArg, CppFrom, + DefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/sort_no_copy.rs b/tests/unit/out/refcount/sort_no_copy.rs index bef796ab38..3df7c7a773 100644 --- a/tests/unit/out/refcount/sort_no_copy.rs +++ b/tests/unit/out/refcount/sort_no_copy.rs @@ -61,6 +61,13 @@ impl Clone for Tracked { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } +impl DefaultConstructible for Tracked { + fn default_constructor(this: &Ptr) { + { + TrackedImpl::construct_2(this); + } + } +} impl Default for Tracked { fn default() -> Self { { @@ -85,6 +92,7 @@ pub fn greater_2(a: Ptr, b: Ptr) -> bool { FnPtrArg, CppFrom, Destructible, + DefaultConstructible, Memberwise, Swappable, Default, @@ -140,6 +148,13 @@ impl CppEq for Bag { operator_eq_5(__lhs.clone(), __rhs.clone()) } } +impl DefaultConstructible for Bag { + fn default_constructor(this: &Ptr) { + { + BagImpl::construct_1(this); + } + } +} pub fn operator_lt_4(a: Ptr, b: Ptr) -> bool { return ({ (*a.upgrade().deref()).items.len() } < { (*b.upgrade().deref()).items.len() }); } @@ -329,9 +344,13 @@ fn main_0() -> i32 { && ({ (*vec_.borrow())[3_usize].v } == 2) ); assert!((copies_0.with(|rc| *rc.borrow()) == 0)); - let bags: Value> = Rc::new(RefCell::new( - (0..3).map(|_| ::default()).collect::>(), - )); + let bags: Value> = Rc::new(RefCell::new(Box::new(std::array::from_fn::<_, 3, _>( + |_| { + let __v: Value = Rc::new(RefCell::new(::zero_init())); + BagImpl::construct_1(&__v.as_pointer()); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }, + )))); { let mut __tmp_9 = { { @@ -595,6 +614,14 @@ fn main_0() -> i32 { ); return copies_0.with(|rc| *rc.borrow()); } +pub trait BagImpl { + fn construct_1(&self); +} +impl BagImpl for Ptr { + fn construct_1(&self) { + field!((*self), items).write(Vec::new()); + } +} pub trait MoveOnlyImpl { fn construct(&self, v: i32); } diff --git a/tests/unit/out/refcount/static_local.rs b/tests/unit/out/refcount/static_local.rs index 24ae2dfc21..013817257f 100644 --- a/tests/unit/out/refcount/static_local.rs +++ b/tests/unit/out/refcount/static_local.rs @@ -34,7 +34,16 @@ thread_local!( static x_7: Value = Rc::new(RefCell::new(3)); ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct S_8 {} diff --git a/tests/unit/out/refcount/static_var_in_class.rs b/tests/unit/out/refcount/static_var_in_class.rs index 35e90123f8..006f87571e 100644 --- a/tests/unit/out/refcount/static_var_in_class.rs +++ b/tests/unit/out/refcount/static_var_in_class.rs @@ -10,7 +10,16 @@ thread_local!( static inner_const_0: Value = Rc::new(RefCell::new(1)); ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct C {} @@ -20,7 +29,16 @@ thread_local!( pub type anon_3 = u32; pub const anon_3_kValue: anon_3 = 3; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct S {} diff --git a/tests/unit/out/refcount/stdcopy.rs b/tests/unit/out/refcount/stdcopy.rs index b432be3106..8ab807fa76 100644 --- a/tests/unit/out/refcount/stdcopy.rs +++ b/tests/unit/out/refcount/stdcopy.rs @@ -15,6 +15,7 @@ use std::rc::{Rc, Weak}; VaArg, FnPtrArg, CppFrom, + DefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/strdup.rs b/tests/unit/out/refcount/strdup.rs index 8e26d342dc..664a0ba542 100644 --- a/tests/unit/out/refcount/strdup.rs +++ b/tests/unit/out/refcount/strdup.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, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct record { diff --git a/tests/unit/out/refcount/string_literal_ptr_init.rs b/tests/unit/out/refcount/string_literal_ptr_init.rs index 207c5f0207..5bdec31e47 100644 --- a/tests/unit/out/refcount/string_literal_ptr_init.rs +++ b/tests/unit/out/refcount/string_literal_ptr_init.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, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(24)] pub struct label { diff --git a/tests/unit/out/refcount/string_substr.rs b/tests/unit/out/refcount/string_substr.rs index fd214114c0..a39ab082f0 100644 --- a/tests/unit/out/refcount/string_substr.rs +++ b/tests/unit/out/refcount/string_substr.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, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Text { diff --git a/tests/unit/out/refcount/struct_2d_array_field.rs b/tests/unit/out/refcount/struct_2d_array_field.rs index 006d428772..755ec6e161 100644 --- a/tests/unit/out/refcount/struct_2d_array_field.rs +++ b/tests/unit/out/refcount/struct_2d_array_field.rs @@ -6,7 +6,16 @@ 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, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[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 3d98fc2e88..a996c4e4d6 100644 --- a/tests/unit/out/refcount/struct_ctor.rs +++ b/tests/unit/out/refcount/struct_ctor.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct StructWithCtor { @@ -28,6 +37,7 @@ pub fn foo_0(x: Ptr) -> Ptr { VaArg, FnPtrArg, CppFrom, + DefaultConstructible, TriviallyCopyable, Default, )] @@ -47,6 +57,13 @@ pub struct Ptr_ { #[byte_size(4)] pub v2: Value_, } +impl DefaultConstructible for Ptr_ { + fn default_constructor(this: &Ptr) { + { + Ptr_Impl::construct(this); + } + } +} impl Default for Ptr_ { fn default() -> Self { { diff --git a/tests/unit/out/refcount/struct_default_ctor.rs b/tests/unit/out/refcount/struct_default_ctor.rs index 4f8707f78a..078f368158 100644 --- a/tests/unit/out/refcount/struct_default_ctor.rs +++ b/tests/unit/out/refcount/struct_default_ctor.rs @@ -14,6 +14,13 @@ pub struct S { #[offset(4)] pub b: bool, } +impl DefaultConstructible for S { + fn default_constructor(this: &Ptr) { + { + SImpl::construct(this); + } + } +} impl Default for S { fn default() -> Self { { @@ -26,7 +33,16 @@ impl Default for S { } } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Declared { @@ -41,6 +57,13 @@ pub struct Holder { #[array_len(2)] pub items: Box<[S]>, } +impl DefaultConstructible for Holder { + fn default_constructor(this: &Ptr) { + { + HolderImpl::construct_1(this); + } + } +} impl Default for Holder { fn default() -> Self { { @@ -59,6 +82,13 @@ pub struct FromStatic { #[offset(0)] pub v: i32, } +impl DefaultConstructible for FromStatic { + fn default_constructor(this: &Ptr) { + { + FromStaticImpl::construct_1(this); + } + } +} impl Default for FromStatic { fn default() -> Self { { @@ -101,6 +131,26 @@ pub trait DeclaredImpl { } } impl DeclaredImpl for Ptr {} +pub trait FromStaticImpl { + fn construct_1(&self); +} +impl FromStaticImpl for Ptr { + fn construct_1(&self) { + field!((*self), v).write(kInit_0.with(|rc| *rc.borrow())); + } +} +pub trait HolderImpl { + fn construct_1(&self); +} +impl HolderImpl for Ptr { + fn construct_1(&self) { + field!((*self), items).write(Box::new(std::array::from_fn::<_, 2, _>(|_| { + let __v: Value = Rc::new(RefCell::new(::zero_init())); + SImpl::construct(&__v.as_pointer()); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }))); + } +} pub trait SImpl { fn construct(&self); } diff --git a/tests/unit/out/refcount/struct_member_array_adjacency.rs b/tests/unit/out/refcount/struct_member_array_adjacency.rs index 51904107ec..eebc2f0783 100644 --- a/tests/unit/out/refcount/struct_member_array_adjacency.rs +++ b/tests/unit/out/refcount/struct_member_array_adjacency.rs @@ -6,7 +6,16 @@ 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, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[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 720a2e9fc5..f22220b76b 100644 --- a/tests/unit/out/refcount/struct_ptr.rs +++ b/tests/unit/out/refcount/struct_ptr.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct XX { diff --git a/tests/unit/out/refcount/structured_binding_copy_ctor.rs b/tests/unit/out/refcount/structured_binding_copy_ctor.rs index 7e1d1d28ad..5b3372a993 100644 --- a/tests/unit/out/refcount/structured_binding_copy_ctor.rs +++ b/tests/unit/out/refcount/structured_binding_copy_ctor.rs @@ -16,6 +16,7 @@ thread_local!( VaArg, FnPtrArg, Destructible, + DefaultConstructible, Memberwise, Movable, Default, diff --git a/tests/unit/out/refcount/structured_binding_element_ctor.rs b/tests/unit/out/refcount/structured_binding_element_ctor.rs index 1f1f671a28..728a39fb63 100644 --- a/tests/unit/out/refcount/structured_binding_element_ctor.rs +++ b/tests/unit/out/refcount/structured_binding_element_ctor.rs @@ -20,6 +20,7 @@ thread_local!( FnPtrArg, CppFrom, Destructible, + DefaultConstructible, CopyAssignable, MoveAssignable, Swappable, @@ -60,6 +61,7 @@ impl Clone for Elem { VaArg, FnPtrArg, Destructible, + DefaultConstructible, Memberwise, 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 67d7d68b52..2e41d829ad 100644 --- a/tests/unit/out/refcount/structured_binding_move_ctor.rs +++ b/tests/unit/out/refcount/structured_binding_move_ctor.rs @@ -19,6 +19,7 @@ thread_local!( VaArg, FnPtrArg, Destructible, + DefaultConstructible, CopyAssignable, MoveAssignable, Swappable, @@ -81,6 +82,13 @@ pub struct Holder { #[byte_size(24)] pub ys: Vec, } +impl DefaultConstructible for Holder { + fn default_constructor(this: &Ptr) { + { + HolderImpl::construct_1(this); + } + } +} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); @@ -118,6 +126,7 @@ fn main_0() -> i32 { } pub trait HolderImpl { fn extract(&self, this: Ptr); + fn construct_1(&self); } impl HolderImpl for Ptr { fn extract(&self, this: Ptr) { @@ -127,6 +136,10 @@ impl HolderImpl for Ptr { }); return; } + fn construct_1(&self) { + field!((*self), xs).write(Vec::new()); + field!((*self), ys).write(Vec::new()); + } } pub trait MovableImpl { fn construct(&self, x: i32, y: i32); diff --git a/tests/unit/out/refcount/structured_binding_range_for.rs b/tests/unit/out/refcount/structured_binding_range_for.rs index acd97c4bfe..61e37232cf 100644 --- a/tests/unit/out/refcount/structured_binding_range_for.rs +++ b/tests/unit/out/refcount/structured_binding_range_for.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Pair { diff --git a/tests/unit/out/refcount/structured_binding_ref.rs b/tests/unit/out/refcount/structured_binding_ref.rs index 9f79ef66d1..e9256a9569 100644 --- a/tests/unit/out/refcount/structured_binding_ref.rs +++ b/tests/unit/out/refcount/structured_binding_ref.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(12)] pub struct Triple { diff --git a/tests/unit/out/refcount/structured_binding_trivial.rs b/tests/unit/out/refcount/structured_binding_trivial.rs index 7214c5278d..6835c2cbb1 100644 --- a/tests/unit/out/refcount/structured_binding_trivial.rs +++ b/tests/unit/out/refcount/structured_binding_trivial.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Pair { diff --git a/tests/unit/out/refcount/swap_map_no_copy.rs b/tests/unit/out/refcount/swap_map_no_copy.rs index a864490df5..a4282d9c0d 100644 --- a/tests/unit/out/refcount/swap_map_no_copy.rs +++ b/tests/unit/out/refcount/swap_map_no_copy.rs @@ -50,6 +50,13 @@ impl Clone for Tracked { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } +impl DefaultConstructible for Tracked { + fn default_constructor(this: &Ptr) { + { + TrackedImpl::construct_2(this); + } + } +} impl Default for Tracked { fn default() -> Self { { @@ -83,6 +90,13 @@ pub struct Pair { #[byte_size(4)] pub y: Tracked, } +impl DefaultConstructible for Pair { + fn default_constructor(this: &Ptr) { + { + PairImpl::construct_1(this); + } + } +} #[derive( Clone, Record, @@ -106,6 +120,13 @@ pub struct Arrays { #[array_len(2)] pub b: Box<[Tracked]>, } +impl DefaultConstructible for Arrays { + fn default_constructor(this: &Ptr) { + { + ArraysImpl::construct_1(this); + } + } +} impl Default for Arrays { fn default() -> Self { { @@ -126,7 +147,17 @@ thread_local!( thread_local!( pub static copy_only_dtors_2: Value = Rc::new(RefCell::new(0)); ); -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Movable, Default)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + DefaultConstructible, + Movable, + Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct CopyOnly { @@ -167,6 +198,7 @@ impl Clone for CopyOnly { VaArg, FnPtrArg, Destructible, + DefaultConstructible, Memberwise, MoveConstructible, Swappable, @@ -193,7 +225,17 @@ thread_local!( thread_local!( pub static moved_dtors_5: Value = Rc::new(RefCell::new(0)); ); -#[derive(Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Swappable, Default)] +#[derive( + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + DefaultConstructible, + Swappable, + Default, +)] #[cpp_from(i32, construct, value)] #[byte_size(4)] pub struct Moved { @@ -249,6 +291,7 @@ impl Clone for Moved { VaArg, FnPtrArg, Destructible, + DefaultConstructible, Memberwise, Swappable, Default, @@ -292,6 +335,13 @@ pub struct Owner { #[byte_size(8)] pub p: Option>, } +impl DefaultConstructible for Owner { + fn default_constructor(this: &Ptr) { + { + OwnerImpl::construct_1(this); + } + } +} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); @@ -572,7 +622,8 @@ fn main_0() -> i32 { && ({ (*pairs.borrow())[(1) as usize].y.v } == 8) ); assert!((copies_0.with(|rc| *rc.borrow()) == 0)); - let arrays: Value = Rc::new(RefCell::new(::default())); + let arrays: Value = Rc::new(RefCell::new(::zero_init())); + ArraysImpl::construct_1(&arrays.as_pointer()); field!(array_elem!(arrays.as_pointer(), a, 0), v).write(1); field!(array_elem!(arrays.as_pointer(), b, 1), v).write(2); Swappable::swap( @@ -840,6 +891,23 @@ fn main_0() -> i32 { ); return copies_0.with(|rc| *rc.borrow()); } +pub trait ArraysImpl { + fn construct_1(&self); +} +impl ArraysImpl for Ptr { + fn construct_1(&self) { + field!((*self), a).write(Box::new(std::array::from_fn::<_, 2, _>(|_| { + let __v: Value = Rc::new(RefCell::new(::zero_init())); + TrackedImpl::construct_2(&__v.as_pointer()); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }))); + field!((*self), b).write(Box::new(std::array::from_fn::<_, 2, _>(|_| { + let __v: Value = Rc::new(RefCell::new(::zero_init())); + TrackedImpl::construct_2(&__v.as_pointer()); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }))); + } +} pub trait CopyOnlyImpl { fn construct(&self, v: i32); } @@ -856,6 +924,14 @@ impl MovedImpl for Ptr { field!((*self), v).write(v); } } +pub trait OwnerImpl { + fn construct_1(&self); +} +impl OwnerImpl for Ptr { + fn construct_1(&self) { + field!((*self), p).write(None); + } +} pub trait PairImpl { fn construct_1(&self); } diff --git a/tests/unit/out/refcount/tag_vs_identifier_collision.rs b/tests/unit/out/refcount/tag_vs_identifier_collision.rs index 2db918945d..f007cd7459 100644 --- a/tests/unit/out/refcount/tag_vs_identifier_collision.rs +++ b/tests/unit/out/refcount/tag_vs_identifier_collision.rs @@ -11,7 +11,16 @@ 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, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct widget { @@ -21,7 +30,16 @@ pub struct widget { pub mode: widget_enum, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct point_struct { @@ -30,7 +48,9 @@ pub struct point_struct { #[offset(4)] pub y: i32, } -#[derive(VaArg, FnPtrArg, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, +)] #[byte_size(4)] pub struct point { #[offset(0)] @@ -53,7 +73,9 @@ impl Default for point { } } } -#[derive(VaArg, FnPtrArg, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, +)] #[byte_size(4)] pub struct slot_union { #[offset(0)] @@ -80,7 +102,16 @@ 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, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Inner { @@ -88,7 +119,16 @@ pub struct Inner { pub tag_field: i32, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Outer { @@ -97,7 +137,16 @@ pub struct Outer { pub field: Inner, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Inner_struct { diff --git a/tests/unit/out/refcount/template_default_arg.rs b/tests/unit/out/refcount/template_default_arg.rs index 9f7312a0c9..317c4bd139 100644 --- a/tests/unit/out/refcount/template_default_arg.rs +++ b/tests/unit/out/refcount/template_default_arg.rs @@ -15,6 +15,13 @@ pub struct A { #[offset(0)] pub v: i32, } +impl DefaultConstructible for A { + fn default_constructor(this: &Ptr) { + { + AImpl::construct_2(this); + } + } +} impl Default for A { fn default() -> Self { { @@ -32,6 +39,13 @@ pub struct B { #[offset(0)] pub v: i32, } +impl DefaultConstructible for B { + fn default_constructor(this: &Ptr) { + { + BImpl::construct(this); + } + } +} impl Default for B { fn default() -> Self { { @@ -52,6 +66,7 @@ impl Default for B { VaArg, FnPtrArg, CppFrom, + DefaultConstructible, TriviallyCopyable, Default, )] @@ -82,6 +97,7 @@ pub fn always_given_3(mut x: NoDefault) -> i32 { VaArg, FnPtrArg, CppFrom, + DefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/template_static_member.rs b/tests/unit/out/refcount/template_static_member.rs index b97e23a677..0e08d06174 100644 --- a/tests/unit/out/refcount/template_static_member.rs +++ b/tests/unit/out/refcount/template_static_member.rs @@ -10,7 +10,16 @@ thread_local!( pub static s_0: Value = Rc::new(RefCell::new(55)); ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct Static_int_ {} @@ -18,7 +27,16 @@ thread_local!( pub static s_1: Value = Rc::new(RefCell::new(55_i8)); ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct Static_char_ {} @@ -26,7 +44,16 @@ thread_local!( pub static s_2: Value = Rc::new(RefCell::new(55_i64)); ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct Static_long_ {} @@ -37,7 +64,16 @@ thread_local!( pub static hi_4: Value = Rc::new(RefCell::new(1)); ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct Range_int_ {} @@ -48,7 +84,16 @@ thread_local!( pub static hi_6: Value = Rc::new(RefCell::new(2_i64)); ); #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct Range_long_ {} diff --git a/tests/unit/out/refcount/temporary_field_addr.rs b/tests/unit/out/refcount/temporary_field_addr.rs index 9038daf9e3..829c7b3ae5 100644 --- a/tests/unit/out/refcount/temporary_field_addr.rs +++ b/tests/unit/out/refcount/temporary_field_addr.rs @@ -26,6 +26,13 @@ pub struct Inner { #[byte_size(24)] pub values: Vec, } +impl DefaultConstructible for Inner { + fn default_constructor(this: &Ptr) { + { + InnerImpl::construct_1(this); + } + } +} #[derive( Clone, Record, @@ -52,6 +59,13 @@ pub struct Outer { #[array_len(8)] pub name: Box<[i8]>, } +impl DefaultConstructible for Outer { + fn default_constructor(this: &Ptr) { + { + OuterImpl::construct_1(this); + } + } +} impl Default for Outer { fn default() -> Self { { @@ -173,4 +187,22 @@ fn main_0() -> i32 { ); return 0; } +pub trait InnerImpl { + fn construct_1(&self); +} +impl InnerImpl for Ptr { + fn construct_1(&self) { + field!((*self), values).write(Vec::new()); + } +} +pub trait OuterImpl { + fn construct_1(&self); +} +impl OuterImpl for Ptr { + fn construct_1(&self) { + field!((*self), values).write(Vec::new()); + InnerImpl::construct_1(&field_ptr!(self, inner)); + field!((*self), name).write((0..8).map(|_| 0_i8).collect::>()); + } +} 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 546c4836c2..288cc36f84 100644 --- a/tests/unit/out/refcount/temporary_field_ctor_arg.rs +++ b/tests/unit/out/refcount/temporary_field_ctor_arg.rs @@ -26,6 +26,13 @@ pub struct Outer { #[byte_size(24)] pub values: Vec, } +impl DefaultConstructible for Outer { + fn default_constructor(this: &Ptr) { + { + OuterImpl::construct_1(this); + } + } +} pub fn make_0(this: Ptr) { this.write(Outer { values: Vec::from([1, 2, 3, 4]), @@ -41,6 +48,7 @@ pub fn make_0(this: Ptr) { VaArg, FnPtrArg, CppFrom, + DefaultConstructible, TriviallyCopyable, Default, )] @@ -78,4 +86,12 @@ impl HImpl for Ptr { field!((*self), last).write((index!(values, 3_usize).read())); } } +pub trait OuterImpl { + fn construct_1(&self); +} +impl OuterImpl for Ptr { + fn construct_1(&self) { + field!((*self), values).write(Vec::new()); + } +} 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 3d2aaef51a..cf7bf240d4 100644 --- a/tests/unit/out/refcount/temporary_field_two_args.rs +++ b/tests/unit/out/refcount/temporary_field_two_args.rs @@ -26,6 +26,13 @@ pub struct Inner { #[byte_size(24)] pub values: Vec, } +impl DefaultConstructible for Inner { + fn default_constructor(this: &Ptr) { + { + InnerImpl::construct_1(this); + } + } +} #[derive( Clone, Record, @@ -49,6 +56,13 @@ pub struct Outer { #[byte_size(24)] pub inner: Inner, } +impl DefaultConstructible for Outer { + fn default_constructor(this: &Ptr) { + { + OuterImpl::construct_1(this); + } + } +} pub fn make_0(this: Ptr) { this.write(Outer { values: Vec::from([1, 2, 3]), @@ -91,4 +105,21 @@ fn main_0() -> i32 { }; return 0; } +pub trait InnerImpl { + fn construct_1(&self); +} +impl InnerImpl for Ptr { + fn construct_1(&self) { + field!((*self), values).write(Vec::new()); + } +} +pub trait OuterImpl { + fn construct_1(&self); +} +impl OuterImpl for Ptr { + fn construct_1(&self) { + field!((*self), values).write(Vec::new()); + InnerImpl::construct_1(&field_ptr!(self, inner)); + } +} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/this.rs b/tests/unit/out/refcount/this.rs index 991563832f..c603b31c31 100644 --- a/tests/unit/out/refcount/this.rs +++ b/tests/unit/out/refcount/this.rs @@ -14,6 +14,7 @@ use std::rc::{Rc, Weak}; VaArg, FnPtrArg, CppFrom, + DefaultConstructible, TriviallyCopyable, Default, )] @@ -38,6 +39,7 @@ pub fn bump_0(mut p: Ptr) { VaArg, FnPtrArg, CppFrom, + DefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/typedef-anon-struct.rs b/tests/unit/out/refcount/typedef-anon-struct.rs index ffcc92c198..e7c811d3a4 100644 --- a/tests/unit/out/refcount/typedef-anon-struct.rs +++ b/tests/unit/out/refcount/typedef-anon-struct.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Outer_RunInfo { @@ -36,22 +45,38 @@ pub struct Outer { #[byte_size(24)] pub runs: Vec, } +impl DefaultConstructible for Outer { + fn default_constructor(this: &Ptr) { + { + OuterImpl::construct_1(this); + } + } +} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let mut o: Outer = ::default(); + let o: Value = Rc::new(RefCell::new(::zero_init())); + OuterImpl::construct_1(&o.as_pointer()); let mut info: Outer_RunInfo = ::default(); info.block_idx = 1; info.num_extra_zero_runs = 2; { let a0_clone = info.clone(); - o.runs.push(a0_clone) + (*o.borrow_mut()).runs.push(a0_clone) }; - assert!((o.runs.len() == 1_usize)); - assert!((o.runs[0_usize].block_idx == 1)); - assert!((o.runs[0_usize].num_extra_zero_runs == 2)); + assert!(({ ((*o.borrow()).runs.len() == 1_usize) })); + assert!((vec_elem!(o.as_pointer(), runs, 0_usize).with(|__s| __s.block_idx) == 1)); + assert!((vec_elem!(o.as_pointer(), runs, 0_usize).with(|__s| __s.num_extra_zero_runs) == 2)); return 0; } +pub trait OuterImpl { + fn construct_1(&self); +} +impl OuterImpl for Ptr { + fn construct_1(&self) { + field!((*self), runs).write(Vec::new()); + } +} 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 7c88368be3..c58d657e22 100644 --- a/tests/unit/out/refcount/unary_expr_or_type_trait.rs +++ b/tests/unit/out/refcount/unary_expr_or_type_trait.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct S { diff --git a/tests/unit/out/refcount/unboxed_locals.rs b/tests/unit/out/refcount/unboxed_locals.rs index be0c5e2949..61337a7936 100644 --- a/tests/unit/out/refcount/unboxed_locals.rs +++ b/tests/unit/out/refcount/unboxed_locals.rs @@ -15,7 +15,16 @@ pub fn inc_1(r: Ptr) { }); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Pair { @@ -57,7 +66,16 @@ pub trait Shape { fn scale(&mut self, factor: i32) -> i32; } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Destructible, Copyable, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + Destructible, + DefaultConstructible, + Copyable, )] #[byte_size(16)] pub struct Square { diff --git a/tests/unit/out/refcount/unboxed_records.rs b/tests/unit/out/refcount/unboxed_records.rs index d39d30b2e3..0858d9deb1 100644 --- a/tests/unit/out/refcount/unboxed_records.rs +++ b/tests/unit/out/refcount/unboxed_records.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Inner { @@ -16,7 +25,16 @@ pub struct Inner { #[offset(4)] pub b: i32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[byte_size(48)] pub struct Cookie { #[offset(0)] @@ -54,6 +72,13 @@ pub struct Counter { #[offset(0)] pub n: i32, } +impl DefaultConstructible for Counter { + fn default_constructor(this: &Ptr) { + { + CounterImpl::construct_1(this); + } + } +} impl Default for Counter { fn default() -> Self { { Counter { n: 0 } } @@ -118,13 +143,15 @@ fn main_0() -> i32 { let field_addr: Value = Rc::new(RefCell::new(Inner { a: 0, b: 0 })); ({ set_0((field_ptr!(field_addr.as_pointer(), b)), 7) }); assert!(({ (*field_addr.borrow()).b } == 7)); - let counter: Value = Rc::new(RefCell::new(::default())); + let counter: Value = Rc::new(RefCell::new(::zero_init())); + CounterImpl::construct_1(&counter.as_pointer()); ({ CounterImpl::inc(&counter.as_pointer()) }); assert!(({ (*counter.borrow()).n } == 1)); return 0; } pub trait CounterImpl { fn inc(&self); + fn construct_1(&self); } impl CounterImpl for Ptr { fn inc(&self) { @@ -132,5 +159,8 @@ impl CounterImpl for Ptr { __v.prefix_inc(); }); } + fn construct_1(&self) { + field!((*self), n).write(0); + } } pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/union_addrof_external.rs b/tests/unit/out/refcount/union_addrof_external.rs index 38db75558a..09fb092534 100644 --- a/tests/unit/out/refcount/union_addrof_external.rs +++ b/tests/unit/out/refcount/union_addrof_external.rs @@ -6,7 +6,16 @@ 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, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[byte_size(16)] pub struct record { #[offset(0)] @@ -32,7 +41,9 @@ impl Default for record { } } } -#[derive(VaArg, FnPtrArg, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, +)] #[byte_size(128)] pub struct anon_0 { #[offset(0)] @@ -56,7 +67,15 @@ impl Default for anon_0 { } } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(128)] pub struct Container { diff --git a/tests/unit/out/refcount/union_basic.rs b/tests/unit/out/refcount/union_basic.rs index 4c0b892186..3c601c962c 100644 --- a/tests/unit/out/refcount/union_basic.rs +++ b/tests/unit/out/refcount/union_basic.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(VaArg, FnPtrArg, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, +)] #[byte_size(4)] pub struct basic { #[offset(0)] @@ -29,7 +31,9 @@ impl Default for basic { } } } -#[derive(VaArg, FnPtrArg, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, +)] #[byte_size(1)] pub struct empty { #[offset(0)] @@ -45,7 +49,9 @@ impl Default for empty { } } } -#[derive(VaArg, FnPtrArg, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, +)] #[byte_size(8)] pub struct underscores { #[offset(0)] @@ -123,7 +129,9 @@ fn main_0() -> i32 { assert!(((__ + ___) == 3)); return 0; } -#[derive(VaArg, FnPtrArg, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, 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 bc6e773407..7bc3b49b0b 100644 --- a/tests/unit/out/refcount/union_cross_arm_cast.rs +++ b/tests/unit/out/refcount/union_cross_arm_cast.rs @@ -6,7 +6,16 @@ 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, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[byte_size(16)] pub struct shape_a { #[offset(0)] @@ -26,7 +35,16 @@ impl Default for shape_a { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[byte_size(28)] pub struct shape_b { #[offset(0)] @@ -55,7 +73,9 @@ impl Default for shape_b { } } } -#[derive(VaArg, FnPtrArg, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, +)] #[byte_size(64)] pub struct anon_0 { #[offset(0)] @@ -82,7 +102,15 @@ impl Default for anon_0 { } } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(68)] pub struct Container { diff --git a/tests/unit/out/refcount/union_field_alignment.rs b/tests/unit/out/refcount/union_field_alignment.rs index d91fb62317..eced756fe4 100644 --- a/tests/unit/out/refcount/union_field_alignment.rs +++ b/tests/unit/out/refcount/union_field_alignment.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(VaArg, FnPtrArg, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, +)] #[byte_size(8)] pub struct anon_0 { #[offset(0)] @@ -30,7 +32,15 @@ impl Default for anon_0 { } } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct node { diff --git a/tests/unit/out/refcount/union_flex_array_member.rs b/tests/unit/out/refcount/union_flex_array_member.rs index a69afd6de5..d122b3f83f 100644 --- a/tests/unit/out/refcount/union_flex_array_member.rs +++ b/tests/unit/out/refcount/union_flex_array_member.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(VaArg, FnPtrArg, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, +)] #[byte_size(8)] pub struct anon_0 { #[offset(0)] @@ -30,7 +32,15 @@ impl Default for anon_0 { } } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(24)] pub struct node { diff --git a/tests/unit/out/refcount/union_memset_memcpy.rs b/tests/unit/out/refcount/union_memset_memcpy.rs index e215d22c1b..a9776a4229 100644 --- a/tests/unit/out/refcount/union_memset_memcpy.rs +++ b/tests/unit/out/refcount/union_memset_memcpy.rs @@ -6,7 +6,16 @@ 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, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[byte_size(16)] pub struct shape_a { #[offset(0)] @@ -26,7 +35,16 @@ impl Default for shape_a { } } } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[byte_size(16)] pub struct shape_b { #[offset(0)] @@ -52,7 +70,9 @@ impl Default for shape_b { } } } -#[derive(VaArg, FnPtrArg, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, +)] #[byte_size(256)] pub struct anon_0 { #[offset(0)] @@ -79,7 +99,15 @@ impl Default for anon_0 { } } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(256)] pub struct Container { diff --git a/tests/unit/out/refcount/union_nested.rs b/tests/unit/out/refcount/union_nested.rs index 3acf138887..462bcfe60a 100644 --- a/tests/unit/out/refcount/union_nested.rs +++ b/tests/unit/out/refcount/union_nested.rs @@ -6,7 +6,16 @@ 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, TriviallyCopyable)] +#[derive( + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, +)] #[byte_size(16)] pub struct record { #[offset(0)] @@ -26,7 +35,9 @@ impl Default for record { } } } -#[derive(VaArg, FnPtrArg, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, +)] #[byte_size(128)] pub struct anon_0 { #[offset(0)] @@ -50,7 +61,15 @@ impl Default for anon_0 { } } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(128)] pub struct inner { @@ -58,7 +77,9 @@ pub struct inner { #[byte_size(128)] pub view: anon_0, } -#[derive(VaArg, FnPtrArg, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, +)] #[byte_size(128)] pub struct anon_1 { #[offset(0)] @@ -82,7 +103,15 @@ impl Default for anon_1 { } } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(144)] pub struct Outer { diff --git a/tests/unit/out/refcount/union_pointer_pun_address.rs b/tests/unit/out/refcount/union_pointer_pun_address.rs index 687deafd25..8d37a4e617 100644 --- a/tests/unit/out/refcount/union_pointer_pun_address.rs +++ b/tests/unit/out/refcount/union_pointer_pun_address.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct node_a { @@ -15,7 +24,15 @@ pub struct node_a { pub n: i32, } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct node_b { @@ -38,7 +55,9 @@ fn main_0() -> i32 { assert!(({ (out).to_any() } == { (a.as_pointer()).to_any() })); return 0; } -#[derive(VaArg, FnPtrArg, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, 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 222fc22741..a04e7d4613 100644 --- a/tests/unit/out/refcount/union_pointer_pun_writethrough.rs +++ b/tests/unit/out/refcount/union_pointer_pun_writethrough.rs @@ -18,7 +18,9 @@ fn main_0() -> i32 { assert!(({ ((*x.borrow()) == 42_i64) })); return 0; } -#[derive(VaArg, FnPtrArg, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, 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 202db6881e..1bd3abb707 100644 --- a/tests/unit/out/refcount/union_struct_dual_use.rs +++ b/tests/unit/out/refcount/union_struct_dual_use.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Inner { @@ -19,7 +28,9 @@ 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, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, +)] #[byte_size(16)] pub struct anon_1 { #[offset(0)] @@ -43,7 +54,15 @@ impl Default for anon_1 { } } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct Outer { diff --git a/tests/unit/out/refcount/union_tagged_many_arms.rs b/tests/unit/out/refcount/union_tagged_many_arms.rs index 68a74d495f..097272f041 100644 --- a/tests/unit/out/refcount/union_tagged_many_arms.rs +++ b/tests/unit/out/refcount/union_tagged_many_arms.rs @@ -12,7 +12,9 @@ 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, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, +)] #[byte_size(8)] pub struct anon_0 { #[offset(0)] @@ -45,7 +47,15 @@ impl Default for anon_0 { } } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct Slot { diff --git a/tests/unit/out/refcount/union_tagged_simple.rs b/tests/unit/out/refcount/union_tagged_simple.rs index 9ac26454c1..abef917495 100644 --- a/tests/unit/out/refcount/union_tagged_simple.rs +++ b/tests/unit/out/refcount/union_tagged_simple.rs @@ -9,7 +9,9 @@ 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, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, +)] #[byte_size(8)] pub struct anon_0 { #[offset(0)] @@ -33,7 +35,15 @@ impl Default for anon_0 { } } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(24)] pub struct Event { diff --git a/tests/unit/out/refcount/union_tagged_struct_arms.rs b/tests/unit/out/refcount/union_tagged_struct_arms.rs index 761cc43908..70554efe76 100644 --- a/tests/unit/out/refcount/union_tagged_struct_arms.rs +++ b/tests/unit/out/refcount/union_tagged_struct_arms.rs @@ -11,7 +11,15 @@ 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, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(24)] pub struct anon_1 { @@ -24,7 +32,16 @@ pub struct anon_1 { pub cursor: i64, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct anon_2 { @@ -38,7 +55,16 @@ pub struct anon_2 { pub step: u8, } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(40)] pub struct anon_3 { @@ -53,7 +79,9 @@ pub struct anon_3 { #[offset(32)] pub width: i32, } -#[derive(VaArg, FnPtrArg, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, +)] #[byte_size(40)] pub struct anon_0 { #[offset(0)] @@ -80,7 +108,15 @@ impl Default for anon_0 { } } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(48)] pub struct Branch { 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 ee6473ddef..e9a2a623f0 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,9 @@ 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, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, +)] #[byte_size(8)] pub struct anon_0 { #[offset(0)] @@ -40,7 +42,15 @@ impl Default for anon_0 { } } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct Sink { diff --git a/tests/unit/out/refcount/unique_ptr.rs b/tests/unit/out/refcount/unique_ptr.rs index cfe9c99961..9374f54ebb 100644 --- a/tests/unit/out/refcount/unique_ptr.rs +++ b/tests/unit/out/refcount/unique_ptr.rs @@ -16,8 +16,24 @@ pub struct SafePointer { #[byte_size(8)] pub ptr: Option>, } +impl DefaultConstructible for SafePointer { + fn default_constructor(this: &Ptr) { + { + SafePointerImpl::construct_1(this); + } + } +} #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Pair { @@ -233,6 +249,7 @@ impl PairImpl for Ptr { } pub trait SafePointerImpl { fn inc(&self); + fn construct_1(&self); } impl SafePointerImpl for Ptr { fn inc(&self) { @@ -243,5 +260,8 @@ impl SafePointerImpl for Ptr { __v.prefix_inc(); }); } + fn construct_1(&self) { + field!((*self), ptr).write(None); + } } 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 c13b1df61c..ccccc74ed5 100644 --- a/tests/unit/out/refcount/unique_ptr_const_deref.rs +++ b/tests/unit/out/refcount/unique_ptr_const_deref.rs @@ -16,6 +16,13 @@ pub struct Holder { #[byte_size(8)] pub val: Option>, } +impl DefaultConstructible for Holder { + fn default_constructor(this: &Ptr) { + { + HolderImpl::construct_1(this); + } + } +} pub fn read_val_0(mut h: Ptr) -> i32 { return (h.with(|__s| __s.val.clone()).as_pointer().read()); } @@ -27,7 +34,8 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let h: Value = Rc::new(RefCell::new(::default())); + let h: Value = Rc::new(RefCell::new(::zero_init())); + HolderImpl::construct_1(&h.as_pointer()); { (*h.borrow_mut()).val = Some(Rc::new(RefCell::new(10))).take(); }; @@ -35,4 +43,12 @@ fn main_0() -> i32 { assert!((({ read_val_0((h.as_pointer()),) }) == 42)); return 0; } +pub trait HolderImpl { + fn construct_1(&self); +} +impl HolderImpl for Ptr { + fn construct_1(&self) { + field!((*self), val).write(None); + } +} 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 b2349d77b5..5ab941d468 100644 --- a/tests/unit/out/refcount/unique_ptr_field_reset.rs +++ b/tests/unit/out/refcount/unique_ptr_field_reset.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Data { @@ -26,12 +35,20 @@ pub struct Holder { #[offset(8)] pub n: i32, } +impl DefaultConstructible for Holder { + fn default_constructor(this: &Ptr) { + { + HolderImpl::construct_1(this); + } + } +} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let h: Value = Rc::new(RefCell::new(::default())); + let h: Value = Rc::new(RefCell::new(::zero_init())); + HolderImpl::construct_1(&h.as_pointer()); (*h.borrow_mut()).n = 1; let mut hp: Ptr = (h.as_pointer()); { @@ -65,6 +82,7 @@ fn main_0() -> i32 { } pub trait HolderImpl { fn set(&self, p: Ptr); + fn construct_1(&self); } impl HolderImpl for Ptr { fn set(&self, mut p: Ptr) { @@ -73,5 +91,9 @@ impl HolderImpl for Ptr { field_ptr!((*self), data).write(_p.to_owned_opt()) }; } + fn construct_1(&self) { + field!((*self), data).write(None); + field!((*self), n).write(0_i32); + } } 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 44621e9e33..bc6beab004 100644 --- a/tests/unit/out/refcount/unique_ptr_nested.rs +++ b/tests/unit/out/refcount/unique_ptr_nested.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Inner { @@ -26,6 +35,13 @@ pub struct Outer { #[byte_size(8)] pub inner: Option>, } +impl DefaultConstructible for Outer { + fn default_constructor(this: &Ptr) { + { + OuterImpl::construct_1(this); + } + } +} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); @@ -53,4 +69,12 @@ fn main_0() -> i32 { assert!(((sum + (b.as_pointer().read())) == 135)); return 0; } +pub trait OuterImpl { + fn construct_1(&self); +} +impl OuterImpl for Ptr { + fn construct_1(&self) { + field!((*self), inner).write(None); + } +} 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 f2bd49ae0b..0e5a291a3c 100644 --- a/tests/unit/out/refcount/unique_ptr_struct.rs +++ b/tests/unit/out/refcount/unique_ptr_struct.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Point { diff --git a/tests/unit/out/refcount/va_arg_mixed_types.rs b/tests/unit/out/refcount/va_arg_mixed_types.rs index 2a0b78aa51..5ae1c6b310 100644 --- a/tests/unit/out/refcount/va_arg_mixed_types.rs +++ b/tests/unit/out/refcount/va_arg_mixed_types.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct pair { 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 d606d5b110..1ccc584652 100644 --- a/tests/unit/out/refcount/va_arg_non_primitive_ptrs.rs +++ b/tests/unit/out/refcount/va_arg_non_primitive_ptrs.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, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct node { diff --git a/tests/unit/out/refcount/va_arg_struct_ctx.rs b/tests/unit/out/refcount/va_arg_struct_ctx.rs index b68607d5f1..2fbfedcf65 100644 --- a/tests/unit/out/refcount/va_arg_struct_ctx.rs +++ b/tests/unit/out/refcount/va_arg_struct_ctx.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct context { @@ -25,7 +34,9 @@ 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, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization)] +#[derive( + VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, 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 9a7b947b8f..dd959b294a 100644 --- a/tests/unit/out/refcount/va_arg_void_ptr.rs +++ b/tests/unit/out/refcount/va_arg_void_ptr.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, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(16)] pub struct registry { diff --git a/tests/unit/out/refcount/va_list_field.rs b/tests/unit/out/refcount/va_list_field.rs index 274f49b328..d579c7ca12 100644 --- a/tests/unit/out/refcount/va_list_field.rs +++ b/tests/unit/out/refcount/va_list_field.rs @@ -29,7 +29,16 @@ pub fn sum_0(n: i32, __args: Box<[VaArg]>) -> i32 { return total; } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, CppFrom, Copyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + CppFrom, + DefaultConstructible, + Copyable, + Default, )] #[cpp_from(Ptr , construct, mut_ptr)] #[byte_size(16)] @@ -66,7 +75,15 @@ pub fn sum_ptr_2(n: i32, __args: Box<[VaArg]>) -> i32 { return total; } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Cursor_3 { diff --git a/tests/unit/out/refcount/vector.rs b/tests/unit/out/refcount/vector.rs index b3e7b67336..656c95f152 100644 --- a/tests/unit/out/refcount/vector.rs +++ b/tests/unit/out/refcount/vector.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct S { @@ -38,6 +47,13 @@ pub struct Foo { #[byte_size(24)] pub b: Vec, } +impl DefaultConstructible for Foo { + fn default_constructor(this: &Ptr) { + { + FooImpl::construct_1(this); + } + } +} #[derive( Copy, Clone, @@ -47,6 +63,7 @@ pub struct Foo { VaArg, FnPtrArg, CppFrom, + DefaultConstructible, TriviallyCopyable, Default, )] @@ -508,7 +525,8 @@ fn main_0() -> i32 { && ({ (*v11.borrow())[2_usize] } == 3) }) ); - let foo: Value = Rc::new(RefCell::new(::default())); + let foo: Value = Rc::new(RefCell::new(::zero_init())); + FooImpl::construct_1(&foo.as_pointer()); { let __a1 = 5; (*foo.borrow_mut()).a.push(__a1) @@ -756,6 +774,15 @@ fn main_0() -> i32 { } return 0; } +pub trait FooImpl { + fn construct_1(&self); +} +impl FooImpl for Ptr { + fn construct_1(&self) { + field!((*self), a).write(Vec::new()); + field!((*self), b).write(Vec::new()); + } +} pub trait WrappedImpl { fn construct(&self, v: i32); } diff --git a/tests/unit/out/refcount/vector_iter_range_ctor.rs b/tests/unit/out/refcount/vector_iter_range_ctor.rs index 6b64a33821..f7daeb91b2 100644 --- a/tests/unit/out/refcount/vector_iter_range_ctor.rs +++ b/tests/unit/out/refcount/vector_iter_range_ctor.rs @@ -15,6 +15,7 @@ use std::rc::{Rc, Weak}; VaArg, FnPtrArg, CppFrom, + DefaultConstructible, TriviallyCopyable, Default, )] @@ -33,6 +34,7 @@ pub struct Degrees { VaArg, FnPtrArg, CppFrom, + DefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/vector_subscript_direct.rs b/tests/unit/out/refcount/vector_subscript_direct.rs index 37fa62975d..c158a753e8 100644 --- a/tests/unit/out/refcount/vector_subscript_direct.rs +++ b/tests/unit/out/refcount/vector_subscript_direct.rs @@ -7,7 +7,16 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(8)] pub struct Point { @@ -39,6 +48,13 @@ pub struct Holder { #[byte_size(24)] pub points: Vec, } +impl DefaultConstructible for Holder { + fn default_constructor(this: &Ptr) { + { + HolderImpl::construct_1(this); + } + } +} pub fn push_and_index_0(v: Ptr>) -> i32 { { let __a1 = 42; @@ -95,7 +111,8 @@ fn main_0() -> i32 { p.write(9); assert!(({ (*v.borrow())[2_usize] } == 9)); assert!((({ sum_ref_1(v.as_pointer(),) }) == ((((3 + 0) + 9) + 42) + 5))); - let h: Value = Rc::new(RefCell::new(::default())); + let h: Value = Rc::new(RefCell::new(::zero_init())); + HolderImpl::construct_1(&h.as_pointer()); (*h.borrow_mut()).values.resize_with(2_usize, || 0_i32); vec_elem!(h.as_pointer(), values, 1_usize).write(6); { @@ -146,6 +163,15 @@ fn main_0() -> i32 { assert!(({ (*a.borrow())[1_usize] } == 10)); return 0; } +pub trait HolderImpl { + fn construct_1(&self); +} +impl HolderImpl for Ptr { + fn construct_1(&self) { + field!((*self), values).write(Vec::new()); + field!((*self), points).write(Vec::new()); + } +} pub trait PointImpl { fn sum(&self) -> i32; } diff --git a/tests/unit/out/refcount/vector_with_allocator.rs b/tests/unit/out/refcount/vector_with_allocator.rs index bf2a2a2fae..1f263c4fcd 100644 --- a/tests/unit/out/refcount/vector_with_allocator.rs +++ b/tests/unit/out/refcount/vector_with_allocator.rs @@ -7,12 +7,30 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct TestAllocator_int_ {} #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(1)] pub struct TestAllocator_double_ {} diff --git a/tests/unit/out/refcount/void_cast.rs b/tests/unit/out/refcount/void_cast.rs index 26f97d52a8..3af4d6bce7 100644 --- a/tests/unit/out/refcount/void_cast.rs +++ b/tests/unit/out/refcount/void_cast.rs @@ -27,6 +27,13 @@ pub struct NonTrivial { #[byte_size(24)] pub data: Vec, } +impl DefaultConstructible for NonTrivial { + fn default_constructor(this: &Ptr) { + { + NonTrivialImpl::construct_1(this); + } + } +} pub fn unused_ref_param_1(x: Ptr) {} pub fn unused_ptr_param_2(mut p: Ptr) {} thread_local!( @@ -37,7 +44,16 @@ pub fn bump_and_return_4() -> i32 { return side_effect_counter_3.with(|rc| *rc.borrow()); } #[derive( - Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + DefaultConstructible, + TriviallyCopyable, + Default, )] #[byte_size(4)] pub struct Holder { @@ -54,6 +70,13 @@ pub struct NonCopyable { #[byte_size(8)] pub value: Option>, } +impl DefaultConstructible for NonCopyable { + fn default_constructor(this: &Ptr) { + { + NonCopyableImpl::construct_1(this); + } + } +} pub fn unused_noncopyable_param_5(x: Ptr) {} pub fn main() { __cpp2rust_init_globals(); @@ -102,7 +125,8 @@ fn main_0() -> i32 { let mut arr: [i32; 3] = [1, 2, 3]; let h: Value = Rc::new(RefCell::new(Holder { field: 17 })); let mut hp: Ptr = (h.as_pointer()); - let nt: Value = Rc::new(RefCell::new(::default())); + let nt: Value = Rc::new(RefCell::new(::zero_init())); + NonTrivialImpl::construct_1(&nt.as_pointer()); ({ unused_ref_param_1(nt.as_pointer()) }); ({ unused_ptr_param_2((nt.as_pointer())) }); let g: Value = Rc::new(RefCell::new(NonCopyable { @@ -113,6 +137,22 @@ fn main_0() -> i32 { assert!((({ (*g.borrow()).value.clone() }.as_pointer().read()) == 9)); return 0; } +pub trait NonCopyableImpl { + fn construct_1(&self); +} +impl NonCopyableImpl for Ptr { + fn construct_1(&self) { + field!((*self), value).write(None); + } +} +pub trait NonTrivialImpl { + fn construct_1(&self); +} +impl NonTrivialImpl for Ptr { + fn construct_1(&self) { + field!((*self), data).write(Vec::new()); + } +} pub fn __cpp2rust_init_globals() { let _ = side_effect_counter_3.with(|_| ()); } diff --git a/tests/unit/out/unsafe/05_new.rs b/tests/unit/out/unsafe/05_new.rs index ebd9cebebf..cc653b829b 100644 --- a/tests/unit/out/unsafe/05_new.rs +++ b/tests/unit/out/unsafe/05_new.rs @@ -8,12 +8,26 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct A {} #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct D {} impl D { diff --git a/tests/unit/out/unsafe/10_struct.rs b/tests/unit/out/unsafe/10_struct.rs index 613fd301d0..c11c6ef2ab 100644 --- a/tests/unit/out/unsafe/10_struct.rs +++ b/tests/unit/out/unsafe/10_struct.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct GraphNode { pub dst: u32, @@ -16,7 +23,14 @@ pub struct GraphNode { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Graph { pub V: u32, @@ -40,10 +54,20 @@ pub struct Partial { pub p: *mut i32, } impl Partial { - pub unsafe fn construct_1(&mut self, mut q: *mut i32) { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.p).write(std::ptr::null_mut()); + } + pub unsafe fn construct_2(&mut self, mut q: *mut i32) { (&raw mut self.p).write(q); } } +impl DefaultConstructibleUnsafe for Partial { + unsafe fn default_constructor(&mut self) { + unsafe { + Partial::construct_1(&mut *self); + } + } +} impl Default for Partial { fn default() -> Self { unsafe { @@ -55,13 +79,27 @@ impl Default for Partial { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Declared {} impl Declared {} #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct S { pub i: i32, @@ -80,11 +118,12 @@ unsafe fn main_0() -> i32 { }; let mut arr: [i32; 3] = [3, 1, 4]; let mut it: Partial = ::zero_init(); - Partial::construct_1(&mut it, { arr.as_mut_ptr() }); + Partial::construct_2(&mut it, { arr.as_mut_ptr() }); if ((it.p) != (arr.as_mut_ptr())) { return 1; } - let mut def: Partial = ::default(); + let mut def: Partial = ::zero_init(); + Partial::construct_1(&mut def); if !((def.p).is_null()) { return 1; } diff --git a/tests/unit/out/unsafe/addr_of_global.rs b/tests/unit/out/unsafe/addr_of_global.rs index 5e47f92c63..44b8278e34 100644 --- a/tests/unit/out/unsafe/addr_of_global.rs +++ b/tests/unit/out/unsafe/addr_of_global.rs @@ -8,14 +8,28 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Inner { pub value: i32, } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 fc1e8b5c3a..09d28d8fd8 100644 --- a/tests/unit/out/unsafe/anonymous-struct.rs +++ b/tests/unit/out/unsafe/anonymous-struct.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Outer_Named { pub a: i32, @@ -16,7 +23,14 @@ pub struct Outer_Named { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct anon_0 { pub c: i32, @@ -24,7 +38,14 @@ pub struct anon_0 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct anon_1 { pub g: i32, @@ -32,7 +53,14 @@ pub struct anon_1 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct anon_2 { pub e: i32, @@ -40,21 +68,42 @@ pub struct anon_2 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct anon_4 { pub j: i32, } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct anon_5 { pub k: i32, } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct anon_3 { pub i: i32, @@ -63,7 +112,14 @@ pub struct anon_3 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Outer { pub named: Outer_Named, @@ -121,7 +177,14 @@ unsafe fn main_0() -> i32 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct anon_6 { pub x: i32, diff --git a/tests/unit/out/unsafe/anonymous-struct_c.rs b/tests/unit/out/unsafe/anonymous-struct_c.rs index 405a2cac0b..8c7c7a6d6d 100644 --- a/tests/unit/out/unsafe/anonymous-struct_c.rs +++ b/tests/unit/out/unsafe/anonymous-struct_c.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Named { pub a: i32, @@ -16,7 +23,14 @@ pub struct Named { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct anon_0 { pub c: i32, @@ -24,7 +38,14 @@ pub struct anon_0 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct anon_1 { pub g: i32, @@ -32,7 +53,14 @@ pub struct anon_1 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct anon_2 { pub e: i32, @@ -40,21 +68,42 @@ pub struct anon_2 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct anon_4 { pub j: i32, } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct anon_5 { pub k: i32, } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct anon_3 { pub i: i32, @@ -63,7 +112,14 @@ pub struct anon_3 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Outer { pub named: Named, @@ -127,7 +183,14 @@ unsafe fn main_0() -> i32 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct anon_6 { pub x: i32, diff --git a/tests/unit/out/unsafe/anonymous_enum.rs b/tests/unit/out/unsafe/anonymous_enum.rs index f8e6e55e5f..6aa9b0ae63 100644 --- a/tests/unit/out/unsafe/anonymous_enum.rs +++ b/tests/unit/out/unsafe/anonymous_enum.rs @@ -14,7 +14,14 @@ 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, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct S { pub a: i32, @@ -27,7 +34,14 @@ 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, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct WithAnonField { pub a: i32, diff --git a/tests/unit/out/unsafe/anonymous_enum_c.rs b/tests/unit/out/unsafe/anonymous_enum_c.rs index 05055b8ed6..0b58d03a13 100644 --- a/tests/unit/out/unsafe/anonymous_enum_c.rs +++ b/tests/unit/out/unsafe/anonymous_enum_c.rs @@ -14,7 +14,14 @@ 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, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct S { pub a: i32, @@ -27,7 +34,14 @@ 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, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct WithAnonField { pub a: i32, diff --git a/tests/unit/out/unsafe/any.rs b/tests/unit/out/unsafe/any.rs index 855caed29d..45b278dea7 100644 --- a/tests/unit/out/unsafe/any.rs +++ b/tests/unit/out/unsafe/any.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Point { pub x: i32, diff --git a/tests/unit/out/unsafe/array_const_init.rs b/tests/unit/out/unsafe/array_const_init.rs index 2f76988087..6e16428b8b 100644 --- a/tests/unit/out/unsafe/array_const_init.rs +++ b/tests/unit/out/unsafe/array_const_init.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct S { pub head: i32, @@ -24,7 +31,14 @@ pub static mut s_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe }); #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct P { pub x: i32, diff --git a/tests/unit/out/unsafe/array_field_addr.rs b/tests/unit/out/unsafe/array_field_addr.rs index 2625480bd5..0ac36a4b48 100644 --- a/tests/unit/out/unsafe/array_field_addr.rs +++ b/tests/unit/out/unsafe/array_field_addr.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct S { pub before: i32, diff --git a/tests/unit/out/unsafe/array_of_noncopy_struct.rs b/tests/unit/out/unsafe/array_of_noncopy_struct.rs index 8639525a23..f0f5ef1690 100644 --- a/tests/unit/out/unsafe/array_of_noncopy_struct.rs +++ b/tests/unit/out/unsafe/array_of_noncopy_struct.rs @@ -22,6 +22,19 @@ pub struct NonCopy { pub data: Vec, pub tag: i32, } +impl NonCopy { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.data).write(Vec::new()); + (&raw mut self.tag).write(0); + } +} +impl DefaultConstructibleUnsafe for NonCopy { + unsafe fn default_constructor(&mut self) { + unsafe { + NonCopy::construct_1(&mut *self); + } + } +} impl Default for NonCopy { fn default() -> Self { unsafe { @@ -39,7 +52,11 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut arr: [NonCopy; 3] = std::array::from_fn::<_, 3, _>(|_| ::default()); + let mut arr: [NonCopy; 3] = std::array::from_fn::<_, 3, _>(|_| { + let mut __v: NonCopy = ::zero_init(); + NonCopy::construct_1(&mut __v); + __v + }); arr[(0) as usize].tag = 7; { let __a1 = 42; diff --git a/tests/unit/out/unsafe/array_reference.rs b/tests/unit/out/unsafe/array_reference.rs index 77bec757c9..78e86fc7ef 100644 --- a/tests/unit/out/unsafe/array_reference.rs +++ b/tests/unit/out/unsafe/array_reference.rs @@ -58,7 +58,14 @@ pub unsafe fn pick_10(s: *const [libc::c_char; 5]) -> *const [libc::c_char; 5] { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Point { pub x: i32, diff --git a/tests/unit/out/unsafe/as_const.rs b/tests/unit/out/unsafe/as_const.rs index 268e0a0336..0f588d00a6 100644 --- a/tests/unit/out/unsafe/as_const.rs +++ b/tests/unit/out/unsafe/as_const.rs @@ -11,7 +11,14 @@ pub const Overload_kMutableOverload: Overload = 1; pub const Overload_kConstOverload: Overload = 2; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 65997d2d5d..feffbe6373 100644 --- a/tests/unit/out/unsafe/assign_rhs_first.rs +++ b/tests/unit/out/unsafe/assign_rhs_first.rs @@ -14,7 +14,14 @@ pub unsafe fn advance_1() -> i32 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 b8ee840454..895ca1a436 100644 --- a/tests/unit/out/unsafe/assignment_single_eval.rs +++ b/tests/unit/out/unsafe/assignment_single_eval.rs @@ -837,21 +837,42 @@ pub unsafe fn test_reference_members_9() { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Slot_6 { pub value: *mut u32, } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Slot_8 { pub value: *mut i16, } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Slot_10 { pub value: *mut i32, @@ -902,7 +923,14 @@ pub unsafe fn test_pointer_elements_11() { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Holder_12 { pub p: *mut i32, @@ -930,7 +958,14 @@ pub unsafe fn test_reference_pointer_13() { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Node_14 { pub link: *mut *mut Node_14, @@ -1005,28 +1040,56 @@ pub unsafe fn test_reference_subfields_18() { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Index_16 { pub value: u32, } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Slot_17 { pub ref_: *mut Index_16, } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Index_19 { pub value: i16, } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Slot_20 { pub ref_: *mut Index_19, @@ -1068,14 +1131,28 @@ pub unsafe fn observe_24(mut assigned: i32, mut stored: *const i32) -> i32 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct GlobalRecord_Inner { pub value: i32, } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct GlobalRecord { pub inner: GlobalRecord_Inner, @@ -1343,14 +1420,28 @@ static mut promoted_30: std::cell::LazyCell = std::cell::LazyCell::new(|| u static mut flag_31: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { false }); #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Record_32 { pub value: i32, } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Link_33 { pub next: *mut Link_33, @@ -1359,7 +1450,14 @@ 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, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct IndexedBinding {} impl IndexedBinding { @@ -1580,7 +1678,14 @@ 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, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct IndexedMember { pub key: i32, @@ -1841,7 +1946,14 @@ pub static mut scoped_pointers_53: std::cell::LazyCell<[*mut u32; 1]> = }); #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct PointerSelector { pub ptr: *mut u32, @@ -2013,9 +2125,28 @@ pub unsafe fn test_stable_containers_58() { pub struct Counts_59 { pub counts: Vec, } +impl Counts_59 { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.counts).write(Vec::new()); + } +} +impl DefaultConstructibleUnsafe for Counts_59 { + unsafe fn default_constructor(&mut self) { + unsafe { + Counts_59::construct_1(&mut *self); + } + } +} #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Pair_60 { pub u: u32, @@ -2319,14 +2450,28 @@ unsafe fn main_0() -> i32 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Index_62 { pub value: i32, } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Owner_63 { pub values: [i32; 2], diff --git a/tests/unit/out/unsafe/bounded_struct_ptr.rs b/tests/unit/out/unsafe/bounded_struct_ptr.rs index 16f0402ee3..f91cfe97fe 100644 --- a/tests/unit/out/unsafe/bounded_struct_ptr.rs +++ b/tests/unit/out/unsafe/bounded_struct_ptr.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Foo { pub x1: i32, diff --git a/tests/unit/out/unsafe/bst.rs b/tests/unit/out/unsafe/bst.rs index 0058a5ad73..b432bb8fab 100644 --- a/tests/unit/out/unsafe/bst.rs +++ b/tests/unit/out/unsafe/bst.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct node_t { pub left: *mut node_t, diff --git a/tests/unit/out/unsafe/c_struct.rs b/tests/unit/out/unsafe/c_struct.rs index ff68b685b8..56efdf13ad 100644 --- a/tests/unit/out/unsafe/c_struct.rs +++ b/tests/unit/out/unsafe/c_struct.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Point { pub x: i32, @@ -16,7 +23,14 @@ pub struct Point { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Line { pub start: Point, @@ -24,7 +38,14 @@ pub struct Line { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Node { pub value: i32, @@ -36,7 +57,14 @@ pub const Color_GREEN: Color = 1; pub const Color_BLUE: Color = 2; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Inner { pub a: i32, @@ -44,7 +72,14 @@ pub struct Inner { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Container { pub inner: Inner, diff --git a/tests/unit/out/unsafe/cast.rs b/tests/unit/out/unsafe/cast.rs index 1f50aaa85e..a9f65b426c 100644 --- a/tests/unit/out/unsafe/cast.rs +++ b/tests/unit/out/unsafe/cast.rs @@ -12,7 +12,14 @@ pub const E_B: E = 1; pub const E_C: E = 2; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Pair { pub x: i32, @@ -20,14 +27,28 @@ pub struct Pair { } #[repr(C, align(64))] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Wide { pub c: libc::c_char, } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Grid { pub h: i32, @@ -51,6 +72,19 @@ pub struct Bag { pub n: i32, pub items: Vec, } +impl Bag { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.n).write(0_i32); + (&raw mut self.items).write(Vec::new()); + } +} +impl DefaultConstructibleUnsafe for Bag { + unsafe fn default_constructor(&mut self) { + unsafe { + Bag::construct_1(&mut *self); + } + } +} pub unsafe fn adjacent_arrays_0() { let mut a: [i32; 4] = [1, 2, 3, 4]; let mut b: [i32; 4] = [5, 6, 7, 8]; @@ -283,7 +317,8 @@ pub unsafe fn nested_5() { assert!(((m[(1) as usize][(1) as usize]) == (42))); assert!(((pm) == (&mut m[(1) as usize][(1) as usize] as *mut i32))); assert!(((pm) < (&mut m[(2) as usize][(0) as usize] as *mut i32))); - let mut b: Bag = ::default(); + let mut b: Bag = ::zero_init(); + Bag::construct_1(&mut b); if 4_usize > b.items.capacity() as usize { let len_0 = b.items.len(); b.items.reserve_exact(4_usize - len_0 as usize); 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 325a9458f0..6c60f4d038 100644 --- a/tests/unit/out/unsafe/cast_array_to_pointer_decay.rs +++ b/tests/unit/out/unsafe/cast_array_to_pointer_decay.rs @@ -18,7 +18,14 @@ pub unsafe fn strlen_1(mut s: *mut libc::c_char) -> i32 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 750d263682..5abf17bdae 100644 --- a/tests/unit/out/unsafe/class.rs +++ b/tests/unit/out/unsafe/class.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Pair { pub first: i32, @@ -45,7 +52,14 @@ impl Pair { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Route { pub path: Pair, @@ -60,7 +74,14 @@ impl Route { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Counter { pub v: i32, @@ -84,7 +105,14 @@ impl std::cmp::PartialEq for Counter { impl std::cmp::Eq for Counter {} #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 94e7837f31..c3ce7d0ea8 100644 --- a/tests/unit/out/unsafe/class_template_lazy_member.rs +++ b/tests/unit/out/unsafe/class_template_lazy_member.rs @@ -8,14 +8,28 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Point { pub x: i32, } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Box_int_ { pub val: i32, @@ -27,7 +41,14 @@ impl Box_int_ { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Box_Point_ { pub val: Point, @@ -39,7 +60,14 @@ impl Box_Point_ { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Deduced_int_ { pub val: i32, @@ -51,7 +79,14 @@ impl Deduced_int_ { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 e8129a85c2..882f0fd5b3 100644 --- a/tests/unit/out/unsafe/class_templates.rs +++ b/tests/unit/out/unsafe/class_templates.rs @@ -45,6 +45,16 @@ impl MyContainer_int_ { self.vec_.push(a0_clone) }; } + pub unsafe fn construct_1(&mut self) { + (&raw mut self.vec_).write(Vec::new()); + } +} +impl DefaultConstructibleUnsafe for MyContainer_int_ { + unsafe fn default_constructor(&mut self) { + unsafe { + MyContainer_int_::construct_1(&mut *self); + } + } } #[repr(C)] #[derive( @@ -85,6 +95,16 @@ impl MyContainer_char_ { self.vec_.push(a0_clone) }; } + pub unsafe fn construct_1(&mut self) { + (&raw mut self.vec_).write(Vec::new()); + } +} +impl DefaultConstructibleUnsafe for MyContainer_char_ { + unsafe fn default_constructor(&mut self) { + unsafe { + MyContainer_char_::construct_1(&mut *self); + } + } } #[repr(C)] #[derive( @@ -125,10 +145,27 @@ impl MyContainer_float_ { self.vec_.push(a0_clone) }; } + pub unsafe fn construct_1(&mut self) { + (&raw mut self.vec_).write(Vec::new()); + } +} +impl DefaultConstructibleUnsafe for MyContainer_float_ { + unsafe fn default_constructor(&mut self) { + unsafe { + MyContainer_float_::construct_1(&mut *self); + } + } } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Boxed_short_ { pub value: i16, @@ -143,7 +180,14 @@ impl Boxed_short_ { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Boxed_int_ { pub value: i32, @@ -158,7 +202,14 @@ impl Boxed_int_ { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Boxed_long_ { pub value: i64, @@ -173,7 +224,14 @@ impl Boxed_long_ { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Outer_int__Inner_int_ { pub t: i32, @@ -186,7 +244,14 @@ impl Outer_int__Inner_int_ { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Outer_int_ { pub v: i32, @@ -198,7 +263,14 @@ impl Outer_int_ { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Outer_long__Inner_int_ { pub t: i64, @@ -211,7 +283,14 @@ impl Outer_long__Inner_int_ { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Outer_long__Inner_char_ { pub t: i64, @@ -224,7 +303,14 @@ impl Outer_long__Inner_char_ { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Outer_long_ { pub v: i64, @@ -236,7 +322,14 @@ impl Outer_long_ { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Elem { pub i: i32, @@ -277,7 +370,8 @@ unsafe fn main_0() -> i32 { assert!(((unsafe { Boxed_long_::twice(10_i64,) }) == (20_i64))); let mut bl: Boxed_long_ = Boxed_long_ { value: 7_i64 }; assert!(((unsafe { Boxed_long_::plus(&bl, 1_i64,) }) == (8_i64))); - let mut imc: MyContainer_int_ = ::default(); + let mut imc: MyContainer_int_ = ::zero_init(); + MyContainer_int_::construct_1(&mut imc); assert!((unsafe { MyContainer_int_::empty(&imc,) })); (unsafe { let mut _item: i32 = 1; @@ -289,7 +383,8 @@ unsafe fn main_0() -> i32 { ); (unsafe { MyContainer_int_::pop_back(&mut imc) }); assert!((unsafe { MyContainer_int_::empty(&imc,) })); - let mut cmc: MyContainer_char_ = ::default(); + let mut cmc: MyContainer_char_ = ::zero_init(); + MyContainer_char_::construct_1(&mut cmc); assert!((unsafe { MyContainer_char_::empty(&cmc,) })); (unsafe { let mut _item: libc::c_char = ('a' as libc::c_char); @@ -302,7 +397,8 @@ unsafe fn main_0() -> i32 { ); (unsafe { MyContainer_char_::pop_back(&mut cmc) }); assert!((unsafe { MyContainer_char_::empty(&cmc,) })); - let mut fmc: MyContainer_float_ = ::default(); + let mut fmc: MyContainer_float_ = ::zero_init(); + MyContainer_float_::construct_1(&mut fmc); assert!((unsafe { MyContainer_float_::empty(&fmc,) })); (unsafe { let mut _item: f32 = (1_f64 as f32); diff --git a/tests/unit/out/unsafe/clone_vs_move.rs b/tests/unit/out/unsafe/clone_vs_move.rs index 1bb270b340..b5023712ee 100644 --- a/tests/unit/out/unsafe/clone_vs_move.rs +++ b/tests/unit/out/unsafe/clone_vs_move.rs @@ -8,14 +8,28 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Bar { pub w: i32, } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Foo { pub x: i32, @@ -26,7 +40,14 @@ pub struct Foo { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Refs { pub a: *mut i32, diff --git a/tests/unit/out/unsafe/comma_operator.rs b/tests/unit/out/unsafe/comma_operator.rs index 2d4598027a..0a64b4139d 100644 --- a/tests/unit/out/unsafe/comma_operator.rs +++ b/tests/unit/out/unsafe/comma_operator.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Pair { pub first: i32, diff --git a/tests/unit/out/unsafe/complex_function.rs b/tests/unit/out/unsafe/complex_function.rs index 0e2b7bebfb..40e776cfc3 100644 --- a/tests/unit/out/unsafe/complex_function.rs +++ b/tests/unit/out/unsafe/complex_function.rs @@ -17,14 +17,28 @@ pub unsafe fn bar_2(x: *mut i32) -> *mut i32 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct X1 { pub v: i32, } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct X2 { pub v: *mut X1, @@ -36,7 +50,14 @@ impl X2 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct X3 { pub v: *mut X2, @@ -48,7 +69,14 @@ impl X3 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 d04fd5c815..638c56aec7 100644 --- a/tests/unit/out/unsafe/compound_assign_paren.rs +++ b/tests/unit/out/unsafe/compound_assign_paren.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Item { pub flags: u8, diff --git a/tests/unit/out/unsafe/concepts.rs b/tests/unit/out/unsafe/concepts.rs index 480c879e74..4d03a62955 100644 --- a/tests/unit/out/unsafe/concepts.rs +++ b/tests/unit/out/unsafe/concepts.rs @@ -13,7 +13,14 @@ const _: () = assert!( ); #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Sized {} impl Sized { diff --git a/tests/unit/out/unsafe/constexpr_function.rs b/tests/unit/out/unsafe/constexpr_function.rs index 0ab56af31f..b148348ec7 100644 --- a/tests/unit/out/unsafe/constexpr_function.rs +++ b/tests/unit/out/unsafe/constexpr_function.rs @@ -23,7 +23,14 @@ pub unsafe fn half_3(mut x: f64) -> f64 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Flag { pub v: i32, @@ -51,7 +58,14 @@ pub unsafe fn imm_7(mut b: bool) -> bool { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct P { pub v: i32, diff --git a/tests/unit/out/unsafe/constructor.rs b/tests/unit/out/unsafe/constructor.rs index c26e7350dd..d1ba2946d2 100644 --- a/tests/unit/out/unsafe/constructor.rs +++ b/tests/unit/out/unsafe/constructor.rs @@ -14,6 +14,7 @@ pub static mut total_0: std::cell::LazyCell = std::cell::LazyCell::new(|| u FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, @@ -68,6 +69,13 @@ impl Point { self.x += 100; } } +impl DefaultConstructibleUnsafe for Point { + unsafe fn default_constructor(&mut self) { + unsafe { + Point::construct_3(&mut *self); + } + } +} impl Default for Point { fn default() -> Self { unsafe { diff --git a/tests/unit/out/unsafe/container_element_receiver.rs b/tests/unit/out/unsafe/container_element_receiver.rs index 65a02fe5f0..12d3ee6ee9 100644 --- a/tests/unit/out/unsafe/container_element_receiver.rs +++ b/tests/unit/out/unsafe/container_element_receiver.rs @@ -13,6 +13,7 @@ use std::rc::Rc; FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, diff --git a/tests/unit/out/unsafe/container_field_addr.rs b/tests/unit/out/unsafe/container_field_addr.rs index 366e060d2e..f40b97c252 100644 --- a/tests/unit/out/unsafe/container_field_addr.rs +++ b/tests/unit/out/unsafe/container_field_addr.rs @@ -23,6 +23,19 @@ pub struct S { pub tag: i32, pub v: Vec, } +impl S { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.tag).write(0_i32); + (&raw mut self.v).write(Vec::new()); + } +} +impl DefaultConstructibleUnsafe for S { + unsafe fn default_constructor(&mut self) { + unsafe { + S::construct_1(&mut *self); + } + } +} pub unsafe fn add_0(mut v: *mut Vec, mut k: i32) { { let a0_clone = k.clone(); @@ -53,10 +66,15 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut local: S = ::default(); + let mut local: S = ::zero_init(); + S::construct_1(&mut local); local.tag = 7; (unsafe { run_1((&mut local as *mut S)) }); - let mut heap: *mut S = (Box::leak(Box::new(::default())) as *mut S); + let mut heap: *mut S = { + let __p: *mut S = Box::leak(Box::new(::zero_init())); + S::construct_1(&mut *__p); + __p + }; (*heap).tag = 7; (unsafe { run_1(heap) }); { diff --git a/tests/unit/out/unsafe/conversion_operator_same_translation.rs b/tests/unit/out/unsafe/conversion_operator_same_translation.rs index a80b02ea99..5b0743d485 100644 --- a/tests/unit/out/unsafe/conversion_operator_same_translation.rs +++ b/tests/unit/out/unsafe/conversion_operator_same_translation.rs @@ -14,6 +14,7 @@ use std::rc::Rc; FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -38,6 +39,7 @@ impl S { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/copy_assign.rs b/tests/unit/out/unsafe/copy_assign.rs index 2b5b3bdd0c..92ebb0676e 100644 --- a/tests/unit/out/unsafe/copy_assign.rs +++ b/tests/unit/out/unsafe/copy_assign.rs @@ -8,7 +8,15 @@ 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, MovableUnsafe, Default)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + DefaultConstructibleUnsafe, + MovableUnsafe, + Default, +)] pub struct Partial { pub v: i32, pub keep: i32, @@ -64,6 +72,13 @@ impl NonConstAssign { return &mut (*(self as *mut NonConstAssign)); } } +impl DefaultConstructibleUnsafe for NonConstAssign { + unsafe fn default_constructor(&mut self) { + unsafe { + NonConstAssign::construct(&mut *self); + } + } +} impl Default for NonConstAssign { fn default() -> Self { unsafe { @@ -100,6 +115,13 @@ impl CopyAssignableUnsafe for RefQualified { return &mut (*(self as *mut RefQualified)); } } +impl DefaultConstructibleUnsafe for RefQualified { + unsafe fn default_constructor(&mut self) { + unsafe { + RefQualified::construct(&mut *self); + } + } +} impl Default for RefQualified { fn default() -> Self { unsafe { @@ -118,6 +140,7 @@ impl Default for RefQualified { FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, MoveConstructibleUnsafe, SwappableUnsafe, @@ -136,6 +159,7 @@ pub static mut copies_1: std::cell::LazyCell = std::cell::LazyCell::new(|| ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, MovableUnsafe, Default, @@ -172,6 +196,7 @@ impl Clone for CopyCounted { FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, MoveConstructibleUnsafe, SwappableUnsafe, @@ -196,6 +221,11 @@ pub struct HasCopyCounted { pub struct ExplicitOperatorCall { pub w: Vec, } +impl ExplicitOperatorCall { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.w).write(Vec::new()); + } +} impl CopyAssignableUnsafe for ExplicitOperatorCall { unsafe fn copy_assign(&mut self, o: *const ExplicitOperatorCall) -> *mut ExplicitOperatorCall { { @@ -204,6 +234,13 @@ impl CopyAssignableUnsafe for ExplicitOperatorCall { return &mut (*(self as *mut ExplicitOperatorCall)); } } +impl DefaultConstructibleUnsafe for ExplicitOperatorCall { + unsafe fn default_constructor(&mut self) { + unsafe { + ExplicitOperatorCall::construct_1(&mut *self); + } + } +} pub fn main() { unsafe { __cpp2rust_init_globals(); @@ -362,8 +399,10 @@ unsafe fn main_0() -> i32 { && ((hc1.arr[(1) as usize].v) == (6)) ); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_1)) == (0))); - let mut e1: ExplicitOperatorCall = ::default(); - let mut e2: ExplicitOperatorCall = ::default(); + let mut e1: ExplicitOperatorCall = ::zero_init(); + ExplicitOperatorCall::construct_1(&mut e1); + let mut e2: ExplicitOperatorCall = ::zero_init(); + ExplicitOperatorCall::construct_1(&mut e2); { let __a1 = 5; e1.w.push(__a1) diff --git a/tests/unit/out/unsafe/copy_ctor.rs b/tests/unit/out/unsafe/copy_ctor.rs index f5e2d0c867..0c8db0aa5d 100644 --- a/tests/unit/out/unsafe/copy_ctor.rs +++ b/tests/unit/out/unsafe/copy_ctor.rs @@ -14,6 +14,7 @@ pub static mut copies_0: std::cell::LazyCell = std::cell::LazyCell::new(|| ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, MovableUnsafe, Default, @@ -77,6 +78,13 @@ impl Clone for NonConst { } } } +impl DefaultConstructibleUnsafe for NonConst { + unsafe fn default_constructor(&mut self) { + unsafe { + NonConst::construct(&mut *self); + } + } +} impl Default for NonConst { fn default() -> Self { unsafe { @@ -95,6 +103,7 @@ impl Default for NonConst { ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, MovableUnsafe, Default, @@ -131,6 +140,7 @@ impl Clone for Ignored { FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, MoveConstructibleUnsafe, SwappableUnsafe, @@ -148,6 +158,7 @@ pub struct Holder { ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, @@ -185,6 +196,7 @@ impl Clone for Box_int_ { FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, @@ -202,6 +214,7 @@ pub struct Owner { ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, MovableUnsafe, Default, @@ -236,6 +249,11 @@ impl Clone for OutOfLine { pub struct Tracked { pub copied_from: i32, } +impl Tracked { + pub unsafe fn construct(&mut self) { + (&raw mut self.copied_from).write(0); + } +} impl CopyConstructibleUnsafe for Tracked { unsafe fn copy_constructor(&mut self, o: *const Tracked) { (&raw mut self.copied_from).write(0); @@ -257,6 +275,13 @@ impl Clone for Tracked { } } } +impl DefaultConstructibleUnsafe for Tracked { + unsafe fn default_constructor(&mut self) { + unsafe { + Tracked::construct(&mut *self); + } + } +} impl Default for Tracked { fn default() -> Self { unsafe { Tracked { copied_from: 0 } } @@ -380,12 +405,14 @@ unsafe fn main_0() -> i32 { NonConst::construct_2(&mut n2, { &cn }); assert!(((n1.mark) == (1))); assert!(((n2.mark) == (10))); - let mut t1: Tracked = ::default(); + let mut t1: Tracked = ::zero_init(); + Tracked::construct(&mut t1); let mut t2: Tracked = ::zero_init(); CopyConstructibleUnsafe::copy_constructor(&mut t2, { &t1 }); (unsafe { CopyAssignableUnsafe::copy_assign(&mut t2, &t1) }); assert!(((t1.copied_from) == (2))); - let ct: Tracked = ::default(); + let mut ct: Tracked = ::zero_init(); + Tracked::construct(&mut ct); let mut t3: Tracked = ::zero_init(); CopyConstructibleUnsafe::copy_constructor(&mut t3, { &ct }); (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 3addbd8a8d..473e3cf73c 100644 --- a/tests/unit/out/unsafe/copy_move_defaulted.rs +++ b/tests/unit/out/unsafe/copy_move_defaulted.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Inner { pub x: i32, @@ -20,6 +27,7 @@ pub struct Inner { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MoveConstructibleUnsafe, @@ -45,7 +53,14 @@ impl DestructibleUnsafe for Explicit { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Implicit { pub v: i32, @@ -61,6 +76,7 @@ pub struct Implicit { ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, SwappableUnsafe, @@ -96,6 +112,7 @@ impl MoveAssignableUnsafe for DefaultCopyUserMove { ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, SwappableUnsafe, Default, @@ -136,6 +153,7 @@ impl Clone for UserCopyDefaultMove { ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, SwappableUnsafe, Default, @@ -176,6 +194,21 @@ pub struct Owner { pub arr: [i32; 2], pub p: Option>, } +impl Owner { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.data).write(Vec::new()); + (&raw mut self.n).write(0_i32); + (&raw mut self.arr).write([0_i32; 2]); + (&raw mut self.p).write(None); + } +} +impl DefaultConstructibleUnsafe for Owner { + unsafe fn default_constructor(&mut self) { + unsafe { + Owner::construct_1(&mut *self); + } + } +} #[repr(C)] #[derive( Clone, @@ -192,12 +225,25 @@ pub struct Owner { pub struct Copyable { pub data: Vec, } +impl Copyable { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.data).write(Vec::new()); + } +} +impl DefaultConstructibleUnsafe for Copyable { + unsafe fn default_constructor(&mut self) { + unsafe { + Copyable::construct_1(&mut *self); + } + } +} #[repr(C)] #[derive( FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, SwappableUnsafe, Default, @@ -227,6 +273,11 @@ pub unsafe fn same_0(a: *const Explicit, b: *const Explicit) -> bool { pub struct SeesThis { pub self_: *mut SeesThis, } +impl SeesThis { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.self_).write(std::ptr::null_mut()); + } +} impl CopyAssignableUnsafe for SeesThis { unsafe fn copy_assign(&mut self, _a0: *const SeesThis) -> *mut SeesThis { self.self_ = (self as *mut SeesThis); @@ -239,6 +290,13 @@ impl MoveAssignableUnsafe for SeesThis { return &mut (*(self as *mut SeesThis)); } } +impl DefaultConstructibleUnsafe for SeesThis { + unsafe fn default_constructor(&mut self) { + unsafe { + SeesThis::construct_1(&mut *self); + } + } +} impl Default for SeesThis { fn default() -> Self { unsafe { @@ -255,12 +313,31 @@ pub struct HasSeesThis { pub s: SeesThis, pub v: Vec, } +impl HasSeesThis { + pub unsafe fn construct_1(&mut self) { + SeesThis::construct_1(&mut self.s); + (&raw mut self.v).write(Vec::new()); + } +} +impl DefaultConstructibleUnsafe for HasSeesThis { + unsafe fn default_constructor(&mut self) { + unsafe { + HasSeesThis::construct_1(&mut *self); + } + } +} #[repr(C)] #[derive(FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, SwappableUnsafe)] pub struct Counted_int_ { pub v: i32, pub moves: i32, } +impl Counted_int_ { + pub unsafe fn construct(&mut self) { + (&raw mut self.v).write(0_i32); + (&raw mut self.moves).write(0); + } +} impl MoveConstructibleUnsafe for Counted_int_ { unsafe fn move_constructor(&mut self, o: *mut Counted_int_) { (&raw mut self.v).write((*o).v); @@ -274,6 +351,13 @@ impl MoveAssignableUnsafe for Counted_int_ { return &mut (*(self as *mut Counted_int_)); } } +impl DefaultConstructibleUnsafe for Counted_int_ { + unsafe fn default_constructor(&mut self) { + unsafe { + Counted_int_::construct(&mut *self); + } + } +} impl Default for Counted_int_ { fn default() -> Self { unsafe { Counted_int_ { v: 0_i32, moves: 0 } } @@ -293,6 +377,19 @@ pub struct HasCounted { pub c: Counted_int_, pub w: Vec, } +impl HasCounted { + pub unsafe fn construct_1(&mut self) { + Counted_int_::construct(&mut self.c); + (&raw mut self.w).write(Vec::new()); + } +} +impl DefaultConstructibleUnsafe for HasCounted { + unsafe fn default_constructor(&mut self) { + unsafe { + HasCounted::construct_1(&mut *self); + } + } +} #[repr(C)] #[derive( VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, SwappableUnsafe, @@ -343,6 +440,13 @@ impl Clone for CtorSeesThis { } } } +impl DefaultConstructibleUnsafe for CtorSeesThis { + unsafe fn default_constructor(&mut self) { + unsafe { + CtorSeesThis::construct_2(&mut *self); + } + } +} impl Default for CtorSeesThis { fn default() -> Self { unsafe { @@ -376,6 +480,13 @@ impl HasCtorSeesThis { (&raw mut self.v).write(Vec::new()); } } +impl DefaultConstructibleUnsafe for HasCtorSeesThis { + unsafe fn default_constructor(&mut self) { + unsafe { + HasCtorSeesThis::construct_1(&mut *self); + } + } +} #[repr(C)] #[derive( Clone, @@ -397,6 +508,13 @@ impl InitsCtorSeesThis { CtorSeesThis::construct_1(&mut self.y, { 2 }); } } +impl DefaultConstructibleUnsafe for InitsCtorSeesThis { + unsafe fn default_constructor(&mut self) { + unsafe { + InitsCtorSeesThis::construct(&mut *self); + } + } +} impl Default for InitsCtorSeesThis { fn default() -> Self { unsafe { @@ -438,6 +556,13 @@ impl Clone for OutOfLineDefaulted { } } } +impl DefaultConstructibleUnsafe for OutOfLineDefaulted { + unsafe fn default_constructor(&mut self) { + unsafe { + OutOfLineDefaulted::construct(&mut *self); + } + } +} impl Default for OutOfLineDefaulted { fn default() -> Self { unsafe { @@ -457,6 +582,20 @@ pub struct OutOfLineAssign { pub v: i32, pub w: Vec, } +impl OutOfLineAssign { + pub unsafe fn construct_1(&mut self) { + SeesThis::construct_1(&mut self.s); + (&raw mut self.v).write(1); + (&raw mut self.w).write(Vec::new()); + } +} +impl DefaultConstructibleUnsafe for OutOfLineAssign { + unsafe fn default_constructor(&mut self) { + unsafe { + OutOfLineAssign::construct_1(&mut *self); + } + } +} impl Default for OutOfLineAssign { fn default() -> Self { unsafe { @@ -646,7 +785,8 @@ unsafe fn main_0() -> i32 { (((bufs[(1_usize)].n) == (3)) && ((bufs[(1_usize)].data.len()) == (3_usize))) && (bufs[(0_usize)].data.is_empty()) ); - let mut o1: Owner = ::default(); + let mut o1: Owner = ::zero_init(); + Owner::construct_1(&mut o1); { let __a1 = 5; o1.data.push(__a1) @@ -680,7 +820,8 @@ unsafe fn main_0() -> i32 { .map_or(::std::ptr::null_mut(), |v| v as *mut i32)) .is_null()) ); - let mut o3: Owner = ::default(); + let mut o3: Owner = ::zero_init(); + Owner::construct_1(&mut o3); (unsafe { MoveAssignableUnsafe::move_assign(&mut o3, &mut o2) }); assert!( ((((o3.n) == (5)) && ((o3.data[(0_usize)]) == (5))) && ((o3.arr[(0) as usize]) == (5))) @@ -706,7 +847,8 @@ unsafe fn main_0() -> i32 { MoveConstructibleUnsafe::move_constructor(&mut c3, { &mut c1 }); assert!(((c2.data.len()) == (2_usize)) && ((c3.data.len()) == (2_usize))); assert!(c1.data.is_empty()); - let mut c4: Copyable = ::default(); + let mut c4: Copyable = ::zero_init(); + Copyable::construct_1(&mut c4); (unsafe { MoveAssignableUnsafe::move_assign(&mut c4, &mut c3) }); assert!(((c4.data[(1_usize)]) == (2)) && (c3.data.is_empty())); let mut h1: Holder = ::zero_init(); @@ -759,18 +901,23 @@ unsafe fn main_0() -> i32 { .map_or(::std::ptr::null_mut(), |v| v as *mut i32)) .is_null()) ); - let mut t1: HasSeesThis = ::default(); - let mut t2: HasSeesThis = ::default(); - let mut t3: HasSeesThis = ::default(); + let mut t1: HasSeesThis = ::zero_init(); + HasSeesThis::construct_1(&mut t1); + let mut t2: HasSeesThis = ::zero_init(); + HasSeesThis::construct_1(&mut t2); + let mut t3: HasSeesThis = ::zero_init(); + HasSeesThis::construct_1(&mut t3); (unsafe { MoveAssignableUnsafe::move_assign(&mut t2, &mut t1) }); assert!(((t2.s.self_) == (&mut t2.s as *mut SeesThis))); (unsafe { CopyAssignableUnsafe::copy_assign(&mut t3, &t2) }); assert!(((t3.s.self_) == (&mut t3.s as *mut SeesThis))); - let mut k1: HasCounted = ::default(); + let mut k1: HasCounted = ::zero_init(); + HasCounted::construct_1(&mut k1); let mut k2: HasCounted = ::zero_init(); MoveConstructibleUnsafe::move_constructor(&mut k2, { &mut k1 }); assert!(((k2.c.moves) == (1))); - let mut k3: HasCounted = ::default(); + let mut k3: HasCounted = ::zero_init(); + HasCounted::construct_1(&mut k3); (unsafe { MoveAssignableUnsafe::move_assign(&mut k3, &mut k2) }); assert!(((k3.c.moves) == (2))); { @@ -819,9 +966,12 @@ unsafe fn main_0() -> i32 { let mut o2: OutOfLineDefaulted = ::zero_init(); CopyConstructibleUnsafe::copy_constructor(&mut o2, { &o1 }); assert!(((o2.v) == (2)) && ((o2.x.self_) == (&mut o2.x as *mut CtorSeesThis))); - let mut a1: OutOfLineAssign = ::default(); - let mut a2: OutOfLineAssign = ::default(); - let mut a3: OutOfLineAssign = ::default(); + let mut a1: OutOfLineAssign = ::zero_init(); + OutOfLineAssign::construct_1(&mut a1); + let mut a2: OutOfLineAssign = ::zero_init(); + OutOfLineAssign::construct_1(&mut a2); + let mut a3: OutOfLineAssign = ::zero_init(); + OutOfLineAssign::construct_1(&mut a3); a1.v = 3; { let __a1 = 4; diff --git a/tests/unit/out/unsafe/copy_move_deleted.rs b/tests/unit/out/unsafe/copy_move_deleted.rs index 7a8826e6c0..17d23ae3c2 100644 --- a/tests/unit/out/unsafe/copy_move_deleted.rs +++ b/tests/unit/out/unsafe/copy_move_deleted.rs @@ -8,7 +8,13 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, SwappableUnsafe, Default, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + DefaultConstructibleUnsafe, + SwappableUnsafe, + Default, )] #[cpp_from(i32, construct, value)] pub struct NoCopy { @@ -55,6 +61,13 @@ impl MoveAssignableUnsafe for PrivateCopy { return &mut (*(self as *mut PrivateCopy)); } } +impl DefaultConstructibleUnsafe for PrivateCopy { + unsafe fn default_constructor(&mut self) { + unsafe { + PrivateCopy::construct(&mut *self); + } + } +} impl Default for PrivateCopy { fn default() -> Self { unsafe { @@ -76,6 +89,13 @@ impl Immovable { (&raw mut self.v).write(0); } } +impl DefaultConstructibleUnsafe for Immovable { + unsafe fn default_constructor(&mut self) { + unsafe { + Immovable::construct(&mut *self); + } + } +} impl Default for Immovable { fn default() -> Self { unsafe { @@ -92,6 +112,7 @@ impl Default for Immovable { FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, SwappableUnsafe, Default, @@ -114,6 +135,18 @@ pub struct Container { pub struct VecHolder { pub items: Vec, } +impl VecHolder { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.items).write(Vec::new()); + } +} +impl DefaultConstructibleUnsafe for VecHolder { + unsafe fn default_constructor(&mut self) { + unsafe { + VecHolder::construct_1(&mut *self); + } + } +} pub unsafe fn bump_0(mut p: *mut NoCopy) { (*p).v.postfix_inc(); } @@ -161,7 +194,8 @@ unsafe fn main_0() -> i32 { let mut d: Container = ::zero_init(); MoveConstructibleUnsafe::move_constructor(&mut d, { &mut c }); assert!((((d.inner.v) == (6)) && ((d.tag) == (7))) && ((c.inner.v) == (0))); - let mut h: VecHolder = ::default(); + let mut h: VecHolder = ::zero_init(); + VecHolder::construct_1(&mut h); let mut h2: VecHolder = ::zero_init(); MoveConstructibleUnsafe::move_constructor(&mut h2, { &mut h }); assert!(((h2.items.len()) == (0_usize))); diff --git a/tests/unit/out/unsafe/default.rs b/tests/unit/out/unsafe/default.rs index 7a7e47d5e3..b9e5c44e47 100644 --- a/tests/unit/out/unsafe/default.rs +++ b/tests/unit/out/unsafe/default.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Pointers { pub x1: *mut i32, @@ -19,7 +26,14 @@ pub struct Pointers { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct SmallArrays { pub a: [i32; 32], @@ -28,7 +42,15 @@ pub struct SmallArrays { pub p: [Pointers; 2], } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, +)] 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 78d8544017..1ea5ec908a 100644 --- a/tests/unit/out/unsafe/default_function_arguments.rs +++ b/tests/unit/out/unsafe/default_function_arguments.rs @@ -25,6 +25,13 @@ impl Bar { (&raw mut self.v).write(v); } } +impl DefaultConstructibleUnsafe for Bar { + unsafe fn default_constructor(&mut self) { + unsafe { + Bar::construct(&mut *self, { 1 }); + } + } +} impl Default for Bar { fn default() -> Self { unsafe { @@ -64,7 +71,14 @@ pub unsafe fn first_9(r: *mut [i32; 3]) -> i32 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 34002d7223..8fd415c68a 100644 --- a/tests/unit/out/unsafe/default_in_statics.rs +++ b/tests/unit/out/unsafe/default_in_statics.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Inner { pub v: i32, @@ -16,7 +23,14 @@ pub struct Inner { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Outer { pub p1: *mut i32, @@ -30,7 +44,14 @@ pub struct Outer { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Foo { pub s1: *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 c2ab8fcfbf..2c06312414 100644 --- a/tests/unit/out/unsafe/delete_array_order.rs +++ b/tests/unit/out/unsafe/delete_array_order.rs @@ -12,6 +12,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, diff --git a/tests/unit/out/unsafe/destructor.rs b/tests/unit/out/unsafe/destructor.rs index 15b5d3977c..32602c9f17 100644 --- a/tests/unit/out/unsafe/destructor.rs +++ b/tests/unit/out/unsafe/destructor.rs @@ -13,6 +13,7 @@ pub static mut global_0: std::cell::LazyCell = std::cell::LazyCell::new(|| VaArg, FnPtrArg, ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, @@ -32,6 +33,7 @@ impl DestructibleUnsafe for S { FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, @@ -49,6 +51,7 @@ pub struct Defaulted { FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MoveConstructibleUnsafe, @@ -67,6 +70,7 @@ pub struct Middle { FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MoveConstructibleUnsafe, @@ -85,6 +89,7 @@ pub struct Outer { FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MoveConstructibleUnsafe, @@ -102,6 +107,7 @@ pub struct ArrayMember { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, @@ -122,6 +128,7 @@ impl DestructibleUnsafe for EmptyBody { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, @@ -144,6 +151,7 @@ impl DestructibleUnsafe for Templated_char_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, @@ -166,6 +174,7 @@ impl DestructibleUnsafe for Templated_int_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, @@ -189,6 +198,7 @@ pub static mut order_count_2: std::cell::LazyCell = std::cell::LazyCell::ne VaArg, FnPtrArg, ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, @@ -212,6 +222,7 @@ impl DestructibleUnsafe for Tagged { FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MoveConstructibleUnsafe, diff --git a/tests/unit/out/unsafe/destructor_params.rs b/tests/unit/out/unsafe/destructor_params.rs index 871d406641..81ee89854f 100644 --- a/tests/unit/out/unsafe/destructor_params.rs +++ b/tests/unit/out/unsafe/destructor_params.rs @@ -14,6 +14,7 @@ pub static mut last_1: std::cell::LazyCell = std::cell::LazyCell::new(|| un VaArg, FnPtrArg, ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, @@ -38,7 +39,14 @@ pub unsafe fn with_default_3(mut s: S) -> i32 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 e9957badc9..6904470158 100644 --- a/tests/unit/out/unsafe/destructor_temporaries.rs +++ b/tests/unit/out/unsafe/destructor_temporaries.rs @@ -14,6 +14,7 @@ pub static mut last_1: std::cell::LazyCell = std::cell::LazyCell::new(|| un VaArg, FnPtrArg, ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, @@ -41,6 +42,7 @@ impl DestructibleUnsafe for S { FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MoveConstructibleUnsafe, diff --git a/tests/unit/out/unsafe/doubly_linked_list.rs b/tests/unit/out/unsafe/doubly_linked_list.rs index 49791e76f9..9c1979342e 100644 --- a/tests/unit/out/unsafe/doubly_linked_list.rs +++ b/tests/unit/out/unsafe/doubly_linked_list.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Node { pub val: i32, diff --git a/tests/unit/out/unsafe/enum_default_in_static.rs b/tests/unit/out/unsafe/enum_default_in_static.rs index 5cad8e0ea3..6fec1a66b5 100644 --- a/tests/unit/out/unsafe/enum_default_in_static.rs +++ b/tests/unit/out/unsafe/enum_default_in_static.rs @@ -12,7 +12,14 @@ pub const Mode_MODE_ONE: Mode = 1; pub const Mode_MODE_TWO: Mode = 2; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Config { pub count: i32, diff --git a/tests/unit/out/unsafe/enum_int_interop.rs b/tests/unit/out/unsafe/enum_int_interop.rs index 465cf425c9..4897a577ae 100644 --- a/tests/unit/out/unsafe/enum_int_interop.rs +++ b/tests/unit/out/unsafe/enum_int_interop.rs @@ -21,7 +21,14 @@ pub const Tag_TAG_ONE: Tag = 1; pub const Tag_TAG_TWO: Tag = 2; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Entry { pub name: *const libc::c_char, diff --git a/tests/unit/out/unsafe/enum_int_interop_c.rs b/tests/unit/out/unsafe/enum_int_interop_c.rs index 196efb71de..de3dfd7a2b 100644 --- a/tests/unit/out/unsafe/enum_int_interop_c.rs +++ b/tests/unit/out/unsafe/enum_int_interop_c.rs @@ -21,7 +21,14 @@ 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, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Entry { pub name: *const libc::c_char, diff --git a/tests/unit/out/unsafe/enum_underlying_type.rs b/tests/unit/out/unsafe/enum_underlying_type.rs index df814b3919..2a11401e30 100644 --- a/tests/unit/out/unsafe/enum_underlying_type.rs +++ b/tests/unit/out/unsafe/enum_underlying_type.rs @@ -30,6 +30,18 @@ pub type Empty = bool; pub struct HoldsEmpty { pub e: Empty, } +impl HoldsEmpty { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.e).write(false); + } +} +impl DefaultConstructibleUnsafe for HoldsEmpty { + unsafe fn default_constructor(&mut self) { + unsafe { + HoldsEmpty::construct_1(&mut *self); + } + } +} impl Default for HoldsEmpty { fn default() -> Self { unsafe { HoldsEmpty { e: false } } @@ -68,7 +80,8 @@ unsafe fn main_0() -> i32 { let mut sc: Scoped = Scoped_NEG; assert!(((sc as i32) == (-2_i32))); assert!((((Scoped_POS as i8) as i32) == (2))); - let mut he: HoldsEmpty = ::default(); + let mut he: HoldsEmpty = ::zero_init(); + HoldsEmpty::construct_1(&mut he); assert!(!(he.e)); let mut ev: Empty = false; assert!(((ev as i32) == (he.e as i32))); diff --git a/tests/unit/out/unsafe/exprs.rs b/tests/unit/out/unsafe/exprs.rs index 587c772493..62f542c41e 100644 --- a/tests/unit/out/unsafe/exprs.rs +++ b/tests/unit/out/unsafe/exprs.rs @@ -8,14 +8,28 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct X { pub x: i32, } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Y { pub x: X, diff --git a/tests/unit/out/unsafe/fft.rs b/tests/unit/out/unsafe/fft.rs index 4b58094771..a045cac687 100644 --- a/tests/unit/out/unsafe/fft.rs +++ b/tests/unit/out/unsafe/fft.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Complex { pub re: f64, diff --git a/tests/unit/out/unsafe/field_aliasing.rs b/tests/unit/out/unsafe/field_aliasing.rs index ae45a46254..434a131865 100644 --- a/tests/unit/out/unsafe/field_aliasing.rs +++ b/tests/unit/out/unsafe/field_aliasing.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct In { pub x: i32, @@ -16,7 +23,14 @@ pub struct In { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct S { pub in_: In, @@ -26,7 +40,14 @@ pub struct S { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Node { pub x: i32, diff --git a/tests/unit/out/unsafe/field_array_elem_ptr.rs b/tests/unit/out/unsafe/field_array_elem_ptr.rs index 9d94aafcd0..e4030c8980 100644 --- a/tests/unit/out/unsafe/field_array_elem_ptr.rs +++ b/tests/unit/out/unsafe/field_array_elem_ptr.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Point { pub x: i32, @@ -16,7 +23,14 @@ pub struct Point { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Shape { pub id: i32, diff --git a/tests/unit/out/unsafe/field_method_receiver.rs b/tests/unit/out/unsafe/field_method_receiver.rs index b09f1527c6..51e5d5c637 100644 --- a/tests/unit/out/unsafe/field_method_receiver.rs +++ b/tests/unit/out/unsafe/field_method_receiver.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Counter { pub n: i32, @@ -54,6 +61,19 @@ impl S { Counter::add(&mut self.c, _k) }); } + pub unsafe fn construct_1(&mut self) { + (&raw mut self.tag).write(0_i32); + (&raw mut self.c).write(::default()); + (&raw mut self.arr).write([::default(); 2]); + (&raw mut self.v).write(Vec::new()); + } +} +impl DefaultConstructibleUnsafe for S { + unsafe fn default_constructor(&mut self) { + unsafe { + S::construct_1(&mut *self); + } + } } pub unsafe fn run_0(mut o: *mut S) { (unsafe { Counter::add(&mut (*o).c, 2) }); diff --git a/tests/unit/out/unsafe/field_pointers.rs b/tests/unit/out/unsafe/field_pointers.rs index df6ff0c4d5..dea879cad2 100644 --- a/tests/unit/out/unsafe/field_pointers.rs +++ b/tests/unit/out/unsafe/field_pointers.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Inner { pub a: i32, @@ -16,7 +23,14 @@ pub struct Inner { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Header { pub tag: i32, @@ -56,6 +70,21 @@ impl Outer { self.v.push(__a1) }; } + pub unsafe fn construct_1(&mut self) { + (&raw mut self.x).write(0_i32); + (&raw mut self.inner).write(::default()); + (&raw mut self.items).write([::default(); 3]); + (&raw mut self.v).write(Vec::new()); + (&raw mut self.cursor).write(std::ptr::null_mut()); + (&raw mut self.buf).write([0_i32; 4]); + } +} +impl DefaultConstructibleUnsafe for Outer { + unsafe fn default_constructor(&mut self) { + unsafe { + Outer::construct_1(&mut *self); + } + } } pub unsafe fn set_0(mut p: *mut i32, mut value: i32) { (*p) = value; diff --git a/tests/unit/out/unsafe/field_pointers_malloced_struct.rs b/tests/unit/out/unsafe/field_pointers_malloced_struct.rs index 599048e691..ed65dc69b6 100644 --- a/tests/unit/out/unsafe/field_pointers_malloced_struct.rs +++ b/tests/unit/out/unsafe/field_pointers_malloced_struct.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct S { pub a: i32, diff --git a/tests/unit/out/unsafe/field_reinterpret_write_through.rs b/tests/unit/out/unsafe/field_reinterpret_write_through.rs index 322d84a1ac..522a2b0d16 100644 --- a/tests/unit/out/unsafe/field_reinterpret_write_through.rs +++ b/tests/unit/out/unsafe/field_reinterpret_write_through.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct In { pub a: i16, @@ -16,7 +23,14 @@ pub struct In { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct S { pub x: i32, diff --git a/tests/unit/out/unsafe/find.rs b/tests/unit/out/unsafe/find.rs index d6a9669f68..2c3892acf0 100644 --- a/tests/unit/out/unsafe/find.rs +++ b/tests/unit/out/unsafe/find.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 c8d27d5f2d..28cecee3b7 100644 --- a/tests/unit/out/unsafe/first_field_ptr_covers_struct.rs +++ b/tests/unit/out/unsafe/first_field_ptr_covers_struct.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct In { pub a: i16, @@ -16,7 +23,14 @@ pub struct In { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct S { pub x: i32, diff --git a/tests/unit/out/unsafe/first_member_downcast.rs b/tests/unit/out/unsafe/first_member_downcast.rs index 10998b103e..709b2595f2 100644 --- a/tests/unit/out/unsafe/first_member_downcast.rs +++ b/tests/unit/out/unsafe/first_member_downcast.rs @@ -8,14 +8,28 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct base { pub kind: i32, } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct derived { pub head: base, diff --git a/tests/unit/out/unsafe/flex_array_member_incomplete.rs b/tests/unit/out/unsafe/flex_array_member_incomplete.rs index bd098b41b0..1be4d73e24 100644 --- a/tests/unit/out/unsafe/flex_array_member_incomplete.rs +++ b/tests/unit/out/unsafe/flex_array_member_incomplete.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(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, +)] 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 ab6c9a3511..ec00e209ef 100644 --- a/tests/unit/out/unsafe/flex_array_member_sibling_write.rs +++ b/tests/unit/out/unsafe/flex_array_member_sibling_write.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct S { pub n: i32, @@ -16,7 +23,14 @@ pub struct S { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct E { pub id: i32, @@ -24,7 +38,14 @@ pub struct E { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct T { pub n: i32, diff --git a/tests/unit/out/unsafe/fn_ptr.rs b/tests/unit/out/unsafe/fn_ptr.rs index edc159f955..3be14a6a1b 100644 --- a/tests/unit/out/unsafe/fn_ptr.rs +++ b/tests/unit/out/unsafe/fn_ptr.rs @@ -39,6 +39,7 @@ pub unsafe fn identity_hash_6(mut v: bool) -> usize { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/fn_ptr_cast.rs b/tests/unit/out/unsafe/fn_ptr_cast.rs index 825705351a..0331629544 100644 --- a/tests/unit/out/unsafe/fn_ptr_cast.rs +++ b/tests/unit/out/unsafe/fn_ptr_cast.rs @@ -31,7 +31,14 @@ pub unsafe fn test_double_cast_2() { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 df7044da69..b6aa39b6ea 100644 --- a/tests/unit/out/unsafe/fn_ptr_stable_sort.rs +++ b/tests/unit/out/unsafe/fn_ptr_stable_sort.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Item { pub key: i32, diff --git a/tests/unit/out/unsafe/fn_ptr_struct.rs b/tests/unit/out/unsafe/fn_ptr_struct.rs index 5caba87dc5..8f2dcd3eab 100644 --- a/tests/unit/out/unsafe/fn_ptr_struct.rs +++ b/tests/unit/out/unsafe/fn_ptr_struct.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Handler { pub tag: i32, @@ -22,7 +29,14 @@ pub unsafe fn negate_1(mut x: i32) -> i32 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct S {} impl S { @@ -37,7 +51,14 @@ impl S { } } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, Default)] +#[derive( + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + DefaultConstructibleUnsafe, + 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 1d944e9e7a..07bb8d7542 100644 --- a/tests/unit/out/unsafe/fn_ptr_typedef_cast.rs +++ b/tests/unit/out/unsafe/fn_ptr_typedef_cast.rs @@ -20,7 +20,14 @@ pub unsafe fn via_size_t_return_3(mut b: u64) -> usize { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct pair { pub a: i32, diff --git a/tests/unit/out/unsafe/fn_ptr_vtable.rs b/tests/unit/out/unsafe/fn_ptr_vtable.rs index 7cf2c23e14..c258ffbf74 100644 --- a/tests/unit/out/unsafe/fn_ptr_vtable.rs +++ b/tests/unit/out/unsafe/fn_ptr_vtable.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Vtable { pub create: Option *mut ::libc::c_void>, diff --git a/tests/unit/out/unsafe/fn_ref.rs b/tests/unit/out/unsafe/fn_ref.rs index b4d5eef237..01c8fbec66 100644 --- a/tests/unit/out/unsafe/fn_ref.rs +++ b/tests/unit/out/unsafe/fn_ref.rs @@ -23,7 +23,14 @@ pub unsafe fn call_forwarded_4(f: Option i32>, mut x: i32) -> } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 6d98c6f0fb..89e07cb38c 100644 --- a/tests/unit/out/unsafe/for_body_destructor.rs +++ b/tests/unit/out/unsafe/for_body_destructor.rs @@ -12,6 +12,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, diff --git a/tests/unit/out/unsafe/foreach_disjoint_field_borrow.rs b/tests/unit/out/unsafe/foreach_disjoint_field_borrow.rs index eee6559f8c..f91c11c753 100644 --- a/tests/unit/out/unsafe/foreach_disjoint_field_borrow.rs +++ b/tests/unit/out/unsafe/foreach_disjoint_field_borrow.rs @@ -23,6 +23,19 @@ pub struct S { pub v: Vec, pub a: i32, } +impl S { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.v).write(Vec::new()); + (&raw mut self.a).write(0_i32); + } +} +impl DefaultConstructibleUnsafe for S { + unsafe fn default_constructor(&mut self) { + unsafe { + S::construct_1(&mut *self); + } + } +} pub fn main() { unsafe { __cpp2rust_init_globals(); @@ -30,7 +43,8 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut s: S = ::default(); + let mut s: S = ::zero_init(); + S::construct_1(&mut s); { let __a1 = 1; s.v.push(__a1) diff --git a/tests/unit/out/unsafe/forward_basic.rs b/tests/unit/out/unsafe/forward_basic.rs index 3be3338cf7..07a4bf7a7a 100644 --- a/tests/unit/out/unsafe/forward_basic.rs +++ b/tests/unit/out/unsafe/forward_basic.rs @@ -16,6 +16,7 @@ pub const Overload_kRvalueOverload: Overload = 2; ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -82,6 +83,7 @@ impl Holder { ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, diff --git a/tests/unit/out/unsafe/forward_decltype.rs b/tests/unit/out/unsafe/forward_decltype.rs index 4a72585444..ee8260cd19 100644 --- a/tests/unit/out/unsafe/forward_decltype.rs +++ b/tests/unit/out/unsafe/forward_decltype.rs @@ -16,6 +16,7 @@ pub const Overload_kRvalueOverload: Overload = 2; ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, diff --git a/tests/unit/out/unsafe/forward_explicit.rs b/tests/unit/out/unsafe/forward_explicit.rs index 819ff4cbb9..5a80d06188 100644 --- a/tests/unit/out/unsafe/forward_explicit.rs +++ b/tests/unit/out/unsafe/forward_explicit.rs @@ -18,6 +18,7 @@ pub const Overload_kIntRvalueOverload: Overload = 4; ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, diff --git a/tests/unit/out/unsafe/forward_pack.rs b/tests/unit/out/unsafe/forward_pack.rs index e8bd03f9a9..850bdd73b1 100644 --- a/tests/unit/out/unsafe/forward_pack.rs +++ b/tests/unit/out/unsafe/forward_pack.rs @@ -18,6 +18,7 @@ pub const Overload_kIntRvalueOverload: Overload = 4; ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -119,6 +120,7 @@ impl Pair { FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, diff --git a/tests/unit/out/unsafe/friend.rs b/tests/unit/out/unsafe/friend.rs index 9640b96b2a..4e47cb64f0 100644 --- a/tests/unit/out/unsafe/friend.rs +++ b/tests/unit/out/unsafe/friend.rs @@ -20,7 +20,14 @@ pub unsafe fn scaled_3(v: *const V, mut k: f64) -> f64 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct V { pub x: i32, @@ -36,7 +43,14 @@ pub unsafe fn get_4(w: *const W_int_) -> i32 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct W_int_ { pub x: i32, @@ -46,14 +60,28 @@ pub unsafe fn get_5(w: *const W_long_) -> i64 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct W_long_ { pub x: i64, } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 f4a7056241..d2384a63d3 100644 --- a/tests/unit/out/unsafe/function_overloading.rs +++ b/tests/unit/out/unsafe/function_overloading.rs @@ -23,7 +23,14 @@ pub unsafe fn bar_4(x: *mut i32) -> i32 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Foo {} impl Foo { diff --git a/tests/unit/out/unsafe/global_call_temporaries.rs b/tests/unit/out/unsafe/global_call_temporaries.rs index b5136c2e10..3908155dfa 100644 --- a/tests/unit/out/unsafe/global_call_temporaries.rs +++ b/tests/unit/out/unsafe/global_call_temporaries.rs @@ -78,7 +78,14 @@ pub static mut call_assigned_6: std::cell::LazyCell = std::cell::LazyCell:: }); #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 19ef3b0524..10d4ea7348 100644 --- a/tests/unit/out/unsafe/global_init_side_effect.rs +++ b/tests/unit/out/unsafe/global_init_side_effect.rs @@ -15,6 +15,7 @@ pub static mut total_0: std::cell::LazyCell = std::cell::LazyCell::new(|| u FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/global_non_const_init.rs b/tests/unit/out/unsafe/global_non_const_init.rs index 7a1fc91ea3..2c4f905ec9 100644 --- a/tests/unit/out/unsafe/global_non_const_init.rs +++ b/tests/unit/out/unsafe/global_non_const_init.rs @@ -40,6 +40,13 @@ impl Ctor { (&raw mut self.v).write(x); } } +impl DefaultConstructibleUnsafe for Ctor { + unsafe fn default_constructor(&mut self) { + unsafe { + Ctor::construct_1(&mut *self); + } + } +} impl Default for Ctor { fn default() -> Self { unsafe { @@ -82,7 +89,14 @@ pub static mut inline_member_11: std::cell::LazyCell = std::cell::LazyCell }); #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Holder {} pub static mut member_10: std::cell::LazyCell = @@ -113,6 +127,13 @@ impl Singleton { return &mut (*std::cell::LazyCell::force_mut(&mut *&raw mut s_15)); } } +impl DefaultConstructibleUnsafe for Singleton { + unsafe fn default_constructor(&mut self) { + unsafe { + Singleton::construct(&mut *self); + } + } +} impl Default for Singleton { fn default() -> Self { unsafe { diff --git a/tests/unit/out/unsafe/global_pointers.rs b/tests/unit/out/unsafe/global_pointers.rs index 8eecf5ac09..636dde3124 100644 --- a/tests/unit/out/unsafe/global_pointers.rs +++ b/tests/unit/out/unsafe/global_pointers.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Entry { pub name: *const libc::c_char, diff --git a/tests/unit/out/unsafe/global_without_initializer.rs b/tests/unit/out/unsafe/global_without_initializer.rs index 074b02c2c8..95e8d82200 100644 --- a/tests/unit/out/unsafe/global_without_initializer.rs +++ b/tests/unit/out/unsafe/global_without_initializer.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 c098ed98ac..de51ef653c 100644 --- a/tests/unit/out/unsafe/goto_aggregate_default.rs +++ b/tests/unit/out/unsafe/goto_aggregate_default.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Point { pub x: i32, diff --git a/tests/unit/out/unsafe/goto_cleanup.rs b/tests/unit/out/unsafe/goto_cleanup.rs index b37692ba80..7e0fea174a 100644 --- a/tests/unit/out/unsafe/goto_cleanup.rs +++ b/tests/unit/out/unsafe/goto_cleanup.rs @@ -78,7 +78,14 @@ pub unsafe fn from_switch_2(mut n: i32) -> i32 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 aecc080728..3aecc9f83d 100644 --- a/tests/unit/out/unsafe/huffman.rs +++ b/tests/unit/out/unsafe/huffman.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct MinHeapNode { pub data: libc::c_char, @@ -244,6 +251,20 @@ impl MinHeap { } } } + pub unsafe fn construct_1(&mut self) { + (&raw mut self.size).write(0_i32); + (&raw mut self.capacity).write(0_i32); + (&raw mut self.arr).write(None); + (&raw mut self.next).write(0_i32); + (&raw mut self.alloc).write(None); + } +} +impl DefaultConstructibleUnsafe for MinHeap { + unsafe fn default_constructor(&mut self) { + unsafe { + MinHeap::construct_1(&mut *self); + } + } } pub unsafe fn AllocMinHeap_1(mut capacity: i32) -> Option> { let mut minHeap: Option> = Some(Box::new(MinHeap { 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 02cd1fd8ca..d5f55f24d6 100644 --- a/tests/unit/out/unsafe/immutable-deref-on-func-call.rs +++ b/tests/unit/out/unsafe/immutable-deref-on-func-call.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 077bb0b899..cd7b648f4c 100644 --- a/tests/unit/out/unsafe/implicit_autoref.rs +++ b/tests/unit/out/unsafe/implicit_autoref.rs @@ -22,6 +22,18 @@ use std::rc::Rc; pub struct Holder { pub v: Vec, } +impl Holder { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.v).write(Vec::new()); + } +} +impl DefaultConstructibleUnsafe for Holder { + unsafe fn default_constructor(&mut self) { + unsafe { + Holder::construct_1(&mut *self); + } + } +} pub unsafe fn write_through_0(mut p: *mut i32) { (*p) = 42; } @@ -44,7 +56,8 @@ unsafe fn main_0() -> i32 { let mut p: *mut Vec = (&mut v as *mut Vec); let mut a: i32 = (&mut (*p))[(0_usize)]; (&mut (*p))[(1_usize)] = 30; - let mut h: Holder = ::default(); + let mut h: Holder = ::zero_init(); + Holder::construct_1(&mut h); { let __a1 = 40; h.v.push(__a1) diff --git a/tests/unit/out/unsafe/in_class_field_initializer.rs b/tests/unit/out/unsafe/in_class_field_initializer.rs index 4372b9097c..55b71e7da9 100644 --- a/tests/unit/out/unsafe/in_class_field_initializer.rs +++ b/tests/unit/out/unsafe/in_class_field_initializer.rs @@ -12,6 +12,19 @@ pub struct Inner { pub x: i32, pub y: i32, } +impl Inner { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.x).write(3); + (&raw mut self.y).write(4); + } +} +impl DefaultConstructibleUnsafe for Inner { + unsafe fn default_constructor(&mut self) { + unsafe { + Inner::construct_1(&mut *self); + } + } +} impl Default for Inner { fn default() -> Self { unsafe { Inner { x: 3, y: 4 } } @@ -25,6 +38,21 @@ pub struct S { pub c: Inner, pub d: Inner, } +impl S { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.a).write(1); + (&raw mut self.b).write((2 as libc::c_char)); + (&raw mut self.c).write(::default()); + Inner::construct_1(&mut self.d); + } +} +impl DefaultConstructibleUnsafe for S { + unsafe fn default_constructor(&mut self) { + unsafe { + S::construct_1(&mut *self); + } + } +} impl Default for S { fn default() -> Self { unsafe { @@ -38,7 +66,15 @@ impl Default for S { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, +)] pub struct Boxed_int_ { pub v: i32, pub tag: i32, @@ -61,7 +97,8 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut s: S = ::default(); + let mut s: S = ::zero_init(); + S::construct_1(&mut s); assert!(((s.a) == (1))); assert!(((s.b as i32) == (2))); assert!(((s.c.x) == (3))); diff --git a/tests/unit/out/unsafe/init.rs b/tests/unit/out/unsafe/init.rs index dff1966872..9479718576 100644 --- a/tests/unit/out/unsafe/init.rs +++ b/tests/unit/out/unsafe/init.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 c77ac10955..60fc824a98 100644 --- a/tests/unit/out/unsafe/init_list.rs +++ b/tests/unit/out/unsafe/init_list.rs @@ -9,7 +9,14 @@ use std::rc::Rc; pub unsafe fn f_0(mut list: Vec) {} #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Pair { pub a: i32, @@ -25,6 +32,16 @@ impl Holder { self.p = (*o); return &mut (*(self as *mut Holder)); } + pub unsafe fn construct_1(&mut self) { + (&raw mut self.p).write(Pair { a: 0, b: 0 }); + } +} +impl DefaultConstructibleUnsafe for Holder { + unsafe fn default_constructor(&mut self) { + unsafe { + Holder::construct_1(&mut *self); + } + } } impl Default for Holder { fn default() -> Self { @@ -43,6 +60,18 @@ pub unsafe fn sum_1(p: *const Pair) -> i32 { pub struct Seven { pub v: i32, } +impl Seven { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.v).write(7); + } +} +impl DefaultConstructibleUnsafe for Seven { + unsafe fn default_constructor(&mut self) { + unsafe { + Seven::construct_1(&mut *self); + } + } +} impl Default for Seven { fn default() -> Self { unsafe { Seven { v: 7 } } @@ -63,7 +92,8 @@ unsafe fn main_0() -> i32 { let mut vec_: Vec = Vec::from([1, 2, 3]); (unsafe { f_0(Vec::from([1, 2, 3, 4])) }); let mut p: Pair = Pair { a: 1, b: 2 }; - let mut h: Holder = ::default(); + let mut h: Holder = ::zero_init(); + Holder::construct_1(&mut h); (unsafe { Holder::operator_assign_1(&mut h, &mut p) }); assert!(((h.p.a) == (1)) && ((h.p.b) == (2))); assert!(((unsafe { sum_1(&p,) }) == (3))); diff --git a/tests/unit/out/unsafe/inline_container_fields.rs b/tests/unit/out/unsafe/inline_container_fields.rs index a574455fe6..49f771aa9a 100644 --- a/tests/unit/out/unsafe/inline_container_fields.rs +++ b/tests/unit/out/unsafe/inline_container_fields.rs @@ -24,6 +24,20 @@ pub struct Elem { pub hist: [i32; 4], pub coeffs: Vec, } +impl Elem { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.id).write(0_i32); + (&raw mut self.hist).write([0_i32; 4]); + (&raw mut self.coeffs).write(Vec::new()); + } +} +impl DefaultConstructibleUnsafe for Elem { + unsafe fn default_constructor(&mut self) { + unsafe { + Elem::construct_1(&mut *self); + } + } +} #[repr(C)] #[derive( Clone, @@ -43,6 +57,22 @@ pub struct State { pub elems: Vec, pub rows: Vec>, } +impl State { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.count).write(0_i32); + (&raw mut self.grid).write([[0_i32; 3]; 2]); + (&raw mut self.arr).write(std::array::from_fn::<_, 3, _>(|_| 0_i32)); + (&raw mut self.elems).write(Vec::new()); + (&raw mut self.rows).write(Vec::new()); + } +} +impl DefaultConstructibleUnsafe for State { + unsafe fn default_constructor(&mut self) { + unsafe { + State::construct_1(&mut *self); + } + } +} impl Default for State { fn default() -> Self { unsafe { @@ -116,6 +146,11 @@ pub static mut move_assigns_5: std::cell::LazyCell = std::cell::LazyCell::n pub struct Counted { pub v: i32, } +impl Counted { + pub unsafe fn construct(&mut self) { + (&raw mut self.v).write(0); + } +} impl CopyConstructibleUnsafe for Counted { unsafe fn copy_constructor(&mut self, o: *const Counted) { (&raw mut self.v).write((*o).v); @@ -153,6 +188,13 @@ impl Clone for Counted { } } } +impl DefaultConstructibleUnsafe for Counted { + unsafe fn default_constructor(&mut self) { + unsafe { + Counted::construct(&mut *self); + } + } +} impl Default for Counted { fn default() -> Self { unsafe { Counted { v: 0 } } diff --git a/tests/unit/out/unsafe/kruskal.rs b/tests/unit/out/unsafe/kruskal.rs index 4b3e877125..eef2db6b66 100644 --- a/tests/unit/out/unsafe/kruskal.rs +++ b/tests/unit/out/unsafe/kruskal.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Edge { pub u: i32, @@ -284,6 +291,18 @@ impl DisjointSet { + (1)); } } + pub unsafe fn construct_1(&mut self) { + (&raw mut self.rank).write(None); + (&raw mut self.parent).write(None); + (&raw mut self.n).write(0_i32); + } +} +impl DefaultConstructibleUnsafe for DisjointSet { + unsafe fn default_constructor(&mut self) { + unsafe { + DisjointSet::construct_1(&mut *self); + } + } } #[repr(C)] #[derive( @@ -300,6 +319,20 @@ pub struct Graph { pub V: i32, pub E: i32, } +impl Graph { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.edges).write(None); + (&raw mut self.V).write(0_i32); + (&raw mut self.E).write(0_i32); + } +} +impl DefaultConstructibleUnsafe for Graph { + unsafe fn default_constructor(&mut self) { + unsafe { + Graph::construct_1(&mut *self); + } + } +} pub unsafe fn MSTKruskal_2(graph: *mut Graph) -> f64 { (unsafe { let _arr: *mut Option> = &mut (*graph).edges; diff --git a/tests/unit/out/unsafe/lambda_as_field.rs b/tests/unit/out/unsafe/lambda_as_field.rs index a272565864..249f877ef8 100644 --- a/tests/unit/out/unsafe/lambda_as_field.rs +++ b/tests/unit/out/unsafe/lambda_as_field.rs @@ -12,6 +12,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, @@ -37,7 +38,15 @@ impl Default for Guard__lambda_at_lambda_as_field_cpp_34_13__ { } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CopyableUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + CopyableUnsafe, + Default, +)] pub struct Guard__lambda_at_lambda_as_field_cpp_45_13__ { pub f: FnPtr, } @@ -47,7 +56,14 @@ impl DestructibleUnsafe for Guard__lambda_at_lambda_as_field_cpp_45_13__ { } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, +)] pub struct Holder__lambda_at_lambda_as_field_cpp_39_12__ { pub f: FnPtr i32>, pub calls: i32, @@ -73,7 +89,15 @@ impl Default for Holder__lambda_at_lambda_as_field_cpp_39_12__ { } } #[repr(C)] -#[derive(Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default)] +#[derive( + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, +)] pub struct Holder__lambda_at_lambda_as_field_cpp_51_12__ { pub f: FnPtr i32>, pub calls: i32, @@ -85,7 +109,13 @@ impl Holder__lambda_at_lambda_as_field_cpp_51_12__ { } } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe)] +#[derive( + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + DefaultConstructibleUnsafe, +)] #[cpp_from(FnPtr i32 > , construct, value)] pub struct Moving__lambda_at_lambda_as_field_cpp_64_12__ { pub f: FnPtr i32>, diff --git a/tests/unit/out/unsafe/lambda_capture_copy_ctor.rs b/tests/unit/out/unsafe/lambda_capture_copy_ctor.rs index e12c4a9d84..1241bd62c7 100644 --- a/tests/unit/out/unsafe/lambda_capture_copy_ctor.rs +++ b/tests/unit/out/unsafe/lambda_capture_copy_ctor.rs @@ -47,6 +47,13 @@ impl Clone for Counted { } } } +impl DefaultConstructibleUnsafe for Counted { + unsafe fn default_constructor(&mut self) { + unsafe { + Counted::construct(&mut *self); + } + } +} impl Default for Counted { fn default() -> Self { unsafe { @@ -92,6 +99,13 @@ impl Clone for Dropped { } } } +impl DefaultConstructibleUnsafe for Dropped { + unsafe fn default_constructor(&mut self) { + unsafe { + Dropped::construct(&mut *self); + } + } +} impl Default for Dropped { fn default() -> Self { unsafe { diff --git a/tests/unit/out/unsafe/lambda_capture_ref.rs b/tests/unit/out/unsafe/lambda_capture_ref.rs index 273bccdd6d..31ee27bc49 100644 --- a/tests/unit/out/unsafe/lambda_capture_ref.rs +++ b/tests/unit/out/unsafe/lambda_capture_ref.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct S { pub x: i32, diff --git a/tests/unit/out/unsafe/lambda_capture_star_this.rs b/tests/unit/out/unsafe/lambda_capture_star_this.rs index be3bf1f6e9..b2c0c15523 100644 --- a/tests/unit/out/unsafe/lambda_capture_star_this.rs +++ b/tests/unit/out/unsafe/lambda_capture_star_this.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 ee019462ca..ee942180d8 100644 --- a/tests/unit/out/unsafe/lambda_capture_this.rs +++ b/tests/unit/out/unsafe/lambda_capture_this.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct S { pub n: i32, diff --git a/tests/unit/out/unsafe/lambda_capture_value.rs b/tests/unit/out/unsafe/lambda_capture_value.rs index 1d721ec289..2b545652de 100644 --- a/tests/unit/out/unsafe/lambda_capture_value.rs +++ b/tests/unit/out/unsafe/lambda_capture_value.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct S { pub x: i32, diff --git a/tests/unit/out/unsafe/lambda_decltype_type.rs b/tests/unit/out/unsafe/lambda_decltype_type.rs index 16f90a62a7..60687a3f34 100644 --- a/tests/unit/out/unsafe/lambda_decltype_type.rs +++ b/tests/unit/out/unsafe/lambda_decltype_type.rs @@ -28,6 +28,24 @@ impl Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { self.items[(i) as usize] = v; self.size.postfix_inc(); } + pub unsafe fn construct_1(&mut self) { + (&raw mut self.items).write([0_i32; 4]); + (&raw mut self.size).write(0); + (&raw mut self.cmp).write(FnPtr:: bool>::new( + |mut a: i32, mut b: i32| -> bool { + unsafe { + return ((a) > (b)); + } + }, + )); + } +} +impl DefaultConstructibleUnsafe for Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { + unsafe fn default_constructor(&mut self) { + unsafe { + Sorted__lambda_at_lambda_decltype_type_cpp_22_18__::construct_1(&mut *self); + } + } } impl Default for Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { fn default() -> Self { @@ -66,6 +84,24 @@ impl Sorted__lambda_at_lambda_decltype_type_cpp_19_23__ { self.items[(i) as usize] = v; self.size.postfix_inc(); } + pub unsafe fn construct_1(&mut self) { + (&raw mut self.items).write([0_i32; 4]); + (&raw mut self.size).write(0); + (&raw mut self.cmp).write(FnPtr:: bool>::new( + |mut a: i32, mut b: i32| -> bool { + unsafe { + return ((a) < (b)); + } + }, + )); + } +} +impl DefaultConstructibleUnsafe for Sorted__lambda_at_lambda_decltype_type_cpp_19_23__ { + unsafe fn default_constructor(&mut self) { + unsafe { + Sorted__lambda_at_lambda_decltype_type_cpp_19_23__::construct_1(&mut *self); + } + } } impl Default for Sorted__lambda_at_lambda_decltype_type_cpp_19_23__ { fn default() -> Self { @@ -96,7 +132,8 @@ unsafe fn main_0() -> i32 { } }); let mut desc: Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ = - ::default(); + ::zero_init(); + Sorted__lambda_at_lambda_decltype_type_cpp_22_18__::construct_1(&mut desc); (unsafe { Sorted__lambda_at_lambda_decltype_type_cpp_22_18__::insert(&mut desc, 2) }); (unsafe { Sorted__lambda_at_lambda_decltype_type_cpp_22_18__::insert(&mut desc, 7) }); (unsafe { Sorted__lambda_at_lambda_decltype_type_cpp_22_18__::insert(&mut desc, 4) }); @@ -104,7 +141,8 @@ unsafe fn main_0() -> i32 { assert!(((desc.items[(1) as usize]) == (4))); assert!(((desc.items[(2) as usize]) == (2))); let mut asc: Sorted__lambda_at_lambda_decltype_type_cpp_19_23__ = - ::default(); + ::zero_init(); + Sorted__lambda_at_lambda_decltype_type_cpp_19_23__::construct_1(&mut asc); (unsafe { Sorted__lambda_at_lambda_decltype_type_cpp_19_23__::insert(&mut asc, 2) }); (unsafe { Sorted__lambda_at_lambda_decltype_type_cpp_19_23__::insert(&mut asc, 7) }); (unsafe { Sorted__lambda_at_lambda_decltype_type_cpp_19_23__::insert(&mut asc, 4) }); diff --git a/tests/unit/out/unsafe/lambda_generic_explicit_args.rs b/tests/unit/out/unsafe/lambda_generic_explicit_args.rs index 887fadc14d..b757e96c71 100644 --- a/tests/unit/out/unsafe/lambda_generic_explicit_args.rs +++ b/tests/unit/out/unsafe/lambda_generic_explicit_args.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 63e8e560ae..a37cb08200 100644 --- a/tests/unit/out/unsafe/lambda_immediate_init.rs +++ b/tests/unit/out/unsafe/lambda_immediate_init.rs @@ -15,6 +15,28 @@ pub struct S { pub j: i32, pub k: i32, } +impl S { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.j).write(10); + (&raw mut self.k).write( + ((unsafe { + FnPtr:: i32>::new(|| -> i32 { + unsafe { + return 3; + } + }) + .call() + }) + (1)), + ); + } +} +impl DefaultConstructibleUnsafe for S { + unsafe fn default_constructor(&mut self) { + unsafe { + S::construct_1(&mut *self); + } + } +} impl Default for S { fn default() -> Self { unsafe { @@ -74,7 +96,8 @@ unsafe fn main_0() -> i32 { }) == (237)) ); assert!(((unsafe { pick_0(1,) }) == (1))); - let mut s: S = ::default(); + let mut s: S = ::zero_init(); + S::construct_1(&mut s); assert!(((s.k) == (4))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut g_1)) == (10))); let mut a: i32 = 2; diff --git a/tests/unit/out/unsafe/lambda_move_only_capture.rs b/tests/unit/out/unsafe/lambda_move_only_capture.rs index d527d39c0f..605f07f325 100644 --- a/tests/unit/out/unsafe/lambda_move_only_capture.rs +++ b/tests/unit/out/unsafe/lambda_move_only_capture.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, Default)] +#[derive( + FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DefaultConstructibleUnsafe, Default, +)] #[cpp_from(i32, construct, value)] pub struct Owner { pub p: *mut i32, diff --git a/tests/unit/out/unsafe/lambda_nested.rs b/tests/unit/out/unsafe/lambda_nested.rs index 1afcc23943..57d88d4ec9 100644 --- a/tests/unit/out/unsafe/lambda_nested.rs +++ b/tests/unit/out/unsafe/lambda_nested.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 8c46892420..5165d9bdf8 100644 --- a/tests/unit/out/unsafe/lambda_static_local.rs +++ b/tests/unit/out/unsafe/lambda_static_local.rs @@ -69,7 +69,14 @@ static mut calls_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsaf static mut calls_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct P_4 { pub x: i32, diff --git a/tests/unit/out/unsafe/libc_struct_without_default.rs b/tests/unit/out/unsafe/libc_struct_without_default.rs index aca94964ca..8b419446a8 100644 --- a/tests/unit/out/unsafe/libc_struct_without_default.rs +++ b/tests/unit/out/unsafe/libc_struct_without_default.rs @@ -22,6 +22,19 @@ pub struct UserDefined { pub a: [i32; 1], pub v: Vec, } +impl UserDefined { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.a).write(std::array::from_fn::<_, 1, _>(|_| 0_i32)); + (&raw mut self.v).write(Vec::new()); + } +} +impl DefaultConstructibleUnsafe for UserDefined { + unsafe fn default_constructor(&mut self) { + unsafe { + UserDefined::construct_1(&mut *self); + } + } +} impl Default for UserDefined { fn default() -> Self { unsafe { @@ -33,7 +46,15 @@ impl Default for UserDefined { } } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, +)] pub struct FieldIsLibcType { pub addr: libc::sockaddr, } @@ -73,7 +94,8 @@ unsafe fn main_0() -> i32 { let mut st: ::libc::stat = std::mem::zeroed(); st.st_size = (1024 as ::libc::off_t); assert!(((st.st_size) == (1024 as ::libc::off_t))); - let mut ud: UserDefined = ::default(); + let mut ud: UserDefined = ::zero_init(); + UserDefined::construct_1(&mut ud); ud.a[(0_usize)] = 3; assert!(((ud.a[(0_usize)]) == (3))); assert!(((ud.v.len()) == (0_usize))); diff --git a/tests/unit/out/unsafe/linked_list.rs b/tests/unit/out/unsafe/linked_list.rs index 17392bf6ab..1b9ec10d92 100644 --- a/tests/unit/out/unsafe/linked_list.rs +++ b/tests/unit/out/unsafe/linked_list.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Node { pub val: i32, diff --git a/tests/unit/out/unsafe/local_anon_struct_collision.rs b/tests/unit/out/unsafe/local_anon_struct_collision.rs index 22a5a31b74..777c92a2b4 100644 --- a/tests/unit/out/unsafe/local_anon_struct_collision.rs +++ b/tests/unit/out/unsafe/local_anon_struct_collision.rs @@ -14,7 +14,14 @@ pub unsafe fn first_0() -> i32 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct anon_1 { pub x: i32, @@ -28,7 +35,14 @@ pub unsafe fn second_2() -> i32 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct anon_3 { pub a: i64, diff --git a/tests/unit/out/unsafe/local_record_template.rs b/tests/unit/out/unsafe/local_record_template.rs index 6bfee633be..3dbf3ca3d8 100644 --- a/tests/unit/out/unsafe/local_record_template.rs +++ b/tests/unit/out/unsafe/local_record_template.rs @@ -31,14 +31,28 @@ pub unsafe fn wrap_10(mut v: i64) -> i32 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Local_5 { pub x: i32, } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Local_7 { pub x: i64, @@ -49,7 +63,14 @@ pub unsafe fn other_11() -> i32 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Local_1 { pub x: i64, @@ -72,7 +93,14 @@ unsafe fn main_0() -> i32 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 5df1205c96..5a5e085296 100644 --- a/tests/unit/out/unsafe/map.rs +++ b/tests/unit/out/unsafe/map.rs @@ -31,6 +31,13 @@ impl Point { (&raw mut self.y).write(y); } } +impl DefaultConstructibleUnsafe for Point { + unsafe fn default_constructor(&mut self) { + unsafe { + Point::construct_1(&mut *self); + } + } +} impl Default for Point { fn default() -> Self { unsafe { diff --git a/tests/unit/out/unsafe/map_key_copy_ctor.rs b/tests/unit/out/unsafe/map_key_copy_ctor.rs index 92f323efd5..49aaf19d17 100644 --- a/tests/unit/out/unsafe/map_key_copy_ctor.rs +++ b/tests/unit/out/unsafe/map_key_copy_ctor.rs @@ -16,6 +16,7 @@ pub static mut made_2: std::cell::LazyCell = std::cell::LazyCell::new(|| un ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, diff --git a/tests/unit/out/unsafe/map_key_identity.rs b/tests/unit/out/unsafe/map_key_identity.rs index 579d8cc551..e498496c4f 100644 --- a/tests/unit/out/unsafe/map_key_identity.rs +++ b/tests/unit/out/unsafe/map_key_identity.rs @@ -10,7 +10,14 @@ pub static mut default_constructions_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Key { pub order: i32, @@ -57,6 +64,13 @@ impl Mapped { (*std::cell::LazyCell::force_mut(&mut *&raw mut default_constructions_0)).prefix_inc(); } } +impl DefaultConstructibleUnsafe for Mapped { + unsafe fn default_constructor(&mut self) { + unsafe { + Mapped::construct(&mut *self); + } + } +} impl Default for Mapped { fn default() -> Self { unsafe { diff --git a/tests/unit/out/unsafe/map_try_emplace.rs b/tests/unit/out/unsafe/map_try_emplace.rs index cab1642c41..83e8b13217 100644 --- a/tests/unit/out/unsafe/map_try_emplace.rs +++ b/tests/unit/out/unsafe/map_try_emplace.rs @@ -56,6 +56,13 @@ impl Clone for Item { } } } +impl DefaultConstructibleUnsafe for Item { + unsafe fn default_constructor(&mut self) { + unsafe { + Item::construct_2(&mut *self); + } + } +} impl Default for Item { fn default() -> Self { unsafe { @@ -88,6 +95,13 @@ impl RefItem { (*std::cell::LazyCell::force_mut(&mut *&raw mut made_1)).prefix_inc(); } } +impl DefaultConstructibleUnsafe for RefItem { + unsafe fn default_constructor(&mut self) { + unsafe { + RefItem::construct_1(&mut *self); + } + } +} impl Default for RefItem { fn default() -> Self { unsafe { diff --git a/tests/unit/out/unsafe/map_try_emplace_lvalues.rs b/tests/unit/out/unsafe/map_try_emplace_lvalues.rs index 1229f2461d..ce454e0021 100644 --- a/tests/unit/out/unsafe/map_try_emplace_lvalues.rs +++ b/tests/unit/out/unsafe/map_try_emplace_lvalues.rs @@ -25,6 +25,13 @@ impl Item { (*std::cell::LazyCell::force_mut(&mut *&raw mut made_0)).prefix_inc(); } } +impl DefaultConstructibleUnsafe for Item { + unsafe fn default_constructor(&mut self) { + unsafe { + Item::construct_1(&mut *self); + } + } +} impl Default for Item { fn default() -> Self { unsafe { @@ -59,6 +66,13 @@ impl Temporary { (*std::cell::LazyCell::force_mut(&mut *&raw mut temporary_calls_4)).prefix_inc(); } } +impl DefaultConstructibleUnsafe for Temporary { + unsafe fn default_constructor(&mut self) { + unsafe { + Temporary::construct(&mut *self); + } + } +} impl Default for Temporary { fn default() -> Self { unsafe { @@ -82,6 +96,13 @@ impl Nested { Temporary::construct(&mut self.inner); } } +impl DefaultConstructibleUnsafe for Nested { + unsafe fn default_constructor(&mut self) { + unsafe { + Nested::construct_1(&mut *self); + } + } +} pub unsafe fn make_temporary_5() -> Temporary { return { let mut __v: Temporary = ::zero_init(); @@ -119,6 +140,13 @@ impl Owner { .n; } } +impl DefaultConstructibleUnsafe for Owner { + unsafe fn default_constructor(&mut self) { + unsafe { + Owner::construct(&mut *self); + } + } +} impl Default for Owner { fn default() -> Self { unsafe { @@ -135,6 +163,18 @@ impl Default for Owner { pub struct Noncopy { pub n: i32, } +impl Noncopy { + pub unsafe fn construct(&mut self) { + (&raw mut self.n).write(5); + } +} +impl DefaultConstructibleUnsafe for Noncopy { + unsafe fn default_constructor(&mut self) { + unsafe { + Noncopy::construct(&mut *self); + } + } +} impl Default for Noncopy { fn default() -> Self { unsafe { Noncopy { n: 5 } } @@ -159,6 +199,13 @@ impl Held { (&raw mut self.ptr).write((*n).as_ptr()); } } +impl DefaultConstructibleUnsafe for Held { + unsafe fn default_constructor(&mut self) { + unsafe { + Held::construct_2(&mut *self); + } + } +} impl Default for Held { fn default() -> Self { unsafe { @@ -1287,7 +1334,11 @@ unsafe fn main_0() -> i32 { ) = { let mut __tmp_103: Option>; match (({ - __tmp_103 = Some(Box::new(::default())); + __tmp_103 = Some(Box::new({ + let mut __v: Noncopy = ::zero_init(); + Noncopy::construct(&mut __v); + __v + })); &mut __tmp_103 } as *mut Option>),) { @@ -1300,7 +1351,11 @@ unsafe fn main_0() -> i32 { ) = { let mut __tmp_105: Option>; match (({ - __tmp_105 = Some(Box::new(::default())); + __tmp_105 = Some(Box::new({ + let mut __v: Noncopy = ::zero_init(); + Noncopy::construct(&mut __v); + __v + })); &mut __tmp_105 } as *mut Option>),) { diff --git a/tests/unit/out/unsafe/max.rs b/tests/unit/out/unsafe/max.rs index 3e34a334ab..7309c90eba 100644 --- a/tests/unit/out/unsafe/max.rs +++ b/tests/unit/out/unsafe/max.rs @@ -23,6 +23,7 @@ pub unsafe fn pick_3(mut i: i32) -> *mut i32 { ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, MovableUnsafe, Default, diff --git a/tests/unit/out/unsafe/memcpy_struct_bytes.rs b/tests/unit/out/unsafe/memcpy_struct_bytes.rs index 52ed9a3a88..3a8b1e7889 100644 --- a/tests/unit/out/unsafe/memcpy_struct_bytes.rs +++ b/tests/unit/out/unsafe/memcpy_struct_bytes.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct point { pub x: i32, diff --git a/tests/unit/out/unsafe/memcpy_struct_layouts.rs b/tests/unit/out/unsafe/memcpy_struct_layouts.rs index b39f168db7..c4fe753df2 100644 --- a/tests/unit/out/unsafe/memcpy_struct_layouts.rs +++ b/tests/unit/out/unsafe/memcpy_struct_layouts.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct packed { pub a: i32, @@ -18,7 +25,14 @@ pub struct packed { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct reordered { pub a: libc::c_char, @@ -27,7 +41,14 @@ pub struct reordered { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct tail { pub a: libc::c_char, @@ -35,7 +56,14 @@ pub struct tail { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct nested { pub t: tail, @@ -43,7 +71,14 @@ pub struct nested { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct array { pub name: [libc::c_char; 3], diff --git a/tests/unit/out/unsafe/memcpy_struct_struct.rs b/tests/unit/out/unsafe/memcpy_struct_struct.rs index 0bc61206d3..678b416258 100644 --- a/tests/unit/out/unsafe/memcpy_struct_struct.rs +++ b/tests/unit/out/unsafe/memcpy_struct_struct.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Entry { pub bits: u8, diff --git a/tests/unit/out/unsafe/memset_struct_tail.rs b/tests/unit/out/unsafe/memset_struct_tail.rs index 68364362d3..82bfda53c2 100644 --- a/tests/unit/out/unsafe/memset_struct_tail.rs +++ b/tests/unit/out/unsafe/memset_struct_tail.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct S { pub keep: i32, diff --git a/tests/unit/out/unsafe/move_assign.rs b/tests/unit/out/unsafe/move_assign.rs index 1de05ce949..7b5935c379 100644 --- a/tests/unit/out/unsafe/move_assign.rs +++ b/tests/unit/out/unsafe/move_assign.rs @@ -8,7 +8,13 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, SwappableUnsafe, Default, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + DefaultConstructibleUnsafe, + SwappableUnsafe, + Default, )] #[cpp_from(i32, construct, value)] pub struct MoveOnly { @@ -53,6 +59,13 @@ impl ConstMoveAssign { return &mut (*(self as *mut ConstMoveAssign)); } } +impl DefaultConstructibleUnsafe for ConstMoveAssign { + unsafe fn default_constructor(&mut self) { + unsafe { + ConstMoveAssign::construct(&mut *self); + } + } +} impl Default for ConstMoveAssign { fn default() -> Self { unsafe { diff --git a/tests/unit/out/unsafe/move_ctor.rs b/tests/unit/out/unsafe/move_ctor.rs index 1b424b4893..87ca249222 100644 --- a/tests/unit/out/unsafe/move_ctor.rs +++ b/tests/unit/out/unsafe/move_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(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, Default)] +#[derive( + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + DefaultConstructibleUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct MoveOnly { pub v: i32, @@ -39,6 +46,13 @@ impl ConstMove { (&raw mut self.mark).write((((*o).mark) + (10))); } } +impl DefaultConstructibleUnsafe for ConstMove { + unsafe fn default_constructor(&mut self) { + unsafe { + ConstMove::construct(&mut *self); + } + } +} impl Default for ConstMove { fn default() -> Self { unsafe { @@ -57,6 +71,7 @@ impl Default for ConstMove { ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -106,6 +121,7 @@ impl Clone for ThrowingMove { ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, diff --git a/tests/unit/out/unsafe/move_this.rs b/tests/unit/out/unsafe/move_this.rs index 4a4d682523..78dfd01396 100644 --- a/tests/unit/out/unsafe/move_this.rs +++ b/tests/unit/out/unsafe/move_this.rs @@ -13,6 +13,7 @@ use std::rc::Rc; ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, diff --git a/tests/unit/out/unsafe/nested_structs.rs b/tests/unit/out/unsafe/nested_structs.rs index 44583fc00c..4b513687ac 100644 --- a/tests/unit/out/unsafe/nested_structs.rs +++ b/tests/unit/out/unsafe/nested_structs.rs @@ -8,14 +8,28 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Level0_Level1_1_Level2_1_Level3_1 { pub x1: i32, } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Level0_Level1_1_Level2_1_Level3_2 { pub x1: i32, @@ -23,21 +37,42 @@ pub struct Level0_Level1_1_Level2_1_Level3_2 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Level0_Level1_1_Level2_1 { pub x1: i32, } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Level0_Level1_1 { pub x1: i32, } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Level0_Level1_2 { pub x1: i32, @@ -45,7 +80,14 @@ pub struct Level0_Level1_2 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Level0 {} pub fn main() { diff --git a/tests/unit/out/unsafe/new.rs b/tests/unit/out/unsafe/new.rs index e0d3015cbc..6220abaafb 100644 --- a/tests/unit/out/unsafe/new.rs +++ b/tests/unit/out/unsafe/new.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Pair { pub x: i32, diff --git a/tests/unit/out/unsafe/new_bst.rs b/tests/unit/out/unsafe/new_bst.rs index 97b631f9e3..9632757f9b 100644 --- a/tests/unit/out/unsafe/new_bst.rs +++ b/tests/unit/out/unsafe/new_bst.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct node_t { pub left: *mut node_t, diff --git a/tests/unit/out/unsafe/new_struct.rs b/tests/unit/out/unsafe/new_struct.rs index a9f66e50da..47bb9cf3f1 100644 --- a/tests/unit/out/unsafe/new_struct.rs +++ b/tests/unit/out/unsafe/new_struct.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Pair { pub x: i32, @@ -16,7 +23,14 @@ pub struct Pair { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Triple { pub a: i32, diff --git a/tests/unit/out/unsafe/nttp_distinct_specializations.rs b/tests/unit/out/unsafe/nttp_distinct_specializations.rs index 7e4ddc2f00..8cee7819a9 100644 --- a/tests/unit/out/unsafe/nttp_distinct_specializations.rs +++ b/tests/unit/out/unsafe/nttp_distinct_specializations.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct S_2_ { pub v: i32, @@ -21,7 +28,14 @@ impl S_2_ { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct S_1_ { pub v: i32, @@ -33,7 +47,14 @@ impl S_1_ { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 c65bc82147..e7cdacc7c5 100644 --- a/tests/unit/out/unsafe/offsetof.rs +++ b/tests/unit/out/unsafe/offsetof.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Layout { pub a: u8, @@ -16,7 +23,15 @@ pub struct Layout { pub c: u16, } #[repr(C)] -#[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, +)] 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 35a56e4387..e3d4034809 100644 --- a/tests/unit/out/unsafe/opaque_forward_decl.rs +++ b/tests/unit/out/unsafe/opaque_forward_decl.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct container { pub p: *mut opaque, diff --git a/tests/unit/out/unsafe/opaque_record_copy.rs b/tests/unit/out/unsafe/opaque_record_copy.rs index 935d03778c..ba8f5b71c8 100644 --- a/tests/unit/out/unsafe/opaque_record_copy.rs +++ b/tests/unit/out/unsafe/opaque_record_copy.rs @@ -8,12 +8,26 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Probe {} #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Wrapper_Probe_ { pub base_: Probe, diff --git a/tests/unit/out/unsafe/opaque_then_defined.rs b/tests/unit/out/unsafe/opaque_then_defined.rs index b9fa7b8b1d..e4b22a5391 100644 --- a/tests/unit/out/unsafe/opaque_then_defined.rs +++ b/tests/unit/out/unsafe/opaque_then_defined.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct list { pub head: *mut node, @@ -16,7 +23,14 @@ pub struct list { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct node { pub value: i32, diff --git a/tests/unit/out/unsafe/operator_arithmetic_free.rs b/tests/unit/out/unsafe/operator_arithmetic_free.rs index 64109d8e9b..bcffc4392a 100644 --- a/tests/unit/out/unsafe/operator_arithmetic_free.rs +++ b/tests/unit/out/unsafe/operator_arithmetic_free.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 ee2d516935..b0543f4012 100644 --- a/tests/unit/out/unsafe/operator_arithmetic_member.rs +++ b/tests/unit/out/unsafe/operator_arithmetic_member.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 3bb31d9b8e..3afd1bccf6 100644 --- a/tests/unit/out/unsafe/operator_bitwise_free.rs +++ b/tests/unit/out/unsafe/operator_bitwise_free.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 87bf73b2ab..b512be50e1 100644 --- a/tests/unit/out/unsafe/operator_bitwise_member.rs +++ b/tests/unit/out/unsafe/operator_bitwise_member.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 88aa881c93..5710ea0d7d 100644 --- a/tests/unit/out/unsafe/operator_comparison_defaulted.rs +++ b/tests/unit/out/unsafe/operator_comparison_defaulted.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Eq { pub a: i32, @@ -28,7 +35,14 @@ impl std::cmp::PartialEq for Eq { impl std::cmp::Eq for Eq {} #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Cmp { pub a: i32, @@ -75,7 +89,14 @@ impl std::cmp::PartialEq for Cmp { impl std::cmp::Eq for Cmp {} #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Both { pub a: i32, @@ -113,7 +134,14 @@ impl std::cmp::PartialEq for Both { impl std::cmp::Eq for Both {} #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct OrdOnly { pub a: i32, @@ -148,7 +176,14 @@ impl std::cmp::PartialEq for OrdOnly { impl std::cmp::Eq for OrdOnly {} #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Inner { pub x: i32, @@ -186,7 +221,14 @@ impl std::cmp::PartialEq for Inner { impl std::cmp::Eq for Inner {} #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Outer { pub i: Inner, @@ -237,7 +279,14 @@ impl std::cmp::PartialEq for Outer { impl std::cmp::Eq for Outer {} #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Secondary { pub a: i32, @@ -286,7 +335,14 @@ impl std::cmp::PartialEq for Secondary { impl std::cmp::Eq for Secondary {} #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 32cff29854..2705370eba 100644 --- a/tests/unit/out/unsafe/operator_comparison_free.rs +++ b/tests/unit/out/unsafe/operator_comparison_free.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct S { pub v: i32, @@ -63,7 +70,14 @@ pub unsafe fn operator_lt_7(mut a: i32, b: *const S) -> bool { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 ea4b46c0a2..f122b5b633 100644 --- a/tests/unit/out/unsafe/operator_comparison_member.rs +++ b/tests/unit/out/unsafe/operator_comparison_member.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 ee981c88a3..f6be0a019c 100644 --- a/tests/unit/out/unsafe/operator_comparison_mixed.rs +++ b/tests/unit/out/unsafe/operator_comparison_mixed.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 2545422fb7..bbc7198aa1 100644 --- a/tests/unit/out/unsafe/operator_comparison_nonbool.rs +++ b/tests/unit/out/unsafe/operator_comparison_nonbool.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct X { pub v: i32, @@ -57,14 +64,28 @@ pub unsafe fn operator_ge_5(mut a: X, mut b: X) -> i32 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Result { pub r: i32, } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Custom { pub v: i32, @@ -78,7 +99,14 @@ impl Custom { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Mixed { pub v: i32, @@ -128,6 +156,7 @@ impl std::cmp::Eq for Mixed {} FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -145,7 +174,14 @@ impl MyBool { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Boolish { pub v: i32, @@ -200,7 +236,14 @@ pub unsafe fn operator_lt_6(mut a: Boolish, mut b: Boolish) -> MyBool { }; } #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, Default)] +#[derive( + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + DefaultConstructibleUnsafe, + Default, +)] #[cpp_into(bool, to_bool)] pub struct RefBool { pub value: bool, @@ -222,7 +265,14 @@ pub static mut ref_true_8: std::cell::LazyCell = std::cell::LazyCell::n }); #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 9ff1c43465..0b474f7b5a 100644 --- a/tests/unit/out/unsafe/operator_comparison_noncopyable.rs +++ b/tests/unit/out/unsafe/operator_comparison_noncopyable.rs @@ -14,7 +14,13 @@ pub unsafe fn operator_lt_1(x: *const S, y: *const S) -> bool { } #[repr(C)] #[derive( - FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, MemberwiseUnsafe, Default, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DestructibleUnsafe, + DefaultConstructibleUnsafe, + MemberwiseUnsafe, + Default, )] #[memberwise(move_constructor)] #[cpp_from(i32, construct, value)] diff --git a/tests/unit/out/unsafe/operator_compound_assignment_free.rs b/tests/unit/out/unsafe/operator_compound_assignment_free.rs index fb40f51dc6..33bb6ca69d 100644 --- a/tests/unit/out/unsafe/operator_compound_assignment_free.rs +++ b/tests/unit/out/unsafe/operator_compound_assignment_free.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 0808deae9b..438344e59d 100644 --- a/tests/unit/out/unsafe/operator_compound_assignment_member.rs +++ b/tests/unit/out/unsafe/operator_compound_assignment_member.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 a6df4497b0..7ff60a7632 100644 --- a/tests/unit/out/unsafe/operator_friend.rs +++ b/tests/unit/out/unsafe/operator_friend.rs @@ -11,7 +11,14 @@ pub unsafe fn operator_eq_0(_a0: *const Defaulted, _a1: *const Defaulted) -> boo } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Defaulted { pub a: i32, @@ -40,7 +47,14 @@ pub unsafe fn operator_eq_2(_a0: *const DefaultedOrd, _a1: *const DefaultedOrd) } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct DefaultedOrd { pub a: i32, @@ -74,7 +88,14 @@ pub unsafe fn operator_add_5(x: *const Inline, y: *const Inline) -> Inline { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Inline { pub a: i32, @@ -105,7 +126,14 @@ impl std::cmp::PartialEq for Inline { impl std::cmp::Eq for Inline {} #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct OutOfLine { pub a: i32, @@ -136,7 +164,14 @@ pub unsafe fn operator_eq_10(x: *const Tmpl_int_, y: *const Tmpl_long_) -> bool } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Tmpl_int_ { pub v: i32, @@ -167,7 +202,14 @@ impl std::cmp::PartialEq for Tmpl_int_ { impl std::cmp::Eq for Tmpl_int_ {} #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Tmpl_long_ { pub v: i64, @@ -180,7 +222,14 @@ pub unsafe fn operator_eq_11( } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 f103a49839..8654102168 100644 --- a/tests/unit/out/unsafe/operator_less_than.rs +++ b/tests/unit/out/unsafe/operator_less_than.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Pair { pub x: i32, diff --git a/tests/unit/out/unsafe/operator_logical_free.rs b/tests/unit/out/unsafe/operator_logical_free.rs index db4b49c826..2b05ae036c 100644 --- a/tests/unit/out/unsafe/operator_logical_free.rs +++ b/tests/unit/out/unsafe/operator_logical_free.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 a368075737..9bcc9de46c 100644 --- a/tests/unit/out/unsafe/operator_logical_member.rs +++ b/tests/unit/out/unsafe/operator_logical_member.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 ee71b10103..73ffdc99b8 100644 --- a/tests/unit/out/unsafe/operator_member_pointer_free.rs +++ b/tests/unit/out/unsafe/operator_member_pointer_free.rs @@ -8,14 +8,28 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Inner { pub x: i32, } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct S { pub data: [i32; 3], diff --git a/tests/unit/out/unsafe/operator_member_pointer_member.rs b/tests/unit/out/unsafe/operator_member_pointer_member.rs index a8a73c8051..0fb2465724 100644 --- a/tests/unit/out/unsafe/operator_member_pointer_member.rs +++ b/tests/unit/out/unsafe/operator_member_pointer_member.rs @@ -8,14 +8,28 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Inner { pub x: i32, } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Table {} impl Table { @@ -27,7 +41,14 @@ 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, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct S { pub data: [i32; 3], diff --git a/tests/unit/out/unsafe/operator_other_free.rs b/tests/unit/out/unsafe/operator_other_free.rs index 720986742f..ee158e2b83 100644 --- a/tests/unit/out/unsafe/operator_other_free.rs +++ b/tests/unit/out/unsafe/operator_other_free.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 a86f1392c8..be18c378ee 100644 --- a/tests/unit/out/unsafe/operator_other_member.rs +++ b/tests/unit/out/unsafe/operator_other_member.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Static {} impl Static { @@ -24,6 +31,7 @@ impl Static { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/operator_overloads.rs b/tests/unit/out/unsafe/operator_overloads.rs index 40733c02ca..1c6720f49a 100644 --- a/tests/unit/out/unsafe/operator_overloads.rs +++ b/tests/unit/out/unsafe/operator_overloads.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 d8385e40b6..c78d57f462 100644 --- a/tests/unit/out/unsafe/operator_qualifiers.rs +++ b/tests/unit/out/unsafe/operator_qualifiers.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 6ee24d91b7..1a5acbc4e9 100644 --- a/tests/unit/out/unsafe/operator_three_way.rs +++ b/tests/unit/out/unsafe/operator_three_way.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 00009f4690..3ada3cd6ed 100644 --- a/tests/unit/out/unsafe/operator_traits.rs +++ b/tests/unit/out/unsafe/operator_traits.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Lt { pub v: i32, @@ -47,7 +54,14 @@ impl std::cmp::PartialEq for Lt { impl std::cmp::Eq for Lt {} #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Eq { pub v: i32, @@ -65,7 +79,14 @@ impl std::cmp::PartialEq for Eq { impl std::cmp::Eq for Eq {} #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Cmp { pub v: i32, @@ -96,7 +117,14 @@ impl std::cmp::PartialEq for Cmp { impl std::cmp::Eq for Cmp {} #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Free { pub v: i32, @@ -133,7 +161,14 @@ pub unsafe fn operator_eq_1(a: *const Free, b: *const Free) -> bool { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 c03438486d..883bffb2d2 100644 --- a/tests/unit/out/unsafe/overload_mangling.rs +++ b/tests/unit/out/unsafe/overload_mangling.rs @@ -17,7 +17,14 @@ pub unsafe fn twice_2(mut n: i32) -> i32 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Access_S_ {} impl Access_S_ { @@ -36,7 +43,14 @@ impl Access_S_ { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct S { pub base: i32, @@ -112,7 +126,14 @@ impl S { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 21764ba5f4..f4b085cec4 100644 --- a/tests/unit/out/unsafe/pair_converting_construction.rs +++ b/tests/unit/out/unsafe/pair_converting_construction.rs @@ -14,6 +14,7 @@ use std::rc::Rc; FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -34,6 +35,7 @@ impl Celsius { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -54,6 +56,7 @@ impl Meters { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -74,6 +77,7 @@ impl Label { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -101,6 +105,7 @@ impl Owner { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -126,6 +131,13 @@ impl Fallback { (&raw mut self.value).write(v); } } +impl DefaultConstructibleUnsafe for Fallback { + unsafe fn default_constructor(&mut self) { + unsafe { + Fallback::construct(&mut *self, { -1_i32 }); + } + } +} impl Default for Fallback { fn default() -> Self { unsafe { @@ -139,7 +151,14 @@ impl Default for Fallback { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Counter { pub hits: i32, @@ -152,6 +171,7 @@ pub struct Counter { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -178,6 +198,7 @@ impl Tag { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -193,6 +214,7 @@ pub struct Tag { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/pod.rs b/tests/unit/out/unsafe/pod.rs index 426d5907a1..4b7b4c4d29 100644 --- a/tests/unit/out/unsafe/pod.rs +++ b/tests/unit/out/unsafe/pod.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct POD { pub x1: i32, diff --git a/tests/unit/out/unsafe/pointer_array.rs b/tests/unit/out/unsafe/pointer_array.rs index ed7cea0ce1..8647f517db 100644 --- a/tests/unit/out/unsafe/pointer_array.rs +++ b/tests/unit/out/unsafe/pointer_array.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 befa1c43c2..c5a6e540dd 100644 --- a/tests/unit/out/unsafe/pointers.rs +++ b/tests/unit/out/unsafe/pointers.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Test { pub x: i32, diff --git a/tests/unit/out/unsafe/polymorphism.rs b/tests/unit/out/unsafe/polymorphism.rs index 5cd87101e7..04b0374704 100644 --- a/tests/unit/out/unsafe/polymorphism.rs +++ b/tests/unit/out/unsafe/polymorphism.rs @@ -17,6 +17,7 @@ pub unsafe trait Animal { FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, CopyableUnsafe, Default, )] @@ -29,6 +30,7 @@ pub struct Dog {} FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, CopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/ptr_cast_init.rs b/tests/unit/out/unsafe/ptr_cast_init.rs index b75e0c1aa8..68205c6cb6 100644 --- a/tests/unit/out/unsafe/ptr_cast_init.rs +++ b/tests/unit/out/unsafe/ptr_cast_init.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct header { pub tag: i32, @@ -16,7 +23,14 @@ pub struct header { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 a641089e2b..4a3879c5c5 100644 --- a/tests/unit/out/unsafe/push_emplace_back.rs +++ b/tests/unit/out/unsafe/push_emplace_back.rs @@ -8,14 +8,28 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Chunk { pub data: i32, } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Writer { pub output: *mut Vec, @@ -38,6 +52,19 @@ pub struct JPEGData { pub com_data: Vec>, pub app_data: Vec>, } +impl JPEGData { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.com_data).write(Vec::new()); + (&raw mut self.app_data).write(Vec::new()); + } +} +impl DefaultConstructibleUnsafe for JPEGData { + unsafe fn default_constructor(&mut self) { + unsafe { + JPEGData::construct_1(&mut *self); + } + } +} pub unsafe fn push_param_0(mut dest: *mut Vec>) { { let __a1 = Vec::new(); @@ -126,6 +153,13 @@ impl Pair { (&raw mut self.second).write(((b) * (2))); } } +impl DefaultConstructibleUnsafe for Pair { + unsafe fn default_constructor(&mut self) { + unsafe { + Pair::construct_2(&mut *self); + } + } +} impl Default for Pair { fn default() -> Self { unsafe { @@ -226,6 +260,19 @@ pub struct Bytes { pub v: Vec>, pub b: [u8; 3], } +impl Bytes { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.v).write(Vec::new()); + (&raw mut self.b).write([0_u8; 3]); + } +} +impl DefaultConstructibleUnsafe for Bytes { + unsafe fn default_constructor(&mut self) { + unsafe { + Bytes::construct_1(&mut *self); + } + } +} pub unsafe fn emplace_from_element_14(mut v: *mut Vec>) { let mut p: *mut u8 = (&mut (*v))[(0_usize)].as_mut_ptr(); (*v).push_mut({ @@ -241,7 +288,14 @@ pub unsafe fn emplace_from_element_14(mut v: *mut Vec>) { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Plain { pub a: i32, @@ -258,7 +312,14 @@ 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, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Counted { pub seen: usize, @@ -303,7 +364,8 @@ unsafe fn main_0() -> i32 { (unsafe { push_param_0((&mut vecs as *mut Vec>)) }); assert!(((vecs.len()) == (1_usize))); assert!(vecs[(0_usize)].is_empty()); - let mut jpg: JPEGData = ::default(); + let mut jpg: JPEGData = ::zero_init(); + JPEGData::construct_1(&mut jpg); (unsafe { push_local_from_field_1((&mut jpg as *mut JPEGData), true) }); assert!(((jpg.com_data.len()) == (1_usize))); assert!(((jpg.com_data[(0_usize)].len()) == (3_usize))); diff --git a/tests/unit/out/unsafe/random.rs b/tests/unit/out/unsafe/random.rs index 1d648ec428..e2bf3c868b 100644 --- a/tests/unit/out/unsafe/random.rs +++ b/tests/unit/out/unsafe/random.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Pair { pub x: i32, @@ -44,7 +51,14 @@ pub unsafe fn zero_0() -> i32 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 1b0bea1b7d..68a385f9c3 100644 --- a/tests/unit/out/unsafe/reference_wrapper.rs +++ b/tests/unit/out/unsafe/reference_wrapper.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Point { pub x: i32, diff --git a/tests/unit/out/unsafe/references.rs b/tests/unit/out/unsafe/references.rs index 3aee6a8e84..a24673eaf1 100644 --- a/tests/unit/out/unsafe/references.rs +++ b/tests/unit/out/unsafe/references.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Pair { pub x: i32, @@ -17,7 +24,14 @@ pub struct Pair { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 6787508651..084e4653e2 100644 --- a/tests/unit/out/unsafe/refs_as_args.rs +++ b/tests/unit/out/unsafe/refs_as_args.rs @@ -19,7 +19,14 @@ pub unsafe fn more_refs_0(mut x1: i32, mut x2: i32, r1: *mut i32, r2: *const i32 } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 4d4b50fbf5..54edde9f09 100644 --- a/tests/unit/out/unsafe/reinterpret_cast_ptr_cmp.rs +++ b/tests/unit/out/unsafe/reinterpret_cast_ptr_cmp.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct S { pub x: i32, @@ -16,7 +23,14 @@ pub struct S { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct W { pub h: i32, @@ -24,7 +38,14 @@ pub struct W { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct P { pub a: *mut i32, diff --git a/tests/unit/out/unsafe/reinterpret_cast_struct.rs b/tests/unit/out/unsafe/reinterpret_cast_struct.rs index 70c3f03d6a..bee53d9fee 100644 --- a/tests/unit/out/unsafe/reinterpret_cast_struct.rs +++ b/tests/unit/out/unsafe/reinterpret_cast_struct.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Point { pub x: 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 5d4fe4a7a4..ed29ef0dea 100644 --- a/tests/unit/out/unsafe/reinterpret_cast_struct_to_struct.rs +++ b/tests/unit/out/unsafe/reinterpret_cast_struct_to_struct.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Point { pub x: u32, @@ -16,7 +23,14 @@ pub struct Point { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Pair { pub first: u32, diff --git a/tests/unit/out/unsafe/reserved_keywords.rs b/tests/unit/out/unsafe/reserved_keywords.rs index 877a6e3bd7..666ae8cb9e 100644 --- a/tests/unit/out/unsafe/reserved_keywords.rs +++ b/tests/unit/out/unsafe/reserved_keywords.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct S { pub as_: i32, @@ -52,14 +59,28 @@ pub struct S { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct type_ { pub v: i32, } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 55e500cd2f..a1a1641eb6 100644 --- a/tests/unit/out/unsafe/return_move.rs +++ b/tests/unit/out/unsafe/return_move.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct node { pub value: i32, @@ -16,7 +23,14 @@ pub struct node { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct pair_t { pub a: i32, diff --git a/tests/unit/out/unsafe/rule_of_five.rs b/tests/unit/out/unsafe/rule_of_five.rs index 4642b609a7..00095af8a8 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, SwappableUnsafe, Default)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DefaultConstructibleUnsafe, + 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 35fb03efd2..2c4522dbcb 100644 --- a/tests/unit/out/unsafe/rule_of_three.rs +++ b/tests/unit/out/unsafe/rule_of_three.rs @@ -9,7 +9,15 @@ 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, MovableUnsafe, Default)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DefaultConstructibleUnsafe, + MovableUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct Buffer { pub data: [i32; 4], diff --git a/tests/unit/out/unsafe/rvalue_rule_arg_move.rs b/tests/unit/out/unsafe/rvalue_rule_arg_move.rs index bfb0002d1d..52aa55c424 100644 --- a/tests/unit/out/unsafe/rvalue_rule_arg_move.rs +++ b/tests/unit/out/unsafe/rvalue_rule_arg_move.rs @@ -15,6 +15,7 @@ pub static mut moves_1: std::cell::LazyCell = std::cell::LazyCell::new(|| u ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, SwappableUnsafe, Default, diff --git a/tests/unit/out/unsafe/rvalue_struct.rs b/tests/unit/out/unsafe/rvalue_struct.rs index d6ce18406c..8c37674c4b 100644 --- a/tests/unit/out/unsafe/rvalue_struct.rs +++ b/tests/unit/out/unsafe/rvalue_struct.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct S { pub a: i32, diff --git a/tests/unit/out/unsafe/scalar_builtin_construct_destruct.rs b/tests/unit/out/unsafe/scalar_builtin_construct_destruct.rs index a2269572cb..b711711828 100644 --- a/tests/unit/out/unsafe/scalar_builtin_construct_destruct.rs +++ b/tests/unit/out/unsafe/scalar_builtin_construct_destruct.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 2b3660c3e9..714b31194f 100644 --- a/tests/unit/out/unsafe/self_referencing_initializer.rs +++ b/tests/unit/out/unsafe/self_referencing_initializer.rs @@ -8,14 +8,28 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct list_head { pub next: *mut list_head, } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct node { pub value: i32, @@ -27,6 +41,19 @@ pub struct node_with_defaults { pub next: *mut node_with_defaults, pub value: i32, } +impl node_with_defaults { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.next).write(std::ptr::null_mut()); + (&raw mut self.value).write(3); + } +} +impl DefaultConstructibleUnsafe for node_with_defaults { + unsafe fn default_constructor(&mut self) { + unsafe { + node_with_defaults::construct_1(&mut *self); + } + } +} impl Default for node_with_defaults { fn default() -> Self { unsafe { diff --git a/tests/unit/out/unsafe/size_t_static_member.rs b/tests/unit/out/unsafe/size_t_static_member.rs index 769cdd00c5..719488559e 100644 --- a/tests/unit/out/unsafe/size_t_static_member.rs +++ b/tests/unit/out/unsafe/size_t_static_member.rs @@ -9,14 +9,28 @@ 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, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Table_char_ {} pub fn main() { diff --git a/tests/unit/out/unsafe/size_t_template_param.rs b/tests/unit/out/unsafe/size_t_template_param.rs index 2ae0627be2..154b0534be 100644 --- a/tests/unit/out/unsafe/size_t_template_param.rs +++ b/tests/unit/out/unsafe/size_t_template_param.rs @@ -18,6 +18,7 @@ pub unsafe fn array_ref_0(a: *mut [u64; 3]) -> u64 { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -38,6 +39,7 @@ impl PtrCtor_unsigned_long_ { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/sort_no_copy.rs b/tests/unit/out/unsafe/sort_no_copy.rs index 23aa4f3ae7..460f0b45c3 100644 --- a/tests/unit/out/unsafe/sort_no_copy.rs +++ b/tests/unit/out/unsafe/sort_no_copy.rs @@ -83,6 +83,13 @@ impl Clone for Tracked { } } } +impl DefaultConstructibleUnsafe for Tracked { + unsafe fn default_constructor(&mut self) { + unsafe { + Tracked::construct_2(&mut *self); + } + } +} impl Default for Tracked { fn default() -> Self { unsafe { @@ -106,6 +113,7 @@ pub unsafe fn greater_2(a: *const Tracked, b: *const Tracked) -> bool { ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, SwappableUnsafe, Default, @@ -166,6 +174,11 @@ pub unsafe fn operator_lt_3(a: *const MoveOnly, b: *const MoveOnly) -> bool { pub struct Bag { pub items: Vec, } +impl Bag { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.items).write(Vec::new()); + } +} impl std::cmp::Ord for Bag { fn cmp(&self, other: &Self) -> std::cmp::Ordering { unsafe { @@ -190,6 +203,13 @@ impl std::cmp::PartialEq for Bag { } } impl std::cmp::Eq for Bag {} +impl DefaultConstructibleUnsafe for Bag { + unsafe fn default_constructor(&mut self) { + unsafe { + Bag::construct_1(&mut *self); + } + } +} pub unsafe fn operator_lt_4(a: *const Bag, b: *const Bag) -> bool { return (((*a).items.len()) < ((*b).items.len())); } @@ -395,7 +415,11 @@ unsafe fn main_0() -> i32 { && ((vec_[(3_usize)].v) == (2)) ); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (0))); - let mut bags: [Bag; 3] = std::array::from_fn::<_, 3, _>(|_| ::default()); + let mut bags: [Bag; 3] = std::array::from_fn::<_, 3, _>(|_| { + let mut __v: Bag = ::zero_init(); + Bag::construct_1(&mut __v); + __v + }); bags[(0) as usize].items.push_mut({ let mut __v: Tracked = ::zero_init(); Tracked::construct_1(&mut __v, { 1 }); diff --git a/tests/unit/out/unsafe/static_local.rs b/tests/unit/out/unsafe/static_local.rs index bb036d12a4..27e2a08934 100644 --- a/tests/unit/out/unsafe/static_local.rs +++ b/tests/unit/out/unsafe/static_local.rs @@ -23,7 +23,14 @@ 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, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct S_8 {} impl S_8 { diff --git a/tests/unit/out/unsafe/static_var_in_class.rs b/tests/unit/out/unsafe/static_var_in_class.rs index 47d463cbbe..e4897c1929 100644 --- a/tests/unit/out/unsafe/static_var_in_class.rs +++ b/tests/unit/out/unsafe/static_var_in_class.rs @@ -9,7 +9,14 @@ 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, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct C {} impl C { @@ -22,7 +29,14 @@ pub type anon_3 = u32; pub const anon_3_kValue: anon_3 = 3; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct S {} impl S { diff --git a/tests/unit/out/unsafe/stdcopy.rs b/tests/unit/out/unsafe/stdcopy.rs index 166d2a7737..8062f30857 100644 --- a/tests/unit/out/unsafe/stdcopy.rs +++ b/tests/unit/out/unsafe/stdcopy.rs @@ -14,6 +14,7 @@ use std::rc::Rc; FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/strdup.rs b/tests/unit/out/unsafe/strdup.rs index f8f193d880..d3a57644e4 100644 --- a/tests/unit/out/unsafe/strdup.rs +++ b/tests/unit/out/unsafe/strdup.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 db1f57c658..e7dabf0680 100644 --- a/tests/unit/out/unsafe/string_literal_ptr_init.rs +++ b/tests/unit/out/unsafe/string_literal_ptr_init.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct label { pub name: *const libc::c_char, diff --git a/tests/unit/out/unsafe/string_substr.rs b/tests/unit/out/unsafe/string_substr.rs index 8a30096f81..ed518f348e 100644 --- a/tests/unit/out/unsafe/string_substr.rs +++ b/tests/unit/out/unsafe/string_substr.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 eede3d9f91..d2e1e9ac30 100644 --- a/tests/unit/out/unsafe/struct_2d_array_field.rs +++ b/tests/unit/out/unsafe/struct_2d_array_field.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct table { pub rows: [[libc::c_char; 10]; 3], diff --git a/tests/unit/out/unsafe/struct_ctor.rs b/tests/unit/out/unsafe/struct_ctor.rs index 0590ff9da9..215d979b12 100644 --- a/tests/unit/out/unsafe/struct_ctor.rs +++ b/tests/unit/out/unsafe/struct_ctor.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct StructWithCtor { x1_: i32, @@ -39,6 +46,7 @@ pub unsafe fn foo_0(x: *mut i32) -> *mut i32 { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -63,6 +71,13 @@ impl Ptr_ { Value_::construct(&mut self.v2, { 22 }); } } +impl DefaultConstructibleUnsafe for Ptr_ { + unsafe fn default_constructor(&mut self) { + unsafe { + Ptr_::construct(&mut *self); + } + } +} impl Default for Ptr_ { fn default() -> Self { unsafe { diff --git a/tests/unit/out/unsafe/struct_default_ctor.rs b/tests/unit/out/unsafe/struct_default_ctor.rs index 639719e520..caf9880449 100644 --- a/tests/unit/out/unsafe/struct_default_ctor.rs +++ b/tests/unit/out/unsafe/struct_default_ctor.rs @@ -18,6 +18,13 @@ impl S { (&raw mut self.b).write(true); } } +impl DefaultConstructibleUnsafe for S { + unsafe fn default_constructor(&mut self) { + unsafe { + S::construct(&mut *self); + } + } +} impl Default for S { fn default() -> Self { unsafe { @@ -31,7 +38,14 @@ impl Default for S { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Declared { pub v: i32, @@ -44,12 +58,40 @@ impl Declared {} pub struct Holder { pub items: [S; 2], } +impl Holder { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.items).write(std::array::from_fn::<_, 2, _>(|_| { + let mut __v: S = ::zero_init(); + S::construct(&mut __v); + __v + })); + } +} +impl DefaultConstructibleUnsafe for Holder { + unsafe fn default_constructor(&mut self) { + unsafe { + Holder::construct_1(&mut *self); + } + } +} pub static mut kInit_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 3 }); #[repr(C)] #[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe)] pub struct FromStatic { pub v: i32, } +impl FromStatic { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.v).write((*std::cell::LazyCell::force_mut(&mut *&raw mut kInit_0))); + } +} +impl DefaultConstructibleUnsafe for FromStatic { + unsafe fn default_constructor(&mut self) { + unsafe { + FromStatic::construct_1(&mut *self); + } + } +} impl Default for FromStatic { fn default() -> Self { unsafe { diff --git a/tests/unit/out/unsafe/struct_member_array_adjacency.rs b/tests/unit/out/unsafe/struct_member_array_adjacency.rs index 3e0de4505b..4cedb93a0c 100644 --- a/tests/unit/out/unsafe/struct_member_array_adjacency.rs +++ b/tests/unit/out/unsafe/struct_member_array_adjacency.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct pair { pub a: [i32; 4], diff --git a/tests/unit/out/unsafe/struct_ptr.rs b/tests/unit/out/unsafe/struct_ptr.rs index 16cebb0e9f..c65158a1f3 100644 --- a/tests/unit/out/unsafe/struct_ptr.rs +++ b/tests/unit/out/unsafe/struct_ptr.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 6cd2a5ad8d..485ba731e0 100644 --- a/tests/unit/out/unsafe/structured_binding_copy_ctor.rs +++ b/tests/unit/out/unsafe/structured_binding_copy_ctor.rs @@ -13,6 +13,7 @@ pub static mut copies_0: std::cell::LazyCell = std::cell::LazyCell::new(|| FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, MovableUnsafe, Default, diff --git a/tests/unit/out/unsafe/structured_binding_element_ctor.rs b/tests/unit/out/unsafe/structured_binding_element_ctor.rs index 53168c11e1..9f0940098b 100644 --- a/tests/unit/out/unsafe/structured_binding_element_ctor.rs +++ b/tests/unit/out/unsafe/structured_binding_element_ctor.rs @@ -15,6 +15,7 @@ pub static mut moves_1: std::cell::LazyCell = std::cell::LazyCell::new(|| u ZeroInitializationUnsafe, CppFromUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -58,6 +59,7 @@ impl Clone for Elem { FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, 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 e771405876..4402ae6737 100644 --- a/tests/unit/out/unsafe/structured_binding_move_ctor.rs +++ b/tests/unit/out/unsafe/structured_binding_move_ctor.rs @@ -14,6 +14,7 @@ pub static mut moves_1: std::cell::LazyCell = std::cell::LazyCell::new(|| u FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -79,6 +80,17 @@ impl Holder { }); return; } + pub unsafe fn construct_1(&mut self) { + (&raw mut self.xs).write(Vec::new()); + (&raw mut self.ys).write(Vec::new()); + } +} +impl DefaultConstructibleUnsafe for Holder { + unsafe fn default_constructor(&mut self) { + unsafe { + Holder::construct_1(&mut *self); + } + } } pub fn main() { unsafe { diff --git a/tests/unit/out/unsafe/structured_binding_range_for.rs b/tests/unit/out/unsafe/structured_binding_range_for.rs index 0e7b34de55..e89e734b0d 100644 --- a/tests/unit/out/unsafe/structured_binding_range_for.rs +++ b/tests/unit/out/unsafe/structured_binding_range_for.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Pair { pub first: i32, diff --git a/tests/unit/out/unsafe/structured_binding_ref.rs b/tests/unit/out/unsafe/structured_binding_ref.rs index 22848283b9..afb0b3790b 100644 --- a/tests/unit/out/unsafe/structured_binding_ref.rs +++ b/tests/unit/out/unsafe/structured_binding_ref.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Triple { pub a: i32, diff --git a/tests/unit/out/unsafe/structured_binding_trivial.rs b/tests/unit/out/unsafe/structured_binding_trivial.rs index 5c791ba031..1d723cd70f 100644 --- a/tests/unit/out/unsafe/structured_binding_trivial.rs +++ b/tests/unit/out/unsafe/structured_binding_trivial.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Pair { pub first: i32, diff --git a/tests/unit/out/unsafe/swap_map_no_copy.rs b/tests/unit/out/unsafe/swap_map_no_copy.rs index 3e364975ed..fbad8de9c5 100644 --- a/tests/unit/out/unsafe/swap_map_no_copy.rs +++ b/tests/unit/out/unsafe/swap_map_no_copy.rs @@ -56,6 +56,13 @@ impl Clone for Tracked { } } } +impl DefaultConstructibleUnsafe for Tracked { + unsafe fn default_constructor(&mut self) { + unsafe { + Tracked::construct_2(&mut *self); + } + } +} impl Default for Tracked { fn default() -> Self { unsafe { @@ -89,6 +96,13 @@ impl Pair { Tracked::construct_2(&mut self.y); } } +impl DefaultConstructibleUnsafe for Pair { + unsafe fn default_constructor(&mut self) { + unsafe { + Pair::construct_1(&mut *self); + } + } +} #[repr(C)] #[derive( Clone, @@ -105,12 +119,41 @@ pub struct Arrays { pub a: [Tracked; 2], pub b: [Tracked; 2], } +impl Arrays { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.a).write(std::array::from_fn::<_, 2, _>(|_| { + let mut __v: Tracked = ::zero_init(); + Tracked::construct_2(&mut __v); + __v + })); + (&raw mut self.b).write(std::array::from_fn::<_, 2, _>(|_| { + let mut __v: Tracked = ::zero_init(); + Tracked::construct_2(&mut __v); + __v + })); + } +} +impl DefaultConstructibleUnsafe for Arrays { + unsafe fn default_constructor(&mut self) { + unsafe { + Arrays::construct_1(&mut *self); + } + } +} pub static mut copy_only_copies_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut copy_only_dtors_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive(VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, MovableUnsafe, Default)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DefaultConstructibleUnsafe, + MovableUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct CopyOnly { pub v: i32, @@ -154,6 +197,7 @@ impl Clone for CopyOnly { FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, MoveConstructibleUnsafe, SwappableUnsafe, @@ -170,7 +214,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, SwappableUnsafe, Default)] +#[derive( + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DefaultConstructibleUnsafe, + SwappableUnsafe, + Default, +)] #[cpp_from(i32, construct, value)] pub struct Moved { pub v: i32, @@ -229,6 +281,7 @@ impl Clone for Moved { FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, + DefaultConstructibleUnsafe, MemberwiseUnsafe, SwappableUnsafe, Default, @@ -266,6 +319,18 @@ pub unsafe fn swapped_once_6() -> bool { pub struct Owner { pub p: Option>, } +impl Owner { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.p).write(None); + } +} +impl DefaultConstructibleUnsafe for Owner { + unsafe fn default_constructor(&mut self) { + unsafe { + Owner::construct_1(&mut *self); + } + } +} pub fn main() { unsafe { __cpp2rust_init_globals(); @@ -550,7 +615,8 @@ unsafe fn main_0() -> i32 { }; 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(); + let mut arrays: Arrays = ::zero_init(); + Arrays::construct_1(&mut arrays); arrays.a[(0) as usize].v = 1; arrays.b[(1) as usize].v = 2; { diff --git a/tests/unit/out/unsafe/tag_vs_identifier_collision.rs b/tests/unit/out/unsafe/tag_vs_identifier_collision.rs index b877ab1c96..c4fdce8ed1 100644 --- a/tests/unit/out/unsafe/tag_vs_identifier_collision.rs +++ b/tests/unit/out/unsafe/tag_vs_identifier_collision.rs @@ -12,7 +12,14 @@ 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, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct widget { pub id: i32, @@ -20,14 +27,29 @@ pub struct widget { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct point_struct { pub x: i32, pub y: i32, } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, +)] pub union point { pub whole: i32, pub half: i16, @@ -38,7 +60,15 @@ impl Default for point { } } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, +)] pub union slot_union { pub i: i32, pub u: u32, @@ -53,21 +83,42 @@ pub const slot_SLOT_A: slot = 0; pub const slot_SLOT_B: slot = 1; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Inner { pub tag_field: i32, } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Outer { pub field: Inner, } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 e7439926b7..3e54f16e64 100644 --- a/tests/unit/out/unsafe/template_default_arg.rs +++ b/tests/unit/out/unsafe/template_default_arg.rs @@ -22,6 +22,13 @@ impl A { (&raw mut self.v).write(v); } } +impl DefaultConstructibleUnsafe for A { + unsafe fn default_constructor(&mut self) { + unsafe { + A::construct_2(&mut *self); + } + } +} impl Default for A { fn default() -> Self { unsafe { @@ -43,6 +50,13 @@ impl B { (&raw mut self.v).write(2); } } +impl DefaultConstructibleUnsafe for B { + unsafe fn default_constructor(&mut self) { + unsafe { + B::construct(&mut *self); + } + } +} impl Default for B { fn default() -> Self { unsafe { @@ -62,6 +76,7 @@ impl Default for B { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -94,6 +109,7 @@ pub unsafe fn always_given_3(mut x: NoDefault) -> i32 { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/template_static_member.rs b/tests/unit/out/unsafe/template_static_member.rs index bc79dde79b..88b41df568 100644 --- a/tests/unit/out/unsafe/template_static_member.rs +++ b/tests/unit/out/unsafe/template_static_member.rs @@ -9,27 +9,55 @@ 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, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Range_int_ {} pub static mut lo_5: std::cell::LazyCell = @@ -37,7 +65,14 @@ pub static mut lo_5: std::cell::LazyCell = pub static mut hi_6: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 2_i64 }); #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Range_long_ {} pub fn main() { diff --git a/tests/unit/out/unsafe/temporary_field_addr.rs b/tests/unit/out/unsafe/temporary_field_addr.rs index 7f21ff56bf..3c7222fe2d 100644 --- a/tests/unit/out/unsafe/temporary_field_addr.rs +++ b/tests/unit/out/unsafe/temporary_field_addr.rs @@ -22,6 +22,18 @@ use std::rc::Rc; pub struct Inner { pub values: Vec, } +impl Inner { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.values).write(Vec::new()); + } +} +impl DefaultConstructibleUnsafe for Inner { + unsafe fn default_constructor(&mut self) { + unsafe { + Inner::construct_1(&mut *self); + } + } +} #[repr(C)] #[derive( Clone, @@ -40,6 +52,20 @@ pub struct Outer { pub inner: Inner, pub name: [libc::c_char; 8], } +impl Outer { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.values).write(Vec::new()); + Inner::construct_1(&mut self.inner); + (&raw mut self.name).write([(0 as libc::c_char); 8]); + } +} +impl DefaultConstructibleUnsafe for Outer { + unsafe fn default_constructor(&mut self) { + unsafe { + Outer::construct_1(&mut *self); + } + } +} pub unsafe fn make_0(this: *mut Outer, calls: *mut i32) { (*calls).prefix_inc(); this.write(Outer { diff --git a/tests/unit/out/unsafe/temporary_field_ctor_arg.rs b/tests/unit/out/unsafe/temporary_field_ctor_arg.rs index 6f6520eed7..7fd3455d08 100644 --- a/tests/unit/out/unsafe/temporary_field_ctor_arg.rs +++ b/tests/unit/out/unsafe/temporary_field_ctor_arg.rs @@ -22,6 +22,18 @@ use std::rc::Rc; pub struct Outer { pub values: Vec, } +impl Outer { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.values).write(Vec::new()); + } +} +impl DefaultConstructibleUnsafe for Outer { + unsafe fn default_constructor(&mut self) { + unsafe { + Outer::construct_1(&mut *self); + } + } +} pub unsafe fn make_0(this: *mut Outer) { this.write(Outer { values: Vec::from([1, 2, 3, 4]), @@ -36,6 +48,7 @@ pub unsafe fn make_0(this: *mut Outer) { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/temporary_field_two_args.rs b/tests/unit/out/unsafe/temporary_field_two_args.rs index e2abfbf781..433a1a6b27 100644 --- a/tests/unit/out/unsafe/temporary_field_two_args.rs +++ b/tests/unit/out/unsafe/temporary_field_two_args.rs @@ -22,6 +22,18 @@ use std::rc::Rc; pub struct Inner { pub values: Vec, } +impl Inner { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.values).write(Vec::new()); + } +} +impl DefaultConstructibleUnsafe for Inner { + unsafe fn default_constructor(&mut self) { + unsafe { + Inner::construct_1(&mut *self); + } + } +} #[repr(C)] #[derive( Clone, @@ -39,6 +51,19 @@ pub struct Outer { pub values: Vec, pub inner: Inner, } +impl Outer { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.values).write(Vec::new()); + Inner::construct_1(&mut self.inner); + } +} +impl DefaultConstructibleUnsafe for Outer { + unsafe fn default_constructor(&mut self) { + unsafe { + Outer::construct_1(&mut *self); + } + } +} pub unsafe fn make_0(this: *mut Outer) { this.write(Outer { values: Vec::from([1, 2, 3]), diff --git a/tests/unit/out/unsafe/this.rs b/tests/unit/out/unsafe/this.rs index cca0ba2b77..1406ae60bf 100644 --- a/tests/unit/out/unsafe/this.rs +++ b/tests/unit/out/unsafe/this.rs @@ -14,6 +14,7 @@ use std::rc::Rc; FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -117,6 +118,7 @@ pub unsafe fn bump_0(mut p: *mut S) { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/typedef-anon-struct.rs b/tests/unit/out/unsafe/typedef-anon-struct.rs index fc3bf233d1..462abc8e35 100644 --- a/tests/unit/out/unsafe/typedef-anon-struct.rs +++ b/tests/unit/out/unsafe/typedef-anon-struct.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Outer_RunInfo { pub block_idx: i32, @@ -30,6 +37,18 @@ pub struct Outer_RunInfo { pub struct Outer { pub runs: Vec, } +impl Outer { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.runs).write(Vec::new()); + } +} +impl DefaultConstructibleUnsafe for Outer { + unsafe fn default_constructor(&mut self) { + unsafe { + Outer::construct_1(&mut *self); + } + } +} pub fn main() { unsafe { __cpp2rust_init_globals(); @@ -37,7 +56,8 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut o: Outer = ::default(); + let mut o: Outer = ::zero_init(); + Outer::construct_1(&mut o); let mut info: Outer_RunInfo = ::default(); info.block_idx = 1; info.num_extra_zero_runs = 2; 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 21d2a4b70d..9a0559bc53 100644 --- a/tests/unit/out/unsafe/unary_expr_or_type_trait.rs +++ b/tests/unit/out/unsafe/unary_expr_or_type_trait.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C, align(16))] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct S { pub c: libc::c_char, diff --git a/tests/unit/out/unsafe/unboxed_locals.rs b/tests/unit/out/unsafe/unboxed_locals.rs index ba618290d5..cbcac74707 100644 --- a/tests/unit/out/unsafe/unboxed_locals.rs +++ b/tests/unit/out/unsafe/unboxed_locals.rs @@ -14,7 +14,14 @@ pub unsafe fn inc_1(r: *mut i32) { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Pair { pub first: i32, @@ -54,7 +61,14 @@ pub unsafe trait Shape { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DestructibleUnsafe, + DefaultConstructibleUnsafe, + 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 e417e9742c..ec424b3a28 100644 --- a/tests/unit/out/unsafe/unboxed_records.rs +++ b/tests/unit/out/unsafe/unboxed_records.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Inner { pub a: i32, @@ -16,7 +23,14 @@ pub struct Inner { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Cookie { pub x: i32, @@ -34,6 +48,16 @@ impl Counter { pub unsafe fn inc(&mut self) { self.n.prefix_inc(); } + pub unsafe fn construct_1(&mut self) { + (&raw mut self.n).write(0); + } +} +impl DefaultConstructibleUnsafe for Counter { + unsafe fn default_constructor(&mut self) { + unsafe { + Counter::construct_1(&mut *self); + } + } } impl Default for Counter { fn default() -> Self { @@ -102,7 +126,8 @@ unsafe fn main_0() -> i32 { let mut field_addr: Inner = Inner { a: 0, b: 0 }; (unsafe { set_0((&mut field_addr.b as *mut i32), 7) }); assert!(((field_addr.b) == (7))); - let mut counter: Counter = ::default(); + let mut counter: Counter = ::zero_init(); + Counter::construct_1(&mut counter); (unsafe { Counter::inc(&mut counter) }); assert!(((counter.n) == (1))); return 0; diff --git a/tests/unit/out/unsafe/union_addrof_external.rs b/tests/unit/out/unsafe/union_addrof_external.rs index 0f754c8ee8..c1656623f2 100644 --- a/tests/unit/out/unsafe/union_addrof_external.rs +++ b/tests/unit/out/unsafe/union_addrof_external.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct record { pub code: u16, @@ -17,7 +24,15 @@ pub struct record { pub pad: [libc::c_char; 8], } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, +)] pub union anon_0 { pub h: record, pub raw_: [libc::c_char; 128], @@ -29,7 +44,14 @@ impl Default for anon_0 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 a7abc7ab17..770a41be0c 100644 --- a/tests/unit/out/unsafe/union_basic.rs +++ b/tests/unit/out/unsafe/union_basic.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(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, +)] pub union basic { pub i: i32, pub f: f32, @@ -18,7 +26,15 @@ impl Default for basic { } } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, +)] pub union empty { __empty: u8, } @@ -28,7 +44,15 @@ impl Default for empty { } } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, +)] pub union underscores { pub __: i32, pub ___: f64, @@ -91,7 +115,15 @@ unsafe fn main_0() -> i32 { return 0; } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, +)] 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 09ac989918..bae6b1f301 100644 --- a/tests/unit/out/unsafe/union_cross_arm_cast.rs +++ b/tests/unit/out/unsafe/union_cross_arm_cast.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct shape_a { pub code: u16, @@ -16,7 +23,14 @@ pub struct shape_a { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct shape_b { pub code: u16, @@ -26,7 +40,15 @@ pub struct shape_b { pub tail: u32, } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, +)] pub union anon_0 { pub a: shape_a, pub b: shape_b, @@ -39,7 +61,14 @@ impl Default for anon_0 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Container { pub len: u32, diff --git a/tests/unit/out/unsafe/union_field_alignment.rs b/tests/unit/out/unsafe/union_field_alignment.rs index e8e05f86a0..fa48910fa0 100644 --- a/tests/unit/out/unsafe/union_field_alignment.rs +++ b/tests/unit/out/unsafe/union_field_alignment.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(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, +)] pub union anon_0 { pub bytes: [u8; 1], pub aligner: *mut ::libc::c_void, @@ -19,7 +27,14 @@ impl Default for anon_0 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct node { pub next: *mut node, diff --git a/tests/unit/out/unsafe/union_flex_array_member.rs b/tests/unit/out/unsafe/union_flex_array_member.rs index db9fcda57c..a90a4d410d 100644 --- a/tests/unit/out/unsafe/union_flex_array_member.rs +++ b/tests/unit/out/unsafe/union_flex_array_member.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(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, +)] pub union anon_0 { pub bytes: [u8; 1], pub aligner: *mut ::libc::c_void, @@ -19,7 +27,14 @@ impl Default for anon_0 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct node { pub len: usize, diff --git a/tests/unit/out/unsafe/union_memset_memcpy.rs b/tests/unit/out/unsafe/union_memset_memcpy.rs index 55f7fccb24..8805d23fa4 100644 --- a/tests/unit/out/unsafe/union_memset_memcpy.rs +++ b/tests/unit/out/unsafe/union_memset_memcpy.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct shape_a { pub code: u16, @@ -16,7 +23,14 @@ pub struct shape_a { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct shape_b { pub code: u16, @@ -25,7 +39,15 @@ pub struct shape_b { pub fill: [libc::c_char; 8], } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, +)] pub union anon_0 { pub a: shape_a, pub b: shape_b, @@ -38,7 +60,14 @@ impl Default for anon_0 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 8d3fcb317c..5118a441e8 100644 --- a/tests/unit/out/unsafe/union_nested.rs +++ b/tests/unit/out/unsafe/union_nested.rs @@ -8,14 +8,29 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct record { pub code: u16, pub pad: [libc::c_char; 14], } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, +)] pub union anon_0 { pub h: record, pub raw_: [libc::c_char; 128], @@ -27,13 +42,28 @@ impl Default for anon_0 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct inner { pub view: anon_0, } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, +)] pub union anon_1 { pub h: record, pub nested: inner, @@ -45,7 +75,14 @@ impl Default for anon_1 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Outer { pub kind: i32, diff --git a/tests/unit/out/unsafe/union_pointer_pun_address.rs b/tests/unit/out/unsafe/union_pointer_pun_address.rs index 69afa6f4c5..a0d540a390 100644 --- a/tests/unit/out/unsafe/union_pointer_pun_address.rs +++ b/tests/unit/out/unsafe/union_pointer_pun_address.rs @@ -8,14 +8,28 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct node_a { pub n: i32, } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct node_b { pub data: *mut ::libc::c_void, @@ -36,7 +50,15 @@ unsafe fn main_0() -> i32 { return 0; } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, +)] 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 61886a058c..b9a9570992 100644 --- a/tests/unit/out/unsafe/union_pointer_pun_writethrough.rs +++ b/tests/unit/out/unsafe/union_pointer_pun_writethrough.rs @@ -21,7 +21,15 @@ unsafe fn main_0() -> i32 { return 0; } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, +)] 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 002cfff370..2153658726 100644 --- a/tests/unit/out/unsafe/union_struct_dual_use.rs +++ b/tests/unit/out/unsafe/union_struct_dual_use.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Inner { pub a: i32, @@ -18,7 +25,15 @@ pub unsafe fn sum_inner_0(mut i: *mut Inner) -> i32 { return (((*i).a) + ((*i).b)); } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, +)] pub union anon_1 { pub inner: Inner, pub raw_: [libc::c_char; 16], @@ -30,7 +45,14 @@ impl Default for anon_1 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 28a1e52f33..dde4703d4f 100644 --- a/tests/unit/out/unsafe/union_tagged_many_arms.rs +++ b/tests/unit/out/unsafe/union_tagged_many_arms.rs @@ -13,7 +13,15 @@ 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, TriviallyCopyableUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, +)] pub union anon_0 { pub text: *const libc::c_char, pub handle: *mut ::libc::c_void, @@ -28,7 +36,14 @@ impl Default for anon_0 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Slot { pub tag: Tag_enum, diff --git a/tests/unit/out/unsafe/union_tagged_simple.rs b/tests/unit/out/unsafe/union_tagged_simple.rs index 852e094d49..abf3ec2665 100644 --- a/tests/unit/out/unsafe/union_tagged_simple.rs +++ b/tests/unit/out/unsafe/union_tagged_simple.rs @@ -10,7 +10,15 @@ 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, TriviallyCopyableUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, +)] pub union anon_0 { pub obj: *mut ::libc::c_void, pub code: i32, @@ -22,7 +30,14 @@ impl Default for anon_0 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Event { pub kind: Kind_enum, diff --git a/tests/unit/out/unsafe/union_tagged_struct_arms.rs b/tests/unit/out/unsafe/union_tagged_struct_arms.rs index f55e0018a5..b51c40ab71 100644 --- a/tests/unit/out/unsafe/union_tagged_struct_arms.rs +++ b/tests/unit/out/unsafe/union_tagged_struct_arms.rs @@ -12,7 +12,14 @@ 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, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct anon_1 { pub items: *mut *mut libc::c_char, @@ -21,7 +28,14 @@ pub struct anon_1 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct anon_2 { pub lo: i32, @@ -31,7 +45,14 @@ pub struct anon_2 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct anon_3 { pub lo: i64, @@ -41,7 +62,15 @@ pub struct anon_3 { pub width: i32, } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, +)] pub union anon_0 { pub list: anon_1, pub letters: anon_2, @@ -54,7 +83,14 @@ impl Default for anon_0 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Branch { pub choice: Choice_enum, 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 4ab15acce4..d53652740d 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,15 @@ 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, TriviallyCopyableUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, +)] pub union anon_0 { pub text: *const libc::c_char, pub handle: *mut ::libc::c_void, @@ -25,7 +33,14 @@ impl Default for anon_0 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Sink { pub width: Width_enum, diff --git a/tests/unit/out/unsafe/unique_ptr.rs b/tests/unit/out/unsafe/unique_ptr.rs index c149f5685f..f534891291 100644 --- a/tests/unit/out/unsafe/unique_ptr.rs +++ b/tests/unit/out/unsafe/unique_ptr.rs @@ -27,10 +27,27 @@ impl SafePointer { .map_or(::std::ptr::null_mut(), |v| v as *const i32 as *mut i32)) .prefix_inc(); } + pub unsafe fn construct_1(&mut self) { + (&raw mut self.ptr).write(None); + } +} +impl DefaultConstructibleUnsafe for SafePointer { + unsafe fn default_constructor(&mut self) { + unsafe { + SafePointer::construct_1(&mut *self); + } + } } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Pair { pub x: i32, diff --git a/tests/unit/out/unsafe/unique_ptr_const_deref.rs b/tests/unit/out/unsafe/unique_ptr_const_deref.rs index e94b5ca597..cff5e65a8c 100644 --- a/tests/unit/out/unsafe/unique_ptr_const_deref.rs +++ b/tests/unit/out/unsafe/unique_ptr_const_deref.rs @@ -19,6 +19,18 @@ use std::rc::Rc; pub struct Holder { pub val: Option>, } +impl Holder { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.val).write(None); + } +} +impl DefaultConstructibleUnsafe for Holder { + unsafe fn default_constructor(&mut self) { + unsafe { + Holder::construct_1(&mut *self); + } + } +} pub unsafe fn read_val_0(mut h: *const Holder) -> i32 { return (*(*h) .val @@ -38,7 +50,8 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut h: Holder = ::default(); + let mut h: Holder = ::zero_init(); + Holder::construct_1(&mut h); { h.val = Some(Box::new(10)).take(); }; diff --git a/tests/unit/out/unsafe/unique_ptr_field_reset.rs b/tests/unit/out/unsafe/unique_ptr_field_reset.rs index af0389c13b..e9e4a99bc1 100644 --- a/tests/unit/out/unsafe/unique_ptr_field_reset.rs +++ b/tests/unit/out/unsafe/unique_ptr_field_reset.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Data { pub v: i32, @@ -38,6 +45,17 @@ impl Holder { } }; } + pub unsafe fn construct_1(&mut self) { + (&raw mut self.data).write(None); + (&raw mut self.n).write(0_i32); + } +} +impl DefaultConstructibleUnsafe for Holder { + unsafe fn default_constructor(&mut self) { + unsafe { + Holder::construct_1(&mut *self); + } + } } pub fn main() { unsafe { @@ -46,7 +64,8 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut h: Holder = ::default(); + let mut h: Holder = ::zero_init(); + Holder::construct_1(&mut h); h.n = 1; let mut hp: *mut Holder = (&mut h as *mut Holder); { diff --git a/tests/unit/out/unsafe/unique_ptr_nested.rs b/tests/unit/out/unsafe/unique_ptr_nested.rs index 1e46c6f7f9..8e7fdb1193 100644 --- a/tests/unit/out/unsafe/unique_ptr_nested.rs +++ b/tests/unit/out/unsafe/unique_ptr_nested.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Inner { pub x: i32, @@ -27,6 +34,18 @@ pub struct Inner { pub struct Outer { pub inner: Option>, } +impl Outer { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.inner).write(None); + } +} +impl DefaultConstructibleUnsafe for Outer { + unsafe fn default_constructor(&mut self) { + unsafe { + Outer::construct_1(&mut *self); + } + } +} pub fn main() { unsafe { __cpp2rust_init_globals(); diff --git a/tests/unit/out/unsafe/unique_ptr_struct.rs b/tests/unit/out/unsafe/unique_ptr_struct.rs index a19bcfabac..4135e2b7bd 100644 --- a/tests/unit/out/unsafe/unique_ptr_struct.rs +++ b/tests/unit/out/unsafe/unique_ptr_struct.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Point { pub x: i32, diff --git a/tests/unit/out/unsafe/va_arg_mixed_types.rs b/tests/unit/out/unsafe/va_arg_mixed_types.rs index bfbaf84296..79016ef237 100644 --- a/tests/unit/out/unsafe/va_arg_mixed_types.rs +++ b/tests/unit/out/unsafe/va_arg_mixed_types.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct pair { pub a: 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 203e407a40..c9f51cc2f6 100644 --- a/tests/unit/out/unsafe/va_arg_non_primitive_ptrs.rs +++ b/tests/unit/out/unsafe/va_arg_non_primitive_ptrs.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct node { pub data: i32, diff --git a/tests/unit/out/unsafe/va_arg_struct_ctx.rs b/tests/unit/out/unsafe/va_arg_struct_ctx.rs index f8beb11294..54450ad99c 100644 --- a/tests/unit/out/unsafe/va_arg_struct_ctx.rs +++ b/tests/unit/out/unsafe/va_arg_struct_ctx.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct context { pub verbose: i32, @@ -26,7 +33,15 @@ pub unsafe fn set_error_0( } } #[repr(C)] -#[derive(Copy, Clone, FnPtrArg, VaArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe)] +#[derive( + Copy, + Clone, + FnPtrArg, + VaArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, +)] 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 134c4d2127..e8c6f42b68 100644 --- a/tests/unit/out/unsafe/va_arg_void_ptr.rs +++ b/tests/unit/out/unsafe/va_arg_void_ptr.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct registry { pub slot: *mut ::libc::c_void, diff --git a/tests/unit/out/unsafe/va_list_field.rs b/tests/unit/out/unsafe/va_list_field.rs index dfa3571717..788e47d132 100644 --- a/tests/unit/out/unsafe/va_list_field.rs +++ b/tests/unit/out/unsafe/va_list_field.rs @@ -28,7 +28,14 @@ pub unsafe fn sum_0(mut n: i32, __args: Box<[VaArg]>) -> i32 { } #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, CopyableUnsafe, Default, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + CppFromUnsafe, + DefaultConstructibleUnsafe, + CopyableUnsafe, + Default, )] #[cpp_from(*const VaArg , construct, mut_ptr)] pub struct Guard_1 { @@ -66,7 +73,14 @@ pub unsafe fn sum_ptr_2(mut n: i32, __args: Box<[VaArg]>) -> i32 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + 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 9a18bc7161..92fe1f5c29 100644 --- a/tests/unit/out/unsafe/vector.rs +++ b/tests/unit/out/unsafe/vector.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct S { pub x: i32, @@ -31,6 +38,19 @@ pub struct Foo { pub a: Vec, pub b: Vec, } +impl Foo { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.a).write(Vec::new()); + (&raw mut self.b).write(Vec::new()); + } +} +impl DefaultConstructibleUnsafe for Foo { + unsafe fn default_constructor(&mut self) { + unsafe { + Foo::construct_1(&mut *self); + } + } +} #[repr(C)] #[derive( Copy, @@ -39,6 +59,7 @@ pub struct Foo { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -390,7 +411,8 @@ unsafe fn main_0() -> i32 { ((((v10.len()) == (1_usize)) && ((v10[(0_usize)]) == (4))) && ((v11.len()) == (3_usize))) && ((v11[(2_usize)]) == (3)) ); - let mut foo: Foo = ::default(); + let mut foo: Foo = ::zero_init(); + Foo::construct_1(&mut foo); { let __a1 = 5; foo.a.push(__a1) diff --git a/tests/unit/out/unsafe/vector_iter_range_ctor.rs b/tests/unit/out/unsafe/vector_iter_range_ctor.rs index c01dfed5bc..42e9e768e9 100644 --- a/tests/unit/out/unsafe/vector_iter_range_ctor.rs +++ b/tests/unit/out/unsafe/vector_iter_range_ctor.rs @@ -14,6 +14,7 @@ use std::rc::Rc; FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -34,6 +35,7 @@ impl Degrees { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/vector_subscript_direct.rs b/tests/unit/out/unsafe/vector_subscript_direct.rs index 19e48705ef..120e9e8d88 100644 --- a/tests/unit/out/unsafe/vector_subscript_direct.rs +++ b/tests/unit/out/unsafe/vector_subscript_direct.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Point { pub x: i32, @@ -36,6 +43,19 @@ pub struct Holder { pub values: Vec, pub points: Vec, } +impl Holder { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.values).write(Vec::new()); + (&raw mut self.points).write(Vec::new()); + } +} +impl DefaultConstructibleUnsafe for Holder { + unsafe fn default_constructor(&mut self) { + unsafe { + Holder::construct_1(&mut *self); + } + } +} pub unsafe fn push_and_index_0(v: *mut Vec) -> i32 { { let __a1 = 42; @@ -96,7 +116,8 @@ unsafe fn main_0() -> i32 { (*p) = 9; assert!(((v[(2_usize)]) == (9))); assert!(((unsafe { sum_ref_1(&v,) }) == (((((3) + (0)) + (9)) + (42)) + (5)))); - let mut h: Holder = ::default(); + let mut h: Holder = ::zero_init(); + Holder::construct_1(&mut h); h.values.resize_with(2_usize, || 0_i32); h.values[(1_usize)] = 6; { diff --git a/tests/unit/out/unsafe/vector_with_allocator.rs b/tests/unit/out/unsafe/vector_with_allocator.rs index 6ea2e26239..6d4afbc96f 100644 --- a/tests/unit/out/unsafe/vector_with_allocator.rs +++ b/tests/unit/out/unsafe/vector_with_allocator.rs @@ -8,7 +8,14 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct TestAllocator_int_ {} impl TestAllocator_int_ { @@ -30,7 +37,14 @@ impl TestAllocator_int_ { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct TestAllocator_double_ {} impl TestAllocator_double_ { diff --git a/tests/unit/out/unsafe/void_cast.rs b/tests/unit/out/unsafe/void_cast.rs index 4851a690fa..a745444ef9 100644 --- a/tests/unit/out/unsafe/void_cast.rs +++ b/tests/unit/out/unsafe/void_cast.rs @@ -23,6 +23,18 @@ pub unsafe fn unused_param_0(mut x: i32) {} pub struct NonTrivial { pub data: Vec, } +impl NonTrivial { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.data).write(Vec::new()); + } +} +impl DefaultConstructibleUnsafe for NonTrivial { + unsafe fn default_constructor(&mut self) { + unsafe { + NonTrivial::construct_1(&mut *self); + } + } +} pub unsafe fn unused_ref_param_1(x: *const NonTrivial) {} pub unsafe fn unused_ptr_param_2(mut p: *const NonTrivial) {} pub static mut side_effect_counter_3: std::cell::LazyCell = @@ -33,7 +45,14 @@ pub unsafe fn bump_and_return_4() -> i32 { } #[repr(C)] #[derive( - Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + DefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, )] pub struct Holder { pub field: i32, @@ -51,6 +70,18 @@ pub struct Holder { pub struct NonCopyable { pub value: Option>, } +impl NonCopyable { + pub unsafe fn construct_1(&mut self) { + (&raw mut self.value).write(None); + } +} +impl DefaultConstructibleUnsafe for NonCopyable { + unsafe fn default_constructor(&mut self) { + unsafe { + NonCopyable::construct_1(&mut *self); + } + } +} pub unsafe fn unused_noncopyable_param_5(x: *const NonCopyable) {} pub fn main() { unsafe { @@ -101,7 +132,8 @@ unsafe fn main_0() -> i32 { let mut arr: [i32; 3] = [1, 2, 3]; let mut h: Holder = Holder { field: 17 }; let mut hp: *mut Holder = (&mut h as *mut Holder); - let mut nt: NonTrivial = ::default(); + let mut nt: NonTrivial = ::zero_init(); + NonTrivial::construct_1(&mut nt); (unsafe { unused_ref_param_1(&nt) }); (unsafe { unused_ptr_param_2((&mut nt as *mut NonTrivial).cast_const()) }); let mut g: NonCopyable = NonCopyable { From d749782b32296ca9bd15400f751e1e74e40a4668 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Wed, 2 Dec 2026 12:41:36 +0000 Subject: [PATCH 02/13] Add DefaultConstructible and DefaultInitializable --- libcc2rs/src/constructor.rs | 60 +++++++++++++++++++++++++++++++++++++ libcc2rs/src/lib.rs | 8 +++-- 2 files changed, 65 insertions(+), 3 deletions(-) diff --git a/libcc2rs/src/constructor.rs b/libcc2rs/src/constructor.rs index c62805e4c6..5d9fa7ac46 100644 --- a/libcc2rs/src/constructor.rs +++ b/libcc2rs/src/constructor.rs @@ -10,6 +10,10 @@ use crate::rc::Ptr; use crate::reinterpret::ByteRepr; use crate::void::AnyPtr; +pub trait DefaultConstructible: Sized { + fn default_constructor(this: &Ptr); +} + pub trait MoveConstructible: Sized { fn move_constructor(this: &Ptr, src: Ptr); } @@ -42,6 +46,10 @@ pub trait Swappable: Sized { fn swap(this: &Ptr, other: Ptr); } +pub trait DefaultInitializable: DefaultConstructible + Destructible {} + +impl DefaultInitializable for T {} + pub trait Movable: MoveConstructible + MoveAssignable + Swappable + Destructible {} impl Movable for T {} @@ -69,6 +77,12 @@ impl< { } +pub trait DefaultConstructibleUnsafe { + /// # Safety + /// `self` must be valid for writes. + unsafe fn default_constructor(&mut self); +} + pub trait MoveConstructibleUnsafe { /// # Safety /// `src` must point to a live value. @@ -115,6 +129,10 @@ pub trait SwappableUnsafe { unsafe fn swap(&mut self, other: *mut Self); } +pub trait DefaultInitializableUnsafe: DefaultConstructibleUnsafe + DestructibleUnsafe {} + +impl DefaultInitializableUnsafe for T {} + pub trait MovableUnsafe: MoveConstructibleUnsafe + MoveAssignableUnsafe + SwappableUnsafe + DestructibleUnsafe { @@ -399,6 +417,48 @@ macro_rules! impl_move_by_take { } pub(crate) use impl_move_by_take; +macro_rules! impl_default_by_default { + ($(<$($param:ident),*> $ty:ty),* $(,)?) => {$( + impl<$($param),*> $crate::DefaultConstructible for $ty + where + $ty: Default + $crate::ByteRepr, + { + fn default_constructor(this: &$crate::Ptr) { + this.write(Self::default()); + } + } + + impl<$($param),*> $crate::DefaultConstructibleUnsafe for $ty + where + $ty: Default, + { + unsafe fn default_constructor(&mut self) { + unsafe { std::ptr::write(self, Self::default()) } + } + } + )*}; +} + +impl_default_by_default!( + <> (), + <> bool, + <> i8, + <> u8, + <> i16, + <> u16, + <> i32, + <> u32, + <> i64, + <> u64, + <> i128, + <> u128, + <> isize, + <> usize, + <> f32, + <> f64, + Ptr, +); + impl_trivial_copy_move!( (), bool, diff --git a/libcc2rs/src/lib.rs b/libcc2rs/src/lib.rs index 165c836eae..ab37d61f7a 100644 --- a/libcc2rs/src/lib.rs +++ b/libcc2rs/src/lib.rs @@ -49,7 +49,8 @@ pub use capture::{ mod constructor; pub use constructor::{ CopyAssignable, CopyAssignableUnsafe, CopyConstructible, CopyConstructibleUnsafe, Copyable, - CopyableUnsafe, Movable, MovableUnsafe, MoveAssignable, MoveAssignableUnsafe, + CopyableUnsafe, DefaultConstructible, DefaultConstructibleUnsafe, DefaultInitializable, + DefaultInitializableUnsafe, Movable, MovableUnsafe, MoveAssignable, MoveAssignableUnsafe, MoveConstructible, MoveConstructibleUnsafe, Swappable, SwappableUnsafe, TriviallyCopyAssignable, TriviallyCopyAssignableUnsafe, TriviallyCopyConstructible, TriviallyCopyConstructibleUnsafe, TriviallyCopyable, TriviallyCopyableUnsafe, @@ -119,8 +120,9 @@ pub use format::*; pub use libcc2rs_macros::{ ByteRepr, CopyAssignable, CopyAssignableUnsafe, CopyConstructible, CopyConstructibleUnsafe, - Copyable, CopyableUnsafe, CppFrom, CppFromUnsafe, Destructible, DestructibleUnsafe, FnPtrArg, - Memberwise, MemberwiseUnsafe, Movable, MovableUnsafe, MoveAssignable, MoveAssignableUnsafe, + Copyable, CopyableUnsafe, CppFrom, CppFromUnsafe, DefaultConstructible, + DefaultConstructibleUnsafe, Destructible, DestructibleUnsafe, FnPtrArg, Memberwise, + MemberwiseUnsafe, Movable, MovableUnsafe, MoveAssignable, MoveAssignableUnsafe, MoveConstructible, MoveConstructibleUnsafe, Record, Swappable, SwappableUnsafe, TriviallyCopyable, TriviallyCopyableUnsafe, VaArg, ZeroInitialization, ZeroInitializationUnsafe, goto, goto_block, lambda, lambda_unsafe, switch, From b53e45aa2bce6ad038ccbeca88bba9daad7e0c37 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Wed, 2 Dec 2026 12:46:05 +0000 Subject: [PATCH 03/13] Update tests --- .../out/refcount/defaulted_move_cross_tu.rs | 10 +- .../out/unsafe/defaulted_move_cross_tu.rs | 9 +- .../out/refcount/friend_operator.rs | 3 +- .../out/unsafe/friend_operator.rs | 3 +- .../refcount/out_of_line_methods_cross_tu.rs | 3 +- .../unsafe/out_of_line_methods_cross_tu.rs | 3 +- .../template_method_late_instantiation.rs | 10 +- .../template_method_late_instantiation.rs | 9 +- .../out/refcount/p14-class-in-two-files.rs | 30 ++- .../out/unsafe/p14-class-in-two-files.rs | 29 ++- .../p15-class-template-static-member.rs | 30 ++- .../p15-class-template-static-member.rs | 29 ++- .../out/refcount/p15-function-template.rs | 37 ++-- .../out/unsafe/p15-function-template.rs | 36 ++-- .../out/refcount/p15-inline-function.rs | 25 +-- .../out/unsafe/p15-inline-function.rs | 24 +-- .../out/refcount/p15-inline-variable.rs | 25 +-- .../out/unsafe/p15-inline-variable.rs | 24 +-- .../p16-default-argument-lambda-in-class.rs | 28 +-- .../p16-default-argument-lambda-in-class.rs | 27 +-- .../refcount/p16-lambda-in-inline-function.rs | 25 +-- .../unsafe/p16-lambda-in-inline-function.rs | 24 +-- .../basic.link/out/refcount/basic.link.rs | 83 ++----- .../basic/basic.link/out/unsafe/basic.link.rs | 68 ++---- .../out/refcount/basic.scope.block.rs | 35 ++- .../out/refcount/basic.scope.class.rs | 22 +- .../out/refcount/basic.scope.pdecl.rs | 33 +-- .../out/refcount/basic.scope.scope.rs | 67 +++--- .../out/unsafe/basic.scope.block.rs | 34 ++- .../out/unsafe/basic.scope.class.rs | 20 +- .../out/unsafe/basic.scope.pdecl.rs | 18 +- .../out/unsafe/basic.scope.scope.rs | 64 +++--- .../out/refcount/basic.start.term.rs | 6 +- .../out/unsafe/basic.start.term.rs | 6 +- .../out/refcount/basic.types.general.rs | 6 +- .../out/unsafe/basic.types.general.rs | 6 +- tests/std/basic/out/refcount/basic.def.odr.rs | 150 +++---------- tests/std/basic/out/unsafe/basic.def.odr.rs | 112 +++------- .../class.conv/out/refcount/class.conv.fct.rs | 3 +- .../class.conv/out/unsafe/class.conv.fct.rs | 3 +- .../class.mem/out/refcount/class.free.rs | 6 +- .../out/refcount/class.mem.general.rs | 22 +- .../class/class.mem/out/unsafe/class.free.rs | 6 +- .../class.mem/out/unsafe/class.mem.general.rs | 18 +- .../dcl.init.general-p6.2-padding-bits.rs | 9 +- .../dcl.init/out/refcount/dcl.init.general.rs | 84 ++------ .../dcl.init.general-p6.2-padding-bits.rs | 9 +- .../dcl.init/out/unsafe/dcl.init.general.rs | 56 ++--- .../dcl.meaning/out/refcount/dcl.array.rs | 3 +- .../out/refcount/dcl.fct.default.rs | 23 +- .../dcl.meaning/out/refcount/dcl.mptr.rs | 22 +- .../dcl.meaning/out/unsafe/dcl.array.rs | 3 +- .../dcl.meaning/out/unsafe/dcl.fct.default.rs | 21 +- .../dcl.meaning/out/unsafe/dcl.mptr.rs | 15 +- tests/std/expr/conv/out/refcount/conv.mem.rs | 3 +- tests/std/expr/conv/out/unsafe/conv.mem.rs | 3 +- .../expr.post/out/refcount/expr.const.cast.rs | 3 +- ...nterpret.cast-p10-result-is-unspecified.rs | 6 +- .../out/refcount/expr.reinterpret.cast.rs | 12 +- .../expr.post/out/unsafe/expr.const.cast.rs | 3 +- ...nterpret.cast-p10-result-is-unspecified.rs | 6 +- .../out/unsafe/expr.reinterpret.cast.rs | 12 +- .../expr.unary/out/refcount/expr.pre.incr.rs | 3 +- .../expr.unary/out/refcount/expr.unary.op.rs | 9 +- .../expr.unary/out/unsafe/expr.pre.incr.rs | 3 +- .../expr.unary/out/unsafe/expr.unary.op.rs | 9 +- .../expr.compound/out/refcount/expr.cond.rs | 3 +- .../expr.compound/out/refcount/expr.eq.rs | 9 +- ...ptr.oper-p6-null-pointer-to-data-member.rs | 3 +- .../out/refcount/expr.mptr.oper.rs | 15 +- .../expr.compound/out/unsafe/expr.cond.rs | 3 +- .../expr/expr.compound/out/unsafe/expr.eq.rs | 9 +- ...ptr.oper-p6-null-pointer-to-data-member.rs | 3 +- .../out/unsafe/expr.mptr.oper.rs | 15 +- .../allocator.requirements.general.rs | 14 +- .../unsafe/allocator.requirements.general.rs | 15 +- .../stmt.select/out/refcount/stmt.if.rs | 24 +-- .../stmt.select/out/refcount/stmt.switch.rs | 25 +-- .../stmt.select/out/unsafe/stmt.if.rs | 23 +- .../stmt.select/out/unsafe/stmt.switch.rs | 24 +-- tests/std/temp/out/refcount/temp.type.rs | 12 +- tests/std/temp/out/unsafe/temp.type.rs | 12 +- .../temp/temp.spec/out/refcount/temp.inst.rs | 28 +-- .../temp/temp.spec/out/unsafe/temp.inst.rs | 20 +- .../utility/out/refcount/forward-helpers.rs | 14 +- .../utilities/utility/out/refcount/forward.rs | 3 +- .../utility/out/refcount/utility.as.const.rs | 3 +- .../utility/out/unsafe/forward-helpers.rs | 11 +- .../utilities/utility/out/unsafe/forward.rs | 3 +- .../utility/out/unsafe/utility.as.const.rs | 3 +- .../refcount/self_referencing_initializer.rs | 3 +- .../unsafe/self_referencing_initializer.rs | 3 +- tests/unit/out/refcount/05_new.rs | 6 +- tests/unit/out/refcount/10_struct.rs | 25 +-- tests/unit/out/refcount/addr_of_global.rs | 6 +- tests/unit/out/refcount/anonymous-struct.rs | 27 ++- tests/unit/out/refcount/anonymous_enum.rs | 6 +- .../out/refcount/array_of_noncopy_struct.rs | 16 +- tests/unit/out/refcount/array_reference.rs | 3 +- tests/unit/out/refcount/as_const.rs | 3 +- tests/unit/out/refcount/assign_rhs_first.rs | 3 +- .../out/refcount/assignment_single_eval.rs | 58 +++-- tests/unit/out/refcount/bounded_struct_ptr.rs | 3 +- tests/unit/out/refcount/bst.rs | 3 +- tests/unit/out/refcount/cast.rs | 32 +-- .../refcount/cast_array_to_pointer_decay.rs | 10 +- tests/unit/out/refcount/class.rs | 12 +- .../refcount/class_template_lazy_member.rs | 15 +- tests/unit/out/refcount/class_templates.rs | 57 +++-- tests/unit/out/refcount/clone_vs_move.rs | 3 +- tests/unit/out/refcount/comma_operator.rs | 3 +- tests/unit/out/refcount/complex_function.rs | 9 +- .../out/refcount/compound_assign_paren.rs | 3 +- tests/unit/out/refcount/concepts.rs | 3 +- tests/unit/out/refcount/constexpr_function.rs | 6 +- tests/unit/out/refcount/constructor.rs | 16 +- .../unit/out/refcount/container_field_addr.rs | 18 +- .../conversion_operator_same_translation.rs | 6 +- tests/unit/out/refcount/copy_assign.rs | 60 ++---- tests/unit/out/refcount/copy_ctor.rs | 46 ++-- .../unit/out/refcount/copy_move_defaulted.rs | 203 +++++------------- tests/unit/out/refcount/copy_move_deleted.rs | 54 ++--- tests/unit/out/refcount/default.rs | 30 +-- tests/unit/out/refcount/default_in_statics.rs | 16 +- tests/unit/out/refcount/delete_array_order.rs | 3 +- tests/unit/out/refcount/destructor.rs | 33 +-- tests/unit/out/refcount/destructor_params.rs | 3 +- .../out/refcount/destructor_temporaries.rs | 6 +- tests/unit/out/refcount/doubly_linked_list.rs | 3 +- tests/unit/out/refcount/enum_int_interop.rs | 3 +- .../unit/out/refcount/enum_underlying_type.rs | 14 +- tests/unit/out/refcount/exprs.rs | 6 +- tests/unit/out/refcount/fft.rs | 3 +- .../unit/out/refcount/field_array_elem_ptr.rs | 13 +- .../out/refcount/field_method_receiver.rs | 25 +-- tests/unit/out/refcount/field_pointers.rs | 31 +-- .../field_pointers_malloced_struct.rs | 3 +- tests/unit/out/refcount/find.rs | 3 +- tests/unit/out/refcount/fn_ptr_cast.rs | 3 +- tests/unit/out/refcount/fn_ptr_stable_sort.rs | 3 +- tests/unit/out/refcount/fn_ptr_struct.rs | 6 +- tests/unit/out/refcount/fn_ptr_vtable.rs | 3 +- .../unit/out/refcount/for_body_destructor.rs | 3 +- .../refcount/foreach_disjoint_field_borrow.rs | 16 +- tests/unit/out/refcount/friend.rs | 12 +- .../unit/out/refcount/function_overloading.rs | 3 +- .../out/refcount/global_call_temporaries.rs | 3 +- .../out/refcount/global_non_const_init.rs | 41 ++-- tests/unit/out/refcount/global_pointers.rs | 3 +- .../refcount/global_without_initializer.rs | 3 +- tests/unit/out/refcount/huffman.rs | 19 +- .../refcount/immutable-deref-on-func-call.rs | 3 +- tests/unit/out/refcount/implicit_autoref.rs | 14 +- .../refcount/in_class_field_initializer.rs | 34 +-- tests/unit/out/refcount/init.rs | 3 +- tests/unit/out/refcount/init_list.rs | 25 +-- .../out/refcount/inline_container_fields.rs | 68 ++---- tests/unit/out/refcount/kruskal.rs | 31 +-- tests/unit/out/refcount/lambda_as_field.rs | 13 +- .../out/refcount/lambda_capture_copy_ctor.rs | 52 ++--- tests/unit/out/refcount/lambda_capture_ref.rs | 3 +- .../out/refcount/lambda_capture_star_this.rs | 3 +- .../unit/out/refcount/lambda_capture_this.rs | 3 +- .../unit/out/refcount/lambda_capture_value.rs | 3 +- .../unit/out/refcount/lambda_decltype_type.rs | 52 ++--- .../refcount/lambda_generic_explicit_args.rs | 3 +- .../out/refcount/lambda_immediate_init.rs | 34 ++- tests/unit/out/refcount/lambda_nested.rs | 3 +- .../unit/out/refcount/lambda_static_local.rs | 3 +- .../refcount/libc_struct_without_default.rs | 30 +-- tests/unit/out/refcount/linked_list.rs | 3 +- .../out/refcount/local_record_template.rs | 12 +- tests/unit/out/refcount/map.rs | 20 +- tests/unit/out/refcount/map_key_identity.rs | 19 +- tests/unit/out/refcount/map_try_emplace.rs | 38 ++-- .../out/refcount/map_try_emplace_lvalues.rs | 154 +++++-------- .../unit/out/refcount/memcpy_struct_struct.rs | 3 +- tests/unit/out/refcount/move_assign.rs | 18 +- tests/unit/out/refcount/move_ctor.rs | 14 +- tests/unit/out/refcount/nested_structs.rs | 18 +- tests/unit/out/refcount/new.rs | 3 +- tests/unit/out/refcount/new_bst.rs | 3 +- tests/unit/out/refcount/new_struct.rs | 6 +- .../refcount/nttp_distinct_specializations.rs | 9 +- tests/unit/out/refcount/offsetof.rs | 13 +- tests/unit/out/refcount/opaque_record_copy.rs | 6 +- .../out/refcount/operator_arithmetic_free.rs | 3 +- .../refcount/operator_arithmetic_member.rs | 3 +- .../out/refcount/operator_bitwise_free.rs | 3 +- .../out/refcount/operator_bitwise_member.rs | 3 +- .../refcount/operator_comparison_defaulted.rs | 24 ++- .../out/refcount/operator_comparison_free.rs | 6 +- .../refcount/operator_comparison_member.rs | 3 +- .../out/refcount/operator_comparison_mixed.rs | 3 +- .../refcount/operator_comparison_nonbool.rs | 18 +- .../operator_compound_assignment_free.rs | 3 +- .../operator_compound_assignment_member.rs | 3 +- tests/unit/out/refcount/operator_friend.rs | 21 +- tests/unit/out/refcount/operator_less_than.rs | 3 +- .../out/refcount/operator_logical_free.rs | 3 +- .../out/refcount/operator_logical_member.rs | 3 +- .../refcount/operator_member_pointer_free.rs | 13 +- .../operator_member_pointer_member.rs | 16 +- .../unit/out/refcount/operator_other_free.rs | 3 +- .../out/refcount/operator_other_member.rs | 6 +- tests/unit/out/refcount/operator_overloads.rs | 3 +- .../unit/out/refcount/operator_qualifiers.rs | 3 +- tests/unit/out/refcount/operator_three_way.rs | 3 +- tests/unit/out/refcount/operator_traits.rs | 15 +- tests/unit/out/refcount/overload_mangling.rs | 9 +- .../refcount/pair_converting_construction.rs | 6 +- tests/unit/out/refcount/pod.rs | 3 +- tests/unit/out/refcount/pointer_array.rs | 10 +- tests/unit/out/refcount/pointers.rs | 3 +- tests/unit/out/refcount/push_emplace_back.rs | 76 ++----- tests/unit/out/refcount/random.rs | 3 +- tests/unit/out/refcount/reference_wrapper.rs | 3 +- tests/unit/out/refcount/references.rs | 13 +- tests/unit/out/refcount/refs_as_args.rs | 3 +- .../out/refcount/reinterpret_cast_ptr_cmp.rs | 23 +- .../out/refcount/reinterpret_cast_struct.rs | 3 +- .../reinterpret_cast_struct_to_struct.rs | 6 +- tests/unit/out/refcount/reserved_keywords.rs | 9 +- tests/unit/out/refcount/return_move.rs | 6 +- .../scalar_builtin_construct_destruct.rs | 3 +- .../refcount/self_referencing_initializer.rs | 20 +- .../unit/out/refcount/size_t_static_member.rs | 6 +- tests/unit/out/refcount/sort_no_copy.rs | 40 ++-- tests/unit/out/refcount/static_local.rs | 3 +- .../unit/out/refcount/static_var_in_class.rs | 6 +- tests/unit/out/refcount/struct_ctor.rs | 18 +- .../unit/out/refcount/struct_default_ctor.rs | 68 ++---- tests/unit/out/refcount/struct_ptr.rs | 3 +- .../refcount/structured_binding_move_ctor.rs | 10 +- .../refcount/structured_binding_range_for.rs | 3 +- .../out/refcount/structured_binding_ref.rs | 3 +- .../refcount/structured_binding_trivial.rs | 3 +- tests/unit/out/refcount/swap_map_no_copy.rs | 76 ++----- .../unit/out/refcount/template_default_arg.rs | 28 +-- .../out/refcount/template_static_member.rs | 15 +- .../unit/out/refcount/temporary_field_addr.rs | 28 +-- .../out/refcount/temporary_field_ctor_arg.rs | 12 +- .../out/refcount/temporary_field_two_args.rs | 26 +-- .../unit/out/refcount/typedef-anon-struct.rs | 17 +- .../out/refcount/unary_expr_or_type_trait.rs | 3 +- tests/unit/out/refcount/unboxed_locals.rs | 3 +- tests/unit/out/refcount/unboxed_records.rs | 23 +- tests/unit/out/refcount/unique_ptr.rs | 11 +- .../out/refcount/unique_ptr_const_deref.rs | 14 +- .../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 | 3 +- tests/unit/out/refcount/va_list_field.rs | 3 +- tests/unit/out/refcount/vector.rs | 19 +- .../out/refcount/vector_iter_range_ctor.rs | 3 +- .../out/refcount/vector_subscript_direct.rs | 19 +- .../out/refcount/vector_with_allocator.rs | 6 +- tests/unit/out/refcount/void_cast.rs | 29 +-- tests/unit/out/unsafe/05_new.rs | 6 +- tests/unit/out/unsafe/10_struct.rs | 22 +- tests/unit/out/unsafe/addr_of_global.rs | 6 +- tests/unit/out/unsafe/anonymous-struct.rs | 27 ++- tests/unit/out/unsafe/anonymous_enum.rs | 6 +- .../out/unsafe/array_of_noncopy_struct.rs | 13 +- tests/unit/out/unsafe/array_reference.rs | 3 +- tests/unit/out/unsafe/as_const.rs | 3 +- tests/unit/out/unsafe/assign_rhs_first.rs | 3 +- .../unit/out/unsafe/assignment_single_eval.rs | 48 +++-- tests/unit/out/unsafe/bounded_struct_ptr.rs | 3 +- tests/unit/out/unsafe/bst.rs | 3 +- tests/unit/out/unsafe/cast.rs | 22 +- .../out/unsafe/cast_array_to_pointer_decay.rs | 3 +- tests/unit/out/unsafe/class.rs | 12 +- .../out/unsafe/class_template_lazy_member.rs | 15 +- tests/unit/out/unsafe/class_templates.rs | 54 +++-- tests/unit/out/unsafe/clone_vs_move.rs | 3 +- tests/unit/out/unsafe/comma_operator.rs | 3 +- tests/unit/out/unsafe/complex_function.rs | 9 +- .../unit/out/unsafe/compound_assign_paren.rs | 3 +- tests/unit/out/unsafe/concepts.rs | 3 +- tests/unit/out/unsafe/constexpr_function.rs | 6 +- tests/unit/out/unsafe/constructor.rs | 13 +- tests/unit/out/unsafe/container_field_addr.rs | 15 +- .../conversion_operator_same_translation.rs | 6 +- tests/unit/out/unsafe/copy_assign.rs | 47 ++-- tests/unit/out/unsafe/copy_ctor.rs | 36 ++-- tests/unit/out/unsafe/copy_move_defaulted.rs | 156 ++++---------- tests/unit/out/unsafe/copy_move_deleted.rs | 39 +--- tests/unit/out/unsafe/default.rs | 9 +- tests/unit/out/unsafe/default_in_statics.rs | 9 +- tests/unit/out/unsafe/delete_array_order.rs | 3 +- tests/unit/out/unsafe/destructor.rs | 33 +-- tests/unit/out/unsafe/destructor_params.rs | 3 +- .../unit/out/unsafe/destructor_temporaries.rs | 6 +- tests/unit/out/unsafe/doubly_linked_list.rs | 3 +- tests/unit/out/unsafe/enum_int_interop.rs | 3 +- tests/unit/out/unsafe/enum_underlying_type.rs | 11 +- tests/unit/out/unsafe/exprs.rs | 6 +- tests/unit/out/unsafe/fft.rs | 3 +- tests/unit/out/unsafe/field_array_elem_ptr.rs | 6 +- .../unit/out/unsafe/field_method_receiver.rs | 14 +- tests/unit/out/unsafe/field_pointers.rs | 17 +- .../unsafe/field_pointers_malloced_struct.rs | 3 +- tests/unit/out/unsafe/find.rs | 3 +- tests/unit/out/unsafe/fn_ptr_cast.rs | 3 +- tests/unit/out/unsafe/fn_ptr_stable_sort.rs | 3 +- tests/unit/out/unsafe/fn_ptr_struct.rs | 6 +- tests/unit/out/unsafe/fn_ptr_vtable.rs | 3 +- tests/unit/out/unsafe/for_body_destructor.rs | 3 +- .../unsafe/foreach_disjoint_field_borrow.rs | 13 +- tests/unit/out/unsafe/friend.rs | 12 +- tests/unit/out/unsafe/function_overloading.rs | 3 +- .../out/unsafe/global_call_temporaries.rs | 3 +- .../unit/out/unsafe/global_non_const_init.rs | 33 ++- tests/unit/out/unsafe/global_pointers.rs | 3 +- .../out/unsafe/global_without_initializer.rs | 3 +- tests/unit/out/unsafe/huffman.rs | 14 +- .../unsafe/immutable-deref-on-func-call.rs | 3 +- tests/unit/out/unsafe/implicit_autoref.rs | 11 +- .../out/unsafe/in_class_field_initializer.rs | 26 +-- tests/unit/out/unsafe/init.rs | 3 +- tests/unit/out/unsafe/init_list.rs | 21 +- .../out/unsafe/inline_container_fields.rs | 33 +-- tests/unit/out/unsafe/kruskal.rs | 25 +-- tests/unit/out/unsafe/lambda_as_field.rs | 11 +- .../out/unsafe/lambda_capture_copy_ctor.rs | 36 +--- tests/unit/out/unsafe/lambda_capture_ref.rs | 3 +- .../out/unsafe/lambda_capture_star_this.rs | 3 +- tests/unit/out/unsafe/lambda_capture_this.rs | 3 +- tests/unit/out/unsafe/lambda_capture_value.rs | 3 +- tests/unit/out/unsafe/lambda_decltype_type.rs | 26 +-- .../unsafe/lambda_generic_explicit_args.rs | 3 +- .../unit/out/unsafe/lambda_immediate_init.rs | 13 +- tests/unit/out/unsafe/lambda_nested.rs | 3 +- tests/unit/out/unsafe/lambda_static_local.rs | 3 +- .../out/unsafe/libc_struct_without_default.rs | 16 +- tests/unit/out/unsafe/linked_list.rs | 3 +- .../unit/out/unsafe/local_record_template.rs | 12 +- tests/unit/out/unsafe/map.rs | 17 +- tests/unit/out/unsafe/map_key_identity.rs | 16 +- tests/unit/out/unsafe/map_try_emplace.rs | 34 ++- .../out/unsafe/map_try_emplace_lvalues.rs | 136 +++++------- tests/unit/out/unsafe/memcpy_struct_struct.rs | 3 +- tests/unit/out/unsafe/move_assign.rs | 17 +- tests/unit/out/unsafe/move_ctor.rs | 13 +- tests/unit/out/unsafe/nested_structs.rs | 18 +- tests/unit/out/unsafe/new.rs | 3 +- tests/unit/out/unsafe/new_bst.rs | 3 +- tests/unit/out/unsafe/new_struct.rs | 6 +- .../unsafe/nttp_distinct_specializations.rs | 9 +- tests/unit/out/unsafe/offsetof.rs | 6 +- tests/unit/out/unsafe/opaque_record_copy.rs | 6 +- .../out/unsafe/operator_arithmetic_free.rs | 3 +- .../out/unsafe/operator_arithmetic_member.rs | 3 +- .../unit/out/unsafe/operator_bitwise_free.rs | 3 +- .../out/unsafe/operator_bitwise_member.rs | 3 +- .../unsafe/operator_comparison_defaulted.rs | 24 ++- .../out/unsafe/operator_comparison_free.rs | 6 +- .../out/unsafe/operator_comparison_member.rs | 3 +- .../out/unsafe/operator_comparison_mixed.rs | 3 +- .../out/unsafe/operator_comparison_nonbool.rs | 18 +- .../operator_compound_assignment_free.rs | 3 +- .../operator_compound_assignment_member.rs | 3 +- tests/unit/out/unsafe/operator_friend.rs | 21 +- tests/unit/out/unsafe/operator_less_than.rs | 3 +- .../unit/out/unsafe/operator_logical_free.rs | 3 +- .../out/unsafe/operator_logical_member.rs | 3 +- .../unsafe/operator_member_pointer_free.rs | 6 +- .../unsafe/operator_member_pointer_member.rs | 9 +- tests/unit/out/unsafe/operator_other_free.rs | 3 +- .../unit/out/unsafe/operator_other_member.rs | 6 +- tests/unit/out/unsafe/operator_overloads.rs | 3 +- tests/unit/out/unsafe/operator_qualifiers.rs | 3 +- tests/unit/out/unsafe/operator_three_way.rs | 3 +- tests/unit/out/unsafe/operator_traits.rs | 15 +- tests/unit/out/unsafe/overload_mangling.rs | 9 +- .../unsafe/pair_converting_construction.rs | 6 +- tests/unit/out/unsafe/pod.rs | 3 +- tests/unit/out/unsafe/pointer_array.rs | 3 +- tests/unit/out/unsafe/pointers.rs | 3 +- tests/unit/out/unsafe/push_emplace_back.rs | 60 ++---- tests/unit/out/unsafe/random.rs | 3 +- tests/unit/out/unsafe/reference_wrapper.rs | 3 +- tests/unit/out/unsafe/references.rs | 6 +- tests/unit/out/unsafe/refs_as_args.rs | 3 +- .../out/unsafe/reinterpret_cast_ptr_cmp.rs | 9 +- .../out/unsafe/reinterpret_cast_struct.rs | 3 +- .../reinterpret_cast_struct_to_struct.rs | 6 +- tests/unit/out/unsafe/reserved_keywords.rs | 9 +- tests/unit/out/unsafe/return_move.rs | 6 +- .../scalar_builtin_construct_destruct.rs | 3 +- .../unsafe/self_referencing_initializer.rs | 17 +- tests/unit/out/unsafe/size_t_static_member.rs | 6 +- tests/unit/out/unsafe/sort_no_copy.rs | 30 +-- tests/unit/out/unsafe/static_local.rs | 3 +- tests/unit/out/unsafe/static_var_in_class.rs | 6 +- tests/unit/out/unsafe/struct_ctor.rs | 15 +- tests/unit/out/unsafe/struct_default_ctor.rs | 52 ++--- tests/unit/out/unsafe/struct_ptr.rs | 3 +- .../unsafe/structured_binding_move_ctor.rs | 9 +- .../unsafe/structured_binding_range_for.rs | 3 +- .../unit/out/unsafe/structured_binding_ref.rs | 3 +- .../out/unsafe/structured_binding_trivial.rs | 3 +- tests/unit/out/unsafe/swap_map_no_copy.rs | 54 ++--- tests/unit/out/unsafe/template_default_arg.rs | 24 +-- .../unit/out/unsafe/template_static_member.rs | 15 +- tests/unit/out/unsafe/temporary_field_addr.rs | 22 +- .../out/unsafe/temporary_field_ctor_arg.rs | 9 +- .../out/unsafe/temporary_field_two_args.rs | 20 +- tests/unit/out/unsafe/typedef-anon-struct.rs | 14 +- .../out/unsafe/unary_expr_or_type_trait.rs | 3 +- tests/unit/out/unsafe/unboxed_locals.rs | 3 +- tests/unit/out/unsafe/unboxed_records.rs | 15 +- tests/unit/out/unsafe/unique_ptr.rs | 10 +- .../unit/out/unsafe/unique_ptr_const_deref.rs | 11 +- .../unit/out/unsafe/unique_ptr_field_reset.rs | 14 +- tests/unit/out/unsafe/unique_ptr_nested.rs | 12 +- tests/unit/out/unsafe/unique_ptr_struct.rs | 3 +- tests/unit/out/unsafe/va_list_field.rs | 3 +- tests/unit/out/unsafe/vector.rs | 16 +- .../unit/out/unsafe/vector_iter_range_ctor.rs | 3 +- .../out/unsafe/vector_subscript_direct.rs | 16 +- .../unit/out/unsafe/vector_with_allocator.rs | 6 +- tests/unit/out/unsafe/void_cast.rs | 23 +- 424 files changed, 2498 insertions(+), 4091 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 934ef84c52..6da759e41e 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 @@ -56,9 +56,7 @@ pub struct T { } impl DefaultConstructible for T { fn default_constructor(this: &Ptr) { - { - TImpl::construct_1(this); - } + field!((*this), v).write(Vec::new()); } } pub fn sum_0(s: Ptr) -> i32 { @@ -95,7 +93,7 @@ pub fn shuffle_1(mut x: i32) -> i32 { let u: Value = Rc::new(RefCell::new(::zero_init())); MoveConstructible::move_constructor(&u.as_pointer(), { t.as_pointer() }); let w: Value = Rc::new(RefCell::new(::zero_init())); - TImpl::construct_1(&w.as_pointer()); + DefaultConstructible::default_constructor(&w.as_pointer()); ({ MoveAssignable::move_assign(&w.as_pointer(), u.as_pointer()) }); assert!( ((({ TImpl::size(&t.as_pointer(),) }) == 0) && (({ TImpl::size(&u.as_pointer(),) }) == 0)) @@ -114,14 +112,10 @@ impl SImpl for Ptr { } pub trait TImpl { fn size(&self) -> i32; - fn construct_1(&self); } impl TImpl for Ptr { fn size(&self) -> i32 { return (((*(*self).upgrade().deref()).v.len()) as i32); } - fn construct_1(&self) { - field!((*self), v).write(Vec::new()); - } } 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 0b9dfcf93a..21fba8bfee 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 @@ -49,15 +49,10 @@ impl T { pub unsafe fn size(&self) -> i32 { return ((self.v.len()) as i32); } - pub unsafe fn construct_1(&mut self) { - (&raw mut self.v).write(Vec::new()); - } } impl DefaultConstructibleUnsafe for T { unsafe fn default_constructor(&mut self) { - unsafe { - T::construct_1(&mut *self); - } + (&raw mut self.v).write(Vec::new()); } } pub unsafe fn sum_0(s: *const S) -> i32 { @@ -94,7 +89,7 @@ pub unsafe fn shuffle_1(mut x: i32) -> i32 { let mut u: T = ::zero_init(); MoveConstructibleUnsafe::move_constructor(&mut u, { &mut t }); let mut w: T = ::zero_init(); - T::construct_1(&mut w); + DefaultConstructibleUnsafe::default_constructor(&mut w); (unsafe { MoveAssignableUnsafe::move_assign(&mut w, &mut u) }); assert!( (((unsafe { T::size(&t,) }) == (0)) && ((unsafe { T::size(&u,) }) == (0))) 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 9e742a44d9..1e6ba2f9a5 100644 --- a/tests/multi-file/friend_operator/out/refcount/friend_operator.rs +++ b/tests/multi-file/friend_operator/out/refcount/friend_operator.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 69fd6cb896..b541578a68 100644 --- a/tests/multi-file/friend_operator/out/unsafe/friend_operator.rs +++ b/tests/multi-file/friend_operator/out/unsafe/friend_operator.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct S { pub a: i32, pub b: 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 d430a37c9c..845b4334c8 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 @@ -62,10 +62,11 @@ pub struct Derived { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 fc2f5e5a5d..2add483e0e 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 @@ -61,10 +61,11 @@ impl Derived {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 03370fce30..00463deb12 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 @@ -14,9 +14,7 @@ pub struct S_int_ { } impl DefaultConstructible for S_int_ { fn default_constructor(this: &Ptr) { - { - S_int_Impl::construct_1(this); - } + field!((*this), x).write(0); } } impl Default for S_int_ { @@ -30,7 +28,7 @@ pub fn main() { } fn main_0() -> i32 { let p: Value = Rc::new(RefCell::new(::zero_init())); - S_int_Impl::construct_1(&p.as_pointer()); + DefaultConstructible::default_constructor(&p.as_pointer()); ({ S_int_Impl::set(&p.as_pointer(), 3) }); assert!((({ f_0((p.as_pointer()),) }) == 3)); return 0; @@ -43,15 +41,11 @@ pub trait S_int_Impl { fn get(&self) -> i32 { unimplemented!() } - fn construct_1(&self); } impl S_int_Impl for Ptr { fn set(&self, mut v: i32) { field!((*self), x).write(v); } - fn construct_1(&self) { - field!((*self), x).write(0); - } fn get(&self) -> i32 { return (*self).with(|__s| __s.x); } 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 0edc9fed0c..19760378df 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 @@ -15,15 +15,10 @@ impl S_int_ { pub unsafe fn set(&mut self, mut v: i32) { self.x = v; } - pub unsafe fn construct_1(&mut self) { - (&raw mut self.x).write(0); - } } impl DefaultConstructibleUnsafe for S_int_ { unsafe fn default_constructor(&mut self) { - unsafe { - S_int_::construct_1(&mut *self); - } + (&raw mut self.x).write(0); } } impl Default for S_int_ { @@ -39,7 +34,7 @@ pub fn main() { } unsafe fn main_0() -> i32 { let mut p: S_int_ = ::zero_init(); - S_int_::construct_1(&mut p); + DefaultConstructibleUnsafe::default_constructor(&mut p); (unsafe { S_int_::set(&mut p, 3) }); assert!(((unsafe { f_0((&mut p as *mut S_int_),) }) == (3))); return 0; 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 1b0cc37e8c..a4f679bcd4 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 @@ -45,6 +45,12 @@ impl LifetimeTracked { }); } } +impl DefaultConstructible for LifetimeTracked { + fn default_constructor(this: &Ptr) { + field!((*this), uses).write(0); + (*ctorCount_0.with(Value::clone).borrow_mut()).prefix_inc(); + } +} impl CopyConstructible for LifetimeTracked { fn copy_constructor(this: &Ptr, _a0: Ptr) { field!((*this), uses).write(0); @@ -66,20 +72,13 @@ impl Clone for LifetimeTracked { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } -impl DefaultConstructible for LifetimeTracked { - fn default_constructor(this: &Ptr) { - { - LifetimeTrackedImpl::construct(this); - } - } -} impl Default for LifetimeTracked { fn default() -> Self { { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -92,13 +91,12 @@ impl Default for LifetimeTracked { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(copy_assign)] +#[memberwise(default_constructor, copy_assign)] #[byte_size(4)] pub struct AssertsDtorCountAtExit { #[offset(0)] @@ -122,7 +120,7 @@ thread_local!( pub static shared_5: Value = { let __static = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); libcc2rs::register_static_destructor(|| { @@ -139,10 +137,11 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct HasInlineMembers {} impl HasInlineMembers { @@ -154,7 +153,7 @@ thread_local!( static local_6: Value = { let __static = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); libcc2rs::register_static_destructor(|| { @@ -190,14 +189,9 @@ pub fn b_instance_address_9() -> Ptr { return ({ HasInlineMembers::instance() }); } pub trait LifetimeTrackedImpl { - fn construct(&self); fn use_(&self); } impl LifetimeTrackedImpl for Ptr { - fn construct(&self) { - field!((*self), uses).write(0); - (*ctorCount_0.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 28e9bf3de6..31881ff00a 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 @@ -29,15 +29,17 @@ impl LifetimeTracked { (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)) }; } - pub unsafe fn construct(&mut self) { - (&raw mut self.uses).write(0); - (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).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(); } } +impl DefaultConstructibleUnsafe for LifetimeTracked { + unsafe fn default_constructor(&mut self) { + (&raw mut self.uses).write(0); + (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).prefix_inc(); + } +} impl CopyConstructibleUnsafe for LifetimeTracked { unsafe fn copy_constructor(&mut self, _a0: *const LifetimeTracked) { (&raw mut self.uses).write(0); @@ -58,19 +60,12 @@ impl Clone for LifetimeTracked { } } } -impl DefaultConstructibleUnsafe for LifetimeTracked { - unsafe fn default_constructor(&mut self) { - unsafe { - LifetimeTracked::construct(&mut *self); - } - } -} impl Default for LifetimeTracked { fn default() -> Self { unsafe { { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -82,13 +77,12 @@ impl Default for LifetimeTracked { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(copy_assign)] +#[memberwise(default_constructor, copy_assign)] pub struct AssertsDtorCountAtExit { pub expected: i32, } @@ -112,7 +106,7 @@ pub static mut shared_5: std::cell::LazyCell = { let __static = { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v }; libcc2rs::register_static_destructor(|| { @@ -128,10 +122,11 @@ pub static mut shared_5: std::cell::LazyCell = VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct HasInlineMembers {} impl HasInlineMembers { pub unsafe fn instance() -> *mut LifetimeTracked { @@ -142,7 +137,7 @@ static mut local_6: std::cell::LazyCell = std::cell::LazyCell:: { let __static = { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v }; libcc2rs::register_static_destructor(|| { 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 7899fdd3b9..c57cf0418a 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 @@ -45,6 +45,12 @@ impl LifetimeTracked { }); } } +impl DefaultConstructible for LifetimeTracked { + fn default_constructor(this: &Ptr) { + field!((*this), uses).write(0); + (*ctorCount_0.with(Value::clone).borrow_mut()).prefix_inc(); + } +} impl CopyConstructible for LifetimeTracked { fn copy_constructor(this: &Ptr, _a0: Ptr) { field!((*this), uses).write(0); @@ -66,20 +72,13 @@ impl Clone for LifetimeTracked { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } -impl DefaultConstructible for LifetimeTracked { - fn default_constructor(this: &Ptr) { - { - LifetimeTrackedImpl::construct(this); - } - } -} impl Default for LifetimeTracked { fn default() -> Self { { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -89,7 +88,7 @@ thread_local!( pub static member_4: Value = { let __static = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); libcc2rs::register_static_destructor(|| { @@ -106,17 +105,18 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct HasStaticMember_int_ {} thread_local!( pub static member_5: Value = { let __static = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); libcc2rs::register_static_destructor(|| { @@ -133,10 +133,11 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct HasStaticMember_long_ {} pub fn main() { @@ -164,14 +165,9 @@ pub fn b_int_address_8() -> Ptr { return (member_4.with(|v| v.as_pointer())); } pub trait LifetimeTrackedImpl { - fn construct(&self); fn use_(&self); } impl LifetimeTrackedImpl for Ptr { - fn construct(&self) { - field!((*self), uses).write(0); - (*ctorCount_0.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 34723b507b..ae9a331879 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 @@ -29,15 +29,17 @@ impl LifetimeTracked { (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)) }; } - pub unsafe fn construct(&mut self) { - (&raw mut self.uses).write(0); - (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).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(); } } +impl DefaultConstructibleUnsafe for LifetimeTracked { + unsafe fn default_constructor(&mut self) { + (&raw mut self.uses).write(0); + (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).prefix_inc(); + } +} impl CopyConstructibleUnsafe for LifetimeTracked { unsafe fn copy_constructor(&mut self, _a0: *const LifetimeTracked) { (&raw mut self.uses).write(0); @@ -58,19 +60,12 @@ impl Clone for LifetimeTracked { } } } -impl DefaultConstructibleUnsafe for LifetimeTracked { - unsafe fn default_constructor(&mut self) { - unsafe { - LifetimeTracked::construct(&mut *self); - } - } -} impl Default for LifetimeTracked { fn default() -> Self { unsafe { { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -81,7 +76,7 @@ pub static mut member_4: std::cell::LazyCell = { let __static = { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v }; libcc2rs::register_static_destructor(|| { @@ -97,17 +92,18 @@ pub static mut member_4: std::cell::LazyCell = VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct HasStaticMember_int_ {} pub static mut member_5: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { { let __static = { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v }; libcc2rs::register_static_destructor(|| { @@ -123,10 +119,11 @@ pub static mut member_5: std::cell::LazyCell = VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 2f991637b6..fc403d7b43 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 @@ -45,6 +45,12 @@ impl LifetimeTracked { }); } } +impl DefaultConstructible for LifetimeTracked { + fn default_constructor(this: &Ptr) { + field!((*this), uses).write(0); + (*ctorCount_0.with(Value::clone).borrow_mut()).prefix_inc(); + } +} impl CopyConstructible for LifetimeTracked { fn copy_constructor(this: &Ptr, _a0: Ptr) { field!((*this), uses).write(0); @@ -66,20 +72,13 @@ impl Clone for LifetimeTracked { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } -impl DefaultConstructible for LifetimeTracked { - fn default_constructor(this: &Ptr) { - { - LifetimeTrackedImpl::construct(this); - } - } -} impl Default for LifetimeTracked { fn default() -> Self { { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -92,13 +91,12 @@ impl Default for LifetimeTracked { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(copy_assign)] +#[memberwise(default_constructor, copy_assign)] #[byte_size(4)] pub struct AssertsDtorCountAtExit { #[offset(0)] @@ -122,7 +120,7 @@ thread_local!( static t_5: Value = { let __static = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); libcc2rs::register_static_destructor(|| { @@ -138,7 +136,7 @@ thread_local!( static t_8: Value = { let __static = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); libcc2rs::register_static_destructor(|| { @@ -154,7 +152,7 @@ thread_local!( static t_11: Value = { let __static = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); libcc2rs::register_static_destructor(|| { @@ -201,10 +199,11 @@ fn main_0() -> i32 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct S_14 {} pub fn count_18() -> i32 { @@ -214,7 +213,7 @@ thread_local!( static t_19: Value = { let __static = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); libcc2rs::register_static_destructor(|| { @@ -243,21 +242,17 @@ pub fn b_count_local_15() -> i32 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct S_21 {} pub trait LifetimeTrackedImpl { - fn construct(&self); fn use_(&self); } impl LifetimeTrackedImpl for Ptr { - fn construct(&self) { - field!((*self), uses).write(0); - (*ctorCount_0.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 38f21a50d2..cb9dd96f43 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 @@ -29,15 +29,17 @@ impl LifetimeTracked { (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)) }; } - pub unsafe fn construct(&mut self) { - (&raw mut self.uses).write(0); - (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).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(); } } +impl DefaultConstructibleUnsafe for LifetimeTracked { + unsafe fn default_constructor(&mut self) { + (&raw mut self.uses).write(0); + (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).prefix_inc(); + } +} impl CopyConstructibleUnsafe for LifetimeTracked { unsafe fn copy_constructor(&mut self, _a0: *const LifetimeTracked) { (&raw mut self.uses).write(0); @@ -58,19 +60,12 @@ impl Clone for LifetimeTracked { } } } -impl DefaultConstructibleUnsafe for LifetimeTracked { - unsafe fn default_constructor(&mut self) { - unsafe { - LifetimeTracked::construct(&mut *self); - } - } -} impl Default for LifetimeTracked { fn default() -> Self { unsafe { { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -82,13 +77,12 @@ impl Default for LifetimeTracked { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(copy_assign)] +#[memberwise(default_constructor, copy_assign)] pub struct AssertsDtorCountAtExit { pub expected: i32, } @@ -110,7 +104,7 @@ static mut t_5: std::cell::LazyCell = std::cell::LazyCell::new( { let __static = { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v }; libcc2rs::register_static_destructor(|| { @@ -124,7 +118,7 @@ static mut t_8: std::cell::LazyCell = std::cell::LazyCell::new( { let __static = { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v }; libcc2rs::register_static_destructor(|| { @@ -138,7 +132,7 @@ static mut t_11: std::cell::LazyCell = std::cell::LazyCell::new { let __static = { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v }; libcc2rs::register_static_destructor(|| { @@ -185,10 +179,11 @@ unsafe fn main_0() -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct S_14 {} pub unsafe fn count_18() -> i32 { return (*(*std::cell::LazyCell::force_mut(&mut *&raw mut n_20)).prefix_inc()); @@ -197,7 +192,7 @@ static mut t_19: std::cell::LazyCell = std::cell::LazyCell::new { let __static = { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v }; libcc2rs::register_static_destructor(|| { @@ -223,10 +218,11 @@ pub unsafe fn b_count_local_15() -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 51af8a0b32..d4b76e85e8 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 @@ -45,6 +45,12 @@ impl LifetimeTracked { }); } } +impl DefaultConstructible for LifetimeTracked { + fn default_constructor(this: &Ptr) { + field!((*this), uses).write(0); + (*ctorCount_0.with(Value::clone).borrow_mut()).prefix_inc(); + } +} impl CopyConstructible for LifetimeTracked { fn copy_constructor(this: &Ptr, _a0: Ptr) { field!((*this), uses).write(0); @@ -66,20 +72,13 @@ impl Clone for LifetimeTracked { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } -impl DefaultConstructible for LifetimeTracked { - fn default_constructor(this: &Ptr) { - { - LifetimeTrackedImpl::construct(this); - } - } -} impl Default for LifetimeTracked { fn default() -> Self { { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -92,13 +91,12 @@ impl Default for LifetimeTracked { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(copy_assign)] +#[memberwise(default_constructor, copy_assign)] #[byte_size(4)] pub struct AssertsDtorCountAtExit { #[offset(0)] @@ -116,7 +114,7 @@ thread_local!( static t_5: Value = { let __static = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); libcc2rs::register_static_destructor(|| { @@ -157,14 +155,9 @@ pub fn b_address_8() -> Ptr { return ({ instance_4() }); } pub trait LifetimeTrackedImpl { - fn construct(&self); fn use_(&self); } impl LifetimeTrackedImpl for Ptr { - fn construct(&self) { - field!((*self), uses).write(0); - (*ctorCount_0.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 ffa52931a5..0e434c17d4 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 @@ -29,15 +29,17 @@ impl LifetimeTracked { (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)) }; } - pub unsafe fn construct(&mut self) { - (&raw mut self.uses).write(0); - (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).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(); } } +impl DefaultConstructibleUnsafe for LifetimeTracked { + unsafe fn default_constructor(&mut self) { + (&raw mut self.uses).write(0); + (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).prefix_inc(); + } +} impl CopyConstructibleUnsafe for LifetimeTracked { unsafe fn copy_constructor(&mut self, _a0: *const LifetimeTracked) { (&raw mut self.uses).write(0); @@ -58,19 +60,12 @@ impl Clone for LifetimeTracked { } } } -impl DefaultConstructibleUnsafe for LifetimeTracked { - unsafe fn default_constructor(&mut self) { - unsafe { - LifetimeTracked::construct(&mut *self); - } - } -} impl Default for LifetimeTracked { fn default() -> Self { unsafe { { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -82,13 +77,12 @@ impl Default for LifetimeTracked { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(copy_assign)] +#[memberwise(default_constructor, copy_assign)] pub struct AssertsDtorCountAtExit { pub expected: i32, } @@ -104,7 +98,7 @@ static mut t_5: std::cell::LazyCell = std::cell::LazyCell::new( { let __static = { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v }; libcc2rs::register_static_destructor(|| { 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 6665a3cab5..adeeb15c1a 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 @@ -45,6 +45,12 @@ impl LifetimeTracked { }); } } +impl DefaultConstructible for LifetimeTracked { + fn default_constructor(this: &Ptr) { + field!((*this), uses).write(0); + (*ctorCount_0.with(Value::clone).borrow_mut()).prefix_inc(); + } +} impl CopyConstructible for LifetimeTracked { fn copy_constructor(this: &Ptr, _a0: Ptr) { field!((*this), uses).write(0); @@ -66,20 +72,13 @@ impl Clone for LifetimeTracked { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } -impl DefaultConstructible for LifetimeTracked { - fn default_constructor(this: &Ptr) { - { - LifetimeTrackedImpl::construct(this); - } - } -} impl Default for LifetimeTracked { fn default() -> Self { { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -92,13 +91,12 @@ impl Default for LifetimeTracked { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(copy_assign)] +#[memberwise(default_constructor, copy_assign)] #[byte_size(4)] pub struct AssertsDtorCountAtExit { #[offset(0)] @@ -122,7 +120,7 @@ thread_local!( pub static shared_5: Value = { let __static = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); libcc2rs::register_static_destructor(|| { @@ -152,14 +150,9 @@ pub fn b_address_7() -> Ptr { return (shared_5.with(|v| v.as_pointer())); } pub trait LifetimeTrackedImpl { - fn construct(&self); fn use_(&self); } impl LifetimeTrackedImpl for Ptr { - fn construct(&self) { - field!((*self), uses).write(0); - (*ctorCount_0.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 5ad038b95e..766bbb54ee 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 @@ -29,15 +29,17 @@ impl LifetimeTracked { (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)) }; } - pub unsafe fn construct(&mut self) { - (&raw mut self.uses).write(0); - (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).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(); } } +impl DefaultConstructibleUnsafe for LifetimeTracked { + unsafe fn default_constructor(&mut self) { + (&raw mut self.uses).write(0); + (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).prefix_inc(); + } +} impl CopyConstructibleUnsafe for LifetimeTracked { unsafe fn copy_constructor(&mut self, _a0: *const LifetimeTracked) { (&raw mut self.uses).write(0); @@ -58,19 +60,12 @@ impl Clone for LifetimeTracked { } } } -impl DefaultConstructibleUnsafe for LifetimeTracked { - unsafe fn default_constructor(&mut self) { - unsafe { - LifetimeTracked::construct(&mut *self); - } - } -} impl Default for LifetimeTracked { fn default() -> Self { unsafe { { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -82,13 +77,12 @@ impl Default for LifetimeTracked { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(copy_assign)] +#[memberwise(default_constructor, copy_assign)] pub struct AssertsDtorCountAtExit { pub expected: i32, } @@ -112,7 +106,7 @@ pub static mut shared_5: std::cell::LazyCell = { let __static = { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v }; libcc2rs::register_static_destructor(|| { 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 22ed9c3830..ba1fc34c94 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 @@ -45,6 +45,12 @@ impl LifetimeTracked { }); } } +impl DefaultConstructible for LifetimeTracked { + fn default_constructor(this: &Ptr) { + field!((*this), uses).write(0); + (*ctorCount_0.with(Value::clone).borrow_mut()).prefix_inc(); + } +} impl CopyConstructible for LifetimeTracked { fn copy_constructor(this: &Ptr, _a0: Ptr) { field!((*this), uses).write(0); @@ -66,20 +72,13 @@ impl Clone for LifetimeTracked { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } -impl DefaultConstructible for LifetimeTracked { - fn default_constructor(this: &Ptr) { - { - LifetimeTrackedImpl::construct(this); - } - } -} impl Default for LifetimeTracked { fn default() -> Self { { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -92,13 +91,12 @@ impl Default for LifetimeTracked { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(copy_assign)] +#[memberwise(default_constructor, copy_assign)] #[byte_size(4)] pub struct AssertsDtorCountAtExit { #[offset(0)] @@ -117,17 +115,18 @@ impl Destructible for AssertsDtorCountAtExit { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct X {} thread_local!( static local_4: Value = { let __static = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); libcc2rs::register_static_destructor(|| { @@ -181,14 +180,9 @@ pub fn b_call_6() { }); } pub trait LifetimeTrackedImpl { - fn construct(&self); fn use_(&self); } impl LifetimeTrackedImpl for Ptr { - fn construct(&self) { - field!((*self), uses).write(0); - (*ctorCount_0.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 d978b37d13..4b5befdc1f 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 @@ -29,15 +29,17 @@ impl LifetimeTracked { (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)) }; } - pub unsafe fn construct(&mut self) { - (&raw mut self.uses).write(0); - (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).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(); } } +impl DefaultConstructibleUnsafe for LifetimeTracked { + unsafe fn default_constructor(&mut self) { + (&raw mut self.uses).write(0); + (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).prefix_inc(); + } +} impl CopyConstructibleUnsafe for LifetimeTracked { unsafe fn copy_constructor(&mut self, _a0: *const LifetimeTracked) { (&raw mut self.uses).write(0); @@ -58,19 +60,12 @@ impl Clone for LifetimeTracked { } } } -impl DefaultConstructibleUnsafe for LifetimeTracked { - unsafe fn default_constructor(&mut self) { - unsafe { - LifetimeTracked::construct(&mut *self); - } - } -} impl Default for LifetimeTracked { fn default() -> Self { unsafe { { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -82,13 +77,12 @@ impl Default for LifetimeTracked { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(copy_assign)] +#[memberwise(default_constructor, copy_assign)] pub struct AssertsDtorCountAtExit { pub expected: i32, } @@ -104,10 +98,11 @@ impl DestructibleUnsafe for AssertsDtorCountAtExit { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct X {} impl X { pub unsafe fn h(&mut self, mut cond: bool, mut p: Option) { @@ -134,7 +129,7 @@ static mut local_4: std::cell::LazyCell = std::cell::LazyCell:: { let __static = { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v }; libcc2rs::register_static_destructor(|| { 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 5ac131b701..a25034aead 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 @@ -45,6 +45,12 @@ impl LifetimeTracked { }); } } +impl DefaultConstructible for LifetimeTracked { + fn default_constructor(this: &Ptr) { + field!((*this), uses).write(0); + (*ctorCount_0.with(Value::clone).borrow_mut()).prefix_inc(); + } +} impl CopyConstructible for LifetimeTracked { fn copy_constructor(this: &Ptr, _a0: Ptr) { field!((*this), uses).write(0); @@ -66,20 +72,13 @@ impl Clone for LifetimeTracked { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } -impl DefaultConstructible for LifetimeTracked { - fn default_constructor(this: &Ptr) { - { - LifetimeTrackedImpl::construct(this); - } - } -} impl Default for LifetimeTracked { fn default() -> Self { { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -92,13 +91,12 @@ impl Default for LifetimeTracked { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(copy_assign)] +#[memberwise(default_constructor, copy_assign)] #[byte_size(4)] pub struct AssertsDtorCountAtExit { #[offset(0)] @@ -127,7 +125,7 @@ thread_local!( static local_5: Value = { let __static = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); libcc2rs::register_static_destructor(|| { @@ -163,14 +161,9 @@ pub fn b_call_7() { ({ f_4(true, FnPtr::::null()) }); } pub trait LifetimeTrackedImpl { - fn construct(&self); fn use_(&self); } impl LifetimeTrackedImpl for Ptr { - fn construct(&self) { - field!((*self), uses).write(0); - (*ctorCount_0.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 b50e4fd3d8..467836b4b5 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 @@ -29,15 +29,17 @@ impl LifetimeTracked { (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)) }; } - pub unsafe fn construct(&mut self) { - (&raw mut self.uses).write(0); - (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).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(); } } +impl DefaultConstructibleUnsafe for LifetimeTracked { + unsafe fn default_constructor(&mut self) { + (&raw mut self.uses).write(0); + (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).prefix_inc(); + } +} impl CopyConstructibleUnsafe for LifetimeTracked { unsafe fn copy_constructor(&mut self, _a0: *const LifetimeTracked) { (&raw mut self.uses).write(0); @@ -58,19 +60,12 @@ impl Clone for LifetimeTracked { } } } -impl DefaultConstructibleUnsafe for LifetimeTracked { - unsafe fn default_constructor(&mut self) { - unsafe { - LifetimeTracked::construct(&mut *self); - } - } -} impl Default for LifetimeTracked { fn default() -> Self { unsafe { { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -82,13 +77,12 @@ impl Default for LifetimeTracked { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(copy_assign)] +#[memberwise(default_constructor, copy_assign)] pub struct AssertsDtorCountAtExit { pub expected: i32, } @@ -119,7 +113,7 @@ static mut local_5: std::cell::LazyCell = std::cell::LazyCell:: { let __static = { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v }; libcc2rs::register_static_destructor(|| { 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 73faaa229a..ba7584e19e 100644 --- a/tests/std/basic/basic.link/out/refcount/basic.link.rs +++ b/tests/std/basic/basic.link/out/refcount/basic.link.rs @@ -77,9 +77,7 @@ pub struct Record_19 { } impl DefaultConstructible for Record_19 { fn default_constructor(this: &Ptr) { - { - Record_19Impl::construct_1(this); - } + field!((*this), id).write(100); } } impl Default for Record_19 { @@ -95,7 +93,7 @@ pub fn test_21() { assert!((({ bump_in_b_22() }) == 51)); assert!((counter_17.with(|rc| *rc.borrow()) == 2)); let record: Value = Rc::new(RefCell::new(::zero_init())); - Record_19Impl::construct_1(&record.as_pointer()); + DefaultConstructible::default_constructor(&record.as_pointer()); assert!(({ (*record.borrow()).id } == 100)); assert!((({ record_id_in_b_23() }) == 200)); assert!((depth_20.with(|rc| *rc.borrow()) == 3)); @@ -121,10 +119,11 @@ pub fn test_29() { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct Tally_31 {} thread_local!( @@ -144,10 +143,11 @@ pub fn test_33() { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct p5_members_of_class_with_external_linkage_Ledger {} pub fn test_36() { @@ -204,12 +204,12 @@ thread_local!( ); pub fn first_key_51() -> i32 { let entry: Value = Rc::new(RefCell::new(::zero_init())); - Entry_52Impl::construct_1(&entry.as_pointer()); + DefaultConstructible::default_constructor(&entry.as_pointer()); return { (*entry.borrow()).key }; } pub fn second_key_plus_value_53() -> i32 { let entry: Value = Rc::new(RefCell::new(::zero_init())); - Entry_54Impl::construct_1(&entry.as_pointer()); + DefaultConstructible::default_constructor(&entry.as_pointer()); return ({ (*entry.borrow()).key } + { (*entry.borrow()).value }); } pub fn test_55() { @@ -225,9 +225,7 @@ pub struct Entry_52 { } impl DefaultConstructible for Entry_52 { fn default_constructor(this: &Ptr) { - { - Entry_52Impl::construct_1(this); - } + field!((*this), key).write(1); } } impl Default for Entry_52 { @@ -245,9 +243,8 @@ pub struct Entry_54 { } impl DefaultConstructible for Entry_54 { fn default_constructor(this: &Ptr) { - { - Entry_54Impl::construct_1(this); - } + field!((*this), key).write(2); + field!((*this), value).write(30); } } impl Default for Entry_54 { @@ -364,9 +361,8 @@ pub struct Record_65 { } impl DefaultConstructible for Record_65 { fn default_constructor(this: &Ptr) { - { - Record_65Impl::construct_1(this); - } + field!((*this), id).write(200_i64); + field!((*this), extra).write(1); } } impl Default for Record_65 { @@ -387,7 +383,7 @@ pub fn bump_in_b_22() -> i32 { } pub fn record_id_in_b_23() -> i32 { let record: Value = Rc::new(RefCell::new(::zero_init())); - Record_65Impl::construct_1(&record.as_pointer()); + DefaultConstructible::default_constructor(&record.as_pointer()); return ({ (*record.borrow()).id } as i32); } pub fn depth_in_b_24() -> i32 { @@ -414,10 +410,11 @@ pub fn raise_30(mut by: i32) -> i32 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct Tally_67 {} thread_local!( @@ -457,7 +454,7 @@ thread_local!( ); pub fn key_in_b_56() -> i32 { let entry: Value = Rc::new(RefCell::new(::zero_init())); - Entry_71Impl::construct_1(&entry.as_pointer()); + DefaultConstructible::default_constructor(&entry.as_pointer()); return ({ (*entry.borrow()).key } as i32); } #[derive(Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable)] @@ -468,9 +465,7 @@ pub struct Entry_71 { } impl DefaultConstructible for Entry_71 { fn default_constructor(this: &Ptr) { - { - Entry_71Impl::construct_1(this); - } + field!((*this), key).write(400_i64); } } impl Default for Entry_71 { @@ -493,48 +488,6 @@ pub fn table_sum_in_b_59() -> i32 { table_57.with(|rc| rc.borrow()[__idx0]) })); } -pub trait Entry_52Impl { - fn construct_1(&self); -} -impl Entry_52Impl for Ptr { - fn construct_1(&self) { - field!((*self), key).write(1); - } -} -pub trait Entry_54Impl { - fn construct_1(&self); -} -impl Entry_54Impl for Ptr { - fn construct_1(&self) { - field!((*self), key).write(2); - field!((*self), value).write(30); - } -} -pub trait Entry_71Impl { - fn construct_1(&self); -} -impl Entry_71Impl for Ptr { - fn construct_1(&self) { - field!((*self), key).write(400_i64); - } -} -pub trait Record_19Impl { - fn construct_1(&self); -} -impl Record_19Impl for Ptr { - fn construct_1(&self) { - field!((*self), id).write(100); - } -} -pub trait Record_65Impl { - fn construct_1(&self); -} -impl Record_65Impl for Ptr { - fn construct_1(&self) { - field!((*self), id).write(200_i64); - field!((*self), extra).write(1); - } -} pub trait Tally_31Impl { fn add(&self, amount: i32) -> i32; } 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 ba5cfb1869..d3c3a39245 100644 --- a/tests/std/basic/basic.link/out/unsafe/basic.link.rs +++ b/tests/std/basic/basic.link/out/unsafe/basic.link.rs @@ -72,16 +72,9 @@ pub unsafe fn bump_18() -> i32 { pub struct Record_19 { pub id: i32, } -impl Record_19 { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.id).write(100); - } -} impl DefaultConstructibleUnsafe for Record_19 { unsafe fn default_constructor(&mut self) { - unsafe { - Record_19::construct_1(&mut *self); - } + (&raw mut self.id).write(100); } } impl Default for Record_19 { @@ -95,7 +88,7 @@ pub unsafe fn test_21() { assert!(((unsafe { bump_in_b_22() }) == (51))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut counter_17)) == (2))); let mut record: Record_19 = ::zero_init(); - Record_19::construct_1(&mut record); + DefaultConstructibleUnsafe::default_constructor(&mut record); assert!(((record.id) == (100))); assert!(((unsafe { record_id_in_b_23() }) == (200))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut depth_20)) == (3))); @@ -120,10 +113,11 @@ pub unsafe fn test_29() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Tally_31 {} impl Tally_31 { pub unsafe fn add(&mut self, mut amount: i32) -> i32 { @@ -145,10 +139,11 @@ pub unsafe fn test_33() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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))); @@ -198,12 +193,12 @@ static mut count_46: std::cell::LazyCell = std::cell::LazyCell::new(|| unsa static mut count_48: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 1 }); pub unsafe fn first_key_51() -> i32 { let mut entry: Entry_52 = ::zero_init(); - Entry_52::construct_1(&mut entry); + DefaultConstructibleUnsafe::default_constructor(&mut entry); return entry.key; } pub unsafe fn second_key_plus_value_53() -> i32 { let mut entry: Entry_54 = ::zero_init(); - Entry_54::construct_1(&mut entry); + DefaultConstructibleUnsafe::default_constructor(&mut entry); return ((entry.key) + (entry.value)); } pub unsafe fn test_55() { @@ -216,16 +211,9 @@ pub unsafe fn test_55() { pub struct Entry_52 { pub key: i32, } -impl Entry_52 { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.key).write(1); - } -} impl DefaultConstructibleUnsafe for Entry_52 { unsafe fn default_constructor(&mut self) { - unsafe { - Entry_52::construct_1(&mut *self); - } + (&raw mut self.key).write(1); } } impl Default for Entry_52 { @@ -239,17 +227,10 @@ pub struct Entry_54 { pub key: i32, pub value: i32, } -impl Entry_54 { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.key).write(2); - (&raw mut self.value).write(30); - } -} impl DefaultConstructibleUnsafe for Entry_54 { unsafe fn default_constructor(&mut self) { - unsafe { - Entry_54::construct_1(&mut *self); - } + (&raw mut self.key).write(2); + (&raw mut self.value).write(30); } } impl Default for Entry_54 { @@ -345,17 +326,10 @@ pub struct Record_65 { pub id: i64, pub extra: i32, } -impl Record_65 { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.id).write(200_i64); - (&raw mut self.extra).write(1); - } -} impl DefaultConstructibleUnsafe for Record_65 { unsafe fn default_constructor(&mut self) { - unsafe { - Record_65::construct_1(&mut *self); - } + (&raw mut self.id).write(200_i64); + (&raw mut self.extra).write(1); } } impl Default for Record_65 { @@ -374,7 +348,7 @@ pub unsafe fn bump_in_b_22() -> i32 { } pub unsafe fn record_id_in_b_23() -> i32 { let mut record: Record_65 = ::zero_init(); - Record_65::construct_1(&mut record); + DefaultConstructibleUnsafe::default_constructor(&mut record); return (record.id as i32); } pub unsafe fn depth_in_b_24() -> i32 { @@ -397,10 +371,11 @@ pub unsafe fn raise_30(mut by: i32) -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Tally_67 {} impl Tally_67 { pub unsafe fn add(&mut self, mut amount: i32) -> i32 { @@ -435,7 +410,7 @@ pub unsafe fn next_in_b_50() -> i32 { static mut count_70: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub unsafe fn key_in_b_56() -> i32 { let mut entry: Entry_71 = ::zero_init(); - Entry_71::construct_1(&mut entry); + DefaultConstructibleUnsafe::default_constructor(&mut entry); return (entry.key as i32); } #[repr(C)] @@ -443,16 +418,9 @@ pub unsafe fn key_in_b_56() -> i32 { pub struct Entry_71 { pub key: i64, } -impl Entry_71 { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.key).write(400_i64); - } -} impl DefaultConstructibleUnsafe for Entry_71 { unsafe fn default_constructor(&mut self) { - unsafe { - Entry_71::construct_1(&mut *self); - } + (&raw mut self.key).write(400_i64); } } impl Default for Entry_71 { 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 8cdcd7cbcb..e2d3b812c9 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 @@ -45,6 +45,12 @@ impl LifetimeTracked { }); } } +impl DefaultConstructible for LifetimeTracked { + fn default_constructor(this: &Ptr) { + field!((*this), uses).write(0); + (*ctorCount_0.with(Value::clone).borrow_mut()).prefix_inc(); + } +} impl CopyConstructible for LifetimeTracked { fn copy_constructor(this: &Ptr, _a0: Ptr) { field!((*this), uses).write(0); @@ -66,20 +72,13 @@ impl Clone for LifetimeTracked { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } -impl DefaultConstructible for LifetimeTracked { - fn default_constructor(this: &Ptr) { - { - LifetimeTrackedImpl::construct(this); - } - } -} impl Default for LifetimeTracked { fn default() -> Self { { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -101,13 +100,12 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(copy_assign)] +#[memberwise(default_constructor, copy_assign)] #[byte_size(4)] pub struct p1_1_condition_variable_visible_in_else_ConvertsToBool { #[offset(0)] @@ -185,7 +183,7 @@ pub fn test_8() { pub fn test_9() { ({ LifetimeTracked::reset() }); let scoped: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::construct(&scoped.as_pointer()); + DefaultConstructible::default_constructor(&scoped.as_pointer()); let _dtor_scoped = std::mem::DropGuard::new(scoped.clone(), |__p| { Destructible::destroy(&__p.as_pointer()) }); @@ -196,7 +194,7 @@ pub fn test_9() { 'for_body: { let scoped: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::construct(&scoped.as_pointer()); + DefaultConstructible::default_constructor(&scoped.as_pointer()); let _dtor_scoped = std::mem::DropGuard::new(scoped.clone(), |__p| { Destructible::destroy(&__p.as_pointer()) }); @@ -208,7 +206,7 @@ pub fn test_9() { assert!((dtorCount_2.with(|rc| *rc.borrow()) == 3)); if (ctorCount_0.with(|rc| *rc.borrow()) == 4) { let scoped: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::construct(&scoped.as_pointer()); + DefaultConstructible::default_constructor(&scoped.as_pointer()); let _dtor_scoped = std::mem::DropGuard::new(scoped.clone(), |__p| { Destructible::destroy(&__p.as_pointer()) }); @@ -218,7 +216,7 @@ pub fn test_9() { if (ctorCount_0.with(|rc| *rc.borrow()) == 0) { } else { let scoped: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::construct(&scoped.as_pointer()); + DefaultConstructible::default_constructor(&scoped.as_pointer()); let _dtor_scoped = std::mem::DropGuard::new(scoped.clone(), |__p| { Destructible::destroy(&__p.as_pointer()) }); @@ -251,13 +249,13 @@ pub fn test_10() { pub fn test_11() { ({ LifetimeTracked::reset() }); let tracked: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::construct(&tracked.as_pointer()); + DefaultConstructible::default_constructor(&tracked.as_pointer()); let _dtor_tracked = std::mem::DropGuard::new(tracked.clone(), |__p| { Destructible::destroy(&__p.as_pointer()) }); { let tracked: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::construct(&tracked.as_pointer()); + DefaultConstructible::default_constructor(&tracked.as_pointer()); let _dtor_tracked = std::mem::DropGuard::new(tracked.clone(), |__p| { Destructible::destroy(&__p.as_pointer()) }); @@ -347,14 +345,9 @@ fn main_0() -> i32 { return 0; } pub trait LifetimeTrackedImpl { - fn construct(&self); fn use_(&self); } impl LifetimeTrackedImpl for Ptr { - fn construct(&self) { - field!((*self), uses).write(0); - (*ctorCount_0.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.scope/out/refcount/basic.scope.class.rs b/tests/std/basic/basic.scope/out/refcount/basic.scope.class.rs index 494a5a4b6b..0d4692d5d3 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 @@ -17,9 +17,7 @@ pub struct p1_member_hides_namespace_variable_HasBalance { } impl DefaultConstructible for p1_member_hides_namespace_variable_HasBalance { fn default_constructor(this: &Ptr) { - { - p1_member_hides_namespace_variable_HasBalanceImpl::construct_1(this); - } + field!((*this), balance).write(7); } } impl Default for p1_member_hides_namespace_variable_HasBalance { @@ -31,7 +29,7 @@ pub fn test_1() { let object: Value = Rc::new(RefCell::new( ::zero_init(), )); - p1_member_hides_namespace_variable_HasBalanceImpl::construct_1(&object.as_pointer()); + DefaultConstructible::default_constructor(&object.as_pointer()); assert!( (({ p1_member_hides_namespace_variable_HasBalanceImpl::deposit(&object.as_pointer(), 3) @@ -61,9 +59,7 @@ pub struct p1_out_of_class_definition_is_in_class_scope_HasStaticTotal { } impl DefaultConstructible for p1_out_of_class_definition_is_in_class_scope_HasStaticTotal { fn default_constructor(this: &Ptr) { - { - p1_out_of_class_definition_is_in_class_scope_HasStaticTotalImpl::construct_1(this); - } + field!((*this), held).write(1); } } impl Default for p1_out_of_class_definition_is_in_class_scope_HasStaticTotal { @@ -82,9 +78,7 @@ pub fn test_5() { let object: Value = Rc::new( RefCell::new(::zero_init()), ); - p1_out_of_class_definition_is_in_class_scope_HasStaticTotalImpl::construct_1( - &object.as_pointer(), - ); + DefaultConstructible::default_constructor(&object.as_pointer()); assert!( (({ p1_out_of_class_definition_is_in_class_scope_HasStaticTotalImpl::add( @@ -109,7 +103,6 @@ fn main_0() -> i32 { pub trait p1_member_hides_namespace_variable_HasBalanceImpl { fn deposit(&self, amount: i32) -> i32; fn deposit_globally(&self, amount: i32) -> i32; - fn construct_1(&self); } impl p1_member_hides_namespace_variable_HasBalanceImpl for Ptr @@ -124,20 +117,13 @@ impl p1_member_hides_namespace_variable_HasBalanceImpl balance_0.with(|rc| *rc.borrow_mut() += amount); return balance_0.with(|rc| *rc.borrow()); } - fn construct_1(&self) { - field!((*self), balance).write(7); - } } pub trait p1_out_of_class_definition_is_in_class_scope_HasStaticTotalImpl { fn add(&self, amount: i32) -> i32; - fn construct_1(&self); } impl p1_out_of_class_definition_is_in_class_scope_HasStaticTotalImpl for Ptr { - fn construct_1(&self) { - field!((*self), held).write(1); - } fn add(&self, mut amount: i32) -> i32 { { field!((*self), held).with_mut(|__v| *__v = *__v + amount) 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 d8c51cb590..42916998f0 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 @@ -25,10 +25,11 @@ pub fn test_0() { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(16)] pub struct p1_own_address_in_initializer_SelfLinked { #[offset(0)] @@ -92,9 +93,11 @@ pub struct p9_func_declared_before_function_body_RecordsConstructorName { } impl DefaultConstructible for p9_func_declared_before_function_body_RecordsConstructorName { fn default_constructor(this: &Ptr) { - { - p9_func_declared_before_function_body_RecordsConstructorNameImpl::construct(this); - } + field!((*this), name).write(Ptr::::from_string_literal(b"RecordsConstructorName")); + assert!( + ((*this).with(|__s| __s.name.clone()) + == Ptr::::from_string_literal(b"RecordsConstructorName")) + ); } } impl Default for p9_func_declared_before_function_body_RecordsConstructorName { @@ -105,9 +108,7 @@ impl Default for p9_func_declared_before_function_body_RecordsConstructorName { Rc::new(RefCell::new( ::zero_init(), )); - p9_func_declared_before_function_body_RecordsConstructorNameImpl::construct( - &__v.as_pointer(), - ); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -138,9 +139,7 @@ pub fn test_6() { let object: Value = Rc::new( RefCell::new(::zero_init()), ); - p9_func_declared_before_function_body_RecordsConstructorNameImpl::construct( - &object.as_pointer(), - ); + DefaultConstructible::default_constructor(&object.as_pointer()); assert!( ({ let mut __it1 = { (*object.borrow()).name.clone() }.to_c_string_iterator(); @@ -213,18 +212,4 @@ fn main_0() -> i32 { ({ test_7() }); return 0; } -pub trait p9_func_declared_before_function_body_RecordsConstructorNameImpl { - fn construct(&self); -} -impl p9_func_declared_before_function_body_RecordsConstructorNameImpl - for Ptr -{ - fn construct(&self) { - field!((*self), name).write(Ptr::::from_string_literal(b"RecordsConstructorName")); - assert!( - ((*self).with(|__s| __s.name.clone()) - == Ptr::::from_string_literal(b"RecordsConstructorName")) - ); - } -} pub fn __cpp2rust_init_globals() {} 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 8a00075bba..51baf6a208 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 @@ -52,10 +52,11 @@ pub const p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum_Size_large: ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum {} pub fn test_5() { @@ -91,10 +92,11 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct p2_12_class_name_in_own_scope_HasStaticCounter {} impl p2_12_class_name_in_own_scope_HasStaticCounter { @@ -170,10 +172,11 @@ impl Default for anon_9 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(16)] pub struct p2_13_anonymous_union_members_in_parent_scope_HasAnonymousUnion { #[offset(0)] @@ -244,9 +247,8 @@ pub struct p3_2_const_qualified_member_is_distinct_HasConstOverload { } impl DefaultConstructible for p3_2_const_qualified_member_is_distinct_HasConstOverload { fn default_constructor(this: &Ptr) { - { - p3_2_const_qualified_member_is_distinct_HasConstOverloadImpl::construct_1(this); - } + field!((*this), plain_calls).write(0); + field!((*this), const_calls).write(0); } } impl Default for p3_2_const_qualified_member_is_distinct_HasConstOverload { @@ -263,7 +265,7 @@ pub fn test_12() { let object: Value = Rc::new( RefCell::new(::zero_init()), ); - p3_2_const_qualified_member_is_distinct_HasConstOverloadImpl::construct_1(&object.as_pointer()); + DefaultConstructible::default_constructor(&object.as_pointer()); let view: Ptr = object.as_pointer(); assert!( (({ @@ -296,9 +298,7 @@ impl DefaultConstructible for p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload { fn default_constructor(this: &Ptr) { - { - p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverloadImpl :: construct_1 ( this , ) ; - } + field!((*this), base).write(10); } } impl Default for p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload { @@ -317,9 +317,7 @@ pub fn test_15() { ::zero_init( ), )); - p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverloadImpl::construct_1( - &object.as_pointer(), - ); + DefaultConstructible::default_constructor(&object.as_pointer()); assert!( (({ as p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverloadImpl>::pick_1 ( object .as_pointer() , 1 , ) @@ -331,7 +329,7 @@ pub fn test_15() { let __tmp_0: Value = Rc::new(RefCell::new(::zero_init())); assert!( (({ - p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverloadImpl :: pick_2 ( &{ p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverloadImpl :: construct_1 ( &__tmp_0.as_pointer() , ) ; __tmp_0.as_pointer() } , 2 , ) + p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverloadImpl :: pick_2 ( &{ DefaultConstructible :: default_constructor ( &__tmp_0.as_pointer() , ) ; __tmp_0.as_pointer() } , 2 , ) }) == 112) ) }; @@ -352,10 +350,11 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct p3_2_ref_qualified_members_are_distinct_HasRefQualifiedOverloads {} pub fn test_18() { @@ -405,9 +404,8 @@ impl DefaultConstructible for p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload { fn default_constructor(this: &Ptr) { - { - p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverloadImpl :: construct_1 ( this , ) ; - } + field!((*this), plain_calls).write(0); + field!((*this), const_calls).write(0); } } impl Default for p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload { @@ -422,9 +420,7 @@ impl Default for p3_4_const_qualified_member_templates_are_distinct_HasConstTemp } pub fn test_19() { let object: Value = Rc::new(RefCell::new(::zero_init())); - p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverloadImpl::construct_1( - &object.as_pointer(), - ); + DefaultConstructible::default_constructor(&object.as_pointer()); let view: Ptr = object.as_pointer(); assert!( @@ -456,10 +452,11 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct p3_4_ref_qualified_member_templates_are_distinct_HasRefQualifiedTemplateOverloads {} pub fn test_22() { @@ -497,10 +494,11 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct p4_friend_definition_defines_earlier_friend_declaration_DeclaresFriend {} pub fn shared_friend_24() -> i32 { @@ -515,10 +513,11 @@ pub fn shared_friend_24() -> i32 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct p4_friend_definition_defines_earlier_friend_declaration_DefinesFriend {} pub fn test_25() { @@ -558,10 +557,11 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct p4_2_class_and_function_share_name_Reading { #[offset(0)] @@ -587,10 +587,11 @@ pub fn test_33() { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct p4_2_class_and_variable_share_name_Limit { #[offset(0)] @@ -790,7 +791,6 @@ impl p2_13_anonymous_union_members_in_parent_scope_HasAnonymousUnionImpl pub trait p3_2_const_qualified_member_is_distinct_HasConstOverloadImpl { fn get_1(&self) -> i32; fn get_2(&self) -> i32; - fn construct_1(&self); } impl p3_2_const_qualified_member_is_distinct_HasConstOverloadImpl for Ptr @@ -807,10 +807,6 @@ impl p3_2_const_qualified_member_is_distinct_HasConstOverloadImpl }); return 2; } - fn construct_1(&self) { - field!((*self), plain_calls).write(0); - field!((*self), const_calls).write(0); - } } pub trait p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverloadImpl { fn pick_1( @@ -818,7 +814,6 @@ pub trait p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObject amount: i32, ) -> i32; fn pick_2(&self, amount: i32) -> i32; - fn construct_1(&self); } impl p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverloadImpl for Ptr @@ -834,9 +829,6 @@ impl p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverl (*rvalue_calls_14.with(Value::clone).borrow_mut()).prefix_inc(); return (((*self).with(|__s| __s.base) + amount) + 100); } - fn construct_1(&self) { - field!((*self), base).write(10); - } } pub trait p3_2_ref_qualified_members_are_distinct_HasRefQualifiedOverloadsImpl { fn get_1(&self) -> i32; @@ -855,17 +847,12 @@ impl p3_2_ref_qualified_members_are_distinct_HasRefQualifiedOverloadsImpl } } pub trait p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverloadImpl { - fn construct_1(&self); fn get_1_int(&self, value: i32) -> i32; fn get_2_int(&self, value: i32) -> i32; } impl p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverloadImpl for Ptr { - fn construct_1(&self) { - field!((*self), plain_calls).write(0); - field!((*self), const_calls).write(0); - } fn get_1_int(&self, mut value: i32) -> i32 { field!((*self), plain_calls).with_mut(|__v| { __v.prefix_inc(); 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 a3af1efa1e..d189f181da 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 @@ -29,15 +29,17 @@ impl LifetimeTracked { (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)) }; } - pub unsafe fn construct(&mut self) { - (&raw mut self.uses).write(0); - (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).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(); } } +impl DefaultConstructibleUnsafe for LifetimeTracked { + unsafe fn default_constructor(&mut self) { + (&raw mut self.uses).write(0); + (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).prefix_inc(); + } +} impl CopyConstructibleUnsafe for LifetimeTracked { unsafe fn copy_constructor(&mut self, _a0: *const LifetimeTracked) { (&raw mut self.uses).write(0); @@ -58,19 +60,12 @@ impl Clone for LifetimeTracked { } } } -impl DefaultConstructibleUnsafe for LifetimeTracked { - unsafe fn default_constructor(&mut self) { - unsafe { - LifetimeTracked::construct(&mut *self); - } - } -} impl Default for LifetimeTracked { fn default() -> Self { unsafe { { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -87,13 +82,12 @@ pub static mut dtorCount_6: std::cell::LazyCell = std::cell::LazyCell::new( VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(copy_assign)] +#[memberwise(default_constructor, copy_assign)] pub struct p1_1_condition_variable_visible_in_else_ConvertsToBool { pub value: i32, } @@ -166,7 +160,7 @@ pub unsafe fn test_8() { pub unsafe fn test_9() { (unsafe { LifetimeTracked::reset() }); let mut scoped: LifetimeTracked = ::zero_init(); - LifetimeTracked::construct(&mut scoped); + DefaultConstructibleUnsafe::default_constructor(&mut scoped); let _dtor_scoped = std::mem::DropGuard::new(&raw mut scoped, |__p| unsafe { DestructibleUnsafe::destroy(&mut *__p) }); @@ -176,7 +170,7 @@ pub unsafe fn test_9() { 'loop_: while ((index) < (3)) { 'for_body: { let mut scoped: LifetimeTracked = ::zero_init(); - LifetimeTracked::construct(&mut scoped); + DefaultConstructibleUnsafe::default_constructor(&mut scoped); let _dtor_scoped = std::mem::DropGuard::new(&raw mut scoped, |__p| unsafe { DestructibleUnsafe::destroy(&mut *__p) }); @@ -188,7 +182,7 @@ pub unsafe fn test_9() { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)) == (3))); if ((*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)) == (4)) { let mut scoped: LifetimeTracked = ::zero_init(); - LifetimeTracked::construct(&mut scoped); + DefaultConstructibleUnsafe::default_constructor(&mut scoped); let _dtor_scoped = std::mem::DropGuard::new(&raw mut scoped, |__p| unsafe { DestructibleUnsafe::destroy(&mut *__p) }); @@ -198,7 +192,7 @@ pub unsafe fn test_9() { if ((*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)) == (0)) { } else { let mut scoped: LifetimeTracked = ::zero_init(); - LifetimeTracked::construct(&mut scoped); + DefaultConstructibleUnsafe::default_constructor(&mut scoped); let _dtor_scoped = std::mem::DropGuard::new(&raw mut scoped, |__p| unsafe { DestructibleUnsafe::destroy(&mut *__p) }); @@ -227,13 +221,13 @@ pub unsafe fn test_10() { pub unsafe fn test_11() { (unsafe { LifetimeTracked::reset() }); let mut tracked: LifetimeTracked = ::zero_init(); - LifetimeTracked::construct(&mut tracked); + DefaultConstructibleUnsafe::default_constructor(&mut tracked); let _dtor_tracked = std::mem::DropGuard::new(&raw mut tracked, |__p| unsafe { DestructibleUnsafe::destroy(&mut *__p) }); { let mut tracked: LifetimeTracked = ::zero_init(); - LifetimeTracked::construct(&mut tracked); + DefaultConstructibleUnsafe::default_constructor(&mut tracked); let _dtor_tracked = std::mem::DropGuard::new(&raw mut tracked, |__p| unsafe { DestructibleUnsafe::destroy(&mut *__p) }); 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 0b1e1e3c87..a5dd7660f9 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 @@ -21,15 +21,10 @@ impl p1_member_hides_namespace_variable_HasBalance { (*std::cell::LazyCell::force_mut(&mut *&raw mut balance_0)) += amount; return (*std::cell::LazyCell::force_mut(&mut *&raw mut balance_0)); } - pub unsafe fn construct_1(&mut self) { - (&raw mut self.balance).write(7); - } } impl DefaultConstructibleUnsafe for p1_member_hides_namespace_variable_HasBalance { unsafe fn default_constructor(&mut self) { - unsafe { - p1_member_hides_namespace_variable_HasBalance::construct_1(&mut *self); - } + (&raw mut self.balance).write(7); } } impl Default for p1_member_hides_namespace_variable_HasBalance { @@ -40,7 +35,7 @@ impl Default for p1_member_hides_namespace_variable_HasBalance { pub unsafe fn test_1() { let mut object: p1_member_hides_namespace_variable_HasBalance = ::zero_init(); - p1_member_hides_namespace_variable_HasBalance::construct_1(&mut object); + DefaultConstructibleUnsafe::default_constructor(&mut object); assert!( ((unsafe { p1_member_hides_namespace_variable_HasBalance::deposit(&mut object, 3,) }) == (10)) @@ -61,16 +56,9 @@ pub static mut initial_2: std::cell::LazyCell = std::cell::LazyCell::new(|| pub struct p1_out_of_class_definition_is_in_class_scope_HasStaticTotal { pub held: i32, } -impl p1_out_of_class_definition_is_in_class_scope_HasStaticTotal { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.held).write(1); - } -} impl DefaultConstructibleUnsafe for p1_out_of_class_definition_is_in_class_scope_HasStaticTotal { unsafe fn default_constructor(&mut self) { - unsafe { - p1_out_of_class_definition_is_in_class_scope_HasStaticTotal::construct_1(&mut *self); - } + (&raw mut self.held).write(1); } } impl Default for p1_out_of_class_definition_is_in_class_scope_HasStaticTotal { @@ -94,7 +82,7 @@ pub unsafe fn test_5() { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut total_4)) == (7))); let mut object: p1_out_of_class_definition_is_in_class_scope_HasStaticTotal = ::zero_init(); - p1_out_of_class_definition_is_in_class_scope_HasStaticTotal::construct_1(&mut object); + DefaultConstructibleUnsafe::default_constructor(&mut object); assert!( ((unsafe { p1_out_of_class_definition_is_in_class_scope_HasStaticTotal::add(&mut object, 4) 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 c6511a0471..e4d9044635 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 @@ -25,10 +25,11 @@ pub unsafe fn test_0() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct p1_own_address_in_initializer_SelfLinked { pub next: *mut p1_own_address_in_initializer_SelfLinked, pub value: i32, @@ -85,17 +86,10 @@ pub const anon_4_above: anon_4 = 14; pub struct p9_func_declared_before_function_body_RecordsConstructorName { pub name: *const libc::c_char, } -impl p9_func_declared_before_function_body_RecordsConstructorName { - pub unsafe fn construct(&mut self) { - (&raw mut self.name).write(c"RecordsConstructorName".as_ptr()); - assert!(((self.name) == (c"RecordsConstructorName".as_ptr()))); - } -} impl DefaultConstructibleUnsafe for p9_func_declared_before_function_body_RecordsConstructorName { unsafe fn default_constructor(&mut self) { - unsafe { - p9_func_declared_before_function_body_RecordsConstructorName::construct(&mut *self); - } + (&raw mut self.name).write(c"RecordsConstructorName".as_ptr()); + assert!(((self.name) == (c"RecordsConstructorName".as_ptr()))); } } impl Default for p9_func_declared_before_function_body_RecordsConstructorName { @@ -104,7 +98,7 @@ impl Default for p9_func_declared_before_function_body_RecordsConstructorName { { let mut __v: p9_func_declared_before_function_body_RecordsConstructorName = ::zero_init(); - p9_func_declared_before_function_body_RecordsConstructorName::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -118,7 +112,7 @@ pub unsafe fn test_6() { assert!(((unsafe { plain_function_5() }) == (unsafe { plain_function_5() }))); let mut object: p9_func_declared_before_function_body_RecordsConstructorName = ::zero_init(); - p9_func_declared_before_function_body_RecordsConstructorName::construct(&mut object); + DefaultConstructibleUnsafe::default_constructor(&mut object); assert!(((libc::strcmp(object.name, c"RecordsConstructorName".as_ptr())) == (0))); let mut enclosing: *const libc::c_char = c"test".as_ptr(); let mut lambda: FnPtr *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 d13d1cedeb..a5995ea92e 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 @@ -48,10 +48,11 @@ pub const p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum_Size_large: VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 { @@ -84,10 +85,11 @@ pub static mut count_6: std::cell::LazyCell = std::cell::LazyCell::new(|| u VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct p2_12_class_name_in_own_scope_HasStaticCounter {} impl p2_12_class_name_in_own_scope_HasStaticCounter { pub unsafe fn bump() { @@ -149,10 +151,11 @@ impl Default for anon_9 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct p2_13_anonymous_union_members_in_parent_scope_HasAnonymousUnion { pub tag: i32, pub anon_9: anon_9, @@ -222,16 +225,11 @@ impl p3_2_const_qualified_member_is_distinct_HasConstOverload { (*(&raw const self.const_calls).cast_mut()).prefix_inc(); return 2; } - pub unsafe fn construct_1(&mut self) { - (&raw mut self.plain_calls).write(0); - (&raw mut self.const_calls).write(0); - } } impl DefaultConstructibleUnsafe for p3_2_const_qualified_member_is_distinct_HasConstOverload { unsafe fn default_constructor(&mut self) { - unsafe { - p3_2_const_qualified_member_is_distinct_HasConstOverload::construct_1(&mut *self); - } + (&raw mut self.plain_calls).write(0); + (&raw mut self.const_calls).write(0); } } impl Default for p3_2_const_qualified_member_is_distinct_HasConstOverload { @@ -247,7 +245,7 @@ impl Default for p3_2_const_qualified_member_is_distinct_HasConstOverload { pub unsafe fn test_12() { let mut object: p3_2_const_qualified_member_is_distinct_HasConstOverload = ::zero_init(); - p3_2_const_qualified_member_is_distinct_HasConstOverload::construct_1(&mut object); + DefaultConstructibleUnsafe::default_constructor(&mut object); let view: *const p3_2_const_qualified_member_is_distinct_HasConstOverload = &object; assert!( ((unsafe { @@ -284,17 +282,12 @@ impl p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverl (*std::cell::LazyCell::force_mut(&mut *&raw mut rvalue_calls_14)).prefix_inc(); return (((self.base) + (amount)) + (100)); } - pub unsafe fn construct_1(&mut self) { - (&raw mut self.base).write(10); - } } impl DefaultConstructibleUnsafe for p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload { unsafe fn default_constructor(&mut self) { - unsafe { - p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload :: construct_1 ( &mut *self , ) ; - } + (&raw mut self.base).write(10); } } impl Default for p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload { @@ -310,9 +303,7 @@ pub unsafe fn test_15() { let mut object: p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload = ::zero_init( ); - p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload::construct_1( - &mut object, - ); + DefaultConstructibleUnsafe::default_constructor(&mut object); assert!( ((unsafe { p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload::pick_1( @@ -327,7 +318,7 @@ pub unsafe fn test_15() { let mut __tmp_0: p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload = ::zero_init(); assert!( ((unsafe { - p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload :: pick_2 ( &mut (*{ p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload :: construct_1 ( &mut __tmp_0 , ) ; & mut __tmp_0 } ) , 2 , ) + p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload :: pick_2 ( &mut (*{ DefaultConstructibleUnsafe :: default_constructor ( &mut __tmp_0 , ) ; & mut __tmp_0 } ) , 2 , ) }) == (112)) ) }; @@ -345,10 +336,11 @@ pub static mut rvalue_calls_17: std::cell::LazyCell = VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 { @@ -394,10 +386,6 @@ pub struct p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOv pub const_calls: i32, } impl p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.plain_calls).write(0); - (&raw mut self.const_calls).write(0); - } pub unsafe fn get_1_int(&mut self, mut value: i32) -> i32 { self.plain_calls.prefix_inc(); return ((value) + (1)); @@ -411,9 +399,8 @@ impl DefaultConstructibleUnsafe for p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload { unsafe fn default_constructor(&mut self) { - unsafe { - p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload :: construct_1 ( &mut *self , ) ; - } + (&raw mut self.plain_calls).write(0); + (&raw mut self.const_calls).write(0); } } impl Default for p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload { @@ -429,9 +416,7 @@ impl Default for p3_4_const_qualified_member_templates_are_distinct_HasConstTemp pub unsafe fn test_19() { let mut object: p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload = ::zero_init(); - p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload::construct_1( - &mut object, - ); + DefaultConstructibleUnsafe::default_constructor(&mut object); let view: *const p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload = &object; assert!( @@ -466,10 +451,11 @@ pub static mut rvalue_calls_21: std::cell::LazyCell = VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 { @@ -514,10 +500,11 @@ pub static mut friend_calls_23: std::cell::LazyCell = VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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(); @@ -530,10 +517,11 @@ pub unsafe fn shared_friend_24() -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct p4_friend_definition_defines_earlier_friend_declaration_DefinesFriend {} pub unsafe fn test_25() { assert!(((unsafe { shared_friend_24() }) == (7))); @@ -568,10 +556,11 @@ pub static mut function_calls_31: std::cell::LazyCell = VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct p4_2_class_and_function_share_name_Reading { pub value: i32, } @@ -594,10 +583,11 @@ pub unsafe fn test_33() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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.rs b/tests/std/basic/basic.start/out/refcount/basic.start.term.rs index 07c73281f0..922dd393ca 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 @@ -61,10 +61,11 @@ pub struct HoldsTracker { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct TriviallyDestructible { #[offset(0)] @@ -160,10 +161,11 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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.rs b/tests/std/basic/basic.start/out/unsafe/basic.start.term.rs index 992363dd2f..ccc34b8bbb 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 @@ -62,10 +62,11 @@ pub struct HoldsTracker { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct TriviallyDestructible { pub value: i32, } @@ -161,10 +162,11 @@ pub static mut trivial_9: std::cell::LazyCell = VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 3ec7f2af61..ece91156d4 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 @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct p2_pointer_to_data_member_bytes_round_trip_HasTwoInts { #[offset(0)] @@ -88,10 +89,11 @@ pub fn test_0() { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 11729441e8..c6593c2727 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 @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct p2_pointer_to_data_member_bytes_round_trip_HasTwoInts { pub first: i32, pub second: i32, @@ -91,10 +92,11 @@ pub unsafe fn test_0() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 2679a8ed5e..b8b11d1512 100644 --- a/tests/std/basic/out/refcount/basic.def.odr.rs +++ b/tests/std/basic/out/refcount/basic.def.odr.rs @@ -88,6 +88,12 @@ impl LifetimeTracked { }); } } +impl DefaultConstructible for LifetimeTracked { + fn default_constructor(this: &Ptr) { + field!((*this), uses).write(0); + (*ctorCount_1.with(Value::clone).borrow_mut()).prefix_inc(); + } +} impl CopyConstructible for LifetimeTracked { fn copy_constructor(this: &Ptr, _a0: Ptr) { field!((*this), uses).write(0); @@ -109,20 +115,13 @@ impl Clone for LifetimeTracked { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } -impl DefaultConstructible for LifetimeTracked { - fn default_constructor(this: &Ptr) { - { - LifetimeTrackedImpl::construct(this); - } - } -} impl Default for LifetimeTracked { fn default() -> Self { { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -289,7 +288,7 @@ thread_local!( pub static global_12: Value = { let __static = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); libcc2rs::register_static_destructor(|| { @@ -313,7 +312,7 @@ pub fn test_13() { pub fn test_14() { ({ LifetimeTracked::reset() }); let t: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::construct(&t.as_pointer()); + DefaultConstructible::default_constructor(&t.as_pointer()); let _dtor_t = std::mem::DropGuard::new(t.clone(), |__p| Destructible::destroy(&__p.as_pointer())); let r: Ptr = t.as_pointer(); @@ -486,9 +485,8 @@ pub struct p6_unevaluated_binding_needs_no_capture_HasTwoMembers { } impl DefaultConstructible for p6_unevaluated_binding_needs_no_capture_HasTwoMembers { fn default_constructor(this: &Ptr) { - { - p6_unevaluated_binding_needs_no_capture_HasTwoMembersImpl::construct_1(this); - } + DefaultConstructible::default_constructor(&field_ptr!(this, a)); + DefaultConstructible::default_constructor(&field_ptr!(this, b)); } } pub fn test_20() { @@ -498,13 +496,13 @@ pub fn test_20() { a: { let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() }, b: { let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() }, }, @@ -547,9 +545,8 @@ pub struct p7_member_access_captures_this_HasMemberUsedInLambda { } impl DefaultConstructible for p7_member_access_captures_this_HasMemberUsedInLambda { fn default_constructor(this: &Ptr) { - { - p7_member_access_captures_this_HasMemberUsedInLambdaImpl::construct_1(this); - } + DefaultConstructible::default_constructor(&field_ptr!(this, x)); + field!((*this), n).write(1); } } impl Default for p7_member_access_captures_this_HasMemberUsedInLambda { @@ -567,7 +564,7 @@ pub fn test_22() { let c: Value = Rc::new(RefCell::new( ::zero_init(), )); - p7_member_access_captures_this_HasMemberUsedInLambdaImpl::construct_1(&c.as_pointer()); + DefaultConstructible::default_constructor(&c.as_pointer()); let _dtor_c = std::mem::DropGuard::new(c.clone(), |__p| Destructible::destroy(&__p.as_pointer())); let f: Value i32>> = Rc::new(RefCell::new( @@ -604,9 +601,7 @@ pub struct p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda { } impl DefaultConstructible for p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda { fn default_constructor(this: &Ptr) { - { - p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambdaImpl::construct_1(this); - } + DefaultConstructible::default_constructor(&field_ptr!(this, x)); } } pub fn test_23() { @@ -614,7 +609,7 @@ pub fn test_23() { let c: Value = Rc::new( RefCell::new(::zero_init()), ); - p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambdaImpl::construct_1(&c.as_pointer()); + DefaultConstructible::default_constructor(&c.as_pointer()); let _dtor_c = std::mem::DropGuard::new(c.clone(), |__p| Destructible::destroy(&__p.as_pointer())); let f: Value usize>> = Rc::new(RefCell::new( @@ -665,9 +660,7 @@ thread_local!( pub struct p9_destructor_not_potentially_invoked_HasUndefinedDestructor {} impl DefaultConstructible for p9_destructor_not_potentially_invoked_HasUndefinedDestructor { fn default_constructor(this: &Ptr) { - { - p9_destructor_not_potentially_invoked_HasUndefinedDestructorImpl::construct(this); - } + (*t_ctors_27.with(Value::clone).borrow_mut()).prefix_inc(); } } impl Default for p9_destructor_not_potentially_invoked_HasUndefinedDestructor { @@ -678,9 +671,7 @@ impl Default for p9_destructor_not_potentially_invoked_HasUndefinedDestructor { Rc::new(RefCell::new( ::zero_init(), )); - p9_destructor_not_potentially_invoked_HasUndefinedDestructorImpl::construct( - &__v.as_pointer(), - ); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -690,7 +681,7 @@ pub fn test_28() { let mut p: Ptr = { let __p = Ptr::alloc(::zero_init()); - p9_destructor_not_potentially_invoked_HasUndefinedDestructorImpl::construct(&__p); + DefaultConstructible::default_constructor(&__p); __p }; assert!(!((p).is_null())); @@ -717,9 +708,8 @@ pub struct p9_unused_copy_constructor_HasUndefinedCopyCtor { } impl DefaultConstructible for p9_unused_copy_constructor_HasUndefinedCopyCtor { fn default_constructor(this: &Ptr) { - { - p9_unused_copy_constructor_HasUndefinedCopyCtorImpl::construct(this); - } + field!((*this), value).write(3); + (*ctor_calls_29.with(Value::clone).borrow_mut()).prefix_inc(); } } impl Default for p9_unused_copy_constructor_HasUndefinedCopyCtor { @@ -729,7 +719,7 @@ impl Default for p9_unused_copy_constructor_HasUndefinedCopyCtor { let __v: Value = Rc::new( RefCell::new(::zero_init()), ); - p9_unused_copy_constructor_HasUndefinedCopyCtorImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -742,7 +732,7 @@ pub fn test_31() { let a: Value = Rc::new(RefCell::new( ::zero_init(), )); - p9_unused_copy_constructor_HasUndefinedCopyCtorImpl::construct(&a.as_pointer()); + DefaultConstructible::default_constructor(&a.as_pointer()); assert!((({ read_30(a.as_pointer(),) }) == 3)); assert!((ctor_calls_29.with(|rc| *rc.borrow()) == 1)); } @@ -765,9 +755,7 @@ thread_local!( pub struct p9_unused_implicit_assignment_HasUndefinedCopyAssignment {} impl DefaultConstructible for p9_unused_implicit_assignment_HasUndefinedCopyAssignment { fn default_constructor(this: &Ptr) { - { - p9_unused_implicit_assignment_HasUndefinedCopyAssignmentImpl::construct(this); - } + (*m_ctors_32.with(Value::clone).borrow_mut()).prefix_inc(); } } impl Default for p9_unused_implicit_assignment_HasUndefinedCopyAssignment { @@ -778,9 +766,7 @@ impl Default for p9_unused_implicit_assignment_HasUndefinedCopyAssignment { Rc::new(RefCell::new( ::zero_init(), )); - p9_unused_implicit_assignment_HasUndefinedCopyAssignmentImpl::construct( - &__v.as_pointer(), - ); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -810,11 +796,7 @@ pub struct p9_unused_implicit_assignment_HasMemberWithUndefinedCopyAssignment { } impl DefaultConstructible for p9_unused_implicit_assignment_HasMemberWithUndefinedCopyAssignment { fn default_constructor(this: &Ptr) { - { - p9_unused_implicit_assignment_HasMemberWithUndefinedCopyAssignmentImpl::construct_1( - this, - ); - } + DefaultConstructible::default_constructor(&field_ptr!(this, m)); } } pub fn test_33() { @@ -822,16 +804,12 @@ pub fn test_33() { Rc::new(RefCell::new( ::zero_init(), )); - p9_unused_implicit_assignment_HasMemberWithUndefinedCopyAssignmentImpl::construct_1( - &a.as_pointer(), - ); + DefaultConstructible::default_constructor(&a.as_pointer()); let b: Value = Rc::new(RefCell::new( ::zero_init(), )); - p9_unused_implicit_assignment_HasMemberWithUndefinedCopyAssignmentImpl::construct_1( - &b.as_pointer(), - ); + DefaultConstructible::default_constructor(&b.as_pointer()); assert!((m_ctors_32.with(|rc| *rc.borrow()) == 2)); } thread_local!( @@ -995,14 +973,9 @@ impl HasConstexprCtorImpl for Ptr { } } pub trait LifetimeTrackedImpl { - fn construct(&self); fn use_(&self); } impl LifetimeTrackedImpl for Ptr { - fn construct(&self) { - field!((*self), uses).write(0); - (*ctorCount_1.with(Value::clone).borrow_mut()).prefix_inc(); - } fn use_(&self) { field!((*self), uses).with_mut(|__v| { __v.prefix_inc(); @@ -1021,20 +994,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 construct_1(&self); -} -impl p6_unevaluated_binding_needs_no_capture_HasTwoMembersImpl - for Ptr -{ - fn construct_1(&self) { - LifetimeTrackedImpl::construct(&field_ptr!(self, a)); - LifetimeTrackedImpl::construct(&field_ptr!(self, b)); - } -} pub trait p7_member_access_captures_this_HasMemberUsedInLambdaImpl { fn makeLambda(&self) -> FnPtr i32>; - fn construct_1(&self); } impl p7_member_access_captures_this_HasMemberUsedInLambdaImpl for Ptr @@ -1051,14 +1012,9 @@ impl p7_member_access_captures_this_HasMemberUsedInLambdaImpl } ); } - fn construct_1(&self) { - LifetimeTrackedImpl::construct(&field_ptr!(self, x)); - field!((*self), n).write(1); - } } pub trait p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambdaImpl { fn sizer(&self) -> FnPtr usize>; - fn construct_1(&self); } impl p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambdaImpl for Ptr @@ -1070,52 +1026,6 @@ impl p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambdaImpl } }); } - fn construct_1(&self) { - LifetimeTrackedImpl::construct(&field_ptr!(self, x)); - } -} -pub trait p9_destructor_not_potentially_invoked_HasUndefinedDestructorImpl { - fn construct(&self); -} -impl p9_destructor_not_potentially_invoked_HasUndefinedDestructorImpl - for Ptr -{ - fn construct(&self) { - (*t_ctors_27.with(Value::clone).borrow_mut()).prefix_inc(); - } -} -pub trait p9_unused_copy_constructor_HasUndefinedCopyCtorImpl { - fn construct(&self); -} -impl p9_unused_copy_constructor_HasUndefinedCopyCtorImpl - for Ptr -{ - fn construct(&self) { - field!((*self), value).write(3); - (*ctor_calls_29.with(Value::clone).borrow_mut()).prefix_inc(); - } -} -pub trait p9_unused_implicit_assignment_HasMemberWithUndefinedCopyAssignmentImpl { - fn construct_1(&self); -} -impl p9_unused_implicit_assignment_HasMemberWithUndefinedCopyAssignmentImpl - for Ptr -{ - fn construct_1(&self) { - p9_unused_implicit_assignment_HasUndefinedCopyAssignmentImpl::construct(&field_ptr!( - self, m - )); - } -} -pub trait p9_unused_implicit_assignment_HasUndefinedCopyAssignmentImpl { - fn construct(&self); -} -impl p9_unused_implicit_assignment_HasUndefinedCopyAssignmentImpl - for Ptr -{ - fn construct(&self) { - (*m_ctors_32.with(Value::clone).borrow_mut()).prefix_inc(); - } } pub fn __cpp2rust_init_globals() { let _ = copyCount_0.with(|_| ()); diff --git a/tests/std/basic/out/unsafe/basic.def.odr.rs b/tests/std/basic/out/unsafe/basic.def.odr.rs index 4995652b78..f5447ded36 100644 --- a/tests/std/basic/out/unsafe/basic.def.odr.rs +++ b/tests/std/basic/out/unsafe/basic.def.odr.rs @@ -70,15 +70,17 @@ impl LifetimeTracked { (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_2)) }; } - pub unsafe fn construct(&mut self) { - (&raw mut self.uses).write(0); - (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_1)).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(); } } +impl DefaultConstructibleUnsafe for LifetimeTracked { + unsafe fn default_constructor(&mut self) { + (&raw mut self.uses).write(0); + (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_1)).prefix_inc(); + } +} impl CopyConstructibleUnsafe for LifetimeTracked { unsafe fn copy_constructor(&mut self, _a0: *const LifetimeTracked) { (&raw mut self.uses).write(0); @@ -99,19 +101,12 @@ impl Clone for LifetimeTracked { } } } -impl DefaultConstructibleUnsafe for LifetimeTracked { - unsafe fn default_constructor(&mut self) { - unsafe { - LifetimeTracked::construct(&mut *self); - } - } -} impl Default for LifetimeTracked { fn default() -> Self { unsafe { { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -254,7 +249,7 @@ pub static mut global_12: std::cell::LazyCell = { let __static = { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v }; libcc2rs::register_static_destructor(|| { @@ -282,7 +277,7 @@ pub unsafe fn test_13() { pub unsafe fn test_14() { (unsafe { LifetimeTracked::reset() }); let mut t: LifetimeTracked = ::zero_init(); - LifetimeTracked::construct(&mut t); + DefaultConstructibleUnsafe::default_constructor(&mut t); let _dtor_t = std::mem::DropGuard::new(&raw mut t, |__p| unsafe { DestructibleUnsafe::destroy(&mut *__p) }); @@ -440,17 +435,10 @@ pub struct p6_unevaluated_binding_needs_no_capture_HasTwoMembers { #[destroy] pub b: LifetimeTracked, } -impl p6_unevaluated_binding_needs_no_capture_HasTwoMembers { - pub unsafe fn construct_1(&mut self) { - LifetimeTracked::construct(&mut self.a); - LifetimeTracked::construct(&mut self.b); - } -} impl DefaultConstructibleUnsafe for p6_unevaluated_binding_needs_no_capture_HasTwoMembers { unsafe fn default_constructor(&mut self) { - unsafe { - p6_unevaluated_binding_needs_no_capture_HasTwoMembers::construct_1(&mut *self); - } + DefaultConstructibleUnsafe::default_constructor(&mut self.a); + DefaultConstructibleUnsafe::default_constructor(&mut self.b); } } pub unsafe fn test_20() { @@ -459,12 +447,12 @@ pub unsafe fn test_20() { p6_unevaluated_binding_needs_no_capture_HasTwoMembers { a: { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v }, b: { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v }, }; @@ -512,16 +500,11 @@ impl p7_member_access_captures_this_HasMemberUsedInLambda { } ); } - pub unsafe fn construct_1(&mut self) { - LifetimeTracked::construct(&mut self.x); - (&raw mut self.n).write(1); - } } impl DefaultConstructibleUnsafe for p7_member_access_captures_this_HasMemberUsedInLambda { unsafe fn default_constructor(&mut self) { - unsafe { - p7_member_access_captures_this_HasMemberUsedInLambda::construct_1(&mut *self); - } + DefaultConstructibleUnsafe::default_constructor(&mut self.x); + (&raw mut self.n).write(1); } } impl Default for p7_member_access_captures_this_HasMemberUsedInLambda { @@ -538,7 +521,7 @@ pub unsafe fn test_22() { (unsafe { LifetimeTracked::reset() }); let mut c: p7_member_access_captures_this_HasMemberUsedInLambda = ::zero_init(); - p7_member_access_captures_this_HasMemberUsedInLambda::construct_1(&mut c); + DefaultConstructibleUnsafe::default_constructor(&mut c); let _dtor_c = std::mem::DropGuard::new(&raw mut c, |__p| unsafe { DestructibleUnsafe::destroy(&mut *__p) }); @@ -577,22 +560,17 @@ impl p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda { } }); } - pub unsafe fn construct_1(&mut self) { - LifetimeTracked::construct(&mut self.x); - } } impl DefaultConstructibleUnsafe for p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda { unsafe fn default_constructor(&mut self) { - unsafe { - p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda::construct_1(&mut *self); - } + DefaultConstructibleUnsafe::default_constructor(&mut self.x); } } pub unsafe fn test_23() { (unsafe { LifetimeTracked::reset() }); let mut c: p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda = ::zero_init(); - p7_unevaluated_this_needs_no_capture_HasMemberUsedInLambda::construct_1(&mut c); + DefaultConstructibleUnsafe::default_constructor(&mut c); let _dtor_c = std::mem::DropGuard::new(&raw mut c, |__p| unsafe { DestructibleUnsafe::destroy(&mut *__p) }); @@ -636,16 +614,9 @@ pub static mut t_ctors_27: std::cell::LazyCell = std::cell::LazyCell::new(| )] #[memberwise(copy_assign)] pub struct p9_destructor_not_potentially_invoked_HasUndefinedDestructor {} -impl p9_destructor_not_potentially_invoked_HasUndefinedDestructor { - pub unsafe fn construct(&mut self) { - (*std::cell::LazyCell::force_mut(&mut *&raw mut t_ctors_27)).prefix_inc(); - } -} impl DefaultConstructibleUnsafe for p9_destructor_not_potentially_invoked_HasUndefinedDestructor { unsafe fn default_constructor(&mut self) { - unsafe { - p9_destructor_not_potentially_invoked_HasUndefinedDestructor::construct(&mut *self); - } + (*std::cell::LazyCell::force_mut(&mut *&raw mut t_ctors_27)).prefix_inc(); } } impl Default for p9_destructor_not_potentially_invoked_HasUndefinedDestructor { @@ -654,7 +625,7 @@ impl Default for p9_destructor_not_potentially_invoked_HasUndefinedDestructor { { let mut __v: p9_destructor_not_potentially_invoked_HasUndefinedDestructor = ::zero_init(); - p9_destructor_not_potentially_invoked_HasUndefinedDestructor::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -665,7 +636,7 @@ pub unsafe fn test_28() { let __p: *mut p9_destructor_not_potentially_invoked_HasUndefinedDestructor = Box::leak( Box::new(::zero_init()), ); - p9_destructor_not_potentially_invoked_HasUndefinedDestructor::construct(&mut *__p); + DefaultConstructibleUnsafe::default_constructor(&mut *__p); __p }; assert!(!((p).is_null())); @@ -686,17 +657,10 @@ pub static mut ctor_calls_29: std::cell::LazyCell = pub struct p9_unused_copy_constructor_HasUndefinedCopyCtor { pub value: i32, } -impl p9_unused_copy_constructor_HasUndefinedCopyCtor { - pub unsafe fn construct(&mut self) { - (&raw mut self.value).write(3); - (*std::cell::LazyCell::force_mut(&mut *&raw mut ctor_calls_29)).prefix_inc(); - } -} impl DefaultConstructibleUnsafe for p9_unused_copy_constructor_HasUndefinedCopyCtor { unsafe fn default_constructor(&mut self) { - unsafe { - p9_unused_copy_constructor_HasUndefinedCopyCtor::construct(&mut *self); - } + (&raw mut self.value).write(3); + (*std::cell::LazyCell::force_mut(&mut *&raw mut ctor_calls_29)).prefix_inc(); } } impl Default for p9_unused_copy_constructor_HasUndefinedCopyCtor { @@ -705,7 +669,7 @@ impl Default for p9_unused_copy_constructor_HasUndefinedCopyCtor { { let mut __v: p9_unused_copy_constructor_HasUndefinedCopyCtor = ::zero_init(); - p9_unused_copy_constructor_HasUndefinedCopyCtor::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -717,7 +681,7 @@ pub unsafe fn read_30(object: *const p9_unused_copy_constructor_HasUndefinedCopy pub unsafe fn test_31() { let mut a: p9_unused_copy_constructor_HasUndefinedCopyCtor = ::zero_init(); - p9_unused_copy_constructor_HasUndefinedCopyCtor::construct(&mut a); + DefaultConstructibleUnsafe::default_constructor(&mut a); assert!(((unsafe { read_30(&a,) }) == (3))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut ctor_calls_29)) == (1))); } @@ -734,16 +698,9 @@ pub static mut m_ctors_32: std::cell::LazyCell = std::cell::LazyCell::new(| MovableUnsafe, )] pub struct p9_unused_implicit_assignment_HasUndefinedCopyAssignment {} -impl p9_unused_implicit_assignment_HasUndefinedCopyAssignment { - pub unsafe fn construct(&mut self) { - (*std::cell::LazyCell::force_mut(&mut *&raw mut m_ctors_32)).prefix_inc(); - } -} impl DefaultConstructibleUnsafe for p9_unused_implicit_assignment_HasUndefinedCopyAssignment { unsafe fn default_constructor(&mut self) { - unsafe { - p9_unused_implicit_assignment_HasUndefinedCopyAssignment::construct(&mut *self); - } + (*std::cell::LazyCell::force_mut(&mut *&raw mut m_ctors_32)).prefix_inc(); } } impl Default for p9_unused_implicit_assignment_HasUndefinedCopyAssignment { @@ -752,7 +709,7 @@ impl Default for p9_unused_implicit_assignment_HasUndefinedCopyAssignment { { let mut __v: p9_unused_implicit_assignment_HasUndefinedCopyAssignment = ::zero_init(); - p9_unused_implicit_assignment_HasUndefinedCopyAssignment::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -776,29 +733,20 @@ impl Default for p9_unused_implicit_assignment_HasUndefinedCopyAssignment { pub struct p9_unused_implicit_assignment_HasMemberWithUndefinedCopyAssignment { pub m: p9_unused_implicit_assignment_HasUndefinedCopyAssignment, } -impl p9_unused_implicit_assignment_HasMemberWithUndefinedCopyAssignment { - pub unsafe fn construct_1(&mut self) { - p9_unused_implicit_assignment_HasUndefinedCopyAssignment::construct(&mut self.m); - } -} impl DefaultConstructibleUnsafe for p9_unused_implicit_assignment_HasMemberWithUndefinedCopyAssignment { unsafe fn default_constructor(&mut self) { - unsafe { - p9_unused_implicit_assignment_HasMemberWithUndefinedCopyAssignment::construct_1( - &mut *self, - ); - } + DefaultConstructibleUnsafe::default_constructor(&mut self.m); } } pub unsafe fn test_33() { let mut a: p9_unused_implicit_assignment_HasMemberWithUndefinedCopyAssignment = ::zero_init(); - p9_unused_implicit_assignment_HasMemberWithUndefinedCopyAssignment::construct_1(&mut a); + DefaultConstructibleUnsafe::default_constructor(&mut a); let mut b: p9_unused_implicit_assignment_HasMemberWithUndefinedCopyAssignment = ::zero_init(); - p9_unused_implicit_assignment_HasMemberWithUndefinedCopyAssignment::construct_1(&mut b); + DefaultConstructibleUnsafe::default_constructor(&mut b); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut m_ctors_32)) == (2))); } pub static mut else_runs_34: std::cell::LazyCell = 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 fc3c5585bc..6cfc8d47cf 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 @@ -15,10 +15,11 @@ use std::rc::{Rc, Weak}; VaArg, FnPtrArg, CppFrom, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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.fct.rs b/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.fct.rs index 5249cbdbd8..3b99ed74a8 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 @@ -14,10 +14,11 @@ use std::rc::Rc; FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] #[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/out/refcount/class.free.rs b/tests/std/class/class.mem/out/refcount/class.free.rs index 9f4cca8f1d..406272bcc5 100644 --- a/tests/std/class/class.mem/out/refcount/class.free.rs +++ b/tests/std/class/class.mem/out/refcount/class.free.rs @@ -17,10 +17,11 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct p1_allocation_function_is_static_Allocates {} impl p1_allocation_function_is_static_Allocates { @@ -65,10 +66,11 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 5191033a54..11ed85587e 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 @@ -22,9 +22,7 @@ pub struct p7_1_function_body_names_later_member_HasLaterMembers { } impl DefaultConstructible for p7_1_function_body_names_later_member_HasLaterMembers { fn default_constructor(this: &Ptr) { - { - p7_1_function_body_names_later_member_HasLaterMembersImpl::construct_1(this); - } + field!((*this), stock).write(9); } } impl Default for p7_1_function_body_names_later_member_HasLaterMembers { @@ -36,7 +34,7 @@ pub fn test_3() { let object: Value = Rc::new( RefCell::new(::zero_init()), ); - p7_1_function_body_names_later_member_HasLaterMembersImpl::construct_1(&object.as_pointer()); + DefaultConstructible::default_constructor(&object.as_pointer()); assert!( (({ p7_1_function_body_names_later_member_HasLaterMembersImpl::take(&object.as_pointer(), 3) @@ -59,9 +57,7 @@ pub struct p7_2_default_argument_names_later_member_HasLaterStaticStep { } impl DefaultConstructible for p7_2_default_argument_names_later_member_HasLaterStaticStep { fn default_constructor(this: &Ptr) { - { - p7_2_default_argument_names_later_member_HasLaterStaticStepImpl::construct_1(this); - } + field!((*this), total).write(1); } } impl Default for p7_2_default_argument_names_later_member_HasLaterStaticStep { @@ -73,9 +69,7 @@ pub fn test_6() { let object: Value = Rc::new( RefCell::new(::zero_init()), ); - p7_2_default_argument_names_later_member_HasLaterStaticStepImpl::construct_1( - &object.as_pointer(), - ); + DefaultConstructible::default_constructor(&object.as_pointer()); assert!( (({ p7_2_default_argument_names_later_member_HasLaterStaticStepImpl::advance( @@ -106,7 +100,6 @@ fn main_0() -> i32 { pub trait p7_1_function_body_names_later_member_HasLaterMembersImpl { fn take(&self, amount: i32) -> i32; fn minimum(&self) -> i32; - fn construct_1(&self); } impl p7_1_function_body_names_later_member_HasLaterMembersImpl for Ptr @@ -122,13 +115,9 @@ impl p7_1_function_body_names_later_member_HasLaterMembersImpl fn minimum(&self) -> i32 { return 2; } - fn construct_1(&self) { - field!((*self), stock).write(9); - } } pub trait p7_2_default_argument_names_later_member_HasLaterStaticStepImpl { fn advance(&self, amount: i32) -> i32; - fn construct_1(&self); } impl p7_2_default_argument_names_later_member_HasLaterStaticStepImpl for Ptr @@ -139,9 +128,6 @@ impl p7_2_default_argument_names_later_member_HasLaterStaticStepImpl }; return (*self).with(|__s| __s.total); } - fn construct_1(&self) { - field!((*self), total).write(1); - } } pub fn __cpp2rust_init_globals() { let _ = stock_0.with(|_| ()); 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 ae1a8a1abe..4ec8fca4af 100644 --- a/tests/std/class/class.mem/out/unsafe/class.free.rs +++ b/tests/std/class/class.mem/out/unsafe/class.free.rs @@ -14,10 +14,11 @@ pub static mut allocations_0: std::cell::LazyCell = std::cell::LazyCell::ne VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 { @@ -57,10 +58,11 @@ pub static mut deallocations_2: std::cell::LazyCell = VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 48f6d90fba..ad96fdd5ac 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 @@ -27,15 +27,10 @@ impl p7_1_function_body_names_later_member_HasLaterMembers { pub unsafe fn minimum(&self) -> i32 { return 2; } - pub unsafe fn construct_1(&mut self) { - (&raw mut self.stock).write(9); - } } impl DefaultConstructibleUnsafe for p7_1_function_body_names_later_member_HasLaterMembers { unsafe fn default_constructor(&mut self) { - unsafe { - p7_1_function_body_names_later_member_HasLaterMembers::construct_1(&mut *self); - } + (&raw mut self.stock).write(9); } } impl Default for p7_1_function_body_names_later_member_HasLaterMembers { @@ -46,7 +41,7 @@ impl Default for p7_1_function_body_names_later_member_HasLaterMembers { pub unsafe fn test_3() { let mut object: p7_1_function_body_names_later_member_HasLaterMembers = ::zero_init(); - p7_1_function_body_names_later_member_HasLaterMembers::construct_1(&mut object); + DefaultConstructibleUnsafe::default_constructor(&mut object); assert!( ((unsafe { p7_1_function_body_names_later_member_HasLaterMembers::take(&mut object, 3,) }) == (38)) @@ -66,15 +61,10 @@ impl p7_2_default_argument_names_later_member_HasLaterStaticStep { self.total += amount; return self.total; } - pub unsafe fn construct_1(&mut self) { - (&raw mut self.total).write(1); - } } impl DefaultConstructibleUnsafe for p7_2_default_argument_names_later_member_HasLaterStaticStep { unsafe fn default_constructor(&mut self) { - unsafe { - p7_2_default_argument_names_later_member_HasLaterStaticStep::construct_1(&mut *self); - } + (&raw mut self.total).write(1); } } impl Default for p7_2_default_argument_names_later_member_HasLaterStaticStep { @@ -85,7 +75,7 @@ impl Default for p7_2_default_argument_names_later_member_HasLaterStaticStep { pub unsafe fn test_6() { let mut object: p7_2_default_argument_names_later_member_HasLaterStaticStep = ::zero_init(); - p7_2_default_argument_names_later_member_HasLaterStaticStep::construct_1(&mut object); + DefaultConstructibleUnsafe::default_constructor(&mut object); assert!( ((unsafe { p7_2_default_argument_names_later_member_HasLaterStaticStep::advance( 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 d868770c6c..b9e40fe16d 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 @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct p6_2_zero_initialized_padding_Padded { #[offset(0)] @@ -33,10 +34,11 @@ pub struct p6_2_zero_initialized_padding_Padded { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct p6_2_zero_initialized_padding_TailPadded { #[offset(0)] @@ -52,10 +54,11 @@ pub struct p6_2_zero_initialized_padding_TailPadded { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 ec9a99b4ab..684dbfdca2 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 @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct p6_1_zero_initialized_pointer_to_member_HasTwoInts { #[offset(0)] @@ -33,9 +34,10 @@ pub struct p6_1_zero_initialized_pointer_to_member_HasTwoInts { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct p6_1_zero_initialized_pointer_to_member_HoldsSelector { #[offset(0)] @@ -139,10 +141,11 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(24)] pub struct p6_2_zero_initialized_class_Inner { #[offset(0)] @@ -154,15 +157,9 @@ pub struct p6_2_zero_initialized_class_Inner { pub pointer: Ptr, } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - DefaultConstructible, - TriviallyCopyable, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, )] +#[memberwise(default_constructor)] #[byte_size(96)] pub struct p6_2_zero_initialized_class_Outer { #[offset(0)] @@ -280,10 +277,11 @@ pub fn test_17() { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct p6_4_zero_initialized_array_Pair { #[offset(0)] @@ -397,9 +395,8 @@ pub struct p9_1_2_zero_then_default_initialized_WithDefaultMember { } impl DefaultConstructible for p9_1_2_zero_then_default_initialized_WithDefaultMember { fn default_constructor(this: &Ptr) { - { - p9_1_2_zero_then_default_initialized_WithDefaultMemberImpl::construct_1(this); - } + field!((*this), zeroed).write(0_i32); + field!((*this), five).write(5); } } impl Default for p9_1_2_zero_then_default_initialized_WithDefaultMember { @@ -420,9 +417,7 @@ pub struct p9_1_2_zero_then_default_initialized_LeavesMemberAlone { } impl DefaultConstructible for p9_1_2_zero_then_default_initialized_LeavesMemberAlone { fn default_constructor(this: &Ptr) { - { - p9_1_2_zero_then_default_initialized_LeavesMemberAloneImpl::construct(this); - } + field!((*this), untouched).write(0_i32); } } impl Default for p9_1_2_zero_then_default_initialized_LeavesMemberAlone { @@ -433,9 +428,7 @@ impl Default for p9_1_2_zero_then_default_initialized_LeavesMemberAlone { Rc::new(RefCell::new( ::zero_init(), )); - p9_1_2_zero_then_default_initialized_LeavesMemberAloneImpl::construct( - &__v.as_pointer(), - ); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -454,21 +447,20 @@ pub struct p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAlone { } impl DefaultConstructible for p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAlone { fn default_constructor(this: &Ptr) { - { - p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAloneImpl::construct_1(this); - } + field!((*this), number).write(0_i32); + DefaultConstructible::default_constructor(&field_ptr!(this, member)); } } pub fn test_22() { let value: Value = Rc::new( RefCell::new(::zero_init()), ); - p9_1_2_zero_then_default_initialized_WithDefaultMemberImpl::construct_1(&value.as_pointer()); + DefaultConstructible::default_constructor(&value.as_pointer()); assert!(({ (*value.borrow()).zeroed } == 0)); assert!(({ (*value.borrow()).five } == 5)); let mut heap: Ptr = { let __p = Ptr::alloc(::zero_init()); - p9_1_2_zero_then_default_initialized_WithDefaultMemberImpl::construct_1(&__p); + DefaultConstructible::default_constructor(&__p); __p }; assert!((heap.with(|__s| __s.zeroed) == 0)); @@ -477,15 +469,13 @@ pub fn test_22() { let holder: Value = Rc::new( RefCell::new(::zero_init()), ); - p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAloneImpl::construct_1( - &holder.as_pointer(), - ); + DefaultConstructible::default_constructor(&holder.as_pointer()); assert!(({ (*holder.borrow()).number } == 0)); assert!(({ (*holder.borrow()).member.untouched } == 0)); let mut heap_holder: Ptr = { let __p = Ptr::alloc(::zero_init()); - p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAloneImpl::construct_1(&__p); + DefaultConstructible::default_constructor(&__p); __p }; assert!((heap_holder.with(|__s| __s.number) == 0)); @@ -505,40 +495,6 @@ fn main_0() -> i32 { ({ test_22() }); return 0; } -pub trait p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAloneImpl { - fn construct_1(&self); -} -impl p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAloneImpl - for Ptr -{ - fn construct_1(&self) { - field!((*self), number).write(0_i32); - p9_1_2_zero_then_default_initialized_LeavesMemberAloneImpl::construct(&field_ptr!( - self, member - )); - } -} -pub trait p9_1_2_zero_then_default_initialized_LeavesMemberAloneImpl { - fn construct(&self); -} -impl p9_1_2_zero_then_default_initialized_LeavesMemberAloneImpl - for Ptr -{ - fn construct(&self) { - field!((*self), untouched).write(0_i32); - } -} -pub trait p9_1_2_zero_then_default_initialized_WithDefaultMemberImpl { - fn construct_1(&self); -} -impl p9_1_2_zero_then_default_initialized_WithDefaultMemberImpl - for Ptr -{ - fn construct_1(&self) { - field!((*self), zeroed).write(0_i32); - field!((*self), five).write(5); - } -} pub fn __cpp2rust_init_globals() { let _ = static_pm_0.with(|_| ()); let _ = static_int_2.with(|_| ()); 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 2f2c8d6706..2a30154179 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 @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct p6_2_zero_initialized_padding_Padded { pub letter: libc::c_char, pub number: i32, @@ -28,10 +29,11 @@ pub struct p6_2_zero_initialized_padding_Padded { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct p6_2_zero_initialized_padding_TailPadded { pub number: i32, pub letter: libc::c_char, @@ -43,10 +45,11 @@ pub struct p6_2_zero_initialized_padding_TailPadded { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 d2fc531ec7..2aeae93d67 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 @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct p6_1_zero_initialized_pointer_to_member_HasTwoInts { pub first: i32, pub second: i32, @@ -28,9 +29,10 @@ pub struct p6_1_zero_initialized_pointer_to_member_HasTwoInts { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, )] +#[memberwise(default_constructor)] pub struct p6_1_zero_initialized_pointer_to_member_HoldsSelector { pub selector: isize, } @@ -130,10 +132,11 @@ static mut counter_11: std::cell::LazyCell = std::cell::LazyCell::new(|| un VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct p6_2_zero_initialized_class_Inner { pub number: i32, pub real: f64, @@ -146,10 +149,11 @@ pub struct p6_2_zero_initialized_class_Inner { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct p6_2_zero_initialized_class_Outer { pub letter: libc::c_char, pub inner: p6_2_zero_initialized_class_Inner, @@ -234,10 +238,11 @@ pub unsafe fn test_17() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct p6_4_zero_initialized_array_Pair { pub first: i32, pub second: i32, @@ -332,17 +337,10 @@ pub struct p9_1_2_zero_then_default_initialized_WithDefaultMember { pub zeroed: i32, pub five: i32, } -impl p9_1_2_zero_then_default_initialized_WithDefaultMember { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.zeroed).write(0_i32); - (&raw mut self.five).write(5); - } -} impl DefaultConstructibleUnsafe for p9_1_2_zero_then_default_initialized_WithDefaultMember { unsafe fn default_constructor(&mut self) { - unsafe { - p9_1_2_zero_then_default_initialized_WithDefaultMember::construct_1(&mut *self); - } + (&raw mut self.zeroed).write(0_i32); + (&raw mut self.five).write(5); } } impl Default for p9_1_2_zero_then_default_initialized_WithDefaultMember { @@ -360,16 +358,9 @@ impl Default for p9_1_2_zero_then_default_initialized_WithDefaultMember { pub struct p9_1_2_zero_then_default_initialized_LeavesMemberAlone { pub untouched: i32, } -impl p9_1_2_zero_then_default_initialized_LeavesMemberAlone { - pub unsafe fn construct(&mut self) { - (&raw mut self.untouched).write(0_i32); - } -} impl DefaultConstructibleUnsafe for p9_1_2_zero_then_default_initialized_LeavesMemberAlone { unsafe fn default_constructor(&mut self) { - unsafe { - p9_1_2_zero_then_default_initialized_LeavesMemberAlone::construct(&mut *self); - } + (&raw mut self.untouched).write(0_i32); } } impl Default for p9_1_2_zero_then_default_initialized_LeavesMemberAlone { @@ -378,7 +369,7 @@ impl Default for p9_1_2_zero_then_default_initialized_LeavesMemberAlone { { let mut __v: p9_1_2_zero_then_default_initialized_LeavesMemberAlone = ::zero_init(); - p9_1_2_zero_then_default_initialized_LeavesMemberAlone::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -392,30 +383,23 @@ pub struct p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAlone { pub number: i32, pub member: p9_1_2_zero_then_default_initialized_LeavesMemberAlone, } -impl p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAlone { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.number).write(0_i32); - p9_1_2_zero_then_default_initialized_LeavesMemberAlone::construct(&mut self.member); - } -} impl DefaultConstructibleUnsafe for p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAlone { unsafe fn default_constructor(&mut self) { - unsafe { - p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAlone::construct_1(&mut *self); - } + (&raw mut self.number).write(0_i32); + DefaultConstructibleUnsafe::default_constructor(&mut self.member); } } pub unsafe fn test_22() { let mut value: p9_1_2_zero_then_default_initialized_WithDefaultMember = ::zero_init(); - p9_1_2_zero_then_default_initialized_WithDefaultMember::construct_1(&mut value); + DefaultConstructibleUnsafe::default_constructor(&mut value); assert!(((value.zeroed) == (0))); assert!(((value.five) == (5))); let mut heap: *mut p9_1_2_zero_then_default_initialized_WithDefaultMember = { let __p: *mut p9_1_2_zero_then_default_initialized_WithDefaultMember = Box::leak(Box::new( ::zero_init(), )); - p9_1_2_zero_then_default_initialized_WithDefaultMember::construct_1(&mut *__p); + DefaultConstructibleUnsafe::default_constructor(&mut *__p); __p }; assert!((((*heap).zeroed) == (0))); @@ -428,14 +412,14 @@ pub unsafe fn test_22() { }; let mut holder: p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAlone = ::zero_init(); - p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAlone::construct_1(&mut holder); + DefaultConstructibleUnsafe::default_constructor(&mut holder); assert!(((holder.number) == (0))); assert!(((holder.member.untouched) == (0))); let mut heap_holder: *mut p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAlone = { let __p: *mut p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAlone = Box::leak( Box::new(::zero_init()), ); - p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAlone::construct_1(&mut *__p); + DefaultConstructibleUnsafe::default_constructor(&mut *__p); __p }; assert!((((*heap_holder).number) == (0))); 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 a352955573..4f84c45591 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 @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 a3c41d59d2..4708cf3a9a 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 @@ -62,9 +62,7 @@ pub struct p9_static_member_hides_namespace_variable_HasStaticStep { } impl DefaultConstructible for p9_static_member_hides_namespace_variable_HasStaticStep { fn default_constructor(this: &Ptr) { - { - p9_static_member_hides_namespace_variable_HasStaticStepImpl::construct_1(this); - } + field!((*this), total).write(1); } } impl Default for p9_static_member_hides_namespace_variable_HasStaticStep { @@ -76,7 +74,7 @@ pub fn test_11() { let object: Value = Rc::new( RefCell::new(::zero_init()), ); - p9_static_member_hides_namespace_variable_HasStaticStepImpl::construct_1(&object.as_pointer()); + DefaultConstructible::default_constructor(&object.as_pointer()); assert!( (({ p9_static_member_hides_namespace_variable_HasStaticStepImpl::advance( @@ -165,9 +163,7 @@ impl p9_evaluated_each_time_called_Account { } impl DefaultConstructible for p9_evaluated_each_time_called_Account { fn default_constructor(this: &Ptr) { - { - p9_evaluated_each_time_called_AccountImpl::construct_1(this); - } + field!((*this), balance).write(0); } } impl Default for p9_evaluated_each_time_called_Account { @@ -208,7 +204,7 @@ pub fn test_17() { let account: Value = Rc::new(RefCell::new( ::zero_init(), )); - p9_evaluated_each_time_called_AccountImpl::construct_1(&account.as_pointer()); + DefaultConstructible::default_constructor(&account.as_pointer()); assert!( (({ p9_evaluated_each_time_called_AccountImpl::deposit( @@ -245,10 +241,11 @@ pub fn add_18(mut a: i32, mut b: i32) -> i32 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct p9_not_part_of_the_type_Scale {} impl p9_not_part_of_the_type_Scale { @@ -322,7 +319,6 @@ fn main_0() -> i32 { } pub trait p9_evaluated_each_time_called_AccountImpl { fn deposit(&self, amount: i32) -> i32; - fn construct_1(&self); } impl p9_evaluated_each_time_called_AccountImpl for Ptr { fn deposit(&self, mut amount: i32) -> i32 { @@ -331,9 +327,6 @@ impl p9_evaluated_each_time_called_AccountImpl for Ptr i32; - fn construct_1(&self); } impl p9_static_member_hides_namespace_variable_HasStaticStepImpl for Ptr @@ -356,9 +348,6 @@ impl p9_static_member_hides_namespace_variable_HasStaticStepImpl }; return (*self).with(|__s| __s.total); } - fn construct_1(&self) { - field!((*self), total).write(1); - } } pub fn __cpp2rust_init_globals() { let _ = scaled_calls_0.with(|_| ()); 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 899f714087..4a15c5e4a7 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 @@ -7,15 +7,9 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - DefaultConstructible, - TriviallyCopyable, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, )] +#[memberwise(default_constructor)] #[byte_size(16)] pub struct p2_pointer_to_array_member_HasIntArray { #[offset(0)] @@ -57,10 +51,11 @@ pub fn test_0() { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct p2_pointer_to_data_member_HasTwoInts { #[offset(0)] @@ -96,10 +91,11 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct p2_pointer_to_member_of_incomplete_class_CompletedLater { #[offset(0)] @@ -136,10 +132,11 @@ pub fn test_3() { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct p2_pointer_to_member_of_pointer_to_member_type_HasTwoInts { #[offset(0)] @@ -155,9 +152,10 @@ pub struct p2_pointer_to_member_of_pointer_to_member_type_HasTwoInts { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, )] +#[memberwise(default_constructor)] #[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 e7a70db643..95ab2466e0 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 @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 10f62ed91a..aec121953d 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 @@ -63,15 +63,10 @@ impl p9_static_member_hides_namespace_variable_HasStaticStep { self.total += amount; return self.total; } - pub unsafe fn construct_1(&mut self) { - (&raw mut self.total).write(1); - } } impl DefaultConstructibleUnsafe for p9_static_member_hides_namespace_variable_HasStaticStep { unsafe fn default_constructor(&mut self) { - unsafe { - p9_static_member_hides_namespace_variable_HasStaticStep::construct_1(&mut *self); - } + (&raw mut self.total).write(1); } } impl Default for p9_static_member_hides_namespace_variable_HasStaticStep { @@ -82,7 +77,7 @@ impl Default for p9_static_member_hides_namespace_variable_HasStaticStep { pub unsafe fn test_11() { let mut object: p9_static_member_hides_namespace_variable_HasStaticStep = ::zero_init(); - p9_static_member_hides_namespace_variable_HasStaticStep::construct_1(&mut object); + DefaultConstructibleUnsafe::default_constructor(&mut object); assert!( ((unsafe { p9_static_member_hides_namespace_variable_HasStaticStep::advance( @@ -170,15 +165,10 @@ impl p9_evaluated_each_time_called_Account { pub unsafe fn set_base(mut value: i32) { (*std::cell::LazyCell::force_mut(&mut *&raw mut base_15)) = value; } - pub unsafe fn construct_1(&mut self) { - (&raw mut self.balance).write(0); - } } impl DefaultConstructibleUnsafe for p9_evaluated_each_time_called_Account { unsafe fn default_constructor(&mut self) { - unsafe { - p9_evaluated_each_time_called_Account::construct_1(&mut *self); - } + (&raw mut self.balance).write(0); } } impl Default for p9_evaluated_each_time_called_Account { @@ -213,7 +203,7 @@ pub unsafe fn test_17() { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut defaults_evaluated_12)) == (5))); let mut account: p9_evaluated_each_time_called_Account = ::zero_init(); - p9_evaluated_each_time_called_Account::construct_1(&mut account); + DefaultConstructibleUnsafe::default_constructor(&mut account); assert!( ((unsafe { p9_evaluated_each_time_called_Account::deposit( @@ -253,10 +243,11 @@ pub unsafe fn add_18(mut a: i32, mut b: i32) -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 e4546ce994..07dd44859c 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 @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct p2_pointer_to_array_member_HasIntArray { pub before: i32, pub elements: [i32; 3], @@ -53,10 +54,11 @@ pub unsafe fn test_0() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct p2_pointer_to_data_member_HasTwoInts { pub first: i32, pub second: i32, @@ -100,10 +102,11 @@ pub static mut pm_2: std::cell::LazyCell = std::cell::LazyCell::new(|| un VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct p2_pointer_to_member_of_incomplete_class_CompletedLater { pub first: i32, pub second: i32, @@ -133,10 +136,11 @@ pub unsafe fn test_3() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct p2_pointer_to_member_of_pointer_to_member_type_HasTwoInts { pub first: i32, pub second: i32, @@ -148,9 +152,10 @@ pub struct p2_pointer_to_member_of_pointer_to_member_type_HasTwoInts { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, )] +#[memberwise(default_constructor)] 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 644ed4f0f2..17ea23be25 100644 --- a/tests/std/expr/conv/out/refcount/conv.mem.rs +++ b/tests/std/expr/conv/out/refcount/conv.mem.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 17b3ab2791..6efa3346e8 100644 --- a/tests/std/expr/conv/out/unsafe/conv.mem.rs +++ b/tests/std/expr/conv/out/unsafe/conv.mem.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 6eabe95687..c6cddfa9e8 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 @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 494a0d9202..421a779029 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 @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct HasTwoInts { #[offset(0)] @@ -33,10 +34,11 @@ pub struct HasTwoInts { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 00a14a5e2a..b004bee244 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 @@ -24,10 +24,11 @@ pub fn test_0() { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct p10_null_converts_to_null_HasTwoInts { #[offset(0)] @@ -43,10 +44,11 @@ pub struct p10_null_converts_to_null_HasTwoInts { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct p10_null_converts_to_null_HasChar { #[offset(0)] @@ -65,10 +67,11 @@ pub fn test_1() { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct p10_2_data_member_round_trip_HasTwoInts { #[offset(0)] @@ -84,10 +87,11 @@ pub struct p10_2_data_member_round_trip_HasTwoInts { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 2ec3a4632e..0e58a2d020 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 @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 3c761eb2e9..946c2bee32 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 @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct HasTwoInts { pub first: i32, pub second: i32, @@ -28,10 +29,11 @@ pub struct HasTwoInts { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 8d1a31724b..e348f6534f 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 @@ -23,10 +23,11 @@ pub unsafe fn test_0() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct p10_null_converts_to_null_HasTwoInts { pub first: i32, pub second: i32, @@ -38,10 +39,11 @@ pub struct p10_null_converts_to_null_HasTwoInts { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct p10_null_converts_to_null_HasChar { pub character: libc::c_char, } @@ -57,10 +59,11 @@ pub unsafe fn test_1() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct p10_2_data_member_round_trip_HasTwoInts { pub first: i32, pub second: i32, @@ -72,10 +75,11 @@ pub struct p10_2_data_member_round_trip_HasTwoInts { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 a20f54def6..230a7b92c2 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 @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 3bd52a9bf2..baceb70e5e 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 @@ -20,10 +20,11 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct p3_2_static_member_is_ordinary_pointer_HasStaticMembers {} impl p3_2_static_member_is_ordinary_pointer_HasStaticMembers { @@ -49,10 +50,11 @@ pub fn test_2() { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct p3_2_explicit_object_member_is_ordinary_pointer_HasExplicitObjectMember { #[offset(0)] @@ -76,10 +78,11 @@ pub fn test_3() { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 f3ed68283c..a77a2dfbdc 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 @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 f49718692a..7616314225 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 @@ -15,10 +15,11 @@ pub static mut calls_1: std::cell::LazyCell = std::cell::LazyCell::new(|| u VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct p3_2_static_member_is_ordinary_pointer_HasStaticMembers {} impl p3_2_static_member_is_ordinary_pointer_HasStaticMembers { pub unsafe fn run() { @@ -43,10 +44,11 @@ pub unsafe fn test_2() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct p3_2_explicit_object_member_is_ordinary_pointer_HasExplicitObjectMember { pub base: i32, } @@ -78,10 +80,11 @@ pub unsafe fn test_3() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 18f20a8a90..e6066b56ca 100644 --- a/tests/std/expr/expr.compound/out/refcount/expr.cond.rs +++ b/tests/std/expr/expr.compound/out/refcount/expr.cond.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 83480e6cc4..9efaa0d88a 100644 --- a/tests/std/expr/expr.compound/out/refcount/expr.eq.rs +++ b/tests/std/expr/expr.compound/out/refcount/expr.eq.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct p4_1_both_null_HasTwoInts { #[offset(0)] @@ -39,10 +40,11 @@ pub fn test_0() { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct p4_2_one_null_HasTwoInts { #[offset(0)] @@ -97,10 +99,11 @@ pub fn test_2() { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 be37d63477..dbbea46c37 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 @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 aa0fe9ce9b..eef2a538a4 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 @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct p3_arrow_star_HasTwoInts { #[offset(0)] @@ -46,10 +47,11 @@ pub fn test_0() { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct p4_object_expression_sequenced_first_HasValue { #[offset(0)] @@ -99,10 +101,11 @@ pub fn test_7() { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct p6_data_member_of_lvalue_is_lvalue_HasTwoInts { #[offset(0)] @@ -138,12 +141,13 @@ thread_local!( VaArg, FnPtrArg, Destructible, - DefaultConstructible, + Memberwise, CopyAssignable, MoveAssignable, Swappable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves {} impl CopyConstructible for p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves { @@ -182,14 +186,13 @@ impl Clone for p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves { VaArg, FnPtrArg, Destructible, - DefaultConstructible, Memberwise, CopyAssignable, MoveAssignable, Swappable, Default, )] -#[memberwise(copy_constructor, move_constructor)] +#[memberwise(copy_constructor, move_constructor, default_constructor)] #[byte_size(1)] pub struct p6_data_member_of_rvalue_is_xvalue_HoldsCounted { #[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 10e3d66892..85e9ac22cb 100644 --- a/tests/std/expr/expr.compound/out/unsafe/expr.cond.rs +++ b/tests/std/expr/expr.compound/out/unsafe/expr.cond.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 3b4925d01d..d2ae83e01b 100644 --- a/tests/std/expr/expr.compound/out/unsafe/expr.eq.rs +++ b/tests/std/expr/expr.compound/out/unsafe/expr.eq.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct p4_1_both_null_HasTwoInts { pub first: i32, pub second: i32, @@ -34,10 +35,11 @@ pub unsafe fn test_0() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct p4_2_one_null_HasTwoInts { pub first: i32, pub second: i32, @@ -82,10 +84,11 @@ pub unsafe fn test_2() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 65eb30e323..ac36acad0b 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 @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 27d45db986..de05cf1737 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 @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct p3_arrow_star_HasTwoInts { pub first: i32, pub second: i32, @@ -46,10 +47,11 @@ pub unsafe fn test_0() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct p4_object_expression_sequenced_first_HasValue { pub value: i32, } @@ -89,10 +91,11 @@ pub unsafe fn test_7() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct p6_data_member_of_lvalue_is_lvalue_HasTwoInts { pub first: i32, pub second: i32, @@ -126,12 +129,13 @@ pub static mut moveCount_10: std::cell::LazyCell = std::cell::LazyCell::new FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves {} impl CopyConstructibleUnsafe for p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves { unsafe fn copy_constructor( @@ -169,14 +173,13 @@ impl Clone for p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves { FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, - DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, Default, )] -#[memberwise(copy_constructor, move_constructor)] +#[memberwise(copy_constructor, move_constructor, default_constructor)] pub struct p6_data_member_of_rvalue_is_xvalue_HoldsCounted { pub member: p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves, } 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 230bf27b03..1dacb6432a 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 @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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, TriviallyCopyable)] @@ -28,9 +29,7 @@ pub struct p16_rebind_member_Alloc_std_pair_const_int__int__ { } impl DefaultConstructible for p16_rebind_member_Alloc_std_pair_const_int__int__ { fn default_constructor(this: &Ptr) { - { - p16_rebind_member_Alloc_std_pair_const_int__int__Impl::construct(this); - } + field!((*this), id).write(0); } } impl Default for p16_rebind_member_Alloc_std_pair_const_int__int__ { @@ -69,10 +68,11 @@ pub fn test_0() { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct p18_rebind_to_container_node_Alloc_std_pair_const_int__int__ {} pub fn test_1() { @@ -104,7 +104,6 @@ fn main_0() -> i32 { return 0; } pub trait p16_rebind_member_Alloc_std_pair_const_int__int__Impl { - fn construct(&self); fn allocate(&self, mut n: usize) -> Ptr<(Value, Value)> { unimplemented!() } @@ -115,9 +114,6 @@ pub trait p16_rebind_member_Alloc_std_pair_const_int__int__Impl { impl p16_rebind_member_Alloc_std_pair_const_int__int__Impl for Ptr { - fn construct(&self) { - field!((*self), id).write(0); - } } pub trait p18_rebind_to_container_node_Alloc_std_pair_const_int__int__Impl { fn allocate(&self, mut n: usize) -> Ptr<(Value, Value)> { 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 3786566e29..13a751b2de 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 @@ -13,26 +13,20 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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, TriviallyCopyableUnsafe)] pub struct p16_rebind_member_Alloc_std_pair_const_int__int__ { pub id: i32, } -impl p16_rebind_member_Alloc_std_pair_const_int__int__ { - pub unsafe fn construct(&mut self) { - (&raw mut self.id).write(0); - } -} impl DefaultConstructibleUnsafe for p16_rebind_member_Alloc_std_pair_const_int__int__ { unsafe fn default_constructor(&mut self) { - unsafe { - p16_rebind_member_Alloc_std_pair_const_int__int__::construct(&mut *self); - } + (&raw mut self.id).write(0); } } impl Default for p16_rebind_member_Alloc_std_pair_const_int__int__ { @@ -71,10 +65,11 @@ pub unsafe fn test_0() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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.select/out/refcount/stmt.if.rs b/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.if.rs index f9dcfd4d89..2c9a908f79 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 @@ -45,6 +45,12 @@ impl LifetimeTracked { }); } } +impl DefaultConstructible for LifetimeTracked { + fn default_constructor(this: &Ptr) { + field!((*this), uses).write(0); + (*ctorCount_0.with(Value::clone).borrow_mut()).prefix_inc(); + } +} impl CopyConstructible for LifetimeTracked { fn copy_constructor(this: &Ptr, _a0: Ptr) { field!((*this), uses).write(0); @@ -66,20 +72,13 @@ impl Clone for LifetimeTracked { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } -impl DefaultConstructible for LifetimeTracked { - fn default_constructor(this: &Ptr) { - { - LifetimeTrackedImpl::construct(this); - } - } -} impl Default for LifetimeTracked { fn default() -> Self { { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -96,7 +95,7 @@ pub fn test_6() { let mut choice: i32 = 9; { let guard: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::construct(&guard.as_pointer()); + DefaultConstructible::default_constructor(&guard.as_pointer()); let _dtor_guard = std::mem::DropGuard::new(guard.clone(), |__p| { Destructible::destroy(&__p.as_pointer()) }); @@ -116,7 +115,7 @@ pub fn test_6() { assert!((dtorCount_2.with(|rc| *rc.borrow()) == 1)); { let guard: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::construct(&guard.as_pointer()); + DefaultConstructible::default_constructor(&guard.as_pointer()); let _dtor_guard = std::mem::DropGuard::new(guard.clone(), |__p| { Destructible::destroy(&__p.as_pointer()) }); @@ -214,14 +213,9 @@ fn main_0() -> i32 { return 0; } pub trait LifetimeTrackedImpl { - fn construct(&self); fn use_(&self); } impl LifetimeTrackedImpl for Ptr { - fn construct(&self) { - field!((*self), uses).write(0); - (*ctorCount_0.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 8b8d518169..707a52a6d9 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 @@ -45,6 +45,12 @@ impl LifetimeTracked { }); } } +impl DefaultConstructible for LifetimeTracked { + fn default_constructor(this: &Ptr) { + field!((*this), uses).write(0); + (*ctorCount_0.with(Value::clone).borrow_mut()).prefix_inc(); + } +} impl CopyConstructible for LifetimeTracked { fn copy_constructor(this: &Ptr, _a0: Ptr) { field!((*this), uses).write(0); @@ -66,20 +72,13 @@ impl Clone for LifetimeTracked { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } -impl DefaultConstructible for LifetimeTracked { - fn default_constructor(this: &Ptr) { - { - LifetimeTrackedImpl::construct(this); - } - } -} impl Default for LifetimeTracked { fn default() -> Self { { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -102,13 +101,12 @@ thread_local!( VaArg, FnPtrArg, CppFrom, - DefaultConstructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(copy_assign)] +#[memberwise(default_constructor, copy_assign)] #[cpp_into(i32, to_i32)] #[byte_size(4)] pub struct p2_condition_variable_lives_for_whole_statement_ConvertsToInt { @@ -165,7 +163,7 @@ pub fn test_10() { let mut selector: i32 = 9; { let guard: Value = Rc::new(RefCell::new(::zero_init())); - LifetimeTrackedImpl::construct(&guard.as_pointer()); + DefaultConstructible::default_constructor(&guard.as_pointer()); let _dtor_guard = std::mem::DropGuard::new(guard.clone(), |__p| { Destructible::destroy(&__p.as_pointer()) }); @@ -240,14 +238,9 @@ fn main_0() -> i32 { return 0; } pub trait LifetimeTrackedImpl { - fn construct(&self); fn use_(&self); } impl LifetimeTrackedImpl for Ptr { - fn construct(&self) { - field!((*self), uses).write(0); - (*ctorCount_0.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/unsafe/stmt.if.rs b/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.if.rs index 07bb6234a0..679aebbfc6 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 @@ -29,15 +29,17 @@ impl LifetimeTracked { (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)) }; } - pub unsafe fn construct(&mut self) { - (&raw mut self.uses).write(0); - (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).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(); } } +impl DefaultConstructibleUnsafe for LifetimeTracked { + unsafe fn default_constructor(&mut self) { + (&raw mut self.uses).write(0); + (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).prefix_inc(); + } +} impl CopyConstructibleUnsafe for LifetimeTracked { unsafe fn copy_constructor(&mut self, _a0: *const LifetimeTracked) { (&raw mut self.uses).write(0); @@ -58,19 +60,12 @@ impl Clone for LifetimeTracked { } } } -impl DefaultConstructibleUnsafe for LifetimeTracked { - unsafe fn default_constructor(&mut self) { - unsafe { - LifetimeTracked::construct(&mut *self); - } - } -} impl Default for LifetimeTracked { fn default() -> Self { unsafe { { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -85,7 +80,7 @@ pub unsafe fn test_6() { let mut choice: i32 = 9; { let mut guard: LifetimeTracked = ::zero_init(); - LifetimeTracked::construct(&mut guard); + DefaultConstructibleUnsafe::default_constructor(&mut guard); let _dtor_guard = std::mem::DropGuard::new(&raw mut guard, |__p| unsafe { DestructibleUnsafe::destroy(&mut *__p) }); @@ -105,7 +100,7 @@ pub unsafe fn test_6() { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_2)) == (1))); { let mut guard: LifetimeTracked = ::zero_init(); - LifetimeTracked::construct(&mut guard); + DefaultConstructibleUnsafe::default_constructor(&mut guard); let _dtor_guard = std::mem::DropGuard::new(&raw mut guard, |__p| unsafe { DestructibleUnsafe::destroy(&mut *__p) }); 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 b1c965e4ee..99caf0fa95 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 @@ -29,15 +29,17 @@ impl LifetimeTracked { (*std::cell::LazyCell::force_mut(&mut *&raw mut copyCount_1)) }; } - pub unsafe fn construct(&mut self) { - (&raw mut self.uses).write(0); - (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).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(); } } +impl DefaultConstructibleUnsafe for LifetimeTracked { + unsafe fn default_constructor(&mut self) { + (&raw mut self.uses).write(0); + (*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)).prefix_inc(); + } +} impl CopyConstructibleUnsafe for LifetimeTracked { unsafe fn copy_constructor(&mut self, _a0: *const LifetimeTracked) { (&raw mut self.uses).write(0); @@ -58,19 +60,12 @@ impl Clone for LifetimeTracked { } } } -impl DefaultConstructibleUnsafe for LifetimeTracked { - unsafe fn default_constructor(&mut self) { - unsafe { - LifetimeTracked::construct(&mut *self); - } - } -} impl Default for LifetimeTracked { fn default() -> Self { unsafe { { let mut __v: LifetimeTracked = ::zero_init(); - LifetimeTracked::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -88,13 +83,12 @@ pub static mut dtorCount_6: std::cell::LazyCell = std::cell::LazyCell::new( FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(copy_assign)] +#[memberwise(default_constructor, copy_assign)] #[cpp_into(i32, to_i32)] pub struct p2_condition_variable_lives_for_whole_statement_ConvertsToInt { pub value: i32, @@ -150,7 +144,7 @@ pub unsafe fn test_10() { let mut selector: i32 = 9; { let mut guard: LifetimeTracked = ::zero_init(); - LifetimeTracked::construct(&mut guard); + DefaultConstructibleUnsafe::default_constructor(&mut guard); let _dtor_guard = std::mem::DropGuard::new(&raw mut guard, |__p| unsafe { DestructibleUnsafe::destroy(&mut *__p) }); diff --git a/tests/std/temp/out/refcount/temp.type.rs b/tests/std/temp/out/refcount/temp.type.rs index e2587de149..3ba8828386 100644 --- a/tests/std/temp/out/refcount/temp.type.rs +++ b/tests/std/temp/out/refcount/temp.type.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct p2_6_pointer_to_member_argument_HasTwoInts { #[offset(0)] @@ -36,10 +37,11 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct p2_6_pointer_to_member_argument_CountsPerMember_refp2_6_pointer_to_member_argument_HasTwoInts_first_ {} @@ -54,10 +56,11 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct p2_6_pointer_to_member_argument_CountsPerMember_refp2_6_pointer_to_member_argument_HasTwoInts_second_ {} @@ -72,10 +75,11 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 0759585309..d78d8fb422 100644 --- a/tests/std/temp/out/unsafe/temp.type.rs +++ b/tests/std/temp/out/unsafe/temp.type.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct p2_6_pointer_to_member_argument_HasTwoInts { pub first: i32, pub second: i32, @@ -29,10 +30,11 @@ pub static mut count_0: std::cell::LazyCell = std::cell::LazyCell::new(|| u VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 }); @@ -43,10 +45,11 @@ pub static mut count_1: std::cell::LazyCell = std::cell::LazyCell::new(|| u VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 }); @@ -57,10 +60,11 @@ pub static mut count_2: std::cell::LazyCell = std::cell::LazyCell::new(|| u VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 1d21441178..d4de75e7f6 100644 --- a/tests/std/temp/temp.spec/out/refcount/temp.inst.rs +++ b/tests/std/temp/temp.spec/out/refcount/temp.inst.rs @@ -14,9 +14,7 @@ pub struct p2_reference_does_not_instantiate_Member { } impl DefaultConstructible for p2_reference_does_not_instantiate_Member { fn default_constructor(this: &Ptr) { - { - p2_reference_does_not_instantiate_MemberImpl::construct_1(this); - } + field!((*this), value).write(1); } } impl Default for p2_reference_does_not_instantiate_Member { @@ -34,16 +32,14 @@ pub struct p2_reference_does_not_instantiate_Holder { } impl DefaultConstructible for p2_reference_does_not_instantiate_Holder { fn default_constructor(this: &Ptr) { - { - p2_reference_does_not_instantiate_HolderImpl::construct_1(this); - } + DefaultConstructible::default_constructor(&field_ptr!(this, member)); } } pub fn test_0() { let holder: Value = Rc::new(RefCell::new( ::zero_init(), )); - p2_reference_does_not_instantiate_HolderImpl::construct_1(&holder.as_pointer()); + DefaultConstructible::default_constructor(&holder.as_pointer()); assert!(({ (*holder.borrow()).member.value } == 1)); (*holder.borrow_mut()).member.value = 3; assert!(({ (*holder.borrow()).member.value } == 3)); @@ -59,27 +55,13 @@ 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 construct_1(&self); -} -impl p2_reference_does_not_instantiate_HolderImpl - for Ptr -{ - fn construct_1(&self) { - p2_reference_does_not_instantiate_MemberImpl::construct_1(&field_ptr!(self, member)); - } -} pub trait p2_reference_does_not_instantiate_MemberImpl { - fn construct_1(&self); - fn construct_2(&self, _a0: Ptr); + fn construct_1(&self, _a0: Ptr); } impl p2_reference_does_not_instantiate_MemberImpl for Ptr { - fn construct_1(&self) { - field!((*self), value).write(1); - } - fn construct_2(&self, _a0: Ptr) { + fn construct_1(&self, _a0: Ptr) { field!((*self), value).write(2); } } 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 f994f2ee06..e11b60685f 100644 --- a/tests/std/temp/temp.spec/out/unsafe/temp.inst.rs +++ b/tests/std/temp/temp.spec/out/unsafe/temp.inst.rs @@ -12,10 +12,7 @@ pub struct p2_reference_does_not_instantiate_Member { pub value: i32, } impl p2_reference_does_not_instantiate_Member { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.value).write(1); - } - pub unsafe fn construct_2( + pub unsafe fn construct_1( &mut self, _a0: *const p2_reference_does_not_instantiate_Wrapper_int_, ) { @@ -24,9 +21,7 @@ impl p2_reference_does_not_instantiate_Member { } impl DefaultConstructibleUnsafe for p2_reference_does_not_instantiate_Member { unsafe fn default_constructor(&mut self) { - unsafe { - p2_reference_does_not_instantiate_Member::construct_1(&mut *self); - } + (&raw mut self.value).write(1); } } impl Default for p2_reference_does_not_instantiate_Member { @@ -40,22 +35,15 @@ impl Default for p2_reference_does_not_instantiate_Member { 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 construct_1(&mut self) { - p2_reference_does_not_instantiate_Member::construct_1(&mut self.member); - } -} impl DefaultConstructibleUnsafe for p2_reference_does_not_instantiate_Holder { unsafe fn default_constructor(&mut self) { - unsafe { - p2_reference_does_not_instantiate_Holder::construct_1(&mut *self); - } + DefaultConstructibleUnsafe::default_constructor(&mut self.member); } } pub unsafe fn test_0() { let mut holder: p2_reference_does_not_instantiate_Holder = ::zero_init(); - p2_reference_does_not_instantiate_Holder::construct_1(&mut holder); + DefaultConstructibleUnsafe::default_constructor(&mut holder); assert!(((holder.member.value) == (1))); holder.member.value = 3; assert!(((holder.member.value) == (3))); diff --git a/tests/std/utilities/utility/out/refcount/forward-helpers.rs b/tests/std/utilities/utility/out/refcount/forward-helpers.rs index 249cfa6f7a..5a708cc6e5 100644 --- a/tests/std/utilities/utility/out/refcount/forward-helpers.rs +++ b/tests/std/utilities/utility/out/refcount/forward-helpers.rs @@ -79,9 +79,7 @@ pub struct p6_forward_like_Holder { } impl DefaultConstructible for p6_forward_like_Holder { fn default_constructor(this: &Ptr) { - { - p6_forward_like_HolderImpl::construct_1(this); - } + p6_forward_like_MovableImpl::construct(&field_ptr!(this, member), { 1 }); } } impl Default for p6_forward_like_Holder { @@ -109,7 +107,7 @@ pub fn take_2(this: Ptr, self_: Ptr = Rc::new(RefCell::new(::zero_init())); - p6_forward_like_HolderImpl::construct_1(&holder.as_pointer()); + DefaultConstructible::default_constructor(&holder.as_pointer()); let copied: Value = Rc::new(RefCell::new(::zero_init())); ({ take_1(Ptr::clone(&copied.as_pointer()), holder.as_pointer()) }); @@ -411,14 +409,6 @@ impl p11_move_if_noexcept_ThrowingMoveImpl for Ptr { - fn construct_1(&self) { - p6_forward_like_MovableImpl::construct(&field_ptr!(self, member), { 1 }); - } -} pub trait p6_forward_like_MovableImpl { fn construct(&self, value: i32); } diff --git a/tests/std/utilities/utility/out/refcount/forward.rs b/tests/std/utilities/utility/out/refcount/forward.rs index 90330e7314..3f331f64c6 100644 --- a/tests/std/utilities/utility/out/refcount/forward.rs +++ b/tests/std/utilities/utility/out/refcount/forward.rs @@ -20,10 +20,11 @@ pub fn test_0() { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 fe8fd7363a..d5e0eb128e 100644 --- a/tests/std/utilities/utility/out/refcount/utility.as.const.rs +++ b/tests/std/utilities/utility/out/refcount/utility.as.const.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 18d458428b..6452e83914 100644 --- a/tests/std/utilities/utility/out/unsafe/forward-helpers.rs +++ b/tests/std/utilities/utility/out/unsafe/forward-helpers.rs @@ -75,16 +75,9 @@ impl Clone for p6_forward_like_Movable { pub struct p6_forward_like_Holder { pub member: p6_forward_like_Movable, } -impl p6_forward_like_Holder { - pub unsafe fn construct_1(&mut self) { - p6_forward_like_Movable::construct(&mut self.member, { 1 }); - } -} impl DefaultConstructibleUnsafe for p6_forward_like_Holder { unsafe fn default_constructor(&mut self) { - unsafe { - p6_forward_like_Holder::construct_1(&mut *self); - } + p6_forward_like_Movable::construct(&mut self.member, { 1 }); } } impl Default for p6_forward_like_Holder { @@ -110,7 +103,7 @@ pub unsafe fn take_2(this: *mut p6_forward_like_Movable, self_: *mut p6_forward_ } pub unsafe fn test_3() { let mut holder: p6_forward_like_Holder = ::zero_init(); - p6_forward_like_Holder::construct_1(&mut holder); + DefaultConstructibleUnsafe::default_constructor(&mut holder); let mut copied: p6_forward_like_Movable = ::zero_init(); (unsafe { take_1(&mut copied, &mut holder) }); assert!(((copied.value) == (1)) && ((holder.member.value) == (1))); diff --git a/tests/std/utilities/utility/out/unsafe/forward.rs b/tests/std/utilities/utility/out/unsafe/forward.rs index 4704b9ce79..5741c6cf70 100644 --- a/tests/std/utilities/utility/out/unsafe/forward.rs +++ b/tests/std/utilities/utility/out/unsafe/forward.rs @@ -19,10 +19,11 @@ pub unsafe fn test_0() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 a2bad17073..3a67e63949 100644 --- a/tests/std/utilities/utility/out/unsafe/utility.as.const.rs +++ b/tests/std/utilities/utility/out/unsafe/utility.as.const.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct p1_as_const_Counter { pub value: i32, } diff --git a/tests/ub/out/refcount/self_referencing_initializer.rs b/tests/ub/out/refcount/self_referencing_initializer.rs index f44c5f8da7..05d7d34b76 100644 --- a/tests/ub/out/refcount/self_referencing_initializer.rs +++ b/tests/ub/out/refcount/self_referencing_initializer.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct pair { #[offset(0)] diff --git a/tests/ub/out/unsafe/self_referencing_initializer.rs b/tests/ub/out/unsafe/self_referencing_initializer.rs index a553ac42ea..7d14c20812 100644 --- a/tests/ub/out/unsafe/self_referencing_initializer.rs +++ b/tests/ub/out/unsafe/self_referencing_initializer.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct pair { pub a: i32, pub b: i32, diff --git a/tests/unit/out/refcount/05_new.rs b/tests/unit/out/refcount/05_new.rs index 825932b94c..00ebfee217 100644 --- a/tests/unit/out/refcount/05_new.rs +++ b/tests/unit/out/refcount/05_new.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct A {} #[derive( @@ -28,10 +29,11 @@ pub struct A {} ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 b8dcd64be3..858dbff246 100644 --- a/tests/unit/out/refcount/10_struct.rs +++ b/tests/unit/out/refcount/10_struct.rs @@ -13,10 +13,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(16)] pub struct GraphNode { #[offset(0)] @@ -32,10 +33,11 @@ pub struct GraphNode { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(16)] pub struct Graph { #[offset(0)] @@ -53,9 +55,7 @@ pub struct Partial { } impl DefaultConstructible for Partial { fn default_constructor(this: &Ptr) { - { - PartialImpl::construct_1(this); - } + field!((*this), p).write(Ptr::::null()); } } impl Default for Partial { @@ -88,10 +88,11 @@ pub struct Declared {} ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(16)] pub struct S { #[offset(0)] @@ -111,12 +112,12 @@ fn main_0() -> i32 { }; let arr: Value> = Rc::new(RefCell::new(Box::new([3, 1, 4]))); let it: Value = Rc::new(RefCell::new(::zero_init())); - PartialImpl::construct_2(&it.as_pointer(), { arr.decay() }); + PartialImpl::construct_1(&it.as_pointer(), { arr.decay() }); if ({ { (*it.borrow()).p.clone() } } != { arr.decay() }) { return 1; } let def: Value = Rc::new(RefCell::new(::zero_init())); - PartialImpl::construct_1(&def.as_pointer()); + DefaultConstructible::default_constructor(&def.as_pointer()); if !(({ (*def.borrow()).p.clone() }).is_null()) { return 1; } @@ -151,8 +152,7 @@ impl GraphImpl for Ptr { } } pub trait PartialImpl { - fn construct_1(&self); - fn construct_2(&self, q: Ptr); + fn construct_1(&self, q: Ptr); fn get(&self) -> Ptr { unimplemented!() } @@ -164,10 +164,7 @@ pub trait PartialImpl { } } impl PartialImpl for Ptr { - fn construct_1(&self) { - field!((*self), p).write(Ptr::::null()); - } - fn construct_2(&self, mut q: Ptr) { + fn construct_1(&self, mut q: Ptr) { field!((*self), p).write((q).clone()); } } diff --git a/tests/unit/out/refcount/addr_of_global.rs b/tests/unit/out/refcount/addr_of_global.rs index 325660b7a0..fa9c30bed0 100644 --- a/tests/unit/out/refcount/addr_of_global.rs +++ b/tests/unit/out/refcount/addr_of_global.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Inner { #[offset(0)] @@ -30,10 +31,11 @@ pub struct Inner { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 158fe314f6..660b333fcc 100644 --- a/tests/unit/out/refcount/anonymous-struct.rs +++ b/tests/unit/out/refcount/anonymous-struct.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct Outer_Named { #[offset(0)] @@ -33,10 +34,11 @@ pub struct Outer_Named { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct anon_0 { #[offset(0)] @@ -52,10 +54,11 @@ pub struct anon_0 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct anon_1 { #[offset(0)] @@ -71,10 +74,11 @@ pub struct anon_1 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct anon_2 { #[offset(0)] @@ -90,10 +94,11 @@ pub struct anon_2 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct anon_4 { #[offset(0)] @@ -107,10 +112,11 @@ pub struct anon_4 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct anon_5 { #[offset(0)] @@ -124,10 +130,11 @@ pub struct anon_5 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(12)] pub struct anon_3 { #[offset(0)] @@ -147,10 +154,11 @@ pub struct anon_3 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(44)] pub struct Outer { #[offset(0)] @@ -222,10 +230,11 @@ fn main_0() -> i32 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 d808c6d2ff..ae0c180cae 100644 --- a/tests/unit/out/refcount/anonymous_enum.rs +++ b/tests/unit/out/refcount/anonymous_enum.rs @@ -20,10 +20,11 @@ pub const anon_1_SECOND_B: anon_1 = 1; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct S { #[offset(0)] @@ -43,10 +44,11 @@ pub const anon_2_FIELD_B: anon_2 = 1; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct WithAnonField { #[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 f3c414bc24..62c02d5cfb 100644 --- a/tests/unit/out/refcount/array_of_noncopy_struct.rs +++ b/tests/unit/out/refcount/array_of_noncopy_struct.rs @@ -29,9 +29,8 @@ pub struct NonCopy { } impl DefaultConstructible for NonCopy { fn default_constructor(this: &Ptr) { - { - NonCopyImpl::construct_1(this); - } + field!((*this), data).write(Vec::new()); + field!((*this), tag).write(0); } } impl Default for NonCopy { @@ -51,7 +50,7 @@ pub fn main() { fn main_0() -> i32 { let mut arr: [NonCopy; 3] = std::array::from_fn::<_, 3, _>(|_| { let __v: Value = Rc::new(RefCell::new(::zero_init())); - NonCopyImpl::construct_1(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() }); arr[(0) as usize].tag = 7; @@ -66,13 +65,4 @@ fn main_0() -> i32 { assert!((arr[(2) as usize].data.len() == 0_usize)); return 0; } -pub trait NonCopyImpl { - fn construct_1(&self); -} -impl NonCopyImpl for Ptr { - fn construct_1(&self) { - field!((*self), data).write(Vec::new()); - field!((*self), tag).write(0); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/array_reference.rs b/tests/unit/out/refcount/array_reference.rs index 72b41e9565..18f7c24e02 100644 --- a/tests/unit/out/refcount/array_reference.rs +++ b/tests/unit/out/refcount/array_reference.rs @@ -67,10 +67,11 @@ pub fn pick_10(s: Ptr) -> Ptr { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 61fc9aa4e6..14bbf46c41 100644 --- a/tests/unit/out/refcount/as_const.rs +++ b/tests/unit/out/refcount/as_const.rs @@ -17,10 +17,11 @@ pub const Overload_kConstOverload: Overload = 2; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 92a13669d6..4835d44aca 100644 --- a/tests/unit/out/refcount/assign_rhs_first.rs +++ b/tests/unit/out/refcount/assign_rhs_first.rs @@ -22,10 +22,11 @@ pub fn advance_1() -> i32 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 1d68e30dd8..2a3ac2025f 100644 --- a/tests/unit/out/refcount/assignment_single_eval.rs +++ b/tests/unit/out/refcount/assignment_single_eval.rs @@ -926,10 +926,11 @@ pub fn test_pointer_elements_11() { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct Holder_12 { #[offset(0)] @@ -1078,10 +1079,11 @@ pub fn test_reference_subfields_18() { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Index_16 { #[offset(0)] @@ -1112,10 +1114,11 @@ pub struct Slot_17 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(2)] pub struct Index_19 { #[offset(0)] @@ -1181,10 +1184,11 @@ pub fn observe_24(mut assigned: i32, mut stored: Ptr) -> i32 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct GlobalRecord_Inner { #[offset(0)] @@ -1198,10 +1202,11 @@ pub struct GlobalRecord_Inner { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct GlobalRecord { #[offset(0)] @@ -1450,10 +1455,11 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Record_32 { #[offset(0)] @@ -1466,10 +1472,11 @@ pub struct Record_32 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct Link_33 { #[offset(0)] @@ -1488,10 +1495,11 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct IndexedBinding {} pub fn test_binding_35() { @@ -1734,10 +1742,11 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(12)] pub struct IndexedMember { #[offset(0)] @@ -2105,10 +2114,11 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct PointerSelector { #[offset(0)] @@ -2331,9 +2341,7 @@ pub struct Counts_59 { } impl DefaultConstructible for Counts_59 { fn default_constructor(this: &Ptr) { - { - Counts_59Impl::construct_1(this); - } + field!((*this), counts).write(Vec::new()); } } #[derive( @@ -2344,10 +2352,11 @@ impl DefaultConstructible for Counts_59 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct Pair_60 { #[offset(0)] @@ -2666,25 +2675,20 @@ fn main_0() -> i32 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Index_62 { #[offset(0)] pub value: i32, } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - DefaultConstructible, - TriviallyCopyable, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, )] +#[memberwise(default_constructor)] #[byte_size(12)] pub struct Owner_63 { #[offset(0)] @@ -2704,14 +2708,6 @@ impl Default for Owner_63 { } } } -pub trait Counts_59Impl { - fn construct_1(&self); -} -impl Counts_59Impl for Ptr { - fn construct_1(&self) { - field!((*self), counts).write(Vec::new()); - } -} pub trait IndexedBindingImpl { fn get_1_0(&self) -> Ptr; } diff --git a/tests/unit/out/refcount/bounded_struct_ptr.rs b/tests/unit/out/refcount/bounded_struct_ptr.rs index 49fb64a8d3..80fd4f695f 100644 --- a/tests/unit/out/refcount/bounded_struct_ptr.rs +++ b/tests/unit/out/refcount/bounded_struct_ptr.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 5f31e8f754..71d17f64ee 100644 --- a/tests/unit/out/refcount/bst.rs +++ b/tests/unit/out/refcount/bst.rs @@ -13,10 +13,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(24)] pub struct node_t { #[offset(0)] diff --git a/tests/unit/out/refcount/cast.rs b/tests/unit/out/refcount/cast.rs index 1aae79711e..d2bdfc4bdf 100644 --- a/tests/unit/out/refcount/cast.rs +++ b/tests/unit/out/refcount/cast.rs @@ -18,10 +18,11 @@ pub const E_C: E = 2; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct Pair { #[offset(0)] @@ -37,10 +38,11 @@ pub struct Pair { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(64)] #[byte_align(64)] pub struct Wide { @@ -48,15 +50,9 @@ pub struct Wide { pub c: i8, } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - DefaultConstructible, - TriviallyCopyable, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, )] +#[memberwise(default_constructor)] #[byte_size(40)] pub struct Grid { #[offset(0)] @@ -107,9 +103,8 @@ pub struct Bag { } impl DefaultConstructible for Bag { fn default_constructor(this: &Ptr) { - { - BagImpl::construct_1(this); - } + field!((*this), n).write(0_i32); + field!((*this), items).write(Vec::new()); } } pub fn adjacent_arrays_0() { @@ -382,7 +377,7 @@ pub fn nested_5() { assert!(({ (pm).clone() } == { (m.decay().offset(1).decay().offset(1)) })); assert!(({ (pm).clone() } < { (m.decay().offset(2).decay().offset(0)) })); let b: Value = Rc::new(RefCell::new(::zero_init())); - BagImpl::construct_1(&b.as_pointer()); + DefaultConstructible::default_constructor(&b.as_pointer()); if 4_usize > (*b.borrow()).items.capacity() as usize { let len_0 = (*b.borrow()).items.len(); (*b.borrow_mut()) @@ -566,13 +561,4 @@ fn main_0() -> i32 { ({ bool_to_floating_10() }); return 0; } -pub trait BagImpl { - fn construct_1(&self); -} -impl BagImpl for Ptr { - fn construct_1(&self) { - field!((*self), n).write(0_i32); - field!((*self), items).write(Vec::new()); - } -} 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 0229f2700e..7537a31ccd 100644 --- a/tests/unit/out/refcount/cast_array_to_pointer_decay.rs +++ b/tests/unit/out/refcount/cast_array_to_pointer_decay.rs @@ -17,15 +17,9 @@ pub fn strlen_1(mut s: Ptr) -> i32 { return c; } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - DefaultConstructible, - TriviallyCopyable, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, )] +#[memberwise(default_constructor)] #[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 eac68f8b7f..595127f67a 100644 --- a/tests/unit/out/refcount/class.rs +++ b/tests/unit/out/refcount/class.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct Pair { #[offset(0)] @@ -33,10 +34,11 @@ pub struct Pair { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(16)] pub struct Route { #[offset(0)] @@ -53,10 +55,11 @@ pub struct Route { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct Counter { #[offset(0)] @@ -77,10 +80,11 @@ impl CppEq for Counter { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 83de1e5182..e35871d748 100644 --- a/tests/unit/out/refcount/class_template_lazy_member.rs +++ b/tests/unit/out/refcount/class_template_lazy_member.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Point { #[offset(0)] @@ -31,10 +32,11 @@ pub struct Point { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Box_int_ { #[offset(0)] @@ -48,10 +50,11 @@ pub struct Box_int_ { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Box_Point_ { #[offset(0)] @@ -66,10 +69,11 @@ pub struct Box_Point_ { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Deduced_int_ { #[offset(0)] @@ -83,10 +87,11 @@ pub struct Deduced_int_ { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 a16fe7368c..51e3dc3a62 100644 --- a/tests/unit/out/refcount/class_templates.rs +++ b/tests/unit/out/refcount/class_templates.rs @@ -28,9 +28,7 @@ pub struct MyContainer_int_ { } impl DefaultConstructible for MyContainer_int_ { fn default_constructor(this: &Ptr) { - { - MyContainer_int_Impl::construct_1(this); - } + field!((*this), vec_).write(Vec::new()); } } #[derive( @@ -55,9 +53,7 @@ pub struct MyContainer_char_ { } impl DefaultConstructible for MyContainer_char_ { fn default_constructor(this: &Ptr) { - { - MyContainer_char_Impl::construct_1(this); - } + field!((*this), vec_).write(Vec::new()); } } #[derive( @@ -82,9 +78,7 @@ pub struct MyContainer_float_ { } impl DefaultConstructible for MyContainer_float_ { fn default_constructor(this: &Ptr) { - { - MyContainer_float_Impl::construct_1(this); - } + field!((*this), vec_).write(Vec::new()); } } #[derive( @@ -95,10 +89,11 @@ impl DefaultConstructible for MyContainer_float_ { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(2)] pub struct Boxed_short_ { #[offset(0)] @@ -117,10 +112,11 @@ impl Boxed_short_ { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Boxed_int_ { #[offset(0)] @@ -139,10 +135,11 @@ impl Boxed_int_ { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct Boxed_long_ { #[offset(0)] @@ -161,10 +158,11 @@ impl Boxed_long_ { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct Outer_int__Inner_int_ { #[offset(0)] @@ -180,10 +178,11 @@ pub struct Outer_int__Inner_int_ { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Outer_int_ { #[offset(0)] @@ -197,10 +196,11 @@ pub struct Outer_int_ { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(16)] pub struct Outer_long__Inner_int_ { #[offset(0)] @@ -216,10 +216,11 @@ pub struct Outer_long__Inner_int_ { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(16)] pub struct Outer_long__Inner_char_ { #[offset(0)] @@ -235,10 +236,11 @@ pub struct Outer_long__Inner_char_ { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct Outer_long_ { #[offset(0)] @@ -252,10 +254,11 @@ pub struct Outer_long_ { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Elem { #[offset(0)] @@ -309,7 +312,7 @@ fn main_0() -> i32 { let bl: Value = Rc::new(RefCell::new(Boxed_long_ { value: 7_i64 })); assert!((({ Boxed_long_Impl::plus(&bl.as_pointer(), 1_i64,) }) == 8_i64)); let imc: Value = Rc::new(RefCell::new(::zero_init())); - MyContainer_int_Impl::construct_1(&imc.as_pointer()); + DefaultConstructible::default_constructor(&imc.as_pointer()); assert!(({ MyContainer_int_Impl::empty(&imc.as_pointer(),) })); ({ let _item: Value = Rc::new(RefCell::new(1)); @@ -322,7 +325,7 @@ fn main_0() -> i32 { ({ MyContainer_int_Impl::pop_back(&imc.as_pointer()) }); assert!(({ MyContainer_int_Impl::empty(&imc.as_pointer(),) })); let cmc: Value = Rc::new(RefCell::new(::zero_init())); - MyContainer_char_Impl::construct_1(&cmc.as_pointer()); + DefaultConstructible::default_constructor(&cmc.as_pointer()); assert!(({ MyContainer_char_Impl::empty(&cmc.as_pointer(),) })); ({ let _item: Value = Rc::new(RefCell::new(('a' as i8))); @@ -336,7 +339,7 @@ fn main_0() -> i32 { ({ MyContainer_char_Impl::pop_back(&cmc.as_pointer()) }); assert!(({ MyContainer_char_Impl::empty(&cmc.as_pointer(),) })); let fmc: Value = Rc::new(RefCell::new(::zero_init())); - MyContainer_float_Impl::construct_1(&fmc.as_pointer()); + DefaultConstructible::default_constructor(&fmc.as_pointer()); assert!(({ MyContainer_float_Impl::empty(&fmc.as_pointer(),) })); ({ let _item: Value = Rc::new(RefCell::new((1_f64 as f32))); @@ -384,7 +387,6 @@ pub trait MyContainer_char_Impl { fn back_4(&self) -> Ptr; fn pop_back(&self); fn push_back(&self, item: Ptr); - fn construct_1(&self); } impl MyContainer_char_Impl for Ptr { fn empty(&self) -> bool { @@ -409,9 +411,6 @@ impl MyContainer_char_Impl for Ptr { field!((*self), vec_).with_mut(|__v: &mut Vec| __v.push(a0_clone)) }; } - fn construct_1(&self) { - field!((*self), vec_).write(Vec::new()); - } } pub trait MyContainer_float_Impl { fn empty(&self) -> bool; @@ -422,7 +421,6 @@ pub trait MyContainer_float_Impl { fn back_4(&self) -> Ptr; fn pop_back(&self); fn push_back(&self, item: Ptr); - fn construct_1(&self); } impl MyContainer_float_Impl for Ptr { fn empty(&self) -> bool { @@ -447,9 +445,6 @@ impl MyContainer_float_Impl for Ptr { field!((*self), vec_).with_mut(|__v: &mut Vec| __v.push(a0_clone)) }; } - fn construct_1(&self) { - field!((*self), vec_).write(Vec::new()); - } } pub trait MyContainer_int_Impl { fn empty(&self) -> bool; @@ -460,7 +455,6 @@ pub trait MyContainer_int_Impl { fn back_4(&self) -> Ptr; fn pop_back(&self); fn push_back(&self, item: Ptr); - fn construct_1(&self); } impl MyContainer_int_Impl for Ptr { fn empty(&self) -> bool { @@ -485,9 +479,6 @@ impl MyContainer_int_Impl for Ptr { field!((*self), vec_).with_mut(|__v: &mut Vec| __v.push(a0_clone)) }; } - fn construct_1(&self) { - field!((*self), vec_).write(Vec::new()); - } } pub trait Outer_int_Impl { fn with(&self, n: i32) -> Outer_int__Inner_int_; diff --git a/tests/unit/out/refcount/clone_vs_move.rs b/tests/unit/out/refcount/clone_vs_move.rs index 5fbb67ca6c..68fa6756a5 100644 --- a/tests/unit/out/refcount/clone_vs_move.rs +++ b/tests/unit/out/refcount/clone_vs_move.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Bar { #[offset(0)] diff --git a/tests/unit/out/refcount/comma_operator.rs b/tests/unit/out/refcount/comma_operator.rs index 9f04a89f1a..9d51ebf6cb 100644 --- a/tests/unit/out/refcount/comma_operator.rs +++ b/tests/unit/out/refcount/comma_operator.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 f160bcf747..31ec172305 100644 --- a/tests/unit/out/refcount/complex_function.rs +++ b/tests/unit/out/refcount/complex_function.rs @@ -23,10 +23,11 @@ pub fn bar_2(x: Ptr) -> Ptr { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct X1 { #[offset(0)] @@ -56,10 +57,11 @@ pub struct X2 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct X3 { #[offset(0)] @@ -73,10 +75,11 @@ pub struct X3 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 fb0440b491..7d2d5a0342 100644 --- a/tests/unit/out/refcount/compound_assign_paren.rs +++ b/tests/unit/out/refcount/compound_assign_paren.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 21314c993a..840cf1584f 100644 --- a/tests/unit/out/refcount/concepts.rs +++ b/tests/unit/out/refcount/concepts.rs @@ -19,10 +19,11 @@ const _: () = assert!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 6b606f0d63..4c493e257e 100644 --- a/tests/unit/out/refcount/constexpr_function.rs +++ b/tests/unit/out/refcount/constexpr_function.rs @@ -29,10 +29,11 @@ pub fn half_3(mut x: f64) -> f64 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Flag { #[offset(0)] @@ -63,10 +64,11 @@ pub fn imm_7(mut b: bool) -> bool { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 24cb0340e7..ba2ca763c6 100644 --- a/tests/unit/out/refcount/constructor.rs +++ b/tests/unit/out/refcount/constructor.rs @@ -50,9 +50,10 @@ pub struct Point { } impl DefaultConstructible for Point { fn default_constructor(this: &Ptr) { + PointImpl::construct_1(this, { 4 }); { - PointImpl::construct_3(this); - } + field!((*this), x).with_mut(|__v| *__v = *__v + 100) + }; } } impl Default for Point { @@ -60,7 +61,7 @@ impl Default for Point { { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - PointImpl::construct_3(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -81,7 +82,7 @@ fn main_0() -> i32 { } assert!((total_0.with(|rc| *rc.borrow()) == 18)); let p: Value = Rc::new(RefCell::new(::zero_init())); - PointImpl::construct_3(&p.as_pointer()); + DefaultConstructible::default_constructor(&p.as_pointer()); assert!(({ (*p.borrow()).x } == 104)); assert!(({ (*p.borrow()).y } == 50)); let q: Value = Rc::new(RefCell::new(::zero_init())); @@ -93,7 +94,6 @@ fn main_0() -> i32 { pub trait PointImpl { fn construct_2(&self, x: i32, y: i32); fn construct_1(&self, v: i32); - fn construct_3(&self); } impl PointImpl for Ptr { fn construct_2(&self, mut x: i32, mut y: i32) { @@ -106,12 +106,6 @@ impl PointImpl for Ptr { field!((*self), y).with_mut(|__v| *__v = *__v * 10) }; } - fn construct_3(&self) { - PointImpl::construct_1(self, { 4 }); - { - field!((*self), x).with_mut(|__v| *__v = *__v + 100) - }; - } } pub trait SImpl { fn const_method(&self) -> i32; diff --git a/tests/unit/out/refcount/container_field_addr.rs b/tests/unit/out/refcount/container_field_addr.rs index cb9fee17db..931646d616 100644 --- a/tests/unit/out/refcount/container_field_addr.rs +++ b/tests/unit/out/refcount/container_field_addr.rs @@ -30,9 +30,8 @@ pub struct S { } impl DefaultConstructible for S { fn default_constructor(this: &Ptr) { - { - SImpl::construct_1(this); - } + field!((*this), tag).write(0_i32); + field!((*this), v).write(Vec::new()); } } pub fn add_0(mut v: Ptr>, mut k: i32) { @@ -63,12 +62,12 @@ pub fn main() { } fn main_0() -> i32 { let local: Value = Rc::new(RefCell::new(::zero_init())); - SImpl::construct_1(&local.as_pointer()); + DefaultConstructible::default_constructor(&local.as_pointer()); (*local.borrow_mut()).tag = 7; ({ run_1((local.as_pointer())) }); let mut heap: Ptr = { let __p = Ptr::alloc(::zero_init()); - SImpl::construct_1(&__p); + DefaultConstructible::default_constructor(&__p); __p }; field!(heap, tag).write(7); @@ -76,13 +75,4 @@ fn main_0() -> i32 { heap.delete(); return 0; } -pub trait SImpl { - fn construct_1(&self); -} -impl SImpl for Ptr { - fn construct_1(&self) { - field!((*self), tag).write(0_i32); - field!((*self), v).write(Vec::new()); - } -} 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 62abe35571..cae7036b01 100644 --- a/tests/unit/out/refcount/conversion_operator_same_translation.rs +++ b/tests/unit/out/refcount/conversion_operator_same_translation.rs @@ -15,10 +15,11 @@ use std::rc::{Rc, Weak}; VaArg, FnPtrArg, CppFrom, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[cpp_into(i8, to_i8)] #[cpp_into(u8, to_u8)] #[byte_size(4)] @@ -35,10 +36,11 @@ pub struct S { VaArg, FnPtrArg, CppFrom, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 0008da9867..6acca04f8f 100644 --- a/tests/unit/out/refcount/copy_assign.rs +++ b/tests/unit/out/refcount/copy_assign.rs @@ -64,9 +64,7 @@ pub struct NonConstAssign { } impl DefaultConstructible for NonConstAssign { fn default_constructor(this: &Ptr) { - { - NonConstAssignImpl::construct(this); - } + field!((*this), mark).write(0); } } impl Default for NonConstAssign { @@ -75,7 +73,7 @@ impl Default for NonConstAssign { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - NonConstAssignImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -98,25 +96,23 @@ pub struct RefQualified { #[offset(0)] pub mark: i32, } +impl DefaultConstructible for RefQualified { + fn default_constructor(this: &Ptr) { + field!((*this), 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(); } } -impl DefaultConstructible for RefQualified { - fn default_constructor(this: &Ptr) { - { - RefQualifiedImpl::construct(this); - } - } -} impl Default for RefQualified { fn default() -> Self { { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - RefQualifiedImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -262,9 +258,7 @@ impl CopyAssignable for ExplicitOperatorCall { } impl DefaultConstructible for ExplicitOperatorCall { fn default_constructor(this: &Ptr) { - { - ExplicitOperatorCallImpl::construct_1(this); - } + field!((*this), w).write(Vec::new()); } } pub fn main() { @@ -338,21 +332,21 @@ fn main_0() -> i32 { ); assert!((assigns_0.with(|rc| *rc.borrow()) == 8)); let n: Value = Rc::new(RefCell::new(::zero_init())); - NonConstAssignImpl::construct(&n.as_pointer()); + DefaultConstructible::default_constructor(&n.as_pointer()); let n1: Value = Rc::new(RefCell::new(::zero_init())); - NonConstAssignImpl::construct(&n1.as_pointer()); + DefaultConstructible::default_constructor(&n1.as_pointer()); let n2: Value = Rc::new(RefCell::new(::zero_init())); - NonConstAssignImpl::construct(&n2.as_pointer()); + DefaultConstructible::default_constructor(&n2.as_pointer()); let cn: Value = Rc::new(RefCell::new(::zero_init())); - NonConstAssignImpl::construct(&cn.as_pointer()); + DefaultConstructible::default_constructor(&cn.as_pointer()); ({ NonConstAssignImpl::operator_assign_2(&n1.as_pointer(), n.as_pointer()) }); ({ NonConstAssignImpl::operator_assign_3(&n2.as_pointer(), cn.as_pointer()) }); assert!(({ (*n1.borrow()).mark } == 1)); assert!(({ (*n2.borrow()).mark } == 10)); let r: Value = Rc::new(RefCell::new(::zero_init())); - RefQualifiedImpl::construct(&r.as_pointer()); + DefaultConstructible::default_constructor(&r.as_pointer()); let r1: Value = Rc::new(RefCell::new(::zero_init())); - RefQualifiedImpl::construct(&r1.as_pointer()); + DefaultConstructible::default_constructor(&r1.as_pointer()); ({ CopyAssignable::copy_assign(&r1.as_pointer(), r.as_pointer()) }); assert!(({ (*r1.borrow()).mark } == 1)); let h2: Value = Rc::new(RefCell::new(Holder { @@ -434,10 +428,10 @@ fn main_0() -> i32 { assert!((copies_1.with(|rc| *rc.borrow()) == 0)); let e1: Value = Rc::new(RefCell::new(::zero_init())); - ExplicitOperatorCallImpl::construct_1(&e1.as_pointer()); + DefaultConstructible::default_constructor(&e1.as_pointer()); let e2: Value = Rc::new(RefCell::new(::zero_init())); - ExplicitOperatorCallImpl::construct_1(&e2.as_pointer()); + DefaultConstructible::default_constructor(&e2.as_pointer()); { let __a1 = 5; (*e1.borrow_mut()).w.push(__a1) @@ -460,23 +454,11 @@ impl CopyCountedImpl for Ptr { field!((*self), v).write(v); } } -pub trait ExplicitOperatorCallImpl { - fn construct_1(&self); -} -impl ExplicitOperatorCallImpl for Ptr { - fn construct_1(&self) { - field!((*self), w).write(Vec::new()); - } -} pub trait NonConstAssignImpl { - fn construct(&self); fn operator_assign_2(&self, o: Ptr) -> Ptr; fn operator_assign_3(&self, o: Ptr) -> Ptr; } impl NonConstAssignImpl for Ptr { - fn construct(&self) { - field!((*self), mark).write(0); - } fn operator_assign_2(&self, o: Ptr) -> Ptr { field!((*self), mark).write((o.with(|__s| __s.mark) + 1)); return (*self).clone(); @@ -495,14 +477,6 @@ impl PartialImpl for Ptr { field!((*self), keep).write(keep); } } -pub trait RefQualifiedImpl { - fn construct(&self); -} -impl RefQualifiedImpl for Ptr { - fn construct(&self) { - field!((*self), mark).write(0); - } -} 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 97b89c1c4e..717a7b0e90 100644 --- a/tests/unit/out/refcount/copy_ctor.rs +++ b/tests/unit/out/refcount/copy_ctor.rs @@ -60,6 +60,11 @@ pub struct NonConst { #[offset(0)] pub mark: i32, } +impl DefaultConstructible for NonConst { + fn default_constructor(this: &Ptr) { + field!((*this), mark).write(0); + } +} impl Clone for NonConst { fn clone(&self) -> Self { let __src: Value = Rc::new(RefCell::new(NonConst { @@ -70,19 +75,12 @@ impl Clone for NonConst { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } -impl DefaultConstructible for NonConst { - fn default_constructor(this: &Ptr) { - { - NonConstImpl::construct(this); - } - } -} impl Default for NonConst { fn default() -> Self { { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - NonConstImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -257,6 +255,11 @@ pub struct Tracked { #[offset(0)] pub copied_from: i32, } +impl DefaultConstructible for Tracked { + fn default_constructor(this: &Ptr) { + field!((*this), copied_from).write(0); + } +} impl CopyConstructible for Tracked { fn copy_constructor(this: &Ptr, o: Ptr) { field!((*this), copied_from).write(0); @@ -283,13 +286,6 @@ impl Clone for Tracked { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } -impl DefaultConstructible for Tracked { - fn default_constructor(this: &Ptr) { - { - TrackedImpl::construct(this); - } - } -} impl Default for Tracked { fn default() -> Self { { Tracked { copied_from: 0 } } @@ -407,23 +403,23 @@ fn main_0() -> i32 { assert!(({ (*ol2.borrow()).v } == 105)); assert!((copies_0.with(|rc| *rc.borrow()) == 12)); let n: Value = Rc::new(RefCell::new(::zero_init())); - NonConstImpl::construct(&n.as_pointer()); + DefaultConstructible::default_constructor(&n.as_pointer()); let n1: Value = Rc::new(RefCell::new(::zero_init())); NonConstImpl::construct_1(&n1.as_pointer(), { n.as_pointer() }); let cn: Value = Rc::new(RefCell::new(::zero_init())); - NonConstImpl::construct(&cn.as_pointer()); + DefaultConstructible::default_constructor(&cn.as_pointer()); let n2: Value = Rc::new(RefCell::new(::zero_init())); NonConstImpl::construct_2(&n2.as_pointer(), { cn.as_pointer() }); assert!(({ (*n1.borrow()).mark } == 1)); assert!(({ (*n2.borrow()).mark } == 10)); let t1: Value = Rc::new(RefCell::new(::zero_init())); - TrackedImpl::construct(&t1.as_pointer()); + DefaultConstructible::default_constructor(&t1.as_pointer()); let t2: Value = Rc::new(RefCell::new(::zero_init())); CopyConstructible::copy_constructor(&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(::zero_init())); - TrackedImpl::construct(&ct.as_pointer()); + DefaultConstructible::default_constructor(&ct.as_pointer()); let t3: Value = Rc::new(RefCell::new(::zero_init())); CopyConstructible::copy_constructor(&t3.as_pointer(), { ct.as_pointer() }); ({ touch_1((ct.as_pointer())) }); @@ -455,14 +451,10 @@ impl IgnoredImpl for Ptr { } } pub trait NonConstImpl { - fn construct(&self); fn construct_1(&self, o: Ptr); fn construct_2(&self, o: Ptr); } impl NonConstImpl for Ptr { - fn construct(&self) { - field!((*self), mark).write(0); - } fn construct_1(&self, o: Ptr) { field!((*self), mark).write((o.with(|__s| __s.mark) + 1)); } @@ -478,14 +470,6 @@ impl OutOfLineImpl for Ptr { field!((*self), v).write(v); } } -pub trait TrackedImpl { - fn construct(&self); -} -impl TrackedImpl for Ptr { - fn construct(&self) { - field!((*self), copied_from).write(0); - } -} 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 1b045e0ad9..4073b9a5af 100644 --- a/tests/unit/out/refcount/copy_move_defaulted.rs +++ b/tests/unit/out/refcount/copy_move_defaulted.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Inner { #[offset(0)] @@ -60,15 +61,9 @@ impl Default for Explicit { } } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - DefaultConstructible, - TriviallyCopyable, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, )] +#[memberwise(default_constructor)] #[byte_size(16)] pub struct Implicit { #[offset(0)] @@ -221,9 +216,10 @@ pub struct Owner { } impl DefaultConstructible for Owner { fn default_constructor(this: &Ptr) { - { - OwnerImpl::construct_1(this); - } + field!((*this), data).write(Vec::new()); + field!((*this), n).write(0_i32); + field!((*this), arr).write((0..2).map(|_| 0_i32).collect::>()); + field!((*this), p).write(None); } } impl Default for Owner { @@ -260,9 +256,7 @@ pub struct Copyable { } impl DefaultConstructible for Copyable { fn default_constructor(this: &Ptr) { - { - CopyableImpl::construct_1(this); - } + field!((*this), data).write(Vec::new()); } } #[derive( @@ -319,9 +313,7 @@ impl MoveAssignable for SeesThis { } impl DefaultConstructible for SeesThis { fn default_constructor(this: &Ptr) { - { - SeesThisImpl::construct_1(this); - } + field!((*this), self_).write(Ptr::::null()); } } impl Default for SeesThis { @@ -346,9 +338,8 @@ pub struct HasSeesThis { } impl DefaultConstructible for HasSeesThis { fn default_constructor(this: &Ptr) { - { - HasSeesThisImpl::construct_1(this); - } + DefaultConstructible::default_constructor(&field_ptr!(this, s)); + field!((*this), v).write(Vec::new()); } } #[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Swappable)] @@ -359,6 +350,12 @@ pub struct Counted_int_ { #[offset(4)] pub moves: i32, } +impl DefaultConstructible for Counted_int_ { + fn default_constructor(this: &Ptr) { + field!((*this), v).write(0_i32); + field!((*this), moves).write(0); + } +} impl MoveConstructible for Counted_int_ { fn move_constructor(this: &Ptr, o: Ptr) { field!((*this), v).write(o.with(|__s| __s.v)); @@ -372,13 +369,6 @@ impl MoveAssignable for Counted_int_ { return (*this).clone(); } } -impl DefaultConstructible for Counted_int_ { - fn default_constructor(this: &Ptr) { - { - Counted_int_Impl::construct(this); - } - } -} impl Default for Counted_int_ { fn default() -> Self { { Counted_int_ { v: 0_i32, moves: 0 } } @@ -399,9 +389,8 @@ pub struct HasCounted { } impl DefaultConstructible for HasCounted { fn default_constructor(this: &Ptr) { - { - HasCountedImpl::construct_1(this); - } + DefaultConstructible::default_constructor(&field_ptr!(this, c)); + field!((*this), w).write(Vec::new()); } } #[derive( @@ -416,6 +405,12 @@ pub struct CtorSeesThis { #[offset(8)] pub id: i32, } +impl DefaultConstructible for CtorSeesThis { + fn default_constructor(this: &Ptr) { + field!((*this), self_).write((*this).clone()); + field!((*this), id).write(0); + } +} impl CopyConstructible for CtorSeesThis { fn copy_constructor(this: &Ptr, _a0: Ptr) { field!((*this), self_).write((*this).clone()); @@ -449,19 +444,12 @@ impl Clone for CtorSeesThis { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } -impl DefaultConstructible for CtorSeesThis { - fn default_constructor(this: &Ptr) { - { - CtorSeesThisImpl::construct_2(this); - } - } -} impl Default for CtorSeesThis { fn default() -> Self { { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - CtorSeesThisImpl::construct_2(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -491,9 +479,8 @@ pub struct HasCtorSeesThis { } impl DefaultConstructible for HasCtorSeesThis { fn default_constructor(this: &Ptr) { - { - HasCtorSeesThisImpl::construct_1(this); - } + DefaultConstructible::default_constructor(&field_ptr!(this, x)); + field!((*this), v).write(Vec::new()); } } #[derive( @@ -519,9 +506,8 @@ pub struct InitsCtorSeesThis { } impl DefaultConstructible for InitsCtorSeesThis { fn default_constructor(this: &Ptr) { - { - InitsCtorSeesThisImpl::construct(this); - } + CtorSeesThisImpl::construct_1(&field_ptr!(this, x), { 1 }); + CtorSeesThisImpl::construct_1(&field_ptr!(this, y), { 2 }); } } impl Default for InitsCtorSeesThis { @@ -530,7 +516,7 @@ impl Default for InitsCtorSeesThis { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - InitsCtorSeesThisImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -603,9 +589,9 @@ pub struct OutOfLineAssign { } impl DefaultConstructible for OutOfLineAssign { fn default_constructor(this: &Ptr) { - { - OutOfLineAssignImpl::construct_1(this); - } + DefaultConstructible::default_constructor(&field_ptr!(this, s)); + field!((*this), v).write(1); + field!((*this), w).write(Vec::new()); } } impl Default for OutOfLineAssign { @@ -820,7 +806,7 @@ fn main_0() -> i32 { }) ); let o1: Value = Rc::new(RefCell::new(::zero_init())); - OwnerImpl::construct_1(&o1.as_pointer()); + DefaultConstructible::default_constructor(&o1.as_pointer()); { let __a1 = 5; (*o1.borrow_mut()).data.push(__a1) @@ -848,7 +834,7 @@ fn main_0() -> i32 { }) ); let o3: Value = Rc::new(RefCell::new(::zero_init())); - OwnerImpl::construct_1(&o3.as_pointer()); + DefaultConstructible::default_constructor(&o3.as_pointer()); ({ MoveAssignable::move_assign(&o3.as_pointer(), o2.as_pointer()) }); assert!( ((({ (*o3.borrow()).n } == 5) @@ -871,7 +857,7 @@ fn main_0() -> i32 { 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(::zero_init())); - CopyableImpl::construct_1(&c4.as_pointer()); + DefaultConstructible::default_constructor(&c4.as_pointer()); ({ MoveAssignable::move_assign(&c4.as_pointer(), c3.as_pointer()) }); assert!( ({ @@ -908,27 +894,27 @@ fn main_0() -> i32 { && (({ (*h2.borrow()).p.clone() }.as_pointer()).is_null()) ); let t1: Value = Rc::new(RefCell::new(::zero_init())); - HasSeesThisImpl::construct_1(&t1.as_pointer()); + DefaultConstructible::default_constructor(&t1.as_pointer()); let t2: Value = Rc::new(RefCell::new(::zero_init())); - HasSeesThisImpl::construct_1(&t2.as_pointer()); + DefaultConstructible::default_constructor(&t2.as_pointer()); let t3: Value = Rc::new(RefCell::new(::zero_init())); - HasSeesThisImpl::construct_1(&t3.as_pointer()); + DefaultConstructible::default_constructor(&t3.as_pointer()); ({ MoveAssignable::move_assign(&t2.as_pointer(), t1.as_pointer()) }); assert!(({ { (*t2.borrow()).s.self_.clone() } } == { (field_ptr!(t2.as_pointer(), s)) })); ({ CopyAssignable::copy_assign(&t3.as_pointer(), t2.as_pointer()) }); assert!(({ { (*t3.borrow()).s.self_.clone() } } == { (field_ptr!(t3.as_pointer(), s)) })); let k1: Value = Rc::new(RefCell::new(::zero_init())); - HasCountedImpl::construct_1(&k1.as_pointer()); + DefaultConstructible::default_constructor(&k1.as_pointer()); let k2: Value = Rc::new(RefCell::new(::zero_init())); MoveConstructible::move_constructor(&k2.as_pointer(), { k1.as_pointer() }); assert!(({ (*k2.borrow()).c.moves } == 1)); let k3: Value = Rc::new(RefCell::new(::zero_init())); - HasCountedImpl::construct_1(&k3.as_pointer()); + DefaultConstructible::default_constructor(&k3.as_pointer()); ({ MoveAssignable::move_assign(&k3.as_pointer(), k2.as_pointer()) }); assert!(({ (*k3.borrow()).c.moves } == 2)); { let d: Value = Rc::new(RefCell::new(::zero_init())); - CtorSeesThisImpl::construct_2(&d.as_pointer()); + DefaultConstructible::default_constructor(&d.as_pointer()); assert!(({ { (*d.borrow()).self_.clone() } } == { (d.as_pointer()) })); let e: Value = Rc::new(RefCell::new(::zero_init())); CopyConstructible::copy_constructor(&e.as_pointer(), { d.as_pointer() }); @@ -940,7 +926,7 @@ fn main_0() -> i32 { && ({ (*f.borrow()).id } == 3) ); let h1: Value = Rc::new(RefCell::new(::zero_init())); - HasCtorSeesThisImpl::construct_1(&h1.as_pointer()); + DefaultConstructible::default_constructor(&h1.as_pointer()); assert!(({ { (*h1.borrow()).x.self_.clone() } } == { (field_ptr!(h1.as_pointer(), x)) })); let h2: Value = Rc::new(RefCell::new(::zero_init())); CopyConstructible::copy_constructor(&h2.as_pointer(), { h1.as_pointer() }); @@ -953,7 +939,7 @@ fn main_0() -> i32 { ({ CopyAssignable::copy_assign(&h2.as_pointer(), h1.as_pointer()) }); assert!(({ { (*h2.borrow()).x.self_.clone() } } == { (field_ptr!(h2.as_pointer(), x)) })); let i: Value = Rc::new(RefCell::new(::zero_init())); - InitsCtorSeesThisImpl::construct(&i.as_pointer()); + DefaultConstructible::default_constructor(&i.as_pointer()); assert!( ({ { (*i.borrow()).x.self_.clone() } } == { (field_ptr!(i.as_pointer(), x)) }) && ({ (*i.borrow()).x.id } == 1) @@ -987,11 +973,11 @@ fn main_0() -> i32 { && ({ { (*o2.borrow()).x.self_.clone() } } == { (field_ptr!(o2.as_pointer(), x)) }) ); let a1: Value = Rc::new(RefCell::new(::zero_init())); - OutOfLineAssignImpl::construct_1(&a1.as_pointer()); + DefaultConstructible::default_constructor(&a1.as_pointer()); let a2: Value = Rc::new(RefCell::new(::zero_init())); - OutOfLineAssignImpl::construct_1(&a2.as_pointer()); + DefaultConstructible::default_constructor(&a2.as_pointer()); let a3: Value = Rc::new(RefCell::new(::zero_init())); - OutOfLineAssignImpl::construct_1(&a3.as_pointer()); + DefaultConstructible::default_constructor(&a3.as_pointer()); (*a1.borrow_mut()).v = 3; { let __a1 = 4; @@ -1035,34 +1021,12 @@ impl BufferImpl for Ptr { }; } } -pub trait CopyableImpl { - fn construct_1(&self); -} -impl CopyableImpl for Ptr { - fn construct_1(&self) { - field!((*self), data).write(Vec::new()); - } -} -pub trait Counted_int_Impl { - fn construct(&self); -} -impl Counted_int_Impl for Ptr { - fn construct(&self) { - field!((*self), v).write(0_i32); - field!((*self), moves).write(0); - } -} pub trait CtorSeesThisImpl { - fn construct_2(&self); fn construct_1(&self, id: i32); } impl CtorSeesThisImpl for Ptr { - fn construct_2(&self) { - field!((*self), self_).write((*self).clone()); - field!((*self), id).write(0); - } fn construct_1(&self, mut id: i32) { - CtorSeesThisImpl::construct_2(self); + DefaultConstructible::default_constructor(self); field!((*self), id).write(id); } } @@ -1084,33 +1048,6 @@ impl ExplicitImpl for Ptr { field!((*self), arr).write(Box::new([v, (v + 1)])); } } -pub trait HasCountedImpl { - fn construct_1(&self); -} -impl HasCountedImpl for Ptr { - fn construct_1(&self) { - Counted_int_Impl::construct(&field_ptr!(self, c)); - field!((*self), w).write(Vec::new()); - } -} -pub trait HasCtorSeesThisImpl { - fn construct_1(&self); -} -impl HasCtorSeesThisImpl for Ptr { - fn construct_1(&self) { - CtorSeesThisImpl::construct_2(&field_ptr!(self, x)); - field!((*self), v).write(Vec::new()); - } -} -pub trait HasSeesThisImpl { - fn construct_1(&self); -} -impl HasSeesThisImpl for Ptr { - fn construct_1(&self) { - SeesThisImpl::construct_1(&field_ptr!(self, s)); - field!((*self), v).write(Vec::new()); - } -} pub trait HolderImpl { fn construct(&self, v: i32); } @@ -1121,53 +1058,15 @@ impl HolderImpl for Ptr { field!((*self), p).write(None); } } -pub trait InitsCtorSeesThisImpl { - fn construct(&self); -} -impl InitsCtorSeesThisImpl for Ptr { - fn construct(&self) { - CtorSeesThisImpl::construct_1(&field_ptr!(self, x), { 1 }); - CtorSeesThisImpl::construct_1(&field_ptr!(self, y), { 2 }); - } -} -pub trait OutOfLineAssignImpl { - fn construct_1(&self); -} -impl OutOfLineAssignImpl for Ptr { - fn construct_1(&self) { - SeesThisImpl::construct_1(&field_ptr!(self, s)); - field!((*self), v).write(1); - field!((*self), w).write(Vec::new()); - } -} pub trait OutOfLineDefaultedImpl { fn construct(&self); } impl OutOfLineDefaultedImpl for Ptr { fn construct(&self) { - CtorSeesThisImpl::construct_2(&field_ptr!(self, x)); + DefaultConstructible::default_constructor(&field_ptr!(self, x)); field!((*self), v).write(1); } } -pub trait OwnerImpl { - fn construct_1(&self); -} -impl OwnerImpl for Ptr { - fn construct_1(&self) { - field!((*self), data).write(Vec::new()); - field!((*self), n).write(0_i32); - field!((*self), arr).write((0..2).map(|_| 0_i32).collect::>()); - field!((*self), p).write(None); - } -} -pub trait SeesThisImpl { - fn construct_1(&self); -} -impl SeesThisImpl for Ptr { - fn construct_1(&self) { - field!((*self), self_).write(Ptr::::null()); - } -} 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 3aaca65469..cb3fa5660b 100644 --- a/tests/unit/out/refcount/copy_move_deleted.rs +++ b/tests/unit/out/refcount/copy_move_deleted.rs @@ -42,6 +42,11 @@ pub struct PrivateCopy { #[offset(0)] pub v: i32, } +impl DefaultConstructible for PrivateCopy { + fn default_constructor(this: &Ptr) { + field!((*this), v).write(0); + } +} impl MoveConstructible for PrivateCopy { fn move_constructor(this: &Ptr, o: Ptr) { field!((*this), v).write(o.with(|__s| __s.v)); @@ -55,19 +60,12 @@ impl MoveAssignable for PrivateCopy { return (*this).clone(); } } -impl DefaultConstructible for PrivateCopy { - fn default_constructor(this: &Ptr) { - { - PrivateCopyImpl::construct(this); - } - } -} impl Default for PrivateCopy { fn default() -> Self { { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - PrivateCopyImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -81,9 +79,7 @@ pub struct Immovable { } impl DefaultConstructible for Immovable { fn default_constructor(this: &Ptr) { - { - ImmovableImpl::construct(this); - } + field!((*this), v).write(0); } } impl Default for Immovable { @@ -91,7 +87,7 @@ impl Default for Immovable { { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - ImmovableImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -129,9 +125,7 @@ pub struct VecHolder { } impl DefaultConstructible for VecHolder { fn default_constructor(this: &Ptr) { - { - VecHolderImpl::construct_1(this); - } + field!((*this), items).write(Vec::new()); } } pub fn bump_0(mut p: Ptr) { @@ -155,7 +149,7 @@ fn main_0() -> i32 { ({ bump_0((a.as_pointer())) }); assert!(({ (*a.borrow()).v } == 2)); let p: Value = Rc::new(RefCell::new(::zero_init())); - PrivateCopyImpl::construct(&p.as_pointer()); + DefaultConstructible::default_constructor(&p.as_pointer()); (*p.borrow_mut()).v = 3; let q: Value = Rc::new(RefCell::new(::zero_init())); MoveConstructible::move_constructor(&q.as_pointer(), { p.as_pointer() }); @@ -163,7 +157,7 @@ fn main_0() -> i32 { ({ 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(::zero_init())); - ImmovableImpl::construct(&im.as_pointer()); + DefaultConstructible::default_constructor(&im.as_pointer()); (*im.borrow_mut()).v = 4; ({ bump_ref_1(im.as_pointer()) }); let mut pim: Ptr = (im.as_pointer()); @@ -183,7 +177,7 @@ fn main_0() -> i32 { && ({ (*c.borrow()).inner.v } == 0) ); let h: Value = Rc::new(RefCell::new(::zero_init())); - VecHolderImpl::construct_1(&h.as_pointer()); + DefaultConstructible::default_constructor(&h.as_pointer()); let h2: Value = Rc::new(RefCell::new(::zero_init())); MoveConstructible::move_constructor(&h2.as_pointer(), { h.as_pointer() }); assert!(({ ((*h2.borrow()).items.len() == 0_usize) })); @@ -199,14 +193,6 @@ impl CopyConstructible for PrivateCopy { unreachable!("PrivateCopy::copy_constructor is never defined") } } -pub trait ImmovableImpl { - fn construct(&self); -} -impl ImmovableImpl for Ptr { - fn construct(&self) { - field!((*self), v).write(0); - } -} pub trait NoCopyImpl { fn construct(&self, v: i32); } @@ -215,20 +201,4 @@ impl NoCopyImpl for Ptr { field!((*self), v).write(v); } } -pub trait PrivateCopyImpl { - fn construct(&self); -} -impl PrivateCopyImpl for Ptr { - fn construct(&self) { - field!((*self), v).write(0); - } -} -pub trait VecHolderImpl { - fn construct_1(&self); -} -impl VecHolderImpl for Ptr { - fn construct_1(&self) { - field!((*self), items).write(Vec::new()); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/default.rs b/tests/unit/out/refcount/default.rs index 8525663eef..9d09b432d3 100644 --- a/tests/unit/out/refcount/default.rs +++ b/tests/unit/out/refcount/default.rs @@ -7,15 +7,9 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - DefaultConstructible, - TriviallyCopyable, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, )] +#[memberwise(default_constructor)] #[byte_size(144)] pub struct Pointers { #[offset(0)] @@ -53,15 +47,9 @@ impl Default for Pointers { } } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - DefaultConstructible, - TriviallyCopyable, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, )] +#[memberwise(default_constructor)] #[byte_size(440)] pub struct SmallArrays { #[offset(0)] @@ -97,15 +85,9 @@ impl Default for SmallArrays { } } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - DefaultConstructible, - TriviallyCopyable, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, )] +#[memberwise(default_constructor)] #[byte_size(132)] pub struct BigArray { #[offset(0)] diff --git a/tests/unit/out/refcount/default_in_statics.rs b/tests/unit/out/refcount/default_in_statics.rs index 2e3fd971b0..f770978730 100644 --- a/tests/unit/out/refcount/default_in_statics.rs +++ b/tests/unit/out/refcount/default_in_statics.rs @@ -13,10 +13,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(16)] pub struct Inner { #[offset(0)] @@ -26,15 +27,9 @@ pub struct Inner { pub name: Ptr, } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - DefaultConstructible, - TriviallyCopyable, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, )] +#[memberwise(default_constructor)] #[byte_size(88)] pub struct Outer { #[offset(0)] @@ -87,10 +82,11 @@ impl Default for Outer { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 a52965372c..ffe3b3dc2a 100644 --- a/tests/unit/out/refcount/delete_array_order.rs +++ b/tests/unit/out/refcount/delete_array_order.rs @@ -13,13 +13,12 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(copy_assign)] +#[memberwise(default_constructor, copy_assign)] #[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 165f47cec7..14bd438aaf 100644 --- a/tests/unit/out/refcount/destructor.rs +++ b/tests/unit/out/refcount/destructor.rs @@ -16,13 +16,12 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(copy_assign)] +#[memberwise(copy_assign, default_constructor)] #[byte_size(1)] pub struct S {} impl Destructible for S { @@ -38,13 +37,12 @@ impl Destructible for S { VaArg, FnPtrArg, Destructible, - DefaultConstructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(copy_assign)] +#[memberwise(default_constructor, copy_assign)] #[byte_size(1)] pub struct Defaulted { #[offset(0)] @@ -60,14 +58,13 @@ pub struct Defaulted { VaArg, FnPtrArg, Destructible, - DefaultConstructible, Memberwise, CopyConstructible, MoveConstructible, Swappable, Default, )] -#[memberwise(move_assign, copy_assign)] +#[memberwise(move_assign, default_constructor, copy_assign)] #[byte_size(1)] pub struct Middle { #[offset(0)] @@ -83,14 +80,13 @@ pub struct Middle { VaArg, FnPtrArg, Destructible, - DefaultConstructible, Memberwise, CopyConstructible, MoveConstructible, Swappable, Default, )] -#[memberwise(copy_assign, move_assign)] +#[memberwise(default_constructor, copy_assign, move_assign)] #[byte_size(1)] pub struct Outer { #[offset(0)] @@ -106,13 +102,12 @@ pub struct Outer { VaArg, FnPtrArg, Destructible, - DefaultConstructible, Memberwise, CopyConstructible, MoveConstructible, Swappable, )] -#[memberwise(move_assign, copy_assign)] +#[memberwise(move_assign, default_constructor, copy_assign)] #[byte_size(3)] pub struct ArrayMember { #[offset(0)] @@ -137,13 +132,12 @@ impl Default for ArrayMember { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(copy_assign)] +#[memberwise(default_constructor, copy_assign)] #[byte_size(1)] pub struct EmptyBody { #[offset(0)] @@ -162,13 +156,12 @@ impl Destructible for EmptyBody { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(copy_assign)] +#[memberwise(default_constructor, copy_assign)] #[byte_size(1)] pub struct Templated_char_ { #[offset(0)] @@ -191,13 +184,12 @@ impl Destructible for Templated_char_ { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(copy_assign)] +#[memberwise(default_constructor, copy_assign)] #[byte_size(4)] pub struct Templated_int_ { #[offset(0)] @@ -220,13 +212,12 @@ impl Destructible for Templated_int_ { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(copy_assign)] +#[memberwise(default_constructor, copy_assign)] #[byte_size(4)] pub struct Copied { #[offset(0)] @@ -251,13 +242,12 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(copy_assign)] +#[memberwise(copy_assign, default_constructor)] #[byte_size(4)] pub struct Tagged { #[offset(0)] @@ -278,14 +268,13 @@ impl Destructible for Tagged { VaArg, FnPtrArg, Destructible, - DefaultConstructible, Memberwise, CopyConstructible, MoveConstructible, Swappable, Default, )] -#[memberwise(move_assign, copy_assign)] +#[memberwise(move_assign, default_constructor, copy_assign)] #[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 1850b9c3e2..a08a6c7ec3 100644 --- a/tests/unit/out/refcount/destructor_params.rs +++ b/tests/unit/out/refcount/destructor_params.rs @@ -19,13 +19,12 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(copy_assign)] +#[memberwise(default_constructor, copy_assign)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/destructor_temporaries.rs b/tests/unit/out/refcount/destructor_temporaries.rs index 14cb4a6600..a68fa96d27 100644 --- a/tests/unit/out/refcount/destructor_temporaries.rs +++ b/tests/unit/out/refcount/destructor_temporaries.rs @@ -19,13 +19,12 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(copy_assign)] +#[memberwise(copy_assign, default_constructor)] #[byte_size(4)] pub struct S { #[offset(0)] @@ -45,14 +44,13 @@ impl Destructible for S { VaArg, FnPtrArg, Destructible, - DefaultConstructible, Memberwise, CopyConstructible, MoveConstructible, Swappable, Default, )] -#[memberwise(move_assign, copy_assign)] +#[memberwise(move_assign, default_constructor, copy_assign)] #[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 6354f2a64e..b25f47850e 100644 --- a/tests/unit/out/refcount/doubly_linked_list.rs +++ b/tests/unit/out/refcount/doubly_linked_list.rs @@ -13,10 +13,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(24)] pub struct Node { #[offset(0)] diff --git a/tests/unit/out/refcount/enum_int_interop.rs b/tests/unit/out/refcount/enum_int_interop.rs index 93ff893eb2..4c360c6353 100644 --- a/tests/unit/out/refcount/enum_int_interop.rs +++ b/tests/unit/out/refcount/enum_int_interop.rs @@ -26,10 +26,11 @@ pub const Tag_TAG_TWO: Tag = 2; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 603aae5610..b4a52f1c63 100644 --- a/tests/unit/out/refcount/enum_underlying_type.rs +++ b/tests/unit/out/refcount/enum_underlying_type.rs @@ -33,9 +33,7 @@ pub struct HoldsEmpty { } impl DefaultConstructible for HoldsEmpty { fn default_constructor(this: &Ptr) { - { - HoldsEmptyImpl::construct_1(this); - } + field!((*this), e).write(::default()); } } impl Default for HoldsEmpty { @@ -79,18 +77,10 @@ fn main_0() -> i32 { assert!(((sc as i32) == -2_i32)); assert!((((Scoped_POS as i8) as i32) == 2)); let he: Value = Rc::new(RefCell::new(::zero_init())); - HoldsEmptyImpl::construct_1(&he.as_pointer()); + DefaultConstructible::default_constructor(&he.as_pointer()); assert!(!({ (*he.borrow()).e })); let mut ev: Empty = ::default(); assert!(((ev as i32) == ({ (*he.borrow()).e } as i32))); return 0; } -pub trait HoldsEmptyImpl { - fn construct_1(&self); -} -impl HoldsEmptyImpl for Ptr { - fn construct_1(&self) { - field!((*self), e).write(::default()); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/exprs.rs b/tests/unit/out/refcount/exprs.rs index db71fa3715..92c5f095c2 100644 --- a/tests/unit/out/refcount/exprs.rs +++ b/tests/unit/out/refcount/exprs.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct X { #[offset(0)] @@ -30,10 +31,11 @@ pub struct X { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 5062f26861..82827896d7 100644 --- a/tests/unit/out/refcount/fft.rs +++ b/tests/unit/out/refcount/fft.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(16)] pub struct Complex { #[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 d7afa27d5a..b97a6b3350 100644 --- a/tests/unit/out/refcount/field_array_elem_ptr.rs +++ b/tests/unit/out/refcount/field_array_elem_ptr.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct Point { #[offset(0)] @@ -26,15 +27,9 @@ pub struct Point { pub y: i32, } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - DefaultConstructible, - TriviallyCopyable, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, )] +#[memberwise(default_constructor)] #[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 f208012e53..32d8c6a0b2 100644 --- a/tests/unit/out/refcount/field_method_receiver.rs +++ b/tests/unit/out/refcount/field_method_receiver.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Counter { #[offset(0)] @@ -53,9 +54,14 @@ pub struct S { } impl DefaultConstructible for S { fn default_constructor(this: &Ptr) { - { - SImpl::construct_1(this); - } + field!((*this), tag).write(0_i32); + field!((*this), c).write(::default()); + field!((*this), arr).write( + (0..2) + .map(|_| ::default()) + .collect::>(), + ); + field!((*this), v).write(Vec::new()); } } impl Default for S { @@ -147,21 +153,10 @@ impl CounterImpl for Ptr { } pub trait SImpl { fn bump(&self); - fn construct_1(&self); } impl SImpl for Ptr { fn bump(&self) { ({ CounterImpl::add(&field_ptr!((*self), c), (*self).with(|__s| __s.tag)) }); } - fn construct_1(&self) { - field!((*self), tag).write(0_i32); - field!((*self), c).write(::default()); - field!((*self), arr).write( - (0..2) - .map(|_| ::default()) - .collect::>(), - ); - field!((*self), v).write(Vec::new()); - } } pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/field_pointers.rs b/tests/unit/out/refcount/field_pointers.rs index 44fb5c6208..792361dcb8 100644 --- a/tests/unit/out/refcount/field_pointers.rs +++ b/tests/unit/out/refcount/field_pointers.rs @@ -7,15 +7,9 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - DefaultConstructible, - TriviallyCopyable, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, )] +#[memberwise(default_constructor)] #[byte_size(12)] pub struct Inner { #[offset(0)] @@ -43,10 +37,11 @@ impl Default for Inner { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct Header { #[offset(0)] @@ -91,9 +86,12 @@ pub struct Outer { } impl DefaultConstructible for Outer { fn default_constructor(this: &Ptr) { - { - OuterImpl::construct_1(this); - } + field!((*this), x).write(0_i32); + field!((*this), inner).write(::default()); + field!((*this), items).write((0..3).map(|_| ::default()).collect::>()); + field!((*this), v).write(Vec::new()); + field!((*this), cursor).write(Ptr::::null()); + field!((*this), buf).write((0..4).map(|_| 0_i32).collect::>()); } } impl Default for Outer { @@ -251,7 +249,6 @@ pub trait OuterImpl { fn next(&self) -> i32; fn sum(&self) -> i32; fn push(&self, k: i32); - fn construct_1(&self); } impl OuterImpl for Ptr { fn next(&self) -> i32 { @@ -271,13 +268,5 @@ impl OuterImpl for Ptr { field!((*self), v).with_mut(|__v: &mut Vec| __v.push(__a1)) }; } - fn construct_1(&self) { - field!((*self), x).write(0_i32); - field!((*self), inner).write(::default()); - field!((*self), items).write((0..3).map(|_| ::default()).collect::>()); - field!((*self), v).write(Vec::new()); - field!((*self), cursor).write(Ptr::::null()); - field!((*self), buf).write((0..4).map(|_| 0_i32).collect::>()); - } } 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 e3534b6121..8dc4a853d1 100644 --- a/tests/unit/out/refcount/field_pointers_malloced_struct.rs +++ b/tests/unit/out/refcount/field_pointers_malloced_struct.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(12)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/find.rs b/tests/unit/out/refcount/find.rs index 770723db7b..dc45f81270 100644 --- a/tests/unit/out/refcount/find.rs +++ b/tests/unit/out/refcount/find.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct P { #[offset(0)] diff --git a/tests/unit/out/refcount/fn_ptr_cast.rs b/tests/unit/out/refcount/fn_ptr_cast.rs index 779ef32c2b..ea5b6fb237 100644 --- a/tests/unit/out/refcount/fn_ptr_cast.rs +++ b/tests/unit/out/refcount/fn_ptr_cast.rs @@ -31,10 +31,11 @@ pub fn test_double_cast_2() { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 aa8da0b587..c8dc28c3fa 100644 --- a/tests/unit/out/refcount/fn_ptr_stable_sort.rs +++ b/tests/unit/out/refcount/fn_ptr_stable_sort.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 5c8f81cb2f..a677ca0d15 100644 --- a/tests/unit/out/refcount/fn_ptr_struct.rs +++ b/tests/unit/out/refcount/fn_ptr_struct.rs @@ -13,10 +13,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(16)] pub struct Handler { #[offset(0)] @@ -39,10 +40,11 @@ pub fn negate_1(mut x: i32) -> i32 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct S {} impl S { diff --git a/tests/unit/out/refcount/fn_ptr_vtable.rs b/tests/unit/out/refcount/fn_ptr_vtable.rs index 2fe9e11060..75d3248f38 100644 --- a/tests/unit/out/refcount/fn_ptr_vtable.rs +++ b/tests/unit/out/refcount/fn_ptr_vtable.rs @@ -13,10 +13,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(24)] pub struct Vtable { #[offset(0)] diff --git a/tests/unit/out/refcount/for_body_destructor.rs b/tests/unit/out/refcount/for_body_destructor.rs index 0e8fc6ea03..6b0bccd3ea 100644 --- a/tests/unit/out/refcount/for_body_destructor.rs +++ b/tests/unit/out/refcount/for_body_destructor.rs @@ -13,13 +13,12 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(copy_assign)] +#[memberwise(default_constructor, copy_assign)] #[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 6fbfc5bf05..becc3fb3a8 100644 --- a/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs +++ b/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs @@ -30,9 +30,8 @@ pub struct S { } impl DefaultConstructible for S { fn default_constructor(this: &Ptr) { - { - SImpl::construct_1(this); - } + field!((*this), v).write(Vec::new()); + field!((*this), a).write(0_i32); } } pub fn main() { @@ -41,7 +40,7 @@ pub fn main() { } fn main_0() -> i32 { let s: Value = Rc::new(RefCell::new(::zero_init())); - SImpl::construct_1(&s.as_pointer()); + DefaultConstructible::default_constructor(&s.as_pointer()); { let __a1 = 1; (*s.borrow_mut()).v.push(__a1) @@ -55,13 +54,4 @@ fn main_0() -> i32 { } return 0; } -pub trait SImpl { - fn construct_1(&self); -} -impl SImpl for Ptr { - fn construct_1(&self) { - field!((*self), v).write(Vec::new()); - field!((*self), a).write(0_i32); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/friend.rs b/tests/unit/out/refcount/friend.rs index 7a0f68285e..d562161d3b 100644 --- a/tests/unit/out/refcount/friend.rs +++ b/tests/unit/out/refcount/friend.rs @@ -26,10 +26,11 @@ pub fn scaled_3(v: Ptr, mut k: f64) -> f64 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct V { #[offset(0)] @@ -51,10 +52,11 @@ pub fn get_4(w: Ptr) -> i32 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct W_int_ { #[offset(0)] @@ -71,10 +73,11 @@ pub fn get_5(w: Ptr) -> i64 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct W_long_ { #[offset(0)] @@ -88,10 +91,11 @@ pub struct W_long_ { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 2aac587de4..174aed4071 100644 --- a/tests/unit/out/refcount/function_overloading.rs +++ b/tests/unit/out/refcount/function_overloading.rs @@ -29,10 +29,11 @@ pub fn bar_4(x: Ptr) -> i32 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 1f7213625a..093f653c35 100644 --- a/tests/unit/out/refcount/global_call_temporaries.rs +++ b/tests/unit/out/refcount/global_call_temporaries.rs @@ -102,10 +102,11 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Item { #[offset(0)] diff --git a/tests/unit/out/refcount/global_non_const_init.rs b/tests/unit/out/refcount/global_non_const_init.rs index 7d5484777a..0ae7b12795 100644 --- a/tests/unit/out/refcount/global_non_const_init.rs +++ b/tests/unit/out/refcount/global_non_const_init.rs @@ -40,9 +40,7 @@ pub struct Ctor { } impl DefaultConstructible for Ctor { fn default_constructor(this: &Ptr) { - { - CtorImpl::construct_1(this); - } + field!((*this), v).write(({ next_0() })); } } impl Default for Ctor { @@ -50,7 +48,7 @@ impl Default for Ctor { { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - CtorImpl::construct_1(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -59,14 +57,14 @@ impl Default for Ctor { thread_local!( pub static default_ctor_7: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - CtorImpl::construct_1(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); ); thread_local!( pub static arg_ctor_8: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - CtorImpl::construct_2(&__v.as_pointer(), { 7 }); + CtorImpl::construct_1(&__v.as_pointer(), { 7 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); ); @@ -80,7 +78,7 @@ thread_local!( thread_local!( pub static inline_member_11: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - CtorImpl::construct_2(&__v.as_pointer(), { 5 }); + CtorImpl::construct_1(&__v.as_pointer(), { 5 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); ); @@ -92,10 +90,11 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct Holder {} thread_local!( @@ -110,7 +109,7 @@ thread_local!( thread_local!( static local_ctor_14: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - CtorImpl::construct_2(&__v.as_pointer(), { 3 }); + CtorImpl::construct_1(&__v.as_pointer(), { 3 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); ); @@ -127,9 +126,7 @@ impl Singleton { } impl DefaultConstructible for Singleton { fn default_constructor(this: &Ptr) { - { - SingletonImpl::construct(this); - } + field!((*this), hits).write(0); } } impl Default for Singleton { @@ -137,7 +134,7 @@ impl Default for Singleton { { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - SingletonImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -146,7 +143,7 @@ impl Default for Singleton { thread_local!( static s_15: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - SingletonImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); ); @@ -194,25 +191,13 @@ fn main_0() -> i32 { return 0; } pub trait CtorImpl { - fn construct_1(&self); - fn construct_2(&self, x: i32); + fn construct_1(&self, x: i32); } impl CtorImpl for Ptr { - fn construct_1(&self) { - field!((*self), v).write(({ next_0() })); - } - fn construct_2(&self, mut x: i32) { + fn construct_1(&self, mut x: i32) { field!((*self), v).write(x); } } -pub trait SingletonImpl { - fn construct(&self); -} -impl SingletonImpl for Ptr { - fn construct(&self) { - field!((*self), hits).write(0); - } -} pub fn __cpp2rust_init_globals() { let _ = signature_3.with(|_| ()); let _ = single_4.with(|_| ()); diff --git a/tests/unit/out/refcount/global_pointers.rs b/tests/unit/out/refcount/global_pointers.rs index 687fb4e9b4..ecbab311d4 100644 --- a/tests/unit/out/refcount/global_pointers.rs +++ b/tests/unit/out/refcount/global_pointers.rs @@ -13,10 +13,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 698c33abfe..102c29538c 100644 --- a/tests/unit/out/refcount/global_without_initializer.rs +++ b/tests/unit/out/refcount/global_without_initializer.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/huffman.rs b/tests/unit/out/refcount/huffman.rs index a710ae792c..6dcb8dc2e4 100644 --- a/tests/unit/out/refcount/huffman.rs +++ b/tests/unit/out/refcount/huffman.rs @@ -13,10 +13,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(24)] pub struct MinHeapNode { #[offset(0)] @@ -71,9 +72,11 @@ pub struct MinHeap { } impl DefaultConstructible for MinHeap { fn default_constructor(this: &Ptr) { - { - MinHeapImpl::construct_1(this); - } + field!((*this), size).write(0_i32); + field!((*this), capacity).write(0_i32); + field!((*this), arr).write(None); + field!((*this), next).write(0_i32); + field!((*this), alloc).write(None); } } pub fn AllocMinHeap_1(mut capacity: i32) -> Option> { @@ -292,7 +295,6 @@ pub trait MinHeapImpl { freq: Ptr>>>, n: i32, ); - fn construct_1(&self); } impl MinHeapImpl for Ptr { fn Alloc(&self, mut data: i8, mut freq: i32) -> Ptr { @@ -458,13 +460,6 @@ impl MinHeapImpl for Ptr { } } } - fn construct_1(&self) { - field!((*self), size).write(0_i32); - field!((*self), capacity).write(0_i32); - field!((*self), arr).write(None); - field!((*self), next).write(0_i32); - field!((*self), alloc).write(None); - } } pub trait MinHeapNodeImpl { fn IsLeaf(&self) -> bool; 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 81b6299b52..244b3a8535 100644 --- a/tests/unit/out/refcount/immutable-deref-on-func-call.rs +++ b/tests/unit/out/refcount/immutable-deref-on-func-call.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 b72b549e06..2416d2bca3 100644 --- a/tests/unit/out/refcount/implicit_autoref.rs +++ b/tests/unit/out/refcount/implicit_autoref.rs @@ -28,9 +28,7 @@ pub struct Holder { } impl DefaultConstructible for Holder { fn default_constructor(this: &Ptr) { - { - HolderImpl::construct_1(this); - } + field!((*this), v).write(Vec::new()); } } pub fn write_through_0(mut p: Ptr) { @@ -54,7 +52,7 @@ fn main_0() -> i32 { let mut a: i32 = (index!(p, 0_usize).read()); index!(p, 1_usize).write(30); let h: Value = Rc::new(RefCell::new(::zero_init())); - HolderImpl::construct_1(&h.as_pointer()); + DefaultConstructible::default_constructor(&h.as_pointer()); { let __a1 = 40; (*h.borrow_mut()).v.push(__a1) @@ -83,12 +81,4 @@ fn main_0() -> i32 { assert!(((index!(p, 0_usize).read()) == 42)); return 0; } -pub trait HolderImpl { - fn construct_1(&self); -} -impl HolderImpl for Ptr { - fn construct_1(&self) { - field!((*self), v).write(Vec::new()); - } -} 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 a714669f83..7dd361a93b 100644 --- a/tests/unit/out/refcount/in_class_field_initializer.rs +++ b/tests/unit/out/refcount/in_class_field_initializer.rs @@ -16,9 +16,8 @@ pub struct Inner { } impl DefaultConstructible for Inner { fn default_constructor(this: &Ptr) { - { - InnerImpl::construct_1(this); - } + field!((*this), x).write(3); + field!((*this), y).write(4); } } impl Default for Inner { @@ -42,9 +41,10 @@ pub struct S { } impl DefaultConstructible for S { fn default_constructor(this: &Ptr) { - { - SImpl::construct_1(this); - } + field!((*this), a).write(1); + field!((*this), b).write(2_i8); + field!((*this), c).write(::default()); + DefaultConstructible::default_constructor(&field_ptr!(this, d)); } } impl Default for S { @@ -88,7 +88,7 @@ pub fn main() { } fn main_0() -> i32 { let s: Value = Rc::new(RefCell::new(::zero_init())); - SImpl::construct_1(&s.as_pointer()); + DefaultConstructible::default_constructor(&s.as_pointer()); assert!(({ (*s.borrow()).a } == 1)); assert!((({ (*s.borrow()).b } as i32) == 2)); assert!(({ (*s.borrow()).c.x } == 3)); @@ -110,24 +110,4 @@ impl Boxed_int_Impl for Ptr { field!((*self), tag).write(t); } } -pub trait InnerImpl { - fn construct_1(&self); -} -impl InnerImpl for Ptr { - fn construct_1(&self) { - field!((*self), x).write(3); - field!((*self), y).write(4); - } -} -pub trait SImpl { - fn construct_1(&self); -} -impl SImpl for Ptr { - fn construct_1(&self) { - field!((*self), a).write(1); - field!((*self), b).write(2_i8); - field!((*self), c).write(::default()); - InnerImpl::construct_1(&field_ptr!(self, d)); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/init.rs b/tests/unit/out/refcount/init.rs index 89f9be2d87..c4aea1f864 100644 --- a/tests/unit/out/refcount/init.rs +++ b/tests/unit/out/refcount/init.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 5804dd5f32..9814254946 100644 --- a/tests/unit/out/refcount/init_list.rs +++ b/tests/unit/out/refcount/init_list.rs @@ -17,10 +17,11 @@ pub fn f_0(list: Vec) { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct Pair { #[offset(0)] @@ -37,9 +38,7 @@ pub struct Holder { } impl DefaultConstructible for Holder { fn default_constructor(this: &Ptr) { - { - HolderImpl::construct_1(this); - } + field!((*this), p).write(Pair { a: 0, b: 0 }); } } impl Default for Holder { @@ -62,9 +61,7 @@ pub struct Seven { } impl DefaultConstructible for Seven { fn default_constructor(this: &Ptr) { - { - SevenImpl::construct_1(this); - } + field!((*this), v).write(7); } } impl Default for Seven { @@ -86,7 +83,7 @@ fn main_0() -> i32 { ({ f_0(Vec::from([1, 2, 3, 4])) }); let p: Value = Rc::new(RefCell::new(Pair { a: 1, b: 2 })); let h: Value = Rc::new(RefCell::new(::zero_init())); - HolderImpl::construct_1(&h.as_pointer()); + DefaultConstructible::default_constructor(&h.as_pointer()); ({ HolderImpl::operator_assign_1(&h.as_pointer(), p.as_pointer()) }); assert!(({ (*h.borrow()).p.a } == 1) && ({ (*h.borrow()).p.b } == 2)); assert!((({ sum_1(p.as_pointer(),) }) == 3)); @@ -104,23 +101,11 @@ fn main_0() -> i32 { } pub trait HolderImpl { fn operator_assign_1(&self, o: Ptr) -> Ptr; - fn construct_1(&self); } impl HolderImpl for Ptr { fn operator_assign_1(&self, o: Ptr) -> Ptr { field!((*self), p).write({ (*o.upgrade().deref()) }); return (*self).clone(); } - fn construct_1(&self) { - field!((*self), p).write(Pair { a: 0, b: 0 }); - } -} -pub trait SevenImpl { - fn construct_1(&self); -} -impl SevenImpl for Ptr { - fn construct_1(&self) { - field!((*self), v).write(7); - } } 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 f26a59a08b..9e363fbfcf 100644 --- a/tests/unit/out/refcount/inline_container_fields.rs +++ b/tests/unit/out/refcount/inline_container_fields.rs @@ -33,9 +33,9 @@ pub struct Elem { } impl DefaultConstructible for Elem { fn default_constructor(this: &Ptr) { - { - ElemImpl::construct_1(this); - } + field!((*this), id).write(0_i32); + field!((*this), hist).write((0..4).map(|_| 0_i32).collect::>()); + field!((*this), coeffs).write(Vec::new()); } } impl Default for Elem { @@ -83,9 +83,17 @@ pub struct State { } impl DefaultConstructible for State { fn default_constructor(this: &Ptr) { - { - StateImpl::construct_1(this); - } + field!((*this), count).write(0_i32); + field!((*this), grid).write( + (0..2) + .map(|_| (0..3).map(|_| 0_i32).collect::>()) + .collect::]>>(), + ); + field!((*this), arr).write(Box::<[i32]>::from(std::array::from_fn::<_, 3, _>(|_| { + 0_i32 + }))); + field!((*this), elems).write(Vec::new()); + field!((*this), rows).write(Vec::new()); } } impl Default for State { @@ -171,6 +179,11 @@ pub struct Counted { #[offset(0)] pub v: i32, } +impl DefaultConstructible for Counted { + fn default_constructor(this: &Ptr) { + field!((*this), v).write(0); + } +} impl CopyConstructible for Counted { fn copy_constructor(this: &Ptr, o: Ptr) { field!((*this), v).write(o.with(|__s| __s.v)); @@ -207,13 +220,6 @@ impl Clone for Counted { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } -impl DefaultConstructible for Counted { - fn default_constructor(this: &Ptr) { - { - CountedImpl::construct(this); - } - } -} impl Default for Counted { fn default() -> Self { { Counted { v: 0 } } @@ -487,42 +493,6 @@ fn main_0() -> i32 { ); return 0; } -pub trait CountedImpl { - fn construct(&self); -} -impl CountedImpl for Ptr { - fn construct(&self) { - field!((*self), v).write(0); - } -} -pub trait ElemImpl { - fn construct_1(&self); -} -impl ElemImpl for Ptr { - fn construct_1(&self) { - field!((*self), id).write(0_i32); - field!((*self), hist).write((0..4).map(|_| 0_i32).collect::>()); - field!((*self), coeffs).write(Vec::new()); - } -} -pub trait StateImpl { - fn construct_1(&self); -} -impl StateImpl for Ptr { - fn construct_1(&self) { - field!((*self), count).write(0_i32); - field!((*self), grid).write( - (0..2) - .map(|_| (0..3).map(|_| 0_i32).collect::>()) - .collect::]>>(), - ); - field!((*self), arr).write(Box::<[i32]>::from(std::array::from_fn::<_, 3, _>(|_| { - 0_i32 - }))); - field!((*self), elems).write(Vec::new()); - field!((*self), rows).write(Vec::new()); - } -} 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 af97726dca..d879e19e3c 100644 --- a/tests/unit/out/refcount/kruskal.rs +++ b/tests/unit/out/refcount/kruskal.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(16)] pub struct Edge { #[offset(0)] @@ -127,9 +128,9 @@ pub struct DisjointSet { } impl DefaultConstructible for DisjointSet { fn default_constructor(this: &Ptr) { - { - DisjointSetImpl::construct_1(this); - } + field!((*this), rank).write(None); + field!((*this), parent).write(None); + field!((*this), n).write(0_i32); } } #[derive( @@ -148,9 +149,9 @@ pub struct Graph { } impl DefaultConstructible for Graph { fn default_constructor(this: &Ptr) { - { - GraphImpl::construct_1(this); - } + field!((*this), edges).write(None); + field!((*this), V).write(0_i32); + field!((*this), E).write(0_i32); } } pub fn MSTKruskal_2(graph: Ptr) -> f64 { @@ -265,7 +266,6 @@ pub trait DisjointSetImpl { fn makeSet(&self); fn find(&self, x: i32) -> i32; fn merge(&self, x: i32, y: i32); - fn construct_1(&self); } impl DisjointSetImpl for Ptr { fn makeSet(&self) { @@ -376,20 +376,5 @@ impl DisjointSetImpl for Ptr { ); } } - fn construct_1(&self) { - field!((*self), rank).write(None); - field!((*self), parent).write(None); - field!((*self), n).write(0_i32); - } -} -pub trait GraphImpl { - fn construct_1(&self); -} -impl GraphImpl for Ptr { - fn construct_1(&self) { - field!((*self), edges).write(None); - field!((*self), V).write(0_i32); - field!((*self), E).write(0_i32); - } } 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 6b2d5258a2..9cce0c8b54 100644 --- a/tests/unit/out/refcount/lambda_as_field.rs +++ b/tests/unit/out/refcount/lambda_as_field.rs @@ -13,12 +13,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, Memberwise, CopyConstructible, Movable, )] -#[memberwise(copy_assign)] +#[memberwise(default_constructor, copy_assign)] #[byte_size(1)] pub struct Guard__lambda_at_lambda_as_field_cpp_34_13__ { #[offset(0)] @@ -64,15 +63,9 @@ impl Destructible for Guard__lambda_at_lambda_as_field_cpp_45_13__ { } } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - DefaultConstructible, - TriviallyCopyable, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct Holder__lambda_at_lambda_as_field_cpp_39_12__ { #[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 fcab8b6ae8..fd30292c1b 100644 --- a/tests/unit/out/refcount/lambda_capture_copy_ctor.rs +++ b/tests/unit/out/refcount/lambda_capture_copy_ctor.rs @@ -24,6 +24,12 @@ pub struct Counted { #[offset(4)] pub moves: i32, } +impl DefaultConstructible for Counted { + fn default_constructor(this: &Ptr) { + field!((*this), copies).write(0); + field!((*this), moves).write(0); + } +} impl CopyConstructible for Counted { fn copy_constructor(this: &Ptr, o: Ptr) { field!((*this), copies).write((o.with(|__s| __s.copies) + 1)); @@ -47,19 +53,12 @@ impl Clone for Counted { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } -impl DefaultConstructible for Counted { - fn default_constructor(this: &Ptr) { - { - CountedImpl::construct(this); - } - } -} impl Default for Counted { fn default() -> Self { { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - CountedImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -73,6 +72,9 @@ thread_local!( )] #[byte_size(1)] pub struct Dropped {} +impl DefaultConstructible for Dropped { + fn default_constructor(this: &Ptr) {} +} impl CopyConstructible for Dropped { fn copy_constructor(this: &Ptr, _a0: Ptr) {} } @@ -92,19 +94,12 @@ impl Clone for Dropped { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } -impl DefaultConstructible for Dropped { - fn default_constructor(this: &Ptr) { - { - DroppedImpl::construct(this); - } - } -} impl Default for Dropped { fn default() -> Self { { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - DroppedImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -116,7 +111,7 @@ pub fn main() { } fn main_0() -> i32 { let c: Value = Rc::new(RefCell::new(::zero_init())); - CountedImpl::construct(&c.as_pointer()); + DefaultConstructible::default_constructor(&c.as_pointer()); let f: Value i32>> = Rc::new(RefCell::new(lambda!( { let c: Value = Rc::new(RefCell::new({ @@ -164,7 +159,7 @@ fn main_0() -> i32 { let arr: Value> = Rc::new(RefCell::new(Box::new( std::array::from_fn::<_, 2, _>(|_| { let __v: Value = Rc::new(RefCell::new(::zero_init())); - CountedImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() }), ))); @@ -196,7 +191,7 @@ fn main_0() -> i32 { { let d: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - DroppedImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); }, @@ -214,7 +209,7 @@ fn main_0() -> i32 { { let d: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - DroppedImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); }, @@ -232,7 +227,7 @@ fn main_0() -> i32 { { let d: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - DroppedImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() })); }, @@ -255,21 +250,6 @@ fn main_0() -> i32 { assert!((drops_0.with(|rc| *rc.borrow()) == 6)); return 0; } -pub trait CountedImpl { - fn construct(&self); -} -impl CountedImpl for Ptr { - fn construct(&self) { - field!((*self), copies).write(0); - field!((*self), moves).write(0); - } -} -pub trait DroppedImpl { - fn construct(&self); -} -impl DroppedImpl for Ptr { - fn construct(&self) {} -} 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 c3a99303f2..82eb224654 100644 --- a/tests/unit/out/refcount/lambda_capture_ref.rs +++ b/tests/unit/out/refcount/lambda_capture_ref.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 edeff6ad5e..1ab6eee6a9 100644 --- a/tests/unit/out/refcount/lambda_capture_star_this.rs +++ b/tests/unit/out/refcount/lambda_capture_star_this.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 a4555e1b08..b1e2c00fed 100644 --- a/tests/unit/out/refcount/lambda_capture_this.rs +++ b/tests/unit/out/refcount/lambda_capture_this.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 2ec6f7b430..cac2673b47 100644 --- a/tests/unit/out/refcount/lambda_capture_value.rs +++ b/tests/unit/out/refcount/lambda_capture_value.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 026656e22d..860e8394c0 100644 --- a/tests/unit/out/refcount/lambda_decltype_type.rs +++ b/tests/unit/out/refcount/lambda_decltype_type.rs @@ -21,9 +21,15 @@ pub struct Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { } impl DefaultConstructible for Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { fn default_constructor(this: &Ptr) { - { - Sorted__lambda_at_lambda_decltype_type_cpp_22_18__Impl::construct_1(this); - } + field!((*this), items).write((0..4).map(|_| 0_i32).collect::>()); + field!((*this), size).write(0); + field!((*this), cmp).write(FnPtr:: bool>::new( + |mut a: i32, mut b: i32| -> bool { + { + return (a > b); + } + }, + )); } } impl Default for Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { @@ -56,9 +62,15 @@ pub struct Sorted__lambda_at_lambda_decltype_type_cpp_19_23__ { } impl DefaultConstructible for Sorted__lambda_at_lambda_decltype_type_cpp_19_23__ { fn default_constructor(this: &Ptr) { - { - Sorted__lambda_at_lambda_decltype_type_cpp_19_23__Impl::construct_1(this); - } + field!((*this), items).write((0..4).map(|_| 0_i32).collect::>()); + field!((*this), size).write(0); + field!((*this), cmp).write(FnPtr:: bool>::new( + |mut a: i32, mut b: i32| -> bool { + { + return (a < b); + } + }, + )); } } impl Default for Sorted__lambda_at_lambda_decltype_type_cpp_19_23__ { @@ -92,7 +104,7 @@ fn main_0() -> i32 { let desc: Value = Rc::new(RefCell::new( ::zero_init(), )); - Sorted__lambda_at_lambda_decltype_type_cpp_22_18__Impl::construct_1(&desc.as_pointer()); + DefaultConstructible::default_constructor(&desc.as_pointer()); ({ Sorted__lambda_at_lambda_decltype_type_cpp_22_18__Impl::insert(&desc.as_pointer(), 2) }); ({ Sorted__lambda_at_lambda_decltype_type_cpp_22_18__Impl::insert(&desc.as_pointer(), 7) }); ({ Sorted__lambda_at_lambda_decltype_type_cpp_22_18__Impl::insert(&desc.as_pointer(), 4) }); @@ -102,7 +114,7 @@ fn main_0() -> i32 { let asc: Value = Rc::new(RefCell::new( ::zero_init(), )); - Sorted__lambda_at_lambda_decltype_type_cpp_19_23__Impl::construct_1(&asc.as_pointer()); + DefaultConstructible::default_constructor(&asc.as_pointer()); ({ Sorted__lambda_at_lambda_decltype_type_cpp_19_23__Impl::insert(&asc.as_pointer(), 2) }); ({ Sorted__lambda_at_lambda_decltype_type_cpp_19_23__Impl::insert(&asc.as_pointer(), 7) }); ({ Sorted__lambda_at_lambda_decltype_type_cpp_19_23__Impl::insert(&asc.as_pointer(), 4) }); @@ -142,7 +154,6 @@ fn main_0() -> i32 { } pub trait Sorted__lambda_at_lambda_decltype_type_cpp_19_23__Impl { fn insert(&self, v: i32); - fn construct_1(&self); } impl Sorted__lambda_at_lambda_decltype_type_cpp_19_23__Impl for Ptr @@ -162,21 +173,9 @@ impl Sorted__lambda_at_lambda_decltype_type_cpp_19_23__Impl array_elem!((*self), items, i).write(v); field!((*self), size).with_mut(|__v| __v.postfix_inc()); } - fn construct_1(&self) { - field!((*self), items).write((0..4).map(|_| 0_i32).collect::>()); - field!((*self), size).write(0); - field!((*self), cmp).write(FnPtr:: bool>::new( - |mut a: i32, mut b: i32| -> bool { - { - return (a < b); - } - }, - )); - } } pub trait Sorted__lambda_at_lambda_decltype_type_cpp_22_18__Impl { fn insert(&self, v: i32); - fn construct_1(&self); } impl Sorted__lambda_at_lambda_decltype_type_cpp_22_18__Impl for Ptr @@ -196,16 +195,5 @@ impl Sorted__lambda_at_lambda_decltype_type_cpp_22_18__Impl array_elem!((*self), items, i).write(v); field!((*self), size).with_mut(|__v| __v.postfix_inc()); } - fn construct_1(&self) { - field!((*self), items).write((0..4).map(|_| 0_i32).collect::>()); - field!((*self), size).write(0); - field!((*self), cmp).write(FnPtr:: bool>::new( - |mut a: i32, mut b: i32| -> bool { - { - return (a > b); - } - }, - )); - } } pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/lambda_generic_explicit_args.rs b/tests/unit/out/refcount/lambda_generic_explicit_args.rs index 97fd3c0b4e..a6d607d66f 100644 --- a/tests/unit/out/refcount/lambda_generic_explicit_args.rs +++ b/tests/unit/out/refcount/lambda_generic_explicit_args.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 c4b489743f..3b67ac708b 100644 --- a/tests/unit/out/refcount/lambda_immediate_init.rs +++ b/tests/unit/out/refcount/lambda_immediate_init.rs @@ -19,9 +19,17 @@ pub struct S { } impl DefaultConstructible for S { fn default_constructor(this: &Ptr) { - { - SImpl::construct_1(this); - } + field!((*this), j).write(10); + field!((*this), k).write( + (({ + FnPtr:: i32>::new(|| -> i32 { + { + return 3; + } + }) + .call() + }) + 1), + ); } } impl Default for S { @@ -84,7 +92,7 @@ fn main_0() -> i32 { ); assert!((({ pick_0(1,) }) == 1)); let s: Value = Rc::new(RefCell::new(::zero_init())); - SImpl::construct_1(&s.as_pointer()); + DefaultConstructible::default_constructor(&s.as_pointer()); assert!(({ (*s.borrow()).k } == 4)); assert!((g_1.with(|rc| *rc.borrow()) == 10)); let a: Value = Rc::new(RefCell::new(2)); @@ -104,24 +112,6 @@ fn main_0() -> i32 { assert!(({ ((*a.borrow()) == 3) })); return 0; } -pub trait SImpl { - fn construct_1(&self); -} -impl SImpl for Ptr { - fn construct_1(&self) { - field!((*self), j).write(10); - field!((*self), k).write( - (({ - FnPtr:: i32>::new(|| -> i32 { - { - return 3; - } - }) - .call() - }) + 1), - ); - } -} pub fn __cpp2rust_init_globals() { let _ = g_1.with(|_| ()); } diff --git a/tests/unit/out/refcount/lambda_nested.rs b/tests/unit/out/refcount/lambda_nested.rs index 1ad661608f..7e784f518b 100644 --- a/tests/unit/out/refcount/lambda_nested.rs +++ b/tests/unit/out/refcount/lambda_nested.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 944d9f7aee..cfb5fd6d93 100644 --- a/tests/unit/out/refcount/lambda_static_local.rs +++ b/tests/unit/out/refcount/lambda_static_local.rs @@ -86,10 +86,11 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 2bc803ebfb..05eebfa56c 100644 --- a/tests/unit/out/refcount/libc_struct_without_default.rs +++ b/tests/unit/out/refcount/libc_struct_without_default.rs @@ -31,9 +31,10 @@ pub struct UserDefined { } impl DefaultConstructible for UserDefined { fn default_constructor(this: &Ptr) { - { - UserDefinedImpl::construct_1(this); - } + field!((*this), a).write(Box::<[i32]>::from(std::array::from_fn::<_, 1, _>(|_| { + 0_i32 + }))); + field!((*this), v).write(Vec::new()); } } impl Default for UserDefined { @@ -47,15 +48,9 @@ impl Default for UserDefined { } } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - DefaultConstructible, - TriviallyCopyable, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, )] +#[memberwise(default_constructor)] #[byte_size(16)] pub struct FieldIsLibcType { #[offset(0)] @@ -97,7 +92,7 @@ fn main_0() -> i32 { (*st.borrow_mut()).st_size = (1024 as ::libc::off_t); assert!(({ (*st.borrow()).st_size } == (1024 as ::libc::off_t))); let ud: Value = Rc::new(RefCell::new(::zero_init())); - UserDefinedImpl::construct_1(&ud.as_pointer()); + DefaultConstructible::default_constructor(&ud.as_pointer()); elem!(field_ref!(ud.as_pointer(), a).decay(), 0_usize).write(3); assert!(((elem!(field_ref!(ud.as_pointer(), a).decay(), 0_usize).read()) == 3)); assert!(({ ((*ud.borrow()).v.len() == 0_usize) })); @@ -106,15 +101,4 @@ fn main_0() -> i32 { assert!(((filt.addr.sa_family as i32) == 2)); return 0; } -pub trait UserDefinedImpl { - fn construct_1(&self); -} -impl UserDefinedImpl for Ptr { - fn construct_1(&self) { - field!((*self), a).write(Box::<[i32]>::from(std::array::from_fn::<_, 1, _>(|_| { - 0_i32 - }))); - field!((*self), v).write(Vec::new()); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/linked_list.rs b/tests/unit/out/refcount/linked_list.rs index 82ddbb713d..a79de20e11 100644 --- a/tests/unit/out/refcount/linked_list.rs +++ b/tests/unit/out/refcount/linked_list.rs @@ -13,10 +13,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(16)] pub struct Node { #[offset(0)] diff --git a/tests/unit/out/refcount/local_record_template.rs b/tests/unit/out/refcount/local_record_template.rs index 64b84258ce..795fcb60c0 100644 --- a/tests/unit/out/refcount/local_record_template.rs +++ b/tests/unit/out/refcount/local_record_template.rs @@ -37,10 +37,11 @@ pub fn wrap_10(mut v: i64) -> i32 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Local_5 { #[offset(0)] @@ -54,10 +55,11 @@ pub struct Local_5 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct Local_7 { #[offset(0)] @@ -75,10 +77,11 @@ pub fn other_11() -> i32 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(16)] pub struct Local_1 { #[offset(0)] @@ -107,10 +110,11 @@ fn main_0() -> i32 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 07299b8ecd..560aa8aeb7 100644 --- a/tests/unit/out/refcount/map.rs +++ b/tests/unit/out/refcount/map.rs @@ -25,9 +25,8 @@ pub struct Point { } impl DefaultConstructible for Point { fn default_constructor(this: &Ptr) { - { - PointImpl::construct_1(this); - } + field!((*this), x).write(0); + field!((*this), y).write(0); } } impl Default for Point { @@ -35,7 +34,7 @@ impl Default for Point { { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - PointImpl::construct_1(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -740,7 +739,7 @@ fn main_0() -> i32 { Rc::new(RefCell::new(copy_constructed(key1.as_pointer().clone()))), Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - PointImpl::construct_2(&__v.as_pointer(), { 3 }, { 4 }); + PointImpl::construct_1(&__v.as_pointer(), { 3 }, { 4 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })), ) @@ -787,7 +786,7 @@ fn main_0() -> i32 { Rc::new(RefCell::new(({ (*key8.borrow()) }))), Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - PointImpl::construct_2(&__v.as_pointer(), { 5 }, { 6 }); + PointImpl::construct_1(&__v.as_pointer(), { 5 }, { 6 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })), ) @@ -1042,15 +1041,10 @@ fn main_0() -> i32 { return 0; } pub trait PointImpl { - fn construct_1(&self); - fn construct_2(&self, x: i32, y: i32); + fn construct_1(&self, x: i32, y: i32); } impl PointImpl for Ptr { - fn construct_1(&self) { - field!((*self), x).write(0); - field!((*self), y).write(0); - } - fn construct_2(&self, mut x: i32, mut y: i32) { + fn construct_1(&self, mut x: i32, mut y: i32) { field!((*self), x).write(x); field!((*self), y).write(y); } diff --git a/tests/unit/out/refcount/map_key_identity.rs b/tests/unit/out/refcount/map_key_identity.rs index 8c667383c7..47abbd3ee5 100644 --- a/tests/unit/out/refcount/map_key_identity.rs +++ b/tests/unit/out/refcount/map_key_identity.rs @@ -17,10 +17,11 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct Key { #[offset(0)] @@ -52,9 +53,8 @@ pub struct Mapped { } impl DefaultConstructible for Mapped { fn default_constructor(this: &Ptr) { - { - MappedImpl::construct(this); - } + field!((*this), value).write(0); + (*default_constructions_0.with(Value::clone).borrow_mut()).prefix_inc(); } } impl Default for Mapped { @@ -62,7 +62,7 @@ impl Default for Mapped { { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - MappedImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -446,15 +446,6 @@ fn main_0() -> i32 { }; return if ok { 0 } else { 1 }; } -pub trait MappedImpl { - fn construct(&self); -} -impl MappedImpl for Ptr { - fn construct(&self) { - field!((*self), value).write(0); - (*default_constructions_0.with(Value::clone).borrow_mut()).prefix_inc(); - } -} pub fn __cpp2rust_init_globals() { let _ = default_constructions_0.with(|_| ()); } diff --git a/tests/unit/out/refcount/map_try_emplace.rs b/tests/unit/out/refcount/map_try_emplace.rs index 0656a3bca4..c2be719489 100644 --- a/tests/unit/out/refcount/map_try_emplace.rs +++ b/tests/unit/out/refcount/map_try_emplace.rs @@ -36,6 +36,11 @@ pub struct Item { #[offset(0)] pub value: i32, } +impl DefaultConstructible for Item { + fn default_constructor(this: &Ptr) { + field!((*this), value).write(0); + } +} impl CopyConstructible for Item { fn copy_constructor(this: &Ptr, other: Ptr) { field!((*this), value).write(other.with(|__s| __s.value)); @@ -59,19 +64,12 @@ impl Clone for Item { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } -impl DefaultConstructible for Item { - fn default_constructor(this: &Ptr) { - { - ItemImpl::construct_2(this); - } - } -} impl Default for Item { fn default() -> Self { { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - ItemImpl::construct_2(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -89,9 +87,7 @@ pub struct RefItem { } impl DefaultConstructible for RefItem { fn default_constructor(this: &Ptr) { - { - RefItemImpl::construct_1(this); - } + field!((*this), value).write(0); } } impl Default for RefItem { @@ -99,7 +95,7 @@ impl Default for RefItem { { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - RefItemImpl::construct_1(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -568,7 +564,7 @@ fn main_0() -> i32 { Rc::new(RefCell::new(copy_constructed(key.as_pointer().clone()))), Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - RefItemImpl::construct_2(&__v.as_pointer(), { counter.as_pointer() }, { 5 }); + RefItemImpl::construct_1(&__v.as_pointer(), { counter.as_pointer() }, { 5 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })), ) @@ -590,7 +586,7 @@ fn main_0() -> i32 { Rc::new(RefCell::new(copy_constructed(key.as_pointer().clone()))), Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - RefItemImpl::construct_2(&__v.as_pointer(), { (__tmp_10).clone() }, { + RefItemImpl::construct_1(&__v.as_pointer(), { (__tmp_10).clone() }, { 2 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() @@ -623,7 +619,7 @@ fn main_0() -> i32 { Rc::new(RefCell::new(copy_constructed(key.as_pointer().clone()))), Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - RefItemImpl::construct_2(&__v.as_pointer(), { (__tmp_11).clone() }, { + RefItemImpl::construct_1(&__v.as_pointer(), { (__tmp_11).clone() }, { 2 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() @@ -765,27 +761,19 @@ fn main_0() -> i32 { return if ok { 0 } else { 1 }; } pub trait ItemImpl { - fn construct_2(&self); fn construct_1(&self, value: i32); } impl ItemImpl for Ptr { - fn construct_2(&self) { - field!((*self), value).write(0); - } fn construct_1(&self, mut value: i32) { field!((*self), value).write(value); (*made_1.with(Value::clone).borrow_mut()).prefix_inc(); } } pub trait RefItemImpl { - fn construct_1(&self); - fn construct_2(&self, counter: Ptr, amount: i32); + fn construct_1(&self, counter: Ptr, amount: i32); } impl RefItemImpl for Ptr { - fn construct_1(&self) { - field!((*self), value).write(0); - } - fn construct_2(&self, counter: Ptr, mut amount: i32) { + fn construct_1(&self, counter: Ptr, mut amount: i32) { field!((*self), value).write({ { counter.with_mut(|__v| *__v = *__v + amount) diff --git a/tests/unit/out/refcount/map_try_emplace_lvalues.rs b/tests/unit/out/refcount/map_try_emplace_lvalues.rs index d22753101a..841f850e4e 100644 --- a/tests/unit/out/refcount/map_try_emplace_lvalues.rs +++ b/tests/unit/out/refcount/map_try_emplace_lvalues.rs @@ -20,9 +20,7 @@ pub struct Item { } impl DefaultConstructible for Item { fn default_constructor(this: &Ptr) { - { - ItemImpl::construct_1(this); - } + field!((*this), value).write(0); } } impl Default for Item { @@ -30,7 +28,7 @@ impl Default for Item { { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - ItemImpl::construct_1(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -61,9 +59,9 @@ pub struct Temporary { } impl DefaultConstructible for Temporary { fn default_constructor(this: &Ptr) { - { - TemporaryImpl::construct(this); - } + field!((*this), n).write(5); + field!((*this), data).write(Box::new([6, 7])); + (*temporary_calls_4.with(Value::clone).borrow_mut()).prefix_inc(); } } impl Default for Temporary { @@ -71,7 +69,7 @@ impl Default for Temporary { { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - TemporaryImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -88,22 +86,20 @@ pub struct Nested { } impl DefaultConstructible for Nested { fn default_constructor(this: &Ptr) { - { - NestedImpl::construct_1(this); - } + DefaultConstructible::default_constructor(&field_ptr!(this, inner)); } } pub fn make_temporary_5() -> Temporary { return { let __v: Value = Rc::new(RefCell::new(::zero_init())); - TemporaryImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; } pub fn make_nested_6() -> Nested { return { let __v: Value = Rc::new(RefCell::new(::zero_init())); - NestedImpl::construct_1(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; } @@ -117,9 +113,11 @@ pub struct Owner { } impl DefaultConstructible for Owner { fn default_constructor(this: &Ptr) { - { - OwnerImpl::construct(this); - } + field!((*this), ptr).write(Some(Rc::new(RefCell::new({ + let __v: Value = Rc::new(RefCell::new(::zero_init())); + DefaultConstructible::default_constructor(&__v.as_pointer()); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + })))); } } impl Default for Owner { @@ -127,7 +125,7 @@ impl Default for Owner { { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - OwnerImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -141,9 +139,7 @@ pub struct Noncopy { } impl DefaultConstructible for Noncopy { fn default_constructor(this: &Ptr) { - { - NoncopyImpl::construct(this); - } + field!((*this), n).write(5); } } impl Default for Noncopy { @@ -163,9 +159,7 @@ pub struct Held { } impl DefaultConstructible for Held { fn default_constructor(this: &Ptr) { - { - HeldImpl::construct_2(this); - } + field!((*this), ptr).write(Ptr::::null()); } } impl Default for Held { @@ -173,7 +167,7 @@ impl Default for Held { { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - HeldImpl::construct_2(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -289,7 +283,7 @@ thread_local!( (*{ __tmp_7 = Some(Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - TemporaryImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() }))); &mut __tmp_7 @@ -384,7 +378,7 @@ fn main_0() -> i32 { Rc::new(RefCell::new(copy_constructed(key.as_pointer().clone()))), Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - ItemImpl::construct_2(&__v.as_pointer(), { counter.as_pointer() }, { 3 }); + ItemImpl::construct_1(&__v.as_pointer(), { counter.as_pointer() }, { 3 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })), ) @@ -412,7 +406,7 @@ fn main_0() -> i32 { Rc::new(RefCell::new(copy_constructed(key.as_pointer().clone()))), Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - ItemImpl::construct_2(&__v.as_pointer(), { (__tmp_9).clone() }, { 2 }); + ItemImpl::construct_1(&__v.as_pointer(), { (__tmp_9).clone() }, { 2 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })), ) @@ -450,7 +444,7 @@ fn main_0() -> i32 { Rc::new(RefCell::new(copy_constructed(key.as_pointer().clone()))), Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - ItemImpl::construct_2(&__v.as_pointer(), { (__tmp_11).clone() }, { 2 }); + ItemImpl::construct_1(&__v.as_pointer(), { (__tmp_11).clone() }, { 2 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })), ) @@ -485,7 +479,7 @@ fn main_0() -> i32 { Rc::new(RefCell::new(copy_constructed(key.as_pointer().clone()))), Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - ItemImpl::construct_2(&__v.as_pointer(), { (__tmp_13).clone() }, { 2 }); + ItemImpl::construct_1(&__v.as_pointer(), { (__tmp_13).clone() }, { 2 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })), ) @@ -521,7 +515,7 @@ fn main_0() -> i32 { Rc::new(RefCell::new(copy_constructed(key.as_pointer().clone()))), Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - ItemImpl::construct_2(&__v.as_pointer(), { (__tmp_16).clone() }, { 2 }); + ItemImpl::construct_1(&__v.as_pointer(), { (__tmp_16).clone() }, { 2 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })), ) @@ -566,7 +560,7 @@ fn main_0() -> i32 { Rc::new(RefCell::new(copy_constructed(key.as_pointer().clone()))), Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - ItemImpl::construct_2(&__v.as_pointer(), { (__tmp_19).clone() }, { 3 }); + ItemImpl::construct_1(&__v.as_pointer(), { (__tmp_19).clone() }, { 3 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })), ) @@ -597,7 +591,7 @@ fn main_0() -> i32 { Rc::new(RefCell::new(copy_constructed(key.as_pointer().clone()))), Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - ItemImpl::construct_2(&__v.as_pointer(), { (__tmp_21).clone() }, { 3 }); + ItemImpl::construct_1(&__v.as_pointer(), { (__tmp_21).clone() }, { 3 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })), ) @@ -628,7 +622,7 @@ fn main_0() -> i32 { Rc::new(RefCell::new(copy_constructed(key.as_pointer().clone()))), Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - ItemImpl::construct_2(&__v.as_pointer(), { (__tmp_24).clone() }, { 3 }); + ItemImpl::construct_1(&__v.as_pointer(), { (__tmp_24).clone() }, { 3 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })), ) @@ -667,7 +661,7 @@ fn main_0() -> i32 { Rc::new(RefCell::new(copy_constructed(key.as_pointer().clone()))), Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - ItemImpl::construct_2(&__v.as_pointer(), { (__tmp_27).clone() }, { 3 }); + ItemImpl::construct_1(&__v.as_pointer(), { (__tmp_27).clone() }, { 3 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })), ) @@ -708,7 +702,7 @@ fn main_0() -> i32 { Rc::new(RefCell::new(copy_constructed(key.as_pointer().clone()))), Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - ItemImpl::construct_2(&__v.as_pointer(), { (__tmp_30).clone() }, { 3 }); + ItemImpl::construct_1(&__v.as_pointer(), { (__tmp_30).clone() }, { 3 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })), ) @@ -735,7 +729,7 @@ fn main_0() -> i32 { Rc::new(RefCell::new(copy_constructed(key.as_pointer().clone()))), Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - ItemImpl::construct_2(&__v.as_pointer(), { (__tmp_33).clone() }, { 3 }); + ItemImpl::construct_1(&__v.as_pointer(), { (__tmp_33).clone() }, { 3 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() })), ) @@ -1252,7 +1246,7 @@ fn main_0() -> i32 { let __v: Value = Rc::new( RefCell::new(::zero_init()), ); - ItemImpl::construct_2( + ItemImpl::construct_1( &__v.as_pointer(), { (__tmp_61).clone() }, { 2 }, @@ -1305,7 +1299,7 @@ fn main_0() -> i32 { let __v: Value = Rc::new( RefCell::new(::zero_init()), ); - ItemImpl::construct_2( + ItemImpl::construct_1( &__v.as_pointer(), { (__tmp_64).clone() }, { 2 }, @@ -1358,7 +1352,7 @@ fn main_0() -> i32 { let __v: Value = Rc::new( RefCell::new(::zero_init()), ); - ItemImpl::construct_2( + ItemImpl::construct_1( &__v.as_pointer(), { (__tmp_69).clone() }, { 2 }, @@ -1729,7 +1723,7 @@ fn main_0() -> i32 { Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - HeldImpl::construct_3( + HeldImpl::construct_2( &__v.as_pointer(), { ordinary_array.decay() }, { 0 }, @@ -1782,7 +1776,7 @@ fn main_0() -> i32 { let __v: Value = Rc::new( RefCell::new(::zero_init()), ); - HeldImpl::construct_3( + HeldImpl::construct_2( &__v.as_pointer(), { (__tmp_88).clone() }, { 0 }, @@ -1851,7 +1845,7 @@ fn main_0() -> i32 { __tmp_94 = Some(Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - TemporaryImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() }))); &mut __tmp_94 @@ -1888,7 +1882,7 @@ fn main_0() -> i32 { __tmp_96 = Some(Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - NestedImpl::construct_1(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() }))); &mut __tmp_96 @@ -1926,7 +1920,7 @@ fn main_0() -> i32 { __tmp_98 = Some(Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - TemporaryImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() }))); &mut __tmp_98 @@ -1963,7 +1957,7 @@ fn main_0() -> i32 { __tmp_100 = Some(Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - TemporaryImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() }))); &mut __tmp_100 @@ -1999,7 +1993,7 @@ fn main_0() -> i32 { __tmp_102 = Some(Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - TemporaryImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() }))); &mut __tmp_102 @@ -2035,7 +2029,7 @@ fn main_0() -> i32 { __tmp_104 = Some(Rc::new(RefCell::new(Some(Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - TemporaryImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() })))))); &mut __tmp_104 @@ -2139,7 +2133,9 @@ fn main_0() -> i32 { let __v: Value = Rc::new( RefCell::new(::zero_init()), ); - TemporaryImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor( + &__v.as_pointer(), + ); Rc::try_unwrap(__v).ok().unwrap().into_inner() }))); &mut __tmp_106 @@ -2154,7 +2150,9 @@ fn main_0() -> i32 { let __v: Value = Rc::new( RefCell::new(::zero_init()), ); - TemporaryImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor( + &__v.as_pointer(), + ); Rc::try_unwrap(__v).ok().unwrap().into_inner() }))); &mut __tmp_107 @@ -2224,7 +2222,9 @@ fn main_0() -> i32 { { match (({ OwnerImpl::value(&{ - OwnerImpl::construct(&__tmp_109.as_pointer()); + DefaultConstructible::default_constructor( + &__tmp_109.as_pointer(), + ); __tmp_109.as_pointer() }) }),) @@ -2299,7 +2299,7 @@ fn main_0() -> i32 { match ({ __tmp_111 = Rc::new(RefCell::new(Some(Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - NoncopyImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() }))))); __tmp_111.as_pointer() @@ -2339,7 +2339,7 @@ fn main_0() -> i32 { match ({ __tmp_113 = Rc::new(RefCell::new(Some(Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - NoncopyImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() }))))); __tmp_113.as_pointer() @@ -2494,30 +2494,22 @@ fn main_0() -> i32 { return 0; } pub trait HeldImpl { - fn construct_2(&self); fn construct_1(&self, n: Ptr); - fn construct_3(&self, n: Ptr, _a1: i32); + fn construct_2(&self, n: Ptr, _a1: i32); } impl HeldImpl for Ptr { - fn construct_2(&self) { - field!((*self), ptr).write(Ptr::::null()); - } fn construct_1(&self, n: Ptr) { field!((*self), ptr).write((n).clone()); } - fn construct_3(&self, n: Ptr, mut _a1: i32) { + fn construct_2(&self, n: Ptr, mut _a1: i32) { field!((*self), ptr).write((n).clone()); } } pub trait ItemImpl { - fn construct_1(&self); - fn construct_2(&self, counter: Ptr, amount: i32); + fn construct_1(&self, counter: Ptr, amount: i32); } impl ItemImpl for Ptr { - fn construct_1(&self) { - field!((*self), value).write(0); - } - fn construct_2(&self, counter: Ptr, mut amount: i32) { + fn construct_1(&self, counter: Ptr, mut amount: i32) { field!((*self), value).write({ { counter.with_mut(|__v| *__v = *__v + amount) @@ -2527,48 +2519,14 @@ impl ItemImpl for Ptr { (*made_0.with(Value::clone).borrow_mut()).prefix_inc(); } } -pub trait NestedImpl { - fn construct_1(&self); -} -impl NestedImpl for Ptr { - fn construct_1(&self) { - TemporaryImpl::construct(&field_ptr!(self, inner)); - } -} -pub trait NoncopyImpl { - fn construct(&self); -} -impl NoncopyImpl for Ptr { - fn construct(&self) { - field!((*self), n).write(5); - } -} pub trait OwnerImpl { - fn construct(&self); fn value(&self) -> Ptr; } impl OwnerImpl for Ptr { - fn construct(&self) { - field!((*self), ptr).write(Some(Rc::new(RefCell::new({ - let __v: Value = Rc::new(RefCell::new(::zero_init())); - TemporaryImpl::construct(&__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - })))); - } fn value(&self) -> Ptr { return field_ptr!((*self).with(|__s| __s.ptr.clone()).as_pointer(), n); } } -pub trait TemporaryImpl { - fn construct(&self); -} -impl TemporaryImpl for Ptr { - fn construct(&self) { - field!((*self), n).write(5); - field!((*self), data).write(Box::new([6, 7])); - (*temporary_calls_4.with(Value::clone).borrow_mut()).prefix_inc(); - } -} pub fn __cpp2rust_init_globals() { let _ = made_0.with(|_| ()); let _ = visits_1.with(|_| ()); diff --git a/tests/unit/out/refcount/memcpy_struct_struct.rs b/tests/unit/out/refcount/memcpy_struct_struct.rs index 42b1f1190e..34aa1bafb7 100644 --- a/tests/unit/out/refcount/memcpy_struct_struct.rs +++ b/tests/unit/out/refcount/memcpy_struct_struct.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Entry { #[offset(0)] diff --git a/tests/unit/out/refcount/move_assign.rs b/tests/unit/out/refcount/move_assign.rs index 248918836a..dd2eb41520 100644 --- a/tests/unit/out/refcount/move_assign.rs +++ b/tests/unit/out/refcount/move_assign.rs @@ -47,9 +47,7 @@ pub struct ConstMoveAssign { } impl DefaultConstructible for ConstMoveAssign { fn default_constructor(this: &Ptr) { - { - ConstMoveAssignImpl::construct(this); - } + field!((*this), mark).write(0); } } impl Default for ConstMoveAssign { @@ -58,7 +56,7 @@ impl Default for ConstMoveAssign { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - ConstMoveAssignImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -127,13 +125,13 @@ fn main_0() -> i32 { assert!(({ (*vec_.borrow())[0_usize].v } == 8)); assert!(({ (*d.borrow()).v } == 0)); let m: Value = Rc::new(RefCell::new(::zero_init())); - ConstMoveAssignImpl::construct(&m.as_pointer()); + DefaultConstructible::default_constructor(&m.as_pointer()); let m1: Value = Rc::new(RefCell::new(::zero_init())); - ConstMoveAssignImpl::construct(&m1.as_pointer()); + DefaultConstructible::default_constructor(&m1.as_pointer()); let m2: Value = Rc::new(RefCell::new(::zero_init())); - ConstMoveAssignImpl::construct(&m2.as_pointer()); + DefaultConstructible::default_constructor(&m2.as_pointer()); let cm: Value = Rc::new(RefCell::new(::zero_init())); - ConstMoveAssignImpl::construct(&cm.as_pointer()); + DefaultConstructible::default_constructor(&cm.as_pointer()); ({ ConstMoveAssignImpl::operator_assign_2(&m1.as_pointer(), m.as_pointer()) }); ({ ConstMoveAssignImpl::operator_assign_3(&m2.as_pointer(), cm.as_pointer()) }); assert!(({ (*m1.borrow()).mark } == 1)); @@ -141,14 +139,10 @@ fn main_0() -> i32 { return 0; } pub trait ConstMoveAssignImpl { - fn construct(&self); fn operator_assign_2(&self, o: Ptr) -> Ptr; fn operator_assign_3(&self, o: Ptr) -> Ptr; } impl ConstMoveAssignImpl for Ptr { - fn construct(&self) { - field!((*self), mark).write(0); - } fn operator_assign_2(&self, o: Ptr) -> Ptr { field!((*self), mark).write((o.with(|__s| __s.mark) + 1)); return (*self).clone(); diff --git a/tests/unit/out/refcount/move_ctor.rs b/tests/unit/out/refcount/move_ctor.rs index 595e027b6c..c0c4196664 100644 --- a/tests/unit/out/refcount/move_ctor.rs +++ b/tests/unit/out/refcount/move_ctor.rs @@ -36,9 +36,7 @@ pub struct ConstMove { } impl DefaultConstructible for ConstMove { fn default_constructor(this: &Ptr) { - { - ConstMoveImpl::construct(this); - } + field!((*this), mark).write(0); } } impl Default for ConstMove { @@ -46,7 +44,7 @@ impl Default for ConstMove { { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - ConstMoveImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -226,11 +224,11 @@ fn main_0() -> i32 { assert!((vec_[0_usize].v == 7) && (vec_[1_usize].v == 8)); assert!(({ (*f.borrow()).v } == 0)); let m: Value = Rc::new(RefCell::new(::zero_init())); - ConstMoveImpl::construct(&m.as_pointer()); + DefaultConstructible::default_constructor(&m.as_pointer()); let m1: Value = Rc::new(RefCell::new(::zero_init())); ConstMoveImpl::construct_1(&m1.as_pointer(), { m.as_pointer() }); let cm: Value = Rc::new(RefCell::new(::zero_init())); - ConstMoveImpl::construct(&cm.as_pointer()); + DefaultConstructible::default_constructor(&cm.as_pointer()); let m2: Value = Rc::new(RefCell::new(::zero_init())); ConstMoveImpl::construct_2(&m2.as_pointer(), { cm.as_pointer() }); assert!(({ (*m1.borrow()).mark } == 1)); @@ -260,14 +258,10 @@ fn main_0() -> i32 { return 0; } pub trait ConstMoveImpl { - fn construct(&self); fn construct_1(&self, o: Ptr); fn construct_2(&self, o: Ptr); } impl ConstMoveImpl for Ptr { - fn construct(&self) { - field!((*self), mark).write(0); - } fn construct_1(&self, o: Ptr) { field!((*self), mark).write((o.with(|__s| __s.mark) + 1)); } diff --git a/tests/unit/out/refcount/nested_structs.rs b/tests/unit/out/refcount/nested_structs.rs index 694e8c96ce..479d2f985e 100644 --- a/tests/unit/out/refcount/nested_structs.rs +++ b/tests/unit/out/refcount/nested_structs.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Level0_Level1_1_Level2_1_Level3_1 { #[offset(0)] @@ -31,10 +32,11 @@ pub struct Level0_Level1_1_Level2_1_Level3_1 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct Level0_Level1_1_Level2_1_Level3_2 { #[offset(0)] @@ -50,10 +52,11 @@ pub struct Level0_Level1_1_Level2_1_Level3_2 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Level0_Level1_1_Level2_1 { #[offset(0)] @@ -67,10 +70,11 @@ pub struct Level0_Level1_1_Level2_1 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Level0_Level1_1 { #[offset(0)] @@ -84,10 +88,11 @@ pub struct Level0_Level1_1 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct Level0_Level1_2 { #[offset(0)] @@ -103,10 +108,11 @@ pub struct Level0_Level1_2 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 076ef1ecf0..07cb27e4d6 100644 --- a/tests/unit/out/refcount/new.rs +++ b/tests/unit/out/refcount/new.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 749feb2c24..491fba9645 100644 --- a/tests/unit/out/refcount/new_bst.rs +++ b/tests/unit/out/refcount/new_bst.rs @@ -13,10 +13,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 395ba97173..7f543997b4 100644 --- a/tests/unit/out/refcount/new_struct.rs +++ b/tests/unit/out/refcount/new_struct.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct Pair { #[offset(0)] @@ -33,10 +34,11 @@ pub struct Pair { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 3a844a9b26..ea8dd7b6af 100644 --- a/tests/unit/out/refcount/nttp_distinct_specializations.rs +++ b/tests/unit/out/refcount/nttp_distinct_specializations.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct S_2_ { #[offset(0)] @@ -33,10 +34,11 @@ pub struct S_2_ { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct S_1_ { #[offset(0)] @@ -50,10 +52,11 @@ pub struct S_1_ { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 9e6a562889..8c9813c487 100644 --- a/tests/unit/out/refcount/offsetof.rs +++ b/tests/unit/out/refcount/offsetof.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(12)] pub struct Layout { #[offset(0)] @@ -28,15 +29,9 @@ pub struct Layout { pub c: u16, } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - DefaultConstructible, - TriviallyCopyable, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, )] +#[memberwise(default_constructor)] #[byte_size(66)] pub struct Frame { #[offset(0)] diff --git a/tests/unit/out/refcount/opaque_record_copy.rs b/tests/unit/out/refcount/opaque_record_copy.rs index 449fef34ff..bcec386aa6 100644 --- a/tests/unit/out/refcount/opaque_record_copy.rs +++ b/tests/unit/out/refcount/opaque_record_copy.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct Probe {} #[derive( @@ -28,10 +29,11 @@ pub struct Probe {} ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct Wrapper_Probe_ { #[offset(0)] diff --git a/tests/unit/out/refcount/operator_arithmetic_free.rs b/tests/unit/out/refcount/operator_arithmetic_free.rs index 1484bf75e9..a11dcf5193 100644 --- a/tests/unit/out/refcount/operator_arithmetic_free.rs +++ b/tests/unit/out/refcount/operator_arithmetic_free.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 d2f53fd792..1db97f7648 100644 --- a/tests/unit/out/refcount/operator_arithmetic_member.rs +++ b/tests/unit/out/refcount/operator_arithmetic_member.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 35751e1776..3084655e27 100644 --- a/tests/unit/out/refcount/operator_bitwise_free.rs +++ b/tests/unit/out/refcount/operator_bitwise_free.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 a89486e3b2..395baa006a 100644 --- a/tests/unit/out/refcount/operator_bitwise_member.rs +++ b/tests/unit/out/refcount/operator_bitwise_member.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 8ff9674d42..d1d15c3878 100644 --- a/tests/unit/out/refcount/operator_comparison_defaulted.rs +++ b/tests/unit/out/refcount/operator_comparison_defaulted.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct Eq { #[offset(0)] @@ -38,10 +39,11 @@ impl CppEq for Eq { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct Cmp { #[offset(0)] @@ -67,10 +69,11 @@ impl CppEq for Cmp { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Both { #[offset(0)] @@ -94,10 +97,11 @@ impl CppEq for Both { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct OrdOnly { #[offset(0)] @@ -121,10 +125,11 @@ impl CppEq for OrdOnly { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Inner { #[offset(0)] @@ -148,10 +153,11 @@ impl CppEq for Inner { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct Outer { #[offset(0)] @@ -178,10 +184,11 @@ impl CppEq for Outer { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Secondary { #[offset(0)] @@ -204,10 +211,11 @@ impl CppEq for Secondary { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 59c84cf1fe..4bbe2a994b 100644 --- a/tests/unit/out/refcount/operator_comparison_free.rs +++ b/tests/unit/out/refcount/operator_comparison_free.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct S { #[offset(0)] @@ -65,10 +66,11 @@ pub fn operator_lt_7(mut a: i32, b: Ptr) -> bool { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 10855feb83..a786f591ca 100644 --- a/tests/unit/out/refcount/operator_comparison_member.rs +++ b/tests/unit/out/refcount/operator_comparison_member.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 d3a8d5b638..20bf2615e7 100644 --- a/tests/unit/out/refcount/operator_comparison_mixed.rs +++ b/tests/unit/out/refcount/operator_comparison_mixed.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 6d2821eb4b..252bfced35 100644 --- a/tests/unit/out/refcount/operator_comparison_nonbool.rs +++ b/tests/unit/out/refcount/operator_comparison_nonbool.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct X { #[offset(0)] @@ -59,10 +60,11 @@ pub fn operator_ge_5(mut a: X, mut b: X) -> i32 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Result { #[offset(0)] @@ -76,10 +78,11 @@ pub struct Result { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Custom { #[offset(0)] @@ -93,10 +96,11 @@ pub struct Custom { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Mixed { #[offset(0)] @@ -139,10 +143,11 @@ pub struct MyBool { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Boolish { #[offset(0)] @@ -209,10 +214,11 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 385ca1b84c..ed28164cc3 100644 --- a/tests/unit/out/refcount/operator_compound_assignment_free.rs +++ b/tests/unit/out/refcount/operator_compound_assignment_free.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 20e985bd60..e14d0ec15d 100644 --- a/tests/unit/out/refcount/operator_compound_assignment_member.rs +++ b/tests/unit/out/refcount/operator_compound_assignment_member.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 f14907d44e..4a6ce02ef1 100644 --- a/tests/unit/out/refcount/operator_friend.rs +++ b/tests/unit/out/refcount/operator_friend.rs @@ -18,10 +18,11 @@ pub fn operator_eq_0(_a0: Ptr, _a1: Ptr) -> bool { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct Defaulted { #[offset(0)] @@ -57,10 +58,11 @@ pub fn operator_eq_2(_a0: Ptr, _a1: Ptr) -> bool { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct DefaultedOrd { #[offset(0)] @@ -95,10 +97,11 @@ pub fn operator_add_5(x: Ptr, y: Ptr) -> Inline { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Inline { #[offset(0)] @@ -122,10 +125,11 @@ impl CppEq for Inline { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct OutOfLine { #[offset(0)] @@ -159,10 +163,11 @@ pub fn operator_eq_10(x: Ptr, y: Ptr) -> bool { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Tmpl_int_ { #[offset(0)] @@ -186,10 +191,11 @@ impl CppEq for Tmpl_int_ { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct Tmpl_long_ { #[offset(0)] @@ -206,10 +212,11 @@ pub fn operator_eq_11(_a0: Ptr, _a1: Ptr ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 ce6b237224..76efcaee83 100644 --- a/tests/unit/out/refcount/operator_less_than.rs +++ b/tests/unit/out/refcount/operator_less_than.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 e5f6760ac8..35767994c8 100644 --- a/tests/unit/out/refcount/operator_logical_free.rs +++ b/tests/unit/out/refcount/operator_logical_free.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 e80efaa8a9..bce7772810 100644 --- a/tests/unit/out/refcount/operator_logical_member.rs +++ b/tests/unit/out/refcount/operator_logical_member.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 aec0e548f1..b58f504f86 100644 --- a/tests/unit/out/refcount/operator_member_pointer_free.rs +++ b/tests/unit/out/refcount/operator_member_pointer_free.rs @@ -14,25 +14,20 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Inner { #[offset(0)] pub x: i32, } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - DefaultConstructible, - TriviallyCopyable, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, )] +#[memberwise(default_constructor)] #[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 f0106f3348..d1ddd58270 100644 --- a/tests/unit/out/refcount/operator_member_pointer_member.rs +++ b/tests/unit/out/refcount/operator_member_pointer_member.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Inner { #[offset(0)] @@ -31,10 +32,11 @@ pub struct Inner { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct Table {} impl Table { @@ -46,15 +48,9 @@ thread_local!( pub static table_0: Value> = Rc::new(RefCell::new(Box::new([7, 8, 9]))); ); #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - DefaultConstructible, - TriviallyCopyable, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, )] +#[memberwise(default_constructor)] #[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 8cf19de228..89805f8b05 100644 --- a/tests/unit/out/refcount/operator_other_free.rs +++ b/tests/unit/out/refcount/operator_other_free.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 46db70d48e..7208a1c279 100644 --- a/tests/unit/out/refcount/operator_other_member.rs +++ b/tests/unit/out/refcount/operator_other_member.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct Static {} impl Static { @@ -34,10 +35,11 @@ impl Static { VaArg, FnPtrArg, CppFrom, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 f87daf5951..9e8b787283 100644 --- a/tests/unit/out/refcount/operator_overloads.rs +++ b/tests/unit/out/refcount/operator_overloads.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 32782605b0..261012c6bf 100644 --- a/tests/unit/out/refcount/operator_qualifiers.rs +++ b/tests/unit/out/refcount/operator_qualifiers.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 74050dc4ef..675b9286dd 100644 --- a/tests/unit/out/refcount/operator_three_way.rs +++ b/tests/unit/out/refcount/operator_three_way.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 fb77202334..4a00b7fad9 100644 --- a/tests/unit/out/refcount/operator_traits.rs +++ b/tests/unit/out/refcount/operator_traits.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Lt { #[offset(0)] @@ -41,10 +42,11 @@ impl CppEq for Lt { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Eq { #[offset(0)] @@ -63,10 +65,11 @@ impl CppEq for Eq { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Cmp { #[offset(0)] @@ -90,10 +93,11 @@ impl CppEq for Cmp { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Free { #[offset(0)] @@ -123,10 +127,11 @@ pub fn operator_eq_1(a: Ptr, b: Ptr) -> bool { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 ed62777669..54cfe5f6f4 100644 --- a/tests/unit/out/refcount/overload_mangling.rs +++ b/tests/unit/out/refcount/overload_mangling.rs @@ -27,10 +27,11 @@ pub fn twice_2(mut n: i32) -> i32 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct Access_S_ {} #[derive( @@ -41,10 +42,11 @@ pub struct Access_S_ {} ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct S { #[offset(0)] @@ -58,10 +60,11 @@ pub struct S { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 7bd5381049..98f937979e 100644 --- a/tests/unit/out/refcount/pair_converting_construction.rs +++ b/tests/unit/out/refcount/pair_converting_construction.rs @@ -34,10 +34,11 @@ pub struct Celsius { VaArg, FnPtrArg, CppFrom, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[cpp_into(i32, to_i32)] #[byte_size(4)] pub struct Meters { @@ -139,10 +140,11 @@ impl Default for Fallback { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Counter { #[offset(0)] diff --git a/tests/unit/out/refcount/pod.rs b/tests/unit/out/refcount/pod.rs index 434a2d3018..bc7a7cb33f 100644 --- a/tests/unit/out/refcount/pod.rs +++ b/tests/unit/out/refcount/pod.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 a0dedd7f47..139dc6c4b5 100644 --- a/tests/unit/out/refcount/pointer_array.rs +++ b/tests/unit/out/refcount/pointer_array.rs @@ -7,15 +7,9 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - DefaultConstructible, - TriviallyCopyable, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, )] +#[memberwise(default_constructor)] #[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 ab49adeaba..05073d9188 100644 --- a/tests/unit/out/refcount/pointers.rs +++ b/tests/unit/out/refcount/pointers.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Test { #[offset(0)] diff --git a/tests/unit/out/refcount/push_emplace_back.rs b/tests/unit/out/refcount/push_emplace_back.rs index b107b08edf..71fe867b7b 100644 --- a/tests/unit/out/refcount/push_emplace_back.rs +++ b/tests/unit/out/refcount/push_emplace_back.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Chunk { #[offset(0)] @@ -30,10 +31,11 @@ pub struct Chunk { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(16)] pub struct Writer { #[offset(0)] @@ -68,9 +70,8 @@ pub struct JPEGData { } impl DefaultConstructible for JPEGData { fn default_constructor(this: &Ptr) { - { - JPEGDataImpl::construct_1(this); - } + field!((*this), com_data).write(Vec::new()); + field!((*this), app_data).write(Vec::new()); } } pub fn push_param_0(mut dest: Ptr>>) { @@ -160,9 +161,8 @@ pub struct Pair { } impl DefaultConstructible for Pair { fn default_constructor(this: &Ptr) { - { - PairImpl::construct_2(this); - } + field!((*this), first).write(-1_i32); + field!((*this), second).write(-1_i32); } } impl Default for Pair { @@ -170,7 +170,7 @@ impl Default for Pair { { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - PairImpl::construct_2(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -181,7 +181,7 @@ pub fn emplace_ctor_args_7(mut pairs: Ptr>) { pairs.with_mut(|__v: &mut Vec| { __v.push({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - PairImpl::construct_2(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() }) }); @@ -200,7 +200,7 @@ pub fn emplace_ctor_args_7(mut pairs: Ptr>) { let mut __tmp_5 = { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - PairImpl::construct_3(&__v.as_pointer(), { 4 }, { 5 }); + PairImpl::construct_2(&__v.as_pointer(), { 4 }, { 5 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() } }; @@ -212,7 +212,7 @@ pub fn emplace_deque_8(mut queue: Ptr>) { let mut __tmp_6 = { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - PairImpl::construct_3(&__v.as_pointer(), { 6 }, { 7 }); + PairImpl::construct_2(&__v.as_pointer(), { 6 }, { 7 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() } }; @@ -222,7 +222,7 @@ pub fn emplace_deque_8(mut queue: Ptr>) { queue.with_mut(|__v: &mut Vec| { __v.push({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - PairImpl::construct_2(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() }) }); @@ -242,7 +242,7 @@ pub fn emplace_ref_through_ptr_10(mut pairs: Ptr>) { let mut __tmp_7 = { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - PairImpl::construct_3(&__v.as_pointer(), { 1 }, { 2 }); + PairImpl::construct_2(&__v.as_pointer(), { 1 }, { 2 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() } }; @@ -294,7 +294,7 @@ pub fn emplace_self_reads_12(mut values: Ptr>, mut pairs: Ptr let mut __tmp_11 = { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - PairImpl::construct_3( + PairImpl::construct_2( &__v.as_pointer(), { pairs.with(|__s| { @@ -350,9 +350,8 @@ pub struct Bytes { } impl DefaultConstructible for Bytes { fn default_constructor(this: &Ptr) { - { - BytesImpl::construct_1(this); - } + field!((*this), v).write(Vec::new()); + field!((*this), b).write((0..3).map(|_| 0_u8).collect::>()); } } impl Default for Bytes { @@ -384,15 +383,9 @@ pub fn emplace_from_element_14(mut v: Ptr>>) { }; } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - DefaultConstructible, - TriviallyCopyable, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, )] +#[memberwise(default_constructor)] #[byte_size(24)] pub struct Plain { #[offset(0)] @@ -484,7 +477,7 @@ fn main_0() -> i32 { assert!(({ ((*vecs.borrow()).len() == 1_usize) })); assert!(({ (*vecs.decay().offset(0_usize).upgrade().deref()).is_empty() })); let jpg: Value = Rc::new(RefCell::new(::zero_init())); - JPEGDataImpl::construct_1(&jpg.as_pointer()); + DefaultConstructible::default_constructor(&jpg.as_pointer()); ({ push_local_from_field_1((jpg.as_pointer()), true) }); assert!(({ ((*jpg.borrow()).com_data.len() == 1_usize) })); assert!( @@ -632,7 +625,7 @@ fn main_0() -> i32 { let mut __tmp_18 = { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - PairImpl::construct_3(&__v.as_pointer(), { 1 }, { 2 }); + PairImpl::construct_2(&__v.as_pointer(), { 1 }, { 2 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() } }; @@ -694,15 +687,6 @@ fn main_0() -> i32 { ); return 0; } -pub trait BytesImpl { - fn construct_1(&self); -} -impl BytesImpl for Ptr { - fn construct_1(&self) { - field!((*self), v).write(Vec::new()); - field!((*self), b).write((0..3).map(|_| 0_u8).collect::>()); - } -} pub trait CountedImpl { fn construct(&self, _a0: i32); } @@ -716,30 +700,16 @@ impl CountedImpl for Ptr { ); } } -pub trait JPEGDataImpl { - fn construct_1(&self); -} -impl JPEGDataImpl for Ptr { - fn construct_1(&self) { - field!((*self), com_data).write(Vec::new()); - field!((*self), app_data).write(Vec::new()); - } -} pub trait PairImpl { - fn construct_2(&self); fn construct_1(&self, a: i32); - fn construct_3(&self, a: i32, b: i32); + fn construct_2(&self, a: i32, b: i32); } impl PairImpl for Ptr { - fn construct_2(&self) { - field!((*self), first).write(-1_i32); - field!((*self), second).write(-1_i32); - } fn construct_1(&self, mut a: i32) { field!((*self), first).write(a); field!((*self), second).write(0); } - fn construct_3(&self, mut a: i32, mut b: i32) { + fn construct_2(&self, mut a: i32, mut b: i32) { field!((*self), first).write(a); field!((*self), second).write((b * 2)); } diff --git a/tests/unit/out/refcount/random.rs b/tests/unit/out/refcount/random.rs index ae5f74865b..c75fd3fd56 100644 --- a/tests/unit/out/refcount/random.rs +++ b/tests/unit/out/refcount/random.rs @@ -68,10 +68,11 @@ pub fn zero_0() -> i32 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 896d96f41d..f039ee1ec9 100644 --- a/tests/unit/out/refcount/reference_wrapper.rs +++ b/tests/unit/out/refcount/reference_wrapper.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 16ff50cd10..6f163db0ef 100644 --- a/tests/unit/out/refcount/references.rs +++ b/tests/unit/out/refcount/references.rs @@ -7,15 +7,9 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - DefaultConstructible, - TriviallyCopyable, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, )] +#[memberwise(default_constructor)] #[byte_size(16)] pub struct Pair { #[offset(0)] @@ -45,10 +39,11 @@ impl Default for Pair { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 41a465be15..9f134409b1 100644 --- a/tests/unit/out/refcount/refs_as_args.rs +++ b/tests/unit/out/refcount/refs_as_args.rs @@ -38,10 +38,11 @@ pub fn more_refs_0(x1: i32, x2: i32, r1: Ptr, r2: Ptr) { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 b8de211ecd..c3bc515f73 100644 --- a/tests/unit/out/refcount/reinterpret_cast_ptr_cmp.rs +++ b/tests/unit/out/refcount/reinterpret_cast_ptr_cmp.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct S { #[offset(0)] @@ -26,15 +27,9 @@ pub struct S { pub y: i32, } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - DefaultConstructible, - TriviallyCopyable, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, )] +#[memberwise(default_constructor)] #[byte_size(28)] pub struct W { #[offset(0)] @@ -55,15 +50,9 @@ impl Default for W { } } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - DefaultConstructible, - TriviallyCopyable, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, )] +#[memberwise(default_constructor)] #[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 7fb62cc45b..5caba9f067 100644 --- a/tests/unit/out/refcount/reinterpret_cast_struct.rs +++ b/tests/unit/out/refcount/reinterpret_cast_struct.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 4a98041e13..13d7c777ff 100644 --- a/tests/unit/out/refcount/reinterpret_cast_struct_to_struct.rs +++ b/tests/unit/out/refcount/reinterpret_cast_struct_to_struct.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct Point { #[offset(0)] @@ -33,10 +34,11 @@ pub struct Point { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 f8e4a94062..ab65071ec6 100644 --- a/tests/unit/out/refcount/reserved_keywords.rs +++ b/tests/unit/out/refcount/reserved_keywords.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(152)] pub struct S { #[offset(0)] @@ -105,10 +106,11 @@ pub struct S { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct type_ { #[offset(0)] @@ -122,10 +124,11 @@ pub struct type_ { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 e933c1c3fc..a569922ac5 100644 --- a/tests/unit/out/refcount/return_move.rs +++ b/tests/unit/out/refcount/return_move.rs @@ -13,10 +13,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(16)] pub struct node { #[offset(0)] @@ -32,10 +33,11 @@ pub struct node { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(16)] pub struct pair_t { #[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 1359aaf06b..9b1fdddff2 100644 --- a/tests/unit/out/refcount/scalar_builtin_construct_destruct.rs +++ b/tests/unit/out/refcount/scalar_builtin_construct_destruct.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 0480959140..b7305c10e8 100644 --- a/tests/unit/out/refcount/self_referencing_initializer.rs +++ b/tests/unit/out/refcount/self_referencing_initializer.rs @@ -13,10 +13,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct list_head { #[offset(0)] @@ -30,10 +31,11 @@ pub struct list_head { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(16)] pub struct node { #[offset(0)] @@ -53,9 +55,8 @@ pub struct node_with_defaults { } impl DefaultConstructible for node_with_defaults { fn default_constructor(this: &Ptr) { - { - node_with_defaultsImpl::construct_1(this); - } + field!((*this), next).write(Ptr::::null()); + field!((*this), value).write(3); } } impl Default for node_with_defaults { @@ -121,13 +122,4 @@ fn main_0() -> i32 { assert!((size == ::std::mem::size_of::())); return 0; } -pub trait node_with_defaultsImpl { - fn construct_1(&self); -} -impl node_with_defaultsImpl for Ptr { - fn construct_1(&self) { - field!((*self), next).write(Ptr::::null()); - field!((*self), value).write(3); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/size_t_static_member.rs b/tests/unit/out/refcount/size_t_static_member.rs index 039ab43e6c..5f37a51c4d 100644 --- a/tests/unit/out/refcount/size_t_static_member.rs +++ b/tests/unit/out/refcount/size_t_static_member.rs @@ -17,10 +17,11 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct S {} thread_local!( @@ -34,10 +35,11 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct Table_char_ {} pub fn main() { diff --git a/tests/unit/out/refcount/sort_no_copy.rs b/tests/unit/out/refcount/sort_no_copy.rs index 3df7c7a773..583bc6aa86 100644 --- a/tests/unit/out/refcount/sort_no_copy.rs +++ b/tests/unit/out/refcount/sort_no_copy.rs @@ -18,6 +18,11 @@ pub struct Tracked { #[offset(0)] pub v: i32, } +impl DefaultConstructible for Tracked { + fn default_constructor(this: &Ptr) { + field!((*this), v).write(0); + } +} impl CopyConstructible for Tracked { fn copy_constructor(this: &Ptr, o: Ptr) { field!((*this), v).write(o.with(|__s| __s.v)); @@ -61,19 +66,12 @@ impl Clone for Tracked { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } -impl DefaultConstructible for Tracked { - fn default_constructor(this: &Ptr) { - { - TrackedImpl::construct_2(this); - } - } -} impl Default for Tracked { fn default() -> Self { { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - TrackedImpl::construct_2(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -138,6 +136,11 @@ pub struct Bag { #[byte_size(24)] pub items: Vec, } +impl DefaultConstructible for Bag { + fn default_constructor(this: &Ptr) { + field!((*this), items).write(Vec::new()); + } +} impl CppLess for Bag { fn less(__lhs: &Ptr, __rhs: &Ptr) -> bool { operator_lt_4(__lhs.clone(), __rhs.clone()) @@ -148,13 +151,6 @@ impl CppEq for Bag { operator_eq_5(__lhs.clone(), __rhs.clone()) } } -impl DefaultConstructible for Bag { - fn default_constructor(this: &Ptr) { - { - BagImpl::construct_1(this); - } - } -} pub fn operator_lt_4(a: Ptr, b: Ptr) -> bool { return ({ (*a.upgrade().deref()).items.len() } < { (*b.upgrade().deref()).items.len() }); } @@ -347,7 +343,7 @@ fn main_0() -> i32 { let bags: Value> = Rc::new(RefCell::new(Box::new(std::array::from_fn::<_, 3, _>( |_| { let __v: Value = Rc::new(RefCell::new(::zero_init())); - BagImpl::construct_1(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() }, )))); @@ -614,14 +610,6 @@ fn main_0() -> i32 { ); return copies_0.with(|rc| *rc.borrow()); } -pub trait BagImpl { - fn construct_1(&self); -} -impl BagImpl for Ptr { - fn construct_1(&self) { - field!((*self), items).write(Vec::new()); - } -} pub trait MoveOnlyImpl { fn construct(&self, v: i32); } @@ -631,13 +619,9 @@ impl MoveOnlyImpl for Ptr { } } pub trait TrackedImpl { - fn construct_2(&self); fn construct_1(&self, v: i32); } impl TrackedImpl for Ptr { - fn construct_2(&self) { - field!((*self), v).write(0); - } fn construct_1(&self, mut v: i32) { field!((*self), v).write(v); } diff --git a/tests/unit/out/refcount/static_local.rs b/tests/unit/out/refcount/static_local.rs index 013817257f..ae781e3dfd 100644 --- a/tests/unit/out/refcount/static_local.rs +++ b/tests/unit/out/refcount/static_local.rs @@ -41,10 +41,11 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 006f87571e..e92891f73f 100644 --- a/tests/unit/out/refcount/static_var_in_class.rs +++ b/tests/unit/out/refcount/static_var_in_class.rs @@ -17,10 +17,11 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct C {} thread_local!( @@ -36,10 +37,11 @@ pub const anon_3_kValue: anon_3 = 3; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct S {} impl S { diff --git a/tests/unit/out/refcount/struct_ctor.rs b/tests/unit/out/refcount/struct_ctor.rs index a996c4e4d6..f4d63e0bb7 100644 --- a/tests/unit/out/refcount/struct_ctor.rs +++ b/tests/unit/out/refcount/struct_ctor.rs @@ -59,9 +59,8 @@ pub struct Ptr_ { } impl DefaultConstructible for Ptr_ { fn default_constructor(this: &Ptr) { - { - Ptr_Impl::construct(this); - } + Value_Impl::construct(&field_ptr!(this, v1), { 11 }); + Value_Impl::construct(&field_ptr!(this, v2), { 22 }); } } impl Default for Ptr_ { @@ -69,7 +68,7 @@ impl Default for Ptr_ { { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - Ptr_Impl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -90,20 +89,11 @@ fn main_0() -> i32 { && ((({ StructWithCtorImpl::x2(&struct_with_ctor.as_pointer(),) }).read()) == 1) ); let p: Value = Rc::new(RefCell::new(::zero_init())); - Ptr_Impl::construct(&p.as_pointer()); + DefaultConstructible::default_constructor(&p.as_pointer()); assert!(({ (*p.borrow()).v1.v } == 11)); assert!(({ (*p.borrow()).v2.v } == 22)); return 0; } -pub trait Ptr_Impl { - fn construct(&self); -} -impl Ptr_Impl for Ptr { - fn construct(&self) { - Value_Impl::construct(&field_ptr!(self, v1), { 11 }); - Value_Impl::construct(&field_ptr!(self, v2), { 22 }); - } -} pub trait StructWithCtorImpl { fn construct(&self, x1: i32, x2: i32); fn x1(&self) -> Ptr; diff --git a/tests/unit/out/refcount/struct_default_ctor.rs b/tests/unit/out/refcount/struct_default_ctor.rs index 078f368158..a1658d8694 100644 --- a/tests/unit/out/refcount/struct_default_ctor.rs +++ b/tests/unit/out/refcount/struct_default_ctor.rs @@ -16,9 +16,8 @@ pub struct S { } impl DefaultConstructible for S { fn default_constructor(this: &Ptr) { - { - SImpl::construct(this); - } + field!((*this), a).write(11); + field!((*this), b).write(true); } } impl Default for S { @@ -26,23 +25,14 @@ impl Default for S { { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - SImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } } } #[derive( - Copy, - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - DefaultConstructible, - TriviallyCopyable, - Default, + Copy, Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Default, )] #[byte_size(4)] pub struct Declared { @@ -59,9 +49,11 @@ pub struct Holder { } impl DefaultConstructible for Holder { fn default_constructor(this: &Ptr) { - { - HolderImpl::construct_1(this); - } + field!((*this), items).write(Box::new(std::array::from_fn::<_, 2, _>(|_| { + let __v: Value = Rc::new(RefCell::new(::zero_init())); + DefaultConstructible::default_constructor(&__v.as_pointer()); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }))); } } impl Default for Holder { @@ -84,9 +76,7 @@ pub struct FromStatic { } impl DefaultConstructible for FromStatic { fn default_constructor(this: &Ptr) { - { - FromStaticImpl::construct_1(this); - } + field!((*this), v).write(kInit_0.with(|rc| *rc.borrow())); } } impl Default for FromStatic { @@ -106,7 +96,7 @@ fn main_0() -> i32 { let mut d: Ptr = Ptr::::null(); assert!((d).is_null()); let s: Value = Rc::new(RefCell::new(::zero_init())); - SImpl::construct(&s.as_pointer()); + DefaultConstructible::default_constructor(&s.as_pointer()); assert!(({ (*s.borrow()).a } == 11)); assert!((({ (*s.borrow()).b } as i32) == (true as i32))); let mut h: Ptr = Ptr::alloc_array( @@ -125,39 +115,9 @@ fn main_0() -> i32 { fs.delete(); return 0; } -pub trait DeclaredImpl { - fn construct(&self) { - unimplemented!() - } -} -impl DeclaredImpl for Ptr {} -pub trait FromStaticImpl { - fn construct_1(&self); -} -impl FromStaticImpl for Ptr { - fn construct_1(&self) { - field!((*self), v).write(kInit_0.with(|rc| *rc.borrow())); - } -} -pub trait HolderImpl { - fn construct_1(&self); -} -impl HolderImpl for Ptr { - fn construct_1(&self) { - field!((*self), items).write(Box::new(std::array::from_fn::<_, 2, _>(|_| { - let __v: Value = Rc::new(RefCell::new(::zero_init())); - SImpl::construct(&__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }))); - } -} -pub trait SImpl { - fn construct(&self); -} -impl SImpl for Ptr { - fn construct(&self) { - field!((*self), a).write(11); - field!((*self), b).write(true); +impl DefaultConstructible for Declared { + fn default_constructor(this: &Ptr) { + unreachable!("Declared::default_constructor is never defined") } } pub fn __cpp2rust_init_globals() { diff --git a/tests/unit/out/refcount/struct_ptr.rs b/tests/unit/out/refcount/struct_ptr.rs index f22220b76b..f0247a718b 100644 --- a/tests/unit/out/refcount/struct_ptr.rs +++ b/tests/unit/out/refcount/struct_ptr.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct XX { #[offset(0)] diff --git a/tests/unit/out/refcount/structured_binding_move_ctor.rs b/tests/unit/out/refcount/structured_binding_move_ctor.rs index 2e41d829ad..0ba68fc81a 100644 --- a/tests/unit/out/refcount/structured_binding_move_ctor.rs +++ b/tests/unit/out/refcount/structured_binding_move_ctor.rs @@ -84,9 +84,8 @@ pub struct Holder { } impl DefaultConstructible for Holder { fn default_constructor(this: &Ptr) { - { - HolderImpl::construct_1(this); - } + field!((*this), xs).write(Vec::new()); + field!((*this), ys).write(Vec::new()); } } pub fn main() { @@ -126,7 +125,6 @@ fn main_0() -> i32 { } pub trait HolderImpl { fn extract(&self, this: Ptr); - fn construct_1(&self); } impl HolderImpl for Ptr { fn extract(&self, this: Ptr) { @@ -136,10 +134,6 @@ impl HolderImpl for Ptr { }); return; } - fn construct_1(&self) { - field!((*self), xs).write(Vec::new()); - field!((*self), ys).write(Vec::new()); - } } pub trait MovableImpl { fn construct(&self, x: i32, y: i32); diff --git a/tests/unit/out/refcount/structured_binding_range_for.rs b/tests/unit/out/refcount/structured_binding_range_for.rs index 61e37232cf..a7d85eaa13 100644 --- a/tests/unit/out/refcount/structured_binding_range_for.rs +++ b/tests/unit/out/refcount/structured_binding_range_for.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 e9256a9569..68638e555d 100644 --- a/tests/unit/out/refcount/structured_binding_ref.rs +++ b/tests/unit/out/refcount/structured_binding_ref.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 6835c2cbb1..deb1d0e7df 100644 --- a/tests/unit/out/refcount/structured_binding_trivial.rs +++ b/tests/unit/out/refcount/structured_binding_trivial.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 a4282d9c0d..89105bcc98 100644 --- a/tests/unit/out/refcount/swap_map_no_copy.rs +++ b/tests/unit/out/refcount/swap_map_no_copy.rs @@ -18,6 +18,11 @@ pub struct Tracked { #[offset(0)] pub v: i32, } +impl DefaultConstructible for Tracked { + fn default_constructor(this: &Ptr) { + field!((*this), v).write(0); + } +} impl CopyConstructible for Tracked { fn copy_constructor(this: &Ptr, o: Ptr) { field!((*this), v).write(o.with(|__s| __s.v)); @@ -50,19 +55,12 @@ impl Clone for Tracked { Rc::try_unwrap(__v).ok().unwrap().into_inner() } } -impl DefaultConstructible for Tracked { - fn default_constructor(this: &Ptr) { - { - TrackedImpl::construct_2(this); - } - } -} impl Default for Tracked { fn default() -> Self { { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - TrackedImpl::construct_2(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -92,9 +90,8 @@ pub struct Pair { } impl DefaultConstructible for Pair { fn default_constructor(this: &Ptr) { - { - PairImpl::construct_1(this); - } + DefaultConstructible::default_constructor(&field_ptr!(this, x)); + DefaultConstructible::default_constructor(&field_ptr!(this, y)); } } #[derive( @@ -122,9 +119,16 @@ pub struct Arrays { } impl DefaultConstructible for Arrays { fn default_constructor(this: &Ptr) { - { - ArraysImpl::construct_1(this); - } + field!((*this), a).write(Box::new(std::array::from_fn::<_, 2, _>(|_| { + let __v: Value = Rc::new(RefCell::new(::zero_init())); + DefaultConstructible::default_constructor(&__v.as_pointer()); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }))); + field!((*this), b).write(Box::new(std::array::from_fn::<_, 2, _>(|_| { + let __v: Value = Rc::new(RefCell::new(::zero_init())); + DefaultConstructible::default_constructor(&__v.as_pointer()); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }))); } } impl Default for Arrays { @@ -337,9 +341,7 @@ pub struct Owner { } impl DefaultConstructible for Owner { fn default_constructor(this: &Ptr) { - { - OwnerImpl::construct_1(this); - } + field!((*this), p).write(None); } } pub fn main() { @@ -623,7 +625,7 @@ fn main_0() -> i32 { ); assert!((copies_0.with(|rc| *rc.borrow()) == 0)); let arrays: Value = Rc::new(RefCell::new(::zero_init())); - ArraysImpl::construct_1(&arrays.as_pointer()); + DefaultConstructible::default_constructor(&arrays.as_pointer()); field!(array_elem!(arrays.as_pointer(), a, 0), v).write(1); field!(array_elem!(arrays.as_pointer(), b, 1), v).write(2); Swappable::swap( @@ -891,23 +893,6 @@ fn main_0() -> i32 { ); return copies_0.with(|rc| *rc.borrow()); } -pub trait ArraysImpl { - fn construct_1(&self); -} -impl ArraysImpl for Ptr { - fn construct_1(&self) { - field!((*self), a).write(Box::new(std::array::from_fn::<_, 2, _>(|_| { - let __v: Value = Rc::new(RefCell::new(::zero_init())); - TrackedImpl::construct_2(&__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }))); - field!((*self), b).write(Box::new(std::array::from_fn::<_, 2, _>(|_| { - let __v: Value = Rc::new(RefCell::new(::zero_init())); - TrackedImpl::construct_2(&__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }))); - } -} pub trait CopyOnlyImpl { fn construct(&self, v: i32); } @@ -924,31 +909,10 @@ impl MovedImpl for Ptr { field!((*self), v).write(v); } } -pub trait OwnerImpl { - fn construct_1(&self); -} -impl OwnerImpl for Ptr { - fn construct_1(&self) { - field!((*self), p).write(None); - } -} -pub trait PairImpl { - fn construct_1(&self); -} -impl PairImpl for Ptr { - fn construct_1(&self) { - TrackedImpl::construct_2(&field_ptr!(self, x)); - TrackedImpl::construct_2(&field_ptr!(self, y)); - } -} pub trait TrackedImpl { - fn construct_2(&self); fn construct_1(&self, v: i32); } impl TrackedImpl for Ptr { - fn construct_2(&self) { - field!((*self), v).write(0); - } fn construct_1(&self, mut v: i32) { field!((*self), v).write(v); } diff --git a/tests/unit/out/refcount/template_default_arg.rs b/tests/unit/out/refcount/template_default_arg.rs index 317c4bd139..f595448251 100644 --- a/tests/unit/out/refcount/template_default_arg.rs +++ b/tests/unit/out/refcount/template_default_arg.rs @@ -17,9 +17,7 @@ pub struct A { } impl DefaultConstructible for A { fn default_constructor(this: &Ptr) { - { - AImpl::construct_2(this); - } + field!((*this), v).write(1); } } impl Default for A { @@ -27,7 +25,7 @@ impl Default for A { { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - AImpl::construct_2(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -41,9 +39,7 @@ pub struct B { } impl DefaultConstructible for B { fn default_constructor(this: &Ptr) { - { - BImpl::construct(this); - } + field!((*this), v).write(2); } } impl Default for B { @@ -51,7 +47,7 @@ impl Default for B { { { let __v: Value = Rc::new(RefCell::new(::zero_init())); - BImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() } } @@ -116,7 +112,7 @@ fn main_0() -> i32 { (({ used_0({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - AImpl::construct_2(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() }) }) == 1) @@ -134,7 +130,7 @@ fn main_0() -> i32 { (({ used_1({ let __v: Value = Rc::new(RefCell::new(::zero_init())); - BImpl::construct(&__v.as_pointer()); + DefaultConstructible::default_constructor(&__v.as_pointer()); Rc::try_unwrap(__v).ok().unwrap().into_inner() }) }) == 2) @@ -186,25 +182,13 @@ fn main_0() -> i32 { return 0; } pub trait AImpl { - fn construct_2(&self); fn construct_1(&self, v: i32); } impl AImpl for Ptr { - fn construct_2(&self) { - field!((*self), v).write(1); - } fn construct_1(&self, mut v: i32) { field!((*self), v).write(v); } } -pub trait BImpl { - fn construct(&self); -} -impl BImpl for Ptr { - fn construct(&self) { - field!((*self), v).write(2); - } -} pub trait NoDefaultImpl { fn construct(&self, v: i32); } diff --git a/tests/unit/out/refcount/template_static_member.rs b/tests/unit/out/refcount/template_static_member.rs index 0e08d06174..8dafaaf0e1 100644 --- a/tests/unit/out/refcount/template_static_member.rs +++ b/tests/unit/out/refcount/template_static_member.rs @@ -17,10 +17,11 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct Static_int_ {} thread_local!( @@ -34,10 +35,11 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct Static_char_ {} thread_local!( @@ -51,10 +53,11 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct Static_long_ {} thread_local!( @@ -71,10 +74,11 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct Range_int_ {} thread_local!( @@ -91,10 +95,11 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 829c7b3ae5..d246ec5fa3 100644 --- a/tests/unit/out/refcount/temporary_field_addr.rs +++ b/tests/unit/out/refcount/temporary_field_addr.rs @@ -28,9 +28,7 @@ pub struct Inner { } impl DefaultConstructible for Inner { fn default_constructor(this: &Ptr) { - { - InnerImpl::construct_1(this); - } + field!((*this), values).write(Vec::new()); } } #[derive( @@ -61,9 +59,9 @@ pub struct Outer { } impl DefaultConstructible for Outer { fn default_constructor(this: &Ptr) { - { - OuterImpl::construct_1(this); - } + field!((*this), values).write(Vec::new()); + DefaultConstructible::default_constructor(&field_ptr!(this, inner)); + field!((*this), name).write((0..8).map(|_| 0_i8).collect::>()); } } impl Default for Outer { @@ -187,22 +185,4 @@ fn main_0() -> i32 { ); return 0; } -pub trait InnerImpl { - fn construct_1(&self); -} -impl InnerImpl for Ptr { - fn construct_1(&self) { - field!((*self), values).write(Vec::new()); - } -} -pub trait OuterImpl { - fn construct_1(&self); -} -impl OuterImpl for Ptr { - fn construct_1(&self) { - field!((*self), values).write(Vec::new()); - InnerImpl::construct_1(&field_ptr!(self, inner)); - field!((*self), name).write((0..8).map(|_| 0_i8).collect::>()); - } -} 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 288cc36f84..dd8e331040 100644 --- a/tests/unit/out/refcount/temporary_field_ctor_arg.rs +++ b/tests/unit/out/refcount/temporary_field_ctor_arg.rs @@ -28,9 +28,7 @@ pub struct Outer { } impl DefaultConstructible for Outer { fn default_constructor(this: &Ptr) { - { - OuterImpl::construct_1(this); - } + field!((*this), values).write(Vec::new()); } } pub fn make_0(this: Ptr) { @@ -86,12 +84,4 @@ impl HImpl for Ptr { field!((*self), last).write((index!(values, 3_usize).read())); } } -pub trait OuterImpl { - fn construct_1(&self); -} -impl OuterImpl for Ptr { - fn construct_1(&self) { - field!((*self), values).write(Vec::new()); - } -} 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 cf7bf240d4..324e8a8a43 100644 --- a/tests/unit/out/refcount/temporary_field_two_args.rs +++ b/tests/unit/out/refcount/temporary_field_two_args.rs @@ -28,9 +28,7 @@ pub struct Inner { } impl DefaultConstructible for Inner { fn default_constructor(this: &Ptr) { - { - InnerImpl::construct_1(this); - } + field!((*this), values).write(Vec::new()); } } #[derive( @@ -58,9 +56,8 @@ pub struct Outer { } impl DefaultConstructible for Outer { fn default_constructor(this: &Ptr) { - { - OuterImpl::construct_1(this); - } + field!((*this), values).write(Vec::new()); + DefaultConstructible::default_constructor(&field_ptr!(this, inner)); } } pub fn make_0(this: Ptr) { @@ -105,21 +102,4 @@ fn main_0() -> i32 { }; return 0; } -pub trait InnerImpl { - fn construct_1(&self); -} -impl InnerImpl for Ptr { - fn construct_1(&self) { - field!((*self), values).write(Vec::new()); - } -} -pub trait OuterImpl { - fn construct_1(&self); -} -impl OuterImpl for Ptr { - fn construct_1(&self) { - field!((*self), values).write(Vec::new()); - InnerImpl::construct_1(&field_ptr!(self, 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 e7c811d3a4..05797da470 100644 --- a/tests/unit/out/refcount/typedef-anon-struct.rs +++ b/tests/unit/out/refcount/typedef-anon-struct.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct Outer_RunInfo { #[offset(0)] @@ -47,9 +48,7 @@ pub struct Outer { } impl DefaultConstructible for Outer { fn default_constructor(this: &Ptr) { - { - OuterImpl::construct_1(this); - } + field!((*this), runs).write(Vec::new()); } } pub fn main() { @@ -58,7 +57,7 @@ pub fn main() { } fn main_0() -> i32 { let o: Value = Rc::new(RefCell::new(::zero_init())); - OuterImpl::construct_1(&o.as_pointer()); + DefaultConstructible::default_constructor(&o.as_pointer()); let mut info: Outer_RunInfo = ::default(); info.block_idx = 1; info.num_extra_zero_runs = 2; @@ -71,12 +70,4 @@ fn main_0() -> i32 { assert!((vec_elem!(o.as_pointer(), runs, 0_usize).with(|__s| __s.num_extra_zero_runs) == 2)); return 0; } -pub trait OuterImpl { - fn construct_1(&self); -} -impl OuterImpl for Ptr { - fn construct_1(&self) { - field!((*self), runs).write(Vec::new()); - } -} 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 c58d657e22..308b333975 100644 --- a/tests/unit/out/refcount/unary_expr_or_type_trait.rs +++ b/tests/unit/out/refcount/unary_expr_or_type_trait.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 61337a7936..eb56995aa9 100644 --- a/tests/unit/out/refcount/unboxed_locals.rs +++ b/tests/unit/out/refcount/unboxed_locals.rs @@ -22,10 +22,11 @@ pub fn inc_1(r: Ptr) { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct Pair { #[offset(0)] diff --git a/tests/unit/out/refcount/unboxed_records.rs b/tests/unit/out/refcount/unboxed_records.rs index 0858d9deb1..3b5ea5d7cf 100644 --- a/tests/unit/out/refcount/unboxed_records.rs +++ b/tests/unit/out/refcount/unboxed_records.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct Inner { #[offset(0)] @@ -26,15 +27,9 @@ pub struct Inner { pub b: i32, } #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - DefaultConstructible, - TriviallyCopyable, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, )] +#[memberwise(default_constructor)] #[byte_size(48)] pub struct Cookie { #[offset(0)] @@ -74,9 +69,7 @@ pub struct Counter { } impl DefaultConstructible for Counter { fn default_constructor(this: &Ptr) { - { - CounterImpl::construct_1(this); - } + field!((*this), n).write(0); } } impl Default for Counter { @@ -144,14 +137,13 @@ fn main_0() -> i32 { ({ set_0((field_ptr!(field_addr.as_pointer(), b)), 7) }); assert!(({ (*field_addr.borrow()).b } == 7)); let counter: Value = Rc::new(RefCell::new(::zero_init())); - CounterImpl::construct_1(&counter.as_pointer()); + DefaultConstructible::default_constructor(&counter.as_pointer()); ({ CounterImpl::inc(&counter.as_pointer()) }); assert!(({ (*counter.borrow()).n } == 1)); return 0; } pub trait CounterImpl { fn inc(&self); - fn construct_1(&self); } impl CounterImpl for Ptr { fn inc(&self) { @@ -159,8 +151,5 @@ impl CounterImpl for Ptr { __v.prefix_inc(); }); } - fn construct_1(&self) { - field!((*self), n).write(0); - } } pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/unique_ptr.rs b/tests/unit/out/refcount/unique_ptr.rs index 9374f54ebb..ecf779d62a 100644 --- a/tests/unit/out/refcount/unique_ptr.rs +++ b/tests/unit/out/refcount/unique_ptr.rs @@ -18,9 +18,7 @@ pub struct SafePointer { } impl DefaultConstructible for SafePointer { fn default_constructor(this: &Ptr) { - { - SafePointerImpl::construct_1(this); - } + field!((*this), ptr).write(None); } } #[derive( @@ -31,10 +29,11 @@ impl DefaultConstructible for SafePointer { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct Pair { #[offset(0)] @@ -249,7 +248,6 @@ impl PairImpl for Ptr { } pub trait SafePointerImpl { fn inc(&self); - fn construct_1(&self); } impl SafePointerImpl for Ptr { fn inc(&self) { @@ -260,8 +258,5 @@ impl SafePointerImpl for Ptr { __v.prefix_inc(); }); } - fn construct_1(&self) { - field!((*self), ptr).write(None); - } } 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 ccccc74ed5..dcdbf722b9 100644 --- a/tests/unit/out/refcount/unique_ptr_const_deref.rs +++ b/tests/unit/out/refcount/unique_ptr_const_deref.rs @@ -18,9 +18,7 @@ pub struct Holder { } impl DefaultConstructible for Holder { fn default_constructor(this: &Ptr) { - { - HolderImpl::construct_1(this); - } + field!((*this), val).write(None); } } pub fn read_val_0(mut h: Ptr) -> i32 { @@ -35,7 +33,7 @@ pub fn main() { } fn main_0() -> i32 { let h: Value = Rc::new(RefCell::new(::zero_init())); - HolderImpl::construct_1(&h.as_pointer()); + DefaultConstructible::default_constructor(&h.as_pointer()); { (*h.borrow_mut()).val = Some(Rc::new(RefCell::new(10))).take(); }; @@ -43,12 +41,4 @@ fn main_0() -> i32 { assert!((({ read_val_0((h.as_pointer()),) }) == 42)); return 0; } -pub trait HolderImpl { - fn construct_1(&self); -} -impl HolderImpl for Ptr { - fn construct_1(&self) { - field!((*self), val).write(None); - } -} 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 5ab941d468..4a8f86e0d7 100644 --- a/tests/unit/out/refcount/unique_ptr_field_reset.rs +++ b/tests/unit/out/refcount/unique_ptr_field_reset.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Data { #[offset(0)] @@ -37,9 +38,8 @@ pub struct Holder { } impl DefaultConstructible for Holder { fn default_constructor(this: &Ptr) { - { - HolderImpl::construct_1(this); - } + field!((*this), data).write(None); + field!((*this), n).write(0_i32); } } pub fn main() { @@ -48,7 +48,7 @@ pub fn main() { } fn main_0() -> i32 { let h: Value = Rc::new(RefCell::new(::zero_init())); - HolderImpl::construct_1(&h.as_pointer()); + DefaultConstructible::default_constructor(&h.as_pointer()); (*h.borrow_mut()).n = 1; let mut hp: Ptr = (h.as_pointer()); { @@ -82,7 +82,6 @@ fn main_0() -> i32 { } pub trait HolderImpl { fn set(&self, p: Ptr); - fn construct_1(&self); } impl HolderImpl for Ptr { fn set(&self, mut p: Ptr) { @@ -91,9 +90,5 @@ impl HolderImpl for Ptr { field_ptr!((*self), data).write(_p.to_owned_opt()) }; } - fn construct_1(&self) { - field!((*self), data).write(None); - field!((*self), n).write(0_i32); - } } 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 bc6beab004..b25972dd3d 100644 --- a/tests/unit/out/refcount/unique_ptr_nested.rs +++ b/tests/unit/out/refcount/unique_ptr_nested.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct Inner { #[offset(0)] @@ -37,9 +38,7 @@ pub struct Outer { } impl DefaultConstructible for Outer { fn default_constructor(this: &Ptr) { - { - OuterImpl::construct_1(this); - } + field!((*this), inner).write(None); } } pub fn main() { @@ -69,12 +68,4 @@ fn main_0() -> i32 { assert!(((sum + (b.as_pointer().read())) == 135)); return 0; } -pub trait OuterImpl { - fn construct_1(&self); -} -impl OuterImpl for Ptr { - fn construct_1(&self) { - field!((*self), inner).write(None); - } -} 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 0e5a291a3c..05afdafb01 100644 --- a/tests/unit/out/refcount/unique_ptr_struct.rs +++ b/tests/unit/out/refcount/unique_ptr_struct.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct Point { #[offset(0)] diff --git a/tests/unit/out/refcount/va_list_field.rs b/tests/unit/out/refcount/va_list_field.rs index d579c7ca12..8b546942eb 100644 --- a/tests/unit/out/refcount/va_list_field.rs +++ b/tests/unit/out/refcount/va_list_field.rs @@ -81,10 +81,11 @@ pub fn sum_ptr_2(n: i32, __args: Box<[VaArg]>) -> i32 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 656c95f152..c238d0d575 100644 --- a/tests/unit/out/refcount/vector.rs +++ b/tests/unit/out/refcount/vector.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct S { #[offset(0)] @@ -49,9 +50,8 @@ pub struct Foo { } impl DefaultConstructible for Foo { fn default_constructor(this: &Ptr) { - { - FooImpl::construct_1(this); - } + field!((*this), a).write(Vec::new()); + field!((*this), b).write(Vec::new()); } } #[derive( @@ -526,7 +526,7 @@ fn main_0() -> i32 { }) ); let foo: Value = Rc::new(RefCell::new(::zero_init())); - FooImpl::construct_1(&foo.as_pointer()); + DefaultConstructible::default_constructor(&foo.as_pointer()); { let __a1 = 5; (*foo.borrow_mut()).a.push(__a1) @@ -774,15 +774,6 @@ fn main_0() -> i32 { } return 0; } -pub trait FooImpl { - fn construct_1(&self); -} -impl FooImpl for Ptr { - fn construct_1(&self) { - field!((*self), a).write(Vec::new()); - field!((*self), b).write(Vec::new()); - } -} pub trait WrappedImpl { fn construct(&self, v: i32); } diff --git a/tests/unit/out/refcount/vector_iter_range_ctor.rs b/tests/unit/out/refcount/vector_iter_range_ctor.rs index f7daeb91b2..1c65c3a547 100644 --- a/tests/unit/out/refcount/vector_iter_range_ctor.rs +++ b/tests/unit/out/refcount/vector_iter_range_ctor.rs @@ -34,10 +34,11 @@ pub struct Degrees { VaArg, FnPtrArg, CppFrom, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 c158a753e8..a54801b365 100644 --- a/tests/unit/out/refcount/vector_subscript_direct.rs +++ b/tests/unit/out/refcount/vector_subscript_direct.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(8)] pub struct Point { #[offset(0)] @@ -50,9 +51,8 @@ pub struct Holder { } impl DefaultConstructible for Holder { fn default_constructor(this: &Ptr) { - { - HolderImpl::construct_1(this); - } + field!((*this), values).write(Vec::new()); + field!((*this), points).write(Vec::new()); } } pub fn push_and_index_0(v: Ptr>) -> i32 { @@ -112,7 +112,7 @@ fn main_0() -> i32 { assert!(({ (*v.borrow())[2_usize] } == 9)); assert!((({ sum_ref_1(v.as_pointer(),) }) == ((((3 + 0) + 9) + 42) + 5))); let h: Value = Rc::new(RefCell::new(::zero_init())); - HolderImpl::construct_1(&h.as_pointer()); + DefaultConstructible::default_constructor(&h.as_pointer()); (*h.borrow_mut()).values.resize_with(2_usize, || 0_i32); vec_elem!(h.as_pointer(), values, 1_usize).write(6); { @@ -163,15 +163,6 @@ fn main_0() -> i32 { assert!(({ (*a.borrow())[1_usize] } == 10)); return 0; } -pub trait HolderImpl { - fn construct_1(&self); -} -impl HolderImpl for Ptr { - fn construct_1(&self) { - field!((*self), values).write(Vec::new()); - field!((*self), points).write(Vec::new()); - } -} pub trait PointImpl { fn sum(&self) -> i32; } diff --git a/tests/unit/out/refcount/vector_with_allocator.rs b/tests/unit/out/refcount/vector_with_allocator.rs index 1f263c4fcd..a2a7b7b5e7 100644 --- a/tests/unit/out/refcount/vector_with_allocator.rs +++ b/tests/unit/out/refcount/vector_with_allocator.rs @@ -14,10 +14,11 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(1)] pub struct TestAllocator_int_ {} #[derive( @@ -28,10 +29,11 @@ pub struct TestAllocator_int_ {} ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[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 3af4d6bce7..4a50e89fb3 100644 --- a/tests/unit/out/refcount/void_cast.rs +++ b/tests/unit/out/refcount/void_cast.rs @@ -29,9 +29,7 @@ pub struct NonTrivial { } impl DefaultConstructible for NonTrivial { fn default_constructor(this: &Ptr) { - { - NonTrivialImpl::construct_1(this); - } + field!((*this), data).write(Vec::new()); } } pub fn unused_ref_param_1(x: Ptr) {} @@ -51,10 +49,11 @@ pub fn bump_and_return_4() -> i32 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + Memberwise, TriviallyCopyable, Default, )] +#[memberwise(default_constructor)] #[byte_size(4)] pub struct Holder { #[offset(0)] @@ -72,9 +71,7 @@ pub struct NonCopyable { } impl DefaultConstructible for NonCopyable { fn default_constructor(this: &Ptr) { - { - NonCopyableImpl::construct_1(this); - } + field!((*this), value).write(None); } } pub fn unused_noncopyable_param_5(x: Ptr) {} @@ -126,7 +123,7 @@ fn main_0() -> i32 { let h: Value = Rc::new(RefCell::new(Holder { field: 17 })); let mut hp: Ptr = (h.as_pointer()); let nt: Value = Rc::new(RefCell::new(::zero_init())); - NonTrivialImpl::construct_1(&nt.as_pointer()); + DefaultConstructible::default_constructor(&nt.as_pointer()); ({ unused_ref_param_1(nt.as_pointer()) }); ({ unused_ptr_param_2((nt.as_pointer())) }); let g: Value = Rc::new(RefCell::new(NonCopyable { @@ -137,22 +134,6 @@ fn main_0() -> i32 { assert!((({ (*g.borrow()).value.clone() }.as_pointer().read()) == 9)); return 0; } -pub trait NonCopyableImpl { - fn construct_1(&self); -} -impl NonCopyableImpl for Ptr { - fn construct_1(&self) { - field!((*self), value).write(None); - } -} -pub trait NonTrivialImpl { - fn construct_1(&self); -} -impl NonTrivialImpl for Ptr { - fn construct_1(&self) { - field!((*self), data).write(Vec::new()); - } -} pub fn __cpp2rust_init_globals() { let _ = side_effect_counter_3.with(|_| ()); } diff --git a/tests/unit/out/unsafe/05_new.rs b/tests/unit/out/unsafe/05_new.rs index cc653b829b..3158e132a9 100644 --- a/tests/unit/out/unsafe/05_new.rs +++ b/tests/unit/out/unsafe/05_new.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct A {} #[repr(C)] #[derive( @@ -25,10 +26,11 @@ pub struct A {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 c11c6ef2ab..b173fb9b9f 100644 --- a/tests/unit/out/unsafe/10_struct.rs +++ b/tests/unit/out/unsafe/10_struct.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct GraphNode { pub dst: u32, pub next: *mut GraphNode, @@ -28,10 +29,11 @@ pub struct GraphNode { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Graph { pub V: u32, pub adj: *mut *mut GraphNode, @@ -54,18 +56,13 @@ pub struct Partial { pub p: *mut i32, } impl Partial { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.p).write(std::ptr::null_mut()); - } - pub unsafe fn construct_2(&mut self, mut q: *mut i32) { + pub unsafe fn construct_1(&mut self, mut q: *mut i32) { (&raw mut self.p).write(q); } } impl DefaultConstructibleUnsafe for Partial { unsafe fn default_constructor(&mut self) { - unsafe { - Partial::construct_1(&mut *self); - } + (&raw mut self.p).write(std::ptr::null_mut()); } } impl Default for Partial { @@ -97,10 +94,11 @@ impl Declared {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct S { pub i: i32, pub d: *mut Declared, @@ -118,12 +116,12 @@ unsafe fn main_0() -> i32 { }; let mut arr: [i32; 3] = [3, 1, 4]; let mut it: Partial = ::zero_init(); - Partial::construct_2(&mut it, { arr.as_mut_ptr() }); + Partial::construct_1(&mut it, { arr.as_mut_ptr() }); if ((it.p) != (arr.as_mut_ptr())) { return 1; } let mut def: Partial = ::zero_init(); - Partial::construct_1(&mut def); + DefaultConstructibleUnsafe::default_constructor(&mut def); if !((def.p).is_null()) { return 1; } diff --git a/tests/unit/out/unsafe/addr_of_global.rs b/tests/unit/out/unsafe/addr_of_global.rs index 44b8278e34..1d664375e5 100644 --- a/tests/unit/out/unsafe/addr_of_global.rs +++ b/tests/unit/out/unsafe/addr_of_global.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Inner { pub value: i32, } @@ -27,10 +28,11 @@ pub struct Inner { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 09d28d8fd8..6b58974607 100644 --- a/tests/unit/out/unsafe/anonymous-struct.rs +++ b/tests/unit/out/unsafe/anonymous-struct.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Outer_Named { pub a: i32, pub b: i32, @@ -28,10 +29,11 @@ pub struct Outer_Named { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct anon_0 { pub c: i32, pub d: i32, @@ -43,10 +45,11 @@ pub struct anon_0 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct anon_1 { pub g: i32, pub h: i32, @@ -58,10 +61,11 @@ pub struct anon_1 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct anon_2 { pub e: i32, pub f: i32, @@ -73,10 +77,11 @@ pub struct anon_2 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct anon_4 { pub j: i32, } @@ -87,10 +92,11 @@ pub struct anon_4 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct anon_5 { pub k: i32, } @@ -101,10 +107,11 @@ pub struct anon_5 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct anon_3 { pub i: i32, pub inner_named: anon_4, @@ -117,10 +124,11 @@ pub struct anon_3 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Outer { pub named: Outer_Named, pub anonymous_named_0: anon_0, @@ -182,10 +190,11 @@ unsafe fn main_0() -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 6aa9b0ae63..006a3afdd1 100644 --- a/tests/unit/out/unsafe/anonymous_enum.rs +++ b/tests/unit/out/unsafe/anonymous_enum.rs @@ -19,10 +19,11 @@ pub const anon_1_SECOND_B: anon_1 = 1; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct S { pub a: i32, } @@ -39,10 +40,11 @@ pub const anon_2_FIELD_B: anon_2 = 1; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct WithAnonField { pub a: i32, pub field: anon_2, diff --git a/tests/unit/out/unsafe/array_of_noncopy_struct.rs b/tests/unit/out/unsafe/array_of_noncopy_struct.rs index f0f5ef1690..ce87fa9d47 100644 --- a/tests/unit/out/unsafe/array_of_noncopy_struct.rs +++ b/tests/unit/out/unsafe/array_of_noncopy_struct.rs @@ -22,17 +22,10 @@ pub struct NonCopy { pub data: Vec, pub tag: i32, } -impl NonCopy { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.data).write(Vec::new()); - (&raw mut self.tag).write(0); - } -} impl DefaultConstructibleUnsafe for NonCopy { unsafe fn default_constructor(&mut self) { - unsafe { - NonCopy::construct_1(&mut *self); - } + (&raw mut self.data).write(Vec::new()); + (&raw mut self.tag).write(0); } } impl Default for NonCopy { @@ -54,7 +47,7 @@ pub fn main() { unsafe fn main_0() -> i32 { let mut arr: [NonCopy; 3] = std::array::from_fn::<_, 3, _>(|_| { let mut __v: NonCopy = ::zero_init(); - NonCopy::construct_1(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v }); arr[(0) as usize].tag = 7; diff --git a/tests/unit/out/unsafe/array_reference.rs b/tests/unit/out/unsafe/array_reference.rs index 78e86fc7ef..76aa1b2ed2 100644 --- a/tests/unit/out/unsafe/array_reference.rs +++ b/tests/unit/out/unsafe/array_reference.rs @@ -63,10 +63,11 @@ pub unsafe fn pick_10(s: *const [libc::c_char; 5]) -> *const [libc::c_char; 5] { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 0f588d00a6..c7b393f371 100644 --- a/tests/unit/out/unsafe/as_const.rs +++ b/tests/unit/out/unsafe/as_const.rs @@ -16,10 +16,11 @@ pub const Overload_kConstOverload: Overload = 2; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 feffbe6373..bcbffb5a8c 100644 --- a/tests/unit/out/unsafe/assign_rhs_first.rs +++ b/tests/unit/out/unsafe/assign_rhs_first.rs @@ -19,10 +19,11 @@ pub unsafe fn advance_1() -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 895ca1a436..0f4c5c263c 100644 --- a/tests/unit/out/unsafe/assignment_single_eval.rs +++ b/tests/unit/out/unsafe/assignment_single_eval.rs @@ -928,10 +928,11 @@ pub unsafe fn test_pointer_elements_11() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Holder_12 { pub p: *mut i32, } @@ -1045,10 +1046,11 @@ pub unsafe fn test_reference_subfields_18() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Index_16 { pub value: u32, } @@ -1073,10 +1075,11 @@ pub struct Slot_17 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Index_19 { pub value: i16, } @@ -1136,10 +1139,11 @@ pub unsafe fn observe_24(mut assigned: i32, mut stored: *const i32) -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct GlobalRecord_Inner { pub value: i32, } @@ -1150,10 +1154,11 @@ pub struct GlobalRecord_Inner { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct GlobalRecord { pub inner: GlobalRecord_Inner, } @@ -1425,10 +1430,11 @@ static mut flag_31: std::cell::LazyCell = std::cell::LazyCell::new(|| unsa VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Record_32 { pub value: i32, } @@ -1439,10 +1445,11 @@ pub struct Record_32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Link_33 { pub next: *mut Link_33, } @@ -1455,10 +1462,11 @@ pub static mut selected_values_34: std::cell::LazyCell<[u32; 3]> = VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct IndexedBinding {} impl IndexedBinding { pub unsafe fn get_1_0(&mut self) -> *mut u32 { @@ -1683,10 +1691,11 @@ pub static mut global_rows_46: std::cell::LazyCell<[[u32; 2]; 2]> = VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct IndexedMember { pub key: i32, pub value: u32, @@ -1951,10 +1960,11 @@ pub static mut scoped_pointers_53: std::cell::LazyCell<[*mut u32; 1]> = VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct PointerSelector { pub ptr: *mut u32, } @@ -2125,16 +2135,9 @@ pub unsafe fn test_stable_containers_58() { pub struct Counts_59 { pub counts: Vec, } -impl Counts_59 { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.counts).write(Vec::new()); - } -} impl DefaultConstructibleUnsafe for Counts_59 { unsafe fn default_constructor(&mut self) { - unsafe { - Counts_59::construct_1(&mut *self); - } + (&raw mut self.counts).write(Vec::new()); } } #[repr(C)] @@ -2144,10 +2147,11 @@ impl DefaultConstructibleUnsafe for Counts_59 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Pair_60 { pub u: u32, pub f: i32, @@ -2455,10 +2459,11 @@ unsafe fn main_0() -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Index_62 { pub value: i32, } @@ -2469,10 +2474,11 @@ pub struct Index_62 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 f91cfe97fe..f5b967b39e 100644 --- a/tests/unit/out/unsafe/bounded_struct_ptr.rs +++ b/tests/unit/out/unsafe/bounded_struct_ptr.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 b432bb8fab..da743a7a46 100644 --- a/tests/unit/out/unsafe/bst.rs +++ b/tests/unit/out/unsafe/bst.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct node_t { pub left: *mut node_t, pub right: *mut node_t, diff --git a/tests/unit/out/unsafe/cast.rs b/tests/unit/out/unsafe/cast.rs index a9f65b426c..c32f956c62 100644 --- a/tests/unit/out/unsafe/cast.rs +++ b/tests/unit/out/unsafe/cast.rs @@ -17,10 +17,11 @@ pub const E_C: E = 2; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Pair { pub x: i32, pub y: i32, @@ -32,10 +33,11 @@ pub struct Pair { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Wide { pub c: libc::c_char, } @@ -46,10 +48,11 @@ pub struct Wide { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Grid { pub h: i32, pub row: [i32; 3], @@ -72,17 +75,10 @@ pub struct Bag { pub n: i32, pub items: Vec, } -impl Bag { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.n).write(0_i32); - (&raw mut self.items).write(Vec::new()); - } -} impl DefaultConstructibleUnsafe for Bag { unsafe fn default_constructor(&mut self) { - unsafe { - Bag::construct_1(&mut *self); - } + (&raw mut self.n).write(0_i32); + (&raw mut self.items).write(Vec::new()); } } pub unsafe fn adjacent_arrays_0() { @@ -318,7 +314,7 @@ pub unsafe fn nested_5() { assert!(((pm) == (&mut m[(1) as usize][(1) as usize] as *mut i32))); assert!(((pm) < (&mut m[(2) as usize][(0) as usize] as *mut i32))); let mut b: Bag = ::zero_init(); - Bag::construct_1(&mut b); + DefaultConstructibleUnsafe::default_constructor(&mut b); if 4_usize > b.items.capacity() as usize { let len_0 = b.items.len(); b.items.reserve_exact(4_usize - len_0 as usize); 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 6c60f4d038..ac129d2de3 100644 --- a/tests/unit/out/unsafe/cast_array_to_pointer_decay.rs +++ b/tests/unit/out/unsafe/cast_array_to_pointer_decay.rs @@ -23,10 +23,11 @@ pub unsafe fn strlen_1(mut s: *mut libc::c_char) -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Row { pub a: [i32; 3], } diff --git a/tests/unit/out/unsafe/class.rs b/tests/unit/out/unsafe/class.rs index 5abf17bdae..3941476384 100644 --- a/tests/unit/out/unsafe/class.rs +++ b/tests/unit/out/unsafe/class.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Pair { pub first: i32, pub second: i32, @@ -57,10 +58,11 @@ impl Pair { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Route { pub path: Pair, pub cost: f64, @@ -79,10 +81,11 @@ impl Route { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Counter { pub v: i32, pub calls: i32, @@ -110,10 +113,11 @@ impl std::cmp::Eq for Counter {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 c3ce7d0ea8..c414598b10 100644 --- a/tests/unit/out/unsafe/class_template_lazy_member.rs +++ b/tests/unit/out/unsafe/class_template_lazy_member.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Point { pub x: i32, } @@ -27,10 +28,11 @@ pub struct Point { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Box_int_ { pub val: i32, } @@ -46,10 +48,11 @@ impl Box_int_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Box_Point_ { pub val: Point, } @@ -65,10 +68,11 @@ impl Box_Point_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Deduced_int_ { pub val: i32, } @@ -84,10 +88,11 @@ impl Deduced_int_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 882f0fd5b3..c2a4f9d216 100644 --- a/tests/unit/out/unsafe/class_templates.rs +++ b/tests/unit/out/unsafe/class_templates.rs @@ -45,15 +45,10 @@ impl MyContainer_int_ { self.vec_.push(a0_clone) }; } - pub unsafe fn construct_1(&mut self) { - (&raw mut self.vec_).write(Vec::new()); - } } impl DefaultConstructibleUnsafe for MyContainer_int_ { unsafe fn default_constructor(&mut self) { - unsafe { - MyContainer_int_::construct_1(&mut *self); - } + (&raw mut self.vec_).write(Vec::new()); } } #[repr(C)] @@ -95,15 +90,10 @@ impl MyContainer_char_ { self.vec_.push(a0_clone) }; } - pub unsafe fn construct_1(&mut self) { - (&raw mut self.vec_).write(Vec::new()); - } } impl DefaultConstructibleUnsafe for MyContainer_char_ { unsafe fn default_constructor(&mut self) { - unsafe { - MyContainer_char_::construct_1(&mut *self); - } + (&raw mut self.vec_).write(Vec::new()); } } #[repr(C)] @@ -145,15 +135,10 @@ impl MyContainer_float_ { self.vec_.push(a0_clone) }; } - pub unsafe fn construct_1(&mut self) { - (&raw mut self.vec_).write(Vec::new()); - } } impl DefaultConstructibleUnsafe for MyContainer_float_ { unsafe fn default_constructor(&mut self) { - unsafe { - MyContainer_float_::construct_1(&mut *self); - } + (&raw mut self.vec_).write(Vec::new()); } } #[repr(C)] @@ -163,10 +148,11 @@ impl DefaultConstructibleUnsafe for MyContainer_float_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Boxed_short_ { pub value: i16, } @@ -185,10 +171,11 @@ impl Boxed_short_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Boxed_int_ { pub value: i32, } @@ -207,10 +194,11 @@ impl Boxed_int_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Boxed_long_ { pub value: i64, } @@ -229,10 +217,11 @@ impl Boxed_long_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Outer_int__Inner_int_ { pub t: i32, pub u: i32, @@ -249,10 +238,11 @@ impl Outer_int__Inner_int_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Outer_int_ { pub v: i32, } @@ -268,10 +258,11 @@ impl Outer_int_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Outer_long__Inner_int_ { pub t: i64, pub u: i32, @@ -288,10 +279,11 @@ impl Outer_long__Inner_int_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Outer_long__Inner_char_ { pub t: i64, pub u: libc::c_char, @@ -308,10 +300,11 @@ impl Outer_long__Inner_char_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Outer_long_ { pub v: i64, } @@ -327,10 +320,11 @@ impl Outer_long_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Elem { pub i: i32, } @@ -371,7 +365,7 @@ unsafe fn main_0() -> i32 { let mut bl: Boxed_long_ = Boxed_long_ { value: 7_i64 }; assert!(((unsafe { Boxed_long_::plus(&bl, 1_i64,) }) == (8_i64))); let mut imc: MyContainer_int_ = ::zero_init(); - MyContainer_int_::construct_1(&mut imc); + DefaultConstructibleUnsafe::default_constructor(&mut imc); assert!((unsafe { MyContainer_int_::empty(&imc,) })); (unsafe { let mut _item: i32 = 1; @@ -384,7 +378,7 @@ unsafe fn main_0() -> i32 { (unsafe { MyContainer_int_::pop_back(&mut imc) }); assert!((unsafe { MyContainer_int_::empty(&imc,) })); let mut cmc: MyContainer_char_ = ::zero_init(); - MyContainer_char_::construct_1(&mut cmc); + DefaultConstructibleUnsafe::default_constructor(&mut cmc); assert!((unsafe { MyContainer_char_::empty(&cmc,) })); (unsafe { let mut _item: libc::c_char = ('a' as libc::c_char); @@ -398,7 +392,7 @@ unsafe fn main_0() -> i32 { (unsafe { MyContainer_char_::pop_back(&mut cmc) }); assert!((unsafe { MyContainer_char_::empty(&cmc,) })); let mut fmc: MyContainer_float_ = ::zero_init(); - MyContainer_float_::construct_1(&mut fmc); + DefaultConstructibleUnsafe::default_constructor(&mut fmc); assert!((unsafe { MyContainer_float_::empty(&fmc,) })); (unsafe { let mut _item: f32 = (1_f64 as f32); diff --git a/tests/unit/out/unsafe/clone_vs_move.rs b/tests/unit/out/unsafe/clone_vs_move.rs index b5023712ee..dec18f1168 100644 --- a/tests/unit/out/unsafe/clone_vs_move.rs +++ b/tests/unit/out/unsafe/clone_vs_move.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Bar { pub w: i32, } diff --git a/tests/unit/out/unsafe/comma_operator.rs b/tests/unit/out/unsafe/comma_operator.rs index 0a64b4139d..86864b4712 100644 --- a/tests/unit/out/unsafe/comma_operator.rs +++ b/tests/unit/out/unsafe/comma_operator.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 40e776cfc3..eb36708200 100644 --- a/tests/unit/out/unsafe/complex_function.rs +++ b/tests/unit/out/unsafe/complex_function.rs @@ -22,10 +22,11 @@ pub unsafe fn bar_2(x: *mut i32) -> *mut i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct X1 { pub v: i32, } @@ -55,10 +56,11 @@ impl X2 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct X3 { pub v: *mut X2, } @@ -74,10 +76,11 @@ impl X3 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 638c56aec7..954e808663 100644 --- a/tests/unit/out/unsafe/compound_assign_paren.rs +++ b/tests/unit/out/unsafe/compound_assign_paren.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Item { pub flags: u8, } diff --git a/tests/unit/out/unsafe/concepts.rs b/tests/unit/out/unsafe/concepts.rs index 4d03a62955..9dcb70434d 100644 --- a/tests/unit/out/unsafe/concepts.rs +++ b/tests/unit/out/unsafe/concepts.rs @@ -18,10 +18,11 @@ const _: () = assert!( VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 b148348ec7..c4734b9e75 100644 --- a/tests/unit/out/unsafe/constexpr_function.rs +++ b/tests/unit/out/unsafe/constexpr_function.rs @@ -28,10 +28,11 @@ pub unsafe fn half_3(mut x: f64) -> f64 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Flag { pub v: i32, } @@ -63,10 +64,11 @@ pub unsafe fn imm_7(mut b: bool) -> bool { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct P { pub v: i32, } diff --git a/tests/unit/out/unsafe/constructor.rs b/tests/unit/out/unsafe/constructor.rs index d1ba2946d2..8b32fe97b9 100644 --- a/tests/unit/out/unsafe/constructor.rs +++ b/tests/unit/out/unsafe/constructor.rs @@ -64,16 +64,11 @@ impl Point { Point::construct_2(&mut *self, { v }, { ((v) + (1)) }); self.y *= 10; } - pub unsafe fn construct_3(&mut self) { - Point::construct_1(&mut *self, { 4 }); - self.x += 100; - } } impl DefaultConstructibleUnsafe for Point { unsafe fn default_constructor(&mut self) { - unsafe { - Point::construct_3(&mut *self); - } + Point::construct_1(&mut *self, { 4 }); + self.x += 100; } } impl Default for Point { @@ -81,7 +76,7 @@ impl Default for Point { unsafe { { let mut __v: Point = ::zero_init(); - Point::construct_3(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -105,7 +100,7 @@ unsafe fn main_0() -> i32 { } assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut total_0)) == (18))); let mut p: Point = ::zero_init(); - Point::construct_3(&mut p); + DefaultConstructibleUnsafe::default_constructor(&mut p); assert!(((p.x) == (104))); assert!(((p.y) == (50))); let mut q: Point = ::zero_init(); diff --git a/tests/unit/out/unsafe/container_field_addr.rs b/tests/unit/out/unsafe/container_field_addr.rs index f40b97c252..bcd097a4ca 100644 --- a/tests/unit/out/unsafe/container_field_addr.rs +++ b/tests/unit/out/unsafe/container_field_addr.rs @@ -23,17 +23,10 @@ pub struct S { pub tag: i32, pub v: Vec, } -impl S { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.tag).write(0_i32); - (&raw mut self.v).write(Vec::new()); - } -} impl DefaultConstructibleUnsafe for S { unsafe fn default_constructor(&mut self) { - unsafe { - S::construct_1(&mut *self); - } + (&raw mut self.tag).write(0_i32); + (&raw mut self.v).write(Vec::new()); } } pub unsafe fn add_0(mut v: *mut Vec, mut k: i32) { @@ -67,12 +60,12 @@ pub fn main() { } unsafe fn main_0() -> i32 { let mut local: S = ::zero_init(); - S::construct_1(&mut local); + DefaultConstructibleUnsafe::default_constructor(&mut local); local.tag = 7; (unsafe { run_1((&mut local as *mut S)) }); let mut heap: *mut S = { let __p: *mut S = Box::leak(Box::new(::zero_init())); - S::construct_1(&mut *__p); + DefaultConstructibleUnsafe::default_constructor(&mut *__p); __p }; (*heap).tag = 7; diff --git a/tests/unit/out/unsafe/conversion_operator_same_translation.rs b/tests/unit/out/unsafe/conversion_operator_same_translation.rs index 5b0743d485..8521a78d3c 100644 --- a/tests/unit/out/unsafe/conversion_operator_same_translation.rs +++ b/tests/unit/out/unsafe/conversion_operator_same_translation.rs @@ -14,10 +14,11 @@ use std::rc::Rc; FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] #[cpp_into(libc::c_char, to_libcc_char)] #[cpp_into(u8, to_u8)] pub struct S { @@ -39,10 +40,11 @@ impl S { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] #[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 92ebb0676e..ba4e43a606 100644 --- a/tests/unit/out/unsafe/copy_assign.rs +++ b/tests/unit/out/unsafe/copy_assign.rs @@ -60,9 +60,6 @@ pub struct NonConstAssign { pub mark: i32, } impl NonConstAssign { - pub unsafe fn construct(&mut self) { - (&raw mut self.mark).write(0); - } pub unsafe fn operator_assign_2(&mut self, o: *mut NonConstAssign) -> *mut NonConstAssign { self.mark = (((*o).mark) + (1)); return &mut (*(self as *mut NonConstAssign)); @@ -74,9 +71,7 @@ impl NonConstAssign { } impl DefaultConstructibleUnsafe for NonConstAssign { unsafe fn default_constructor(&mut self) { - unsafe { - NonConstAssign::construct(&mut *self); - } + (&raw mut self.mark).write(0); } } impl Default for NonConstAssign { @@ -84,7 +79,7 @@ impl Default for NonConstAssign { unsafe { { let mut __v: NonConstAssign = ::zero_init(); - NonConstAssign::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -104,8 +99,8 @@ impl Default for NonConstAssign { pub struct RefQualified { pub mark: i32, } -impl RefQualified { - pub unsafe fn construct(&mut self) { +impl DefaultConstructibleUnsafe for RefQualified { + unsafe fn default_constructor(&mut self) { (&raw mut self.mark).write(0); } } @@ -115,19 +110,12 @@ impl CopyAssignableUnsafe for RefQualified { return &mut (*(self as *mut RefQualified)); } } -impl DefaultConstructibleUnsafe for RefQualified { - unsafe fn default_constructor(&mut self) { - unsafe { - RefQualified::construct(&mut *self); - } - } -} impl Default for RefQualified { fn default() -> Self { unsafe { { let mut __v: RefQualified = ::zero_init(); - RefQualified::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -221,11 +209,6 @@ pub struct HasCopyCounted { pub struct ExplicitOperatorCall { pub w: Vec, } -impl ExplicitOperatorCall { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.w).write(Vec::new()); - } -} impl CopyAssignableUnsafe for ExplicitOperatorCall { unsafe fn copy_assign(&mut self, o: *const ExplicitOperatorCall) -> *mut ExplicitOperatorCall { { @@ -236,9 +219,7 @@ impl CopyAssignableUnsafe for ExplicitOperatorCall { } impl DefaultConstructibleUnsafe for ExplicitOperatorCall { unsafe fn default_constructor(&mut self) { - unsafe { - ExplicitOperatorCall::construct_1(&mut *self); - } + (&raw mut self.w).write(Vec::new()); } } pub fn main() { @@ -309,21 +290,21 @@ unsafe fn main_0() -> i32 { 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))); let mut n: NonConstAssign = ::zero_init(); - NonConstAssign::construct(&mut n); + DefaultConstructibleUnsafe::default_constructor(&mut n); let mut n1: NonConstAssign = ::zero_init(); - NonConstAssign::construct(&mut n1); + DefaultConstructibleUnsafe::default_constructor(&mut n1); let mut n2: NonConstAssign = ::zero_init(); - NonConstAssign::construct(&mut n2); + DefaultConstructibleUnsafe::default_constructor(&mut n2); let mut cn: NonConstAssign = ::zero_init(); - NonConstAssign::construct(&mut cn); + DefaultConstructibleUnsafe::default_constructor(&mut cn); (unsafe { NonConstAssign::operator_assign_2(&mut n1, &mut n) }); (unsafe { NonConstAssign::operator_assign_3(&mut n2, &cn) }); assert!(((n1.mark) == (1))); assert!(((n2.mark) == (10))); let mut r: RefQualified = ::zero_init(); - RefQualified::construct(&mut r); + DefaultConstructibleUnsafe::default_constructor(&mut r); let mut r1: RefQualified = ::zero_init(); - RefQualified::construct(&mut r1); + DefaultConstructibleUnsafe::default_constructor(&mut r1); (unsafe { CopyAssignableUnsafe::copy_assign(&mut r1, &r) }); assert!(((r1.mark) == (1))); let mut h2: Holder = Holder { @@ -400,9 +381,9 @@ unsafe fn main_0() -> i32 { ); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_1)) == (0))); let mut e1: ExplicitOperatorCall = ::zero_init(); - ExplicitOperatorCall::construct_1(&mut e1); + DefaultConstructibleUnsafe::default_constructor(&mut e1); let mut e2: ExplicitOperatorCall = ::zero_init(); - ExplicitOperatorCall::construct_1(&mut e2); + DefaultConstructibleUnsafe::default_constructor(&mut e2); { let __a1 = 5; e1.w.push(__a1) diff --git a/tests/unit/out/unsafe/copy_ctor.rs b/tests/unit/out/unsafe/copy_ctor.rs index 0c8db0aa5d..74f4b79ce9 100644 --- a/tests/unit/out/unsafe/copy_ctor.rs +++ b/tests/unit/out/unsafe/copy_ctor.rs @@ -59,9 +59,6 @@ pub struct NonConst { pub mark: i32, } impl NonConst { - pub unsafe fn construct(&mut self) { - (&raw mut self.mark).write(0); - } pub unsafe fn construct_1(&mut self, o: *mut NonConst) { (&raw mut self.mark).write((((*o).mark) + (1))); } @@ -69,6 +66,11 @@ impl NonConst { (&raw mut self.mark).write((((*o).mark) + (10))); } } +impl DefaultConstructibleUnsafe for NonConst { + unsafe fn default_constructor(&mut self) { + (&raw mut self.mark).write(0); + } +} impl Clone for NonConst { fn clone(&self) -> Self { unsafe { @@ -78,19 +80,12 @@ impl Clone for NonConst { } } } -impl DefaultConstructibleUnsafe for NonConst { - unsafe fn default_constructor(&mut self) { - unsafe { - NonConst::construct(&mut *self); - } - } -} impl Default for NonConst { fn default() -> Self { unsafe { { let mut __v: NonConst = ::zero_init(); - NonConst::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -249,8 +244,8 @@ impl Clone for OutOfLine { pub struct Tracked { pub copied_from: i32, } -impl Tracked { - pub unsafe fn construct(&mut self) { +impl DefaultConstructibleUnsafe for Tracked { + unsafe fn default_constructor(&mut self) { (&raw mut self.copied_from).write(0); } } @@ -275,13 +270,6 @@ impl Clone for Tracked { } } } -impl DefaultConstructibleUnsafe for Tracked { - unsafe fn default_constructor(&mut self) { - unsafe { - Tracked::construct(&mut *self); - } - } -} impl Default for Tracked { fn default() -> Self { unsafe { Tracked { copied_from: 0 } } @@ -396,23 +384,23 @@ unsafe fn main_0() -> i32 { assert!(((ol2.v) == (105))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (12))); let mut n: NonConst = ::zero_init(); - NonConst::construct(&mut n); + DefaultConstructibleUnsafe::default_constructor(&mut n); let mut n1: NonConst = ::zero_init(); NonConst::construct_1(&mut n1, { &mut n }); let mut cn: NonConst = ::zero_init(); - NonConst::construct(&mut cn); + DefaultConstructibleUnsafe::default_constructor(&mut cn); let mut n2: NonConst = ::zero_init(); NonConst::construct_2(&mut n2, { &cn }); assert!(((n1.mark) == (1))); assert!(((n2.mark) == (10))); let mut t1: Tracked = ::zero_init(); - Tracked::construct(&mut t1); + DefaultConstructibleUnsafe::default_constructor(&mut t1); let mut t2: Tracked = ::zero_init(); CopyConstructibleUnsafe::copy_constructor(&mut t2, { &t1 }); (unsafe { CopyAssignableUnsafe::copy_assign(&mut t2, &t1) }); assert!(((t1.copied_from) == (2))); let mut ct: Tracked = ::zero_init(); - Tracked::construct(&mut ct); + DefaultConstructibleUnsafe::default_constructor(&mut ct); let mut t3: Tracked = ::zero_init(); CopyConstructibleUnsafe::copy_constructor(&mut t3, { &ct }); (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 473e3cf73c..b43b34703e 100644 --- a/tests/unit/out/unsafe/copy_move_defaulted.rs +++ b/tests/unit/out/unsafe/copy_move_defaulted.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Inner { pub x: i32, } @@ -58,10 +59,11 @@ impl DestructibleUnsafe for Explicit { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Implicit { pub v: i32, pub inner: Inner, @@ -194,21 +196,14 @@ pub struct Owner { pub arr: [i32; 2], pub p: Option>, } -impl Owner { - pub unsafe fn construct_1(&mut self) { +impl DefaultConstructibleUnsafe for Owner { + unsafe fn default_constructor(&mut self) { (&raw mut self.data).write(Vec::new()); (&raw mut self.n).write(0_i32); (&raw mut self.arr).write([0_i32; 2]); (&raw mut self.p).write(None); } } -impl DefaultConstructibleUnsafe for Owner { - unsafe fn default_constructor(&mut self) { - unsafe { - Owner::construct_1(&mut *self); - } - } -} #[repr(C)] #[derive( Clone, @@ -225,16 +220,9 @@ impl DefaultConstructibleUnsafe for Owner { pub struct Copyable { pub data: Vec, } -impl Copyable { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.data).write(Vec::new()); - } -} impl DefaultConstructibleUnsafe for Copyable { unsafe fn default_constructor(&mut self) { - unsafe { - Copyable::construct_1(&mut *self); - } + (&raw mut self.data).write(Vec::new()); } } #[repr(C)] @@ -273,11 +261,6 @@ pub unsafe fn same_0(a: *const Explicit, b: *const Explicit) -> bool { pub struct SeesThis { pub self_: *mut SeesThis, } -impl SeesThis { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.self_).write(std::ptr::null_mut()); - } -} impl CopyAssignableUnsafe for SeesThis { unsafe fn copy_assign(&mut self, _a0: *const SeesThis) -> *mut SeesThis { self.self_ = (self as *mut SeesThis); @@ -292,9 +275,7 @@ impl MoveAssignableUnsafe for SeesThis { } impl DefaultConstructibleUnsafe for SeesThis { unsafe fn default_constructor(&mut self) { - unsafe { - SeesThis::construct_1(&mut *self); - } + (&raw mut self.self_).write(std::ptr::null_mut()); } } impl Default for SeesThis { @@ -313,17 +294,10 @@ pub struct HasSeesThis { pub s: SeesThis, pub v: Vec, } -impl HasSeesThis { - pub unsafe fn construct_1(&mut self) { - SeesThis::construct_1(&mut self.s); - (&raw mut self.v).write(Vec::new()); - } -} impl DefaultConstructibleUnsafe for HasSeesThis { unsafe fn default_constructor(&mut self) { - unsafe { - HasSeesThis::construct_1(&mut *self); - } + DefaultConstructibleUnsafe::default_constructor(&mut self.s); + (&raw mut self.v).write(Vec::new()); } } #[repr(C)] @@ -332,8 +306,8 @@ pub struct Counted_int_ { pub v: i32, pub moves: i32, } -impl Counted_int_ { - pub unsafe fn construct(&mut self) { +impl DefaultConstructibleUnsafe for Counted_int_ { + unsafe fn default_constructor(&mut self) { (&raw mut self.v).write(0_i32); (&raw mut self.moves).write(0); } @@ -351,13 +325,6 @@ impl MoveAssignableUnsafe for Counted_int_ { return &mut (*(self as *mut Counted_int_)); } } -impl DefaultConstructibleUnsafe for Counted_int_ { - unsafe fn default_constructor(&mut self) { - unsafe { - Counted_int_::construct(&mut *self); - } - } -} impl Default for Counted_int_ { fn default() -> Self { unsafe { Counted_int_ { v: 0_i32, moves: 0 } } @@ -377,17 +344,10 @@ pub struct HasCounted { pub c: Counted_int_, pub w: Vec, } -impl HasCounted { - pub unsafe fn construct_1(&mut self) { - Counted_int_::construct(&mut self.c); - (&raw mut self.w).write(Vec::new()); - } -} impl DefaultConstructibleUnsafe for HasCounted { unsafe fn default_constructor(&mut self) { - unsafe { - HasCounted::construct_1(&mut *self); - } + DefaultConstructibleUnsafe::default_constructor(&mut self.c); + (&raw mut self.w).write(Vec::new()); } } #[repr(C)] @@ -400,15 +360,17 @@ pub struct CtorSeesThis { pub id: i32, } impl CtorSeesThis { - pub unsafe fn construct_2(&mut self) { - (&raw mut self.self_).write((self as *mut CtorSeesThis)); - (&raw mut self.id).write(0); - } pub unsafe fn construct_1(&mut self, mut id: i32) { - CtorSeesThis::construct_2(&mut *self); + DefaultConstructibleUnsafe::default_constructor(&mut *self); self.id = id; } } +impl DefaultConstructibleUnsafe for CtorSeesThis { + unsafe fn default_constructor(&mut self) { + (&raw mut self.self_).write((self as *mut CtorSeesThis)); + (&raw mut self.id).write(0); + } +} impl CopyConstructibleUnsafe for CtorSeesThis { unsafe fn copy_constructor(&mut self, _a0: *const CtorSeesThis) { (&raw mut self.self_).write((self as *mut CtorSeesThis)); @@ -440,19 +402,12 @@ impl Clone for CtorSeesThis { } } } -impl DefaultConstructibleUnsafe for CtorSeesThis { - unsafe fn default_constructor(&mut self) { - unsafe { - CtorSeesThis::construct_2(&mut *self); - } - } -} impl Default for CtorSeesThis { fn default() -> Self { unsafe { { let mut __v: CtorSeesThis = ::zero_init(); - CtorSeesThis::construct_2(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -474,17 +429,10 @@ pub struct HasCtorSeesThis { pub x: CtorSeesThis, pub v: Vec, } -impl HasCtorSeesThis { - pub unsafe fn construct_1(&mut self) { - CtorSeesThis::construct_2(&mut self.x); - (&raw mut self.v).write(Vec::new()); - } -} impl DefaultConstructibleUnsafe for HasCtorSeesThis { unsafe fn default_constructor(&mut self) { - unsafe { - HasCtorSeesThis::construct_1(&mut *self); - } + DefaultConstructibleUnsafe::default_constructor(&mut self.x); + (&raw mut self.v).write(Vec::new()); } } #[repr(C)] @@ -502,17 +450,10 @@ pub struct InitsCtorSeesThis { pub x: CtorSeesThis, pub y: CtorSeesThis, } -impl InitsCtorSeesThis { - pub unsafe fn construct(&mut self) { - CtorSeesThis::construct_1(&mut self.x, { 1 }); - CtorSeesThis::construct_1(&mut self.y, { 2 }); - } -} impl DefaultConstructibleUnsafe for InitsCtorSeesThis { unsafe fn default_constructor(&mut self) { - unsafe { - InitsCtorSeesThis::construct(&mut *self); - } + CtorSeesThis::construct_1(&mut self.x, { 1 }); + CtorSeesThis::construct_1(&mut self.y, { 2 }); } } impl Default for InitsCtorSeesThis { @@ -520,7 +461,7 @@ impl Default for InitsCtorSeesThis { unsafe { { let mut __v: InitsCtorSeesThis = ::zero_init(); - InitsCtorSeesThis::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -537,7 +478,7 @@ pub struct OutOfLineDefaulted { } impl OutOfLineDefaulted { pub unsafe fn construct(&mut self) { - CtorSeesThis::construct_2(&mut self.x); + DefaultConstructibleUnsafe::default_constructor(&mut self.x); (&raw mut self.v).write(1); } } @@ -582,18 +523,11 @@ pub struct OutOfLineAssign { pub v: i32, pub w: Vec, } -impl OutOfLineAssign { - pub unsafe fn construct_1(&mut self) { - SeesThis::construct_1(&mut self.s); - (&raw mut self.v).write(1); - (&raw mut self.w).write(Vec::new()); - } -} impl DefaultConstructibleUnsafe for OutOfLineAssign { unsafe fn default_constructor(&mut self) { - unsafe { - OutOfLineAssign::construct_1(&mut *self); - } + DefaultConstructibleUnsafe::default_constructor(&mut self.s); + (&raw mut self.v).write(1); + (&raw mut self.w).write(Vec::new()); } } impl Default for OutOfLineAssign { @@ -786,7 +720,7 @@ unsafe fn main_0() -> i32 { && (bufs[(0_usize)].data.is_empty()) ); let mut o1: Owner = ::zero_init(); - Owner::construct_1(&mut o1); + DefaultConstructibleUnsafe::default_constructor(&mut o1); { let __a1 = 5; o1.data.push(__a1) @@ -821,7 +755,7 @@ unsafe fn main_0() -> i32 { .is_null()) ); let mut o3: Owner = ::zero_init(); - Owner::construct_1(&mut o3); + DefaultConstructibleUnsafe::default_constructor(&mut o3); (unsafe { MoveAssignableUnsafe::move_assign(&mut o3, &mut o2) }); assert!( ((((o3.n) == (5)) && ((o3.data[(0_usize)]) == (5))) && ((o3.arr[(0) as usize]) == (5))) @@ -848,7 +782,7 @@ unsafe fn main_0() -> i32 { assert!(((c2.data.len()) == (2_usize)) && ((c3.data.len()) == (2_usize))); assert!(c1.data.is_empty()); let mut c4: Copyable = ::zero_init(); - Copyable::construct_1(&mut c4); + DefaultConstructibleUnsafe::default_constructor(&mut c4); (unsafe { MoveAssignableUnsafe::move_assign(&mut c4, &mut c3) }); assert!(((c4.data[(1_usize)]) == (2)) && (c3.data.is_empty())); let mut h1: Holder = ::zero_init(); @@ -902,27 +836,27 @@ unsafe fn main_0() -> i32 { .is_null()) ); let mut t1: HasSeesThis = ::zero_init(); - HasSeesThis::construct_1(&mut t1); + DefaultConstructibleUnsafe::default_constructor(&mut t1); let mut t2: HasSeesThis = ::zero_init(); - HasSeesThis::construct_1(&mut t2); + DefaultConstructibleUnsafe::default_constructor(&mut t2); let mut t3: HasSeesThis = ::zero_init(); - HasSeesThis::construct_1(&mut t3); + DefaultConstructibleUnsafe::default_constructor(&mut t3); (unsafe { MoveAssignableUnsafe::move_assign(&mut t2, &mut t1) }); assert!(((t2.s.self_) == (&mut t2.s as *mut SeesThis))); (unsafe { CopyAssignableUnsafe::copy_assign(&mut t3, &t2) }); assert!(((t3.s.self_) == (&mut t3.s as *mut SeesThis))); let mut k1: HasCounted = ::zero_init(); - HasCounted::construct_1(&mut k1); + DefaultConstructibleUnsafe::default_constructor(&mut k1); let mut k2: HasCounted = ::zero_init(); MoveConstructibleUnsafe::move_constructor(&mut k2, { &mut k1 }); assert!(((k2.c.moves) == (1))); let mut k3: HasCounted = ::zero_init(); - HasCounted::construct_1(&mut k3); + DefaultConstructibleUnsafe::default_constructor(&mut k3); (unsafe { MoveAssignableUnsafe::move_assign(&mut k3, &mut k2) }); assert!(((k3.c.moves) == (2))); { let mut d: CtorSeesThis = ::zero_init(); - CtorSeesThis::construct_2(&mut d); + DefaultConstructibleUnsafe::default_constructor(&mut d); assert!(((d.self_) == (&mut d as *mut CtorSeesThis))); let mut e: CtorSeesThis = ::zero_init(); CopyConstructibleUnsafe::copy_constructor(&mut e, { &d }); @@ -931,7 +865,7 @@ unsafe fn main_0() -> i32 { CtorSeesThis::construct_1(&mut f, { 3 }); assert!(((f.self_) == (&mut f as *mut CtorSeesThis)) && ((f.id) == (3))); let mut h1: HasCtorSeesThis = ::zero_init(); - HasCtorSeesThis::construct_1(&mut h1); + DefaultConstructibleUnsafe::default_constructor(&mut h1); assert!(((h1.x.self_) == (&mut h1.x as *mut CtorSeesThis))); let mut h2: HasCtorSeesThis = ::zero_init(); CopyConstructibleUnsafe::copy_constructor(&mut h2, { &h1 }); @@ -944,7 +878,7 @@ unsafe fn main_0() -> i32 { (unsafe { CopyAssignableUnsafe::copy_assign(&mut h2, &h1) }); assert!(((h2.x.self_) == (&mut h2.x as *mut CtorSeesThis))); let mut i: InitsCtorSeesThis = ::zero_init(); - InitsCtorSeesThis::construct(&mut i); + DefaultConstructibleUnsafe::default_constructor(&mut i); assert!(((i.x.self_) == (&mut i.x as *mut CtorSeesThis)) && ((i.x.id) == (1))); assert!(((i.y.self_) == (&mut i.y as *mut CtorSeesThis)) && ((i.y.id) == (2))); let mut p: *mut CtorSeesThis = { @@ -967,11 +901,11 @@ unsafe fn main_0() -> i32 { CopyConstructibleUnsafe::copy_constructor(&mut o2, { &o1 }); assert!(((o2.v) == (2)) && ((o2.x.self_) == (&mut o2.x as *mut CtorSeesThis))); let mut a1: OutOfLineAssign = ::zero_init(); - OutOfLineAssign::construct_1(&mut a1); + DefaultConstructibleUnsafe::default_constructor(&mut a1); let mut a2: OutOfLineAssign = ::zero_init(); - OutOfLineAssign::construct_1(&mut a2); + DefaultConstructibleUnsafe::default_constructor(&mut a2); let mut a3: OutOfLineAssign = ::zero_init(); - OutOfLineAssign::construct_1(&mut a3); + DefaultConstructibleUnsafe::default_constructor(&mut a3); a1.v = 3; { let __a1 = 4; diff --git a/tests/unit/out/unsafe/copy_move_deleted.rs b/tests/unit/out/unsafe/copy_move_deleted.rs index 17d23ae3c2..b45396d9d2 100644 --- a/tests/unit/out/unsafe/copy_move_deleted.rs +++ b/tests/unit/out/unsafe/copy_move_deleted.rs @@ -43,8 +43,8 @@ impl MoveAssignableUnsafe for NoCopy { pub struct PrivateCopy { pub v: i32, } -impl PrivateCopy { - pub unsafe fn construct(&mut self) { +impl DefaultConstructibleUnsafe for PrivateCopy { + unsafe fn default_constructor(&mut self) { (&raw mut self.v).write(0); } } @@ -61,19 +61,12 @@ impl MoveAssignableUnsafe for PrivateCopy { return &mut (*(self as *mut PrivateCopy)); } } -impl DefaultConstructibleUnsafe for PrivateCopy { - unsafe fn default_constructor(&mut self) { - unsafe { - PrivateCopy::construct(&mut *self); - } - } -} impl Default for PrivateCopy { fn default() -> Self { unsafe { { let mut __v: PrivateCopy = ::zero_init(); - PrivateCopy::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -84,16 +77,9 @@ impl Default for PrivateCopy { pub struct Immovable { pub v: i32, } -impl Immovable { - pub unsafe fn construct(&mut self) { - (&raw mut self.v).write(0); - } -} impl DefaultConstructibleUnsafe for Immovable { unsafe fn default_constructor(&mut self) { - unsafe { - Immovable::construct(&mut *self); - } + (&raw mut self.v).write(0); } } impl Default for Immovable { @@ -101,7 +87,7 @@ impl Default for Immovable { unsafe { { let mut __v: Immovable = ::zero_init(); - Immovable::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -135,16 +121,9 @@ pub struct Container { pub struct VecHolder { pub items: Vec, } -impl VecHolder { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.items).write(Vec::new()); - } -} impl DefaultConstructibleUnsafe for VecHolder { unsafe fn default_constructor(&mut self) { - unsafe { - VecHolder::construct_1(&mut *self); - } + (&raw mut self.items).write(Vec::new()); } } pub unsafe fn bump_0(mut p: *mut NoCopy) { @@ -170,7 +149,7 @@ unsafe fn main_0() -> i32 { (unsafe { bump_0((&mut a as *mut NoCopy)) }); assert!(((a.v) == (2))); let mut p: PrivateCopy = ::zero_init(); - PrivateCopy::construct(&mut p); + DefaultConstructibleUnsafe::default_constructor(&mut p); p.v = 3; let mut q: PrivateCopy = ::zero_init(); MoveConstructibleUnsafe::move_constructor(&mut q, { &mut p }); @@ -178,7 +157,7 @@ unsafe fn main_0() -> i32 { (unsafe { MoveAssignableUnsafe::move_assign(&mut p, &mut q) }); assert!(((p.v) == (3)) && ((q.v) == (0))); let mut im: Immovable = ::zero_init(); - Immovable::construct(&mut im); + DefaultConstructibleUnsafe::default_constructor(&mut im); im.v = 4; (unsafe { bump_ref_1(&mut im) }); let mut pim: *mut Immovable = (&mut im as *mut Immovable); @@ -195,7 +174,7 @@ unsafe fn main_0() -> i32 { MoveConstructibleUnsafe::move_constructor(&mut d, { &mut c }); assert!((((d.inner.v) == (6)) && ((d.tag) == (7))) && ((c.inner.v) == (0))); let mut h: VecHolder = ::zero_init(); - VecHolder::construct_1(&mut h); + DefaultConstructibleUnsafe::default_constructor(&mut h); let mut h2: VecHolder = ::zero_init(); MoveConstructibleUnsafe::move_constructor(&mut h2, { &mut h }); assert!(((h2.items.len()) == (0_usize))); diff --git a/tests/unit/out/unsafe/default.rs b/tests/unit/out/unsafe/default.rs index b9e5c44e47..18c4fe334c 100644 --- a/tests/unit/out/unsafe/default.rs +++ b/tests/unit/out/unsafe/default.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Pointers { pub x1: *mut i32, pub x2: *const i32, @@ -31,10 +32,11 @@ pub struct Pointers { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct SmallArrays { pub a: [i32; 32], pub f: Option i32>, @@ -48,9 +50,10 @@ pub struct SmallArrays { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, )] +#[memberwise(default_constructor)] pub struct BigArray { pub a: [i32; 33], } diff --git a/tests/unit/out/unsafe/default_in_statics.rs b/tests/unit/out/unsafe/default_in_statics.rs index 8fd415c68a..e24d3d1071 100644 --- a/tests/unit/out/unsafe/default_in_statics.rs +++ b/tests/unit/out/unsafe/default_in_statics.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Inner { pub v: i32, pub name: *const libc::c_char, @@ -28,10 +29,11 @@ pub struct Inner { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Outer { pub p1: *mut i32, pub p2: *const i32, @@ -49,10 +51,11 @@ pub struct Outer { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 2c06312414..a4c5568f7b 100644 --- a/tests/unit/out/unsafe/delete_array_order.rs +++ b/tests/unit/out/unsafe/delete_array_order.rs @@ -12,13 +12,12 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(copy_assign)] +#[memberwise(default_constructor, copy_assign)] 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 32602c9f17..1ca37d2691 100644 --- a/tests/unit/out/unsafe/destructor.rs +++ b/tests/unit/out/unsafe/destructor.rs @@ -13,13 +13,12 @@ pub static mut global_0: std::cell::LazyCell = std::cell::LazyCell::new(|| VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(copy_assign)] +#[memberwise(copy_assign, default_constructor)] pub struct S {} impl DestructibleUnsafe for S { unsafe fn destroy(&mut self) { @@ -33,13 +32,12 @@ impl DestructibleUnsafe for S { FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, - DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(copy_assign)] +#[memberwise(default_constructor, copy_assign)] pub struct Defaulted { #[destroy] pub s: S, @@ -51,14 +49,13 @@ pub struct Defaulted { FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, - DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MoveConstructibleUnsafe, SwappableUnsafe, Default, )] -#[memberwise(move_assign, copy_assign)] +#[memberwise(move_assign, default_constructor, copy_assign)] pub struct Middle { #[destroy] pub s: S, @@ -70,14 +67,13 @@ pub struct Middle { FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, - DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MoveConstructibleUnsafe, SwappableUnsafe, Default, )] -#[memberwise(copy_assign, move_assign)] +#[memberwise(default_constructor, copy_assign, move_assign)] pub struct Outer { #[destroy] pub m: Middle, @@ -89,14 +85,13 @@ pub struct Outer { FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, - DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MoveConstructibleUnsafe, SwappableUnsafe, Default, )] -#[memberwise(move_assign, copy_assign)] +#[memberwise(move_assign, default_constructor, copy_assign)] pub struct ArrayMember { #[destroy] pub items: [S; 3], @@ -107,13 +102,12 @@ pub struct ArrayMember { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(copy_assign)] +#[memberwise(default_constructor, copy_assign)] pub struct EmptyBody { pub s: S, } @@ -128,13 +122,12 @@ impl DestructibleUnsafe for EmptyBody { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(copy_assign)] +#[memberwise(default_constructor, copy_assign)] pub struct Templated_char_ { pub v: libc::c_char, } @@ -151,13 +144,12 @@ impl DestructibleUnsafe for Templated_char_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(copy_assign)] +#[memberwise(default_constructor, copy_assign)] pub struct Templated_int_ { pub v: i32, } @@ -174,13 +166,12 @@ impl DestructibleUnsafe for Templated_int_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(copy_assign)] +#[memberwise(default_constructor, copy_assign)] pub struct Copied { pub v: i32, } @@ -198,13 +189,12 @@ pub static mut order_count_2: std::cell::LazyCell = std::cell::LazyCell::ne VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(copy_assign)] +#[memberwise(copy_assign, default_constructor)] pub struct Tagged { pub tag: i32, } @@ -222,14 +212,13 @@ impl DestructibleUnsafe for Tagged { FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, - DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MoveConstructibleUnsafe, SwappableUnsafe, Default, )] -#[memberwise(move_assign, copy_assign)] +#[memberwise(move_assign, default_constructor, copy_assign)] pub struct Ordered { #[destroy] pub first: Tagged, diff --git a/tests/unit/out/unsafe/destructor_params.rs b/tests/unit/out/unsafe/destructor_params.rs index 81ee89854f..05c22bc386 100644 --- a/tests/unit/out/unsafe/destructor_params.rs +++ b/tests/unit/out/unsafe/destructor_params.rs @@ -14,13 +14,12 @@ pub static mut last_1: std::cell::LazyCell = std::cell::LazyCell::new(|| un VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(copy_assign)] +#[memberwise(default_constructor, copy_assign)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/destructor_temporaries.rs b/tests/unit/out/unsafe/destructor_temporaries.rs index 6904470158..76033b4191 100644 --- a/tests/unit/out/unsafe/destructor_temporaries.rs +++ b/tests/unit/out/unsafe/destructor_temporaries.rs @@ -14,13 +14,12 @@ pub static mut last_1: std::cell::LazyCell = std::cell::LazyCell::new(|| un VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(copy_assign)] +#[memberwise(copy_assign, default_constructor)] pub struct S { pub v: i32, } @@ -42,14 +41,13 @@ impl DestructibleUnsafe for S { FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, - DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MoveConstructibleUnsafe, SwappableUnsafe, Default, )] -#[memberwise(move_assign, copy_assign)] +#[memberwise(move_assign, default_constructor, copy_assign)] pub struct Outer { #[destroy] pub inner: S, diff --git a/tests/unit/out/unsafe/doubly_linked_list.rs b/tests/unit/out/unsafe/doubly_linked_list.rs index 9c1979342e..f630e70e7e 100644 --- a/tests/unit/out/unsafe/doubly_linked_list.rs +++ b/tests/unit/out/unsafe/doubly_linked_list.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Node { pub val: i32, pub next: *mut Node, diff --git a/tests/unit/out/unsafe/enum_int_interop.rs b/tests/unit/out/unsafe/enum_int_interop.rs index 4897a577ae..d94cf7831e 100644 --- a/tests/unit/out/unsafe/enum_int_interop.rs +++ b/tests/unit/out/unsafe/enum_int_interop.rs @@ -26,10 +26,11 @@ pub const Tag_TAG_TWO: Tag = 2; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 2a11401e30..0e4a01774d 100644 --- a/tests/unit/out/unsafe/enum_underlying_type.rs +++ b/tests/unit/out/unsafe/enum_underlying_type.rs @@ -30,16 +30,9 @@ pub type Empty = bool; pub struct HoldsEmpty { pub e: Empty, } -impl HoldsEmpty { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.e).write(false); - } -} impl DefaultConstructibleUnsafe for HoldsEmpty { unsafe fn default_constructor(&mut self) { - unsafe { - HoldsEmpty::construct_1(&mut *self); - } + (&raw mut self.e).write(false); } } impl Default for HoldsEmpty { @@ -81,7 +74,7 @@ unsafe fn main_0() -> i32 { assert!(((sc as i32) == (-2_i32))); assert!((((Scoped_POS as i8) as i32) == (2))); let mut he: HoldsEmpty = ::zero_init(); - HoldsEmpty::construct_1(&mut he); + DefaultConstructibleUnsafe::default_constructor(&mut he); assert!(!(he.e)); let mut ev: Empty = false; assert!(((ev as i32) == (he.e as i32))); diff --git a/tests/unit/out/unsafe/exprs.rs b/tests/unit/out/unsafe/exprs.rs index 62f542c41e..f350990143 100644 --- a/tests/unit/out/unsafe/exprs.rs +++ b/tests/unit/out/unsafe/exprs.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct X { pub x: i32, } @@ -27,10 +28,11 @@ pub struct X { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 a045cac687..2c73a68c34 100644 --- a/tests/unit/out/unsafe/fft.rs +++ b/tests/unit/out/unsafe/fft.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Complex { pub re: f64, pub img: f64, diff --git a/tests/unit/out/unsafe/field_array_elem_ptr.rs b/tests/unit/out/unsafe/field_array_elem_ptr.rs index e4030c8980..796fbbfcad 100644 --- a/tests/unit/out/unsafe/field_array_elem_ptr.rs +++ b/tests/unit/out/unsafe/field_array_elem_ptr.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Point { pub x: i32, pub y: i32, @@ -28,10 +29,11 @@ pub struct Point { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 51e5d5c637..5280d88e4e 100644 --- a/tests/unit/out/unsafe/field_method_receiver.rs +++ b/tests/unit/out/unsafe/field_method_receiver.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Counter { pub n: i32, } @@ -61,20 +62,15 @@ impl S { Counter::add(&mut self.c, _k) }); } - pub unsafe fn construct_1(&mut self) { +} +impl DefaultConstructibleUnsafe for S { + unsafe fn default_constructor(&mut self) { (&raw mut self.tag).write(0_i32); (&raw mut self.c).write(::default()); (&raw mut self.arr).write([::default(); 2]); (&raw mut self.v).write(Vec::new()); } } -impl DefaultConstructibleUnsafe for S { - unsafe fn default_constructor(&mut self) { - unsafe { - S::construct_1(&mut *self); - } - } -} pub unsafe fn run_0(mut o: *mut S) { (unsafe { Counter::add(&mut (*o).c, 2) }); assert!(((unsafe { Counter::get(&(*o).c,) }) == (2))); diff --git a/tests/unit/out/unsafe/field_pointers.rs b/tests/unit/out/unsafe/field_pointers.rs index dea879cad2..0fefe76d01 100644 --- a/tests/unit/out/unsafe/field_pointers.rs +++ b/tests/unit/out/unsafe/field_pointers.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Inner { pub a: i32, pub name: [libc::c_char; 8], @@ -28,10 +29,11 @@ pub struct Inner { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Header { pub tag: i32, pub size: i16, @@ -70,7 +72,9 @@ impl Outer { self.v.push(__a1) }; } - pub unsafe fn construct_1(&mut self) { +} +impl DefaultConstructibleUnsafe for Outer { + unsafe fn default_constructor(&mut self) { (&raw mut self.x).write(0_i32); (&raw mut self.inner).write(::default()); (&raw mut self.items).write([::default(); 3]); @@ -79,13 +83,6 @@ impl Outer { (&raw mut self.buf).write([0_i32; 4]); } } -impl DefaultConstructibleUnsafe for Outer { - unsafe fn default_constructor(&mut self) { - unsafe { - Outer::construct_1(&mut *self); - } - } -} pub unsafe fn set_0(mut p: *mut i32, mut value: i32) { (*p) = value; } diff --git a/tests/unit/out/unsafe/field_pointers_malloced_struct.rs b/tests/unit/out/unsafe/field_pointers_malloced_struct.rs index ed65dc69b6..af498cc090 100644 --- a/tests/unit/out/unsafe/field_pointers_malloced_struct.rs +++ b/tests/unit/out/unsafe/field_pointers_malloced_struct.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct S { pub a: i32, pub b: i32, diff --git a/tests/unit/out/unsafe/find.rs b/tests/unit/out/unsafe/find.rs index 2c3892acf0..573c0fe9af 100644 --- a/tests/unit/out/unsafe/find.rs +++ b/tests/unit/out/unsafe/find.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct P { pub x: i32, } diff --git a/tests/unit/out/unsafe/fn_ptr_cast.rs b/tests/unit/out/unsafe/fn_ptr_cast.rs index 0331629544..278a538689 100644 --- a/tests/unit/out/unsafe/fn_ptr_cast.rs +++ b/tests/unit/out/unsafe/fn_ptr_cast.rs @@ -36,10 +36,11 @@ pub unsafe fn test_double_cast_2() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 b6aa39b6ea..b235d786e6 100644 --- a/tests/unit/out/unsafe/fn_ptr_stable_sort.rs +++ b/tests/unit/out/unsafe/fn_ptr_stable_sort.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 8f2dcd3eab..6fba958a95 100644 --- a/tests/unit/out/unsafe/fn_ptr_struct.rs +++ b/tests/unit/out/unsafe/fn_ptr_struct.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Handler { pub tag: i32, pub cb: Option i32>, @@ -34,10 +35,11 @@ pub unsafe fn negate_1(mut x: i32) -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct S {} impl S { pub unsafe fn pick_1(mut x: i32) -> i32 { diff --git a/tests/unit/out/unsafe/fn_ptr_vtable.rs b/tests/unit/out/unsafe/fn_ptr_vtable.rs index c258ffbf74..dd06154101 100644 --- a/tests/unit/out/unsafe/fn_ptr_vtable.rs +++ b/tests/unit/out/unsafe/fn_ptr_vtable.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Vtable { pub create: Option *mut ::libc::c_void>, pub get: Option i32>, diff --git a/tests/unit/out/unsafe/for_body_destructor.rs b/tests/unit/out/unsafe/for_body_destructor.rs index 89e07cb38c..bd47e8ec2d 100644 --- a/tests/unit/out/unsafe/for_body_destructor.rs +++ b/tests/unit/out/unsafe/for_body_destructor.rs @@ -12,13 +12,12 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(copy_assign)] +#[memberwise(default_constructor, copy_assign)] 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 f91c11c753..2dd1a83093 100644 --- a/tests/unit/out/unsafe/foreach_disjoint_field_borrow.rs +++ b/tests/unit/out/unsafe/foreach_disjoint_field_borrow.rs @@ -23,17 +23,10 @@ pub struct S { pub v: Vec, pub a: i32, } -impl S { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.v).write(Vec::new()); - (&raw mut self.a).write(0_i32); - } -} impl DefaultConstructibleUnsafe for S { unsafe fn default_constructor(&mut self) { - unsafe { - S::construct_1(&mut *self); - } + (&raw mut self.v).write(Vec::new()); + (&raw mut self.a).write(0_i32); } } pub fn main() { @@ -44,7 +37,7 @@ pub fn main() { } unsafe fn main_0() -> i32 { let mut s: S = ::zero_init(); - S::construct_1(&mut s); + DefaultConstructibleUnsafe::default_constructor(&mut s); { let __a1 = 1; s.v.push(__a1) diff --git a/tests/unit/out/unsafe/friend.rs b/tests/unit/out/unsafe/friend.rs index 4e47cb64f0..704b92154f 100644 --- a/tests/unit/out/unsafe/friend.rs +++ b/tests/unit/out/unsafe/friend.rs @@ -25,10 +25,11 @@ pub unsafe fn scaled_3(v: *const V, mut k: f64) -> f64 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct V { pub x: i32, } @@ -48,10 +49,11 @@ pub unsafe fn get_4(w: *const W_int_) -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct W_int_ { pub x: i32, } @@ -65,10 +67,11 @@ pub unsafe fn get_5(w: *const W_long_) -> i64 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct W_long_ { pub x: i64, } @@ -79,10 +82,11 @@ pub struct W_long_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 d2384a63d3..4ccba5aa7c 100644 --- a/tests/unit/out/unsafe/function_overloading.rs +++ b/tests/unit/out/unsafe/function_overloading.rs @@ -28,10 +28,11 @@ pub unsafe fn bar_4(x: *mut i32) -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 3908155dfa..f72f187afe 100644 --- a/tests/unit/out/unsafe/global_call_temporaries.rs +++ b/tests/unit/out/unsafe/global_call_temporaries.rs @@ -83,10 +83,11 @@ pub static mut call_assigned_6: std::cell::LazyCell = std::cell::LazyCell:: VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Item { pub value: i32, } diff --git a/tests/unit/out/unsafe/global_non_const_init.rs b/tests/unit/out/unsafe/global_non_const_init.rs index 2c4f905ec9..f30b351851 100644 --- a/tests/unit/out/unsafe/global_non_const_init.rs +++ b/tests/unit/out/unsafe/global_non_const_init.rs @@ -33,18 +33,13 @@ pub struct Ctor { pub v: i32, } impl Ctor { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.v).write((unsafe { next_0() })); - } - pub unsafe fn construct_2(&mut self, mut x: i32) { + pub unsafe fn construct_1(&mut self, mut x: i32) { (&raw mut self.v).write(x); } } impl DefaultConstructibleUnsafe for Ctor { unsafe fn default_constructor(&mut self) { - unsafe { - Ctor::construct_1(&mut *self); - } + (&raw mut self.v).write((unsafe { next_0() })); } } impl Default for Ctor { @@ -52,7 +47,7 @@ impl Default for Ctor { unsafe { { let mut __v: Ctor = ::zero_init(); - Ctor::construct_1(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -61,14 +56,14 @@ impl Default for Ctor { pub static mut default_ctor_7: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { { let mut __v: Ctor = ::zero_init(); - Ctor::construct_1(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } }); pub static mut arg_ctor_8: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { { let mut __v: Ctor = ::zero_init(); - Ctor::construct_2(&mut __v, { 7 }); + Ctor::construct_1(&mut __v, { 7 }); __v } }); @@ -83,7 +78,7 @@ pub static mut str_9: std::cell::LazyCell> = pub static mut inline_member_11: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { { let mut __v: Ctor = ::zero_init(); - Ctor::construct_2(&mut __v, { 5 }); + Ctor::construct_1(&mut __v, { 5 }); __v } }); @@ -94,10 +89,11 @@ pub static mut inline_member_11: std::cell::LazyCell = std::cell::LazyCell VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Holder {} pub static mut member_10: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { (unsafe { next_0() }) }); @@ -110,7 +106,7 @@ static mut once_13: std::cell::LazyCell = static mut local_ctor_14: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { { let mut __v: Ctor = ::zero_init(); - Ctor::construct_2(&mut __v, { 3 }); + Ctor::construct_1(&mut __v, { 3 }); __v } }); @@ -120,18 +116,13 @@ pub struct Singleton { pub hits: i32, } impl Singleton { - pub unsafe fn construct(&mut self) { - (&raw mut self.hits).write(0); - } pub unsafe fn instance() -> *mut Singleton { return &mut (*std::cell::LazyCell::force_mut(&mut *&raw mut s_15)); } } impl DefaultConstructibleUnsafe for Singleton { unsafe fn default_constructor(&mut self) { - unsafe { - Singleton::construct(&mut *self); - } + (&raw mut self.hits).write(0); } } impl Default for Singleton { @@ -139,7 +130,7 @@ impl Default for Singleton { unsafe { { let mut __v: Singleton = ::zero_init(); - Singleton::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -148,7 +139,7 @@ impl Default for Singleton { static mut s_15: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { { let mut __v: Singleton = ::zero_init(); - Singleton::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } }); diff --git a/tests/unit/out/unsafe/global_pointers.rs b/tests/unit/out/unsafe/global_pointers.rs index 636dde3124..409eafa036 100644 --- a/tests/unit/out/unsafe/global_pointers.rs +++ b/tests/unit/out/unsafe/global_pointers.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 95e8d82200..eb9b073ead 100644 --- a/tests/unit/out/unsafe/global_without_initializer.rs +++ b/tests/unit/out/unsafe/global_without_initializer.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct S { pub a: i32, } diff --git a/tests/unit/out/unsafe/huffman.rs b/tests/unit/out/unsafe/huffman.rs index 3aecc9f83d..7fc99d1f0c 100644 --- a/tests/unit/out/unsafe/huffman.rs +++ b/tests/unit/out/unsafe/huffman.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct MinHeapNode { pub data: libc::c_char, pub freq: i32, @@ -251,7 +252,9 @@ impl MinHeap { } } } - pub unsafe fn construct_1(&mut self) { +} +impl DefaultConstructibleUnsafe for MinHeap { + unsafe fn default_constructor(&mut self) { (&raw mut self.size).write(0_i32); (&raw mut self.capacity).write(0_i32); (&raw mut self.arr).write(None); @@ -259,13 +262,6 @@ impl MinHeap { (&raw mut self.alloc).write(None); } } -impl DefaultConstructibleUnsafe for MinHeap { - unsafe fn default_constructor(&mut self) { - unsafe { - MinHeap::construct_1(&mut *self); - } - } -} pub unsafe fn AllocMinHeap_1(mut capacity: i32) -> Option> { let mut minHeap: Option> = Some(Box::new(MinHeap { size: 0, 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 d5f55f24d6..ff68aef47b 100644 --- a/tests/unit/out/unsafe/immutable-deref-on-func-call.rs +++ b/tests/unit/out/unsafe/immutable-deref-on-func-call.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 cd7b648f4c..04e93654e4 100644 --- a/tests/unit/out/unsafe/implicit_autoref.rs +++ b/tests/unit/out/unsafe/implicit_autoref.rs @@ -22,16 +22,9 @@ use std::rc::Rc; pub struct Holder { pub v: Vec, } -impl Holder { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.v).write(Vec::new()); - } -} impl DefaultConstructibleUnsafe for Holder { unsafe fn default_constructor(&mut self) { - unsafe { - Holder::construct_1(&mut *self); - } + (&raw mut self.v).write(Vec::new()); } } pub unsafe fn write_through_0(mut p: *mut i32) { @@ -57,7 +50,7 @@ unsafe fn main_0() -> i32 { let mut a: i32 = (&mut (*p))[(0_usize)]; (&mut (*p))[(1_usize)] = 30; let mut h: Holder = ::zero_init(); - Holder::construct_1(&mut h); + DefaultConstructibleUnsafe::default_constructor(&mut h); { let __a1 = 40; h.v.push(__a1) diff --git a/tests/unit/out/unsafe/in_class_field_initializer.rs b/tests/unit/out/unsafe/in_class_field_initializer.rs index 55b71e7da9..04cd99efe7 100644 --- a/tests/unit/out/unsafe/in_class_field_initializer.rs +++ b/tests/unit/out/unsafe/in_class_field_initializer.rs @@ -12,17 +12,10 @@ pub struct Inner { pub x: i32, pub y: i32, } -impl Inner { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.x).write(3); - (&raw mut self.y).write(4); - } -} impl DefaultConstructibleUnsafe for Inner { unsafe fn default_constructor(&mut self) { - unsafe { - Inner::construct_1(&mut *self); - } + (&raw mut self.x).write(3); + (&raw mut self.y).write(4); } } impl Default for Inner { @@ -38,19 +31,12 @@ pub struct S { pub c: Inner, pub d: Inner, } -impl S { - pub unsafe fn construct_1(&mut self) { +impl DefaultConstructibleUnsafe for S { + unsafe fn default_constructor(&mut self) { (&raw mut self.a).write(1); (&raw mut self.b).write((2 as libc::c_char)); (&raw mut self.c).write(::default()); - Inner::construct_1(&mut self.d); - } -} -impl DefaultConstructibleUnsafe for S { - unsafe fn default_constructor(&mut self) { - unsafe { - S::construct_1(&mut *self); - } + DefaultConstructibleUnsafe::default_constructor(&mut self.d); } } impl Default for S { @@ -98,7 +84,7 @@ pub fn main() { } unsafe fn main_0() -> i32 { let mut s: S = ::zero_init(); - S::construct_1(&mut s); + DefaultConstructibleUnsafe::default_constructor(&mut s); assert!(((s.a) == (1))); assert!(((s.b as i32) == (2))); assert!(((s.c.x) == (3))); diff --git a/tests/unit/out/unsafe/init.rs b/tests/unit/out/unsafe/init.rs index 9479718576..367a5325e9 100644 --- a/tests/unit/out/unsafe/init.rs +++ b/tests/unit/out/unsafe/init.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 60fc824a98..88f7a20777 100644 --- a/tests/unit/out/unsafe/init_list.rs +++ b/tests/unit/out/unsafe/init_list.rs @@ -14,10 +14,11 @@ pub unsafe fn f_0(mut list: Vec) {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Pair { pub a: i32, pub b: i32, @@ -32,15 +33,10 @@ impl Holder { self.p = (*o); return &mut (*(self as *mut Holder)); } - pub unsafe fn construct_1(&mut self) { - (&raw mut self.p).write(Pair { a: 0, b: 0 }); - } } impl DefaultConstructibleUnsafe for Holder { unsafe fn default_constructor(&mut self) { - unsafe { - Holder::construct_1(&mut *self); - } + (&raw mut self.p).write(Pair { a: 0, b: 0 }); } } impl Default for Holder { @@ -60,16 +56,9 @@ pub unsafe fn sum_1(p: *const Pair) -> i32 { pub struct Seven { pub v: i32, } -impl Seven { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.v).write(7); - } -} impl DefaultConstructibleUnsafe for Seven { unsafe fn default_constructor(&mut self) { - unsafe { - Seven::construct_1(&mut *self); - } + (&raw mut self.v).write(7); } } impl Default for Seven { @@ -93,7 +82,7 @@ unsafe fn main_0() -> i32 { (unsafe { f_0(Vec::from([1, 2, 3, 4])) }); let mut p: Pair = Pair { a: 1, b: 2 }; let mut h: Holder = ::zero_init(); - Holder::construct_1(&mut h); + DefaultConstructibleUnsafe::default_constructor(&mut h); (unsafe { Holder::operator_assign_1(&mut h, &mut p) }); assert!(((h.p.a) == (1)) && ((h.p.b) == (2))); assert!(((unsafe { sum_1(&p,) }) == (3))); diff --git a/tests/unit/out/unsafe/inline_container_fields.rs b/tests/unit/out/unsafe/inline_container_fields.rs index 49f771aa9a..c0038a17ea 100644 --- a/tests/unit/out/unsafe/inline_container_fields.rs +++ b/tests/unit/out/unsafe/inline_container_fields.rs @@ -24,20 +24,13 @@ pub struct Elem { pub hist: [i32; 4], pub coeffs: Vec, } -impl Elem { - pub unsafe fn construct_1(&mut self) { +impl DefaultConstructibleUnsafe for Elem { + unsafe fn default_constructor(&mut self) { (&raw mut self.id).write(0_i32); (&raw mut self.hist).write([0_i32; 4]); (&raw mut self.coeffs).write(Vec::new()); } } -impl DefaultConstructibleUnsafe for Elem { - unsafe fn default_constructor(&mut self) { - unsafe { - Elem::construct_1(&mut *self); - } - } -} #[repr(C)] #[derive( Clone, @@ -57,8 +50,8 @@ pub struct State { pub elems: Vec, pub rows: Vec>, } -impl State { - pub unsafe fn construct_1(&mut self) { +impl DefaultConstructibleUnsafe for State { + unsafe fn default_constructor(&mut self) { (&raw mut self.count).write(0_i32); (&raw mut self.grid).write([[0_i32; 3]; 2]); (&raw mut self.arr).write(std::array::from_fn::<_, 3, _>(|_| 0_i32)); @@ -66,13 +59,6 @@ impl State { (&raw mut self.rows).write(Vec::new()); } } -impl DefaultConstructibleUnsafe for State { - unsafe fn default_constructor(&mut self) { - unsafe { - State::construct_1(&mut *self); - } - } -} impl Default for State { fn default() -> Self { unsafe { @@ -146,8 +132,8 @@ pub static mut move_assigns_5: std::cell::LazyCell = std::cell::LazyCell::n pub struct Counted { pub v: i32, } -impl Counted { - pub unsafe fn construct(&mut self) { +impl DefaultConstructibleUnsafe for Counted { + unsafe fn default_constructor(&mut self) { (&raw mut self.v).write(0); } } @@ -188,13 +174,6 @@ impl Clone for Counted { } } } -impl DefaultConstructibleUnsafe for Counted { - unsafe fn default_constructor(&mut self) { - unsafe { - Counted::construct(&mut *self); - } - } -} impl Default for Counted { fn default() -> Self { unsafe { Counted { v: 0 } } diff --git a/tests/unit/out/unsafe/kruskal.rs b/tests/unit/out/unsafe/kruskal.rs index eef2db6b66..0ece169b26 100644 --- a/tests/unit/out/unsafe/kruskal.rs +++ b/tests/unit/out/unsafe/kruskal.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Edge { pub u: i32, pub v: i32, @@ -291,17 +292,12 @@ impl DisjointSet { + (1)); } } - pub unsafe fn construct_1(&mut self) { - (&raw mut self.rank).write(None); - (&raw mut self.parent).write(None); - (&raw mut self.n).write(0_i32); - } } impl DefaultConstructibleUnsafe for DisjointSet { unsafe fn default_constructor(&mut self) { - unsafe { - DisjointSet::construct_1(&mut *self); - } + (&raw mut self.rank).write(None); + (&raw mut self.parent).write(None); + (&raw mut self.n).write(0_i32); } } #[repr(C)] @@ -319,20 +315,13 @@ pub struct Graph { pub V: i32, pub E: i32, } -impl Graph { - pub unsafe fn construct_1(&mut self) { +impl DefaultConstructibleUnsafe for Graph { + unsafe fn default_constructor(&mut self) { (&raw mut self.edges).write(None); (&raw mut self.V).write(0_i32); (&raw mut self.E).write(0_i32); } } -impl DefaultConstructibleUnsafe for Graph { - unsafe fn default_constructor(&mut self) { - unsafe { - Graph::construct_1(&mut *self); - } - } -} pub unsafe fn MSTKruskal_2(graph: *mut Graph) -> f64 { (unsafe { let _arr: *mut Option> = &mut (*graph).edges; diff --git a/tests/unit/out/unsafe/lambda_as_field.rs b/tests/unit/out/unsafe/lambda_as_field.rs index 249f877ef8..474a168dc1 100644 --- a/tests/unit/out/unsafe/lambda_as_field.rs +++ b/tests/unit/out/unsafe/lambda_as_field.rs @@ -12,12 +12,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, )] -#[memberwise(copy_assign)] +#[memberwise(default_constructor, copy_assign)] pub struct Guard__lambda_at_lambda_as_field_cpp_34_13__ { pub f: FnPtr, } @@ -57,13 +56,9 @@ impl DestructibleUnsafe for Guard__lambda_at_lambda_as_field_cpp_45_13__ { } #[repr(C)] #[derive( - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, - TriviallyCopyableUnsafe, + Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MemberwiseUnsafe, TriviallyCopyableUnsafe, )] +#[memberwise(default_constructor)] pub struct Holder__lambda_at_lambda_as_field_cpp_39_12__ { pub f: FnPtr i32>, pub calls: i32, diff --git a/tests/unit/out/unsafe/lambda_capture_copy_ctor.rs b/tests/unit/out/unsafe/lambda_capture_copy_ctor.rs index 1241bd62c7..aa225e35f9 100644 --- a/tests/unit/out/unsafe/lambda_capture_copy_ctor.rs +++ b/tests/unit/out/unsafe/lambda_capture_copy_ctor.rs @@ -20,8 +20,8 @@ pub struct Counted { pub copies: i32, pub moves: i32, } -impl Counted { - pub unsafe fn construct(&mut self) { +impl DefaultConstructibleUnsafe for Counted { + unsafe fn default_constructor(&mut self) { (&raw mut self.copies).write(0); (&raw mut self.moves).write(0); } @@ -47,19 +47,12 @@ impl Clone for Counted { } } } -impl DefaultConstructibleUnsafe for Counted { - unsafe fn default_constructor(&mut self) { - unsafe { - Counted::construct(&mut *self); - } - } -} impl Default for Counted { fn default() -> Self { unsafe { { let mut __v: Counted = ::zero_init(); - Counted::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -76,8 +69,8 @@ pub static mut drops_0: std::cell::LazyCell = std::cell::LazyCell::new(|| u SwappableUnsafe, )] pub struct Dropped {} -impl Dropped { - pub unsafe fn construct(&mut self) {} +impl DefaultConstructibleUnsafe for Dropped { + unsafe fn default_constructor(&mut self) {} } impl CopyConstructibleUnsafe for Dropped { unsafe fn copy_constructor(&mut self, _a0: *const Dropped) {} @@ -99,19 +92,12 @@ impl Clone for Dropped { } } } -impl DefaultConstructibleUnsafe for Dropped { - unsafe fn default_constructor(&mut self) { - unsafe { - Dropped::construct(&mut *self); - } - } -} impl Default for Dropped { fn default() -> Self { unsafe { { let mut __v: Dropped = ::zero_init(); - Dropped::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -125,7 +111,7 @@ pub fn main() { } unsafe fn main_0() -> i32 { let mut c: Counted = ::zero_init(); - Counted::construct(&mut c); + DefaultConstructibleUnsafe::default_constructor(&mut c); let mut f: FnPtr i32> = lambda_unsafe!( { let c: Counted = { @@ -170,7 +156,7 @@ unsafe fn main_0() -> i32 { assert!(((returned) == (2))); let mut arr: [Counted; 2] = std::array::from_fn::<_, 2, _>(|_| { let mut __v: Counted = ::zero_init(); - Counted::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v }); let mut a: FnPtr i32> = lambda_unsafe!( @@ -195,7 +181,7 @@ unsafe fn main_0() -> i32 { { let d: Dropped = { let mut __v: Dropped = ::zero_init(); - Dropped::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v }; }, @@ -215,7 +201,7 @@ unsafe fn main_0() -> i32 { { let d: Dropped = { let mut __v: Dropped = ::zero_init(); - Dropped::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v }; }, @@ -235,7 +221,7 @@ unsafe fn main_0() -> i32 { { let d: Dropped = { let mut __v: Dropped = ::zero_init(); - Dropped::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v }; }, diff --git a/tests/unit/out/unsafe/lambda_capture_ref.rs b/tests/unit/out/unsafe/lambda_capture_ref.rs index 31ee27bc49..daff8aaf71 100644 --- a/tests/unit/out/unsafe/lambda_capture_ref.rs +++ b/tests/unit/out/unsafe/lambda_capture_ref.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 b2c0c15523..5517164beb 100644 --- a/tests/unit/out/unsafe/lambda_capture_star_this.rs +++ b/tests/unit/out/unsafe/lambda_capture_star_this.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 ee942180d8..dbc5dafed4 100644 --- a/tests/unit/out/unsafe/lambda_capture_this.rs +++ b/tests/unit/out/unsafe/lambda_capture_this.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 2b545652de..f7ffe2524d 100644 --- a/tests/unit/out/unsafe/lambda_capture_value.rs +++ b/tests/unit/out/unsafe/lambda_capture_value.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 60687a3f34..c2045e123a 100644 --- a/tests/unit/out/unsafe/lambda_decltype_type.rs +++ b/tests/unit/out/unsafe/lambda_decltype_type.rs @@ -28,7 +28,9 @@ impl Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { self.items[(i) as usize] = v; self.size.postfix_inc(); } - pub unsafe fn construct_1(&mut self) { +} +impl DefaultConstructibleUnsafe for Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { + unsafe fn default_constructor(&mut self) { (&raw mut self.items).write([0_i32; 4]); (&raw mut self.size).write(0); (&raw mut self.cmp).write(FnPtr:: bool>::new( @@ -40,13 +42,6 @@ impl Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { )); } } -impl DefaultConstructibleUnsafe for Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { - unsafe fn default_constructor(&mut self) { - unsafe { - Sorted__lambda_at_lambda_decltype_type_cpp_22_18__::construct_1(&mut *self); - } - } -} impl Default for Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { fn default() -> Self { unsafe { @@ -84,7 +79,9 @@ impl Sorted__lambda_at_lambda_decltype_type_cpp_19_23__ { self.items[(i) as usize] = v; self.size.postfix_inc(); } - pub unsafe fn construct_1(&mut self) { +} +impl DefaultConstructibleUnsafe for Sorted__lambda_at_lambda_decltype_type_cpp_19_23__ { + unsafe fn default_constructor(&mut self) { (&raw mut self.items).write([0_i32; 4]); (&raw mut self.size).write(0); (&raw mut self.cmp).write(FnPtr:: bool>::new( @@ -96,13 +93,6 @@ impl Sorted__lambda_at_lambda_decltype_type_cpp_19_23__ { )); } } -impl DefaultConstructibleUnsafe for Sorted__lambda_at_lambda_decltype_type_cpp_19_23__ { - unsafe fn default_constructor(&mut self) { - unsafe { - Sorted__lambda_at_lambda_decltype_type_cpp_19_23__::construct_1(&mut *self); - } - } -} impl Default for Sorted__lambda_at_lambda_decltype_type_cpp_19_23__ { fn default() -> Self { unsafe { @@ -133,7 +123,7 @@ unsafe fn main_0() -> i32 { }); let mut desc: Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ = ::zero_init(); - Sorted__lambda_at_lambda_decltype_type_cpp_22_18__::construct_1(&mut desc); + DefaultConstructibleUnsafe::default_constructor(&mut desc); (unsafe { Sorted__lambda_at_lambda_decltype_type_cpp_22_18__::insert(&mut desc, 2) }); (unsafe { Sorted__lambda_at_lambda_decltype_type_cpp_22_18__::insert(&mut desc, 7) }); (unsafe { Sorted__lambda_at_lambda_decltype_type_cpp_22_18__::insert(&mut desc, 4) }); @@ -142,7 +132,7 @@ unsafe fn main_0() -> i32 { assert!(((desc.items[(2) as usize]) == (2))); let mut asc: Sorted__lambda_at_lambda_decltype_type_cpp_19_23__ = ::zero_init(); - Sorted__lambda_at_lambda_decltype_type_cpp_19_23__::construct_1(&mut asc); + DefaultConstructibleUnsafe::default_constructor(&mut asc); (unsafe { Sorted__lambda_at_lambda_decltype_type_cpp_19_23__::insert(&mut asc, 2) }); (unsafe { Sorted__lambda_at_lambda_decltype_type_cpp_19_23__::insert(&mut asc, 7) }); (unsafe { Sorted__lambda_at_lambda_decltype_type_cpp_19_23__::insert(&mut asc, 4) }); diff --git a/tests/unit/out/unsafe/lambda_generic_explicit_args.rs b/tests/unit/out/unsafe/lambda_generic_explicit_args.rs index b757e96c71..dbf8da6c29 100644 --- a/tests/unit/out/unsafe/lambda_generic_explicit_args.rs +++ b/tests/unit/out/unsafe/lambda_generic_explicit_args.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 a37cb08200..278473131e 100644 --- a/tests/unit/out/unsafe/lambda_immediate_init.rs +++ b/tests/unit/out/unsafe/lambda_immediate_init.rs @@ -15,8 +15,8 @@ pub struct S { pub j: i32, pub k: i32, } -impl S { - pub unsafe fn construct_1(&mut self) { +impl DefaultConstructibleUnsafe for S { + unsafe fn default_constructor(&mut self) { (&raw mut self.j).write(10); (&raw mut self.k).write( ((unsafe { @@ -30,13 +30,6 @@ impl S { ); } } -impl DefaultConstructibleUnsafe for S { - unsafe fn default_constructor(&mut self) { - unsafe { - S::construct_1(&mut *self); - } - } -} impl Default for S { fn default() -> Self { unsafe { @@ -97,7 +90,7 @@ unsafe fn main_0() -> i32 { ); assert!(((unsafe { pick_0(1,) }) == (1))); let mut s: S = ::zero_init(); - S::construct_1(&mut s); + DefaultConstructibleUnsafe::default_constructor(&mut s); assert!(((s.k) == (4))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut g_1)) == (10))); let mut a: i32 = 2; diff --git a/tests/unit/out/unsafe/lambda_nested.rs b/tests/unit/out/unsafe/lambda_nested.rs index 57d88d4ec9..f3d51a79b2 100644 --- a/tests/unit/out/unsafe/lambda_nested.rs +++ b/tests/unit/out/unsafe/lambda_nested.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 5165d9bdf8..4ebe28b446 100644 --- a/tests/unit/out/unsafe/lambda_static_local.rs +++ b/tests/unit/out/unsafe/lambda_static_local.rs @@ -74,10 +74,11 @@ static mut calls_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsaf VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 8b419446a8..4ab20009e8 100644 --- a/tests/unit/out/unsafe/libc_struct_without_default.rs +++ b/tests/unit/out/unsafe/libc_struct_without_default.rs @@ -22,17 +22,10 @@ pub struct UserDefined { pub a: [i32; 1], pub v: Vec, } -impl UserDefined { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.a).write(std::array::from_fn::<_, 1, _>(|_| 0_i32)); - (&raw mut self.v).write(Vec::new()); - } -} impl DefaultConstructibleUnsafe for UserDefined { unsafe fn default_constructor(&mut self) { - unsafe { - UserDefined::construct_1(&mut *self); - } + (&raw mut self.a).write(std::array::from_fn::<_, 1, _>(|_| 0_i32)); + (&raw mut self.v).write(Vec::new()); } } impl Default for UserDefined { @@ -52,9 +45,10 @@ impl Default for UserDefined { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, )] +#[memberwise(default_constructor)] pub struct FieldIsLibcType { pub addr: libc::sockaddr, } @@ -95,7 +89,7 @@ unsafe fn main_0() -> i32 { st.st_size = (1024 as ::libc::off_t); assert!(((st.st_size) == (1024 as ::libc::off_t))); let mut ud: UserDefined = ::zero_init(); - UserDefined::construct_1(&mut ud); + DefaultConstructibleUnsafe::default_constructor(&mut ud); ud.a[(0_usize)] = 3; assert!(((ud.a[(0_usize)]) == (3))); assert!(((ud.v.len()) == (0_usize))); diff --git a/tests/unit/out/unsafe/linked_list.rs b/tests/unit/out/unsafe/linked_list.rs index 1b9ec10d92..ca4b3cb327 100644 --- a/tests/unit/out/unsafe/linked_list.rs +++ b/tests/unit/out/unsafe/linked_list.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Node { pub val: i32, pub next: *mut Node, diff --git a/tests/unit/out/unsafe/local_record_template.rs b/tests/unit/out/unsafe/local_record_template.rs index 3dbf3ca3d8..2256a2c0b4 100644 --- a/tests/unit/out/unsafe/local_record_template.rs +++ b/tests/unit/out/unsafe/local_record_template.rs @@ -36,10 +36,11 @@ pub unsafe fn wrap_10(mut v: i64) -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Local_5 { pub x: i32, } @@ -50,10 +51,11 @@ pub struct Local_5 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Local_7 { pub x: i64, } @@ -68,10 +70,11 @@ pub unsafe fn other_11() -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Local_1 { pub x: i64, pub y: i64, @@ -98,10 +101,11 @@ unsafe fn main_0() -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Local_3 { pub x: i32, } diff --git a/tests/unit/out/unsafe/map.rs b/tests/unit/out/unsafe/map.rs index 5a5e085296..79f7fa8b55 100644 --- a/tests/unit/out/unsafe/map.rs +++ b/tests/unit/out/unsafe/map.rs @@ -22,20 +22,15 @@ pub struct Point { pub y: i32, } impl Point { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.x).write(0); - (&raw mut self.y).write(0); - } - pub unsafe fn construct_2(&mut self, mut x: i32, mut y: i32) { + pub unsafe fn construct_1(&mut self, mut x: i32, mut y: i32) { (&raw mut self.x).write(x); (&raw mut self.y).write(y); } } impl DefaultConstructibleUnsafe for Point { unsafe fn default_constructor(&mut self) { - unsafe { - Point::construct_1(&mut *self); - } + (&raw mut self.x).write(0); + (&raw mut self.y).write(0); } } impl Default for Point { @@ -43,7 +38,7 @@ impl Default for Point { unsafe { { let mut __v: Point = ::zero_init(); - Point::construct_1(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -452,7 +447,7 @@ unsafe fn main_0() -> i32 { let mut point_new: (UnsafeBidirectionalIterator<(i32, Point)>, bool) = points.try_emplace(key1, || { let mut __v: Point = ::zero_init(); - Point::construct_2(&mut __v, { 3 }, { 4 }); + Point::construct_1(&mut __v, { 3 }, { 4 }); __v }); assert!(((point_new.1) as bool)); @@ -486,7 +481,7 @@ unsafe fn main_0() -> i32 { }; points.emplace((key8, { let mut __v: Point = ::zero_init(); - Point::construct_2(&mut __v, { 5 }, { 6 }); + Point::construct_1(&mut __v, { 5 }, { 6 }); __v })); { diff --git a/tests/unit/out/unsafe/map_key_identity.rs b/tests/unit/out/unsafe/map_key_identity.rs index e498496c4f..768efb1f6e 100644 --- a/tests/unit/out/unsafe/map_key_identity.rs +++ b/tests/unit/out/unsafe/map_key_identity.rs @@ -15,10 +15,11 @@ pub static mut default_constructions_0: std::cell::LazyCell = VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Key { pub order: i32, pub identity: i32, @@ -58,17 +59,10 @@ pub unsafe fn operator_eq_2(a: *const Key, b: *const Key) -> bool { pub struct Mapped { pub value: i32, } -impl Mapped { - pub unsafe fn construct(&mut self) { - (&raw mut self.value).write(0); - (*std::cell::LazyCell::force_mut(&mut *&raw mut default_constructions_0)).prefix_inc(); - } -} impl DefaultConstructibleUnsafe for Mapped { unsafe fn default_constructor(&mut self) { - unsafe { - Mapped::construct(&mut *self); - } + (&raw mut self.value).write(0); + (*std::cell::LazyCell::force_mut(&mut *&raw mut default_constructions_0)).prefix_inc(); } } impl Default for Mapped { @@ -76,7 +70,7 @@ impl Default for Mapped { unsafe { { let mut __v: Mapped = ::zero_init(); - Mapped::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } diff --git a/tests/unit/out/unsafe/map_try_emplace.rs b/tests/unit/out/unsafe/map_try_emplace.rs index 83e8b13217..0736c71e2a 100644 --- a/tests/unit/out/unsafe/map_try_emplace.rs +++ b/tests/unit/out/unsafe/map_try_emplace.rs @@ -26,14 +26,16 @@ pub struct Item { pub value: i32, } impl Item { - pub unsafe fn construct_2(&mut self) { - (&raw mut self.value).write(0); - } pub unsafe fn construct_1(&mut self, mut value: i32) { (&raw mut self.value).write(value); (*std::cell::LazyCell::force_mut(&mut *&raw mut made_1)).prefix_inc(); } } +impl DefaultConstructibleUnsafe for Item { + unsafe fn default_constructor(&mut self) { + (&raw mut self.value).write(0); + } +} impl CopyConstructibleUnsafe for Item { unsafe fn copy_constructor(&mut self, other: *const Item) { (&raw mut self.value).write((*other).value); @@ -56,19 +58,12 @@ impl Clone for Item { } } } -impl DefaultConstructibleUnsafe for Item { - unsafe fn default_constructor(&mut self) { - unsafe { - Item::construct_2(&mut *self); - } - } -} impl Default for Item { fn default() -> Self { unsafe { { let mut __v: Item = ::zero_init(); - Item::construct_2(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -84,10 +79,7 @@ pub struct RefItem { pub value: i32, } impl RefItem { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.value).write(0); - } - pub unsafe fn construct_2(&mut self, counter: *mut i32, mut amount: i32) { + pub unsafe fn construct_1(&mut self, counter: *mut i32, mut amount: i32) { (&raw mut self.value).write({ (*counter) += amount; (*counter) @@ -97,9 +89,7 @@ impl RefItem { } impl DefaultConstructibleUnsafe for RefItem { unsafe fn default_constructor(&mut self) { - unsafe { - RefItem::construct_1(&mut *self); - } + (&raw mut self.value).write(0); } } impl Default for RefItem { @@ -107,7 +97,7 @@ impl Default for RefItem { unsafe { { let mut __v: RefItem = ::zero_init(); - RefItem::construct_1(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -365,7 +355,7 @@ unsafe fn main_0() -> i32 { let mut counter: i32 = 0; refs.try_emplace(key, || { let mut __v: RefItem = ::zero_init(); - RefItem::construct_2(&mut __v, { &mut counter }, { 5 }); + RefItem::construct_1(&mut __v, { &mut counter }, { 5 }); __v }); (*std::cell::LazyCell::force_mut(&mut *&raw mut made_1)) = 0; @@ -373,7 +363,7 @@ unsafe fn main_0() -> i32 { match (((unsafe { reference_5(&mut counter) }) as *mut i32),) { (__tmp_10,) => refs.try_emplace(key, || { let mut __v: RefItem = ::zero_init(); - RefItem::construct_2(&mut __v, { __tmp_10 }, { 2 }); + RefItem::construct_1(&mut __v, { __tmp_10 }, { 2 }); __v }), }; @@ -388,7 +378,7 @@ unsafe fn main_0() -> i32 { match (((unsafe { reference_5(&mut counter) }) as *mut i32),) { (__tmp_11,) => refs.try_emplace(key, || { let mut __v: RefItem = ::zero_init(); - RefItem::construct_2(&mut __v, { __tmp_11 }, { 2 }); + RefItem::construct_1(&mut __v, { __tmp_11 }, { 2 }); __v }), }; diff --git a/tests/unit/out/unsafe/map_try_emplace_lvalues.rs b/tests/unit/out/unsafe/map_try_emplace_lvalues.rs index ce454e0021..7236ef67ec 100644 --- a/tests/unit/out/unsafe/map_try_emplace_lvalues.rs +++ b/tests/unit/out/unsafe/map_try_emplace_lvalues.rs @@ -14,10 +14,7 @@ pub struct Item { pub value: i32, } impl Item { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.value).write(0); - } - pub unsafe fn construct_2(&mut self, counter: *mut i32, mut amount: i32) { + pub unsafe fn construct_1(&mut self, counter: *mut i32, mut amount: i32) { (&raw mut self.value).write({ (*counter) += amount; (*counter) @@ -27,9 +24,7 @@ impl Item { } impl DefaultConstructibleUnsafe for Item { unsafe fn default_constructor(&mut self) { - unsafe { - Item::construct_1(&mut *self); - } + (&raw mut self.value).write(0); } } impl Default for Item { @@ -37,7 +32,7 @@ impl Default for Item { unsafe { { let mut __v: Item = ::zero_init(); - Item::construct_1(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -59,26 +54,19 @@ pub struct Temporary { pub n: i32, pub data: [i32; 2], } -impl Temporary { - pub unsafe fn construct(&mut self) { +impl DefaultConstructibleUnsafe for Temporary { + unsafe fn default_constructor(&mut self) { (&raw mut self.n).write(5); (&raw mut self.data).write([6, 7]); (*std::cell::LazyCell::force_mut(&mut *&raw mut temporary_calls_4)).prefix_inc(); } } -impl DefaultConstructibleUnsafe for Temporary { - unsafe fn default_constructor(&mut self) { - unsafe { - Temporary::construct(&mut *self); - } - } -} impl Default for Temporary { fn default() -> Self { unsafe { { let mut __v: Temporary = ::zero_init(); - Temporary::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -91,29 +79,22 @@ impl Default for Temporary { pub struct Nested { pub inner: Temporary, } -impl Nested { - pub unsafe fn construct_1(&mut self) { - Temporary::construct(&mut self.inner); - } -} impl DefaultConstructibleUnsafe for Nested { unsafe fn default_constructor(&mut self) { - unsafe { - Nested::construct_1(&mut *self); - } + DefaultConstructibleUnsafe::default_constructor(&mut self.inner); } } pub unsafe fn make_temporary_5() -> Temporary { return { let mut __v: Temporary = ::zero_init(); - Temporary::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v }; } pub unsafe fn make_nested_6() -> Nested { return { let mut __v: Nested = ::zero_init(); - Nested::construct_1(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v }; } @@ -126,13 +107,6 @@ pub struct Owner { pub ptr: Option>, } impl Owner { - pub unsafe fn construct(&mut self) { - (&raw mut self.ptr).write(Some(Box::new({ - let mut __v: Temporary = ::zero_init(); - Temporary::construct(&mut __v); - __v - }))); - } pub unsafe fn value(&mut self) -> *const i32 { return &(*self.ptr.as_deref().map_or(::std::ptr::null_mut(), |v| { v as *const Temporary as *mut Temporary @@ -142,9 +116,11 @@ impl Owner { } impl DefaultConstructibleUnsafe for Owner { unsafe fn default_constructor(&mut self) { - unsafe { - Owner::construct(&mut *self); - } + (&raw mut self.ptr).write(Some(Box::new({ + let mut __v: Temporary = ::zero_init(); + DefaultConstructibleUnsafe::default_constructor(&mut __v); + __v + }))); } } impl Default for Owner { @@ -152,7 +128,7 @@ impl Default for Owner { unsafe { { let mut __v: Owner = ::zero_init(); - Owner::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -163,16 +139,9 @@ impl Default for Owner { pub struct Noncopy { pub n: i32, } -impl Noncopy { - pub unsafe fn construct(&mut self) { - (&raw mut self.n).write(5); - } -} impl DefaultConstructibleUnsafe for Noncopy { unsafe fn default_constructor(&mut self) { - unsafe { - Noncopy::construct(&mut *self); - } + (&raw mut self.n).write(5); } } impl Default for Noncopy { @@ -189,21 +158,16 @@ pub struct Held { pub ptr: *const i32, } impl Held { - pub unsafe fn construct_2(&mut self) { - (&raw mut self.ptr).write(std::ptr::null()); - } pub unsafe fn construct_1(&mut self, n: *const i32) { (&raw mut self.ptr).write((n)); } - pub unsafe fn construct_3(&mut self, n: *const [i32; 2], mut _a1: i32) { + pub unsafe fn construct_2(&mut self, n: *const [i32; 2], mut _a1: i32) { (&raw mut self.ptr).write((*n).as_ptr()); } } impl DefaultConstructibleUnsafe for Held { unsafe fn default_constructor(&mut self) { - unsafe { - Held::construct_2(&mut *self); - } + (&raw mut self.ptr).write(std::ptr::null()); } } impl Default for Held { @@ -211,7 +175,7 @@ impl Default for Held { unsafe { { let mut __v: Held = ::zero_init(); - Held::construct_2(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -282,7 +246,7 @@ pub static mut global_owned_16: std::cell::LazyCell<( match ((&mut (*(*{ __tmp_6 = Some(Box::new({ let mut __v: Temporary = ::zero_init(); - Temporary::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v })); &mut __tmp_6 @@ -336,7 +300,7 @@ unsafe fn main_0() -> i32 { let mut counter: i32 = 0; m.try_emplace(key, || { let mut __v: Item = ::zero_init(); - Item::construct_2(&mut __v, { &mut counter }, { 3 }); + Item::construct_1(&mut __v, { &mut counter }, { 3 }); __v }); (*std::cell::LazyCell::force_mut(&mut *&raw mut made_0)) = 0; @@ -350,7 +314,7 @@ unsafe fn main_0() -> i32 { ) { (__tmp_7, __tmp_8) => (*__tmp_7).try_emplace(key, || { let mut __v: Item = ::zero_init(); - Item::construct_2(&mut __v, { __tmp_8 }, { 2 }); + Item::construct_1(&mut __v, { __tmp_8 }, { 2 }); __v }), }; @@ -368,7 +332,7 @@ unsafe fn main_0() -> i32 { { (__tmp_10,) => m.try_emplace(key, || { let mut __v: Item = ::zero_init(); - Item::construct_2(&mut __v, { __tmp_10 }, { 2 }); + Item::construct_1(&mut __v, { __tmp_10 }, { 2 }); __v }), }; @@ -386,7 +350,7 @@ unsafe fn main_0() -> i32 { { (__tmp_12,) => m.try_emplace(key, || { let mut __v: Item = ::zero_init(); - Item::construct_2(&mut __v, { __tmp_12 }, { 2 }); + Item::construct_1(&mut __v, { __tmp_12 }, { 2 }); __v }), }; @@ -405,7 +369,7 @@ unsafe fn main_0() -> i32 { { (__tmp_15,) => m.try_emplace(key, || { let mut __v: Item = ::zero_init(); - Item::construct_2(&mut __v, { __tmp_15 }, { 2 }); + Item::construct_1(&mut __v, { __tmp_15 }, { 2 }); __v }), }; @@ -428,7 +392,7 @@ unsafe fn main_0() -> i32 { { (__tmp_18,) => m.try_emplace(key, || { let mut __v: Item = ::zero_init(); - Item::construct_2(&mut __v, { __tmp_18 }, { 3 }); + Item::construct_1(&mut __v, { __tmp_18 }, { 3 }); __v }), }; @@ -449,7 +413,7 @@ unsafe fn main_0() -> i32 { { (__tmp_20,) => m.try_emplace(key, || { let mut __v: Item = ::zero_init(); - Item::construct_2(&mut __v, { __tmp_20 }, { 3 }); + Item::construct_1(&mut __v, { __tmp_20 }, { 3 }); __v }), }; @@ -466,7 +430,7 @@ unsafe fn main_0() -> i32 { { (__tmp_23,) => m.try_emplace(key, || { let mut __v: Item = ::zero_init(); - Item::construct_2(&mut __v, { __tmp_23 }, { 3 }); + Item::construct_1(&mut __v, { __tmp_23 }, { 3 }); __v }), }; @@ -492,7 +456,7 @@ unsafe fn main_0() -> i32 { { (__tmp_26,) => m.try_emplace(key, || { let mut __v: Item = ::zero_init(); - Item::construct_2(&mut __v, { __tmp_26 }, { 3 }); + Item::construct_1(&mut __v, { __tmp_26 }, { 3 }); __v }), }; @@ -517,7 +481,7 @@ unsafe fn main_0() -> i32 { { (__tmp_29,) => m.try_emplace(key, || { let mut __v: Item = ::zero_init(); - Item::construct_2(&mut __v, { __tmp_29 }, { 3 }); + Item::construct_1(&mut __v, { __tmp_29 }, { 3 }); __v }), }; @@ -532,7 +496,7 @@ unsafe fn main_0() -> i32 { { (__tmp_32,) => m.try_emplace(key, || { let mut __v: Item = ::zero_init(); - Item::construct_2(&mut __v, { __tmp_32 }, { 3 }); + Item::construct_1(&mut __v, { __tmp_32 }, { 3 }); __v }), }; @@ -763,7 +727,7 @@ unsafe fn main_0() -> i32 { { (__tmp_60,) => selected.try_emplace(keys[(0) as usize], || { let mut __v: Item = ::zero_init(); - Item::construct_2(&mut __v, { __tmp_60 }, { 2 }); + Item::construct_1(&mut __v, { __tmp_60 }, { 2 }); __v }), }; @@ -786,7 +750,7 @@ unsafe fn main_0() -> i32 { { (__tmp_63,) => selected.try_emplace(keys[(1) as usize], || { let mut __v: Item = ::zero_init(); - Item::construct_2(&mut __v, { __tmp_63 }, { 2 }); + Item::construct_1(&mut __v, { __tmp_63 }, { 2 }); __v }), }; @@ -809,7 +773,7 @@ unsafe fn main_0() -> i32 { { (__tmp_68,) => selected.try_emplace(keys[(2) as usize], || { let mut __v: Item = ::zero_init(); - Item::construct_2(&mut __v, { __tmp_68 }, { 2 }); + Item::construct_1(&mut __v, { __tmp_68 }, { 2 }); __v }), }; @@ -1007,7 +971,7 @@ unsafe fn main_0() -> i32 { if (hit != 0) { arrays.try_emplace(key, || { let mut __v: Held = ::zero_init(); - Held::construct_3(&mut __v, { &ordinary_array }, { 0 }); + Held::construct_2(&mut __v, { &ordinary_array }, { 0 }); __v }); } @@ -1036,7 +1000,7 @@ unsafe fn main_0() -> i32 { { (__tmp_82,) => arrays.try_emplace(key, || { let mut __v: Held = ::zero_init(); - Held::construct_3(&mut __v, { __tmp_82 }, { 0 }); + Held::construct_2(&mut __v, { __tmp_82 }, { 0 }); __v }), }; @@ -1081,7 +1045,7 @@ unsafe fn main_0() -> i32 { match ((&mut (*(*{ __tmp_86 = Some(Box::new({ let mut __v: Temporary = ::zero_init(); - Temporary::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v })); &mut __tmp_86 @@ -1100,7 +1064,7 @@ unsafe fn main_0() -> i32 { match ((&mut (*&mut (*(*{ __tmp_88 = Some(Box::new({ let mut __v: Nested = ::zero_init(); - Nested::construct_1(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v })); &mut __tmp_88 @@ -1120,7 +1084,7 @@ unsafe fn main_0() -> i32 { match ((&mut (*(*{ __tmp_90 = Some(Box::new({ let mut __v: Temporary = ::zero_init(); - Temporary::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v })); &mut __tmp_90 @@ -1139,7 +1103,7 @@ unsafe fn main_0() -> i32 { match ((&mut (*(*{ __tmp_92 = Some(Box::new({ let mut __v: Temporary = ::zero_init(); - Temporary::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v })); &mut __tmp_92 @@ -1156,7 +1120,7 @@ unsafe fn main_0() -> i32 { match ((&mut (*((*{ __tmp_94 = Some(Box::new({ let mut __v: Temporary = ::zero_init(); - Temporary::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v })); &mut __tmp_94 @@ -1175,7 +1139,7 @@ unsafe fn main_0() -> i32 { match ((&mut (*((*(*{ __tmp_96 = Some(Box::new(Some(Box::new({ let mut __v: Temporary = ::zero_init(); - Temporary::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v })))); &mut __tmp_96 @@ -1244,7 +1208,9 @@ unsafe fn main_0() -> i32 { (&mut (*(*{ __tmp_98 = Some(Box::new({ let mut __v: Temporary = ::zero_init(); - Temporary::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor( + &mut __v, + ); __v })); &mut __tmp_98 @@ -1258,7 +1224,9 @@ unsafe fn main_0() -> i32 { (&mut (*(*{ __tmp_99 = Some(Box::new({ let mut __v: Temporary = ::zero_init(); - Temporary::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor( + &mut __v, + ); __v })); &mut __tmp_99 @@ -1303,7 +1271,9 @@ unsafe fn main_0() -> i32 { match (((unsafe { Owner::value( &mut (*{ - Owner::construct(&mut __tmp_101); + DefaultConstructibleUnsafe::default_constructor( + &mut __tmp_101, + ); &mut __tmp_101 }), ) @@ -1336,7 +1306,7 @@ unsafe fn main_0() -> i32 { match (({ __tmp_103 = Some(Box::new({ let mut __v: Noncopy = ::zero_init(); - Noncopy::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v })); &mut __tmp_103 @@ -1353,7 +1323,7 @@ unsafe fn main_0() -> i32 { match (({ __tmp_105 = Some(Box::new({ let mut __v: Noncopy = ::zero_init(); - Noncopy::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v })); &mut __tmp_105 diff --git a/tests/unit/out/unsafe/memcpy_struct_struct.rs b/tests/unit/out/unsafe/memcpy_struct_struct.rs index 678b416258..98efc4c3f3 100644 --- a/tests/unit/out/unsafe/memcpy_struct_struct.rs +++ b/tests/unit/out/unsafe/memcpy_struct_struct.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Entry { pub bits: u8, pub value: u16, diff --git a/tests/unit/out/unsafe/move_assign.rs b/tests/unit/out/unsafe/move_assign.rs index 7b5935c379..a4250a2b7f 100644 --- a/tests/unit/out/unsafe/move_assign.rs +++ b/tests/unit/out/unsafe/move_assign.rs @@ -47,9 +47,6 @@ pub struct ConstMoveAssign { pub mark: i32, } impl ConstMoveAssign { - pub unsafe fn construct(&mut self) { - (&raw mut self.mark).write(0); - } pub unsafe fn operator_assign_2(&mut self, o: *mut ConstMoveAssign) -> *mut ConstMoveAssign { self.mark = (((*o).mark) + (1)); return &mut (*(self as *mut ConstMoveAssign)); @@ -61,9 +58,7 @@ impl ConstMoveAssign { } impl DefaultConstructibleUnsafe for ConstMoveAssign { unsafe fn default_constructor(&mut self) { - unsafe { - ConstMoveAssign::construct(&mut *self); - } + (&raw mut self.mark).write(0); } } impl Default for ConstMoveAssign { @@ -71,7 +66,7 @@ impl Default for ConstMoveAssign { unsafe { { let mut __v: ConstMoveAssign = ::zero_init(); - ConstMoveAssign::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -143,13 +138,13 @@ unsafe fn main_0() -> i32 { assert!(((vec_[(0_usize)].v) == (8))); assert!(((d.v) == (0))); let mut m: ConstMoveAssign = ::zero_init(); - ConstMoveAssign::construct(&mut m); + DefaultConstructibleUnsafe::default_constructor(&mut m); let mut m1: ConstMoveAssign = ::zero_init(); - ConstMoveAssign::construct(&mut m1); + DefaultConstructibleUnsafe::default_constructor(&mut m1); let mut m2: ConstMoveAssign = ::zero_init(); - ConstMoveAssign::construct(&mut m2); + DefaultConstructibleUnsafe::default_constructor(&mut m2); let mut cm: ConstMoveAssign = ::zero_init(); - ConstMoveAssign::construct(&mut cm); + DefaultConstructibleUnsafe::default_constructor(&mut cm); (unsafe { ConstMoveAssign::operator_assign_2(&mut m1, &mut m) }); (unsafe { ConstMoveAssign::operator_assign_3(&mut m2, &cm) }); assert!(((m1.mark) == (1))); diff --git a/tests/unit/out/unsafe/move_ctor.rs b/tests/unit/out/unsafe/move_ctor.rs index 87ca249222..17c54e25ff 100644 --- a/tests/unit/out/unsafe/move_ctor.rs +++ b/tests/unit/out/unsafe/move_ctor.rs @@ -36,9 +36,6 @@ pub struct ConstMove { pub mark: i32, } impl ConstMove { - pub unsafe fn construct(&mut self) { - (&raw mut self.mark).write(0); - } pub unsafe fn construct_1(&mut self, o: *mut ConstMove) { (&raw mut self.mark).write((((*o).mark) + (1))); } @@ -48,9 +45,7 @@ impl ConstMove { } impl DefaultConstructibleUnsafe for ConstMove { unsafe fn default_constructor(&mut self) { - unsafe { - ConstMove::construct(&mut *self); - } + (&raw mut self.mark).write(0); } } impl Default for ConstMove { @@ -58,7 +53,7 @@ impl Default for ConstMove { unsafe { { let mut __v: ConstMove = ::zero_init(); - ConstMove::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -238,11 +233,11 @@ unsafe fn main_0() -> i32 { assert!(((vec_[(0_usize)].v) == (7)) && ((vec_[(1_usize)].v) == (8))); assert!(((f.v) == (0))); let mut m: ConstMove = ::zero_init(); - ConstMove::construct(&mut m); + DefaultConstructibleUnsafe::default_constructor(&mut m); let mut m1: ConstMove = ::zero_init(); ConstMove::construct_1(&mut m1, { &mut m }); let mut cm: ConstMove = ::zero_init(); - ConstMove::construct(&mut cm); + DefaultConstructibleUnsafe::default_constructor(&mut cm); let mut m2: ConstMove = ::zero_init(); ConstMove::construct_2(&mut m2, { &cm }); assert!(((m1.mark) == (1))); diff --git a/tests/unit/out/unsafe/nested_structs.rs b/tests/unit/out/unsafe/nested_structs.rs index 4b513687ac..f4d90e4da9 100644 --- a/tests/unit/out/unsafe/nested_structs.rs +++ b/tests/unit/out/unsafe/nested_structs.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Level0_Level1_1_Level2_1_Level3_1 { pub x1: i32, } @@ -27,10 +28,11 @@ pub struct Level0_Level1_1_Level2_1_Level3_1 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Level0_Level1_1_Level2_1_Level3_2 { pub x1: i32, pub x2: i32, @@ -42,10 +44,11 @@ pub struct Level0_Level1_1_Level2_1_Level3_2 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Level0_Level1_1_Level2_1 { pub x1: i32, } @@ -56,10 +59,11 @@ pub struct Level0_Level1_1_Level2_1 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Level0_Level1_1 { pub x1: i32, } @@ -70,10 +74,11 @@ pub struct Level0_Level1_1 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Level0_Level1_2 { pub x1: i32, pub x2: i32, @@ -85,10 +90,11 @@ pub struct Level0_Level1_2 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Level0 {} pub fn main() { unsafe { diff --git a/tests/unit/out/unsafe/new.rs b/tests/unit/out/unsafe/new.rs index 6220abaafb..2ac66d4f30 100644 --- a/tests/unit/out/unsafe/new.rs +++ b/tests/unit/out/unsafe/new.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 9632757f9b..59bb5973e7 100644 --- a/tests/unit/out/unsafe/new_bst.rs +++ b/tests/unit/out/unsafe/new_bst.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 47bb9cf3f1..03324cdc1f 100644 --- a/tests/unit/out/unsafe/new_struct.rs +++ b/tests/unit/out/unsafe/new_struct.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Pair { pub x: i32, pub y: i32, @@ -28,10 +29,11 @@ pub struct Pair { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 8cee7819a9..6333a08ee4 100644 --- a/tests/unit/out/unsafe/nttp_distinct_specializations.rs +++ b/tests/unit/out/unsafe/nttp_distinct_specializations.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct S_2_ { pub v: i32, pub w: i32, @@ -33,10 +34,11 @@ impl S_2_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct S_1_ { pub v: i32, } @@ -52,10 +54,11 @@ impl S_1_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct S_3_ { pub v: i32, } diff --git a/tests/unit/out/unsafe/offsetof.rs b/tests/unit/out/unsafe/offsetof.rs index e7cdacc7c5..9975135d3b 100644 --- a/tests/unit/out/unsafe/offsetof.rs +++ b/tests/unit/out/unsafe/offsetof.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Layout { pub a: u8, pub b: u32, @@ -29,9 +30,10 @@ pub struct Layout { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, )] +#[memberwise(default_constructor)] pub struct Frame { pub tag: u16, pub body: [libc::c_char; 64], diff --git a/tests/unit/out/unsafe/opaque_record_copy.rs b/tests/unit/out/unsafe/opaque_record_copy.rs index ba8f5b71c8..5c0f357c51 100644 --- a/tests/unit/out/unsafe/opaque_record_copy.rs +++ b/tests/unit/out/unsafe/opaque_record_copy.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Probe {} #[repr(C)] #[derive( @@ -25,10 +26,11 @@ pub struct Probe {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Wrapper_Probe_ { pub base_: Probe, pub tag: i32, diff --git a/tests/unit/out/unsafe/operator_arithmetic_free.rs b/tests/unit/out/unsafe/operator_arithmetic_free.rs index bcffc4392a..e4199278a9 100644 --- a/tests/unit/out/unsafe/operator_arithmetic_free.rs +++ b/tests/unit/out/unsafe/operator_arithmetic_free.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 b0543f4012..44d84b7e6a 100644 --- a/tests/unit/out/unsafe/operator_arithmetic_member.rs +++ b/tests/unit/out/unsafe/operator_arithmetic_member.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 3afd1bccf6..e11e2d9e48 100644 --- a/tests/unit/out/unsafe/operator_bitwise_free.rs +++ b/tests/unit/out/unsafe/operator_bitwise_free.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 b512be50e1..2c0a7ee4c5 100644 --- a/tests/unit/out/unsafe/operator_bitwise_member.rs +++ b/tests/unit/out/unsafe/operator_bitwise_member.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 5710ea0d7d..33067d7992 100644 --- a/tests/unit/out/unsafe/operator_comparison_defaulted.rs +++ b/tests/unit/out/unsafe/operator_comparison_defaulted.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Eq { pub a: i32, pub b: i32, @@ -40,10 +41,11 @@ impl std::cmp::Eq for Eq {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Cmp { pub a: i32, pub b: i32, @@ -94,10 +96,11 @@ impl std::cmp::Eq for Cmp {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Both { pub a: i32, } @@ -139,10 +142,11 @@ impl std::cmp::Eq for Both {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct OrdOnly { pub a: i32, } @@ -181,10 +185,11 @@ impl std::cmp::Eq for OrdOnly {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Inner { pub x: i32, } @@ -226,10 +231,11 @@ impl std::cmp::Eq for Inner {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Outer { pub i: Inner, pub y: i32, @@ -284,10 +290,11 @@ impl std::cmp::Eq for Outer {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Secondary { pub a: i32, } @@ -340,10 +347,11 @@ impl std::cmp::Eq for Secondary {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 2705370eba..0b18714abb 100644 --- a/tests/unit/out/unsafe/operator_comparison_free.rs +++ b/tests/unit/out/unsafe/operator_comparison_free.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct S { pub v: i32, } @@ -75,10 +76,11 @@ pub unsafe fn operator_lt_7(mut a: i32, b: *const S) -> bool { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 f122b5b633..8c9f42fc87 100644 --- a/tests/unit/out/unsafe/operator_comparison_member.rs +++ b/tests/unit/out/unsafe/operator_comparison_member.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 f6be0a019c..559114f5c5 100644 --- a/tests/unit/out/unsafe/operator_comparison_mixed.rs +++ b/tests/unit/out/unsafe/operator_comparison_mixed.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 bbc7198aa1..ec7886cfb4 100644 --- a/tests/unit/out/unsafe/operator_comparison_nonbool.rs +++ b/tests/unit/out/unsafe/operator_comparison_nonbool.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct X { pub v: i32, } @@ -69,10 +70,11 @@ pub unsafe fn operator_ge_5(mut a: X, mut b: X) -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Result { pub r: i32, } @@ -83,10 +85,11 @@ pub struct Result { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Custom { pub v: i32, } @@ -104,10 +107,11 @@ impl Custom { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Mixed { pub v: i32, } @@ -179,10 +183,11 @@ impl MyBool { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Boolish { pub v: i32, } @@ -270,10 +275,11 @@ pub static mut ref_true_8: std::cell::LazyCell = std::cell::LazyCell::n VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 33bb6ca69d..fb0eb14060 100644 --- a/tests/unit/out/unsafe/operator_compound_assignment_free.rs +++ b/tests/unit/out/unsafe/operator_compound_assignment_free.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 438344e59d..a4b231f6d1 100644 --- a/tests/unit/out/unsafe/operator_compound_assignment_member.rs +++ b/tests/unit/out/unsafe/operator_compound_assignment_member.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 7ff60a7632..9623a2c3fe 100644 --- a/tests/unit/out/unsafe/operator_friend.rs +++ b/tests/unit/out/unsafe/operator_friend.rs @@ -16,10 +16,11 @@ pub unsafe fn operator_eq_0(_a0: *const Defaulted, _a1: *const Defaulted) -> boo VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Defaulted { pub a: i32, pub b: i32, @@ -52,10 +53,11 @@ pub unsafe fn operator_eq_2(_a0: *const DefaultedOrd, _a1: *const DefaultedOrd) VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct DefaultedOrd { pub a: i32, } @@ -93,10 +95,11 @@ pub unsafe fn operator_add_5(x: *const Inline, y: *const Inline) -> Inline { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Inline { pub a: i32, } @@ -131,10 +134,11 @@ impl std::cmp::Eq for Inline {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct OutOfLine { pub a: i32, } @@ -169,10 +173,11 @@ pub unsafe fn operator_eq_10(x: *const Tmpl_int_, y: *const Tmpl_long_) -> bool VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Tmpl_int_ { pub v: i32, } @@ -207,10 +212,11 @@ impl std::cmp::Eq for Tmpl_int_ {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Tmpl_long_ { pub v: i64, } @@ -227,10 +233,11 @@ pub unsafe fn operator_eq_11( VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 8654102168..87baa70af0 100644 --- a/tests/unit/out/unsafe/operator_less_than.rs +++ b/tests/unit/out/unsafe/operator_less_than.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 2b05ae036c..67b6ddb418 100644 --- a/tests/unit/out/unsafe/operator_logical_free.rs +++ b/tests/unit/out/unsafe/operator_logical_free.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 9bcc9de46c..65eb9a462e 100644 --- a/tests/unit/out/unsafe/operator_logical_member.rs +++ b/tests/unit/out/unsafe/operator_logical_member.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 73ffdc99b8..2cb9016d5b 100644 --- a/tests/unit/out/unsafe/operator_member_pointer_free.rs +++ b/tests/unit/out/unsafe/operator_member_pointer_free.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Inner { pub x: i32, } @@ -27,10 +28,11 @@ pub struct Inner { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 0fb2465724..938843c18e 100644 --- a/tests/unit/out/unsafe/operator_member_pointer_member.rs +++ b/tests/unit/out/unsafe/operator_member_pointer_member.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Inner { pub x: i32, } @@ -27,10 +28,11 @@ pub struct Inner { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Table {} impl Table { pub unsafe fn operator_index(mut i: i32) -> *mut i32 { @@ -46,10 +48,11 @@ pub static mut table_0: std::cell::LazyCell<[i32; 3]> = VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 ee158e2b83..b09a8c33a2 100644 --- a/tests/unit/out/unsafe/operator_other_free.rs +++ b/tests/unit/out/unsafe/operator_other_free.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 be18c378ee..f0c958ae49 100644 --- a/tests/unit/out/unsafe/operator_other_member.rs +++ b/tests/unit/out/unsafe/operator_other_member.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Static {} impl Static { pub unsafe fn operator_call(mut a: i32, mut b: i32) -> i32 { @@ -31,10 +32,11 @@ impl Static { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] #[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 1c6720f49a..33b1e754aa 100644 --- a/tests/unit/out/unsafe/operator_overloads.rs +++ b/tests/unit/out/unsafe/operator_overloads.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 c78d57f462..b78eb7e09a 100644 --- a/tests/unit/out/unsafe/operator_qualifiers.rs +++ b/tests/unit/out/unsafe/operator_qualifiers.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 1a5acbc4e9..2bb9c2cd2c 100644 --- a/tests/unit/out/unsafe/operator_three_way.rs +++ b/tests/unit/out/unsafe/operator_three_way.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 3ada3cd6ed..ecf6793226 100644 --- a/tests/unit/out/unsafe/operator_traits.rs +++ b/tests/unit/out/unsafe/operator_traits.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Lt { pub v: i32, } @@ -59,10 +60,11 @@ impl std::cmp::Eq for Lt {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Eq { pub v: i32, } @@ -84,10 +86,11 @@ impl std::cmp::Eq for Eq {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Cmp { pub v: i32, } @@ -122,10 +125,11 @@ impl std::cmp::Eq for Cmp {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Free { pub v: i32, } @@ -166,10 +170,11 @@ pub unsafe fn operator_eq_1(a: *const Free, b: *const Free) -> bool { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 883bffb2d2..a94d7b5c64 100644 --- a/tests/unit/out/unsafe/overload_mangling.rs +++ b/tests/unit/out/unsafe/overload_mangling.rs @@ -22,10 +22,11 @@ pub unsafe fn twice_2(mut n: i32) -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Access_S_ {} impl Access_S_ { pub unsafe fn get_1(&mut self, mut p: *mut S) -> i32 { @@ -48,10 +49,11 @@ impl Access_S_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct S { pub base: i32, } @@ -131,10 +133,11 @@ impl S { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 f4b085cec4..7521888ece 100644 --- a/tests/unit/out/unsafe/pair_converting_construction.rs +++ b/tests/unit/out/unsafe/pair_converting_construction.rs @@ -35,10 +35,11 @@ impl Celsius { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] #[cpp_into(i32, to_i32)] pub struct Meters { pub value: i32, @@ -156,10 +157,11 @@ impl Default for Fallback { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Counter { pub hits: i32, } diff --git a/tests/unit/out/unsafe/pod.rs b/tests/unit/out/unsafe/pod.rs index 4b7b4c4d29..16136af535 100644 --- a/tests/unit/out/unsafe/pod.rs +++ b/tests/unit/out/unsafe/pod.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 8647f517db..c6ef74f43b 100644 --- a/tests/unit/out/unsafe/pointer_array.rs +++ b/tests/unit/out/unsafe/pointer_array.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 c5a6e540dd..57b62f52aa 100644 --- a/tests/unit/out/unsafe/pointers.rs +++ b/tests/unit/out/unsafe/pointers.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Test { pub x: i32, } diff --git a/tests/unit/out/unsafe/push_emplace_back.rs b/tests/unit/out/unsafe/push_emplace_back.rs index 4a3879c5c5..d387d5baad 100644 --- a/tests/unit/out/unsafe/push_emplace_back.rs +++ b/tests/unit/out/unsafe/push_emplace_back.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Chunk { pub data: i32, } @@ -27,10 +28,11 @@ pub struct Chunk { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Writer { pub output: *mut Vec, pub chunk: Chunk, @@ -52,17 +54,10 @@ pub struct JPEGData { pub com_data: Vec>, pub app_data: Vec>, } -impl JPEGData { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.com_data).write(Vec::new()); - (&raw mut self.app_data).write(Vec::new()); - } -} impl DefaultConstructibleUnsafe for JPEGData { unsafe fn default_constructor(&mut self) { - unsafe { - JPEGData::construct_1(&mut *self); - } + (&raw mut self.com_data).write(Vec::new()); + (&raw mut self.app_data).write(Vec::new()); } } pub unsafe fn push_param_0(mut dest: *mut Vec>) { @@ -140,24 +135,19 @@ pub struct Pair { pub second: i32, } impl Pair { - pub unsafe fn construct_2(&mut self) { - (&raw mut self.first).write(-1_i32); - (&raw mut self.second).write(-1_i32); - } pub unsafe fn construct_1(&mut self, mut a: i32) { (&raw mut self.first).write(a); (&raw mut self.second).write(0); } - pub unsafe fn construct_3(&mut self, mut a: i32, mut b: i32) { + pub unsafe fn construct_2(&mut self, mut a: i32, mut b: i32) { (&raw mut self.first).write(a); (&raw mut self.second).write(((b) * (2))); } } impl DefaultConstructibleUnsafe for Pair { unsafe fn default_constructor(&mut self) { - unsafe { - Pair::construct_2(&mut *self); - } + (&raw mut self.first).write(-1_i32); + (&raw mut self.second).write(-1_i32); } } impl Default for Pair { @@ -165,7 +155,7 @@ impl Default for Pair { unsafe { { let mut __v: Pair = ::zero_init(); - Pair::construct_2(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -174,7 +164,7 @@ impl Default for Pair { pub unsafe fn emplace_ctor_args_7(mut pairs: *mut Vec) { (*pairs).push_mut({ let mut __v: Pair = ::zero_init(); - Pair::construct_2(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v }); (*pairs).push_mut({ @@ -184,19 +174,19 @@ pub unsafe fn emplace_ctor_args_7(mut pairs: *mut Vec) { }); (*pairs).push_mut({ let mut __v: Pair = ::zero_init(); - Pair::construct_3(&mut __v, { 4 }, { 5 }); + Pair::construct_2(&mut __v, { 4 }, { 5 }); __v }); } pub unsafe fn emplace_deque_8(mut queue: *mut Vec) { (*queue).push_mut({ let mut __v: Pair = ::zero_init(); - Pair::construct_3(&mut __v, { 6 }, { 7 }); + Pair::construct_2(&mut __v, { 6 }, { 7 }); __v }); (*queue).push_mut({ let mut __v: Pair = ::zero_init(); - Pair::construct_2(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v }); } @@ -207,7 +197,7 @@ pub unsafe fn emplace_scalar_9(mut values: *mut Vec, mut x: i32) { pub unsafe fn emplace_ref_through_ptr_10(mut pairs: *mut Vec) { let p: *mut Pair = (*pairs).push_mut({ let mut __v: Pair = ::zero_init(); - Pair::construct_3(&mut __v, { 1 }, { 2 }); + Pair::construct_2(&mut __v, { 1 }, { 2 }); __v }); (*p).second = 3; @@ -226,7 +216,7 @@ pub unsafe fn emplace_self_reads_12(mut values: *mut Vec, mut pairs: *mut V (*pairs).push_mut((&mut (*pairs))[(0_usize)]); (*pairs).push_mut({ let mut __v: Pair = ::zero_init(); - Pair::construct_3( + Pair::construct_2( &mut __v, { (*{ @@ -260,17 +250,10 @@ pub struct Bytes { pub v: Vec>, pub b: [u8; 3], } -impl Bytes { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.v).write(Vec::new()); - (&raw mut self.b).write([0_u8; 3]); - } -} impl DefaultConstructibleUnsafe for Bytes { unsafe fn default_constructor(&mut self) { - unsafe { - Bytes::construct_1(&mut *self); - } + (&raw mut self.v).write(Vec::new()); + (&raw mut self.b).write([0_u8; 3]); } } pub unsafe fn emplace_from_element_14(mut v: *mut Vec>) { @@ -293,10 +276,11 @@ pub unsafe fn emplace_from_element_14(mut v: *mut Vec>) { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Plain { pub a: i32, pub b: [f64; 2], @@ -365,7 +349,7 @@ unsafe fn main_0() -> i32 { assert!(((vecs.len()) == (1_usize))); assert!(vecs[(0_usize)].is_empty()); let mut jpg: JPEGData = ::zero_init(); - JPEGData::construct_1(&mut jpg); + DefaultConstructibleUnsafe::default_constructor(&mut jpg); (unsafe { push_local_from_field_1((&mut jpg as *mut JPEGData), true) }); assert!(((jpg.com_data.len()) == (1_usize))); assert!(((jpg.com_data[(0_usize)].len()) == (3_usize))); @@ -444,7 +428,7 @@ unsafe fn main_0() -> i32 { let mut self_pairs: Vec = Vec::new(); self_pairs.push_mut({ let mut __v: Pair = ::zero_init(); - Pair::construct_3(&mut __v, { 1 }, { 2 }); + Pair::construct_2(&mut __v, { 1 }, { 2 }); __v }); (unsafe { diff --git a/tests/unit/out/unsafe/random.rs b/tests/unit/out/unsafe/random.rs index e2bf3c868b..81561413f5 100644 --- a/tests/unit/out/unsafe/random.rs +++ b/tests/unit/out/unsafe/random.rs @@ -56,10 +56,11 @@ pub unsafe fn zero_0() -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 68a385f9c3..b75da31ce1 100644 --- a/tests/unit/out/unsafe/reference_wrapper.rs +++ b/tests/unit/out/unsafe/reference_wrapper.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 a24673eaf1..d855ac2c3f 100644 --- a/tests/unit/out/unsafe/references.rs +++ b/tests/unit/out/unsafe/references.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Pair { pub x: i32, pub y: i32, @@ -29,10 +30,11 @@ pub struct Pair { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 084e4653e2..389cff6497 100644 --- a/tests/unit/out/unsafe/refs_as_args.rs +++ b/tests/unit/out/unsafe/refs_as_args.rs @@ -24,10 +24,11 @@ pub unsafe fn more_refs_0(mut x1: i32, mut x2: i32, r1: *mut i32, r2: *const i32 VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 54edde9f09..d8346ba081 100644 --- a/tests/unit/out/unsafe/reinterpret_cast_ptr_cmp.rs +++ b/tests/unit/out/unsafe/reinterpret_cast_ptr_cmp.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct S { pub x: i32, pub y: i32, @@ -28,10 +29,11 @@ pub struct S { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct W { pub h: i32, pub arr: [S; 3], @@ -43,10 +45,11 @@ pub struct W { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 bee53d9fee..98e794eaf4 100644 --- a/tests/unit/out/unsafe/reinterpret_cast_struct.rs +++ b/tests/unit/out/unsafe/reinterpret_cast_struct.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 ed29ef0dea..4336d7f618 100644 --- a/tests/unit/out/unsafe/reinterpret_cast_struct_to_struct.rs +++ b/tests/unit/out/unsafe/reinterpret_cast_struct_to_struct.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Point { pub x: u32, pub y: u32, @@ -28,10 +29,11 @@ pub struct Point { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 666ae8cb9e..805e143550 100644 --- a/tests/unit/out/unsafe/reserved_keywords.rs +++ b/tests/unit/out/unsafe/reserved_keywords.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct S { pub as_: i32, pub async_: i32, @@ -64,10 +65,11 @@ pub struct S { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct type_ { pub v: i32, } @@ -78,10 +80,11 @@ pub struct type_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 a1a1641eb6..d03cbdcf56 100644 --- a/tests/unit/out/unsafe/return_move.rs +++ b/tests/unit/out/unsafe/return_move.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct node { pub value: i32, pub next: *mut node, @@ -28,10 +29,11 @@ pub struct node { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct pair_t { pub a: i32, pub n: *mut node, diff --git a/tests/unit/out/unsafe/scalar_builtin_construct_destruct.rs b/tests/unit/out/unsafe/scalar_builtin_construct_destruct.rs index b711711828..3e4a5119b6 100644 --- a/tests/unit/out/unsafe/scalar_builtin_construct_destruct.rs +++ b/tests/unit/out/unsafe/scalar_builtin_construct_destruct.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 714b31194f..9c05272f65 100644 --- a/tests/unit/out/unsafe/self_referencing_initializer.rs +++ b/tests/unit/out/unsafe/self_referencing_initializer.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct list_head { pub next: *mut list_head, } @@ -27,10 +28,11 @@ pub struct list_head { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct node { pub value: i32, pub value_ptr: *mut i32, @@ -41,17 +43,10 @@ pub struct node_with_defaults { pub next: *mut node_with_defaults, pub value: i32, } -impl node_with_defaults { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.next).write(std::ptr::null_mut()); - (&raw mut self.value).write(3); - } -} impl DefaultConstructibleUnsafe for node_with_defaults { unsafe fn default_constructor(&mut self) { - unsafe { - node_with_defaults::construct_1(&mut *self); - } + (&raw mut self.next).write(std::ptr::null_mut()); + (&raw mut self.value).write(3); } } impl Default for node_with_defaults { diff --git a/tests/unit/out/unsafe/size_t_static_member.rs b/tests/unit/out/unsafe/size_t_static_member.rs index 719488559e..6f6b83ea3d 100644 --- a/tests/unit/out/unsafe/size_t_static_member.rs +++ b/tests/unit/out/unsafe/size_t_static_member.rs @@ -14,10 +14,11 @@ pub static mut c_0: std::cell::LazyCell = std::cell::LazyCell::new(|| uns VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct S {} pub static mut table_size_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 256_usize }); @@ -28,10 +29,11 @@ pub static mut table_size_1: std::cell::LazyCell = VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Table_char_ {} pub fn main() { unsafe { diff --git a/tests/unit/out/unsafe/sort_no_copy.rs b/tests/unit/out/unsafe/sort_no_copy.rs index 460f0b45c3..61857d53ed 100644 --- a/tests/unit/out/unsafe/sort_no_copy.rs +++ b/tests/unit/out/unsafe/sort_no_copy.rs @@ -16,13 +16,15 @@ pub struct Tracked { pub v: i32, } impl Tracked { - pub unsafe fn construct_2(&mut self) { - (&raw mut self.v).write(0); - } pub unsafe fn construct_1(&mut self, mut v: i32) { (&raw mut self.v).write(v); } } +impl DefaultConstructibleUnsafe for Tracked { + unsafe fn default_constructor(&mut self) { + (&raw mut self.v).write(0); + } +} impl CopyConstructibleUnsafe for Tracked { unsafe fn copy_constructor(&mut self, o: *const Tracked) { (&raw mut self.v).write((*o).v); @@ -83,19 +85,12 @@ impl Clone for Tracked { } } } -impl DefaultConstructibleUnsafe for Tracked { - unsafe fn default_constructor(&mut self) { - unsafe { - Tracked::construct_2(&mut *self); - } - } -} impl Default for Tracked { fn default() -> Self { unsafe { { let mut __v: Tracked = ::zero_init(); - Tracked::construct_2(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -174,8 +169,8 @@ pub unsafe fn operator_lt_3(a: *const MoveOnly, b: *const MoveOnly) -> bool { pub struct Bag { pub items: Vec, } -impl Bag { - pub unsafe fn construct_1(&mut self) { +impl DefaultConstructibleUnsafe for Bag { + unsafe fn default_constructor(&mut self) { (&raw mut self.items).write(Vec::new()); } } @@ -203,13 +198,6 @@ impl std::cmp::PartialEq for Bag { } } impl std::cmp::Eq for Bag {} -impl DefaultConstructibleUnsafe for Bag { - unsafe fn default_constructor(&mut self) { - unsafe { - Bag::construct_1(&mut *self); - } - } -} pub unsafe fn operator_lt_4(a: *const Bag, b: *const Bag) -> bool { return (((*a).items.len()) < ((*b).items.len())); } @@ -417,7 +405,7 @@ unsafe fn main_0() -> i32 { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (0))); let mut bags: [Bag; 3] = std::array::from_fn::<_, 3, _>(|_| { let mut __v: Bag = ::zero_init(); - Bag::construct_1(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v }); bags[(0) as usize].items.push_mut({ diff --git a/tests/unit/out/unsafe/static_local.rs b/tests/unit/out/unsafe/static_local.rs index 27e2a08934..91bd7e1dba 100644 --- a/tests/unit/out/unsafe/static_local.rs +++ b/tests/unit/out/unsafe/static_local.rs @@ -28,10 +28,11 @@ static mut x_7: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 e4897c1929..2b4c159fdc 100644 --- a/tests/unit/out/unsafe/static_var_in_class.rs +++ b/tests/unit/out/unsafe/static_var_in_class.rs @@ -14,10 +14,11 @@ static mut inner_const_0: std::cell::LazyCell = std::cell::LazyCell::new(|| VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct C {} impl C { pub unsafe fn get(&mut self) -> i32 { @@ -34,10 +35,11 @@ pub const anon_3_kValue: anon_3 = 3; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct S {} impl S { pub unsafe fn f() -> i32 { diff --git a/tests/unit/out/unsafe/struct_ctor.rs b/tests/unit/out/unsafe/struct_ctor.rs index 215d979b12..9b32ca8b9e 100644 --- a/tests/unit/out/unsafe/struct_ctor.rs +++ b/tests/unit/out/unsafe/struct_ctor.rs @@ -65,17 +65,10 @@ pub struct Ptr_ { pub v1: Value_, pub v2: Value_, } -impl Ptr_ { - pub unsafe fn construct(&mut self) { - Value_::construct(&mut self.v1, { 11 }); - Value_::construct(&mut self.v2, { 22 }); - } -} impl DefaultConstructibleUnsafe for Ptr_ { unsafe fn default_constructor(&mut self) { - unsafe { - Ptr_::construct(&mut *self); - } + Value_::construct(&mut self.v1, { 11 }); + Value_::construct(&mut self.v2, { 22 }); } } impl Default for Ptr_ { @@ -83,7 +76,7 @@ impl Default for Ptr_ { unsafe { { let mut __v: Ptr_ = ::zero_init(); - Ptr_::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -105,7 +98,7 @@ unsafe fn main_0() -> i32 { && ((*(unsafe { StructWithCtor::x2(&struct_with_ctor,) })) == (1)) ); let mut p: Ptr_ = ::zero_init(); - Ptr_::construct(&mut p); + DefaultConstructibleUnsafe::default_constructor(&mut p); assert!(((p.v1.v) == (11))); assert!(((p.v2.v) == (22))); return 0; diff --git a/tests/unit/out/unsafe/struct_default_ctor.rs b/tests/unit/out/unsafe/struct_default_ctor.rs index caf9880449..c003d64bf9 100644 --- a/tests/unit/out/unsafe/struct_default_ctor.rs +++ b/tests/unit/out/unsafe/struct_default_ctor.rs @@ -12,17 +12,10 @@ pub struct S { pub a: i32, pub b: bool, } -impl S { - pub unsafe fn construct(&mut self) { - (&raw mut self.a).write(11); - (&raw mut self.b).write(true); - } -} impl DefaultConstructibleUnsafe for S { unsafe fn default_constructor(&mut self) { - unsafe { - S::construct(&mut *self); - } + (&raw mut self.a).write(11); + (&raw mut self.b).write(true); } } impl Default for S { @@ -30,7 +23,7 @@ impl Default for S { unsafe { { let mut __v: S = ::zero_init(); - S::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -38,19 +31,11 @@ impl Default for S { } #[repr(C)] #[derive( - Copy, - Clone, - VaArg, - FnPtrArg, - ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, - TriviallyCopyableUnsafe, - Default, + Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, )] pub struct Declared { pub v: i32, } -impl Declared {} #[repr(C)] #[derive( Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, Default, @@ -58,38 +43,24 @@ impl Declared {} pub struct Holder { pub items: [S; 2], } -impl Holder { - pub unsafe fn construct_1(&mut self) { +impl DefaultConstructibleUnsafe for Holder { + unsafe fn default_constructor(&mut self) { (&raw mut self.items).write(std::array::from_fn::<_, 2, _>(|_| { let mut __v: S = ::zero_init(); - S::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v })); } } -impl DefaultConstructibleUnsafe for Holder { - unsafe fn default_constructor(&mut self) { - unsafe { - Holder::construct_1(&mut *self); - } - } -} pub static mut kInit_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 3 }); #[repr(C)] #[derive(Copy, Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe)] pub struct FromStatic { pub v: i32, } -impl FromStatic { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.v).write((*std::cell::LazyCell::force_mut(&mut *&raw mut kInit_0))); - } -} impl DefaultConstructibleUnsafe for FromStatic { unsafe fn default_constructor(&mut self) { - unsafe { - FromStatic::construct_1(&mut *self); - } + (&raw mut self.v).write((*std::cell::LazyCell::force_mut(&mut *&raw mut kInit_0))); } } impl Default for FromStatic { @@ -111,7 +82,7 @@ unsafe fn main_0() -> i32 { let mut d: *mut Declared = std::ptr::null_mut(); assert!((d).is_null()); let mut s: S = ::zero_init(); - S::construct(&mut s); + DefaultConstructibleUnsafe::default_constructor(&mut s); assert!(((s.a) == (11))); assert!(((s.b as i32) == (true as i32))); let mut h: *mut Holder = Box::leak( @@ -150,6 +121,11 @@ unsafe fn main_0() -> i32 { }; return 0; } +impl DefaultConstructibleUnsafe for Declared { + unsafe fn default_constructor(&mut self) { + unreachable!("Declared::default_constructor is never defined") + } +} pub unsafe fn __cpp2rust_init_globals() { std::cell::LazyCell::force(&*&raw const kInit_0); } diff --git a/tests/unit/out/unsafe/struct_ptr.rs b/tests/unit/out/unsafe/struct_ptr.rs index c65158a1f3..5edaaa7d39 100644 --- a/tests/unit/out/unsafe/struct_ptr.rs +++ b/tests/unit/out/unsafe/struct_ptr.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct XX { pub x: i32, } diff --git a/tests/unit/out/unsafe/structured_binding_move_ctor.rs b/tests/unit/out/unsafe/structured_binding_move_ctor.rs index 4402ae6737..da6697a90b 100644 --- a/tests/unit/out/unsafe/structured_binding_move_ctor.rs +++ b/tests/unit/out/unsafe/structured_binding_move_ctor.rs @@ -80,16 +80,11 @@ impl Holder { }); return; } - pub unsafe fn construct_1(&mut self) { - (&raw mut self.xs).write(Vec::new()); - (&raw mut self.ys).write(Vec::new()); - } } impl DefaultConstructibleUnsafe for Holder { unsafe fn default_constructor(&mut self) { - unsafe { - Holder::construct_1(&mut *self); - } + (&raw mut self.xs).write(Vec::new()); + (&raw mut self.ys).write(Vec::new()); } } pub fn main() { diff --git a/tests/unit/out/unsafe/structured_binding_range_for.rs b/tests/unit/out/unsafe/structured_binding_range_for.rs index e89e734b0d..d4483f962c 100644 --- a/tests/unit/out/unsafe/structured_binding_range_for.rs +++ b/tests/unit/out/unsafe/structured_binding_range_for.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 afb0b3790b..a02ce5d909 100644 --- a/tests/unit/out/unsafe/structured_binding_ref.rs +++ b/tests/unit/out/unsafe/structured_binding_ref.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 1d723cd70f..c418819c91 100644 --- a/tests/unit/out/unsafe/structured_binding_trivial.rs +++ b/tests/unit/out/unsafe/structured_binding_trivial.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 fbad8de9c5..7cc8b7f550 100644 --- a/tests/unit/out/unsafe/swap_map_no_copy.rs +++ b/tests/unit/out/unsafe/swap_map_no_copy.rs @@ -16,13 +16,15 @@ pub struct Tracked { pub v: i32, } impl Tracked { - pub unsafe fn construct_2(&mut self) { - (&raw mut self.v).write(0); - } pub unsafe fn construct_1(&mut self, mut v: i32) { (&raw mut self.v).write(v); } } +impl DefaultConstructibleUnsafe for Tracked { + unsafe fn default_constructor(&mut self) { + (&raw mut self.v).write(0); + } +} impl CopyConstructibleUnsafe for Tracked { unsafe fn copy_constructor(&mut self, o: *const Tracked) { (&raw mut self.v).write((*o).v); @@ -56,19 +58,12 @@ impl Clone for Tracked { } } } -impl DefaultConstructibleUnsafe for Tracked { - unsafe fn default_constructor(&mut self) { - unsafe { - Tracked::construct_2(&mut *self); - } - } -} impl Default for Tracked { fn default() -> Self { unsafe { { let mut __v: Tracked = ::zero_init(); - Tracked::construct_2(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -90,17 +85,10 @@ pub struct Pair { pub x: Tracked, pub y: Tracked, } -impl Pair { - pub unsafe fn construct_1(&mut self) { - Tracked::construct_2(&mut self.x); - Tracked::construct_2(&mut self.y); - } -} impl DefaultConstructibleUnsafe for Pair { unsafe fn default_constructor(&mut self) { - unsafe { - Pair::construct_1(&mut *self); - } + DefaultConstructibleUnsafe::default_constructor(&mut self.x); + DefaultConstructibleUnsafe::default_constructor(&mut self.y); } } #[repr(C)] @@ -119,27 +107,20 @@ pub struct Arrays { pub a: [Tracked; 2], pub b: [Tracked; 2], } -impl Arrays { - pub unsafe fn construct_1(&mut self) { +impl DefaultConstructibleUnsafe for Arrays { + unsafe fn default_constructor(&mut self) { (&raw mut self.a).write(std::array::from_fn::<_, 2, _>(|_| { let mut __v: Tracked = ::zero_init(); - Tracked::construct_2(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v })); (&raw mut self.b).write(std::array::from_fn::<_, 2, _>(|_| { let mut __v: Tracked = ::zero_init(); - Tracked::construct_2(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v })); } } -impl DefaultConstructibleUnsafe for Arrays { - unsafe fn default_constructor(&mut self) { - unsafe { - Arrays::construct_1(&mut *self); - } - } -} pub static mut copy_only_copies_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut copy_only_dtors_2: std::cell::LazyCell = @@ -319,16 +300,9 @@ pub unsafe fn swapped_once_6() -> bool { pub struct Owner { pub p: Option>, } -impl Owner { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.p).write(None); - } -} impl DefaultConstructibleUnsafe for Owner { unsafe fn default_constructor(&mut self) { - unsafe { - Owner::construct_1(&mut *self); - } + (&raw mut self.p).write(None); } } pub fn main() { @@ -616,7 +590,7 @@ unsafe fn main_0() -> i32 { 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 = ::zero_init(); - Arrays::construct_1(&mut arrays); + DefaultConstructibleUnsafe::default_constructor(&mut arrays); arrays.a[(0) as usize].v = 1; arrays.b[(1) as usize].v = 2; { diff --git a/tests/unit/out/unsafe/template_default_arg.rs b/tests/unit/out/unsafe/template_default_arg.rs index 3e54f16e64..47483c2e50 100644 --- a/tests/unit/out/unsafe/template_default_arg.rs +++ b/tests/unit/out/unsafe/template_default_arg.rs @@ -15,18 +15,13 @@ pub struct A { pub v: i32, } impl A { - pub unsafe fn construct_2(&mut self) { - (&raw mut self.v).write(1); - } pub unsafe fn construct_1(&mut self, mut v: i32) { (&raw mut self.v).write(v); } } impl DefaultConstructibleUnsafe for A { unsafe fn default_constructor(&mut self) { - unsafe { - A::construct_2(&mut *self); - } + (&raw mut self.v).write(1); } } impl Default for A { @@ -34,7 +29,7 @@ impl Default for A { unsafe { { let mut __v: A = ::zero_init(); - A::construct_2(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -45,16 +40,9 @@ impl Default for A { pub struct B { pub v: i32, } -impl B { - pub unsafe fn construct(&mut self) { - (&raw mut self.v).write(2); - } -} impl DefaultConstructibleUnsafe for B { unsafe fn default_constructor(&mut self) { - unsafe { - B::construct(&mut *self); - } + (&raw mut self.v).write(2); } } impl Default for B { @@ -62,7 +50,7 @@ impl Default for B { unsafe { { let mut __v: B = ::zero_init(); - B::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v } } @@ -136,7 +124,7 @@ unsafe fn main_0() -> i32 { ((unsafe { used_0({ let mut __v: A = ::zero_init(); - A::construct_2(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v }) }) == (1)) @@ -154,7 +142,7 @@ unsafe fn main_0() -> i32 { ((unsafe { used_1({ let mut __v: B = ::zero_init(); - B::construct(&mut __v); + DefaultConstructibleUnsafe::default_constructor(&mut __v); __v }) }) == (2)) diff --git a/tests/unit/out/unsafe/template_static_member.rs b/tests/unit/out/unsafe/template_static_member.rs index 88b41df568..ccf509b20a 100644 --- a/tests/unit/out/unsafe/template_static_member.rs +++ b/tests/unit/out/unsafe/template_static_member.rs @@ -14,10 +14,11 @@ pub static mut s_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsaf VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Static_int_ {} pub static mut s_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { (55 as libc::c_char) }); @@ -28,10 +29,11 @@ pub static mut s_1: std::cell::LazyCell = VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Static_char_ {} pub static mut s_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 55_i64 }); #[repr(C)] @@ -41,10 +43,11 @@ pub static mut s_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsaf VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 }); @@ -55,10 +58,11 @@ pub static mut hi_4: std::cell::LazyCell = std::cell::LazyCell::new(|| unsa VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Range_int_ {} pub static mut lo_5: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { (-2_i32 as i64) }); @@ -70,10 +74,11 @@ pub static mut hi_6: std::cell::LazyCell = std::cell::LazyCell::new(|| unsa VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 3c7222fe2d..f49b2ebbbc 100644 --- a/tests/unit/out/unsafe/temporary_field_addr.rs +++ b/tests/unit/out/unsafe/temporary_field_addr.rs @@ -22,16 +22,9 @@ use std::rc::Rc; pub struct Inner { pub values: Vec, } -impl Inner { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.values).write(Vec::new()); - } -} impl DefaultConstructibleUnsafe for Inner { unsafe fn default_constructor(&mut self) { - unsafe { - Inner::construct_1(&mut *self); - } + (&raw mut self.values).write(Vec::new()); } } #[repr(C)] @@ -52,18 +45,11 @@ pub struct Outer { pub inner: Inner, pub name: [libc::c_char; 8], } -impl Outer { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.values).write(Vec::new()); - Inner::construct_1(&mut self.inner); - (&raw mut self.name).write([(0 as libc::c_char); 8]); - } -} impl DefaultConstructibleUnsafe for Outer { unsafe fn default_constructor(&mut self) { - unsafe { - Outer::construct_1(&mut *self); - } + (&raw mut self.values).write(Vec::new()); + DefaultConstructibleUnsafe::default_constructor(&mut self.inner); + (&raw mut self.name).write([(0 as libc::c_char); 8]); } } pub unsafe fn make_0(this: *mut Outer, calls: *mut i32) { diff --git a/tests/unit/out/unsafe/temporary_field_ctor_arg.rs b/tests/unit/out/unsafe/temporary_field_ctor_arg.rs index 7fd3455d08..d2f7645b92 100644 --- a/tests/unit/out/unsafe/temporary_field_ctor_arg.rs +++ b/tests/unit/out/unsafe/temporary_field_ctor_arg.rs @@ -22,16 +22,9 @@ use std::rc::Rc; pub struct Outer { pub values: Vec, } -impl Outer { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.values).write(Vec::new()); - } -} impl DefaultConstructibleUnsafe for Outer { unsafe fn default_constructor(&mut self) { - unsafe { - Outer::construct_1(&mut *self); - } + (&raw mut self.values).write(Vec::new()); } } pub unsafe fn make_0(this: *mut Outer) { diff --git a/tests/unit/out/unsafe/temporary_field_two_args.rs b/tests/unit/out/unsafe/temporary_field_two_args.rs index 433a1a6b27..35738bb6ba 100644 --- a/tests/unit/out/unsafe/temporary_field_two_args.rs +++ b/tests/unit/out/unsafe/temporary_field_two_args.rs @@ -22,16 +22,9 @@ use std::rc::Rc; pub struct Inner { pub values: Vec, } -impl Inner { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.values).write(Vec::new()); - } -} impl DefaultConstructibleUnsafe for Inner { unsafe fn default_constructor(&mut self) { - unsafe { - Inner::construct_1(&mut *self); - } + (&raw mut self.values).write(Vec::new()); } } #[repr(C)] @@ -51,17 +44,10 @@ pub struct Outer { pub values: Vec, pub inner: Inner, } -impl Outer { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.values).write(Vec::new()); - Inner::construct_1(&mut self.inner); - } -} impl DefaultConstructibleUnsafe for Outer { unsafe fn default_constructor(&mut self) { - unsafe { - Outer::construct_1(&mut *self); - } + (&raw mut self.values).write(Vec::new()); + DefaultConstructibleUnsafe::default_constructor(&mut self.inner); } } pub unsafe fn make_0(this: *mut Outer) { diff --git a/tests/unit/out/unsafe/typedef-anon-struct.rs b/tests/unit/out/unsafe/typedef-anon-struct.rs index 462abc8e35..01f721d87e 100644 --- a/tests/unit/out/unsafe/typedef-anon-struct.rs +++ b/tests/unit/out/unsafe/typedef-anon-struct.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Outer_RunInfo { pub block_idx: i32, pub num_extra_zero_runs: i32, @@ -37,16 +38,9 @@ pub struct Outer_RunInfo { pub struct Outer { pub runs: Vec, } -impl Outer { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.runs).write(Vec::new()); - } -} impl DefaultConstructibleUnsafe for Outer { unsafe fn default_constructor(&mut self) { - unsafe { - Outer::construct_1(&mut *self); - } + (&raw mut self.runs).write(Vec::new()); } } pub fn main() { @@ -57,7 +51,7 @@ pub fn main() { } unsafe fn main_0() -> i32 { let mut o: Outer = ::zero_init(); - Outer::construct_1(&mut o); + DefaultConstructibleUnsafe::default_constructor(&mut o); let mut info: Outer_RunInfo = ::default(); info.block_idx = 1; info.num_extra_zero_runs = 2; 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 9a0559bc53..cfd310d39a 100644 --- a/tests/unit/out/unsafe/unary_expr_or_type_trait.rs +++ b/tests/unit/out/unsafe/unary_expr_or_type_trait.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 cbcac74707..52ea049e2e 100644 --- a/tests/unit/out/unsafe/unboxed_locals.rs +++ b/tests/unit/out/unsafe/unboxed_locals.rs @@ -19,10 +19,11 @@ pub unsafe fn inc_1(r: *mut i32) { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Pair { pub first: i32, pub second: i32, diff --git a/tests/unit/out/unsafe/unboxed_records.rs b/tests/unit/out/unsafe/unboxed_records.rs index ec424b3a28..a5f99dd91d 100644 --- a/tests/unit/out/unsafe/unboxed_records.rs +++ b/tests/unit/out/unsafe/unboxed_records.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Inner { pub a: i32, pub b: i32, @@ -28,10 +29,11 @@ pub struct Inner { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Cookie { pub x: i32, pub data: *mut i32, @@ -48,15 +50,10 @@ impl Counter { pub unsafe fn inc(&mut self) { self.n.prefix_inc(); } - pub unsafe fn construct_1(&mut self) { - (&raw mut self.n).write(0); - } } impl DefaultConstructibleUnsafe for Counter { unsafe fn default_constructor(&mut self) { - unsafe { - Counter::construct_1(&mut *self); - } + (&raw mut self.n).write(0); } } impl Default for Counter { @@ -127,7 +124,7 @@ unsafe fn main_0() -> i32 { (unsafe { set_0((&mut field_addr.b as *mut i32), 7) }); assert!(((field_addr.b) == (7))); let mut counter: Counter = ::zero_init(); - Counter::construct_1(&mut counter); + DefaultConstructibleUnsafe::default_constructor(&mut counter); (unsafe { Counter::inc(&mut counter) }); assert!(((counter.n) == (1))); return 0; diff --git a/tests/unit/out/unsafe/unique_ptr.rs b/tests/unit/out/unsafe/unique_ptr.rs index f534891291..87c759096d 100644 --- a/tests/unit/out/unsafe/unique_ptr.rs +++ b/tests/unit/out/unsafe/unique_ptr.rs @@ -27,15 +27,10 @@ impl SafePointer { .map_or(::std::ptr::null_mut(), |v| v as *const i32 as *mut i32)) .prefix_inc(); } - pub unsafe fn construct_1(&mut self) { - (&raw mut self.ptr).write(None); - } } impl DefaultConstructibleUnsafe for SafePointer { unsafe fn default_constructor(&mut self) { - unsafe { - SafePointer::construct_1(&mut *self); - } + (&raw mut self.ptr).write(None); } } #[repr(C)] @@ -45,10 +40,11 @@ impl DefaultConstructibleUnsafe for SafePointer { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 cff5e65a8c..4262d071d6 100644 --- a/tests/unit/out/unsafe/unique_ptr_const_deref.rs +++ b/tests/unit/out/unsafe/unique_ptr_const_deref.rs @@ -19,16 +19,9 @@ use std::rc::Rc; pub struct Holder { pub val: Option>, } -impl Holder { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.val).write(None); - } -} impl DefaultConstructibleUnsafe for Holder { unsafe fn default_constructor(&mut self) { - unsafe { - Holder::construct_1(&mut *self); - } + (&raw mut self.val).write(None); } } pub unsafe fn read_val_0(mut h: *const Holder) -> i32 { @@ -51,7 +44,7 @@ pub fn main() { } unsafe fn main_0() -> i32 { let mut h: Holder = ::zero_init(); - Holder::construct_1(&mut h); + DefaultConstructibleUnsafe::default_constructor(&mut h); { h.val = Some(Box::new(10)).take(); }; diff --git a/tests/unit/out/unsafe/unique_ptr_field_reset.rs b/tests/unit/out/unsafe/unique_ptr_field_reset.rs index e9e4a99bc1..4b3ca886aa 100644 --- a/tests/unit/out/unsafe/unique_ptr_field_reset.rs +++ b/tests/unit/out/unsafe/unique_ptr_field_reset.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Data { pub v: i32, } @@ -45,16 +46,11 @@ impl Holder { } }; } - pub unsafe fn construct_1(&mut self) { - (&raw mut self.data).write(None); - (&raw mut self.n).write(0_i32); - } } impl DefaultConstructibleUnsafe for Holder { unsafe fn default_constructor(&mut self) { - unsafe { - Holder::construct_1(&mut *self); - } + (&raw mut self.data).write(None); + (&raw mut self.n).write(0_i32); } } pub fn main() { @@ -65,7 +61,7 @@ pub fn main() { } unsafe fn main_0() -> i32 { let mut h: Holder = ::zero_init(); - Holder::construct_1(&mut h); + DefaultConstructibleUnsafe::default_constructor(&mut h); h.n = 1; let mut hp: *mut Holder = (&mut h as *mut Holder); { diff --git a/tests/unit/out/unsafe/unique_ptr_nested.rs b/tests/unit/out/unsafe/unique_ptr_nested.rs index 8e7fdb1193..5483321dfa 100644 --- a/tests/unit/out/unsafe/unique_ptr_nested.rs +++ b/tests/unit/out/unsafe/unique_ptr_nested.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Inner { pub x: i32, pub y: i32, @@ -34,16 +35,9 @@ pub struct Inner { pub struct Outer { pub inner: Option>, } -impl Outer { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.inner).write(None); - } -} impl DefaultConstructibleUnsafe for Outer { unsafe fn default_constructor(&mut self) { - unsafe { - Outer::construct_1(&mut *self); - } + (&raw mut self.inner).write(None); } } pub fn main() { diff --git a/tests/unit/out/unsafe/unique_ptr_struct.rs b/tests/unit/out/unsafe/unique_ptr_struct.rs index 4135e2b7bd..d9c473c70a 100644 --- a/tests/unit/out/unsafe/unique_ptr_struct.rs +++ b/tests/unit/out/unsafe/unique_ptr_struct.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Point { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/va_list_field.rs b/tests/unit/out/unsafe/va_list_field.rs index 788e47d132..a66697d9c7 100644 --- a/tests/unit/out/unsafe/va_list_field.rs +++ b/tests/unit/out/unsafe/va_list_field.rs @@ -78,10 +78,11 @@ pub unsafe fn sum_ptr_2(mut n: i32, __args: Box<[VaArg]>) -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 92fe1f5c29..e52be36fa7 100644 --- a/tests/unit/out/unsafe/vector.rs +++ b/tests/unit/out/unsafe/vector.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct S { pub x: i32, } @@ -38,17 +39,10 @@ pub struct Foo { pub a: Vec, pub b: Vec, } -impl Foo { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.a).write(Vec::new()); - (&raw mut self.b).write(Vec::new()); - } -} impl DefaultConstructibleUnsafe for Foo { unsafe fn default_constructor(&mut self) { - unsafe { - Foo::construct_1(&mut *self); - } + (&raw mut self.a).write(Vec::new()); + (&raw mut self.b).write(Vec::new()); } } #[repr(C)] @@ -412,7 +406,7 @@ unsafe fn main_0() -> i32 { && ((v11[(2_usize)]) == (3)) ); let mut foo: Foo = ::zero_init(); - Foo::construct_1(&mut foo); + DefaultConstructibleUnsafe::default_constructor(&mut foo); { let __a1 = 5; foo.a.push(__a1) diff --git a/tests/unit/out/unsafe/vector_iter_range_ctor.rs b/tests/unit/out/unsafe/vector_iter_range_ctor.rs index 42e9e768e9..bcb5dddaec 100644 --- a/tests/unit/out/unsafe/vector_iter_range_ctor.rs +++ b/tests/unit/out/unsafe/vector_iter_range_ctor.rs @@ -35,10 +35,11 @@ impl Degrees { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] #[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 120e9e8d88..c4f1c6b32e 100644 --- a/tests/unit/out/unsafe/vector_subscript_direct.rs +++ b/tests/unit/out/unsafe/vector_subscript_direct.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Point { pub x: i32, pub y: i32, @@ -43,17 +44,10 @@ pub struct Holder { pub values: Vec, pub points: Vec, } -impl Holder { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.values).write(Vec::new()); - (&raw mut self.points).write(Vec::new()); - } -} impl DefaultConstructibleUnsafe for Holder { unsafe fn default_constructor(&mut self) { - unsafe { - Holder::construct_1(&mut *self); - } + (&raw mut self.values).write(Vec::new()); + (&raw mut self.points).write(Vec::new()); } } pub unsafe fn push_and_index_0(v: *mut Vec) -> i32 { @@ -117,7 +111,7 @@ unsafe fn main_0() -> i32 { assert!(((v[(2_usize)]) == (9))); assert!(((unsafe { sum_ref_1(&v,) }) == (((((3) + (0)) + (9)) + (42)) + (5)))); let mut h: Holder = ::zero_init(); - Holder::construct_1(&mut h); + DefaultConstructibleUnsafe::default_constructor(&mut h); h.values.resize_with(2_usize, || 0_i32); h.values[(1_usize)] = 6; { diff --git a/tests/unit/out/unsafe/vector_with_allocator.rs b/tests/unit/out/unsafe/vector_with_allocator.rs index 6d4afbc96f..a2bace4ed1 100644 --- a/tests/unit/out/unsafe/vector_with_allocator.rs +++ b/tests/unit/out/unsafe/vector_with_allocator.rs @@ -13,10 +13,11 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct TestAllocator_int_ {} impl TestAllocator_int_ { pub unsafe fn allocate(&mut self, mut n: usize) -> *mut i32 { @@ -42,10 +43,11 @@ impl TestAllocator_int_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] 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 a745444ef9..f757d825d9 100644 --- a/tests/unit/out/unsafe/void_cast.rs +++ b/tests/unit/out/unsafe/void_cast.rs @@ -23,16 +23,9 @@ pub unsafe fn unused_param_0(mut x: i32) {} pub struct NonTrivial { pub data: Vec, } -impl NonTrivial { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.data).write(Vec::new()); - } -} impl DefaultConstructibleUnsafe for NonTrivial { unsafe fn default_constructor(&mut self) { - unsafe { - NonTrivial::construct_1(&mut *self); - } + (&raw mut self.data).write(Vec::new()); } } pub unsafe fn unused_ref_param_1(x: *const NonTrivial) {} @@ -50,10 +43,11 @@ pub unsafe fn bump_and_return_4() -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + MemberwiseUnsafe, TriviallyCopyableUnsafe, Default, )] +#[memberwise(default_constructor)] pub struct Holder { pub field: i32, } @@ -70,16 +64,9 @@ pub struct Holder { pub struct NonCopyable { pub value: Option>, } -impl NonCopyable { - pub unsafe fn construct_1(&mut self) { - (&raw mut self.value).write(None); - } -} impl DefaultConstructibleUnsafe for NonCopyable { unsafe fn default_constructor(&mut self) { - unsafe { - NonCopyable::construct_1(&mut *self); - } + (&raw mut self.value).write(None); } } pub unsafe fn unused_noncopyable_param_5(x: *const NonCopyable) {} @@ -133,7 +120,7 @@ unsafe fn main_0() -> i32 { let mut h: Holder = Holder { field: 17 }; let mut hp: *mut Holder = (&mut h as *mut Holder); let mut nt: NonTrivial = ::zero_init(); - NonTrivial::construct_1(&mut nt); + DefaultConstructibleUnsafe::default_constructor(&mut nt); (unsafe { unused_ref_param_1(&nt) }); (unsafe { unused_ptr_param_2((&mut nt as *mut NonTrivial).cast_const()) }); let mut g: NonCopyable = NonCopyable { From 877cc6e852e5df20eba1d04d085a878f470eaa13 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Wed, 2 Dec 2026 12:50:17 +0000 Subject: [PATCH 04/13] Add DefaultConstructible in converter --- cpp2rust/converter/converter.cpp | 75 ++++++++++++----- cpp2rust/converter/converter.h | 16 +++- cpp2rust/converter/converter_lib.cpp | 63 ++++++++------ cpp2rust/converter/converter_lib.h | 82 ++++++++++++------- .../converter/models/converter_refcount.cpp | 10 +-- .../converter/models/converter_refcount.h | 3 +- libcc2rs-macros/src/constructor.rs | 61 ++++++++++++++ libcc2rs-macros/src/lib.rs | 10 +++ libcc2rs/src/constructor.rs | 46 +++++++++++ tests/std/basic/out/refcount/basic.def.odr.rs | 6 +- tests/unit/out/refcount/copy_move_deleted.rs | 4 +- 11 files changed, 284 insertions(+), 92 deletions(-) diff --git a/cpp2rust/converter/converter.cpp b/cpp2rust/converter/converter.cpp index 06ed04af8c..4928f03073 100644 --- a/cpp2rust/converter/converter.cpp +++ b/cpp2rust/converter/converter.cpp @@ -73,12 +73,11 @@ void Converter::EmitUndefinedRecordTraits(Model model, std::string &out) { if (converted_record_traits_.contains({record, name})) { continue; } + const auto &spelling = is_unsafe ? trait->unsafe : trait->refcount; 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); + spelling.name, record, spelling.signature, record, trait->method); } } } @@ -88,16 +87,16 @@ void Converter::DeclareRecordTraits(const clang::CXXRecordDecl *decl) { for (auto *method : decl->methods()) { if (auto *trait = GetRecordTrait(method); trait && !IsDerivedCopyOrMove(method)) { - traits.emplace(trait->name, trait); + traits.emplace(trait->refcount.name, trait); } } - if (traits.contains(kCopyConstructible.name) && + if (traits.contains(kCopyConstructible.refcount.name) && !decl->hasUserDeclaredMoveConstructor()) { - traits.emplace(kMoveConstructible.name, &kMoveConstructible); + traits.emplace(kMoveConstructible.refcount.name, &kMoveConstructible); } - if (traits.contains(kCopyAssignable.name) && + if (traits.contains(kCopyAssignable.refcount.name) && !decl->hasUserDeclaredMoveAssignment()) { - traits.emplace(kMoveAssignable.name, &kMoveAssignable); + traits.emplace(kMoveAssignable.refcount.name, &kMoveAssignable); } } @@ -1098,7 +1097,7 @@ void Converter::ConvertCopyOrMoveTraitImpl(clang::CXXMethodDecl *method, return; } converted_record_traits_.emplace(GetRecordName(method->getParent()), - trait.name); + trait.refcount.name); StrCat(keyword::kImpl, GetCopyOrMoveTraitName(trait), "for", GetRecordName(method->getParent())); PushBrace brace(*this); @@ -2663,8 +2662,13 @@ std::string Converter::GetUFCSName(const clang::CXXMethodDecl *method) const { return GetRecordName(method->getParent()); } +const RecordTraitSpelling & +Converter::GetRecordTraitSpelling(const RecordTrait &trait) const { + return trait.unsafe; +} + const char *Converter::GetCopyOrMoveTraitName(const RecordTrait &trait) const { - return trait.unsafe_name; + return GetRecordTraitSpelling(trait).name; } void Converter::ConvertUserOperatorCall(clang::CXXOperatorCallExpr *expr) { @@ -5251,7 +5255,7 @@ Converter::GetStructAttributes(const clang::RecordDecl *decl) { if (!RecordDerivesTriviallyCopyable(decl)) { union_attrs.emplace_back("DestructibleUnsafe"); } - AddCopyAndMoveDerives(decl, union_attrs); + AddSpecialMemberDerives(decl, union_attrs); return union_attrs; } @@ -5280,7 +5284,7 @@ Converter::GetStructAttributes(const clang::RecordDecl *decl) { struct_attrs.emplace_back("DestructibleUnsafe"); } - AddCopyAndMoveDerives(decl, struct_attrs); + AddSpecialMemberDerives(decl, struct_attrs); if (RecordDerivesDefault(decl)) { struct_attrs.emplace_back("Default"); @@ -5802,8 +5806,8 @@ void Converter::AddCloneTrait(const clang::RecordDecl *decl) { TakePlacementValue())); } -void Converter::AddCopyAndMoveDerives(const clang::RecordDecl *decl, - std::vector &attrs) { +void Converter::AddSpecialMemberDerives(const clang::RecordDecl *decl, + std::vector &attrs) { auto implements = [&](const RecordTrait *trait) { return ImplementsRecordTrait(decl, *trait); }; @@ -5812,9 +5816,13 @@ void Converter::AddCopyAndMoveDerives(const clang::RecordDecl *decl, attrs.emplace_back(GetCopyOrMoveTraitName(trait)); for (const auto *provided_trait : provided) { converted_record_traits_.emplace(GetRecordName(decl), - provided_trait->name); + provided_trait->refcount.name); } }; + if (!implements(&kDefaultConstructible) && + !GetConvertedDefaultConstructor(decl)) { + attrs.emplace_back(GetCopyOrMoveTraitName(kDefaultConstructible)); + } if (!GetDerivedCopyOrMoves(decl).empty()) { attrs.emplace_back(GetCopyOrMoveTraitName(kMemberwise)); } @@ -5879,6 +5887,11 @@ void Converter::AddDefaultTraitForUnion(const clang::RecordDecl *decl) { } void Converter::AddDefaultTrait(const clang::RecordDecl *decl) { + if (auto *default_ctor = GetConvertedDefaultConstructor(decl); + default_ctor && !GetRecordTrait(default_ctor)) { + AddDefaultConstructibleTrait(clang::cast(decl), + default_ctor); + } if (decl->isUnion()) { AddDefaultTraitForUnion(decl); return; @@ -5896,19 +5909,37 @@ void Converter::AddDefaultTrait(const clang::RecordDecl *decl) { } if (auto *default_ctor = cxx ? GetUserDefinedDefaultConstructor(cxx) : nullptr) { - std::vector args; - for (auto *param : default_ctor->parameters()) { - args.push_back(clang::CXXDefaultArgExpr::Create( - ctx_, param->getLocation(), param, nullptr, default_ctor)); - } - Convert(MakeConstructExpr(ctx_, ctx_.getCanonicalTagType(decl), - default_ctor, args)); + Convert(MakeDefaultConstructExpr(cxx, default_ctor)); } else { EmitDefaultStructLiteral(decl); } }); } +clang::CXXConstructExpr * +Converter::MakeDefaultConstructExpr(const clang::CXXRecordDecl *decl, + clang::CXXConstructorDecl *ctor) { + std::vector args; + for (auto *param : ctor->parameters()) { + args.push_back(clang::CXXDefaultArgExpr::Create(ctx_, param->getLocation(), + param, nullptr, ctor)); + } + return MakeConstructExpr(ctx_, ctx_.getCanonicalTagType(decl), ctor, args); +} + +void Converter::AddDefaultConstructibleTrait(const clang::CXXRecordDecl *decl, + clang::CXXConstructorDecl *ctor) { + const auto &spelling = GetRecordTraitSpelling(kDefaultConstructible); + StrCat(keyword::kImpl, spelling.name, "for", GetRecordName(decl)); + PushBrace impl_brace(*this); + StrCat(spelling.signature); + PushBrace fn_brace(*this); + StrCat(keyword_unsafe_); + PushBrace unsafe_brace(*this); + auto *construct = MakeDefaultConstructExpr(decl, ctor); + ConstructInPlace(construct, construct, spelling.receiver); +} + void Converter::EmitDefaultImpl(const clang::RecordDecl *decl, llvm::function_ref body) { StrCat(std::format("impl Default for {}", GetRecordName(decl))); diff --git a/cpp2rust/converter/converter.h b/cpp2rust/converter/converter.h index 6f76693a61..de99a7cf8b 100644 --- a/cpp2rust/converter/converter.h +++ b/cpp2rust/converter/converter.h @@ -381,10 +381,13 @@ class Converter : public clang::RecursiveASTVisitor { virtual const char *GetConversionTraitName() const; - virtual const char *GetCopyOrMoveTraitName(const RecordTrait &trait) const; + virtual const RecordTraitSpelling & + GetRecordTraitSpelling(const RecordTrait &trait) const; - void AddCopyAndMoveDerives(const clang::RecordDecl *decl, - std::vector &attrs); + const char *GetCopyOrMoveTraitName(const RecordTrait &trait) const; + + void AddSpecialMemberDerives(const clang::RecordDecl *decl, + std::vector &attrs); virtual std::string DerefPtrExpr(std::string_view ptr_expr, clang::QualType pointee_type); @@ -970,6 +973,13 @@ class Converter : public clang::RecursiveASTVisitor { virtual void AddDefaultTraitForUnion(const clang::RecordDecl *decl); + clang::CXXConstructExpr * + MakeDefaultConstructExpr(const clang::CXXRecordDecl *decl, + clang::CXXConstructorDecl *ctor); + + void AddDefaultConstructibleTrait(const clang::CXXRecordDecl *decl, + clang::CXXConstructorDecl *ctor); + void EmitDefaultStructLiteral(const clang::RecordDecl *decl); // Emits `impl Default for decl`, whose default() returns what body emits. diff --git a/cpp2rust/converter/converter_lib.cpp b/cpp2rust/converter/converter_lib.cpp index 260006725e..50d9c1703f 100644 --- a/cpp2rust/converter/converter_lib.cpp +++ b/cpp2rust/converter/converter_lib.cpp @@ -578,6 +578,9 @@ const char *GetCopyOrMoveName(const clang::CXXMethodDecl *method) { if (ctor->isMoveConstructor()) { return "move_from"; } + if (ctor->isDefaultConstructor() && ctor->getNumParams() == 0) { + return "default_constructor"; + } return nullptr; } if (method->isCopyAssignmentOperator()) { @@ -606,8 +609,14 @@ static bool IsTranslatedCopyAssignment(const clang::CXXMethodDecl *method); static bool IsTranslatedMoveAssignment(const clang::CXXMethodDecl *method); -static bool IsTranslatedCopyOrMove(const clang::CXXMethodDecl *method) { +static bool IsConvertibleImplicitMemberParent(const clang::CXXRecordDecl *decl); + +static bool IsTranslatedSpecialMember(const clang::CXXMethodDecl *method) { if (auto *ctor = clang::dyn_cast(method)) { + if (ctor->isDefaultConstructor()) { + return !ctor->isUserProvided() && !ctor->getParent()->isUnion() && + IsConvertibleImplicitMemberParent(ctor->getParent()); + } return IsConvertibleCopyOrMoveConstructor(ctor); } return method->isCopyAssignmentOperator() @@ -633,13 +642,16 @@ const RecordTrait *GetRecordTrait(const clang::CXXMethodDecl *method) { const char *name = GetCopyOrMoveName(method); if (!name || method->isDeleted() || method->isVirtual() || !CanUseCopyOrMoveName(method, name) || - (!IsUserWrittenMember(method) && !IsTranslatedCopyOrMove(method))) { + (!IsUserWrittenMember(method) && !IsTranslatedSpecialMember(method))) { return nullptr; } auto *ctor = clang::dyn_cast(method); if (!ctor && !method->getReturnType()->isLValueReferenceType()) { return nullptr; } + if (ctor && ctor->isDefaultConstructor()) { + return &kDefaultConstructible; + } auto param = method->getParamDecl(0)->getType(); bool is_copy = ctor ? ctor->isCopyConstructor() : method->isCopyAssignmentOperator(); @@ -654,6 +666,10 @@ const RecordTrait *GetRecordTrait(const clang::CXXMethodDecl *method) { } bool IsDerivedCopyOrMove(const clang::CXXMethodDecl *method) { + if (auto *ctor = clang::dyn_cast(method); + ctor && ctor->isDefaultConstructor() && !ctor->isTrivial()) { + return false; + } return !method->isUserProvided() && GetRecordTrait(method); } @@ -708,35 +724,11 @@ bool IsConvertibleCopyConstructor(const clang::CXXConstructorDecl *ctor) { HasFieldWithCopyConstructor(ctor->getParent())); } -// Whether default-initializing a field of decl runs a translated constructor, -// which receives the field in place. -static bool HasFieldWithDefaultConstructor(const clang::CXXRecordDecl *decl) { - for (const auto *field : decl->fields()) { - if (auto *init = field->getInClassInitializer()) { - if (GetPlacementInitializer(init)) { - return true; - } - continue; - } - auto *record = field->getType()->getAsCXXRecordDecl(); - if (!record || !record->hasDefinition() || !IsUserDefinedDecl(record) || - record->isLambda()) { - continue; - } - if (record->hasUserProvidedDefaultConstructor() || - (IsConvertibleImplicitMemberParent(record) && - HasFieldWithDefaultConstructor(record))) { - return true; - } - } - return false; -} - bool IsConvertibleDefaultConstructor(const clang::CXXConstructorDecl *ctor) { return ctor->isDefaultConstructor() && !ctor->isUserProvided() && !ctor->isDeleted() && IsConvertibleImplicitMemberParent(ctor->getParent()) && - HasFieldWithDefaultConstructor(ctor->getParent()); + !ctor->isTrivial(); } // Whether moving a field of decl isn't a copy: the field is a record with a @@ -1248,6 +1240,23 @@ GetUserDefinedDefaultConstructor(const clang::CXXRecordDecl *decl) { return nullptr; } +clang::CXXConstructorDecl * +GetConvertedDefaultConstructor(const clang::RecordDecl *decl) { + auto *cxx = clang::dyn_cast(decl); + if (!cxx || cxx->isUnion()) { + return nullptr; + } + if (auto *ctor = GetUserDefinedDefaultConstructor(cxx)) { + return ctor; + } + for (auto *ctor : cxx->ctors()) { + if (IsConvertibleDefaultConstructor(ctor)) { + return ctor; + } + } + return nullptr; +} + bool HasUsableDefaultArg(const clang::ParmVarDecl *param) { return param->hasDefaultArg() && !param->hasUninstantiatedDefaultArg(); } diff --git a/cpp2rust/converter/converter_lib.h b/cpp2rust/converter/converter_lib.h index 6213a38288..6627ee8cec 100644 --- a/cpp2rust/converter/converter_lib.h +++ b/cpp2rust/converter/converter_lib.h @@ -105,45 +105,66 @@ const char *GetCopyOrMoveName(const clang::CXXMethodDecl *method); bool CanUseCopyOrMoveName(const clang::CXXMethodDecl *decl, const std::string &name); -struct RecordTrait { +struct RecordTraitSpelling { const char *name; - const char *unsafe_name; + const char *signature = nullptr; + const char *receiver = nullptr; +}; + +struct RecordTrait { const char *method; - const char *signature; - const char *unsafe_signature; + RecordTraitSpelling refcount; + RecordTraitSpelling unsafe; }; +inline constexpr RecordTrait kDefaultConstructible{ + "default_constructor", + {"DefaultConstructible", "fn default_constructor(this: &Ptr)", + "this"}, + {"DefaultConstructibleUnsafe", "unsafe fn default_constructor(&mut self)", + "&mut *self"}}; inline constexpr RecordTrait kCopyConstructible{ - "CopyConstructible", "CopyConstructibleUnsafe", "copy_constructor", - "fn copy_constructor(_: &Ptr, _: Ptr)", - "unsafe fn copy_constructor(&mut self, _: *const Self)"}; + "copy_constructor", + {"CopyConstructible", "fn copy_constructor(this: &Ptr, _: Ptr)", + "this"}, + {"CopyConstructibleUnsafe", + "unsafe fn copy_constructor(&mut self, _: *const Self)", "&mut *self"}}; inline constexpr RecordTrait kMoveConstructible{ - "MoveConstructible", "MoveConstructibleUnsafe", "move_constructor", - "fn move_constructor(_: &Ptr, _: Ptr)", - "unsafe fn move_constructor(&mut self, _: *mut Self)"}; + "move_constructor", + {"MoveConstructible", "fn move_constructor(this: &Ptr, _: Ptr)", + "this"}, + {"MoveConstructibleUnsafe", + "unsafe fn move_constructor(&mut self, _: *mut Self)", "&mut *self"}}; inline constexpr RecordTrait kCopyAssignable{ - "CopyAssignable", "CopyAssignableUnsafe", "copy_assign", - "fn copy_assign(_: &Ptr, _: Ptr) -> Ptr", - "unsafe fn copy_assign(&mut self, _: *const Self) -> *mut Self"}; + "copy_assign", + {"CopyAssignable", + "fn copy_assign(this: &Ptr, _: Ptr) -> Ptr", "this"}, + {"CopyAssignableUnsafe", + "unsafe fn copy_assign(&mut self, _: *const Self) -> *mut Self", + "&mut *self"}}; inline constexpr RecordTrait kMoveAssignable{ - "MoveAssignable", "MoveAssignableUnsafe", "move_assign", - "fn move_assign(_: &Ptr, _: Ptr) -> Ptr", - "unsafe fn move_assign(&mut self, _: *mut Self) -> *mut Self"}; + "move_assign", + {"MoveAssignable", + "fn move_assign(this: &Ptr, _: Ptr) -> Ptr", "this"}, + {"MoveAssignableUnsafe", + "unsafe fn move_assign(&mut self, _: *mut Self) -> *mut Self", + "&mut *self"}}; inline constexpr RecordTrait kSwappable{ - "Swappable", "SwappableUnsafe", "swap", - "fn swap(_: &Ptr, _: Ptr)", - "unsafe fn swap(&mut self, _: *mut Self)"}; + "swap", + {"Swappable", "fn swap(this: &Ptr, _: Ptr)", "this"}, + {"SwappableUnsafe", "unsafe fn swap(&mut self, _: *mut Self)", + "&mut *self"}}; 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}; + "destroy", + {"Destructible", "fn destroy(this: &Ptr)", "this"}, + {"DestructibleUnsafe", "unsafe fn destroy(&mut self)", "&mut *self"}}; +inline constexpr RecordTrait kMovable{nullptr, {"Movable"}, {"MovableUnsafe"}}; +inline constexpr RecordTrait kCopyable{ + nullptr, {"Copyable"}, {"CopyableUnsafe"}}; inline constexpr RecordTrait kTriviallyCopyable{ - "TriviallyCopyable", "TriviallyCopyableUnsafe", nullptr, nullptr, nullptr}; -inline constexpr RecordTrait kMemberwise{"Memberwise", "MemberwiseUnsafe", - nullptr, nullptr, nullptr}; + nullptr, {"TriviallyCopyable"}, {"TriviallyCopyableUnsafe"}}; +inline constexpr RecordTrait kMemberwise{ + nullptr, {"Memberwise"}, {"MemberwiseUnsafe"}}; const RecordTrait *GetRecordTrait(const clang::CXXMethodDecl *method); @@ -163,7 +184,7 @@ bool IsConvertibleCopyOrMoveConstructor(const clang::CXXConstructorDecl *ctor); bool IsConvertibleCopyConstructor(const clang::CXXConstructorDecl *ctor); // Whether ctor is a defaulted default constructor that is translated, as it -// default-initializes a field with a translated constructor, in place. +// is not trivial. bool IsConvertibleDefaultConstructor(const clang::CXXConstructorDecl *ctor); bool IsDefaultedMoveConstructor(const clang::CXXConstructorDecl *ctor); @@ -277,6 +298,9 @@ unsigned GetCtorIndex(clang::CXXConstructorDecl *ctor); clang::CXXConstructorDecl * GetUserDefinedDefaultConstructor(const clang::CXXRecordDecl *decl); +clang::CXXConstructorDecl * +GetConvertedDefaultConstructor(const clang::RecordDecl *decl); + bool HasUsableDefaultArg(const clang::ParmVarDecl *param); std::string GetFileName(const clang::Decl *decl); diff --git a/cpp2rust/converter/models/converter_refcount.cpp b/cpp2rust/converter/models/converter_refcount.cpp index 4e339e06a7..2e063fc4c2 100644 --- a/cpp2rust/converter/models/converter_refcount.cpp +++ b/cpp2rust/converter/models/converter_refcount.cpp @@ -2360,7 +2360,7 @@ ConverterRefCount::GetStructAttributes(const clang::RecordDecl *decl) { if (!RecordDerivesTriviallyCopyable(decl)) { union_attrs.emplace_back("Destructible"); } - AddCopyAndMoveDerives(decl, union_attrs); + AddSpecialMemberDerives(decl, union_attrs); return union_attrs; } @@ -2392,7 +2392,7 @@ ConverterRefCount::GetStructAttributes(const clang::RecordDecl *decl) { attrs.emplace_back("Destructible"); } - AddCopyAndMoveDerives(decl, attrs); + AddSpecialMemberDerives(decl, attrs); if (RecordDerivesDefault(decl)) { attrs.emplace_back("Default"); @@ -2404,9 +2404,9 @@ const char *ConverterRefCount::GetConversionTraitName() const { return "CppFrom"; } -const char * -ConverterRefCount::GetCopyOrMoveTraitName(const RecordTrait &trait) const { - return trait.name; +const RecordTraitSpelling & +ConverterRefCount::GetRecordTraitSpelling(const RecordTrait &trait) const { + return trait.refcount; } bool ConverterRefCount::TypeDerivesDefault(clang::QualType qual_type) { diff --git a/cpp2rust/converter/models/converter_refcount.h b/cpp2rust/converter/models/converter_refcount.h index 0ad31c5959..39eac342a4 100644 --- a/cpp2rust/converter/models/converter_refcount.h +++ b/cpp2rust/converter/models/converter_refcount.h @@ -542,7 +542,8 @@ class ConverterRefCount final : public Converter { const char *GetConversionTraitName() const override; - const char *GetCopyOrMoveTraitName(const RecordTrait &trait) const override; + const RecordTraitSpelling & + GetRecordTraitSpelling(const RecordTrait &trait) const override; bool IsBoxedType(clang::QualType type); bool IsVecType(clang::QualType type); diff --git a/libcc2rs-macros/src/constructor.rs b/libcc2rs-macros/src/constructor.rs index f2d1f9ea95..7e33660e37 100644 --- a/libcc2rs-macros/src/constructor.rs +++ b/libcc2rs-macros/src/constructor.rs @@ -32,6 +32,35 @@ pub fn expand_movable(input: TokenStream, is_unsafe: bool) -> TokenStream { quote!(#(#impls)* #swap).into() } +pub fn expand_default_constructible(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(); + if is_unsafe { + quote! { + impl #impl_generics ::libcc2rs::DefaultConstructibleUnsafe for #name #ty_generics #where_clause { + unsafe fn default_constructor(&mut self) { + unsafe { + ::std::ptr::write( + self, + ::zero_init(), + ) + } + } + } + } + } else { + quote! { + impl #impl_generics ::libcc2rs::DefaultConstructible for #name #ty_generics #where_clause { + fn default_constructor(this: &::libcc2rs::Ptr) { + this.write(::zero_init()); + } + } + } + } + .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() @@ -237,6 +266,10 @@ pub fn expand_memberwise(input: TokenStream, is_unsafe: bool) -> TokenStream { } let mut impls = Vec::new(); for method in methods { + if method == "default_constructor" { + impls.push(impl_memberwise_default(&input, is_unsafe)); + continue; + } let (op, is_assign) = match method.to_string().as_str() { "copy_constructor" => ("copy", false), "move_constructor" => ("move", false), @@ -253,6 +286,34 @@ pub fn expand_memberwise(input: TokenStream, is_unsafe: bool) -> TokenStream { quote!(#(#impls)*).into() } +fn impl_memberwise_default(input: &DeriveInput, is_unsafe: bool) -> TokenStream2 { + let syn::Data::Struct(data) = &input.data else { + return syn::Error::new_spanned(input, "memberwise derives need a struct") + .to_compile_error(); + }; + let members: Vec<_> = data.fields.members().collect(); + let name = &input.ident; + let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl(); + if is_unsafe { + let tr = quote!(::libcc2rs::DefaultConstructibleUnsafe); + return quote! { + impl #impl_generics #tr for #name #ty_generics #where_clause { + unsafe fn default_constructor(&mut self) { + #(unsafe { #tr::default_constructor(&mut self.#members) };)* + } + } + }; + } + let tr = quote!(::libcc2rs::DefaultConstructible); + quote! { + impl #impl_generics #tr for #name #ty_generics #where_clause { + fn default_constructor(this: &::libcc2rs::Ptr) { + #(#tr::default_constructor(&::libcc2rs::field_ptr!(this, #members));)* + } + } + } +} + fn impl_memberwise( input: &DeriveInput, op: &str, diff --git a/libcc2rs-macros/src/lib.rs b/libcc2rs-macros/src/lib.rs index ca0513fd73..9312c8ff6c 100644 --- a/libcc2rs-macros/src/lib.rs +++ b/libcc2rs-macros/src/lib.rs @@ -175,6 +175,16 @@ pub fn derive_zero_initialization_unsafe(input: TokenStream) -> TokenStream { initialization::expand_unsafe(input) } +#[proc_macro_derive(DefaultConstructible)] +pub fn derive_default_constructible(input: TokenStream) -> TokenStream { + constructor::expand_default_constructible(input, false) +} + +#[proc_macro_derive(DefaultConstructibleUnsafe)] +pub fn derive_default_constructible_unsafe(input: TokenStream) -> TokenStream { + constructor::expand_default_constructible(input, true) +} + #[proc_macro_derive(CopyConstructible)] pub fn derive_copy_constructible(input: TokenStream) -> TokenStream { constructor::expand(input, "copy", false, false) diff --git a/libcc2rs/src/constructor.rs b/libcc2rs/src/constructor.rs index 5d9fa7ac46..53b7191b74 100644 --- a/libcc2rs/src/constructor.rs +++ b/libcc2rs/src/constructor.rs @@ -456,9 +456,55 @@ impl_default_by_default!( <> usize, <> f32, <> f64, + <> AnyPtr, Ptr, + Option, + Vec, + std::collections::BTreeMap, ); +impl DefaultConstructible for FnPtr { + fn default_constructor(this: &Ptr) { + this.with_mut(|dst| *dst = ::zero_init()); + } +} + +impl DefaultConstructibleUnsafe for FnPtr { + unsafe fn default_constructor(&mut self) { + unsafe { std::ptr::write(self, ::zero_init()) } + } +} + +impl DefaultConstructible for Box<[T]> { + fn default_constructor(this: &Ptr) { + let len = this.with(|elems| elems.len()); + let dst = this.decay(); + for i in 0..len { + T::default_constructor(&dst.offset(i)); + } + } +} + +impl DefaultConstructibleUnsafe for [T; N] { + unsafe fn default_constructor(&mut self) { + for elem in self.iter_mut() { + unsafe { elem.default_constructor() } + } + } +} + +impl DefaultConstructibleUnsafe for *mut T { + unsafe fn default_constructor(&mut self) { + unsafe { std::ptr::write(self, std::ptr::null_mut()) } + } +} + +impl DefaultConstructibleUnsafe for *const T { + unsafe fn default_constructor(&mut self) { + unsafe { std::ptr::write(self, std::ptr::null()) } + } +} + impl_trivial_copy_move!( (), bool, diff --git a/tests/std/basic/out/refcount/basic.def.odr.rs b/tests/std/basic/out/refcount/basic.def.odr.rs index b8b11d1512..7254902f74 100644 --- a/tests/std/basic/out/refcount/basic.def.odr.rs +++ b/tests/std/basic/out/refcount/basic.def.odr.rs @@ -944,21 +944,21 @@ impl p4_1_pure_virtual_without_definition_HasPureVirtual } } impl Destructible for p9_destructor_not_potentially_invoked_HasUndefinedDestructor { - fn destroy(_: &Ptr) { + fn destroy(this: &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) { + fn copy_constructor(this: &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 { + fn copy_assign(this: &Ptr, _: Ptr) -> Ptr { unreachable!( "p9_unused_implicit_assignment_HasUndefinedCopyAssignment::copy_assign is never defined" ) diff --git a/tests/unit/out/refcount/copy_move_deleted.rs b/tests/unit/out/refcount/copy_move_deleted.rs index cb3fa5660b..9bfb0215fb 100644 --- a/tests/unit/out/refcount/copy_move_deleted.rs +++ b/tests/unit/out/refcount/copy_move_deleted.rs @@ -184,12 +184,12 @@ fn main_0() -> i32 { return 0; } impl CopyAssignable for PrivateCopy { - fn copy_assign(_: &Ptr, _: Ptr) -> Ptr { + fn copy_assign(this: &Ptr, _: Ptr) -> Ptr { unreachable!("PrivateCopy::copy_assign is never defined") } } impl CopyConstructible for PrivateCopy { - fn copy_constructor(_: &Ptr, _: Ptr) { + fn copy_constructor(this: &Ptr, _: Ptr) { unreachable!("PrivateCopy::copy_constructor is never defined") } } From c84f92f0b9305d4049783d8b13c84e4f7b10d0de Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Wed, 2 Dec 2026 12:53:29 +0000 Subject: [PATCH 05/13] Add default by zeroed for libc shims --- libcc2rs/src/constructor.rs | 11 +++++++++++ rules/dirent/shim.rs | 5 ++++- rules/ifaddrs/shim.rs | 7 ++++++- rules/ip/shim.rs | 9 +++++++-- rules/netdb/shim.rs | 7 ++++++- rules/poll/shim.rs | 7 ++++++- rules/pwd/shim.rs | 7 ++++++- rules/socket/shim.rs | 32 ++++++++++++++++++++++---------- rules/stat/shim.rs | 5 ++++- rules/termios/shim.rs | 7 +++++-- rules/time/shim.rs | 15 ++++++++++++--- 11 files changed, 89 insertions(+), 23 deletions(-) diff --git a/libcc2rs/src/constructor.rs b/libcc2rs/src/constructor.rs index 53b7191b74..99e569edaa 100644 --- a/libcc2rs/src/constructor.rs +++ b/libcc2rs/src/constructor.rs @@ -439,6 +439,17 @@ macro_rules! impl_default_by_default { )*}; } +macro_rules! impl_default_by_zeroed { + ($($ty:ty),* $(,)?) => {$( + impl $crate::DefaultConstructibleUnsafe for $ty { + unsafe fn default_constructor(&mut self) { + unsafe { std::ptr::write(self, std::mem::zeroed()) } + } + } + )*}; +} +pub(crate) use impl_default_by_zeroed; + impl_default_by_default!( <> (), <> bool, diff --git a/rules/dirent/shim.rs b/rules/dirent/shim.rs index 02c56e203b..9f53574cbc 100644 --- a/rules/dirent/shim.rs +++ b/rules/dirent/shim.rs @@ -1,11 +1,12 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. +use crate::DefaultConstructible; use crate::{ByteRepr, Record, TriviallyCopyable, ZeroInitialization, size_of_field}; use std::cell::Cell; use std::mem::{offset_of, size_of}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, TriviallyCopyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, DefaultConstructible, TriviallyCopyable)] #[byte_size(size_of::<::libc::dirent>())] pub struct Dirent { #[offset(offset_of!(::libc::dirent, d_ino))] @@ -87,3 +88,5 @@ impl ByteRepr for CDir {} impl ByteRepr for ::libc::dirent {} crate::constructor::impl_trivial_copy_move!(::libc::dirent,); + +crate::constructor::impl_default_by_zeroed!(::libc::dirent,); diff --git a/rules/ifaddrs/shim.rs b/rules/ifaddrs/shim.rs index 72bb389b4d..490824db08 100644 --- a/rules/ifaddrs/shim.rs +++ b/rules/ifaddrs/shim.rs @@ -1,13 +1,16 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. +use crate::DefaultConstructible; use crate::{ ByteRepr, Ptr, Record, Sockaddr, SockaddrIn, SockaddrIn6, SockaddrStorage, TriviallyCopyable, ZeroInitialization, }; use std::mem::{offset_of, size_of}; -#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, TriviallyCopyable)] +#[derive( + Clone, Default, Record, ByteRepr, ZeroInitialization, DefaultConstructible, TriviallyCopyable, +)] #[byte_size(size_of::<::libc::ifaddrs>())] pub struct Ifaddrs { #[offset(offset_of!(::libc::ifaddrs, ifa_next))] @@ -59,3 +62,5 @@ impl Ifaddrs { impl ByteRepr for ::libc::ifaddrs {} crate::constructor::impl_trivial_copy_move!(::libc::ifaddrs,); + +crate::constructor::impl_default_by_zeroed!(::libc::ifaddrs,); diff --git a/rules/ip/shim.rs b/rules/ip/shim.rs index 0ddbf861b2..6daa972eab 100644 --- a/rules/ip/shim.rs +++ b/rules/ip/shim.rs @@ -1,16 +1,19 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. +use crate::DefaultConstructible; use crate::{ByteRepr, Ptr, Record, TriviallyCopyable, ZeroInitialization}; -#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, TriviallyCopyable)] +#[derive( + Clone, Default, Record, ByteRepr, ZeroInitialization, DefaultConstructible, TriviallyCopyable, +)] #[byte_size(4)] pub struct InAddr { #[offset(0)] pub s_addr: u32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, TriviallyCopyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, DefaultConstructible, TriviallyCopyable)] #[byte_size(16)] pub struct In6Addr { #[offset(0)] @@ -37,3 +40,5 @@ 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_default_by_zeroed!(::libc::in_addr, ::libc::in6_addr,); diff --git a/rules/netdb/shim.rs b/rules/netdb/shim.rs index 9759114ae9..965be26d37 100644 --- a/rules/netdb/shim.rs +++ b/rules/netdb/shim.rs @@ -1,10 +1,13 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. +use crate::DefaultConstructible; use crate::{ByteRepr, Ptr, Record, Sockaddr, TriviallyCopyable, ZeroInitialization}; use std::mem::{offset_of, size_of}; -#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, TriviallyCopyable)] +#[derive( + Clone, Default, Record, ByteRepr, ZeroInitialization, DefaultConstructible, TriviallyCopyable, +)] #[byte_size(size_of::<::libc::addrinfo>())] pub struct Addrinfo { #[offset(offset_of!(::libc::addrinfo, ai_flags))] @@ -28,3 +31,5 @@ pub struct Addrinfo { impl ByteRepr for ::libc::addrinfo {} crate::constructor::impl_trivial_copy_move!(::libc::addrinfo,); + +crate::constructor::impl_default_by_zeroed!(::libc::addrinfo,); diff --git a/rules/poll/shim.rs b/rules/poll/shim.rs index e3fd49fee5..5f7699d66c 100644 --- a/rules/poll/shim.rs +++ b/rules/poll/shim.rs @@ -1,10 +1,13 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. +use crate::DefaultConstructible; use crate::{ByteRepr, Record, TriviallyCopyable, ZeroInitialization}; use std::mem::{offset_of, size_of}; -#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, TriviallyCopyable)] +#[derive( + Clone, Default, Record, ByteRepr, ZeroInitialization, DefaultConstructible, TriviallyCopyable, +)] #[byte_size(size_of::<::libc::pollfd>())] pub struct Pollfd { #[offset(offset_of!(::libc::pollfd, fd))] @@ -18,3 +21,5 @@ pub struct Pollfd { impl ByteRepr for ::libc::pollfd {} crate::constructor::impl_trivial_copy_move!(::libc::pollfd,); + +crate::constructor::impl_default_by_zeroed!(::libc::pollfd,); diff --git a/rules/pwd/shim.rs b/rules/pwd/shim.rs index ce42470db6..885b6ec628 100644 --- a/rules/pwd/shim.rs +++ b/rules/pwd/shim.rs @@ -1,10 +1,13 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. +use crate::DefaultConstructible; use crate::{ByteRepr, Ptr, Record, TriviallyCopyable, ZeroInitialization}; use std::mem::{offset_of, size_of}; -#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, TriviallyCopyable)] +#[derive( + Clone, Default, Record, ByteRepr, ZeroInitialization, DefaultConstructible, TriviallyCopyable, +)] #[byte_size(size_of::<::libc::passwd>())] pub struct Passwd { #[offset(offset_of!(::libc::passwd, pw_name))] @@ -53,3 +56,5 @@ impl Passwd { impl ByteRepr for ::libc::passwd {} crate::constructor::impl_trivial_copy_move!(::libc::passwd,); + +crate::constructor::impl_default_by_zeroed!(::libc::passwd,); diff --git a/rules/socket/shim.rs b/rules/socket/shim.rs index d88e067aa7..7e2763c0b3 100644 --- a/rules/socket/shim.rs +++ b/rules/socket/shim.rs @@ -1,10 +1,11 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. +use crate::DefaultConstructible; use crate::{ByteRepr, CChar, In6Addr, InAddr, Ptr, Record, TriviallyCopyable, ZeroInitialization}; // The fields are at the offsets of the byte representation below. -#[derive(Clone, Record, ByteRepr, ZeroInitialization, TriviallyCopyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, DefaultConstructible, TriviallyCopyable)] #[byte_size(16)] pub struct Sockaddr { #[offset(0)] @@ -15,7 +16,7 @@ pub struct Sockaddr { pub sa_data: Box<[i8]>, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, TriviallyCopyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, DefaultConstructible, TriviallyCopyable)] #[byte_size(16)] pub struct SockaddrIn { #[offset(0)] @@ -30,7 +31,9 @@ pub struct SockaddrIn { pub sin_zero: Box<[u8]>, } -#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, TriviallyCopyable)] +#[derive( + Clone, Default, Record, ByteRepr, ZeroInitialization, DefaultConstructible, TriviallyCopyable, +)] #[byte_size(28)] pub struct SockaddrIn6 { #[offset(0)] @@ -45,7 +48,7 @@ pub struct SockaddrIn6 { pub sin6_scope_id: u32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, TriviallyCopyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, DefaultConstructible, TriviallyCopyable)] #[byte_size(110)] pub struct SockaddrUn { #[offset(0)] @@ -56,7 +59,7 @@ pub struct SockaddrUn { pub sun_path: Box<[i8]>, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, TriviallyCopyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, DefaultConstructible, TriviallyCopyable)] #[byte_size(128)] pub struct SockaddrStorage { #[offset(0)] @@ -76,11 +79,12 @@ impl SockaddrIn { sin_addr: InAddr { s_addr: l.sin_addr.s_addr, }, - sin_zero: l.sin_zero - .iter() - .map(|&b| b as u8) - .collect::>() - .into_boxed_slice(), + sin_zero: l + .sin_zero + .iter() + .map(|&b| b as u8) + .collect::>() + .into_boxed_slice(), } } @@ -405,3 +409,11 @@ crate::constructor::impl_trivial_copy_move!( ::libc::sockaddr_un, ::libc::sockaddr_storage, ); + +crate::constructor::impl_default_by_zeroed!( + ::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 e56c9642cc..a336c3d284 100644 --- a/rules/stat/shim.rs +++ b/rules/stat/shim.rs @@ -1,10 +1,11 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. +use crate::DefaultConstructible; use crate::{ByteRepr, Record, TriviallyCopyable, ZeroInitialization}; use std::mem::{offset_of, size_of}; -#[derive(Clone, Default, Record, ZeroInitialization, TriviallyCopyable)] +#[derive(Clone, Default, Record, ZeroInitialization, DefaultConstructible, TriviallyCopyable)] // 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"), @@ -71,3 +72,5 @@ impl ByteRepr for Stat { impl ByteRepr for ::libc::stat {} crate::constructor::impl_trivial_copy_move!(::libc::stat,); + +crate::constructor::impl_default_by_zeroed!(::libc::stat,); diff --git a/rules/termios/shim.rs b/rules/termios/shim.rs index e6d0c1bb5c..06dd21671e 100644 --- a/rules/termios/shim.rs +++ b/rules/termios/shim.rs @@ -1,10 +1,11 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. +use crate::DefaultConstructible; use crate::{ByteRepr, Record, TriviallyCopyable, ZeroInitialization}; use std::mem::{offset_of, size_of}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, TriviallyCopyable)] +#[derive(Clone, Record, ByteRepr, ZeroInitialization, DefaultConstructible, TriviallyCopyable)] #[byte_size(size_of::<::libc::termios>())] pub struct Termios { #[offset(offset_of!(::libc::termios, c_iflag))] @@ -105,7 +106,9 @@ impl Termios { } } -#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, TriviallyCopyable)] +#[derive( + Clone, Default, Record, ByteRepr, ZeroInitialization, DefaultConstructible, TriviallyCopyable, +)] #[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 b0093f7db8..687ceb4f23 100644 --- a/rules/time/shim.rs +++ b/rules/time/shim.rs @@ -1,10 +1,13 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. +use crate::DefaultConstructible; use crate::{ByteRepr, Ptr, Record, TriviallyCopyable, ZeroInitialization}; use std::mem::{offset_of, size_of}; -#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, TriviallyCopyable)] +#[derive( + Clone, Default, Record, ByteRepr, ZeroInitialization, DefaultConstructible, TriviallyCopyable, +)] #[byte_size(size_of::<::libc::tm>())] pub struct Tm { #[offset(offset_of!(::libc::tm, tm_sec))] @@ -65,7 +68,9 @@ impl Tm { } } -#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, TriviallyCopyable)] +#[derive( + Clone, Default, Record, ByteRepr, ZeroInitialization, DefaultConstructible, TriviallyCopyable, +)] #[byte_size(size_of::<::libc::timeval>())] pub struct Timeval { #[offset(offset_of!(::libc::timeval, tv_sec))] @@ -74,7 +79,9 @@ pub struct Timeval { pub tv_usec: i64, } -#[derive(Clone, Default, Record, ByteRepr, ZeroInitialization, TriviallyCopyable)] +#[derive( + Clone, Default, Record, ByteRepr, ZeroInitialization, DefaultConstructible, TriviallyCopyable, +)] #[byte_size(size_of::<::libc::timespec>())] pub struct Timespec { #[offset(offset_of!(::libc::timespec, tv_sec))] @@ -88,3 +95,5 @@ 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_default_by_zeroed!(::libc::tm, ::libc::timeval, ::libc::timespec,); From 9e6004b8bd1f8c614d14813d459f7f1af831b021 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Wed, 2 Dec 2026 13:10:03 +0000 Subject: [PATCH 06/13] Update tests --- .../refcount/sequence.reqmts-unsupported.rs | 8 +- .../out/unsafe/sequence.reqmts-unsupported.rs | 2 +- .../expr.post/out/refcount/expr.const.cast.rs | 11 +- .../expr.post/out/unsafe/expr.const.cast.rs | 2 +- .../expr.compound/out/refcount/expr.cast.rs | 11 +- .../expr.compound/out/unsafe/expr.cast.rs | 2 +- .../utilities/pairs/out/unsafe/pairs.pair.rs | 2 +- .../utility/out/refcount/forward-helpers.rs | 18 +- .../utilities/utility/out/refcount/forward.rs | 18 +- .../utility/out/unsafe/forward-helpers.rs | 2 +- .../utilities/utility/out/unsafe/forward.rs | 8 +- tests/unit/out/refcount/12_test.rs | 8 +- .../out/refcount/array_of_noncopy_struct.rs | 11 +- tests/unit/out/refcount/auto.rs | 22 +- tests/unit/out/refcount/cast.rs | 72 +++-- tests/unit/out/refcount/class_templates.rs | 11 +- tests/unit/out/refcount/clone_vs_move.rs | 19 +- tests/unit/out/refcount/comma_operator.rs | 11 +- .../unit/out/refcount/compound_assign_ref.rs | 11 +- .../refcount/container_element_receiver.rs | 33 ++- .../unit/out/refcount/container_field_addr.rs | 8 +- tests/unit/out/refcount/copy_assign.rs | 11 +- .../unit/out/refcount/copy_move_defaulted.rs | 54 ++-- .../refcount/elidable_iterator_copy_cxx11.rs | 46 +-- .../out/refcount/field_method_receiver.rs | 8 +- tests/unit/out/refcount/field_pointers.rs | 20 +- tests/unit/out/refcount/find.rs | 106 ++++--- tests/unit/out/refcount/fn_ptr_stable_sort.rs | 53 ++-- .../refcount/foreach_disjoint_field_borrow.rs | 11 +- tests/unit/out/refcount/foreach_double.rs | 63 ++-- tests/unit/out/refcount/foreach_mut.rs | 57 ++-- tests/unit/out/refcount/implicit_autoref.rs | 44 ++- .../out/refcount/inline_container_fields.rs | 19 +- tests/unit/out/refcount/iterators.rs | 16 +- tests/unit/out/refcount/map.rs | 157 +++++----- tests/unit/out/refcount/move_assign.rs | 17 +- tests/unit/out/refcount/move_ctor.rs | 23 +- tests/unit/out/refcount/push_emplace_back.rs | 114 +++---- .../refcount/reinterpret_cast_vec_write.rs | 22 +- tests/unit/out/refcount/return_move.rs | 11 +- tests/unit/out/refcount/sort.rs | 118 +++++--- tests/unit/out/refcount/vector.rs | 279 ++++++++++-------- tests/unit/out/refcount/vector2.rs | 110 ++++--- .../refcount/vector_deque_vector_string.rs | 185 ++++++------ .../out/refcount/vector_subscript_direct.rs | 38 ++- .../out/refcount/vector_with_allocator.rs | 222 ++++++++------ tests/unit/out/unsafe/12_test.rs | 2 +- .../out/unsafe/array_of_noncopy_struct.rs | 2 +- tests/unit/out/unsafe/auto.rs | 4 +- tests/unit/out/unsafe/cast.rs | 12 +- tests/unit/out/unsafe/class_templates.rs | 2 +- tests/unit/out/unsafe/clone_vs_move.rs | 4 +- tests/unit/out/unsafe/comma_operator.rs | 2 +- tests/unit/out/unsafe/compound_assign_ref.rs | 2 +- .../out/unsafe/container_element_receiver.rs | 2 +- tests/unit/out/unsafe/container_field_addr.rs | 2 +- tests/unit/out/unsafe/copy_assign.rs | 2 +- tests/unit/out/unsafe/copy_move_defaulted.rs | 14 +- .../unsafe/elidable_iterator_copy_cxx11.rs | 4 +- .../unit/out/unsafe/field_method_receiver.rs | 2 +- tests/unit/out/unsafe/field_pointers.rs | 2 +- tests/unit/out/unsafe/find.rs | 6 +- tests/unit/out/unsafe/fn_ptr_stable_sort.rs | 6 +- .../unsafe/foreach_disjoint_field_borrow.rs | 2 +- tests/unit/out/unsafe/foreach_double.rs | 12 +- tests/unit/out/unsafe/foreach_mut.rs | 12 +- tests/unit/out/unsafe/implicit_autoref.rs | 8 +- .../out/unsafe/inline_container_fields.rs | 4 +- tests/unit/out/unsafe/iterators.rs | 4 +- tests/unit/out/unsafe/map.rs | 6 +- tests/unit/out/unsafe/move_assign.rs | 16 +- tests/unit/out/unsafe/move_ctor.rs | 22 +- tests/unit/out/unsafe/pair.rs | 12 +- tests/unit/out/unsafe/push_emplace_back.rs | 8 +- .../out/unsafe/reinterpret_cast_vec_write.rs | 4 +- tests/unit/out/unsafe/return_move.rs | 2 +- tests/unit/out/unsafe/sort.rs | 20 +- tests/unit/out/unsafe/vector.rs | 25 +- tests/unit/out/unsafe/vector2.rs | 20 +- .../out/unsafe/vector_deque_vector_string.rs | 40 +-- .../out/unsafe/vector_subscript_direct.rs | 8 +- .../unit/out/unsafe/vector_with_allocator.rs | 28 +- 82 files changed, 1381 insertions(+), 1036 deletions(-) diff --git a/tests/std/containers/container.requirements/out/refcount/sequence.reqmts-unsupported.rs b/tests/std/containers/container.requirements/out/refcount/sequence.reqmts-unsupported.rs index 5bafc2821e..5e6b8ba2af 100644 --- a/tests/std/containers/container.requirements/out/refcount/sequence.reqmts-unsupported.rs +++ b/tests/std/containers/container.requirements/out/refcount/sequence.reqmts-unsupported.rs @@ -33,9 +33,11 @@ pub fn test_1() { ))); let pairs: Value>>, Value)>> = Rc::new(RefCell::new(Vec::new())); - { - let __a1 = ({ std::mem::take(&mut (*source.borrow_mut())) }); - (*pairs.borrow_mut()).push(__a1) + match (source.as_pointer(),) { + (__tmp_1,) => { + let __a1 = move_constructed(&__tmp_1); + (*pairs.borrow_mut()).push(__a1) + } }; assert!(((({ (*(*pairs.borrow())[0_usize].0.borrow()).as_pointer() }).read()) == 1)); assert!(({ (*(*source.borrow()).0.borrow()).is_none() })); diff --git a/tests/std/containers/container.requirements/out/unsafe/sequence.reqmts-unsupported.rs b/tests/std/containers/container.requirements/out/unsafe/sequence.reqmts-unsupported.rs index 1ab56c3d53..f5f606d7b4 100644 --- a/tests/std/containers/container.requirements/out/unsafe/sequence.reqmts-unsupported.rs +++ b/tests/std/containers/container.requirements/out/unsafe/sequence.reqmts-unsupported.rs @@ -31,7 +31,7 @@ pub unsafe fn test_1() { (Some(Box::from_raw((Box::leak(Box::new(1)) as *mut i32))), 2); let mut pairs: Vec<(Option>, i32)> = Vec::new(); { - let __a1 = std::mem::take(&mut source); + let __a1 = move_constructed_unsafe(&raw mut source); pairs.push(__a1) }; assert!( 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 c6cddfa9e8..f93681baaf 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 @@ -41,10 +41,13 @@ pub fn test_1() { assert!(({ (*pair.borrow()).x } == 2)); let vec_: Value> = Rc::new(RefCell::new(Vec::from([1]))); let cvec: Ptr> = vec_.as_pointer(); - { - let __a1 = 2; - cvec.with_mut(|__v: &mut Vec| __v.push(__a1)) - }; + ({ + let __tmp_0: Value = Rc::new(RefCell::new(2)); + { + let __a1 = move_constructed(&__tmp_0.as_pointer()); + cvec.with_mut(|__v: &mut Vec| __v.push(__a1)) + } + }); assert!(({ ((*vec_.borrow()).len() == 2_usize) })); } pub fn main() { 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 0e58a2d020..e9217f5803 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 @@ -38,7 +38,7 @@ pub unsafe fn test_1() { let mut vec_: Vec = Vec::from([1]); let cvec: *const Vec = &vec_; { - let __a1 = 2; + let __a1 = move_constructed_unsafe(&raw mut 2); (*(&raw const (*cvec)).cast_mut()).push(__a1) }; assert!(((vec_.len()) == (2_usize))); diff --git a/tests/std/expr/expr.compound/out/refcount/expr.cast.rs b/tests/std/expr/expr.compound/out/refcount/expr.cast.rs index aac015a39c..1fa9fd8735 100644 --- a/tests/std/expr/expr.compound/out/refcount/expr.cast.rs +++ b/tests/std/expr/expr.compound/out/refcount/expr.cast.rs @@ -21,10 +21,13 @@ pub fn test_2() { assert!(({ ((*v.borrow()) == 8) })); let vec_: Value> = Rc::new(RefCell::new(Vec::from([1]))); let cvec: Ptr> = vec_.as_pointer(); - { - let __a1 = 2; - cvec.with_mut(|__v: &mut Vec| __v.push(__a1)) - }; + ({ + let __tmp_0: Value = Rc::new(RefCell::new(2)); + { + let __a1 = move_constructed(&__tmp_0.as_pointer()); + cvec.with_mut(|__v: &mut Vec| __v.push(__a1)) + } + }); assert!(({ ((*vec_.borrow()).len() == 2_usize) })); } pub fn main() { diff --git a/tests/std/expr/expr.compound/out/unsafe/expr.cast.rs b/tests/std/expr/expr.compound/out/unsafe/expr.cast.rs index 93c9f95cf1..d18ac825c6 100644 --- a/tests/std/expr/expr.compound/out/unsafe/expr.cast.rs +++ b/tests/std/expr/expr.compound/out/unsafe/expr.cast.rs @@ -22,7 +22,7 @@ pub unsafe fn test_2() { let mut vec_: Vec = Vec::from([1]); let cvec: *const Vec = &vec_; { - let __a1 = 2; + let __a1 = move_constructed_unsafe(&raw mut 2); (*(&raw const (*cvec)).cast_mut()).push(__a1) }; assert!(((vec_.len()) == (2_usize))); diff --git a/tests/std/utilities/pairs/out/unsafe/pairs.pair.rs b/tests/std/utilities/pairs/out/unsafe/pairs.pair.rs index 449f96584a..b560e72340 100644 --- a/tests/std/utilities/pairs/out/unsafe/pairs.pair.rs +++ b/tests/std/utilities/pairs/out/unsafe/pairs.pair.rs @@ -108,7 +108,7 @@ pub unsafe fn test_3() { .1 .as_deref_mut() .map_or(::std::ptr::null_mut(), |v| v as *mut i32); - let mut target: (i64, Option>) = <(i64, Option>)>::default(); + let mut target: (i64, Option>) = (0_i64, None); { target = (((*&mut source.0) as i64), cpp_move_unsafe!(&mut source.1)); }; diff --git a/tests/std/utilities/utility/out/refcount/forward-helpers.rs b/tests/std/utilities/utility/out/refcount/forward-helpers.rs index 5a708cc6e5..85cf44f7e7 100644 --- a/tests/std/utilities/utility/out/refcount/forward-helpers.rs +++ b/tests/std/utilities/utility/out/refcount/forward-helpers.rs @@ -156,21 +156,23 @@ pub fn test_4() { MoveConstructible::move_constructor(&destination.as_pointer(), { source.as_pointer() }); assert!(({ (*destination.borrow()).value } == 3) && ({ (*source.borrow()).value } == 0)); let strings: Value>> = Rc::new(RefCell::new(Vec::new())); - let mut text: Vec = { + let text: Value> = Rc::new(RefCell::new({ let mut __bytes = Ptr::::from_string_literal(b"text").to_c_bytes(); __bytes.push(0); __bytes - }; - { - let __a1 = std::mem::replace(&mut text, vec![0]); - (*strings.borrow_mut()).push(__a1) + })); + match (text.as_pointer(),) { + (__tmp_0,) => { + let __a1 = move_constructed(&__tmp_0); + (*strings.borrow_mut()).push(__a1) + } }; assert!( ({ match (strings.decay().offset(0_usize),) { - (__tmp_0,) => Ptr::::from_string_literal(b"text").with_c_str(|__s| { - (*__tmp_0.upgrade().deref()) - [..(*__tmp_0.upgrade().deref()).len().saturating_sub(1)] + (__tmp_1,) => Ptr::::from_string_literal(b"text").with_c_str(|__s| { + (*__tmp_1.upgrade().deref()) + [..(*__tmp_1.upgrade().deref()).len().saturating_sub(1)] == *__s }), } diff --git a/tests/std/utilities/utility/out/refcount/forward.rs b/tests/std/utilities/utility/out/refcount/forward.rs index 3f331f64c6..999c8761e3 100644 --- a/tests/std/utilities/utility/out/refcount/forward.rs +++ b/tests/std/utilities/utility/out/refcount/forward.rs @@ -46,14 +46,17 @@ pub fn test_1() { assert!((assigned.x == 3) && (assigned.y == 4)); assert!((other.x == 3) && (other.y == 4)); let mut points: Vec = Vec::new(); - let mut element: p9_move_trivially_copyable_Point = - p9_move_trivially_copyable_Point { x: 5, y: 6 }; + let element: Value = + Rc::new(RefCell::new(p9_move_trivially_copyable_Point { + x: 5, + y: 6, + })); { - let __a1 = element; + let __a1 = move_constructed(&element.as_pointer()); points.push(__a1) }; assert!((points[0_usize].x == 5) && (points[0_usize].y == 6)); - assert!((element.x == 5) && (element.y == 6)); + assert!(({ (*element.borrow()).x } == 5) && ({ (*element.borrow()).y } == 6)); } #[derive( Record, @@ -91,12 +94,7 @@ pub fn test_2() { Rc::new(RefCell::new(::zero_init())); p10_move_constructor_AImpl::construct(&element.as_pointer(), { 2 }); { - let __a1 = { - let __v: Value = - Rc::new(RefCell::new(::zero_init())); - MoveConstructible::move_constructor(&__v.as_pointer(), { element.as_pointer() }); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }; + let __a1 = move_constructed(&element.as_pointer()); values.push(__a1) }; assert!((values[0_usize].value == 2)); diff --git a/tests/std/utilities/utility/out/unsafe/forward-helpers.rs b/tests/std/utilities/utility/out/unsafe/forward-helpers.rs index 6452e83914..1b1cf5ff53 100644 --- a/tests/std/utilities/utility/out/unsafe/forward-helpers.rs +++ b/tests/std/utilities/utility/out/unsafe/forward-helpers.rs @@ -157,7 +157,7 @@ pub unsafe fn test_4() { ) .to_vec(); { - let __a1 = std::mem::replace(&mut text, vec![0]); + let __a1 = move_constructed_unsafe(&raw mut text); strings.push(__a1) }; assert!( diff --git a/tests/std/utilities/utility/out/unsafe/forward.rs b/tests/std/utilities/utility/out/unsafe/forward.rs index 5741c6cf70..6821edefec 100644 --- a/tests/std/utilities/utility/out/unsafe/forward.rs +++ b/tests/std/utilities/utility/out/unsafe/forward.rs @@ -45,7 +45,7 @@ pub unsafe fn test_1() { let mut element: p9_move_trivially_copyable_Point = p9_move_trivially_copyable_Point { x: 5, y: 6 }; { - let __a1 = element; + let __a1 = move_constructed_unsafe(&raw mut element); points.push(__a1) }; assert!(((points[(0_usize)].x) == (5)) && ((points[(0_usize)].y) == (6))); @@ -86,11 +86,7 @@ pub unsafe fn test_2() { let mut element: p10_move_constructor_A = ::zero_init(); p10_move_constructor_A::construct(&mut element, { 2 }); { - let __a1 = { - let mut __v: p10_move_constructor_A = ::zero_init(); - MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut element }); - __v - }; + let __a1 = move_constructed_unsafe(&raw mut element); values.push(__a1) }; assert!(((values[(0_usize)].value) == (2))); diff --git a/tests/unit/out/refcount/12_test.rs b/tests/unit/out/refcount/12_test.rs index eb8d610955..eb98d63e51 100644 --- a/tests/unit/out/refcount/12_test.rs +++ b/tests/unit/out/refcount/12_test.rs @@ -12,9 +12,11 @@ pub fn main() { } fn main_0() -> i32 { let v: Value>> = Rc::new(RefCell::new(Vec::new())); - { - let __a1 = Vec::from_fn(10_usize, |_| 0_i32); - (*v.borrow_mut()).push(__a1) + match (Rc::new(RefCell::new(Vec::from_fn(10_usize, |_| 0_i32))).as_pointer(),) { + (__tmp_0,) => { + let __a1 = move_constructed(&(__tmp_0).clone()); + (*v.borrow_mut()).push(__a1) + } }; return 0; } diff --git a/tests/unit/out/refcount/array_of_noncopy_struct.rs b/tests/unit/out/refcount/array_of_noncopy_struct.rs index 62c02d5cfb..58bd30f55a 100644 --- a/tests/unit/out/refcount/array_of_noncopy_struct.rs +++ b/tests/unit/out/refcount/array_of_noncopy_struct.rs @@ -54,10 +54,13 @@ fn main_0() -> i32 { Rc::try_unwrap(__v).ok().unwrap().into_inner() }); arr[(0) as usize].tag = 7; - { - let __a1 = 42; - arr[(1) as usize].data.push(__a1) - }; + ({ + let __tmp_0: Value = Rc::new(RefCell::new(42)); + { + let __a1 = move_constructed(&__tmp_0.as_pointer()); + arr[(1) as usize].data.push(__a1) + } + }); assert!((arr[(0) as usize].tag == 7)); assert!((arr[(1) as usize].data.len() == 1_usize)); assert!((arr[(1) as usize].data[0_usize] == 42)); diff --git a/tests/unit/out/refcount/auto.rs b/tests/unit/out/refcount/auto.rs index 70764424af..305afc0bc5 100644 --- a/tests/unit/out/refcount/auto.rs +++ b/tests/unit/out/refcount/auto.rs @@ -15,14 +15,20 @@ fn main_0() -> i32 { let mut x2: i16 = 2_i16; let mut x3: u32 = 4_u32; let v: Value> = Rc::new(RefCell::new(Vec::new())); - { - let __a1 = 1; - (*v.borrow_mut()).push(__a1) - }; - { - let __a1 = 2; - (*v.borrow_mut()).push(__a1) - }; + ({ + let __tmp_0: Value = Rc::new(RefCell::new(1)); + { + let __a1 = move_constructed(&__tmp_0.as_pointer()); + (*v.borrow_mut()).push(__a1) + } + }); + ({ + let __tmp_1: Value = Rc::new(RefCell::new(2)); + { + let __a1 = move_constructed(&__tmp_1.as_pointer()); + (*v.borrow_mut()).push(__a1) + } + }); let mut sum: i32 = 0; 'loop_: for elem in IterRange::new(v.decay().begin(), v.decay().end()) { let mut elem: i32 = (elem.iter_deref().read()); diff --git a/tests/unit/out/refcount/cast.rs b/tests/unit/out/refcount/cast.rs index d2bdfc4bdf..688fc25557 100644 --- a/tests/unit/out/refcount/cast.rs +++ b/tests/unit/out/refcount/cast.rs @@ -279,19 +279,28 @@ pub fn vector_capacity_4() { (*__b0).reserve_exact(4_usize - len_0 as usize); } }); - { - let __a1 = 1; - (*v.borrow_mut()).push(__a1) - }; + ({ + let __tmp_1: Value = Rc::new(RefCell::new(1)); + { + let __a1 = move_constructed(&__tmp_1.as_pointer()); + (*v.borrow_mut()).push(__a1) + } + }); let mut i0: usize = (v.decay().offset(0_usize)).to_int(); - { - let __a1 = 2; - (*v.borrow_mut()).push(__a1) - }; - { - let __a1 = 3; - (*v.borrow_mut()).push(__a1) - }; + ({ + let __tmp_2: Value = Rc::new(RefCell::new(2)); + { + let __a1 = move_constructed(&__tmp_2.as_pointer()); + (*v.borrow_mut()).push(__a1) + } + }); + ({ + let __tmp_3: Value = Rc::new(RefCell::new(3)); + { + let __a1 = move_constructed(&__tmp_3.as_pointer()); + (*v.borrow_mut()).push(__a1) + } + }); assert!( ((v.decay().offset(2_usize)).to_int() == ((i0 as u64).wrapping_add( @@ -384,23 +393,32 @@ pub fn nested_5() { .items .reserve_exact(4_usize - len_0 as usize); }; - { - let __a1 = 1; - (*b.borrow_mut()).items.push(__a1) - }; - { - let __a1 = 2; - (*b.borrow_mut()).items.push(__a1) - }; + ({ + let __tmp_4: Value = Rc::new(RefCell::new(1)); + { + let __a1 = move_constructed(&__tmp_4.as_pointer()); + (*b.borrow_mut()).items.push(__a1) + } + }); + ({ + let __tmp_5: Value = Rc::new(RefCell::new(2)); + { + let __a1 = move_constructed(&__tmp_5.as_pointer()); + (*b.borrow_mut()).items.push(__a1) + } + }); let mut ib: usize = (field_ref!(b.as_pointer(), items).decay().offset(0_usize)).to_int(); assert!( ((field_ref!(b.as_pointer(), items).decay().offset(1_usize)).to_int() == ((ib as u64).wrapping_add((::std::mem::size_of::() as u64)) as usize)) ); - { - let __a1 = 3; - (*b.borrow_mut()).items.push(__a1) - }; + ({ + let __tmp_6: Value = Rc::new(RefCell::new(3)); + { + let __a1 = move_constructed(&__tmp_6.as_pointer()); + (*b.borrow_mut()).items.push(__a1) + } + }); assert!( ((field_ref!(b.as_pointer(), items).decay().offset(2_usize)).to_int() == ((ib as u64).wrapping_add( @@ -494,9 +512,9 @@ pub fn c_strings_8() { ); let d: Value> = Rc::new(RefCell::new((0..6).map(|_| 0_i8).collect::>())); { - let mut __tmp_1 = { (>::from_int(d.decay().to_int())).to_any() }; - __tmp_1.memcpy(&(p).to_any(), ::std::mem::size_of::<[i8; 6]>()); - (__tmp_1).clone() + let mut __tmp_7 = { (>::from_int(d.decay().to_int())).to_any() }; + __tmp_7.memcpy(&(p).to_any(), ::std::mem::size_of::<[i8; 6]>()); + (__tmp_7).clone() }; assert!( ((>::from_int(d.decay().to_int())) diff --git a/tests/unit/out/refcount/class_templates.rs b/tests/unit/out/refcount/class_templates.rs index 51e3dc3a62..efcc936423 100644 --- a/tests/unit/out/refcount/class_templates.rs +++ b/tests/unit/out/refcount/class_templates.rs @@ -270,10 +270,13 @@ pub fn main() { } fn main_0() -> i32 { let mut ev: Vec = Vec::new(); - { - let __a1 = (Elem { i: 2 }); - ev.push(__a1) - }; + ({ + let __tmp_0: Value = Rc::new(RefCell::new(Elem { i: 2 })); + { + let __a1 = move_constructed(&(__tmp_0.as_pointer())); + ev.push(__a1) + } + }); assert!((ev[0_usize].i == 2)); assert!(((({ Boxed_short_::twice(2_i16,) }) as i32) == 4)); let oi: Value = Rc::new(RefCell::new(Outer_int_ { v: 3 })); diff --git a/tests/unit/out/refcount/clone_vs_move.rs b/tests/unit/out/refcount/clone_vs_move.rs index 68fa6756a5..de48bd8e45 100644 --- a/tests/unit/out/refcount/clone_vs_move.rs +++ b/tests/unit/out/refcount/clone_vs_move.rs @@ -205,9 +205,11 @@ fn main_0() -> i32 { let mut i: i32 = 0; 'loop_: while (i < N) { 'for_body: { - { - let __a1 = Vec::from_fn(10_usize, |_| 0_i32); - (*m1.borrow_mut()).push(__a1) + match (Rc::new(RefCell::new(Vec::from_fn(10_usize, |_| 0_i32))).as_pointer(),) { + (__tmp_0,) => { + let __a1 = move_constructed(&(__tmp_0).clone()); + (*m1.borrow_mut()).push(__a1) + } }; } i.prefix_inc(); @@ -364,10 +366,13 @@ fn main_0() -> i32 { Rc::new(RefCell::new((*pair3.borrow()).0.borrow().clone())), Rc::new(RefCell::new((*pair3.borrow()).1.borrow().clone())), ))); - { - let __a1 = 1; - (*(*pair4.borrow()).0.borrow_mut()).push(__a1) - }; + ({ + let __tmp_1: Value = Rc::new(RefCell::new(1)); + { + let __a1 = move_constructed(&__tmp_1.as_pointer()); + (*(*pair4.borrow()).0.borrow_mut()).push(__a1) + } + }); (*(*pair4.borrow()).1.borrow_mut()) = 1; assert!(({ ((*(*pair4.borrow()).0.borrow()).len() == 1_usize) })); assert!(({ ((*(*pair4.borrow()).1.borrow()) == 1) })); diff --git a/tests/unit/out/refcount/comma_operator.rs b/tests/unit/out/refcount/comma_operator.rs index 9d51ebf6cb..b320f3408b 100644 --- a/tests/unit/out/refcount/comma_operator.rs +++ b/tests/unit/out/refcount/comma_operator.rs @@ -82,10 +82,13 @@ fn main_0() -> i32 { } }) .clone(); - { - let __a1 = 3; - v2.push(__a1) - }; + ({ + let __tmp_0: Value = Rc::new(RefCell::new(3)); + { + let __a1 = move_constructed(&__tmp_0.as_pointer()); + v2.push(__a1) + } + }); assert!((a == 5)); assert!(({ ((*v1.borrow()).len() == 2_usize) })); assert!((v2.len() == 3_usize)); diff --git a/tests/unit/out/refcount/compound_assign_ref.rs b/tests/unit/out/refcount/compound_assign_ref.rs index 317daf6323..bb97bc1847 100644 --- a/tests/unit/out/refcount/compound_assign_ref.rs +++ b/tests/unit/out/refcount/compound_assign_ref.rs @@ -12,10 +12,13 @@ pub fn main() { } fn main_0() -> i32 { let mut v: Vec = Vec::new(); - { - let __a1 = 10; - v.push(__a1) - }; + ({ + let __tmp_0: Value = Rc::new(RefCell::new(10)); + { + let __a1 = move_constructed(&__tmp_0.as_pointer()); + v.push(__a1) + } + }); v[0] += 5; assert!((v[0] == 15)); return 0; diff --git a/tests/unit/out/refcount/container_element_receiver.rs b/tests/unit/out/refcount/container_element_receiver.rs index 0c10054ba6..33b54dcc0d 100644 --- a/tests/unit/out/refcount/container_element_receiver.rs +++ b/tests/unit/out/refcount/container_element_receiver.rs @@ -99,27 +99,30 @@ fn main_0() -> i32 { .write(7); assert!(((vec_elem!(h.as_pointer(), vec_, 0_usize).read()) == 7)); let m: Value, Value>)>> = Rc::new(RefCell::new(Map::new())); - { - let __a1 = 8; - match (Rc::new(RefCell::new(1)).as_pointer(),) { - (__tmp_1,) => { - ({ - (*m.borrow_mut()).subscript_move( - __tmp_1, - |__k| cpp_move!(__k), - || Default::default(), - ) - }) + ({ + let __tmp_1: Value = Rc::new(RefCell::new(8)); + { + let __a1 = move_constructed(&__tmp_1.as_pointer()); + match (Rc::new(RefCell::new(1)).as_pointer(),) { + (__tmp_2,) => { + ({ + (*m.borrow_mut()).subscript_move( + __tmp_2, + |__k| cpp_move!(__k), + || Default::default(), + ) + }) + } } + .with_mut(|__v: &mut Vec| __v.push(__a1)) } - .with_mut(|__v: &mut Vec| __v.push(__a1)) - }; + }); assert!( ((match (Rc::new(RefCell::new(1)).as_pointer(),) { - (__tmp_2,) => { + (__tmp_3,) => { ({ (*m.borrow_mut()).subscript_move( - __tmp_2, + __tmp_3, |__k| cpp_move!(__k), || Default::default(), ) diff --git a/tests/unit/out/refcount/container_field_addr.rs b/tests/unit/out/refcount/container_field_addr.rs index 931646d616..44dc7f84df 100644 --- a/tests/unit/out/refcount/container_field_addr.rs +++ b/tests/unit/out/refcount/container_field_addr.rs @@ -43,9 +43,11 @@ pub fn add_0(mut v: Ptr>, mut k: i32) { pub fn run_1(mut h: Ptr) { ({ add_0((field_ref!(h, v).as_pointer()), h.with(|__s| __s.tag)) }); let mut pv: Ptr> = (field_ref!(h, v).as_pointer()); - { - let __a1 = (((*pv.upgrade().deref()).len()) as i32); - pv.with_mut(|__v: &mut Vec| __v.push(__a1)) + match (Rc::new(RefCell::new((((*pv.upgrade().deref()).len()) as i32))).as_pointer(),) { + (__tmp_0,) => { + let __a1 = move_constructed(&(__tmp_0).clone()); + pv.with_mut(|__v: &mut Vec| __v.push(__a1)) + } }; assert!( ({ diff --git a/tests/unit/out/refcount/copy_assign.rs b/tests/unit/out/refcount/copy_assign.rs index 6acca04f8f..efd32cd6e6 100644 --- a/tests/unit/out/refcount/copy_assign.rs +++ b/tests/unit/out/refcount/copy_assign.rs @@ -432,10 +432,13 @@ fn main_0() -> i32 { let e2: Value = Rc::new(RefCell::new(::zero_init())); DefaultConstructible::default_constructor(&e2.as_pointer()); - { - let __a1 = 5; - (*e1.borrow_mut()).w.push(__a1) - }; + ({ + let __tmp_1: Value = Rc::new(RefCell::new(5)); + { + let __a1 = move_constructed(&__tmp_1.as_pointer()); + (*e1.borrow_mut()).w.push(__a1) + } + }); ({ CopyAssignable::copy_assign(&e2.as_pointer(), e1.as_pointer()) }); assert!( ({ diff --git a/tests/unit/out/refcount/copy_move_defaulted.rs b/tests/unit/out/refcount/copy_move_defaulted.rs index 4073b9a5af..59e0f8b8b0 100644 --- a/tests/unit/out/refcount/copy_move_defaulted.rs +++ b/tests/unit/out/refcount/copy_move_defaulted.rs @@ -700,13 +700,17 @@ fn main_0() -> i32 { let a0_clone = (*b.borrow()).clone(); vec_.push(a0_clone) }; + match (Rc::new(RefCell::new({ + let __v: Value = Rc::new(RefCell::new(::zero_init())); + ExplicitImpl::construct(&__v.as_pointer(), { 9 }); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + })) + .as_pointer(),) { - let __a1 = { - let __v: Value = Rc::new(RefCell::new(::zero_init())); - ExplicitImpl::construct(&__v.as_pointer(), { 9 }); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }; - vec_.push(__a1) + (__tmp_1,) => { + let __a1 = move_constructed(&(__tmp_1).clone()); + vec_.push(__a1) + } }; assert!((vec_[0_usize].v == 1) && (vec_[1_usize].v == 9)); let m: Value = Rc::new(RefCell::new(::zero_init())); @@ -778,16 +782,14 @@ fn main_0() -> i32 { }) ); let bufs: Value> = Rc::new(RefCell::new(Vec::new())); - { - let __a1 = { - let __v: Value = Rc::new(RefCell::new(::zero_init())); - MoveConstructible::move_constructor(&__v.as_pointer(), { r.as_pointer() }); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }; - (*bufs.borrow_mut()).push(__a1) + match (r.as_pointer(),) { + (__tmp_2,) => { + let __a1 = move_constructed(&__tmp_2); + (*bufs.borrow_mut()).push(__a1) + } }; { - let mut __tmp_1 = { + let mut __tmp_3 = { { let __v: Value = Rc::new(RefCell::new(::zero_init())); MoveConstructible::move_constructor(&__v.as_pointer(), { @@ -796,7 +798,7 @@ fn main_0() -> i32 { Rc::try_unwrap(__v).ok().unwrap().into_inner() } }; - (*bufs.borrow_mut()).push(__tmp_1); + (*bufs.borrow_mut()).push(__tmp_3); }; assert!( ({ @@ -807,10 +809,13 @@ fn main_0() -> i32 { ); let o1: Value = Rc::new(RefCell::new(::zero_init())); DefaultConstructible::default_constructor(&o1.as_pointer()); - { - let __a1 = 5; - (*o1.borrow_mut()).data.push(__a1) - }; + ({ + let __tmp_4: Value = Rc::new(RefCell::new(5)); + { + let __a1 = move_constructed(&__tmp_4.as_pointer()); + (*o1.borrow_mut()).data.push(__a1) + } + }); (*o1.borrow_mut()).n = 5; array_elem!(o1.as_pointer(), arr, 0).write(5); array_elem!(o1.as_pointer(), arr, 1).write(6); @@ -979,10 +984,13 @@ fn main_0() -> i32 { let a3: Value = Rc::new(RefCell::new(::zero_init())); DefaultConstructible::default_constructor(&a3.as_pointer()); (*a1.borrow_mut()).v = 3; - { - let __a1 = 4; - (*a1.borrow_mut()).w.push(__a1) - }; + ({ + let __tmp_5: Value = Rc::new(RefCell::new(4)); + { + let __a1 = move_constructed(&__tmp_5.as_pointer()); + (*a1.borrow_mut()).w.push(__a1) + } + }); ({ CopyAssignable::copy_assign(&a2.as_pointer(), a1.as_pointer()) }); assert!( ({ diff --git a/tests/unit/out/refcount/elidable_iterator_copy_cxx11.rs b/tests/unit/out/refcount/elidable_iterator_copy_cxx11.rs index 144e6264c0..c46cf3578e 100644 --- a/tests/unit/out/refcount/elidable_iterator_copy_cxx11.rs +++ b/tests/unit/out/refcount/elidable_iterator_copy_cxx11.rs @@ -12,22 +12,28 @@ pub fn main() { } fn main_0() -> i32 { let v: Value> = Rc::new(RefCell::new(Vec::new())); - { - let __a1 = 4; - (*v.borrow_mut()).push(__a1) - }; - { - let __a1 = 7; - (*v.borrow_mut()).push(__a1) - }; + ({ + let __tmp_0: Value = Rc::new(RefCell::new(4)); + { + let __a1 = move_constructed(&__tmp_0.as_pointer()); + (*v.borrow_mut()).push(__a1) + } + }); + ({ + let __tmp_1: Value = Rc::new(RefCell::new(7)); + { + let __a1 = move_constructed(&__tmp_1.as_pointer()); + (*v.borrow_mut()).push(__a1) + } + }); let it: Value> = Rc::new(RefCell::new( ({ - let __tmp_2: Value = Rc::new(RefCell::new(7)); + let __tmp_4: Value = Rc::new(RefCell::new(7)); { - let mut __tmp_0 = { v.decay().begin() }; - let mut __tmp_1 = { v.decay().end() }; - let mut __it = (__tmp_0).clone(); - while __it != __tmp_1 && !CppEq::equal(&__it.iter_deref(), &__tmp_2.as_pointer()) { + let mut __tmp_2 = { v.decay().begin() }; + let mut __tmp_3 = { v.decay().end() }; + let mut __it = (__tmp_2).clone(); + while __it != __tmp_3 && !CppEq::equal(&__it.iter_deref(), &__tmp_4.as_pointer()) { __it.iter_inc(); } __it @@ -37,21 +43,21 @@ fn main_0() -> i32 { assert!((*it.borrow()) != v.decay().end()); assert!(((({ (*it.borrow()).iter_deref() }).read()) == 7)); { - let mut __tmp_3 = { v.decay().begin() }; - let __n = v.decay().end().iter_distance(&__tmp_3); + let mut __tmp_5 = { v.decay().begin() }; + let __n = v.decay().end().iter_distance(&__tmp_5); 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; - Swappable::swap(&__tmp_3.iter_at(__i), __tmp_3.iter_at(__j)); + Swappable::swap(&__tmp_5.iter_at(__i), __tmp_5.iter_at(__j)); } }; { - let mut __tmp_4 = { v.decay().begin() }; - let __n = v.decay().end().iter_distance(&__tmp_4); + let mut __tmp_6 = { v.decay().begin() }; + let __n = v.decay().end().iter_distance(&__tmp_6); let mut __order: Vec = (0..__n).collect(); - __order.sort_by(|&__x, &__y| cpp_cmp(&__tmp_4.iter_at(__x), &__tmp_4.iter_at(__y))); - reorder(__order, |__i| __tmp_4.iter_at(__i)); + __order.sort_by(|&__x, &__y| cpp_cmp(&__tmp_6.iter_at(__x), &__tmp_6.iter_at(__y))); + reorder(__order, |__i| __tmp_6.iter_at(__i)); }; assert!(({ (*v.borrow())[0_usize] } == 4) && ({ (*v.borrow())[1_usize] } == 7)); return 0; diff --git a/tests/unit/out/refcount/field_method_receiver.rs b/tests/unit/out/refcount/field_method_receiver.rs index 32d8c6a0b2..a2e908181d 100644 --- a/tests/unit/out/refcount/field_method_receiver.rs +++ b/tests/unit/out/refcount/field_method_receiver.rs @@ -100,9 +100,11 @@ pub fn run_0(mut o: Ptr) { assert!((({ CounterImpl::get(&field_ptr!(o, c),) }) == 0)); ({ SImpl::bump(&o) }); assert!((({ CounterImpl::get(&field_ptr!(o, c),) }) == 1)); - { - let __a1 = ({ CounterImpl::get(&field_ptr!(o, c)) }); - field!(o, v).with_mut(|__v: &mut Vec| __v.push(__a1)) + match (Rc::new(RefCell::new(({ CounterImpl::get(&field_ptr!(o, c)) }))).as_pointer(),) { + (__tmp_0,) => { + let __a1 = move_constructed(&(__tmp_0).clone()); + field!(o, v).with_mut(|__v: &mut Vec| __v.push(__a1)) + } }; assert!( ({ diff --git a/tests/unit/out/refcount/field_pointers.rs b/tests/unit/out/refcount/field_pointers.rs index 792361dcb8..8f89da49bc 100644 --- a/tests/unit/out/refcount/field_pointers.rs +++ b/tests/unit/out/refcount/field_pointers.rs @@ -190,14 +190,14 @@ fn main_0() -> i32 { assert!((({ OuterImpl::sum(&o.as_pointer(),) }) == 7)); let y: Value = Rc::new(RefCell::new(0)); { - let mut __tmp_0 = { + let mut __tmp_1 = { (field_ptr!( array_field_ptr!(o.as_pointer(), items).offset((2) as isize), a )) .to_any() }; - __tmp_0.memcpy( + __tmp_1.memcpy( &(field_ptr!( array_field_ptr!(o.as_pointer(), items).offset((1) as isize), a @@ -205,11 +205,11 @@ fn main_0() -> i32 { .to_any(), ::std::mem::size_of::(), ); - (__tmp_0).clone() + (__tmp_1).clone() }; { - let mut __tmp_1 = { (y.as_pointer()).to_any() }; - __tmp_1.memcpy( + let mut __tmp_2 = { (y.as_pointer()).to_any() }; + __tmp_2.memcpy( &(field_ptr!( array_field_ptr!(o.as_pointer(), items).offset((2) as isize), a @@ -217,7 +217,7 @@ fn main_0() -> i32 { .to_any(), ::std::mem::size_of::(), ); - (__tmp_1).clone() + (__tmp_2).clone() }; assert!(({ ((*y.borrow()) == 4) })); let bytes: Value> = Rc::new(RefCell::new(Box::new([0_u8; 8]))); @@ -263,9 +263,11 @@ impl OuterImpl for Ptr { return ((*self).with(|__s| __s.x) + (*self).with(|__s| __s.inner.a)); } fn push(&self, mut k: i32) { - { - let __a1 = (k + (*self).with(|__s| __s.x)); - field!((*self), v).with_mut(|__v: &mut Vec| __v.push(__a1)) + match (Rc::new(RefCell::new((k + (*self).with(|__s| __s.x)))).as_pointer(),) { + (__tmp_0,) => { + let __a1 = move_constructed(&__tmp_0); + field!((*self), v).with_mut(|__v: &mut Vec| __v.push(__a1)) + } }; } } diff --git a/tests/unit/out/refcount/find.rs b/tests/unit/out/refcount/find.rs index dc45f81270..4f96ed20f6 100644 --- a/tests/unit/out/refcount/find.rs +++ b/tests/unit/out/refcount/find.rs @@ -35,27 +35,36 @@ pub fn main() { } fn main_0() -> i32 { let v: Value> = Rc::new(RefCell::new(Vec::new())); - { - let __a1 = 1; - (*v.borrow_mut()).push(__a1) - }; - { - let __a1 = 2; - (*v.borrow_mut()).push(__a1) - }; - { - let __a1 = 3; - (*v.borrow_mut()).push(__a1) - }; + ({ + let __tmp_0: Value = Rc::new(RefCell::new(1)); + { + let __a1 = move_constructed(&__tmp_0.as_pointer()); + (*v.borrow_mut()).push(__a1) + } + }); + ({ + let __tmp_1: Value = Rc::new(RefCell::new(2)); + { + let __a1 = move_constructed(&__tmp_1.as_pointer()); + (*v.borrow_mut()).push(__a1) + } + }); + ({ + let __tmp_2: Value = Rc::new(RefCell::new(3)); + { + let __a1 = move_constructed(&__tmp_2.as_pointer()); + (*v.borrow_mut()).push(__a1) + } + }); let v_begin: Value> = Rc::new(RefCell::new(v.decay().begin())); let v_end: Value> = Rc::new(RefCell::new(v.decay().end())); let it: Value> = Rc::new(RefCell::new( ({ - let __tmp_1: Value = Rc::new(RefCell::new(2)); + let __tmp_4: Value = Rc::new(RefCell::new(2)); { - let mut __tmp_0 = { (*v_end.borrow()).clone() }; + let mut __tmp_3 = { (*v_end.borrow()).clone() }; let mut __it = ({ (*v_begin.borrow()).clone() }); - while __it != __tmp_0 && !CppEq::equal(&__it.iter_deref(), &__tmp_1.as_pointer()) { + while __it != __tmp_3 && !CppEq::equal(&__it.iter_deref(), &__tmp_4.as_pointer()) { __it.iter_inc(); } __it @@ -65,20 +74,20 @@ fn main_0() -> i32 { let mut v_result_true: bool = (*it.borrow()) != v.decay().end(); let m: Value, Value)>> = Rc::new(RefCell::new(Map::new())); match (Rc::new(RefCell::new(1)).as_pointer(),) { - (__tmp_2,) => { - ({ (*m.borrow_mut()).subscript_move(__tmp_2, |__k| cpp_move!(__k), || 0_f64) }) + (__tmp_5,) => { + ({ (*m.borrow_mut()).subscript_move(__tmp_5, |__k| cpp_move!(__k), || 0_f64) }) } } .write(1_f64); match (Rc::new(RefCell::new(2)).as_pointer(),) { - (__tmp_3,) => { - ({ (*m.borrow_mut()).subscript_move(__tmp_3, |__k| cpp_move!(__k), || 0_f64) }) + (__tmp_6,) => { + ({ (*m.borrow_mut()).subscript_move(__tmp_6, |__k| cpp_move!(__k), || 0_f64) }) } } .write(2_f64); match (Rc::new(RefCell::new(3)).as_pointer(),) { - (__tmp_4,) => { - ({ (*m.borrow_mut()).subscript_move(__tmp_4, |__k| cpp_move!(__k), || 0_f64) }) + (__tmp_7,) => { + ({ (*m.borrow_mut()).subscript_move(__tmp_7, |__k| cpp_move!(__k), || 0_f64) }) } } .write(3_f64); @@ -94,13 +103,13 @@ fn main_0() -> i32 { assert!( ((v_result_true) && (m_result_true)) && (({ - let __tmp_7: Value = Rc::new(RefCell::new(2)); + let __tmp_10: Value = Rc::new(RefCell::new(2)); { - let mut __tmp_5 = { v.decay().begin() }; - let mut __tmp_6 = { v.decay().begin() }; - let mut __it = (__tmp_5).clone(); - while __it != __tmp_6 - && !CppEq::equal(&__it.iter_deref(), &__tmp_7.as_pointer()) + let mut __tmp_8 = { v.decay().begin() }; + let mut __tmp_9 = { v.decay().begin() }; + let mut __it = (__tmp_8).clone(); + while __it != __tmp_9 + && !CppEq::equal(&__it.iter_deref(), &__tmp_10.as_pointer()) { __it.iter_inc(); } @@ -111,12 +120,13 @@ fn main_0() -> i32 { let w: Value> = Rc::new(RefCell::new(Vec::from([1, 2, 3, 4, 5]))); assert!( ({ - let __tmp_10: Value = Rc::new(RefCell::new(4)); + let __tmp_13: Value = Rc::new(RefCell::new(4)); { - let mut __tmp_8 = { w.decay().begin().iter_add(2_isize) }; - let mut __tmp_9 = { w.decay().end() }; - let mut __it = (__tmp_8).clone(); - while __it != __tmp_9 && !CppEq::equal(&__it.iter_deref(), &__tmp_10.as_pointer()) { + let mut __tmp_11 = { w.decay().begin().iter_add(2_isize) }; + let mut __tmp_12 = { w.decay().end() }; + let mut __it = (__tmp_11).clone(); + while __it != __tmp_12 && !CppEq::equal(&__it.iter_deref(), &__tmp_13.as_pointer()) + { __it.iter_inc(); } __it @@ -125,12 +135,12 @@ fn main_0() -> i32 { ); assert!( ({ - let __tmp_13: Value = Rc::new(RefCell::new(1)); + let __tmp_16: Value = Rc::new(RefCell::new(1)); { - let mut __tmp_11 = { w.decay().begin().iter_add(2_isize) }; - let mut __tmp_12 = { w.decay().end() }; - let mut __it = (__tmp_11).clone(); - while __it != __tmp_12 && !CppEq::equal(&__it.iter_deref(), &__tmp_13.as_pointer()) + let mut __tmp_14 = { w.decay().begin().iter_add(2_isize) }; + let mut __tmp_15 = { w.decay().end() }; + let mut __it = (__tmp_14).clone(); + while __it != __tmp_15 && !CppEq::equal(&__it.iter_deref(), &__tmp_16.as_pointer()) { __it.iter_inc(); } @@ -140,12 +150,12 @@ fn main_0() -> i32 { ); assert!( ({ - let __tmp_16: Value = Rc::new(RefCell::new(5)); + let __tmp_19: Value = Rc::new(RefCell::new(5)); { - let mut __tmp_14 = { w.decay().begin().iter_add(2_isize) }; - let mut __tmp_15 = { w.decay().begin().iter_add(4_isize) }; - let mut __it = (__tmp_14).clone(); - while __it != __tmp_15 && !CppEq::equal(&__it.iter_deref(), &__tmp_16.as_pointer()) + let mut __tmp_17 = { w.decay().begin().iter_add(2_isize) }; + let mut __tmp_18 = { w.decay().begin().iter_add(4_isize) }; + let mut __it = (__tmp_17).clone(); + while __it != __tmp_18 && !CppEq::equal(&__it.iter_deref(), &__tmp_19.as_pointer()) { __it.iter_inc(); } @@ -160,13 +170,13 @@ fn main_0() -> i32 { ]))); assert!( ({ - let __tmp_19: Value

= Rc::new(RefCell::new(P { x: 1 })); + let __tmp_22: Value

= Rc::new(RefCell::new(P { x: 1 })); { - let mut __tmp_17 = { p.decay().begin() }; - let mut __tmp_18 = { p.decay().end() }; - let mut __it = (__tmp_17).clone(); - while __it != __tmp_18 - && !CppEq::equal(&__it.iter_deref(), &(__tmp_19.as_pointer())) + let mut __tmp_20 = { p.decay().begin() }; + let mut __tmp_21 = { p.decay().end() }; + let mut __it = (__tmp_20).clone(); + while __it != __tmp_21 + && !CppEq::equal(&__it.iter_deref(), &(__tmp_22.as_pointer())) { __it.iter_inc(); } diff --git a/tests/unit/out/refcount/fn_ptr_stable_sort.rs b/tests/unit/out/refcount/fn_ptr_stable_sort.rs index c8dc28c3fa..fa30c29725 100644 --- a/tests/unit/out/refcount/fn_ptr_stable_sort.rs +++ b/tests/unit/out/refcount/fn_ptr_stable_sort.rs @@ -38,25 +38,34 @@ pub fn main() { } fn main_0() -> i32 { let v: Value> = Rc::new(RefCell::new(Vec::new())); + ({ + let __tmp_0: Value = Rc::new(RefCell::new(Item { key: 3, value: 30 })); + { + let __a1 = move_constructed(&(__tmp_0.as_pointer())); + (*v.borrow_mut()).push(__a1) + } + }); + ({ + let __tmp_1: Value = Rc::new(RefCell::new(Item { key: 1, value: 10 })); + { + let __a1 = move_constructed(&(__tmp_1.as_pointer())); + (*v.borrow_mut()).push(__a1) + } + }); + ({ + let __tmp_2: Value = Rc::new(RefCell::new(Item { key: 2, value: 20 })); + { + let __a1 = move_constructed(&(__tmp_2.as_pointer())); + (*v.borrow_mut()).push(__a1) + } + }); { - let __a1 = (Item { key: 3, value: 30 }); - (*v.borrow_mut()).push(__a1) - }; - { - let __a1 = (Item { key: 1, value: 10 }); - (*v.borrow_mut()).push(__a1) - }; - { - let __a1 = (Item { key: 2, value: 20 }); - (*v.borrow_mut()).push(__a1) - }; - { - let mut __tmp_0 = { v.decay().begin() }; - let __n = v.decay().end().iter_distance(&__tmp_0); + let mut __tmp_3 = { v.decay().begin() }; + let __n = v.decay().end().iter_distance(&__tmp_3); let mut __order: Vec = (0..__n).collect(); __order.sort_by(|&__x, &__y| { - let __a = __tmp_0.iter_at(__x); - let __b = __tmp_0.iter_at(__y); + let __a = __tmp_3.iter_at(__x); + let __b = __tmp_3.iter_at(__y); if Compare_0.call(__a.clone(), __b.clone()) { std::cmp::Ordering::Less } else if Compare_0.call(__b, __a) { @@ -65,18 +74,18 @@ fn main_0() -> i32 { std::cmp::Ordering::Equal } }); - reorder(__order, |__i| __tmp_0.iter_at(__i)); + reorder(__order, |__i| __tmp_3.iter_at(__i)); }; assert!(({ { (*v.borrow())[0_usize] }.key } == 1)); assert!(({ { (*v.borrow())[1_usize] }.key } == 2)); assert!(({ { (*v.borrow())[2_usize] }.key } == 3)); { - let mut __tmp_1 = { v.decay().begin() }; - let __n = v.decay().end().iter_distance(&__tmp_1); + let mut __tmp_4 = { v.decay().begin() }; + let __n = v.decay().end().iter_distance(&__tmp_4); let mut __order: Vec = (0..__n).collect(); __order.sort_by(|&__x, &__y| { - let __a = __tmp_1.iter_at(__x); - let __b = __tmp_1.iter_at(__y); + let __a = __tmp_4.iter_at(__x); + let __b = __tmp_4.iter_at(__y); if CompareDesc_1.call(__a.clone(), __b.clone()) { std::cmp::Ordering::Less } else if CompareDesc_1.call(__b, __a) { @@ -85,7 +94,7 @@ fn main_0() -> i32 { std::cmp::Ordering::Equal } }); - reorder(__order, |__i| __tmp_1.iter_at(__i)); + reorder(__order, |__i| __tmp_4.iter_at(__i)); }; assert!(({ { (*v.borrow())[0_usize] }.key } == 3)); assert!(({ { (*v.borrow())[1_usize] }.key } == 2)); diff --git a/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs b/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs index becc3fb3a8..7641eee94d 100644 --- a/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs +++ b/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs @@ -41,10 +41,13 @@ pub fn main() { fn main_0() -> i32 { let s: Value = Rc::new(RefCell::new(::zero_init())); DefaultConstructible::default_constructor(&s.as_pointer()); - { - let __a1 = 1; - (*s.borrow_mut()).v.push(__a1) - }; + ({ + let __tmp_0: Value = Rc::new(RefCell::new(1)); + { + let __a1 = move_constructed(&__tmp_0.as_pointer()); + (*s.borrow_mut()).v.push(__a1) + } + }); 'loop_: for e in IterRange::new( field_ref!(s.as_pointer(), v).decay().begin(), field_ref!(s.as_pointer(), v).decay().end(), diff --git a/tests/unit/out/refcount/foreach_double.rs b/tests/unit/out/refcount/foreach_double.rs index f4fba80a0f..3a3ef13027 100644 --- a/tests/unit/out/refcount/foreach_double.rs +++ b/tests/unit/out/refcount/foreach_double.rs @@ -12,18 +12,27 @@ pub fn main() { } fn main_0() -> i32 { let v: Value> = Rc::new(RefCell::new(Vec::new())); - { - let __a1 = 1; - (*v.borrow_mut()).push(__a1) - }; - { - let __a1 = 2; - (*v.borrow_mut()).push(__a1) - }; - { - let __a1 = 3; - (*v.borrow_mut()).push(__a1) - }; + ({ + let __tmp_0: Value = Rc::new(RefCell::new(1)); + { + let __a1 = move_constructed(&__tmp_0.as_pointer()); + (*v.borrow_mut()).push(__a1) + } + }); + ({ + let __tmp_1: Value = Rc::new(RefCell::new(2)); + { + let __a1 = move_constructed(&__tmp_1.as_pointer()); + (*v.borrow_mut()).push(__a1) + } + }); + ({ + let __tmp_2: Value = Rc::new(RefCell::new(3)); + { + let __a1 = move_constructed(&__tmp_2.as_pointer()); + (*v.borrow_mut()).push(__a1) + } + }); let mut square: i32 = 0; 'loop_: for e1 in IterRange::new(v.decay().begin(), v.decay().end()) { let mut e1: i32 = (e1.iter_deref().read()); @@ -54,20 +63,26 @@ fn main_0() -> i32 { } } let m: Value>> = Rc::new(RefCell::new(Vec::new())); - let mut v1: Vec = Vec::new(); - { - let __a1 = std::mem::take(&mut v1); - (*m.borrow_mut()).push(__a1) + let v1: Value> = Rc::new(RefCell::new(Vec::new())); + match (v1.as_pointer(),) { + (__tmp_3,) => { + let __a1 = move_constructed(&__tmp_3); + (*m.borrow_mut()).push(__a1) + } }; - let mut v2: Vec = Vec::new(); - { - let __a1 = std::mem::take(&mut v2); - (*m.borrow_mut()).push(__a1) + let v2: Value> = Rc::new(RefCell::new(Vec::new())); + match (v2.as_pointer(),) { + (__tmp_4,) => { + let __a1 = move_constructed(&__tmp_4); + (*m.borrow_mut()).push(__a1) + } }; - let mut v3: Vec = Vec::new(); - { - let __a1 = std::mem::take(&mut v3); - (*m.borrow_mut()).push(__a1) + let v3: Value> = Rc::new(RefCell::new(Vec::new())); + match (v3.as_pointer(),) { + (__tmp_5,) => { + let __a1 = move_constructed(&__tmp_5); + (*m.borrow_mut()).push(__a1) + } }; 'loop_: for row in IterRange::new(m.decay().begin(), m.decay().end()) { let row: Ptr> = row.iter_deref(); diff --git a/tests/unit/out/refcount/foreach_mut.rs b/tests/unit/out/refcount/foreach_mut.rs index efd8652ead..ce4fdccbe7 100644 --- a/tests/unit/out/refcount/foreach_mut.rs +++ b/tests/unit/out/refcount/foreach_mut.rs @@ -12,18 +12,27 @@ pub fn main() { } fn main_0() -> i32 { let v1: Value> = Rc::new(RefCell::new(Vec::new())); - { - let __a1 = 1; - (*v1.borrow_mut()).push(__a1) - }; - { - let __a1 = 2; - (*v1.borrow_mut()).push(__a1) - }; - { - let __a1 = 3; - (*v1.borrow_mut()).push(__a1) - }; + ({ + let __tmp_0: Value = Rc::new(RefCell::new(1)); + { + let __a1 = move_constructed(&__tmp_0.as_pointer()); + (*v1.borrow_mut()).push(__a1) + } + }); + ({ + let __tmp_1: Value = Rc::new(RefCell::new(2)); + { + let __a1 = move_constructed(&__tmp_1.as_pointer()); + (*v1.borrow_mut()).push(__a1) + } + }); + ({ + let __tmp_2: Value = Rc::new(RefCell::new(3)); + { + let __a1 = move_constructed(&__tmp_2.as_pointer()); + (*v1.borrow_mut()).push(__a1) + } + }); let mut sum: i32 = 0; 'loop_: for x in IterRange::new(v1.decay().begin(), v1.decay().end()) { let mut x: i32 = (x.iter_deref().read()); @@ -44,17 +53,23 @@ fn main_0() -> i32 { sum += (x.read()); } let v2: Value>> = Rc::new(RefCell::new(Vec::new())); - { - let __a1 = (v1.decay().offset(0_usize)); - (*v2.borrow_mut()).push(__a1) + match (Rc::new(RefCell::new((v1.decay().offset(0_usize)))).as_pointer(),) { + (__tmp_3,) => { + let __a1 = move_constructed(&(__tmp_3).clone()); + (*v2.borrow_mut()).push(__a1) + } }; - { - let __a1 = (v1.decay().offset(1_usize)); - (*v2.borrow_mut()).push(__a1) + match (Rc::new(RefCell::new((v1.decay().offset(1_usize)))).as_pointer(),) { + (__tmp_4,) => { + let __a1 = move_constructed(&(__tmp_4).clone()); + (*v2.borrow_mut()).push(__a1) + } }; - { - let __a1 = (v1.decay().offset(2_usize)); - (*v2.borrow_mut()).push(__a1) + match (Rc::new(RefCell::new((v1.decay().offset(2_usize)))).as_pointer(),) { + (__tmp_5,) => { + let __a1 = move_constructed(&(__tmp_5).clone()); + (*v2.borrow_mut()).push(__a1) + } }; 'loop_: for p in IterRange::new(v2.decay().begin(), v2.decay().end()) { let mut p: Ptr = (p.iter_deref().read()); diff --git a/tests/unit/out/refcount/implicit_autoref.rs b/tests/unit/out/refcount/implicit_autoref.rs index 2416d2bca3..57abc7bd7a 100644 --- a/tests/unit/out/refcount/implicit_autoref.rs +++ b/tests/unit/out/refcount/implicit_autoref.rs @@ -40,27 +40,39 @@ pub fn main() { } fn main_0() -> i32 { let v: Value> = Rc::new(RefCell::new(Vec::new())); - { - let __a1 = 10; - (*v.borrow_mut()).push(__a1) - }; - { - let __a1 = 20; - (*v.borrow_mut()).push(__a1) - }; + ({ + let __tmp_0: Value = Rc::new(RefCell::new(10)); + { + let __a1 = move_constructed(&__tmp_0.as_pointer()); + (*v.borrow_mut()).push(__a1) + } + }); + ({ + let __tmp_1: Value = Rc::new(RefCell::new(20)); + { + let __a1 = move_constructed(&__tmp_1.as_pointer()); + (*v.borrow_mut()).push(__a1) + } + }); let mut p: Ptr> = (v.as_pointer()); let mut a: i32 = (index!(p, 0_usize).read()); index!(p, 1_usize).write(30); let h: Value = Rc::new(RefCell::new(::zero_init())); DefaultConstructible::default_constructor(&h.as_pointer()); - { - let __a1 = 40; - (*h.borrow_mut()).v.push(__a1) - }; - { - let __a1 = 50; - (*h.borrow_mut()).v.push(__a1) - }; + ({ + let __tmp_2: Value = Rc::new(RefCell::new(40)); + { + let __a1 = move_constructed(&__tmp_2.as_pointer()); + (*h.borrow_mut()).v.push(__a1) + } + }); + ({ + let __tmp_3: Value = Rc::new(RefCell::new(50)); + { + let __a1 = move_constructed(&__tmp_3.as_pointer()); + (*h.borrow_mut()).v.push(__a1) + } + }); let mut hp: Ptr = (h.as_pointer()); let mut b: i32 = (vec_elem!((hp), v, 0_usize).read()); vec_elem!((hp), v, 1_usize).write(60); diff --git a/tests/unit/out/refcount/inline_container_fields.rs b/tests/unit/out/refcount/inline_container_fields.rs index 9e363fbfcf..11f6bccf82 100644 --- a/tests/unit/out/refcount/inline_container_fields.rs +++ b/tests/unit/out/refcount/inline_container_fields.rs @@ -156,9 +156,11 @@ pub fn fill_1(mut s: Ptr) { i.prefix_inc(); } } - { - let __a1 = Vec::from([1, 2, 3]); - field!(s, rows).with_mut(|__v: &mut Vec>| __v.push(__a1)) + match (Rc::new(RefCell::new(Vec::from([1, 2, 3]))).as_pointer(),) { + (__tmp_0,) => { + let __a1 = move_constructed(&(__tmp_0).clone()); + field!(s, rows).with_mut(|__v: &mut Vec>| __v.push(__a1)) + } }; } thread_local!( @@ -453,10 +455,13 @@ fn main_0() -> i32 { let va: Value]>> = Rc::new(RefCell::new(Box::<[Vec]>::from( std::array::from_fn::<_, 2, _>(|_| Default::default()), ))); - { - let __a1 = 1; - elem!(va.decay(), 0_usize).with_mut(|__v: &mut Vec| __v.push(__a1)) - }; + ({ + let __tmp_1: Value = Rc::new(RefCell::new(1)); + { + let __a1 = move_constructed(&__tmp_1.as_pointer()); + elem!(va.decay(), 0_usize).with_mut(|__v: &mut Vec| __v.push(__a1)) + } + }); let vb: Value]>> = Rc::new(RefCell::new({ let __v: Value]>> = Rc::new(RefCell::new( (0..2).map(|_| >::zero_init()).collect(), diff --git a/tests/unit/out/refcount/iterators.rs b/tests/unit/out/refcount/iterators.rs index 9ac5d8faac..e74063822b 100644 --- a/tests/unit/out/refcount/iterators.rs +++ b/tests/unit/out/refcount/iterators.rs @@ -40,13 +40,17 @@ fn main_0() -> i32 { printf!(b"%c\n", (c as i32)); } let v: Value>> = Rc::new(RefCell::new(Vec::new())); - { - let __a1 = Ptr::alloc(2); - (*v.borrow_mut()).push(__a1) + match (Rc::new(RefCell::new(Ptr::alloc(2))).as_pointer(),) { + (__tmp_0,) => { + let __a1 = move_constructed(&(__tmp_0).clone()); + (*v.borrow_mut()).push(__a1) + } }; - { - let __a1 = Ptr::alloc(3); - (*v.borrow_mut()).push(__a1) + match (Rc::new(RefCell::new(Ptr::alloc(3))).as_pointer(),) { + (__tmp_1,) => { + let __a1 = move_constructed(&(__tmp_1).clone()); + (*v.borrow_mut()).push(__a1) + } }; 'loop_: for p in IterRange::new(v.decay().begin(), v.decay().end()) { let mut p: Ptr = (p.iter_deref().read()); diff --git a/tests/unit/out/refcount/map.rs b/tests/unit/out/refcount/map.rs index 560aa8aeb7..c146fa66b2 100644 --- a/tests/unit/out/refcount/map.rs +++ b/tests/unit/out/refcount/map.rs @@ -502,10 +502,13 @@ fn main_0() -> i32 { let mut i: u32 = 60_u32; 'loop_: while (i > 30_u32) { 'for_body: { - { - let __a1 = (i as i32); - (*indexes.borrow_mut()).push(__a1) - }; + ({ + let __tmp_41: Value = Rc::new(RefCell::new((i as i32))); + { + let __a1 = move_constructed(&__tmp_41.as_pointer()); + (*indexes.borrow_mut()).push(__a1) + } + }); } i.prefix_dec(); } @@ -514,10 +517,13 @@ fn main_0() -> i32 { let mut i: u32 = 100_u32; 'loop_: while (i > 60_u32) { 'for_body: { - { - let __a1 = (i as i32); - (*indexes.borrow_mut()).push(__a1) - }; + ({ + let __tmp_42: Value = Rc::new(RefCell::new((i as i32))); + { + let __a1 = move_constructed(&__tmp_42.as_pointer()); + (*indexes.borrow_mut()).push(__a1) + } + }); } i.prefix_dec(); } @@ -526,10 +532,13 @@ fn main_0() -> i32 { let mut i: u32 = 30_u32; 'loop_: while (i > 0_u32) { 'for_body: { - { - let __a1 = (i as i32); - (*indexes.borrow_mut()).push(__a1) - }; + ({ + let __tmp_43: Value = Rc::new(RefCell::new((i as i32))); + { + let __a1 = move_constructed(&__tmp_43.as_pointer()); + (*indexes.borrow_mut()).push(__a1) + } + }); } i.prefix_dec(); } @@ -539,7 +548,7 @@ fn main_0() -> i32 { 'loop_: while ((i as usize) < (*indexes.borrow()).len()) { 'for_body: { match (indexes.decay().offset((i as usize)),) { - (__tmp_41,) => ({ (*m2.borrow_mut()).subscript(__tmp_41, || false) }), + (__tmp_44,) => ({ (*m2.borrow_mut()).subscript(__tmp_44, || false) }), } .write(((i).wrapping_rem(2_u32) != 0)); } @@ -570,9 +579,9 @@ fn main_0() -> i32 { Value, Value)>>, Value, )> = Rc::new(RefCell::new({ - let mut __tmp_42 = { (Rc::new(RefCell::new(1)), Rc::new(RefCell::new(2))) }; + let mut __tmp_45 = { (Rc::new(RefCell::new(1)), Rc::new(RefCell::new(2))) }; let (__it, __inserted) = - Map::emplace(m3.as_pointer(), &__tmp_42.0.as_pointer(), || __tmp_42); + Map::emplace(m3.as_pointer(), &__tmp_45.0.as_pointer(), || __tmp_45); ( Rc::new(RefCell::new(__it)), Rc::new(RefCell::new(__inserted)), @@ -593,9 +602,9 @@ fn main_0() -> i32 { Value, Value)>>, Value, )> = Rc::new(RefCell::new({ - let mut __tmp_43 = { (Rc::new(RefCell::new(1)), Rc::new(RefCell::new(3))) }; + let mut __tmp_46 = { (Rc::new(RefCell::new(1)), Rc::new(RefCell::new(3))) }; let (__it, __inserted) = - Map::emplace(m3.as_pointer(), &__tmp_43.0.as_pointer(), || __tmp_43); + Map::emplace(m3.as_pointer(), &__tmp_46.0.as_pointer(), || __tmp_46); ( Rc::new(RefCell::new(__it)), Rc::new(RefCell::new(__inserted)), @@ -613,25 +622,25 @@ fn main_0() -> i32 { }) ); { - let mut __tmp_45 = { + let mut __tmp_48 = { match (Rc::new(RefCell::new(( Rc::new(RefCell::new(4)), Rc::new(RefCell::new(5)), ))) .as_pointer(),) { - (__tmp_44,) => ( + (__tmp_47,) => ( Rc::new(RefCell::new( - ((*__tmp_44.upgrade().deref()).0.as_pointer().read()), + ((*__tmp_47.upgrade().deref()).0.as_pointer().read()), )), Rc::new(RefCell::new( - ((*__tmp_44.upgrade().deref()).1.as_pointer().read()), + ((*__tmp_47.upgrade().deref()).1.as_pointer().read()), )), ), } }; let (__it, __inserted) = - Map::emplace(m3.as_pointer(), &__tmp_45.0.as_pointer(), || __tmp_45); + Map::emplace(m3.as_pointer(), &__tmp_48.0.as_pointer(), || __tmp_48); ( Rc::new(RefCell::new(__it)), Rc::new(RefCell::new(__inserted)), @@ -640,8 +649,8 @@ fn main_0() -> i32 { assert!(({ ((*m3.borrow()).len() == 2_usize) })); assert!( ((match (Rc::new(RefCell::new(1)).as_pointer(),) { - (__tmp_46,) => { - ({ (*m3.borrow_mut()).subscript_move(__tmp_46, |__k| cpp_move!(__k), || 0_i32) }) + (__tmp_49,) => { + ({ (*m3.borrow_mut()).subscript_move(__tmp_49, |__k| cpp_move!(__k), || 0_i32) }) } } .read()) @@ -649,23 +658,23 @@ fn main_0() -> i32 { ); assert!( ((match (Rc::new(RefCell::new(4)).as_pointer(),) { - (__tmp_47,) => { - ({ (*m3.borrow_mut()).subscript_move(__tmp_47, |__k| cpp_move!(__k), || 0_i32) }) + (__tmp_50,) => { + ({ (*m3.borrow_mut()).subscript_move(__tmp_50, |__k| cpp_move!(__k), || 0_i32) }) } } .read()) == 5) ); let hinted: Value, Value)>> = Rc::new(RefCell::new({ - let mut __tmp_48 = { + let mut __tmp_51 = { , Value)>>::from( m3.as_pointer() .with(|__m: &Map, Value)>| __m.end()), ) }; - let mut __tmp_49 = { (Rc::new(RefCell::new(6)), Rc::new(RefCell::new(7))) }; - let _ = (__tmp_48).clone(); - Map::emplace(m3.as_pointer(), &__tmp_49.0.as_pointer(), || __tmp_49).0 + let mut __tmp_52 = { (Rc::new(RefCell::new(6)), Rc::new(RefCell::new(7))) }; + let _ = (__tmp_51).clone(); + Map::emplace(m3.as_pointer(), &__tmp_52.0.as_pointer(), || __tmp_52).0 })); assert!( ({ @@ -721,8 +730,8 @@ fn main_0() -> i32 { assert!(({ ((*(*tried_new.borrow()).1.borrow()) as bool) })); assert!( ((match (Rc::new(RefCell::new(8)).as_pointer(),) { - (__tmp_50,) => { - ({ (*m3.borrow_mut()).subscript_move(__tmp_50, |__k| cpp_move!(__k), || 0_i32) }) + (__tmp_53,) => { + ({ (*m3.borrow_mut()).subscript_move(__tmp_53, |__k| cpp_move!(__k), || 0_i32) }) } } .read()) @@ -752,10 +761,10 @@ fn main_0() -> i32 { assert!(({ ((*(*point_new.borrow()).1.borrow()) as bool) })); assert!( (match (Rc::new(RefCell::new(1)).as_pointer(),) { - (__tmp_51,) => { + (__tmp_54,) => { ({ (*points.borrow_mut()).subscript_move( - __tmp_51, + __tmp_54, |__k| cpp_move!(__k), || ::default(), ) @@ -767,10 +776,10 @@ fn main_0() -> i32 { ); assert!( (match (Rc::new(RefCell::new(1)).as_pointer(),) { - (__tmp_52,) => { + (__tmp_55,) => { ({ (*points.borrow_mut()).subscript_move( - __tmp_52, + __tmp_55, |__k| cpp_move!(__k), || ::default(), ) @@ -781,7 +790,7 @@ fn main_0() -> i32 { == 4) ); { - let mut __tmp_53 = { + let mut __tmp_56 = { ( Rc::new(RefCell::new(({ (*key8.borrow()) }))), Rc::new(RefCell::new({ @@ -792,7 +801,7 @@ fn main_0() -> i32 { ) }; let (__it, __inserted) = - Map::emplace(points.as_pointer(), &__tmp_53.0.as_pointer(), || __tmp_53); + Map::emplace(points.as_pointer(), &__tmp_56.0.as_pointer(), || __tmp_56); ( Rc::new(RefCell::new(__it)), Rc::new(RefCell::new(__inserted)), @@ -800,10 +809,10 @@ fn main_0() -> i32 { }; assert!( (match (Rc::new(RefCell::new(8)).as_pointer(),) { - (__tmp_54,) => { + (__tmp_57,) => { ({ (*points.borrow_mut()).subscript_move( - __tmp_54, + __tmp_57, |__k| cpp_move!(__k), || ::default(), ) @@ -815,10 +824,10 @@ fn main_0() -> i32 { ); assert!( (match (Rc::new(RefCell::new(8)).as_pointer(),) { - (__tmp_55,) => { + (__tmp_58,) => { ({ (*points.borrow_mut()).subscript_move( - __tmp_55, + __tmp_58, |__k| cpp_move!(__k), || ::default(), ) @@ -861,9 +870,9 @@ fn main_0() -> i32 { ); k = 0; let value_0: Ptr = ({ - let __tmp_56: Value = Rc::new(RefCell::new((k as i16))); + let __tmp_59: Value = Rc::new(RefCell::new((k as i16))); (*m.borrow()) - .get(&__tmp_56.as_pointer()) + .get(&__tmp_59.as_pointer()) .expect("out of range!") .borrow() .1 @@ -902,10 +911,10 @@ fn main_0() -> i32 { ); { match (Rc::new(RefCell::new((pk2.as_pointer()))).as_pointer(),) { - (__tmp_57,) => { + (__tmp_60,) => { ({ (*ptr_counts.borrow_mut()).subscript_move( - __tmp_57, + __tmp_60, |__k| cpp_move!(__k), || 0_i32, ) @@ -916,10 +925,10 @@ fn main_0() -> i32 { }; assert!( ((match (Rc::new(RefCell::new((pk2.as_pointer()))).as_pointer(),) { - (__tmp_58,) => { + (__tmp_61,) => { ({ (*ptr_counts.borrow_mut()).subscript_move( - __tmp_58, + __tmp_61, |__k| cpp_move!(__k), || 0_i32, ) @@ -933,75 +942,75 @@ fn main_0() -> i32 { { let t: Value, Value)>> = Rc::new(RefCell::new(Map::new())); match (Rc::new(RefCell::new(1_i64)).as_pointer(),) { - (__tmp_59,) => { - ({ (*t.borrow_mut()).subscript_move(__tmp_59, |__k| cpp_move!(__k), || 0_i32) }) + (__tmp_62,) => { + ({ (*t.borrow_mut()).subscript_move(__tmp_62, |__k| cpp_move!(__k), || 0_i32) }) } } .write(5); { match (Rc::new(RefCell::new(2_i64)).as_pointer(),) { - (__tmp_60,) => { - ({ (*t.borrow_mut()).subscript_move(__tmp_60, |__k| cpp_move!(__k), || 0_i32) }) + (__tmp_63,) => { + ({ (*t.borrow_mut()).subscript_move(__tmp_63, |__k| cpp_move!(__k), || 0_i32) }) } } .with_mut(|__v| *__v = *__v + 3) }; match (Rc::new(RefCell::new(3_i64)).as_pointer(),) { - (__tmp_61,) => { - ({ (*t.borrow_mut()).subscript_move(__tmp_61, |__k| cpp_move!(__k), || 0_i32) }) + (__tmp_64,) => { + ({ (*t.borrow_mut()).subscript_move(__tmp_64, |__k| cpp_move!(__k), || 0_i32) }) } } .with_mut(|__v| __v.postfix_inc()); let r: Ptr = match (Rc::new(RefCell::new(1_i64)).as_pointer(),) { - (__tmp_62,) => { - ({ (*t.borrow_mut()).subscript_move(__tmp_62, |__k| cpp_move!(__k), || 0_i32) }) + (__tmp_65,) => { + ({ (*t.borrow_mut()).subscript_move(__tmp_65, |__k| cpp_move!(__k), || 0_i32) }) } }; r.write(6); let mut p: Ptr = (match (Rc::new(RefCell::new(2_i64)).as_pointer(),) { - (__tmp_63,) => { - ({ (*t.borrow_mut()).subscript_move(__tmp_63, |__k| cpp_move!(__k), || 0_i32) }) + (__tmp_66,) => { + ({ (*t.borrow_mut()).subscript_move(__tmp_66, |__k| cpp_move!(__k), || 0_i32) }) } }); p.write(4); ({ inc_2(match (Rc::new(RefCell::new(3_i64)).as_pointer(),) { - (__tmp_64,) => { - ({ (*t.borrow_mut()).subscript_move(__tmp_64, |__k| cpp_move!(__k), || 0_i32) }) + (__tmp_67,) => { + ({ (*t.borrow_mut()).subscript_move(__tmp_67, |__k| cpp_move!(__k), || 0_i32) }) } }) }); Swappable::swap( &match (Rc::new(RefCell::new(1_i64)).as_pointer(),) { - (__tmp_65,) => { - ({ (*t.borrow_mut()).subscript_move(__tmp_65, |__k| cpp_move!(__k), || 0_i32) }) + (__tmp_68,) => { + ({ (*t.borrow_mut()).subscript_move(__tmp_68, |__k| cpp_move!(__k), || 0_i32) }) } }, match (Rc::new(RefCell::new(2_i64)).as_pointer(),) { - (__tmp_66,) => { - ({ (*t.borrow_mut()).subscript_move(__tmp_66, |__k| cpp_move!(__k), || 0_i32) }) + (__tmp_69,) => { + ({ (*t.borrow_mut()).subscript_move(__tmp_69, |__k| cpp_move!(__k), || 0_i32) }) } }, ); let mut x: i32 = ((match (Rc::new(RefCell::new(1_i64)).as_pointer(),) { - (__tmp_67,) => { - ({ (*t.borrow_mut()).subscript_move(__tmp_67, |__k| cpp_move!(__k), || 0_i32) }) + (__tmp_70,) => { + ({ (*t.borrow_mut()).subscript_move(__tmp_70, |__k| cpp_move!(__k), || 0_i32) }) } } .read()) + (match (Rc::new(RefCell::new(2_i64)).as_pointer(),) { - (__tmp_68,) => { - ({ (*t.borrow_mut()).subscript_move(__tmp_68, |__k| cpp_move!(__k), || 0_i32) }) + (__tmp_71,) => { + ({ (*t.borrow_mut()).subscript_move(__tmp_71, |__k| cpp_move!(__k), || 0_i32) }) } } .read())); assert!( (((x == 10) && ((match (Rc::new(RefCell::new(1_i64)).as_pointer(),) { - (__tmp_69,) => { + (__tmp_72,) => { ({ (*t.borrow_mut()).subscript_move( - __tmp_69, + __tmp_72, |__k| cpp_move!(__k), || 0_i32, ) @@ -1011,10 +1020,10 @@ fn main_0() -> i32 { .read()) == 4)) && ((match (Rc::new(RefCell::new(2_i64)).as_pointer(),) { - (__tmp_70,) => { + (__tmp_73,) => { ({ (*t.borrow_mut()).subscript_move( - __tmp_70, + __tmp_73, |__k| cpp_move!(__k), || 0_i32, ) @@ -1024,10 +1033,10 @@ fn main_0() -> i32 { .read()) == 6)) && ((match (Rc::new(RefCell::new(3_i64)).as_pointer(),) { - (__tmp_71,) => { + (__tmp_74,) => { ({ (*t.borrow_mut()).subscript_move( - __tmp_71, + __tmp_74, |__k| cpp_move!(__k), || 0_i32, ) diff --git a/tests/unit/out/refcount/move_assign.rs b/tests/unit/out/refcount/move_assign.rs index dd2eb41520..e73c45e1d0 100644 --- a/tests/unit/out/refcount/move_assign.rs +++ b/tests/unit/out/refcount/move_assign.rs @@ -112,12 +112,17 @@ fn main_0() -> i32 { assert!(({ (*a.borrow()).v } == 6)); let vec_: Value> = Rc::new(RefCell::new(Vec::new())); { - let __a1 = { - let __v: Value = Rc::new(RefCell::new(::zero_init())); - MoveOnlyImpl::construct(&__v.as_pointer(), { 7 }); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }; - (*vec_.borrow_mut()).push(__a1) + let __tmp_1: Value = Rc::new(RefCell::new(::zero_init())); + match ({ + MoveOnlyImpl::construct(&__tmp_1.as_pointer(), { 7 }); + __tmp_1.as_pointer() + },) + { + (__tmp_0,) => { + let __a1 = move_constructed(&(__tmp_0).clone()); + (*vec_.borrow_mut()).push(__a1) + } + } }; let d: Value = Rc::new(RefCell::new(::zero_init())); MoveOnlyImpl::construct(&d.as_pointer(), { 8 }); diff --git a/tests/unit/out/refcount/move_ctor.rs b/tests/unit/out/refcount/move_ctor.rs index c0c4196664..1db2bf956f 100644 --- a/tests/unit/out/refcount/move_ctor.rs +++ b/tests/unit/out/refcount/move_ctor.rs @@ -204,21 +204,22 @@ fn main_0() -> i32 { assert!(({ (*e.borrow()).v } == 0)); let mut vec_: Vec = Vec::new(); { - let __a1 = { - let __v: Value = Rc::new(RefCell::new(::zero_init())); - MoveOnlyImpl::construct(&__v.as_pointer(), { 7 }); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }; - vec_.push(__a1) + let __tmp_1: Value = Rc::new(RefCell::new(::zero_init())); + match ({ + MoveOnlyImpl::construct(&__tmp_1.as_pointer(), { 7 }); + __tmp_1.as_pointer() + },) + { + (__tmp_0,) => { + let __a1 = move_constructed(&(__tmp_0).clone()); + vec_.push(__a1) + } + } }; let f: Value = Rc::new(RefCell::new(::zero_init())); MoveOnlyImpl::construct(&f.as_pointer(), { 8 }); { - let __a1 = { - let __v: Value = Rc::new(RefCell::new(::zero_init())); - MoveConstructible::move_constructor(&__v.as_pointer(), { f.as_pointer() }); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }; + let __a1 = move_constructed(&f.as_pointer()); vec_.push(__a1) }; assert!((vec_[0_usize].v == 7) && (vec_[1_usize].v == 8)); diff --git a/tests/unit/out/refcount/push_emplace_back.rs b/tests/unit/out/refcount/push_emplace_back.rs index 71fe867b7b..ed6ef8e747 100644 --- a/tests/unit/out/refcount/push_emplace_back.rs +++ b/tests/unit/out/refcount/push_emplace_back.rs @@ -75,9 +75,11 @@ impl DefaultConstructible for JPEGData { } } pub fn push_param_0(mut dest: Ptr>>) { - { - let __a1 = Vec::new(); - dest.with_mut(|__v: &mut Vec>| __v.push(__a1)) + match (Rc::new(RefCell::new(Vec::new())).as_pointer(),) { + (__tmp_0,) => { + let __a1 = move_constructed(&(__tmp_0).clone()); + dest.with_mut(|__v: &mut Vec>| __v.push(__a1)) + } }; } pub fn push_local_from_field_1(mut jpg: Ptr, mut cond: bool) { @@ -88,28 +90,34 @@ pub fn push_local_from_field_1(mut jpg: Ptr, mut cond: bool) { } else { dest = (field_ref!(jpg, app_data).as_pointer()); } + match (Rc::new(RefCell::new({ + let mut __tmp_2 = { head.decay().offset((3) as isize) }; + let mut __v = Vec::new(); + let mut __it = head.decay(); + while __it != __tmp_2 { + __v.push((__it.iter_deref().read())); + __it.iter_inc(); + } + __v + })) + .as_pointer(),) { - let __a1 = { - let mut __tmp_0 = { head.decay().offset((3) as isize) }; - let mut __v = Vec::new(); - let mut __it = head.decay(); - while __it != __tmp_0 { - __v.push((__it.iter_deref().read())); - __it.iter_inc(); - } - __v - }; - dest.with_mut(|__v: &mut Vec>| __v.push(__a1)) + (__tmp_1,) => { + let __a1 = move_constructed(&(__tmp_1).clone()); + dest.with_mut(|__v: &mut Vec>| __v.push(__a1)) + } }; } pub fn shrink_through_ptr_2(mut comps: Ptr>) { comps.with_mut(|__v: &mut Vec| __v.shrink_to_fit()); } pub fn nested_push_move_3(mut bw: Ptr) { - { - let __a1 = bw.with(|__s| __s.chunk); - bw.with(|__s| __s.output.clone()) - .with_mut(|__v: &mut Vec| __v.push(__a1)) + match (field_ptr!(bw, chunk),) { + (__tmp_3,) => { + let __a1 = move_constructed(&__tmp_3); + bw.with(|__s| __s.output.clone()) + .with_mut(|__v: &mut Vec| __v.push(__a1)) + } }; } pub fn emplace_local_from_field_4(mut jpg: Ptr, mut cond: bool) { @@ -123,10 +131,10 @@ pub fn emplace_local_from_field_4(mut jpg: Ptr, mut cond: bool) { { dest.with_mut(|__v: &mut Vec>| { __v.push({ - let mut __tmp_1 = { head.decay().offset((3) as isize) }; + let mut __tmp_4 = { head.decay().offset((3) as isize) }; let mut __v = Vec::new(); let mut __it = head.decay(); - while __it != __tmp_1 { + while __it != __tmp_4 { __v.push((__it.iter_deref().read())); __it.iter_inc(); } @@ -137,9 +145,9 @@ pub fn emplace_local_from_field_4(mut jpg: Ptr, mut cond: bool) { } pub fn nested_emplace_move_5(mut bw: Ptr) { { - let mut __tmp_2 = { bw.with(|__s| __s.output.clone()) }; - let mut __tmp_3 = { bw.with(|__s| __s.chunk) }; - __tmp_2.with_mut(|__v: &mut Vec| __v.push(__tmp_3)); + let mut __tmp_5 = { bw.with(|__s| __s.output.clone()) }; + let mut __tmp_6 = { bw.with(|__s| __s.chunk) }; + __tmp_5.with_mut(|__v: &mut Vec| __v.push(__tmp_6)); }; } pub fn self_ref_push_6(mut comps: Ptr>) { @@ -187,36 +195,36 @@ pub fn emplace_ctor_args_7(mut pairs: Ptr>) { }); }; { - let mut __tmp_4 = { + let mut __tmp_7 = { { let __v: Value = Rc::new(RefCell::new(::zero_init())); PairImpl::construct_1(&__v.as_pointer(), { 3 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() } }; - pairs.with_mut(|__v: &mut Vec| __v.push(__tmp_4)); + pairs.with_mut(|__v: &mut Vec| __v.push(__tmp_7)); }; { - let mut __tmp_5 = { + let mut __tmp_8 = { { let __v: Value = Rc::new(RefCell::new(::zero_init())); PairImpl::construct_2(&__v.as_pointer(), { 4 }, { 5 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() } }; - pairs.with_mut(|__v: &mut Vec| __v.push(__tmp_5)); + pairs.with_mut(|__v: &mut Vec| __v.push(__tmp_8)); }; } pub fn emplace_deque_8(mut queue: Ptr>) { { - let mut __tmp_6 = { + let mut __tmp_9 = { { let __v: Value = Rc::new(RefCell::new(::zero_init())); PairImpl::construct_2(&__v.as_pointer(), { 6 }, { 7 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() } }; - queue.with_mut(|__v: &mut Vec| __v.push(__tmp_6)); + queue.with_mut(|__v: &mut Vec| __v.push(__tmp_9)); }; { queue.with_mut(|__v: &mut Vec| { @@ -239,7 +247,7 @@ pub fn emplace_scalar_9(mut values: Ptr>, x: i32) { } pub fn emplace_ref_through_ptr_10(mut pairs: Ptr>) { let p: Ptr = { - let mut __tmp_7 = { + let mut __tmp_10 = { { let __v: Value = Rc::new(RefCell::new(::zero_init())); PairImpl::construct_2(&__v.as_pointer(), { 1 }, { 2 }); @@ -247,7 +255,7 @@ pub fn emplace_ref_through_ptr_10(mut pairs: Ptr>) { } }; pairs.with_mut(|__b0| { - (*__b0).push(__tmp_7); + (*__b0).push(__tmp_10); let __n = (*__b0).len() - 1; pairs.decay().offset((__n) as isize) }) @@ -256,7 +264,7 @@ pub fn emplace_ref_through_ptr_10(mut pairs: Ptr>) { { field!( { - let mut __tmp_8 = { + let mut __tmp_11 = { { let __v: Value = Rc::new(RefCell::new(::zero_init())); PairImpl::construct_1(&__v.as_pointer(), { 4 }); @@ -264,7 +272,7 @@ pub fn emplace_ref_through_ptr_10(mut pairs: Ptr>) { } }; pairs.with_mut(|__b0| { - (*__b0).push(__tmp_8); + (*__b0).push(__tmp_11); let __n = (*__b0).len() - 1; pairs.decay().offset((__n) as isize) }) @@ -283,15 +291,15 @@ pub fn emplace_addr_11(values: Ptr>) -> Ptr { } pub fn emplace_self_reads_12(mut values: Ptr>, mut pairs: Ptr>) { { - let mut __tmp_9 = { (((*values.upgrade().deref()).len()) as i64) }; - values.with_mut(|__v: &mut Vec| __v.push(__tmp_9)); + let mut __tmp_12 = { (((*values.upgrade().deref()).len()) as i64) }; + values.with_mut(|__v: &mut Vec| __v.push(__tmp_12)); }; { - let mut __tmp_10 = { index!(pairs, 0_usize).read() }; - pairs.with_mut(|__v: &mut Vec| __v.push(__tmp_10)); + let mut __tmp_13 = { index!(pairs, 0_usize).read() }; + pairs.with_mut(|__v: &mut Vec| __v.push(__tmp_13)); }; { - let mut __tmp_11 = { + let mut __tmp_14 = { { let __v: Value = Rc::new(RefCell::new(::zero_init())); PairImpl::construct_2( @@ -312,14 +320,14 @@ pub fn emplace_self_reads_12(mut values: Ptr>, mut pairs: Ptr Rc::try_unwrap(__v).ok().unwrap().into_inner() } }; - pairs.with_mut(|__v: &mut Vec| __v.push(__tmp_11)); + pairs.with_mut(|__v: &mut Vec| __v.push(__tmp_14)); }; } pub fn emplace_ref_self_read_13(values: Ptr>) -> Ptr { return { - let mut __tmp_12 = { (values.decay().read()) }; + let mut __tmp_15 = { (values.decay().read()) }; values.with_mut(|__b0| { - (*__b0).push(__tmp_12); + (*__b0).push(__tmp_15); let __n = (*__b0).len() - 1; values.decay().offset((__n) as isize) }) @@ -367,19 +375,19 @@ impl Default for Bytes { pub fn emplace_from_element_14(mut v: Ptr>>) { let p: Value> = Rc::new(RefCell::new((v).decay().offset(0_usize).decay())); { - let mut __tmp_14 = { + let mut __tmp_17 = { { - let mut __tmp_13 = { (*p.borrow()).offset((3) as isize) }; + let mut __tmp_16 = { (*p.borrow()).offset((3) as isize) }; let mut __v = Vec::new(); let mut __it = ({ (*p.borrow()).clone() }); - while __it != __tmp_13 { + while __it != __tmp_16 { __v.push((__it.iter_deref().read())); __it.iter_inc(); } __v } }; - v.with_mut(|__v: &mut Vec>| __v.push(__tmp_14)); + v.with_mut(|__v: &mut Vec>| __v.push(__tmp_17)); }; } #[derive( @@ -438,33 +446,33 @@ pub struct Counted { impl Counted {} pub fn emplace_counted_17(mut v: Ptr>) { { - let mut __tmp_15 = { + let mut __tmp_18 = { { let __v: Value = Rc::new(RefCell::new(::zero_init())); CountedImpl::construct(&__v.as_pointer(), { 1 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() } }; - v.with_mut(|__v: &mut Vec| __v.push(__tmp_15)); + v.with_mut(|__v: &mut Vec| __v.push(__tmp_18)); }; } pub fn emplace_from_sibling_18(mut s: Ptr) { let p: Value> = Rc::new(RefCell::new(array_field_ptr!(s, b))); let mut v: Ptr>> = (field_ref!(s, v).as_pointer()); { - let mut __tmp_17 = { + let mut __tmp_20 = { { - let mut __tmp_16 = { (*p.borrow()).offset((3) as isize) }; + let mut __tmp_19 = { (*p.borrow()).offset((3) as isize) }; let mut __v = Vec::new(); let mut __it = ({ (*p.borrow()).clone() }); - while __it != __tmp_16 { + while __it != __tmp_19 { __v.push((__it.iter_deref().read())); __it.iter_inc(); } __v } }; - v.with_mut(|__v: &mut Vec>| __v.push(__tmp_17)); + v.with_mut(|__v: &mut Vec>| __v.push(__tmp_20)); }; } pub fn main() { @@ -622,14 +630,14 @@ fn main_0() -> i32 { let self_values: Value> = Rc::new(RefCell::new(Vec::from([7_i64]))); let self_pairs: Value> = Rc::new(RefCell::new(Vec::new())); { - let mut __tmp_18 = { + let mut __tmp_21 = { { let __v: Value = Rc::new(RefCell::new(::zero_init())); PairImpl::construct_2(&__v.as_pointer(), { 1 }, { 2 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() } }; - (*self_pairs.borrow_mut()).push(__tmp_18); + (*self_pairs.borrow_mut()).push(__tmp_21); }; ({ emplace_self_reads_12((self_values.as_pointer()), (self_pairs.as_pointer())) }); { diff --git a/tests/unit/out/refcount/reinterpret_cast_vec_write.rs b/tests/unit/out/refcount/reinterpret_cast_vec_write.rs index 2d1a57c532..e16b4e230c 100644 --- a/tests/unit/out/refcount/reinterpret_cast_vec_write.rs +++ b/tests/unit/out/refcount/reinterpret_cast_vec_write.rs @@ -12,14 +12,20 @@ pub fn main() { } fn main_0() -> i32 { let vec_: Value> = Rc::new(RefCell::new(Vec::new())); - { - let __a1 = 67305985_u32; - (*vec_.borrow_mut()).push(__a1) - }; - { - let __a1 = 134678021_u32; - (*vec_.borrow_mut()).push(__a1) - }; + ({ + let __tmp_0: Value = Rc::new(RefCell::new(67305985_u32)); + { + let __a1 = move_constructed(&__tmp_0.as_pointer()); + (*vec_.borrow_mut()).push(__a1) + } + }); + ({ + let __tmp_1: Value = Rc::new(RefCell::new(134678021_u32)); + { + let __a1 = move_constructed(&__tmp_1.as_pointer()); + (*vec_.borrow_mut()).push(__a1) + } + }); let mut bytes: Ptr = vec_.decay().reinterpret_cast::(); assert!((((elem!(bytes, 0).read()) as i32) == 1)); assert!((((elem!(bytes, 1).read()) as i32) == 2)); diff --git a/tests/unit/out/refcount/return_move.rs b/tests/unit/out/refcount/return_move.rs index a569922ac5..a0207c79d7 100644 --- a/tests/unit/out/refcount/return_move.rs +++ b/tests/unit/out/refcount/return_move.rs @@ -101,10 +101,13 @@ pub fn ret_vec_12(mut v: Vec) -> Vec { } pub fn ret_vec_local_13() -> Vec { let mut v: Vec = Vec::new(); - { - let __a1 = 1; - v.push(__a1) - }; + ({ + let __tmp_0: Value = Rc::new(RefCell::new(1)); + { + let __a1 = move_constructed(&__tmp_0.as_pointer()); + v.push(__a1) + } + }); return std::mem::take(&mut v); } pub fn ret_loop_14(mut n: Ptr) -> Ptr { diff --git a/tests/unit/out/refcount/sort.rs b/tests/unit/out/refcount/sort.rs index b1625696ab..49277e502c 100644 --- a/tests/unit/out/refcount/sort.rs +++ b/tests/unit/out/refcount/sort.rs @@ -12,52 +12,82 @@ pub fn main() { } fn main_0() -> i32 { let v: Value> = Rc::new(RefCell::new(Vec::new())); + ({ + let __tmp_0: Value = Rc::new(RefCell::new(10)); + { + let __a1 = move_constructed(&__tmp_0.as_pointer()); + (*v.borrow_mut()).push(__a1) + } + }); + ({ + let __tmp_1: Value = Rc::new(RefCell::new(1)); + { + let __a1 = move_constructed(&__tmp_1.as_pointer()); + (*v.borrow_mut()).push(__a1) + } + }); + ({ + let __tmp_2: Value = Rc::new(RefCell::new(9)); + { + let __a1 = move_constructed(&__tmp_2.as_pointer()); + (*v.borrow_mut()).push(__a1) + } + }); + ({ + let __tmp_3: Value = Rc::new(RefCell::new(2)); + { + let __a1 = move_constructed(&__tmp_3.as_pointer()); + (*v.borrow_mut()).push(__a1) + } + }); + ({ + let __tmp_4: Value = Rc::new(RefCell::new(8)); + { + let __a1 = move_constructed(&__tmp_4.as_pointer()); + (*v.borrow_mut()).push(__a1) + } + }); + ({ + let __tmp_5: Value = Rc::new(RefCell::new(3)); + { + let __a1 = move_constructed(&__tmp_5.as_pointer()); + (*v.borrow_mut()).push(__a1) + } + }); + ({ + let __tmp_6: Value = Rc::new(RefCell::new(7)); + { + let __a1 = move_constructed(&__tmp_6.as_pointer()); + (*v.borrow_mut()).push(__a1) + } + }); + ({ + let __tmp_7: Value = Rc::new(RefCell::new(4)); + { + let __a1 = move_constructed(&__tmp_7.as_pointer()); + (*v.borrow_mut()).push(__a1) + } + }); + ({ + let __tmp_8: Value = Rc::new(RefCell::new(5)); + { + let __a1 = move_constructed(&__tmp_8.as_pointer()); + (*v.borrow_mut()).push(__a1) + } + }); + ({ + let __tmp_9: Value = Rc::new(RefCell::new(6)); + { + let __a1 = move_constructed(&__tmp_9.as_pointer()); + (*v.borrow_mut()).push(__a1) + } + }); { - let __a1 = 10; - (*v.borrow_mut()).push(__a1) - }; - { - let __a1 = 1; - (*v.borrow_mut()).push(__a1) - }; - { - let __a1 = 9; - (*v.borrow_mut()).push(__a1) - }; - { - let __a1 = 2; - (*v.borrow_mut()).push(__a1) - }; - { - let __a1 = 8; - (*v.borrow_mut()).push(__a1) - }; - { - let __a1 = 3; - (*v.borrow_mut()).push(__a1) - }; - { - let __a1 = 7; - (*v.borrow_mut()).push(__a1) - }; - { - let __a1 = 4; - (*v.borrow_mut()).push(__a1) - }; - { - let __a1 = 5; - (*v.borrow_mut()).push(__a1) - }; - { - let __a1 = 6; - (*v.borrow_mut()).push(__a1) - }; - { - let mut __tmp_0 = { v.decay().begin() }; - let __n = v.decay().end().iter_distance(&__tmp_0); + let mut __tmp_10 = { v.decay().begin() }; + let __n = v.decay().end().iter_distance(&__tmp_10); let mut __order: Vec = (0..__n).collect(); - __order.sort_by(|&__x, &__y| cpp_cmp(&__tmp_0.iter_at(__x), &__tmp_0.iter_at(__y))); - reorder(__order, |__i| __tmp_0.iter_at(__i)); + __order.sort_by(|&__x, &__y| cpp_cmp(&__tmp_10.iter_at(__x), &__tmp_10.iter_at(__y))); + reorder(__order, |__i| __tmp_10.iter_at(__i)); }; { let mut i: u32 = 0_u32; diff --git a/tests/unit/out/refcount/vector.rs b/tests/unit/out/refcount/vector.rs index c238d0d575..95d975e81c 100644 --- a/tests/unit/out/refcount/vector.rs +++ b/tests/unit/out/refcount/vector.rs @@ -84,10 +84,13 @@ fn main_0() -> i32 { let mut v1: Vec = Vec::new(); assert!((v1.len() == 0_usize)); assert!(v1.is_empty()); - { - let __a1 = 1; - v1.push(__a1) - }; + ({ + let __tmp_0: Value = Rc::new(RefCell::new(1)); + { + let __a1 = move_constructed(&__tmp_0.as_pointer()); + v1.push(__a1) + } + }); assert!(!(v1.is_empty())); v1.pop(); assert!(v1.is_empty()); @@ -101,32 +104,41 @@ fn main_0() -> i32 { assert!((v1[99_usize] == 50)); let v2: Value> = Rc::new(RefCell::new(Vec::new())); assert!(({ ((*v2.borrow()).len() == 0_usize) })); - { - let __a1 = 1; - (*v2.borrow_mut()).push(__a1) - }; - { - let __a1 = 2; - (*v2.borrow_mut()).push(__a1) - }; - { - let __a1 = 3; - (*v2.borrow_mut()).push(__a1) - }; + ({ + let __tmp_1: Value = Rc::new(RefCell::new(1)); + { + let __a1 = move_constructed(&__tmp_1.as_pointer()); + (*v2.borrow_mut()).push(__a1) + } + }); + ({ + let __tmp_2: Value = Rc::new(RefCell::new(2)); + { + let __a1 = move_constructed(&__tmp_2.as_pointer()); + (*v2.borrow_mut()).push(__a1) + } + }); + ({ + let __tmp_3: Value = Rc::new(RefCell::new(3)); + { + let __a1 = move_constructed(&__tmp_3.as_pointer()); + (*v2.borrow_mut()).push(__a1) + } + }); assert!(({ ((*v2.borrow()).len() == 3_usize) })); { - let mut __tmp_0 = { >::from(v2.decay().begin()) }; + let mut __tmp_4 = { >::from(v2.decay().begin()) }; v2.as_pointer() - .with_mut(|__v: &mut Vec| __v.remove(__tmp_0.index())); - (__tmp_0).clone() + .with_mut(|__v: &mut Vec| __v.remove(__tmp_4.index())); + (__tmp_4).clone() }; assert!(({ ((*v2.borrow()).len() == 2_usize) })); assert!(({ (*v2.borrow())[0_usize] } == 2)); assert!(({ (*v2.borrow())[1_usize] } == 3)); { - let mut __tmp_1 = { >::from(v2.decay().begin()) }; - (*v2.borrow_mut()).insert(__tmp_1.index(), 100); - (__tmp_1).clone() + let mut __tmp_5 = { >::from(v2.decay().begin()) }; + (*v2.borrow_mut()).insert(__tmp_5.index(), 100); + (__tmp_5).clone() }; ({ copy_0({ (*v2.borrow()).clone() }) }); assert!(({ ((*v2.borrow()).len() == 3_usize) })); @@ -135,30 +147,30 @@ fn main_0() -> i32 { assert!(({ (*v2.borrow())[2_usize] } == 3)); let mut x: i32 = 7; { - let mut __tmp_2 = + let mut __tmp_6 = { >::from(v2.decay().begin().iter_add(1_isize)) }; - (*v2.borrow_mut()).insert(__tmp_2.index(), x); - (__tmp_2).clone() + (*v2.borrow_mut()).insert(__tmp_6.index(), x); + (__tmp_6).clone() }; assert!(({ ((*v2.borrow()).len() == 4_usize) })); assert!(({ (*v2.borrow())[0_usize] } == 100)); assert!(({ (*v2.borrow())[1_usize] } == 7)); assert!(({ (*v2.borrow())[2_usize] } == 2)); { - let mut __tmp_3 = { >::from(v2.decay().end()) }; - let __off = __tmp_3.index(); + let mut __tmp_7 = { >::from(v2.decay().end()) }; + let __off = __tmp_7.index(); (*v2.borrow_mut()).splice(__off..__off, std::iter::repeat_n(9, 2_usize)); - (__tmp_3).clone() + (__tmp_7).clone() }; assert!(({ ((*v2.borrow()).len() == 6_usize) })); assert!(({ (*v2.borrow())[4_usize] } == 9)); assert!(({ (*v2.borrow())[5_usize] } == 9)); { - let mut __tmp_4 = + let mut __tmp_8 = { >::from(v2.decay().begin().iter_add(2_isize)) }; - let __off = __tmp_4.index(); + let __off = __tmp_8.index(); (*v2.borrow_mut()).splice(__off..__off, Vec::from([11, 12, 13])); - (__tmp_4).clone() + (__tmp_8).clone() }; assert!(({ ((*v2.borrow()).len() == 9_usize) })); assert!(({ (*v2.borrow())[1_usize] } == 7)); @@ -169,47 +181,47 @@ fn main_0() -> i32 { assert!(({ (*v2.borrow())[8_usize] } == 9)); let src: Value> = Rc::new(RefCell::new(Vec::from([21, 22]))); { - let mut __tmp_5 = { >::from(v2.decay().begin()) }; - let mut __tmp_6 = { src.decay().begin() }; - let mut __tmp_7 = { src.decay().end() }; - let start_idx = __tmp_5.index(); + let mut __tmp_9 = { >::from(v2.decay().begin()) }; + let mut __tmp_10 = { src.decay().begin() }; + let mut __tmp_11 = { src.decay().end() }; + let start_idx = __tmp_9.index(); let mut temp_vec: Vec = Vec::new(); - let mut __it = (__tmp_6).clone(); - while __it != __tmp_7 { + let mut __it = (__tmp_10).clone(); + while __it != __tmp_11 { temp_vec.push((__it.iter_deref().read())); __it.iter_inc(); } v2.as_pointer().with_mut(|v: &mut Vec| { v.splice(start_idx..start_idx, temp_vec); }); - (__tmp_5).clone() + (__tmp_9).clone() }; assert!(({ ((*v2.borrow()).len() == 11_usize) })); assert!(({ (*v2.borrow())[0_usize] } == 21)); assert!(({ (*v2.borrow())[1_usize] } == 22)); assert!(({ (*v2.borrow())[2_usize] } == 100)); { - let mut __tmp_8 = { >::from(v2.decay().begin()) }; + let mut __tmp_12 = { >::from(v2.decay().begin()) }; v2.as_pointer() - .with_mut(|__v: &mut Vec| __v.remove(__tmp_8.index())); - (__tmp_8).clone() + .with_mut(|__v: &mut Vec| __v.remove(__tmp_12.index())); + (__tmp_12).clone() }; { - let mut __tmp_9 = { >::from(v2.decay().begin()) }; + let mut __tmp_13 = { >::from(v2.decay().begin()) }; v2.as_pointer() - .with_mut(|__v: &mut Vec| __v.remove(__tmp_9.index())); - (__tmp_9).clone() + .with_mut(|__v: &mut Vec| __v.remove(__tmp_13.index())); + (__tmp_13).clone() }; { let mut i: i32 = 0; 'loop_: while (i < 4) { 'for_body: { { - let mut __tmp_10 = + let mut __tmp_14 = { >::from(v2.decay().begin().iter_add(1_isize)) }; v2.as_pointer() - .with_mut(|__v: &mut Vec| __v.remove(__tmp_10.index())); - (__tmp_10).clone() + .with_mut(|__v: &mut Vec| __v.remove(__tmp_14.index())); + (__tmp_14).clone() }; } i.prefix_inc(); @@ -416,11 +428,11 @@ fn main_0() -> i32 { assert!( ({ (({ - let mut __tmp_11 = { (idx as usize) }; - if __tmp_11 >= (*v6.borrow()).len() { + let mut __tmp_15 = { (idx as usize) }; + if __tmp_15 >= (*v6.borrow()).len() { panic!("out of bounds access") } - v6.decay().offset((__tmp_11) as isize) + v6.decay().offset((__tmp_15) as isize) } .read()) == 2_f64) @@ -429,22 +441,22 @@ fn main_0() -> i32 { assert!( ({ (({ - let mut __tmp_12 = { (s2).wrapping_sub(1_usize) }; - if __tmp_12 >= (*v6.borrow()).len() { + let mut __tmp_16 = { (s2).wrapping_sub(1_usize) }; + if __tmp_16 >= (*v6.borrow()).len() { panic!("out of bounds access") } - v6.decay().offset((__tmp_12) as isize) + v6.decay().offset((__tmp_16) as isize) } .read()) == 5_f64) }) ); let ref1: Ptr = { - let mut __tmp_13 = { (s2).wrapping_sub(1_usize) }; - if __tmp_13 >= (*v6.borrow()).len() { + let mut __tmp_17 = { (s2).wrapping_sub(1_usize) }; + if __tmp_17 >= (*v6.borrow()).len() { panic!("out of bounds access") } - v6.decay().offset((__tmp_13) as isize) + v6.decay().offset((__tmp_17) as isize) }; { ref1.with_mut(|__v| *__v = *__v + 1.5_f64) @@ -452,22 +464,22 @@ fn main_0() -> i32 { assert!( ({ (({ - let mut __tmp_14 = { (s2).wrapping_sub(1_usize) }; - if __tmp_14 >= (*v6.borrow()).len() { + let mut __tmp_18 = { (s2).wrapping_sub(1_usize) }; + if __tmp_18 >= (*v6.borrow()).len() { panic!("out of bounds access") } - v6.decay().offset((__tmp_14) as isize) + v6.decay().offset((__tmp_18) as isize) } .read()) == 6.5_f64) }) ); let mut x1: f64 = ({ - let mut __tmp_15 = { (s2).wrapping_sub(1_usize) }; - if __tmp_15 >= (*v6.borrow()).len() { + let mut __tmp_19 = { (s2).wrapping_sub(1_usize) }; + if __tmp_19 >= (*v6.borrow()).len() { panic!("out of bounds access") } - v6.decay().offset((__tmp_15) as isize) + v6.decay().offset((__tmp_19) as isize) } .read()); assert!((x1 == 6.5_f64)); @@ -475,11 +487,11 @@ fn main_0() -> i32 { assert!( ({ (({ - let mut __tmp_16 = { (s2).wrapping_sub(1_usize) }; - if __tmp_16 >= (*v6.borrow()).len() { + let mut __tmp_20 = { (s2).wrapping_sub(1_usize) }; + if __tmp_20 >= (*v6.borrow()).len() { panic!("out of bounds access") } - v6.decay().offset((__tmp_16) as isize) + v6.decay().offset((__tmp_20) as isize) } .read()) == 6.5_f64) @@ -501,17 +513,23 @@ fn main_0() -> i32 { let a: Value = Rc::new(RefCell::new(S { x: 1 })); let pa: Value> = Rc::new(RefCell::new((a.as_pointer()))); let mut v8: Vec>> = Vec::new(); - { - let __a1 = (pa.as_pointer()); - v8.push(__a1) - }; + ({ + let __tmp_21: Value>> = Rc::new(RefCell::new((pa.as_pointer()))); + { + let __a1 = move_constructed(&__tmp_21.as_pointer()); + v8.push(__a1) + } + }); assert!(((v8[0_usize].read()).with(|__s| __s.x) == 1)); let ppa: Value>> = Rc::new(RefCell::new((pa.as_pointer()))); let mut v9: Vec>>> = Vec::new(); - { - let __a1 = (ppa.as_pointer()); - v9.push(__a1) - }; + ({ + let __tmp_22: Value>>> = Rc::new(RefCell::new((ppa.as_pointer()))); + { + let __a1 = move_constructed(&__tmp_22.as_pointer()); + v9.push(__a1) + } + }); field!(((v9[0_usize].read()).read()), x).write(2); assert!(({ (*a.borrow()).x } == 2)); let v10: Value> = Rc::new(RefCell::new(Vec::from([1, 2, 3]))); @@ -527,18 +545,27 @@ fn main_0() -> i32 { ); let foo: Value = Rc::new(RefCell::new(::zero_init())); DefaultConstructible::default_constructor(&foo.as_pointer()); - { - let __a1 = 5; - (*foo.borrow_mut()).a.push(__a1) - }; - { - let __a1 = 6; - (*foo.borrow_mut()).b.push(__a1) - }; - { - let __a1 = 7; - (*foo.borrow_mut()).b.push(__a1) - }; + ({ + let __tmp_23: Value = Rc::new(RefCell::new(5)); + { + let __a1 = move_constructed(&__tmp_23.as_pointer()); + (*foo.borrow_mut()).a.push(__a1) + } + }); + ({ + let __tmp_24: Value = Rc::new(RefCell::new(6)); + { + let __a1 = move_constructed(&__tmp_24.as_pointer()); + (*foo.borrow_mut()).b.push(__a1) + } + }); + ({ + let __tmp_25: Value = Rc::new(RefCell::new(7)); + { + let __a1 = move_constructed(&__tmp_25.as_pointer()); + (*foo.borrow_mut()).b.push(__a1) + } + }); field_ref!(foo.as_pointer(), a) .as_pointer() .swap_with(&field_ref!(foo.as_pointer(), b).as_pointer(), |__v| { @@ -567,19 +594,21 @@ fn main_0() -> i32 { let mut v12: Vec = Vec::new(); let moved: Value = Rc::new(RefCell::new(5)); { - let __a1 = ({ (*moved.borrow()) }); + let __a1 = move_constructed(&moved.as_pointer()); v12.push(__a1) }; assert!(({ (v12[0_usize] == 5) && ((*moved.borrow()) == 5) })); let mut v13: Vec> = Vec::new(); - let mut moved_ptr: Ptr = (moved.as_pointer()); + let moved_ptr: Value> = Rc::new(RefCell::new((moved.as_pointer()))); { - let __a1 = (moved_ptr).clone(); + let __a1 = move_constructed(&moved_ptr.as_pointer()); v13.push(__a1) }; assert!( - (v13[0_usize] == (moved.as_pointer())) - && ({ (moved_ptr).clone() } == { (moved.as_pointer()) }) + ({ + (v13[0_usize] == (moved.as_pointer())) + && ({ (*moved_ptr.borrow()).clone() } == { (moved.as_pointer()) }) + }) ); let mut v14: Vec = Vec::from([1, 2, 3]); let __rhs = ((*{ @@ -636,19 +665,19 @@ fn main_0() -> i32 { let v16: Value> = Rc::new(RefCell::new(Vec::from([1, 2, 3, 4, 5, 6, 7, 8]))); let mut after_v16: Vec = Vec::from([0]); let inserted: Value> = Rc::new(RefCell::new({ - let mut __tmp_17 = + let mut __tmp_26 = { >::from(v16.decay().begin().iter_add(1_isize)) }; - (*v16.borrow_mut()).insert(__tmp_17.index(), 7); - (__tmp_17).clone() + (*v16.borrow_mut()).insert(__tmp_26.index(), 7); + (__tmp_26).clone() })); { ({ (*inserted.borrow()).iter_deref() }).with_mut(|__v| *__v = *__v + 1) }; let mut nine: i32 = 9; let inserted_copy: Value> = Rc::new(RefCell::new({ - let mut __tmp_18 = { >::from(v16.decay().begin()) }; - (*v16.borrow_mut()).insert(__tmp_18.index(), nine); - (__tmp_18).clone() + let mut __tmp_27 = { >::from(v16.decay().begin()) }; + (*v16.borrow_mut()).insert(__tmp_27.index(), nine); + (__tmp_27).clone() })); { ({ (*inserted_copy.borrow()).iter_deref() }).with_mut(|__v| *__v = *__v + 1) @@ -661,20 +690,20 @@ fn main_0() -> i32 { let ints: Value> = Rc::new(RefCell::new(Box::new([1, 2, 3]))); let longs: Value> = Rc::new(RefCell::new(Vec::from([10_i64, 20_i64]))); let pos: Value> = Rc::new(RefCell::new({ - let mut __tmp_19 = + let mut __tmp_28 = { >::from(longs.decay().begin().iter_add(1_isize)) }; - let mut __tmp_20 = { ints.decay().offset((3) as isize) }; - let start_idx = __tmp_19.index(); + let mut __tmp_29 = { ints.decay().offset((3) as isize) }; + let start_idx = __tmp_28.index(); let mut temp_vec: Vec = Vec::new(); let mut __it = ints.decay(); - while __it != __tmp_20 { + while __it != __tmp_29 { temp_vec.push(((__it.iter_deref().read()) as i64)); __it.iter_inc(); } longs.as_pointer().with_mut(|v: &mut Vec| { v.splice(start_idx..start_idx, temp_vec); }); - (__tmp_19).clone() + (__tmp_28).clone() })); assert!( ({ @@ -686,39 +715,39 @@ fn main_0() -> i32 { ); let more: Value> = Rc::new(RefCell::new(Vec::from([4, 5]))); { - let mut __tmp_21 = { >::from(longs.decay().end()) }; - let mut __tmp_22 = { more.decay().begin() }; - let mut __tmp_23 = { more.decay().end() }; - let start_idx = __tmp_21.index(); + let mut __tmp_30 = { >::from(longs.decay().end()) }; + let mut __tmp_31 = { more.decay().begin() }; + let mut __tmp_32 = { more.decay().end() }; + let start_idx = __tmp_30.index(); let mut temp_vec: Vec = Vec::new(); - let mut __it = (__tmp_22).clone(); - while __it != __tmp_23 { + let mut __it = (__tmp_31).clone(); + while __it != __tmp_32 { temp_vec.push(((__it.iter_deref().read()) as i64)); __it.iter_inc(); } longs.as_pointer().with_mut(|v: &mut Vec| { v.splice(start_idx..start_idx, temp_vec); }); - (__tmp_21).clone() + (__tmp_30).clone() }; assert!( ({ ((*longs.borrow()).len() == 7_usize) && ({ (*longs.borrow())[6_usize] } == 5_i64) }) ); let doubles: Value> = Rc::new(RefCell::new(Vec::new())); { - let mut __tmp_24 = { >::from(doubles.decay().begin()) }; - let mut __tmp_25 = { ints.decay().offset((2) as isize) }; - let start_idx = __tmp_24.index(); + let mut __tmp_33 = { >::from(doubles.decay().begin()) }; + let mut __tmp_34 = { ints.decay().offset((2) as isize) }; + let start_idx = __tmp_33.index(); let mut temp_vec: Vec = Vec::new(); let mut __it = ints.decay(); - while __it != __tmp_25 { + while __it != __tmp_34 { temp_vec.push(((__it.iter_deref().read()) as f64)); __it.iter_inc(); } doubles.as_pointer().with_mut(|v: &mut Vec| { v.splice(start_idx..start_idx, temp_vec); }); - (__tmp_24).clone() + (__tmp_33).clone() }; assert!( ({ @@ -728,19 +757,19 @@ fn main_0() -> i32 { ); let wrapped: Value> = Rc::new(RefCell::new(Vec::new())); { - let mut __tmp_26 = { >::from(wrapped.decay().begin()) }; - let mut __tmp_27 = { ints.decay().offset((3) as isize) }; - let start_idx = __tmp_26.index(); + let mut __tmp_35 = { >::from(wrapped.decay().begin()) }; + let mut __tmp_36 = { ints.decay().offset((3) as isize) }; + let start_idx = __tmp_35.index(); let mut temp_vec: Vec = Vec::new(); let mut __it = ints.decay(); - while __it != __tmp_27 { + while __it != __tmp_36 { temp_vec.push(>::cpp_from(__it.iter_deref())); __it.iter_inc(); } wrapped.as_pointer().with_mut(|v: &mut Vec| { v.splice(start_idx..start_idx, temp_vec); }); - (__tmp_26).clone() + (__tmp_35).clone() }; assert!( ({ @@ -750,20 +779,20 @@ fn main_0() -> i32 { ); let same: Value> = Rc::new(RefCell::new(Vec::from([7]))); { - let mut __tmp_28 = { >::from(same.decay().begin()) }; - let mut __tmp_29 = { more.decay().begin() }; - let mut __tmp_30 = { more.decay().end() }; - let start_idx = __tmp_28.index(); + let mut __tmp_37 = { >::from(same.decay().begin()) }; + let mut __tmp_38 = { more.decay().begin() }; + let mut __tmp_39 = { more.decay().end() }; + let start_idx = __tmp_37.index(); let mut temp_vec: Vec = Vec::new(); - let mut __it = (__tmp_29).clone(); - while __it != __tmp_30 { + let mut __it = (__tmp_38).clone(); + while __it != __tmp_39 { temp_vec.push((__it.iter_deref().read())); __it.iter_inc(); } same.as_pointer().with_mut(|v: &mut Vec| { v.splice(start_idx..start_idx, temp_vec); }); - (__tmp_28).clone() + (__tmp_37).clone() }; assert!( ({ diff --git a/tests/unit/out/refcount/vector2.rs b/tests/unit/out/refcount/vector2.rs index 21be1608e6..0d6c759866 100644 --- a/tests/unit/out/refcount/vector2.rs +++ b/tests/unit/out/refcount/vector2.rs @@ -8,25 +8,37 @@ use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn fn_0(v: Ptr>, v3: Vec) { let v3: Value> = Rc::new(RefCell::new(v3)); - { - let __a1 = 20; - v.with_mut(|__v: &mut Vec| __v.push(__a1)) - }; + ({ + let __tmp_0: Value = Rc::new(RefCell::new(20)); + { + let __a1 = move_constructed(&__tmp_0.as_pointer()); + v.with_mut(|__v: &mut Vec| __v.push(__a1)) + } + }); let mut x: i32 = 0_i32; let mut v2: Vec = Vec::new(); let mut v4: Ptr> = (v3.as_pointer()); - { - let __a1 = 0; - v2.push(__a1) - }; - { - let __a1 = 1; - v2.push(__a1) - }; - { - let __a1 = 3; - v2.push(__a1) - }; + ({ + let __tmp_1: Value = Rc::new(RefCell::new(0)); + { + let __a1 = move_constructed(&__tmp_1.as_pointer()); + v2.push(__a1) + } + }); + ({ + let __tmp_2: Value = Rc::new(RefCell::new(1)); + { + let __a1 = move_constructed(&__tmp_2.as_pointer()); + v2.push(__a1) + } + }); + ({ + let __tmp_3: Value = Rc::new(RefCell::new(3)); + { + let __a1 = move_constructed(&__tmp_3.as_pointer()); + v2.push(__a1) + } + }); x = (index!(v, 2_usize).read()); v2[0_usize] = 1; elem!( @@ -57,10 +69,13 @@ pub fn fn_0(v: Ptr>, v3: Vec) { assert!((v2[2_usize] == 6)); assert!(({ (*v3.borrow())[0_usize] } == 7)); assert!(({ (*v3.borrow())[1_usize] } == 13)); - { - let __a1 = 20; - v.with_mut(|__v: &mut Vec| __v.push(__a1)) - }; + ({ + let __tmp_4: Value = Rc::new(RefCell::new(20)); + { + let __a1 = move_constructed(&__tmp_4.as_pointer()); + v.with_mut(|__v: &mut Vec| __v.push(__a1)) + } + }); } pub fn main() { __cpp2rust_init_globals(); @@ -69,26 +84,41 @@ pub fn main() { fn main_0() -> i32 { let v: Value> = Rc::new(RefCell::new(Vec::new())); let mut v2: Vec = Vec::new(); - { - let __a1 = 4; - (*v.borrow_mut()).push(__a1) - }; - { - let __a1 = 5; - (*v.borrow_mut()).push(__a1) - }; - { - let __a1 = 6; - (*v.borrow_mut()).push(__a1) - }; - { - let __a1 = 8; - v2.push(__a1) - }; - { - let __a1 = 9; - v2.push(__a1) - }; + ({ + let __tmp_5: Value = Rc::new(RefCell::new(4)); + { + let __a1 = move_constructed(&__tmp_5.as_pointer()); + (*v.borrow_mut()).push(__a1) + } + }); + ({ + let __tmp_6: Value = Rc::new(RefCell::new(5)); + { + let __a1 = move_constructed(&__tmp_6.as_pointer()); + (*v.borrow_mut()).push(__a1) + } + }); + ({ + let __tmp_7: Value = Rc::new(RefCell::new(6)); + { + let __a1 = move_constructed(&__tmp_7.as_pointer()); + (*v.borrow_mut()).push(__a1) + } + }); + ({ + let __tmp_8: Value = Rc::new(RefCell::new(8)); + { + let __a1 = move_constructed(&__tmp_8.as_pointer()); + v2.push(__a1) + } + }); + ({ + let __tmp_9: Value = Rc::new(RefCell::new(9)); + { + let __a1 = move_constructed(&__tmp_9.as_pointer()); + v2.push(__a1) + } + }); ({ fn_0(v.as_pointer(), v2.clone()) }); return 0; } diff --git a/tests/unit/out/refcount/vector_deque_vector_string.rs b/tests/unit/out/refcount/vector_deque_vector_string.rs index 48eed56b68..bbda640036 100644 --- a/tests/unit/out/refcount/vector_deque_vector_string.rs +++ b/tests/unit/out/refcount/vector_deque_vector_string.rs @@ -19,70 +19,85 @@ fn main_0() -> i32 { (*v.borrow_mut()).push(Vec::new()); }; let row: Value>> = Rc::new(RefCell::new(Vec::new())); + match (Rc::new(RefCell::new({ + let mut __bytes = Ptr::::from_string_literal(b"a").to_c_bytes(); + __bytes.push(0); + __bytes + })) + .as_pointer(),) { - let __a1 = { - let mut __bytes = Ptr::::from_string_literal(b"a").to_c_bytes(); - __bytes.push(0); - __bytes - }; - (*row.borrow_mut()).push(__a1) + (__tmp_0,) => { + let __a1 = move_constructed(&(__tmp_0).clone()); + (*row.borrow_mut()).push(__a1) + } }; + match (Rc::new(RefCell::new({ + let mut __bytes = Ptr::::from_string_literal(b"bc").to_c_bytes(); + __bytes.push(0); + __bytes + })) + .as_pointer(),) { - let __a1 = { - let mut __bytes = Ptr::::from_string_literal(b"bc").to_c_bytes(); - __bytes.push(0); - __bytes - }; - (*row.borrow_mut()).push(__a1) + (__tmp_1,) => { + let __a1 = move_constructed(&(__tmp_1).clone()); + (*row.borrow_mut()).push(__a1) + } }; elem!(v.decay(), 0_usize) .with_mut(|__v: &mut Vec>>| __v.push(({ (*row.borrow()).clone() }))); + match (Rc::new(RefCell::new({ + let mut __bytes = Ptr::::from_string_literal(b"def").to_c_bytes(); + __bytes.push(0); + __bytes + })) + .as_pointer(),) { - let __a1 = { - let mut __bytes = Ptr::::from_string_literal(b"def").to_c_bytes(); - __bytes.push(0); - __bytes - }; - (*row.borrow_mut()).push(__a1) + (__tmp_2,) => { + let __a1 = move_constructed(&(__tmp_2).clone()); + (*row.borrow_mut()).push(__a1) + } }; elem!(v.decay(), 1_usize) .with_mut(|__v: &mut Vec>>| __v.push(({ (*row.borrow()).clone() }))); match (v.decay().offset(1_usize),) { - (__tmp_0,) => { - __tmp_0.with_mut(|__v: &mut Vec>>| __v.push(Vec::new())); + (__tmp_3,) => { + __tmp_3.with_mut(|__v: &mut Vec>>| __v.push(Vec::new())); } }; - match (match (v.decay().offset(1_usize),) { - (__tmp_2,) => { - let __n = (*__tmp_2.upgrade().deref()).len() - 1; - __tmp_2.decay().offset((__n) as isize) - } - },) - { - (__tmp_1,) => { - let __a1 = { - let mut r = ({ - (*match (v.decay().offset(0_usize),) { - (__tmp_3,) => __tmp_3.decay(), - } - .decay() - .offset(1_usize) - .upgrade() - .deref()) - .clone() - }); - r.pop(); - Ptr::::from_string_literal(b"x").with_c_str(|__s| r.extend_from_slice(__s)); - r.push(0); - r - }; - __tmp_1.with_mut(|__v: &mut Vec>| __v.push(__a1)) + match ( + match (v.decay().offset(1_usize),) { + (__tmp_5,) => { + let __n = (*__tmp_5.upgrade().deref()).len() - 1; + __tmp_5.decay().offset((__n) as isize) + } + }, + Rc::new(RefCell::new({ + let mut r = ({ + (*match (v.decay().offset(0_usize),) { + (__tmp_7,) => __tmp_7.decay(), + } + .decay() + .offset(1_usize) + .upgrade() + .deref()) + .clone() + }); + r.pop(); + Ptr::::from_string_literal(b"x").with_c_str(|__s| r.extend_from_slice(__s)); + r.push(0); + r + })) + .as_pointer(), + ) { + (__tmp_4, __tmp_6) => { + let __a1 = move_constructed(&(__tmp_6).clone()); + __tmp_4.with_mut(|__v: &mut Vec>| __v.push(__a1)) } }; assert!( ({ ((*match (v.decay().offset(0_usize),) { - (__tmp_4,) => __tmp_4.decay(), + (__tmp_8,) => __tmp_8.decay(), } .upgrade() .deref()) @@ -93,21 +108,21 @@ fn main_0() -> i32 { assert!( ({ ((*match (v.decay().offset(1_usize),) { - (__tmp_5,) => __tmp_5.decay(), + (__tmp_9,) => __tmp_9.decay(), } .upgrade() .deref()) .len() == 3_usize) && (match (match (v.decay().offset(1_usize),) { - (__tmp_7,) => __tmp_7.decay(), + (__tmp_11,) => __tmp_11.decay(), } .decay() .offset(2_usize),) { - (__tmp_6,) => Ptr::::from_string_literal(b"def").with_c_str(|__s| { - (*__tmp_6.upgrade().deref()) - [..(*__tmp_6.upgrade().deref()).len().saturating_sub(1)] + (__tmp_10,) => Ptr::::from_string_literal(b"def").with_c_str(|__s| { + (*__tmp_10.upgrade().deref()) + [..(*__tmp_10.upgrade().deref()).len().saturating_sub(1)] == *__s }), }) @@ -116,17 +131,17 @@ fn main_0() -> i32 { assert!( ({ match (match (v.decay().offset(1_usize),) { - (__tmp_9,) => { - let __n = (*__tmp_9.upgrade().deref()).len() - 1; - __tmp_9.decay().offset((__n) as isize) + (__tmp_13,) => { + let __n = (*__tmp_13.upgrade().deref()).len() - 1; + __tmp_13.decay().offset((__n) as isize) } } .decay() .offset(0_usize),) { - (__tmp_8,) => Ptr::::from_string_literal(b"bcx").with_c_str(|__s| { - (*__tmp_8.upgrade().deref()) - [..(*__tmp_8.upgrade().deref()).len().saturating_sub(1)] + (__tmp_12,) => Ptr::::from_string_literal(b"bcx").with_c_str(|__s| { + (*__tmp_12.upgrade().deref()) + [..(*__tmp_12.upgrade().deref()).len().saturating_sub(1)] == *__s }), } @@ -135,7 +150,7 @@ fn main_0() -> i32 { let copy: Value>>>> = Rc::new(RefCell::new((*v.borrow()).clone())); match ( match (copy.decay().offset(0_usize),) { - (__tmp_11,) => __tmp_11.decay(), + (__tmp_15,) => __tmp_15.decay(), } .decay() .offset(0_usize), @@ -146,46 +161,46 @@ fn main_0() -> i32 { })) .as_pointer(), ) { - (__tmp_10, __tmp_12) => __tmp_10.with_mut(|__b0| { - (*__b0) = __tmp_12.with_mut(|__v| std::mem::replace(__v, vec![0])); + (__tmp_14, __tmp_16) => __tmp_14.with_mut(|__b0| { + (*__b0) = __tmp_16.with_mut(|__v| std::mem::replace(__v, vec![0])); }), }; match (match (v.decay().offset(0_usize),) { - (__tmp_14,) => __tmp_14.decay(), + (__tmp_18,) => __tmp_18.decay(), } .decay() .offset(1_usize),) { - (__tmp_13,) => { - if 0_usize >= (*__tmp_13.upgrade().deref()).len() - 1 { + (__tmp_17,) => { + if 0_usize >= (*__tmp_17.upgrade().deref()).len() - 1 { panic!("out of bounds access") } - __tmp_13.decay().offset((0_usize) as isize) + __tmp_17.decay().offset((0_usize) as isize) } } .write(('B' as i8)); assert!( ({ (match (match (v.decay().offset(0_usize),) { - (__tmp_16,) => __tmp_16.decay(), + (__tmp_20,) => __tmp_20.decay(), } .decay() .offset(0_usize),) { - (__tmp_15,) => Ptr::::from_string_literal(b"a").with_c_str(|__s| { - (*__tmp_15.upgrade().deref()) - [..(*__tmp_15.upgrade().deref()).len().saturating_sub(1)] + (__tmp_19,) => Ptr::::from_string_literal(b"a").with_c_str(|__s| { + (*__tmp_19.upgrade().deref()) + [..(*__tmp_19.upgrade().deref()).len().saturating_sub(1)] == *__s }), }) && (match (match (copy.decay().offset(0_usize),) { - (__tmp_18,) => __tmp_18.decay(), + (__tmp_22,) => __tmp_22.decay(), } .decay() .offset(0_usize),) { - (__tmp_17,) => Ptr::::from_string_literal(b"z").with_c_str(|__s| { - (*__tmp_17.upgrade().deref()) - [..(*__tmp_17.upgrade().deref()).len().saturating_sub(1)] + (__tmp_21,) => Ptr::::from_string_literal(b"z").with_c_str(|__s| { + (*__tmp_21.upgrade().deref()) + [..(*__tmp_21.upgrade().deref()).len().saturating_sub(1)] == *__s }), }) @@ -194,25 +209,25 @@ fn main_0() -> i32 { assert!( ({ (match (match (v.decay().offset(0_usize),) { - (__tmp_20,) => __tmp_20.decay(), + (__tmp_24,) => __tmp_24.decay(), } .decay() .offset(1_usize),) { - (__tmp_19,) => Ptr::::from_string_literal(b"Bc").with_c_str(|__s| { - (*__tmp_19.upgrade().deref()) - [..(*__tmp_19.upgrade().deref()).len().saturating_sub(1)] + (__tmp_23,) => Ptr::::from_string_literal(b"Bc").with_c_str(|__s| { + (*__tmp_23.upgrade().deref()) + [..(*__tmp_23.upgrade().deref()).len().saturating_sub(1)] == *__s }), }) && (match (match (copy.decay().offset(0_usize),) { - (__tmp_22,) => __tmp_22.decay(), + (__tmp_26,) => __tmp_26.decay(), } .decay() .offset(1_usize),) { - (__tmp_21,) => Ptr::::from_string_literal(b"bc").with_c_str(|__s| { - (*__tmp_21.upgrade().deref()) - [..(*__tmp_21.upgrade().deref()).len().saturating_sub(1)] + (__tmp_25,) => Ptr::::from_string_literal(b"bc").with_c_str(|__s| { + (*__tmp_25.upgrade().deref()) + [..(*__tmp_25.upgrade().deref()).len().saturating_sub(1)] == *__s }), }) @@ -222,14 +237,14 @@ fn main_0() -> i32 { assert!( ({ match (match (v.decay().offset(1_usize),) { - (__tmp_24,) => __tmp_24.decay(), + (__tmp_28,) => __tmp_28.decay(), } .decay() .offset(0_usize),) { - (__tmp_23,) => Ptr::::from_string_literal(b"bcx").with_c_str(|__s| { - (*__tmp_23.upgrade().deref()) - [..(*__tmp_23.upgrade().deref()).len().saturating_sub(1)] + (__tmp_27,) => Ptr::::from_string_literal(b"bcx").with_c_str(|__s| { + (*__tmp_27.upgrade().deref()) + [..(*__tmp_27.upgrade().deref()).len().saturating_sub(1)] == *__s }), } @@ -238,7 +253,7 @@ fn main_0() -> i32 { assert!( ({ ((*match (copy.decay().offset(1_usize),) { - (__tmp_25,) => __tmp_25.decay(), + (__tmp_29,) => __tmp_29.decay(), } .upgrade() .deref()) diff --git a/tests/unit/out/refcount/vector_subscript_direct.rs b/tests/unit/out/refcount/vector_subscript_direct.rs index a54801b365..4850b63e30 100644 --- a/tests/unit/out/refcount/vector_subscript_direct.rs +++ b/tests/unit/out/refcount/vector_subscript_direct.rs @@ -56,10 +56,13 @@ impl DefaultConstructible for Holder { } } pub fn push_and_index_0(v: Ptr>) -> i32 { - { - let __a1 = 42; - v.with_mut(|__v: &mut Vec| __v.push(__a1)) - }; + ({ + let __tmp_0: Value = Rc::new(RefCell::new(42)); + { + let __a1 = move_constructed(&__tmp_0.as_pointer()); + v.with_mut(|__v: &mut Vec| __v.push(__a1)) + } + }); return ((((*v.upgrade().deref()).len()) as i32) - 1); } pub fn sum_ref_1(v: Ptr>) -> i32 { @@ -115,10 +118,13 @@ fn main_0() -> i32 { DefaultConstructible::default_constructor(&h.as_pointer()); (*h.borrow_mut()).values.resize_with(2_usize, || 0_i32); vec_elem!(h.as_pointer(), values, 1_usize).write(6); - { - let __a1 = (Point { x: 1, y: 2 }); - (*h.borrow_mut()).points.push(__a1) - }; + ({ + let __tmp_1: Value = Rc::new(RefCell::new(Point { x: 1, y: 2 })); + { + let __a1 = move_constructed(&(__tmp_1.as_pointer())); + (*h.borrow_mut()).points.push(__a1) + } + }); field!(vec_elem!(h.as_pointer(), points, 0_usize), y).write(5); assert!(((vec_elem!(h.as_pointer(), values, 1_usize).read()) == 6)); assert!( @@ -135,13 +141,17 @@ fn main_0() -> i32 { q.x = 0; assert!((vec_elem!(h.as_pointer(), points, 0_usize).with(|__s| __s.x) == 7)); let grid: Value>> = Rc::new(RefCell::new(Vec::new())); - { - let __a1 = vec![0; 3_usize]; - (*grid.borrow_mut()).push(__a1) + match (Rc::new(RefCell::new(vec![0; 3_usize])).as_pointer(),) { + (__tmp_2,) => { + let __a1 = move_constructed(&(__tmp_2).clone()); + (*grid.borrow_mut()).push(__a1) + } }; - { - let __a1 = vec![0; 3_usize]; - (*grid.borrow_mut()).push(__a1) + match (Rc::new(RefCell::new(vec![0; 3_usize])).as_pointer(),) { + (__tmp_3,) => { + let __a1 = move_constructed(&(__tmp_3).clone()); + (*grid.borrow_mut()).push(__a1) + } }; index!(elem!(grid.decay(), 1_usize), 2_usize).write(8); assert!( diff --git a/tests/unit/out/refcount/vector_with_allocator.rs b/tests/unit/out/refcount/vector_with_allocator.rs index a2a7b7b5e7..fe1e3e40e3 100644 --- a/tests/unit/out/refcount/vector_with_allocator.rs +++ b/tests/unit/out/refcount/vector_with_allocator.rs @@ -39,25 +39,37 @@ pub struct TestAllocator_double_ {} pub fn copy_0(mut copy_vector: Vec) {} pub fn fn_1(v: Ptr>, v3: Vec) { let v3: Value> = Rc::new(RefCell::new(v3)); - { - let __a1 = 20; - v.with_mut(|__v: &mut Vec| __v.push(__a1)) - }; + ({ + let __tmp_0: Value = Rc::new(RefCell::new(20)); + { + let __a1 = move_constructed(&__tmp_0.as_pointer()); + v.with_mut(|__v: &mut Vec| __v.push(__a1)) + } + }); let mut x: i32 = 0_i32; let mut v4: Ptr> = (v3.as_pointer()); let mut v2: Vec = Vec::new(); - { - let __a1 = 0; - v2.push(__a1) - }; - { - let __a1 = 1; - v2.push(__a1) - }; - { - let __a1 = 3; - v2.push(__a1) - }; + ({ + let __tmp_1: Value = Rc::new(RefCell::new(0)); + { + let __a1 = move_constructed(&__tmp_1.as_pointer()); + v2.push(__a1) + } + }); + ({ + let __tmp_2: Value = Rc::new(RefCell::new(1)); + { + let __a1 = move_constructed(&__tmp_2.as_pointer()); + v2.push(__a1) + } + }); + ({ + let __tmp_3: Value = Rc::new(RefCell::new(3)); + { + let __a1 = move_constructed(&__tmp_3.as_pointer()); + v2.push(__a1) + } + }); x = (index!(v, 2_usize).read()); v2[0_usize] = 1; elem!( @@ -82,10 +94,13 @@ pub fn fn_1(v: Ptr>, v3: Vec) { ); assert!(({ (*v3.borrow())[0_usize] } == 7)); assert!(({ (*v3.borrow())[1_usize] } == 13)); - { - let __a1 = 20; - v.with_mut(|__v: &mut Vec| __v.push(__a1)) - }; + ({ + let __tmp_4: Value = Rc::new(RefCell::new(20)); + { + let __a1 = move_constructed(&__tmp_4.as_pointer()); + v.with_mut(|__v: &mut Vec| __v.push(__a1)) + } + }); } pub fn main() { __cpp2rust_init_globals(); @@ -95,10 +110,13 @@ fn main_0() -> i32 { let mut v1: Vec = Vec::new(); assert!((v1.len() == 0_usize)); assert!(v1.is_empty()); - { - let __a1 = 1; - v1.push(__a1) - }; + ({ + let __tmp_5: Value = Rc::new(RefCell::new(1)); + { + let __a1 = move_constructed(&__tmp_5.as_pointer()); + v1.push(__a1) + } + }); assert!(!(v1.is_empty())); v1.pop(); assert!(v1.is_empty()); @@ -112,32 +130,41 @@ fn main_0() -> i32 { assert!((v1[99_usize] == 50)); let v2: Value> = Rc::new(RefCell::new(Vec::new())); assert!(({ ((*v2.borrow()).len() == 0_usize) })); - { - let __a1 = 1; - (*v2.borrow_mut()).push(__a1) - }; - { - let __a1 = 2; - (*v2.borrow_mut()).push(__a1) - }; - { - let __a1 = 3; - (*v2.borrow_mut()).push(__a1) - }; + ({ + let __tmp_6: Value = Rc::new(RefCell::new(1)); + { + let __a1 = move_constructed(&__tmp_6.as_pointer()); + (*v2.borrow_mut()).push(__a1) + } + }); + ({ + let __tmp_7: Value = Rc::new(RefCell::new(2)); + { + let __a1 = move_constructed(&__tmp_7.as_pointer()); + (*v2.borrow_mut()).push(__a1) + } + }); + ({ + let __tmp_8: Value = Rc::new(RefCell::new(3)); + { + let __a1 = move_constructed(&__tmp_8.as_pointer()); + (*v2.borrow_mut()).push(__a1) + } + }); assert!(({ ((*v2.borrow()).len() == 3_usize) })); { - let mut __tmp_0 = { >::from(v2.decay().begin()) }; + let mut __tmp_9 = { >::from(v2.decay().begin()) }; v2.as_pointer() - .with_mut(|__v: &mut Vec| __v.remove(__tmp_0.index())); - (__tmp_0).clone() + .with_mut(|__v: &mut Vec| __v.remove(__tmp_9.index())); + (__tmp_9).clone() }; assert!(({ ((*v2.borrow()).len() == 2_usize) })); assert!(({ (*v2.borrow())[0_usize] } == 2)); assert!(({ (*v2.borrow())[1_usize] } == 3)); { - let mut __tmp_1 = { >::from(v2.decay().begin()) }; - (*v2.borrow_mut()).insert(__tmp_1.index(), 100); - (__tmp_1).clone() + let mut __tmp_10 = { >::from(v2.decay().begin()) }; + (*v2.borrow_mut()).insert(__tmp_10.index(), 100); + (__tmp_10).clone() }; ({ copy_0({ (*v2.borrow()).clone() }) }); assert!(({ ((*v2.borrow()).len() == 3_usize) })); @@ -281,11 +308,11 @@ fn main_0() -> i32 { assert!( ({ (({ - let mut __tmp_2 = { (idx as usize) }; - if __tmp_2 >= (*v6.borrow()).len() { + let mut __tmp_11 = { (idx as usize) }; + if __tmp_11 >= (*v6.borrow()).len() { panic!("out of bounds access") } - v6.decay().offset((__tmp_2) as isize) + v6.decay().offset((__tmp_11) as isize) } .read()) == 2_f64) @@ -294,22 +321,22 @@ fn main_0() -> i32 { assert!( ({ (({ - let mut __tmp_3 = { (s2).wrapping_sub(1_usize) }; - if __tmp_3 >= (*v6.borrow()).len() { + let mut __tmp_12 = { (s2).wrapping_sub(1_usize) }; + if __tmp_12 >= (*v6.borrow()).len() { panic!("out of bounds access") } - v6.decay().offset((__tmp_3) as isize) + v6.decay().offset((__tmp_12) as isize) } .read()) == 5_f64) }) ); let ref1: Ptr = { - let mut __tmp_4 = { (s2).wrapping_sub(1_usize) }; - if __tmp_4 >= (*v6.borrow()).len() { + let mut __tmp_13 = { (s2).wrapping_sub(1_usize) }; + if __tmp_13 >= (*v6.borrow()).len() { panic!("out of bounds access") } - v6.decay().offset((__tmp_4) as isize) + v6.decay().offset((__tmp_13) as isize) }; { ref1.with_mut(|__v| *__v = *__v + 1.5_f64) @@ -317,22 +344,22 @@ fn main_0() -> i32 { assert!( ({ (({ - let mut __tmp_5 = { (s2).wrapping_sub(1_usize) }; - if __tmp_5 >= (*v6.borrow()).len() { + let mut __tmp_14 = { (s2).wrapping_sub(1_usize) }; + if __tmp_14 >= (*v6.borrow()).len() { panic!("out of bounds access") } - v6.decay().offset((__tmp_5) as isize) + v6.decay().offset((__tmp_14) as isize) } .read()) == 6.5_f64) }) ); let mut x1: f64 = ({ - let mut __tmp_6 = { (s2).wrapping_sub(1_usize) }; - if __tmp_6 >= (*v6.borrow()).len() { + let mut __tmp_15 = { (s2).wrapping_sub(1_usize) }; + if __tmp_15 >= (*v6.borrow()).len() { panic!("out of bounds access") } - v6.decay().offset((__tmp_6) as isize) + v6.decay().offset((__tmp_15) as isize) } .read()); assert!((x1 == 6.5_f64)); @@ -340,11 +367,11 @@ fn main_0() -> i32 { assert!( ({ (({ - let mut __tmp_7 = { (s2).wrapping_sub(1_usize) }; - if __tmp_7 >= (*v6.borrow()).len() { + let mut __tmp_16 = { (s2).wrapping_sub(1_usize) }; + if __tmp_16 >= (*v6.borrow()).len() { panic!("out of bounds access") } - v6.decay().offset((__tmp_7) as isize) + v6.decay().offset((__tmp_16) as isize) } .read()) == 6.5_f64) @@ -352,33 +379,48 @@ fn main_0() -> i32 { ); let v7: Value> = Rc::new(RefCell::new(Vec::new())); let mut v8: Vec = Vec::new(); - { - let __a1 = 4; - (*v7.borrow_mut()).push(__a1) - }; - { - let __a1 = 5; - (*v7.borrow_mut()).push(__a1) - }; - { - let __a1 = 6; - (*v7.borrow_mut()).push(__a1) - }; - { - let __a1 = 8; - v8.push(__a1) - }; - { - let __a1 = 9; - v8.push(__a1) - }; + ({ + let __tmp_17: Value = Rc::new(RefCell::new(4)); + { + let __a1 = move_constructed(&__tmp_17.as_pointer()); + (*v7.borrow_mut()).push(__a1) + } + }); + ({ + let __tmp_18: Value = Rc::new(RefCell::new(5)); + { + let __a1 = move_constructed(&__tmp_18.as_pointer()); + (*v7.borrow_mut()).push(__a1) + } + }); + ({ + let __tmp_19: Value = Rc::new(RefCell::new(6)); + { + let __a1 = move_constructed(&__tmp_19.as_pointer()); + (*v7.borrow_mut()).push(__a1) + } + }); + ({ + let __tmp_20: Value = Rc::new(RefCell::new(8)); + { + let __a1 = move_constructed(&__tmp_20.as_pointer()); + v8.push(__a1) + } + }); + ({ + let __tmp_21: Value = Rc::new(RefCell::new(9)); + { + let __a1 = move_constructed(&__tmp_21.as_pointer()); + v8.push(__a1) + } + }); ({ fn_1(v7.as_pointer(), v8.clone()) }); let src: Value> = Rc::new(RefCell::new(Box::new([1_u32, 2_u32, 3_u32]))); let mut v9: Vec = { - let mut __tmp_8 = { src.decay().offset((3) as isize) }; + let mut __tmp_22 = { src.decay().offset((3) as isize) }; let mut __v = Vec::new(); let mut __it = src.decay(); - while __it != __tmp_8 { + while __it != __tmp_22 { __v.push((__it.iter_deref().read())); __it.iter_inc(); } @@ -387,10 +429,10 @@ fn main_0() -> i32 { assert!((v9.len() == 3_usize)); assert!(((v9[0_usize] == 1_u32) && (v9[1_usize] == 2_u32)) && (v9[2_usize] == 3_u32)); let mut v10: Vec = { - let mut __tmp_9 = { src.decay().offset((3) as isize) }; + let mut __tmp_23 = { src.decay().offset((3) as isize) }; let mut __v = Vec::new(); let mut __it = src.decay(); - while __it != __tmp_9 { + while __it != __tmp_23 { __v.push(((__it.iter_deref().read()) as u64)); __it.iter_inc(); } @@ -399,10 +441,10 @@ fn main_0() -> i32 { assert!((v10.len() == 3_usize)); assert!(((v10[0_usize] == 1_u64) && (v10[1_usize] == 2_u64)) && (v10[2_usize] == 3_u64)); let mut v11: Vec = { - let mut __tmp_10 = { src.decay().offset((3) as isize) }; + let mut __tmp_24 = { src.decay().offset((3) as isize) }; let mut __v = Vec::new(); let mut __it = src.decay(); - while __it != __tmp_10 { + while __it != __tmp_24 { __v.push(((__it.iter_deref().read()) as i32)); __it.iter_inc(); } @@ -412,10 +454,10 @@ fn main_0() -> i32 { assert!(((v11[0_usize] == 1) && (v11[1_usize] == 2)) && (v11[2_usize] == 3)); let src1: Value> = Rc::new(RefCell::new(Box::new([1_u32, 2_u32, 3_u32]))); let mut v12: Vec = { - let mut __tmp_11 = { src1.decay().to_end() }; + let mut __tmp_25 = { src1.decay().to_end() }; let mut __v = Vec::new(); let mut __it = src1.decay(); - while __it != __tmp_11 { + while __it != __tmp_25 { __v.push((__it.iter_deref().read())); __it.iter_inc(); } @@ -428,10 +470,10 @@ fn main_0() -> i32 { let mut start: Ptr = buf.decay(); let mut len: usize = 5_usize; let mut v13: Vec = { - let mut __tmp_12 = { start.offset((len) as isize) }; + let mut __tmp_26 = { start.offset((len) as isize) }; let mut __v = Vec::new(); let mut __it = (start).clone(); - while __it != __tmp_12 { + while __it != __tmp_26 { __v.push((__it.iter_deref().read())); __it.iter_inc(); } diff --git a/tests/unit/out/unsafe/12_test.rs b/tests/unit/out/unsafe/12_test.rs index b40ae15c5f..b2255e755b 100644 --- a/tests/unit/out/unsafe/12_test.rs +++ b/tests/unit/out/unsafe/12_test.rs @@ -15,7 +15,7 @@ pub fn main() { unsafe fn main_0() -> i32 { let mut v: Vec> = Vec::new(); { - let __a1 = Vec::from_fn(10_usize, |_| 0_i32); + let __a1 = move_constructed_unsafe(&raw mut Vec::from_fn(10_usize, |_| 0_i32)); v.push(__a1) }; return 0; diff --git a/tests/unit/out/unsafe/array_of_noncopy_struct.rs b/tests/unit/out/unsafe/array_of_noncopy_struct.rs index ce87fa9d47..5a7ccd43f1 100644 --- a/tests/unit/out/unsafe/array_of_noncopy_struct.rs +++ b/tests/unit/out/unsafe/array_of_noncopy_struct.rs @@ -52,7 +52,7 @@ unsafe fn main_0() -> i32 { }); arr[(0) as usize].tag = 7; { - let __a1 = 42; + let __a1 = move_constructed_unsafe(&raw mut 42); arr[(1) as usize].data.push(__a1) }; assert!(((arr[(0) as usize].tag) == (7))); diff --git a/tests/unit/out/unsafe/auto.rs b/tests/unit/out/unsafe/auto.rs index a3f067d494..0e673ae955 100644 --- a/tests/unit/out/unsafe/auto.rs +++ b/tests/unit/out/unsafe/auto.rs @@ -18,11 +18,11 @@ unsafe fn main_0() -> i32 { let mut x3: u32 = 4_u32; let mut v: Vec = Vec::new(); { - let __a1 = 1; + let __a1 = move_constructed_unsafe(&raw mut 1); v.push(__a1) }; { - let __a1 = 2; + let __a1 = move_constructed_unsafe(&raw mut 2); v.push(__a1) }; let mut sum: i32 = 0; diff --git a/tests/unit/out/unsafe/cast.rs b/tests/unit/out/unsafe/cast.rs index c32f956c62..cc7f160baa 100644 --- a/tests/unit/out/unsafe/cast.rs +++ b/tests/unit/out/unsafe/cast.rs @@ -238,16 +238,16 @@ pub unsafe fn vector_capacity_4() { v.reserve_exact(4_usize - len_0 as usize); }; { - let __a1 = 1; + let __a1 = move_constructed_unsafe(&raw mut 1); v.push(__a1) }; let mut i0: usize = ((&mut v[(0_usize)] as *mut i32) as *mut i32 as usize); { - let __a1 = 2; + let __a1 = move_constructed_unsafe(&raw mut 2); v.push(__a1) }; { - let __a1 = 3; + let __a1 = move_constructed_unsafe(&raw mut 3); v.push(__a1) }; assert!( @@ -320,11 +320,11 @@ pub unsafe fn nested_5() { b.items.reserve_exact(4_usize - len_0 as usize); }; { - let __a1 = 1; + let __a1 = move_constructed_unsafe(&raw mut 1); b.items.push(__a1) }; { - let __a1 = 2; + let __a1 = move_constructed_unsafe(&raw mut 2); b.items.push(__a1) }; let mut ib: usize = ((&mut b.items[(0_usize)] as *mut i32) as *mut i32 as usize); @@ -333,7 +333,7 @@ pub unsafe fn nested_5() { == ((ib as u64).wrapping_add((::std::mem::size_of::() as u64)) as usize)) ); { - let __a1 = 3; + let __a1 = move_constructed_unsafe(&raw mut 3); b.items.push(__a1) }; assert!( diff --git a/tests/unit/out/unsafe/class_templates.rs b/tests/unit/out/unsafe/class_templates.rs index c2a4f9d216..e9d8d375cf 100644 --- a/tests/unit/out/unsafe/class_templates.rs +++ b/tests/unit/out/unsafe/class_templates.rs @@ -337,7 +337,7 @@ pub fn main() { unsafe fn main_0() -> i32 { let mut ev: Vec = Vec::new(); { - let __a1 = (Elem { i: 2 }); + let __a1 = move_constructed_unsafe(&raw mut (Elem { i: 2 })); ev.push(__a1) }; assert!(((ev[(0_usize)].i) == (2))); diff --git a/tests/unit/out/unsafe/clone_vs_move.rs b/tests/unit/out/unsafe/clone_vs_move.rs index dec18f1168..f46d375496 100644 --- a/tests/unit/out/unsafe/clone_vs_move.rs +++ b/tests/unit/out/unsafe/clone_vs_move.rs @@ -171,7 +171,7 @@ unsafe fn main_0() -> i32 { 'loop_: while ((i) < (N)) { 'for_body: { { - let __a1 = Vec::from_fn(10_usize, |_| 0_i32); + let __a1 = move_constructed_unsafe(&raw mut Vec::from_fn(10_usize, |_| 0_i32)); m1.push(__a1) }; } @@ -278,7 +278,7 @@ unsafe fn main_0() -> i32 { let mut pair3: (Vec, i32) = (Vec::from_fn(0_usize, |_| 0_i32), 0); let mut pair4: (Vec, i32) = pair3.clone(); { - let __a1 = 1; + let __a1 = move_constructed_unsafe(&raw mut 1); pair4.0.push(__a1) }; pair4.1 = 1; diff --git a/tests/unit/out/unsafe/comma_operator.rs b/tests/unit/out/unsafe/comma_operator.rs index 86864b4712..a51c46b55d 100644 --- a/tests/unit/out/unsafe/comma_operator.rs +++ b/tests/unit/out/unsafe/comma_operator.rs @@ -79,7 +79,7 @@ unsafe fn main_0() -> i32 { } .clone(); { - let __a1 = 3; + let __a1 = move_constructed_unsafe(&raw mut 3); v2.push(__a1) }; assert!(((a) == (5))); diff --git a/tests/unit/out/unsafe/compound_assign_ref.rs b/tests/unit/out/unsafe/compound_assign_ref.rs index 5bda4dc486..0423738c76 100644 --- a/tests/unit/out/unsafe/compound_assign_ref.rs +++ b/tests/unit/out/unsafe/compound_assign_ref.rs @@ -15,7 +15,7 @@ pub fn main() { unsafe fn main_0() -> i32 { let mut v: Vec = Vec::new(); { - let __a1 = 10; + let __a1 = move_constructed_unsafe(&raw mut 10); v.push(__a1) }; v[0] += 5; diff --git a/tests/unit/out/unsafe/container_element_receiver.rs b/tests/unit/out/unsafe/container_element_receiver.rs index 12d3ee6ee9..9af6cf4424 100644 --- a/tests/unit/out/unsafe/container_element_receiver.rs +++ b/tests/unit/out/unsafe/container_element_receiver.rs @@ -74,7 +74,7 @@ unsafe fn main_0() -> i32 { { let mut __tmp_0: i32; { - let __a1 = 8; + let __a1 = move_constructed_unsafe(&raw mut 8); (*{ __tmp_0 = 1; &raw mut (*m.subscript_move( diff --git a/tests/unit/out/unsafe/container_field_addr.rs b/tests/unit/out/unsafe/container_field_addr.rs index bcd097a4ca..d5035d263e 100644 --- a/tests/unit/out/unsafe/container_field_addr.rs +++ b/tests/unit/out/unsafe/container_field_addr.rs @@ -43,7 +43,7 @@ pub unsafe fn run_1(mut h: *mut S) { }); let mut pv: *mut Vec = (&mut (*h).v as *mut Vec); { - let __a1 = (((*(pv).cast_const()).len()) as i32); + let __a1 = move_constructed_unsafe(&raw mut (((*(pv).cast_const()).len()) as i32)); (*pv).push(__a1) }; assert!( diff --git a/tests/unit/out/unsafe/copy_assign.rs b/tests/unit/out/unsafe/copy_assign.rs index ba4e43a606..41ebfa5823 100644 --- a/tests/unit/out/unsafe/copy_assign.rs +++ b/tests/unit/out/unsafe/copy_assign.rs @@ -385,7 +385,7 @@ unsafe fn main_0() -> i32 { let mut e2: ExplicitOperatorCall = ::zero_init(); DefaultConstructibleUnsafe::default_constructor(&mut e2); { - let __a1 = 5; + let __a1 = move_constructed_unsafe(&raw mut 5); e1.w.push(__a1) }; (unsafe { CopyAssignableUnsafe::copy_assign(&mut e2, &e1) }); diff --git a/tests/unit/out/unsafe/copy_move_defaulted.rs b/tests/unit/out/unsafe/copy_move_defaulted.rs index b43b34703e..8e5e5ccd38 100644 --- a/tests/unit/out/unsafe/copy_move_defaulted.rs +++ b/tests/unit/out/unsafe/copy_move_defaulted.rs @@ -642,11 +642,11 @@ unsafe fn main_0() -> i32 { vec_.push(a0_clone) }; { - let __a1 = { + let __a1 = move_constructed_unsafe(&raw mut { let mut __v: Explicit = ::zero_init(); Explicit::construct(&mut __v, { 9 }); __v - }; + }); vec_.push(__a1) }; assert!(((vec_[(0_usize)].v) == (1)) && ((vec_[(1_usize)].v) == (9))); @@ -698,11 +698,7 @@ unsafe fn main_0() -> i32 { ); let mut bufs: Vec = Vec::new(); { - let __a1 = { - let mut __v: Buffer = ::zero_init(); - MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut r }); - __v - }; + let __a1 = move_constructed_unsafe(&raw mut r); bufs.push(__a1) }; { @@ -722,7 +718,7 @@ unsafe fn main_0() -> i32 { let mut o1: Owner = ::zero_init(); DefaultConstructibleUnsafe::default_constructor(&mut o1); { - let __a1 = 5; + let __a1 = move_constructed_unsafe(&raw mut 5); o1.data.push(__a1) }; o1.n = 5; @@ -908,7 +904,7 @@ unsafe fn main_0() -> i32 { DefaultConstructibleUnsafe::default_constructor(&mut a3); a1.v = 3; { - let __a1 = 4; + let __a1 = move_constructed_unsafe(&raw mut 4); a1.w.push(__a1) }; (unsafe { CopyAssignableUnsafe::copy_assign(&mut a2, &a1) }); diff --git a/tests/unit/out/unsafe/elidable_iterator_copy_cxx11.rs b/tests/unit/out/unsafe/elidable_iterator_copy_cxx11.rs index 0a5d147cf5..f7b48b1521 100644 --- a/tests/unit/out/unsafe/elidable_iterator_copy_cxx11.rs +++ b/tests/unit/out/unsafe/elidable_iterator_copy_cxx11.rs @@ -15,11 +15,11 @@ pub fn main() { unsafe fn main_0() -> i32 { let mut v: Vec = Vec::new(); { - let __a1 = 4; + let __a1 = move_constructed_unsafe(&raw mut 4); v.push(__a1) }; { - let __a1 = 7; + let __a1 = move_constructed_unsafe(&raw mut 7); v.push(__a1) }; let mut it: UnsafeRandomAccessIterator = { diff --git a/tests/unit/out/unsafe/field_method_receiver.rs b/tests/unit/out/unsafe/field_method_receiver.rs index 5280d88e4e..d43427f175 100644 --- a/tests/unit/out/unsafe/field_method_receiver.rs +++ b/tests/unit/out/unsafe/field_method_receiver.rs @@ -95,7 +95,7 @@ pub unsafe fn run_0(mut o: *mut S) { (unsafe { S::bump(&mut (*o)) }); assert!(((unsafe { Counter::get(&(*o).c,) }) == (1))); { - let __a1 = (unsafe { Counter::get(&(*o).c) }); + let __a1 = move_constructed_unsafe(&raw mut (unsafe { Counter::get(&(*o).c) })); (*o).v.push(__a1) }; assert!((((*o).v.len()) == (1_usize)) && (((&mut (*o)).v[(0_usize)]) == (1))); diff --git a/tests/unit/out/unsafe/field_pointers.rs b/tests/unit/out/unsafe/field_pointers.rs index 0fefe76d01..e9e1ce6c5f 100644 --- a/tests/unit/out/unsafe/field_pointers.rs +++ b/tests/unit/out/unsafe/field_pointers.rs @@ -68,7 +68,7 @@ impl Outer { } pub unsafe fn push(&mut self, mut k: i32) { { - let __a1 = ((k) + (self.x)); + let __a1 = move_constructed_unsafe(&raw mut ((k) + (self.x))); self.v.push(__a1) }; } diff --git a/tests/unit/out/unsafe/find.rs b/tests/unit/out/unsafe/find.rs index 573c0fe9af..565916d34d 100644 --- a/tests/unit/out/unsafe/find.rs +++ b/tests/unit/out/unsafe/find.rs @@ -41,15 +41,15 @@ pub fn main() { unsafe fn main_0() -> i32 { let mut v: Vec = Vec::new(); { - let __a1 = 1; + let __a1 = move_constructed_unsafe(&raw mut 1); v.push(__a1) }; { - let __a1 = 2; + let __a1 = move_constructed_unsafe(&raw mut 2); v.push(__a1) }; { - let __a1 = 3; + let __a1 = move_constructed_unsafe(&raw mut 3); v.push(__a1) }; let mut v_begin: UnsafeRandomAccessIterator = v.begin(); diff --git a/tests/unit/out/unsafe/fn_ptr_stable_sort.rs b/tests/unit/out/unsafe/fn_ptr_stable_sort.rs index b235d786e6..3fa376abcf 100644 --- a/tests/unit/out/unsafe/fn_ptr_stable_sort.rs +++ b/tests/unit/out/unsafe/fn_ptr_stable_sort.rs @@ -37,15 +37,15 @@ pub fn main() { unsafe fn main_0() -> i32 { let mut v: Vec = Vec::new(); { - let __a1 = (Item { key: 3, value: 30 }); + let __a1 = move_constructed_unsafe(&raw mut (Item { key: 3, value: 30 })); v.push(__a1) }; { - let __a1 = (Item { key: 1, value: 10 }); + let __a1 = move_constructed_unsafe(&raw mut (Item { key: 1, value: 10 })); v.push(__a1) }; { - let __a1 = (Item { key: 2, value: 20 }); + let __a1 = move_constructed_unsafe(&raw mut (Item { key: 2, value: 20 })); v.push(__a1) }; { diff --git a/tests/unit/out/unsafe/foreach_disjoint_field_borrow.rs b/tests/unit/out/unsafe/foreach_disjoint_field_borrow.rs index 2dd1a83093..6df4dfb9bb 100644 --- a/tests/unit/out/unsafe/foreach_disjoint_field_borrow.rs +++ b/tests/unit/out/unsafe/foreach_disjoint_field_borrow.rs @@ -39,7 +39,7 @@ unsafe fn main_0() -> i32 { let mut s: S = ::zero_init(); DefaultConstructibleUnsafe::default_constructor(&mut s); { - let __a1 = 1; + let __a1 = move_constructed_unsafe(&raw mut 1); s.v.push(__a1) }; 'loop_: for e in IterRange::new(s.v.begin(), s.v.end()) { diff --git a/tests/unit/out/unsafe/foreach_double.rs b/tests/unit/out/unsafe/foreach_double.rs index 90d3c48fef..c4c625c980 100644 --- a/tests/unit/out/unsafe/foreach_double.rs +++ b/tests/unit/out/unsafe/foreach_double.rs @@ -15,15 +15,15 @@ pub fn main() { unsafe fn main_0() -> i32 { let mut v: Vec = Vec::new(); { - let __a1 = 1; + let __a1 = move_constructed_unsafe(&raw mut 1); v.push(__a1) }; { - let __a1 = 2; + let __a1 = move_constructed_unsafe(&raw mut 2); v.push(__a1) }; { - let __a1 = 3; + let __a1 = move_constructed_unsafe(&raw mut 3); v.push(__a1) }; let mut square: i32 = 0; @@ -58,17 +58,17 @@ unsafe fn main_0() -> i32 { let mut m: Vec> = Vec::new(); let mut v1: Vec = Vec::new(); { - let __a1 = std::mem::take(&mut v1); + let __a1 = move_constructed_unsafe(&raw mut v1); m.push(__a1) }; let mut v2: Vec = Vec::new(); { - let __a1 = std::mem::take(&mut v2); + let __a1 = move_constructed_unsafe(&raw mut v2); m.push(__a1) }; let mut v3: Vec = Vec::new(); { - let __a1 = std::mem::take(&mut v3); + let __a1 = move_constructed_unsafe(&raw mut v3); m.push(__a1) }; 'loop_: for row in IterRange::new(m.begin(), m.end()) { diff --git a/tests/unit/out/unsafe/foreach_mut.rs b/tests/unit/out/unsafe/foreach_mut.rs index b869c91348..885a57bb5b 100644 --- a/tests/unit/out/unsafe/foreach_mut.rs +++ b/tests/unit/out/unsafe/foreach_mut.rs @@ -15,15 +15,15 @@ pub fn main() { unsafe fn main_0() -> i32 { let mut v1: Vec = Vec::new(); { - let __a1 = 1; + let __a1 = move_constructed_unsafe(&raw mut 1); v1.push(__a1) }; { - let __a1 = 2; + let __a1 = move_constructed_unsafe(&raw mut 2); v1.push(__a1) }; { - let __a1 = 3; + let __a1 = move_constructed_unsafe(&raw mut 3); v1.push(__a1) }; let mut sum: i32 = 0; @@ -45,15 +45,15 @@ unsafe fn main_0() -> i32 { } let mut v2: Vec<*mut i32> = Vec::new(); { - let __a1 = (&mut v1[(0_usize)] as *mut i32); + let __a1 = move_constructed_unsafe(&raw mut (&mut v1[(0_usize)] as *mut i32)); v2.push(__a1) }; { - let __a1 = (&mut v1[(1_usize)] as *mut i32); + let __a1 = move_constructed_unsafe(&raw mut (&mut v1[(1_usize)] as *mut i32)); v2.push(__a1) }; { - let __a1 = (&mut v1[(2_usize)] as *mut i32); + let __a1 = move_constructed_unsafe(&raw mut (&mut v1[(2_usize)] as *mut i32)); v2.push(__a1) }; 'loop_: for p in IterRange::new(v2.begin(), v2.end()) { diff --git a/tests/unit/out/unsafe/implicit_autoref.rs b/tests/unit/out/unsafe/implicit_autoref.rs index 04e93654e4..80eb5d29a7 100644 --- a/tests/unit/out/unsafe/implicit_autoref.rs +++ b/tests/unit/out/unsafe/implicit_autoref.rs @@ -39,11 +39,11 @@ pub fn main() { unsafe fn main_0() -> i32 { let mut v: Vec = Vec::new(); { - let __a1 = 10; + let __a1 = move_constructed_unsafe(&raw mut 10); v.push(__a1) }; { - let __a1 = 20; + let __a1 = move_constructed_unsafe(&raw mut 20); v.push(__a1) }; let mut p: *mut Vec = (&mut v as *mut Vec); @@ -52,11 +52,11 @@ unsafe fn main_0() -> i32 { let mut h: Holder = ::zero_init(); DefaultConstructibleUnsafe::default_constructor(&mut h); { - let __a1 = 40; + let __a1 = move_constructed_unsafe(&raw mut 40); h.v.push(__a1) }; { - let __a1 = 50; + let __a1 = move_constructed_unsafe(&raw mut 50); h.v.push(__a1) }; let mut hp: *mut Holder = (&mut h as *mut Holder); diff --git a/tests/unit/out/unsafe/inline_container_fields.rs b/tests/unit/out/unsafe/inline_container_fields.rs index c0038a17ea..842d4b4015 100644 --- a/tests/unit/out/unsafe/inline_container_fields.rs +++ b/tests/unit/out/unsafe/inline_container_fields.rs @@ -119,7 +119,7 @@ pub unsafe fn fill_1(mut s: *mut State) { } } { - let __a1 = Vec::from([1, 2, 3]); + let __a1 = move_constructed_unsafe(&raw mut Vec::from([1, 2, 3])); (*s).rows.push(__a1) }; } @@ -320,7 +320,7 @@ unsafe fn main_0() -> i32 { ); let mut va: [Vec; 2] = std::array::from_fn::<_, 2, _>(|_| Default::default()); { - let __a1 = 1; + let __a1 = move_constructed_unsafe(&raw mut 1); va[(0_usize)].push(__a1) }; let mut vb: [Vec; 2] = { diff --git a/tests/unit/out/unsafe/iterators.rs b/tests/unit/out/unsafe/iterators.rs index ef0a32a6b5..2bc146f32e 100644 --- a/tests/unit/out/unsafe/iterators.rs +++ b/tests/unit/out/unsafe/iterators.rs @@ -44,11 +44,11 @@ unsafe fn main_0() -> i32 { } let mut v: Vec<*mut i32> = Vec::new(); { - let __a1 = (Box::leak(Box::new(2)) as *mut i32); + let __a1 = move_constructed_unsafe(&raw mut (Box::leak(Box::new(2)) as *mut i32)); v.push(__a1) }; { - let __a1 = (Box::leak(Box::new(3)) as *mut i32); + let __a1 = move_constructed_unsafe(&raw mut (Box::leak(Box::new(3)) as *mut i32)); v.push(__a1) }; 'loop_: for p in IterRange::new(v.begin(), v.end()) { diff --git a/tests/unit/out/unsafe/map.rs b/tests/unit/out/unsafe/map.rs index 79f7fa8b55..076a95d7e5 100644 --- a/tests/unit/out/unsafe/map.rs +++ b/tests/unit/out/unsafe/map.rs @@ -344,7 +344,7 @@ unsafe fn main_0() -> i32 { 'loop_: while ((i) > (30_u32)) { 'for_body: { { - let __a1 = (i as i32); + let __a1 = move_constructed_unsafe(&raw mut (i as i32)); indexes.push(__a1) }; } @@ -356,7 +356,7 @@ unsafe fn main_0() -> i32 { 'loop_: while ((i) > (60_u32)) { 'for_body: { { - let __a1 = (i as i32); + let __a1 = move_constructed_unsafe(&raw mut (i as i32)); indexes.push(__a1) }; } @@ -368,7 +368,7 @@ unsafe fn main_0() -> i32 { 'loop_: while ((i) > (0_u32)) { 'for_body: { { - let __a1 = (i as i32); + let __a1 = move_constructed_unsafe(&raw mut (i as i32)); indexes.push(__a1) }; } diff --git a/tests/unit/out/unsafe/move_assign.rs b/tests/unit/out/unsafe/move_assign.rs index a4250a2b7f..83c6ffab38 100644 --- a/tests/unit/out/unsafe/move_assign.rs +++ b/tests/unit/out/unsafe/move_assign.rs @@ -125,12 +125,16 @@ unsafe fn main_0() -> i32 { assert!(((a.v) == (6))); let mut vec_: Vec = Vec::new(); { - let __a1 = { - let mut __v: MoveOnly = ::zero_init(); - MoveOnly::construct(&mut __v, { 7 }); - __v - }; - vec_.push(__a1) + let mut __tmp_0: MoveOnly = ::zero_init(); + { + let __a1 = move_constructed_unsafe( + &raw mut (*{ + MoveOnly::construct(&mut __tmp_0, { 7 }); + &mut __tmp_0 + }), + ); + vec_.push(__a1) + } }; let mut d: MoveOnly = ::zero_init(); MoveOnly::construct(&mut d, { 8 }); diff --git a/tests/unit/out/unsafe/move_ctor.rs b/tests/unit/out/unsafe/move_ctor.rs index 17c54e25ff..80416de718 100644 --- a/tests/unit/out/unsafe/move_ctor.rs +++ b/tests/unit/out/unsafe/move_ctor.rs @@ -213,21 +213,21 @@ unsafe fn main_0() -> i32 { assert!(((e.v) == (0))); let mut vec_: Vec = Vec::new(); { - let __a1 = { - let mut __v: MoveOnly = ::zero_init(); - MoveOnly::construct(&mut __v, { 7 }); - __v - }; - vec_.push(__a1) + let mut __tmp_0: MoveOnly = ::zero_init(); + { + let __a1 = move_constructed_unsafe( + &raw mut (*{ + MoveOnly::construct(&mut __tmp_0, { 7 }); + &mut __tmp_0 + }), + ); + vec_.push(__a1) + } }; let mut f: MoveOnly = ::zero_init(); MoveOnly::construct(&mut f, { 8 }); { - let __a1 = { - let mut __v: MoveOnly = ::zero_init(); - MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut f }); - __v - }; + let __a1 = move_constructed_unsafe(&raw mut f); vec_.push(__a1) }; assert!(((vec_[(0_usize)].v) == (7)) && ((vec_[(1_usize)].v) == (8))); diff --git a/tests/unit/out/unsafe/pair.rs b/tests/unit/out/unsafe/pair.rs index 5517bc3b36..18b42dbdc1 100644 --- a/tests/unit/out/unsafe/pair.rs +++ b/tests/unit/out/unsafe/pair.rs @@ -27,7 +27,7 @@ unsafe fn main_0() -> i32 { let arr: [i32; 2] = [1, 2]; let mut n: u32 = 2_u32; let mut const_ptr_pairs: Vec<(*const i32, u64)> = - Vec::from_fn(1_usize, |_| <(*const i32, u64)>::default()); + Vec::from_fn(1_usize, |_| (std::ptr::null(), 0_u64)); match ( (&mut const_ptr_pairs[(0_usize)] as *mut (*const i32, u64)), (&mut (arr.as_ptr().offset((1) as isize), n) as *mut (*const i32, u32)), @@ -65,7 +65,10 @@ unsafe fn main_0() -> i32 { let mut pd: *mut i32 = (&mut d.0 as *mut i32); let mut ps: *mut i32 = (&mut s.0 as *mut i32); { - d = std::mem::take(&mut s); + d = ( + move_constructed_unsafe(&raw mut (s).0), + move_constructed_unsafe(&raw mut (s).1), + ); }; assert!(((*pd) == (3))); (*ps) = 5; @@ -90,7 +93,10 @@ unsafe fn main_0() -> i32 { .1 = 7; assert!(((p.1) == (7)) && ((q.1) == (4))); (*{ - d = std::mem::take(&mut q); + d = ( + move_constructed_unsafe(&raw mut (q).0), + move_constructed_unsafe(&raw mut (q).1), + ); &mut d }) .0 = 8; diff --git a/tests/unit/out/unsafe/push_emplace_back.rs b/tests/unit/out/unsafe/push_emplace_back.rs index d387d5baad..a93c036898 100644 --- a/tests/unit/out/unsafe/push_emplace_back.rs +++ b/tests/unit/out/unsafe/push_emplace_back.rs @@ -62,7 +62,7 @@ impl DefaultConstructibleUnsafe for JPEGData { } pub unsafe fn push_param_0(mut dest: *mut Vec>) { { - let __a1 = Vec::new(); + let __a1 = move_constructed_unsafe(&raw mut Vec::new()); (*dest).push(__a1) }; } @@ -75,7 +75,7 @@ pub unsafe fn push_local_from_field_1(mut jpg: *mut JPEGData, mut cond: bool) { dest = (&mut (*jpg).app_data as *mut Vec>); } { - let __a1 = { + let __a1 = move_constructed_unsafe(&raw mut { let mut __tmp_0 = { head.as_mut_ptr().offset((3) as isize) }; let mut __v = Vec::new(); let mut __it = head.as_mut_ptr(); @@ -84,7 +84,7 @@ pub unsafe fn push_local_from_field_1(mut jpg: *mut JPEGData, mut cond: bool) { __it.iter_inc(); } __v - }; + }); (*dest).push(__a1) }; } @@ -93,7 +93,7 @@ pub unsafe fn shrink_through_ptr_2(mut comps: *mut Vec) { } pub unsafe fn nested_push_move_3(mut bw: *mut Writer) { { - let __a1 = (*bw).chunk; + let __a1 = move_constructed_unsafe(&raw mut (*bw).chunk); (*(*bw).output).push(__a1) }; } diff --git a/tests/unit/out/unsafe/reinterpret_cast_vec_write.rs b/tests/unit/out/unsafe/reinterpret_cast_vec_write.rs index 3bb370798c..1fecfa5c8e 100644 --- a/tests/unit/out/unsafe/reinterpret_cast_vec_write.rs +++ b/tests/unit/out/unsafe/reinterpret_cast_vec_write.rs @@ -15,11 +15,11 @@ pub fn main() { unsafe fn main_0() -> i32 { let mut vec_: Vec = Vec::new(); { - let __a1 = 67305985_u32; + let __a1 = move_constructed_unsafe(&raw mut 67305985_u32); vec_.push(__a1) }; { - let __a1 = 134678021_u32; + let __a1 = move_constructed_unsafe(&raw mut 134678021_u32); vec_.push(__a1) }; let mut bytes: *mut u8 = ((vec_.as_mut_ptr()) as *mut u8); diff --git a/tests/unit/out/unsafe/return_move.rs b/tests/unit/out/unsafe/return_move.rs index d03cbdcf56..d6bb50213f 100644 --- a/tests/unit/out/unsafe/return_move.rs +++ b/tests/unit/out/unsafe/return_move.rs @@ -92,7 +92,7 @@ pub unsafe fn ret_vec_12(mut v: Vec) -> Vec { pub unsafe fn ret_vec_local_13() -> Vec { let mut v: Vec = Vec::new(); { - let __a1 = 1; + let __a1 = move_constructed_unsafe(&raw mut 1); v.push(__a1) }; return std::mem::take(&mut v); diff --git a/tests/unit/out/unsafe/sort.rs b/tests/unit/out/unsafe/sort.rs index ad88a714c0..25125579e5 100644 --- a/tests/unit/out/unsafe/sort.rs +++ b/tests/unit/out/unsafe/sort.rs @@ -15,43 +15,43 @@ pub fn main() { unsafe fn main_0() -> i32 { let mut v: Vec = Vec::new(); { - let __a1 = 10; + let __a1 = move_constructed_unsafe(&raw mut 10); v.push(__a1) }; { - let __a1 = 1; + let __a1 = move_constructed_unsafe(&raw mut 1); v.push(__a1) }; { - let __a1 = 9; + let __a1 = move_constructed_unsafe(&raw mut 9); v.push(__a1) }; { - let __a1 = 2; + let __a1 = move_constructed_unsafe(&raw mut 2); v.push(__a1) }; { - let __a1 = 8; + let __a1 = move_constructed_unsafe(&raw mut 8); v.push(__a1) }; { - let __a1 = 3; + let __a1 = move_constructed_unsafe(&raw mut 3); v.push(__a1) }; { - let __a1 = 7; + let __a1 = move_constructed_unsafe(&raw mut 7); v.push(__a1) }; { - let __a1 = 4; + let __a1 = move_constructed_unsafe(&raw mut 4); v.push(__a1) }; { - let __a1 = 5; + let __a1 = move_constructed_unsafe(&raw mut 5); v.push(__a1) }; { - let __a1 = 6; + let __a1 = move_constructed_unsafe(&raw mut 6); v.push(__a1) }; { diff --git a/tests/unit/out/unsafe/vector.rs b/tests/unit/out/unsafe/vector.rs index e52be36fa7..6fe70ef6be 100644 --- a/tests/unit/out/unsafe/vector.rs +++ b/tests/unit/out/unsafe/vector.rs @@ -80,7 +80,7 @@ unsafe fn main_0() -> i32 { assert!(((v1.len()) == (0_usize))); assert!(v1.is_empty()); { - let __a1 = 1; + let __a1 = move_constructed_unsafe(&raw mut 1); v1.push(__a1) }; assert!(!(v1.is_empty())); @@ -97,15 +97,15 @@ unsafe fn main_0() -> i32 { let mut v2: Vec = Vec::new(); assert!(((v2.len()) == (0_usize))); { - let __a1 = 1; + let __a1 = move_constructed_unsafe(&raw mut 1); v2.push(__a1) }; { - let __a1 = 2; + let __a1 = move_constructed_unsafe(&raw mut 2); v2.push(__a1) }; { - let __a1 = 3; + let __a1 = move_constructed_unsafe(&raw mut 3); v2.push(__a1) }; assert!(((v2.len()) == (3_usize))); @@ -264,8 +264,7 @@ unsafe fn main_0() -> i32 { i.prefix_inc(); } } - let mut v7: Vec<(*const i32, i32)> = - Vec::from_fn(200_usize, |_| <(*const i32, i32)>::default()); + let mut v7: Vec<(*const i32, i32)> = Vec::from_fn(200_usize, |_| (std::ptr::null(), 0_i32)); assert!(((v7.len()) == (200_usize))); { let mut i: u32 = 0_u32; @@ -386,14 +385,14 @@ unsafe fn main_0() -> i32 { let mut pa: *mut S = (&mut a as *mut S); let mut v8: Vec<*const *mut S> = Vec::new(); { - let __a1 = (&mut pa as *mut *mut S).cast_const(); + let __a1 = move_constructed_unsafe(&raw mut (&mut pa as *mut *mut S).cast_const()); v8.push(__a1) }; assert!((((*(*v8[(0_usize)])).x) == (1))); let mut ppa: *mut *mut S = (&mut pa as *mut *mut S); let mut v9: Vec<*mut *mut *mut S> = Vec::new(); { - let __a1 = (&mut ppa as *mut *mut *mut S); + let __a1 = move_constructed_unsafe(&raw mut (&mut ppa as *mut *mut *mut S)); v9.push(__a1) }; (*(*(*v9[(0_usize)]))).x = 2; @@ -408,15 +407,15 @@ unsafe fn main_0() -> i32 { let mut foo: Foo = ::zero_init(); DefaultConstructibleUnsafe::default_constructor(&mut foo); { - let __a1 = 5; + let __a1 = move_constructed_unsafe(&raw mut 5); foo.a.push(__a1) }; { - let __a1 = 6; + let __a1 = move_constructed_unsafe(&raw mut 6); foo.b.push(__a1) }; { - let __a1 = 7; + let __a1 = move_constructed_unsafe(&raw mut 7); foo.b.push(__a1) }; std::mem::swap(&mut foo.a, &mut foo.b); @@ -431,14 +430,14 @@ unsafe fn main_0() -> i32 { let mut v12: Vec = Vec::new(); let mut moved: i32 = 5; { - let __a1 = moved; + let __a1 = move_constructed_unsafe(&raw mut moved); v12.push(__a1) }; assert!(((v12[(0_usize)]) == (5)) && ((moved) == (5))); let mut v13: Vec<*mut i32> = Vec::new(); let mut moved_ptr: *mut i32 = (&mut moved as *mut i32); { - let __a1 = moved_ptr; + let __a1 = move_constructed_unsafe(&raw mut moved_ptr); v13.push(__a1) }; assert!( diff --git a/tests/unit/out/unsafe/vector2.rs b/tests/unit/out/unsafe/vector2.rs index 2d6bbb88a8..7e0d682ba6 100644 --- a/tests/unit/out/unsafe/vector2.rs +++ b/tests/unit/out/unsafe/vector2.rs @@ -8,22 +8,22 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub unsafe fn fn_0(v: *mut Vec, mut v3: Vec) { { - let __a1 = 20; + let __a1 = move_constructed_unsafe(&raw mut 20); (*v).push(__a1) }; let mut x: i32 = 0_i32; let mut v2: Vec = Vec::new(); let mut v4: *mut Vec = (&mut v3 as *mut Vec); { - let __a1 = 0; + let __a1 = move_constructed_unsafe(&raw mut 0); v2.push(__a1) }; { - let __a1 = 1; + let __a1 = move_constructed_unsafe(&raw mut 1); v2.push(__a1) }; { - let __a1 = 3; + let __a1 = move_constructed_unsafe(&raw mut 3); v2.push(__a1) }; x = (&mut (*v))[(2_usize)]; @@ -53,7 +53,7 @@ pub unsafe fn fn_0(v: *mut Vec, mut v3: Vec) { assert!(((v3[(0_usize)]) == (7))); assert!(((v3[(1_usize)]) == (13))); { - let __a1 = 20; + let __a1 = move_constructed_unsafe(&raw mut 20); (*v).push(__a1) }; } @@ -67,23 +67,23 @@ unsafe fn main_0() -> i32 { let mut v: Vec = Vec::new(); let mut v2: Vec = Vec::new(); { - let __a1 = 4; + let __a1 = move_constructed_unsafe(&raw mut 4); v.push(__a1) }; { - let __a1 = 5; + let __a1 = move_constructed_unsafe(&raw mut 5); v.push(__a1) }; { - let __a1 = 6; + let __a1 = move_constructed_unsafe(&raw mut 6); v.push(__a1) }; { - let __a1 = 8; + let __a1 = move_constructed_unsafe(&raw mut 8); v2.push(__a1) }; { - let __a1 = 9; + let __a1 = move_constructed_unsafe(&raw mut 9); v2.push(__a1) }; (unsafe { fn_0(&mut v, v2.clone()) }); diff --git a/tests/unit/out/unsafe/vector_deque_vector_string.rs b/tests/unit/out/unsafe/vector_deque_vector_string.rs index fee5f4bd4e..0ece051e47 100644 --- a/tests/unit/out/unsafe/vector_deque_vector_string.rs +++ b/tests/unit/out/unsafe/vector_deque_vector_string.rs @@ -18,28 +18,34 @@ unsafe fn main_0() -> i32 { v.push_mut(Vec::new()); let mut row: Vec> = Vec::new(); { - let __a1 = std::slice::from_raw_parts( - c"a".as_ptr(), - (0..).take_while(|&i| *c"a".as_ptr().add(i) != 0).count() + 1, - ) - .to_vec(); + let __a1 = move_constructed_unsafe( + &raw mut std::slice::from_raw_parts( + c"a".as_ptr(), + (0..).take_while(|&i| *c"a".as_ptr().add(i) != 0).count() + 1, + ) + .to_vec(), + ); row.push(__a1) }; { - let __a1 = std::slice::from_raw_parts( - c"bc".as_ptr(), - (0..).take_while(|&i| *c"bc".as_ptr().add(i) != 0).count() + 1, - ) - .to_vec(); + let __a1 = move_constructed_unsafe( + &raw mut std::slice::from_raw_parts( + c"bc".as_ptr(), + (0..).take_while(|&i| *c"bc".as_ptr().add(i) != 0).count() + 1, + ) + .to_vec(), + ); row.push(__a1) }; v[(0_usize)].push((row).clone()); { - let __a1 = std::slice::from_raw_parts( - c"def".as_ptr(), - (0..).take_while(|&i| *c"def".as_ptr().add(i) != 0).count() + 1, - ) - .to_vec(); + let __a1 = move_constructed_unsafe( + &raw mut std::slice::from_raw_parts( + c"def".as_ptr(), + (0..).take_while(|&i| *c"def".as_ptr().add(i) != 0).count() + 1, + ) + .to_vec(), + ); row.push(__a1) }; v[(1_usize)].push((row).clone()); @@ -53,7 +59,7 @@ unsafe fn main_0() -> i32 { } as *mut Vec>), ) { (__tmp_0,) => { - let __a1 = { + let __a1 = move_constructed_unsafe(&raw mut { let mut __tmp2 = v[(0_usize)][0][(1_usize)].clone(); __tmp2.pop(); __tmp2.extend_from_slice(::std::slice::from_raw_parts( @@ -62,7 +68,7 @@ unsafe fn main_0() -> i32 { )); __tmp2.push(0); __tmp2 - }; + }); (*__tmp_0).push(__a1) } }; diff --git a/tests/unit/out/unsafe/vector_subscript_direct.rs b/tests/unit/out/unsafe/vector_subscript_direct.rs index c4f1c6b32e..1c56935f45 100644 --- a/tests/unit/out/unsafe/vector_subscript_direct.rs +++ b/tests/unit/out/unsafe/vector_subscript_direct.rs @@ -52,7 +52,7 @@ impl DefaultConstructibleUnsafe for Holder { } pub unsafe fn push_and_index_0(v: *mut Vec) -> i32 { { - let __a1 = 42; + let __a1 = move_constructed_unsafe(&raw mut 42); (*v).push(__a1) }; return ((((*v).len()) as i32) - (1)); @@ -115,7 +115,7 @@ unsafe fn main_0() -> i32 { h.values.resize_with(2_usize, || 0_i32); h.values[(1_usize)] = 6; { - let __a1 = (Point { x: 1, y: 2 }); + let __a1 = move_constructed_unsafe(&raw mut (Point { x: 1, y: 2 })); h.points.push(__a1) }; h.points[(0_usize)].y = 5; @@ -130,11 +130,11 @@ unsafe fn main_0() -> i32 { assert!(((h.points[(0_usize)].x) == (7))); let mut grid: Vec> = Vec::new(); { - let __a1 = vec![0; 3_usize]; + let __a1 = move_constructed_unsafe(&raw mut vec![0; 3_usize]); grid.push(__a1) }; { - let __a1 = vec![0; 3_usize]; + let __a1 = move_constructed_unsafe(&raw mut vec![0; 3_usize]); grid.push(__a1) }; grid[(1_usize)][(2_usize)] = 8; diff --git a/tests/unit/out/unsafe/vector_with_allocator.rs b/tests/unit/out/unsafe/vector_with_allocator.rs index a2bace4ed1..498085bee2 100644 --- a/tests/unit/out/unsafe/vector_with_allocator.rs +++ b/tests/unit/out/unsafe/vector_with_allocator.rs @@ -69,22 +69,22 @@ impl TestAllocator_double_ { pub unsafe fn copy_0(mut copy_vector: Vec) {} pub unsafe fn fn_1(v: *mut Vec, mut v3: Vec) { { - let __a1 = 20; + let __a1 = move_constructed_unsafe(&raw mut 20); (*v).push(__a1) }; let mut x: i32 = 0_i32; let mut v4: *mut Vec = (&mut v3 as *mut Vec); let mut v2: Vec = Vec::new(); { - let __a1 = 0; + let __a1 = move_constructed_unsafe(&raw mut 0); v2.push(__a1) }; { - let __a1 = 1; + let __a1 = move_constructed_unsafe(&raw mut 1); v2.push(__a1) }; { - let __a1 = 3; + let __a1 = move_constructed_unsafe(&raw mut 3); v2.push(__a1) }; x = (&mut (*v))[(2_usize)]; @@ -108,7 +108,7 @@ pub unsafe fn fn_1(v: *mut Vec, mut v3: Vec) { assert!(((v3[(0_usize)]) == (7))); assert!(((v3[(1_usize)]) == (13))); { - let __a1 = 20; + let __a1 = move_constructed_unsafe(&raw mut 20); (*v).push(__a1) }; } @@ -123,7 +123,7 @@ unsafe fn main_0() -> i32 { assert!(((v1.len()) == (0_usize))); assert!(v1.is_empty()); { - let __a1 = 1; + let __a1 = move_constructed_unsafe(&raw mut 1); v1.push(__a1) }; assert!(!(v1.is_empty())); @@ -140,15 +140,15 @@ unsafe fn main_0() -> i32 { let mut v2: Vec = Vec::new(); assert!(((v2.len()) == (0_usize))); { - let __a1 = 1; + let __a1 = move_constructed_unsafe(&raw mut 1); v2.push(__a1) }; { - let __a1 = 2; + let __a1 = move_constructed_unsafe(&raw mut 2); v2.push(__a1) }; { - let __a1 = 3; + let __a1 = move_constructed_unsafe(&raw mut 3); v2.push(__a1) }; assert!(((v2.len()) == (3_usize))); @@ -289,23 +289,23 @@ unsafe fn main_0() -> i32 { let mut v7: Vec = Vec::new(); let mut v8: Vec = Vec::new(); { - let __a1 = 4; + let __a1 = move_constructed_unsafe(&raw mut 4); v7.push(__a1) }; { - let __a1 = 5; + let __a1 = move_constructed_unsafe(&raw mut 5); v7.push(__a1) }; { - let __a1 = 6; + let __a1 = move_constructed_unsafe(&raw mut 6); v7.push(__a1) }; { - let __a1 = 8; + let __a1 = move_constructed_unsafe(&raw mut 8); v8.push(__a1) }; { - let __a1 = 9; + let __a1 = move_constructed_unsafe(&raw mut 9); v8.push(__a1) }; (unsafe { fn_1(&mut v7, v8.clone()) }); From d274a13c28b067bff267729fde51d7bbe79d24a6 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Wed, 2 Dec 2026 13:10:24 +0000 Subject: [PATCH 07/13] Use default_constructible in rules --- rules/array/tgt_refcount.rs | 4 ++-- rules/array/tgt_unsafe.rs | 4 ++-- rules/deque/tgt_refcount.rs | 4 ++++ rules/deque/tgt_unsafe.rs | 4 ++-- rules/map/tgt_refcount.rs | 8 ++++---- rules/map/tgt_unsafe.rs | 8 ++++---- rules/pair/tgt_refcount.rs | 6 +++--- rules/pair/tgt_unsafe.rs | 11 +++++++---- rules/unique_ptr/tgt_refcount.rs | 4 ++-- rules/unique_ptr/tgt_unsafe.rs | 8 ++++---- rules/vector/tgt_refcount.rs | 6 ++++++ rules/vector/tgt_unsafe.rs | 16 ++++++++-------- 12 files changed, 48 insertions(+), 35 deletions(-) diff --git a/rules/array/tgt_refcount.rs b/rules/array/tgt_refcount.rs index cb30bfcc2c..c327c5edcf 100644 --- a/rules/array/tgt_refcount.rs +++ b/rules/array/tgt_refcount.rs @@ -5,8 +5,8 @@ use libcc2rs::*; use std::cell::RefCell; use std::rc::Rc; -fn t1() -> Box<[T1]> { - Box::<[T1]>::from(std::array::from_fn::<_, T2, _>(|_| ::default())) +fn t1() -> Box<[T1]> { + Box::<[T1]>::from(std::array::from_fn::<_, T2, _>(|_| ::default_constructed())) } fn t4() -> Ptr { diff --git a/rules/array/tgt_unsafe.rs b/rules/array/tgt_unsafe.rs index 8d01c78699..53838aadd7 100644 --- a/rules/array/tgt_unsafe.rs +++ b/rules/array/tgt_unsafe.rs @@ -3,8 +3,8 @@ use libcc2rs::*; -fn t1() -> [T1; T2] { - std::array::from_fn::<_, T2, _>(|_| ::default()) +fn t1() -> [T1; T2] { + std::array::from_fn::<_, T2, _>(|_| ::default_constructed()) } fn t2() -> usize { diff --git a/rules/deque/tgt_refcount.rs b/rules/deque/tgt_refcount.rs index 223923720a..23fc809e91 100644 --- a/rules/deque/tgt_refcount.rs +++ b/rules/deque/tgt_refcount.rs @@ -37,3 +37,7 @@ fn f12(a0: &mut Vec, init: T1) -> &mut T1 { let __n = a0.len() - 1; &mut a0[__n] } + +fn f4(a0: &mut Vec, a1: Ptr) { + a0.push(move_constructed(&a1)) +} diff --git a/rules/deque/tgt_unsafe.rs b/rules/deque/tgt_unsafe.rs index e3448c6ae1..b0ce5b3302 100644 --- a/rules/deque/tgt_unsafe.rs +++ b/rules/deque/tgt_unsafe.rs @@ -38,8 +38,8 @@ fn f3(a0: Vec) -> bool { a0.is_empty() } -fn f4(a0: &mut Vec, a1: &mut T1) { - a0.push(std::mem::take(&mut *a1)) +unsafe fn f4(a0: &mut Vec, a1: &mut T1) { + a0.push(move_constructed_unsafe(&raw mut *a1)) } fn f5(a0: &mut Vec) -> T1 { diff --git a/rules/map/tgt_refcount.rs b/rules/map/tgt_refcount.rs index 71cfde537b..a836c66ceb 100644 --- a/rules/map/tgt_refcount.rs +++ b/rules/map/tgt_refcount.rs @@ -9,11 +9,11 @@ fn t1() -> Map, Value)> { Map::new() } -fn f1( +fn f1( a0: &mut Map, Value)>, a1: Ptr, ) -> Ptr { - a0.subscript(a1, || T2::default()) + a0.subscript(a1, || ::default_constructed()) } fn f2(a0: Map, Value)>) -> usize { @@ -39,11 +39,11 @@ fn f7(a0: &mut Map, Value)>, a1: P a0.get(&a1).expect("out of range!").borrow().1.as_pointer() } -fn f8( +fn f8( a0: &mut Map, Value)>, a1: Ptr, ) -> Ptr { - a0.subscript_move(a1, |__k| cpp_move!(__k), || T2::default()) + a0.subscript_move(a1, |__k| cpp_move!(__k), || ::default_constructed()) } fn f9(a0: Ptr, Value)>>) -> BidirectionalIterator<(Value, Value)> { diff --git a/rules/map/tgt_unsafe.rs b/rules/map/tgt_unsafe.rs index 186941ce1e..cf2541b8ed 100644 --- a/rules/map/tgt_unsafe.rs +++ b/rules/map/tgt_unsafe.rs @@ -19,8 +19,8 @@ fn t6() -> T2 { unimplemented!() } -unsafe fn f1(a0: &mut UnsafeMap, a1: T1) -> &mut T2 { - &mut (*a0.subscript(&a1, || T2::default())) +unsafe fn f1(a0: &mut UnsafeMap, a1: T1) -> &mut T2 { + &mut (*a0.subscript(&a1, || ::default_constructed())) } fn f2(a0: UnsafeMap) -> usize { @@ -43,8 +43,8 @@ unsafe fn f7(a0: &mut UnsafeMap, a1: T1) -> *const T2 &raw const (*a0.get(&a1).expect("out of range!")).1 } -unsafe fn f8(a0: &mut UnsafeMap, a1: *mut T1) -> &mut T2 { - &mut (*a0.subscript_move(a1, |__k| cpp_move_unsafe!(__k), || T2::default())) +unsafe fn f8(a0: &mut UnsafeMap, a1: *mut T1) -> &mut T2 { + &mut (*a0.subscript_move(a1, |__k| cpp_move_unsafe!(__k), || ::default_constructed())) } fn f9(a0: UnsafeMap) -> UnsafeBidirectionalIterator<(T1, T2)> { diff --git a/rules/pair/tgt_refcount.rs b/rules/pair/tgt_refcount.rs index addff8790b..17f6a0ab32 100644 --- a/rules/pair/tgt_refcount.rs +++ b/rules/pair/tgt_refcount.rs @@ -5,10 +5,10 @@ use libcc2rs::*; use std::cell::RefCell; use std::rc::Rc; -fn t1() -> (Value, Value) { +fn t1() -> (Value, Value) { ( - Rc::new(RefCell::new(T1::default())), - Rc::new(RefCell::new(T2::default())), + Rc::new(RefCell::new(::default_constructed())), + Rc::new(RefCell::new(::default_constructed())), ) } diff --git a/rules/pair/tgt_unsafe.rs b/rules/pair/tgt_unsafe.rs index 4f17c158b6..7901311266 100644 --- a/rules/pair/tgt_unsafe.rs +++ b/rules/pair/tgt_unsafe.rs @@ -3,8 +3,8 @@ use libcc2rs::*; -fn t1() -> (T1, T2) { - <(T1, T2)>::default() +fn t1() -> (T1, T2) { + (::default_constructed(), ::default_constructed()) } fn t2() -> T1 { @@ -37,8 +37,11 @@ fn f13(a0: &mut (T1, T2), a1: (T1, T2)) -> &mut (T1, T2) { a0 } -fn f14<'a, T1: Default, T2: Default>(a0: &'a mut (T1, T2), a1: &mut (T1, T2)) -> &'a mut (T1, T2) { - *a0 = std::mem::take(&mut *a1); +unsafe fn f14<'a, T1: MoveConstructibleUnsafe, T2: MoveConstructibleUnsafe>(a0: &'a mut (T1, T2), a1: &mut (T1, T2)) -> &'a mut (T1, T2) { + *a0 = ( + move_constructed_unsafe(&raw mut (*a1).0), + move_constructed_unsafe(&raw mut (*a1).1), + ); a0 } diff --git a/rules/unique_ptr/tgt_refcount.rs b/rules/unique_ptr/tgt_refcount.rs index 4b17f09b39..6fae9f658f 100644 --- a/rules/unique_ptr/tgt_refcount.rs +++ b/rules/unique_ptr/tgt_refcount.rs @@ -21,9 +21,9 @@ fn t4() -> Ptr { Ptr::null() } -fn f1, T2: Default>(a0: usize) -> Option>> { +fn f1, T2: DefaultConstructible + ZeroInitialization>(a0: usize) -> Option>> { Some(Rc::new(RefCell::new( - (0..a0).map(|_| ::default()).collect::>(), + (0..a0).map(|_| ::default_constructed()).collect::>(), ))) } diff --git a/rules/unique_ptr/tgt_unsafe.rs b/rules/unique_ptr/tgt_unsafe.rs index f159de037d..5c965faa6a 100644 --- a/rules/unique_ptr/tgt_unsafe.rs +++ b/rules/unique_ptr/tgt_unsafe.rs @@ -19,8 +19,8 @@ fn t4() -> *mut T1 { ::std::ptr::null_mut() } -fn f1, T2: Default>(a0: usize) -> Option> { - Some((0..a0).map(|_| ::default()).collect::>()) +fn f1, T2: DefaultConstructibleUnsafe>(a0: usize) -> Option> { + Some((0..a0).map(|_| ::default_constructed()).collect::>()) } fn f2(a0: &mut Option>) -> *mut T1 { a0.as_deref_mut() @@ -32,7 +32,7 @@ unsafe fn f3(a0: *mut T1) -> Option> { unsafe fn f4(a0: *mut T1) -> Option> { Some(Box::from_raw(a0)) } -unsafe fn f5(a0: &mut Option>, a1: *mut T1) { +unsafe fn f5(a0: &mut Option>, a1: *mut T1) { let _a0: *mut T1 = a1; *a0 = if _a0.is_null() { None @@ -60,7 +60,7 @@ fn f16(a0: &mut Option>) { *a0 = None } -fn f10() -> Option> { +fn f10() -> Option> { None } diff --git a/rules/vector/tgt_refcount.rs b/rules/vector/tgt_refcount.rs index 12753f7ad3..3adbc7c213 100644 --- a/rules/vector/tgt_refcount.rs +++ b/rules/vector/tgt_refcount.rs @@ -58,6 +58,12 @@ fn f72(a0: Ptr) -> RandomAccessIterator { a0.begin() } +fn f73(a0: &mut Vec, a1: Ptr) { + let __a1 = move_constructed(&a1); + a0.push(__a1) +} + + fn f76(a0: Ptr) -> RandomAccessIterator { a0.end() } diff --git a/rules/vector/tgt_unsafe.rs b/rules/vector/tgt_unsafe.rs index d96b2af328..8c6b2bbedc 100644 --- a/rules/vector/tgt_unsafe.rs +++ b/rules/vector/tgt_unsafe.rs @@ -81,8 +81,8 @@ fn f66(a0: &mut Vec, a1: usize) -> &mut T1 { &mut a0[a1] } -fn f67(a0: usize) -> Vec { - Vec::from_fn(a0, |_| ::default()) +fn f67(a0: usize) -> Vec { + Vec::from_fn(a0, |_| ::default_constructed()) } fn f68(a0: &mut Vec) -> &mut T1 { @@ -109,13 +109,13 @@ fn f72(a0: &mut Vec) -> UnsafeRandomAccessIterator { a0.begin() } -fn f73(a0: &mut Vec, a1: &mut T1) { - let __a1 = std::mem::take(&mut *a1); +unsafe fn f73(a0: &mut Vec, a1: &mut T1) { + let __a1 = move_constructed_unsafe(&raw mut *a1); a0.push(__a1) } -fn f74(a0: &mut Vec, a1: usize) { - a0.resize_with(a1, || ::default()) +fn f74(a0: &mut Vec, a1: usize) { + a0.resize_with(a1, || ::default_constructed()) } fn f75(a0: &mut Vec) { @@ -132,7 +132,7 @@ fn f77(a0: &mut Vec, a1: UnsafeRandomAccessIterator, a2: T1) -> Unsa UnsafeRandomAccessIterator::Vec(a0.insert_mut(pos, a2)) } -fn f78(a0: usize, a1: T1) -> Vec { +fn f78(a0: usize, a1: T1) -> Vec { vec![a1; a0] } @@ -203,7 +203,7 @@ unsafe fn f101, T2, T3: UnsafeCppInputIterator, T4>( UnsafeRandomAccessIterator::Vec(a0.as_mut_ptr().add(__off)) } -fn f102(a0: &mut Vec, a1: usize, a2: T1) { +fn f102(a0: &mut Vec, a1: usize, a2: T1) { a0.resize(a1, a2) } From 101ea9c4aeb270d2cc7638cca657ef26743414e3 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Wed, 2 Dec 2026 13:11:06 +0000 Subject: [PATCH 08/13] Add default_constructed on T --- cpp2rust/converter/converter.cpp | 4 ++-- libcc2rs/src/constructor.rs | 24 +++++++++++++++++++++++- libcc2rs/src/lib.rs | 4 +++- libcc2rs/src/swap.rs | 4 ++-- 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/cpp2rust/converter/converter.cpp b/cpp2rust/converter/converter.cpp index 4928f03073..30dddb7e42 100644 --- a/cpp2rust/converter/converter.cpp +++ b/cpp2rust/converter/converter.cpp @@ -6880,8 +6880,8 @@ std::string Converter::ConvertGenericCall( assert(expr && "unbound generic outside an expression rule"); type = RuleRegistry::GetGenericType(ctx_, expr, call.generic); } - if (call.method == "default") { - assert(call_args.empty() && "default takes no arguments"); + if (call.method == "default_constructed") { + assert(call_args.empty() && "default_constructed takes no arguments"); return GetUnboxedDefaultAsString(type); } if (call.method == "cpp_from" || call.method == "cpp_from_move") { diff --git a/libcc2rs/src/constructor.rs b/libcc2rs/src/constructor.rs index 99e569edaa..268ef497cb 100644 --- a/libcc2rs/src/constructor.rs +++ b/libcc2rs/src/constructor.rs @@ -6,12 +6,22 @@ use crate::capture::{ }; use crate::fn_ptr::{FnPtr, FnSig}; use crate::initialization::ZeroInitialization; -use crate::rc::Ptr; +use crate::rc::{AsPointer, Ptr, Value}; use crate::reinterpret::ByteRepr; use crate::void::AnyPtr; pub trait DefaultConstructible: Sized { fn default_constructor(this: &Ptr); + + // TODO: remove default_constructed. + fn default_constructed() -> Self + where + Self: ZeroInitialization, + { + let dst: Value = std::rc::Rc::new(std::cell::RefCell::new(Self::zero_init())); + Self::default_constructor(&AsPointer::::as_pointer(&dst)); + std::rc::Rc::try_unwrap(dst).ok().unwrap().into_inner() + } } pub trait MoveConstructible: Sized { @@ -81,6 +91,18 @@ pub trait DefaultConstructibleUnsafe { /// # Safety /// `self` must be valid for writes. unsafe fn default_constructor(&mut self); + + // TODO: remove default_constructed. + fn default_constructed() -> Self + where + Self: Sized, + { + let mut dst = std::mem::MaybeUninit::::zeroed(); + unsafe { + (*dst.as_mut_ptr()).default_constructor(); + dst.assume_init() + } + } } pub trait MoveConstructibleUnsafe { diff --git a/libcc2rs/src/lib.rs b/libcc2rs/src/lib.rs index ab37d61f7a..28e1d43f95 100644 --- a/libcc2rs/src/lib.rs +++ b/libcc2rs/src/lib.rs @@ -68,7 +68,9 @@ mod initialization; pub use initialization::{ZeroInitialization, ZeroInitializationUnsafe}; mod swap; -pub use swap::{copy_constructed, swap_by_move, swap_by_move_unsafe}; +pub use swap::{ + copy_constructed, move_constructed, move_constructed_unsafe, 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 5a73a257f4..3ea7c2c178 100644 --- a/libcc2rs/src/swap.rs +++ b/libcc2rs/src/swap.rs @@ -48,7 +48,7 @@ pub fn pointer(value: &Value) -> Ptr { as AsPointer>::as_pointer(value) } -fn move_constructed(src: &Ptr) -> T { +pub 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() @@ -68,7 +68,7 @@ unsafe fn copy_constructed_unsafe(src: *const T) -> } } -unsafe fn move_constructed_unsafe(src: *mut T) -> T { +pub unsafe fn move_constructed_unsafe(src: *mut T) -> T { let mut dst = std::mem::MaybeUninit::::uninit(); unsafe { (*dst.as_mut_ptr()).move_constructor(src); From fa38a5e0cae756660634f5d093c584774f67d767 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Wed, 2 Dec 2026 13:29:07 +0000 Subject: [PATCH 09/13] Update tests --- .../refcount/sequence.reqmts-unsupported.rs | 8 +- .../out/unsafe/sequence.reqmts-unsupported.rs | 2 +- .../expr.post/out/refcount/expr.const.cast.rs | 11 +- .../expr.post/out/unsafe/expr.const.cast.rs | 2 +- .../expr.compound/out/refcount/expr.cast.rs | 11 +- .../expr.compound/out/unsafe/expr.cast.rs | 2 +- .../utility/out/refcount/forward-helpers.rs | 14 +- .../utilities/utility/out/refcount/forward.rs | 9 +- .../utility/out/unsafe/forward-helpers.rs | 2 +- .../utilities/utility/out/unsafe/forward.rs | 8 +- tests/unit/out/refcount/12_test.rs | 2 +- .../out/refcount/array_of_noncopy_struct.rs | 11 +- tests/unit/out/refcount/auto.rs | 22 +- tests/unit/out/refcount/cast.rs | 72 ++--- tests/unit/out/refcount/class_templates.rs | 11 +- tests/unit/out/refcount/clone_vs_move.rs | 13 +- tests/unit/out/refcount/comma_operator.rs | 11 +- .../unit/out/refcount/compound_assign_ref.rs | 11 +- .../refcount/container_element_receiver.rs | 33 +-- .../unit/out/refcount/container_field_addr.rs | 2 +- tests/unit/out/refcount/copy_assign.rs | 11 +- .../unit/out/refcount/copy_move_defaulted.rs | 40 ++- .../refcount/elidable_iterator_copy_cxx11.rs | 46 ++- .../out/refcount/field_method_receiver.rs | 2 +- tests/unit/out/refcount/field_pointers.rs | 20 +- tests/unit/out/refcount/find.rs | 106 ++++--- tests/unit/out/refcount/fn_ptr_stable_sort.rs | 53 ++-- .../refcount/foreach_disjoint_field_borrow.rs | 11 +- tests/unit/out/refcount/foreach_double.rs | 57 ++-- tests/unit/out/refcount/foreach_mut.rs | 45 ++- tests/unit/out/refcount/implicit_autoref.rs | 44 ++- .../out/refcount/inline_container_fields.rs | 13 +- tests/unit/out/refcount/iterators.rs | 4 +- tests/unit/out/refcount/map.rs | 157 +++++----- tests/unit/out/refcount/move_assign.rs | 6 +- tests/unit/out/refcount/move_ctor.rs | 12 +- tests/unit/out/refcount/push_emplace_back.rs | 84 +++--- .../refcount/reinterpret_cast_vec_write.rs | 22 +- tests/unit/out/refcount/return_move.rs | 20 +- tests/unit/out/refcount/sort.rs | 118 +++----- tests/unit/out/refcount/string.rs | 126 ++++---- tests/unit/out/refcount/string_moved_from.rs | 11 +- tests/unit/out/refcount/string_substr.rs | 168 ++++++----- tests/unit/out/refcount/vector.rs | 271 ++++++++---------- tests/unit/out/refcount/vector2.rs | 110 +++---- .../refcount/vector_deque_vector_string.rs | 8 +- .../out/refcount/vector_subscript_direct.rs | 30 +- .../out/refcount/vector_with_allocator.rs | 222 ++++++-------- tests/unit/out/unsafe/12_test.rs | 2 +- .../out/unsafe/array_of_noncopy_struct.rs | 2 +- tests/unit/out/unsafe/auto.rs | 4 +- tests/unit/out/unsafe/cast.rs | 12 +- tests/unit/out/unsafe/class_templates.rs | 2 +- tests/unit/out/unsafe/clone_vs_move.rs | 4 +- tests/unit/out/unsafe/comma_operator.rs | 2 +- tests/unit/out/unsafe/compound_assign_ref.rs | 2 +- .../out/unsafe/container_element_receiver.rs | 2 +- tests/unit/out/unsafe/container_field_addr.rs | 2 +- tests/unit/out/unsafe/copy_assign.rs | 2 +- tests/unit/out/unsafe/copy_move_defaulted.rs | 14 +- .../unsafe/elidable_iterator_copy_cxx11.rs | 4 +- .../unit/out/unsafe/field_method_receiver.rs | 2 +- tests/unit/out/unsafe/field_pointers.rs | 2 +- tests/unit/out/unsafe/find.rs | 6 +- tests/unit/out/unsafe/fn_ptr_stable_sort.rs | 6 +- .../unsafe/foreach_disjoint_field_borrow.rs | 2 +- tests/unit/out/unsafe/foreach_double.rs | 12 +- tests/unit/out/unsafe/foreach_mut.rs | 12 +- tests/unit/out/unsafe/implicit_autoref.rs | 8 +- .../out/unsafe/inline_container_fields.rs | 4 +- tests/unit/out/unsafe/iterators.rs | 4 +- tests/unit/out/unsafe/map.rs | 6 +- tests/unit/out/unsafe/move_assign.rs | 16 +- tests/unit/out/unsafe/move_ctor.rs | 22 +- tests/unit/out/unsafe/pair.rs | 10 +- tests/unit/out/unsafe/push_emplace_back.rs | 8 +- .../out/unsafe/reinterpret_cast_vec_write.rs | 4 +- tests/unit/out/unsafe/return_move.rs | 2 +- tests/unit/out/unsafe/sort.rs | 20 +- tests/unit/out/unsafe/vector.rs | 22 +- tests/unit/out/unsafe/vector2.rs | 20 +- .../out/unsafe/vector_deque_vector_string.rs | 40 ++- .../out/unsafe/vector_subscript_direct.rs | 8 +- .../unit/out/unsafe/vector_with_allocator.rs | 28 +- 84 files changed, 1085 insertions(+), 1307 deletions(-) diff --git a/tests/std/containers/container.requirements/out/refcount/sequence.reqmts-unsupported.rs b/tests/std/containers/container.requirements/out/refcount/sequence.reqmts-unsupported.rs index 5e6b8ba2af..5bafc2821e 100644 --- a/tests/std/containers/container.requirements/out/refcount/sequence.reqmts-unsupported.rs +++ b/tests/std/containers/container.requirements/out/refcount/sequence.reqmts-unsupported.rs @@ -33,11 +33,9 @@ pub fn test_1() { ))); let pairs: Value>>, Value)>> = Rc::new(RefCell::new(Vec::new())); - match (source.as_pointer(),) { - (__tmp_1,) => { - let __a1 = move_constructed(&__tmp_1); - (*pairs.borrow_mut()).push(__a1) - } + { + let __a1 = ({ std::mem::take(&mut (*source.borrow_mut())) }); + (*pairs.borrow_mut()).push(__a1) }; assert!(((({ (*(*pairs.borrow())[0_usize].0.borrow()).as_pointer() }).read()) == 1)); assert!(({ (*(*source.borrow()).0.borrow()).is_none() })); diff --git a/tests/std/containers/container.requirements/out/unsafe/sequence.reqmts-unsupported.rs b/tests/std/containers/container.requirements/out/unsafe/sequence.reqmts-unsupported.rs index f5f606d7b4..1ab56c3d53 100644 --- a/tests/std/containers/container.requirements/out/unsafe/sequence.reqmts-unsupported.rs +++ b/tests/std/containers/container.requirements/out/unsafe/sequence.reqmts-unsupported.rs @@ -31,7 +31,7 @@ pub unsafe fn test_1() { (Some(Box::from_raw((Box::leak(Box::new(1)) as *mut i32))), 2); let mut pairs: Vec<(Option>, i32)> = Vec::new(); { - let __a1 = move_constructed_unsafe(&raw mut source); + let __a1 = std::mem::take(&mut source); pairs.push(__a1) }; assert!( 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 f93681baaf..c6cddfa9e8 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 @@ -41,13 +41,10 @@ pub fn test_1() { assert!(({ (*pair.borrow()).x } == 2)); let vec_: Value> = Rc::new(RefCell::new(Vec::from([1]))); let cvec: Ptr> = vec_.as_pointer(); - ({ - let __tmp_0: Value = Rc::new(RefCell::new(2)); - { - let __a1 = move_constructed(&__tmp_0.as_pointer()); - cvec.with_mut(|__v: &mut Vec| __v.push(__a1)) - } - }); + { + let __a1 = 2; + cvec.with_mut(|__v: &mut Vec| __v.push(__a1)) + }; assert!(({ ((*vec_.borrow()).len() == 2_usize) })); } pub fn main() { 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 e9217f5803..0e58a2d020 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 @@ -38,7 +38,7 @@ pub unsafe fn test_1() { let mut vec_: Vec = Vec::from([1]); let cvec: *const Vec = &vec_; { - let __a1 = move_constructed_unsafe(&raw mut 2); + let __a1 = 2; (*(&raw const (*cvec)).cast_mut()).push(__a1) }; assert!(((vec_.len()) == (2_usize))); diff --git a/tests/std/expr/expr.compound/out/refcount/expr.cast.rs b/tests/std/expr/expr.compound/out/refcount/expr.cast.rs index 1fa9fd8735..aac015a39c 100644 --- a/tests/std/expr/expr.compound/out/refcount/expr.cast.rs +++ b/tests/std/expr/expr.compound/out/refcount/expr.cast.rs @@ -21,13 +21,10 @@ pub fn test_2() { assert!(({ ((*v.borrow()) == 8) })); let vec_: Value> = Rc::new(RefCell::new(Vec::from([1]))); let cvec: Ptr> = vec_.as_pointer(); - ({ - let __tmp_0: Value = Rc::new(RefCell::new(2)); - { - let __a1 = move_constructed(&__tmp_0.as_pointer()); - cvec.with_mut(|__v: &mut Vec| __v.push(__a1)) - } - }); + { + let __a1 = 2; + cvec.with_mut(|__v: &mut Vec| __v.push(__a1)) + }; assert!(({ ((*vec_.borrow()).len() == 2_usize) })); } pub fn main() { diff --git a/tests/std/expr/expr.compound/out/unsafe/expr.cast.rs b/tests/std/expr/expr.compound/out/unsafe/expr.cast.rs index d18ac825c6..93c9f95cf1 100644 --- a/tests/std/expr/expr.compound/out/unsafe/expr.cast.rs +++ b/tests/std/expr/expr.compound/out/unsafe/expr.cast.rs @@ -22,7 +22,7 @@ pub unsafe fn test_2() { let mut vec_: Vec = Vec::from([1]); let cvec: *const Vec = &vec_; { - let __a1 = move_constructed_unsafe(&raw mut 2); + let __a1 = 2; (*(&raw const (*cvec)).cast_mut()).push(__a1) }; assert!(((vec_.len()) == (2_usize))); diff --git a/tests/std/utilities/utility/out/refcount/forward-helpers.rs b/tests/std/utilities/utility/out/refcount/forward-helpers.rs index 85cf44f7e7..49fd26de92 100644 --- a/tests/std/utilities/utility/out/refcount/forward-helpers.rs +++ b/tests/std/utilities/utility/out/refcount/forward-helpers.rs @@ -161,18 +161,16 @@ pub fn test_4() { __bytes.push(0); __bytes })); - match (text.as_pointer(),) { - (__tmp_0,) => { - let __a1 = move_constructed(&__tmp_0); - (*strings.borrow_mut()).push(__a1) - } + { + let __a1 = ({ std::mem::replace(&mut (*text.borrow_mut()), vec![0]) }); + (*strings.borrow_mut()).push(__a1) }; assert!( ({ match (strings.decay().offset(0_usize),) { - (__tmp_1,) => Ptr::::from_string_literal(b"text").with_c_str(|__s| { - (*__tmp_1.upgrade().deref()) - [..(*__tmp_1.upgrade().deref()).len().saturating_sub(1)] + (__tmp_0,) => Ptr::::from_string_literal(b"text").with_c_str(|__s| { + (*__tmp_0.upgrade().deref()) + [..(*__tmp_0.upgrade().deref()).len().saturating_sub(1)] == *__s }), } diff --git a/tests/std/utilities/utility/out/refcount/forward.rs b/tests/std/utilities/utility/out/refcount/forward.rs index 999c8761e3..04f175ced7 100644 --- a/tests/std/utilities/utility/out/refcount/forward.rs +++ b/tests/std/utilities/utility/out/refcount/forward.rs @@ -52,7 +52,7 @@ pub fn test_1() { y: 6, })); { - let __a1 = move_constructed(&element.as_pointer()); + let __a1 = ({ (*element.borrow()) }); points.push(__a1) }; assert!((points[0_usize].x == 5) && (points[0_usize].y == 6)); @@ -94,7 +94,12 @@ pub fn test_2() { Rc::new(RefCell::new(::zero_init())); p10_move_constructor_AImpl::construct(&element.as_pointer(), { 2 }); { - let __a1 = move_constructed(&element.as_pointer()); + let __a1 = { + let __v: Value = + Rc::new(RefCell::new(::zero_init())); + MoveConstructible::move_constructor(&__v.as_pointer(), { element.as_pointer() }); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }; values.push(__a1) }; assert!((values[0_usize].value == 2)); diff --git a/tests/std/utilities/utility/out/unsafe/forward-helpers.rs b/tests/std/utilities/utility/out/unsafe/forward-helpers.rs index 1b1cf5ff53..6452e83914 100644 --- a/tests/std/utilities/utility/out/unsafe/forward-helpers.rs +++ b/tests/std/utilities/utility/out/unsafe/forward-helpers.rs @@ -157,7 +157,7 @@ pub unsafe fn test_4() { ) .to_vec(); { - let __a1 = move_constructed_unsafe(&raw mut text); + let __a1 = std::mem::replace(&mut text, vec![0]); strings.push(__a1) }; assert!( diff --git a/tests/std/utilities/utility/out/unsafe/forward.rs b/tests/std/utilities/utility/out/unsafe/forward.rs index 6821edefec..5741c6cf70 100644 --- a/tests/std/utilities/utility/out/unsafe/forward.rs +++ b/tests/std/utilities/utility/out/unsafe/forward.rs @@ -45,7 +45,7 @@ pub unsafe fn test_1() { let mut element: p9_move_trivially_copyable_Point = p9_move_trivially_copyable_Point { x: 5, y: 6 }; { - let __a1 = move_constructed_unsafe(&raw mut element); + let __a1 = element; points.push(__a1) }; assert!(((points[(0_usize)].x) == (5)) && ((points[(0_usize)].y) == (6))); @@ -86,7 +86,11 @@ pub unsafe fn test_2() { let mut element: p10_move_constructor_A = ::zero_init(); p10_move_constructor_A::construct(&mut element, { 2 }); { - let __a1 = move_constructed_unsafe(&raw mut element); + let __a1 = { + let mut __v: p10_move_constructor_A = ::zero_init(); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut element }); + __v + }; values.push(__a1) }; assert!(((values[(0_usize)].value) == (2))); diff --git a/tests/unit/out/refcount/12_test.rs b/tests/unit/out/refcount/12_test.rs index eb98d63e51..9d34100e87 100644 --- a/tests/unit/out/refcount/12_test.rs +++ b/tests/unit/out/refcount/12_test.rs @@ -14,7 +14,7 @@ fn main_0() -> i32 { let v: Value>> = Rc::new(RefCell::new(Vec::new())); match (Rc::new(RefCell::new(Vec::from_fn(10_usize, |_| 0_i32))).as_pointer(),) { (__tmp_0,) => { - let __a1 = move_constructed(&(__tmp_0).clone()); + let __a1 = __tmp_0.with_mut(std::mem::take); (*v.borrow_mut()).push(__a1) } }; diff --git a/tests/unit/out/refcount/array_of_noncopy_struct.rs b/tests/unit/out/refcount/array_of_noncopy_struct.rs index 58bd30f55a..62c02d5cfb 100644 --- a/tests/unit/out/refcount/array_of_noncopy_struct.rs +++ b/tests/unit/out/refcount/array_of_noncopy_struct.rs @@ -54,13 +54,10 @@ fn main_0() -> i32 { Rc::try_unwrap(__v).ok().unwrap().into_inner() }); arr[(0) as usize].tag = 7; - ({ - let __tmp_0: Value = Rc::new(RefCell::new(42)); - { - let __a1 = move_constructed(&__tmp_0.as_pointer()); - arr[(1) as usize].data.push(__a1) - } - }); + { + let __a1 = 42; + arr[(1) as usize].data.push(__a1) + }; assert!((arr[(0) as usize].tag == 7)); assert!((arr[(1) as usize].data.len() == 1_usize)); assert!((arr[(1) as usize].data[0_usize] == 42)); diff --git a/tests/unit/out/refcount/auto.rs b/tests/unit/out/refcount/auto.rs index 305afc0bc5..70764424af 100644 --- a/tests/unit/out/refcount/auto.rs +++ b/tests/unit/out/refcount/auto.rs @@ -15,20 +15,14 @@ fn main_0() -> i32 { let mut x2: i16 = 2_i16; let mut x3: u32 = 4_u32; let v: Value> = Rc::new(RefCell::new(Vec::new())); - ({ - let __tmp_0: Value = Rc::new(RefCell::new(1)); - { - let __a1 = move_constructed(&__tmp_0.as_pointer()); - (*v.borrow_mut()).push(__a1) - } - }); - ({ - let __tmp_1: Value = Rc::new(RefCell::new(2)); - { - let __a1 = move_constructed(&__tmp_1.as_pointer()); - (*v.borrow_mut()).push(__a1) - } - }); + { + let __a1 = 1; + (*v.borrow_mut()).push(__a1) + }; + { + let __a1 = 2; + (*v.borrow_mut()).push(__a1) + }; let mut sum: i32 = 0; 'loop_: for elem in IterRange::new(v.decay().begin(), v.decay().end()) { let mut elem: i32 = (elem.iter_deref().read()); diff --git a/tests/unit/out/refcount/cast.rs b/tests/unit/out/refcount/cast.rs index 688fc25557..d2bdfc4bdf 100644 --- a/tests/unit/out/refcount/cast.rs +++ b/tests/unit/out/refcount/cast.rs @@ -279,28 +279,19 @@ pub fn vector_capacity_4() { (*__b0).reserve_exact(4_usize - len_0 as usize); } }); - ({ - let __tmp_1: Value = Rc::new(RefCell::new(1)); - { - let __a1 = move_constructed(&__tmp_1.as_pointer()); - (*v.borrow_mut()).push(__a1) - } - }); + { + let __a1 = 1; + (*v.borrow_mut()).push(__a1) + }; let mut i0: usize = (v.decay().offset(0_usize)).to_int(); - ({ - let __tmp_2: Value = Rc::new(RefCell::new(2)); - { - let __a1 = move_constructed(&__tmp_2.as_pointer()); - (*v.borrow_mut()).push(__a1) - } - }); - ({ - let __tmp_3: Value = Rc::new(RefCell::new(3)); - { - let __a1 = move_constructed(&__tmp_3.as_pointer()); - (*v.borrow_mut()).push(__a1) - } - }); + { + let __a1 = 2; + (*v.borrow_mut()).push(__a1) + }; + { + let __a1 = 3; + (*v.borrow_mut()).push(__a1) + }; assert!( ((v.decay().offset(2_usize)).to_int() == ((i0 as u64).wrapping_add( @@ -393,32 +384,23 @@ pub fn nested_5() { .items .reserve_exact(4_usize - len_0 as usize); }; - ({ - let __tmp_4: Value = Rc::new(RefCell::new(1)); - { - let __a1 = move_constructed(&__tmp_4.as_pointer()); - (*b.borrow_mut()).items.push(__a1) - } - }); - ({ - let __tmp_5: Value = Rc::new(RefCell::new(2)); - { - let __a1 = move_constructed(&__tmp_5.as_pointer()); - (*b.borrow_mut()).items.push(__a1) - } - }); + { + let __a1 = 1; + (*b.borrow_mut()).items.push(__a1) + }; + { + let __a1 = 2; + (*b.borrow_mut()).items.push(__a1) + }; let mut ib: usize = (field_ref!(b.as_pointer(), items).decay().offset(0_usize)).to_int(); assert!( ((field_ref!(b.as_pointer(), items).decay().offset(1_usize)).to_int() == ((ib as u64).wrapping_add((::std::mem::size_of::() as u64)) as usize)) ); - ({ - let __tmp_6: Value = Rc::new(RefCell::new(3)); - { - let __a1 = move_constructed(&__tmp_6.as_pointer()); - (*b.borrow_mut()).items.push(__a1) - } - }); + { + let __a1 = 3; + (*b.borrow_mut()).items.push(__a1) + }; assert!( ((field_ref!(b.as_pointer(), items).decay().offset(2_usize)).to_int() == ((ib as u64).wrapping_add( @@ -512,9 +494,9 @@ pub fn c_strings_8() { ); let d: Value> = Rc::new(RefCell::new((0..6).map(|_| 0_i8).collect::>())); { - let mut __tmp_7 = { (>::from_int(d.decay().to_int())).to_any() }; - __tmp_7.memcpy(&(p).to_any(), ::std::mem::size_of::<[i8; 6]>()); - (__tmp_7).clone() + let mut __tmp_1 = { (>::from_int(d.decay().to_int())).to_any() }; + __tmp_1.memcpy(&(p).to_any(), ::std::mem::size_of::<[i8; 6]>()); + (__tmp_1).clone() }; assert!( ((>::from_int(d.decay().to_int())) diff --git a/tests/unit/out/refcount/class_templates.rs b/tests/unit/out/refcount/class_templates.rs index efcc936423..51e3dc3a62 100644 --- a/tests/unit/out/refcount/class_templates.rs +++ b/tests/unit/out/refcount/class_templates.rs @@ -270,13 +270,10 @@ pub fn main() { } fn main_0() -> i32 { let mut ev: Vec = Vec::new(); - ({ - let __tmp_0: Value = Rc::new(RefCell::new(Elem { i: 2 })); - { - let __a1 = move_constructed(&(__tmp_0.as_pointer())); - ev.push(__a1) - } - }); + { + let __a1 = (Elem { i: 2 }); + ev.push(__a1) + }; assert!((ev[0_usize].i == 2)); assert!(((({ Boxed_short_::twice(2_i16,) }) as i32) == 4)); let oi: Value = Rc::new(RefCell::new(Outer_int_ { v: 3 })); diff --git a/tests/unit/out/refcount/clone_vs_move.rs b/tests/unit/out/refcount/clone_vs_move.rs index de48bd8e45..06587c7a98 100644 --- a/tests/unit/out/refcount/clone_vs_move.rs +++ b/tests/unit/out/refcount/clone_vs_move.rs @@ -207,7 +207,7 @@ fn main_0() -> i32 { 'for_body: { match (Rc::new(RefCell::new(Vec::from_fn(10_usize, |_| 0_i32))).as_pointer(),) { (__tmp_0,) => { - let __a1 = move_constructed(&(__tmp_0).clone()); + let __a1 = __tmp_0.with_mut(std::mem::take); (*m1.borrow_mut()).push(__a1) } }; @@ -366,13 +366,10 @@ fn main_0() -> i32 { Rc::new(RefCell::new((*pair3.borrow()).0.borrow().clone())), Rc::new(RefCell::new((*pair3.borrow()).1.borrow().clone())), ))); - ({ - let __tmp_1: Value = Rc::new(RefCell::new(1)); - { - let __a1 = move_constructed(&__tmp_1.as_pointer()); - (*(*pair4.borrow()).0.borrow_mut()).push(__a1) - } - }); + { + let __a1 = 1; + (*(*pair4.borrow()).0.borrow_mut()).push(__a1) + }; (*(*pair4.borrow()).1.borrow_mut()) = 1; assert!(({ ((*(*pair4.borrow()).0.borrow()).len() == 1_usize) })); assert!(({ ((*(*pair4.borrow()).1.borrow()) == 1) })); diff --git a/tests/unit/out/refcount/comma_operator.rs b/tests/unit/out/refcount/comma_operator.rs index b320f3408b..9d51ebf6cb 100644 --- a/tests/unit/out/refcount/comma_operator.rs +++ b/tests/unit/out/refcount/comma_operator.rs @@ -82,13 +82,10 @@ fn main_0() -> i32 { } }) .clone(); - ({ - let __tmp_0: Value = Rc::new(RefCell::new(3)); - { - let __a1 = move_constructed(&__tmp_0.as_pointer()); - v2.push(__a1) - } - }); + { + let __a1 = 3; + v2.push(__a1) + }; assert!((a == 5)); assert!(({ ((*v1.borrow()).len() == 2_usize) })); assert!((v2.len() == 3_usize)); diff --git a/tests/unit/out/refcount/compound_assign_ref.rs b/tests/unit/out/refcount/compound_assign_ref.rs index bb97bc1847..317daf6323 100644 --- a/tests/unit/out/refcount/compound_assign_ref.rs +++ b/tests/unit/out/refcount/compound_assign_ref.rs @@ -12,13 +12,10 @@ pub fn main() { } fn main_0() -> i32 { let mut v: Vec = Vec::new(); - ({ - let __tmp_0: Value = Rc::new(RefCell::new(10)); - { - let __a1 = move_constructed(&__tmp_0.as_pointer()); - v.push(__a1) - } - }); + { + let __a1 = 10; + v.push(__a1) + }; v[0] += 5; assert!((v[0] == 15)); return 0; diff --git a/tests/unit/out/refcount/container_element_receiver.rs b/tests/unit/out/refcount/container_element_receiver.rs index 33b54dcc0d..0c10054ba6 100644 --- a/tests/unit/out/refcount/container_element_receiver.rs +++ b/tests/unit/out/refcount/container_element_receiver.rs @@ -99,30 +99,27 @@ fn main_0() -> i32 { .write(7); assert!(((vec_elem!(h.as_pointer(), vec_, 0_usize).read()) == 7)); let m: Value, Value>)>> = Rc::new(RefCell::new(Map::new())); - ({ - let __tmp_1: Value = Rc::new(RefCell::new(8)); - { - let __a1 = move_constructed(&__tmp_1.as_pointer()); - match (Rc::new(RefCell::new(1)).as_pointer(),) { - (__tmp_2,) => { - ({ - (*m.borrow_mut()).subscript_move( - __tmp_2, - |__k| cpp_move!(__k), - || Default::default(), - ) - }) - } + { + let __a1 = 8; + match (Rc::new(RefCell::new(1)).as_pointer(),) { + (__tmp_1,) => { + ({ + (*m.borrow_mut()).subscript_move( + __tmp_1, + |__k| cpp_move!(__k), + || Default::default(), + ) + }) } - .with_mut(|__v: &mut Vec| __v.push(__a1)) } - }); + .with_mut(|__v: &mut Vec| __v.push(__a1)) + }; assert!( ((match (Rc::new(RefCell::new(1)).as_pointer(),) { - (__tmp_3,) => { + (__tmp_2,) => { ({ (*m.borrow_mut()).subscript_move( - __tmp_3, + __tmp_2, |__k| cpp_move!(__k), || Default::default(), ) diff --git a/tests/unit/out/refcount/container_field_addr.rs b/tests/unit/out/refcount/container_field_addr.rs index 44dc7f84df..7a1352fc2a 100644 --- a/tests/unit/out/refcount/container_field_addr.rs +++ b/tests/unit/out/refcount/container_field_addr.rs @@ -45,7 +45,7 @@ pub fn run_1(mut h: Ptr) { let mut pv: Ptr> = (field_ref!(h, v).as_pointer()); match (Rc::new(RefCell::new((((*pv.upgrade().deref()).len()) as i32))).as_pointer(),) { (__tmp_0,) => { - let __a1 = move_constructed(&(__tmp_0).clone()); + let __a1 = (__tmp_0.read()); pv.with_mut(|__v: &mut Vec| __v.push(__a1)) } }; diff --git a/tests/unit/out/refcount/copy_assign.rs b/tests/unit/out/refcount/copy_assign.rs index efd32cd6e6..6acca04f8f 100644 --- a/tests/unit/out/refcount/copy_assign.rs +++ b/tests/unit/out/refcount/copy_assign.rs @@ -432,13 +432,10 @@ fn main_0() -> i32 { let e2: Value = Rc::new(RefCell::new(::zero_init())); DefaultConstructible::default_constructor(&e2.as_pointer()); - ({ - let __tmp_1: Value = Rc::new(RefCell::new(5)); - { - let __a1 = move_constructed(&__tmp_1.as_pointer()); - (*e1.borrow_mut()).w.push(__a1) - } - }); + { + let __a1 = 5; + (*e1.borrow_mut()).w.push(__a1) + }; ({ CopyAssignable::copy_assign(&e2.as_pointer(), e1.as_pointer()) }); assert!( ({ diff --git a/tests/unit/out/refcount/copy_move_defaulted.rs b/tests/unit/out/refcount/copy_move_defaulted.rs index 59e0f8b8b0..e935229fc9 100644 --- a/tests/unit/out/refcount/copy_move_defaulted.rs +++ b/tests/unit/out/refcount/copy_move_defaulted.rs @@ -708,7 +708,7 @@ fn main_0() -> i32 { .as_pointer(),) { (__tmp_1,) => { - let __a1 = move_constructed(&(__tmp_1).clone()); + let __a1 = ({ (*__tmp_1.upgrade().deref()).clone() }); vec_.push(__a1) } }; @@ -782,14 +782,16 @@ fn main_0() -> i32 { }) ); let bufs: Value> = Rc::new(RefCell::new(Vec::new())); - match (r.as_pointer(),) { - (__tmp_2,) => { - let __a1 = move_constructed(&__tmp_2); - (*bufs.borrow_mut()).push(__a1) - } + { + let __a1 = { + let __v: Value = Rc::new(RefCell::new(::zero_init())); + MoveConstructible::move_constructor(&__v.as_pointer(), { r.as_pointer() }); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }; + (*bufs.borrow_mut()).push(__a1) }; { - let mut __tmp_3 = { + let mut __tmp_2 = { { let __v: Value = Rc::new(RefCell::new(::zero_init())); MoveConstructible::move_constructor(&__v.as_pointer(), { @@ -798,7 +800,7 @@ fn main_0() -> i32 { Rc::try_unwrap(__v).ok().unwrap().into_inner() } }; - (*bufs.borrow_mut()).push(__tmp_3); + (*bufs.borrow_mut()).push(__tmp_2); }; assert!( ({ @@ -809,13 +811,10 @@ fn main_0() -> i32 { ); let o1: Value = Rc::new(RefCell::new(::zero_init())); DefaultConstructible::default_constructor(&o1.as_pointer()); - ({ - let __tmp_4: Value = Rc::new(RefCell::new(5)); - { - let __a1 = move_constructed(&__tmp_4.as_pointer()); - (*o1.borrow_mut()).data.push(__a1) - } - }); + { + let __a1 = 5; + (*o1.borrow_mut()).data.push(__a1) + }; (*o1.borrow_mut()).n = 5; array_elem!(o1.as_pointer(), arr, 0).write(5); array_elem!(o1.as_pointer(), arr, 1).write(6); @@ -984,13 +983,10 @@ fn main_0() -> i32 { let a3: Value = Rc::new(RefCell::new(::zero_init())); DefaultConstructible::default_constructor(&a3.as_pointer()); (*a1.borrow_mut()).v = 3; - ({ - let __tmp_5: Value = Rc::new(RefCell::new(4)); - { - let __a1 = move_constructed(&__tmp_5.as_pointer()); - (*a1.borrow_mut()).w.push(__a1) - } - }); + { + let __a1 = 4; + (*a1.borrow_mut()).w.push(__a1) + }; ({ CopyAssignable::copy_assign(&a2.as_pointer(), a1.as_pointer()) }); assert!( ({ diff --git a/tests/unit/out/refcount/elidable_iterator_copy_cxx11.rs b/tests/unit/out/refcount/elidable_iterator_copy_cxx11.rs index c46cf3578e..144e6264c0 100644 --- a/tests/unit/out/refcount/elidable_iterator_copy_cxx11.rs +++ b/tests/unit/out/refcount/elidable_iterator_copy_cxx11.rs @@ -12,28 +12,22 @@ pub fn main() { } fn main_0() -> i32 { let v: Value> = Rc::new(RefCell::new(Vec::new())); - ({ - let __tmp_0: Value = Rc::new(RefCell::new(4)); - { - let __a1 = move_constructed(&__tmp_0.as_pointer()); - (*v.borrow_mut()).push(__a1) - } - }); - ({ - let __tmp_1: Value = Rc::new(RefCell::new(7)); - { - let __a1 = move_constructed(&__tmp_1.as_pointer()); - (*v.borrow_mut()).push(__a1) - } - }); + { + let __a1 = 4; + (*v.borrow_mut()).push(__a1) + }; + { + let __a1 = 7; + (*v.borrow_mut()).push(__a1) + }; let it: Value> = Rc::new(RefCell::new( ({ - let __tmp_4: Value = Rc::new(RefCell::new(7)); + let __tmp_2: Value = Rc::new(RefCell::new(7)); { - let mut __tmp_2 = { v.decay().begin() }; - let mut __tmp_3 = { v.decay().end() }; - let mut __it = (__tmp_2).clone(); - while __it != __tmp_3 && !CppEq::equal(&__it.iter_deref(), &__tmp_4.as_pointer()) { + let mut __tmp_0 = { v.decay().begin() }; + let mut __tmp_1 = { v.decay().end() }; + let mut __it = (__tmp_0).clone(); + while __it != __tmp_1 && !CppEq::equal(&__it.iter_deref(), &__tmp_2.as_pointer()) { __it.iter_inc(); } __it @@ -43,21 +37,21 @@ fn main_0() -> i32 { assert!((*it.borrow()) != v.decay().end()); assert!(((({ (*it.borrow()).iter_deref() }).read()) == 7)); { - let mut __tmp_5 = { v.decay().begin() }; - let __n = v.decay().end().iter_distance(&__tmp_5); + let mut __tmp_3 = { v.decay().begin() }; + let __n = v.decay().end().iter_distance(&__tmp_3); 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; - Swappable::swap(&__tmp_5.iter_at(__i), __tmp_5.iter_at(__j)); + Swappable::swap(&__tmp_3.iter_at(__i), __tmp_3.iter_at(__j)); } }; { - let mut __tmp_6 = { v.decay().begin() }; - let __n = v.decay().end().iter_distance(&__tmp_6); + let mut __tmp_4 = { v.decay().begin() }; + let __n = v.decay().end().iter_distance(&__tmp_4); let mut __order: Vec = (0..__n).collect(); - __order.sort_by(|&__x, &__y| cpp_cmp(&__tmp_6.iter_at(__x), &__tmp_6.iter_at(__y))); - reorder(__order, |__i| __tmp_6.iter_at(__i)); + __order.sort_by(|&__x, &__y| cpp_cmp(&__tmp_4.iter_at(__x), &__tmp_4.iter_at(__y))); + reorder(__order, |__i| __tmp_4.iter_at(__i)); }; assert!(({ (*v.borrow())[0_usize] } == 4) && ({ (*v.borrow())[1_usize] } == 7)); return 0; diff --git a/tests/unit/out/refcount/field_method_receiver.rs b/tests/unit/out/refcount/field_method_receiver.rs index a2e908181d..984da547de 100644 --- a/tests/unit/out/refcount/field_method_receiver.rs +++ b/tests/unit/out/refcount/field_method_receiver.rs @@ -102,7 +102,7 @@ pub fn run_0(mut o: Ptr) { assert!((({ CounterImpl::get(&field_ptr!(o, c),) }) == 1)); match (Rc::new(RefCell::new(({ CounterImpl::get(&field_ptr!(o, c)) }))).as_pointer(),) { (__tmp_0,) => { - let __a1 = move_constructed(&(__tmp_0).clone()); + let __a1 = (__tmp_0.read()); field!(o, v).with_mut(|__v: &mut Vec| __v.push(__a1)) } }; diff --git a/tests/unit/out/refcount/field_pointers.rs b/tests/unit/out/refcount/field_pointers.rs index 8f89da49bc..792361dcb8 100644 --- a/tests/unit/out/refcount/field_pointers.rs +++ b/tests/unit/out/refcount/field_pointers.rs @@ -190,14 +190,14 @@ fn main_0() -> i32 { assert!((({ OuterImpl::sum(&o.as_pointer(),) }) == 7)); let y: Value = Rc::new(RefCell::new(0)); { - let mut __tmp_1 = { + let mut __tmp_0 = { (field_ptr!( array_field_ptr!(o.as_pointer(), items).offset((2) as isize), a )) .to_any() }; - __tmp_1.memcpy( + __tmp_0.memcpy( &(field_ptr!( array_field_ptr!(o.as_pointer(), items).offset((1) as isize), a @@ -205,11 +205,11 @@ fn main_0() -> i32 { .to_any(), ::std::mem::size_of::(), ); - (__tmp_1).clone() + (__tmp_0).clone() }; { - let mut __tmp_2 = { (y.as_pointer()).to_any() }; - __tmp_2.memcpy( + let mut __tmp_1 = { (y.as_pointer()).to_any() }; + __tmp_1.memcpy( &(field_ptr!( array_field_ptr!(o.as_pointer(), items).offset((2) as isize), a @@ -217,7 +217,7 @@ fn main_0() -> i32 { .to_any(), ::std::mem::size_of::(), ); - (__tmp_2).clone() + (__tmp_1).clone() }; assert!(({ ((*y.borrow()) == 4) })); let bytes: Value> = Rc::new(RefCell::new(Box::new([0_u8; 8]))); @@ -263,11 +263,9 @@ impl OuterImpl for Ptr { return ((*self).with(|__s| __s.x) + (*self).with(|__s| __s.inner.a)); } fn push(&self, mut k: i32) { - match (Rc::new(RefCell::new((k + (*self).with(|__s| __s.x)))).as_pointer(),) { - (__tmp_0,) => { - let __a1 = move_constructed(&__tmp_0); - field!((*self), v).with_mut(|__v: &mut Vec| __v.push(__a1)) - } + { + let __a1 = (k + (*self).with(|__s| __s.x)); + field!((*self), v).with_mut(|__v: &mut Vec| __v.push(__a1)) }; } } diff --git a/tests/unit/out/refcount/find.rs b/tests/unit/out/refcount/find.rs index 4f96ed20f6..dc45f81270 100644 --- a/tests/unit/out/refcount/find.rs +++ b/tests/unit/out/refcount/find.rs @@ -35,36 +35,27 @@ pub fn main() { } fn main_0() -> i32 { let v: Value> = Rc::new(RefCell::new(Vec::new())); - ({ - let __tmp_0: Value = Rc::new(RefCell::new(1)); - { - let __a1 = move_constructed(&__tmp_0.as_pointer()); - (*v.borrow_mut()).push(__a1) - } - }); - ({ - let __tmp_1: Value = Rc::new(RefCell::new(2)); - { - let __a1 = move_constructed(&__tmp_1.as_pointer()); - (*v.borrow_mut()).push(__a1) - } - }); - ({ - let __tmp_2: Value = Rc::new(RefCell::new(3)); - { - let __a1 = move_constructed(&__tmp_2.as_pointer()); - (*v.borrow_mut()).push(__a1) - } - }); + { + let __a1 = 1; + (*v.borrow_mut()).push(__a1) + }; + { + let __a1 = 2; + (*v.borrow_mut()).push(__a1) + }; + { + let __a1 = 3; + (*v.borrow_mut()).push(__a1) + }; let v_begin: Value> = Rc::new(RefCell::new(v.decay().begin())); let v_end: Value> = Rc::new(RefCell::new(v.decay().end())); let it: Value> = Rc::new(RefCell::new( ({ - let __tmp_4: Value = Rc::new(RefCell::new(2)); + let __tmp_1: Value = Rc::new(RefCell::new(2)); { - let mut __tmp_3 = { (*v_end.borrow()).clone() }; + let mut __tmp_0 = { (*v_end.borrow()).clone() }; let mut __it = ({ (*v_begin.borrow()).clone() }); - while __it != __tmp_3 && !CppEq::equal(&__it.iter_deref(), &__tmp_4.as_pointer()) { + while __it != __tmp_0 && !CppEq::equal(&__it.iter_deref(), &__tmp_1.as_pointer()) { __it.iter_inc(); } __it @@ -74,20 +65,20 @@ fn main_0() -> i32 { let mut v_result_true: bool = (*it.borrow()) != v.decay().end(); let m: Value, Value)>> = Rc::new(RefCell::new(Map::new())); match (Rc::new(RefCell::new(1)).as_pointer(),) { - (__tmp_5,) => { - ({ (*m.borrow_mut()).subscript_move(__tmp_5, |__k| cpp_move!(__k), || 0_f64) }) + (__tmp_2,) => { + ({ (*m.borrow_mut()).subscript_move(__tmp_2, |__k| cpp_move!(__k), || 0_f64) }) } } .write(1_f64); match (Rc::new(RefCell::new(2)).as_pointer(),) { - (__tmp_6,) => { - ({ (*m.borrow_mut()).subscript_move(__tmp_6, |__k| cpp_move!(__k), || 0_f64) }) + (__tmp_3,) => { + ({ (*m.borrow_mut()).subscript_move(__tmp_3, |__k| cpp_move!(__k), || 0_f64) }) } } .write(2_f64); match (Rc::new(RefCell::new(3)).as_pointer(),) { - (__tmp_7,) => { - ({ (*m.borrow_mut()).subscript_move(__tmp_7, |__k| cpp_move!(__k), || 0_f64) }) + (__tmp_4,) => { + ({ (*m.borrow_mut()).subscript_move(__tmp_4, |__k| cpp_move!(__k), || 0_f64) }) } } .write(3_f64); @@ -103,13 +94,13 @@ fn main_0() -> i32 { assert!( ((v_result_true) && (m_result_true)) && (({ - let __tmp_10: Value = Rc::new(RefCell::new(2)); + let __tmp_7: Value = Rc::new(RefCell::new(2)); { - let mut __tmp_8 = { v.decay().begin() }; - let mut __tmp_9 = { v.decay().begin() }; - let mut __it = (__tmp_8).clone(); - while __it != __tmp_9 - && !CppEq::equal(&__it.iter_deref(), &__tmp_10.as_pointer()) + let mut __tmp_5 = { v.decay().begin() }; + let mut __tmp_6 = { v.decay().begin() }; + let mut __it = (__tmp_5).clone(); + while __it != __tmp_6 + && !CppEq::equal(&__it.iter_deref(), &__tmp_7.as_pointer()) { __it.iter_inc(); } @@ -120,13 +111,12 @@ fn main_0() -> i32 { let w: Value> = Rc::new(RefCell::new(Vec::from([1, 2, 3, 4, 5]))); assert!( ({ - let __tmp_13: Value = Rc::new(RefCell::new(4)); + let __tmp_10: Value = Rc::new(RefCell::new(4)); { - let mut __tmp_11 = { w.decay().begin().iter_add(2_isize) }; - let mut __tmp_12 = { w.decay().end() }; - let mut __it = (__tmp_11).clone(); - while __it != __tmp_12 && !CppEq::equal(&__it.iter_deref(), &__tmp_13.as_pointer()) - { + let mut __tmp_8 = { w.decay().begin().iter_add(2_isize) }; + let mut __tmp_9 = { w.decay().end() }; + let mut __it = (__tmp_8).clone(); + while __it != __tmp_9 && !CppEq::equal(&__it.iter_deref(), &__tmp_10.as_pointer()) { __it.iter_inc(); } __it @@ -135,12 +125,12 @@ fn main_0() -> i32 { ); assert!( ({ - let __tmp_16: Value = Rc::new(RefCell::new(1)); + let __tmp_13: Value = Rc::new(RefCell::new(1)); { - let mut __tmp_14 = { w.decay().begin().iter_add(2_isize) }; - let mut __tmp_15 = { w.decay().end() }; - let mut __it = (__tmp_14).clone(); - while __it != __tmp_15 && !CppEq::equal(&__it.iter_deref(), &__tmp_16.as_pointer()) + let mut __tmp_11 = { w.decay().begin().iter_add(2_isize) }; + let mut __tmp_12 = { w.decay().end() }; + let mut __it = (__tmp_11).clone(); + while __it != __tmp_12 && !CppEq::equal(&__it.iter_deref(), &__tmp_13.as_pointer()) { __it.iter_inc(); } @@ -150,12 +140,12 @@ fn main_0() -> i32 { ); assert!( ({ - let __tmp_19: Value = Rc::new(RefCell::new(5)); + let __tmp_16: Value = Rc::new(RefCell::new(5)); { - let mut __tmp_17 = { w.decay().begin().iter_add(2_isize) }; - let mut __tmp_18 = { w.decay().begin().iter_add(4_isize) }; - let mut __it = (__tmp_17).clone(); - while __it != __tmp_18 && !CppEq::equal(&__it.iter_deref(), &__tmp_19.as_pointer()) + let mut __tmp_14 = { w.decay().begin().iter_add(2_isize) }; + let mut __tmp_15 = { w.decay().begin().iter_add(4_isize) }; + let mut __it = (__tmp_14).clone(); + while __it != __tmp_15 && !CppEq::equal(&__it.iter_deref(), &__tmp_16.as_pointer()) { __it.iter_inc(); } @@ -170,13 +160,13 @@ fn main_0() -> i32 { ]))); assert!( ({ - let __tmp_22: Value

= Rc::new(RefCell::new(P { x: 1 })); + let __tmp_19: Value

= Rc::new(RefCell::new(P { x: 1 })); { - let mut __tmp_20 = { p.decay().begin() }; - let mut __tmp_21 = { p.decay().end() }; - let mut __it = (__tmp_20).clone(); - while __it != __tmp_21 - && !CppEq::equal(&__it.iter_deref(), &(__tmp_22.as_pointer())) + let mut __tmp_17 = { p.decay().begin() }; + let mut __tmp_18 = { p.decay().end() }; + let mut __it = (__tmp_17).clone(); + while __it != __tmp_18 + && !CppEq::equal(&__it.iter_deref(), &(__tmp_19.as_pointer())) { __it.iter_inc(); } diff --git a/tests/unit/out/refcount/fn_ptr_stable_sort.rs b/tests/unit/out/refcount/fn_ptr_stable_sort.rs index fa30c29725..c8dc28c3fa 100644 --- a/tests/unit/out/refcount/fn_ptr_stable_sort.rs +++ b/tests/unit/out/refcount/fn_ptr_stable_sort.rs @@ -38,34 +38,25 @@ pub fn main() { } fn main_0() -> i32 { let v: Value> = Rc::new(RefCell::new(Vec::new())); - ({ - let __tmp_0: Value = Rc::new(RefCell::new(Item { key: 3, value: 30 })); - { - let __a1 = move_constructed(&(__tmp_0.as_pointer())); - (*v.borrow_mut()).push(__a1) - } - }); - ({ - let __tmp_1: Value = Rc::new(RefCell::new(Item { key: 1, value: 10 })); - { - let __a1 = move_constructed(&(__tmp_1.as_pointer())); - (*v.borrow_mut()).push(__a1) - } - }); - ({ - let __tmp_2: Value = Rc::new(RefCell::new(Item { key: 2, value: 20 })); - { - let __a1 = move_constructed(&(__tmp_2.as_pointer())); - (*v.borrow_mut()).push(__a1) - } - }); { - let mut __tmp_3 = { v.decay().begin() }; - let __n = v.decay().end().iter_distance(&__tmp_3); + let __a1 = (Item { key: 3, value: 30 }); + (*v.borrow_mut()).push(__a1) + }; + { + let __a1 = (Item { key: 1, value: 10 }); + (*v.borrow_mut()).push(__a1) + }; + { + let __a1 = (Item { key: 2, value: 20 }); + (*v.borrow_mut()).push(__a1) + }; + { + let mut __tmp_0 = { v.decay().begin() }; + let __n = v.decay().end().iter_distance(&__tmp_0); let mut __order: Vec = (0..__n).collect(); __order.sort_by(|&__x, &__y| { - let __a = __tmp_3.iter_at(__x); - let __b = __tmp_3.iter_at(__y); + let __a = __tmp_0.iter_at(__x); + let __b = __tmp_0.iter_at(__y); if Compare_0.call(__a.clone(), __b.clone()) { std::cmp::Ordering::Less } else if Compare_0.call(__b, __a) { @@ -74,18 +65,18 @@ fn main_0() -> i32 { std::cmp::Ordering::Equal } }); - reorder(__order, |__i| __tmp_3.iter_at(__i)); + reorder(__order, |__i| __tmp_0.iter_at(__i)); }; assert!(({ { (*v.borrow())[0_usize] }.key } == 1)); assert!(({ { (*v.borrow())[1_usize] }.key } == 2)); assert!(({ { (*v.borrow())[2_usize] }.key } == 3)); { - let mut __tmp_4 = { v.decay().begin() }; - let __n = v.decay().end().iter_distance(&__tmp_4); + let mut __tmp_1 = { v.decay().begin() }; + let __n = v.decay().end().iter_distance(&__tmp_1); let mut __order: Vec = (0..__n).collect(); __order.sort_by(|&__x, &__y| { - let __a = __tmp_4.iter_at(__x); - let __b = __tmp_4.iter_at(__y); + let __a = __tmp_1.iter_at(__x); + let __b = __tmp_1.iter_at(__y); if CompareDesc_1.call(__a.clone(), __b.clone()) { std::cmp::Ordering::Less } else if CompareDesc_1.call(__b, __a) { @@ -94,7 +85,7 @@ fn main_0() -> i32 { std::cmp::Ordering::Equal } }); - reorder(__order, |__i| __tmp_4.iter_at(__i)); + reorder(__order, |__i| __tmp_1.iter_at(__i)); }; assert!(({ { (*v.borrow())[0_usize] }.key } == 3)); assert!(({ { (*v.borrow())[1_usize] }.key } == 2)); diff --git a/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs b/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs index 7641eee94d..becc3fb3a8 100644 --- a/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs +++ b/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs @@ -41,13 +41,10 @@ pub fn main() { fn main_0() -> i32 { let s: Value = Rc::new(RefCell::new(::zero_init())); DefaultConstructible::default_constructor(&s.as_pointer()); - ({ - let __tmp_0: Value = Rc::new(RefCell::new(1)); - { - let __a1 = move_constructed(&__tmp_0.as_pointer()); - (*s.borrow_mut()).v.push(__a1) - } - }); + { + let __a1 = 1; + (*s.borrow_mut()).v.push(__a1) + }; 'loop_: for e in IterRange::new( field_ref!(s.as_pointer(), v).decay().begin(), field_ref!(s.as_pointer(), v).decay().end(), diff --git a/tests/unit/out/refcount/foreach_double.rs b/tests/unit/out/refcount/foreach_double.rs index 3a3ef13027..bfd0c3bc29 100644 --- a/tests/unit/out/refcount/foreach_double.rs +++ b/tests/unit/out/refcount/foreach_double.rs @@ -12,27 +12,18 @@ pub fn main() { } fn main_0() -> i32 { let v: Value> = Rc::new(RefCell::new(Vec::new())); - ({ - let __tmp_0: Value = Rc::new(RefCell::new(1)); - { - let __a1 = move_constructed(&__tmp_0.as_pointer()); - (*v.borrow_mut()).push(__a1) - } - }); - ({ - let __tmp_1: Value = Rc::new(RefCell::new(2)); - { - let __a1 = move_constructed(&__tmp_1.as_pointer()); - (*v.borrow_mut()).push(__a1) - } - }); - ({ - let __tmp_2: Value = Rc::new(RefCell::new(3)); - { - let __a1 = move_constructed(&__tmp_2.as_pointer()); - (*v.borrow_mut()).push(__a1) - } - }); + { + let __a1 = 1; + (*v.borrow_mut()).push(__a1) + }; + { + let __a1 = 2; + (*v.borrow_mut()).push(__a1) + }; + { + let __a1 = 3; + (*v.borrow_mut()).push(__a1) + }; let mut square: i32 = 0; 'loop_: for e1 in IterRange::new(v.decay().begin(), v.decay().end()) { let mut e1: i32 = (e1.iter_deref().read()); @@ -64,25 +55,19 @@ fn main_0() -> i32 { } let m: Value>> = Rc::new(RefCell::new(Vec::new())); let v1: Value> = Rc::new(RefCell::new(Vec::new())); - match (v1.as_pointer(),) { - (__tmp_3,) => { - let __a1 = move_constructed(&__tmp_3); - (*m.borrow_mut()).push(__a1) - } + { + let __a1 = ({ std::mem::take(&mut (*v1.borrow_mut())) }); + (*m.borrow_mut()).push(__a1) }; let v2: Value> = Rc::new(RefCell::new(Vec::new())); - match (v2.as_pointer(),) { - (__tmp_4,) => { - let __a1 = move_constructed(&__tmp_4); - (*m.borrow_mut()).push(__a1) - } + { + let __a1 = ({ std::mem::take(&mut (*v2.borrow_mut())) }); + (*m.borrow_mut()).push(__a1) }; let v3: Value> = Rc::new(RefCell::new(Vec::new())); - match (v3.as_pointer(),) { - (__tmp_5,) => { - let __a1 = move_constructed(&__tmp_5); - (*m.borrow_mut()).push(__a1) - } + { + let __a1 = ({ std::mem::take(&mut (*v3.borrow_mut())) }); + (*m.borrow_mut()).push(__a1) }; 'loop_: for row in IterRange::new(m.decay().begin(), m.decay().end()) { let row: Ptr> = row.iter_deref(); diff --git a/tests/unit/out/refcount/foreach_mut.rs b/tests/unit/out/refcount/foreach_mut.rs index ce4fdccbe7..f1ab6bcae9 100644 --- a/tests/unit/out/refcount/foreach_mut.rs +++ b/tests/unit/out/refcount/foreach_mut.rs @@ -12,27 +12,18 @@ pub fn main() { } fn main_0() -> i32 { let v1: Value> = Rc::new(RefCell::new(Vec::new())); - ({ - let __tmp_0: Value = Rc::new(RefCell::new(1)); - { - let __a1 = move_constructed(&__tmp_0.as_pointer()); - (*v1.borrow_mut()).push(__a1) - } - }); - ({ - let __tmp_1: Value = Rc::new(RefCell::new(2)); - { - let __a1 = move_constructed(&__tmp_1.as_pointer()); - (*v1.borrow_mut()).push(__a1) - } - }); - ({ - let __tmp_2: Value = Rc::new(RefCell::new(3)); - { - let __a1 = move_constructed(&__tmp_2.as_pointer()); - (*v1.borrow_mut()).push(__a1) - } - }); + { + let __a1 = 1; + (*v1.borrow_mut()).push(__a1) + }; + { + let __a1 = 2; + (*v1.borrow_mut()).push(__a1) + }; + { + let __a1 = 3; + (*v1.borrow_mut()).push(__a1) + }; let mut sum: i32 = 0; 'loop_: for x in IterRange::new(v1.decay().begin(), v1.decay().end()) { let mut x: i32 = (x.iter_deref().read()); @@ -54,20 +45,20 @@ fn main_0() -> i32 { } let v2: Value>> = Rc::new(RefCell::new(Vec::new())); match (Rc::new(RefCell::new((v1.decay().offset(0_usize)))).as_pointer(),) { - (__tmp_3,) => { - let __a1 = move_constructed(&(__tmp_3).clone()); + (__tmp_0,) => { + let __a1 = (__tmp_0.read()); (*v2.borrow_mut()).push(__a1) } }; match (Rc::new(RefCell::new((v1.decay().offset(1_usize)))).as_pointer(),) { - (__tmp_4,) => { - let __a1 = move_constructed(&(__tmp_4).clone()); + (__tmp_1,) => { + let __a1 = (__tmp_1.read()); (*v2.borrow_mut()).push(__a1) } }; match (Rc::new(RefCell::new((v1.decay().offset(2_usize)))).as_pointer(),) { - (__tmp_5,) => { - let __a1 = move_constructed(&(__tmp_5).clone()); + (__tmp_2,) => { + let __a1 = (__tmp_2.read()); (*v2.borrow_mut()).push(__a1) } }; diff --git a/tests/unit/out/refcount/implicit_autoref.rs b/tests/unit/out/refcount/implicit_autoref.rs index 57abc7bd7a..2416d2bca3 100644 --- a/tests/unit/out/refcount/implicit_autoref.rs +++ b/tests/unit/out/refcount/implicit_autoref.rs @@ -40,39 +40,27 @@ pub fn main() { } fn main_0() -> i32 { let v: Value> = Rc::new(RefCell::new(Vec::new())); - ({ - let __tmp_0: Value = Rc::new(RefCell::new(10)); - { - let __a1 = move_constructed(&__tmp_0.as_pointer()); - (*v.borrow_mut()).push(__a1) - } - }); - ({ - let __tmp_1: Value = Rc::new(RefCell::new(20)); - { - let __a1 = move_constructed(&__tmp_1.as_pointer()); - (*v.borrow_mut()).push(__a1) - } - }); + { + let __a1 = 10; + (*v.borrow_mut()).push(__a1) + }; + { + let __a1 = 20; + (*v.borrow_mut()).push(__a1) + }; let mut p: Ptr> = (v.as_pointer()); let mut a: i32 = (index!(p, 0_usize).read()); index!(p, 1_usize).write(30); let h: Value = Rc::new(RefCell::new(::zero_init())); DefaultConstructible::default_constructor(&h.as_pointer()); - ({ - let __tmp_2: Value = Rc::new(RefCell::new(40)); - { - let __a1 = move_constructed(&__tmp_2.as_pointer()); - (*h.borrow_mut()).v.push(__a1) - } - }); - ({ - let __tmp_3: Value = Rc::new(RefCell::new(50)); - { - let __a1 = move_constructed(&__tmp_3.as_pointer()); - (*h.borrow_mut()).v.push(__a1) - } - }); + { + let __a1 = 40; + (*h.borrow_mut()).v.push(__a1) + }; + { + let __a1 = 50; + (*h.borrow_mut()).v.push(__a1) + }; let mut hp: Ptr = (h.as_pointer()); let mut b: i32 = (vec_elem!((hp), v, 0_usize).read()); vec_elem!((hp), v, 1_usize).write(60); diff --git a/tests/unit/out/refcount/inline_container_fields.rs b/tests/unit/out/refcount/inline_container_fields.rs index 11f6bccf82..73a7ee6fb0 100644 --- a/tests/unit/out/refcount/inline_container_fields.rs +++ b/tests/unit/out/refcount/inline_container_fields.rs @@ -158,7 +158,7 @@ pub fn fill_1(mut s: Ptr) { } match (Rc::new(RefCell::new(Vec::from([1, 2, 3]))).as_pointer(),) { (__tmp_0,) => { - let __a1 = move_constructed(&(__tmp_0).clone()); + let __a1 = __tmp_0.with_mut(std::mem::take); field!(s, rows).with_mut(|__v: &mut Vec>| __v.push(__a1)) } }; @@ -455,13 +455,10 @@ fn main_0() -> i32 { let va: Value]>> = Rc::new(RefCell::new(Box::<[Vec]>::from( std::array::from_fn::<_, 2, _>(|_| Default::default()), ))); - ({ - let __tmp_1: Value = Rc::new(RefCell::new(1)); - { - let __a1 = move_constructed(&__tmp_1.as_pointer()); - elem!(va.decay(), 0_usize).with_mut(|__v: &mut Vec| __v.push(__a1)) - } - }); + { + let __a1 = 1; + elem!(va.decay(), 0_usize).with_mut(|__v: &mut Vec| __v.push(__a1)) + }; let vb: Value]>> = Rc::new(RefCell::new({ let __v: Value]>> = Rc::new(RefCell::new( (0..2).map(|_| >::zero_init()).collect(), diff --git a/tests/unit/out/refcount/iterators.rs b/tests/unit/out/refcount/iterators.rs index e74063822b..07a999ca3f 100644 --- a/tests/unit/out/refcount/iterators.rs +++ b/tests/unit/out/refcount/iterators.rs @@ -42,13 +42,13 @@ fn main_0() -> i32 { let v: Value>> = Rc::new(RefCell::new(Vec::new())); match (Rc::new(RefCell::new(Ptr::alloc(2))).as_pointer(),) { (__tmp_0,) => { - let __a1 = move_constructed(&(__tmp_0).clone()); + let __a1 = (__tmp_0.read()); (*v.borrow_mut()).push(__a1) } }; match (Rc::new(RefCell::new(Ptr::alloc(3))).as_pointer(),) { (__tmp_1,) => { - let __a1 = move_constructed(&(__tmp_1).clone()); + let __a1 = (__tmp_1.read()); (*v.borrow_mut()).push(__a1) } }; diff --git a/tests/unit/out/refcount/map.rs b/tests/unit/out/refcount/map.rs index c146fa66b2..560aa8aeb7 100644 --- a/tests/unit/out/refcount/map.rs +++ b/tests/unit/out/refcount/map.rs @@ -502,13 +502,10 @@ fn main_0() -> i32 { let mut i: u32 = 60_u32; 'loop_: while (i > 30_u32) { 'for_body: { - ({ - let __tmp_41: Value = Rc::new(RefCell::new((i as i32))); - { - let __a1 = move_constructed(&__tmp_41.as_pointer()); - (*indexes.borrow_mut()).push(__a1) - } - }); + { + let __a1 = (i as i32); + (*indexes.borrow_mut()).push(__a1) + }; } i.prefix_dec(); } @@ -517,13 +514,10 @@ fn main_0() -> i32 { let mut i: u32 = 100_u32; 'loop_: while (i > 60_u32) { 'for_body: { - ({ - let __tmp_42: Value = Rc::new(RefCell::new((i as i32))); - { - let __a1 = move_constructed(&__tmp_42.as_pointer()); - (*indexes.borrow_mut()).push(__a1) - } - }); + { + let __a1 = (i as i32); + (*indexes.borrow_mut()).push(__a1) + }; } i.prefix_dec(); } @@ -532,13 +526,10 @@ fn main_0() -> i32 { let mut i: u32 = 30_u32; 'loop_: while (i > 0_u32) { 'for_body: { - ({ - let __tmp_43: Value = Rc::new(RefCell::new((i as i32))); - { - let __a1 = move_constructed(&__tmp_43.as_pointer()); - (*indexes.borrow_mut()).push(__a1) - } - }); + { + let __a1 = (i as i32); + (*indexes.borrow_mut()).push(__a1) + }; } i.prefix_dec(); } @@ -548,7 +539,7 @@ fn main_0() -> i32 { 'loop_: while ((i as usize) < (*indexes.borrow()).len()) { 'for_body: { match (indexes.decay().offset((i as usize)),) { - (__tmp_44,) => ({ (*m2.borrow_mut()).subscript(__tmp_44, || false) }), + (__tmp_41,) => ({ (*m2.borrow_mut()).subscript(__tmp_41, || false) }), } .write(((i).wrapping_rem(2_u32) != 0)); } @@ -579,9 +570,9 @@ fn main_0() -> i32 { Value, Value)>>, Value, )> = Rc::new(RefCell::new({ - let mut __tmp_45 = { (Rc::new(RefCell::new(1)), Rc::new(RefCell::new(2))) }; + let mut __tmp_42 = { (Rc::new(RefCell::new(1)), Rc::new(RefCell::new(2))) }; let (__it, __inserted) = - Map::emplace(m3.as_pointer(), &__tmp_45.0.as_pointer(), || __tmp_45); + Map::emplace(m3.as_pointer(), &__tmp_42.0.as_pointer(), || __tmp_42); ( Rc::new(RefCell::new(__it)), Rc::new(RefCell::new(__inserted)), @@ -602,9 +593,9 @@ fn main_0() -> i32 { Value, Value)>>, Value, )> = Rc::new(RefCell::new({ - let mut __tmp_46 = { (Rc::new(RefCell::new(1)), Rc::new(RefCell::new(3))) }; + let mut __tmp_43 = { (Rc::new(RefCell::new(1)), Rc::new(RefCell::new(3))) }; let (__it, __inserted) = - Map::emplace(m3.as_pointer(), &__tmp_46.0.as_pointer(), || __tmp_46); + Map::emplace(m3.as_pointer(), &__tmp_43.0.as_pointer(), || __tmp_43); ( Rc::new(RefCell::new(__it)), Rc::new(RefCell::new(__inserted)), @@ -622,25 +613,25 @@ fn main_0() -> i32 { }) ); { - let mut __tmp_48 = { + let mut __tmp_45 = { match (Rc::new(RefCell::new(( Rc::new(RefCell::new(4)), Rc::new(RefCell::new(5)), ))) .as_pointer(),) { - (__tmp_47,) => ( + (__tmp_44,) => ( Rc::new(RefCell::new( - ((*__tmp_47.upgrade().deref()).0.as_pointer().read()), + ((*__tmp_44.upgrade().deref()).0.as_pointer().read()), )), Rc::new(RefCell::new( - ((*__tmp_47.upgrade().deref()).1.as_pointer().read()), + ((*__tmp_44.upgrade().deref()).1.as_pointer().read()), )), ), } }; let (__it, __inserted) = - Map::emplace(m3.as_pointer(), &__tmp_48.0.as_pointer(), || __tmp_48); + Map::emplace(m3.as_pointer(), &__tmp_45.0.as_pointer(), || __tmp_45); ( Rc::new(RefCell::new(__it)), Rc::new(RefCell::new(__inserted)), @@ -649,8 +640,8 @@ fn main_0() -> i32 { assert!(({ ((*m3.borrow()).len() == 2_usize) })); assert!( ((match (Rc::new(RefCell::new(1)).as_pointer(),) { - (__tmp_49,) => { - ({ (*m3.borrow_mut()).subscript_move(__tmp_49, |__k| cpp_move!(__k), || 0_i32) }) + (__tmp_46,) => { + ({ (*m3.borrow_mut()).subscript_move(__tmp_46, |__k| cpp_move!(__k), || 0_i32) }) } } .read()) @@ -658,23 +649,23 @@ fn main_0() -> i32 { ); assert!( ((match (Rc::new(RefCell::new(4)).as_pointer(),) { - (__tmp_50,) => { - ({ (*m3.borrow_mut()).subscript_move(__tmp_50, |__k| cpp_move!(__k), || 0_i32) }) + (__tmp_47,) => { + ({ (*m3.borrow_mut()).subscript_move(__tmp_47, |__k| cpp_move!(__k), || 0_i32) }) } } .read()) == 5) ); let hinted: Value, Value)>> = Rc::new(RefCell::new({ - let mut __tmp_51 = { + let mut __tmp_48 = { , Value)>>::from( m3.as_pointer() .with(|__m: &Map, Value)>| __m.end()), ) }; - let mut __tmp_52 = { (Rc::new(RefCell::new(6)), Rc::new(RefCell::new(7))) }; - let _ = (__tmp_51).clone(); - Map::emplace(m3.as_pointer(), &__tmp_52.0.as_pointer(), || __tmp_52).0 + let mut __tmp_49 = { (Rc::new(RefCell::new(6)), Rc::new(RefCell::new(7))) }; + let _ = (__tmp_48).clone(); + Map::emplace(m3.as_pointer(), &__tmp_49.0.as_pointer(), || __tmp_49).0 })); assert!( ({ @@ -730,8 +721,8 @@ fn main_0() -> i32 { assert!(({ ((*(*tried_new.borrow()).1.borrow()) as bool) })); assert!( ((match (Rc::new(RefCell::new(8)).as_pointer(),) { - (__tmp_53,) => { - ({ (*m3.borrow_mut()).subscript_move(__tmp_53, |__k| cpp_move!(__k), || 0_i32) }) + (__tmp_50,) => { + ({ (*m3.borrow_mut()).subscript_move(__tmp_50, |__k| cpp_move!(__k), || 0_i32) }) } } .read()) @@ -761,10 +752,10 @@ fn main_0() -> i32 { assert!(({ ((*(*point_new.borrow()).1.borrow()) as bool) })); assert!( (match (Rc::new(RefCell::new(1)).as_pointer(),) { - (__tmp_54,) => { + (__tmp_51,) => { ({ (*points.borrow_mut()).subscript_move( - __tmp_54, + __tmp_51, |__k| cpp_move!(__k), || ::default(), ) @@ -776,10 +767,10 @@ fn main_0() -> i32 { ); assert!( (match (Rc::new(RefCell::new(1)).as_pointer(),) { - (__tmp_55,) => { + (__tmp_52,) => { ({ (*points.borrow_mut()).subscript_move( - __tmp_55, + __tmp_52, |__k| cpp_move!(__k), || ::default(), ) @@ -790,7 +781,7 @@ fn main_0() -> i32 { == 4) ); { - let mut __tmp_56 = { + let mut __tmp_53 = { ( Rc::new(RefCell::new(({ (*key8.borrow()) }))), Rc::new(RefCell::new({ @@ -801,7 +792,7 @@ fn main_0() -> i32 { ) }; let (__it, __inserted) = - Map::emplace(points.as_pointer(), &__tmp_56.0.as_pointer(), || __tmp_56); + Map::emplace(points.as_pointer(), &__tmp_53.0.as_pointer(), || __tmp_53); ( Rc::new(RefCell::new(__it)), Rc::new(RefCell::new(__inserted)), @@ -809,10 +800,10 @@ fn main_0() -> i32 { }; assert!( (match (Rc::new(RefCell::new(8)).as_pointer(),) { - (__tmp_57,) => { + (__tmp_54,) => { ({ (*points.borrow_mut()).subscript_move( - __tmp_57, + __tmp_54, |__k| cpp_move!(__k), || ::default(), ) @@ -824,10 +815,10 @@ fn main_0() -> i32 { ); assert!( (match (Rc::new(RefCell::new(8)).as_pointer(),) { - (__tmp_58,) => { + (__tmp_55,) => { ({ (*points.borrow_mut()).subscript_move( - __tmp_58, + __tmp_55, |__k| cpp_move!(__k), || ::default(), ) @@ -870,9 +861,9 @@ fn main_0() -> i32 { ); k = 0; let value_0: Ptr = ({ - let __tmp_59: Value = Rc::new(RefCell::new((k as i16))); + let __tmp_56: Value = Rc::new(RefCell::new((k as i16))); (*m.borrow()) - .get(&__tmp_59.as_pointer()) + .get(&__tmp_56.as_pointer()) .expect("out of range!") .borrow() .1 @@ -911,10 +902,10 @@ fn main_0() -> i32 { ); { match (Rc::new(RefCell::new((pk2.as_pointer()))).as_pointer(),) { - (__tmp_60,) => { + (__tmp_57,) => { ({ (*ptr_counts.borrow_mut()).subscript_move( - __tmp_60, + __tmp_57, |__k| cpp_move!(__k), || 0_i32, ) @@ -925,10 +916,10 @@ fn main_0() -> i32 { }; assert!( ((match (Rc::new(RefCell::new((pk2.as_pointer()))).as_pointer(),) { - (__tmp_61,) => { + (__tmp_58,) => { ({ (*ptr_counts.borrow_mut()).subscript_move( - __tmp_61, + __tmp_58, |__k| cpp_move!(__k), || 0_i32, ) @@ -942,75 +933,75 @@ fn main_0() -> i32 { { let t: Value, Value)>> = Rc::new(RefCell::new(Map::new())); match (Rc::new(RefCell::new(1_i64)).as_pointer(),) { - (__tmp_62,) => { - ({ (*t.borrow_mut()).subscript_move(__tmp_62, |__k| cpp_move!(__k), || 0_i32) }) + (__tmp_59,) => { + ({ (*t.borrow_mut()).subscript_move(__tmp_59, |__k| cpp_move!(__k), || 0_i32) }) } } .write(5); { match (Rc::new(RefCell::new(2_i64)).as_pointer(),) { - (__tmp_63,) => { - ({ (*t.borrow_mut()).subscript_move(__tmp_63, |__k| cpp_move!(__k), || 0_i32) }) + (__tmp_60,) => { + ({ (*t.borrow_mut()).subscript_move(__tmp_60, |__k| cpp_move!(__k), || 0_i32) }) } } .with_mut(|__v| *__v = *__v + 3) }; match (Rc::new(RefCell::new(3_i64)).as_pointer(),) { - (__tmp_64,) => { - ({ (*t.borrow_mut()).subscript_move(__tmp_64, |__k| cpp_move!(__k), || 0_i32) }) + (__tmp_61,) => { + ({ (*t.borrow_mut()).subscript_move(__tmp_61, |__k| cpp_move!(__k), || 0_i32) }) } } .with_mut(|__v| __v.postfix_inc()); let r: Ptr = match (Rc::new(RefCell::new(1_i64)).as_pointer(),) { - (__tmp_65,) => { - ({ (*t.borrow_mut()).subscript_move(__tmp_65, |__k| cpp_move!(__k), || 0_i32) }) + (__tmp_62,) => { + ({ (*t.borrow_mut()).subscript_move(__tmp_62, |__k| cpp_move!(__k), || 0_i32) }) } }; r.write(6); let mut p: Ptr = (match (Rc::new(RefCell::new(2_i64)).as_pointer(),) { - (__tmp_66,) => { - ({ (*t.borrow_mut()).subscript_move(__tmp_66, |__k| cpp_move!(__k), || 0_i32) }) + (__tmp_63,) => { + ({ (*t.borrow_mut()).subscript_move(__tmp_63, |__k| cpp_move!(__k), || 0_i32) }) } }); p.write(4); ({ inc_2(match (Rc::new(RefCell::new(3_i64)).as_pointer(),) { - (__tmp_67,) => { - ({ (*t.borrow_mut()).subscript_move(__tmp_67, |__k| cpp_move!(__k), || 0_i32) }) + (__tmp_64,) => { + ({ (*t.borrow_mut()).subscript_move(__tmp_64, |__k| cpp_move!(__k), || 0_i32) }) } }) }); Swappable::swap( &match (Rc::new(RefCell::new(1_i64)).as_pointer(),) { - (__tmp_68,) => { - ({ (*t.borrow_mut()).subscript_move(__tmp_68, |__k| cpp_move!(__k), || 0_i32) }) + (__tmp_65,) => { + ({ (*t.borrow_mut()).subscript_move(__tmp_65, |__k| cpp_move!(__k), || 0_i32) }) } }, match (Rc::new(RefCell::new(2_i64)).as_pointer(),) { - (__tmp_69,) => { - ({ (*t.borrow_mut()).subscript_move(__tmp_69, |__k| cpp_move!(__k), || 0_i32) }) + (__tmp_66,) => { + ({ (*t.borrow_mut()).subscript_move(__tmp_66, |__k| cpp_move!(__k), || 0_i32) }) } }, ); let mut x: i32 = ((match (Rc::new(RefCell::new(1_i64)).as_pointer(),) { - (__tmp_70,) => { - ({ (*t.borrow_mut()).subscript_move(__tmp_70, |__k| cpp_move!(__k), || 0_i32) }) + (__tmp_67,) => { + ({ (*t.borrow_mut()).subscript_move(__tmp_67, |__k| cpp_move!(__k), || 0_i32) }) } } .read()) + (match (Rc::new(RefCell::new(2_i64)).as_pointer(),) { - (__tmp_71,) => { - ({ (*t.borrow_mut()).subscript_move(__tmp_71, |__k| cpp_move!(__k), || 0_i32) }) + (__tmp_68,) => { + ({ (*t.borrow_mut()).subscript_move(__tmp_68, |__k| cpp_move!(__k), || 0_i32) }) } } .read())); assert!( (((x == 10) && ((match (Rc::new(RefCell::new(1_i64)).as_pointer(),) { - (__tmp_72,) => { + (__tmp_69,) => { ({ (*t.borrow_mut()).subscript_move( - __tmp_72, + __tmp_69, |__k| cpp_move!(__k), || 0_i32, ) @@ -1020,10 +1011,10 @@ fn main_0() -> i32 { .read()) == 4)) && ((match (Rc::new(RefCell::new(2_i64)).as_pointer(),) { - (__tmp_73,) => { + (__tmp_70,) => { ({ (*t.borrow_mut()).subscript_move( - __tmp_73, + __tmp_70, |__k| cpp_move!(__k), || 0_i32, ) @@ -1033,10 +1024,10 @@ fn main_0() -> i32 { .read()) == 6)) && ((match (Rc::new(RefCell::new(3_i64)).as_pointer(),) { - (__tmp_74,) => { + (__tmp_71,) => { ({ (*t.borrow_mut()).subscript_move( - __tmp_74, + __tmp_71, |__k| cpp_move!(__k), || 0_i32, ) diff --git a/tests/unit/out/refcount/move_assign.rs b/tests/unit/out/refcount/move_assign.rs index e73c45e1d0..45c5b94afa 100644 --- a/tests/unit/out/refcount/move_assign.rs +++ b/tests/unit/out/refcount/move_assign.rs @@ -119,7 +119,11 @@ fn main_0() -> i32 { },) { (__tmp_0,) => { - let __a1 = move_constructed(&(__tmp_0).clone()); + let __a1 = { + let __v: Value = Rc::new(RefCell::new(::zero_init())); + MoveConstructible::move_constructor(&__v.as_pointer(), { (__tmp_0).clone() }); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }; (*vec_.borrow_mut()).push(__a1) } } diff --git a/tests/unit/out/refcount/move_ctor.rs b/tests/unit/out/refcount/move_ctor.rs index 1db2bf956f..77a7be3614 100644 --- a/tests/unit/out/refcount/move_ctor.rs +++ b/tests/unit/out/refcount/move_ctor.rs @@ -211,7 +211,11 @@ fn main_0() -> i32 { },) { (__tmp_0,) => { - let __a1 = move_constructed(&(__tmp_0).clone()); + let __a1 = { + let __v: Value = Rc::new(RefCell::new(::zero_init())); + MoveConstructible::move_constructor(&__v.as_pointer(), { (__tmp_0).clone() }); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }; vec_.push(__a1) } } @@ -219,7 +223,11 @@ fn main_0() -> i32 { let f: Value = Rc::new(RefCell::new(::zero_init())); MoveOnlyImpl::construct(&f.as_pointer(), { 8 }); { - let __a1 = move_constructed(&f.as_pointer()); + let __a1 = { + let __v: Value = Rc::new(RefCell::new(::zero_init())); + MoveConstructible::move_constructor(&__v.as_pointer(), { f.as_pointer() }); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }; vec_.push(__a1) }; assert!((vec_[0_usize].v == 7) && (vec_[1_usize].v == 8)); diff --git a/tests/unit/out/refcount/push_emplace_back.rs b/tests/unit/out/refcount/push_emplace_back.rs index ed6ef8e747..9cc934a524 100644 --- a/tests/unit/out/refcount/push_emplace_back.rs +++ b/tests/unit/out/refcount/push_emplace_back.rs @@ -77,7 +77,7 @@ impl DefaultConstructible for JPEGData { pub fn push_param_0(mut dest: Ptr>>) { match (Rc::new(RefCell::new(Vec::new())).as_pointer(),) { (__tmp_0,) => { - let __a1 = move_constructed(&(__tmp_0).clone()); + let __a1 = __tmp_0.with_mut(std::mem::take); dest.with_mut(|__v: &mut Vec>| __v.push(__a1)) } }; @@ -103,7 +103,7 @@ pub fn push_local_from_field_1(mut jpg: Ptr, mut cond: bool) { .as_pointer(),) { (__tmp_1,) => { - let __a1 = move_constructed(&(__tmp_1).clone()); + let __a1 = __tmp_1.with_mut(std::mem::take); dest.with_mut(|__v: &mut Vec>| __v.push(__a1)) } }; @@ -112,12 +112,10 @@ pub fn shrink_through_ptr_2(mut comps: Ptr>) { comps.with_mut(|__v: &mut Vec| __v.shrink_to_fit()); } pub fn nested_push_move_3(mut bw: Ptr) { - match (field_ptr!(bw, chunk),) { - (__tmp_3,) => { - let __a1 = move_constructed(&__tmp_3); - bw.with(|__s| __s.output.clone()) - .with_mut(|__v: &mut Vec| __v.push(__a1)) - } + { + let __a1 = bw.with(|__s| __s.chunk); + bw.with(|__s| __s.output.clone()) + .with_mut(|__v: &mut Vec| __v.push(__a1)) }; } pub fn emplace_local_from_field_4(mut jpg: Ptr, mut cond: bool) { @@ -131,10 +129,10 @@ pub fn emplace_local_from_field_4(mut jpg: Ptr, mut cond: bool) { { dest.with_mut(|__v: &mut Vec>| { __v.push({ - let mut __tmp_4 = { head.decay().offset((3) as isize) }; + let mut __tmp_3 = { head.decay().offset((3) as isize) }; let mut __v = Vec::new(); let mut __it = head.decay(); - while __it != __tmp_4 { + while __it != __tmp_3 { __v.push((__it.iter_deref().read())); __it.iter_inc(); } @@ -145,9 +143,9 @@ pub fn emplace_local_from_field_4(mut jpg: Ptr, mut cond: bool) { } pub fn nested_emplace_move_5(mut bw: Ptr) { { - let mut __tmp_5 = { bw.with(|__s| __s.output.clone()) }; - let mut __tmp_6 = { bw.with(|__s| __s.chunk) }; - __tmp_5.with_mut(|__v: &mut Vec| __v.push(__tmp_6)); + let mut __tmp_4 = { bw.with(|__s| __s.output.clone()) }; + let mut __tmp_5 = { bw.with(|__s| __s.chunk) }; + __tmp_4.with_mut(|__v: &mut Vec| __v.push(__tmp_5)); }; } pub fn self_ref_push_6(mut comps: Ptr>) { @@ -195,36 +193,36 @@ pub fn emplace_ctor_args_7(mut pairs: Ptr>) { }); }; { - let mut __tmp_7 = { + let mut __tmp_6 = { { let __v: Value = Rc::new(RefCell::new(::zero_init())); PairImpl::construct_1(&__v.as_pointer(), { 3 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() } }; - pairs.with_mut(|__v: &mut Vec| __v.push(__tmp_7)); + pairs.with_mut(|__v: &mut Vec| __v.push(__tmp_6)); }; { - let mut __tmp_8 = { + let mut __tmp_7 = { { let __v: Value = Rc::new(RefCell::new(::zero_init())); PairImpl::construct_2(&__v.as_pointer(), { 4 }, { 5 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() } }; - pairs.with_mut(|__v: &mut Vec| __v.push(__tmp_8)); + pairs.with_mut(|__v: &mut Vec| __v.push(__tmp_7)); }; } pub fn emplace_deque_8(mut queue: Ptr>) { { - let mut __tmp_9 = { + let mut __tmp_8 = { { let __v: Value = Rc::new(RefCell::new(::zero_init())); PairImpl::construct_2(&__v.as_pointer(), { 6 }, { 7 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() } }; - queue.with_mut(|__v: &mut Vec| __v.push(__tmp_9)); + queue.with_mut(|__v: &mut Vec| __v.push(__tmp_8)); }; { queue.with_mut(|__v: &mut Vec| { @@ -247,7 +245,7 @@ pub fn emplace_scalar_9(mut values: Ptr>, x: i32) { } pub fn emplace_ref_through_ptr_10(mut pairs: Ptr>) { let p: Ptr = { - let mut __tmp_10 = { + let mut __tmp_9 = { { let __v: Value = Rc::new(RefCell::new(::zero_init())); PairImpl::construct_2(&__v.as_pointer(), { 1 }, { 2 }); @@ -255,7 +253,7 @@ pub fn emplace_ref_through_ptr_10(mut pairs: Ptr>) { } }; pairs.with_mut(|__b0| { - (*__b0).push(__tmp_10); + (*__b0).push(__tmp_9); let __n = (*__b0).len() - 1; pairs.decay().offset((__n) as isize) }) @@ -264,7 +262,7 @@ pub fn emplace_ref_through_ptr_10(mut pairs: Ptr>) { { field!( { - let mut __tmp_11 = { + let mut __tmp_10 = { { let __v: Value = Rc::new(RefCell::new(::zero_init())); PairImpl::construct_1(&__v.as_pointer(), { 4 }); @@ -272,7 +270,7 @@ pub fn emplace_ref_through_ptr_10(mut pairs: Ptr>) { } }; pairs.with_mut(|__b0| { - (*__b0).push(__tmp_11); + (*__b0).push(__tmp_10); let __n = (*__b0).len() - 1; pairs.decay().offset((__n) as isize) }) @@ -291,15 +289,15 @@ pub fn emplace_addr_11(values: Ptr>) -> Ptr { } pub fn emplace_self_reads_12(mut values: Ptr>, mut pairs: Ptr>) { { - let mut __tmp_12 = { (((*values.upgrade().deref()).len()) as i64) }; - values.with_mut(|__v: &mut Vec| __v.push(__tmp_12)); + let mut __tmp_11 = { (((*values.upgrade().deref()).len()) as i64) }; + values.with_mut(|__v: &mut Vec| __v.push(__tmp_11)); }; { - let mut __tmp_13 = { index!(pairs, 0_usize).read() }; - pairs.with_mut(|__v: &mut Vec| __v.push(__tmp_13)); + let mut __tmp_12 = { index!(pairs, 0_usize).read() }; + pairs.with_mut(|__v: &mut Vec| __v.push(__tmp_12)); }; { - let mut __tmp_14 = { + let mut __tmp_13 = { { let __v: Value = Rc::new(RefCell::new(::zero_init())); PairImpl::construct_2( @@ -320,14 +318,14 @@ pub fn emplace_self_reads_12(mut values: Ptr>, mut pairs: Ptr Rc::try_unwrap(__v).ok().unwrap().into_inner() } }; - pairs.with_mut(|__v: &mut Vec| __v.push(__tmp_14)); + pairs.with_mut(|__v: &mut Vec| __v.push(__tmp_13)); }; } pub fn emplace_ref_self_read_13(values: Ptr>) -> Ptr { return { - let mut __tmp_15 = { (values.decay().read()) }; + let mut __tmp_14 = { (values.decay().read()) }; values.with_mut(|__b0| { - (*__b0).push(__tmp_15); + (*__b0).push(__tmp_14); let __n = (*__b0).len() - 1; values.decay().offset((__n) as isize) }) @@ -375,19 +373,19 @@ impl Default for Bytes { pub fn emplace_from_element_14(mut v: Ptr>>) { let p: Value> = Rc::new(RefCell::new((v).decay().offset(0_usize).decay())); { - let mut __tmp_17 = { + let mut __tmp_16 = { { - let mut __tmp_16 = { (*p.borrow()).offset((3) as isize) }; + let mut __tmp_15 = { (*p.borrow()).offset((3) as isize) }; let mut __v = Vec::new(); let mut __it = ({ (*p.borrow()).clone() }); - while __it != __tmp_16 { + while __it != __tmp_15 { __v.push((__it.iter_deref().read())); __it.iter_inc(); } __v } }; - v.with_mut(|__v: &mut Vec>| __v.push(__tmp_17)); + v.with_mut(|__v: &mut Vec>| __v.push(__tmp_16)); }; } #[derive( @@ -446,33 +444,33 @@ pub struct Counted { impl Counted {} pub fn emplace_counted_17(mut v: Ptr>) { { - let mut __tmp_18 = { + let mut __tmp_17 = { { let __v: Value = Rc::new(RefCell::new(::zero_init())); CountedImpl::construct(&__v.as_pointer(), { 1 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() } }; - v.with_mut(|__v: &mut Vec| __v.push(__tmp_18)); + v.with_mut(|__v: &mut Vec| __v.push(__tmp_17)); }; } pub fn emplace_from_sibling_18(mut s: Ptr) { let p: Value> = Rc::new(RefCell::new(array_field_ptr!(s, b))); let mut v: Ptr>> = (field_ref!(s, v).as_pointer()); { - let mut __tmp_20 = { + let mut __tmp_19 = { { - let mut __tmp_19 = { (*p.borrow()).offset((3) as isize) }; + let mut __tmp_18 = { (*p.borrow()).offset((3) as isize) }; let mut __v = Vec::new(); let mut __it = ({ (*p.borrow()).clone() }); - while __it != __tmp_19 { + while __it != __tmp_18 { __v.push((__it.iter_deref().read())); __it.iter_inc(); } __v } }; - v.with_mut(|__v: &mut Vec>| __v.push(__tmp_20)); + v.with_mut(|__v: &mut Vec>| __v.push(__tmp_19)); }; } pub fn main() { @@ -630,14 +628,14 @@ fn main_0() -> i32 { let self_values: Value> = Rc::new(RefCell::new(Vec::from([7_i64]))); let self_pairs: Value> = Rc::new(RefCell::new(Vec::new())); { - let mut __tmp_21 = { + let mut __tmp_20 = { { let __v: Value = Rc::new(RefCell::new(::zero_init())); PairImpl::construct_2(&__v.as_pointer(), { 1 }, { 2 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() } }; - (*self_pairs.borrow_mut()).push(__tmp_21); + (*self_pairs.borrow_mut()).push(__tmp_20); }; ({ emplace_self_reads_12((self_values.as_pointer()), (self_pairs.as_pointer())) }); { diff --git a/tests/unit/out/refcount/reinterpret_cast_vec_write.rs b/tests/unit/out/refcount/reinterpret_cast_vec_write.rs index e16b4e230c..2d1a57c532 100644 --- a/tests/unit/out/refcount/reinterpret_cast_vec_write.rs +++ b/tests/unit/out/refcount/reinterpret_cast_vec_write.rs @@ -12,20 +12,14 @@ pub fn main() { } fn main_0() -> i32 { let vec_: Value> = Rc::new(RefCell::new(Vec::new())); - ({ - let __tmp_0: Value = Rc::new(RefCell::new(67305985_u32)); - { - let __a1 = move_constructed(&__tmp_0.as_pointer()); - (*vec_.borrow_mut()).push(__a1) - } - }); - ({ - let __tmp_1: Value = Rc::new(RefCell::new(134678021_u32)); - { - let __a1 = move_constructed(&__tmp_1.as_pointer()); - (*vec_.borrow_mut()).push(__a1) - } - }); + { + let __a1 = 67305985_u32; + (*vec_.borrow_mut()).push(__a1) + }; + { + let __a1 = 134678021_u32; + (*vec_.borrow_mut()).push(__a1) + }; let mut bytes: Ptr = vec_.decay().reinterpret_cast::(); assert!((((elem!(bytes, 0).read()) as i32) == 1)); assert!((((elem!(bytes, 1).read()) as i32) == 2)); diff --git a/tests/unit/out/refcount/return_move.rs b/tests/unit/out/refcount/return_move.rs index a0207c79d7..18b9f89be1 100644 --- a/tests/unit/out/refcount/return_move.rs +++ b/tests/unit/out/refcount/return_move.rs @@ -96,19 +96,17 @@ pub fn ret_struct_param_10(mut p: pair_t) -> pair_t { pub fn ret_struct_ref_11(p: Ptr) -> pair_t { return (*p.upgrade().deref()).clone(); } -pub fn ret_vec_12(mut v: Vec) -> Vec { - return std::mem::take(&mut v); +pub fn ret_vec_12(v: Vec) -> Vec { + let v: Value> = Rc::new(RefCell::new(v)); + return ({ std::mem::take(&mut (*v.borrow_mut())) }); } pub fn ret_vec_local_13() -> Vec { - let mut v: Vec = Vec::new(); - ({ - let __tmp_0: Value = Rc::new(RefCell::new(1)); - { - let __a1 = move_constructed(&__tmp_0.as_pointer()); - v.push(__a1) - } - }); - return std::mem::take(&mut v); + let v: Value> = Rc::new(RefCell::new(Vec::new())); + { + let __a1 = 1; + (*v.borrow_mut()).push(__a1) + }; + return ({ std::mem::take(&mut (*v.borrow_mut())) }); } pub fn ret_loop_14(mut n: Ptr) -> Ptr { 'loop_: while !(n.with(|__s| __s.next.clone())).is_null() { diff --git a/tests/unit/out/refcount/sort.rs b/tests/unit/out/refcount/sort.rs index 49277e502c..b1625696ab 100644 --- a/tests/unit/out/refcount/sort.rs +++ b/tests/unit/out/refcount/sort.rs @@ -12,82 +12,52 @@ pub fn main() { } fn main_0() -> i32 { let v: Value> = Rc::new(RefCell::new(Vec::new())); - ({ - let __tmp_0: Value = Rc::new(RefCell::new(10)); - { - let __a1 = move_constructed(&__tmp_0.as_pointer()); - (*v.borrow_mut()).push(__a1) - } - }); - ({ - let __tmp_1: Value = Rc::new(RefCell::new(1)); - { - let __a1 = move_constructed(&__tmp_1.as_pointer()); - (*v.borrow_mut()).push(__a1) - } - }); - ({ - let __tmp_2: Value = Rc::new(RefCell::new(9)); - { - let __a1 = move_constructed(&__tmp_2.as_pointer()); - (*v.borrow_mut()).push(__a1) - } - }); - ({ - let __tmp_3: Value = Rc::new(RefCell::new(2)); - { - let __a1 = move_constructed(&__tmp_3.as_pointer()); - (*v.borrow_mut()).push(__a1) - } - }); - ({ - let __tmp_4: Value = Rc::new(RefCell::new(8)); - { - let __a1 = move_constructed(&__tmp_4.as_pointer()); - (*v.borrow_mut()).push(__a1) - } - }); - ({ - let __tmp_5: Value = Rc::new(RefCell::new(3)); - { - let __a1 = move_constructed(&__tmp_5.as_pointer()); - (*v.borrow_mut()).push(__a1) - } - }); - ({ - let __tmp_6: Value = Rc::new(RefCell::new(7)); - { - let __a1 = move_constructed(&__tmp_6.as_pointer()); - (*v.borrow_mut()).push(__a1) - } - }); - ({ - let __tmp_7: Value = Rc::new(RefCell::new(4)); - { - let __a1 = move_constructed(&__tmp_7.as_pointer()); - (*v.borrow_mut()).push(__a1) - } - }); - ({ - let __tmp_8: Value = Rc::new(RefCell::new(5)); - { - let __a1 = move_constructed(&__tmp_8.as_pointer()); - (*v.borrow_mut()).push(__a1) - } - }); - ({ - let __tmp_9: Value = Rc::new(RefCell::new(6)); - { - let __a1 = move_constructed(&__tmp_9.as_pointer()); - (*v.borrow_mut()).push(__a1) - } - }); { - let mut __tmp_10 = { v.decay().begin() }; - let __n = v.decay().end().iter_distance(&__tmp_10); + let __a1 = 10; + (*v.borrow_mut()).push(__a1) + }; + { + let __a1 = 1; + (*v.borrow_mut()).push(__a1) + }; + { + let __a1 = 9; + (*v.borrow_mut()).push(__a1) + }; + { + let __a1 = 2; + (*v.borrow_mut()).push(__a1) + }; + { + let __a1 = 8; + (*v.borrow_mut()).push(__a1) + }; + { + let __a1 = 3; + (*v.borrow_mut()).push(__a1) + }; + { + let __a1 = 7; + (*v.borrow_mut()).push(__a1) + }; + { + let __a1 = 4; + (*v.borrow_mut()).push(__a1) + }; + { + let __a1 = 5; + (*v.borrow_mut()).push(__a1) + }; + { + let __a1 = 6; + (*v.borrow_mut()).push(__a1) + }; + { + let mut __tmp_0 = { v.decay().begin() }; + let __n = v.decay().end().iter_distance(&__tmp_0); let mut __order: Vec = (0..__n).collect(); - __order.sort_by(|&__x, &__y| cpp_cmp(&__tmp_10.iter_at(__x), &__tmp_10.iter_at(__y))); - reorder(__order, |__i| __tmp_10.iter_at(__i)); + __order.sort_by(|&__x, &__y| cpp_cmp(&__tmp_0.iter_at(__x), &__tmp_0.iter_at(__y))); + reorder(__order, |__i| __tmp_0.iter_at(__i)); }; { let mut i: u32 = 0_u32; diff --git a/tests/unit/out/refcount/string.rs b/tests/unit/out/refcount/string.rs index 40d9533341..044be9781a 100644 --- a/tests/unit/out/refcount/string.rs +++ b/tests/unit/out/refcount/string.rs @@ -409,22 +409,26 @@ fn main_0() -> i32 { })); printf!(b"position: %s %zu\n", once.decay(), substr_pos); let mut substr_count: usize = 2_usize; + match (Rc::new(RefCell::new({ + let mut __tmp_3 = { substr_count.postfix_inc() }; + s1.as_pointer().with(|__s: &Vec| { + let mut __tmp1 = __s + [1_usize..::std::cmp::min(1_usize + __tmp_3, __s.len().saturating_sub(1))] + .to_vec(); + __tmp1.push(0); + __tmp1 + }) + })) + .as_pointer(),) { - (*once.borrow_mut()) = { - let mut __tmp_2 = { substr_count.postfix_inc() }; - s1.as_pointer().with(|__s: &Vec| { - let mut __tmp1 = __s - [1_usize..::std::cmp::min(1_usize + __tmp_2, __s.len().saturating_sub(1))] - .to_vec(); - __tmp1.push(0); - __tmp1 - }) - }; + (__tmp_2,) => { + (*once.borrow_mut()) = __tmp_2.with_mut(|__v| std::mem::replace(__v, vec![0])); + } }; printf!(b"count: %s %zu\n", once.decay(), substr_count); let receiver_calls: Value = Rc::new(RefCell::new(0)); - { - (*once.borrow_mut()) = Rc::new(RefCell::new( + match (Rc::new(RefCell::new( + Rc::new(RefCell::new( ({ counted_string_0(receiver_calls.as_pointer()) }), )) .as_pointer() @@ -434,7 +438,13 @@ fn main_0() -> i32 { .to_vec(); __tmp1.push(0); __tmp1 - }); + }), + )) + .as_pointer(),) + { + (__tmp_4,) => { + (*once.borrow_mut()) = __tmp_4.with_mut(|__v| std::mem::replace(__v, vec![0])); + } }; printf!( b"receiver: %s %d\n", @@ -448,18 +458,18 @@ fn main_0() -> i32 { __bytes })); match (({ counted_ref_1(target.as_pointer(), ref_calls.as_pointer()) }),) { - (__tmp_3,) => __tmp_3.with_mut(|__b0| { + (__tmp_5,) => __tmp_5.with_mut(|__b0| { (*__b0).pop(); (*__b0).resize((1_usize) as usize, 0); (*__b0).push(0) }), }; match (({ counted_ref_1(target.as_pointer(), ref_calls.as_pointer()) }),) { - (__tmp_4,) => { - if 0_usize >= (*__tmp_4.upgrade().deref()).len() - 1 { + (__tmp_6,) => { + if 0_usize >= (*__tmp_6.upgrade().deref()).len() - 1 { panic!("out of bounds access") } - __tmp_4.decay().offset((0_usize) as isize) + __tmp_6.decay().offset((0_usize) as isize) } } .write(('A' as i8)); @@ -486,7 +496,7 @@ fn main_0() -> i32 { ]))); let mut target_index: i32 = 0; match (targets.decay().offset(target_index.postfix_inc()),) { - (__tmp_5,) => __tmp_5.with_mut(|__b0| { + (__tmp_7,) => __tmp_7.with_mut(|__b0| { (*__b0).pop(); (*__b0).resize((1_usize) as usize, 0); (*__b0).push(0) @@ -518,8 +528,8 @@ fn main_0() -> i32 { { { ({ - let mut __tmp_6 = { (*target.borrow()).clone() }; - (*chained.borrow_mut()) = __tmp_6; + let mut __tmp_8 = { (*target.borrow()).clone() }; + (*chained.borrow_mut()) = __tmp_8; }); chained.with_mut(|__b0| { (*__b0).pop(); @@ -569,18 +579,18 @@ fn main_0() -> i32 { })); let self_ptr: Value>> = Rc::new(RefCell::new((self_.as_pointer()))); { - let mut __tmp_7 = { { (*self_.borrow())[0_usize] } }; + let mut __tmp_9 = { { (*self_.borrow())[0_usize] } }; self_.with_mut(|__b0| { (*__b0).pop(); - (*__b0).resize((*__b0).len() + 2_usize, __tmp_7); + (*__b0).resize((*__b0).len() + 2_usize, __tmp_9); (*__b0).push(0); }) }; { - let mut __tmp_8 = { (index!((*self_ptr.borrow()), 1_usize).read()) }; + let mut __tmp_10 = { (index!((*self_ptr.borrow()), 1_usize).read()) }; (*self_ptr.borrow()).with_mut(|__b0| { (*__b0).pop(); - (*__b0).resize((*__b0).len() + 1_usize, __tmp_8); + (*__b0).resize((*__b0).len() + 1_usize, __tmp_10); (*__b0).push(0); }) }; @@ -628,10 +638,10 @@ fn main_0() -> i32 { })); { { - let mut __tmp_9 = { { (*local.borrow())[0_usize] } }; + let mut __tmp_11 = { { (*local.borrow())[0_usize] } }; local.with_mut(|__b0| { (*__b0).pop(); - (*__b0).resize((*__b0).len() + 1_usize, __tmp_9); + (*__b0).resize((*__b0).len() + 1_usize, __tmp_11); (*__b0).push(0); }) }; @@ -642,8 +652,8 @@ fn main_0() -> i32 { }) }; { - let mut __tmp_10 = { (*local.borrow()).clone() }; - (*local.borrow_mut()) = __tmp_10; + let mut __tmp_12 = { (*local.borrow()).clone() }; + (*local.borrow_mut()) = __tmp_12; }; assert!( ({ @@ -668,10 +678,10 @@ fn main_0() -> i32 { )) .as_pointer(),) { - (__tmp_11,) => { + (__tmp_13,) => { Ptr::::from_string_literal(b"-42").with_c_str(|__s| { - (*__tmp_11.upgrade().deref()) - [..(*__tmp_11.upgrade().deref()).len().saturating_sub(1)] + (*__tmp_13.upgrade().deref()) + [..(*__tmp_13.upgrade().deref()).len().saturating_sub(1)] == *__s }) } @@ -686,10 +696,10 @@ fn main_0() -> i32 { )) .as_pointer(),) { - (__tmp_12,) => { + (__tmp_14,) => { Ptr::::from_string_literal(b"-9223372036854775808").with_c_str(|__s| { - (*__tmp_12.upgrade().deref()) - [..(*__tmp_12.upgrade().deref()).len().saturating_sub(1)] + (*__tmp_14.upgrade().deref()) + [..(*__tmp_14.upgrade().deref()).len().saturating_sub(1)] == *__s }) } @@ -704,10 +714,10 @@ fn main_0() -> i32 { )) .as_pointer(),) { - (__tmp_13,) => { + (__tmp_15,) => { Ptr::::from_string_literal(b"1099511627776").with_c_str(|__s| { - (*__tmp_13.upgrade().deref()) - [..(*__tmp_13.upgrade().deref()).len().saturating_sub(1)] + (*__tmp_15.upgrade().deref()) + [..(*__tmp_15.upgrade().deref()).len().saturating_sub(1)] == *__s }) } @@ -722,10 +732,10 @@ fn main_0() -> i32 { )) .as_pointer(),) { - (__tmp_14,) => { + (__tmp_16,) => { Ptr::::from_string_literal(b"4294967295").with_c_str(|__s| { - (*__tmp_14.upgrade().deref()) - [..(*__tmp_14.upgrade().deref()).len().saturating_sub(1)] + (*__tmp_16.upgrade().deref()) + [..(*__tmp_16.upgrade().deref()).len().saturating_sub(1)] == *__s }) } @@ -740,10 +750,10 @@ fn main_0() -> i32 { )) .as_pointer(),) { - (__tmp_15,) => { + (__tmp_17,) => { Ptr::::from_string_literal(b"18446744073709551615").with_c_str(|__s| { - (*__tmp_15.upgrade().deref()) - [..(*__tmp_15.upgrade().deref()).len().saturating_sub(1)] + (*__tmp_17.upgrade().deref()) + [..(*__tmp_17.upgrade().deref()).len().saturating_sub(1)] == *__s }) } @@ -758,10 +768,10 @@ fn main_0() -> i32 { )) .as_pointer(),) { - (__tmp_16,) => { + (__tmp_18,) => { Ptr::::from_string_literal(b"0").with_c_str(|__s| { - (*__tmp_16.upgrade().deref()) - [..(*__tmp_16.upgrade().deref()).len().saturating_sub(1)] + (*__tmp_18.upgrade().deref()) + [..(*__tmp_18.upgrade().deref()).len().saturating_sub(1)] == *__s }) } @@ -775,10 +785,10 @@ fn main_0() -> i32 { )) .as_pointer(),) { - (__tmp_17,) => { + (__tmp_19,) => { Ptr::::from_string_literal(b"1.500000").with_c_str(|__s| { - (*__tmp_17.upgrade().deref()) - [..(*__tmp_17.upgrade().deref()).len().saturating_sub(1)] + (*__tmp_19.upgrade().deref()) + [..(*__tmp_19.upgrade().deref()).len().saturating_sub(1)] == *__s }) } @@ -792,10 +802,10 @@ fn main_0() -> i32 { )) .as_pointer(),) { - (__tmp_18,) => { + (__tmp_20,) => { Ptr::::from_string_literal(b"-0.250000").with_c_str(|__s| { - (*__tmp_18.upgrade().deref()) - [..(*__tmp_18.upgrade().deref()).len().saturating_sub(1)] + (*__tmp_20.upgrade().deref()) + [..(*__tmp_20.upgrade().deref()).len().saturating_sub(1)] == *__s }) } @@ -823,10 +833,10 @@ fn main_0() -> i32 { )) .as_pointer(),) { - (__tmp_19,) => { + (__tmp_21,) => { Ptr::::from_string_literal(b"-5").with_c_str(|__s| { - (*__tmp_19.upgrade().deref()) - [..(*__tmp_19.upgrade().deref()).len().saturating_sub(1)] + (*__tmp_21.upgrade().deref()) + [..(*__tmp_21.upgrade().deref()).len().saturating_sub(1)] == *__s }) } @@ -840,10 +850,10 @@ fn main_0() -> i32 { )) .as_pointer(),) { - (__tmp_20,) => { + (__tmp_22,) => { Ptr::::from_string_literal(b"15").with_c_str(|__s| { - (*__tmp_20.upgrade().deref()) - [..(*__tmp_20.upgrade().deref()).len().saturating_sub(1)] + (*__tmp_22.upgrade().deref()) + [..(*__tmp_22.upgrade().deref()).len().saturating_sub(1)] == *__s }) } diff --git a/tests/unit/out/refcount/string_moved_from.rs b/tests/unit/out/refcount/string_moved_from.rs index 85688562f9..da86aade59 100644 --- a/tests/unit/out/refcount/string_moved_from.rs +++ b/tests/unit/out/refcount/string_moved_from.rs @@ -25,15 +25,16 @@ pub fn print_moved_from_0(mut label: Ptr, from: Ptr>, to: Ptr Vec { - let mut word: Vec = { + let word: Value> = Rc::new(RefCell::new({ let mut __bytes = Ptr::::from_string_literal(b"returned local").to_c_bytes(); __bytes.push(0); __bytes - }; - return std::mem::take(&mut (word)); + })); + return ({ std::mem::take(&mut (*word.borrow_mut())) }); } -pub fn return_parameter_2(mut word: Vec) -> Vec { - return std::mem::take(&mut word); +pub fn return_parameter_2(word: Vec) -> Vec { + let word: Value> = Rc::new(RefCell::new(word)); + return ({ std::mem::take(&mut (*word.borrow_mut())) }); } pub fn return_reference_3(word: Ptr>) -> Vec { return word.with_mut(|__v| std::mem::replace(__v, vec![0])); diff --git a/tests/unit/out/refcount/string_substr.rs b/tests/unit/out/refcount/string_substr.rs index a39ab082f0..ca659b6f35 100644 --- a/tests/unit/out/refcount/string_substr.rs +++ b/tests/unit/out/refcount/string_substr.rs @@ -65,8 +65,8 @@ fn main_0() -> i32 { )); printf!(b"receiver: %s %d\n", out.decay(), (*calls.borrow())); (*calls.borrow_mut()) = 0; - { - (*out.borrow_mut()) = Rc::new(RefCell::new(({ temporary_1(calls.as_pointer()) }))) + match (Rc::new(RefCell::new( + Rc::new(RefCell::new(({ temporary_1(calls.as_pointer()) }))) .as_pointer() .with(|__s: &Vec| { let mut __tmp1 = __s @@ -74,61 +74,78 @@ fn main_0() -> i32 { .to_vec(); __tmp1.push(0); __tmp1 - }); + }), + )) + .as_pointer(),) + { + (__tmp_2,) => { + (*out.borrow_mut()) = __tmp_2.with_mut(|__v| std::mem::replace(__v, vec![0])); + } }; printf!(b"temporary: %s %d\n", out.decay(), (*calls.borrow())); - { - (*out.borrow_mut()) = { - let mut __tmp_2 = { - ({ - (*s.borrow_mut())[0_usize] = ('j' as i8); - 0 - } as usize) - }; - s.as_pointer().with(|__s: &Vec| { - let mut __tmp1 = __s - [__tmp_2..::std::cmp::min(__tmp_2 + 2_usize, __s.len().saturating_sub(1))] - .to_vec(); - __tmp1.push(0); - __tmp1 - }) + match (Rc::new(RefCell::new({ + let mut __tmp_4 = { + ({ + (*s.borrow_mut())[0_usize] = ('j' as i8); + 0 + } as usize) }; + s.as_pointer().with(|__s: &Vec| { + let mut __tmp1 = __s + [__tmp_4..::std::cmp::min(__tmp_4 + 2_usize, __s.len().saturating_sub(1))] + .to_vec(); + __tmp1.push(0); + __tmp1 + }) + })) + .as_pointer(),) + { + (__tmp_3,) => { + (*out.borrow_mut()) = __tmp_3.with_mut(|__v| std::mem::replace(__v, vec![0])); + } }; printf!(b"position mutation: %s %s\n", out.decay(), s.decay()); - { - (*out.borrow_mut()) = { - let mut __tmp_3 = { - ({ - (*s.borrow_mut())[1_usize] = ('a' as i8); - 2 - } as usize) - }; - s.as_pointer().with(|__s: &Vec| { - let mut __tmp1 = __s - [0_usize..::std::cmp::min(0_usize + __tmp_3, __s.len().saturating_sub(1))] - .to_vec(); - __tmp1.push(0); - __tmp1 - }) + match (Rc::new(RefCell::new({ + let mut __tmp_6 = { + ({ + (*s.borrow_mut())[1_usize] = ('a' as i8); + 2 + } as usize) }; + s.as_pointer().with(|__s: &Vec| { + let mut __tmp1 = __s + [0_usize..::std::cmp::min(0_usize + __tmp_6, __s.len().saturating_sub(1))] + .to_vec(); + __tmp1.push(0); + __tmp1 + }) + })) + .as_pointer(),) + { + (__tmp_5,) => { + (*out.borrow_mut()) = __tmp_5.with_mut(|__v| std::mem::replace(__v, vec![0])); + } }; printf!(b"count mutation: %s %s\n", out.decay(), s.decay()); (*out.borrow_mut())[0_usize] = ('X' as i8); (*s.borrow_mut())[1_usize] = ('b' as i8); printf!(b"independent: %s %s\n", out.decay(), s.decay()); let mut p: Ptr> = (s.as_pointer()); + match (Rc::new(RefCell::new(p.with(|__s: &Vec| { + let mut __tmp1 = + __s[1_usize..::std::cmp::min(1_usize + 2_usize, __s.len().saturating_sub(1))].to_vec(); + __tmp1.push(0); + __tmp1 + }))) + .as_pointer(),) { - (*out.borrow_mut()) = p.with(|__s: &Vec| { - let mut __tmp1 = __s - [1_usize..::std::cmp::min(1_usize + 2_usize, __s.len().saturating_sub(1))] - .to_vec(); - __tmp1.push(0); - __tmp1 - }); + (__tmp_7,) => { + (*out.borrow_mut()) = __tmp_7.with_mut(|__v| std::mem::replace(__v, vec![0])); + } }; printf!(b"pointer: %s\n", out.decay()); - { - (*out.borrow_mut()) = Rc::new(RefCell::new( + match (Rc::new(RefCell::new( + Rc::new(RefCell::new( Rc::new(RefCell::new({ let mut __bytes = Ptr::::from_string_literal(b"hello").to_c_bytes(); __bytes.push(0); @@ -150,20 +167,30 @@ fn main_0() -> i32 { .to_vec(); __tmp1.push(0); __tmp1 - }); + }), + )) + .as_pointer(),) + { + (__tmp_8,) => { + (*out.borrow_mut()) = __tmp_8.with_mut(|__v| std::mem::replace(__v, vec![0])); + } }; printf!(b"nested: %s\n", out.decay()); + match (Rc::new(RefCell::new({ + let mut __tmp_10 = { ((*s.borrow()).len() - 1) }; + s.as_pointer().with(|__s: &Vec| { + let mut __tmp1 = __s + [__tmp_10..::std::cmp::min(__tmp_10 + 0_usize, __s.len().saturating_sub(1))] + .to_vec(); + __tmp1.push(0); + __tmp1 + }) + })) + .as_pointer(),) { - (*out.borrow_mut()) = { - let mut __tmp_4 = { ((*s.borrow()).len() - 1) }; - s.as_pointer().with(|__s: &Vec| { - let mut __tmp1 = __s - [__tmp_4..::std::cmp::min(__tmp_4 + 0_usize, __s.len().saturating_sub(1))] - .to_vec(); - __tmp1.push(0); - __tmp1 - }) - }; + (__tmp_9,) => { + (*out.borrow_mut()) = __tmp_9.with_mut(|__v| std::mem::replace(__v, vec![0])); + } }; printf!(b"empty: %zu\n", ((*out.borrow()).len() - 1)); let field: Value> = Rc::new(RefCell::new({ @@ -174,14 +201,21 @@ fn main_0() -> i32 { let text: Value = Rc::new(RefCell::new(Text { value: field.as_pointer(), })); - { - (*out.borrow_mut()) = { (*text.borrow()).value.clone() }.with(|__s: &Vec| { - let mut __tmp1 = __s - [1_usize..::std::cmp::min(1_usize + 2_usize, __s.len().saturating_sub(1))] - .to_vec(); - __tmp1.push(0); - __tmp1 - }); + match ( + Rc::new(RefCell::new({ (*text.borrow()).value.clone() }.with( + |__s: &Vec| { + let mut __tmp1 = __s + [1_usize..::std::cmp::min(1_usize + 2_usize, __s.len().saturating_sub(1))] + .to_vec(); + __tmp1.push(0); + __tmp1 + }, + ))) + .as_pointer(), + ) { + (__tmp_11,) => { + (*out.borrow_mut()) = __tmp_11.with_mut(|__v| std::mem::replace(__v, vec![0])); + } }; printf!( b"field: %s %s\n", @@ -201,8 +235,8 @@ fn main_0() -> i32 { }, ]))); let mut index: usize = 0_usize; - { - (*out.borrow_mut()) = strings + match (Rc::new(RefCell::new( + strings .decay() .offset(index.postfix_inc()) .with(|__s: &Vec| { @@ -211,7 +245,13 @@ fn main_0() -> i32 { .to_vec(); __tmp1.push(0); __tmp1 - }); + }), + )) + .as_pointer(),) + { + (__tmp_12,) => { + (*out.borrow_mut()) = __tmp_12.with_mut(|__v| std::mem::replace(__v, vec![0])); + } }; printf!(b"element: %s %zu\n", out.decay(), index); return 0; diff --git a/tests/unit/out/refcount/vector.rs b/tests/unit/out/refcount/vector.rs index 95d975e81c..7775c9ee22 100644 --- a/tests/unit/out/refcount/vector.rs +++ b/tests/unit/out/refcount/vector.rs @@ -84,13 +84,10 @@ fn main_0() -> i32 { let mut v1: Vec = Vec::new(); assert!((v1.len() == 0_usize)); assert!(v1.is_empty()); - ({ - let __tmp_0: Value = Rc::new(RefCell::new(1)); - { - let __a1 = move_constructed(&__tmp_0.as_pointer()); - v1.push(__a1) - } - }); + { + let __a1 = 1; + v1.push(__a1) + }; assert!(!(v1.is_empty())); v1.pop(); assert!(v1.is_empty()); @@ -104,41 +101,32 @@ fn main_0() -> i32 { assert!((v1[99_usize] == 50)); let v2: Value> = Rc::new(RefCell::new(Vec::new())); assert!(({ ((*v2.borrow()).len() == 0_usize) })); - ({ - let __tmp_1: Value = Rc::new(RefCell::new(1)); - { - let __a1 = move_constructed(&__tmp_1.as_pointer()); - (*v2.borrow_mut()).push(__a1) - } - }); - ({ - let __tmp_2: Value = Rc::new(RefCell::new(2)); - { - let __a1 = move_constructed(&__tmp_2.as_pointer()); - (*v2.borrow_mut()).push(__a1) - } - }); - ({ - let __tmp_3: Value = Rc::new(RefCell::new(3)); - { - let __a1 = move_constructed(&__tmp_3.as_pointer()); - (*v2.borrow_mut()).push(__a1) - } - }); + { + let __a1 = 1; + (*v2.borrow_mut()).push(__a1) + }; + { + let __a1 = 2; + (*v2.borrow_mut()).push(__a1) + }; + { + let __a1 = 3; + (*v2.borrow_mut()).push(__a1) + }; assert!(({ ((*v2.borrow()).len() == 3_usize) })); { - let mut __tmp_4 = { >::from(v2.decay().begin()) }; + let mut __tmp_0 = { >::from(v2.decay().begin()) }; v2.as_pointer() - .with_mut(|__v: &mut Vec| __v.remove(__tmp_4.index())); - (__tmp_4).clone() + .with_mut(|__v: &mut Vec| __v.remove(__tmp_0.index())); + (__tmp_0).clone() }; assert!(({ ((*v2.borrow()).len() == 2_usize) })); assert!(({ (*v2.borrow())[0_usize] } == 2)); assert!(({ (*v2.borrow())[1_usize] } == 3)); { - let mut __tmp_5 = { >::from(v2.decay().begin()) }; - (*v2.borrow_mut()).insert(__tmp_5.index(), 100); - (__tmp_5).clone() + let mut __tmp_1 = { >::from(v2.decay().begin()) }; + (*v2.borrow_mut()).insert(__tmp_1.index(), 100); + (__tmp_1).clone() }; ({ copy_0({ (*v2.borrow()).clone() }) }); assert!(({ ((*v2.borrow()).len() == 3_usize) })); @@ -147,30 +135,30 @@ fn main_0() -> i32 { assert!(({ (*v2.borrow())[2_usize] } == 3)); let mut x: i32 = 7; { - let mut __tmp_6 = + let mut __tmp_2 = { >::from(v2.decay().begin().iter_add(1_isize)) }; - (*v2.borrow_mut()).insert(__tmp_6.index(), x); - (__tmp_6).clone() + (*v2.borrow_mut()).insert(__tmp_2.index(), x); + (__tmp_2).clone() }; assert!(({ ((*v2.borrow()).len() == 4_usize) })); assert!(({ (*v2.borrow())[0_usize] } == 100)); assert!(({ (*v2.borrow())[1_usize] } == 7)); assert!(({ (*v2.borrow())[2_usize] } == 2)); { - let mut __tmp_7 = { >::from(v2.decay().end()) }; - let __off = __tmp_7.index(); + let mut __tmp_3 = { >::from(v2.decay().end()) }; + let __off = __tmp_3.index(); (*v2.borrow_mut()).splice(__off..__off, std::iter::repeat_n(9, 2_usize)); - (__tmp_7).clone() + (__tmp_3).clone() }; assert!(({ ((*v2.borrow()).len() == 6_usize) })); assert!(({ (*v2.borrow())[4_usize] } == 9)); assert!(({ (*v2.borrow())[5_usize] } == 9)); { - let mut __tmp_8 = + let mut __tmp_4 = { >::from(v2.decay().begin().iter_add(2_isize)) }; - let __off = __tmp_8.index(); + let __off = __tmp_4.index(); (*v2.borrow_mut()).splice(__off..__off, Vec::from([11, 12, 13])); - (__tmp_8).clone() + (__tmp_4).clone() }; assert!(({ ((*v2.borrow()).len() == 9_usize) })); assert!(({ (*v2.borrow())[1_usize] } == 7)); @@ -181,47 +169,47 @@ fn main_0() -> i32 { assert!(({ (*v2.borrow())[8_usize] } == 9)); let src: Value> = Rc::new(RefCell::new(Vec::from([21, 22]))); { - let mut __tmp_9 = { >::from(v2.decay().begin()) }; - let mut __tmp_10 = { src.decay().begin() }; - let mut __tmp_11 = { src.decay().end() }; - let start_idx = __tmp_9.index(); + let mut __tmp_5 = { >::from(v2.decay().begin()) }; + let mut __tmp_6 = { src.decay().begin() }; + let mut __tmp_7 = { src.decay().end() }; + let start_idx = __tmp_5.index(); let mut temp_vec: Vec = Vec::new(); - let mut __it = (__tmp_10).clone(); - while __it != __tmp_11 { + let mut __it = (__tmp_6).clone(); + while __it != __tmp_7 { temp_vec.push((__it.iter_deref().read())); __it.iter_inc(); } v2.as_pointer().with_mut(|v: &mut Vec| { v.splice(start_idx..start_idx, temp_vec); }); - (__tmp_9).clone() + (__tmp_5).clone() }; assert!(({ ((*v2.borrow()).len() == 11_usize) })); assert!(({ (*v2.borrow())[0_usize] } == 21)); assert!(({ (*v2.borrow())[1_usize] } == 22)); assert!(({ (*v2.borrow())[2_usize] } == 100)); { - let mut __tmp_12 = { >::from(v2.decay().begin()) }; + let mut __tmp_8 = { >::from(v2.decay().begin()) }; v2.as_pointer() - .with_mut(|__v: &mut Vec| __v.remove(__tmp_12.index())); - (__tmp_12).clone() + .with_mut(|__v: &mut Vec| __v.remove(__tmp_8.index())); + (__tmp_8).clone() }; { - let mut __tmp_13 = { >::from(v2.decay().begin()) }; + let mut __tmp_9 = { >::from(v2.decay().begin()) }; v2.as_pointer() - .with_mut(|__v: &mut Vec| __v.remove(__tmp_13.index())); - (__tmp_13).clone() + .with_mut(|__v: &mut Vec| __v.remove(__tmp_9.index())); + (__tmp_9).clone() }; { let mut i: i32 = 0; 'loop_: while (i < 4) { 'for_body: { { - let mut __tmp_14 = + let mut __tmp_10 = { >::from(v2.decay().begin().iter_add(1_isize)) }; v2.as_pointer() - .with_mut(|__v: &mut Vec| __v.remove(__tmp_14.index())); - (__tmp_14).clone() + .with_mut(|__v: &mut Vec| __v.remove(__tmp_10.index())); + (__tmp_10).clone() }; } i.prefix_inc(); @@ -428,11 +416,11 @@ fn main_0() -> i32 { assert!( ({ (({ - let mut __tmp_15 = { (idx as usize) }; - if __tmp_15 >= (*v6.borrow()).len() { + let mut __tmp_11 = { (idx as usize) }; + if __tmp_11 >= (*v6.borrow()).len() { panic!("out of bounds access") } - v6.decay().offset((__tmp_15) as isize) + v6.decay().offset((__tmp_11) as isize) } .read()) == 2_f64) @@ -441,22 +429,22 @@ fn main_0() -> i32 { assert!( ({ (({ - let mut __tmp_16 = { (s2).wrapping_sub(1_usize) }; - if __tmp_16 >= (*v6.borrow()).len() { + let mut __tmp_12 = { (s2).wrapping_sub(1_usize) }; + if __tmp_12 >= (*v6.borrow()).len() { panic!("out of bounds access") } - v6.decay().offset((__tmp_16) as isize) + v6.decay().offset((__tmp_12) as isize) } .read()) == 5_f64) }) ); let ref1: Ptr = { - let mut __tmp_17 = { (s2).wrapping_sub(1_usize) }; - if __tmp_17 >= (*v6.borrow()).len() { + let mut __tmp_13 = { (s2).wrapping_sub(1_usize) }; + if __tmp_13 >= (*v6.borrow()).len() { panic!("out of bounds access") } - v6.decay().offset((__tmp_17) as isize) + v6.decay().offset((__tmp_13) as isize) }; { ref1.with_mut(|__v| *__v = *__v + 1.5_f64) @@ -464,22 +452,22 @@ fn main_0() -> i32 { assert!( ({ (({ - let mut __tmp_18 = { (s2).wrapping_sub(1_usize) }; - if __tmp_18 >= (*v6.borrow()).len() { + let mut __tmp_14 = { (s2).wrapping_sub(1_usize) }; + if __tmp_14 >= (*v6.borrow()).len() { panic!("out of bounds access") } - v6.decay().offset((__tmp_18) as isize) + v6.decay().offset((__tmp_14) as isize) } .read()) == 6.5_f64) }) ); let mut x1: f64 = ({ - let mut __tmp_19 = { (s2).wrapping_sub(1_usize) }; - if __tmp_19 >= (*v6.borrow()).len() { + let mut __tmp_15 = { (s2).wrapping_sub(1_usize) }; + if __tmp_15 >= (*v6.borrow()).len() { panic!("out of bounds access") } - v6.decay().offset((__tmp_19) as isize) + v6.decay().offset((__tmp_15) as isize) } .read()); assert!((x1 == 6.5_f64)); @@ -487,11 +475,11 @@ fn main_0() -> i32 { assert!( ({ (({ - let mut __tmp_20 = { (s2).wrapping_sub(1_usize) }; - if __tmp_20 >= (*v6.borrow()).len() { + let mut __tmp_16 = { (s2).wrapping_sub(1_usize) }; + if __tmp_16 >= (*v6.borrow()).len() { panic!("out of bounds access") } - v6.decay().offset((__tmp_20) as isize) + v6.decay().offset((__tmp_16) as isize) } .read()) == 6.5_f64) @@ -513,23 +501,17 @@ fn main_0() -> i32 { let a: Value = Rc::new(RefCell::new(S { x: 1 })); let pa: Value> = Rc::new(RefCell::new((a.as_pointer()))); let mut v8: Vec>> = Vec::new(); - ({ - let __tmp_21: Value>> = Rc::new(RefCell::new((pa.as_pointer()))); - { - let __a1 = move_constructed(&__tmp_21.as_pointer()); - v8.push(__a1) - } - }); + { + let __a1 = (pa.as_pointer()); + v8.push(__a1) + }; assert!(((v8[0_usize].read()).with(|__s| __s.x) == 1)); let ppa: Value>> = Rc::new(RefCell::new((pa.as_pointer()))); let mut v9: Vec>>> = Vec::new(); - ({ - let __tmp_22: Value>>> = Rc::new(RefCell::new((ppa.as_pointer()))); - { - let __a1 = move_constructed(&__tmp_22.as_pointer()); - v9.push(__a1) - } - }); + { + let __a1 = (ppa.as_pointer()); + v9.push(__a1) + }; field!(((v9[0_usize].read()).read()), x).write(2); assert!(({ (*a.borrow()).x } == 2)); let v10: Value> = Rc::new(RefCell::new(Vec::from([1, 2, 3]))); @@ -545,27 +527,18 @@ fn main_0() -> i32 { ); let foo: Value = Rc::new(RefCell::new(::zero_init())); DefaultConstructible::default_constructor(&foo.as_pointer()); - ({ - let __tmp_23: Value = Rc::new(RefCell::new(5)); - { - let __a1 = move_constructed(&__tmp_23.as_pointer()); - (*foo.borrow_mut()).a.push(__a1) - } - }); - ({ - let __tmp_24: Value = Rc::new(RefCell::new(6)); - { - let __a1 = move_constructed(&__tmp_24.as_pointer()); - (*foo.borrow_mut()).b.push(__a1) - } - }); - ({ - let __tmp_25: Value = Rc::new(RefCell::new(7)); - { - let __a1 = move_constructed(&__tmp_25.as_pointer()); - (*foo.borrow_mut()).b.push(__a1) - } - }); + { + let __a1 = 5; + (*foo.borrow_mut()).a.push(__a1) + }; + { + let __a1 = 6; + (*foo.borrow_mut()).b.push(__a1) + }; + { + let __a1 = 7; + (*foo.borrow_mut()).b.push(__a1) + }; field_ref!(foo.as_pointer(), a) .as_pointer() .swap_with(&field_ref!(foo.as_pointer(), b).as_pointer(), |__v| { @@ -594,14 +567,14 @@ fn main_0() -> i32 { let mut v12: Vec = Vec::new(); let moved: Value = Rc::new(RefCell::new(5)); { - let __a1 = move_constructed(&moved.as_pointer()); + let __a1 = ({ (*moved.borrow()) }); v12.push(__a1) }; assert!(({ (v12[0_usize] == 5) && ((*moved.borrow()) == 5) })); let mut v13: Vec> = Vec::new(); let moved_ptr: Value> = Rc::new(RefCell::new((moved.as_pointer()))); { - let __a1 = move_constructed(&moved_ptr.as_pointer()); + let __a1 = ({ (*moved_ptr.borrow()).clone() }); v13.push(__a1) }; assert!( @@ -665,19 +638,19 @@ fn main_0() -> i32 { let v16: Value> = Rc::new(RefCell::new(Vec::from([1, 2, 3, 4, 5, 6, 7, 8]))); let mut after_v16: Vec = Vec::from([0]); let inserted: Value> = Rc::new(RefCell::new({ - let mut __tmp_26 = + let mut __tmp_17 = { >::from(v16.decay().begin().iter_add(1_isize)) }; - (*v16.borrow_mut()).insert(__tmp_26.index(), 7); - (__tmp_26).clone() + (*v16.borrow_mut()).insert(__tmp_17.index(), 7); + (__tmp_17).clone() })); { ({ (*inserted.borrow()).iter_deref() }).with_mut(|__v| *__v = *__v + 1) }; let mut nine: i32 = 9; let inserted_copy: Value> = Rc::new(RefCell::new({ - let mut __tmp_27 = { >::from(v16.decay().begin()) }; - (*v16.borrow_mut()).insert(__tmp_27.index(), nine); - (__tmp_27).clone() + let mut __tmp_18 = { >::from(v16.decay().begin()) }; + (*v16.borrow_mut()).insert(__tmp_18.index(), nine); + (__tmp_18).clone() })); { ({ (*inserted_copy.borrow()).iter_deref() }).with_mut(|__v| *__v = *__v + 1) @@ -690,20 +663,20 @@ fn main_0() -> i32 { let ints: Value> = Rc::new(RefCell::new(Box::new([1, 2, 3]))); let longs: Value> = Rc::new(RefCell::new(Vec::from([10_i64, 20_i64]))); let pos: Value> = Rc::new(RefCell::new({ - let mut __tmp_28 = + let mut __tmp_19 = { >::from(longs.decay().begin().iter_add(1_isize)) }; - let mut __tmp_29 = { ints.decay().offset((3) as isize) }; - let start_idx = __tmp_28.index(); + let mut __tmp_20 = { ints.decay().offset((3) as isize) }; + let start_idx = __tmp_19.index(); let mut temp_vec: Vec = Vec::new(); let mut __it = ints.decay(); - while __it != __tmp_29 { + while __it != __tmp_20 { temp_vec.push(((__it.iter_deref().read()) as i64)); __it.iter_inc(); } longs.as_pointer().with_mut(|v: &mut Vec| { v.splice(start_idx..start_idx, temp_vec); }); - (__tmp_28).clone() + (__tmp_19).clone() })); assert!( ({ @@ -715,39 +688,39 @@ fn main_0() -> i32 { ); let more: Value> = Rc::new(RefCell::new(Vec::from([4, 5]))); { - let mut __tmp_30 = { >::from(longs.decay().end()) }; - let mut __tmp_31 = { more.decay().begin() }; - let mut __tmp_32 = { more.decay().end() }; - let start_idx = __tmp_30.index(); + let mut __tmp_21 = { >::from(longs.decay().end()) }; + let mut __tmp_22 = { more.decay().begin() }; + let mut __tmp_23 = { more.decay().end() }; + let start_idx = __tmp_21.index(); let mut temp_vec: Vec = Vec::new(); - let mut __it = (__tmp_31).clone(); - while __it != __tmp_32 { + let mut __it = (__tmp_22).clone(); + while __it != __tmp_23 { temp_vec.push(((__it.iter_deref().read()) as i64)); __it.iter_inc(); } longs.as_pointer().with_mut(|v: &mut Vec| { v.splice(start_idx..start_idx, temp_vec); }); - (__tmp_30).clone() + (__tmp_21).clone() }; assert!( ({ ((*longs.borrow()).len() == 7_usize) && ({ (*longs.borrow())[6_usize] } == 5_i64) }) ); let doubles: Value> = Rc::new(RefCell::new(Vec::new())); { - let mut __tmp_33 = { >::from(doubles.decay().begin()) }; - let mut __tmp_34 = { ints.decay().offset((2) as isize) }; - let start_idx = __tmp_33.index(); + let mut __tmp_24 = { >::from(doubles.decay().begin()) }; + let mut __tmp_25 = { ints.decay().offset((2) as isize) }; + let start_idx = __tmp_24.index(); let mut temp_vec: Vec = Vec::new(); let mut __it = ints.decay(); - while __it != __tmp_34 { + while __it != __tmp_25 { temp_vec.push(((__it.iter_deref().read()) as f64)); __it.iter_inc(); } doubles.as_pointer().with_mut(|v: &mut Vec| { v.splice(start_idx..start_idx, temp_vec); }); - (__tmp_33).clone() + (__tmp_24).clone() }; assert!( ({ @@ -757,19 +730,19 @@ fn main_0() -> i32 { ); let wrapped: Value> = Rc::new(RefCell::new(Vec::new())); { - let mut __tmp_35 = { >::from(wrapped.decay().begin()) }; - let mut __tmp_36 = { ints.decay().offset((3) as isize) }; - let start_idx = __tmp_35.index(); + let mut __tmp_26 = { >::from(wrapped.decay().begin()) }; + let mut __tmp_27 = { ints.decay().offset((3) as isize) }; + let start_idx = __tmp_26.index(); let mut temp_vec: Vec = Vec::new(); let mut __it = ints.decay(); - while __it != __tmp_36 { + while __it != __tmp_27 { temp_vec.push(>::cpp_from(__it.iter_deref())); __it.iter_inc(); } wrapped.as_pointer().with_mut(|v: &mut Vec| { v.splice(start_idx..start_idx, temp_vec); }); - (__tmp_35).clone() + (__tmp_26).clone() }; assert!( ({ @@ -779,20 +752,20 @@ fn main_0() -> i32 { ); let same: Value> = Rc::new(RefCell::new(Vec::from([7]))); { - let mut __tmp_37 = { >::from(same.decay().begin()) }; - let mut __tmp_38 = { more.decay().begin() }; - let mut __tmp_39 = { more.decay().end() }; - let start_idx = __tmp_37.index(); + let mut __tmp_28 = { >::from(same.decay().begin()) }; + let mut __tmp_29 = { more.decay().begin() }; + let mut __tmp_30 = { more.decay().end() }; + let start_idx = __tmp_28.index(); let mut temp_vec: Vec = Vec::new(); - let mut __it = (__tmp_38).clone(); - while __it != __tmp_39 { + let mut __it = (__tmp_29).clone(); + while __it != __tmp_30 { temp_vec.push((__it.iter_deref().read())); __it.iter_inc(); } same.as_pointer().with_mut(|v: &mut Vec| { v.splice(start_idx..start_idx, temp_vec); }); - (__tmp_37).clone() + (__tmp_28).clone() }; assert!( ({ diff --git a/tests/unit/out/refcount/vector2.rs b/tests/unit/out/refcount/vector2.rs index 0d6c759866..21be1608e6 100644 --- a/tests/unit/out/refcount/vector2.rs +++ b/tests/unit/out/refcount/vector2.rs @@ -8,37 +8,25 @@ use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn fn_0(v: Ptr>, v3: Vec) { let v3: Value> = Rc::new(RefCell::new(v3)); - ({ - let __tmp_0: Value = Rc::new(RefCell::new(20)); - { - let __a1 = move_constructed(&__tmp_0.as_pointer()); - v.with_mut(|__v: &mut Vec| __v.push(__a1)) - } - }); + { + let __a1 = 20; + v.with_mut(|__v: &mut Vec| __v.push(__a1)) + }; let mut x: i32 = 0_i32; let mut v2: Vec = Vec::new(); let mut v4: Ptr> = (v3.as_pointer()); - ({ - let __tmp_1: Value = Rc::new(RefCell::new(0)); - { - let __a1 = move_constructed(&__tmp_1.as_pointer()); - v2.push(__a1) - } - }); - ({ - let __tmp_2: Value = Rc::new(RefCell::new(1)); - { - let __a1 = move_constructed(&__tmp_2.as_pointer()); - v2.push(__a1) - } - }); - ({ - let __tmp_3: Value = Rc::new(RefCell::new(3)); - { - let __a1 = move_constructed(&__tmp_3.as_pointer()); - v2.push(__a1) - } - }); + { + let __a1 = 0; + v2.push(__a1) + }; + { + let __a1 = 1; + v2.push(__a1) + }; + { + let __a1 = 3; + v2.push(__a1) + }; x = (index!(v, 2_usize).read()); v2[0_usize] = 1; elem!( @@ -69,13 +57,10 @@ pub fn fn_0(v: Ptr>, v3: Vec) { assert!((v2[2_usize] == 6)); assert!(({ (*v3.borrow())[0_usize] } == 7)); assert!(({ (*v3.borrow())[1_usize] } == 13)); - ({ - let __tmp_4: Value = Rc::new(RefCell::new(20)); - { - let __a1 = move_constructed(&__tmp_4.as_pointer()); - v.with_mut(|__v: &mut Vec| __v.push(__a1)) - } - }); + { + let __a1 = 20; + v.with_mut(|__v: &mut Vec| __v.push(__a1)) + }; } pub fn main() { __cpp2rust_init_globals(); @@ -84,41 +69,26 @@ pub fn main() { fn main_0() -> i32 { let v: Value> = Rc::new(RefCell::new(Vec::new())); let mut v2: Vec = Vec::new(); - ({ - let __tmp_5: Value = Rc::new(RefCell::new(4)); - { - let __a1 = move_constructed(&__tmp_5.as_pointer()); - (*v.borrow_mut()).push(__a1) - } - }); - ({ - let __tmp_6: Value = Rc::new(RefCell::new(5)); - { - let __a1 = move_constructed(&__tmp_6.as_pointer()); - (*v.borrow_mut()).push(__a1) - } - }); - ({ - let __tmp_7: Value = Rc::new(RefCell::new(6)); - { - let __a1 = move_constructed(&__tmp_7.as_pointer()); - (*v.borrow_mut()).push(__a1) - } - }); - ({ - let __tmp_8: Value = Rc::new(RefCell::new(8)); - { - let __a1 = move_constructed(&__tmp_8.as_pointer()); - v2.push(__a1) - } - }); - ({ - let __tmp_9: Value = Rc::new(RefCell::new(9)); - { - let __a1 = move_constructed(&__tmp_9.as_pointer()); - v2.push(__a1) - } - }); + { + let __a1 = 4; + (*v.borrow_mut()).push(__a1) + }; + { + let __a1 = 5; + (*v.borrow_mut()).push(__a1) + }; + { + let __a1 = 6; + (*v.borrow_mut()).push(__a1) + }; + { + let __a1 = 8; + v2.push(__a1) + }; + { + let __a1 = 9; + v2.push(__a1) + }; ({ fn_0(v.as_pointer(), v2.clone()) }); return 0; } diff --git a/tests/unit/out/refcount/vector_deque_vector_string.rs b/tests/unit/out/refcount/vector_deque_vector_string.rs index bbda640036..4c952f0928 100644 --- a/tests/unit/out/refcount/vector_deque_vector_string.rs +++ b/tests/unit/out/refcount/vector_deque_vector_string.rs @@ -27,7 +27,7 @@ fn main_0() -> i32 { .as_pointer(),) { (__tmp_0,) => { - let __a1 = move_constructed(&(__tmp_0).clone()); + let __a1 = __tmp_0.with_mut(|__v| std::mem::replace(__v, vec![0])); (*row.borrow_mut()).push(__a1) } }; @@ -39,7 +39,7 @@ fn main_0() -> i32 { .as_pointer(),) { (__tmp_1,) => { - let __a1 = move_constructed(&(__tmp_1).clone()); + let __a1 = __tmp_1.with_mut(|__v| std::mem::replace(__v, vec![0])); (*row.borrow_mut()).push(__a1) } }; @@ -53,7 +53,7 @@ fn main_0() -> i32 { .as_pointer(),) { (__tmp_2,) => { - let __a1 = move_constructed(&(__tmp_2).clone()); + let __a1 = __tmp_2.with_mut(|__v| std::mem::replace(__v, vec![0])); (*row.borrow_mut()).push(__a1) } }; @@ -90,7 +90,7 @@ fn main_0() -> i32 { .as_pointer(), ) { (__tmp_4, __tmp_6) => { - let __a1 = move_constructed(&(__tmp_6).clone()); + let __a1 = __tmp_6.with_mut(|__v| std::mem::replace(__v, vec![0])); __tmp_4.with_mut(|__v: &mut Vec>| __v.push(__a1)) } }; diff --git a/tests/unit/out/refcount/vector_subscript_direct.rs b/tests/unit/out/refcount/vector_subscript_direct.rs index 4850b63e30..bc796517ef 100644 --- a/tests/unit/out/refcount/vector_subscript_direct.rs +++ b/tests/unit/out/refcount/vector_subscript_direct.rs @@ -56,13 +56,10 @@ impl DefaultConstructible for Holder { } } pub fn push_and_index_0(v: Ptr>) -> i32 { - ({ - let __tmp_0: Value = Rc::new(RefCell::new(42)); - { - let __a1 = move_constructed(&__tmp_0.as_pointer()); - v.with_mut(|__v: &mut Vec| __v.push(__a1)) - } - }); + { + let __a1 = 42; + v.with_mut(|__v: &mut Vec| __v.push(__a1)) + }; return ((((*v.upgrade().deref()).len()) as i32) - 1); } pub fn sum_ref_1(v: Ptr>) -> i32 { @@ -118,13 +115,10 @@ fn main_0() -> i32 { DefaultConstructible::default_constructor(&h.as_pointer()); (*h.borrow_mut()).values.resize_with(2_usize, || 0_i32); vec_elem!(h.as_pointer(), values, 1_usize).write(6); - ({ - let __tmp_1: Value = Rc::new(RefCell::new(Point { x: 1, y: 2 })); - { - let __a1 = move_constructed(&(__tmp_1.as_pointer())); - (*h.borrow_mut()).points.push(__a1) - } - }); + { + let __a1 = (Point { x: 1, y: 2 }); + (*h.borrow_mut()).points.push(__a1) + }; field!(vec_elem!(h.as_pointer(), points, 0_usize), y).write(5); assert!(((vec_elem!(h.as_pointer(), values, 1_usize).read()) == 6)); assert!( @@ -142,14 +136,14 @@ fn main_0() -> i32 { assert!((vec_elem!(h.as_pointer(), points, 0_usize).with(|__s| __s.x) == 7)); let grid: Value>> = Rc::new(RefCell::new(Vec::new())); match (Rc::new(RefCell::new(vec![0; 3_usize])).as_pointer(),) { - (__tmp_2,) => { - let __a1 = move_constructed(&(__tmp_2).clone()); + (__tmp_0,) => { + let __a1 = __tmp_0.with_mut(std::mem::take); (*grid.borrow_mut()).push(__a1) } }; match (Rc::new(RefCell::new(vec![0; 3_usize])).as_pointer(),) { - (__tmp_3,) => { - let __a1 = move_constructed(&(__tmp_3).clone()); + (__tmp_1,) => { + let __a1 = __tmp_1.with_mut(std::mem::take); (*grid.borrow_mut()).push(__a1) } }; diff --git a/tests/unit/out/refcount/vector_with_allocator.rs b/tests/unit/out/refcount/vector_with_allocator.rs index fe1e3e40e3..a2a7b7b5e7 100644 --- a/tests/unit/out/refcount/vector_with_allocator.rs +++ b/tests/unit/out/refcount/vector_with_allocator.rs @@ -39,37 +39,25 @@ pub struct TestAllocator_double_ {} pub fn copy_0(mut copy_vector: Vec) {} pub fn fn_1(v: Ptr>, v3: Vec) { let v3: Value> = Rc::new(RefCell::new(v3)); - ({ - let __tmp_0: Value = Rc::new(RefCell::new(20)); - { - let __a1 = move_constructed(&__tmp_0.as_pointer()); - v.with_mut(|__v: &mut Vec| __v.push(__a1)) - } - }); + { + let __a1 = 20; + v.with_mut(|__v: &mut Vec| __v.push(__a1)) + }; let mut x: i32 = 0_i32; let mut v4: Ptr> = (v3.as_pointer()); let mut v2: Vec = Vec::new(); - ({ - let __tmp_1: Value = Rc::new(RefCell::new(0)); - { - let __a1 = move_constructed(&__tmp_1.as_pointer()); - v2.push(__a1) - } - }); - ({ - let __tmp_2: Value = Rc::new(RefCell::new(1)); - { - let __a1 = move_constructed(&__tmp_2.as_pointer()); - v2.push(__a1) - } - }); - ({ - let __tmp_3: Value = Rc::new(RefCell::new(3)); - { - let __a1 = move_constructed(&__tmp_3.as_pointer()); - v2.push(__a1) - } - }); + { + let __a1 = 0; + v2.push(__a1) + }; + { + let __a1 = 1; + v2.push(__a1) + }; + { + let __a1 = 3; + v2.push(__a1) + }; x = (index!(v, 2_usize).read()); v2[0_usize] = 1; elem!( @@ -94,13 +82,10 @@ pub fn fn_1(v: Ptr>, v3: Vec) { ); assert!(({ (*v3.borrow())[0_usize] } == 7)); assert!(({ (*v3.borrow())[1_usize] } == 13)); - ({ - let __tmp_4: Value = Rc::new(RefCell::new(20)); - { - let __a1 = move_constructed(&__tmp_4.as_pointer()); - v.with_mut(|__v: &mut Vec| __v.push(__a1)) - } - }); + { + let __a1 = 20; + v.with_mut(|__v: &mut Vec| __v.push(__a1)) + }; } pub fn main() { __cpp2rust_init_globals(); @@ -110,13 +95,10 @@ fn main_0() -> i32 { let mut v1: Vec = Vec::new(); assert!((v1.len() == 0_usize)); assert!(v1.is_empty()); - ({ - let __tmp_5: Value = Rc::new(RefCell::new(1)); - { - let __a1 = move_constructed(&__tmp_5.as_pointer()); - v1.push(__a1) - } - }); + { + let __a1 = 1; + v1.push(__a1) + }; assert!(!(v1.is_empty())); v1.pop(); assert!(v1.is_empty()); @@ -130,41 +112,32 @@ fn main_0() -> i32 { assert!((v1[99_usize] == 50)); let v2: Value> = Rc::new(RefCell::new(Vec::new())); assert!(({ ((*v2.borrow()).len() == 0_usize) })); - ({ - let __tmp_6: Value = Rc::new(RefCell::new(1)); - { - let __a1 = move_constructed(&__tmp_6.as_pointer()); - (*v2.borrow_mut()).push(__a1) - } - }); - ({ - let __tmp_7: Value = Rc::new(RefCell::new(2)); - { - let __a1 = move_constructed(&__tmp_7.as_pointer()); - (*v2.borrow_mut()).push(__a1) - } - }); - ({ - let __tmp_8: Value = Rc::new(RefCell::new(3)); - { - let __a1 = move_constructed(&__tmp_8.as_pointer()); - (*v2.borrow_mut()).push(__a1) - } - }); + { + let __a1 = 1; + (*v2.borrow_mut()).push(__a1) + }; + { + let __a1 = 2; + (*v2.borrow_mut()).push(__a1) + }; + { + let __a1 = 3; + (*v2.borrow_mut()).push(__a1) + }; assert!(({ ((*v2.borrow()).len() == 3_usize) })); { - let mut __tmp_9 = { >::from(v2.decay().begin()) }; + let mut __tmp_0 = { >::from(v2.decay().begin()) }; v2.as_pointer() - .with_mut(|__v: &mut Vec| __v.remove(__tmp_9.index())); - (__tmp_9).clone() + .with_mut(|__v: &mut Vec| __v.remove(__tmp_0.index())); + (__tmp_0).clone() }; assert!(({ ((*v2.borrow()).len() == 2_usize) })); assert!(({ (*v2.borrow())[0_usize] } == 2)); assert!(({ (*v2.borrow())[1_usize] } == 3)); { - let mut __tmp_10 = { >::from(v2.decay().begin()) }; - (*v2.borrow_mut()).insert(__tmp_10.index(), 100); - (__tmp_10).clone() + let mut __tmp_1 = { >::from(v2.decay().begin()) }; + (*v2.borrow_mut()).insert(__tmp_1.index(), 100); + (__tmp_1).clone() }; ({ copy_0({ (*v2.borrow()).clone() }) }); assert!(({ ((*v2.borrow()).len() == 3_usize) })); @@ -308,11 +281,11 @@ fn main_0() -> i32 { assert!( ({ (({ - let mut __tmp_11 = { (idx as usize) }; - if __tmp_11 >= (*v6.borrow()).len() { + let mut __tmp_2 = { (idx as usize) }; + if __tmp_2 >= (*v6.borrow()).len() { panic!("out of bounds access") } - v6.decay().offset((__tmp_11) as isize) + v6.decay().offset((__tmp_2) as isize) } .read()) == 2_f64) @@ -321,22 +294,22 @@ fn main_0() -> i32 { assert!( ({ (({ - let mut __tmp_12 = { (s2).wrapping_sub(1_usize) }; - if __tmp_12 >= (*v6.borrow()).len() { + let mut __tmp_3 = { (s2).wrapping_sub(1_usize) }; + if __tmp_3 >= (*v6.borrow()).len() { panic!("out of bounds access") } - v6.decay().offset((__tmp_12) as isize) + v6.decay().offset((__tmp_3) as isize) } .read()) == 5_f64) }) ); let ref1: Ptr = { - let mut __tmp_13 = { (s2).wrapping_sub(1_usize) }; - if __tmp_13 >= (*v6.borrow()).len() { + let mut __tmp_4 = { (s2).wrapping_sub(1_usize) }; + if __tmp_4 >= (*v6.borrow()).len() { panic!("out of bounds access") } - v6.decay().offset((__tmp_13) as isize) + v6.decay().offset((__tmp_4) as isize) }; { ref1.with_mut(|__v| *__v = *__v + 1.5_f64) @@ -344,22 +317,22 @@ fn main_0() -> i32 { assert!( ({ (({ - let mut __tmp_14 = { (s2).wrapping_sub(1_usize) }; - if __tmp_14 >= (*v6.borrow()).len() { + let mut __tmp_5 = { (s2).wrapping_sub(1_usize) }; + if __tmp_5 >= (*v6.borrow()).len() { panic!("out of bounds access") } - v6.decay().offset((__tmp_14) as isize) + v6.decay().offset((__tmp_5) as isize) } .read()) == 6.5_f64) }) ); let mut x1: f64 = ({ - let mut __tmp_15 = { (s2).wrapping_sub(1_usize) }; - if __tmp_15 >= (*v6.borrow()).len() { + let mut __tmp_6 = { (s2).wrapping_sub(1_usize) }; + if __tmp_6 >= (*v6.borrow()).len() { panic!("out of bounds access") } - v6.decay().offset((__tmp_15) as isize) + v6.decay().offset((__tmp_6) as isize) } .read()); assert!((x1 == 6.5_f64)); @@ -367,11 +340,11 @@ fn main_0() -> i32 { assert!( ({ (({ - let mut __tmp_16 = { (s2).wrapping_sub(1_usize) }; - if __tmp_16 >= (*v6.borrow()).len() { + let mut __tmp_7 = { (s2).wrapping_sub(1_usize) }; + if __tmp_7 >= (*v6.borrow()).len() { panic!("out of bounds access") } - v6.decay().offset((__tmp_16) as isize) + v6.decay().offset((__tmp_7) as isize) } .read()) == 6.5_f64) @@ -379,48 +352,33 @@ fn main_0() -> i32 { ); let v7: Value> = Rc::new(RefCell::new(Vec::new())); let mut v8: Vec = Vec::new(); - ({ - let __tmp_17: Value = Rc::new(RefCell::new(4)); - { - let __a1 = move_constructed(&__tmp_17.as_pointer()); - (*v7.borrow_mut()).push(__a1) - } - }); - ({ - let __tmp_18: Value = Rc::new(RefCell::new(5)); - { - let __a1 = move_constructed(&__tmp_18.as_pointer()); - (*v7.borrow_mut()).push(__a1) - } - }); - ({ - let __tmp_19: Value = Rc::new(RefCell::new(6)); - { - let __a1 = move_constructed(&__tmp_19.as_pointer()); - (*v7.borrow_mut()).push(__a1) - } - }); - ({ - let __tmp_20: Value = Rc::new(RefCell::new(8)); - { - let __a1 = move_constructed(&__tmp_20.as_pointer()); - v8.push(__a1) - } - }); - ({ - let __tmp_21: Value = Rc::new(RefCell::new(9)); - { - let __a1 = move_constructed(&__tmp_21.as_pointer()); - v8.push(__a1) - } - }); + { + let __a1 = 4; + (*v7.borrow_mut()).push(__a1) + }; + { + let __a1 = 5; + (*v7.borrow_mut()).push(__a1) + }; + { + let __a1 = 6; + (*v7.borrow_mut()).push(__a1) + }; + { + let __a1 = 8; + v8.push(__a1) + }; + { + let __a1 = 9; + v8.push(__a1) + }; ({ fn_1(v7.as_pointer(), v8.clone()) }); let src: Value> = Rc::new(RefCell::new(Box::new([1_u32, 2_u32, 3_u32]))); let mut v9: Vec = { - let mut __tmp_22 = { src.decay().offset((3) as isize) }; + let mut __tmp_8 = { src.decay().offset((3) as isize) }; let mut __v = Vec::new(); let mut __it = src.decay(); - while __it != __tmp_22 { + while __it != __tmp_8 { __v.push((__it.iter_deref().read())); __it.iter_inc(); } @@ -429,10 +387,10 @@ fn main_0() -> i32 { assert!((v9.len() == 3_usize)); assert!(((v9[0_usize] == 1_u32) && (v9[1_usize] == 2_u32)) && (v9[2_usize] == 3_u32)); let mut v10: Vec = { - let mut __tmp_23 = { src.decay().offset((3) as isize) }; + let mut __tmp_9 = { src.decay().offset((3) as isize) }; let mut __v = Vec::new(); let mut __it = src.decay(); - while __it != __tmp_23 { + while __it != __tmp_9 { __v.push(((__it.iter_deref().read()) as u64)); __it.iter_inc(); } @@ -441,10 +399,10 @@ fn main_0() -> i32 { assert!((v10.len() == 3_usize)); assert!(((v10[0_usize] == 1_u64) && (v10[1_usize] == 2_u64)) && (v10[2_usize] == 3_u64)); let mut v11: Vec = { - let mut __tmp_24 = { src.decay().offset((3) as isize) }; + let mut __tmp_10 = { src.decay().offset((3) as isize) }; let mut __v = Vec::new(); let mut __it = src.decay(); - while __it != __tmp_24 { + while __it != __tmp_10 { __v.push(((__it.iter_deref().read()) as i32)); __it.iter_inc(); } @@ -454,10 +412,10 @@ fn main_0() -> i32 { assert!(((v11[0_usize] == 1) && (v11[1_usize] == 2)) && (v11[2_usize] == 3)); let src1: Value> = Rc::new(RefCell::new(Box::new([1_u32, 2_u32, 3_u32]))); let mut v12: Vec = { - let mut __tmp_25 = { src1.decay().to_end() }; + let mut __tmp_11 = { src1.decay().to_end() }; let mut __v = Vec::new(); let mut __it = src1.decay(); - while __it != __tmp_25 { + while __it != __tmp_11 { __v.push((__it.iter_deref().read())); __it.iter_inc(); } @@ -470,10 +428,10 @@ fn main_0() -> i32 { let mut start: Ptr = buf.decay(); let mut len: usize = 5_usize; let mut v13: Vec = { - let mut __tmp_26 = { start.offset((len) as isize) }; + let mut __tmp_12 = { start.offset((len) as isize) }; let mut __v = Vec::new(); let mut __it = (start).clone(); - while __it != __tmp_26 { + while __it != __tmp_12 { __v.push((__it.iter_deref().read())); __it.iter_inc(); } diff --git a/tests/unit/out/unsafe/12_test.rs b/tests/unit/out/unsafe/12_test.rs index b2255e755b..b40ae15c5f 100644 --- a/tests/unit/out/unsafe/12_test.rs +++ b/tests/unit/out/unsafe/12_test.rs @@ -15,7 +15,7 @@ pub fn main() { unsafe fn main_0() -> i32 { let mut v: Vec> = Vec::new(); { - let __a1 = move_constructed_unsafe(&raw mut Vec::from_fn(10_usize, |_| 0_i32)); + let __a1 = Vec::from_fn(10_usize, |_| 0_i32); v.push(__a1) }; return 0; diff --git a/tests/unit/out/unsafe/array_of_noncopy_struct.rs b/tests/unit/out/unsafe/array_of_noncopy_struct.rs index 5a7ccd43f1..ce87fa9d47 100644 --- a/tests/unit/out/unsafe/array_of_noncopy_struct.rs +++ b/tests/unit/out/unsafe/array_of_noncopy_struct.rs @@ -52,7 +52,7 @@ unsafe fn main_0() -> i32 { }); arr[(0) as usize].tag = 7; { - let __a1 = move_constructed_unsafe(&raw mut 42); + let __a1 = 42; arr[(1) as usize].data.push(__a1) }; assert!(((arr[(0) as usize].tag) == (7))); diff --git a/tests/unit/out/unsafe/auto.rs b/tests/unit/out/unsafe/auto.rs index 0e673ae955..a3f067d494 100644 --- a/tests/unit/out/unsafe/auto.rs +++ b/tests/unit/out/unsafe/auto.rs @@ -18,11 +18,11 @@ unsafe fn main_0() -> i32 { let mut x3: u32 = 4_u32; let mut v: Vec = Vec::new(); { - let __a1 = move_constructed_unsafe(&raw mut 1); + let __a1 = 1; v.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 2); + let __a1 = 2; v.push(__a1) }; let mut sum: i32 = 0; diff --git a/tests/unit/out/unsafe/cast.rs b/tests/unit/out/unsafe/cast.rs index cc7f160baa..c32f956c62 100644 --- a/tests/unit/out/unsafe/cast.rs +++ b/tests/unit/out/unsafe/cast.rs @@ -238,16 +238,16 @@ pub unsafe fn vector_capacity_4() { v.reserve_exact(4_usize - len_0 as usize); }; { - let __a1 = move_constructed_unsafe(&raw mut 1); + let __a1 = 1; v.push(__a1) }; let mut i0: usize = ((&mut v[(0_usize)] as *mut i32) as *mut i32 as usize); { - let __a1 = move_constructed_unsafe(&raw mut 2); + let __a1 = 2; v.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 3); + let __a1 = 3; v.push(__a1) }; assert!( @@ -320,11 +320,11 @@ pub unsafe fn nested_5() { b.items.reserve_exact(4_usize - len_0 as usize); }; { - let __a1 = move_constructed_unsafe(&raw mut 1); + let __a1 = 1; b.items.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 2); + let __a1 = 2; b.items.push(__a1) }; let mut ib: usize = ((&mut b.items[(0_usize)] as *mut i32) as *mut i32 as usize); @@ -333,7 +333,7 @@ pub unsafe fn nested_5() { == ((ib as u64).wrapping_add((::std::mem::size_of::() as u64)) as usize)) ); { - let __a1 = move_constructed_unsafe(&raw mut 3); + let __a1 = 3; b.items.push(__a1) }; assert!( diff --git a/tests/unit/out/unsafe/class_templates.rs b/tests/unit/out/unsafe/class_templates.rs index e9d8d375cf..c2a4f9d216 100644 --- a/tests/unit/out/unsafe/class_templates.rs +++ b/tests/unit/out/unsafe/class_templates.rs @@ -337,7 +337,7 @@ pub fn main() { unsafe fn main_0() -> i32 { let mut ev: Vec = Vec::new(); { - let __a1 = move_constructed_unsafe(&raw mut (Elem { i: 2 })); + let __a1 = (Elem { i: 2 }); ev.push(__a1) }; assert!(((ev[(0_usize)].i) == (2))); diff --git a/tests/unit/out/unsafe/clone_vs_move.rs b/tests/unit/out/unsafe/clone_vs_move.rs index f46d375496..dec18f1168 100644 --- a/tests/unit/out/unsafe/clone_vs_move.rs +++ b/tests/unit/out/unsafe/clone_vs_move.rs @@ -171,7 +171,7 @@ unsafe fn main_0() -> i32 { 'loop_: while ((i) < (N)) { 'for_body: { { - let __a1 = move_constructed_unsafe(&raw mut Vec::from_fn(10_usize, |_| 0_i32)); + let __a1 = Vec::from_fn(10_usize, |_| 0_i32); m1.push(__a1) }; } @@ -278,7 +278,7 @@ unsafe fn main_0() -> i32 { let mut pair3: (Vec, i32) = (Vec::from_fn(0_usize, |_| 0_i32), 0); let mut pair4: (Vec, i32) = pair3.clone(); { - let __a1 = move_constructed_unsafe(&raw mut 1); + let __a1 = 1; pair4.0.push(__a1) }; pair4.1 = 1; diff --git a/tests/unit/out/unsafe/comma_operator.rs b/tests/unit/out/unsafe/comma_operator.rs index a51c46b55d..86864b4712 100644 --- a/tests/unit/out/unsafe/comma_operator.rs +++ b/tests/unit/out/unsafe/comma_operator.rs @@ -79,7 +79,7 @@ unsafe fn main_0() -> i32 { } .clone(); { - let __a1 = move_constructed_unsafe(&raw mut 3); + let __a1 = 3; v2.push(__a1) }; assert!(((a) == (5))); diff --git a/tests/unit/out/unsafe/compound_assign_ref.rs b/tests/unit/out/unsafe/compound_assign_ref.rs index 0423738c76..5bda4dc486 100644 --- a/tests/unit/out/unsafe/compound_assign_ref.rs +++ b/tests/unit/out/unsafe/compound_assign_ref.rs @@ -15,7 +15,7 @@ pub fn main() { unsafe fn main_0() -> i32 { let mut v: Vec = Vec::new(); { - let __a1 = move_constructed_unsafe(&raw mut 10); + let __a1 = 10; v.push(__a1) }; v[0] += 5; diff --git a/tests/unit/out/unsafe/container_element_receiver.rs b/tests/unit/out/unsafe/container_element_receiver.rs index 9af6cf4424..12d3ee6ee9 100644 --- a/tests/unit/out/unsafe/container_element_receiver.rs +++ b/tests/unit/out/unsafe/container_element_receiver.rs @@ -74,7 +74,7 @@ unsafe fn main_0() -> i32 { { let mut __tmp_0: i32; { - let __a1 = move_constructed_unsafe(&raw mut 8); + let __a1 = 8; (*{ __tmp_0 = 1; &raw mut (*m.subscript_move( diff --git a/tests/unit/out/unsafe/container_field_addr.rs b/tests/unit/out/unsafe/container_field_addr.rs index d5035d263e..bcd097a4ca 100644 --- a/tests/unit/out/unsafe/container_field_addr.rs +++ b/tests/unit/out/unsafe/container_field_addr.rs @@ -43,7 +43,7 @@ pub unsafe fn run_1(mut h: *mut S) { }); let mut pv: *mut Vec = (&mut (*h).v as *mut Vec); { - let __a1 = move_constructed_unsafe(&raw mut (((*(pv).cast_const()).len()) as i32)); + let __a1 = (((*(pv).cast_const()).len()) as i32); (*pv).push(__a1) }; assert!( diff --git a/tests/unit/out/unsafe/copy_assign.rs b/tests/unit/out/unsafe/copy_assign.rs index 41ebfa5823..ba4e43a606 100644 --- a/tests/unit/out/unsafe/copy_assign.rs +++ b/tests/unit/out/unsafe/copy_assign.rs @@ -385,7 +385,7 @@ unsafe fn main_0() -> i32 { let mut e2: ExplicitOperatorCall = ::zero_init(); DefaultConstructibleUnsafe::default_constructor(&mut e2); { - let __a1 = move_constructed_unsafe(&raw mut 5); + let __a1 = 5; e1.w.push(__a1) }; (unsafe { CopyAssignableUnsafe::copy_assign(&mut e2, &e1) }); diff --git a/tests/unit/out/unsafe/copy_move_defaulted.rs b/tests/unit/out/unsafe/copy_move_defaulted.rs index 8e5e5ccd38..b43b34703e 100644 --- a/tests/unit/out/unsafe/copy_move_defaulted.rs +++ b/tests/unit/out/unsafe/copy_move_defaulted.rs @@ -642,11 +642,11 @@ unsafe fn main_0() -> i32 { vec_.push(a0_clone) }; { - let __a1 = move_constructed_unsafe(&raw mut { + let __a1 = { let mut __v: Explicit = ::zero_init(); Explicit::construct(&mut __v, { 9 }); __v - }); + }; vec_.push(__a1) }; assert!(((vec_[(0_usize)].v) == (1)) && ((vec_[(1_usize)].v) == (9))); @@ -698,7 +698,11 @@ unsafe fn main_0() -> i32 { ); let mut bufs: Vec = Vec::new(); { - let __a1 = move_constructed_unsafe(&raw mut r); + let __a1 = { + let mut __v: Buffer = ::zero_init(); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut r }); + __v + }; bufs.push(__a1) }; { @@ -718,7 +722,7 @@ unsafe fn main_0() -> i32 { let mut o1: Owner = ::zero_init(); DefaultConstructibleUnsafe::default_constructor(&mut o1); { - let __a1 = move_constructed_unsafe(&raw mut 5); + let __a1 = 5; o1.data.push(__a1) }; o1.n = 5; @@ -904,7 +908,7 @@ unsafe fn main_0() -> i32 { DefaultConstructibleUnsafe::default_constructor(&mut a3); a1.v = 3; { - let __a1 = move_constructed_unsafe(&raw mut 4); + let __a1 = 4; a1.w.push(__a1) }; (unsafe { CopyAssignableUnsafe::copy_assign(&mut a2, &a1) }); diff --git a/tests/unit/out/unsafe/elidable_iterator_copy_cxx11.rs b/tests/unit/out/unsafe/elidable_iterator_copy_cxx11.rs index f7b48b1521..0a5d147cf5 100644 --- a/tests/unit/out/unsafe/elidable_iterator_copy_cxx11.rs +++ b/tests/unit/out/unsafe/elidable_iterator_copy_cxx11.rs @@ -15,11 +15,11 @@ pub fn main() { unsafe fn main_0() -> i32 { let mut v: Vec = Vec::new(); { - let __a1 = move_constructed_unsafe(&raw mut 4); + let __a1 = 4; v.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 7); + let __a1 = 7; v.push(__a1) }; let mut it: UnsafeRandomAccessIterator = { diff --git a/tests/unit/out/unsafe/field_method_receiver.rs b/tests/unit/out/unsafe/field_method_receiver.rs index d43427f175..5280d88e4e 100644 --- a/tests/unit/out/unsafe/field_method_receiver.rs +++ b/tests/unit/out/unsafe/field_method_receiver.rs @@ -95,7 +95,7 @@ pub unsafe fn run_0(mut o: *mut S) { (unsafe { S::bump(&mut (*o)) }); assert!(((unsafe { Counter::get(&(*o).c,) }) == (1))); { - let __a1 = move_constructed_unsafe(&raw mut (unsafe { Counter::get(&(*o).c) })); + let __a1 = (unsafe { Counter::get(&(*o).c) }); (*o).v.push(__a1) }; assert!((((*o).v.len()) == (1_usize)) && (((&mut (*o)).v[(0_usize)]) == (1))); diff --git a/tests/unit/out/unsafe/field_pointers.rs b/tests/unit/out/unsafe/field_pointers.rs index e9e1ce6c5f..0fefe76d01 100644 --- a/tests/unit/out/unsafe/field_pointers.rs +++ b/tests/unit/out/unsafe/field_pointers.rs @@ -68,7 +68,7 @@ impl Outer { } pub unsafe fn push(&mut self, mut k: i32) { { - let __a1 = move_constructed_unsafe(&raw mut ((k) + (self.x))); + let __a1 = ((k) + (self.x)); self.v.push(__a1) }; } diff --git a/tests/unit/out/unsafe/find.rs b/tests/unit/out/unsafe/find.rs index 565916d34d..573c0fe9af 100644 --- a/tests/unit/out/unsafe/find.rs +++ b/tests/unit/out/unsafe/find.rs @@ -41,15 +41,15 @@ pub fn main() { unsafe fn main_0() -> i32 { let mut v: Vec = Vec::new(); { - let __a1 = move_constructed_unsafe(&raw mut 1); + let __a1 = 1; v.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 2); + let __a1 = 2; v.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 3); + let __a1 = 3; v.push(__a1) }; let mut v_begin: UnsafeRandomAccessIterator = v.begin(); diff --git a/tests/unit/out/unsafe/fn_ptr_stable_sort.rs b/tests/unit/out/unsafe/fn_ptr_stable_sort.rs index 3fa376abcf..b235d786e6 100644 --- a/tests/unit/out/unsafe/fn_ptr_stable_sort.rs +++ b/tests/unit/out/unsafe/fn_ptr_stable_sort.rs @@ -37,15 +37,15 @@ pub fn main() { unsafe fn main_0() -> i32 { let mut v: Vec = Vec::new(); { - let __a1 = move_constructed_unsafe(&raw mut (Item { key: 3, value: 30 })); + let __a1 = (Item { key: 3, value: 30 }); v.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut (Item { key: 1, value: 10 })); + let __a1 = (Item { key: 1, value: 10 }); v.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut (Item { key: 2, value: 20 })); + let __a1 = (Item { key: 2, value: 20 }); v.push(__a1) }; { diff --git a/tests/unit/out/unsafe/foreach_disjoint_field_borrow.rs b/tests/unit/out/unsafe/foreach_disjoint_field_borrow.rs index 6df4dfb9bb..2dd1a83093 100644 --- a/tests/unit/out/unsafe/foreach_disjoint_field_borrow.rs +++ b/tests/unit/out/unsafe/foreach_disjoint_field_borrow.rs @@ -39,7 +39,7 @@ unsafe fn main_0() -> i32 { let mut s: S = ::zero_init(); DefaultConstructibleUnsafe::default_constructor(&mut s); { - let __a1 = move_constructed_unsafe(&raw mut 1); + let __a1 = 1; s.v.push(__a1) }; 'loop_: for e in IterRange::new(s.v.begin(), s.v.end()) { diff --git a/tests/unit/out/unsafe/foreach_double.rs b/tests/unit/out/unsafe/foreach_double.rs index c4c625c980..90d3c48fef 100644 --- a/tests/unit/out/unsafe/foreach_double.rs +++ b/tests/unit/out/unsafe/foreach_double.rs @@ -15,15 +15,15 @@ pub fn main() { unsafe fn main_0() -> i32 { let mut v: Vec = Vec::new(); { - let __a1 = move_constructed_unsafe(&raw mut 1); + let __a1 = 1; v.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 2); + let __a1 = 2; v.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 3); + let __a1 = 3; v.push(__a1) }; let mut square: i32 = 0; @@ -58,17 +58,17 @@ unsafe fn main_0() -> i32 { let mut m: Vec> = Vec::new(); let mut v1: Vec = Vec::new(); { - let __a1 = move_constructed_unsafe(&raw mut v1); + let __a1 = std::mem::take(&mut v1); m.push(__a1) }; let mut v2: Vec = Vec::new(); { - let __a1 = move_constructed_unsafe(&raw mut v2); + let __a1 = std::mem::take(&mut v2); m.push(__a1) }; let mut v3: Vec = Vec::new(); { - let __a1 = move_constructed_unsafe(&raw mut v3); + let __a1 = std::mem::take(&mut v3); m.push(__a1) }; 'loop_: for row in IterRange::new(m.begin(), m.end()) { diff --git a/tests/unit/out/unsafe/foreach_mut.rs b/tests/unit/out/unsafe/foreach_mut.rs index 885a57bb5b..b869c91348 100644 --- a/tests/unit/out/unsafe/foreach_mut.rs +++ b/tests/unit/out/unsafe/foreach_mut.rs @@ -15,15 +15,15 @@ pub fn main() { unsafe fn main_0() -> i32 { let mut v1: Vec = Vec::new(); { - let __a1 = move_constructed_unsafe(&raw mut 1); + let __a1 = 1; v1.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 2); + let __a1 = 2; v1.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 3); + let __a1 = 3; v1.push(__a1) }; let mut sum: i32 = 0; @@ -45,15 +45,15 @@ unsafe fn main_0() -> i32 { } let mut v2: Vec<*mut i32> = Vec::new(); { - let __a1 = move_constructed_unsafe(&raw mut (&mut v1[(0_usize)] as *mut i32)); + let __a1 = (&mut v1[(0_usize)] as *mut i32); v2.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut (&mut v1[(1_usize)] as *mut i32)); + let __a1 = (&mut v1[(1_usize)] as *mut i32); v2.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut (&mut v1[(2_usize)] as *mut i32)); + let __a1 = (&mut v1[(2_usize)] as *mut i32); v2.push(__a1) }; 'loop_: for p in IterRange::new(v2.begin(), v2.end()) { diff --git a/tests/unit/out/unsafe/implicit_autoref.rs b/tests/unit/out/unsafe/implicit_autoref.rs index 80eb5d29a7..04e93654e4 100644 --- a/tests/unit/out/unsafe/implicit_autoref.rs +++ b/tests/unit/out/unsafe/implicit_autoref.rs @@ -39,11 +39,11 @@ pub fn main() { unsafe fn main_0() -> i32 { let mut v: Vec = Vec::new(); { - let __a1 = move_constructed_unsafe(&raw mut 10); + let __a1 = 10; v.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 20); + let __a1 = 20; v.push(__a1) }; let mut p: *mut Vec = (&mut v as *mut Vec); @@ -52,11 +52,11 @@ unsafe fn main_0() -> i32 { let mut h: Holder = ::zero_init(); DefaultConstructibleUnsafe::default_constructor(&mut h); { - let __a1 = move_constructed_unsafe(&raw mut 40); + let __a1 = 40; h.v.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 50); + let __a1 = 50; h.v.push(__a1) }; let mut hp: *mut Holder = (&mut h as *mut Holder); diff --git a/tests/unit/out/unsafe/inline_container_fields.rs b/tests/unit/out/unsafe/inline_container_fields.rs index 842d4b4015..c0038a17ea 100644 --- a/tests/unit/out/unsafe/inline_container_fields.rs +++ b/tests/unit/out/unsafe/inline_container_fields.rs @@ -119,7 +119,7 @@ pub unsafe fn fill_1(mut s: *mut State) { } } { - let __a1 = move_constructed_unsafe(&raw mut Vec::from([1, 2, 3])); + let __a1 = Vec::from([1, 2, 3]); (*s).rows.push(__a1) }; } @@ -320,7 +320,7 @@ unsafe fn main_0() -> i32 { ); let mut va: [Vec; 2] = std::array::from_fn::<_, 2, _>(|_| Default::default()); { - let __a1 = move_constructed_unsafe(&raw mut 1); + let __a1 = 1; va[(0_usize)].push(__a1) }; let mut vb: [Vec; 2] = { diff --git a/tests/unit/out/unsafe/iterators.rs b/tests/unit/out/unsafe/iterators.rs index 2bc146f32e..ef0a32a6b5 100644 --- a/tests/unit/out/unsafe/iterators.rs +++ b/tests/unit/out/unsafe/iterators.rs @@ -44,11 +44,11 @@ unsafe fn main_0() -> i32 { } let mut v: Vec<*mut i32> = Vec::new(); { - let __a1 = move_constructed_unsafe(&raw mut (Box::leak(Box::new(2)) as *mut i32)); + let __a1 = (Box::leak(Box::new(2)) as *mut i32); v.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut (Box::leak(Box::new(3)) as *mut i32)); + let __a1 = (Box::leak(Box::new(3)) as *mut i32); v.push(__a1) }; 'loop_: for p in IterRange::new(v.begin(), v.end()) { diff --git a/tests/unit/out/unsafe/map.rs b/tests/unit/out/unsafe/map.rs index 076a95d7e5..79f7fa8b55 100644 --- a/tests/unit/out/unsafe/map.rs +++ b/tests/unit/out/unsafe/map.rs @@ -344,7 +344,7 @@ unsafe fn main_0() -> i32 { 'loop_: while ((i) > (30_u32)) { 'for_body: { { - let __a1 = move_constructed_unsafe(&raw mut (i as i32)); + let __a1 = (i as i32); indexes.push(__a1) }; } @@ -356,7 +356,7 @@ unsafe fn main_0() -> i32 { 'loop_: while ((i) > (60_u32)) { 'for_body: { { - let __a1 = move_constructed_unsafe(&raw mut (i as i32)); + let __a1 = (i as i32); indexes.push(__a1) }; } @@ -368,7 +368,7 @@ unsafe fn main_0() -> i32 { 'loop_: while ((i) > (0_u32)) { 'for_body: { { - let __a1 = move_constructed_unsafe(&raw mut (i as i32)); + let __a1 = (i as i32); indexes.push(__a1) }; } diff --git a/tests/unit/out/unsafe/move_assign.rs b/tests/unit/out/unsafe/move_assign.rs index 83c6ffab38..a4250a2b7f 100644 --- a/tests/unit/out/unsafe/move_assign.rs +++ b/tests/unit/out/unsafe/move_assign.rs @@ -125,16 +125,12 @@ unsafe fn main_0() -> i32 { assert!(((a.v) == (6))); let mut vec_: Vec = Vec::new(); { - let mut __tmp_0: MoveOnly = ::zero_init(); - { - let __a1 = move_constructed_unsafe( - &raw mut (*{ - MoveOnly::construct(&mut __tmp_0, { 7 }); - &mut __tmp_0 - }), - ); - vec_.push(__a1) - } + let __a1 = { + let mut __v: MoveOnly = ::zero_init(); + MoveOnly::construct(&mut __v, { 7 }); + __v + }; + vec_.push(__a1) }; let mut d: MoveOnly = ::zero_init(); MoveOnly::construct(&mut d, { 8 }); diff --git a/tests/unit/out/unsafe/move_ctor.rs b/tests/unit/out/unsafe/move_ctor.rs index 80416de718..17c54e25ff 100644 --- a/tests/unit/out/unsafe/move_ctor.rs +++ b/tests/unit/out/unsafe/move_ctor.rs @@ -213,21 +213,21 @@ unsafe fn main_0() -> i32 { assert!(((e.v) == (0))); let mut vec_: Vec = Vec::new(); { - let mut __tmp_0: MoveOnly = ::zero_init(); - { - let __a1 = move_constructed_unsafe( - &raw mut (*{ - MoveOnly::construct(&mut __tmp_0, { 7 }); - &mut __tmp_0 - }), - ); - vec_.push(__a1) - } + let __a1 = { + let mut __v: MoveOnly = ::zero_init(); + MoveOnly::construct(&mut __v, { 7 }); + __v + }; + vec_.push(__a1) }; let mut f: MoveOnly = ::zero_init(); MoveOnly::construct(&mut f, { 8 }); { - let __a1 = move_constructed_unsafe(&raw mut f); + let __a1 = { + let mut __v: MoveOnly = ::zero_init(); + MoveConstructibleUnsafe::move_constructor(&mut __v, { &mut f }); + __v + }; vec_.push(__a1) }; assert!(((vec_[(0_usize)].v) == (7)) && ((vec_[(1_usize)].v) == (8))); diff --git a/tests/unit/out/unsafe/pair.rs b/tests/unit/out/unsafe/pair.rs index 18b42dbdc1..bdb5aec7b5 100644 --- a/tests/unit/out/unsafe/pair.rs +++ b/tests/unit/out/unsafe/pair.rs @@ -65,10 +65,7 @@ unsafe fn main_0() -> i32 { let mut pd: *mut i32 = (&mut d.0 as *mut i32); let mut ps: *mut i32 = (&mut s.0 as *mut i32); { - d = ( - move_constructed_unsafe(&raw mut (s).0), - move_constructed_unsafe(&raw mut (s).1), - ); + d = std::mem::take(&mut s); }; assert!(((*pd) == (3))); (*ps) = 5; @@ -93,10 +90,7 @@ unsafe fn main_0() -> i32 { .1 = 7; assert!(((p.1) == (7)) && ((q.1) == (4))); (*{ - d = ( - move_constructed_unsafe(&raw mut (q).0), - move_constructed_unsafe(&raw mut (q).1), - ); + d = std::mem::take(&mut q); &mut d }) .0 = 8; diff --git a/tests/unit/out/unsafe/push_emplace_back.rs b/tests/unit/out/unsafe/push_emplace_back.rs index a93c036898..d387d5baad 100644 --- a/tests/unit/out/unsafe/push_emplace_back.rs +++ b/tests/unit/out/unsafe/push_emplace_back.rs @@ -62,7 +62,7 @@ impl DefaultConstructibleUnsafe for JPEGData { } pub unsafe fn push_param_0(mut dest: *mut Vec>) { { - let __a1 = move_constructed_unsafe(&raw mut Vec::new()); + let __a1 = Vec::new(); (*dest).push(__a1) }; } @@ -75,7 +75,7 @@ pub unsafe fn push_local_from_field_1(mut jpg: *mut JPEGData, mut cond: bool) { dest = (&mut (*jpg).app_data as *mut Vec>); } { - let __a1 = move_constructed_unsafe(&raw mut { + let __a1 = { let mut __tmp_0 = { head.as_mut_ptr().offset((3) as isize) }; let mut __v = Vec::new(); let mut __it = head.as_mut_ptr(); @@ -84,7 +84,7 @@ pub unsafe fn push_local_from_field_1(mut jpg: *mut JPEGData, mut cond: bool) { __it.iter_inc(); } __v - }); + }; (*dest).push(__a1) }; } @@ -93,7 +93,7 @@ pub unsafe fn shrink_through_ptr_2(mut comps: *mut Vec) { } pub unsafe fn nested_push_move_3(mut bw: *mut Writer) { { - let __a1 = move_constructed_unsafe(&raw mut (*bw).chunk); + let __a1 = (*bw).chunk; (*(*bw).output).push(__a1) }; } diff --git a/tests/unit/out/unsafe/reinterpret_cast_vec_write.rs b/tests/unit/out/unsafe/reinterpret_cast_vec_write.rs index 1fecfa5c8e..3bb370798c 100644 --- a/tests/unit/out/unsafe/reinterpret_cast_vec_write.rs +++ b/tests/unit/out/unsafe/reinterpret_cast_vec_write.rs @@ -15,11 +15,11 @@ pub fn main() { unsafe fn main_0() -> i32 { let mut vec_: Vec = Vec::new(); { - let __a1 = move_constructed_unsafe(&raw mut 67305985_u32); + let __a1 = 67305985_u32; vec_.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 134678021_u32); + let __a1 = 134678021_u32; vec_.push(__a1) }; let mut bytes: *mut u8 = ((vec_.as_mut_ptr()) as *mut u8); diff --git a/tests/unit/out/unsafe/return_move.rs b/tests/unit/out/unsafe/return_move.rs index d6bb50213f..d03cbdcf56 100644 --- a/tests/unit/out/unsafe/return_move.rs +++ b/tests/unit/out/unsafe/return_move.rs @@ -92,7 +92,7 @@ pub unsafe fn ret_vec_12(mut v: Vec) -> Vec { pub unsafe fn ret_vec_local_13() -> Vec { let mut v: Vec = Vec::new(); { - let __a1 = move_constructed_unsafe(&raw mut 1); + let __a1 = 1; v.push(__a1) }; return std::mem::take(&mut v); diff --git a/tests/unit/out/unsafe/sort.rs b/tests/unit/out/unsafe/sort.rs index 25125579e5..ad88a714c0 100644 --- a/tests/unit/out/unsafe/sort.rs +++ b/tests/unit/out/unsafe/sort.rs @@ -15,43 +15,43 @@ pub fn main() { unsafe fn main_0() -> i32 { let mut v: Vec = Vec::new(); { - let __a1 = move_constructed_unsafe(&raw mut 10); + let __a1 = 10; v.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 1); + let __a1 = 1; v.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 9); + let __a1 = 9; v.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 2); + let __a1 = 2; v.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 8); + let __a1 = 8; v.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 3); + let __a1 = 3; v.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 7); + let __a1 = 7; v.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 4); + let __a1 = 4; v.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 5); + let __a1 = 5; v.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 6); + let __a1 = 6; v.push(__a1) }; { diff --git a/tests/unit/out/unsafe/vector.rs b/tests/unit/out/unsafe/vector.rs index 6fe70ef6be..cb882dfe99 100644 --- a/tests/unit/out/unsafe/vector.rs +++ b/tests/unit/out/unsafe/vector.rs @@ -80,7 +80,7 @@ unsafe fn main_0() -> i32 { assert!(((v1.len()) == (0_usize))); assert!(v1.is_empty()); { - let __a1 = move_constructed_unsafe(&raw mut 1); + let __a1 = 1; v1.push(__a1) }; assert!(!(v1.is_empty())); @@ -97,15 +97,15 @@ unsafe fn main_0() -> i32 { let mut v2: Vec = Vec::new(); assert!(((v2.len()) == (0_usize))); { - let __a1 = move_constructed_unsafe(&raw mut 1); + let __a1 = 1; v2.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 2); + let __a1 = 2; v2.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 3); + let __a1 = 3; v2.push(__a1) }; assert!(((v2.len()) == (3_usize))); @@ -385,14 +385,14 @@ unsafe fn main_0() -> i32 { let mut pa: *mut S = (&mut a as *mut S); let mut v8: Vec<*const *mut S> = Vec::new(); { - let __a1 = move_constructed_unsafe(&raw mut (&mut pa as *mut *mut S).cast_const()); + let __a1 = (&mut pa as *mut *mut S).cast_const(); v8.push(__a1) }; assert!((((*(*v8[(0_usize)])).x) == (1))); let mut ppa: *mut *mut S = (&mut pa as *mut *mut S); let mut v9: Vec<*mut *mut *mut S> = Vec::new(); { - let __a1 = move_constructed_unsafe(&raw mut (&mut ppa as *mut *mut *mut S)); + let __a1 = (&mut ppa as *mut *mut *mut S); v9.push(__a1) }; (*(*(*v9[(0_usize)]))).x = 2; @@ -407,15 +407,15 @@ unsafe fn main_0() -> i32 { let mut foo: Foo = ::zero_init(); DefaultConstructibleUnsafe::default_constructor(&mut foo); { - let __a1 = move_constructed_unsafe(&raw mut 5); + let __a1 = 5; foo.a.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 6); + let __a1 = 6; foo.b.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 7); + let __a1 = 7; foo.b.push(__a1) }; std::mem::swap(&mut foo.a, &mut foo.b); @@ -430,14 +430,14 @@ unsafe fn main_0() -> i32 { let mut v12: Vec = Vec::new(); let mut moved: i32 = 5; { - let __a1 = move_constructed_unsafe(&raw mut moved); + let __a1 = moved; v12.push(__a1) }; assert!(((v12[(0_usize)]) == (5)) && ((moved) == (5))); let mut v13: Vec<*mut i32> = Vec::new(); let mut moved_ptr: *mut i32 = (&mut moved as *mut i32); { - let __a1 = move_constructed_unsafe(&raw mut moved_ptr); + let __a1 = moved_ptr; v13.push(__a1) }; assert!( diff --git a/tests/unit/out/unsafe/vector2.rs b/tests/unit/out/unsafe/vector2.rs index 7e0d682ba6..2d6bbb88a8 100644 --- a/tests/unit/out/unsafe/vector2.rs +++ b/tests/unit/out/unsafe/vector2.rs @@ -8,22 +8,22 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub unsafe fn fn_0(v: *mut Vec, mut v3: Vec) { { - let __a1 = move_constructed_unsafe(&raw mut 20); + let __a1 = 20; (*v).push(__a1) }; let mut x: i32 = 0_i32; let mut v2: Vec = Vec::new(); let mut v4: *mut Vec = (&mut v3 as *mut Vec); { - let __a1 = move_constructed_unsafe(&raw mut 0); + let __a1 = 0; v2.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 1); + let __a1 = 1; v2.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 3); + let __a1 = 3; v2.push(__a1) }; x = (&mut (*v))[(2_usize)]; @@ -53,7 +53,7 @@ pub unsafe fn fn_0(v: *mut Vec, mut v3: Vec) { assert!(((v3[(0_usize)]) == (7))); assert!(((v3[(1_usize)]) == (13))); { - let __a1 = move_constructed_unsafe(&raw mut 20); + let __a1 = 20; (*v).push(__a1) }; } @@ -67,23 +67,23 @@ unsafe fn main_0() -> i32 { let mut v: Vec = Vec::new(); let mut v2: Vec = Vec::new(); { - let __a1 = move_constructed_unsafe(&raw mut 4); + let __a1 = 4; v.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 5); + let __a1 = 5; v.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 6); + let __a1 = 6; v.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 8); + let __a1 = 8; v2.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 9); + let __a1 = 9; v2.push(__a1) }; (unsafe { fn_0(&mut v, v2.clone()) }); diff --git a/tests/unit/out/unsafe/vector_deque_vector_string.rs b/tests/unit/out/unsafe/vector_deque_vector_string.rs index 0ece051e47..fee5f4bd4e 100644 --- a/tests/unit/out/unsafe/vector_deque_vector_string.rs +++ b/tests/unit/out/unsafe/vector_deque_vector_string.rs @@ -18,34 +18,28 @@ unsafe fn main_0() -> i32 { v.push_mut(Vec::new()); let mut row: Vec> = Vec::new(); { - let __a1 = move_constructed_unsafe( - &raw mut std::slice::from_raw_parts( - c"a".as_ptr(), - (0..).take_while(|&i| *c"a".as_ptr().add(i) != 0).count() + 1, - ) - .to_vec(), - ); + let __a1 = std::slice::from_raw_parts( + c"a".as_ptr(), + (0..).take_while(|&i| *c"a".as_ptr().add(i) != 0).count() + 1, + ) + .to_vec(); row.push(__a1) }; { - let __a1 = move_constructed_unsafe( - &raw mut std::slice::from_raw_parts( - c"bc".as_ptr(), - (0..).take_while(|&i| *c"bc".as_ptr().add(i) != 0).count() + 1, - ) - .to_vec(), - ); + let __a1 = std::slice::from_raw_parts( + c"bc".as_ptr(), + (0..).take_while(|&i| *c"bc".as_ptr().add(i) != 0).count() + 1, + ) + .to_vec(); row.push(__a1) }; v[(0_usize)].push((row).clone()); { - let __a1 = move_constructed_unsafe( - &raw mut std::slice::from_raw_parts( - c"def".as_ptr(), - (0..).take_while(|&i| *c"def".as_ptr().add(i) != 0).count() + 1, - ) - .to_vec(), - ); + let __a1 = std::slice::from_raw_parts( + c"def".as_ptr(), + (0..).take_while(|&i| *c"def".as_ptr().add(i) != 0).count() + 1, + ) + .to_vec(); row.push(__a1) }; v[(1_usize)].push((row).clone()); @@ -59,7 +53,7 @@ unsafe fn main_0() -> i32 { } as *mut Vec>), ) { (__tmp_0,) => { - let __a1 = move_constructed_unsafe(&raw mut { + let __a1 = { let mut __tmp2 = v[(0_usize)][0][(1_usize)].clone(); __tmp2.pop(); __tmp2.extend_from_slice(::std::slice::from_raw_parts( @@ -68,7 +62,7 @@ unsafe fn main_0() -> i32 { )); __tmp2.push(0); __tmp2 - }); + }; (*__tmp_0).push(__a1) } }; diff --git a/tests/unit/out/unsafe/vector_subscript_direct.rs b/tests/unit/out/unsafe/vector_subscript_direct.rs index 1c56935f45..c4f1c6b32e 100644 --- a/tests/unit/out/unsafe/vector_subscript_direct.rs +++ b/tests/unit/out/unsafe/vector_subscript_direct.rs @@ -52,7 +52,7 @@ impl DefaultConstructibleUnsafe for Holder { } pub unsafe fn push_and_index_0(v: *mut Vec) -> i32 { { - let __a1 = move_constructed_unsafe(&raw mut 42); + let __a1 = 42; (*v).push(__a1) }; return ((((*v).len()) as i32) - (1)); @@ -115,7 +115,7 @@ unsafe fn main_0() -> i32 { h.values.resize_with(2_usize, || 0_i32); h.values[(1_usize)] = 6; { - let __a1 = move_constructed_unsafe(&raw mut (Point { x: 1, y: 2 })); + let __a1 = (Point { x: 1, y: 2 }); h.points.push(__a1) }; h.points[(0_usize)].y = 5; @@ -130,11 +130,11 @@ unsafe fn main_0() -> i32 { assert!(((h.points[(0_usize)].x) == (7))); let mut grid: Vec> = Vec::new(); { - let __a1 = move_constructed_unsafe(&raw mut vec![0; 3_usize]); + let __a1 = vec![0; 3_usize]; grid.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut vec![0; 3_usize]); + let __a1 = vec![0; 3_usize]; grid.push(__a1) }; grid[(1_usize)][(2_usize)] = 8; diff --git a/tests/unit/out/unsafe/vector_with_allocator.rs b/tests/unit/out/unsafe/vector_with_allocator.rs index 498085bee2..a2bace4ed1 100644 --- a/tests/unit/out/unsafe/vector_with_allocator.rs +++ b/tests/unit/out/unsafe/vector_with_allocator.rs @@ -69,22 +69,22 @@ impl TestAllocator_double_ { pub unsafe fn copy_0(mut copy_vector: Vec) {} pub unsafe fn fn_1(v: *mut Vec, mut v3: Vec) { { - let __a1 = move_constructed_unsafe(&raw mut 20); + let __a1 = 20; (*v).push(__a1) }; let mut x: i32 = 0_i32; let mut v4: *mut Vec = (&mut v3 as *mut Vec); let mut v2: Vec = Vec::new(); { - let __a1 = move_constructed_unsafe(&raw mut 0); + let __a1 = 0; v2.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 1); + let __a1 = 1; v2.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 3); + let __a1 = 3; v2.push(__a1) }; x = (&mut (*v))[(2_usize)]; @@ -108,7 +108,7 @@ pub unsafe fn fn_1(v: *mut Vec, mut v3: Vec) { assert!(((v3[(0_usize)]) == (7))); assert!(((v3[(1_usize)]) == (13))); { - let __a1 = move_constructed_unsafe(&raw mut 20); + let __a1 = 20; (*v).push(__a1) }; } @@ -123,7 +123,7 @@ unsafe fn main_0() -> i32 { assert!(((v1.len()) == (0_usize))); assert!(v1.is_empty()); { - let __a1 = move_constructed_unsafe(&raw mut 1); + let __a1 = 1; v1.push(__a1) }; assert!(!(v1.is_empty())); @@ -140,15 +140,15 @@ unsafe fn main_0() -> i32 { let mut v2: Vec = Vec::new(); assert!(((v2.len()) == (0_usize))); { - let __a1 = move_constructed_unsafe(&raw mut 1); + let __a1 = 1; v2.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 2); + let __a1 = 2; v2.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 3); + let __a1 = 3; v2.push(__a1) }; assert!(((v2.len()) == (3_usize))); @@ -289,23 +289,23 @@ unsafe fn main_0() -> i32 { let mut v7: Vec = Vec::new(); let mut v8: Vec = Vec::new(); { - let __a1 = move_constructed_unsafe(&raw mut 4); + let __a1 = 4; v7.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 5); + let __a1 = 5; v7.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 6); + let __a1 = 6; v7.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 8); + let __a1 = 8; v8.push(__a1) }; { - let __a1 = move_constructed_unsafe(&raw mut 9); + let __a1 = 9; v8.push(__a1) }; (unsafe { fn_1(&mut v7, v8.clone()) }); From 7daeaa89f69ce460290e8085271eb618598a2b1e Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Wed, 2 Dec 2026 13:47:20 +0000 Subject: [PATCH 10/13] Fix move construction with deafault --- rule-preprocessor/src/semantic.rs | 24 ++- rule-preprocessor/src/syntactic.rs | 11 +- rules/deque/tgt_refcount.rs | 14 +- rules/deque/tgt_unsafe.rs | 10 +- rules/map/tgt_refcount.rs | 7 +- rules/map/tgt_unsafe.rs | 8 +- rules/pair/tgt_unsafe.rs | 10 +- rules/string/tgt_refcount.rs | 8 +- rules/string/tgt_unsafe.rs | 8 +- rules/vector/tgt_refcount.rs | 14 +- rules/vector/tgt_unsafe.rs | 10 +- .../utility/out/refcount/forward-helpers.rs | 6 +- .../utilities/utility/out/refcount/forward.rs | 11 +- tests/unit/out/refcount/12_test.rs | 8 +- tests/unit/out/refcount/clone_vs_move.rs | 8 +- .../unit/out/refcount/container_field_addr.rs | 8 +- .../unit/out/refcount/copy_move_defaulted.rs | 20 +- .../out/refcount/field_method_receiver.rs | 8 +- tests/unit/out/refcount/foreach_double.rs | 12 +- tests/unit/out/refcount/foreach_mut.rs | 24 +-- .../out/refcount/inline_container_fields.rs | 8 +- tests/unit/out/refcount/iterators.rs | 16 +- tests/unit/out/refcount/move_assign.rs | 21 +- tests/unit/out/refcount/move_ctor.rs | 21 +- tests/unit/out/refcount/push_emplace_back.rs | 104 +++++----- tests/unit/out/refcount/return_move.rs | 11 +- tests/unit/out/refcount/string.rs | 126 ++++++------ tests/unit/out/refcount/string_moved_from.rs | 11 +- tests/unit/out/refcount/string_substr.rs | 168 ++++++---------- tests/unit/out/refcount/vector.rs | 10 +- .../refcount/vector_deque_vector_string.rs | 185 ++++++++---------- .../out/refcount/vector_subscript_direct.rs | 16 +- 32 files changed, 423 insertions(+), 503 deletions(-) diff --git a/rule-preprocessor/src/semantic.rs b/rule-preprocessor/src/semantic.rs index b704e0969c..6ed6611a00 100644 --- a/rule-preprocessor/src/semantic.rs +++ b/rule-preprocessor/src/semantic.rs @@ -523,7 +523,7 @@ impl<'a, 'tcx> AstVisitor<'a, 'tcx> { } } rustc_hir::ExprKind::Call(callee, args) => { - if self.is_std_mem_take(expr) && args.len() == 1 { + if self.is_take(expr) && args.len() == 1 { self.visit_expr(&args[0], Access::Take); } else { self.visit_expr(callee, context); @@ -556,9 +556,23 @@ impl<'a, 'tcx> AstVisitor<'a, 'tcx> { self.fn_ir .resolve_next_param(¶m, &mut self.visited, |p| { if p.access == Access::Unknown { - p.access = Access::Borrow; + p.access = if context == Access::Take { + Access::Take + } else { + Access::Borrow + }; } }); + if context == Access::Take + && let Some(info) = self + .fn_ir + .params + .as_mut() + .and_then(|params| params.get_mut(¶m)) + { + info.is_refcount_pointer = false; + info.is_reference = true; + } return; } self.visit_expr(inner, Access::Borrow); @@ -717,12 +731,14 @@ impl<'a, 'tcx> AstVisitor<'a, 'tcx> { } } - fn is_std_mem_take(&self, expr: &rustc_hir::Expr<'tcx>) -> bool { + fn is_take(&self, expr: &rustc_hir::Expr<'tcx>) -> bool { if let rustc_hir::ExprKind::Call(callee, _) = &expr.kind && let rustc_middle::ty::TyKind::FnDef(def_id, _) = self.tcx.typeck(expr.hir_id.owner).expr_ty(callee).kind() { - return self.tcx.def_path_str(*def_id) == "std::mem::take"; + let name = self.tcx.item_name(*def_id); + return ["move_constructed", "move_constructed_unsafe"].contains(&name.as_str()) + && self.tcx.crate_name(def_id.krate).as_str() == "libcc2rs"; } false } diff --git a/rule-preprocessor/src/syntactic.rs b/rule-preprocessor/src/syntactic.rs index 36570d2c9c..6eab5b34a9 100644 --- a/rule-preprocessor/src/syntactic.rs +++ b/rule-preprocessor/src/syntactic.rs @@ -309,9 +309,14 @@ impl<'a> FragmentCtx<'a> { if param.is_mut_ref && self.text_buf.ends_with('*') { self.text_buf.pop(); } - if param.is_mut_ref && self.text_buf.ends_with("std::mem::take(&mut ") { - self.text_buf - .truncate(self.text_buf.len() - "std::mem::take(&mut ".len()); + let take = if param.is_refcount_pointer { + "move_constructed(&" + } else { + "move_constructed_unsafe(&mut " + }; + if (param.is_refcount_pointer || param.is_mut_ref) && self.text_buf.ends_with(take) + { + self.text_buf.truncate(self.text_buf.len() - take.len()); self.pending_close_parens += 1; access = Access::Unknown; } diff --git a/rules/deque/tgt_refcount.rs b/rules/deque/tgt_refcount.rs index 23fc809e91..63f4bfb2ca 100644 --- a/rules/deque/tgt_refcount.rs +++ b/rules/deque/tgt_refcount.rs @@ -27,8 +27,11 @@ fn f10(a0: &mut Vec, a1: Vec) -> &mut Vec { a0 } -fn f11<'a, T1>(a0: &'a mut Vec, a1: &mut Vec) -> &'a mut Vec { - *a0 = std::mem::take(&mut *a1); +fn f11<'a, T1>(a0: &'a mut Vec, a1: Ptr>) -> &'a mut Vec +where + Vec: MoveConstructible + ZeroInitialization, +{ + *a0 = move_constructed(&a1); a0 } @@ -41,3 +44,10 @@ fn f12(a0: &mut Vec, init: T1) -> &mut T1 { fn f4(a0: &mut Vec, a1: Ptr) { a0.push(move_constructed(&a1)) } + +fn f9(a0: Ptr>) -> Vec +where + Vec: MoveConstructible + ZeroInitialization, +{ + move_constructed(&a0) +} diff --git a/rules/deque/tgt_unsafe.rs b/rules/deque/tgt_unsafe.rs index b0ce5b3302..985cc9de7f 100644 --- a/rules/deque/tgt_unsafe.rs +++ b/rules/deque/tgt_unsafe.rs @@ -39,7 +39,7 @@ fn f3(a0: Vec) -> bool { } unsafe fn f4(a0: &mut Vec, a1: &mut T1) { - a0.push(move_constructed_unsafe(&raw mut *a1)) + a0.push(move_constructed_unsafe(&mut *a1)) } fn f5(a0: &mut Vec) -> T1 { @@ -54,8 +54,8 @@ fn f8(a0: Vec) -> Vec { a0.clone() } -fn f9(a0: &mut Vec) -> Vec { - std::mem::take(&mut *a0) +unsafe fn f9(a0: &mut Vec) -> Vec { + move_constructed_unsafe(&mut *a0) } fn f10(a0: &mut Vec, a1: Vec) -> &mut Vec { @@ -63,8 +63,8 @@ fn f10(a0: &mut Vec, a1: Vec) -> &mut Vec { a0 } -fn f11<'a, T1>(a0: &'a mut Vec, a1: &mut Vec) -> &'a mut Vec { - *a0 = std::mem::take(&mut *a1); +unsafe fn f11<'a, T1>(a0: &'a mut Vec, a1: &mut Vec) -> &'a mut Vec { + *a0 = move_constructed_unsafe(&mut *a1); a0 } diff --git a/rules/map/tgt_refcount.rs b/rules/map/tgt_refcount.rs index a836c66ceb..8369c3d9b6 100644 --- a/rules/map/tgt_refcount.rs +++ b/rules/map/tgt_refcount.rs @@ -74,8 +74,11 @@ fn f24(a0: Ptr, Value)>>) -> Ma a0.with_mut(|__m: &mut Map, Value)>| std::mem::take(__m)) } -fn f25<'a, T1: 'static, T2: 'static>(a0: &'a mut Map, Value)>, a1: &mut Map, Value)>) -> &'a mut Map, Value)> { - *a0 = std::mem::take(&mut *a1); +fn f25<'a, T1: 'static, T2: 'static>(a0: &'a mut Map, Value)>, a1: Ptr, Value)>>) -> &'a mut Map, Value)> +where + Map, Value)>: MoveConstructible + ZeroInitialization, +{ + *a0 = move_constructed(&a1); a0 } diff --git a/rules/map/tgt_unsafe.rs b/rules/map/tgt_unsafe.rs index cf2541b8ed..831307bddc 100644 --- a/rules/map/tgt_unsafe.rs +++ b/rules/map/tgt_unsafe.rs @@ -71,12 +71,12 @@ fn f17(a0: UnsafeMap, a1: T1) -> UnsafeBidirectionalI a0.find(&a1) } -fn f24(a0: &mut UnsafeMap) -> UnsafeMap { - std::mem::take(&mut *a0) +unsafe fn f24(a0: &mut UnsafeMap) -> UnsafeMap { + move_constructed_unsafe(&mut *a0) } -fn f25<'a, T1, T2>(a0: &'a mut UnsafeMap, a1: &mut UnsafeMap) -> &'a mut UnsafeMap { - *a0 = std::mem::take(&mut *a1); +unsafe fn f25<'a, T1, T2>(a0: &'a mut UnsafeMap, a1: &mut UnsafeMap) -> &'a mut UnsafeMap { + *a0 = move_constructed_unsafe(&mut *a1); a0 } diff --git a/rules/pair/tgt_unsafe.rs b/rules/pair/tgt_unsafe.rs index 7901311266..1714c8379f 100644 --- a/rules/pair/tgt_unsafe.rs +++ b/rules/pair/tgt_unsafe.rs @@ -37,11 +37,11 @@ fn f13(a0: &mut (T1, T2), a1: (T1, T2)) -> &mut (T1, T2) { a0 } -unsafe fn f14<'a, T1: MoveConstructibleUnsafe, T2: MoveConstructibleUnsafe>(a0: &'a mut (T1, T2), a1: &mut (T1, T2)) -> &'a mut (T1, T2) { - *a0 = ( - move_constructed_unsafe(&raw mut (*a1).0), - move_constructed_unsafe(&raw mut (*a1).1), - ); +unsafe fn f14<'a, T1, T2>(a0: &'a mut (T1, T2), a1: &mut (T1, T2)) -> &'a mut (T1, T2) +where + (T1, T2): MoveConstructibleUnsafe, +{ + *a0 = move_constructed_unsafe(&mut *a1); a0 } diff --git a/rules/string/tgt_refcount.rs b/rules/string/tgt_refcount.rs index 783649934b..84cb208d85 100644 --- a/rules/string/tgt_refcount.rs +++ b/rules/string/tgt_refcount.rs @@ -178,8 +178,8 @@ fn f27(a0: Vec) -> Vec { a0 } -fn f28(a0: &mut Vec) -> Vec { - std::mem::take(&mut *a0) +fn f28(a0: Ptr>) -> Vec { + move_constructed(&a0) } fn f29(a0: &mut Vec, a1: Vec) -> &mut Vec { @@ -187,8 +187,8 @@ fn f29(a0: &mut Vec, a1: Vec) -> &mut Vec { a0 } -fn f30<'a>(a0: &'a mut Vec, a1: &mut Vec) -> &'a mut Vec { - *a0 = std::mem::take(&mut *a1); +fn f30<'a>(a0: &'a mut Vec, a1: Ptr>) -> &'a mut Vec { + *a0 = move_constructed(&a1); a0 } diff --git a/rules/string/tgt_unsafe.rs b/rules/string/tgt_unsafe.rs index 18a3c1cb65..14e5fded85 100644 --- a/rules/string/tgt_unsafe.rs +++ b/rules/string/tgt_unsafe.rs @@ -182,8 +182,8 @@ fn f27(a0: Vec) -> Vec { a0.clone() } -fn f28(a0: &mut Vec) -> Vec { - std::mem::take(&mut *a0) +unsafe fn f28(a0: &mut Vec) -> Vec { + move_constructed_unsafe(&mut *a0) } fn f29(a0: &mut Vec, a1: Vec) -> &mut Vec { @@ -191,8 +191,8 @@ fn f29(a0: &mut Vec, a1: Vec) -> &mut Vec(a0: &'a mut Vec, a1: &mut Vec) -> &'a mut Vec { - *a0 = std::mem::take(&mut *a1); +unsafe fn f30<'a>(a0: &'a mut Vec, a1: &mut Vec) -> &'a mut Vec { + *a0 = move_constructed_unsafe(&mut *a1); a0 } diff --git a/rules/vector/tgt_refcount.rs b/rules/vector/tgt_refcount.rs index 3adbc7c213..fe73c784f7 100644 --- a/rules/vector/tgt_refcount.rs +++ b/rules/vector/tgt_refcount.rs @@ -135,8 +135,11 @@ fn f101 + ByteRepr, T2, T3: CppInputIterator, T4: ByteRepr>( a1 } -fn f103<'a, T1>(a0: &'a mut Vec, a1: &mut Vec) -> &'a mut Vec { - *a0 = std::mem::take(&mut *a1); +fn f103<'a, T1>(a0: &'a mut Vec, a1: Ptr>) -> &'a mut Vec +where + Vec: MoveConstructible + ZeroInitialization, +{ + *a0 = move_constructed(&a1); a0 } @@ -185,3 +188,10 @@ fn f114(a0: &mut Vec, init: T1) -> &mut T1 { let __n = a0.len() - 1; &mut a0[__n] } + +fn f108(a0: Ptr>) -> Vec +where + Vec: MoveConstructible + ZeroInitialization, +{ + move_constructed(&a0) +} diff --git a/rules/vector/tgt_unsafe.rs b/rules/vector/tgt_unsafe.rs index 8c6b2bbedc..4a637944e8 100644 --- a/rules/vector/tgt_unsafe.rs +++ b/rules/vector/tgt_unsafe.rs @@ -110,7 +110,7 @@ fn f72(a0: &mut Vec) -> UnsafeRandomAccessIterator { } unsafe fn f73(a0: &mut Vec, a1: &mut T1) { - let __a1 = move_constructed_unsafe(&raw mut *a1); + let __a1 = move_constructed_unsafe(&mut *a1); a0.push(__a1) } @@ -207,8 +207,8 @@ fn f102(a0: &mut Vec, a1: usize, a2: T1) { a0.resize(a1, a2) } -fn f103<'a, T1: Clone>(a0: &'a mut Vec, a1: &mut Vec) -> &'a mut Vec { - *a0 = std::mem::take(&mut *a1); +unsafe fn f103<'a, T1: Clone>(a0: &'a mut Vec, a1: &mut Vec) -> &'a mut Vec { + *a0 = move_constructed_unsafe(&mut *a1); a0 } @@ -225,8 +225,8 @@ fn f106(a0: &mut Vec) { a0.shrink_to_fit() } -fn f108(a0: &mut Vec) -> Vec { - std::mem::take(&mut *a0) +unsafe fn f108(a0: &mut Vec) -> Vec { + move_constructed_unsafe(&mut *a0) } fn f110(a0: Vec) -> Vec { diff --git a/tests/std/utilities/utility/out/refcount/forward-helpers.rs b/tests/std/utilities/utility/out/refcount/forward-helpers.rs index 49fd26de92..5a708cc6e5 100644 --- a/tests/std/utilities/utility/out/refcount/forward-helpers.rs +++ b/tests/std/utilities/utility/out/refcount/forward-helpers.rs @@ -156,13 +156,13 @@ pub fn test_4() { MoveConstructible::move_constructor(&destination.as_pointer(), { source.as_pointer() }); assert!(({ (*destination.borrow()).value } == 3) && ({ (*source.borrow()).value } == 0)); let strings: Value>> = Rc::new(RefCell::new(Vec::new())); - let text: Value> = Rc::new(RefCell::new({ + let mut text: Vec = { let mut __bytes = Ptr::::from_string_literal(b"text").to_c_bytes(); __bytes.push(0); __bytes - })); + }; { - let __a1 = ({ std::mem::replace(&mut (*text.borrow_mut()), vec![0]) }); + let __a1 = std::mem::replace(&mut text, vec![0]); (*strings.borrow_mut()).push(__a1) }; assert!( diff --git a/tests/std/utilities/utility/out/refcount/forward.rs b/tests/std/utilities/utility/out/refcount/forward.rs index 04f175ced7..3f331f64c6 100644 --- a/tests/std/utilities/utility/out/refcount/forward.rs +++ b/tests/std/utilities/utility/out/refcount/forward.rs @@ -46,17 +46,14 @@ pub fn test_1() { assert!((assigned.x == 3) && (assigned.y == 4)); assert!((other.x == 3) && (other.y == 4)); let mut points: Vec = Vec::new(); - let element: Value = - Rc::new(RefCell::new(p9_move_trivially_copyable_Point { - x: 5, - y: 6, - })); + let mut element: p9_move_trivially_copyable_Point = + p9_move_trivially_copyable_Point { x: 5, y: 6 }; { - let __a1 = ({ (*element.borrow()) }); + let __a1 = element; points.push(__a1) }; assert!((points[0_usize].x == 5) && (points[0_usize].y == 6)); - assert!(({ (*element.borrow()).x } == 5) && ({ (*element.borrow()).y } == 6)); + assert!((element.x == 5) && (element.y == 6)); } #[derive( Record, diff --git a/tests/unit/out/refcount/12_test.rs b/tests/unit/out/refcount/12_test.rs index 9d34100e87..eb8d610955 100644 --- a/tests/unit/out/refcount/12_test.rs +++ b/tests/unit/out/refcount/12_test.rs @@ -12,11 +12,9 @@ pub fn main() { } fn main_0() -> i32 { let v: Value>> = Rc::new(RefCell::new(Vec::new())); - match (Rc::new(RefCell::new(Vec::from_fn(10_usize, |_| 0_i32))).as_pointer(),) { - (__tmp_0,) => { - let __a1 = __tmp_0.with_mut(std::mem::take); - (*v.borrow_mut()).push(__a1) - } + { + let __a1 = Vec::from_fn(10_usize, |_| 0_i32); + (*v.borrow_mut()).push(__a1) }; return 0; } diff --git a/tests/unit/out/refcount/clone_vs_move.rs b/tests/unit/out/refcount/clone_vs_move.rs index 06587c7a98..68fa6756a5 100644 --- a/tests/unit/out/refcount/clone_vs_move.rs +++ b/tests/unit/out/refcount/clone_vs_move.rs @@ -205,11 +205,9 @@ fn main_0() -> i32 { let mut i: i32 = 0; 'loop_: while (i < N) { 'for_body: { - match (Rc::new(RefCell::new(Vec::from_fn(10_usize, |_| 0_i32))).as_pointer(),) { - (__tmp_0,) => { - let __a1 = __tmp_0.with_mut(std::mem::take); - (*m1.borrow_mut()).push(__a1) - } + { + let __a1 = Vec::from_fn(10_usize, |_| 0_i32); + (*m1.borrow_mut()).push(__a1) }; } i.prefix_inc(); diff --git a/tests/unit/out/refcount/container_field_addr.rs b/tests/unit/out/refcount/container_field_addr.rs index 7a1352fc2a..931646d616 100644 --- a/tests/unit/out/refcount/container_field_addr.rs +++ b/tests/unit/out/refcount/container_field_addr.rs @@ -43,11 +43,9 @@ pub fn add_0(mut v: Ptr>, mut k: i32) { pub fn run_1(mut h: Ptr) { ({ add_0((field_ref!(h, v).as_pointer()), h.with(|__s| __s.tag)) }); let mut pv: Ptr> = (field_ref!(h, v).as_pointer()); - match (Rc::new(RefCell::new((((*pv.upgrade().deref()).len()) as i32))).as_pointer(),) { - (__tmp_0,) => { - let __a1 = (__tmp_0.read()); - pv.with_mut(|__v: &mut Vec| __v.push(__a1)) - } + { + let __a1 = (((*pv.upgrade().deref()).len()) as i32); + pv.with_mut(|__v: &mut Vec| __v.push(__a1)) }; assert!( ({ diff --git a/tests/unit/out/refcount/copy_move_defaulted.rs b/tests/unit/out/refcount/copy_move_defaulted.rs index e935229fc9..4073b9a5af 100644 --- a/tests/unit/out/refcount/copy_move_defaulted.rs +++ b/tests/unit/out/refcount/copy_move_defaulted.rs @@ -700,17 +700,13 @@ fn main_0() -> i32 { let a0_clone = (*b.borrow()).clone(); vec_.push(a0_clone) }; - match (Rc::new(RefCell::new({ - let __v: Value = Rc::new(RefCell::new(::zero_init())); - ExplicitImpl::construct(&__v.as_pointer(), { 9 }); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - })) - .as_pointer(),) { - (__tmp_1,) => { - let __a1 = ({ (*__tmp_1.upgrade().deref()).clone() }); - vec_.push(__a1) - } + let __a1 = { + let __v: Value = Rc::new(RefCell::new(::zero_init())); + ExplicitImpl::construct(&__v.as_pointer(), { 9 }); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }; + vec_.push(__a1) }; assert!((vec_[0_usize].v == 1) && (vec_[1_usize].v == 9)); let m: Value = Rc::new(RefCell::new(::zero_init())); @@ -791,7 +787,7 @@ fn main_0() -> i32 { (*bufs.borrow_mut()).push(__a1) }; { - let mut __tmp_2 = { + let mut __tmp_1 = { { let __v: Value = Rc::new(RefCell::new(::zero_init())); MoveConstructible::move_constructor(&__v.as_pointer(), { @@ -800,7 +796,7 @@ fn main_0() -> i32 { Rc::try_unwrap(__v).ok().unwrap().into_inner() } }; - (*bufs.borrow_mut()).push(__tmp_2); + (*bufs.borrow_mut()).push(__tmp_1); }; assert!( ({ diff --git a/tests/unit/out/refcount/field_method_receiver.rs b/tests/unit/out/refcount/field_method_receiver.rs index 984da547de..32d8c6a0b2 100644 --- a/tests/unit/out/refcount/field_method_receiver.rs +++ b/tests/unit/out/refcount/field_method_receiver.rs @@ -100,11 +100,9 @@ pub fn run_0(mut o: Ptr) { assert!((({ CounterImpl::get(&field_ptr!(o, c),) }) == 0)); ({ SImpl::bump(&o) }); assert!((({ CounterImpl::get(&field_ptr!(o, c),) }) == 1)); - match (Rc::new(RefCell::new(({ CounterImpl::get(&field_ptr!(o, c)) }))).as_pointer(),) { - (__tmp_0,) => { - let __a1 = (__tmp_0.read()); - field!(o, v).with_mut(|__v: &mut Vec| __v.push(__a1)) - } + { + let __a1 = ({ CounterImpl::get(&field_ptr!(o, c)) }); + field!(o, v).with_mut(|__v: &mut Vec| __v.push(__a1)) }; assert!( ({ diff --git a/tests/unit/out/refcount/foreach_double.rs b/tests/unit/out/refcount/foreach_double.rs index bfd0c3bc29..f4fba80a0f 100644 --- a/tests/unit/out/refcount/foreach_double.rs +++ b/tests/unit/out/refcount/foreach_double.rs @@ -54,19 +54,19 @@ fn main_0() -> i32 { } } let m: Value>> = Rc::new(RefCell::new(Vec::new())); - let v1: Value> = Rc::new(RefCell::new(Vec::new())); + let mut v1: Vec = Vec::new(); { - let __a1 = ({ std::mem::take(&mut (*v1.borrow_mut())) }); + let __a1 = std::mem::take(&mut v1); (*m.borrow_mut()).push(__a1) }; - let v2: Value> = Rc::new(RefCell::new(Vec::new())); + let mut v2: Vec = Vec::new(); { - let __a1 = ({ std::mem::take(&mut (*v2.borrow_mut())) }); + let __a1 = std::mem::take(&mut v2); (*m.borrow_mut()).push(__a1) }; - let v3: Value> = Rc::new(RefCell::new(Vec::new())); + let mut v3: Vec = Vec::new(); { - let __a1 = ({ std::mem::take(&mut (*v3.borrow_mut())) }); + let __a1 = std::mem::take(&mut v3); (*m.borrow_mut()).push(__a1) }; 'loop_: for row in IterRange::new(m.decay().begin(), m.decay().end()) { diff --git a/tests/unit/out/refcount/foreach_mut.rs b/tests/unit/out/refcount/foreach_mut.rs index f1ab6bcae9..efd8652ead 100644 --- a/tests/unit/out/refcount/foreach_mut.rs +++ b/tests/unit/out/refcount/foreach_mut.rs @@ -44,23 +44,17 @@ fn main_0() -> i32 { sum += (x.read()); } let v2: Value>> = Rc::new(RefCell::new(Vec::new())); - match (Rc::new(RefCell::new((v1.decay().offset(0_usize)))).as_pointer(),) { - (__tmp_0,) => { - let __a1 = (__tmp_0.read()); - (*v2.borrow_mut()).push(__a1) - } + { + let __a1 = (v1.decay().offset(0_usize)); + (*v2.borrow_mut()).push(__a1) }; - match (Rc::new(RefCell::new((v1.decay().offset(1_usize)))).as_pointer(),) { - (__tmp_1,) => { - let __a1 = (__tmp_1.read()); - (*v2.borrow_mut()).push(__a1) - } + { + let __a1 = (v1.decay().offset(1_usize)); + (*v2.borrow_mut()).push(__a1) }; - match (Rc::new(RefCell::new((v1.decay().offset(2_usize)))).as_pointer(),) { - (__tmp_2,) => { - let __a1 = (__tmp_2.read()); - (*v2.borrow_mut()).push(__a1) - } + { + let __a1 = (v1.decay().offset(2_usize)); + (*v2.borrow_mut()).push(__a1) }; 'loop_: for p in IterRange::new(v2.decay().begin(), v2.decay().end()) { let mut p: Ptr = (p.iter_deref().read()); diff --git a/tests/unit/out/refcount/inline_container_fields.rs b/tests/unit/out/refcount/inline_container_fields.rs index 73a7ee6fb0..9e363fbfcf 100644 --- a/tests/unit/out/refcount/inline_container_fields.rs +++ b/tests/unit/out/refcount/inline_container_fields.rs @@ -156,11 +156,9 @@ pub fn fill_1(mut s: Ptr) { i.prefix_inc(); } } - match (Rc::new(RefCell::new(Vec::from([1, 2, 3]))).as_pointer(),) { - (__tmp_0,) => { - let __a1 = __tmp_0.with_mut(std::mem::take); - field!(s, rows).with_mut(|__v: &mut Vec>| __v.push(__a1)) - } + { + let __a1 = Vec::from([1, 2, 3]); + field!(s, rows).with_mut(|__v: &mut Vec>| __v.push(__a1)) }; } thread_local!( diff --git a/tests/unit/out/refcount/iterators.rs b/tests/unit/out/refcount/iterators.rs index 07a999ca3f..9ac5d8faac 100644 --- a/tests/unit/out/refcount/iterators.rs +++ b/tests/unit/out/refcount/iterators.rs @@ -40,17 +40,13 @@ fn main_0() -> i32 { printf!(b"%c\n", (c as i32)); } let v: Value>> = Rc::new(RefCell::new(Vec::new())); - match (Rc::new(RefCell::new(Ptr::alloc(2))).as_pointer(),) { - (__tmp_0,) => { - let __a1 = (__tmp_0.read()); - (*v.borrow_mut()).push(__a1) - } + { + let __a1 = Ptr::alloc(2); + (*v.borrow_mut()).push(__a1) }; - match (Rc::new(RefCell::new(Ptr::alloc(3))).as_pointer(),) { - (__tmp_1,) => { - let __a1 = (__tmp_1.read()); - (*v.borrow_mut()).push(__a1) - } + { + let __a1 = Ptr::alloc(3); + (*v.borrow_mut()).push(__a1) }; 'loop_: for p in IterRange::new(v.decay().begin(), v.decay().end()) { let mut p: Ptr = (p.iter_deref().read()); diff --git a/tests/unit/out/refcount/move_assign.rs b/tests/unit/out/refcount/move_assign.rs index 45c5b94afa..dd2eb41520 100644 --- a/tests/unit/out/refcount/move_assign.rs +++ b/tests/unit/out/refcount/move_assign.rs @@ -112,21 +112,12 @@ fn main_0() -> i32 { assert!(({ (*a.borrow()).v } == 6)); let vec_: Value> = Rc::new(RefCell::new(Vec::new())); { - let __tmp_1: Value = Rc::new(RefCell::new(::zero_init())); - match ({ - MoveOnlyImpl::construct(&__tmp_1.as_pointer(), { 7 }); - __tmp_1.as_pointer() - },) - { - (__tmp_0,) => { - let __a1 = { - let __v: Value = Rc::new(RefCell::new(::zero_init())); - MoveConstructible::move_constructor(&__v.as_pointer(), { (__tmp_0).clone() }); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }; - (*vec_.borrow_mut()).push(__a1) - } - } + let __a1 = { + let __v: Value = Rc::new(RefCell::new(::zero_init())); + MoveOnlyImpl::construct(&__v.as_pointer(), { 7 }); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }; + (*vec_.borrow_mut()).push(__a1) }; let d: Value = Rc::new(RefCell::new(::zero_init())); MoveOnlyImpl::construct(&d.as_pointer(), { 8 }); diff --git a/tests/unit/out/refcount/move_ctor.rs b/tests/unit/out/refcount/move_ctor.rs index 77a7be3614..c0c4196664 100644 --- a/tests/unit/out/refcount/move_ctor.rs +++ b/tests/unit/out/refcount/move_ctor.rs @@ -204,21 +204,12 @@ fn main_0() -> i32 { assert!(({ (*e.borrow()).v } == 0)); let mut vec_: Vec = Vec::new(); { - let __tmp_1: Value = Rc::new(RefCell::new(::zero_init())); - match ({ - MoveOnlyImpl::construct(&__tmp_1.as_pointer(), { 7 }); - __tmp_1.as_pointer() - },) - { - (__tmp_0,) => { - let __a1 = { - let __v: Value = Rc::new(RefCell::new(::zero_init())); - MoveConstructible::move_constructor(&__v.as_pointer(), { (__tmp_0).clone() }); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }; - vec_.push(__a1) - } - } + let __a1 = { + let __v: Value = Rc::new(RefCell::new(::zero_init())); + MoveOnlyImpl::construct(&__v.as_pointer(), { 7 }); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }; + vec_.push(__a1) }; let f: Value = Rc::new(RefCell::new(::zero_init())); MoveOnlyImpl::construct(&f.as_pointer(), { 8 }); diff --git a/tests/unit/out/refcount/push_emplace_back.rs b/tests/unit/out/refcount/push_emplace_back.rs index 9cc934a524..71fe867b7b 100644 --- a/tests/unit/out/refcount/push_emplace_back.rs +++ b/tests/unit/out/refcount/push_emplace_back.rs @@ -75,11 +75,9 @@ impl DefaultConstructible for JPEGData { } } pub fn push_param_0(mut dest: Ptr>>) { - match (Rc::new(RefCell::new(Vec::new())).as_pointer(),) { - (__tmp_0,) => { - let __a1 = __tmp_0.with_mut(std::mem::take); - dest.with_mut(|__v: &mut Vec>| __v.push(__a1)) - } + { + let __a1 = Vec::new(); + dest.with_mut(|__v: &mut Vec>| __v.push(__a1)) }; } pub fn push_local_from_field_1(mut jpg: Ptr, mut cond: bool) { @@ -90,22 +88,18 @@ pub fn push_local_from_field_1(mut jpg: Ptr, mut cond: bool) { } else { dest = (field_ref!(jpg, app_data).as_pointer()); } - match (Rc::new(RefCell::new({ - let mut __tmp_2 = { head.decay().offset((3) as isize) }; - let mut __v = Vec::new(); - let mut __it = head.decay(); - while __it != __tmp_2 { - __v.push((__it.iter_deref().read())); - __it.iter_inc(); - } - __v - })) - .as_pointer(),) { - (__tmp_1,) => { - let __a1 = __tmp_1.with_mut(std::mem::take); - dest.with_mut(|__v: &mut Vec>| __v.push(__a1)) - } + let __a1 = { + let mut __tmp_0 = { head.decay().offset((3) as isize) }; + let mut __v = Vec::new(); + let mut __it = head.decay(); + while __it != __tmp_0 { + __v.push((__it.iter_deref().read())); + __it.iter_inc(); + } + __v + }; + dest.with_mut(|__v: &mut Vec>| __v.push(__a1)) }; } pub fn shrink_through_ptr_2(mut comps: Ptr>) { @@ -129,10 +123,10 @@ pub fn emplace_local_from_field_4(mut jpg: Ptr, mut cond: bool) { { dest.with_mut(|__v: &mut Vec>| { __v.push({ - let mut __tmp_3 = { head.decay().offset((3) as isize) }; + let mut __tmp_1 = { head.decay().offset((3) as isize) }; let mut __v = Vec::new(); let mut __it = head.decay(); - while __it != __tmp_3 { + while __it != __tmp_1 { __v.push((__it.iter_deref().read())); __it.iter_inc(); } @@ -143,9 +137,9 @@ pub fn emplace_local_from_field_4(mut jpg: Ptr, mut cond: bool) { } pub fn nested_emplace_move_5(mut bw: Ptr) { { - let mut __tmp_4 = { bw.with(|__s| __s.output.clone()) }; - let mut __tmp_5 = { bw.with(|__s| __s.chunk) }; - __tmp_4.with_mut(|__v: &mut Vec| __v.push(__tmp_5)); + let mut __tmp_2 = { bw.with(|__s| __s.output.clone()) }; + let mut __tmp_3 = { bw.with(|__s| __s.chunk) }; + __tmp_2.with_mut(|__v: &mut Vec| __v.push(__tmp_3)); }; } pub fn self_ref_push_6(mut comps: Ptr>) { @@ -193,36 +187,36 @@ pub fn emplace_ctor_args_7(mut pairs: Ptr>) { }); }; { - let mut __tmp_6 = { + let mut __tmp_4 = { { let __v: Value = Rc::new(RefCell::new(::zero_init())); PairImpl::construct_1(&__v.as_pointer(), { 3 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() } }; - pairs.with_mut(|__v: &mut Vec| __v.push(__tmp_6)); + pairs.with_mut(|__v: &mut Vec| __v.push(__tmp_4)); }; { - let mut __tmp_7 = { + let mut __tmp_5 = { { let __v: Value = Rc::new(RefCell::new(::zero_init())); PairImpl::construct_2(&__v.as_pointer(), { 4 }, { 5 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() } }; - pairs.with_mut(|__v: &mut Vec| __v.push(__tmp_7)); + pairs.with_mut(|__v: &mut Vec| __v.push(__tmp_5)); }; } pub fn emplace_deque_8(mut queue: Ptr>) { { - let mut __tmp_8 = { + let mut __tmp_6 = { { let __v: Value = Rc::new(RefCell::new(::zero_init())); PairImpl::construct_2(&__v.as_pointer(), { 6 }, { 7 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() } }; - queue.with_mut(|__v: &mut Vec| __v.push(__tmp_8)); + queue.with_mut(|__v: &mut Vec| __v.push(__tmp_6)); }; { queue.with_mut(|__v: &mut Vec| { @@ -245,7 +239,7 @@ pub fn emplace_scalar_9(mut values: Ptr>, x: i32) { } pub fn emplace_ref_through_ptr_10(mut pairs: Ptr>) { let p: Ptr = { - let mut __tmp_9 = { + let mut __tmp_7 = { { let __v: Value = Rc::new(RefCell::new(::zero_init())); PairImpl::construct_2(&__v.as_pointer(), { 1 }, { 2 }); @@ -253,7 +247,7 @@ pub fn emplace_ref_through_ptr_10(mut pairs: Ptr>) { } }; pairs.with_mut(|__b0| { - (*__b0).push(__tmp_9); + (*__b0).push(__tmp_7); let __n = (*__b0).len() - 1; pairs.decay().offset((__n) as isize) }) @@ -262,7 +256,7 @@ pub fn emplace_ref_through_ptr_10(mut pairs: Ptr>) { { field!( { - let mut __tmp_10 = { + let mut __tmp_8 = { { let __v: Value = Rc::new(RefCell::new(::zero_init())); PairImpl::construct_1(&__v.as_pointer(), { 4 }); @@ -270,7 +264,7 @@ pub fn emplace_ref_through_ptr_10(mut pairs: Ptr>) { } }; pairs.with_mut(|__b0| { - (*__b0).push(__tmp_10); + (*__b0).push(__tmp_8); let __n = (*__b0).len() - 1; pairs.decay().offset((__n) as isize) }) @@ -289,15 +283,15 @@ pub fn emplace_addr_11(values: Ptr>) -> Ptr { } pub fn emplace_self_reads_12(mut values: Ptr>, mut pairs: Ptr>) { { - let mut __tmp_11 = { (((*values.upgrade().deref()).len()) as i64) }; - values.with_mut(|__v: &mut Vec| __v.push(__tmp_11)); + let mut __tmp_9 = { (((*values.upgrade().deref()).len()) as i64) }; + values.with_mut(|__v: &mut Vec| __v.push(__tmp_9)); }; { - let mut __tmp_12 = { index!(pairs, 0_usize).read() }; - pairs.with_mut(|__v: &mut Vec| __v.push(__tmp_12)); + let mut __tmp_10 = { index!(pairs, 0_usize).read() }; + pairs.with_mut(|__v: &mut Vec| __v.push(__tmp_10)); }; { - let mut __tmp_13 = { + let mut __tmp_11 = { { let __v: Value = Rc::new(RefCell::new(::zero_init())); PairImpl::construct_2( @@ -318,14 +312,14 @@ pub fn emplace_self_reads_12(mut values: Ptr>, mut pairs: Ptr Rc::try_unwrap(__v).ok().unwrap().into_inner() } }; - pairs.with_mut(|__v: &mut Vec| __v.push(__tmp_13)); + pairs.with_mut(|__v: &mut Vec| __v.push(__tmp_11)); }; } pub fn emplace_ref_self_read_13(values: Ptr>) -> Ptr { return { - let mut __tmp_14 = { (values.decay().read()) }; + let mut __tmp_12 = { (values.decay().read()) }; values.with_mut(|__b0| { - (*__b0).push(__tmp_14); + (*__b0).push(__tmp_12); let __n = (*__b0).len() - 1; values.decay().offset((__n) as isize) }) @@ -373,19 +367,19 @@ impl Default for Bytes { pub fn emplace_from_element_14(mut v: Ptr>>) { let p: Value> = Rc::new(RefCell::new((v).decay().offset(0_usize).decay())); { - let mut __tmp_16 = { + let mut __tmp_14 = { { - let mut __tmp_15 = { (*p.borrow()).offset((3) as isize) }; + let mut __tmp_13 = { (*p.borrow()).offset((3) as isize) }; let mut __v = Vec::new(); let mut __it = ({ (*p.borrow()).clone() }); - while __it != __tmp_15 { + while __it != __tmp_13 { __v.push((__it.iter_deref().read())); __it.iter_inc(); } __v } }; - v.with_mut(|__v: &mut Vec>| __v.push(__tmp_16)); + v.with_mut(|__v: &mut Vec>| __v.push(__tmp_14)); }; } #[derive( @@ -444,33 +438,33 @@ pub struct Counted { impl Counted {} pub fn emplace_counted_17(mut v: Ptr>) { { - let mut __tmp_17 = { + let mut __tmp_15 = { { let __v: Value = Rc::new(RefCell::new(::zero_init())); CountedImpl::construct(&__v.as_pointer(), { 1 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() } }; - v.with_mut(|__v: &mut Vec| __v.push(__tmp_17)); + v.with_mut(|__v: &mut Vec| __v.push(__tmp_15)); }; } pub fn emplace_from_sibling_18(mut s: Ptr) { let p: Value> = Rc::new(RefCell::new(array_field_ptr!(s, b))); let mut v: Ptr>> = (field_ref!(s, v).as_pointer()); { - let mut __tmp_19 = { + let mut __tmp_17 = { { - let mut __tmp_18 = { (*p.borrow()).offset((3) as isize) }; + let mut __tmp_16 = { (*p.borrow()).offset((3) as isize) }; let mut __v = Vec::new(); let mut __it = ({ (*p.borrow()).clone() }); - while __it != __tmp_18 { + while __it != __tmp_16 { __v.push((__it.iter_deref().read())); __it.iter_inc(); } __v } }; - v.with_mut(|__v: &mut Vec>| __v.push(__tmp_19)); + v.with_mut(|__v: &mut Vec>| __v.push(__tmp_17)); }; } pub fn main() { @@ -628,14 +622,14 @@ fn main_0() -> i32 { let self_values: Value> = Rc::new(RefCell::new(Vec::from([7_i64]))); let self_pairs: Value> = Rc::new(RefCell::new(Vec::new())); { - let mut __tmp_20 = { + let mut __tmp_18 = { { let __v: Value = Rc::new(RefCell::new(::zero_init())); PairImpl::construct_2(&__v.as_pointer(), { 1 }, { 2 }); Rc::try_unwrap(__v).ok().unwrap().into_inner() } }; - (*self_pairs.borrow_mut()).push(__tmp_20); + (*self_pairs.borrow_mut()).push(__tmp_18); }; ({ emplace_self_reads_12((self_values.as_pointer()), (self_pairs.as_pointer())) }); { diff --git a/tests/unit/out/refcount/return_move.rs b/tests/unit/out/refcount/return_move.rs index 18b9f89be1..a569922ac5 100644 --- a/tests/unit/out/refcount/return_move.rs +++ b/tests/unit/out/refcount/return_move.rs @@ -96,17 +96,16 @@ pub fn ret_struct_param_10(mut p: pair_t) -> pair_t { pub fn ret_struct_ref_11(p: Ptr) -> pair_t { return (*p.upgrade().deref()).clone(); } -pub fn ret_vec_12(v: Vec) -> Vec { - let v: Value> = Rc::new(RefCell::new(v)); - return ({ std::mem::take(&mut (*v.borrow_mut())) }); +pub fn ret_vec_12(mut v: Vec) -> Vec { + return std::mem::take(&mut v); } pub fn ret_vec_local_13() -> Vec { - let v: Value> = Rc::new(RefCell::new(Vec::new())); + let mut v: Vec = Vec::new(); { let __a1 = 1; - (*v.borrow_mut()).push(__a1) + v.push(__a1) }; - return ({ std::mem::take(&mut (*v.borrow_mut())) }); + return std::mem::take(&mut v); } pub fn ret_loop_14(mut n: Ptr) -> Ptr { 'loop_: while !(n.with(|__s| __s.next.clone())).is_null() { diff --git a/tests/unit/out/refcount/string.rs b/tests/unit/out/refcount/string.rs index 044be9781a..40d9533341 100644 --- a/tests/unit/out/refcount/string.rs +++ b/tests/unit/out/refcount/string.rs @@ -409,26 +409,22 @@ fn main_0() -> i32 { })); printf!(b"position: %s %zu\n", once.decay(), substr_pos); let mut substr_count: usize = 2_usize; - match (Rc::new(RefCell::new({ - let mut __tmp_3 = { substr_count.postfix_inc() }; - s1.as_pointer().with(|__s: &Vec| { - let mut __tmp1 = __s - [1_usize..::std::cmp::min(1_usize + __tmp_3, __s.len().saturating_sub(1))] - .to_vec(); - __tmp1.push(0); - __tmp1 - }) - })) - .as_pointer(),) { - (__tmp_2,) => { - (*once.borrow_mut()) = __tmp_2.with_mut(|__v| std::mem::replace(__v, vec![0])); - } + (*once.borrow_mut()) = { + let mut __tmp_2 = { substr_count.postfix_inc() }; + s1.as_pointer().with(|__s: &Vec| { + let mut __tmp1 = __s + [1_usize..::std::cmp::min(1_usize + __tmp_2, __s.len().saturating_sub(1))] + .to_vec(); + __tmp1.push(0); + __tmp1 + }) + }; }; printf!(b"count: %s %zu\n", once.decay(), substr_count); let receiver_calls: Value = Rc::new(RefCell::new(0)); - match (Rc::new(RefCell::new( - Rc::new(RefCell::new( + { + (*once.borrow_mut()) = Rc::new(RefCell::new( ({ counted_string_0(receiver_calls.as_pointer()) }), )) .as_pointer() @@ -438,13 +434,7 @@ fn main_0() -> i32 { .to_vec(); __tmp1.push(0); __tmp1 - }), - )) - .as_pointer(),) - { - (__tmp_4,) => { - (*once.borrow_mut()) = __tmp_4.with_mut(|__v| std::mem::replace(__v, vec![0])); - } + }); }; printf!( b"receiver: %s %d\n", @@ -458,18 +448,18 @@ fn main_0() -> i32 { __bytes })); match (({ counted_ref_1(target.as_pointer(), ref_calls.as_pointer()) }),) { - (__tmp_5,) => __tmp_5.with_mut(|__b0| { + (__tmp_3,) => __tmp_3.with_mut(|__b0| { (*__b0).pop(); (*__b0).resize((1_usize) as usize, 0); (*__b0).push(0) }), }; match (({ counted_ref_1(target.as_pointer(), ref_calls.as_pointer()) }),) { - (__tmp_6,) => { - if 0_usize >= (*__tmp_6.upgrade().deref()).len() - 1 { + (__tmp_4,) => { + if 0_usize >= (*__tmp_4.upgrade().deref()).len() - 1 { panic!("out of bounds access") } - __tmp_6.decay().offset((0_usize) as isize) + __tmp_4.decay().offset((0_usize) as isize) } } .write(('A' as i8)); @@ -496,7 +486,7 @@ fn main_0() -> i32 { ]))); let mut target_index: i32 = 0; match (targets.decay().offset(target_index.postfix_inc()),) { - (__tmp_7,) => __tmp_7.with_mut(|__b0| { + (__tmp_5,) => __tmp_5.with_mut(|__b0| { (*__b0).pop(); (*__b0).resize((1_usize) as usize, 0); (*__b0).push(0) @@ -528,8 +518,8 @@ fn main_0() -> i32 { { { ({ - let mut __tmp_8 = { (*target.borrow()).clone() }; - (*chained.borrow_mut()) = __tmp_8; + let mut __tmp_6 = { (*target.borrow()).clone() }; + (*chained.borrow_mut()) = __tmp_6; }); chained.with_mut(|__b0| { (*__b0).pop(); @@ -579,18 +569,18 @@ fn main_0() -> i32 { })); let self_ptr: Value>> = Rc::new(RefCell::new((self_.as_pointer()))); { - let mut __tmp_9 = { { (*self_.borrow())[0_usize] } }; + let mut __tmp_7 = { { (*self_.borrow())[0_usize] } }; self_.with_mut(|__b0| { (*__b0).pop(); - (*__b0).resize((*__b0).len() + 2_usize, __tmp_9); + (*__b0).resize((*__b0).len() + 2_usize, __tmp_7); (*__b0).push(0); }) }; { - let mut __tmp_10 = { (index!((*self_ptr.borrow()), 1_usize).read()) }; + let mut __tmp_8 = { (index!((*self_ptr.borrow()), 1_usize).read()) }; (*self_ptr.borrow()).with_mut(|__b0| { (*__b0).pop(); - (*__b0).resize((*__b0).len() + 1_usize, __tmp_10); + (*__b0).resize((*__b0).len() + 1_usize, __tmp_8); (*__b0).push(0); }) }; @@ -638,10 +628,10 @@ fn main_0() -> i32 { })); { { - let mut __tmp_11 = { { (*local.borrow())[0_usize] } }; + let mut __tmp_9 = { { (*local.borrow())[0_usize] } }; local.with_mut(|__b0| { (*__b0).pop(); - (*__b0).resize((*__b0).len() + 1_usize, __tmp_11); + (*__b0).resize((*__b0).len() + 1_usize, __tmp_9); (*__b0).push(0); }) }; @@ -652,8 +642,8 @@ fn main_0() -> i32 { }) }; { - let mut __tmp_12 = { (*local.borrow()).clone() }; - (*local.borrow_mut()) = __tmp_12; + let mut __tmp_10 = { (*local.borrow()).clone() }; + (*local.borrow_mut()) = __tmp_10; }; assert!( ({ @@ -678,10 +668,10 @@ fn main_0() -> i32 { )) .as_pointer(),) { - (__tmp_13,) => { + (__tmp_11,) => { Ptr::::from_string_literal(b"-42").with_c_str(|__s| { - (*__tmp_13.upgrade().deref()) - [..(*__tmp_13.upgrade().deref()).len().saturating_sub(1)] + (*__tmp_11.upgrade().deref()) + [..(*__tmp_11.upgrade().deref()).len().saturating_sub(1)] == *__s }) } @@ -696,10 +686,10 @@ fn main_0() -> i32 { )) .as_pointer(),) { - (__tmp_14,) => { + (__tmp_12,) => { Ptr::::from_string_literal(b"-9223372036854775808").with_c_str(|__s| { - (*__tmp_14.upgrade().deref()) - [..(*__tmp_14.upgrade().deref()).len().saturating_sub(1)] + (*__tmp_12.upgrade().deref()) + [..(*__tmp_12.upgrade().deref()).len().saturating_sub(1)] == *__s }) } @@ -714,10 +704,10 @@ fn main_0() -> i32 { )) .as_pointer(),) { - (__tmp_15,) => { + (__tmp_13,) => { Ptr::::from_string_literal(b"1099511627776").with_c_str(|__s| { - (*__tmp_15.upgrade().deref()) - [..(*__tmp_15.upgrade().deref()).len().saturating_sub(1)] + (*__tmp_13.upgrade().deref()) + [..(*__tmp_13.upgrade().deref()).len().saturating_sub(1)] == *__s }) } @@ -732,10 +722,10 @@ fn main_0() -> i32 { )) .as_pointer(),) { - (__tmp_16,) => { + (__tmp_14,) => { Ptr::::from_string_literal(b"4294967295").with_c_str(|__s| { - (*__tmp_16.upgrade().deref()) - [..(*__tmp_16.upgrade().deref()).len().saturating_sub(1)] + (*__tmp_14.upgrade().deref()) + [..(*__tmp_14.upgrade().deref()).len().saturating_sub(1)] == *__s }) } @@ -750,10 +740,10 @@ fn main_0() -> i32 { )) .as_pointer(),) { - (__tmp_17,) => { + (__tmp_15,) => { Ptr::::from_string_literal(b"18446744073709551615").with_c_str(|__s| { - (*__tmp_17.upgrade().deref()) - [..(*__tmp_17.upgrade().deref()).len().saturating_sub(1)] + (*__tmp_15.upgrade().deref()) + [..(*__tmp_15.upgrade().deref()).len().saturating_sub(1)] == *__s }) } @@ -768,10 +758,10 @@ fn main_0() -> i32 { )) .as_pointer(),) { - (__tmp_18,) => { + (__tmp_16,) => { Ptr::::from_string_literal(b"0").with_c_str(|__s| { - (*__tmp_18.upgrade().deref()) - [..(*__tmp_18.upgrade().deref()).len().saturating_sub(1)] + (*__tmp_16.upgrade().deref()) + [..(*__tmp_16.upgrade().deref()).len().saturating_sub(1)] == *__s }) } @@ -785,10 +775,10 @@ fn main_0() -> i32 { )) .as_pointer(),) { - (__tmp_19,) => { + (__tmp_17,) => { Ptr::::from_string_literal(b"1.500000").with_c_str(|__s| { - (*__tmp_19.upgrade().deref()) - [..(*__tmp_19.upgrade().deref()).len().saturating_sub(1)] + (*__tmp_17.upgrade().deref()) + [..(*__tmp_17.upgrade().deref()).len().saturating_sub(1)] == *__s }) } @@ -802,10 +792,10 @@ fn main_0() -> i32 { )) .as_pointer(),) { - (__tmp_20,) => { + (__tmp_18,) => { Ptr::::from_string_literal(b"-0.250000").with_c_str(|__s| { - (*__tmp_20.upgrade().deref()) - [..(*__tmp_20.upgrade().deref()).len().saturating_sub(1)] + (*__tmp_18.upgrade().deref()) + [..(*__tmp_18.upgrade().deref()).len().saturating_sub(1)] == *__s }) } @@ -833,10 +823,10 @@ fn main_0() -> i32 { )) .as_pointer(),) { - (__tmp_21,) => { + (__tmp_19,) => { Ptr::::from_string_literal(b"-5").with_c_str(|__s| { - (*__tmp_21.upgrade().deref()) - [..(*__tmp_21.upgrade().deref()).len().saturating_sub(1)] + (*__tmp_19.upgrade().deref()) + [..(*__tmp_19.upgrade().deref()).len().saturating_sub(1)] == *__s }) } @@ -850,10 +840,10 @@ fn main_0() -> i32 { )) .as_pointer(),) { - (__tmp_22,) => { + (__tmp_20,) => { Ptr::::from_string_literal(b"15").with_c_str(|__s| { - (*__tmp_22.upgrade().deref()) - [..(*__tmp_22.upgrade().deref()).len().saturating_sub(1)] + (*__tmp_20.upgrade().deref()) + [..(*__tmp_20.upgrade().deref()).len().saturating_sub(1)] == *__s }) } diff --git a/tests/unit/out/refcount/string_moved_from.rs b/tests/unit/out/refcount/string_moved_from.rs index da86aade59..85688562f9 100644 --- a/tests/unit/out/refcount/string_moved_from.rs +++ b/tests/unit/out/refcount/string_moved_from.rs @@ -25,16 +25,15 @@ pub fn print_moved_from_0(mut label: Ptr, from: Ptr>, to: Ptr Vec { - let word: Value> = Rc::new(RefCell::new({ + let mut word: Vec = { let mut __bytes = Ptr::::from_string_literal(b"returned local").to_c_bytes(); __bytes.push(0); __bytes - })); - return ({ std::mem::take(&mut (*word.borrow_mut())) }); + }; + return std::mem::take(&mut (word)); } -pub fn return_parameter_2(word: Vec) -> Vec { - let word: Value> = Rc::new(RefCell::new(word)); - return ({ std::mem::take(&mut (*word.borrow_mut())) }); +pub fn return_parameter_2(mut word: Vec) -> Vec { + return std::mem::take(&mut word); } pub fn return_reference_3(word: Ptr>) -> Vec { return word.with_mut(|__v| std::mem::replace(__v, vec![0])); diff --git a/tests/unit/out/refcount/string_substr.rs b/tests/unit/out/refcount/string_substr.rs index ca659b6f35..a39ab082f0 100644 --- a/tests/unit/out/refcount/string_substr.rs +++ b/tests/unit/out/refcount/string_substr.rs @@ -65,8 +65,8 @@ fn main_0() -> i32 { )); printf!(b"receiver: %s %d\n", out.decay(), (*calls.borrow())); (*calls.borrow_mut()) = 0; - match (Rc::new(RefCell::new( - Rc::new(RefCell::new(({ temporary_1(calls.as_pointer()) }))) + { + (*out.borrow_mut()) = Rc::new(RefCell::new(({ temporary_1(calls.as_pointer()) }))) .as_pointer() .with(|__s: &Vec| { let mut __tmp1 = __s @@ -74,78 +74,61 @@ fn main_0() -> i32 { .to_vec(); __tmp1.push(0); __tmp1 - }), - )) - .as_pointer(),) - { - (__tmp_2,) => { - (*out.borrow_mut()) = __tmp_2.with_mut(|__v| std::mem::replace(__v, vec![0])); - } + }); }; printf!(b"temporary: %s %d\n", out.decay(), (*calls.borrow())); - match (Rc::new(RefCell::new({ - let mut __tmp_4 = { - ({ - (*s.borrow_mut())[0_usize] = ('j' as i8); - 0 - } as usize) - }; - s.as_pointer().with(|__s: &Vec| { - let mut __tmp1 = __s - [__tmp_4..::std::cmp::min(__tmp_4 + 2_usize, __s.len().saturating_sub(1))] - .to_vec(); - __tmp1.push(0); - __tmp1 - }) - })) - .as_pointer(),) { - (__tmp_3,) => { - (*out.borrow_mut()) = __tmp_3.with_mut(|__v| std::mem::replace(__v, vec![0])); - } + (*out.borrow_mut()) = { + let mut __tmp_2 = { + ({ + (*s.borrow_mut())[0_usize] = ('j' as i8); + 0 + } as usize) + }; + s.as_pointer().with(|__s: &Vec| { + let mut __tmp1 = __s + [__tmp_2..::std::cmp::min(__tmp_2 + 2_usize, __s.len().saturating_sub(1))] + .to_vec(); + __tmp1.push(0); + __tmp1 + }) + }; }; printf!(b"position mutation: %s %s\n", out.decay(), s.decay()); - match (Rc::new(RefCell::new({ - let mut __tmp_6 = { - ({ - (*s.borrow_mut())[1_usize] = ('a' as i8); - 2 - } as usize) - }; - s.as_pointer().with(|__s: &Vec| { - let mut __tmp1 = __s - [0_usize..::std::cmp::min(0_usize + __tmp_6, __s.len().saturating_sub(1))] - .to_vec(); - __tmp1.push(0); - __tmp1 - }) - })) - .as_pointer(),) { - (__tmp_5,) => { - (*out.borrow_mut()) = __tmp_5.with_mut(|__v| std::mem::replace(__v, vec![0])); - } + (*out.borrow_mut()) = { + let mut __tmp_3 = { + ({ + (*s.borrow_mut())[1_usize] = ('a' as i8); + 2 + } as usize) + }; + s.as_pointer().with(|__s: &Vec| { + let mut __tmp1 = __s + [0_usize..::std::cmp::min(0_usize + __tmp_3, __s.len().saturating_sub(1))] + .to_vec(); + __tmp1.push(0); + __tmp1 + }) + }; }; printf!(b"count mutation: %s %s\n", out.decay(), s.decay()); (*out.borrow_mut())[0_usize] = ('X' as i8); (*s.borrow_mut())[1_usize] = ('b' as i8); printf!(b"independent: %s %s\n", out.decay(), s.decay()); let mut p: Ptr> = (s.as_pointer()); - match (Rc::new(RefCell::new(p.with(|__s: &Vec| { - let mut __tmp1 = - __s[1_usize..::std::cmp::min(1_usize + 2_usize, __s.len().saturating_sub(1))].to_vec(); - __tmp1.push(0); - __tmp1 - }))) - .as_pointer(),) { - (__tmp_7,) => { - (*out.borrow_mut()) = __tmp_7.with_mut(|__v| std::mem::replace(__v, vec![0])); - } + (*out.borrow_mut()) = p.with(|__s: &Vec| { + let mut __tmp1 = __s + [1_usize..::std::cmp::min(1_usize + 2_usize, __s.len().saturating_sub(1))] + .to_vec(); + __tmp1.push(0); + __tmp1 + }); }; printf!(b"pointer: %s\n", out.decay()); - match (Rc::new(RefCell::new( - Rc::new(RefCell::new( + { + (*out.borrow_mut()) = Rc::new(RefCell::new( Rc::new(RefCell::new({ let mut __bytes = Ptr::::from_string_literal(b"hello").to_c_bytes(); __bytes.push(0); @@ -167,30 +150,20 @@ fn main_0() -> i32 { .to_vec(); __tmp1.push(0); __tmp1 - }), - )) - .as_pointer(),) - { - (__tmp_8,) => { - (*out.borrow_mut()) = __tmp_8.with_mut(|__v| std::mem::replace(__v, vec![0])); - } + }); }; printf!(b"nested: %s\n", out.decay()); - match (Rc::new(RefCell::new({ - let mut __tmp_10 = { ((*s.borrow()).len() - 1) }; - s.as_pointer().with(|__s: &Vec| { - let mut __tmp1 = __s - [__tmp_10..::std::cmp::min(__tmp_10 + 0_usize, __s.len().saturating_sub(1))] - .to_vec(); - __tmp1.push(0); - __tmp1 - }) - })) - .as_pointer(),) { - (__tmp_9,) => { - (*out.borrow_mut()) = __tmp_9.with_mut(|__v| std::mem::replace(__v, vec![0])); - } + (*out.borrow_mut()) = { + let mut __tmp_4 = { ((*s.borrow()).len() - 1) }; + s.as_pointer().with(|__s: &Vec| { + let mut __tmp1 = __s + [__tmp_4..::std::cmp::min(__tmp_4 + 0_usize, __s.len().saturating_sub(1))] + .to_vec(); + __tmp1.push(0); + __tmp1 + }) + }; }; printf!(b"empty: %zu\n", ((*out.borrow()).len() - 1)); let field: Value> = Rc::new(RefCell::new({ @@ -201,21 +174,14 @@ fn main_0() -> i32 { let text: Value = Rc::new(RefCell::new(Text { value: field.as_pointer(), })); - match ( - Rc::new(RefCell::new({ (*text.borrow()).value.clone() }.with( - |__s: &Vec| { - let mut __tmp1 = __s - [1_usize..::std::cmp::min(1_usize + 2_usize, __s.len().saturating_sub(1))] - .to_vec(); - __tmp1.push(0); - __tmp1 - }, - ))) - .as_pointer(), - ) { - (__tmp_11,) => { - (*out.borrow_mut()) = __tmp_11.with_mut(|__v| std::mem::replace(__v, vec![0])); - } + { + (*out.borrow_mut()) = { (*text.borrow()).value.clone() }.with(|__s: &Vec| { + let mut __tmp1 = __s + [1_usize..::std::cmp::min(1_usize + 2_usize, __s.len().saturating_sub(1))] + .to_vec(); + __tmp1.push(0); + __tmp1 + }); }; printf!( b"field: %s %s\n", @@ -235,8 +201,8 @@ fn main_0() -> i32 { }, ]))); let mut index: usize = 0_usize; - match (Rc::new(RefCell::new( - strings + { + (*out.borrow_mut()) = strings .decay() .offset(index.postfix_inc()) .with(|__s: &Vec| { @@ -245,13 +211,7 @@ fn main_0() -> i32 { .to_vec(); __tmp1.push(0); __tmp1 - }), - )) - .as_pointer(),) - { - (__tmp_12,) => { - (*out.borrow_mut()) = __tmp_12.with_mut(|__v| std::mem::replace(__v, vec![0])); - } + }); }; printf!(b"element: %s %zu\n", out.decay(), index); return 0; diff --git a/tests/unit/out/refcount/vector.rs b/tests/unit/out/refcount/vector.rs index 7775c9ee22..c238d0d575 100644 --- a/tests/unit/out/refcount/vector.rs +++ b/tests/unit/out/refcount/vector.rs @@ -572,16 +572,14 @@ fn main_0() -> i32 { }; assert!(({ (v12[0_usize] == 5) && ((*moved.borrow()) == 5) })); let mut v13: Vec> = Vec::new(); - let moved_ptr: Value> = Rc::new(RefCell::new((moved.as_pointer()))); + let mut moved_ptr: Ptr = (moved.as_pointer()); { - let __a1 = ({ (*moved_ptr.borrow()).clone() }); + let __a1 = (moved_ptr).clone(); v13.push(__a1) }; assert!( - ({ - (v13[0_usize] == (moved.as_pointer())) - && ({ (*moved_ptr.borrow()).clone() } == { (moved.as_pointer()) }) - }) + (v13[0_usize] == (moved.as_pointer())) + && ({ (moved_ptr).clone() } == { (moved.as_pointer()) }) ); let mut v14: Vec = Vec::from([1, 2, 3]); let __rhs = ((*{ diff --git a/tests/unit/out/refcount/vector_deque_vector_string.rs b/tests/unit/out/refcount/vector_deque_vector_string.rs index 4c952f0928..48eed56b68 100644 --- a/tests/unit/out/refcount/vector_deque_vector_string.rs +++ b/tests/unit/out/refcount/vector_deque_vector_string.rs @@ -19,85 +19,70 @@ fn main_0() -> i32 { (*v.borrow_mut()).push(Vec::new()); }; let row: Value>> = Rc::new(RefCell::new(Vec::new())); - match (Rc::new(RefCell::new({ - let mut __bytes = Ptr::::from_string_literal(b"a").to_c_bytes(); - __bytes.push(0); - __bytes - })) - .as_pointer(),) { - (__tmp_0,) => { - let __a1 = __tmp_0.with_mut(|__v| std::mem::replace(__v, vec![0])); - (*row.borrow_mut()).push(__a1) - } + let __a1 = { + let mut __bytes = Ptr::::from_string_literal(b"a").to_c_bytes(); + __bytes.push(0); + __bytes + }; + (*row.borrow_mut()).push(__a1) }; - match (Rc::new(RefCell::new({ - let mut __bytes = Ptr::::from_string_literal(b"bc").to_c_bytes(); - __bytes.push(0); - __bytes - })) - .as_pointer(),) { - (__tmp_1,) => { - let __a1 = __tmp_1.with_mut(|__v| std::mem::replace(__v, vec![0])); - (*row.borrow_mut()).push(__a1) - } + let __a1 = { + let mut __bytes = Ptr::::from_string_literal(b"bc").to_c_bytes(); + __bytes.push(0); + __bytes + }; + (*row.borrow_mut()).push(__a1) }; elem!(v.decay(), 0_usize) .with_mut(|__v: &mut Vec>>| __v.push(({ (*row.borrow()).clone() }))); - match (Rc::new(RefCell::new({ - let mut __bytes = Ptr::::from_string_literal(b"def").to_c_bytes(); - __bytes.push(0); - __bytes - })) - .as_pointer(),) { - (__tmp_2,) => { - let __a1 = __tmp_2.with_mut(|__v| std::mem::replace(__v, vec![0])); - (*row.borrow_mut()).push(__a1) - } + let __a1 = { + let mut __bytes = Ptr::::from_string_literal(b"def").to_c_bytes(); + __bytes.push(0); + __bytes + }; + (*row.borrow_mut()).push(__a1) }; elem!(v.decay(), 1_usize) .with_mut(|__v: &mut Vec>>| __v.push(({ (*row.borrow()).clone() }))); match (v.decay().offset(1_usize),) { - (__tmp_3,) => { - __tmp_3.with_mut(|__v: &mut Vec>>| __v.push(Vec::new())); + (__tmp_0,) => { + __tmp_0.with_mut(|__v: &mut Vec>>| __v.push(Vec::new())); } }; - match ( - match (v.decay().offset(1_usize),) { - (__tmp_5,) => { - let __n = (*__tmp_5.upgrade().deref()).len() - 1; - __tmp_5.decay().offset((__n) as isize) - } - }, - Rc::new(RefCell::new({ - let mut r = ({ - (*match (v.decay().offset(0_usize),) { - (__tmp_7,) => __tmp_7.decay(), - } - .decay() - .offset(1_usize) - .upgrade() - .deref()) - .clone() - }); - r.pop(); - Ptr::::from_string_literal(b"x").with_c_str(|__s| r.extend_from_slice(__s)); - r.push(0); - r - })) - .as_pointer(), - ) { - (__tmp_4, __tmp_6) => { - let __a1 = __tmp_6.with_mut(|__v| std::mem::replace(__v, vec![0])); - __tmp_4.with_mut(|__v: &mut Vec>| __v.push(__a1)) + match (match (v.decay().offset(1_usize),) { + (__tmp_2,) => { + let __n = (*__tmp_2.upgrade().deref()).len() - 1; + __tmp_2.decay().offset((__n) as isize) + } + },) + { + (__tmp_1,) => { + let __a1 = { + let mut r = ({ + (*match (v.decay().offset(0_usize),) { + (__tmp_3,) => __tmp_3.decay(), + } + .decay() + .offset(1_usize) + .upgrade() + .deref()) + .clone() + }); + r.pop(); + Ptr::::from_string_literal(b"x").with_c_str(|__s| r.extend_from_slice(__s)); + r.push(0); + r + }; + __tmp_1.with_mut(|__v: &mut Vec>| __v.push(__a1)) } }; assert!( ({ ((*match (v.decay().offset(0_usize),) { - (__tmp_8,) => __tmp_8.decay(), + (__tmp_4,) => __tmp_4.decay(), } .upgrade() .deref()) @@ -108,21 +93,21 @@ fn main_0() -> i32 { assert!( ({ ((*match (v.decay().offset(1_usize),) { - (__tmp_9,) => __tmp_9.decay(), + (__tmp_5,) => __tmp_5.decay(), } .upgrade() .deref()) .len() == 3_usize) && (match (match (v.decay().offset(1_usize),) { - (__tmp_11,) => __tmp_11.decay(), + (__tmp_7,) => __tmp_7.decay(), } .decay() .offset(2_usize),) { - (__tmp_10,) => Ptr::::from_string_literal(b"def").with_c_str(|__s| { - (*__tmp_10.upgrade().deref()) - [..(*__tmp_10.upgrade().deref()).len().saturating_sub(1)] + (__tmp_6,) => Ptr::::from_string_literal(b"def").with_c_str(|__s| { + (*__tmp_6.upgrade().deref()) + [..(*__tmp_6.upgrade().deref()).len().saturating_sub(1)] == *__s }), }) @@ -131,17 +116,17 @@ fn main_0() -> i32 { assert!( ({ match (match (v.decay().offset(1_usize),) { - (__tmp_13,) => { - let __n = (*__tmp_13.upgrade().deref()).len() - 1; - __tmp_13.decay().offset((__n) as isize) + (__tmp_9,) => { + let __n = (*__tmp_9.upgrade().deref()).len() - 1; + __tmp_9.decay().offset((__n) as isize) } } .decay() .offset(0_usize),) { - (__tmp_12,) => Ptr::::from_string_literal(b"bcx").with_c_str(|__s| { - (*__tmp_12.upgrade().deref()) - [..(*__tmp_12.upgrade().deref()).len().saturating_sub(1)] + (__tmp_8,) => Ptr::::from_string_literal(b"bcx").with_c_str(|__s| { + (*__tmp_8.upgrade().deref()) + [..(*__tmp_8.upgrade().deref()).len().saturating_sub(1)] == *__s }), } @@ -150,7 +135,7 @@ fn main_0() -> i32 { let copy: Value>>>> = Rc::new(RefCell::new((*v.borrow()).clone())); match ( match (copy.decay().offset(0_usize),) { - (__tmp_15,) => __tmp_15.decay(), + (__tmp_11,) => __tmp_11.decay(), } .decay() .offset(0_usize), @@ -161,46 +146,46 @@ fn main_0() -> i32 { })) .as_pointer(), ) { - (__tmp_14, __tmp_16) => __tmp_14.with_mut(|__b0| { - (*__b0) = __tmp_16.with_mut(|__v| std::mem::replace(__v, vec![0])); + (__tmp_10, __tmp_12) => __tmp_10.with_mut(|__b0| { + (*__b0) = __tmp_12.with_mut(|__v| std::mem::replace(__v, vec![0])); }), }; match (match (v.decay().offset(0_usize),) { - (__tmp_18,) => __tmp_18.decay(), + (__tmp_14,) => __tmp_14.decay(), } .decay() .offset(1_usize),) { - (__tmp_17,) => { - if 0_usize >= (*__tmp_17.upgrade().deref()).len() - 1 { + (__tmp_13,) => { + if 0_usize >= (*__tmp_13.upgrade().deref()).len() - 1 { panic!("out of bounds access") } - __tmp_17.decay().offset((0_usize) as isize) + __tmp_13.decay().offset((0_usize) as isize) } } .write(('B' as i8)); assert!( ({ (match (match (v.decay().offset(0_usize),) { - (__tmp_20,) => __tmp_20.decay(), + (__tmp_16,) => __tmp_16.decay(), } .decay() .offset(0_usize),) { - (__tmp_19,) => Ptr::::from_string_literal(b"a").with_c_str(|__s| { - (*__tmp_19.upgrade().deref()) - [..(*__tmp_19.upgrade().deref()).len().saturating_sub(1)] + (__tmp_15,) => Ptr::::from_string_literal(b"a").with_c_str(|__s| { + (*__tmp_15.upgrade().deref()) + [..(*__tmp_15.upgrade().deref()).len().saturating_sub(1)] == *__s }), }) && (match (match (copy.decay().offset(0_usize),) { - (__tmp_22,) => __tmp_22.decay(), + (__tmp_18,) => __tmp_18.decay(), } .decay() .offset(0_usize),) { - (__tmp_21,) => Ptr::::from_string_literal(b"z").with_c_str(|__s| { - (*__tmp_21.upgrade().deref()) - [..(*__tmp_21.upgrade().deref()).len().saturating_sub(1)] + (__tmp_17,) => Ptr::::from_string_literal(b"z").with_c_str(|__s| { + (*__tmp_17.upgrade().deref()) + [..(*__tmp_17.upgrade().deref()).len().saturating_sub(1)] == *__s }), }) @@ -209,25 +194,25 @@ fn main_0() -> i32 { assert!( ({ (match (match (v.decay().offset(0_usize),) { - (__tmp_24,) => __tmp_24.decay(), + (__tmp_20,) => __tmp_20.decay(), } .decay() .offset(1_usize),) { - (__tmp_23,) => Ptr::::from_string_literal(b"Bc").with_c_str(|__s| { - (*__tmp_23.upgrade().deref()) - [..(*__tmp_23.upgrade().deref()).len().saturating_sub(1)] + (__tmp_19,) => Ptr::::from_string_literal(b"Bc").with_c_str(|__s| { + (*__tmp_19.upgrade().deref()) + [..(*__tmp_19.upgrade().deref()).len().saturating_sub(1)] == *__s }), }) && (match (match (copy.decay().offset(0_usize),) { - (__tmp_26,) => __tmp_26.decay(), + (__tmp_22,) => __tmp_22.decay(), } .decay() .offset(1_usize),) { - (__tmp_25,) => Ptr::::from_string_literal(b"bc").with_c_str(|__s| { - (*__tmp_25.upgrade().deref()) - [..(*__tmp_25.upgrade().deref()).len().saturating_sub(1)] + (__tmp_21,) => Ptr::::from_string_literal(b"bc").with_c_str(|__s| { + (*__tmp_21.upgrade().deref()) + [..(*__tmp_21.upgrade().deref()).len().saturating_sub(1)] == *__s }), }) @@ -237,14 +222,14 @@ fn main_0() -> i32 { assert!( ({ match (match (v.decay().offset(1_usize),) { - (__tmp_28,) => __tmp_28.decay(), + (__tmp_24,) => __tmp_24.decay(), } .decay() .offset(0_usize),) { - (__tmp_27,) => Ptr::::from_string_literal(b"bcx").with_c_str(|__s| { - (*__tmp_27.upgrade().deref()) - [..(*__tmp_27.upgrade().deref()).len().saturating_sub(1)] + (__tmp_23,) => Ptr::::from_string_literal(b"bcx").with_c_str(|__s| { + (*__tmp_23.upgrade().deref()) + [..(*__tmp_23.upgrade().deref()).len().saturating_sub(1)] == *__s }), } @@ -253,7 +238,7 @@ fn main_0() -> i32 { assert!( ({ ((*match (copy.decay().offset(1_usize),) { - (__tmp_29,) => __tmp_29.decay(), + (__tmp_25,) => __tmp_25.decay(), } .upgrade() .deref()) diff --git a/tests/unit/out/refcount/vector_subscript_direct.rs b/tests/unit/out/refcount/vector_subscript_direct.rs index bc796517ef..a54801b365 100644 --- a/tests/unit/out/refcount/vector_subscript_direct.rs +++ b/tests/unit/out/refcount/vector_subscript_direct.rs @@ -135,17 +135,13 @@ fn main_0() -> i32 { q.x = 0; assert!((vec_elem!(h.as_pointer(), points, 0_usize).with(|__s| __s.x) == 7)); let grid: Value>> = Rc::new(RefCell::new(Vec::new())); - match (Rc::new(RefCell::new(vec![0; 3_usize])).as_pointer(),) { - (__tmp_0,) => { - let __a1 = __tmp_0.with_mut(std::mem::take); - (*grid.borrow_mut()).push(__a1) - } + { + let __a1 = vec![0; 3_usize]; + (*grid.borrow_mut()).push(__a1) }; - match (Rc::new(RefCell::new(vec![0; 3_usize])).as_pointer(),) { - (__tmp_1,) => { - let __a1 = __tmp_1.with_mut(std::mem::take); - (*grid.borrow_mut()).push(__a1) - } + { + let __a1 = vec![0; 3_usize]; + (*grid.borrow_mut()).push(__a1) }; index!(elem!(grid.decay(), 1_usize), 2_usize).write(8); assert!( From 50a436d390edb676cc72b401d9432d9a8070095a Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Wed, 2 Dec 2026 13:54:41 +0000 Subject: [PATCH 11/13] Derive DefaultInitializable (DefaultConstructible + Destructible) --- cpp2rust/converter/converter.cpp | 19 ++++++++--------- cpp2rust/converter/converter_lib.h | 2 ++ .../converter/models/converter_refcount.cpp | 8 ------- libcc2rs-macros/src/lib.rs | 14 +++++++++++++ libcc2rs/src/lib.rs | 10 ++++----- .../out/refcount/defaulted_move_cross_tu.rs | 3 +-- .../out/unsafe/defaulted_move_cross_tu.rs | 3 +-- .../refcount/out_of_line_methods_cross_tu.rs | 7 ++----- .../unsafe/out_of_line_methods_cross_tu.rs | 7 ++----- .../out/refcount/basic.start.term.rs | 3 +-- .../out/unsafe/basic.start.term.rs | 3 +-- tests/std/basic/out/refcount/basic.def.odr.rs | 9 +++----- tests/std/basic/out/unsafe/basic.def.odr.rs | 9 +++----- .../out/refcount/class.copy.ctor.rs | 3 +-- .../class.ctor/out/unsafe/class.copy.ctor.rs | 3 +-- .../utility/out/refcount/forward-helpers.rs | 21 +++++-------------- .../utilities/utility/out/refcount/forward.rs | 9 +------- .../utility/out/unsafe/forward-helpers.rs | 19 +++++------------ .../utilities/utility/out/unsafe/forward.rs | 7 +------ .../refcount/container_element_receiver.rs | 3 +-- tests/unit/out/refcount/copy_assign.rs | 19 ++++------------- tests/unit/out/refcount/copy_ctor.rs | 18 ++++++---------- .../unit/out/refcount/copy_move_defaulted.rs | 12 ++++------- tests/unit/out/refcount/copy_move_deleted.rs | 6 ++---- tests/unit/out/refcount/fn_ptr_struct.rs | 9 +------- tests/unit/out/refcount/forward_basic.rs | 6 ++---- tests/unit/out/refcount/forward_decltype.rs | 3 +-- tests/unit/out/refcount/forward_explicit.rs | 3 +-- tests/unit/out/refcount/forward_pack.rs | 6 ++---- tests/unit/out/refcount/lambda_as_field.rs | 4 +--- tests/unit/out/refcount/map_key_copy_ctor.rs | 3 +-- tests/unit/out/refcount/max.rs | 3 +-- tests/unit/out/refcount/move_assign.rs | 3 +-- tests/unit/out/refcount/move_ctor.rs | 15 +++---------- tests/unit/out/refcount/move_this.rs | 3 +-- .../refcount/operator_comparison_nonbool.rs | 9 +------- .../operator_comparison_noncopyable.rs | 3 +-- tests/unit/out/refcount/polymorphism.rs | 6 ++---- .../unit/out/refcount/rvalue_rule_arg_move.rs | 3 +-- tests/unit/out/refcount/sort_no_copy.rs | 3 +-- .../refcount/structured_binding_copy_ctor.rs | 3 +-- .../structured_binding_element_ctor.rs | 6 ++---- .../refcount/structured_binding_move_ctor.rs | 3 +-- tests/unit/out/refcount/swap_map_no_copy.rs | 6 ++---- tests/unit/out/refcount/unboxed_locals.rs | 3 +-- .../out/unsafe/container_element_receiver.rs | 3 +-- tests/unit/out/unsafe/copy_assign.rs | 17 ++++----------- tests/unit/out/unsafe/copy_ctor.rs | 18 ++++++---------- tests/unit/out/unsafe/copy_move_defaulted.rs | 12 ++++------- tests/unit/out/unsafe/copy_move_deleted.rs | 6 ++---- tests/unit/out/unsafe/fn_ptr_struct.rs | 7 +------ tests/unit/out/unsafe/forward_basic.rs | 6 ++---- tests/unit/out/unsafe/forward_decltype.rs | 3 +-- tests/unit/out/unsafe/forward_explicit.rs | 3 +-- tests/unit/out/unsafe/forward_pack.rs | 6 ++---- tests/unit/out/unsafe/lambda_as_field.rs | 8 +------ tests/unit/out/unsafe/map_key_copy_ctor.rs | 3 +-- tests/unit/out/unsafe/max.rs | 3 +-- tests/unit/out/unsafe/move_assign.rs | 3 +-- tests/unit/out/unsafe/move_ctor.rs | 13 +++--------- tests/unit/out/unsafe/move_this.rs | 3 +-- .../out/unsafe/operator_comparison_nonbool.rs | 7 +------ .../unsafe/operator_comparison_noncopyable.rs | 3 +-- tests/unit/out/unsafe/polymorphism.rs | 6 ++---- tests/unit/out/unsafe/rvalue_rule_arg_move.rs | 3 +-- tests/unit/out/unsafe/sort_no_copy.rs | 3 +-- .../unsafe/structured_binding_copy_ctor.rs | 3 +-- .../unsafe/structured_binding_element_ctor.rs | 6 ++---- .../unsafe/structured_binding_move_ctor.rs | 3 +-- tests/unit/out/unsafe/swap_map_no_copy.rs | 6 ++---- tests/unit/out/unsafe/unboxed_locals.rs | 3 +-- 71 files changed, 148 insertions(+), 329 deletions(-) diff --git a/cpp2rust/converter/converter.cpp b/cpp2rust/converter/converter.cpp index 30dddb7e42..2ed2423e07 100644 --- a/cpp2rust/converter/converter.cpp +++ b/cpp2rust/converter/converter.cpp @@ -5252,9 +5252,6 @@ Converter::GetStructAttributes(const clang::RecordDecl *decl) { if (decl->isUnion()) { std::vector union_attrs = { "Copy", "Clone", "FnPtrArg", "VaArg", "ZeroInitializationUnsafe"}; - if (!RecordDerivesTriviallyCopyable(decl)) { - union_attrs.emplace_back("DestructibleUnsafe"); - } AddSpecialMemberDerives(decl, union_attrs); return union_attrs; } @@ -5279,11 +5276,6 @@ Converter::GetStructAttributes(const clang::RecordDecl *decl) { struct_attrs.emplace_back("CppFromUnsafe"); } - if (!ImplementsRecordTrait(decl, kDestructible) && - !RecordDerivesTriviallyCopyable(decl)) { - struct_attrs.emplace_back("DestructibleUnsafe"); - } - AddSpecialMemberDerives(decl, struct_attrs); if (RecordDerivesDefault(decl)) { @@ -5819,9 +5811,16 @@ void Converter::AddSpecialMemberDerives(const clang::RecordDecl *decl, provided_trait->refcount.name); } }; - if (!implements(&kDefaultConstructible) && - !GetConvertedDefaultConstructor(decl)) { + bool derives_default = !implements(&kDefaultConstructible) && + !GetConvertedDefaultConstructor(decl); + bool derives_destructible = + !implements(&kDestructible) && !RecordDerivesTriviallyCopyable(decl); + if (derives_default && derives_destructible) { + attrs.emplace_back(GetCopyOrMoveTraitName(kDefaultInitializable)); + } else if (derives_default) { attrs.emplace_back(GetCopyOrMoveTraitName(kDefaultConstructible)); + } else if (derives_destructible) { + attrs.emplace_back(GetCopyOrMoveTraitName(kDestructible)); } if (!GetDerivedCopyOrMoves(decl).empty()) { attrs.emplace_back(GetCopyOrMoveTraitName(kMemberwise)); diff --git a/cpp2rust/converter/converter_lib.h b/cpp2rust/converter/converter_lib.h index 6627ee8cec..3070aad2ce 100644 --- a/cpp2rust/converter/converter_lib.h +++ b/cpp2rust/converter/converter_lib.h @@ -158,6 +158,8 @@ inline constexpr RecordTrait kDestructible{ "destroy", {"Destructible", "fn destroy(this: &Ptr)", "this"}, {"DestructibleUnsafe", "unsafe fn destroy(&mut self)", "&mut *self"}}; +inline constexpr RecordTrait kDefaultInitializable{ + nullptr, {"DefaultInitializable"}, {"DefaultInitializableUnsafe"}}; inline constexpr RecordTrait kMovable{nullptr, {"Movable"}, {"MovableUnsafe"}}; inline constexpr RecordTrait kCopyable{ nullptr, {"Copyable"}, {"CopyableUnsafe"}}; diff --git a/cpp2rust/converter/models/converter_refcount.cpp b/cpp2rust/converter/models/converter_refcount.cpp index 2e063fc4c2..f5b59f4463 100644 --- a/cpp2rust/converter/models/converter_refcount.cpp +++ b/cpp2rust/converter/models/converter_refcount.cpp @@ -2357,9 +2357,6 @@ ConverterRefCount::GetStructAttributes(const clang::RecordDecl *decl) { if (decl->isUnion()) { std::vector union_attrs = {"VaArg", "FnPtrArg"}; - if (!RecordDerivesTriviallyCopyable(decl)) { - union_attrs.emplace_back("Destructible"); - } AddSpecialMemberDerives(decl, union_attrs); return union_attrs; } @@ -2387,11 +2384,6 @@ ConverterRefCount::GetStructAttributes(const clang::RecordDecl *decl) { attrs.emplace_back("CppFrom"); } - if (!ImplementsRecordTrait(decl, kDestructible) && - !RecordDerivesTriviallyCopyable(decl)) { - attrs.emplace_back("Destructible"); - } - AddSpecialMemberDerives(decl, attrs); if (RecordDerivesDefault(decl)) { diff --git a/libcc2rs-macros/src/lib.rs b/libcc2rs-macros/src/lib.rs index 9312c8ff6c..54d6f3f462 100644 --- a/libcc2rs-macros/src/lib.rs +++ b/libcc2rs-macros/src/lib.rs @@ -293,6 +293,20 @@ pub fn derive_memberwise_unsafe(input: TokenStream) -> TokenStream { // Implements the C++ implicit destructor of S, which destroys the fields with a // destroy attribute, in reverse declaration order. +#[proc_macro_derive(DefaultInitializable, attributes(destroy))] +pub fn derive_default_initializable(input: TokenStream) -> TokenStream { + let mut impls = constructor::expand_default_constructible(input.clone(), false); + impls.extend(destructor::expand(input, false)); + impls +} + +#[proc_macro_derive(DefaultInitializableUnsafe, attributes(destroy))] +pub fn derive_default_initializable_unsafe(input: TokenStream) -> TokenStream { + let mut impls = constructor::expand_default_constructible(input.clone(), true); + impls.extend(destructor::expand(input, true)); + impls +} + #[proc_macro_derive(Destructible, attributes(destroy))] pub fn derive_destructible(input: TokenStream) -> TokenStream { destructor::expand(input, false) diff --git a/libcc2rs/src/lib.rs b/libcc2rs/src/lib.rs index 28e1d43f95..0911f7e8a3 100644 --- a/libcc2rs/src/lib.rs +++ b/libcc2rs/src/lib.rs @@ -123,9 +123,9 @@ pub use format::*; pub use libcc2rs_macros::{ ByteRepr, CopyAssignable, CopyAssignableUnsafe, CopyConstructible, CopyConstructibleUnsafe, Copyable, CopyableUnsafe, CppFrom, CppFromUnsafe, DefaultConstructible, - DefaultConstructibleUnsafe, Destructible, DestructibleUnsafe, FnPtrArg, Memberwise, - MemberwiseUnsafe, Movable, MovableUnsafe, MoveAssignable, MoveAssignableUnsafe, - MoveConstructible, MoveConstructibleUnsafe, Record, Swappable, SwappableUnsafe, - TriviallyCopyable, TriviallyCopyableUnsafe, VaArg, ZeroInitialization, - ZeroInitializationUnsafe, goto, goto_block, lambda, lambda_unsafe, switch, + DefaultConstructibleUnsafe, DefaultInitializable, DefaultInitializableUnsafe, Destructible, + DestructibleUnsafe, FnPtrArg, Memberwise, MemberwiseUnsafe, Movable, MovableUnsafe, + MoveAssignable, MoveAssignableUnsafe, MoveConstructible, MoveConstructibleUnsafe, Record, + Swappable, SwappableUnsafe, TriviallyCopyable, TriviallyCopyableUnsafe, VaArg, + ZeroInitialization, ZeroInitializationUnsafe, goto, goto_block, lambda, lambda_unsafe, switch, }; 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 6da759e41e..8862c1b4e3 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 @@ -12,8 +12,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, FnPtrArg, CppFrom, - Destructible, - DefaultConstructible, + DefaultInitializable, Memberwise, 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 21fba8bfee..dab76eb690 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 @@ -11,8 +11,7 @@ use std::rc::Rc; FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, MemberwiseUnsafe, SwappableUnsafe, Default, 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 845b4334c8..584088ddac 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 @@ -25,9 +25,7 @@ pub struct S { #[offset(0)] pub v: i32, } -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, DefaultConstructible, Default, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Default)] #[byte_size(4)] pub struct M { #[offset(0)] @@ -44,8 +42,7 @@ pub trait Base { ZeroInitialization, VaArg, FnPtrArg, - Destructible, - DefaultConstructible, + DefaultInitializable, Copyable, Default, )] 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 2add483e0e..f9911d1acf 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 @@ -28,9 +28,7 @@ impl S { } } #[repr(C)] -#[derive( - FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, DefaultConstructibleUnsafe, Default, -)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, Default)] pub struct M { pub v: i32, } @@ -45,8 +43,7 @@ pub unsafe trait Base { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, CopyableUnsafe, Default, )] 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 922dd393ca..3c2b8e7c58 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 @@ -37,8 +37,7 @@ impl Destructible for Tracker { ZeroInitialization, VaArg, FnPtrArg, - Destructible, - DefaultConstructible, + DefaultInitializable, Memberwise, CopyConstructible, MoveConstructible, 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 ccc34b8bbb..157a19feba 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 @@ -42,8 +42,7 @@ impl DestructibleUnsafe for Tracker { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MoveConstructibleUnsafe, diff --git a/tests/std/basic/out/refcount/basic.def.odr.rs b/tests/std/basic/out/refcount/basic.def.odr.rs index 7254902f74..1e9576d87b 100644 --- a/tests/std/basic/out/refcount/basic.def.odr.rs +++ b/tests/std/basic/out/refcount/basic.def.odr.rs @@ -16,8 +16,7 @@ thread_local!( VaArg, FnPtrArg, CppFrom, - Destructible, - DefaultConstructible, + DefaultInitializable, Memberwise, Movable, Default, @@ -268,8 +267,7 @@ pub trait p4_1_pure_virtual_without_definition_HasPureVirtual { ZeroInitialization, VaArg, FnPtrArg, - Destructible, - DefaultConstructible, + DefaultInitializable, Copyable, Default, )] @@ -393,8 +391,7 @@ thread_local!( VaArg, FnPtrArg, CppFrom, - Destructible, - DefaultConstructible, + DefaultInitializable, Memberwise, Movable, Default, diff --git a/tests/std/basic/out/unsafe/basic.def.odr.rs b/tests/std/basic/out/unsafe/basic.def.odr.rs index f5447ded36..686c763bae 100644 --- a/tests/std/basic/out/unsafe/basic.def.odr.rs +++ b/tests/std/basic/out/unsafe/basic.def.odr.rs @@ -13,8 +13,7 @@ pub static mut copyCount_0: std::cell::LazyCell = std::cell::LazyCell::new( FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, MemberwiseUnsafe, MovableUnsafe, Default, @@ -230,8 +229,7 @@ pub unsafe trait p4_1_pure_virtual_without_definition_HasPureVirtual { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, CopyableUnsafe, Default, )] @@ -354,8 +352,7 @@ pub static mut copies_18: std::cell::LazyCell = std::cell::LazyCell::new(|| FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, MemberwiseUnsafe, MovableUnsafe, Default, 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 5b8fe3a3cd..a2968b2631 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 @@ -12,8 +12,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, FnPtrArg, CppFrom, - Destructible, - DefaultConstructible, + DefaultInitializable, Memberwise, Default, )] 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 722b42639b..46bb3a153f 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 @@ -11,8 +11,7 @@ use std::rc::Rc; FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, MemberwiseUnsafe, Default, )] diff --git a/tests/std/utilities/utility/out/refcount/forward-helpers.rs b/tests/std/utilities/utility/out/refcount/forward-helpers.rs index 5a708cc6e5..8bb5c3e63c 100644 --- a/tests/std/utilities/utility/out/refcount/forward-helpers.rs +++ b/tests/std/utilities/utility/out/refcount/forward-helpers.rs @@ -21,8 +21,7 @@ pub fn test_0() { VaArg, FnPtrArg, CppFrom, - Destructible, - DefaultConstructible, + DefaultInitializable, CopyAssignable, MoveAssignable, Swappable, @@ -118,14 +117,7 @@ pub fn test_3() { assert!(({ (*moved.borrow()).value } == 1) && ({ (*holder.borrow()).member.value } == 0)); } #[derive( - Record, - ByteRepr, - ZeroInitialization, - FnPtrArg, - CppFrom, - Destructible, - DefaultConstructible, - Default, + Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, DefaultInitializable, Default, )] #[cpp_from(i32, construct, value)] #[byte_size(4)] @@ -184,8 +176,7 @@ pub fn test_4() { VaArg, FnPtrArg, CppFrom, - Destructible, - DefaultConstructible, + DefaultInitializable, CopyAssignable, MoveAssignable, Swappable, @@ -270,8 +261,7 @@ pub fn test_7() { VaArg, FnPtrArg, CppFrom, - Destructible, - DefaultConstructible, + DefaultInitializable, CopyAssignable, MoveAssignable, Swappable, @@ -314,8 +304,7 @@ impl Clone for p11_move_if_noexcept_NoexceptMove { VaArg, FnPtrArg, CppFrom, - Destructible, - DefaultConstructible, + DefaultInitializable, CopyAssignable, MoveAssignable, Swappable, diff --git a/tests/std/utilities/utility/out/refcount/forward.rs b/tests/std/utilities/utility/out/refcount/forward.rs index 3f331f64c6..37681ee26e 100644 --- a/tests/std/utilities/utility/out/refcount/forward.rs +++ b/tests/std/utilities/utility/out/refcount/forward.rs @@ -56,14 +56,7 @@ pub fn test_1() { assert!((element.x == 5) && (element.y == 6)); } #[derive( - Record, - ByteRepr, - ZeroInitialization, - FnPtrArg, - CppFrom, - Destructible, - DefaultConstructible, - Default, + Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, DefaultInitializable, Default, )] #[cpp_from(i32, construct, value)] #[byte_size(4)] diff --git a/tests/std/utilities/utility/out/unsafe/forward-helpers.rs b/tests/std/utilities/utility/out/unsafe/forward-helpers.rs index 6452e83914..9c200a3363 100644 --- a/tests/std/utilities/utility/out/unsafe/forward-helpers.rs +++ b/tests/std/utilities/utility/out/unsafe/forward-helpers.rs @@ -20,8 +20,7 @@ pub unsafe fn test_0() { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -113,12 +112,7 @@ pub unsafe fn test_3() { } #[repr(C)] #[derive( - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, - Default, + FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DefaultInitializableUnsafe, Default, )] #[cpp_from(i32, construct, value)] pub struct p9_move_Movable { @@ -176,8 +170,7 @@ pub unsafe fn test_4() { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -253,8 +246,7 @@ pub unsafe fn test_7() { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -299,8 +291,7 @@ impl Clone for p11_move_if_noexcept_NoexceptMove { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, diff --git a/tests/std/utilities/utility/out/unsafe/forward.rs b/tests/std/utilities/utility/out/unsafe/forward.rs index 5741c6cf70..7b4cc6568a 100644 --- a/tests/std/utilities/utility/out/unsafe/forward.rs +++ b/tests/std/utilities/utility/out/unsafe/forward.rs @@ -53,12 +53,7 @@ pub unsafe fn test_1() { } #[repr(C)] #[derive( - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, - Default, + FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DefaultInitializableUnsafe, Default, )] #[cpp_from(i32, construct, value)] pub struct p10_move_constructor_A { diff --git a/tests/unit/out/refcount/container_element_receiver.rs b/tests/unit/out/refcount/container_element_receiver.rs index 0c10054ba6..77daa6419f 100644 --- a/tests/unit/out/refcount/container_element_receiver.rs +++ b/tests/unit/out/refcount/container_element_receiver.rs @@ -13,8 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Destructible, - DefaultConstructible, + DefaultInitializable, Memberwise, CopyConstructible, CopyAssignable, diff --git a/tests/unit/out/refcount/copy_assign.rs b/tests/unit/out/refcount/copy_assign.rs index 6acca04f8f..47f52d2a2d 100644 --- a/tests/unit/out/refcount/copy_assign.rs +++ b/tests/unit/out/refcount/copy_assign.rs @@ -10,15 +10,7 @@ thread_local!( pub static assigns_0: Value = Rc::new(RefCell::new(0)); ); #[derive( - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - Destructible, - DefaultConstructible, - Movable, - Default, + Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, DefaultInitializable, Movable, Default, )] #[byte_size(8)] pub struct Partial { @@ -125,8 +117,7 @@ impl Default for RefQualified { ZeroInitialization, VaArg, FnPtrArg, - Destructible, - DefaultConstructible, + DefaultInitializable, Memberwise, MoveConstructible, Swappable, @@ -164,8 +155,7 @@ thread_local!( VaArg, FnPtrArg, CppFrom, - Destructible, - DefaultConstructible, + DefaultInitializable, Memberwise, Movable, Default, @@ -198,8 +188,7 @@ impl Clone for CopyCounted { ZeroInitialization, VaArg, FnPtrArg, - Destructible, - DefaultConstructible, + DefaultInitializable, Memberwise, MoveConstructible, Swappable, diff --git a/tests/unit/out/refcount/copy_ctor.rs b/tests/unit/out/refcount/copy_ctor.rs index 717a7b0e90..6552133f34 100644 --- a/tests/unit/out/refcount/copy_ctor.rs +++ b/tests/unit/out/refcount/copy_ctor.rs @@ -16,8 +16,7 @@ thread_local!( VaArg, FnPtrArg, CppFrom, - Destructible, - DefaultConstructible, + DefaultInitializable, Memberwise, Movable, Default, @@ -93,8 +92,7 @@ impl Default for NonConst { VaArg, FnPtrArg, CppFrom, - Destructible, - DefaultConstructible, + DefaultInitializable, Memberwise, Movable, Default, @@ -127,8 +125,7 @@ impl Clone for Ignored { ZeroInitialization, VaArg, FnPtrArg, - Destructible, - DefaultConstructible, + DefaultInitializable, Memberwise, MoveConstructible, Swappable, @@ -163,8 +160,7 @@ impl Default for Holder { VaArg, FnPtrArg, CppFrom, - Destructible, - DefaultConstructible, + DefaultInitializable, Memberwise, CopyAssignable, MoveAssignable, @@ -200,8 +196,7 @@ impl Clone for Box_int_ { ZeroInitialization, VaArg, FnPtrArg, - Destructible, - DefaultConstructible, + DefaultInitializable, Memberwise, CopyAssignable, MoveAssignable, @@ -222,8 +217,7 @@ pub struct Owner { VaArg, FnPtrArg, CppFrom, - Destructible, - DefaultConstructible, + DefaultInitializable, Memberwise, Movable, Default, diff --git a/tests/unit/out/refcount/copy_move_defaulted.rs b/tests/unit/out/refcount/copy_move_defaulted.rs index 4073b9a5af..7d15a2f898 100644 --- a/tests/unit/out/refcount/copy_move_defaulted.rs +++ b/tests/unit/out/refcount/copy_move_defaulted.rs @@ -96,8 +96,7 @@ impl Default for Implicit { VaArg, FnPtrArg, CppFrom, - Destructible, - DefaultConstructible, + DefaultInitializable, Memberwise, CopyConstructible, Swappable, @@ -130,8 +129,7 @@ impl MoveAssignable for DefaultCopyUserMove { VaArg, FnPtrArg, CppFrom, - Destructible, - DefaultConstructible, + DefaultInitializable, Memberwise, Swappable, Default, @@ -170,8 +168,7 @@ impl Clone for UserCopyDefaultMove { ZeroInitialization, FnPtrArg, CppFrom, - Destructible, - DefaultConstructible, + DefaultInitializable, Memberwise, Swappable, )] @@ -265,8 +262,7 @@ impl DefaultConstructible for Copyable { ZeroInitialization, FnPtrArg, CppFrom, - Destructible, - DefaultConstructible, + DefaultInitializable, Memberwise, Swappable, Default, diff --git a/tests/unit/out/refcount/copy_move_deleted.rs b/tests/unit/out/refcount/copy_move_deleted.rs index 9bfb0215fb..a2c9f2063b 100644 --- a/tests/unit/out/refcount/copy_move_deleted.rs +++ b/tests/unit/out/refcount/copy_move_deleted.rs @@ -12,8 +12,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, FnPtrArg, CppFrom, - Destructible, - DefaultConstructible, + DefaultInitializable, Swappable, Default, )] @@ -98,8 +97,7 @@ impl Default for Immovable { ByteRepr, ZeroInitialization, FnPtrArg, - Destructible, - DefaultConstructible, + DefaultInitializable, Memberwise, Swappable, Default, diff --git a/tests/unit/out/refcount/fn_ptr_struct.rs b/tests/unit/out/refcount/fn_ptr_struct.rs index a677ca0d15..cdf1ec760c 100644 --- a/tests/unit/out/refcount/fn_ptr_struct.rs +++ b/tests/unit/out/refcount/fn_ptr_struct.rs @@ -59,14 +59,7 @@ impl S { } } #[derive( - Record, - ByteRepr, - ZeroInitialization, - FnPtrArg, - CppFrom, - Destructible, - DefaultConstructible, - Default, + Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, DefaultInitializable, Default, )] #[cpp_from(i32, construct, value)] #[byte_size(4)] diff --git a/tests/unit/out/refcount/forward_basic.rs b/tests/unit/out/refcount/forward_basic.rs index 5f7c92379d..63950f5e66 100644 --- a/tests/unit/out/refcount/forward_basic.rs +++ b/tests/unit/out/refcount/forward_basic.rs @@ -16,8 +16,7 @@ pub const Overload_kRvalueOverload: Overload = 2; VaArg, FnPtrArg, CppFrom, - Destructible, - DefaultConstructible, + DefaultInitializable, CopyAssignable, MoveAssignable, Swappable, @@ -74,8 +73,7 @@ pub fn chosen_overload_1(_a0: Ptr) -> Overload { VaArg, FnPtrArg, CppFrom, - Destructible, - DefaultConstructible, + DefaultInitializable, Memberwise, CopyAssignable, MoveAssignable, diff --git a/tests/unit/out/refcount/forward_decltype.rs b/tests/unit/out/refcount/forward_decltype.rs index 5dcc88106c..7b95593c29 100644 --- a/tests/unit/out/refcount/forward_decltype.rs +++ b/tests/unit/out/refcount/forward_decltype.rs @@ -16,8 +16,7 @@ pub const Overload_kRvalueOverload: Overload = 2; VaArg, FnPtrArg, CppFrom, - Destructible, - DefaultConstructible, + DefaultInitializable, CopyAssignable, MoveAssignable, Swappable, diff --git a/tests/unit/out/refcount/forward_explicit.rs b/tests/unit/out/refcount/forward_explicit.rs index 65611bf290..e0edf48c4c 100644 --- a/tests/unit/out/refcount/forward_explicit.rs +++ b/tests/unit/out/refcount/forward_explicit.rs @@ -18,8 +18,7 @@ pub const Overload_kIntRvalueOverload: Overload = 4; VaArg, FnPtrArg, CppFrom, - Destructible, - DefaultConstructible, + DefaultInitializable, CopyAssignable, MoveAssignable, Swappable, diff --git a/tests/unit/out/refcount/forward_pack.rs b/tests/unit/out/refcount/forward_pack.rs index bc4f10db30..b651ba2883 100644 --- a/tests/unit/out/refcount/forward_pack.rs +++ b/tests/unit/out/refcount/forward_pack.rs @@ -18,8 +18,7 @@ pub const Overload_kIntRvalueOverload: Overload = 4; VaArg, FnPtrArg, CppFrom, - Destructible, - DefaultConstructible, + DefaultInitializable, CopyAssignable, MoveAssignable, Swappable, @@ -117,8 +116,7 @@ pub fn forward_pack_7( ZeroInitialization, VaArg, FnPtrArg, - Destructible, - DefaultConstructible, + DefaultInitializable, Memberwise, CopyAssignable, MoveAssignable, diff --git a/tests/unit/out/refcount/lambda_as_field.rs b/tests/unit/out/refcount/lambda_as_field.rs index 9cce0c8b54..363ef059d5 100644 --- a/tests/unit/out/refcount/lambda_as_field.rs +++ b/tests/unit/out/refcount/lambda_as_field.rs @@ -107,9 +107,7 @@ pub struct Holder__lambda_at_lambda_as_field_cpp_51_12__ { #[offset(4)] pub calls: i32, } -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, Destructible, DefaultConstructible, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, DefaultInitializable)] #[cpp_from(FnPtr i32 > , construct, value)] #[byte_size(8)] pub struct Moving__lambda_at_lambda_as_field_cpp_64_12__ { diff --git a/tests/unit/out/refcount/map_key_copy_ctor.rs b/tests/unit/out/refcount/map_key_copy_ctor.rs index 2b01d56ed8..89b7350153 100644 --- a/tests/unit/out/refcount/map_key_copy_ctor.rs +++ b/tests/unit/out/refcount/map_key_copy_ctor.rs @@ -22,8 +22,7 @@ thread_local!( VaArg, FnPtrArg, CppFrom, - Destructible, - DefaultConstructible, + DefaultInitializable, CopyAssignable, MoveAssignable, Swappable, diff --git a/tests/unit/out/refcount/max.rs b/tests/unit/out/refcount/max.rs index 830c407178..e8ce33d371 100644 --- a/tests/unit/out/refcount/max.rs +++ b/tests/unit/out/refcount/max.rs @@ -27,8 +27,7 @@ pub fn pick_3(mut i: i32) -> Ptr { VaArg, FnPtrArg, CppFrom, - Destructible, - DefaultConstructible, + DefaultInitializable, Memberwise, Movable, Default, diff --git a/tests/unit/out/refcount/move_assign.rs b/tests/unit/out/refcount/move_assign.rs index dd2eb41520..f7f5ad0e73 100644 --- a/tests/unit/out/refcount/move_assign.rs +++ b/tests/unit/out/refcount/move_assign.rs @@ -12,8 +12,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, FnPtrArg, CppFrom, - Destructible, - DefaultConstructible, + DefaultInitializable, Swappable, Default, )] diff --git a/tests/unit/out/refcount/move_ctor.rs b/tests/unit/out/refcount/move_ctor.rs index c0c4196664..f939859150 100644 --- a/tests/unit/out/refcount/move_ctor.rs +++ b/tests/unit/out/refcount/move_ctor.rs @@ -7,14 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - Record, - ByteRepr, - ZeroInitialization, - FnPtrArg, - CppFrom, - Destructible, - DefaultConstructible, - Default, + Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, DefaultInitializable, Default, )] #[cpp_from(i32, construct, value)] #[byte_size(4)] @@ -57,8 +50,7 @@ impl Default for ConstMove { VaArg, FnPtrArg, CppFrom, - Destructible, - DefaultConstructible, + DefaultInitializable, CopyAssignable, MoveAssignable, Swappable, @@ -108,8 +100,7 @@ impl Clone for ThrowingMove { VaArg, FnPtrArg, CppFrom, - Destructible, - DefaultConstructible, + DefaultInitializable, CopyAssignable, MoveAssignable, Swappable, diff --git a/tests/unit/out/refcount/move_this.rs b/tests/unit/out/refcount/move_this.rs index 968d5f3b03..c246783611 100644 --- a/tests/unit/out/refcount/move_this.rs +++ b/tests/unit/out/refcount/move_this.rs @@ -13,8 +13,7 @@ use std::rc::{Rc, Weak}; VaArg, FnPtrArg, CppFrom, - Destructible, - DefaultConstructible, + DefaultInitializable, CopyAssignable, MoveAssignable, Swappable, diff --git a/tests/unit/out/refcount/operator_comparison_nonbool.rs b/tests/unit/out/refcount/operator_comparison_nonbool.rs index 252bfced35..de9f03fdfd 100644 --- a/tests/unit/out/refcount/operator_comparison_nonbool.rs +++ b/tests/unit/out/refcount/operator_comparison_nonbool.rs @@ -184,14 +184,7 @@ pub fn operator_lt_6(mut a: Boolish, mut b: Boolish) -> MyBool { }; } #[derive( - Record, - ByteRepr, - ZeroInitialization, - FnPtrArg, - CppFrom, - Destructible, - DefaultConstructible, - Default, + Record, ByteRepr, ZeroInitialization, FnPtrArg, CppFrom, DefaultInitializable, Default, )] #[cpp_into(bool, to_bool)] #[byte_size(1)] diff --git a/tests/unit/out/refcount/operator_comparison_noncopyable.rs b/tests/unit/out/refcount/operator_comparison_noncopyable.rs index 7e72a50725..ea58048756 100644 --- a/tests/unit/out/refcount/operator_comparison_noncopyable.rs +++ b/tests/unit/out/refcount/operator_comparison_noncopyable.rs @@ -18,8 +18,7 @@ pub fn operator_lt_1(x: Ptr, y: Ptr) -> bool { ZeroInitialization, FnPtrArg, CppFrom, - Destructible, - DefaultConstructible, + DefaultInitializable, Memberwise, Default, )] diff --git a/tests/unit/out/refcount/polymorphism.rs b/tests/unit/out/refcount/polymorphism.rs index 1279cef6a2..574e7324d3 100644 --- a/tests/unit/out/refcount/polymorphism.rs +++ b/tests/unit/out/refcount/polymorphism.rs @@ -17,8 +17,7 @@ pub trait Animal { ZeroInitialization, VaArg, FnPtrArg, - Destructible, - DefaultConstructible, + DefaultInitializable, Copyable, Default, )] @@ -32,8 +31,7 @@ pub struct Dog {} ZeroInitialization, VaArg, FnPtrArg, - Destructible, - DefaultConstructible, + DefaultInitializable, Copyable, Default, )] diff --git a/tests/unit/out/refcount/rvalue_rule_arg_move.rs b/tests/unit/out/refcount/rvalue_rule_arg_move.rs index 51d10c8c5c..fe70068985 100644 --- a/tests/unit/out/refcount/rvalue_rule_arg_move.rs +++ b/tests/unit/out/refcount/rvalue_rule_arg_move.rs @@ -19,8 +19,7 @@ thread_local!( VaArg, FnPtrArg, CppFrom, - Destructible, - DefaultConstructible, + DefaultInitializable, Memberwise, Swappable, Default, diff --git a/tests/unit/out/refcount/sort_no_copy.rs b/tests/unit/out/refcount/sort_no_copy.rs index 583bc6aa86..60aa598e64 100644 --- a/tests/unit/out/refcount/sort_no_copy.rs +++ b/tests/unit/out/refcount/sort_no_copy.rs @@ -89,8 +89,7 @@ pub fn greater_2(a: Ptr, b: Ptr) -> bool { ZeroInitialization, FnPtrArg, CppFrom, - Destructible, - DefaultConstructible, + DefaultInitializable, Memberwise, Swappable, Default, diff --git a/tests/unit/out/refcount/structured_binding_copy_ctor.rs b/tests/unit/out/refcount/structured_binding_copy_ctor.rs index 5b3372a993..c9adaff061 100644 --- a/tests/unit/out/refcount/structured_binding_copy_ctor.rs +++ b/tests/unit/out/refcount/structured_binding_copy_ctor.rs @@ -15,8 +15,7 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Destructible, - DefaultConstructible, + DefaultInitializable, Memberwise, Movable, Default, diff --git a/tests/unit/out/refcount/structured_binding_element_ctor.rs b/tests/unit/out/refcount/structured_binding_element_ctor.rs index 728a39fb63..a4fafef0d9 100644 --- a/tests/unit/out/refcount/structured_binding_element_ctor.rs +++ b/tests/unit/out/refcount/structured_binding_element_ctor.rs @@ -19,8 +19,7 @@ thread_local!( VaArg, FnPtrArg, CppFrom, - Destructible, - DefaultConstructible, + DefaultInitializable, CopyAssignable, MoveAssignable, Swappable, @@ -60,8 +59,7 @@ impl Clone for Elem { ZeroInitialization, VaArg, FnPtrArg, - Destructible, - DefaultConstructible, + DefaultInitializable, Memberwise, 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 0ba68fc81a..11c44c8f16 100644 --- a/tests/unit/out/refcount/structured_binding_move_ctor.rs +++ b/tests/unit/out/refcount/structured_binding_move_ctor.rs @@ -18,8 +18,7 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Destructible, - DefaultConstructible, + DefaultInitializable, CopyAssignable, MoveAssignable, Swappable, diff --git a/tests/unit/out/refcount/swap_map_no_copy.rs b/tests/unit/out/refcount/swap_map_no_copy.rs index 89105bcc98..eca380789a 100644 --- a/tests/unit/out/refcount/swap_map_no_copy.rs +++ b/tests/unit/out/refcount/swap_map_no_copy.rs @@ -201,8 +201,7 @@ impl Clone for CopyOnly { ZeroInitialization, VaArg, FnPtrArg, - Destructible, - DefaultConstructible, + DefaultInitializable, Memberwise, MoveConstructible, Swappable, @@ -294,8 +293,7 @@ impl Clone for Moved { ZeroInitialization, VaArg, FnPtrArg, - Destructible, - DefaultConstructible, + DefaultInitializable, Memberwise, Swappable, Default, diff --git a/tests/unit/out/refcount/unboxed_locals.rs b/tests/unit/out/refcount/unboxed_locals.rs index eb56995aa9..5cea4d85b8 100644 --- a/tests/unit/out/refcount/unboxed_locals.rs +++ b/tests/unit/out/refcount/unboxed_locals.rs @@ -74,8 +74,7 @@ pub trait Shape { ZeroInitialization, VaArg, FnPtrArg, - Destructible, - DefaultConstructible, + DefaultInitializable, Copyable, )] #[byte_size(16)] diff --git a/tests/unit/out/unsafe/container_element_receiver.rs b/tests/unit/out/unsafe/container_element_receiver.rs index 12d3ee6ee9..257c22fb8f 100644 --- a/tests/unit/out/unsafe/container_element_receiver.rs +++ b/tests/unit/out/unsafe/container_element_receiver.rs @@ -12,8 +12,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, CopyAssignableUnsafe, diff --git a/tests/unit/out/unsafe/copy_assign.rs b/tests/unit/out/unsafe/copy_assign.rs index ba4e43a606..3e580b961b 100644 --- a/tests/unit/out/unsafe/copy_assign.rs +++ b/tests/unit/out/unsafe/copy_assign.rs @@ -9,13 +9,7 @@ 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, - DefaultConstructibleUnsafe, - MovableUnsafe, - Default, + VaArg, FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, MovableUnsafe, Default, )] pub struct Partial { pub v: i32, @@ -127,8 +121,7 @@ impl Default for RefQualified { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, MemberwiseUnsafe, MoveConstructibleUnsafe, SwappableUnsafe, @@ -146,8 +139,7 @@ pub static mut copies_1: std::cell::LazyCell = std::cell::LazyCell::new(|| FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, MemberwiseUnsafe, MovableUnsafe, Default, @@ -183,8 +175,7 @@ impl Clone for CopyCounted { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, MemberwiseUnsafe, MoveConstructibleUnsafe, SwappableUnsafe, diff --git a/tests/unit/out/unsafe/copy_ctor.rs b/tests/unit/out/unsafe/copy_ctor.rs index 74f4b79ce9..34df69c218 100644 --- a/tests/unit/out/unsafe/copy_ctor.rs +++ b/tests/unit/out/unsafe/copy_ctor.rs @@ -13,8 +13,7 @@ pub static mut copies_0: std::cell::LazyCell = std::cell::LazyCell::new(|| FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, MemberwiseUnsafe, MovableUnsafe, Default, @@ -97,8 +96,7 @@ impl Default for NonConst { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, MemberwiseUnsafe, MovableUnsafe, Default, @@ -134,8 +132,7 @@ impl Clone for Ignored { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, MemberwiseUnsafe, MoveConstructibleUnsafe, SwappableUnsafe, @@ -152,8 +149,7 @@ pub struct Holder { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, MemberwiseUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, @@ -190,8 +186,7 @@ impl Clone for Box_int_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, MemberwiseUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, @@ -208,8 +203,7 @@ pub struct Owner { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, MemberwiseUnsafe, MovableUnsafe, Default, diff --git a/tests/unit/out/unsafe/copy_move_defaulted.rs b/tests/unit/out/unsafe/copy_move_defaulted.rs index b43b34703e..3941c2bcc6 100644 --- a/tests/unit/out/unsafe/copy_move_defaulted.rs +++ b/tests/unit/out/unsafe/copy_move_defaulted.rs @@ -77,8 +77,7 @@ pub struct Implicit { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, SwappableUnsafe, @@ -113,8 +112,7 @@ impl MoveAssignableUnsafe for DefaultCopyUserMove { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, MemberwiseUnsafe, SwappableUnsafe, Default, @@ -154,8 +152,7 @@ impl Clone for UserCopyDefaultMove { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, MemberwiseUnsafe, SwappableUnsafe, Default, @@ -230,8 +227,7 @@ impl DefaultConstructibleUnsafe for Copyable { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, MemberwiseUnsafe, SwappableUnsafe, Default, diff --git a/tests/unit/out/unsafe/copy_move_deleted.rs b/tests/unit/out/unsafe/copy_move_deleted.rs index b45396d9d2..7c292af683 100644 --- a/tests/unit/out/unsafe/copy_move_deleted.rs +++ b/tests/unit/out/unsafe/copy_move_deleted.rs @@ -11,8 +11,7 @@ use std::rc::Rc; FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, SwappableUnsafe, Default, )] @@ -97,8 +96,7 @@ impl Default for Immovable { #[derive( FnPtrArg, ZeroInitializationUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, MemberwiseUnsafe, SwappableUnsafe, Default, diff --git a/tests/unit/out/unsafe/fn_ptr_struct.rs b/tests/unit/out/unsafe/fn_ptr_struct.rs index 6fba958a95..a937756047 100644 --- a/tests/unit/out/unsafe/fn_ptr_struct.rs +++ b/tests/unit/out/unsafe/fn_ptr_struct.rs @@ -54,12 +54,7 @@ impl S { } #[repr(C)] #[derive( - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, - Default, + FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DefaultInitializableUnsafe, Default, )] #[cpp_from(i32, construct, value)] pub struct MoveOnly { diff --git a/tests/unit/out/unsafe/forward_basic.rs b/tests/unit/out/unsafe/forward_basic.rs index 07a4bf7a7a..2c16f7c39a 100644 --- a/tests/unit/out/unsafe/forward_basic.rs +++ b/tests/unit/out/unsafe/forward_basic.rs @@ -15,8 +15,7 @@ pub const Overload_kRvalueOverload: Overload = 2; FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -82,8 +81,7 @@ impl Holder { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, MemberwiseUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, diff --git a/tests/unit/out/unsafe/forward_decltype.rs b/tests/unit/out/unsafe/forward_decltype.rs index ee8260cd19..cbd14e5e34 100644 --- a/tests/unit/out/unsafe/forward_decltype.rs +++ b/tests/unit/out/unsafe/forward_decltype.rs @@ -15,8 +15,7 @@ pub const Overload_kRvalueOverload: Overload = 2; FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, diff --git a/tests/unit/out/unsafe/forward_explicit.rs b/tests/unit/out/unsafe/forward_explicit.rs index 5a80d06188..743926faf8 100644 --- a/tests/unit/out/unsafe/forward_explicit.rs +++ b/tests/unit/out/unsafe/forward_explicit.rs @@ -17,8 +17,7 @@ pub const Overload_kIntRvalueOverload: Overload = 4; FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, diff --git a/tests/unit/out/unsafe/forward_pack.rs b/tests/unit/out/unsafe/forward_pack.rs index 850bdd73b1..24a1d3baf4 100644 --- a/tests/unit/out/unsafe/forward_pack.rs +++ b/tests/unit/out/unsafe/forward_pack.rs @@ -17,8 +17,7 @@ pub const Overload_kIntRvalueOverload: Overload = 4; FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -119,8 +118,7 @@ impl Pair { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, MemberwiseUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, diff --git a/tests/unit/out/unsafe/lambda_as_field.rs b/tests/unit/out/unsafe/lambda_as_field.rs index 474a168dc1..d7e738d69b 100644 --- a/tests/unit/out/unsafe/lambda_as_field.rs +++ b/tests/unit/out/unsafe/lambda_as_field.rs @@ -104,13 +104,7 @@ impl Holder__lambda_at_lambda_as_field_cpp_51_12__ { } } #[repr(C)] -#[derive( - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, -)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DefaultInitializableUnsafe)] #[cpp_from(FnPtr i32 > , construct, value)] pub struct Moving__lambda_at_lambda_as_field_cpp_64_12__ { pub f: FnPtr i32>, diff --git a/tests/unit/out/unsafe/map_key_copy_ctor.rs b/tests/unit/out/unsafe/map_key_copy_ctor.rs index 49aaf19d17..3b78d2c538 100644 --- a/tests/unit/out/unsafe/map_key_copy_ctor.rs +++ b/tests/unit/out/unsafe/map_key_copy_ctor.rs @@ -15,8 +15,7 @@ pub static mut made_2: std::cell::LazyCell = std::cell::LazyCell::new(|| un FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, diff --git a/tests/unit/out/unsafe/max.rs b/tests/unit/out/unsafe/max.rs index 7309c90eba..9946680f13 100644 --- a/tests/unit/out/unsafe/max.rs +++ b/tests/unit/out/unsafe/max.rs @@ -22,8 +22,7 @@ pub unsafe fn pick_3(mut i: i32) -> *mut i32 { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, MemberwiseUnsafe, MovableUnsafe, Default, diff --git a/tests/unit/out/unsafe/move_assign.rs b/tests/unit/out/unsafe/move_assign.rs index a4250a2b7f..5e254cd5e5 100644 --- a/tests/unit/out/unsafe/move_assign.rs +++ b/tests/unit/out/unsafe/move_assign.rs @@ -11,8 +11,7 @@ use std::rc::Rc; FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, SwappableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/move_ctor.rs b/tests/unit/out/unsafe/move_ctor.rs index 17c54e25ff..5e17dae306 100644 --- a/tests/unit/out/unsafe/move_ctor.rs +++ b/tests/unit/out/unsafe/move_ctor.rs @@ -8,12 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, - Default, + FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DefaultInitializableUnsafe, Default, )] #[cpp_from(i32, construct, value)] pub struct MoveOnly { @@ -65,8 +60,7 @@ impl Default for ConstMove { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -115,8 +109,7 @@ impl Clone for ThrowingMove { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, diff --git a/tests/unit/out/unsafe/move_this.rs b/tests/unit/out/unsafe/move_this.rs index 78dfd01396..5106bbda02 100644 --- a/tests/unit/out/unsafe/move_this.rs +++ b/tests/unit/out/unsafe/move_this.rs @@ -12,8 +12,7 @@ use std::rc::Rc; FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, diff --git a/tests/unit/out/unsafe/operator_comparison_nonbool.rs b/tests/unit/out/unsafe/operator_comparison_nonbool.rs index ec7886cfb4..5910a668e3 100644 --- a/tests/unit/out/unsafe/operator_comparison_nonbool.rs +++ b/tests/unit/out/unsafe/operator_comparison_nonbool.rs @@ -242,12 +242,7 @@ pub unsafe fn operator_lt_6(mut a: Boolish, mut b: Boolish) -> MyBool { } #[repr(C)] #[derive( - FnPtrArg, - ZeroInitializationUnsafe, - CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, - Default, + FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, DefaultInitializableUnsafe, Default, )] #[cpp_into(bool, to_bool)] pub struct RefBool { diff --git a/tests/unit/out/unsafe/operator_comparison_noncopyable.rs b/tests/unit/out/unsafe/operator_comparison_noncopyable.rs index 0b474f7b5a..32de47ce5c 100644 --- a/tests/unit/out/unsafe/operator_comparison_noncopyable.rs +++ b/tests/unit/out/unsafe/operator_comparison_noncopyable.rs @@ -17,8 +17,7 @@ pub unsafe fn operator_lt_1(x: *const S, y: *const S) -> bool { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, MemberwiseUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/polymorphism.rs b/tests/unit/out/unsafe/polymorphism.rs index 04b0374704..393fb634c0 100644 --- a/tests/unit/out/unsafe/polymorphism.rs +++ b/tests/unit/out/unsafe/polymorphism.rs @@ -16,8 +16,7 @@ pub unsafe trait Animal { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, CopyableUnsafe, Default, )] @@ -29,8 +28,7 @@ pub struct Dog {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, CopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/rvalue_rule_arg_move.rs b/tests/unit/out/unsafe/rvalue_rule_arg_move.rs index 52aa55c424..b44c23448b 100644 --- a/tests/unit/out/unsafe/rvalue_rule_arg_move.rs +++ b/tests/unit/out/unsafe/rvalue_rule_arg_move.rs @@ -14,8 +14,7 @@ pub static mut moves_1: std::cell::LazyCell = std::cell::LazyCell::new(|| u FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, MemberwiseUnsafe, SwappableUnsafe, Default, diff --git a/tests/unit/out/unsafe/sort_no_copy.rs b/tests/unit/out/unsafe/sort_no_copy.rs index 61857d53ed..a423be5afe 100644 --- a/tests/unit/out/unsafe/sort_no_copy.rs +++ b/tests/unit/out/unsafe/sort_no_copy.rs @@ -107,8 +107,7 @@ pub unsafe fn greater_2(a: *const Tracked, b: *const Tracked) -> bool { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, MemberwiseUnsafe, SwappableUnsafe, Default, diff --git a/tests/unit/out/unsafe/structured_binding_copy_ctor.rs b/tests/unit/out/unsafe/structured_binding_copy_ctor.rs index 485ba731e0..496c724b7e 100644 --- a/tests/unit/out/unsafe/structured_binding_copy_ctor.rs +++ b/tests/unit/out/unsafe/structured_binding_copy_ctor.rs @@ -12,8 +12,7 @@ pub static mut copies_0: std::cell::LazyCell = std::cell::LazyCell::new(|| VaArg, FnPtrArg, ZeroInitializationUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, MemberwiseUnsafe, MovableUnsafe, Default, diff --git a/tests/unit/out/unsafe/structured_binding_element_ctor.rs b/tests/unit/out/unsafe/structured_binding_element_ctor.rs index 9f0940098b..c47d0957ed 100644 --- a/tests/unit/out/unsafe/structured_binding_element_ctor.rs +++ b/tests/unit/out/unsafe/structured_binding_element_ctor.rs @@ -14,8 +14,7 @@ pub static mut moves_1: std::cell::LazyCell = std::cell::LazyCell::new(|| u FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, @@ -58,8 +57,7 @@ impl Clone for Elem { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, MemberwiseUnsafe, 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 da6697a90b..8d6f40f20d 100644 --- a/tests/unit/out/unsafe/structured_binding_move_ctor.rs +++ b/tests/unit/out/unsafe/structured_binding_move_ctor.rs @@ -13,8 +13,7 @@ pub static mut moves_1: std::cell::LazyCell = std::cell::LazyCell::new(|| u VaArg, FnPtrArg, ZeroInitializationUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, diff --git a/tests/unit/out/unsafe/swap_map_no_copy.rs b/tests/unit/out/unsafe/swap_map_no_copy.rs index 7cc8b7f550..429b098864 100644 --- a/tests/unit/out/unsafe/swap_map_no_copy.rs +++ b/tests/unit/out/unsafe/swap_map_no_copy.rs @@ -177,8 +177,7 @@ impl Clone for CopyOnly { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, MemberwiseUnsafe, MoveConstructibleUnsafe, SwappableUnsafe, @@ -261,8 +260,7 @@ impl Clone for Moved { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, MemberwiseUnsafe, SwappableUnsafe, Default, diff --git a/tests/unit/out/unsafe/unboxed_locals.rs b/tests/unit/out/unsafe/unboxed_locals.rs index 52ea049e2e..b4e4166f9c 100644 --- a/tests/unit/out/unsafe/unboxed_locals.rs +++ b/tests/unit/out/unsafe/unboxed_locals.rs @@ -67,8 +67,7 @@ pub unsafe trait Shape { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DestructibleUnsafe, - DefaultConstructibleUnsafe, + DefaultInitializableUnsafe, CopyableUnsafe, )] pub struct Square { From 92f3108fb5bdb3182d24c8f2facd7571686643ca Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Wed, 2 Dec 2026 14:07:48 +0000 Subject: [PATCH 12/13] Add TriviallyDefaultInitializable --- cpp2rust/converter/converter.cpp | 8 +++- cpp2rust/converter/converter_lib.cpp | 8 ++-- cpp2rust/converter/converter_lib.h | 4 ++ libcc2rs-macros/src/constructor.rs | 48 ++++++++-------------- libcc2rs-macros/src/lib.rs | 10 +++++ libcc2rs/src/constructor.rs | 60 +++++++++++++++++++--------- libcc2rs/src/lib.rs | 9 +++-- rules/dirent/shim.rs | 6 ++- rules/ifaddrs/shim.rs | 10 ++++- rules/ip/shim.rs | 14 +++++-- rules/netdb/shim.rs | 10 ++++- rules/poll/shim.rs | 10 ++++- rules/pwd/shim.rs | 10 ++++- rules/socket/shim.rs | 26 +++++++++--- rules/stat/shim.rs | 6 ++- rules/termios/shim.rs | 14 +++++-- rules/time/shim.rs | 26 ++++++++++-- 17 files changed, 190 insertions(+), 89 deletions(-) diff --git a/cpp2rust/converter/converter.cpp b/cpp2rust/converter/converter.cpp index 2ed2423e07..a24a19ee77 100644 --- a/cpp2rust/converter/converter.cpp +++ b/cpp2rust/converter/converter.cpp @@ -5811,7 +5811,13 @@ void Converter::AddSpecialMemberDerives(const clang::RecordDecl *decl, provided_trait->refcount.name); } }; - bool derives_default = !implements(&kDefaultConstructible) && + auto *cxx = clang::dyn_cast(decl); + bool trivial_default = !cxx || cxx->hasTrivialDefaultConstructor(); + if (trivial_default) { + attrs.emplace_back(GetCopyOrMoveTraitName(kTriviallyDefaultConstructible)); + } + bool derives_default = !trivial_default && + !implements(&kDefaultConstructible) && !GetConvertedDefaultConstructor(decl); bool derives_destructible = !implements(&kDestructible) && !RecordDerivesTriviallyCopyable(decl); diff --git a/cpp2rust/converter/converter_lib.cpp b/cpp2rust/converter/converter_lib.cpp index 50d9c1703f..49599ff6a1 100644 --- a/cpp2rust/converter/converter_lib.cpp +++ b/cpp2rust/converter/converter_lib.cpp @@ -609,13 +609,11 @@ static bool IsTranslatedCopyAssignment(const clang::CXXMethodDecl *method); static bool IsTranslatedMoveAssignment(const clang::CXXMethodDecl *method); -static bool IsConvertibleImplicitMemberParent(const clang::CXXRecordDecl *decl); - static bool IsTranslatedSpecialMember(const clang::CXXMethodDecl *method) { if (auto *ctor = clang::dyn_cast(method)) { if (ctor->isDefaultConstructor()) { - return !ctor->isUserProvided() && !ctor->getParent()->isUnion() && - IsConvertibleImplicitMemberParent(ctor->getParent()); + return !ctor->getParent()->isUnion() && + IsConvertibleDefaultConstructor(ctor); } return IsConvertibleCopyOrMoveConstructor(ctor); } @@ -667,7 +665,7 @@ const RecordTrait *GetRecordTrait(const clang::CXXMethodDecl *method) { bool IsDerivedCopyOrMove(const clang::CXXMethodDecl *method) { if (auto *ctor = clang::dyn_cast(method); - ctor && ctor->isDefaultConstructor() && !ctor->isTrivial()) { + ctor && ctor->isDefaultConstructor()) { return false; } return !method->isUserProvided() && GetRecordTrait(method); diff --git a/cpp2rust/converter/converter_lib.h b/cpp2rust/converter/converter_lib.h index 3070aad2ce..0632105b69 100644 --- a/cpp2rust/converter/converter_lib.h +++ b/cpp2rust/converter/converter_lib.h @@ -158,6 +158,10 @@ inline constexpr RecordTrait kDestructible{ "destroy", {"Destructible", "fn destroy(this: &Ptr)", "this"}, {"DestructibleUnsafe", "unsafe fn destroy(&mut self)", "&mut *self"}}; +inline constexpr RecordTrait kTriviallyDefaultConstructible{ + nullptr, + {"TriviallyDefaultConstructible"}, + {"TriviallyDefaultConstructibleUnsafe"}}; inline constexpr RecordTrait kDefaultInitializable{ nullptr, {"DefaultInitializable"}, {"DefaultInitializableUnsafe"}}; inline constexpr RecordTrait kMovable{nullptr, {"Movable"}, {"MovableUnsafe"}}; diff --git a/libcc2rs-macros/src/constructor.rs b/libcc2rs-macros/src/constructor.rs index 7e33660e37..5c438d0c37 100644 --- a/libcc2rs-macros/src/constructor.rs +++ b/libcc2rs-macros/src/constructor.rs @@ -32,6 +32,22 @@ pub fn expand_movable(input: TokenStream, is_unsafe: bool) -> TokenStream { quote!(#(#impls)* #swap).into() } +pub fn expand_trivially_default_constructible(input: TokenStream, is_unsafe: bool) -> TokenStream { + let mut impls = expand_default_constructible(input.clone(), is_unsafe); + 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 tr = if is_unsafe { + quote!(::libcc2rs::TriviallyDefaultConstructibleUnsafe) + } else { + quote!(::libcc2rs::TriviallyDefaultConstructible) + }; + let marker: TokenStream = + quote!(impl #impl_generics #tr for #name #ty_generics #where_clause {}).into(); + impls.extend(marker); + impls +} + pub fn expand_default_constructible(input: TokenStream, is_unsafe: bool) -> TokenStream { let input = parse_macro_input!(input as DeriveInput); let name = &input.ident; @@ -266,10 +282,6 @@ pub fn expand_memberwise(input: TokenStream, is_unsafe: bool) -> TokenStream { } let mut impls = Vec::new(); for method in methods { - if method == "default_constructor" { - impls.push(impl_memberwise_default(&input, is_unsafe)); - continue; - } let (op, is_assign) = match method.to_string().as_str() { "copy_constructor" => ("copy", false), "move_constructor" => ("move", false), @@ -286,34 +298,6 @@ pub fn expand_memberwise(input: TokenStream, is_unsafe: bool) -> TokenStream { quote!(#(#impls)*).into() } -fn impl_memberwise_default(input: &DeriveInput, is_unsafe: bool) -> TokenStream2 { - let syn::Data::Struct(data) = &input.data else { - return syn::Error::new_spanned(input, "memberwise derives need a struct") - .to_compile_error(); - }; - let members: Vec<_> = data.fields.members().collect(); - let name = &input.ident; - let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl(); - if is_unsafe { - let tr = quote!(::libcc2rs::DefaultConstructibleUnsafe); - return quote! { - impl #impl_generics #tr for #name #ty_generics #where_clause { - unsafe fn default_constructor(&mut self) { - #(unsafe { #tr::default_constructor(&mut self.#members) };)* - } - } - }; - } - let tr = quote!(::libcc2rs::DefaultConstructible); - quote! { - impl #impl_generics #tr for #name #ty_generics #where_clause { - fn default_constructor(this: &::libcc2rs::Ptr) { - #(#tr::default_constructor(&::libcc2rs::field_ptr!(this, #members));)* - } - } - } -} - fn impl_memberwise( input: &DeriveInput, op: &str, diff --git a/libcc2rs-macros/src/lib.rs b/libcc2rs-macros/src/lib.rs index 54d6f3f462..997db20c39 100644 --- a/libcc2rs-macros/src/lib.rs +++ b/libcc2rs-macros/src/lib.rs @@ -293,6 +293,16 @@ pub fn derive_memberwise_unsafe(input: TokenStream) -> TokenStream { // Implements the C++ implicit destructor of S, which destroys the fields with a // destroy attribute, in reverse declaration order. +#[proc_macro_derive(TriviallyDefaultConstructible)] +pub fn derive_trivially_default_constructible(input: TokenStream) -> TokenStream { + constructor::expand_trivially_default_constructible(input, false) +} + +#[proc_macro_derive(TriviallyDefaultConstructibleUnsafe)] +pub fn derive_trivially_default_constructible_unsafe(input: TokenStream) -> TokenStream { + constructor::expand_trivially_default_constructible(input, true) +} + #[proc_macro_derive(DefaultInitializable, attributes(destroy))] pub fn derive_default_initializable(input: TokenStream) -> TokenStream { let mut impls = constructor::expand_default_constructible(input.clone(), false); diff --git a/libcc2rs/src/constructor.rs b/libcc2rs/src/constructor.rs index 268ef497cb..2cd83f6811 100644 --- a/libcc2rs/src/constructor.rs +++ b/libcc2rs/src/constructor.rs @@ -56,6 +56,8 @@ pub trait Swappable: Sized { fn swap(this: &Ptr, other: Ptr); } +pub trait TriviallyDefaultConstructible: DefaultConstructible {} + pub trait DefaultInitializable: DefaultConstructible + Destructible {} impl DefaultInitializable for T {} @@ -151,6 +153,8 @@ pub trait SwappableUnsafe { unsafe fn swap(&mut self, other: *mut Self); } +pub trait TriviallyDefaultConstructibleUnsafe: DefaultConstructibleUnsafe {} + pub trait DefaultInitializableUnsafe: DefaultConstructibleUnsafe + DestructibleUnsafe {} impl DefaultInitializableUnsafe for T {} @@ -439,18 +443,33 @@ macro_rules! impl_move_by_take { } pub(crate) use impl_move_by_take; -macro_rules! impl_default_by_default { +macro_rules! impl_default_by_zeroed { + ($($ty:ty),* $(,)?) => {$( + impl $crate::DefaultConstructibleUnsafe for $ty { + unsafe fn default_constructor(&mut self) { + unsafe { std::ptr::write(self, std::mem::zeroed()) } + } + } + + impl $crate::TriviallyDefaultConstructibleUnsafe for $ty {} + )*}; +} +pub(crate) use impl_default_by_zeroed; + +macro_rules! impl_trivially_default_constructible { ($(<$($param:ident),*> $ty:ty),* $(,)?) => {$( - impl<$($param),*> $crate::DefaultConstructible for $ty + impl<$($param),*> DefaultConstructible for $ty where - $ty: Default + $crate::ByteRepr, + $ty: Default + ByteRepr, { - fn default_constructor(this: &$crate::Ptr) { + fn default_constructor(this: &Ptr) { this.write(Self::default()); } } - impl<$($param),*> $crate::DefaultConstructibleUnsafe for $ty + impl<$($param),*> TriviallyDefaultConstructible for $ty where $ty: Default + ByteRepr {} + + impl<$($param),*> DefaultConstructibleUnsafe for $ty where $ty: Default, { @@ -458,21 +477,12 @@ macro_rules! impl_default_by_default { unsafe { std::ptr::write(self, Self::default()) } } } - )*}; -} -macro_rules! impl_default_by_zeroed { - ($($ty:ty),* $(,)?) => {$( - impl $crate::DefaultConstructibleUnsafe for $ty { - unsafe fn default_constructor(&mut self) { - unsafe { std::ptr::write(self, std::mem::zeroed()) } - } - } + impl<$($param),*> TriviallyDefaultConstructibleUnsafe for $ty where $ty: Default {} )*}; } -pub(crate) use impl_default_by_zeroed; -impl_default_by_default!( +impl_trivially_default_constructible!( <> (), <> bool, <> i8, @@ -491,11 +501,23 @@ impl_default_by_default!( <> f64, <> AnyPtr, Ptr, - Option, - Vec, - std::collections::BTreeMap, ); +impl TriviallyDefaultConstructible for FnPtr {} + +impl TriviallyDefaultConstructibleUnsafe for FnPtr {} + +impl TriviallyDefaultConstructible for Box<[T]> {} + +impl TriviallyDefaultConstructibleUnsafe + for [T; N] +{ +} + +impl TriviallyDefaultConstructibleUnsafe for *mut T {} + +impl TriviallyDefaultConstructibleUnsafe for *const T {} + impl DefaultConstructible for FnPtr { fn default_constructor(this: &Ptr) { this.with_mut(|dst| *dst = ::zero_init()); diff --git a/libcc2rs/src/lib.rs b/libcc2rs/src/lib.rs index 0911f7e8a3..ab6a3ee08f 100644 --- a/libcc2rs/src/lib.rs +++ b/libcc2rs/src/lib.rs @@ -54,8 +54,8 @@ pub use constructor::{ MoveConstructible, MoveConstructibleUnsafe, Swappable, SwappableUnsafe, TriviallyCopyAssignable, TriviallyCopyAssignableUnsafe, TriviallyCopyConstructible, TriviallyCopyConstructibleUnsafe, TriviallyCopyable, TriviallyCopyableUnsafe, - TriviallyMoveAssignable, TriviallyMoveAssignableUnsafe, TriviallyMoveConstructible, - TriviallyMoveConstructibleUnsafe, + TriviallyDefaultConstructible, TriviallyDefaultConstructibleUnsafe, TriviallyMoveAssignable, + TriviallyMoveAssignableUnsafe, TriviallyMoveConstructible, TriviallyMoveConstructibleUnsafe, }; mod cmp; @@ -126,6 +126,7 @@ pub use libcc2rs_macros::{ DefaultConstructibleUnsafe, DefaultInitializable, DefaultInitializableUnsafe, Destructible, DestructibleUnsafe, FnPtrArg, Memberwise, MemberwiseUnsafe, Movable, MovableUnsafe, MoveAssignable, MoveAssignableUnsafe, MoveConstructible, MoveConstructibleUnsafe, Record, - Swappable, SwappableUnsafe, TriviallyCopyable, TriviallyCopyableUnsafe, VaArg, - ZeroInitialization, ZeroInitializationUnsafe, goto, goto_block, lambda, lambda_unsafe, switch, + Swappable, SwappableUnsafe, TriviallyCopyable, TriviallyCopyableUnsafe, + TriviallyDefaultConstructible, TriviallyDefaultConstructibleUnsafe, VaArg, ZeroInitialization, + ZeroInitializationUnsafe, goto, goto_block, lambda, lambda_unsafe, switch, }; diff --git a/rules/dirent/shim.rs b/rules/dirent/shim.rs index 9f53574cbc..ae8f1cb6a1 100644 --- a/rules/dirent/shim.rs +++ b/rules/dirent/shim.rs @@ -1,12 +1,14 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use crate::DefaultConstructible; +use crate::TriviallyDefaultConstructible; use crate::{ByteRepr, Record, TriviallyCopyable, ZeroInitialization, size_of_field}; use std::cell::Cell; use std::mem::{offset_of, size_of}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, DefaultConstructible, TriviallyCopyable)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, TriviallyDefaultConstructible, TriviallyCopyable, +)] #[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 490824db08..f3f1c35480 100644 --- a/rules/ifaddrs/shim.rs +++ b/rules/ifaddrs/shim.rs @@ -1,7 +1,7 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use crate::DefaultConstructible; +use crate::TriviallyDefaultConstructible; use crate::{ ByteRepr, Ptr, Record, Sockaddr, SockaddrIn, SockaddrIn6, SockaddrStorage, TriviallyCopyable, ZeroInitialization, @@ -9,7 +9,13 @@ use crate::{ use std::mem::{offset_of, size_of}; #[derive( - Clone, Default, Record, ByteRepr, ZeroInitialization, DefaultConstructible, TriviallyCopyable, + Clone, + Default, + Record, + ByteRepr, + ZeroInitialization, + TriviallyDefaultConstructible, + TriviallyCopyable, )] #[byte_size(size_of::<::libc::ifaddrs>())] pub struct Ifaddrs { diff --git a/rules/ip/shim.rs b/rules/ip/shim.rs index 6daa972eab..782d43192e 100644 --- a/rules/ip/shim.rs +++ b/rules/ip/shim.rs @@ -1,11 +1,17 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use crate::DefaultConstructible; +use crate::TriviallyDefaultConstructible; use crate::{ByteRepr, Ptr, Record, TriviallyCopyable, ZeroInitialization}; #[derive( - Clone, Default, Record, ByteRepr, ZeroInitialization, DefaultConstructible, TriviallyCopyable, + Clone, + Default, + Record, + ByteRepr, + ZeroInitialization, + TriviallyDefaultConstructible, + TriviallyCopyable, )] #[byte_size(4)] pub struct InAddr { @@ -13,7 +19,9 @@ pub struct InAddr { pub s_addr: u32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, DefaultConstructible, TriviallyCopyable)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, TriviallyDefaultConstructible, TriviallyCopyable, +)] #[byte_size(16)] pub struct In6Addr { #[offset(0)] diff --git a/rules/netdb/shim.rs b/rules/netdb/shim.rs index 965be26d37..3462fee9af 100644 --- a/rules/netdb/shim.rs +++ b/rules/netdb/shim.rs @@ -1,12 +1,18 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use crate::DefaultConstructible; +use crate::TriviallyDefaultConstructible; use crate::{ByteRepr, Ptr, Record, Sockaddr, TriviallyCopyable, ZeroInitialization}; use std::mem::{offset_of, size_of}; #[derive( - Clone, Default, Record, ByteRepr, ZeroInitialization, DefaultConstructible, TriviallyCopyable, + Clone, + Default, + Record, + ByteRepr, + ZeroInitialization, + TriviallyDefaultConstructible, + TriviallyCopyable, )] #[byte_size(size_of::<::libc::addrinfo>())] pub struct Addrinfo { diff --git a/rules/poll/shim.rs b/rules/poll/shim.rs index 5f7699d66c..61d6e8569f 100644 --- a/rules/poll/shim.rs +++ b/rules/poll/shim.rs @@ -1,12 +1,18 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use crate::DefaultConstructible; +use crate::TriviallyDefaultConstructible; use crate::{ByteRepr, Record, TriviallyCopyable, ZeroInitialization}; use std::mem::{offset_of, size_of}; #[derive( - Clone, Default, Record, ByteRepr, ZeroInitialization, DefaultConstructible, TriviallyCopyable, + Clone, + Default, + Record, + ByteRepr, + ZeroInitialization, + TriviallyDefaultConstructible, + TriviallyCopyable, )] #[byte_size(size_of::<::libc::pollfd>())] pub struct Pollfd { diff --git a/rules/pwd/shim.rs b/rules/pwd/shim.rs index 885b6ec628..05d22c24e1 100644 --- a/rules/pwd/shim.rs +++ b/rules/pwd/shim.rs @@ -1,12 +1,18 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use crate::DefaultConstructible; +use crate::TriviallyDefaultConstructible; use crate::{ByteRepr, Ptr, Record, TriviallyCopyable, ZeroInitialization}; use std::mem::{offset_of, size_of}; #[derive( - Clone, Default, Record, ByteRepr, ZeroInitialization, DefaultConstructible, TriviallyCopyable, + Clone, + Default, + Record, + ByteRepr, + ZeroInitialization, + TriviallyDefaultConstructible, + TriviallyCopyable, )] #[byte_size(size_of::<::libc::passwd>())] pub struct Passwd { diff --git a/rules/socket/shim.rs b/rules/socket/shim.rs index 7e2763c0b3..faed480f7c 100644 --- a/rules/socket/shim.rs +++ b/rules/socket/shim.rs @@ -1,11 +1,13 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use crate::DefaultConstructible; +use crate::TriviallyDefaultConstructible; use crate::{ByteRepr, CChar, In6Addr, InAddr, Ptr, Record, TriviallyCopyable, ZeroInitialization}; // The fields are at the offsets of the byte representation below. -#[derive(Clone, Record, ByteRepr, ZeroInitialization, DefaultConstructible, TriviallyCopyable)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, TriviallyDefaultConstructible, TriviallyCopyable, +)] #[byte_size(16)] pub struct Sockaddr { #[offset(0)] @@ -16,7 +18,9 @@ pub struct Sockaddr { pub sa_data: Box<[i8]>, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, DefaultConstructible, TriviallyCopyable)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, TriviallyDefaultConstructible, TriviallyCopyable, +)] #[byte_size(16)] pub struct SockaddrIn { #[offset(0)] @@ -32,7 +36,13 @@ pub struct SockaddrIn { } #[derive( - Clone, Default, Record, ByteRepr, ZeroInitialization, DefaultConstructible, TriviallyCopyable, + Clone, + Default, + Record, + ByteRepr, + ZeroInitialization, + TriviallyDefaultConstructible, + TriviallyCopyable, )] #[byte_size(28)] pub struct SockaddrIn6 { @@ -48,7 +58,9 @@ pub struct SockaddrIn6 { pub sin6_scope_id: u32, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, DefaultConstructible, TriviallyCopyable)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, TriviallyDefaultConstructible, TriviallyCopyable, +)] #[byte_size(110)] pub struct SockaddrUn { #[offset(0)] @@ -59,7 +71,9 @@ pub struct SockaddrUn { pub sun_path: Box<[i8]>, } -#[derive(Clone, Record, ByteRepr, ZeroInitialization, DefaultConstructible, TriviallyCopyable)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, TriviallyDefaultConstructible, TriviallyCopyable, +)] #[byte_size(128)] pub struct SockaddrStorage { #[offset(0)] diff --git a/rules/stat/shim.rs b/rules/stat/shim.rs index a336c3d284..2643e8ec7a 100644 --- a/rules/stat/shim.rs +++ b/rules/stat/shim.rs @@ -1,11 +1,13 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use crate::DefaultConstructible; +use crate::TriviallyDefaultConstructible; use crate::{ByteRepr, Record, TriviallyCopyable, ZeroInitialization}; use std::mem::{offset_of, size_of}; -#[derive(Clone, Default, Record, ZeroInitialization, DefaultConstructible, TriviallyCopyable)] +#[derive( + Clone, Default, Record, ZeroInitialization, TriviallyDefaultConstructible, TriviallyCopyable, +)] // 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 06dd21671e..a5dfbc66cd 100644 --- a/rules/termios/shim.rs +++ b/rules/termios/shim.rs @@ -1,11 +1,13 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use crate::DefaultConstructible; +use crate::TriviallyDefaultConstructible; use crate::{ByteRepr, Record, TriviallyCopyable, ZeroInitialization}; use std::mem::{offset_of, size_of}; -#[derive(Clone, Record, ByteRepr, ZeroInitialization, DefaultConstructible, TriviallyCopyable)] +#[derive( + Clone, Record, ByteRepr, ZeroInitialization, TriviallyDefaultConstructible, TriviallyCopyable, +)] #[byte_size(size_of::<::libc::termios>())] pub struct Termios { #[offset(offset_of!(::libc::termios, c_iflag))] @@ -107,7 +109,13 @@ impl Termios { } #[derive( - Clone, Default, Record, ByteRepr, ZeroInitialization, DefaultConstructible, TriviallyCopyable, + Clone, + Default, + Record, + ByteRepr, + ZeroInitialization, + TriviallyDefaultConstructible, + TriviallyCopyable, )] #[byte_size(size_of::<::libc::winsize>())] pub struct Winsize { diff --git a/rules/time/shim.rs b/rules/time/shim.rs index 687ceb4f23..c30e468c1f 100644 --- a/rules/time/shim.rs +++ b/rules/time/shim.rs @@ -1,12 +1,18 @@ // Copyright (c) 2022-present INESC-ID. // Distributed under the MIT license that can be found in the LICENSE file. -use crate::DefaultConstructible; +use crate::TriviallyDefaultConstructible; use crate::{ByteRepr, Ptr, Record, TriviallyCopyable, ZeroInitialization}; use std::mem::{offset_of, size_of}; #[derive( - Clone, Default, Record, ByteRepr, ZeroInitialization, DefaultConstructible, TriviallyCopyable, + Clone, + Default, + Record, + ByteRepr, + ZeroInitialization, + TriviallyDefaultConstructible, + TriviallyCopyable, )] #[byte_size(size_of::<::libc::tm>())] pub struct Tm { @@ -69,7 +75,13 @@ impl Tm { } #[derive( - Clone, Default, Record, ByteRepr, ZeroInitialization, DefaultConstructible, TriviallyCopyable, + Clone, + Default, + Record, + ByteRepr, + ZeroInitialization, + TriviallyDefaultConstructible, + TriviallyCopyable, )] #[byte_size(size_of::<::libc::timeval>())] pub struct Timeval { @@ -80,7 +92,13 @@ pub struct Timeval { } #[derive( - Clone, Default, Record, ByteRepr, ZeroInitialization, DefaultConstructible, TriviallyCopyable, + Clone, + Default, + Record, + ByteRepr, + ZeroInitialization, + TriviallyDefaultConstructible, + TriviallyCopyable, )] #[byte_size(size_of::<::libc::timespec>())] pub struct Timespec { From cb3b7e80f258d229157adde24d310b2284350b25 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Wed, 2 Dec 2026 14:08:30 +0000 Subject: [PATCH 13/13] Update tests --- .../out/refcount/cross_tu_tag_collision.rs | 2 +- .../out/unsafe/cross_tu_tag_collision.rs | 2 +- .../out/refcount/friend_operator.rs | 3 +- .../out/unsafe/friend_operator.rs | 3 +- .../out/refcount/opaque_forward_decl.rs | 2 +- .../out/unsafe/opaque_forward_decl.rs | 2 +- .../refcount/out_of_line_methods_cross_tu.rs | 3 +- .../unsafe/out_of_line_methods_cross_tu.rs | 3 +- .../out/refcount/p14-class-in-two-files.rs | 6 +- .../out/unsafe/p14-class-in-two-files.rs | 6 +- .../p15-class-template-static-member.rs | 6 +- .../p15-class-template-static-member.rs | 6 +- .../out/refcount/p15-function-template.rs | 9 ++- .../out/unsafe/p15-function-template.rs | 9 ++- .../out/refcount/p15-inline-function.rs | 3 +- .../out/unsafe/p15-inline-function.rs | 3 +- .../out/refcount/p15-inline-variable.rs | 3 +- .../out/unsafe/p15-inline-variable.rs | 3 +- .../p16-default-argument-lambda-in-class.rs | 6 +- .../p16-default-argument-lambda-in-class.rs | 6 +- .../refcount/p16-lambda-in-inline-function.rs | 3 +- .../unsafe/p16-lambda-in-inline-function.rs | 3 +- .../basic.link/out/refcount/basic.link.rs | 25 +++++--- .../basic/basic.link/out/unsafe/basic.link.rs | 13 ++--- .../out/refcount/basic.scope.block.rs | 3 +- .../out/refcount/basic.scope.pdecl.rs | 3 +- .../out/refcount/basic.scope.scope.rs | 51 +++++++++------- .../out/unsafe/basic.scope.block.rs | 3 +- .../out/unsafe/basic.scope.pdecl.rs | 3 +- .../out/unsafe/basic.scope.scope.rs | 33 ++++------- .../out/refcount/basic.start.term.rs | 6 +- .../out/unsafe/basic.start.term.rs | 6 +- .../out/refcount/basic.types.general.rs | 6 +- .../out/unsafe/basic.types.general.rs | 6 +- .../class.conv/out/refcount/class.conv.fct.rs | 3 +- .../class.conv/out/unsafe/class.conv.fct.rs | 3 +- .../class.mem/out/refcount/class.free.rs | 6 +- .../class/class.mem/out/unsafe/class.free.rs | 6 +- .../dcl.init.general-p6.2-padding-bits.rs | 9 +-- .../dcl.init/out/refcount/dcl.init.general.rs | 30 ++++++---- .../dcl.init.general-p6.2-padding-bits.rs | 9 +-- .../dcl.init/out/unsafe/dcl.init.general.rs | 17 ++---- .../dcl.meaning/out/refcount/dcl.array.rs | 3 +- .../out/refcount/dcl.fct.default.rs | 3 +- .../dcl.meaning/out/refcount/dcl.mptr.rs | 22 +++---- .../dcl.meaning/out/unsafe/dcl.array.rs | 3 +- .../dcl.meaning/out/unsafe/dcl.fct.default.rs | 3 +- .../dcl.meaning/out/unsafe/dcl.mptr.rs | 15 ++--- tests/std/expr/conv/out/refcount/conv.mem.rs | 3 +- tests/std/expr/conv/out/unsafe/conv.mem.rs | 3 +- .../expr.post/out/refcount/expr.const.cast.rs | 3 +- ...nterpret.cast-p10-result-is-unspecified.rs | 6 +- .../out/refcount/expr.reinterpret.cast.rs | 12 ++-- .../expr.post/out/unsafe/expr.const.cast.rs | 3 +- ...nterpret.cast-p10-result-is-unspecified.rs | 6 +- .../out/unsafe/expr.reinterpret.cast.rs | 12 ++-- .../expr.unary/out/refcount/expr.pre.incr.rs | 3 +- .../expr.unary/out/refcount/expr.unary.op.rs | 9 +-- .../expr.unary/out/unsafe/expr.pre.incr.rs | 3 +- .../expr.unary/out/unsafe/expr.unary.op.rs | 9 +-- .../expr.compound/out/refcount/expr.cond.rs | 3 +- .../expr.compound/out/refcount/expr.eq.rs | 17 +++--- ...ptr.oper-p6-null-pointer-to-data-member.rs | 3 +- .../out/refcount/expr.mptr.oper.rs | 15 ++--- .../expr.compound/out/unsafe/expr.cond.rs | 3 +- .../expr/expr.compound/out/unsafe/expr.eq.rs | 11 ++-- ...ptr.oper-p6-null-pointer-to-data-member.rs | 3 +- .../out/unsafe/expr.mptr.oper.rs | 15 ++--- .../allocator.requirements.general.rs | 6 +- .../unsafe/allocator.requirements.general.rs | 6 +- .../stmt.select/out/refcount/stmt.switch.rs | 3 +- .../stmt.select/out/unsafe/stmt.switch.rs | 3 +- tests/std/temp/out/refcount/temp.type.rs | 12 ++-- tests/std/temp/out/unsafe/temp.type.rs | 12 ++-- .../utilities/utility/out/refcount/forward.rs | 3 +- .../utility/out/refcount/utility.as.const.rs | 3 +- .../utilities/utility/out/unsafe/forward.rs | 3 +- .../utility/out/unsafe/utility.as.const.rs | 3 +- .../refcount/self_referencing_initializer.rs | 3 +- tests/ub/out/refcount/ub6.rs | 2 +- .../unsafe/self_referencing_initializer.rs | 3 +- tests/ub/out/unsafe/ub6.rs | 2 +- tests/unit/out/refcount/05_new.rs | 6 +- tests/unit/out/refcount/10_struct.rs | 9 +-- tests/unit/out/refcount/addr_of_global.rs | 6 +- tests/unit/out/refcount/anonymous-struct.rs | 27 +++------ tests/unit/out/refcount/anonymous-struct_c.rs | 18 +++--- tests/unit/out/refcount/anonymous_enum.rs | 6 +- tests/unit/out/refcount/anonymous_enum_c.rs | 4 +- tests/unit/out/refcount/array_const_init.rs | 4 +- tests/unit/out/refcount/array_field_addr.rs | 2 +- tests/unit/out/refcount/array_reference.rs | 3 +- tests/unit/out/refcount/as_const.rs | 3 +- tests/unit/out/refcount/assign_rhs_first.rs | 3 +- .../out/refcount/assignment_single_eval.rs | 58 +++++++++---------- tests/unit/out/refcount/bounded_struct_ptr.rs | 3 +- tests/unit/out/refcount/bst.rs | 3 +- tests/unit/out/refcount/c_struct.rs | 10 ++-- tests/unit/out/refcount/cast.rs | 16 +++-- .../refcount/cast_array_to_pointer_decay.rs | 10 +++- tests/unit/out/refcount/class.rs | 12 ++-- .../refcount/class_template_lazy_member.rs | 15 ++--- tests/unit/out/refcount/class_templates.rs | 27 +++------ tests/unit/out/refcount/clone_vs_move.rs | 7 +-- tests/unit/out/refcount/comma_operator.rs | 3 +- tests/unit/out/refcount/complex_function.rs | 11 ++-- .../out/refcount/compound_assign_paren.rs | 3 +- tests/unit/out/refcount/concepts.rs | 3 +- tests/unit/out/refcount/constexpr_function.rs | 6 +- .../conversion_operator_same_translation.rs | 6 +- .../unit/out/refcount/copy_move_defaulted.rs | 13 +++-- tests/unit/out/refcount/default.rs | 30 ++++++++-- tests/unit/out/refcount/default_in_statics.rs | 16 +++-- tests/unit/out/refcount/delete_array_order.rs | 3 +- tests/unit/out/refcount/destructor.rs | 33 +++++++---- tests/unit/out/refcount/destructor_params.rs | 3 +- .../out/refcount/destructor_temporaries.rs | 6 +- tests/unit/out/refcount/doubly_linked_list.rs | 3 +- .../out/refcount/enum_default_in_static.rs | 2 +- tests/unit/out/refcount/enum_int_interop.rs | 3 +- tests/unit/out/refcount/enum_int_interop_c.rs | 2 +- tests/unit/out/refcount/exprs.rs | 6 +- tests/unit/out/refcount/fft.rs | 3 +- tests/unit/out/refcount/field_aliasing.rs | 6 +- .../unit/out/refcount/field_array_elem_ptr.rs | 13 +++-- .../out/refcount/field_method_receiver.rs | 3 +- tests/unit/out/refcount/field_pointers.rs | 13 +++-- .../field_pointers_malloced_struct.rs | 3 +- .../field_reinterpret_write_through.rs | 4 +- tests/unit/out/refcount/find.rs | 3 +- .../refcount/first_field_ptr_covers_struct.rs | 4 +- .../out/refcount/first_member_downcast.rs | 4 +- .../refcount/flex_array_member_incomplete.rs | 2 +- .../flex_array_member_sibling_write.rs | 6 +- tests/unit/out/refcount/fn_ptr_cast.rs | 3 +- tests/unit/out/refcount/fn_ptr_stable_sort.rs | 3 +- tests/unit/out/refcount/fn_ptr_struct.rs | 6 +- .../unit/out/refcount/fn_ptr_typedef_cast.rs | 2 +- tests/unit/out/refcount/fn_ptr_vtable.rs | 3 +- tests/unit/out/refcount/fn_ref.rs | 2 +- .../unit/out/refcount/for_body_destructor.rs | 3 +- tests/unit/out/refcount/friend.rs | 12 ++-- .../unit/out/refcount/function_overloading.rs | 3 +- .../out/refcount/global_call_temporaries.rs | 3 +- .../out/refcount/global_non_const_init.rs | 3 +- tests/unit/out/refcount/global_pointers.rs | 3 +- .../refcount/global_without_initializer.rs | 3 +- .../out/refcount/goto_aggregate_default.rs | 2 +- tests/unit/out/refcount/goto_cleanup.rs | 2 +- tests/unit/out/refcount/huffman.rs | 3 +- .../refcount/immutable-deref-on-func-call.rs | 3 +- tests/unit/out/refcount/init.rs | 3 +- tests/unit/out/refcount/init_list.rs | 3 +- tests/unit/out/refcount/kruskal.rs | 3 +- tests/unit/out/refcount/lambda_as_field.rs | 13 ++++- tests/unit/out/refcount/lambda_capture_ref.rs | 3 +- .../out/refcount/lambda_capture_star_this.rs | 3 +- .../unit/out/refcount/lambda_capture_this.rs | 3 +- .../unit/out/refcount/lambda_capture_value.rs | 3 +- .../refcount/lambda_generic_explicit_args.rs | 3 +- tests/unit/out/refcount/lambda_nested.rs | 3 +- .../unit/out/refcount/lambda_static_local.rs | 3 +- .../refcount/libc_struct_without_default.rs | 10 +++- tests/unit/out/refcount/linked_list.rs | 3 +- .../refcount/local_anon_struct_collision.rs | 4 +- .../out/refcount/local_record_template.rs | 12 ++-- tests/unit/out/refcount/map_key_identity.rs | 3 +- .../unit/out/refcount/memcpy_struct_bytes.rs | 2 +- .../out/refcount/memcpy_struct_layouts.rs | 10 ++-- .../unit/out/refcount/memcpy_struct_struct.rs | 3 +- tests/unit/out/refcount/memset_struct_tail.rs | 2 +- tests/unit/out/refcount/nested_structs.rs | 18 ++---- tests/unit/out/refcount/new.rs | 3 +- tests/unit/out/refcount/new_bst.rs | 3 +- tests/unit/out/refcount/new_struct.rs | 6 +- .../refcount/nttp_distinct_specializations.rs | 9 +-- tests/unit/out/refcount/offsetof.rs | 13 +++-- .../unit/out/refcount/opaque_forward_decl.rs | 2 +- tests/unit/out/refcount/opaque_record_copy.rs | 6 +- .../unit/out/refcount/opaque_then_defined.rs | 4 +- .../out/refcount/operator_arithmetic_free.rs | 3 +- .../refcount/operator_arithmetic_member.rs | 3 +- .../out/refcount/operator_bitwise_free.rs | 3 +- .../out/refcount/operator_bitwise_member.rs | 3 +- .../refcount/operator_comparison_defaulted.rs | 24 +++----- .../out/refcount/operator_comparison_free.rs | 6 +- .../refcount/operator_comparison_member.rs | 3 +- .../out/refcount/operator_comparison_mixed.rs | 3 +- .../refcount/operator_comparison_nonbool.rs | 18 ++---- .../operator_compound_assignment_free.rs | 3 +- .../operator_compound_assignment_member.rs | 3 +- tests/unit/out/refcount/operator_friend.rs | 21 +++---- tests/unit/out/refcount/operator_less_than.rs | 3 +- .../out/refcount/operator_logical_free.rs | 3 +- .../out/refcount/operator_logical_member.rs | 3 +- .../refcount/operator_member_pointer_free.rs | 13 +++-- .../operator_member_pointer_member.rs | 16 +++-- .../unit/out/refcount/operator_other_free.rs | 3 +- .../out/refcount/operator_other_member.rs | 6 +- tests/unit/out/refcount/operator_overloads.rs | 3 +- .../unit/out/refcount/operator_qualifiers.rs | 3 +- tests/unit/out/refcount/operator_three_way.rs | 3 +- tests/unit/out/refcount/operator_traits.rs | 15 ++--- tests/unit/out/refcount/overload_mangling.rs | 9 +-- .../refcount/pair_converting_construction.rs | 6 +- tests/unit/out/refcount/pod.rs | 3 +- tests/unit/out/refcount/pointer_array.rs | 10 +++- tests/unit/out/refcount/pointers.rs | 3 +- tests/unit/out/refcount/ptr_cast_init.rs | 4 +- tests/unit/out/refcount/push_emplace_back.rs | 16 +++-- tests/unit/out/refcount/random.rs | 5 +- tests/unit/out/refcount/reference_wrapper.rs | 3 +- tests/unit/out/refcount/references.rs | 13 +++-- tests/unit/out/refcount/refs_as_args.rs | 3 +- .../out/refcount/reinterpret_cast_ptr_cmp.rs | 23 ++++++-- .../out/refcount/reinterpret_cast_struct.rs | 3 +- .../reinterpret_cast_struct_to_struct.rs | 6 +- tests/unit/out/refcount/reserved_keywords.rs | 9 +-- tests/unit/out/refcount/return_move.rs | 6 +- .../scalar_builtin_construct_destruct.rs | 3 +- .../refcount/self_referencing_initializer.rs | 6 +- .../unit/out/refcount/size_t_static_member.rs | 6 +- tests/unit/out/refcount/static_local.rs | 3 +- .../unit/out/refcount/static_var_in_class.rs | 6 +- tests/unit/out/refcount/strdup.rs | 2 +- .../out/refcount/string_literal_ptr_init.rs | 2 +- tests/unit/out/refcount/string_substr.rs | 2 +- .../out/refcount/struct_2d_array_field.rs | 2 +- .../refcount/struct_member_array_adjacency.rs | 2 +- tests/unit/out/refcount/struct_ptr.rs | 3 +- .../refcount/structured_binding_range_for.rs | 3 +- .../out/refcount/structured_binding_ref.rs | 3 +- .../refcount/structured_binding_trivial.rs | 3 +- .../refcount/tag_vs_identifier_collision.rs | 26 ++++++--- .../out/refcount/template_static_member.rs | 15 ++--- .../unit/out/refcount/typedef-anon-struct.rs | 3 +- .../out/refcount/unary_expr_or_type_trait.rs | 3 +- tests/unit/out/refcount/unboxed_locals.rs | 3 +- tests/unit/out/refcount/unboxed_records.rs | 13 +++-- .../out/refcount/union_addrof_external.rs | 12 +++- tests/unit/out/refcount/union_basic.rs | 32 ++++++++-- .../unit/out/refcount/union_cross_arm_cast.rs | 14 +++-- .../out/refcount/union_field_alignment.rs | 10 +++- .../out/refcount/union_flex_array_member.rs | 10 +++- .../unit/out/refcount/union_memset_memcpy.rs | 14 +++-- tests/unit/out/refcount/union_nested.rs | 22 +++++-- .../out/refcount/union_pointer_pun_address.rs | 12 +++- .../union_pointer_pun_writethrough.rs | 8 ++- .../out/refcount/union_struct_dual_use.rs | 12 +++- .../out/refcount/union_tagged_many_arms.rs | 10 +++- .../unit/out/refcount/union_tagged_simple.rs | 10 +++- .../out/refcount/union_tagged_struct_arms.rs | 16 +++-- .../refcount/union_void_ptr_sized_deref.rs | 10 +++- tests/unit/out/refcount/unique_ptr.rs | 3 +- .../out/refcount/unique_ptr_field_reset.rs | 3 +- tests/unit/out/refcount/unique_ptr_nested.rs | 3 +- tests/unit/out/refcount/unique_ptr_struct.rs | 3 +- tests/unit/out/refcount/va_arg_mixed_types.rs | 2 +- .../out/refcount/va_arg_non_primitive_ptrs.rs | 2 +- tests/unit/out/refcount/va_arg_struct_ctx.rs | 10 +++- tests/unit/out/refcount/va_arg_void_ptr.rs | 2 +- tests/unit/out/refcount/va_list_field.rs | 3 +- tests/unit/out/refcount/vector.rs | 3 +- .../out/refcount/vector_iter_range_ctor.rs | 3 +- .../out/refcount/vector_subscript_direct.rs | 3 +- .../out/refcount/vector_with_allocator.rs | 6 +- tests/unit/out/refcount/void_cast.rs | 3 +- tests/unit/out/unsafe/05_new.rs | 6 +- tests/unit/out/unsafe/10_struct.rs | 9 +-- tests/unit/out/unsafe/addr_of_global.rs | 6 +- tests/unit/out/unsafe/anonymous-struct.rs | 27 +++------ tests/unit/out/unsafe/anonymous-struct_c.rs | 18 +++--- tests/unit/out/unsafe/anonymous_enum.rs | 6 +- tests/unit/out/unsafe/anonymous_enum_c.rs | 4 +- tests/unit/out/unsafe/array_const_init.rs | 4 +- tests/unit/out/unsafe/array_field_addr.rs | 2 +- tests/unit/out/unsafe/array_reference.rs | 3 +- tests/unit/out/unsafe/as_const.rs | 3 +- tests/unit/out/unsafe/assign_rhs_first.rs | 3 +- .../unit/out/unsafe/assignment_single_eval.rs | 51 ++++++---------- tests/unit/out/unsafe/bounded_struct_ptr.rs | 3 +- tests/unit/out/unsafe/bst.rs | 3 +- tests/unit/out/unsafe/c_struct.rs | 10 ++-- tests/unit/out/unsafe/cast.rs | 9 +-- .../out/unsafe/cast_array_to_pointer_decay.rs | 3 +- tests/unit/out/unsafe/class.rs | 12 ++-- .../out/unsafe/class_template_lazy_member.rs | 15 ++--- tests/unit/out/unsafe/class_templates.rs | 27 +++------ tests/unit/out/unsafe/clone_vs_move.rs | 7 +-- tests/unit/out/unsafe/comma_operator.rs | 3 +- tests/unit/out/unsafe/complex_function.rs | 11 ++-- .../unit/out/unsafe/compound_assign_paren.rs | 3 +- tests/unit/out/unsafe/concepts.rs | 3 +- tests/unit/out/unsafe/constexpr_function.rs | 6 +- .../conversion_operator_same_translation.rs | 6 +- tests/unit/out/unsafe/copy_move_defaulted.rs | 6 +- tests/unit/out/unsafe/default.rs | 9 +-- tests/unit/out/unsafe/default_in_statics.rs | 9 +-- tests/unit/out/unsafe/delete_array_order.rs | 3 +- tests/unit/out/unsafe/destructor.rs | 33 +++++++---- tests/unit/out/unsafe/destructor_params.rs | 3 +- .../unit/out/unsafe/destructor_temporaries.rs | 6 +- tests/unit/out/unsafe/doubly_linked_list.rs | 3 +- .../unit/out/unsafe/enum_default_in_static.rs | 2 +- tests/unit/out/unsafe/enum_int_interop.rs | 3 +- tests/unit/out/unsafe/enum_int_interop_c.rs | 2 +- tests/unit/out/unsafe/exprs.rs | 6 +- tests/unit/out/unsafe/fft.rs | 3 +- tests/unit/out/unsafe/field_aliasing.rs | 6 +- tests/unit/out/unsafe/field_array_elem_ptr.rs | 6 +- .../unit/out/unsafe/field_method_receiver.rs | 3 +- tests/unit/out/unsafe/field_pointers.rs | 6 +- .../unsafe/field_pointers_malloced_struct.rs | 3 +- .../unsafe/field_reinterpret_write_through.rs | 4 +- tests/unit/out/unsafe/find.rs | 3 +- .../unsafe/first_field_ptr_covers_struct.rs | 4 +- .../unit/out/unsafe/first_member_downcast.rs | 4 +- .../unsafe/flex_array_member_incomplete.rs | 2 +- .../unsafe/flex_array_member_sibling_write.rs | 6 +- tests/unit/out/unsafe/fn_ptr_cast.rs | 3 +- tests/unit/out/unsafe/fn_ptr_stable_sort.rs | 3 +- tests/unit/out/unsafe/fn_ptr_struct.rs | 6 +- tests/unit/out/unsafe/fn_ptr_typedef_cast.rs | 2 +- tests/unit/out/unsafe/fn_ptr_vtable.rs | 3 +- tests/unit/out/unsafe/fn_ref.rs | 2 +- tests/unit/out/unsafe/for_body_destructor.rs | 3 +- tests/unit/out/unsafe/friend.rs | 12 ++-- tests/unit/out/unsafe/function_overloading.rs | 3 +- .../out/unsafe/global_call_temporaries.rs | 3 +- .../unit/out/unsafe/global_non_const_init.rs | 3 +- tests/unit/out/unsafe/global_pointers.rs | 3 +- .../out/unsafe/global_without_initializer.rs | 3 +- .../unit/out/unsafe/goto_aggregate_default.rs | 2 +- tests/unit/out/unsafe/goto_cleanup.rs | 2 +- tests/unit/out/unsafe/huffman.rs | 3 +- .../unsafe/immutable-deref-on-func-call.rs | 3 +- tests/unit/out/unsafe/init.rs | 3 +- tests/unit/out/unsafe/init_list.rs | 3 +- tests/unit/out/unsafe/kruskal.rs | 3 +- tests/unit/out/unsafe/lambda_as_field.rs | 11 +++- tests/unit/out/unsafe/lambda_capture_ref.rs | 3 +- .../out/unsafe/lambda_capture_star_this.rs | 3 +- tests/unit/out/unsafe/lambda_capture_this.rs | 3 +- tests/unit/out/unsafe/lambda_capture_value.rs | 3 +- .../unsafe/lambda_generic_explicit_args.rs | 3 +- tests/unit/out/unsafe/lambda_nested.rs | 3 +- tests/unit/out/unsafe/lambda_static_local.rs | 3 +- .../out/unsafe/libc_struct_without_default.rs | 3 +- tests/unit/out/unsafe/linked_list.rs | 3 +- .../out/unsafe/local_anon_struct_collision.rs | 4 +- .../unit/out/unsafe/local_record_template.rs | 12 ++-- tests/unit/out/unsafe/map_key_identity.rs | 3 +- tests/unit/out/unsafe/memcpy_struct_bytes.rs | 2 +- .../unit/out/unsafe/memcpy_struct_layouts.rs | 10 ++-- tests/unit/out/unsafe/memcpy_struct_struct.rs | 3 +- tests/unit/out/unsafe/memset_struct_tail.rs | 2 +- tests/unit/out/unsafe/nested_structs.rs | 18 ++---- tests/unit/out/unsafe/new.rs | 3 +- tests/unit/out/unsafe/new_bst.rs | 3 +- tests/unit/out/unsafe/new_struct.rs | 6 +- .../unsafe/nttp_distinct_specializations.rs | 9 +-- tests/unit/out/unsafe/offsetof.rs | 6 +- tests/unit/out/unsafe/opaque_forward_decl.rs | 2 +- tests/unit/out/unsafe/opaque_record_copy.rs | 6 +- tests/unit/out/unsafe/opaque_then_defined.rs | 4 +- .../out/unsafe/operator_arithmetic_free.rs | 3 +- .../out/unsafe/operator_arithmetic_member.rs | 3 +- .../unit/out/unsafe/operator_bitwise_free.rs | 3 +- .../out/unsafe/operator_bitwise_member.rs | 3 +- .../unsafe/operator_comparison_defaulted.rs | 24 +++----- .../out/unsafe/operator_comparison_free.rs | 6 +- .../out/unsafe/operator_comparison_member.rs | 3 +- .../out/unsafe/operator_comparison_mixed.rs | 3 +- .../out/unsafe/operator_comparison_nonbool.rs | 18 ++---- .../operator_compound_assignment_free.rs | 3 +- .../operator_compound_assignment_member.rs | 3 +- tests/unit/out/unsafe/operator_friend.rs | 21 +++---- tests/unit/out/unsafe/operator_less_than.rs | 3 +- .../unit/out/unsafe/operator_logical_free.rs | 3 +- .../out/unsafe/operator_logical_member.rs | 3 +- .../unsafe/operator_member_pointer_free.rs | 6 +- .../unsafe/operator_member_pointer_member.rs | 9 +-- tests/unit/out/unsafe/operator_other_free.rs | 3 +- .../unit/out/unsafe/operator_other_member.rs | 6 +- tests/unit/out/unsafe/operator_overloads.rs | 3 +- tests/unit/out/unsafe/operator_qualifiers.rs | 3 +- tests/unit/out/unsafe/operator_three_way.rs | 3 +- tests/unit/out/unsafe/operator_traits.rs | 15 ++--- tests/unit/out/unsafe/overload_mangling.rs | 9 +-- .../unsafe/pair_converting_construction.rs | 6 +- tests/unit/out/unsafe/pod.rs | 3 +- tests/unit/out/unsafe/pointer_array.rs | 3 +- tests/unit/out/unsafe/pointers.rs | 3 +- tests/unit/out/unsafe/ptr_cast_init.rs | 4 +- tests/unit/out/unsafe/push_emplace_back.rs | 9 +-- tests/unit/out/unsafe/random.rs | 5 +- tests/unit/out/unsafe/reference_wrapper.rs | 3 +- tests/unit/out/unsafe/references.rs | 6 +- tests/unit/out/unsafe/refs_as_args.rs | 3 +- .../out/unsafe/reinterpret_cast_ptr_cmp.rs | 9 +-- .../out/unsafe/reinterpret_cast_struct.rs | 3 +- .../reinterpret_cast_struct_to_struct.rs | 6 +- tests/unit/out/unsafe/reserved_keywords.rs | 9 +-- tests/unit/out/unsafe/return_move.rs | 6 +- .../scalar_builtin_construct_destruct.rs | 3 +- .../unsafe/self_referencing_initializer.rs | 6 +- tests/unit/out/unsafe/size_t_static_member.rs | 6 +- tests/unit/out/unsafe/static_local.rs | 3 +- tests/unit/out/unsafe/static_var_in_class.rs | 6 +- tests/unit/out/unsafe/strdup.rs | 2 +- .../out/unsafe/string_literal_ptr_init.rs | 2 +- tests/unit/out/unsafe/string_substr.rs | 2 +- .../unit/out/unsafe/struct_2d_array_field.rs | 2 +- .../unsafe/struct_member_array_adjacency.rs | 2 +- tests/unit/out/unsafe/struct_ptr.rs | 3 +- .../unsafe/structured_binding_range_for.rs | 3 +- .../unit/out/unsafe/structured_binding_ref.rs | 3 +- .../out/unsafe/structured_binding_trivial.rs | 3 +- .../out/unsafe/tag_vs_identifier_collision.rs | 14 ++--- .../unit/out/unsafe/template_static_member.rs | 15 ++--- tests/unit/out/unsafe/typedef-anon-struct.rs | 3 +- .../out/unsafe/unary_expr_or_type_trait.rs | 3 +- tests/unit/out/unsafe/unboxed_locals.rs | 3 +- tests/unit/out/unsafe/unboxed_records.rs | 6 +- .../unit/out/unsafe/union_addrof_external.rs | 6 +- tests/unit/out/unsafe/union_basic.rs | 8 +-- tests/unit/out/unsafe/union_cross_arm_cast.rs | 8 +-- .../unit/out/unsafe/union_field_alignment.rs | 4 +- .../out/unsafe/union_flex_array_member.rs | 4 +- tests/unit/out/unsafe/union_memset_memcpy.rs | 8 +-- tests/unit/out/unsafe/union_nested.rs | 10 ++-- .../out/unsafe/union_pointer_pun_address.rs | 6 +- .../unsafe/union_pointer_pun_writethrough.rs | 2 +- .../unit/out/unsafe/union_struct_dual_use.rs | 6 +- .../unit/out/unsafe/union_tagged_many_arms.rs | 4 +- tests/unit/out/unsafe/union_tagged_simple.rs | 4 +- .../out/unsafe/union_tagged_struct_arms.rs | 10 ++-- .../out/unsafe/union_void_ptr_sized_deref.rs | 4 +- tests/unit/out/unsafe/unique_ptr.rs | 3 +- .../unit/out/unsafe/unique_ptr_field_reset.rs | 3 +- tests/unit/out/unsafe/unique_ptr_nested.rs | 3 +- tests/unit/out/unsafe/unique_ptr_struct.rs | 3 +- tests/unit/out/unsafe/va_arg_mixed_types.rs | 2 +- .../out/unsafe/va_arg_non_primitive_ptrs.rs | 2 +- tests/unit/out/unsafe/va_arg_struct_ctx.rs | 4 +- tests/unit/out/unsafe/va_arg_void_ptr.rs | 2 +- tests/unit/out/unsafe/va_list_field.rs | 3 +- tests/unit/out/unsafe/vector.rs | 3 +- .../unit/out/unsafe/vector_iter_range_ctor.rs | 3 +- .../out/unsafe/vector_subscript_direct.rs | 3 +- .../unit/out/unsafe/vector_with_allocator.rs | 6 +- tests/unit/out/unsafe/void_cast.rs | 3 +- 452 files changed, 1348 insertions(+), 1610 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 2ff45ea821..ee2522bdfe 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 @@ -14,7 +14,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] 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 2f0394ae47..a6566b5214 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 @@ -13,7 +13,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] 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 1e6ba2f9a5..8a185bce62 100644 --- a/tests/multi-file/friend_operator/out/refcount/friend_operator.rs +++ b/tests/multi-file/friend_operator/out/refcount/friend_operator.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 b541578a68..f48036273a 100644 --- a/tests/multi-file/friend_operator/out/unsafe/friend_operator.rs +++ b/tests/multi-file/friend_operator/out/unsafe/friend_operator.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 f25a835f7f..8bc86701b3 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 @@ -13,7 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] 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 56fb7240a8..20929d6c0c 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 @@ -13,7 +13,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] 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 584088ddac..94cae20caf 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 @@ -59,11 +59,10 @@ pub struct Derived { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 f9911d1acf..98ba6c01cb 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 @@ -58,11 +58,10 @@ impl Derived {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Pair { pub first: i32, pub second: 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 a4f679bcd4..c574946d93 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 @@ -91,12 +91,13 @@ impl Default for LifetimeTracked { ZeroInitialization, VaArg, FnPtrArg, + TriviallyDefaultConstructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(default_constructor, copy_assign)] +#[memberwise(copy_assign)] #[byte_size(4)] pub struct AssertsDtorCountAtExit { #[offset(0)] @@ -137,11 +138,10 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 31881ff00a..71f4a8cafa 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 @@ -77,12 +77,13 @@ impl Default for LifetimeTracked { VaArg, FnPtrArg, ZeroInitializationUnsafe, + TriviallyDefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(default_constructor, copy_assign)] +#[memberwise(copy_assign)] pub struct AssertsDtorCountAtExit { pub expected: i32, } @@ -122,11 +123,10 @@ pub static mut shared_5: std::cell::LazyCell = VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 c57cf0418a..f2de6e7436 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 @@ -105,11 +105,10 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(1)] pub struct HasStaticMember_int_ {} thread_local!( @@ -133,11 +132,10 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 ae9a331879..e41e758cca 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 @@ -92,11 +92,10 @@ pub static mut member_4: std::cell::LazyCell = VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct HasStaticMember_int_ {} pub static mut member_5: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { @@ -119,11 +118,10 @@ pub static mut member_5: std::cell::LazyCell = VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 fc403d7b43..427f6afbf0 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 @@ -91,12 +91,13 @@ impl Default for LifetimeTracked { ZeroInitialization, VaArg, FnPtrArg, + TriviallyDefaultConstructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(default_constructor, copy_assign)] +#[memberwise(copy_assign)] #[byte_size(4)] pub struct AssertsDtorCountAtExit { #[offset(0)] @@ -199,11 +200,10 @@ fn main_0() -> i32 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(1)] pub struct S_14 {} pub fn count_18() -> i32 { @@ -242,11 +242,10 @@ pub fn b_count_local_15() -> i32 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(1)] pub struct S_21 {} pub trait LifetimeTrackedImpl { 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 cb9dd96f43..dcc91dae91 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 @@ -77,12 +77,13 @@ impl Default for LifetimeTracked { VaArg, FnPtrArg, ZeroInitializationUnsafe, + TriviallyDefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(default_constructor, copy_assign)] +#[memberwise(copy_assign)] pub struct AssertsDtorCountAtExit { pub expected: i32, } @@ -179,11 +180,10 @@ unsafe fn main_0() -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct S_14 {} pub unsafe fn count_18() -> i32 { return (*(*std::cell::LazyCell::force_mut(&mut *&raw mut n_20)).prefix_inc()); @@ -218,11 +218,10 @@ pub unsafe fn b_count_local_15() -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 d4b76e85e8..502db9b23e 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 @@ -91,12 +91,13 @@ impl Default for LifetimeTracked { ZeroInitialization, VaArg, FnPtrArg, + TriviallyDefaultConstructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(default_constructor, copy_assign)] +#[memberwise(copy_assign)] #[byte_size(4)] pub struct AssertsDtorCountAtExit { #[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 0e434c17d4..cf503f4fb2 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 @@ -77,12 +77,13 @@ impl Default for LifetimeTracked { VaArg, FnPtrArg, ZeroInitializationUnsafe, + TriviallyDefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(default_constructor, copy_assign)] +#[memberwise(copy_assign)] 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 adeeb15c1a..c30fc358da 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 @@ -91,12 +91,13 @@ impl Default for LifetimeTracked { ZeroInitialization, VaArg, FnPtrArg, + TriviallyDefaultConstructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(default_constructor, copy_assign)] +#[memberwise(copy_assign)] #[byte_size(4)] pub struct AssertsDtorCountAtExit { #[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 766bbb54ee..310dc7de43 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 @@ -77,12 +77,13 @@ impl Default for LifetimeTracked { VaArg, FnPtrArg, ZeroInitializationUnsafe, + TriviallyDefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(default_constructor, copy_assign)] +#[memberwise(copy_assign)] 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 ba1fc34c94..6e95dfe962 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 @@ -91,12 +91,13 @@ impl Default for LifetimeTracked { ZeroInitialization, VaArg, FnPtrArg, + TriviallyDefaultConstructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(default_constructor, copy_assign)] +#[memberwise(copy_assign)] #[byte_size(4)] pub struct AssertsDtorCountAtExit { #[offset(0)] @@ -115,11 +116,10 @@ impl Destructible for AssertsDtorCountAtExit { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 4b5befdc1f..590b59ddc4 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 @@ -77,12 +77,13 @@ impl Default for LifetimeTracked { VaArg, FnPtrArg, ZeroInitializationUnsafe, + TriviallyDefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(default_constructor, copy_assign)] +#[memberwise(copy_assign)] pub struct AssertsDtorCountAtExit { pub expected: i32, } @@ -98,11 +99,10 @@ impl DestructibleUnsafe for AssertsDtorCountAtExit { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 a25034aead..aa37b1cd93 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 @@ -91,12 +91,13 @@ impl Default for LifetimeTracked { ZeroInitialization, VaArg, FnPtrArg, + TriviallyDefaultConstructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(default_constructor, copy_assign)] +#[memberwise(copy_assign)] #[byte_size(4)] pub struct AssertsDtorCountAtExit { #[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 467836b4b5..bc16418ba6 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 @@ -77,12 +77,13 @@ impl Default for LifetimeTracked { VaArg, FnPtrArg, ZeroInitializationUnsafe, + TriviallyDefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(default_constructor, copy_assign)] +#[memberwise(copy_assign)] 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 ba7584e19e..1ca48344f3 100644 --- a/tests/std/basic/basic.link/out/refcount/basic.link.rs +++ b/tests/std/basic/basic.link/out/refcount/basic.link.rs @@ -30,7 +30,13 @@ pub fn test_11() { assert!(((ceiling_10.with(|v| v.as_pointer())) == ({ ceiling_address_in_b_12() }))); } #[derive( - VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, + ByteRepr, + Clone, + ZeroInitialization, )] #[byte_size(4)] pub struct anon_13 { @@ -119,11 +125,10 @@ pub fn test_29() { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(1)] pub struct Tally_31 {} thread_local!( @@ -143,11 +148,10 @@ pub fn test_33() { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(1)] pub struct p5_members_of_class_with_external_linkage_Ledger {} pub fn test_36() { @@ -312,7 +316,13 @@ pub fn ceiling_address_in_b_12() -> Ptr { return (ceiling_10.with(|v| v.as_pointer())); } #[derive( - VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, + ByteRepr, + Clone, + ZeroInitialization, )] #[byte_size(4)] pub struct anon_62 { @@ -410,11 +420,10 @@ pub fn raise_30(mut by: i32) -> i32 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(1)] pub struct Tally_67 {} thread_local!( 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 d3c3a39245..ad2f9a1d64 100644 --- a/tests/std/basic/basic.link/out/unsafe/basic.link.rs +++ b/tests/std/basic/basic.link/out/unsafe/basic.link.rs @@ -43,7 +43,7 @@ pub unsafe fn test_11() { FnPtrArg, VaArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, )] pub union anon_13 { @@ -113,11 +113,10 @@ pub unsafe fn test_29() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Tally_31 {} impl Tally_31 { pub unsafe fn add(&mut self, mut amount: i32) -> i32 { @@ -139,11 +138,10 @@ pub unsafe fn test_33() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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))); @@ -296,7 +294,7 @@ pub unsafe fn ceiling_address_in_b_12() -> *const i32 { FnPtrArg, VaArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, )] pub union anon_62 { @@ -371,11 +369,10 @@ pub unsafe fn raise_30(mut by: i32) -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Tally_67 {} impl Tally_67 { pub unsafe fn add(&mut self, mut amount: i32) -> 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 e2d3b812c9..23daff9bf5 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 @@ -100,12 +100,13 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, + TriviallyDefaultConstructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(default_constructor, copy_assign)] +#[memberwise(copy_assign)] #[byte_size(4)] pub struct p1_1_condition_variable_visible_in_else_ConvertsToBool { #[offset(0)] 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 42916998f0..f44d02b17f 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 @@ -25,11 +25,10 @@ pub fn test_0() { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(16)] pub struct p1_own_address_in_initializer_SelfLinked { #[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 51baf6a208..7cf3f9d9eb 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 @@ -52,11 +52,10 @@ pub const p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum_Size_large: ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(1)] pub struct p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum {} pub fn test_5() { @@ -92,11 +91,10 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(1)] pub struct p2_12_class_name_in_own_scope_HasStaticCounter {} impl p2_12_class_name_in_own_scope_HasStaticCounter { @@ -113,7 +111,13 @@ pub fn test_7() { assert!((count_6.with(|rc| *rc.borrow()) == 6)); } #[derive( - VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, + ByteRepr, + Clone, + ZeroInitialization, )] #[byte_size(8)] pub struct anon_8 { @@ -141,7 +145,13 @@ thread_local!( pub static anon_8: Value = Rc::new(RefCell::new(::default())); ); #[derive( - VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, + ByteRepr, + Clone, + ZeroInitialization, )] #[byte_size(8)] pub struct anon_9 { @@ -172,11 +182,10 @@ impl Default for anon_9 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(16)] pub struct p2_13_anonymous_union_members_in_parent_scope_HasAnonymousUnion { #[offset(0)] @@ -213,7 +222,13 @@ pub fn test_10() { assert!(((anon_11::block_ratio(anon_11.as_pointer()).read()) == 0.75_f64)); } #[derive( - VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, + ByteRepr, + Clone, + ZeroInitialization, )] #[byte_size(8)] pub struct anon_11 { @@ -350,11 +365,10 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(1)] pub struct p3_2_ref_qualified_members_are_distinct_HasRefQualifiedOverloads {} pub fn test_18() { @@ -452,11 +466,10 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(1)] pub struct p3_4_ref_qualified_member_templates_are_distinct_HasRefQualifiedTemplateOverloads {} pub fn test_22() { @@ -494,11 +507,10 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(1)] pub struct p4_friend_definition_defines_earlier_friend_declaration_DeclaresFriend {} pub fn shared_friend_24() -> i32 { @@ -513,11 +525,10 @@ pub fn shared_friend_24() -> i32 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(1)] pub struct p4_friend_definition_defines_earlier_friend_declaration_DefinesFriend {} pub fn test_25() { @@ -557,11 +568,10 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct p4_2_class_and_function_share_name_Reading { #[offset(0)] @@ -587,11 +597,10 @@ pub fn test_33() { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 d189f181da..e0483e2eb1 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 @@ -82,12 +82,13 @@ pub static mut dtorCount_6: std::cell::LazyCell = std::cell::LazyCell::new( VaArg, FnPtrArg, ZeroInitializationUnsafe, + TriviallyDefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(default_constructor, copy_assign)] +#[memberwise(copy_assign)] 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.pdecl.rs b/tests/std/basic/basic.scope/out/unsafe/basic.scope.pdecl.rs index e4d9044635..9e3a02c949 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 @@ -25,11 +25,10 @@ pub unsafe fn test_0() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct p1_own_address_in_initializer_SelfLinked { pub next: *mut p1_own_address_in_initializer_SelfLinked, pub value: i32, 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 a5995ea92e..0108b148e2 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 @@ -48,11 +48,10 @@ pub const p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum_Size_large: VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 { @@ -85,11 +84,10 @@ pub static mut count_6: std::cell::LazyCell = std::cell::LazyCell::new(|| u VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct p2_12_class_name_in_own_scope_HasStaticCounter {} impl p2_12_class_name_in_own_scope_HasStaticCounter { pub unsafe fn bump() { @@ -111,7 +109,7 @@ pub unsafe fn test_7() { FnPtrArg, VaArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, )] pub union anon_8 { @@ -132,7 +130,7 @@ pub static mut anon_8: std::cell::LazyCell = FnPtrArg, VaArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, )] pub union anon_9 { @@ -151,11 +149,10 @@ impl Default for anon_9 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct p2_13_anonymous_union_members_in_parent_scope_HasAnonymousUnion { pub tag: i32, pub anon_9: anon_9, @@ -198,7 +195,7 @@ pub unsafe fn test_10() { FnPtrArg, VaArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, )] pub union anon_11 { @@ -336,11 +333,10 @@ pub static mut rvalue_calls_17: std::cell::LazyCell = VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 { @@ -451,11 +447,10 @@ pub static mut rvalue_calls_21: std::cell::LazyCell = VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 { @@ -500,11 +495,10 @@ pub static mut friend_calls_23: std::cell::LazyCell = VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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(); @@ -517,11 +511,10 @@ pub unsafe fn shared_friend_24() -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct p4_friend_definition_defines_earlier_friend_declaration_DefinesFriend {} pub unsafe fn test_25() { assert!(((unsafe { shared_friend_24() }) == (7))); @@ -556,11 +549,10 @@ pub static mut function_calls_31: std::cell::LazyCell = VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct p4_2_class_and_function_share_name_Reading { pub value: i32, } @@ -583,11 +575,10 @@ pub unsafe fn test_33() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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.rs b/tests/std/basic/basic.start/out/refcount/basic.start.term.rs index 3c2b8e7c58..10c2f86bad 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 @@ -60,11 +60,10 @@ pub struct HoldsTracker { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct TriviallyDestructible { #[offset(0)] @@ -160,11 +159,10 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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.rs b/tests/std/basic/basic.start/out/unsafe/basic.start.term.rs index 157a19feba..186f0cfd46 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 @@ -61,11 +61,10 @@ pub struct HoldsTracker { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct TriviallyDestructible { pub value: i32, } @@ -161,11 +160,10 @@ pub static mut trivial_9: std::cell::LazyCell = VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 ece91156d4..f3ae2ec709 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 @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct p2_pointer_to_data_member_bytes_round_trip_HasTwoInts { #[offset(0)] @@ -89,11 +88,10 @@ pub fn test_0() { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 c6593c2727..0f4f424119 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 @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct p2_pointer_to_data_member_bytes_round_trip_HasTwoInts { pub first: i32, pub second: i32, @@ -92,11 +91,10 @@ pub unsafe fn test_0() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct p3_pointer_to_data_member_bytes_copied_to_other_object_HasTwoInts { pub first: i32, pub second: i32, 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 6cfc8d47cf..23cb1a23dc 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 @@ -15,11 +15,10 @@ use std::rc::{Rc, Weak}; VaArg, FnPtrArg, CppFrom, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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.fct.rs b/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.fct.rs index 3b99ed74a8..0688a1be3f 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 @@ -14,11 +14,10 @@ use std::rc::Rc; FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] #[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/out/refcount/class.free.rs b/tests/std/class/class.mem/out/refcount/class.free.rs index 406272bcc5..472b787e90 100644 --- a/tests/std/class/class.mem/out/refcount/class.free.rs +++ b/tests/std/class/class.mem/out/refcount/class.free.rs @@ -17,11 +17,10 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(1)] pub struct p1_allocation_function_is_static_Allocates {} impl p1_allocation_function_is_static_Allocates { @@ -66,11 +65,10 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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/unsafe/class.free.rs b/tests/std/class/class.mem/out/unsafe/class.free.rs index 4ec8fca4af..108af2684c 100644 --- a/tests/std/class/class.mem/out/unsafe/class.free.rs +++ b/tests/std/class/class.mem/out/unsafe/class.free.rs @@ -14,11 +14,10 @@ pub static mut allocations_0: std::cell::LazyCell = std::cell::LazyCell::ne VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 { @@ -58,11 +57,10 @@ pub static mut deallocations_2: std::cell::LazyCell = VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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/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 b9e40fe16d..401c73ca69 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 @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct p6_2_zero_initialized_padding_Padded { #[offset(0)] @@ -34,11 +33,10 @@ pub struct p6_2_zero_initialized_padding_Padded { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct p6_2_zero_initialized_padding_TailPadded { #[offset(0)] @@ -54,11 +52,10 @@ pub struct p6_2_zero_initialized_padding_TailPadded { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 684dbfdca2..23313f5b3e 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 @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct p6_1_zero_initialized_pointer_to_member_HasTwoInts { #[offset(0)] @@ -34,10 +33,9 @@ pub struct p6_1_zero_initialized_pointer_to_member_HasTwoInts { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct p6_1_zero_initialized_pointer_to_member_HoldsSelector { #[offset(0)] @@ -141,11 +139,10 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(24)] pub struct p6_2_zero_initialized_class_Inner { #[offset(0)] @@ -157,9 +154,15 @@ pub struct p6_2_zero_initialized_class_Inner { pub pointer: Ptr, } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, )] -#[memberwise(default_constructor)] #[byte_size(96)] pub struct p6_2_zero_initialized_class_Outer { #[offset(0)] @@ -231,7 +234,13 @@ pub fn test_15() { heap_outer.delete(); } #[derive( - VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, + ByteRepr, + Clone, + ZeroInitialization, )] #[byte_size(8)] pub struct p6_3_zero_initialized_union_Number { @@ -277,11 +286,10 @@ pub fn test_17() { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct p6_4_zero_initialized_array_Pair { #[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 2a30154179..b57498b6cc 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 @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct p6_2_zero_initialized_padding_Padded { pub letter: libc::c_char, pub number: i32, @@ -29,11 +28,10 @@ pub struct p6_2_zero_initialized_padding_Padded { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct p6_2_zero_initialized_padding_TailPadded { pub number: i32, pub letter: libc::c_char, @@ -45,11 +43,10 @@ pub struct p6_2_zero_initialized_padding_TailPadded { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 2aeae93d67..af85deebce 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 @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct p6_1_zero_initialized_pointer_to_member_HasTwoInts { pub first: i32, pub second: i32, @@ -29,10 +28,9 @@ pub struct p6_1_zero_initialized_pointer_to_member_HasTwoInts { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, )] -#[memberwise(default_constructor)] pub struct p6_1_zero_initialized_pointer_to_member_HoldsSelector { pub selector: isize, } @@ -132,11 +130,10 @@ static mut counter_11: std::cell::LazyCell = std::cell::LazyCell::new(|| un VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct p6_2_zero_initialized_class_Inner { pub number: i32, pub real: f64, @@ -149,11 +146,10 @@ pub struct p6_2_zero_initialized_class_Inner { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct p6_2_zero_initialized_class_Outer { pub letter: libc::c_char, pub inner: p6_2_zero_initialized_class_Inner, @@ -211,7 +207,7 @@ pub unsafe fn test_15() { FnPtrArg, VaArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, )] pub union p6_3_zero_initialized_union_Number { @@ -238,11 +234,10 @@ pub unsafe fn test_17() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct p6_4_zero_initialized_array_Pair { pub first: i32, pub second: i32, 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 4f84c45591..a250ad10a8 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 @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 4708cf3a9a..e91210744e 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 @@ -241,11 +241,10 @@ pub fn add_18(mut a: i32, mut b: i32) -> i32 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 4a15c5e4a7..79fd5f7165 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 @@ -7,9 +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, Memberwise, TriviallyCopyable, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, )] -#[memberwise(default_constructor)] #[byte_size(16)] pub struct p2_pointer_to_array_member_HasIntArray { #[offset(0)] @@ -51,11 +57,10 @@ pub fn test_0() { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct p2_pointer_to_data_member_HasTwoInts { #[offset(0)] @@ -91,11 +96,10 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct p2_pointer_to_member_of_incomplete_class_CompletedLater { #[offset(0)] @@ -132,11 +136,10 @@ pub fn test_3() { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct p2_pointer_to_member_of_pointer_to_member_type_HasTwoInts { #[offset(0)] @@ -152,10 +155,9 @@ pub struct p2_pointer_to_member_of_pointer_to_member_type_HasTwoInts { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, )] -#[memberwise(default_constructor)] #[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 95ab2466e0..b59c1fc2be 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 @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 aec121953d..d0b9de3511 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 @@ -243,11 +243,10 @@ pub unsafe fn add_18(mut a: i32, mut b: i32) -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 07dd44859c..090bcf4650 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 @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct p2_pointer_to_array_member_HasIntArray { pub before: i32, pub elements: [i32; 3], @@ -54,11 +53,10 @@ pub unsafe fn test_0() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct p2_pointer_to_data_member_HasTwoInts { pub first: i32, pub second: i32, @@ -102,11 +100,10 @@ pub static mut pm_2: std::cell::LazyCell = std::cell::LazyCell::new(|| un VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct p2_pointer_to_member_of_incomplete_class_CompletedLater { pub first: i32, pub second: i32, @@ -136,11 +133,10 @@ pub unsafe fn test_3() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct p2_pointer_to_member_of_pointer_to_member_type_HasTwoInts { pub first: i32, pub second: i32, @@ -152,10 +148,9 @@ pub struct p2_pointer_to_member_of_pointer_to_member_type_HasTwoInts { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, )] -#[memberwise(default_constructor)] 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 17ea23be25..0fe2dfc94d 100644 --- a/tests/std/expr/conv/out/refcount/conv.mem.rs +++ b/tests/std/expr/conv/out/refcount/conv.mem.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 6efa3346e8..ebb8082d3c 100644 --- a/tests/std/expr/conv/out/unsafe/conv.mem.rs +++ b/tests/std/expr/conv/out/unsafe/conv.mem.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 c6cddfa9e8..9a71c9350c 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 @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 421a779029..21674a4b82 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 @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct HasTwoInts { #[offset(0)] @@ -34,11 +33,10 @@ pub struct HasTwoInts { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 b004bee244..07fc493b87 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 @@ -24,11 +24,10 @@ pub fn test_0() { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct p10_null_converts_to_null_HasTwoInts { #[offset(0)] @@ -44,11 +43,10 @@ pub struct p10_null_converts_to_null_HasTwoInts { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(1)] pub struct p10_null_converts_to_null_HasChar { #[offset(0)] @@ -67,11 +65,10 @@ pub fn test_1() { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct p10_2_data_member_round_trip_HasTwoInts { #[offset(0)] @@ -87,11 +84,10 @@ pub struct p10_2_data_member_round_trip_HasTwoInts { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 0e58a2d020..258b55e89f 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 @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 946c2bee32..ea41a007c1 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 @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct HasTwoInts { pub first: i32, pub second: i32, @@ -29,11 +28,10 @@ pub struct HasTwoInts { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 e348f6534f..b6e8f87d23 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 @@ -23,11 +23,10 @@ pub unsafe fn test_0() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct p10_null_converts_to_null_HasTwoInts { pub first: i32, pub second: i32, @@ -39,11 +38,10 @@ pub struct p10_null_converts_to_null_HasTwoInts { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct p10_null_converts_to_null_HasChar { pub character: libc::c_char, } @@ -59,11 +57,10 @@ pub unsafe fn test_1() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct p10_2_data_member_round_trip_HasTwoInts { pub first: i32, pub second: i32, @@ -75,11 +72,10 @@ pub struct p10_2_data_member_round_trip_HasTwoInts { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 230a7b92c2..6a56774ca1 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 @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 baceb70e5e..f47f6c147a 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 @@ -20,11 +20,10 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(1)] pub struct p3_2_static_member_is_ordinary_pointer_HasStaticMembers {} impl p3_2_static_member_is_ordinary_pointer_HasStaticMembers { @@ -50,11 +49,10 @@ pub fn test_2() { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct p3_2_explicit_object_member_is_ordinary_pointer_HasExplicitObjectMember { #[offset(0)] @@ -78,11 +76,10 @@ pub fn test_3() { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 a77a2dfbdc..92dd5b993d 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 @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 7616314225..d6ab330b13 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 @@ -15,11 +15,10 @@ pub static mut calls_1: std::cell::LazyCell = std::cell::LazyCell::new(|| u VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct p3_2_static_member_is_ordinary_pointer_HasStaticMembers {} impl p3_2_static_member_is_ordinary_pointer_HasStaticMembers { pub unsafe fn run() { @@ -44,11 +43,10 @@ pub unsafe fn test_2() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct p3_2_explicit_object_member_is_ordinary_pointer_HasExplicitObjectMember { pub base: i32, } @@ -80,11 +78,10 @@ pub unsafe fn test_3() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 e6066b56ca..947947aa82 100644 --- a/tests/std/expr/expr.compound/out/refcount/expr.cond.rs +++ b/tests/std/expr/expr.compound/out/refcount/expr.cond.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 9efaa0d88a..0b27916dfc 100644 --- a/tests/std/expr/expr.compound/out/refcount/expr.eq.rs +++ b/tests/std/expr/expr.compound/out/refcount/expr.eq.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct p4_1_both_null_HasTwoInts { #[offset(0)] @@ -40,11 +39,10 @@ pub fn test_0() { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct p4_2_one_null_HasTwoInts { #[offset(0)] @@ -61,7 +59,13 @@ pub fn test_1() { assert!(!(null_pm == first_pm)); } #[derive( - VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, + ByteRepr, + Clone, + ZeroInitialization, )] #[byte_size(4)] pub struct p4_5_members_of_same_union_HasTwoIntMembers { @@ -99,11 +103,10 @@ pub fn test_2() { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 dbbea46c37..f17758846e 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 @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 eef2a538a4..e6f7aebe5f 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 @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct p3_arrow_star_HasTwoInts { #[offset(0)] @@ -47,11 +46,10 @@ pub fn test_0() { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct p4_object_expression_sequenced_first_HasValue { #[offset(0)] @@ -101,11 +99,10 @@ pub fn test_7() { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct p6_data_member_of_lvalue_is_lvalue_HasTwoInts { #[offset(0)] @@ -140,14 +137,13 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, + TriviallyDefaultConstructible, Destructible, - Memberwise, CopyAssignable, MoveAssignable, Swappable, Default, )] -#[memberwise(default_constructor)] #[byte_size(1)] pub struct p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves {} impl CopyConstructible for p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves { @@ -185,6 +181,7 @@ impl Clone for p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves { ZeroInitialization, VaArg, FnPtrArg, + TriviallyDefaultConstructible, Destructible, Memberwise, CopyAssignable, @@ -192,7 +189,7 @@ impl Clone for p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves { Swappable, Default, )] -#[memberwise(copy_constructor, move_constructor, default_constructor)] +#[memberwise(copy_constructor, move_constructor)] #[byte_size(1)] pub struct p6_data_member_of_rvalue_is_xvalue_HoldsCounted { #[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 85e9ac22cb..7b98a029f5 100644 --- a/tests/std/expr/expr.compound/out/unsafe/expr.cond.rs +++ b/tests/std/expr/expr.compound/out/unsafe/expr.cond.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 d2ae83e01b..07b22b6a6d 100644 --- a/tests/std/expr/expr.compound/out/unsafe/expr.eq.rs +++ b/tests/std/expr/expr.compound/out/unsafe/expr.eq.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct p4_1_both_null_HasTwoInts { pub first: i32, pub second: i32, @@ -35,11 +34,10 @@ pub unsafe fn test_0() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct p4_2_one_null_HasTwoInts { pub first: i32, pub second: i32, @@ -59,7 +57,7 @@ pub unsafe fn test_1() { FnPtrArg, VaArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, )] pub union p4_5_members_of_same_union_HasTwoIntMembers { @@ -84,11 +82,10 @@ pub unsafe fn test_2() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 ac36acad0b..5a6c15a91a 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 @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 de05cf1737..6948a5a22d 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 @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct p3_arrow_star_HasTwoInts { pub first: i32, pub second: i32, @@ -47,11 +46,10 @@ pub unsafe fn test_0() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct p4_object_expression_sequenced_first_HasValue { pub value: i32, } @@ -91,11 +89,10 @@ pub unsafe fn test_7() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct p6_data_member_of_lvalue_is_lvalue_HasTwoInts { pub first: i32, pub second: i32, @@ -128,14 +125,13 @@ pub static mut moveCount_10: std::cell::LazyCell = std::cell::LazyCell::new VaArg, FnPtrArg, ZeroInitializationUnsafe, + TriviallyDefaultConstructibleUnsafe, DestructibleUnsafe, - MemberwiseUnsafe, CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves {} impl CopyConstructibleUnsafe for p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves { unsafe fn copy_constructor( @@ -172,6 +168,7 @@ impl Clone for p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves { VaArg, FnPtrArg, ZeroInitializationUnsafe, + TriviallyDefaultConstructibleUnsafe, DestructibleUnsafe, MemberwiseUnsafe, CopyAssignableUnsafe, @@ -179,7 +176,7 @@ impl Clone for p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves { SwappableUnsafe, Default, )] -#[memberwise(copy_constructor, move_constructor, default_constructor)] +#[memberwise(copy_constructor, move_constructor)] pub struct p6_data_member_of_rvalue_is_xvalue_HoldsCounted { pub member: p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves, } 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 1dacb6432a..31cf739d9f 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 @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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, TriviallyCopyable)] @@ -68,11 +67,10 @@ pub fn test_0() { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 13a751b2de..24bd0567b2 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 @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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, TriviallyCopyableUnsafe)] @@ -65,11 +64,10 @@ pub unsafe fn test_0() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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.select/out/refcount/stmt.switch.rs b/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs index 707a52a6d9..642a65c7b5 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 @@ -101,12 +101,13 @@ thread_local!( VaArg, FnPtrArg, CppFrom, + TriviallyDefaultConstructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(default_constructor, copy_assign)] +#[memberwise(copy_assign)] #[cpp_into(i32, to_i32)] #[byte_size(4)] pub struct p2_condition_variable_lives_for_whole_statement_ConvertsToInt { 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 99caf0fa95..a483cd77f1 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 @@ -83,12 +83,13 @@ pub static mut dtorCount_6: std::cell::LazyCell = std::cell::LazyCell::new( FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, + TriviallyDefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(default_constructor, copy_assign)] +#[memberwise(copy_assign)] #[cpp_into(i32, to_i32)] pub struct p2_condition_variable_lives_for_whole_statement_ConvertsToInt { pub value: i32, diff --git a/tests/std/temp/out/refcount/temp.type.rs b/tests/std/temp/out/refcount/temp.type.rs index 3ba8828386..5309ac5b21 100644 --- a/tests/std/temp/out/refcount/temp.type.rs +++ b/tests/std/temp/out/refcount/temp.type.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct p2_6_pointer_to_member_argument_HasTwoInts { #[offset(0)] @@ -37,11 +36,10 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(1)] pub struct p2_6_pointer_to_member_argument_CountsPerMember_refp2_6_pointer_to_member_argument_HasTwoInts_first_ {} @@ -56,11 +54,10 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(1)] pub struct p2_6_pointer_to_member_argument_CountsPerMember_refp2_6_pointer_to_member_argument_HasTwoInts_second_ {} @@ -75,11 +72,10 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 d78d8fb422..14eacf2404 100644 --- a/tests/std/temp/out/unsafe/temp.type.rs +++ b/tests/std/temp/out/unsafe/temp.type.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct p2_6_pointer_to_member_argument_HasTwoInts { pub first: i32, pub second: i32, @@ -30,11 +29,10 @@ pub static mut count_0: std::cell::LazyCell = std::cell::LazyCell::new(|| u VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 }); @@ -45,11 +43,10 @@ pub static mut count_1: std::cell::LazyCell = std::cell::LazyCell::new(|| u VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 }); @@ -60,11 +57,10 @@ pub static mut count_2: std::cell::LazyCell = std::cell::LazyCell::new(|| u VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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/utilities/utility/out/refcount/forward.rs b/tests/std/utilities/utility/out/refcount/forward.rs index 37681ee26e..864862627a 100644 --- a/tests/std/utilities/utility/out/refcount/forward.rs +++ b/tests/std/utilities/utility/out/refcount/forward.rs @@ -20,11 +20,10 @@ pub fn test_0() { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 d5e0eb128e..a5a0bb1817 100644 --- a/tests/std/utilities/utility/out/refcount/utility.as.const.rs +++ b/tests/std/utilities/utility/out/refcount/utility.as.const.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 7b4cc6568a..d278478579 100644 --- a/tests/std/utilities/utility/out/unsafe/forward.rs +++ b/tests/std/utilities/utility/out/unsafe/forward.rs @@ -19,11 +19,10 @@ pub unsafe fn test_0() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 3a67e63949..9e25c6649a 100644 --- a/tests/std/utilities/utility/out/unsafe/utility.as.const.rs +++ b/tests/std/utilities/utility/out/unsafe/utility.as.const.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct p1_as_const_Counter { pub value: i32, } diff --git a/tests/ub/out/refcount/self_referencing_initializer.rs b/tests/ub/out/refcount/self_referencing_initializer.rs index 05d7d34b76..0628392e3f 100644 --- a/tests/ub/out/refcount/self_referencing_initializer.rs +++ b/tests/ub/out/refcount/self_referencing_initializer.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 314431bf19..a6252b9b78 100644 --- a/tests/ub/out/refcount/ub6.rs +++ b/tests/ub/out/refcount/ub6.rs @@ -13,7 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/ub/out/unsafe/self_referencing_initializer.rs b/tests/ub/out/unsafe/self_referencing_initializer.rs index 7d14c20812..cfa5cbcf96 100644 --- a/tests/ub/out/unsafe/self_referencing_initializer.rs +++ b/tests/ub/out/unsafe/self_referencing_initializer.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 68dfc47a12..d1522f289f 100644 --- a/tests/ub/out/unsafe/ub6.rs +++ b/tests/ub/out/unsafe/ub6.rs @@ -13,7 +13,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/refcount/05_new.rs b/tests/unit/out/refcount/05_new.rs index 00ebfee217..398bb6b1b1 100644 --- a/tests/unit/out/refcount/05_new.rs +++ b/tests/unit/out/refcount/05_new.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(1)] pub struct A {} #[derive( @@ -29,11 +28,10 @@ pub struct A {} ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 858dbff246..0db8b537fa 100644 --- a/tests/unit/out/refcount/10_struct.rs +++ b/tests/unit/out/refcount/10_struct.rs @@ -13,11 +13,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(16)] pub struct GraphNode { #[offset(0)] @@ -33,11 +32,10 @@ pub struct GraphNode { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(16)] pub struct Graph { #[offset(0)] @@ -88,11 +86,10 @@ pub struct Declared {} ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 fa9c30bed0..43a63d57af 100644 --- a/tests/unit/out/refcount/addr_of_global.rs +++ b/tests/unit/out/refcount/addr_of_global.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Inner { #[offset(0)] @@ -31,11 +30,10 @@ pub struct Inner { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 660b333fcc..deaf67bd22 100644 --- a/tests/unit/out/refcount/anonymous-struct.rs +++ b/tests/unit/out/refcount/anonymous-struct.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct Outer_Named { #[offset(0)] @@ -34,11 +33,10 @@ pub struct Outer_Named { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct anon_0 { #[offset(0)] @@ -54,11 +52,10 @@ pub struct anon_0 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct anon_1 { #[offset(0)] @@ -74,11 +71,10 @@ pub struct anon_1 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct anon_2 { #[offset(0)] @@ -94,11 +90,10 @@ pub struct anon_2 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct anon_4 { #[offset(0)] @@ -112,11 +107,10 @@ pub struct anon_4 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct anon_5 { #[offset(0)] @@ -130,11 +124,10 @@ pub struct anon_5 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(12)] pub struct anon_3 { #[offset(0)] @@ -154,11 +147,10 @@ pub struct anon_3 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(44)] pub struct Outer { #[offset(0)] @@ -230,11 +222,10 @@ fn main_0() -> i32 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 61904445eb..1edb3cd3f0 100644 --- a/tests/unit/out/refcount/anonymous-struct_c.rs +++ b/tests/unit/out/refcount/anonymous-struct_c.rs @@ -14,7 +14,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -33,7 +33,7 @@ pub struct Named { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -52,7 +52,7 @@ pub struct anon_0 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -71,7 +71,7 @@ pub struct anon_1 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -90,7 +90,7 @@ pub struct anon_2 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -107,7 +107,7 @@ pub struct anon_4 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -124,7 +124,7 @@ pub struct anon_5 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -147,7 +147,7 @@ pub struct anon_3 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -228,7 +228,7 @@ fn main_0() -> i32 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/anonymous_enum.rs b/tests/unit/out/refcount/anonymous_enum.rs index ae0c180cae..7df4173370 100644 --- a/tests/unit/out/refcount/anonymous_enum.rs +++ b/tests/unit/out/refcount/anonymous_enum.rs @@ -20,11 +20,10 @@ pub const anon_1_SECOND_B: anon_1 = 1; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct S { #[offset(0)] @@ -44,11 +43,10 @@ pub const anon_2_FIELD_B: anon_2 = 1; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 8cdbc3b327..c348d852a2 100644 --- a/tests/unit/out/refcount/anonymous_enum_c.rs +++ b/tests/unit/out/refcount/anonymous_enum_c.rs @@ -20,7 +20,7 @@ pub const anon_1_SECOND_B: anon_1 = 1; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -43,7 +43,7 @@ pub const anon_2_FIELD_B: anon_2 = 1; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/array_const_init.rs b/tests/unit/out/refcount/array_const_init.rs index bf800dd702..4e1c28e929 100644 --- a/tests/unit/out/refcount/array_const_init.rs +++ b/tests/unit/out/refcount/array_const_init.rs @@ -13,7 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, )] #[byte_size(20)] @@ -55,7 +55,7 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/array_field_addr.rs b/tests/unit/out/refcount/array_field_addr.rs index d75a2d2621..0beecd6e81 100644 --- a/tests/unit/out/refcount/array_field_addr.rs +++ b/tests/unit/out/refcount/array_field_addr.rs @@ -13,7 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, )] #[byte_size(12)] diff --git a/tests/unit/out/refcount/array_reference.rs b/tests/unit/out/refcount/array_reference.rs index 18f7c24e02..5ff4b1c8bf 100644 --- a/tests/unit/out/refcount/array_reference.rs +++ b/tests/unit/out/refcount/array_reference.rs @@ -67,11 +67,10 @@ pub fn pick_10(s: Ptr) -> Ptr { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 14bbf46c41..cdddf6c9c4 100644 --- a/tests/unit/out/refcount/as_const.rs +++ b/tests/unit/out/refcount/as_const.rs @@ -17,11 +17,10 @@ pub const Overload_kConstOverload: Overload = 2; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 4835d44aca..4f27f30445 100644 --- a/tests/unit/out/refcount/assign_rhs_first.rs +++ b/tests/unit/out/refcount/assign_rhs_first.rs @@ -22,11 +22,10 @@ pub fn advance_1() -> i32 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 2a3ac2025f..b6e55f35cb 100644 --- a/tests/unit/out/refcount/assignment_single_eval.rs +++ b/tests/unit/out/refcount/assignment_single_eval.rs @@ -817,7 +817,7 @@ pub fn test_reference_members_9() { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -834,7 +834,7 @@ pub struct Slot_6 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -851,7 +851,7 @@ pub struct Slot_8 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -926,11 +926,10 @@ pub fn test_pointer_elements_11() { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct Holder_12 { #[offset(0)] @@ -971,7 +970,7 @@ pub fn test_reference_pointer_13() { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -1079,11 +1078,10 @@ pub fn test_reference_subfields_18() { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Index_16 { #[offset(0)] @@ -1096,7 +1094,7 @@ pub struct Index_16 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -1114,11 +1112,10 @@ pub struct Slot_17 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(2)] pub struct Index_19 { #[offset(0)] @@ -1131,7 +1128,7 @@ pub struct Index_19 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -1184,11 +1181,10 @@ pub fn observe_24(mut assigned: i32, mut stored: Ptr) -> i32 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct GlobalRecord_Inner { #[offset(0)] @@ -1202,11 +1198,10 @@ pub struct GlobalRecord_Inner { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct GlobalRecord { #[offset(0)] @@ -1455,11 +1450,10 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Record_32 { #[offset(0)] @@ -1472,11 +1466,10 @@ pub struct Record_32 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct Link_33 { #[offset(0)] @@ -1495,11 +1488,10 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(1)] pub struct IndexedBinding {} pub fn test_binding_35() { @@ -1742,11 +1734,10 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(12)] pub struct IndexedMember { #[offset(0)] @@ -2114,11 +2105,10 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct PointerSelector { #[offset(0)] @@ -2352,11 +2342,10 @@ impl DefaultConstructible for Counts_59 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct Pair_60 { #[offset(0)] @@ -2675,20 +2664,25 @@ fn main_0() -> i32 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Index_62 { #[offset(0)] pub value: i32, } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, )] -#[memberwise(default_constructor)] #[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 80fd4f695f..54fc36fef8 100644 --- a/tests/unit/out/refcount/bounded_struct_ptr.rs +++ b/tests/unit/out/refcount/bounded_struct_ptr.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 71d17f64ee..5cbf153e90 100644 --- a/tests/unit/out/refcount/bst.rs +++ b/tests/unit/out/refcount/bst.rs @@ -13,11 +13,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 2d690adb0d..e1370c5c1b 100644 --- a/tests/unit/out/refcount/c_struct.rs +++ b/tests/unit/out/refcount/c_struct.rs @@ -14,7 +14,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -33,7 +33,7 @@ pub struct Point { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -53,7 +53,7 @@ pub struct Line { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -77,7 +77,7 @@ pub const Color_BLUE: Color = 2; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -96,7 +96,7 @@ pub struct Inner { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/cast.rs b/tests/unit/out/refcount/cast.rs index d2bdfc4bdf..cbf9f35bc3 100644 --- a/tests/unit/out/refcount/cast.rs +++ b/tests/unit/out/refcount/cast.rs @@ -18,11 +18,10 @@ pub const E_C: E = 2; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct Pair { #[offset(0)] @@ -38,11 +37,10 @@ pub struct Pair { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(64)] #[byte_align(64)] pub struct Wide { @@ -50,9 +48,15 @@ pub struct Wide { pub c: i8, } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, )] -#[memberwise(default_constructor)] #[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 7537a31ccd..33ddcd4565 100644 --- a/tests/unit/out/refcount/cast_array_to_pointer_decay.rs +++ b/tests/unit/out/refcount/cast_array_to_pointer_decay.rs @@ -17,9 +17,15 @@ pub fn strlen_1(mut s: Ptr) -> i32 { return c; } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, )] -#[memberwise(default_constructor)] #[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 595127f67a..6f965ac019 100644 --- a/tests/unit/out/refcount/class.rs +++ b/tests/unit/out/refcount/class.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct Pair { #[offset(0)] @@ -34,11 +33,10 @@ pub struct Pair { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(16)] pub struct Route { #[offset(0)] @@ -55,11 +53,10 @@ pub struct Route { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct Counter { #[offset(0)] @@ -80,11 +77,10 @@ impl CppEq for Counter { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 e35871d748..59afd97391 100644 --- a/tests/unit/out/refcount/class_template_lazy_member.rs +++ b/tests/unit/out/refcount/class_template_lazy_member.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Point { #[offset(0)] @@ -32,11 +31,10 @@ pub struct Point { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Box_int_ { #[offset(0)] @@ -50,11 +48,10 @@ pub struct Box_int_ { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Box_Point_ { #[offset(0)] @@ -69,11 +66,10 @@ pub struct Box_Point_ { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Deduced_int_ { #[offset(0)] @@ -87,11 +83,10 @@ pub struct Deduced_int_ { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 51e3dc3a62..7cab42315c 100644 --- a/tests/unit/out/refcount/class_templates.rs +++ b/tests/unit/out/refcount/class_templates.rs @@ -89,11 +89,10 @@ impl DefaultConstructible for MyContainer_float_ { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(2)] pub struct Boxed_short_ { #[offset(0)] @@ -112,11 +111,10 @@ impl Boxed_short_ { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Boxed_int_ { #[offset(0)] @@ -135,11 +133,10 @@ impl Boxed_int_ { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct Boxed_long_ { #[offset(0)] @@ -158,11 +155,10 @@ impl Boxed_long_ { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct Outer_int__Inner_int_ { #[offset(0)] @@ -178,11 +174,10 @@ pub struct Outer_int__Inner_int_ { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Outer_int_ { #[offset(0)] @@ -196,11 +191,10 @@ pub struct Outer_int_ { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(16)] pub struct Outer_long__Inner_int_ { #[offset(0)] @@ -216,11 +210,10 @@ pub struct Outer_long__Inner_int_ { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(16)] pub struct Outer_long__Inner_char_ { #[offset(0)] @@ -236,11 +229,10 @@ pub struct Outer_long__Inner_char_ { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct Outer_long_ { #[offset(0)] @@ -254,11 +246,10 @@ pub struct Outer_long_ { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 68fa6756a5..936e88ed37 100644 --- a/tests/unit/out/refcount/clone_vs_move.rs +++ b/tests/unit/out/refcount/clone_vs_move.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Bar { #[offset(0)] @@ -31,7 +30,7 @@ pub struct Bar { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, )] #[byte_size(40)] @@ -72,7 +71,7 @@ impl Default for Foo { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/comma_operator.rs b/tests/unit/out/refcount/comma_operator.rs index 9d51ebf6cb..1352de2c61 100644 --- a/tests/unit/out/refcount/comma_operator.rs +++ b/tests/unit/out/refcount/comma_operator.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 31ec172305..c6fbbd220c 100644 --- a/tests/unit/out/refcount/complex_function.rs +++ b/tests/unit/out/refcount/complex_function.rs @@ -23,11 +23,10 @@ pub fn bar_2(x: Ptr) -> Ptr { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct X1 { #[offset(0)] @@ -40,7 +39,7 @@ pub struct X1 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -57,11 +56,10 @@ pub struct X2 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct X3 { #[offset(0)] @@ -75,11 +73,10 @@ pub struct X3 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 7d2d5a0342..700b3a4f88 100644 --- a/tests/unit/out/refcount/compound_assign_paren.rs +++ b/tests/unit/out/refcount/compound_assign_paren.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 840cf1584f..6d8bb7c121 100644 --- a/tests/unit/out/refcount/concepts.rs +++ b/tests/unit/out/refcount/concepts.rs @@ -19,11 +19,10 @@ const _: () = assert!( ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 4c493e257e..7d52dfa2b2 100644 --- a/tests/unit/out/refcount/constexpr_function.rs +++ b/tests/unit/out/refcount/constexpr_function.rs @@ -29,11 +29,10 @@ pub fn half_3(mut x: f64) -> f64 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Flag { #[offset(0)] @@ -64,11 +63,10 @@ pub fn imm_7(mut b: bool) -> bool { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct P { #[offset(0)] diff --git a/tests/unit/out/refcount/conversion_operator_same_translation.rs b/tests/unit/out/refcount/conversion_operator_same_translation.rs index cae7036b01..45c44fe60d 100644 --- a/tests/unit/out/refcount/conversion_operator_same_translation.rs +++ b/tests/unit/out/refcount/conversion_operator_same_translation.rs @@ -15,11 +15,10 @@ use std::rc::{Rc, Weak}; VaArg, FnPtrArg, CppFrom, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[cpp_into(i8, to_i8)] #[cpp_into(u8, to_u8)] #[byte_size(4)] @@ -36,11 +35,10 @@ pub struct S { VaArg, FnPtrArg, CppFrom, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[cpp_into(i64, to_i64_1)] #[byte_size(4)] pub struct T { diff --git a/tests/unit/out/refcount/copy_move_defaulted.rs b/tests/unit/out/refcount/copy_move_defaulted.rs index 7d15a2f898..fa6fbb7a29 100644 --- a/tests/unit/out/refcount/copy_move_defaulted.rs +++ b/tests/unit/out/refcount/copy_move_defaulted.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Inner { #[offset(0)] @@ -61,9 +60,15 @@ impl Default for Explicit { } } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, )] -#[memberwise(default_constructor)] #[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 9d09b432d3..f11e1d2ebc 100644 --- a/tests/unit/out/refcount/default.rs +++ b/tests/unit/out/refcount/default.rs @@ -7,9 +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, Memberwise, TriviallyCopyable, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, )] -#[memberwise(default_constructor)] #[byte_size(144)] pub struct Pointers { #[offset(0)] @@ -47,9 +53,15 @@ impl Default for Pointers { } } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, )] -#[memberwise(default_constructor)] #[byte_size(440)] pub struct SmallArrays { #[offset(0)] @@ -85,9 +97,15 @@ impl Default for SmallArrays { } } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, )] -#[memberwise(default_constructor)] #[byte_size(132)] pub struct BigArray { #[offset(0)] diff --git a/tests/unit/out/refcount/default_in_statics.rs b/tests/unit/out/refcount/default_in_statics.rs index f770978730..b97707734c 100644 --- a/tests/unit/out/refcount/default_in_statics.rs +++ b/tests/unit/out/refcount/default_in_statics.rs @@ -13,11 +13,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(16)] pub struct Inner { #[offset(0)] @@ -27,9 +26,15 @@ pub struct Inner { pub name: Ptr, } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, )] -#[memberwise(default_constructor)] #[byte_size(88)] pub struct Outer { #[offset(0)] @@ -82,11 +87,10 @@ impl Default for Outer { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 ffe3b3dc2a..3aa1f925f8 100644 --- a/tests/unit/out/refcount/delete_array_order.rs +++ b/tests/unit/out/refcount/delete_array_order.rs @@ -13,12 +13,13 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, + TriviallyDefaultConstructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(default_constructor, copy_assign)] +#[memberwise(copy_assign)] #[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 14bd438aaf..ca7ff9c803 100644 --- a/tests/unit/out/refcount/destructor.rs +++ b/tests/unit/out/refcount/destructor.rs @@ -16,12 +16,13 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, + TriviallyDefaultConstructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(copy_assign, default_constructor)] +#[memberwise(copy_assign)] #[byte_size(1)] pub struct S {} impl Destructible for S { @@ -36,13 +37,14 @@ impl Destructible for S { ZeroInitialization, VaArg, FnPtrArg, + TriviallyDefaultConstructible, Destructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(default_constructor, copy_assign)] +#[memberwise(copy_assign)] #[byte_size(1)] pub struct Defaulted { #[offset(0)] @@ -57,6 +59,7 @@ pub struct Defaulted { ZeroInitialization, VaArg, FnPtrArg, + TriviallyDefaultConstructible, Destructible, Memberwise, CopyConstructible, @@ -64,7 +67,7 @@ pub struct Defaulted { Swappable, Default, )] -#[memberwise(move_assign, default_constructor, copy_assign)] +#[memberwise(move_assign, copy_assign)] #[byte_size(1)] pub struct Middle { #[offset(0)] @@ -79,6 +82,7 @@ pub struct Middle { ZeroInitialization, VaArg, FnPtrArg, + TriviallyDefaultConstructible, Destructible, Memberwise, CopyConstructible, @@ -86,7 +90,7 @@ pub struct Middle { Swappable, Default, )] -#[memberwise(default_constructor, copy_assign, move_assign)] +#[memberwise(copy_assign, move_assign)] #[byte_size(1)] pub struct Outer { #[offset(0)] @@ -101,13 +105,14 @@ pub struct Outer { ZeroInitialization, VaArg, FnPtrArg, + TriviallyDefaultConstructible, Destructible, Memberwise, CopyConstructible, MoveConstructible, Swappable, )] -#[memberwise(move_assign, default_constructor, copy_assign)] +#[memberwise(move_assign, copy_assign)] #[byte_size(3)] pub struct ArrayMember { #[offset(0)] @@ -132,12 +137,13 @@ impl Default for ArrayMember { ZeroInitialization, VaArg, FnPtrArg, + TriviallyDefaultConstructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(default_constructor, copy_assign)] +#[memberwise(copy_assign)] #[byte_size(1)] pub struct EmptyBody { #[offset(0)] @@ -156,12 +162,13 @@ impl Destructible for EmptyBody { ZeroInitialization, VaArg, FnPtrArg, + TriviallyDefaultConstructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(default_constructor, copy_assign)] +#[memberwise(copy_assign)] #[byte_size(1)] pub struct Templated_char_ { #[offset(0)] @@ -184,12 +191,13 @@ impl Destructible for Templated_char_ { ZeroInitialization, VaArg, FnPtrArg, + TriviallyDefaultConstructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(default_constructor, copy_assign)] +#[memberwise(copy_assign)] #[byte_size(4)] pub struct Templated_int_ { #[offset(0)] @@ -212,12 +220,13 @@ impl Destructible for Templated_int_ { ZeroInitialization, VaArg, FnPtrArg, + TriviallyDefaultConstructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(default_constructor, copy_assign)] +#[memberwise(copy_assign)] #[byte_size(4)] pub struct Copied { #[offset(0)] @@ -242,12 +251,13 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, + TriviallyDefaultConstructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(copy_assign, default_constructor)] +#[memberwise(copy_assign)] #[byte_size(4)] pub struct Tagged { #[offset(0)] @@ -267,6 +277,7 @@ impl Destructible for Tagged { ZeroInitialization, VaArg, FnPtrArg, + TriviallyDefaultConstructible, Destructible, Memberwise, CopyConstructible, @@ -274,7 +285,7 @@ impl Destructible for Tagged { Swappable, Default, )] -#[memberwise(move_assign, default_constructor, copy_assign)] +#[memberwise(move_assign, copy_assign)] #[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 a08a6c7ec3..7ca26154cd 100644 --- a/tests/unit/out/refcount/destructor_params.rs +++ b/tests/unit/out/refcount/destructor_params.rs @@ -19,12 +19,13 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, + TriviallyDefaultConstructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(default_constructor, copy_assign)] +#[memberwise(copy_assign)] #[byte_size(4)] pub struct S { #[offset(0)] diff --git a/tests/unit/out/refcount/destructor_temporaries.rs b/tests/unit/out/refcount/destructor_temporaries.rs index a68fa96d27..8d672240e5 100644 --- a/tests/unit/out/refcount/destructor_temporaries.rs +++ b/tests/unit/out/refcount/destructor_temporaries.rs @@ -19,12 +19,13 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, + TriviallyDefaultConstructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(copy_assign, default_constructor)] +#[memberwise(copy_assign)] #[byte_size(4)] pub struct S { #[offset(0)] @@ -43,6 +44,7 @@ impl Destructible for S { ZeroInitialization, VaArg, FnPtrArg, + TriviallyDefaultConstructible, Destructible, Memberwise, CopyConstructible, @@ -50,7 +52,7 @@ impl Destructible for S { Swappable, Default, )] -#[memberwise(move_assign, default_constructor, copy_assign)] +#[memberwise(move_assign, copy_assign)] #[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 b25f47850e..4e2e30115b 100644 --- a/tests/unit/out/refcount/doubly_linked_list.rs +++ b/tests/unit/out/refcount/doubly_linked_list.rs @@ -13,11 +13,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 1fce4caaae..d0d934c149 100644 --- a/tests/unit/out/refcount/enum_default_in_static.rs +++ b/tests/unit/out/refcount/enum_default_in_static.rs @@ -18,7 +18,7 @@ pub const Mode_MODE_TWO: Mode = 2; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/enum_int_interop.rs b/tests/unit/out/refcount/enum_int_interop.rs index 4c360c6353..50af878240 100644 --- a/tests/unit/out/refcount/enum_int_interop.rs +++ b/tests/unit/out/refcount/enum_int_interop.rs @@ -26,11 +26,10 @@ pub const Tag_TAG_TWO: Tag = 2; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 b184c231b0..d56a7cf2be 100644 --- a/tests/unit/out/refcount/enum_int_interop_c.rs +++ b/tests/unit/out/refcount/enum_int_interop_c.rs @@ -26,7 +26,7 @@ pub const Tag_enum_TAG_TWO: Tag_enum = 2; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/exprs.rs b/tests/unit/out/refcount/exprs.rs index 92c5f095c2..af35f930f7 100644 --- a/tests/unit/out/refcount/exprs.rs +++ b/tests/unit/out/refcount/exprs.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct X { #[offset(0)] @@ -31,11 +30,10 @@ pub struct X { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 82827896d7..55acde50d1 100644 --- a/tests/unit/out/refcount/fft.rs +++ b/tests/unit/out/refcount/fft.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 c5e34dc158..7e17c2ef68 100644 --- a/tests/unit/out/refcount/field_aliasing.rs +++ b/tests/unit/out/refcount/field_aliasing.rs @@ -14,7 +14,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -32,7 +32,7 @@ pub struct In { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, )] #[byte_size(32)] @@ -68,7 +68,7 @@ impl Default for S { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/field_array_elem_ptr.rs b/tests/unit/out/refcount/field_array_elem_ptr.rs index b97a6b3350..810952eb44 100644 --- a/tests/unit/out/refcount/field_array_elem_ptr.rs +++ b/tests/unit/out/refcount/field_array_elem_ptr.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct Point { #[offset(0)] @@ -27,9 +26,15 @@ pub struct Point { pub y: i32, } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, )] -#[memberwise(default_constructor)] #[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 32d8c6a0b2..6733ac4975 100644 --- a/tests/unit/out/refcount/field_method_receiver.rs +++ b/tests/unit/out/refcount/field_method_receiver.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 792361dcb8..73093a856e 100644 --- a/tests/unit/out/refcount/field_pointers.rs +++ b/tests/unit/out/refcount/field_pointers.rs @@ -7,9 +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, Memberwise, TriviallyCopyable, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, )] -#[memberwise(default_constructor)] #[byte_size(12)] pub struct Inner { #[offset(0)] @@ -37,11 +43,10 @@ impl Default for Inner { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 8dc4a853d1..351fee566e 100644 --- a/tests/unit/out/refcount/field_pointers_malloced_struct.rs +++ b/tests/unit/out/refcount/field_pointers_malloced_struct.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 2892ee7979..d4a33fd864 100644 --- a/tests/unit/out/refcount/field_reinterpret_write_through.rs +++ b/tests/unit/out/refcount/field_reinterpret_write_through.rs @@ -14,7 +14,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -32,7 +32,7 @@ pub struct In { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, )] #[byte_size(40)] diff --git a/tests/unit/out/refcount/find.rs b/tests/unit/out/refcount/find.rs index dc45f81270..2c33f3e67e 100644 --- a/tests/unit/out/refcount/find.rs +++ b/tests/unit/out/refcount/find.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 f72fa26cdc..dedbeb550e 100644 --- a/tests/unit/out/refcount/first_field_ptr_covers_struct.rs +++ b/tests/unit/out/refcount/first_field_ptr_covers_struct.rs @@ -14,7 +14,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -33,7 +33,7 @@ pub struct In { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/first_member_downcast.rs b/tests/unit/out/refcount/first_member_downcast.rs index 1dd39b621a..2ae2ba0ab5 100644 --- a/tests/unit/out/refcount/first_member_downcast.rs +++ b/tests/unit/out/refcount/first_member_downcast.rs @@ -14,7 +14,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -31,7 +31,7 @@ pub struct base { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/flex_array_member_incomplete.rs b/tests/unit/out/refcount/flex_array_member_incomplete.rs index d198e534f1..9cc982b938 100644 --- a/tests/unit/out/refcount/flex_array_member_incomplete.rs +++ b/tests/unit/out/refcount/flex_array_member_incomplete.rs @@ -13,7 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, )] #[byte_size(4)] 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 b91871a943..6e100bd2cf 100644 --- a/tests/unit/out/refcount/flex_array_member_sibling_write.rs +++ b/tests/unit/out/refcount/flex_array_member_sibling_write.rs @@ -13,7 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, )] #[byte_size(8)] @@ -43,7 +43,7 @@ impl Default for S { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -61,7 +61,7 @@ pub struct E { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, )] #[byte_size(16)] diff --git a/tests/unit/out/refcount/fn_ptr_cast.rs b/tests/unit/out/refcount/fn_ptr_cast.rs index ea5b6fb237..5a0f58991f 100644 --- a/tests/unit/out/refcount/fn_ptr_cast.rs +++ b/tests/unit/out/refcount/fn_ptr_cast.rs @@ -31,11 +31,10 @@ pub fn test_double_cast_2() { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 c8dc28c3fa..0bac0bb413 100644 --- a/tests/unit/out/refcount/fn_ptr_stable_sort.rs +++ b/tests/unit/out/refcount/fn_ptr_stable_sort.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 cdf1ec760c..128d7d2399 100644 --- a/tests/unit/out/refcount/fn_ptr_struct.rs +++ b/tests/unit/out/refcount/fn_ptr_struct.rs @@ -13,11 +13,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(16)] pub struct Handler { #[offset(0)] @@ -40,11 +39,10 @@ pub fn negate_1(mut x: i32) -> i32 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 963bfce500..ee141633e2 100644 --- a/tests/unit/out/refcount/fn_ptr_typedef_cast.rs +++ b/tests/unit/out/refcount/fn_ptr_typedef_cast.rs @@ -26,7 +26,7 @@ pub fn via_size_t_return_3(mut b: u64) -> usize { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/fn_ptr_vtable.rs b/tests/unit/out/refcount/fn_ptr_vtable.rs index 75d3248f38..d7b6cf703b 100644 --- a/tests/unit/out/refcount/fn_ptr_vtable.rs +++ b/tests/unit/out/refcount/fn_ptr_vtable.rs @@ -13,11 +13,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 34fc55cf52..ed88a34c1b 100644 --- a/tests/unit/out/refcount/fn_ref.rs +++ b/tests/unit/out/refcount/fn_ref.rs @@ -28,7 +28,7 @@ pub fn call_forwarded_4(f: FnPtr i32>, mut x: i32) -> i32 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/for_body_destructor.rs b/tests/unit/out/refcount/for_body_destructor.rs index 6b0bccd3ea..77f04c5001 100644 --- a/tests/unit/out/refcount/for_body_destructor.rs +++ b/tests/unit/out/refcount/for_body_destructor.rs @@ -13,12 +13,13 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, + TriviallyDefaultConstructible, Memberwise, CopyConstructible, Movable, Default, )] -#[memberwise(default_constructor, copy_assign)] +#[memberwise(copy_assign)] #[byte_size(4)] pub struct Guard { #[offset(0)] diff --git a/tests/unit/out/refcount/friend.rs b/tests/unit/out/refcount/friend.rs index d562161d3b..be8d73196f 100644 --- a/tests/unit/out/refcount/friend.rs +++ b/tests/unit/out/refcount/friend.rs @@ -26,11 +26,10 @@ pub fn scaled_3(v: Ptr, mut k: f64) -> f64 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct V { #[offset(0)] @@ -52,11 +51,10 @@ pub fn get_4(w: Ptr) -> i32 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct W_int_ { #[offset(0)] @@ -73,11 +71,10 @@ pub fn get_5(w: Ptr) -> i64 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct W_long_ { #[offset(0)] @@ -91,11 +88,10 @@ pub struct W_long_ { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 174aed4071..36a73a6ce5 100644 --- a/tests/unit/out/refcount/function_overloading.rs +++ b/tests/unit/out/refcount/function_overloading.rs @@ -29,11 +29,10 @@ pub fn bar_4(x: Ptr) -> i32 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 093f653c35..730dd447c5 100644 --- a/tests/unit/out/refcount/global_call_temporaries.rs +++ b/tests/unit/out/refcount/global_call_temporaries.rs @@ -102,11 +102,10 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Item { #[offset(0)] diff --git a/tests/unit/out/refcount/global_non_const_init.rs b/tests/unit/out/refcount/global_non_const_init.rs index 0ae7b12795..4969644ed1 100644 --- a/tests/unit/out/refcount/global_non_const_init.rs +++ b/tests/unit/out/refcount/global_non_const_init.rs @@ -90,11 +90,10 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(1)] pub struct Holder {} thread_local!( diff --git a/tests/unit/out/refcount/global_pointers.rs b/tests/unit/out/refcount/global_pointers.rs index ecbab311d4..6d36fe5e09 100644 --- a/tests/unit/out/refcount/global_pointers.rs +++ b/tests/unit/out/refcount/global_pointers.rs @@ -13,11 +13,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 102c29538c..021b71d9a2 100644 --- a/tests/unit/out/refcount/global_without_initializer.rs +++ b/tests/unit/out/refcount/global_without_initializer.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 e984cdbab1..e42b37f3b9 100644 --- a/tests/unit/out/refcount/goto_aggregate_default.rs +++ b/tests/unit/out/refcount/goto_aggregate_default.rs @@ -14,7 +14,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/goto_cleanup.rs b/tests/unit/out/refcount/goto_cleanup.rs index 7745133aaa..72d277e6a2 100644 --- a/tests/unit/out/refcount/goto_cleanup.rs +++ b/tests/unit/out/refcount/goto_cleanup.rs @@ -83,7 +83,7 @@ pub fn from_switch_2(mut n: i32) -> i32 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/huffman.rs b/tests/unit/out/refcount/huffman.rs index 6dcb8dc2e4..48c9782dee 100644 --- a/tests/unit/out/refcount/huffman.rs +++ b/tests/unit/out/refcount/huffman.rs @@ -13,11 +13,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 244b3a8535..32f82f427e 100644 --- a/tests/unit/out/refcount/immutable-deref-on-func-call.rs +++ b/tests/unit/out/refcount/immutable-deref-on-func-call.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Item { #[offset(0)] diff --git a/tests/unit/out/refcount/init.rs b/tests/unit/out/refcount/init.rs index c4aea1f864..af6248358f 100644 --- a/tests/unit/out/refcount/init.rs +++ b/tests/unit/out/refcount/init.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 9814254946..b143917b21 100644 --- a/tests/unit/out/refcount/init_list.rs +++ b/tests/unit/out/refcount/init_list.rs @@ -17,11 +17,10 @@ pub fn f_0(list: Vec) { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct Pair { #[offset(0)] diff --git a/tests/unit/out/refcount/kruskal.rs b/tests/unit/out/refcount/kruskal.rs index d879e19e3c..c7bed88aaa 100644 --- a/tests/unit/out/refcount/kruskal.rs +++ b/tests/unit/out/refcount/kruskal.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 363ef059d5..8ed627fda3 100644 --- a/tests/unit/out/refcount/lambda_as_field.rs +++ b/tests/unit/out/refcount/lambda_as_field.rs @@ -13,11 +13,12 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, + TriviallyDefaultConstructible, Memberwise, CopyConstructible, Movable, )] -#[memberwise(default_constructor, copy_assign)] +#[memberwise(copy_assign)] #[byte_size(1)] pub struct Guard__lambda_at_lambda_as_field_cpp_34_13__ { #[offset(0)] @@ -63,9 +64,15 @@ impl Destructible for Guard__lambda_at_lambda_as_field_cpp_45_13__ { } } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct Holder__lambda_at_lambda_as_field_cpp_39_12__ { #[offset(0)] diff --git a/tests/unit/out/refcount/lambda_capture_ref.rs b/tests/unit/out/refcount/lambda_capture_ref.rs index 82eb224654..6eb83999c3 100644 --- a/tests/unit/out/refcount/lambda_capture_ref.rs +++ b/tests/unit/out/refcount/lambda_capture_ref.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 1ab6eee6a9..35f4e7de35 100644 --- a/tests/unit/out/refcount/lambda_capture_star_this.rs +++ b/tests/unit/out/refcount/lambda_capture_star_this.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 b1e2c00fed..48cac3a0f0 100644 --- a/tests/unit/out/refcount/lambda_capture_this.rs +++ b/tests/unit/out/refcount/lambda_capture_this.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 cac2673b47..dc0d6519a4 100644 --- a/tests/unit/out/refcount/lambda_capture_value.rs +++ b/tests/unit/out/refcount/lambda_capture_value.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct S { #[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 a6d607d66f..4eb1a8cd82 100644 --- a/tests/unit/out/refcount/lambda_generic_explicit_args.rs +++ b/tests/unit/out/refcount/lambda_generic_explicit_args.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Val { #[offset(0)] diff --git a/tests/unit/out/refcount/lambda_nested.rs b/tests/unit/out/refcount/lambda_nested.rs index 7e784f518b..19cb26cbdb 100644 --- a/tests/unit/out/refcount/lambda_nested.rs +++ b/tests/unit/out/refcount/lambda_nested.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 cfb5fd6d93..cc2b905054 100644 --- a/tests/unit/out/refcount/lambda_static_local.rs +++ b/tests/unit/out/refcount/lambda_static_local.rs @@ -86,11 +86,10 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 05eebfa56c..a24be77231 100644 --- a/tests/unit/out/refcount/libc_struct_without_default.rs +++ b/tests/unit/out/refcount/libc_struct_without_default.rs @@ -48,9 +48,15 @@ impl Default for UserDefined { } } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, )] -#[memberwise(default_constructor)] #[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 a79de20e11..eb9c1d7488 100644 --- a/tests/unit/out/refcount/linked_list.rs +++ b/tests/unit/out/refcount/linked_list.rs @@ -13,11 +13,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 c220df8663..54d8b3a425 100644 --- a/tests/unit/out/refcount/local_anon_struct_collision.rs +++ b/tests/unit/out/refcount/local_anon_struct_collision.rs @@ -20,7 +20,7 @@ pub fn first_0() -> i32 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -45,7 +45,7 @@ pub fn second_2() -> i32 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/local_record_template.rs b/tests/unit/out/refcount/local_record_template.rs index 795fcb60c0..417268e98e 100644 --- a/tests/unit/out/refcount/local_record_template.rs +++ b/tests/unit/out/refcount/local_record_template.rs @@ -37,11 +37,10 @@ pub fn wrap_10(mut v: i64) -> i32 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Local_5 { #[offset(0)] @@ -55,11 +54,10 @@ pub struct Local_5 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct Local_7 { #[offset(0)] @@ -77,11 +75,10 @@ pub fn other_11() -> i32 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(16)] pub struct Local_1 { #[offset(0)] @@ -110,11 +107,10 @@ fn main_0() -> i32 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Local_3 { #[offset(0)] diff --git a/tests/unit/out/refcount/map_key_identity.rs b/tests/unit/out/refcount/map_key_identity.rs index 47abbd3ee5..dd7635eeaa 100644 --- a/tests/unit/out/refcount/map_key_identity.rs +++ b/tests/unit/out/refcount/map_key_identity.rs @@ -17,11 +17,10 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct Key { #[offset(0)] diff --git a/tests/unit/out/refcount/memcpy_struct_bytes.rs b/tests/unit/out/refcount/memcpy_struct_bytes.rs index a17c0002b2..f4bfdf8820 100644 --- a/tests/unit/out/refcount/memcpy_struct_bytes.rs +++ b/tests/unit/out/refcount/memcpy_struct_bytes.rs @@ -14,7 +14,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/memcpy_struct_layouts.rs b/tests/unit/out/refcount/memcpy_struct_layouts.rs index d253e81e37..79f7c8cd1a 100644 --- a/tests/unit/out/refcount/memcpy_struct_layouts.rs +++ b/tests/unit/out/refcount/memcpy_struct_layouts.rs @@ -14,7 +14,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -37,7 +37,7 @@ pub struct packed { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -58,7 +58,7 @@ pub struct reordered { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -77,7 +77,7 @@ pub struct tail { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -96,7 +96,7 @@ pub struct nested { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, )] #[byte_size(8)] diff --git a/tests/unit/out/refcount/memcpy_struct_struct.rs b/tests/unit/out/refcount/memcpy_struct_struct.rs index 34aa1bafb7..8a4c3563f7 100644 --- a/tests/unit/out/refcount/memcpy_struct_struct.rs +++ b/tests/unit/out/refcount/memcpy_struct_struct.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 fd9b7a8c19..9debd268ff 100644 --- a/tests/unit/out/refcount/memset_struct_tail.rs +++ b/tests/unit/out/refcount/memset_struct_tail.rs @@ -13,7 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, )] #[byte_size(32)] diff --git a/tests/unit/out/refcount/nested_structs.rs b/tests/unit/out/refcount/nested_structs.rs index 479d2f985e..e88997c5c7 100644 --- a/tests/unit/out/refcount/nested_structs.rs +++ b/tests/unit/out/refcount/nested_structs.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Level0_Level1_1_Level2_1_Level3_1 { #[offset(0)] @@ -32,11 +31,10 @@ pub struct Level0_Level1_1_Level2_1_Level3_1 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct Level0_Level1_1_Level2_1_Level3_2 { #[offset(0)] @@ -52,11 +50,10 @@ pub struct Level0_Level1_1_Level2_1_Level3_2 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Level0_Level1_1_Level2_1 { #[offset(0)] @@ -70,11 +67,10 @@ pub struct Level0_Level1_1_Level2_1 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Level0_Level1_1 { #[offset(0)] @@ -88,11 +84,10 @@ pub struct Level0_Level1_1 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct Level0_Level1_2 { #[offset(0)] @@ -108,11 +103,10 @@ pub struct Level0_Level1_2 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 07cb27e4d6..8b075a627b 100644 --- a/tests/unit/out/refcount/new.rs +++ b/tests/unit/out/refcount/new.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 491fba9645..84d527d72b 100644 --- a/tests/unit/out/refcount/new_bst.rs +++ b/tests/unit/out/refcount/new_bst.rs @@ -13,11 +13,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 7f543997b4..f7d7b59779 100644 --- a/tests/unit/out/refcount/new_struct.rs +++ b/tests/unit/out/refcount/new_struct.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct Pair { #[offset(0)] @@ -34,11 +33,10 @@ pub struct Pair { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 ea8dd7b6af..50684d62f7 100644 --- a/tests/unit/out/refcount/nttp_distinct_specializations.rs +++ b/tests/unit/out/refcount/nttp_distinct_specializations.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct S_2_ { #[offset(0)] @@ -34,11 +33,10 @@ pub struct S_2_ { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct S_1_ { #[offset(0)] @@ -52,11 +50,10 @@ pub struct S_1_ { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 8c9813c487..5e769a9cf3 100644 --- a/tests/unit/out/refcount/offsetof.rs +++ b/tests/unit/out/refcount/offsetof.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(12)] pub struct Layout { #[offset(0)] @@ -29,9 +28,15 @@ pub struct Layout { pub c: u16, } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, )] -#[memberwise(default_constructor)] #[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 f74fb93a8e..57e54cc913 100644 --- a/tests/unit/out/refcount/opaque_forward_decl.rs +++ b/tests/unit/out/refcount/opaque_forward_decl.rs @@ -13,7 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/opaque_record_copy.rs b/tests/unit/out/refcount/opaque_record_copy.rs index bcec386aa6..868fa37299 100644 --- a/tests/unit/out/refcount/opaque_record_copy.rs +++ b/tests/unit/out/refcount/opaque_record_copy.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(1)] pub struct Probe {} #[derive( @@ -29,11 +28,10 @@ pub struct Probe {} ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 fb876af679..6d8dc545f9 100644 --- a/tests/unit/out/refcount/opaque_then_defined.rs +++ b/tests/unit/out/refcount/opaque_then_defined.rs @@ -13,7 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -32,7 +32,7 @@ pub struct list { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/operator_arithmetic_free.rs b/tests/unit/out/refcount/operator_arithmetic_free.rs index a11dcf5193..6aa2ec1264 100644 --- a/tests/unit/out/refcount/operator_arithmetic_free.rs +++ b/tests/unit/out/refcount/operator_arithmetic_free.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 1db97f7648..14fb214da2 100644 --- a/tests/unit/out/refcount/operator_arithmetic_member.rs +++ b/tests/unit/out/refcount/operator_arithmetic_member.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 3084655e27..ba2321d034 100644 --- a/tests/unit/out/refcount/operator_bitwise_free.rs +++ b/tests/unit/out/refcount/operator_bitwise_free.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 395baa006a..aedd780f74 100644 --- a/tests/unit/out/refcount/operator_bitwise_member.rs +++ b/tests/unit/out/refcount/operator_bitwise_member.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 d1d15c3878..1e95674b36 100644 --- a/tests/unit/out/refcount/operator_comparison_defaulted.rs +++ b/tests/unit/out/refcount/operator_comparison_defaulted.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct Eq { #[offset(0)] @@ -39,11 +38,10 @@ impl CppEq for Eq { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct Cmp { #[offset(0)] @@ -69,11 +67,10 @@ impl CppEq for Cmp { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Both { #[offset(0)] @@ -97,11 +94,10 @@ impl CppEq for Both { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct OrdOnly { #[offset(0)] @@ -125,11 +121,10 @@ impl CppEq for OrdOnly { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Inner { #[offset(0)] @@ -153,11 +148,10 @@ impl CppEq for Inner { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct Outer { #[offset(0)] @@ -184,11 +178,10 @@ impl CppEq for Outer { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Secondary { #[offset(0)] @@ -211,11 +204,10 @@ impl CppEq for Secondary { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 4bbe2a994b..1884dc7183 100644 --- a/tests/unit/out/refcount/operator_comparison_free.rs +++ b/tests/unit/out/refcount/operator_comparison_free.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct S { #[offset(0)] @@ -66,11 +65,10 @@ pub fn operator_lt_7(mut a: i32, b: Ptr) -> bool { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 a786f591ca..ee3014ac10 100644 --- a/tests/unit/out/refcount/operator_comparison_member.rs +++ b/tests/unit/out/refcount/operator_comparison_member.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 20bf2615e7..d1cd37776b 100644 --- a/tests/unit/out/refcount/operator_comparison_mixed.rs +++ b/tests/unit/out/refcount/operator_comparison_mixed.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 de9f03fdfd..98305fe7aa 100644 --- a/tests/unit/out/refcount/operator_comparison_nonbool.rs +++ b/tests/unit/out/refcount/operator_comparison_nonbool.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct X { #[offset(0)] @@ -60,11 +59,10 @@ pub fn operator_ge_5(mut a: X, mut b: X) -> i32 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Result { #[offset(0)] @@ -78,11 +76,10 @@ pub struct Result { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Custom { #[offset(0)] @@ -96,11 +93,10 @@ pub struct Custom { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Mixed { #[offset(0)] @@ -143,11 +139,10 @@ pub struct MyBool { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Boolish { #[offset(0)] @@ -207,11 +202,10 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 ed28164cc3..581d157864 100644 --- a/tests/unit/out/refcount/operator_compound_assignment_free.rs +++ b/tests/unit/out/refcount/operator_compound_assignment_free.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 e14d0ec15d..ba1b2cb9ae 100644 --- a/tests/unit/out/refcount/operator_compound_assignment_member.rs +++ b/tests/unit/out/refcount/operator_compound_assignment_member.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 4a6ce02ef1..7fe14b5f97 100644 --- a/tests/unit/out/refcount/operator_friend.rs +++ b/tests/unit/out/refcount/operator_friend.rs @@ -18,11 +18,10 @@ pub fn operator_eq_0(_a0: Ptr, _a1: Ptr) -> bool { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct Defaulted { #[offset(0)] @@ -58,11 +57,10 @@ pub fn operator_eq_2(_a0: Ptr, _a1: Ptr) -> bool { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct DefaultedOrd { #[offset(0)] @@ -97,11 +95,10 @@ pub fn operator_add_5(x: Ptr, y: Ptr) -> Inline { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Inline { #[offset(0)] @@ -125,11 +122,10 @@ impl CppEq for Inline { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct OutOfLine { #[offset(0)] @@ -163,11 +159,10 @@ pub fn operator_eq_10(x: Ptr, y: Ptr) -> bool { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Tmpl_int_ { #[offset(0)] @@ -191,11 +186,10 @@ impl CppEq for Tmpl_int_ { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct Tmpl_long_ { #[offset(0)] @@ -212,11 +206,10 @@ pub fn operator_eq_11(_a0: Ptr, _a1: Ptr ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 76efcaee83..3450be62fc 100644 --- a/tests/unit/out/refcount/operator_less_than.rs +++ b/tests/unit/out/refcount/operator_less_than.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 35767994c8..00c15017c1 100644 --- a/tests/unit/out/refcount/operator_logical_free.rs +++ b/tests/unit/out/refcount/operator_logical_free.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 bce7772810..f633eada1d 100644 --- a/tests/unit/out/refcount/operator_logical_member.rs +++ b/tests/unit/out/refcount/operator_logical_member.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 b58f504f86..dc1f21b0e5 100644 --- a/tests/unit/out/refcount/operator_member_pointer_free.rs +++ b/tests/unit/out/refcount/operator_member_pointer_free.rs @@ -14,20 +14,25 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Inner { #[offset(0)] pub x: i32, } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, )] -#[memberwise(default_constructor)] #[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 d1ddd58270..19aad4c322 100644 --- a/tests/unit/out/refcount/operator_member_pointer_member.rs +++ b/tests/unit/out/refcount/operator_member_pointer_member.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Inner { #[offset(0)] @@ -32,11 +31,10 @@ pub struct Inner { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(1)] pub struct Table {} impl Table { @@ -48,9 +46,15 @@ thread_local!( pub static table_0: Value> = Rc::new(RefCell::new(Box::new([7, 8, 9]))); ); #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, )] -#[memberwise(default_constructor)] #[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 89805f8b05..b374fe8e7c 100644 --- a/tests/unit/out/refcount/operator_other_free.rs +++ b/tests/unit/out/refcount/operator_other_free.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 7208a1c279..14e4b3ba85 100644 --- a/tests/unit/out/refcount/operator_other_member.rs +++ b/tests/unit/out/refcount/operator_other_member.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(1)] pub struct Static {} impl Static { @@ -35,11 +34,10 @@ impl Static { VaArg, FnPtrArg, CppFrom, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 9e8b787283..0dace84931 100644 --- a/tests/unit/out/refcount/operator_overloads.rs +++ b/tests/unit/out/refcount/operator_overloads.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 261012c6bf..7536bb88cb 100644 --- a/tests/unit/out/refcount/operator_qualifiers.rs +++ b/tests/unit/out/refcount/operator_qualifiers.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 675b9286dd..1989c8fa75 100644 --- a/tests/unit/out/refcount/operator_three_way.rs +++ b/tests/unit/out/refcount/operator_three_way.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 4a00b7fad9..cf9740e798 100644 --- a/tests/unit/out/refcount/operator_traits.rs +++ b/tests/unit/out/refcount/operator_traits.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Lt { #[offset(0)] @@ -42,11 +41,10 @@ impl CppEq for Lt { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Eq { #[offset(0)] @@ -65,11 +63,10 @@ impl CppEq for Eq { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Cmp { #[offset(0)] @@ -93,11 +90,10 @@ impl CppEq for Cmp { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Free { #[offset(0)] @@ -127,11 +123,10 @@ pub fn operator_eq_1(a: Ptr, b: Ptr) -> bool { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 54cfe5f6f4..4518022b92 100644 --- a/tests/unit/out/refcount/overload_mangling.rs +++ b/tests/unit/out/refcount/overload_mangling.rs @@ -27,11 +27,10 @@ pub fn twice_2(mut n: i32) -> i32 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(1)] pub struct Access_S_ {} #[derive( @@ -42,11 +41,10 @@ pub struct Access_S_ {} ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct S { #[offset(0)] @@ -60,11 +58,10 @@ pub struct S { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 98f937979e..5229ffd044 100644 --- a/tests/unit/out/refcount/pair_converting_construction.rs +++ b/tests/unit/out/refcount/pair_converting_construction.rs @@ -34,11 +34,10 @@ pub struct Celsius { VaArg, FnPtrArg, CppFrom, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[cpp_into(i32, to_i32)] #[byte_size(4)] pub struct Meters { @@ -140,11 +139,10 @@ impl Default for Fallback { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Counter { #[offset(0)] diff --git a/tests/unit/out/refcount/pod.rs b/tests/unit/out/refcount/pod.rs index bc7a7cb33f..f77fd3c72a 100644 --- a/tests/unit/out/refcount/pod.rs +++ b/tests/unit/out/refcount/pod.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 139dc6c4b5..2e0dd03248 100644 --- a/tests/unit/out/refcount/pointer_array.rs +++ b/tests/unit/out/refcount/pointer_array.rs @@ -7,9 +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, Memberwise, TriviallyCopyable, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, )] -#[memberwise(default_constructor)] #[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 05073d9188..3bbb93fbe1 100644 --- a/tests/unit/out/refcount/pointers.rs +++ b/tests/unit/out/refcount/pointers.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Test { #[offset(0)] diff --git a/tests/unit/out/refcount/ptr_cast_init.rs b/tests/unit/out/refcount/ptr_cast_init.rs index 7a2abd438e..87969f89ab 100644 --- a/tests/unit/out/refcount/ptr_cast_init.rs +++ b/tests/unit/out/refcount/ptr_cast_init.rs @@ -14,7 +14,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -33,7 +33,7 @@ pub struct header { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/push_emplace_back.rs b/tests/unit/out/refcount/push_emplace_back.rs index 71fe867b7b..ec49f1451d 100644 --- a/tests/unit/out/refcount/push_emplace_back.rs +++ b/tests/unit/out/refcount/push_emplace_back.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct Chunk { #[offset(0)] @@ -31,11 +30,10 @@ pub struct Chunk { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(16)] pub struct Writer { #[offset(0)] @@ -383,9 +381,15 @@ pub fn emplace_from_element_14(mut v: Ptr>>) { }; } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, )] -#[memberwise(default_constructor)] #[byte_size(24)] pub struct Plain { #[offset(0)] diff --git a/tests/unit/out/refcount/random.rs b/tests/unit/out/refcount/random.rs index c75fd3fd56..b1ada88bb9 100644 --- a/tests/unit/out/refcount/random.rs +++ b/tests/unit/out/refcount/random.rs @@ -13,7 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, )] #[byte_size(72)] @@ -68,11 +68,10 @@ pub fn zero_0() -> i32 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 f039ee1ec9..91523a2d9d 100644 --- a/tests/unit/out/refcount/reference_wrapper.rs +++ b/tests/unit/out/refcount/reference_wrapper.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 6f163db0ef..ef780e7d66 100644 --- a/tests/unit/out/refcount/references.rs +++ b/tests/unit/out/refcount/references.rs @@ -7,9 +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, Memberwise, TriviallyCopyable, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, )] -#[memberwise(default_constructor)] #[byte_size(16)] pub struct Pair { #[offset(0)] @@ -39,11 +45,10 @@ impl Default for Pair { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 9f134409b1..b5de33dd10 100644 --- a/tests/unit/out/refcount/refs_as_args.rs +++ b/tests/unit/out/refcount/refs_as_args.rs @@ -38,11 +38,10 @@ pub fn more_refs_0(x1: i32, x2: i32, r1: Ptr, r2: Ptr) { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 c3bc515f73..d151e3b247 100644 --- a/tests/unit/out/refcount/reinterpret_cast_ptr_cmp.rs +++ b/tests/unit/out/refcount/reinterpret_cast_ptr_cmp.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct S { #[offset(0)] @@ -27,9 +26,15 @@ pub struct S { pub y: i32, } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, )] -#[memberwise(default_constructor)] #[byte_size(28)] pub struct W { #[offset(0)] @@ -50,9 +55,15 @@ impl Default for W { } } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, )] -#[memberwise(default_constructor)] #[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 5caba9f067..1e4384f563 100644 --- a/tests/unit/out/refcount/reinterpret_cast_struct.rs +++ b/tests/unit/out/refcount/reinterpret_cast_struct.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 13d7c777ff..c73b57bcaf 100644 --- a/tests/unit/out/refcount/reinterpret_cast_struct_to_struct.rs +++ b/tests/unit/out/refcount/reinterpret_cast_struct_to_struct.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct Point { #[offset(0)] @@ -34,11 +33,10 @@ pub struct Point { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 ab65071ec6..73a0131a8c 100644 --- a/tests/unit/out/refcount/reserved_keywords.rs +++ b/tests/unit/out/refcount/reserved_keywords.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(152)] pub struct S { #[offset(0)] @@ -106,11 +105,10 @@ pub struct S { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(4)] pub struct type_ { #[offset(0)] @@ -124,11 +122,10 @@ pub struct type_ { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 a569922ac5..062413e198 100644 --- a/tests/unit/out/refcount/return_move.rs +++ b/tests/unit/out/refcount/return_move.rs @@ -13,11 +13,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(16)] pub struct node { #[offset(0)] @@ -33,11 +32,10 @@ pub struct node { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(16)] pub struct pair_t { #[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 9b1fdddff2..315b80bea9 100644 --- a/tests/unit/out/refcount/scalar_builtin_construct_destruct.rs +++ b/tests/unit/out/refcount/scalar_builtin_construct_destruct.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 b7305c10e8..a00d41a99d 100644 --- a/tests/unit/out/refcount/self_referencing_initializer.rs +++ b/tests/unit/out/refcount/self_referencing_initializer.rs @@ -13,11 +13,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct list_head { #[offset(0)] @@ -31,11 +30,10 @@ pub struct list_head { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(16)] pub struct node { #[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 5f37a51c4d..df8590e26b 100644 --- a/tests/unit/out/refcount/size_t_static_member.rs +++ b/tests/unit/out/refcount/size_t_static_member.rs @@ -17,11 +17,10 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(1)] pub struct S {} thread_local!( @@ -35,11 +34,10 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(1)] pub struct Table_char_ {} pub fn main() { diff --git a/tests/unit/out/refcount/static_local.rs b/tests/unit/out/refcount/static_local.rs index ae781e3dfd..0f536f87c9 100644 --- a/tests/unit/out/refcount/static_local.rs +++ b/tests/unit/out/refcount/static_local.rs @@ -41,11 +41,10 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 e92891f73f..e626bafe6b 100644 --- a/tests/unit/out/refcount/static_var_in_class.rs +++ b/tests/unit/out/refcount/static_var_in_class.rs @@ -17,11 +17,10 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(1)] pub struct C {} thread_local!( @@ -37,11 +36,10 @@ pub const anon_3_kValue: anon_3 = 3; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(1)] pub struct S {} impl S { diff --git a/tests/unit/out/refcount/strdup.rs b/tests/unit/out/refcount/strdup.rs index 664a0ba542..1135a0239a 100644 --- a/tests/unit/out/refcount/strdup.rs +++ b/tests/unit/out/refcount/strdup.rs @@ -13,7 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/string_literal_ptr_init.rs b/tests/unit/out/refcount/string_literal_ptr_init.rs index 5bdec31e47..faecbb65d5 100644 --- a/tests/unit/out/refcount/string_literal_ptr_init.rs +++ b/tests/unit/out/refcount/string_literal_ptr_init.rs @@ -13,7 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/string_substr.rs b/tests/unit/out/refcount/string_substr.rs index a39ab082f0..ee651aa954 100644 --- a/tests/unit/out/refcount/string_substr.rs +++ b/tests/unit/out/refcount/string_substr.rs @@ -13,7 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/struct_2d_array_field.rs b/tests/unit/out/refcount/struct_2d_array_field.rs index 755ec6e161..8ac998a96b 100644 --- a/tests/unit/out/refcount/struct_2d_array_field.rs +++ b/tests/unit/out/refcount/struct_2d_array_field.rs @@ -13,7 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, )] #[byte_size(40)] diff --git a/tests/unit/out/refcount/struct_member_array_adjacency.rs b/tests/unit/out/refcount/struct_member_array_adjacency.rs index eebc2f0783..62c22118f0 100644 --- a/tests/unit/out/refcount/struct_member_array_adjacency.rs +++ b/tests/unit/out/refcount/struct_member_array_adjacency.rs @@ -13,7 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, )] #[byte_size(32)] diff --git a/tests/unit/out/refcount/struct_ptr.rs b/tests/unit/out/refcount/struct_ptr.rs index f0247a718b..6be6fcf0b2 100644 --- a/tests/unit/out/refcount/struct_ptr.rs +++ b/tests/unit/out/refcount/struct_ptr.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 a7d85eaa13..3f93184600 100644 --- a/tests/unit/out/refcount/structured_binding_range_for.rs +++ b/tests/unit/out/refcount/structured_binding_range_for.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 68638e555d..87a29e0e56 100644 --- a/tests/unit/out/refcount/structured_binding_ref.rs +++ b/tests/unit/out/refcount/structured_binding_ref.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 deb1d0e7df..6a388376ed 100644 --- a/tests/unit/out/refcount/structured_binding_trivial.rs +++ b/tests/unit/out/refcount/structured_binding_trivial.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 f007cd7459..f86e8dbb0a 100644 --- a/tests/unit/out/refcount/tag_vs_identifier_collision.rs +++ b/tests/unit/out/refcount/tag_vs_identifier_collision.rs @@ -18,7 +18,7 @@ pub const widget_enum_MODE_DONE: widget_enum = 2; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -37,7 +37,7 @@ pub struct widget { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -49,7 +49,13 @@ pub struct point_struct { pub y: i32, } #[derive( - VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, + ByteRepr, + Clone, + ZeroInitialization, )] #[byte_size(4)] pub struct point { @@ -74,7 +80,13 @@ impl Default for point { } } #[derive( - VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, + ByteRepr, + Clone, + ZeroInitialization, )] #[byte_size(4)] pub struct slot_union { @@ -109,7 +121,7 @@ pub const slot_SLOT_B: slot = 1; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -126,7 +138,7 @@ pub struct Inner { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -144,7 +156,7 @@ pub struct Outer { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/template_static_member.rs b/tests/unit/out/refcount/template_static_member.rs index 8dafaaf0e1..8f0105ef25 100644 --- a/tests/unit/out/refcount/template_static_member.rs +++ b/tests/unit/out/refcount/template_static_member.rs @@ -17,11 +17,10 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(1)] pub struct Static_int_ {} thread_local!( @@ -35,11 +34,10 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(1)] pub struct Static_char_ {} thread_local!( @@ -53,11 +51,10 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(1)] pub struct Static_long_ {} thread_local!( @@ -74,11 +71,10 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(1)] pub struct Range_int_ {} thread_local!( @@ -95,11 +91,10 @@ thread_local!( ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(1)] pub struct Range_long_ {} pub fn main() { diff --git a/tests/unit/out/refcount/typedef-anon-struct.rs b/tests/unit/out/refcount/typedef-anon-struct.rs index 05797da470..896757b8d9 100644 --- a/tests/unit/out/refcount/typedef-anon-struct.rs +++ b/tests/unit/out/refcount/typedef-anon-struct.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 308b333975..5016cccfce 100644 --- a/tests/unit/out/refcount/unary_expr_or_type_trait.rs +++ b/tests/unit/out/refcount/unary_expr_or_type_trait.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 5cea4d85b8..5b10d7646f 100644 --- a/tests/unit/out/refcount/unboxed_locals.rs +++ b/tests/unit/out/refcount/unboxed_locals.rs @@ -22,11 +22,10 @@ pub fn inc_1(r: Ptr) { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct Pair { #[offset(0)] diff --git a/tests/unit/out/refcount/unboxed_records.rs b/tests/unit/out/refcount/unboxed_records.rs index 3b5ea5d7cf..c8410306de 100644 --- a/tests/unit/out/refcount/unboxed_records.rs +++ b/tests/unit/out/refcount/unboxed_records.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(8)] pub struct Inner { #[offset(0)] @@ -27,9 +26,15 @@ pub struct Inner { pub b: i32, } #[derive( - Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, Memberwise, TriviallyCopyable, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, )] -#[memberwise(default_constructor)] #[byte_size(48)] pub struct Cookie { #[offset(0)] diff --git a/tests/unit/out/refcount/union_addrof_external.rs b/tests/unit/out/refcount/union_addrof_external.rs index 09fb092534..6987c6e70c 100644 --- a/tests/unit/out/refcount/union_addrof_external.rs +++ b/tests/unit/out/refcount/union_addrof_external.rs @@ -13,7 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, )] #[byte_size(16)] @@ -42,7 +42,13 @@ impl Default for record { } } #[derive( - VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, + ByteRepr, + Clone, + ZeroInitialization, )] #[byte_size(128)] pub struct anon_0 { @@ -73,7 +79,7 @@ impl Default for anon_0 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/union_basic.rs b/tests/unit/out/refcount/union_basic.rs index 3c601c962c..0dc7a5de49 100644 --- a/tests/unit/out/refcount/union_basic.rs +++ b/tests/unit/out/refcount/union_basic.rs @@ -7,7 +7,13 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, + ByteRepr, + Clone, + ZeroInitialization, )] #[byte_size(4)] pub struct basic { @@ -32,7 +38,13 @@ impl Default for basic { } } #[derive( - VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, + ByteRepr, + Clone, + ZeroInitialization, )] #[byte_size(1)] pub struct empty { @@ -50,7 +62,13 @@ impl Default for empty { } } #[derive( - VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, + ByteRepr, + Clone, + ZeroInitialization, )] #[byte_size(8)] pub struct underscores { @@ -130,7 +148,13 @@ fn main_0() -> i32 { return 0; } #[derive( - VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, + ByteRepr, + Clone, + ZeroInitialization, )] #[byte_size(4)] pub struct anon_0 { diff --git a/tests/unit/out/refcount/union_cross_arm_cast.rs b/tests/unit/out/refcount/union_cross_arm_cast.rs index 7bc3b49b0b..d4871fa382 100644 --- a/tests/unit/out/refcount/union_cross_arm_cast.rs +++ b/tests/unit/out/refcount/union_cross_arm_cast.rs @@ -13,7 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, )] #[byte_size(16)] @@ -42,7 +42,7 @@ impl Default for shape_a { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, )] #[byte_size(28)] @@ -74,7 +74,13 @@ impl Default for shape_b { } } #[derive( - VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, + ByteRepr, + Clone, + ZeroInitialization, )] #[byte_size(64)] pub struct anon_0 { @@ -108,7 +114,7 @@ impl Default for anon_0 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/union_field_alignment.rs b/tests/unit/out/refcount/union_field_alignment.rs index eced756fe4..f2f47c1f1b 100644 --- a/tests/unit/out/refcount/union_field_alignment.rs +++ b/tests/unit/out/refcount/union_field_alignment.rs @@ -7,7 +7,13 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, + ByteRepr, + Clone, + ZeroInitialization, )] #[byte_size(8)] pub struct anon_0 { @@ -38,7 +44,7 @@ impl Default for anon_0 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/union_flex_array_member.rs b/tests/unit/out/refcount/union_flex_array_member.rs index d122b3f83f..0cc7bfa269 100644 --- a/tests/unit/out/refcount/union_flex_array_member.rs +++ b/tests/unit/out/refcount/union_flex_array_member.rs @@ -7,7 +7,13 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; #[derive( - VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, + ByteRepr, + Clone, + ZeroInitialization, )] #[byte_size(8)] pub struct anon_0 { @@ -38,7 +44,7 @@ impl Default for anon_0 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/union_memset_memcpy.rs b/tests/unit/out/refcount/union_memset_memcpy.rs index a9776a4229..74c3826b41 100644 --- a/tests/unit/out/refcount/union_memset_memcpy.rs +++ b/tests/unit/out/refcount/union_memset_memcpy.rs @@ -13,7 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, )] #[byte_size(16)] @@ -42,7 +42,7 @@ impl Default for shape_a { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, )] #[byte_size(16)] @@ -71,7 +71,13 @@ impl Default for shape_b { } } #[derive( - VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, + ByteRepr, + Clone, + ZeroInitialization, )] #[byte_size(256)] pub struct anon_0 { @@ -105,7 +111,7 @@ impl Default for anon_0 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/union_nested.rs b/tests/unit/out/refcount/union_nested.rs index 462bcfe60a..85282bf7c9 100644 --- a/tests/unit/out/refcount/union_nested.rs +++ b/tests/unit/out/refcount/union_nested.rs @@ -13,7 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, )] #[byte_size(16)] @@ -36,7 +36,13 @@ impl Default for record { } } #[derive( - VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, + ByteRepr, + Clone, + ZeroInitialization, )] #[byte_size(128)] pub struct anon_0 { @@ -67,7 +73,7 @@ impl Default for anon_0 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -78,7 +84,13 @@ pub struct inner { pub view: anon_0, } #[derive( - VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, + ByteRepr, + Clone, + ZeroInitialization, )] #[byte_size(128)] pub struct anon_1 { @@ -109,7 +121,7 @@ impl Default for anon_1 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/union_pointer_pun_address.rs b/tests/unit/out/refcount/union_pointer_pun_address.rs index 8d37a4e617..69aea799ce 100644 --- a/tests/unit/out/refcount/union_pointer_pun_address.rs +++ b/tests/unit/out/refcount/union_pointer_pun_address.rs @@ -14,7 +14,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -30,7 +30,7 @@ pub struct node_a { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -56,7 +56,13 @@ fn main_0() -> i32 { return 0; } #[derive( - VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, + ByteRepr, + Clone, + ZeroInitialization, )] #[byte_size(8)] pub struct anon_0 { diff --git a/tests/unit/out/refcount/union_pointer_pun_writethrough.rs b/tests/unit/out/refcount/union_pointer_pun_writethrough.rs index a04e7d4613..c256754f30 100644 --- a/tests/unit/out/refcount/union_pointer_pun_writethrough.rs +++ b/tests/unit/out/refcount/union_pointer_pun_writethrough.rs @@ -19,7 +19,13 @@ fn main_0() -> i32 { return 0; } #[derive( - VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, + ByteRepr, + Clone, + ZeroInitialization, )] #[byte_size(8)] pub struct anon_0 { diff --git a/tests/unit/out/refcount/union_struct_dual_use.rs b/tests/unit/out/refcount/union_struct_dual_use.rs index 1bd3abb707..734892b9fe 100644 --- a/tests/unit/out/refcount/union_struct_dual_use.rs +++ b/tests/unit/out/refcount/union_struct_dual_use.rs @@ -14,7 +14,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -29,7 +29,13 @@ pub fn sum_inner_0(mut i: Ptr) -> i32 { return ({ i.with(|__s| __s.a) } + { i.with(|__s| __s.b) }); } #[derive( - VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, + ByteRepr, + Clone, + ZeroInitialization, )] #[byte_size(16)] pub struct anon_1 { @@ -60,7 +66,7 @@ impl Default for anon_1 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/union_tagged_many_arms.rs b/tests/unit/out/refcount/union_tagged_many_arms.rs index 097272f041..83cc27c144 100644 --- a/tests/unit/out/refcount/union_tagged_many_arms.rs +++ b/tests/unit/out/refcount/union_tagged_many_arms.rs @@ -13,7 +13,13 @@ 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, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, + ByteRepr, + Clone, + ZeroInitialization, )] #[byte_size(8)] pub struct anon_0 { @@ -53,7 +59,7 @@ impl Default for anon_0 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/union_tagged_simple.rs b/tests/unit/out/refcount/union_tagged_simple.rs index abef917495..8ecd6d388a 100644 --- a/tests/unit/out/refcount/union_tagged_simple.rs +++ b/tests/unit/out/refcount/union_tagged_simple.rs @@ -10,7 +10,13 @@ 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, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, + ByteRepr, + Clone, + ZeroInitialization, )] #[byte_size(8)] pub struct anon_0 { @@ -41,7 +47,7 @@ impl Default for anon_0 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/union_tagged_struct_arms.rs b/tests/unit/out/refcount/union_tagged_struct_arms.rs index 70554efe76..38b2f15ac3 100644 --- a/tests/unit/out/refcount/union_tagged_struct_arms.rs +++ b/tests/unit/out/refcount/union_tagged_struct_arms.rs @@ -17,7 +17,7 @@ pub const Choice_enum_C_INTEGERS: Choice_enum = 3; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -39,7 +39,7 @@ pub struct anon_1 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -62,7 +62,7 @@ pub struct anon_2 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -80,7 +80,13 @@ pub struct anon_3 { pub width: i32, } #[derive( - VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, + ByteRepr, + Clone, + ZeroInitialization, )] #[byte_size(40)] pub struct anon_0 { @@ -114,7 +120,7 @@ impl Default for anon_0 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] 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 e9a2a623f0..4193557584 100644 --- a/tests/unit/out/refcount/union_void_ptr_sized_deref.rs +++ b/tests/unit/out/refcount/union_void_ptr_sized_deref.rs @@ -11,7 +11,13 @@ 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, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, + ByteRepr, + Clone, + ZeroInitialization, )] #[byte_size(8)] pub struct anon_0 { @@ -48,7 +54,7 @@ impl Default for anon_0 { ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/unique_ptr.rs b/tests/unit/out/refcount/unique_ptr.rs index ecf779d62a..68bef48b82 100644 --- a/tests/unit/out/refcount/unique_ptr.rs +++ b/tests/unit/out/refcount/unique_ptr.rs @@ -29,11 +29,10 @@ impl DefaultConstructible for SafePointer { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 4a8f86e0d7..1485661a7a 100644 --- a/tests/unit/out/refcount/unique_ptr_field_reset.rs +++ b/tests/unit/out/refcount/unique_ptr_field_reset.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 b25972dd3d..83088c96fd 100644 --- a/tests/unit/out/refcount/unique_ptr_nested.rs +++ b/tests/unit/out/refcount/unique_ptr_nested.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 05afdafb01..c265f0cfa5 100644 --- a/tests/unit/out/refcount/unique_ptr_struct.rs +++ b/tests/unit/out/refcount/unique_ptr_struct.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 5ae1c6b310..15514399be 100644 --- a/tests/unit/out/refcount/va_arg_mixed_types.rs +++ b/tests/unit/out/refcount/va_arg_mixed_types.rs @@ -14,7 +14,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] 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 1ccc584652..b3b8484a2f 100644 --- a/tests/unit/out/refcount/va_arg_non_primitive_ptrs.rs +++ b/tests/unit/out/refcount/va_arg_non_primitive_ptrs.rs @@ -13,7 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/va_arg_struct_ctx.rs b/tests/unit/out/refcount/va_arg_struct_ctx.rs index 2fbfedcf65..bff2e8b664 100644 --- a/tests/unit/out/refcount/va_arg_struct_ctx.rs +++ b/tests/unit/out/refcount/va_arg_struct_ctx.rs @@ -14,7 +14,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] @@ -35,7 +35,13 @@ pub fn set_error_0(mut ctx: Ptr, fmt: Ptr, __args: Box<[VaArg]>) { } } #[derive( - VaArg, FnPtrArg, DefaultConstructible, TriviallyCopyable, ByteRepr, Clone, ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, + ByteRepr, + Clone, + ZeroInitialization, )] #[byte_size(8)] pub struct value { diff --git a/tests/unit/out/refcount/va_arg_void_ptr.rs b/tests/unit/out/refcount/va_arg_void_ptr.rs index dd959b294a..f852755b22 100644 --- a/tests/unit/out/refcount/va_arg_void_ptr.rs +++ b/tests/unit/out/refcount/va_arg_void_ptr.rs @@ -13,7 +13,7 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - DefaultConstructible, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] diff --git a/tests/unit/out/refcount/va_list_field.rs b/tests/unit/out/refcount/va_list_field.rs index 8b546942eb..24f3f3e71b 100644 --- a/tests/unit/out/refcount/va_list_field.rs +++ b/tests/unit/out/refcount/va_list_field.rs @@ -81,11 +81,10 @@ pub fn sum_ptr_2(n: i32, __args: Box<[VaArg]>) -> i32 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 c238d0d575..fc0ddfc548 100644 --- a/tests/unit/out/refcount/vector.rs +++ b/tests/unit/out/refcount/vector.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 1c65c3a547..cc1b881f20 100644 --- a/tests/unit/out/refcount/vector_iter_range_ctor.rs +++ b/tests/unit/out/refcount/vector_iter_range_ctor.rs @@ -34,11 +34,10 @@ pub struct Degrees { VaArg, FnPtrArg, CppFrom, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 a54801b365..ce4e2b4ca4 100644 --- a/tests/unit/out/refcount/vector_subscript_direct.rs +++ b/tests/unit/out/refcount/vector_subscript_direct.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 a2a7b7b5e7..e8286a88f2 100644 --- a/tests/unit/out/refcount/vector_with_allocator.rs +++ b/tests/unit/out/refcount/vector_with_allocator.rs @@ -14,11 +14,10 @@ use std::rc::{Rc, Weak}; ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[byte_size(1)] pub struct TestAllocator_int_ {} #[derive( @@ -29,11 +28,10 @@ pub struct TestAllocator_int_ {} ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 4a50e89fb3..993d5af25f 100644 --- a/tests/unit/out/refcount/void_cast.rs +++ b/tests/unit/out/refcount/void_cast.rs @@ -49,11 +49,10 @@ pub fn bump_and_return_4() -> i32 { ZeroInitialization, VaArg, FnPtrArg, - Memberwise, + TriviallyDefaultConstructible, TriviallyCopyable, Default, )] -#[memberwise(default_constructor)] #[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 3158e132a9..e759fb132e 100644 --- a/tests/unit/out/unsafe/05_new.rs +++ b/tests/unit/out/unsafe/05_new.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct A {} #[repr(C)] #[derive( @@ -26,11 +25,10 @@ pub struct A {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 b173fb9b9f..f4eca31939 100644 --- a/tests/unit/out/unsafe/10_struct.rs +++ b/tests/unit/out/unsafe/10_struct.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct GraphNode { pub dst: u32, pub next: *mut GraphNode, @@ -29,11 +28,10 @@ pub struct GraphNode { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Graph { pub V: u32, pub adj: *mut *mut GraphNode, @@ -94,11 +92,10 @@ impl Declared {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 1d664375e5..f341572944 100644 --- a/tests/unit/out/unsafe/addr_of_global.rs +++ b/tests/unit/out/unsafe/addr_of_global.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Inner { pub value: i32, } @@ -28,11 +27,10 @@ pub struct Inner { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 6b58974607..41649bba63 100644 --- a/tests/unit/out/unsafe/anonymous-struct.rs +++ b/tests/unit/out/unsafe/anonymous-struct.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Outer_Named { pub a: i32, pub b: i32, @@ -29,11 +28,10 @@ pub struct Outer_Named { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct anon_0 { pub c: i32, pub d: i32, @@ -45,11 +43,10 @@ pub struct anon_0 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct anon_1 { pub g: i32, pub h: i32, @@ -61,11 +58,10 @@ pub struct anon_1 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct anon_2 { pub e: i32, pub f: i32, @@ -77,11 +73,10 @@ pub struct anon_2 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct anon_4 { pub j: i32, } @@ -92,11 +87,10 @@ pub struct anon_4 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct anon_5 { pub k: i32, } @@ -107,11 +101,10 @@ pub struct anon_5 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct anon_3 { pub i: i32, pub inner_named: anon_4, @@ -124,11 +117,10 @@ pub struct anon_3 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Outer { pub named: Outer_Named, pub anonymous_named_0: anon_0, @@ -190,11 +182,10 @@ unsafe fn main_0() -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 8c7c7a6d6d..b0a56bd075 100644 --- a/tests/unit/out/unsafe/anonymous-struct_c.rs +++ b/tests/unit/out/unsafe/anonymous-struct_c.rs @@ -13,7 +13,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -28,7 +28,7 @@ pub struct Named { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -43,7 +43,7 @@ pub struct anon_0 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -58,7 +58,7 @@ pub struct anon_1 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -73,7 +73,7 @@ pub struct anon_2 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -87,7 +87,7 @@ pub struct anon_4 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -101,7 +101,7 @@ pub struct anon_5 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -117,7 +117,7 @@ pub struct anon_3 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -188,7 +188,7 @@ unsafe fn main_0() -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/anonymous_enum.rs b/tests/unit/out/unsafe/anonymous_enum.rs index 006a3afdd1..0914fe7a73 100644 --- a/tests/unit/out/unsafe/anonymous_enum.rs +++ b/tests/unit/out/unsafe/anonymous_enum.rs @@ -19,11 +19,10 @@ pub const anon_1_SECOND_B: anon_1 = 1; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct S { pub a: i32, } @@ -40,11 +39,10 @@ pub const anon_2_FIELD_B: anon_2 = 1; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 0b58d03a13..74794bce29 100644 --- a/tests/unit/out/unsafe/anonymous_enum_c.rs +++ b/tests/unit/out/unsafe/anonymous_enum_c.rs @@ -19,7 +19,7 @@ pub const anon_1_SECOND_B: anon_1 = 1; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -39,7 +39,7 @@ pub const anon_2_FIELD_B: anon_2 = 1; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/array_const_init.rs b/tests/unit/out/unsafe/array_const_init.rs index 6e16428b8b..4c1845c3e7 100644 --- a/tests/unit/out/unsafe/array_const_init.rs +++ b/tests/unit/out/unsafe/array_const_init.rs @@ -13,7 +13,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -36,7 +36,7 @@ pub static mut s_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/array_field_addr.rs b/tests/unit/out/unsafe/array_field_addr.rs index 0ac36a4b48..268f5269a2 100644 --- a/tests/unit/out/unsafe/array_field_addr.rs +++ b/tests/unit/out/unsafe/array_field_addr.rs @@ -13,7 +13,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/array_reference.rs b/tests/unit/out/unsafe/array_reference.rs index 76aa1b2ed2..5f8e415d87 100644 --- a/tests/unit/out/unsafe/array_reference.rs +++ b/tests/unit/out/unsafe/array_reference.rs @@ -63,11 +63,10 @@ pub unsafe fn pick_10(s: *const [libc::c_char; 5]) -> *const [libc::c_char; 5] { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 c7b393f371..cfe9e4b522 100644 --- a/tests/unit/out/unsafe/as_const.rs +++ b/tests/unit/out/unsafe/as_const.rs @@ -16,11 +16,10 @@ pub const Overload_kConstOverload: Overload = 2; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 bcbffb5a8c..19cbba57bc 100644 --- a/tests/unit/out/unsafe/assign_rhs_first.rs +++ b/tests/unit/out/unsafe/assign_rhs_first.rs @@ -19,11 +19,10 @@ pub unsafe fn advance_1() -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 0f4c5c263c..d1b435ad6f 100644 --- a/tests/unit/out/unsafe/assignment_single_eval.rs +++ b/tests/unit/out/unsafe/assignment_single_eval.rs @@ -842,7 +842,7 @@ pub unsafe fn test_reference_members_9() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -856,7 +856,7 @@ pub struct Slot_6 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -870,7 +870,7 @@ pub struct Slot_8 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -928,11 +928,10 @@ pub unsafe fn test_pointer_elements_11() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Holder_12 { pub p: *mut i32, } @@ -964,7 +963,7 @@ pub unsafe fn test_reference_pointer_13() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -1046,11 +1045,10 @@ pub unsafe fn test_reference_subfields_18() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Index_16 { pub value: u32, } @@ -1061,7 +1059,7 @@ pub struct Index_16 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -1075,11 +1073,10 @@ pub struct Slot_17 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Index_19 { pub value: i16, } @@ -1090,7 +1087,7 @@ pub struct Index_19 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -1139,11 +1136,10 @@ pub unsafe fn observe_24(mut assigned: i32, mut stored: *const i32) -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct GlobalRecord_Inner { pub value: i32, } @@ -1154,11 +1150,10 @@ pub struct GlobalRecord_Inner { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct GlobalRecord { pub inner: GlobalRecord_Inner, } @@ -1430,11 +1425,10 @@ static mut flag_31: std::cell::LazyCell = std::cell::LazyCell::new(|| unsa VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Record_32 { pub value: i32, } @@ -1445,11 +1439,10 @@ pub struct Record_32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Link_33 { pub next: *mut Link_33, } @@ -1462,11 +1455,10 @@ pub static mut selected_values_34: std::cell::LazyCell<[u32; 3]> = VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct IndexedBinding {} impl IndexedBinding { pub unsafe fn get_1_0(&mut self) -> *mut u32 { @@ -1691,11 +1683,10 @@ pub static mut global_rows_46: std::cell::LazyCell<[[u32; 2]; 2]> = VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct IndexedMember { pub key: i32, pub value: u32, @@ -1960,11 +1951,10 @@ pub static mut scoped_pointers_53: std::cell::LazyCell<[*mut u32; 1]> = VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct PointerSelector { pub ptr: *mut u32, } @@ -2147,11 +2137,10 @@ impl DefaultConstructibleUnsafe for Counts_59 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Pair_60 { pub u: u32, pub f: i32, @@ -2459,11 +2448,10 @@ unsafe fn main_0() -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Index_62 { pub value: i32, } @@ -2474,11 +2462,10 @@ pub struct Index_62 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 f5b967b39e..408ea795bd 100644 --- a/tests/unit/out/unsafe/bounded_struct_ptr.rs +++ b/tests/unit/out/unsafe/bounded_struct_ptr.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 da743a7a46..d66b21ad01 100644 --- a/tests/unit/out/unsafe/bst.rs +++ b/tests/unit/out/unsafe/bst.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 56efdf13ad..00cfcdd988 100644 --- a/tests/unit/out/unsafe/c_struct.rs +++ b/tests/unit/out/unsafe/c_struct.rs @@ -13,7 +13,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -28,7 +28,7 @@ pub struct Point { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -43,7 +43,7 @@ pub struct Line { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -62,7 +62,7 @@ pub const Color_BLUE: Color = 2; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -77,7 +77,7 @@ pub struct Inner { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/cast.rs b/tests/unit/out/unsafe/cast.rs index c32f956c62..a5affd3717 100644 --- a/tests/unit/out/unsafe/cast.rs +++ b/tests/unit/out/unsafe/cast.rs @@ -17,11 +17,10 @@ pub const E_C: E = 2; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Pair { pub x: i32, pub y: i32, @@ -33,11 +32,10 @@ pub struct Pair { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Wide { pub c: libc::c_char, } @@ -48,11 +46,10 @@ pub struct Wide { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 ac129d2de3..6cc29e2494 100644 --- a/tests/unit/out/unsafe/cast_array_to_pointer_decay.rs +++ b/tests/unit/out/unsafe/cast_array_to_pointer_decay.rs @@ -23,11 +23,10 @@ pub unsafe fn strlen_1(mut s: *mut libc::c_char) -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Row { pub a: [i32; 3], } diff --git a/tests/unit/out/unsafe/class.rs b/tests/unit/out/unsafe/class.rs index 3941476384..dbd48a62a6 100644 --- a/tests/unit/out/unsafe/class.rs +++ b/tests/unit/out/unsafe/class.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Pair { pub first: i32, pub second: i32, @@ -58,11 +57,10 @@ impl Pair { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Route { pub path: Pair, pub cost: f64, @@ -81,11 +79,10 @@ impl Route { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Counter { pub v: i32, pub calls: i32, @@ -113,11 +110,10 @@ impl std::cmp::Eq for Counter {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 c414598b10..acb08b983b 100644 --- a/tests/unit/out/unsafe/class_template_lazy_member.rs +++ b/tests/unit/out/unsafe/class_template_lazy_member.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Point { pub x: i32, } @@ -28,11 +27,10 @@ pub struct Point { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Box_int_ { pub val: i32, } @@ -48,11 +46,10 @@ impl Box_int_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Box_Point_ { pub val: Point, } @@ -68,11 +65,10 @@ impl Box_Point_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Deduced_int_ { pub val: i32, } @@ -88,11 +84,10 @@ impl Deduced_int_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 c2a4f9d216..443b017cc9 100644 --- a/tests/unit/out/unsafe/class_templates.rs +++ b/tests/unit/out/unsafe/class_templates.rs @@ -148,11 +148,10 @@ impl DefaultConstructibleUnsafe for MyContainer_float_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Boxed_short_ { pub value: i16, } @@ -171,11 +170,10 @@ impl Boxed_short_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Boxed_int_ { pub value: i32, } @@ -194,11 +192,10 @@ impl Boxed_int_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Boxed_long_ { pub value: i64, } @@ -217,11 +214,10 @@ impl Boxed_long_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Outer_int__Inner_int_ { pub t: i32, pub u: i32, @@ -238,11 +234,10 @@ impl Outer_int__Inner_int_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Outer_int_ { pub v: i32, } @@ -258,11 +253,10 @@ impl Outer_int_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Outer_long__Inner_int_ { pub t: i64, pub u: i32, @@ -279,11 +273,10 @@ impl Outer_long__Inner_int_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Outer_long__Inner_char_ { pub t: i64, pub u: libc::c_char, @@ -300,11 +293,10 @@ impl Outer_long__Inner_char_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Outer_long_ { pub v: i64, } @@ -320,11 +312,10 @@ impl Outer_long_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 dec18f1168..9c028caa0f 100644 --- a/tests/unit/out/unsafe/clone_vs_move.rs +++ b/tests/unit/out/unsafe/clone_vs_move.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Bar { pub w: i32, } @@ -28,7 +27,7 @@ pub struct Bar { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -46,7 +45,7 @@ pub struct Foo { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/comma_operator.rs b/tests/unit/out/unsafe/comma_operator.rs index 86864b4712..eb4f607e37 100644 --- a/tests/unit/out/unsafe/comma_operator.rs +++ b/tests/unit/out/unsafe/comma_operator.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 eb36708200..6d0fe914cd 100644 --- a/tests/unit/out/unsafe/complex_function.rs +++ b/tests/unit/out/unsafe/complex_function.rs @@ -22,11 +22,10 @@ pub unsafe fn bar_2(x: *mut i32) -> *mut i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct X1 { pub v: i32, } @@ -37,7 +36,7 @@ pub struct X1 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -56,11 +55,10 @@ impl X2 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct X3 { pub v: *mut X2, } @@ -76,11 +74,10 @@ impl X3 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 954e808663..076ee701db 100644 --- a/tests/unit/out/unsafe/compound_assign_paren.rs +++ b/tests/unit/out/unsafe/compound_assign_paren.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Item { pub flags: u8, } diff --git a/tests/unit/out/unsafe/concepts.rs b/tests/unit/out/unsafe/concepts.rs index 9dcb70434d..23116f6ce1 100644 --- a/tests/unit/out/unsafe/concepts.rs +++ b/tests/unit/out/unsafe/concepts.rs @@ -18,11 +18,10 @@ const _: () = assert!( VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 c4734b9e75..270760aadd 100644 --- a/tests/unit/out/unsafe/constexpr_function.rs +++ b/tests/unit/out/unsafe/constexpr_function.rs @@ -28,11 +28,10 @@ pub unsafe fn half_3(mut x: f64) -> f64 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Flag { pub v: i32, } @@ -64,11 +63,10 @@ pub unsafe fn imm_7(mut b: bool) -> bool { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct P { pub v: i32, } diff --git a/tests/unit/out/unsafe/conversion_operator_same_translation.rs b/tests/unit/out/unsafe/conversion_operator_same_translation.rs index 8521a78d3c..292c0bd955 100644 --- a/tests/unit/out/unsafe/conversion_operator_same_translation.rs +++ b/tests/unit/out/unsafe/conversion_operator_same_translation.rs @@ -14,11 +14,10 @@ use std::rc::Rc; FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] #[cpp_into(libc::c_char, to_libcc_char)] #[cpp_into(u8, to_u8)] pub struct S { @@ -40,11 +39,10 @@ impl S { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] #[cpp_into(i64, to_i64_1)] pub struct T { pub v: i32, diff --git a/tests/unit/out/unsafe/copy_move_defaulted.rs b/tests/unit/out/unsafe/copy_move_defaulted.rs index 3941c2bcc6..84c9ee1bee 100644 --- a/tests/unit/out/unsafe/copy_move_defaulted.rs +++ b/tests/unit/out/unsafe/copy_move_defaulted.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Inner { pub x: i32, } @@ -59,11 +58,10 @@ impl DestructibleUnsafe for Explicit { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 18c4fe334c..a192846a4e 100644 --- a/tests/unit/out/unsafe/default.rs +++ b/tests/unit/out/unsafe/default.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Pointers { pub x1: *mut i32, pub x2: *const i32, @@ -32,11 +31,10 @@ pub struct Pointers { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct SmallArrays { pub a: [i32; 32], pub f: Option i32>, @@ -50,10 +48,9 @@ pub struct SmallArrays { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, )] -#[memberwise(default_constructor)] pub struct BigArray { pub a: [i32; 33], } diff --git a/tests/unit/out/unsafe/default_in_statics.rs b/tests/unit/out/unsafe/default_in_statics.rs index e24d3d1071..b6fea9700d 100644 --- a/tests/unit/out/unsafe/default_in_statics.rs +++ b/tests/unit/out/unsafe/default_in_statics.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Inner { pub v: i32, pub name: *const libc::c_char, @@ -29,11 +28,10 @@ pub struct Inner { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Outer { pub p1: *mut i32, pub p2: *const i32, @@ -51,11 +49,10 @@ pub struct Outer { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 a4c5568f7b..485dbff706 100644 --- a/tests/unit/out/unsafe/delete_array_order.rs +++ b/tests/unit/out/unsafe/delete_array_order.rs @@ -12,12 +12,13 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, + TriviallyDefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(default_constructor, copy_assign)] +#[memberwise(copy_assign)] 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 1ca37d2691..e2e15135cb 100644 --- a/tests/unit/out/unsafe/destructor.rs +++ b/tests/unit/out/unsafe/destructor.rs @@ -13,12 +13,13 @@ pub static mut global_0: std::cell::LazyCell = std::cell::LazyCell::new(|| VaArg, FnPtrArg, ZeroInitializationUnsafe, + TriviallyDefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(copy_assign, default_constructor)] +#[memberwise(copy_assign)] pub struct S {} impl DestructibleUnsafe for S { unsafe fn destroy(&mut self) { @@ -31,13 +32,14 @@ impl DestructibleUnsafe for S { VaArg, FnPtrArg, ZeroInitializationUnsafe, + TriviallyDefaultConstructibleUnsafe, DestructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(default_constructor, copy_assign)] +#[memberwise(copy_assign)] pub struct Defaulted { #[destroy] pub s: S, @@ -48,6 +50,7 @@ pub struct Defaulted { VaArg, FnPtrArg, ZeroInitializationUnsafe, + TriviallyDefaultConstructibleUnsafe, DestructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, @@ -55,7 +58,7 @@ pub struct Defaulted { SwappableUnsafe, Default, )] -#[memberwise(move_assign, default_constructor, copy_assign)] +#[memberwise(move_assign, copy_assign)] pub struct Middle { #[destroy] pub s: S, @@ -66,6 +69,7 @@ pub struct Middle { VaArg, FnPtrArg, ZeroInitializationUnsafe, + TriviallyDefaultConstructibleUnsafe, DestructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, @@ -73,7 +77,7 @@ pub struct Middle { SwappableUnsafe, Default, )] -#[memberwise(default_constructor, copy_assign, move_assign)] +#[memberwise(copy_assign, move_assign)] pub struct Outer { #[destroy] pub m: Middle, @@ -84,6 +88,7 @@ pub struct Outer { VaArg, FnPtrArg, ZeroInitializationUnsafe, + TriviallyDefaultConstructibleUnsafe, DestructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, @@ -91,7 +96,7 @@ pub struct Outer { SwappableUnsafe, Default, )] -#[memberwise(move_assign, default_constructor, copy_assign)] +#[memberwise(move_assign, copy_assign)] pub struct ArrayMember { #[destroy] pub items: [S; 3], @@ -102,12 +107,13 @@ pub struct ArrayMember { VaArg, FnPtrArg, ZeroInitializationUnsafe, + TriviallyDefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(default_constructor, copy_assign)] +#[memberwise(copy_assign)] pub struct EmptyBody { pub s: S, } @@ -122,12 +128,13 @@ impl DestructibleUnsafe for EmptyBody { VaArg, FnPtrArg, ZeroInitializationUnsafe, + TriviallyDefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(default_constructor, copy_assign)] +#[memberwise(copy_assign)] pub struct Templated_char_ { pub v: libc::c_char, } @@ -144,12 +151,13 @@ impl DestructibleUnsafe for Templated_char_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, + TriviallyDefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(default_constructor, copy_assign)] +#[memberwise(copy_assign)] pub struct Templated_int_ { pub v: i32, } @@ -166,12 +174,13 @@ impl DestructibleUnsafe for Templated_int_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, + TriviallyDefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(default_constructor, copy_assign)] +#[memberwise(copy_assign)] pub struct Copied { pub v: i32, } @@ -189,12 +198,13 @@ pub static mut order_count_2: std::cell::LazyCell = std::cell::LazyCell::ne VaArg, FnPtrArg, ZeroInitializationUnsafe, + TriviallyDefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(copy_assign, default_constructor)] +#[memberwise(copy_assign)] pub struct Tagged { pub tag: i32, } @@ -211,6 +221,7 @@ impl DestructibleUnsafe for Tagged { VaArg, FnPtrArg, ZeroInitializationUnsafe, + TriviallyDefaultConstructibleUnsafe, DestructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, @@ -218,7 +229,7 @@ impl DestructibleUnsafe for Tagged { SwappableUnsafe, Default, )] -#[memberwise(move_assign, default_constructor, copy_assign)] +#[memberwise(move_assign, copy_assign)] pub struct Ordered { #[destroy] pub first: Tagged, diff --git a/tests/unit/out/unsafe/destructor_params.rs b/tests/unit/out/unsafe/destructor_params.rs index 05c22bc386..3295a48960 100644 --- a/tests/unit/out/unsafe/destructor_params.rs +++ b/tests/unit/out/unsafe/destructor_params.rs @@ -14,12 +14,13 @@ pub static mut last_1: std::cell::LazyCell = std::cell::LazyCell::new(|| un VaArg, FnPtrArg, ZeroInitializationUnsafe, + TriviallyDefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(default_constructor, copy_assign)] +#[memberwise(copy_assign)] pub struct S { pub v: i32, } diff --git a/tests/unit/out/unsafe/destructor_temporaries.rs b/tests/unit/out/unsafe/destructor_temporaries.rs index 76033b4191..7f127cade6 100644 --- a/tests/unit/out/unsafe/destructor_temporaries.rs +++ b/tests/unit/out/unsafe/destructor_temporaries.rs @@ -14,12 +14,13 @@ pub static mut last_1: std::cell::LazyCell = std::cell::LazyCell::new(|| un VaArg, FnPtrArg, ZeroInitializationUnsafe, + TriviallyDefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(copy_assign, default_constructor)] +#[memberwise(copy_assign)] pub struct S { pub v: i32, } @@ -40,6 +41,7 @@ impl DestructibleUnsafe for S { VaArg, FnPtrArg, ZeroInitializationUnsafe, + TriviallyDefaultConstructibleUnsafe, DestructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, @@ -47,7 +49,7 @@ impl DestructibleUnsafe for S { SwappableUnsafe, Default, )] -#[memberwise(move_assign, default_constructor, copy_assign)] +#[memberwise(move_assign, copy_assign)] pub struct Outer { #[destroy] pub inner: S, diff --git a/tests/unit/out/unsafe/doubly_linked_list.rs b/tests/unit/out/unsafe/doubly_linked_list.rs index f630e70e7e..dc47af772b 100644 --- a/tests/unit/out/unsafe/doubly_linked_list.rs +++ b/tests/unit/out/unsafe/doubly_linked_list.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 6fec1a66b5..4b5e366821 100644 --- a/tests/unit/out/unsafe/enum_default_in_static.rs +++ b/tests/unit/out/unsafe/enum_default_in_static.rs @@ -17,7 +17,7 @@ pub const Mode_MODE_TWO: Mode = 2; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/enum_int_interop.rs b/tests/unit/out/unsafe/enum_int_interop.rs index d94cf7831e..8a143f7963 100644 --- a/tests/unit/out/unsafe/enum_int_interop.rs +++ b/tests/unit/out/unsafe/enum_int_interop.rs @@ -26,11 +26,10 @@ pub const Tag_TAG_TWO: Tag = 2; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 de3dfd7a2b..c2b02f1435 100644 --- a/tests/unit/out/unsafe/enum_int_interop_c.rs +++ b/tests/unit/out/unsafe/enum_int_interop_c.rs @@ -26,7 +26,7 @@ pub const Tag_enum_TAG_TWO: Tag_enum = 2; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/exprs.rs b/tests/unit/out/unsafe/exprs.rs index f350990143..496aac9ce2 100644 --- a/tests/unit/out/unsafe/exprs.rs +++ b/tests/unit/out/unsafe/exprs.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct X { pub x: i32, } @@ -28,11 +27,10 @@ pub struct X { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 2c73a68c34..77b617c94d 100644 --- a/tests/unit/out/unsafe/fft.rs +++ b/tests/unit/out/unsafe/fft.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 434a131865..5f3bd26f5a 100644 --- a/tests/unit/out/unsafe/field_aliasing.rs +++ b/tests/unit/out/unsafe/field_aliasing.rs @@ -13,7 +13,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -28,7 +28,7 @@ pub struct In { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -45,7 +45,7 @@ pub struct S { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/field_array_elem_ptr.rs b/tests/unit/out/unsafe/field_array_elem_ptr.rs index 796fbbfcad..5550ca4167 100644 --- a/tests/unit/out/unsafe/field_array_elem_ptr.rs +++ b/tests/unit/out/unsafe/field_array_elem_ptr.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Point { pub x: i32, pub y: i32, @@ -29,11 +28,10 @@ pub struct Point { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 5280d88e4e..2b5cd1dfa4 100644 --- a/tests/unit/out/unsafe/field_method_receiver.rs +++ b/tests/unit/out/unsafe/field_method_receiver.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 0fefe76d01..3dd4ad79f0 100644 --- a/tests/unit/out/unsafe/field_pointers.rs +++ b/tests/unit/out/unsafe/field_pointers.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Inner { pub a: i32, pub name: [libc::c_char; 8], @@ -29,11 +28,10 @@ pub struct Inner { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 af498cc090..a7ac86a38a 100644 --- a/tests/unit/out/unsafe/field_pointers_malloced_struct.rs +++ b/tests/unit/out/unsafe/field_pointers_malloced_struct.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 522a2b0d16..8e75578838 100644 --- a/tests/unit/out/unsafe/field_reinterpret_write_through.rs +++ b/tests/unit/out/unsafe/field_reinterpret_write_through.rs @@ -13,7 +13,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -28,7 +28,7 @@ pub struct In { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/find.rs b/tests/unit/out/unsafe/find.rs index 573c0fe9af..8a91f42547 100644 --- a/tests/unit/out/unsafe/find.rs +++ b/tests/unit/out/unsafe/find.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 28cecee3b7..0c54613d31 100644 --- a/tests/unit/out/unsafe/first_field_ptr_covers_struct.rs +++ b/tests/unit/out/unsafe/first_field_ptr_covers_struct.rs @@ -13,7 +13,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -28,7 +28,7 @@ pub struct In { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/first_member_downcast.rs b/tests/unit/out/unsafe/first_member_downcast.rs index 709b2595f2..d3f4ab0bee 100644 --- a/tests/unit/out/unsafe/first_member_downcast.rs +++ b/tests/unit/out/unsafe/first_member_downcast.rs @@ -13,7 +13,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -27,7 +27,7 @@ pub struct base { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/flex_array_member_incomplete.rs b/tests/unit/out/unsafe/flex_array_member_incomplete.rs index 1be4d73e24..8750661ff8 100644 --- a/tests/unit/out/unsafe/flex_array_member_incomplete.rs +++ b/tests/unit/out/unsafe/flex_array_member_incomplete.rs @@ -13,7 +13,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, )] pub struct F { 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 ec00e209ef..752bdf1574 100644 --- a/tests/unit/out/unsafe/flex_array_member_sibling_write.rs +++ b/tests/unit/out/unsafe/flex_array_member_sibling_write.rs @@ -13,7 +13,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -28,7 +28,7 @@ pub struct S { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -43,7 +43,7 @@ pub struct E { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/fn_ptr_cast.rs b/tests/unit/out/unsafe/fn_ptr_cast.rs index 278a538689..d7985a0583 100644 --- a/tests/unit/out/unsafe/fn_ptr_cast.rs +++ b/tests/unit/out/unsafe/fn_ptr_cast.rs @@ -36,11 +36,10 @@ pub unsafe fn test_double_cast_2() { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 b235d786e6..104280bce2 100644 --- a/tests/unit/out/unsafe/fn_ptr_stable_sort.rs +++ b/tests/unit/out/unsafe/fn_ptr_stable_sort.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 a937756047..2dfe9fcc22 100644 --- a/tests/unit/out/unsafe/fn_ptr_struct.rs +++ b/tests/unit/out/unsafe/fn_ptr_struct.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Handler { pub tag: i32, pub cb: Option i32>, @@ -35,11 +34,10 @@ pub unsafe fn negate_1(mut x: i32) -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 07bb8d7542..f9c0c8fd7e 100644 --- a/tests/unit/out/unsafe/fn_ptr_typedef_cast.rs +++ b/tests/unit/out/unsafe/fn_ptr_typedef_cast.rs @@ -25,7 +25,7 @@ pub unsafe fn via_size_t_return_3(mut b: u64) -> usize { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/fn_ptr_vtable.rs b/tests/unit/out/unsafe/fn_ptr_vtable.rs index dd06154101..26dce17a82 100644 --- a/tests/unit/out/unsafe/fn_ptr_vtable.rs +++ b/tests/unit/out/unsafe/fn_ptr_vtable.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 01c8fbec66..85484ae166 100644 --- a/tests/unit/out/unsafe/fn_ref.rs +++ b/tests/unit/out/unsafe/fn_ref.rs @@ -28,7 +28,7 @@ pub unsafe fn call_forwarded_4(f: Option i32>, mut x: i32) -> VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/for_body_destructor.rs b/tests/unit/out/unsafe/for_body_destructor.rs index bd47e8ec2d..f06ca860aa 100644 --- a/tests/unit/out/unsafe/for_body_destructor.rs +++ b/tests/unit/out/unsafe/for_body_destructor.rs @@ -12,12 +12,13 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, + TriviallyDefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, Default, )] -#[memberwise(default_constructor, copy_assign)] +#[memberwise(copy_assign)] pub struct Guard { pub digit: i32, } diff --git a/tests/unit/out/unsafe/friend.rs b/tests/unit/out/unsafe/friend.rs index 704b92154f..d1636d2ed8 100644 --- a/tests/unit/out/unsafe/friend.rs +++ b/tests/unit/out/unsafe/friend.rs @@ -25,11 +25,10 @@ pub unsafe fn scaled_3(v: *const V, mut k: f64) -> f64 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct V { pub x: i32, } @@ -49,11 +48,10 @@ pub unsafe fn get_4(w: *const W_int_) -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct W_int_ { pub x: i32, } @@ -67,11 +65,10 @@ pub unsafe fn get_5(w: *const W_long_) -> i64 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct W_long_ { pub x: i64, } @@ -82,11 +79,10 @@ pub struct W_long_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 4ccba5aa7c..d35fad6066 100644 --- a/tests/unit/out/unsafe/function_overloading.rs +++ b/tests/unit/out/unsafe/function_overloading.rs @@ -28,11 +28,10 @@ pub unsafe fn bar_4(x: *mut i32) -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 f72f187afe..7ce2af698a 100644 --- a/tests/unit/out/unsafe/global_call_temporaries.rs +++ b/tests/unit/out/unsafe/global_call_temporaries.rs @@ -83,11 +83,10 @@ pub static mut call_assigned_6: std::cell::LazyCell = std::cell::LazyCell:: VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Item { pub value: i32, } diff --git a/tests/unit/out/unsafe/global_non_const_init.rs b/tests/unit/out/unsafe/global_non_const_init.rs index f30b351851..464645f68c 100644 --- a/tests/unit/out/unsafe/global_non_const_init.rs +++ b/tests/unit/out/unsafe/global_non_const_init.rs @@ -89,11 +89,10 @@ pub static mut inline_member_11: std::cell::LazyCell = std::cell::LazyCell VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Holder {} pub static mut member_10: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { (unsafe { next_0() }) }); diff --git a/tests/unit/out/unsafe/global_pointers.rs b/tests/unit/out/unsafe/global_pointers.rs index 409eafa036..a9c88f06ad 100644 --- a/tests/unit/out/unsafe/global_pointers.rs +++ b/tests/unit/out/unsafe/global_pointers.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 eb9b073ead..7b58d8de0b 100644 --- a/tests/unit/out/unsafe/global_without_initializer.rs +++ b/tests/unit/out/unsafe/global_without_initializer.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 de51ef653c..dae9dd1997 100644 --- a/tests/unit/out/unsafe/goto_aggregate_default.rs +++ b/tests/unit/out/unsafe/goto_aggregate_default.rs @@ -13,7 +13,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/goto_cleanup.rs b/tests/unit/out/unsafe/goto_cleanup.rs index 7e0fea174a..17ac7a507a 100644 --- a/tests/unit/out/unsafe/goto_cleanup.rs +++ b/tests/unit/out/unsafe/goto_cleanup.rs @@ -83,7 +83,7 @@ pub unsafe fn from_switch_2(mut n: i32) -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/huffman.rs b/tests/unit/out/unsafe/huffman.rs index 7fc99d1f0c..7bd66bd8f0 100644 --- a/tests/unit/out/unsafe/huffman.rs +++ b/tests/unit/out/unsafe/huffman.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 ff68aef47b..dfb8ab5645 100644 --- a/tests/unit/out/unsafe/immutable-deref-on-func-call.rs +++ b/tests/unit/out/unsafe/immutable-deref-on-func-call.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Item { pub value: i32, } diff --git a/tests/unit/out/unsafe/init.rs b/tests/unit/out/unsafe/init.rs index 367a5325e9..3d59a03d41 100644 --- a/tests/unit/out/unsafe/init.rs +++ b/tests/unit/out/unsafe/init.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 88f7a20777..7860f3812f 100644 --- a/tests/unit/out/unsafe/init_list.rs +++ b/tests/unit/out/unsafe/init_list.rs @@ -14,11 +14,10 @@ pub unsafe fn f_0(mut list: Vec) {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Pair { pub a: i32, pub b: i32, diff --git a/tests/unit/out/unsafe/kruskal.rs b/tests/unit/out/unsafe/kruskal.rs index 0ece169b26..897b47150b 100644 --- a/tests/unit/out/unsafe/kruskal.rs +++ b/tests/unit/out/unsafe/kruskal.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 d7e738d69b..2228dec7ef 100644 --- a/tests/unit/out/unsafe/lambda_as_field.rs +++ b/tests/unit/out/unsafe/lambda_as_field.rs @@ -12,11 +12,12 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, + TriviallyDefaultConstructibleUnsafe, MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, )] -#[memberwise(default_constructor, copy_assign)] +#[memberwise(copy_assign)] pub struct Guard__lambda_at_lambda_as_field_cpp_34_13__ { pub f: FnPtr, } @@ -56,9 +57,13 @@ impl DestructibleUnsafe for Guard__lambda_at_lambda_as_field_cpp_45_13__ { } #[repr(C)] #[derive( - Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, MemberwiseUnsafe, TriviallyCopyableUnsafe, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + TriviallyDefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, )] -#[memberwise(default_constructor)] pub struct Holder__lambda_at_lambda_as_field_cpp_39_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 daff8aaf71..6590dbd343 100644 --- a/tests/unit/out/unsafe/lambda_capture_ref.rs +++ b/tests/unit/out/unsafe/lambda_capture_ref.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 5517164beb..da181b4648 100644 --- a/tests/unit/out/unsafe/lambda_capture_star_this.rs +++ b/tests/unit/out/unsafe/lambda_capture_star_this.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 dbc5dafed4..77bec8611a 100644 --- a/tests/unit/out/unsafe/lambda_capture_this.rs +++ b/tests/unit/out/unsafe/lambda_capture_this.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 f7ffe2524d..fc656980c3 100644 --- a/tests/unit/out/unsafe/lambda_capture_value.rs +++ b/tests/unit/out/unsafe/lambda_capture_value.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct S { pub x: i32, pub y: i32, diff --git a/tests/unit/out/unsafe/lambda_generic_explicit_args.rs b/tests/unit/out/unsafe/lambda_generic_explicit_args.rs index dbf8da6c29..5de0535d40 100644 --- a/tests/unit/out/unsafe/lambda_generic_explicit_args.rs +++ b/tests/unit/out/unsafe/lambda_generic_explicit_args.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Val { pub x: i32, } diff --git a/tests/unit/out/unsafe/lambda_nested.rs b/tests/unit/out/unsafe/lambda_nested.rs index f3d51a79b2..9617322fc0 100644 --- a/tests/unit/out/unsafe/lambda_nested.rs +++ b/tests/unit/out/unsafe/lambda_nested.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 4ebe28b446..5e0406de52 100644 --- a/tests/unit/out/unsafe/lambda_static_local.rs +++ b/tests/unit/out/unsafe/lambda_static_local.rs @@ -74,11 +74,10 @@ static mut calls_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsaf VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 4ab20009e8..34101b89d6 100644 --- a/tests/unit/out/unsafe/libc_struct_without_default.rs +++ b/tests/unit/out/unsafe/libc_struct_without_default.rs @@ -45,10 +45,9 @@ impl Default for UserDefined { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, )] -#[memberwise(default_constructor)] 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 ca4b3cb327..6cf73c6397 100644 --- a/tests/unit/out/unsafe/linked_list.rs +++ b/tests/unit/out/unsafe/linked_list.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 777c92a2b4..6bc09413c4 100644 --- a/tests/unit/out/unsafe/local_anon_struct_collision.rs +++ b/tests/unit/out/unsafe/local_anon_struct_collision.rs @@ -19,7 +19,7 @@ pub unsafe fn first_0() -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -40,7 +40,7 @@ pub unsafe fn second_2() -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/local_record_template.rs b/tests/unit/out/unsafe/local_record_template.rs index 2256a2c0b4..86593fe51e 100644 --- a/tests/unit/out/unsafe/local_record_template.rs +++ b/tests/unit/out/unsafe/local_record_template.rs @@ -36,11 +36,10 @@ pub unsafe fn wrap_10(mut v: i64) -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Local_5 { pub x: i32, } @@ -51,11 +50,10 @@ pub struct Local_5 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Local_7 { pub x: i64, } @@ -70,11 +68,10 @@ pub unsafe fn other_11() -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Local_1 { pub x: i64, pub y: i64, @@ -101,11 +98,10 @@ unsafe fn main_0() -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Local_3 { pub x: i32, } diff --git a/tests/unit/out/unsafe/map_key_identity.rs b/tests/unit/out/unsafe/map_key_identity.rs index 768efb1f6e..d7f3b4279f 100644 --- a/tests/unit/out/unsafe/map_key_identity.rs +++ b/tests/unit/out/unsafe/map_key_identity.rs @@ -15,11 +15,10 @@ pub static mut default_constructions_0: std::cell::LazyCell = VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Key { pub order: i32, pub identity: i32, diff --git a/tests/unit/out/unsafe/memcpy_struct_bytes.rs b/tests/unit/out/unsafe/memcpy_struct_bytes.rs index 3a8b1e7889..2009639c7e 100644 --- a/tests/unit/out/unsafe/memcpy_struct_bytes.rs +++ b/tests/unit/out/unsafe/memcpy_struct_bytes.rs @@ -13,7 +13,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/memcpy_struct_layouts.rs b/tests/unit/out/unsafe/memcpy_struct_layouts.rs index c4fe753df2..a5b4b4e426 100644 --- a/tests/unit/out/unsafe/memcpy_struct_layouts.rs +++ b/tests/unit/out/unsafe/memcpy_struct_layouts.rs @@ -13,7 +13,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -30,7 +30,7 @@ pub struct packed { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -46,7 +46,7 @@ pub struct reordered { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -61,7 +61,7 @@ pub struct tail { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -76,7 +76,7 @@ pub struct nested { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/memcpy_struct_struct.rs b/tests/unit/out/unsafe/memcpy_struct_struct.rs index 98efc4c3f3..80e3915330 100644 --- a/tests/unit/out/unsafe/memcpy_struct_struct.rs +++ b/tests/unit/out/unsafe/memcpy_struct_struct.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 82bfda53c2..cd756001e9 100644 --- a/tests/unit/out/unsafe/memset_struct_tail.rs +++ b/tests/unit/out/unsafe/memset_struct_tail.rs @@ -13,7 +13,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/nested_structs.rs b/tests/unit/out/unsafe/nested_structs.rs index f4d90e4da9..a32dba8a86 100644 --- a/tests/unit/out/unsafe/nested_structs.rs +++ b/tests/unit/out/unsafe/nested_structs.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Level0_Level1_1_Level2_1_Level3_1 { pub x1: i32, } @@ -28,11 +27,10 @@ pub struct Level0_Level1_1_Level2_1_Level3_1 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Level0_Level1_1_Level2_1_Level3_2 { pub x1: i32, pub x2: i32, @@ -44,11 +42,10 @@ pub struct Level0_Level1_1_Level2_1_Level3_2 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Level0_Level1_1_Level2_1 { pub x1: i32, } @@ -59,11 +56,10 @@ pub struct Level0_Level1_1_Level2_1 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Level0_Level1_1 { pub x1: i32, } @@ -74,11 +70,10 @@ pub struct Level0_Level1_1 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Level0_Level1_2 { pub x1: i32, pub x2: i32, @@ -90,11 +85,10 @@ pub struct Level0_Level1_2 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Level0 {} pub fn main() { unsafe { diff --git a/tests/unit/out/unsafe/new.rs b/tests/unit/out/unsafe/new.rs index 2ac66d4f30..122825c5c6 100644 --- a/tests/unit/out/unsafe/new.rs +++ b/tests/unit/out/unsafe/new.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 59bb5973e7..dac1d68074 100644 --- a/tests/unit/out/unsafe/new_bst.rs +++ b/tests/unit/out/unsafe/new_bst.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 03324cdc1f..fe46b51827 100644 --- a/tests/unit/out/unsafe/new_struct.rs +++ b/tests/unit/out/unsafe/new_struct.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Pair { pub x: i32, pub y: i32, @@ -29,11 +28,10 @@ pub struct Pair { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 6333a08ee4..f9f374e227 100644 --- a/tests/unit/out/unsafe/nttp_distinct_specializations.rs +++ b/tests/unit/out/unsafe/nttp_distinct_specializations.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct S_2_ { pub v: i32, pub w: i32, @@ -34,11 +33,10 @@ impl S_2_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct S_1_ { pub v: i32, } @@ -54,11 +52,10 @@ impl S_1_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct S_3_ { pub v: i32, } diff --git a/tests/unit/out/unsafe/offsetof.rs b/tests/unit/out/unsafe/offsetof.rs index 9975135d3b..fde3ab7987 100644 --- a/tests/unit/out/unsafe/offsetof.rs +++ b/tests/unit/out/unsafe/offsetof.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Layout { pub a: u8, pub b: u32, @@ -30,10 +29,9 @@ pub struct Layout { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, )] -#[memberwise(default_constructor)] 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 e3d4034809..b3b437641c 100644 --- a/tests/unit/out/unsafe/opaque_forward_decl.rs +++ b/tests/unit/out/unsafe/opaque_forward_decl.rs @@ -13,7 +13,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/opaque_record_copy.rs b/tests/unit/out/unsafe/opaque_record_copy.rs index 5c0f357c51..1ec8a560a5 100644 --- a/tests/unit/out/unsafe/opaque_record_copy.rs +++ b/tests/unit/out/unsafe/opaque_record_copy.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Probe {} #[repr(C)] #[derive( @@ -26,11 +25,10 @@ pub struct Probe {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 e4b22a5391..fabebaf001 100644 --- a/tests/unit/out/unsafe/opaque_then_defined.rs +++ b/tests/unit/out/unsafe/opaque_then_defined.rs @@ -13,7 +13,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -28,7 +28,7 @@ pub struct list { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/operator_arithmetic_free.rs b/tests/unit/out/unsafe/operator_arithmetic_free.rs index e4199278a9..eb22d6f97f 100644 --- a/tests/unit/out/unsafe/operator_arithmetic_free.rs +++ b/tests/unit/out/unsafe/operator_arithmetic_free.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 44d84b7e6a..5cae6acad9 100644 --- a/tests/unit/out/unsafe/operator_arithmetic_member.rs +++ b/tests/unit/out/unsafe/operator_arithmetic_member.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 e11e2d9e48..f60a99aedd 100644 --- a/tests/unit/out/unsafe/operator_bitwise_free.rs +++ b/tests/unit/out/unsafe/operator_bitwise_free.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 2c0a7ee4c5..df6d2e2d6c 100644 --- a/tests/unit/out/unsafe/operator_bitwise_member.rs +++ b/tests/unit/out/unsafe/operator_bitwise_member.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 33067d7992..f9b1fa5a6b 100644 --- a/tests/unit/out/unsafe/operator_comparison_defaulted.rs +++ b/tests/unit/out/unsafe/operator_comparison_defaulted.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Eq { pub a: i32, pub b: i32, @@ -41,11 +40,10 @@ impl std::cmp::Eq for Eq {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Cmp { pub a: i32, pub b: i32, @@ -96,11 +94,10 @@ impl std::cmp::Eq for Cmp {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Both { pub a: i32, } @@ -142,11 +139,10 @@ impl std::cmp::Eq for Both {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct OrdOnly { pub a: i32, } @@ -185,11 +181,10 @@ impl std::cmp::Eq for OrdOnly {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Inner { pub x: i32, } @@ -231,11 +226,10 @@ impl std::cmp::Eq for Inner {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Outer { pub i: Inner, pub y: i32, @@ -290,11 +284,10 @@ impl std::cmp::Eq for Outer {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Secondary { pub a: i32, } @@ -347,11 +340,10 @@ impl std::cmp::Eq for Secondary {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 0b18714abb..9d49a17880 100644 --- a/tests/unit/out/unsafe/operator_comparison_free.rs +++ b/tests/unit/out/unsafe/operator_comparison_free.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct S { pub v: i32, } @@ -76,11 +75,10 @@ pub unsafe fn operator_lt_7(mut a: i32, b: *const S) -> bool { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 8c9f42fc87..8f040647f7 100644 --- a/tests/unit/out/unsafe/operator_comparison_member.rs +++ b/tests/unit/out/unsafe/operator_comparison_member.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 559114f5c5..eecee4a3b6 100644 --- a/tests/unit/out/unsafe/operator_comparison_mixed.rs +++ b/tests/unit/out/unsafe/operator_comparison_mixed.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 5910a668e3..ba720b4e53 100644 --- a/tests/unit/out/unsafe/operator_comparison_nonbool.rs +++ b/tests/unit/out/unsafe/operator_comparison_nonbool.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct X { pub v: i32, } @@ -70,11 +69,10 @@ pub unsafe fn operator_ge_5(mut a: X, mut b: X) -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Result { pub r: i32, } @@ -85,11 +83,10 @@ pub struct Result { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Custom { pub v: i32, } @@ -107,11 +104,10 @@ impl Custom { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Mixed { pub v: i32, } @@ -183,11 +179,10 @@ impl MyBool { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Boolish { pub v: i32, } @@ -270,11 +265,10 @@ pub static mut ref_true_8: std::cell::LazyCell = std::cell::LazyCell::n VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 fb0eb14060..8f4b0ef00a 100644 --- a/tests/unit/out/unsafe/operator_compound_assignment_free.rs +++ b/tests/unit/out/unsafe/operator_compound_assignment_free.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 a4b231f6d1..3989e666b1 100644 --- a/tests/unit/out/unsafe/operator_compound_assignment_member.rs +++ b/tests/unit/out/unsafe/operator_compound_assignment_member.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 9623a2c3fe..f87c82e9c5 100644 --- a/tests/unit/out/unsafe/operator_friend.rs +++ b/tests/unit/out/unsafe/operator_friend.rs @@ -16,11 +16,10 @@ pub unsafe fn operator_eq_0(_a0: *const Defaulted, _a1: *const Defaulted) -> boo VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Defaulted { pub a: i32, pub b: i32, @@ -53,11 +52,10 @@ pub unsafe fn operator_eq_2(_a0: *const DefaultedOrd, _a1: *const DefaultedOrd) VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct DefaultedOrd { pub a: i32, } @@ -95,11 +93,10 @@ pub unsafe fn operator_add_5(x: *const Inline, y: *const Inline) -> Inline { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Inline { pub a: i32, } @@ -134,11 +131,10 @@ impl std::cmp::Eq for Inline {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct OutOfLine { pub a: i32, } @@ -173,11 +169,10 @@ pub unsafe fn operator_eq_10(x: *const Tmpl_int_, y: *const Tmpl_long_) -> bool VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Tmpl_int_ { pub v: i32, } @@ -212,11 +207,10 @@ impl std::cmp::Eq for Tmpl_int_ {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Tmpl_long_ { pub v: i64, } @@ -233,11 +227,10 @@ pub unsafe fn operator_eq_11( VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 87baa70af0..6f57bf5217 100644 --- a/tests/unit/out/unsafe/operator_less_than.rs +++ b/tests/unit/out/unsafe/operator_less_than.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 67b6ddb418..4e7bbefdc5 100644 --- a/tests/unit/out/unsafe/operator_logical_free.rs +++ b/tests/unit/out/unsafe/operator_logical_free.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 65eb9a462e..562497a560 100644 --- a/tests/unit/out/unsafe/operator_logical_member.rs +++ b/tests/unit/out/unsafe/operator_logical_member.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 2cb9016d5b..32ef575f1e 100644 --- a/tests/unit/out/unsafe/operator_member_pointer_free.rs +++ b/tests/unit/out/unsafe/operator_member_pointer_free.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Inner { pub x: i32, } @@ -28,11 +27,10 @@ pub struct Inner { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 938843c18e..1da1aa4c95 100644 --- a/tests/unit/out/unsafe/operator_member_pointer_member.rs +++ b/tests/unit/out/unsafe/operator_member_pointer_member.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Inner { pub x: i32, } @@ -28,11 +27,10 @@ pub struct Inner { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Table {} impl Table { pub unsafe fn operator_index(mut i: i32) -> *mut i32 { @@ -48,11 +46,10 @@ pub static mut table_0: std::cell::LazyCell<[i32; 3]> = VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 b09a8c33a2..47881cca64 100644 --- a/tests/unit/out/unsafe/operator_other_free.rs +++ b/tests/unit/out/unsafe/operator_other_free.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 f0c958ae49..c20b77e1cd 100644 --- a/tests/unit/out/unsafe/operator_other_member.rs +++ b/tests/unit/out/unsafe/operator_other_member.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Static {} impl Static { pub unsafe fn operator_call(mut a: i32, mut b: i32) -> i32 { @@ -32,11 +31,10 @@ impl Static { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] #[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 33b1e754aa..fc09de884e 100644 --- a/tests/unit/out/unsafe/operator_overloads.rs +++ b/tests/unit/out/unsafe/operator_overloads.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 b78eb7e09a..af429253b9 100644 --- a/tests/unit/out/unsafe/operator_qualifiers.rs +++ b/tests/unit/out/unsafe/operator_qualifiers.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 2bb9c2cd2c..eb74b41521 100644 --- a/tests/unit/out/unsafe/operator_three_way.rs +++ b/tests/unit/out/unsafe/operator_three_way.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 ecf6793226..ff4e03fc64 100644 --- a/tests/unit/out/unsafe/operator_traits.rs +++ b/tests/unit/out/unsafe/operator_traits.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Lt { pub v: i32, } @@ -60,11 +59,10 @@ impl std::cmp::Eq for Lt {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Eq { pub v: i32, } @@ -86,11 +84,10 @@ impl std::cmp::Eq for Eq {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Cmp { pub v: i32, } @@ -125,11 +122,10 @@ impl std::cmp::Eq for Cmp {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Free { pub v: i32, } @@ -170,11 +166,10 @@ pub unsafe fn operator_eq_1(a: *const Free, b: *const Free) -> bool { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 a94d7b5c64..a508eda753 100644 --- a/tests/unit/out/unsafe/overload_mangling.rs +++ b/tests/unit/out/unsafe/overload_mangling.rs @@ -22,11 +22,10 @@ pub unsafe fn twice_2(mut n: i32) -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Access_S_ {} impl Access_S_ { pub unsafe fn get_1(&mut self, mut p: *mut S) -> i32 { @@ -49,11 +48,10 @@ impl Access_S_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct S { pub base: i32, } @@ -133,11 +131,10 @@ impl S { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 7521888ece..d8dab07195 100644 --- a/tests/unit/out/unsafe/pair_converting_construction.rs +++ b/tests/unit/out/unsafe/pair_converting_construction.rs @@ -35,11 +35,10 @@ impl Celsius { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] #[cpp_into(i32, to_i32)] pub struct Meters { pub value: i32, @@ -157,11 +156,10 @@ impl Default for Fallback { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Counter { pub hits: i32, } diff --git a/tests/unit/out/unsafe/pod.rs b/tests/unit/out/unsafe/pod.rs index 16136af535..6e89b4f531 100644 --- a/tests/unit/out/unsafe/pod.rs +++ b/tests/unit/out/unsafe/pod.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 c6ef74f43b..56b9a155dc 100644 --- a/tests/unit/out/unsafe/pointer_array.rs +++ b/tests/unit/out/unsafe/pointer_array.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 57b62f52aa..6a1d56e4fc 100644 --- a/tests/unit/out/unsafe/pointers.rs +++ b/tests/unit/out/unsafe/pointers.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Test { pub x: i32, } diff --git a/tests/unit/out/unsafe/ptr_cast_init.rs b/tests/unit/out/unsafe/ptr_cast_init.rs index 68205c6cb6..2d789809c0 100644 --- a/tests/unit/out/unsafe/ptr_cast_init.rs +++ b/tests/unit/out/unsafe/ptr_cast_init.rs @@ -13,7 +13,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -28,7 +28,7 @@ pub struct header { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/push_emplace_back.rs b/tests/unit/out/unsafe/push_emplace_back.rs index d387d5baad..d2ac4d13b8 100644 --- a/tests/unit/out/unsafe/push_emplace_back.rs +++ b/tests/unit/out/unsafe/push_emplace_back.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Chunk { pub data: i32, } @@ -28,11 +27,10 @@ pub struct Chunk { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Writer { pub output: *mut Vec, pub chunk: Chunk, @@ -276,11 +274,10 @@ pub unsafe fn emplace_from_element_14(mut v: *mut Vec>) { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Plain { pub a: i32, pub b: [f64; 2], diff --git a/tests/unit/out/unsafe/random.rs b/tests/unit/out/unsafe/random.rs index 81561413f5..4c27c970b7 100644 --- a/tests/unit/out/unsafe/random.rs +++ b/tests/unit/out/unsafe/random.rs @@ -13,7 +13,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -56,11 +56,10 @@ pub unsafe fn zero_0() -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 b75da31ce1..a76872bfa6 100644 --- a/tests/unit/out/unsafe/reference_wrapper.rs +++ b/tests/unit/out/unsafe/reference_wrapper.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 d855ac2c3f..20b4026bfa 100644 --- a/tests/unit/out/unsafe/references.rs +++ b/tests/unit/out/unsafe/references.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Pair { pub x: i32, pub y: i32, @@ -30,11 +29,10 @@ pub struct Pair { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 389cff6497..e3b97faeb2 100644 --- a/tests/unit/out/unsafe/refs_as_args.rs +++ b/tests/unit/out/unsafe/refs_as_args.rs @@ -24,11 +24,10 @@ pub unsafe fn more_refs_0(mut x1: i32, mut x2: i32, r1: *mut i32, r2: *const i32 VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 d8346ba081..685c6ac1b7 100644 --- a/tests/unit/out/unsafe/reinterpret_cast_ptr_cmp.rs +++ b/tests/unit/out/unsafe/reinterpret_cast_ptr_cmp.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct S { pub x: i32, pub y: i32, @@ -29,11 +28,10 @@ pub struct S { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct W { pub h: i32, pub arr: [S; 3], @@ -45,11 +43,10 @@ pub struct W { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 98e794eaf4..228c415c15 100644 --- a/tests/unit/out/unsafe/reinterpret_cast_struct.rs +++ b/tests/unit/out/unsafe/reinterpret_cast_struct.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 4336d7f618..c7c67b47d4 100644 --- a/tests/unit/out/unsafe/reinterpret_cast_struct_to_struct.rs +++ b/tests/unit/out/unsafe/reinterpret_cast_struct_to_struct.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Point { pub x: u32, pub y: u32, @@ -29,11 +28,10 @@ pub struct Point { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 805e143550..7383370766 100644 --- a/tests/unit/out/unsafe/reserved_keywords.rs +++ b/tests/unit/out/unsafe/reserved_keywords.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct S { pub as_: i32, pub async_: i32, @@ -65,11 +64,10 @@ pub struct S { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct type_ { pub v: i32, } @@ -80,11 +78,10 @@ pub struct type_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 d03cbdcf56..3218f6d59d 100644 --- a/tests/unit/out/unsafe/return_move.rs +++ b/tests/unit/out/unsafe/return_move.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct node { pub value: i32, pub next: *mut node, @@ -29,11 +28,10 @@ pub struct node { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct pair_t { pub a: i32, pub n: *mut node, diff --git a/tests/unit/out/unsafe/scalar_builtin_construct_destruct.rs b/tests/unit/out/unsafe/scalar_builtin_construct_destruct.rs index 3e4a5119b6..5d83198246 100644 --- a/tests/unit/out/unsafe/scalar_builtin_construct_destruct.rs +++ b/tests/unit/out/unsafe/scalar_builtin_construct_destruct.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 9c05272f65..6328732c61 100644 --- a/tests/unit/out/unsafe/self_referencing_initializer.rs +++ b/tests/unit/out/unsafe/self_referencing_initializer.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct list_head { pub next: *mut list_head, } @@ -28,11 +27,10 @@ pub struct list_head { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct node { pub value: i32, pub value_ptr: *mut i32, diff --git a/tests/unit/out/unsafe/size_t_static_member.rs b/tests/unit/out/unsafe/size_t_static_member.rs index 6f6b83ea3d..a515d8b1e0 100644 --- a/tests/unit/out/unsafe/size_t_static_member.rs +++ b/tests/unit/out/unsafe/size_t_static_member.rs @@ -14,11 +14,10 @@ pub static mut c_0: std::cell::LazyCell = std::cell::LazyCell::new(|| uns VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct S {} pub static mut table_size_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 256_usize }); @@ -29,11 +28,10 @@ pub static mut table_size_1: std::cell::LazyCell = VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Table_char_ {} pub fn main() { unsafe { diff --git a/tests/unit/out/unsafe/static_local.rs b/tests/unit/out/unsafe/static_local.rs index 91bd7e1dba..9e1e9cab3d 100644 --- a/tests/unit/out/unsafe/static_local.rs +++ b/tests/unit/out/unsafe/static_local.rs @@ -28,11 +28,10 @@ static mut x_7: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 2b4c159fdc..51fca0f3dd 100644 --- a/tests/unit/out/unsafe/static_var_in_class.rs +++ b/tests/unit/out/unsafe/static_var_in_class.rs @@ -14,11 +14,10 @@ static mut inner_const_0: std::cell::LazyCell = std::cell::LazyCell::new(|| VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct C {} impl C { pub unsafe fn get(&mut self) -> i32 { @@ -35,11 +34,10 @@ pub const anon_3_kValue: anon_3 = 3; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct S {} impl S { pub unsafe fn f() -> i32 { diff --git a/tests/unit/out/unsafe/strdup.rs b/tests/unit/out/unsafe/strdup.rs index d3a57644e4..6956bfcdf4 100644 --- a/tests/unit/out/unsafe/strdup.rs +++ b/tests/unit/out/unsafe/strdup.rs @@ -13,7 +13,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/string_literal_ptr_init.rs b/tests/unit/out/unsafe/string_literal_ptr_init.rs index e7dabf0680..2e80d468b6 100644 --- a/tests/unit/out/unsafe/string_literal_ptr_init.rs +++ b/tests/unit/out/unsafe/string_literal_ptr_init.rs @@ -13,7 +13,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/string_substr.rs b/tests/unit/out/unsafe/string_substr.rs index ed518f348e..653aaaa9b4 100644 --- a/tests/unit/out/unsafe/string_substr.rs +++ b/tests/unit/out/unsafe/string_substr.rs @@ -13,7 +13,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/struct_2d_array_field.rs b/tests/unit/out/unsafe/struct_2d_array_field.rs index d2e1e9ac30..029a03a6c9 100644 --- a/tests/unit/out/unsafe/struct_2d_array_field.rs +++ b/tests/unit/out/unsafe/struct_2d_array_field.rs @@ -13,7 +13,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/struct_member_array_adjacency.rs b/tests/unit/out/unsafe/struct_member_array_adjacency.rs index 4cedb93a0c..6f27ef0fe8 100644 --- a/tests/unit/out/unsafe/struct_member_array_adjacency.rs +++ b/tests/unit/out/unsafe/struct_member_array_adjacency.rs @@ -13,7 +13,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/struct_ptr.rs b/tests/unit/out/unsafe/struct_ptr.rs index 5edaaa7d39..81b8aac399 100644 --- a/tests/unit/out/unsafe/struct_ptr.rs +++ b/tests/unit/out/unsafe/struct_ptr.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 d4483f962c..e38ab74e1d 100644 --- a/tests/unit/out/unsafe/structured_binding_range_for.rs +++ b/tests/unit/out/unsafe/structured_binding_range_for.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 a02ce5d909..771faa1782 100644 --- a/tests/unit/out/unsafe/structured_binding_ref.rs +++ b/tests/unit/out/unsafe/structured_binding_ref.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 c418819c91..cf68a5946d 100644 --- a/tests/unit/out/unsafe/structured_binding_trivial.rs +++ b/tests/unit/out/unsafe/structured_binding_trivial.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 c4fdce8ed1..4519752d15 100644 --- a/tests/unit/out/unsafe/tag_vs_identifier_collision.rs +++ b/tests/unit/out/unsafe/tag_vs_identifier_collision.rs @@ -17,7 +17,7 @@ pub const widget_enum_MODE_DONE: widget_enum = 2; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -32,7 +32,7 @@ pub struct widget { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -47,7 +47,7 @@ pub struct point_struct { FnPtrArg, VaArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, )] pub union point { @@ -66,7 +66,7 @@ impl Default for point { FnPtrArg, VaArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, )] pub union slot_union { @@ -88,7 +88,7 @@ pub const slot_SLOT_B: slot = 1; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -102,7 +102,7 @@ pub struct Inner { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -116,7 +116,7 @@ pub struct Outer { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/template_static_member.rs b/tests/unit/out/unsafe/template_static_member.rs index ccf509b20a..0036ac4a57 100644 --- a/tests/unit/out/unsafe/template_static_member.rs +++ b/tests/unit/out/unsafe/template_static_member.rs @@ -14,11 +14,10 @@ pub static mut s_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsaf VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Static_int_ {} pub static mut s_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { (55 as libc::c_char) }); @@ -29,11 +28,10 @@ pub static mut s_1: std::cell::LazyCell = VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Static_char_ {} pub static mut s_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 55_i64 }); #[repr(C)] @@ -43,11 +41,10 @@ pub static mut s_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsaf VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 }); @@ -58,11 +55,10 @@ pub static mut hi_4: std::cell::LazyCell = std::cell::LazyCell::new(|| unsa VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Range_int_ {} pub static mut lo_5: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { (-2_i32 as i64) }); @@ -74,11 +70,10 @@ pub static mut hi_6: std::cell::LazyCell = std::cell::LazyCell::new(|| unsa VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Range_long_ {} pub fn main() { unsafe { diff --git a/tests/unit/out/unsafe/typedef-anon-struct.rs b/tests/unit/out/unsafe/typedef-anon-struct.rs index 01f721d87e..a718d740da 100644 --- a/tests/unit/out/unsafe/typedef-anon-struct.rs +++ b/tests/unit/out/unsafe/typedef-anon-struct.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 cfd310d39a..15e272bafb 100644 --- a/tests/unit/out/unsafe/unary_expr_or_type_trait.rs +++ b/tests/unit/out/unsafe/unary_expr_or_type_trait.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 b4e4166f9c..d2133b3f1a 100644 --- a/tests/unit/out/unsafe/unboxed_locals.rs +++ b/tests/unit/out/unsafe/unboxed_locals.rs @@ -19,11 +19,10 @@ pub unsafe fn inc_1(r: *mut i32) { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Pair { pub first: i32, pub second: i32, diff --git a/tests/unit/out/unsafe/unboxed_records.rs b/tests/unit/out/unsafe/unboxed_records.rs index a5f99dd91d..fa5ce3612b 100644 --- a/tests/unit/out/unsafe/unboxed_records.rs +++ b/tests/unit/out/unsafe/unboxed_records.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Inner { pub a: i32, pub b: i32, @@ -29,11 +28,10 @@ pub struct Inner { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Cookie { pub x: i32, pub data: *mut i32, diff --git a/tests/unit/out/unsafe/union_addrof_external.rs b/tests/unit/out/unsafe/union_addrof_external.rs index c1656623f2..074e9570c5 100644 --- a/tests/unit/out/unsafe/union_addrof_external.rs +++ b/tests/unit/out/unsafe/union_addrof_external.rs @@ -13,7 +13,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -30,7 +30,7 @@ pub struct record { FnPtrArg, VaArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, )] pub union anon_0 { @@ -49,7 +49,7 @@ impl Default for anon_0 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/union_basic.rs b/tests/unit/out/unsafe/union_basic.rs index 770a41be0c..3db1c405cc 100644 --- a/tests/unit/out/unsafe/union_basic.rs +++ b/tests/unit/out/unsafe/union_basic.rs @@ -13,7 +13,7 @@ use std::rc::Rc; FnPtrArg, VaArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, )] pub union basic { @@ -32,7 +32,7 @@ impl Default for basic { FnPtrArg, VaArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, )] pub union empty { @@ -50,7 +50,7 @@ impl Default for empty { FnPtrArg, VaArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, )] pub union underscores { @@ -121,7 +121,7 @@ unsafe fn main_0() -> i32 { FnPtrArg, VaArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, )] pub union anon_0 { diff --git a/tests/unit/out/unsafe/union_cross_arm_cast.rs b/tests/unit/out/unsafe/union_cross_arm_cast.rs index bae6b1f301..4c6f8cb4ab 100644 --- a/tests/unit/out/unsafe/union_cross_arm_cast.rs +++ b/tests/unit/out/unsafe/union_cross_arm_cast.rs @@ -13,7 +13,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -28,7 +28,7 @@ pub struct shape_a { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -46,7 +46,7 @@ pub struct shape_b { FnPtrArg, VaArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, )] pub union anon_0 { @@ -66,7 +66,7 @@ impl Default for anon_0 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/union_field_alignment.rs b/tests/unit/out/unsafe/union_field_alignment.rs index fa48910fa0..770621d105 100644 --- a/tests/unit/out/unsafe/union_field_alignment.rs +++ b/tests/unit/out/unsafe/union_field_alignment.rs @@ -13,7 +13,7 @@ use std::rc::Rc; FnPtrArg, VaArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, )] pub union anon_0 { @@ -32,7 +32,7 @@ impl Default for anon_0 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/union_flex_array_member.rs b/tests/unit/out/unsafe/union_flex_array_member.rs index a90a4d410d..5dd0cae24b 100644 --- a/tests/unit/out/unsafe/union_flex_array_member.rs +++ b/tests/unit/out/unsafe/union_flex_array_member.rs @@ -13,7 +13,7 @@ use std::rc::Rc; FnPtrArg, VaArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, )] pub union anon_0 { @@ -32,7 +32,7 @@ impl Default for anon_0 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/union_memset_memcpy.rs b/tests/unit/out/unsafe/union_memset_memcpy.rs index 8805d23fa4..002f4c8e92 100644 --- a/tests/unit/out/unsafe/union_memset_memcpy.rs +++ b/tests/unit/out/unsafe/union_memset_memcpy.rs @@ -13,7 +13,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -28,7 +28,7 @@ pub struct shape_a { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -45,7 +45,7 @@ pub struct shape_b { FnPtrArg, VaArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, )] pub union anon_0 { @@ -65,7 +65,7 @@ impl Default for anon_0 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/union_nested.rs b/tests/unit/out/unsafe/union_nested.rs index 5118a441e8..d01e16aaf6 100644 --- a/tests/unit/out/unsafe/union_nested.rs +++ b/tests/unit/out/unsafe/union_nested.rs @@ -13,7 +13,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -28,7 +28,7 @@ pub struct record { FnPtrArg, VaArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, )] pub union anon_0 { @@ -47,7 +47,7 @@ impl Default for anon_0 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -61,7 +61,7 @@ pub struct inner { FnPtrArg, VaArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, )] pub union anon_1 { @@ -80,7 +80,7 @@ impl Default for anon_1 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/union_pointer_pun_address.rs b/tests/unit/out/unsafe/union_pointer_pun_address.rs index a0d540a390..800d16877e 100644 --- a/tests/unit/out/unsafe/union_pointer_pun_address.rs +++ b/tests/unit/out/unsafe/union_pointer_pun_address.rs @@ -13,7 +13,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -27,7 +27,7 @@ pub struct node_a { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -56,7 +56,7 @@ unsafe fn main_0() -> i32 { FnPtrArg, VaArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, )] pub union anon_0 { diff --git a/tests/unit/out/unsafe/union_pointer_pun_writethrough.rs b/tests/unit/out/unsafe/union_pointer_pun_writethrough.rs index b9a9570992..abf73be7db 100644 --- a/tests/unit/out/unsafe/union_pointer_pun_writethrough.rs +++ b/tests/unit/out/unsafe/union_pointer_pun_writethrough.rs @@ -27,7 +27,7 @@ unsafe fn main_0() -> i32 { FnPtrArg, VaArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, )] pub union anon_0 { diff --git a/tests/unit/out/unsafe/union_struct_dual_use.rs b/tests/unit/out/unsafe/union_struct_dual_use.rs index 2153658726..eb77ee61b0 100644 --- a/tests/unit/out/unsafe/union_struct_dual_use.rs +++ b/tests/unit/out/unsafe/union_struct_dual_use.rs @@ -13,7 +13,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -31,7 +31,7 @@ pub unsafe fn sum_inner_0(mut i: *mut Inner) -> i32 { FnPtrArg, VaArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, )] pub union anon_1 { @@ -50,7 +50,7 @@ impl Default for anon_1 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/union_tagged_many_arms.rs b/tests/unit/out/unsafe/union_tagged_many_arms.rs index dde4703d4f..2b2c7abcde 100644 --- a/tests/unit/out/unsafe/union_tagged_many_arms.rs +++ b/tests/unit/out/unsafe/union_tagged_many_arms.rs @@ -19,7 +19,7 @@ pub const Tag_enum_T_REF: Tag_enum = 4; FnPtrArg, VaArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, )] pub union anon_0 { @@ -41,7 +41,7 @@ impl Default for anon_0 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/union_tagged_simple.rs b/tests/unit/out/unsafe/union_tagged_simple.rs index abf3ec2665..0797efcf2a 100644 --- a/tests/unit/out/unsafe/union_tagged_simple.rs +++ b/tests/unit/out/unsafe/union_tagged_simple.rs @@ -16,7 +16,7 @@ pub const Kind_enum_KIND_DONE: Kind_enum = 1; FnPtrArg, VaArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, )] pub union anon_0 { @@ -35,7 +35,7 @@ impl Default for anon_0 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/union_tagged_struct_arms.rs b/tests/unit/out/unsafe/union_tagged_struct_arms.rs index b51c40ab71..50de080c50 100644 --- a/tests/unit/out/unsafe/union_tagged_struct_arms.rs +++ b/tests/unit/out/unsafe/union_tagged_struct_arms.rs @@ -17,7 +17,7 @@ pub const Choice_enum_C_INTEGERS: Choice_enum = 3; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -33,7 +33,7 @@ pub struct anon_1 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -50,7 +50,7 @@ pub struct anon_2 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -68,7 +68,7 @@ pub struct anon_3 { FnPtrArg, VaArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, )] pub union anon_0 { @@ -88,7 +88,7 @@ impl Default for anon_0 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] 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 d53652740d..404e5b9cb3 100644 --- a/tests/unit/out/unsafe/union_void_ptr_sized_deref.rs +++ b/tests/unit/out/unsafe/union_void_ptr_sized_deref.rs @@ -17,7 +17,7 @@ pub const Width_enum_W_16: Width_enum = 2; FnPtrArg, VaArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, )] pub union anon_0 { @@ -38,7 +38,7 @@ impl Default for anon_0 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/unique_ptr.rs b/tests/unit/out/unsafe/unique_ptr.rs index 87c759096d..c0dcabc255 100644 --- a/tests/unit/out/unsafe/unique_ptr.rs +++ b/tests/unit/out/unsafe/unique_ptr.rs @@ -40,11 +40,10 @@ impl DefaultConstructibleUnsafe for SafePointer { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 4b3ca886aa..e8e9a643f6 100644 --- a/tests/unit/out/unsafe/unique_ptr_field_reset.rs +++ b/tests/unit/out/unsafe/unique_ptr_field_reset.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 5483321dfa..3ff0cfe3eb 100644 --- a/tests/unit/out/unsafe/unique_ptr_nested.rs +++ b/tests/unit/out/unsafe/unique_ptr_nested.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 d9c473c70a..6fbf268dcf 100644 --- a/tests/unit/out/unsafe/unique_ptr_struct.rs +++ b/tests/unit/out/unsafe/unique_ptr_struct.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 79016ef237..a49854d2a7 100644 --- a/tests/unit/out/unsafe/va_arg_mixed_types.rs +++ b/tests/unit/out/unsafe/va_arg_mixed_types.rs @@ -13,7 +13,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] 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 c9f51cc2f6..ca56031b25 100644 --- a/tests/unit/out/unsafe/va_arg_non_primitive_ptrs.rs +++ b/tests/unit/out/unsafe/va_arg_non_primitive_ptrs.rs @@ -13,7 +13,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/va_arg_struct_ctx.rs b/tests/unit/out/unsafe/va_arg_struct_ctx.rs index 54450ad99c..234eabf4d5 100644 --- a/tests/unit/out/unsafe/va_arg_struct_ctx.rs +++ b/tests/unit/out/unsafe/va_arg_struct_ctx.rs @@ -13,7 +13,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] @@ -39,7 +39,7 @@ pub unsafe fn set_error_0( FnPtrArg, VaArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, )] pub union value { diff --git a/tests/unit/out/unsafe/va_arg_void_ptr.rs b/tests/unit/out/unsafe/va_arg_void_ptr.rs index e8c6f42b68..02d10525e7 100644 --- a/tests/unit/out/unsafe/va_arg_void_ptr.rs +++ b/tests/unit/out/unsafe/va_arg_void_ptr.rs @@ -13,7 +13,7 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultConstructibleUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] diff --git a/tests/unit/out/unsafe/va_list_field.rs b/tests/unit/out/unsafe/va_list_field.rs index a66697d9c7..f1a33733a0 100644 --- a/tests/unit/out/unsafe/va_list_field.rs +++ b/tests/unit/out/unsafe/va_list_field.rs @@ -78,11 +78,10 @@ pub unsafe fn sum_ptr_2(mut n: i32, __args: Box<[VaArg]>) -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 cb882dfe99..5e4e804b63 100644 --- a/tests/unit/out/unsafe/vector.rs +++ b/tests/unit/out/unsafe/vector.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 bcb5dddaec..950aef3614 100644 --- a/tests/unit/out/unsafe/vector_iter_range_ctor.rs +++ b/tests/unit/out/unsafe/vector_iter_range_ctor.rs @@ -35,11 +35,10 @@ impl Degrees { FnPtrArg, ZeroInitializationUnsafe, CppFromUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] #[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 c4f1c6b32e..73e285d3c4 100644 --- a/tests/unit/out/unsafe/vector_subscript_direct.rs +++ b/tests/unit/out/unsafe/vector_subscript_direct.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 a2bace4ed1..1f17dc9a6d 100644 --- a/tests/unit/out/unsafe/vector_with_allocator.rs +++ b/tests/unit/out/unsafe/vector_with_allocator.rs @@ -13,11 +13,10 @@ use std::rc::Rc; VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct TestAllocator_int_ {} impl TestAllocator_int_ { pub unsafe fn allocate(&mut self, mut n: usize) -> *mut i32 { @@ -43,11 +42,10 @@ impl TestAllocator_int_ { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] 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 f757d825d9..38d8a90d65 100644 --- a/tests/unit/out/unsafe/void_cast.rs +++ b/tests/unit/out/unsafe/void_cast.rs @@ -43,11 +43,10 @@ pub unsafe fn bump_and_return_4() -> i32 { VaArg, FnPtrArg, ZeroInitializationUnsafe, - MemberwiseUnsafe, + TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, )] -#[memberwise(default_constructor)] pub struct Holder { pub field: i32, }