From 3e542afb0d25a97c9a4489f06f6fb6955493fec2 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Fri, 4 Dec 2026 19:58:00 +0000 Subject: [PATCH 01/14] Update tests --- .../out/refcount/cross_tu_tag_collision.rs | 3 +- .../out/unsafe/cross_tu_tag_collision.rs | 3 +- .../out/refcount/defaulted_move_cross_tu.rs | 6 - .../out/unsafe/defaulted_move_cross_tu.rs | 2 - .../out/refcount/friend_operator.rs | 1 - .../out/unsafe/friend_operator.rs | 1 - .../out/refcount/opaque_forward_decl.rs | 1 - .../out/unsafe/opaque_forward_decl.rs | 1 - .../refcount/out_of_line_methods_cross_tu.rs | 6 +- .../unsafe/out_of_line_methods_cross_tu.rs | 6 +- .../template_method_late_instantiation.rs | 5 - .../template_method_late_instantiation.rs | 5 - .../out/refcount/p14-class-in-two-files.rs | 1 - .../out/unsafe/p14-class-in-two-files.rs | 1 - .../p15-class-template-static-member.rs | 2 - .../p15-class-template-static-member.rs | 2 - .../out/refcount/p15-function-template.rs | 2 - .../out/unsafe/p15-function-template.rs | 2 - .../p16-default-argument-lambda-in-class.rs | 5 +- .../p16-default-argument-lambda-in-class.rs | 5 +- .../basic.link/out/refcount/basic.link.rs | 55 +-------- .../basic/basic.link/out/unsafe/basic.link.rs | 51 +------- .../out/refcount/basic.scope.class.rs | 10 -- .../out/refcount/basic.scope.param.rs | 1 - .../out/refcount/basic.scope.pdecl.rs | 17 +-- .../out/refcount/basic.scope.scope.rs | 98 ++++------------ .../out/unsafe/basic.scope.class.rs | 10 -- .../out/unsafe/basic.scope.param.rs | 1 - .../out/unsafe/basic.scope.pdecl.rs | 17 +-- .../out/unsafe/basic.scope.scope.rs | 73 ++---------- .../out/refcount/basic.start.term.rs | 2 - .../out/unsafe/basic.start.term.rs | 2 - .../out/refcount/basic.types.general.rs | 2 - .../out/unsafe/basic.types.general.rs | 2 - .../out/refcount/class.spaceship.rs | 4 - .../out/unsafe/class.spaceship.rs | 4 - .../out/refcount/class.base.init.rs | 1 - .../class.init/out/unsafe/class.base.init.rs | 1 - .../out/refcount/class.conv.ctor.rs | 5 - .../class.conv/out/refcount/class.conv.fct.rs | 4 - .../class.conv/out/unsafe/class.conv.ctor.rs | 5 - .../class.conv/out/unsafe/class.conv.fct.rs | 4 - .../out/refcount/class.copy.ctor.rs | 4 +- .../class.ctor/out/unsafe/class.copy.ctor.rs | 4 +- .../class.mem/out/refcount/class.free.rs | 2 - .../out/refcount/class.mem.general.rs | 10 -- .../class/class.mem/out/unsafe/class.free.rs | 2 - .../class.mem/out/unsafe/class.mem.general.rs | 10 -- .../refcount/concept.equalitycomparable.rs | 3 - .../out/refcount/concept.totallyordered.rs | 3 - .../out/unsafe/concept.equalitycomparable.rs | 3 - .../out/unsafe/concept.totallyordered.rs | 3 - .../out/refcount/concept.constructible.rs | 11 +- .../out/refcount/concept.convertible.rs | 3 - .../out/unsafe/concept.constructible.rs | 3 - .../out/unsafe/concept.convertible.rs | 3 - .../out/refcount/sequence.reqmts.rs | 2 - .../out/unsafe/sequence.reqmts.rs | 2 - .../dcl.init.general-p6.2-padding-bits.rs | 43 +++---- .../dcl.init/out/refcount/dcl.init.general.rs | 79 +++---------- .../dcl.init/out/refcount/dcl.init.ref.rs | 1 - .../dcl.init.general-p6.2-padding-bits.rs | 38 +++--- .../dcl.init/out/unsafe/dcl.init.general.rs | 62 +++------- .../dcl.init/out/unsafe/dcl.init.ref.rs | 1 - .../dcl.meaning/out/refcount/dcl.array.rs | 1 - .../out/refcount/dcl.fct.default.rs | 26 ---- .../dcl.meaning/out/refcount/dcl.mptr.rs | 18 --- .../dcl.meaning/out/unsafe/dcl.array.rs | 1 - .../dcl.meaning/out/unsafe/dcl.fct.default.rs | 26 ---- .../dcl.meaning/out/unsafe/dcl.mptr.rs | 11 -- tests/std/expr/conv/out/refcount/conv.mem.rs | 1 - tests/std/expr/conv/out/unsafe/conv.mem.rs | 1 - .../expr.post/out/refcount/expr.const.cast.rs | 1 - ...nterpret.cast-p10-result-is-unspecified.rs | 2 - .../out/refcount/expr.reinterpret.cast.rs | 4 - .../expr.post/out/unsafe/expr.const.cast.rs | 1 - ...nterpret.cast-p10-result-is-unspecified.rs | 2 - .../out/unsafe/expr.reinterpret.cast.rs | 4 - .../expr.unary/out/refcount/expr.pre.incr.rs | 1 - .../expr.unary/out/refcount/expr.unary.op.rs | 3 - .../expr.unary/out/unsafe/expr.pre.incr.rs | 1 - .../expr.unary/out/unsafe/expr.unary.op.rs | 3 - .../expr.compound/out/refcount/expr.cond.rs | 1 - .../expr.compound/out/refcount/expr.eq.rs | 10 -- ...ptr.oper-p6-null-pointer-to-data-member.rs | 1 - .../out/refcount/expr.mptr.oper.rs | 11 +- .../expr.compound/out/unsafe/expr.cond.rs | 1 - .../expr/expr.compound/out/unsafe/expr.eq.rs | 8 -- ...ptr.oper-p6-null-pointer-to-data-member.rs | 1 - .../out/unsafe/expr.mptr.oper.rs | 7 +- .../expr.prim/out/refcount/expr.prim.this.rs | 7 -- .../expr.prim/out/unsafe/expr.prim.this.rs | 7 -- .../allocator.requirements.general.rs | 7 -- .../unsafe/allocator.requirements.general.rs | 7 -- .../out/refcount/utility.arg.requirements.rs | 5 - .../out/unsafe/utility.arg.requirements.rs | 5 - .../support/cmp/out/refcount/cmp.concept.rs | 4 - .../std/support/cmp/out/unsafe/cmp.concept.rs | 4 - tests/std/temp/out/refcount/temp.type.rs | 4 - tests/std/temp/out/unsafe/temp.type.rs | 4 - .../temp/temp.spec/out/refcount/temp.inst.rs | 7 +- .../temp/temp.spec/out/unsafe/temp.inst.rs | 7 +- .../utility/out/refcount/forward-helpers.rs | 35 +----- .../utilities/utility/out/refcount/forward.rs | 5 +- .../utility/out/refcount/utility.as.const.rs | 1 - .../utility/out/unsafe/forward-helpers.rs | 34 +----- .../utilities/utility/out/unsafe/forward.rs | 5 +- .../utility/out/unsafe/utility.as.const.rs | 1 - tests/ub/out/refcount/ctor_ref_member.rs | 1 - .../refcount/self_referencing_initializer.rs | 3 +- tests/ub/out/refcount/ub6.rs | 1 - tests/ub/out/unsafe/ctor_ref_member.rs | 1 - .../unsafe/self_referencing_initializer.rs | 3 +- tests/ub/out/unsafe/ub6.rs | 1 - tests/unit/out/refcount/05_new.rs | 6 +- tests/unit/out/refcount/10_struct.rs | 13 -- tests/unit/out/refcount/addr_of_global.rs | 2 - tests/unit/out/refcount/anonymous-struct.rs | 13 +- tests/unit/out/refcount/anonymous-struct_c.rs | 19 +-- tests/unit/out/refcount/anonymous_enum.rs | 4 +- tests/unit/out/refcount/anonymous_enum_c.rs | 4 +- tests/unit/out/refcount/any.rs | 1 - tests/unit/out/refcount/array_const_init.rs | 18 +-- tests/unit/out/refcount/array_field_addr.rs | 11 -- .../out/refcount/array_of_noncopy_struct.rs | 10 -- tests/unit/out/refcount/array_reference.rs | 1 - tests/unit/out/refcount/as_const.rs | 1 - tests/unit/out/refcount/assign_rhs_first.rs | 1 - .../out/refcount/assignment_single_eval.rs | 33 +----- tests/unit/out/refcount/bounded_struct_ptr.rs | 1 - tests/unit/out/refcount/bst.rs | 1 - tests/unit/out/refcount/c_struct.rs | 7 +- tests/unit/out/refcount/cast.rs | 22 +--- .../refcount/cast_array_to_pointer_decay.rs | 9 -- tests/unit/out/refcount/class.rs | 4 - .../refcount/class_template_lazy_member.rs | 5 - tests/unit/out/refcount/class_templates.rs | 12 -- tests/unit/out/refcount/clone_vs_move.rs | 15 --- tests/unit/out/refcount/comma_operator.rs | 1 - tests/unit/out/refcount/complex_function.rs | 4 - .../out/refcount/compound_assign_paren.rs | 1 - tests/unit/out/refcount/concepts.rs | 1 - tests/unit/out/refcount/constexpr_function.rs | 2 - tests/unit/out/refcount/constructor.rs | 11 -- .../refcount/container_element_receiver.rs | 1 - .../unit/out/refcount/container_field_addr.rs | 1 - .../conversion_operator_same_translation.rs | 2 - tests/unit/out/refcount/copy_assign.rs | 73 +----------- tests/unit/out/refcount/copy_ctor.rs | 62 +--------- .../unit/out/refcount/copy_move_defaulted.rs | 111 +----------------- tests/unit/out/refcount/copy_move_deleted.rs | 45 +------ tests/unit/out/refcount/default.rs | 48 +------- .../refcount/default_function_arguments.rs | 12 -- tests/unit/out/refcount/default_in_statics.rs | 28 +---- tests/unit/out/refcount/destructor.rs | 20 ++-- tests/unit/out/refcount/destructor_params.rs | 1 - tests/unit/out/refcount/doubly_linked_list.rs | 1 - .../out/refcount/enum_default_in_static.rs | 3 +- tests/unit/out/refcount/enum_int_interop.rs | 1 - tests/unit/out/refcount/enum_int_interop_c.rs | 1 - .../unit/out/refcount/enum_underlying_type.rs | 9 -- tests/unit/out/refcount/exprs.rs | 2 - tests/unit/out/refcount/fft.rs | 11 +- tests/unit/out/refcount/field_aliasing.rs | 16 +-- .../unit/out/refcount/field_array_elem_ptr.rs | 13 -- .../field_pointers_malloced_struct.rs | 1 - .../field_reinterpret_write_through.rs | 18 +-- tests/unit/out/refcount/find.rs | 1 - .../refcount/first_field_ptr_covers_struct.rs | 2 - .../out/refcount/first_member_downcast.rs | 2 - .../refcount/flex_array_member_incomplete.rs | 10 -- .../flex_array_member_sibling_write.rs | 22 ---- tests/unit/out/refcount/fn_ptr.rs | 1 - tests/unit/out/refcount/fn_ptr_cast.rs | 3 +- tests/unit/out/refcount/fn_ptr_stable_sort.rs | 1 - tests/unit/out/refcount/fn_ptr_struct.rs | 6 +- .../unit/out/refcount/fn_ptr_typedef_cast.rs | 1 - tests/unit/out/refcount/fn_ptr_vtable.rs | 1 - tests/unit/out/refcount/fn_ref.rs | 1 - .../refcount/foreach_disjoint_field_borrow.rs | 1 - tests/unit/out/refcount/forward_basic.rs | 8 +- tests/unit/out/refcount/forward_decltype.rs | 4 +- tests/unit/out/refcount/forward_explicit.rs | 4 +- tests/unit/out/refcount/forward_pack.rs | 8 +- tests/unit/out/refcount/friend.rs | 4 - .../unit/out/refcount/function_overloading.rs | 5 +- .../out/refcount/global_call_temporaries.rs | 1 - .../out/refcount/global_init_side_effect.rs | 1 - .../out/refcount/global_non_const_init.rs | 23 ---- tests/unit/out/refcount/global_pointers.rs | 1 - .../refcount/global_without_initializer.rs | 1 - .../out/refcount/goto_aggregate_default.rs | 3 +- tests/unit/out/refcount/goto_cleanup.rs | 1 - tests/unit/out/refcount/huffman.rs | 7 +- .../refcount/immutable-deref-on-func-call.rs | 3 +- tests/unit/out/refcount/implicit_autoref.rs | 1 - tests/unit/out/refcount/init.rs | 3 +- tests/unit/out/refcount/kruskal.rs | 11 +- tests/unit/out/refcount/lambda_as_field.rs | 20 ---- .../out/refcount/lambda_capture_copy_ctor.rs | 11 -- tests/unit/out/refcount/lambda_capture_ref.rs | 1 - .../out/refcount/lambda_capture_star_this.rs | 1 - .../unit/out/refcount/lambda_capture_this.rs | 1 - .../unit/out/refcount/lambda_capture_value.rs | 1 - .../unit/out/refcount/lambda_decltype_type.rs | 30 ----- .../refcount/lambda_generic_explicit_args.rs | 1 - .../out/refcount/lambda_immediate_init.rs | 17 --- tests/unit/out/refcount/lambda_nested.rs | 1 - .../unit/out/refcount/lambda_static_local.rs | 1 - .../refcount/libc_struct_without_default.rs | 21 +--- tests/unit/out/refcount/linked_list.rs | 1 - .../refcount/local_anon_struct_collision.rs | 6 +- .../out/refcount/local_record_template.rs | 4 - tests/unit/out/refcount/map_key_copy_ctor.rs | 4 +- tests/unit/out/refcount/map_try_emplace.rs | 22 ---- tests/unit/out/refcount/max.rs | 1 - .../unit/out/refcount/memcpy_struct_bytes.rs | 3 +- .../out/refcount/memcpy_struct_layouts.rs | 24 +--- .../unit/out/refcount/memcpy_struct_struct.rs | 1 - tests/unit/out/refcount/memset_struct_tail.rs | 13 -- tests/unit/out/refcount/move_assign.rs | 21 +--- tests/unit/out/refcount/move_ctor.rs | 23 +--- tests/unit/out/refcount/move_this.rs | 4 +- tests/unit/out/refcount/nested_structs.rs | 6 - tests/unit/out/refcount/new.rs | 3 +- tests/unit/out/refcount/new_bst.rs | 1 - tests/unit/out/refcount/new_struct.rs | 6 +- .../refcount/nttp_distinct_specializations.rs | 3 - tests/unit/out/refcount/offsetof.rs | 11 -- .../unit/out/refcount/opaque_forward_decl.rs | 1 - tests/unit/out/refcount/opaque_record_copy.rs | 4 +- .../unit/out/refcount/opaque_then_defined.rs | 2 - .../out/refcount/operator_arithmetic_free.rs | 1 - .../refcount/operator_arithmetic_member.rs | 1 - .../out/refcount/operator_bitwise_free.rs | 1 - .../out/refcount/operator_bitwise_member.rs | 1 - .../refcount/operator_comparison_defaulted.rs | 8 -- .../out/refcount/operator_comparison_free.rs | 2 - .../refcount/operator_comparison_member.rs | 1 - .../out/refcount/operator_comparison_mixed.rs | 1 - .../refcount/operator_comparison_nonbool.rs | 16 +-- .../operator_comparison_noncopyable.rs | 4 +- .../operator_compound_assignment_free.rs | 1 - .../operator_compound_assignment_member.rs | 1 - tests/unit/out/refcount/operator_friend.rs | 7 -- tests/unit/out/refcount/operator_less_than.rs | 1 - .../out/refcount/operator_logical_free.rs | 1 - .../out/refcount/operator_logical_member.rs | 1 - .../refcount/operator_member_pointer_free.rs | 11 -- .../operator_member_pointer_member.rs | 14 +-- .../unit/out/refcount/operator_other_free.rs | 1 - .../out/refcount/operator_other_member.rs | 4 +- tests/unit/out/refcount/operator_overloads.rs | 1 - .../unit/out/refcount/operator_qualifiers.rs | 1 - tests/unit/out/refcount/operator_three_way.rs | 1 - tests/unit/out/refcount/operator_traits.rs | 5 - tests/unit/out/refcount/overload_mangling.rs | 5 +- .../refcount/pair_converting_construction.rs | 20 ---- tests/unit/out/refcount/pod.rs | 1 - tests/unit/out/refcount/pointer_array.rs | 11 -- tests/unit/out/refcount/pointers.rs | 1 - tests/unit/out/refcount/ptr_cast_init.rs | 2 - tests/unit/out/refcount/push_emplace_back.rs | 37 +----- tests/unit/out/refcount/random.rs | 22 +--- tests/unit/out/refcount/reference_wrapper.rs | 1 - tests/unit/out/refcount/references.rs | 12 -- tests/unit/out/refcount/refs_as_args.rs | 1 - .../out/refcount/reinterpret_cast_ptr_cmp.rs | 27 +---- .../out/refcount/reinterpret_cast_struct.rs | 3 +- .../reinterpret_cast_struct_to_struct.rs | 2 - tests/unit/out/refcount/reserved_keywords.rs | 3 - tests/unit/out/refcount/return_move.rs | 4 +- .../unit/out/refcount/rvalue_rule_arg_move.rs | 9 +- tests/unit/out/refcount/rvalue_struct.rs | 1 - .../scalar_builtin_construct_destruct.rs | 1 - .../unit/out/refcount/size_t_static_member.rs | 2 - .../out/refcount/size_t_template_param.rs | 2 - tests/unit/out/refcount/static_local.rs | 5 +- .../unit/out/refcount/static_var_in_class.rs | 6 +- tests/unit/out/refcount/stdcopy.rs | 1 - tests/unit/out/refcount/strdup.rs | 1 - .../out/refcount/string_literal_ptr_init.rs | 1 - tests/unit/out/refcount/string_substr.rs | 1 - .../out/refcount/struct_2d_array_field.rs | 14 +-- tests/unit/out/refcount/struct_ctor.rs | 13 -- .../refcount/struct_member_array_adjacency.rs | 12 +- tests/unit/out/refcount/struct_ptr.rs | 3 +- .../refcount/structured_binding_copy_ctor.rs | 1 - .../structured_binding_element_ctor.rs | 8 +- .../refcount/structured_binding_move_ctor.rs | 5 +- .../refcount/structured_binding_range_for.rs | 1 - .../out/refcount/structured_binding_ref.rs | 1 - .../refcount/structured_binding_trivial.rs | 1 - .../refcount/tag_vs_identifier_collision.rs | 33 ++---- .../unit/out/refcount/template_default_arg.rs | 24 ---- .../out/refcount/template_static_member.rs | 5 - .../unit/out/refcount/temporary_field_addr.rs | 12 -- .../out/refcount/temporary_field_ctor_arg.rs | 2 - .../out/refcount/temporary_field_two_args.rs | 2 - tests/unit/out/refcount/this.rs | 2 - .../unit/out/refcount/typedef-anon-struct.rs | 4 +- tests/unit/out/refcount/types.rs | 2 +- .../out/refcount/unary_expr_or_type_trait.rs | 3 +- tests/unit/out/refcount/unboxed_records.rs | 23 +--- .../out/refcount/union_addrof_external.rs | 22 +--- tests/unit/out/refcount/union_basic.rs | 40 +------ .../unit/out/refcount/union_cross_arm_cast.rs | 33 +----- .../out/refcount/union_field_alignment.rs | 10 +- .../out/refcount/union_flex_array_member.rs | 8 -- .../unit/out/refcount/union_memset_memcpy.rs | 32 +---- tests/unit/out/refcount/union_nested.rs | 28 +---- .../out/refcount/union_pointer_pun_address.rs | 11 +- .../union_pointer_pun_writethrough.rs | 9 +- .../out/refcount/union_struct_dual_use.rs | 13 +- .../out/refcount/union_tagged_many_arms.rs | 18 +-- .../unit/out/refcount/union_tagged_simple.rs | 12 +- .../out/refcount/union_tagged_struct_arms.rs | 17 +-- .../refcount/union_void_ptr_sized_deref.rs | 10 +- tests/unit/out/refcount/unique_ptr.rs | 11 +- .../out/refcount/unique_ptr_const_deref.rs | 4 +- .../out/refcount/unique_ptr_field_reset.rs | 5 +- tests/unit/out/refcount/unique_ptr_nested.rs | 5 +- tests/unit/out/refcount/unique_ptr_struct.rs | 1 - tests/unit/out/refcount/va_arg_mixed_types.rs | 1 - .../out/refcount/va_arg_non_primitive_ptrs.rs | 1 - tests/unit/out/refcount/va_arg_struct_ctx.rs | 12 +- tests/unit/out/refcount/va_arg_void_ptr.rs | 1 - tests/unit/out/refcount/va_list_field.rs | 1 - tests/unit/out/refcount/vector.rs | 3 - .../out/refcount/vector_iter_range_ctor.rs | 2 - .../out/refcount/vector_subscript_direct.rs | 2 - .../out/refcount/vector_with_allocator.rs | 2 - tests/unit/out/refcount/void_cast.rs | 6 +- tests/unit/out/unsafe/05_new.rs | 6 +- tests/unit/out/unsafe/10_struct.rs | 13 -- tests/unit/out/unsafe/addr_of_global.rs | 2 - tests/unit/out/unsafe/anonymous-struct.rs | 13 +- tests/unit/out/unsafe/anonymous-struct_c.rs | 19 +-- tests/unit/out/unsafe/anonymous_enum.rs | 4 +- tests/unit/out/unsafe/anonymous_enum_c.rs | 4 +- tests/unit/out/unsafe/any.rs | 1 - tests/unit/out/unsafe/array_const_init.rs | 8 +- tests/unit/out/unsafe/array_field_addr.rs | 1 - .../out/unsafe/array_of_noncopy_struct.rs | 10 -- tests/unit/out/unsafe/array_reference.rs | 1 - tests/unit/out/unsafe/as_const.rs | 1 - tests/unit/out/unsafe/assign_rhs_first.rs | 1 - .../unit/out/unsafe/assignment_single_eval.rs | 24 +--- tests/unit/out/unsafe/bounded_struct_ptr.rs | 1 - tests/unit/out/unsafe/bst.rs | 1 - tests/unit/out/unsafe/c_struct.rs | 7 +- tests/unit/out/unsafe/cast.rs | 10 +- .../out/unsafe/cast_array_to_pointer_decay.rs | 1 - tests/unit/out/unsafe/class.rs | 4 - .../out/unsafe/class_template_lazy_member.rs | 5 - tests/unit/out/unsafe/class_templates.rs | 12 -- tests/unit/out/unsafe/clone_vs_move.rs | 3 - tests/unit/out/unsafe/comma_operator.rs | 1 - tests/unit/out/unsafe/complex_function.rs | 4 - .../unit/out/unsafe/compound_assign_paren.rs | 1 - tests/unit/out/unsafe/concepts.rs | 1 - tests/unit/out/unsafe/constexpr_function.rs | 2 - tests/unit/out/unsafe/constructor.rs | 11 -- .../out/unsafe/container_element_receiver.rs | 1 - tests/unit/out/unsafe/container_field_addr.rs | 1 - .../conversion_operator_same_translation.rs | 2 - tests/unit/out/unsafe/copy_assign.rs | 41 ------- tests/unit/out/unsafe/copy_ctor.rs | 51 +------- tests/unit/out/unsafe/copy_move_defaulted.rs | 87 +------------- tests/unit/out/unsafe/copy_move_deleted.rs | 31 +---- tests/unit/out/unsafe/default.rs | 13 +- .../out/unsafe/default_function_arguments.rs | 12 -- tests/unit/out/unsafe/default_in_statics.rs | 9 +- tests/unit/out/unsafe/destructor.rs | 18 +-- tests/unit/out/unsafe/destructor_params.rs | 1 - tests/unit/out/unsafe/doubly_linked_list.rs | 1 - .../unit/out/unsafe/enum_default_in_static.rs | 3 +- tests/unit/out/unsafe/enum_int_interop.rs | 1 - tests/unit/out/unsafe/enum_int_interop_c.rs | 1 - tests/unit/out/unsafe/enum_underlying_type.rs | 5 - tests/unit/out/unsafe/exprs.rs | 2 - tests/unit/out/unsafe/fft.rs | 11 +- tests/unit/out/unsafe/field_aliasing.rs | 5 +- tests/unit/out/unsafe/field_array_elem_ptr.rs | 2 - .../unsafe/field_pointers_malloced_struct.rs | 1 - .../unsafe/field_reinterpret_write_through.rs | 6 +- tests/unit/out/unsafe/find.rs | 1 - .../unsafe/first_field_ptr_covers_struct.rs | 2 - .../unit/out/unsafe/first_member_downcast.rs | 2 - .../unsafe/flex_array_member_incomplete.rs | 5 - .../unsafe/flex_array_member_sibling_write.rs | 3 - tests/unit/out/unsafe/fn_ptr.rs | 1 - tests/unit/out/unsafe/fn_ptr_cast.rs | 3 +- tests/unit/out/unsafe/fn_ptr_stable_sort.rs | 1 - tests/unit/out/unsafe/fn_ptr_struct.rs | 6 +- tests/unit/out/unsafe/fn_ptr_typedef_cast.rs | 1 - tests/unit/out/unsafe/fn_ptr_vtable.rs | 1 - tests/unit/out/unsafe/fn_ref.rs | 1 - .../unsafe/foreach_disjoint_field_borrow.rs | 1 - tests/unit/out/unsafe/forward_basic.rs | 8 +- tests/unit/out/unsafe/forward_decltype.rs | 4 +- tests/unit/out/unsafe/forward_explicit.rs | 4 +- tests/unit/out/unsafe/forward_pack.rs | 8 +- tests/unit/out/unsafe/friend.rs | 4 - tests/unit/out/unsafe/function_overloading.rs | 5 +- .../out/unsafe/global_call_temporaries.rs | 1 - .../out/unsafe/global_init_side_effect.rs | 1 - .../unit/out/unsafe/global_non_const_init.rs | 23 ---- tests/unit/out/unsafe/global_pointers.rs | 1 - .../out/unsafe/global_without_initializer.rs | 1 - .../unit/out/unsafe/goto_aggregate_default.rs | 3 +- tests/unit/out/unsafe/goto_cleanup.rs | 1 - tests/unit/out/unsafe/huffman.rs | 10 +- .../unsafe/immutable-deref-on-func-call.rs | 3 +- tests/unit/out/unsafe/implicit_autoref.rs | 1 - tests/unit/out/unsafe/init.rs | 3 +- tests/unit/out/unsafe/kruskal.rs | 17 +-- tests/unit/out/unsafe/lambda_as_field.rs | 20 ---- .../out/unsafe/lambda_capture_copy_ctor.rs | 11 -- tests/unit/out/unsafe/lambda_capture_ref.rs | 1 - .../out/unsafe/lambda_capture_star_this.rs | 1 - tests/unit/out/unsafe/lambda_capture_this.rs | 1 - tests/unit/out/unsafe/lambda_capture_value.rs | 1 - tests/unit/out/unsafe/lambda_decltype_type.rs | 30 ----- .../unsafe/lambda_generic_explicit_args.rs | 1 - .../unit/out/unsafe/lambda_immediate_init.rs | 17 --- tests/unit/out/unsafe/lambda_nested.rs | 1 - tests/unit/out/unsafe/lambda_static_local.rs | 1 - .../out/unsafe/libc_struct_without_default.rs | 21 +--- tests/unit/out/unsafe/linked_list.rs | 1 - .../out/unsafe/local_anon_struct_collision.rs | 6 +- .../unit/out/unsafe/local_record_template.rs | 4 - tests/unit/out/unsafe/map_key_copy_ctor.rs | 4 +- tests/unit/out/unsafe/map_try_emplace.rs | 22 ---- tests/unit/out/unsafe/max.rs | 1 - tests/unit/out/unsafe/memcpy_struct_bytes.rs | 3 +- .../unit/out/unsafe/memcpy_struct_layouts.rs | 13 +- tests/unit/out/unsafe/memcpy_struct_struct.rs | 1 - tests/unit/out/unsafe/memset_struct_tail.rs | 1 - tests/unit/out/unsafe/move_assign.rs | 12 -- tests/unit/out/unsafe/move_ctor.rs | 23 +--- tests/unit/out/unsafe/move_this.rs | 4 +- tests/unit/out/unsafe/nested_structs.rs | 6 - tests/unit/out/unsafe/new.rs | 3 +- tests/unit/out/unsafe/new_bst.rs | 1 - tests/unit/out/unsafe/new_struct.rs | 6 +- .../unsafe/nttp_distinct_specializations.rs | 3 - tests/unit/out/unsafe/offsetof.rs | 11 -- tests/unit/out/unsafe/opaque_forward_decl.rs | 1 - tests/unit/out/unsafe/opaque_record_copy.rs | 4 +- tests/unit/out/unsafe/opaque_then_defined.rs | 2 - .../out/unsafe/operator_arithmetic_free.rs | 1 - .../out/unsafe/operator_arithmetic_member.rs | 1 - .../unit/out/unsafe/operator_bitwise_free.rs | 1 - .../out/unsafe/operator_bitwise_member.rs | 1 - .../unsafe/operator_comparison_defaulted.rs | 8 -- .../out/unsafe/operator_comparison_free.rs | 2 - .../out/unsafe/operator_comparison_member.rs | 1 - .../out/unsafe/operator_comparison_mixed.rs | 1 - .../out/unsafe/operator_comparison_nonbool.rs | 8 -- .../unsafe/operator_comparison_noncopyable.rs | 4 +- .../operator_compound_assignment_free.rs | 1 - .../operator_compound_assignment_member.rs | 1 - tests/unit/out/unsafe/operator_friend.rs | 7 -- tests/unit/out/unsafe/operator_less_than.rs | 1 - .../unit/out/unsafe/operator_logical_free.rs | 1 - .../out/unsafe/operator_logical_member.rs | 1 - .../unsafe/operator_member_pointer_free.rs | 2 - .../unsafe/operator_member_pointer_member.rs | 5 +- tests/unit/out/unsafe/operator_other_free.rs | 1 - .../unit/out/unsafe/operator_other_member.rs | 4 +- tests/unit/out/unsafe/operator_overloads.rs | 1 - tests/unit/out/unsafe/operator_qualifiers.rs | 1 - tests/unit/out/unsafe/operator_three_way.rs | 1 - tests/unit/out/unsafe/operator_traits.rs | 5 - tests/unit/out/unsafe/overload_mangling.rs | 5 +- .../unsafe/pair_converting_construction.rs | 20 ---- tests/unit/out/unsafe/pod.rs | 1 - tests/unit/out/unsafe/pointer_array.rs | 1 - tests/unit/out/unsafe/pointers.rs | 1 - tests/unit/out/unsafe/ptr_cast_init.rs | 2 - tests/unit/out/unsafe/push_emplace_back.rs | 19 +-- tests/unit/out/unsafe/random.rs | 6 +- tests/unit/out/unsafe/reference_wrapper.rs | 1 - tests/unit/out/unsafe/references.rs | 2 - tests/unit/out/unsafe/refs_as_args.rs | 1 - .../out/unsafe/reinterpret_cast_ptr_cmp.rs | 7 +- .../out/unsafe/reinterpret_cast_struct.rs | 3 +- .../reinterpret_cast_struct_to_struct.rs | 2 - tests/unit/out/unsafe/reserved_keywords.rs | 3 - tests/unit/out/unsafe/return_move.rs | 4 +- tests/unit/out/unsafe/rvalue_rule_arg_move.rs | 1 - tests/unit/out/unsafe/rvalue_struct.rs | 1 - .../scalar_builtin_construct_destruct.rs | 1 - tests/unit/out/unsafe/size_t_static_member.rs | 2 - .../unit/out/unsafe/size_t_template_param.rs | 2 - tests/unit/out/unsafe/static_local.rs | 4 +- tests/unit/out/unsafe/static_var_in_class.rs | 6 +- tests/unit/out/unsafe/stdcopy.rs | 1 - tests/unit/out/unsafe/strdup.rs | 1 - .../out/unsafe/string_literal_ptr_init.rs | 1 - tests/unit/out/unsafe/string_substr.rs | 1 - .../unit/out/unsafe/struct_2d_array_field.rs | 3 +- tests/unit/out/unsafe/struct_ctor.rs | 13 -- .../unsafe/struct_member_array_adjacency.rs | 3 +- tests/unit/out/unsafe/struct_ptr.rs | 3 +- .../unsafe/structured_binding_copy_ctor.rs | 1 - .../unsafe/structured_binding_element_ctor.rs | 8 +- .../unsafe/structured_binding_move_ctor.rs | 5 +- .../unsafe/structured_binding_range_for.rs | 1 - .../unit/out/unsafe/structured_binding_ref.rs | 1 - .../out/unsafe/structured_binding_trivial.rs | 1 - .../out/unsafe/tag_vs_identifier_collision.rs | 29 ++--- tests/unit/out/unsafe/template_default_arg.rs | 24 ---- .../unit/out/unsafe/template_static_member.rs | 5 - tests/unit/out/unsafe/temporary_field_addr.rs | 2 - .../out/unsafe/temporary_field_ctor_arg.rs | 2 - .../out/unsafe/temporary_field_two_args.rs | 2 - tests/unit/out/unsafe/this.rs | 2 - tests/unit/out/unsafe/typedef-anon-struct.rs | 4 +- tests/unit/out/unsafe/types.rs | 2 +- .../out/unsafe/unary_expr_or_type_trait.rs | 3 +- tests/unit/out/unsafe/unboxed_records.rs | 11 +- .../unit/out/unsafe/union_addrof_external.rs | 9 +- tests/unit/out/unsafe/union_basic.rs | 28 +---- tests/unit/out/unsafe/union_cross_arm_cast.rs | 10 +- .../unit/out/unsafe/union_field_alignment.rs | 8 +- .../out/unsafe/union_flex_array_member.rs | 6 - tests/unit/out/unsafe/union_memset_memcpy.rs | 10 +- tests/unit/out/unsafe/union_nested.rs | 15 +-- .../out/unsafe/union_pointer_pun_address.rs | 9 +- .../unsafe/union_pointer_pun_writethrough.rs | 7 +- .../unit/out/unsafe/union_struct_dual_use.rs | 11 +- .../unit/out/unsafe/union_tagged_many_arms.rs | 16 +-- tests/unit/out/unsafe/union_tagged_simple.rs | 10 +- .../out/unsafe/union_tagged_struct_arms.rs | 15 +-- .../out/unsafe/union_void_ptr_sized_deref.rs | 8 +- tests/unit/out/unsafe/unique_ptr.rs | 14 +-- .../unit/out/unsafe/unique_ptr_const_deref.rs | 7 +- .../unit/out/unsafe/unique_ptr_field_reset.rs | 8 +- tests/unit/out/unsafe/unique_ptr_nested.rs | 8 +- tests/unit/out/unsafe/unique_ptr_struct.rs | 1 - tests/unit/out/unsafe/va_arg_mixed_types.rs | 1 - .../out/unsafe/va_arg_non_primitive_ptrs.rs | 1 - tests/unit/out/unsafe/va_arg_struct_ctx.rs | 10 +- tests/unit/out/unsafe/va_arg_void_ptr.rs | 1 - tests/unit/out/unsafe/va_list_field.rs | 1 - tests/unit/out/unsafe/vector.rs | 3 - .../unit/out/unsafe/vector_iter_range_ctor.rs | 2 - .../out/unsafe/vector_subscript_direct.rs | 2 - .../unit/out/unsafe/vector_with_allocator.rs | 2 - tests/unit/out/unsafe/void_cast.rs | 9 +- 552 files changed, 465 insertions(+), 3802 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 ee2522bdfe..688b785051 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 @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(4)] pub struct widget { @@ -24,7 +23,7 @@ pub struct widget { pub id: i32, } pub fn a_value_0() -> i32 { - let mut w: widget = ::default(); + let mut w: widget = { ::zero_init() }; w.id = 11; return w.id; } 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 a6566b5214..324a56c295 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 @@ -15,13 +15,12 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct widget { pub id: i32, } pub unsafe fn a_value_0() -> i32 { - let mut w: widget = ::default(); + let mut w: widget = unsafe { ::zero_init() }; w.id = 11; return w.id; } 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 bc4ba39164..72c848bcd4 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 @@ -34,11 +34,6 @@ impl S { field!(this, n).write(Box::new([(*x.borrow()), ((*x.borrow()) + 1)])); } } -impl Default for S { - fn default() -> Self { - { ::zero_init() } - } -} #[derive( Clone, Record, @@ -50,7 +45,6 @@ impl Default for S { Memberwise, CopyConstructible, Swappable, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(Conversions)] 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 736e2c672a..64869a0ac2 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 @@ -13,7 +13,6 @@ use std::rc::Rc; DefaultInitializableUnsafe, MemberwiseUnsafe, SwappableUnsafe, - Default, )] #[memberwise(move_constructor, move_assign)] #[derive(ConversionsUnsafe)] @@ -41,7 +40,6 @@ impl S { MemberwiseUnsafe, CopyConstructibleUnsafe, SwappableUnsafe, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(ConversionsUnsafe)] 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 1b1ac0deb3..a02d77c9aa 100644 --- a/tests/multi-file/friend_operator/out/refcount/friend_operator.rs +++ b/tests/multi-file/friend_operator/out/refcount/friend_operator.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] 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 9b135af2e2..a886b2e72b 100644 --- a/tests/multi-file/friend_operator/out/unsafe/friend_operator.rs +++ b/tests/multi-file/friend_operator/out/unsafe/friend_operator.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] 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 4f7fd71566..199b2d160c 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 @@ -15,7 +15,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, 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 b5489afd25..bdc484dbe8 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 @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, 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 10e90ff48d..1e4226c12e 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 @@ -31,9 +31,7 @@ impl S { return this.with(|__s| __s.v); } } -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Default, Conversions, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Conversions)] #[conversions(copy, move)] #[byte_size(4)] pub struct M { @@ -54,7 +52,6 @@ pub trait Base { FnPtrArg, DefaultInitializable, Copyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -74,7 +71,6 @@ impl Derived {} FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] 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 51e50e971e..311b98cde1 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 @@ -29,9 +29,7 @@ impl S { } } #[repr(C)] -#[derive( - FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, Default, ConversionsUnsafe, -)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, ConversionsUnsafe)] #[conversions(copy, move)] pub struct M { pub v: i32, @@ -49,7 +47,6 @@ pub unsafe trait Base { ZeroInitializationUnsafe, DefaultInitializableUnsafe, CopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -66,7 +63,6 @@ impl Derived {} ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] 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 f23fc96578..1d14c1bb49 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 @@ -32,11 +32,6 @@ impl S_int_ { field!(this, x).write(0); } } -impl Default for S_int_ { - fn default() -> Self { - { S_int_ { x: 0 } } - } -} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); diff --git a/tests/multi-file/template_method_late_instantiation/out/unsafe/template_method_late_instantiation.rs b/tests/multi-file/template_method_late_instantiation/out/unsafe/template_method_late_instantiation.rs index 4623ba404f..c28a2d0c94 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 @@ -29,11 +29,6 @@ impl S_int_ { (&raw mut (*this).x).write(0); } } -impl Default for S_int_ { - fn default() -> Self { - unsafe { S_int_ { x: 0 } } - } -} pub fn main() { unsafe { __cpp2rust_init_globals(); diff --git a/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/refcount/p14-class-in-two-files.rs b/tests/std/basic/basic.def.odr/p14-class-in-two-files/out/refcount/p14-class-in-two-files.rs index 66076fe075..58817dd82b 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 @@ -136,7 +136,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] 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 5949c7cd1a..f1986b8bc3 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 @@ -116,7 +116,6 @@ pub static mut shared_5: std::cell::LazyCell = ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] 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 dc756f1f38..8b6b1ad6b1 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 @@ -102,7 +102,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -132,7 +131,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] 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 8752bcaa6e..b326994488 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 @@ -82,7 +82,6 @@ pub static mut member_4: std::cell::LazyCell = ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -110,7 +109,6 @@ pub static mut member_5: std::cell::LazyCell = ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] 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 fda33c6c38..267c1438a1 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 @@ -200,7 +200,6 @@ fn main_0() -> i32 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -245,7 +244,6 @@ pub fn b_count_local_15() -> i32 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] 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 fa90a916bb..bdb6ab28a6 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 @@ -173,7 +173,6 @@ unsafe fn main_0() -> i32 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -213,7 +212,6 @@ pub unsafe fn b_count_local_15() -> i32 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] 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 ff87206292..a56c3cfe30 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 @@ -113,7 +113,6 @@ impl Destructible for AssertsDtorCountAtExit { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -165,7 +164,7 @@ pub fn main() { } fn main_0() -> i32 { assert!((ctorCount_0.with(|rc| *rc.borrow()) == 0)); - let x: Value = Rc::new(RefCell::new(::default())); + let x: Value = Rc::new(RefCell::new({ ::zero_init() })); ({ X::h( x.as_pointer(), @@ -183,7 +182,7 @@ fn main_0() -> i32 { return 0; } pub fn b_call_6() { - let x: Value = Rc::new(RefCell::new(::default())); + let x: Value = Rc::new(RefCell::new({ ::zero_init() })); ({ X::h( x.as_pointer(), 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 347a2005ea..3b8785dde5 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 @@ -92,7 +92,6 @@ impl DestructibleUnsafe for AssertsDtorCountAtExit { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -151,7 +150,7 @@ pub fn main() { } unsafe fn main_0() -> i32 { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)) == (0))); - let mut x: X = ::default(); + let mut x: X = unsafe { ::zero_init() }; (unsafe { X::h( &raw mut x, @@ -173,7 +172,7 @@ unsafe fn main_0() -> i32 { return 0; } pub unsafe fn b_call_6() { - let mut x: X = ::default(); + let mut x: X = unsafe { ::zero_init() }; (unsafe { X::h( &raw mut x, 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 b8797e781b..b5ff7e17cf 100644 --- a/tests/std/basic/basic.link/out/refcount/basic.link.rs +++ b/tests/std/basic/basic.link/out/refcount/basic.link.rs @@ -53,15 +53,8 @@ impl anon_13 { this.reinterpret_cast() } } -impl Default for anon_13 { - fn default() -> Self { - anon_13 { - __bytes: Box::from([0u8; 4]), - } - } -} thread_local!( - pub static anon_13: Value = Rc::new(RefCell::new(::default())); + pub static anon_13: Value = Rc::new(RefCell::new({ ::zero_init() })); ); pub fn test_14() { anon_13::whole(anon_13.with(|v| v.as_pointer())).write(5); @@ -98,11 +91,6 @@ impl Record_19 { field!(this, id).write(100); } } -impl Default for Record_19 { - fn default() -> Self { - { Record_19 { id: 100 } } - } -} thread_local!( pub static depth_20: Value = Rc::new(RefCell::new(3)); ); @@ -138,7 +126,6 @@ pub fn test_29() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -154,7 +141,7 @@ thread_local!( pub static total_32: Value = Rc::new(RefCell::new(10)); ); pub fn test_33() { - let tally: Value = Rc::new(RefCell::new(::default())); + let tally: Value = Rc::new(RefCell::new({ ::zero_init() })); assert!((({ Tally_31::add(tally.as_pointer(), 1,) }) == 11)); assert!((({ add_in_b_34(1,) }) == 102)); assert!((total_32.with(|rc| *rc.borrow()) == 11)); @@ -169,7 +156,6 @@ pub fn test_33() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -263,11 +249,6 @@ impl Entry_52 { field!(this, key).write(1); } } -impl Default for Entry_52 { - fn default() -> Self { - { Entry_52 { key: 1 } } - } -} #[derive( Copy, Clone, @@ -294,11 +275,6 @@ impl Entry_54 { field!(this, value).write(30); } } -impl Default for Entry_54 { - fn default() -> Self { - { Entry_54 { key: 2, value: 30 } } - } -} pub fn test_58() { assert!( (({ @@ -382,15 +358,8 @@ impl anon_62 { this.reinterpret_cast() } } -impl Default for anon_62 { - fn default() -> Self { - anon_62 { - __bytes: Box::from([0u8; 4]), - } - } -} thread_local!( - pub static anon_62: Value = Rc::new(RefCell::new(::default())); + pub static anon_62: Value = Rc::new(RefCell::new({ ::zero_init() })); ); pub fn set_whole_in_b_15(mut value: i32) { anon_62::whole(anon_62.with(|v| v.as_pointer())).write(value); @@ -430,16 +399,6 @@ impl Record_65 { field!(this, extra).write(1); } } -impl Default for Record_65 { - fn default() -> Self { - { - Record_65 { - id: 200_i64, - extra: 1, - } - } - } -} thread_local!( pub static depth_66: Value = Rc::new(RefCell::new(4)); ); @@ -476,7 +435,6 @@ pub fn raise_30(mut by: i32) -> i32 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -492,7 +450,7 @@ thread_local!( pub static total_68: Value = Rc::new(RefCell::new(100)); ); pub fn add_in_b_34(mut amount: i32) -> i32 { - let tally: Value = Rc::new(RefCell::new(::default())); + let tally: Value = Rc::new(RefCell::new({ ::zero_init() })); return ({ Tally_67::add(tally.as_pointer(), amount) }); } thread_local!( @@ -550,11 +508,6 @@ impl Entry_71 { field!(this, key).write(400_i64); } } -impl Default for Entry_71 { - fn default() -> Self { - { Entry_71 { key: 400_i64 } } - } -} thread_local!( pub static table_57: Value> = Rc::new(RefCell::new(Box::new([1, 2, 3]))); ); 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 ec942e8e60..6ac0d83eb4 100644 --- a/tests/std/basic/basic.link/out/unsafe/basic.link.rs +++ b/tests/std/basic/basic.link/out/unsafe/basic.link.rs @@ -50,13 +50,8 @@ pub union anon_13 { pub whole: i32, pub fraction: f32, } -impl Default for anon_13 { - fn default() -> Self { - unsafe { std::mem::zeroed() } - } -} pub static mut anon_13: std::cell::LazyCell = - std::cell::LazyCell::new(|| unsafe { ::default() }); + std::cell::LazyCell::new(|| unsafe { unsafe { ::zero_init() } }); pub unsafe fn test_14() { (*std::cell::LazyCell::force_mut(&mut *&raw mut anon_13)).whole = 5; (unsafe { set_whole_in_b_15(6) }); @@ -87,11 +82,6 @@ impl Record_19 { (&raw mut (*this).id).write(100); } } -impl Default for Record_19 { - fn default() -> Self { - unsafe { Record_19 { id: 100 } } - } -} pub static mut depth_20: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 3 }); pub unsafe fn test_21() { assert!(((unsafe { bump_18() }) == (2))); @@ -124,7 +114,6 @@ pub unsafe fn test_29() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -137,7 +126,7 @@ impl Tally_31 { } pub static mut total_32: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 10 }); pub unsafe fn test_33() { - let mut tally: Tally_31 = ::default(); + let mut tally: Tally_31 = unsafe { ::zero_init() }; assert!(((unsafe { Tally_31::add(&raw mut tally, 1,) }) == (11))); assert!(((unsafe { add_in_b_34(1,) }) == (102))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut total_32)) == (11))); @@ -151,7 +140,6 @@ pub unsafe fn test_33() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -235,11 +223,6 @@ impl Entry_52 { (&raw mut (*this).key).write(1); } } -impl Default for Entry_52 { - fn default() -> Self { - unsafe { Entry_52 { key: 1 } } - } -} #[repr(C)] #[derive( Copy, @@ -262,11 +245,6 @@ impl Entry_54 { (&raw mut (*this).value).write(30); } } -impl Default for Entry_54 { - fn default() -> Self { - unsafe { Entry_54 { key: 2, value: 30 } } - } -} pub unsafe fn test_58() { assert!((((*std::cell::LazyCell::force_mut(&mut *&raw mut table_57))[(1) as usize]) == (2))); (*std::cell::LazyCell::force_mut(&mut *&raw mut table_57))[(2) as usize] = 30; @@ -332,13 +310,8 @@ pub union anon_62 { pub whole: i32, pub fraction: f32, } -impl Default for anon_62 { - fn default() -> Self { - unsafe { std::mem::zeroed() } - } -} pub static mut anon_62: std::cell::LazyCell = - std::cell::LazyCell::new(|| unsafe { ::default() }); + std::cell::LazyCell::new(|| unsafe { unsafe { ::zero_init() } }); pub unsafe fn set_whole_in_b_15(mut value: i32) { (*std::cell::LazyCell::force_mut(&mut *&raw mut anon_62)).whole = value; } @@ -371,16 +344,6 @@ impl Record_65 { (&raw mut (*this).extra).write(1); } } -impl Default for Record_65 { - fn default() -> Self { - unsafe { - Record_65 { - id: 200_i64, - extra: 1, - } - } - } -} pub static mut depth_66: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 4 }); pub unsafe fn bump_in_b_22() -> i32 { return (unsafe { bump_64() }); @@ -411,7 +374,6 @@ pub unsafe fn raise_30(mut by: i32) -> i32 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -424,7 +386,7 @@ impl Tally_67 { } pub static mut total_68: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 100 }); pub unsafe fn add_in_b_34(mut amount: i32) -> i32 { - let mut tally: Tally_67 = ::default(); + let mut tally: Tally_67 = unsafe { ::zero_init() }; return (unsafe { Tally_67::add(&raw mut tally, amount) }); } pub static mut balance_35: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 50 }); @@ -471,11 +433,6 @@ impl Entry_71 { (&raw mut (*this).key).write(400_i64); } } -impl Default for Entry_71 { - fn default() -> Self { - unsafe { Entry_71 { key: 400_i64 } } - } -} pub static mut table_57: std::cell::LazyCell<[i32; 3]> = std::cell::LazyCell::new(|| unsafe { [1, 2, 3] }); pub unsafe fn table_sum_in_b_59() -> i32 { 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 166826eb34..0df086d016 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 @@ -42,11 +42,6 @@ impl p1_member_hides_namespace_variable_HasBalance { field!(this, balance).write(7); } } -impl Default for p1_member_hides_namespace_variable_HasBalance { - fn default() -> Self { - { p1_member_hides_namespace_variable_HasBalance { balance: 7 } } - } -} pub fn test_1() { object!( object, @@ -92,11 +87,6 @@ impl p1_out_of_class_definition_is_in_class_scope_HasStaticTotal { field!(this, held).write(1); } } -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 } } - } -} thread_local!( pub static initial_3: Value = Rc::new(RefCell::new(6)); ); 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 c20a931c54..767fedea51 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 @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] 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 2966ede095..13b764c00b 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 @@ -27,7 +27,6 @@ pub fn test_0() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -48,7 +47,7 @@ pub fn test_1() { let mut outer: Ptr = (node.as_pointer()); { let node: Value = - >::default(); + { >::zero_init() }; *node.borrow_mut() = p1_own_address_in_initializer_SelfLinked { next: (node.as_pointer()), value: 7, @@ -105,20 +104,6 @@ impl p9_func_declared_before_function_body_RecordsConstructorName { ); } } -impl Default for p9_func_declared_before_function_body_RecordsConstructorName { - fn default() -> Self { - { - { - let __v: Value = - Rc::new(RefCell::new(ZeroInitialization::zero_init())); - p9_func_declared_before_function_body_RecordsConstructorName::constructor_1( - __v.as_pointer(), - ); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} pub fn plain_function_5() -> Ptr { return Ptr::::from_string_literal(b"plain_function"); } 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 af1207012a..19a6cb5df8 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 @@ -54,7 +54,6 @@ pub const p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum_Size_large: FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -75,9 +74,10 @@ pub fn test_5() { assert!(((p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum_Size_small as i32) == 3)); assert!(((p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum_Size_large as i32) == 8)); assert!(((p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum_Size_large as i32) == 8)); - let object: Value = Rc::new( - RefCell::new(::default()), - ); + let object: Value = + Rc::new(RefCell::new({ + ::zero_init() + })); assert!( (({ p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum::scale(object.as_pointer(), 2) @@ -98,7 +98,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -141,15 +140,8 @@ impl anon_8 { this.reinterpret_cast() } } -impl Default for anon_8 { - fn default() -> Self { - anon_8 { - __bytes: Box::from([0u8; 8]), - } - } -} thread_local!( - pub static anon_8: Value = Rc::new(RefCell::new(::default())); + pub static anon_8: Value = Rc::new(RefCell::new({ ::zero_init() })); ); #[derive( VaArg, @@ -175,13 +167,6 @@ impl anon_9 { this.reinterpret_cast() } } -impl Default for anon_9 { - fn default() -> Self { - anon_9 { - __bytes: Box::from([0u8; 8]), - } - } -} #[derive( Clone, Record, @@ -191,7 +176,6 @@ impl Default for anon_9 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -213,9 +197,10 @@ pub fn test_10() { assert!(((anon_8::namespace_count(anon_8.with(|v| v.as_pointer())).read()) == 4)); anon_8::namespace_ratio(anon_8.with(|v| v.as_pointer())).write(0.25_f64); assert!(((anon_8::namespace_ratio(anon_8.with(|v| v.as_pointer())).read()) == 0.25_f64)); - let object: Value = Rc::new( - RefCell::new(::default()), - ); + let object: Value = + Rc::new(RefCell::new({ + ::zero_init() + })); (*object.borrow_mut()).tag = 1; anon_9::member_count(field_ptr!(object.as_pointer(), anon_9)).write(6); assert!(((anon_9::member_count(field_ptr!(object.as_pointer(), anon_9)).read()) == 6)); @@ -229,7 +214,7 @@ pub fn test_10() { anon_9::member_ratio(field_ptr!(object.as_pointer(), anon_9)).write(0.5_f64); assert!(((anon_9::member_ratio(field_ptr!(object.as_pointer(), anon_9)).read()) == 0.5_f64)); assert!(({ (*object.borrow()).tag } == 1)); - let anon_11: Value = Rc::new(RefCell::new(::default())); + let anon_11: Value = Rc::new(RefCell::new({ ::zero_init() })); anon_11::block_count(anon_11.as_pointer()).write(9); assert!(((anon_11::block_count(anon_11.as_pointer()).read()) == 9)); anon_11::block_ratio(anon_11.as_pointer()).write(0.75_f64); @@ -259,13 +244,6 @@ impl anon_11 { this.reinterpret_cast() } } -impl Default for anon_11 { - fn default() -> Self { - anon_11 { - __bytes: Box::from([0u8; 8]), - } - } -} #[derive( Copy, Clone, @@ -304,16 +282,6 @@ impl p3_2_const_qualified_member_is_distinct_HasConstOverload { field!(this, const_calls).write(0); } } -impl Default for p3_2_const_qualified_member_is_distinct_HasConstOverload { - fn default() -> Self { - { - p3_2_const_qualified_member_is_distinct_HasConstOverload { - plain_calls: 0, - const_calls: 0, - } - } - } -} pub fn test_12() { object!( object, @@ -374,15 +342,6 @@ impl p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverl field!(this, base).write(10); } } -impl Default for p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload { - fn default() -> Self { - { - p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload { - base: 10, - } - } - } -} pub fn test_15() { object!(object, p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload::constructor_1()); assert!( @@ -424,7 +383,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -441,9 +399,10 @@ impl p3_2_ref_qualified_members_are_distinct_HasRefQualifiedOverloads { } } pub fn test_18() { - let object: Value = Rc::new( - RefCell::new(::default()), - ); + let object: Value = + Rc::new(RefCell::new({ + ::zero_init() + })); assert!( (({ p3_2_ref_qualified_members_are_distinct_HasRefQualifiedOverloads::get_1( @@ -456,9 +415,9 @@ pub fn test_18() { assert!( (({ p3_2_ref_qualified_members_are_distinct_HasRefQualifiedOverloads::get_2( - Rc::new(RefCell::new( - ::default(), - )) + Rc::new(RefCell::new({ + ::zero_init() + })) .as_pointer(), ) }) == 4) @@ -513,16 +472,6 @@ impl p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload return (value + 2); } } -impl Default for p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload { - fn default() -> Self { - { - p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload { - plain_calls: 0, - const_calls: 0, - } - } - } -} pub fn test_19() { object!( object, @@ -568,7 +517,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -585,7 +533,11 @@ impl p3_4_ref_qualified_member_templates_are_distinct_HasRefQualifiedTemplateOve } } pub fn test_22() { - let object : Value = Rc::new(RefCell::new(::default() )) ; + let object: Value< + p3_4_ref_qualified_member_templates_are_distinct_HasRefQualifiedTemplateOverloads, + > = Rc::new(RefCell::new({ + ::zero_init() + })); assert!( (({ p3_4_ref_qualified_member_templates_are_distinct_HasRefQualifiedTemplateOverloads :: get_1_int ( object .as_pointer() , 10 , ) @@ -595,7 +547,7 @@ pub fn test_22() { assert!((rvalue_calls_21.with(|rc| *rc.borrow()) == 0)); assert!( (({ - p3_4_ref_qualified_member_templates_are_distinct_HasRefQualifiedTemplateOverloads :: get_2_int ( Rc::new(RefCell::new(::default() )).as_pointer() , 10 , ) + p3_4_ref_qualified_member_templates_are_distinct_HasRefQualifiedTemplateOverloads :: get_2_int ( Rc::new(RefCell::new( { ::zero_init() } )).as_pointer() , 10 , ) }) == 14) ); assert!((lvalue_calls_20.with(|rc| *rc.borrow()) == 1)); @@ -621,7 +573,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -641,7 +592,6 @@ pub fn shared_friend_24() -> i32 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -686,7 +636,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -717,7 +666,6 @@ pub fn test_33() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] 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 d72be59edc..fa6e4d3f37 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 @@ -35,11 +35,6 @@ impl p1_member_hides_namespace_variable_HasBalance { (&raw mut (*this).balance).write(7); } } -impl Default for p1_member_hides_namespace_variable_HasBalance { - fn default() -> Self { - unsafe { p1_member_hides_namespace_variable_HasBalance { balance: 7 } } - } -} pub unsafe fn test_1() { object_unsafe!( object, @@ -80,11 +75,6 @@ impl p1_out_of_class_definition_is_in_class_scope_HasStaticTotal { (&raw mut (*this).held).write(1); } } -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 } } - } -} pub static mut initial_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 6 }); pub static mut total_4: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { ((*std::cell::LazyCell::force_mut(&mut *&raw mut initial_3)) + (1)) 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 d3424bc960..4b9c2d9629 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 @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] 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 16559374a7..53eba697a8 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 @@ -27,7 +27,6 @@ pub unsafe fn test_0() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -45,7 +44,7 @@ pub unsafe fn test_1() { (&mut node as *mut p1_own_address_in_initializer_SelfLinked); { let mut node: p1_own_address_in_initializer_SelfLinked = - ::default(); + unsafe { ::zero_init() }; node = p1_own_address_in_initializer_SelfLinked { next: (&mut node as *mut p1_own_address_in_initializer_SelfLinked), value: 7, @@ -103,20 +102,6 @@ impl p9_func_declared_before_function_body_RecordsConstructorName { assert!((((*this).name) == (c"RecordsConstructorName".as_ptr()))); } } -impl Default for p9_func_declared_before_function_body_RecordsConstructorName { - fn default() -> Self { - unsafe { - { - let mut __v: p9_func_declared_before_function_body_RecordsConstructorName = - ZeroInitializationUnsafe::zero_init(); - p9_func_declared_before_function_body_RecordsConstructorName::constructor_1( - &raw mut __v, - ); - __v - } - } - } -} pub unsafe fn plain_function_5() -> *const libc::c_char { return c"plain_function".as_ptr(); } 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 fd92c6ac36..be87d8c08c 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 @@ -50,7 +50,6 @@ pub const p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum_Size_large: ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -71,7 +70,7 @@ pub unsafe fn test_5() { assert!(((p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum_Size_large as i32) == (8))); assert!(((p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum_Size_large as i32) == (8))); let mut object: p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum = - ::default(); + unsafe { ::zero_init() }; assert!( ((unsafe { p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum::scale(&raw const object, 2) @@ -89,7 +88,6 @@ pub static mut count_6: std::cell::LazyCell = std::cell::LazyCell::new(|| u ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -121,13 +119,8 @@ pub union anon_8 { pub namespace_count: i32, pub namespace_ratio: f64, } -impl Default for anon_8 { - fn default() -> Self { - unsafe { std::mem::zeroed() } - } -} pub static mut anon_8: std::cell::LazyCell = - std::cell::LazyCell::new(|| unsafe { ::default() }); + std::cell::LazyCell::new(|| unsafe { unsafe { ::zero_init() } }); #[repr(C)] #[derive( Copy, @@ -142,11 +135,6 @@ pub union anon_9 { pub member_count: i32, pub member_ratio: f64, } -impl Default for anon_9 { - fn default() -> Self { - unsafe { std::mem::zeroed() } - } -} #[repr(C)] #[derive( Copy, @@ -156,7 +144,6 @@ impl Default for anon_9 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -177,7 +164,7 @@ pub unsafe fn test_10() { (((*std::cell::LazyCell::force_mut(&mut *&raw mut anon_8)).namespace_ratio) == (0.25_f64)) ); let mut object: p2_13_anonymous_union_members_in_parent_scope_HasAnonymousUnion = - ::default(); + unsafe { ::zero_init() }; object.tag = 1; object.anon_9.member_count = 6; assert!(((object.anon_9.member_count) == (6))); @@ -191,7 +178,7 @@ pub unsafe fn test_10() { object.anon_9.member_ratio = 0.5_f64; assert!(((object.anon_9.member_ratio) == (0.5_f64))); assert!(((object.tag) == (1))); - let mut anon_11: anon_11 = ::default(); + let mut anon_11: anon_11 = unsafe { ::zero_init() }; anon_11.block_count = 9; assert!(((anon_11.block_count) == (9))); anon_11.block_ratio = 0.75_f64; @@ -211,11 +198,6 @@ pub union anon_11 { pub block_count: i32, pub block_ratio: f64, } -impl Default for anon_11 { - fn default() -> Self { - unsafe { std::mem::zeroed() } - } -} #[repr(C)] #[derive( Copy, @@ -246,16 +228,6 @@ impl p3_2_const_qualified_member_is_distinct_HasConstOverload { (&raw mut (*this).const_calls).write(0); } } -impl Default for p3_2_const_qualified_member_is_distinct_HasConstOverload { - fn default() -> Self { - unsafe { - p3_2_const_qualified_member_is_distinct_HasConstOverload { - plain_calls: 0, - const_calls: 0, - } - } - } -} pub unsafe fn test_12() { object_unsafe!( object, @@ -312,15 +284,6 @@ impl p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverl (&raw mut (*this).base).write(10); } } -impl Default for p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload { - fn default() -> Self { - unsafe { - p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload { - base: 10, - } - } - } -} pub unsafe fn test_15() { object_unsafe!(object, p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload::constructor_1()); assert!( @@ -357,7 +320,6 @@ pub static mut rvalue_calls_17: std::cell::LazyCell = ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -374,7 +336,7 @@ impl p3_2_ref_qualified_members_are_distinct_HasRefQualifiedOverloads { } pub unsafe fn test_18() { let mut object: p3_2_ref_qualified_members_are_distinct_HasRefQualifiedOverloads = - ::default(); + unsafe { ::zero_init() }; assert!( ((unsafe { p3_2_ref_qualified_members_are_distinct_HasRefQualifiedOverloads::get_1(&raw mut object) @@ -384,9 +346,9 @@ pub unsafe fn test_18() { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut rvalue_calls_17)) == (0))); assert!( ((unsafe { - p3_2_ref_qualified_members_are_distinct_HasRefQualifiedOverloads::get_2( - &mut ::default(), - ) + p3_2_ref_qualified_members_are_distinct_HasRefQualifiedOverloads::get_2(&mut unsafe { + ::zero_init() + }) }) == (4)) ); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut lvalue_calls_16)) == (1))); @@ -429,16 +391,6 @@ impl p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload return ((value) + (2)); } } -impl Default for p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload { - fn default() -> Self { - unsafe { - p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload { - plain_calls: 0, - const_calls: 0, - } - } - } -} pub unsafe fn test_19() { object_unsafe!( object, @@ -481,7 +433,6 @@ pub static mut rvalue_calls_21: std::cell::LazyCell = ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -497,7 +448,7 @@ impl p3_4_ref_qualified_member_templates_are_distinct_HasRefQualifiedTemplateOve } } pub unsafe fn test_22() { - let mut object : p3_4_ref_qualified_member_templates_are_distinct_HasRefQualifiedTemplateOverloads = ::default() ; + let mut object : p3_4_ref_qualified_member_templates_are_distinct_HasRefQualifiedTemplateOverloads = unsafe { ::zero_init() } ; assert!( ((unsafe { p3_4_ref_qualified_member_templates_are_distinct_HasRefQualifiedTemplateOverloads :: get_1_int ( &raw mut object , 10 , ) @@ -507,7 +458,7 @@ pub unsafe fn test_22() { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut rvalue_calls_21)) == (0))); assert!( ((unsafe { - p3_4_ref_qualified_member_templates_are_distinct_HasRefQualifiedTemplateOverloads :: get_2_int ( &mut ::default() , 10 , ) + p3_4_ref_qualified_member_templates_are_distinct_HasRefQualifiedTemplateOverloads :: get_2_int ( &mut unsafe { ::zero_init() } , 10 , ) }) == (14)) ); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut lvalue_calls_20)) == (1))); @@ -531,7 +482,6 @@ pub static mut friend_calls_23: std::cell::LazyCell = ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -549,7 +499,6 @@ pub unsafe fn shared_friend_24() -> i32 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -589,7 +538,6 @@ pub static mut function_calls_31: std::cell::LazyCell = ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -617,7 +565,6 @@ pub unsafe fn test_33() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] 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 b55aea53a8..dfaee8a866 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 @@ -74,7 +74,6 @@ pub struct HoldsTracker { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -176,7 +175,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] 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 47926e2396..13147e4933 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 @@ -71,7 +71,6 @@ pub struct HoldsTracker { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -177,7 +176,6 @@ pub static mut trivial_9: std::cell::LazyCell = ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] 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 62a94b610e..8ba56005be 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 @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -92,7 +91,6 @@ pub fn test_0() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] 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 b7ff0e156e..c3a641ca56 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 @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -95,7 +94,6 @@ pub unsafe fn test_0() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/std/class/class.compare/out/refcount/class.spaceship.rs b/tests/std/class/class.compare/out/refcount/class.spaceship.rs index 222558373f..9ba14eb07f 100644 --- a/tests/std/class/class.compare/out/refcount/class.spaceship.rs +++ b/tests/std/class/class.compare/out/refcount/class.spaceship.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, PartiallyOrderedWith, )] #[three_way(ThreeWayComparable::three_way)] @@ -127,7 +126,6 @@ pub fn test_0() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, PartiallyOrderedWith, )] #[three_way(ThreeWayComparable::three_way)] @@ -217,7 +215,6 @@ pub fn test_1() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, PartiallyOrderedWith, )] #[three_way(weak_ordering_from_user_operator_Fraction::operator_cmp)] @@ -342,7 +339,6 @@ pub fn test_2() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, PartiallyOrderedWith, )] #[three_way(partial_ordering_from_user_operator_Interval::operator_cmp)] diff --git a/tests/std/class/class.compare/out/unsafe/class.spaceship.rs b/tests/std/class/class.compare/out/unsafe/class.spaceship.rs index 38362beb7f..191925992f 100644 --- a/tests/std/class/class.compare/out/unsafe/class.spaceship.rs +++ b/tests/std/class/class.compare/out/unsafe/class.spaceship.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, PartiallyOrderedWithUnsafe, )] #[three_way(ThreeWayComparableUnsafe::three_way)] @@ -127,7 +126,6 @@ pub unsafe fn test_0() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, PartiallyOrderedWithUnsafe, )] #[three_way(ThreeWayComparableUnsafe::three_way)] @@ -205,7 +203,6 @@ pub unsafe fn test_1() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, PartiallyOrderedWithUnsafe, )] #[three_way(weak_ordering_from_user_operator_Fraction::operator_cmp)] @@ -315,7 +312,6 @@ pub unsafe fn test_2() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, PartiallyOrderedWithUnsafe, )] #[three_way(partial_ordering_from_user_operator_Interval::operator_cmp)] 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 e684057e0f..bc65b3ca2f 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 @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] 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 89a481c297..31ea050fe8 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 @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] 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 7d5e62eabe..c3ff30087b 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 @@ -25,7 +25,6 @@ impl p1_template_constructor_from_own_type_Probe { FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -64,7 +63,6 @@ pub fn test_0() { FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -173,7 +171,6 @@ pub fn test_1() { FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -245,7 +242,6 @@ pub fn test_2() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -264,7 +260,6 @@ pub struct p2_explicit_constructor_and_conversion_function_Source { FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] 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 4c4224906a..49aba4337c 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 @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -51,7 +50,6 @@ pub fn test_0() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -132,7 +130,6 @@ pub fn test_1() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -171,7 +168,6 @@ pub fn test_2() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] 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 ec44ca2f4a..5fbd4828b1 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 @@ -24,7 +24,6 @@ impl p1_template_constructor_from_own_type_Probe { ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -60,7 +59,6 @@ pub unsafe fn test_0() { ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -133,7 +131,6 @@ pub unsafe fn test_1() { ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -185,7 +182,6 @@ pub unsafe fn test_2() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -201,7 +197,6 @@ pub struct p2_explicit_constructor_and_conversion_function_Source { ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] 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 9aa229123c..746f9ae7c3 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 @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -45,7 +44,6 @@ pub unsafe fn test_0() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -109,7 +107,6 @@ pub unsafe fn test_1() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -141,7 +138,6 @@ pub unsafe fn test_2() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] 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 6f462ee343..824508ccf4 100644 --- a/tests/std/class/class.mem/class.ctor/out/refcount/class.copy.ctor.rs +++ b/tests/std/class/class.mem/class.ctor/out/refcount/class.copy.ctor.rs @@ -6,9 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Memberwise, Default, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Memberwise)] #[memberwise(move_constructor)] #[derive(Conversions)] #[conversions(move)] 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 d59560429f..20fbb6cc3e 100644 --- a/tests/std/class/class.mem/class.ctor/out/unsafe/class.copy.ctor.rs +++ b/tests/std/class/class.mem/class.ctor/out/unsafe/class.copy.ctor.rs @@ -7,9 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, MemberwiseUnsafe, Default, -)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, MemberwiseUnsafe)] #[memberwise(move_constructor)] #[derive(ConversionsUnsafe)] #[conversions(move)] 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 b432d72898..9aec1f06e8 100644 --- a/tests/std/class/class.mem/out/refcount/class.free.rs +++ b/tests/std/class/class.mem/out/refcount/class.free.rs @@ -19,7 +19,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -69,7 +68,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] 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 977c66d683..53d8db8bf2 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 @@ -48,11 +48,6 @@ impl p7_1_function_body_names_later_member_HasLaterMembers { field!(this, stock).write(9); } } -impl Default for p7_1_function_body_names_later_member_HasLaterMembers { - fn default() -> Self { - { p7_1_function_body_names_later_member_HasLaterMembers { stock: 9 } } - } -} pub fn test_3() { object!( object, @@ -101,11 +96,6 @@ impl p7_2_default_argument_names_later_member_HasLaterStaticStep { field!(this, total).write(1); } } -impl Default for p7_2_default_argument_names_later_member_HasLaterStaticStep { - fn default() -> Self { - { p7_2_default_argument_names_later_member_HasLaterStaticStep { total: 1 } } - } -} pub fn test_6() { object!( object, 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 cc8588b0d2..67fe9f9ac2 100644 --- a/tests/std/class/class.mem/out/unsafe/class.free.rs +++ b/tests/std/class/class.mem/out/unsafe/class.free.rs @@ -16,7 +16,6 @@ pub static mut allocations_0: std::cell::LazyCell = std::cell::LazyCell::ne ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -61,7 +60,6 @@ pub static mut deallocations_2: std::cell::LazyCell = ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] 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 5eace88cf7..05d45ba1dc 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 @@ -43,11 +43,6 @@ impl p7_1_function_body_names_later_member_HasLaterMembers { (&raw mut (*this).stock).write(9); } } -impl Default for p7_1_function_body_names_later_member_HasLaterMembers { - fn default() -> Self { - unsafe { p7_1_function_body_names_later_member_HasLaterMembers { stock: 9 } } - } -} pub unsafe fn test_3() { object_unsafe!( object, @@ -87,11 +82,6 @@ impl p7_2_default_argument_names_later_member_HasLaterStaticStep { (&raw mut (*this).total).write(1); } } -impl Default for p7_2_default_argument_names_later_member_HasLaterStaticStep { - fn default() -> Self { - unsafe { p7_2_default_argument_names_later_member_HasLaterStaticStep { total: 1 } } - } -} pub unsafe fn test_6() { object_unsafe!( object, diff --git a/tests/std/concepts/concepts.compare/out/refcount/concept.equalitycomparable.rs b/tests/std/concepts/concepts.compare/out/refcount/concept.equalitycomparable.rs index 36685a983f..4235945156 100644 --- a/tests/std/concepts/concepts.compare/out/refcount/concept.equalitycomparable.rs +++ b/tests/std/concepts/concepts.compare/out/refcount/concept.equalitycomparable.rs @@ -19,7 +19,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -56,7 +55,6 @@ pub fn test_1() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -103,7 +101,6 @@ pub fn test_2() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/std/concepts/concepts.compare/out/refcount/concept.totallyordered.rs b/tests/std/concepts/concepts.compare/out/refcount/concept.totallyordered.rs index ac877077aa..d88b51e186 100644 --- a/tests/std/concepts/concepts.compare/out/refcount/concept.totallyordered.rs +++ b/tests/std/concepts/concepts.compare/out/refcount/concept.totallyordered.rs @@ -25,7 +25,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -68,7 +67,6 @@ pub fn test_3() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, PartiallyOrderedWith, )] #[three_way(ThreeWayComparable::three_way)] @@ -135,7 +133,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/std/concepts/concepts.compare/out/unsafe/concept.equalitycomparable.rs b/tests/std/concepts/concepts.compare/out/unsafe/concept.equalitycomparable.rs index 232ae81cb3..7de7d66210 100644 --- a/tests/std/concepts/concepts.compare/out/unsafe/concept.equalitycomparable.rs +++ b/tests/std/concepts/concepts.compare/out/unsafe/concept.equalitycomparable.rs @@ -17,7 +17,6 @@ pub static mut not_equal_calls_0: std::cell::LazyCell = ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -44,7 +43,6 @@ pub unsafe fn test_1() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -87,7 +85,6 @@ pub unsafe fn test_2() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/std/concepts/concepts.compare/out/unsafe/concept.totallyordered.rs b/tests/std/concepts/concepts.compare/out/unsafe/concept.totallyordered.rs index 4afcb87738..9d66c12fcd 100644 --- a/tests/std/concepts/concepts.compare/out/unsafe/concept.totallyordered.rs +++ b/tests/std/concepts/concepts.compare/out/unsafe/concept.totallyordered.rs @@ -21,7 +21,6 @@ pub static mut greater_equal_calls_2: std::cell::LazyCell = ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -62,7 +61,6 @@ pub unsafe fn test_3() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, PartiallyOrderedWithUnsafe, )] #[three_way(ThreeWayComparableUnsafe::three_way)] @@ -128,7 +126,6 @@ pub static mut greater_calls_5: std::cell::LazyCell = ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/std/concepts/concepts.lang/out/refcount/concept.constructible.rs b/tests/std/concepts/concepts.lang/out/refcount/concept.constructible.rs index 3d6901ad4e..0800a386c9 100644 --- a/tests/std/concepts/concepts.lang/out/refcount/concept.constructible.rs +++ b/tests/std/concepts/concepts.lang/out/refcount/concept.constructible.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -41,7 +40,6 @@ impl p1_constructible_from_Meters { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -98,14 +96,7 @@ pub fn test_0() { ); } #[derive( - Record, - ByteRepr, - ZeroInitialization, - FnPtrArg, - DefaultInitializable, - Memberwise, - MoveAssignable, - Default, + Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Memberwise, MoveAssignable, )] #[memberwise(copy_assign)] #[derive(Conversions)] diff --git a/tests/std/concepts/concepts.lang/out/refcount/concept.convertible.rs b/tests/std/concepts/concepts.lang/out/refcount/concept.convertible.rs index 08b66f6b78..a13b4bdda9 100644 --- a/tests/std/concepts/concepts.lang/out/refcount/concept.convertible.rs +++ b/tests/std/concepts/concepts.lang/out/refcount/concept.convertible.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -41,7 +40,6 @@ impl p1_convertible_to_Meters { FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -66,7 +64,6 @@ impl p1_convertible_to_Celsius { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/std/concepts/concepts.lang/out/unsafe/concept.constructible.rs b/tests/std/concepts/concepts.lang/out/unsafe/concept.constructible.rs index 8d18ed56ae..e702f8f311 100644 --- a/tests/std/concepts/concepts.lang/out/unsafe/concept.constructible.rs +++ b/tests/std/concepts/concepts.lang/out/unsafe/concept.constructible.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -37,7 +36,6 @@ impl p1_constructible_from_Meters { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -89,7 +87,6 @@ pub unsafe fn test_0() { DefaultInitializableUnsafe, MemberwiseUnsafe, MoveAssignableUnsafe, - Default, )] #[memberwise(copy_assign)] #[derive(ConversionsUnsafe)] diff --git a/tests/std/concepts/concepts.lang/out/unsafe/concept.convertible.rs b/tests/std/concepts/concepts.lang/out/unsafe/concept.convertible.rs index 3a19952892..524ebbc817 100644 --- a/tests/std/concepts/concepts.lang/out/unsafe/concept.convertible.rs +++ b/tests/std/concepts/concepts.lang/out/unsafe/concept.convertible.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -37,7 +36,6 @@ impl p1_convertible_to_Meters { ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -59,7 +57,6 @@ impl p1_convertible_to_Celsius { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/std/containers/container.requirements/out/refcount/sequence.reqmts.rs b/tests/std/containers/container.requirements/out/refcount/sequence.reqmts.rs index 21121f5e06..e7459e2b50 100644 --- a/tests/std/containers/container.requirements/out/refcount/sequence.reqmts.rs +++ b/tests/std/containers/container.requirements/out/refcount/sequence.reqmts.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -80,7 +79,6 @@ pub fn test_0() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/std/containers/container.requirements/out/unsafe/sequence.reqmts.rs b/tests/std/containers/container.requirements/out/unsafe/sequence.reqmts.rs index 17cd966374..f6618863e2 100644 --- a/tests/std/containers/container.requirements/out/unsafe/sequence.reqmts.rs +++ b/tests/std/containers/container.requirements/out/unsafe/sequence.reqmts.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -65,7 +64,6 @@ pub unsafe fn test_0() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] 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 7331d89a7f..ff442ebdfb 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 @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -37,7 +36,6 @@ pub struct p6_2_zero_initialized_padding_Padded { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -58,7 +56,6 @@ pub struct p6_2_zero_initialized_padding_TailPadded { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -73,25 +70,28 @@ pub struct p6_2_zero_initialized_padding_HoldsPadded { pub small: i16, } thread_local!( - pub static static_padded_0: Value = Rc::new( - RefCell::new(::default()), - ); + pub static static_padded_0: Value = + Rc::new(RefCell::new({ + ::zero_init() + })); ); thread_local!( - pub static static_tail_padded_1: Value = Rc::new( - RefCell::new(::default()), - ); + pub static static_tail_padded_1: Value = + Rc::new(RefCell::new({ + ::zero_init() + })); ); thread_local!( - pub static static_holds_padded_2: Value = Rc::new( - RefCell::new(::default()), - ); + pub static static_holds_padded_2: Value = + Rc::new(RefCell::new({ + ::zero_init() + })); ); thread_local!( pub static static_padded_array_3: Value> = Rc::new(RefCell::new( (0..2) - .map(|_| ::default()) + .map(|_| ::zero_init()) .collect::>(), )); ); @@ -131,18 +131,19 @@ pub fn test_5() { (16usize as u64), ) }); - let value_padded: Value = Rc::new(RefCell::new( - ::default(), - )); + let value_padded: Value = Rc::new(RefCell::new({ + ::zero_init() + })); ({ check_zero_bytes_4( (value_padded.as_pointer()).reinterpret_cast::(), (8usize as u64), ) }); - let value_holds_padded: Value = Rc::new( - RefCell::new(::default()), - ); + let value_holds_padded: Value = + Rc::new(RefCell::new({ + ::zero_init() + })); ({ check_zero_bytes_4( (value_holds_padded.as_pointer()).reinterpret_cast::(), @@ -150,11 +151,11 @@ pub fn test_5() { ) }); let mut heap_padded: Ptr = - Ptr::alloc(::default()); + Ptr::alloc({ ::zero_init() }); ({ check_zero_bytes_4(heap_padded.reinterpret_cast::(), (8usize as u64)) }); heap_padded.delete(); let mut heap_tail_padded: Ptr = - Ptr::alloc(::default()); + Ptr::alloc({ ::zero_init() }); ({ check_zero_bytes_4(heap_tail_padded.reinterpret_cast::(), (8usize as u64)) }); heap_tail_padded.delete(); } 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 8cf6d61f92..ecafa6f090 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 @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -46,11 +45,6 @@ pub struct p6_1_zero_initialized_pointer_to_member_HoldsSelector { #[byte_size(8)] pub selector: isize, } -impl Default for p6_1_zero_initialized_pointer_to_member_HoldsSelector { - fn default() -> Self { - { p6_1_zero_initialized_pointer_to_member_HoldsSelector { selector: -1_isize } } - } -} thread_local!( pub static static_pm_0: Value = Rc::new(RefCell::new(-1_isize)); ); @@ -69,7 +63,7 @@ pub fn test_1() { as isize)) ); let mut holder: p6_1_zero_initialized_pointer_to_member_HoldsSelector = - ::default(); + { ::zero_init() }; assert!(((holder.selector) == -1_isize)); assert!( (holder.selector @@ -145,7 +139,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -187,23 +180,10 @@ pub struct p6_2_zero_initialized_class_Outer { #[array_len(2)] pub inners: Box<[p6_2_zero_initialized_class_Inner]>, } -impl Default for p6_2_zero_initialized_class_Outer { - fn default() -> Self { - { - p6_2_zero_initialized_class_Outer { - letter: 0_i8, - inner: ::default(), - numbers: (0..3).map(|_| 0_i32).collect::>(), - inners: (0..2) - .map(|_| ::default()) - .collect::>(), - } - } - } -} thread_local!( - pub static static_outer_13: Value = - Rc::new(RefCell::new(::default())); + pub static static_outer_13: Value = Rc::new(RefCell::new({ + ::zero_init() + })); ); pub fn check_14(outer: Ptr) { assert!(((outer.with(|__s| __s.letter) as i32) == (('\0' as i8) as i32))); @@ -233,11 +213,12 @@ pub fn check_14(outer: Ptr) { } pub fn test_15() { ({ check_14(static_outer_13.with(|v| v.as_pointer())) }); - let value_outer: Value = - Rc::new(RefCell::new(::default())); + let value_outer: Value = Rc::new(RefCell::new({ + ::zero_init() + })); ({ check_14(value_outer.as_pointer()) }); let mut heap_outer: Ptr = - Ptr::alloc(::default()); + Ptr::alloc({ ::zero_init() }); ({ check_14((heap_outer).clone()) }); heap_outer.delete(); } @@ -265,16 +246,11 @@ impl p6_3_zero_initialized_union_Number { this.reinterpret_cast() } } -impl Default for p6_3_zero_initialized_union_Number { - fn default() -> Self { - p6_3_zero_initialized_union_Number { - __bytes: Box::from([0u8; 8]), - } - } -} thread_local!( pub static static_number_16: Value = - Rc::new(RefCell::new(::default())); + Rc::new(RefCell::new({ + ::zero_init() + })); ); pub fn test_17() { assert!( @@ -282,8 +258,9 @@ pub fn test_17() { .read()) == 0) ); - let value_number: Value = - Rc::new(RefCell::new(::default())); + let value_number: Value = Rc::new(RefCell::new({ + ::zero_init() + })); assert!(((p6_3_zero_initialized_union_Number::integer(value_number.as_pointer()).read()) == 0)); } #[derive( @@ -296,7 +273,6 @@ pub fn test_17() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -322,7 +298,7 @@ thread_local!( pub static static_pairs_20: Value> = Rc::new(RefCell::new( (0..2) - .map(|_| ::default()) + .map(|_| ::zero_init()) .collect::>(), )); ); @@ -429,16 +405,6 @@ impl p9_1_2_zero_then_default_initialized_WithDefaultMember { field!(this, five).write(5); } } -impl Default for p9_1_2_zero_then_default_initialized_WithDefaultMember { - fn default() -> Self { - { - p9_1_2_zero_then_default_initialized_WithDefaultMember { - zeroed: 0_i32, - five: 5, - } - } - } -} #[derive( Copy, Clone, @@ -462,20 +428,6 @@ impl p9_1_2_zero_then_default_initialized_LeavesMemberAlone { field!(this, untouched).write(0_i32); } } -impl Default for p9_1_2_zero_then_default_initialized_LeavesMemberAlone { - fn default() -> Self { - { - { - let __v: Value = - Rc::new(RefCell::new(ZeroInitialization::zero_init())); - p9_1_2_zero_then_default_initialized_LeavesMemberAlone::constructor_1( - __v.as_pointer(), - ); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} #[derive( Copy, Clone, @@ -485,7 +437,6 @@ impl Default for p9_1_2_zero_then_default_initialized_LeavesMemberAlone { VaArg, FnPtrArg, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/std/dcl.dcl/dcl.decl/dcl.init/out/refcount/dcl.init.ref.rs b/tests/std/dcl.dcl/dcl.decl/dcl.init/out/refcount/dcl.init.ref.rs index ab9b8c59fa..2b258e2d4e 100644 --- a/tests/std/dcl.dcl/dcl.decl/dcl.init/out/refcount/dcl.init.ref.rs +++ b/tests/std/dcl.dcl/dcl.decl/dcl.init/out/refcount/dcl.init.ref.rs @@ -24,7 +24,6 @@ pub fn test_0() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] 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 f19f44d2d9..01248ef864 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 @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -32,7 +31,6 @@ pub struct p6_2_zero_initialized_padding_Padded { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -49,7 +47,6 @@ pub struct p6_2_zero_initialized_padding_TailPadded { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -59,15 +56,23 @@ pub struct p6_2_zero_initialized_padding_HoldsPadded { pub small: i16, } pub static mut static_padded_0: std::cell::LazyCell = - std::cell::LazyCell::new(|| unsafe { ::default() }); + std::cell::LazyCell::new(|| unsafe { + unsafe { ::zero_init() } + }); pub static mut static_tail_padded_1: std::cell::LazyCell = - std::cell::LazyCell::new(|| unsafe { ::default() }); + std::cell::LazyCell::new(|| unsafe { + unsafe { ::zero_init() } + }); pub static mut static_holds_padded_2: std::cell::LazyCell< p6_2_zero_initialized_padding_HoldsPadded, -> = std::cell::LazyCell::new(|| unsafe { ::default() }); +> = std::cell::LazyCell::new(|| unsafe { + unsafe { ::zero_init() } +}); pub static mut static_padded_array_3: std::cell::LazyCell< [p6_2_zero_initialized_padding_Padded; 2], -> = std::cell::LazyCell::new(|| unsafe { [::default(); 2] }); +> = std::cell::LazyCell::new(|| unsafe { + [unsafe { ::zero_init() }; 2] +}); pub unsafe fn check_zero_bytes_4(mut bytes: *const u8, mut size: u64) { { let mut i: u64 = 0_u64; @@ -110,7 +115,7 @@ pub unsafe fn test_5() { check_zero_bytes_4(_bytes, _size) }); let mut value_padded: p6_2_zero_initialized_padding_Padded = - ::default(); + unsafe { ::zero_init() }; (unsafe { check_zero_bytes_4( ((&mut value_padded as *mut p6_2_zero_initialized_padding_Padded) as *const u8), @@ -118,7 +123,7 @@ pub unsafe fn test_5() { ) }); let mut value_holds_padded: p6_2_zero_initialized_padding_HoldsPadded = - ::default(); + unsafe { ::zero_init() }; (unsafe { check_zero_bytes_4( ((&mut value_holds_padded as *mut p6_2_zero_initialized_padding_HoldsPadded) @@ -126,9 +131,10 @@ pub unsafe fn test_5() { (::std::mem::size_of::() as u64), ) }); - let mut heap_padded: *mut p6_2_zero_initialized_padding_Padded = - (Box::leak(Box::new(::default())) - as *mut p6_2_zero_initialized_padding_Padded); + let mut heap_padded: *mut p6_2_zero_initialized_padding_Padded = (Box::leak(Box::new(unsafe { + ::zero_init() + })) + as *mut p6_2_zero_initialized_padding_Padded); (unsafe { check_zero_bytes_4( (heap_padded as *const u8), @@ -141,10 +147,10 @@ pub unsafe fn test_5() { ::std::mem::drop(Box::from_raw(__p)) } }; - let mut heap_tail_padded: *mut p6_2_zero_initialized_padding_TailPadded = (Box::leak(Box::new( - ::default(), - )) - as *mut p6_2_zero_initialized_padding_TailPadded); + let mut heap_tail_padded: *mut p6_2_zero_initialized_padding_TailPadded = + (Box::leak(Box::new(unsafe { + ::zero_init() + })) as *mut p6_2_zero_initialized_padding_TailPadded); (unsafe { check_zero_bytes_4( (heap_tail_padded as *const u8), 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 406fec871f..188693525c 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 @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -38,11 +37,6 @@ pub struct p6_1_zero_initialized_pointer_to_member_HasTwoInts { pub struct p6_1_zero_initialized_pointer_to_member_HoldsSelector { pub selector: isize, } -impl Default for p6_1_zero_initialized_pointer_to_member_HoldsSelector { - fn default() -> Self { - unsafe { p6_1_zero_initialized_pointer_to_member_HoldsSelector { selector: -1_isize } } - } -} pub static mut static_pm_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { -1_isize }); pub unsafe fn test_1() { @@ -60,7 +54,7 @@ pub unsafe fn test_1() { as isize)) ); let mut holder: p6_1_zero_initialized_pointer_to_member_HoldsSelector = - ::default(); + unsafe { ::zero_init() }; assert!(((holder.selector) == -1_isize)); assert!( ((holder.selector) @@ -136,7 +130,6 @@ static mut counter_11: std::cell::LazyCell = std::cell::LazyCell::new(|| un ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -154,7 +147,6 @@ pub struct p6_2_zero_initialized_class_Inner { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -165,7 +157,9 @@ pub struct p6_2_zero_initialized_class_Outer { pub inners: [p6_2_zero_initialized_class_Inner; 2], } pub static mut static_outer_13: std::cell::LazyCell = - std::cell::LazyCell::new(|| unsafe { ::default() }); + std::cell::LazyCell::new(|| unsafe { + unsafe { ::zero_init() } + }); pub unsafe fn check_14(outer: *const p6_2_zero_initialized_class_Outer) { assert!((((*outer).letter as i32) == (('\0' as libc::c_char) as i32))); assert!((((*outer).inner.number) == (0))); @@ -195,11 +189,12 @@ pub unsafe fn check_14(outer: *const p6_2_zero_initialized_class_Outer) { pub unsafe fn test_15() { (unsafe { check_14(&(*std::cell::LazyCell::force_mut(&mut *&raw mut static_outer_13))) }); let mut value_outer: p6_2_zero_initialized_class_Outer = - ::default(); + unsafe { ::zero_init() }; (unsafe { check_14(&value_outer) }); - let mut heap_outer: *mut p6_2_zero_initialized_class_Outer = - (Box::leak(Box::new(::default())) - as *mut p6_2_zero_initialized_class_Outer); + let mut heap_outer: *mut p6_2_zero_initialized_class_Outer = (Box::leak(Box::new(unsafe { + ::zero_init() + })) + as *mut p6_2_zero_initialized_class_Outer); (unsafe { check_14(&(*heap_outer)) }); { let __p = heap_outer; @@ -222,17 +217,14 @@ pub union p6_3_zero_initialized_union_Number { pub integer: i32, pub bytes: [libc::c_char; 8], } -impl Default for p6_3_zero_initialized_union_Number { - fn default() -> Self { - unsafe { std::mem::zeroed() } - } -} pub static mut static_number_16: std::cell::LazyCell = - std::cell::LazyCell::new(|| unsafe { ::default() }); + std::cell::LazyCell::new(|| unsafe { + unsafe { ::zero_init() } + }); pub unsafe fn test_17() { assert!((((*std::cell::LazyCell::force_mut(&mut *&raw mut static_number_16)).integer) == (0))); let mut value_number: p6_3_zero_initialized_union_Number = - ::default(); + unsafe { ::zero_init() }; assert!(((value_number.integer) == (0))); } #[repr(C)] @@ -244,7 +236,6 @@ pub unsafe fn test_17() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -257,7 +248,9 @@ pub static mut static_numbers_18: std::cell::LazyCell<[i32; 4]> = pub static mut static_matrix_19: std::cell::LazyCell<[[i32; 3]; 2]> = std::cell::LazyCell::new(|| unsafe { [[0_i32; 3]; 2] }); pub static mut static_pairs_20: std::cell::LazyCell<[p6_4_zero_initialized_array_Pair; 2]> = - std::cell::LazyCell::new(|| unsafe { [::default(); 2] }); + std::cell::LazyCell::new(|| unsafe { + [unsafe { ::zero_init() }; 2] + }); pub unsafe fn test_21() { { let mut i: i32 = 0; @@ -358,16 +351,6 @@ impl p9_1_2_zero_then_default_initialized_WithDefaultMember { (&raw mut (*this).five).write(5); } } -impl Default for p9_1_2_zero_then_default_initialized_WithDefaultMember { - fn default() -> Self { - unsafe { - p9_1_2_zero_then_default_initialized_WithDefaultMember { - zeroed: 0_i32, - five: 5, - } - } - } -} #[repr(C)] #[derive( Copy, @@ -388,18 +371,6 @@ impl p9_1_2_zero_then_default_initialized_LeavesMemberAlone { (&raw mut (*this).untouched).write(0_i32); } } -impl Default for p9_1_2_zero_then_default_initialized_LeavesMemberAlone { - fn default() -> Self { - unsafe { - { - let mut __v: p9_1_2_zero_then_default_initialized_LeavesMemberAlone = - ZeroInitializationUnsafe::zero_init(); - p9_1_2_zero_then_default_initialized_LeavesMemberAlone::constructor_1(&raw mut __v); - __v - } - } - } -} #[repr(C)] #[derive( Copy, @@ -408,7 +379,6 @@ impl Default for p9_1_2_zero_then_default_initialized_LeavesMemberAlone { FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/std/dcl.dcl/dcl.decl/dcl.init/out/unsafe/dcl.init.ref.rs b/tests/std/dcl.dcl/dcl.decl/dcl.init/out/unsafe/dcl.init.ref.rs index fbdd2cce8f..d18a56bb40 100644 --- a/tests/std/dcl.dcl/dcl.decl/dcl.init/out/unsafe/dcl.init.ref.rs +++ b/tests/std/dcl.dcl/dcl.decl/dcl.init/out/unsafe/dcl.init.ref.rs @@ -23,7 +23,6 @@ pub unsafe fn test_0() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] 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 54ff35794d..189011b9a5 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 @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] 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 bb0cbf37f5..e2bbf1496c 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 @@ -83,11 +83,6 @@ impl p9_static_member_hides_namespace_variable_HasStaticStep { field!(this, total).write(1); } } -impl Default for p9_static_member_hides_namespace_variable_HasStaticStep { - fn default() -> Self { - { p9_static_member_hides_namespace_variable_HasStaticStep { total: 1 } } - } -} pub fn test_11() { object!( object, @@ -159,21 +154,6 @@ impl Constructor<()> for p9_evaluated_each_time_called_Widget { } } } -impl Default for p9_evaluated_each_time_called_Widget { - fn default() -> Self { - { - { - let __v: Value = - Rc::new(RefCell::new(ZeroInitialization::zero_init())); - p9_evaluated_each_time_called_Widget::constructor_1( - __v.as_pointer(), - ({ count_default_13() }), - ); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} thread_local!( static base_15: Value = Rc::new(RefCell::new(10)); ); @@ -214,11 +194,6 @@ impl p9_evaluated_each_time_called_Account { field!(this, balance).write(0); } } -impl Default for p9_evaluated_each_time_called_Account { - fn default() -> Self { - { p9_evaluated_each_time_called_Account { balance: 0 } } - } -} pub fn test_17() { defaults_evaluated_12.with(|rc| *rc.borrow_mut() = 0); assert!((({ combine_14(1, ({ count_default_13() }),) }) == 101)); @@ -282,7 +257,6 @@ pub fn add_18(mut a: i32, mut b: i32) -> i32 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] 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 cdfc059fb1..701d1a7bc6 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 @@ -27,16 +27,6 @@ pub struct p2_pointer_to_array_member_HasIntArray { #[array_len(3)] pub elements: Box<[i32]>, } -impl Default for p2_pointer_to_array_member_HasIntArray { - fn default() -> Self { - { - p2_pointer_to_array_member_HasIntArray { - before: 0_i32, - elements: (0..3).map(|_| 0_i32).collect::>(), - } - } - } -} pub fn test_0() { let mut pm: isize = (offset_of_field!(p2_pointer_to_array_member_HasIntArray, elements) as isize); @@ -61,7 +51,6 @@ pub fn test_0() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -102,7 +91,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -144,7 +132,6 @@ pub fn test_3() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -174,11 +161,6 @@ pub struct p2_pointer_to_member_of_pointer_to_member_type_HoldsSelector { #[byte_size(8)] pub selector: isize, } -impl Default for p2_pointer_to_member_of_pointer_to_member_type_HoldsSelector { - fn default() -> Self { - { p2_pointer_to_member_of_pointer_to_member_type_HoldsSelector { selector: -1_isize } } - } -} pub fn test_4() { let mut pm: isize = (offset_of_field!( p2_pointer_to_member_of_pointer_to_member_type_HoldsSelector, 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 7fae15cd15..2683b9b44b 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 @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] 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 dd4664c7a7..d87afd0e65 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 @@ -77,11 +77,6 @@ impl p9_static_member_hides_namespace_variable_HasStaticStep { (&raw mut (*this).total).write(1); } } -impl Default for p9_static_member_hides_namespace_variable_HasStaticStep { - fn default() -> Self { - unsafe { p9_static_member_hides_namespace_variable_HasStaticStep { total: 1 } } - } -} pub unsafe fn test_11() { object_unsafe!( object, @@ -149,21 +144,6 @@ impl ConstructorUnsafe<()> for p9_evaluated_each_time_called_Widget { } } } -impl Default for p9_evaluated_each_time_called_Widget { - fn default() -> Self { - unsafe { - { - let mut __v: p9_evaluated_each_time_called_Widget = - ZeroInitializationUnsafe::zero_init(); - p9_evaluated_each_time_called_Widget::constructor_1( - &raw mut __v, - (unsafe { count_default_13() }), - ); - __v - } - } - } -} static mut base_15: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 10 }); pub type anon_16 = u32; pub const anon_16_kBonus: anon_16 = 5; @@ -197,11 +177,6 @@ impl p9_evaluated_each_time_called_Account { (&raw mut (*this).balance).write(0); } } -impl Default for p9_evaluated_each_time_called_Account { - fn default() -> Self { - unsafe { p9_evaluated_each_time_called_Account { balance: 0 } } - } -} pub unsafe fn test_17() { (*std::cell::LazyCell::force_mut(&mut *&raw mut defaults_evaluated_12)) = 0; assert!(((unsafe { combine_14(1, (unsafe { count_default_13() }),) }) == (101))); @@ -272,7 +247,6 @@ pub unsafe fn add_18(mut a: i32, mut b: i32) -> i32 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] 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 2affbf260f..bbe384b3ac 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 @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -57,7 +56,6 @@ pub unsafe fn test_0() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -106,7 +104,6 @@ pub static mut pm_2: std::cell::LazyCell = std::cell::LazyCell::new(|| un ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -141,7 +138,6 @@ pub unsafe fn test_3() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -164,13 +160,6 @@ pub struct p2_pointer_to_member_of_pointer_to_member_type_HasTwoInts { pub struct p2_pointer_to_member_of_pointer_to_member_type_HoldsSelector { pub selector: isize, } -impl Default for p2_pointer_to_member_of_pointer_to_member_type_HoldsSelector { - fn default() -> Self { - unsafe { - p2_pointer_to_member_of_pointer_to_member_type_HoldsSelector { selector: -1_isize } - } - } -} pub unsafe fn test_4() { let mut pm: isize = (::std::mem::offset_of!( p2_pointer_to_member_of_pointer_to_member_type_HoldsSelector, diff --git a/tests/std/expr/conv/out/refcount/conv.mem.rs b/tests/std/expr/conv/out/refcount/conv.mem.rs index 96610506cd..0181a66075 100644 --- a/tests/std/expr/conv/out/refcount/conv.mem.rs +++ b/tests/std/expr/conv/out/refcount/conv.mem.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/std/expr/conv/out/unsafe/conv.mem.rs b/tests/std/expr/conv/out/unsafe/conv.mem.rs index 0bbbc0409d..0fc7ff3087 100644 --- a/tests/std/expr/conv/out/unsafe/conv.mem.rs +++ b/tests/std/expr/conv/out/unsafe/conv.mem.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] 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 901ad5a232..b36c56ffc0 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 @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] 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 867b80578c..05326b559f 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 @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -37,7 +36,6 @@ pub struct HasTwoInts { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] 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 6cc22e6992..5fe13248e2 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 @@ -26,7 +26,6 @@ pub fn test_0() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -47,7 +46,6 @@ pub struct p10_null_converts_to_null_HasTwoInts { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -71,7 +69,6 @@ pub fn test_1() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -92,7 +89,6 @@ pub struct p10_2_data_member_round_trip_HasTwoInts { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] 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 3da9d84c0f..06d8928d2e 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 @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] 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 bd21165242..cc76608d43 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 @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -32,7 +31,6 @@ pub struct HasTwoInts { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] 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 d682c1bf4f..92d44ac68e 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 @@ -25,7 +25,6 @@ pub unsafe fn test_0() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -42,7 +41,6 @@ pub struct p10_null_converts_to_null_HasTwoInts { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -63,7 +61,6 @@ pub unsafe fn test_1() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -80,7 +77,6 @@ pub struct p10_2_data_member_round_trip_HasTwoInts { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] 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 70f4d9a972..2b11e64b3b 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 @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] 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 ed8f449014..666f30bff7 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 @@ -22,7 +22,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -53,7 +52,6 @@ pub fn test_2() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -100,7 +98,6 @@ pub fn test_3() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] 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 1f0d5fc05e..3d5cd58576 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 @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] 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 020ce0f383..5f03040f76 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 @@ -17,7 +17,6 @@ pub static mut calls_1: std::cell::LazyCell = std::cell::LazyCell::new(|| u ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -47,7 +46,6 @@ pub unsafe fn test_2() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -84,7 +82,6 @@ pub unsafe fn test_3() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] 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 1b589f0934..ad54829b5b 100644 --- a/tests/std/expr/expr.compound/out/refcount/expr.cond.rs +++ b/tests/std/expr/expr.compound/out/refcount/expr.cond.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] 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 3116ba3f69..fd2782f3cc 100644 --- a/tests/std/expr/expr.compound/out/refcount/expr.eq.rs +++ b/tests/std/expr/expr.compound/out/refcount/expr.eq.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -43,7 +42,6 @@ pub fn test_0() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -86,13 +84,6 @@ impl p4_5_members_of_same_union_HasTwoIntMembers { this.reinterpret_cast() } } -impl Default for p4_5_members_of_same_union_HasTwoIntMembers { - fn default() -> Self { - p4_5_members_of_same_union_HasTwoIntMembers { - __bytes: Box::from([0u8; 4]), - } - } -} pub fn test_2() { let mut first_pm: isize = 0_isize; let mut second_pm: isize = 0_isize; @@ -109,7 +100,6 @@ pub fn test_2() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] 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 0a5c201024..f8a86cc01e 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 @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] 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 2856256e52..85b550508d 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 @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -50,7 +49,6 @@ pub fn test_0() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -105,7 +103,6 @@ pub fn test_7() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -144,7 +141,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, Destructible, - Default, Conversions, )] #[conversions(copy, move)] @@ -176,7 +172,6 @@ impl p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves { TriviallyDefaultConstructible, Destructible, Memberwise, - Default, )] #[memberwise(copy_constructor, move_constructor)] #[derive(Conversions)] @@ -191,9 +186,9 @@ impl p6_data_member_of_rvalue_is_xvalue_HoldsCounted {} pub fn test_11() { let mut pm: isize = (offset_of_field!(p6_data_member_of_rvalue_is_xvalue_HoldsCounted, member) as isize); - let holder: Value = Rc::new(RefCell::new( - ::default(), - )); + let holder: Value = Rc::new(RefCell::new({ + ::zero_init() + })); object!( from_lvalue, p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves::constructor_2(LvalueRef::bind( 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 eb160580db..cbe1c05bae 100644 --- a/tests/std/expr/expr.compound/out/unsafe/expr.cond.rs +++ b/tests/std/expr/expr.compound/out/unsafe/expr.cond.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] 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 4d1a9f2eab..c781058f90 100644 --- a/tests/std/expr/expr.compound/out/unsafe/expr.eq.rs +++ b/tests/std/expr/expr.compound/out/unsafe/expr.eq.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -38,7 +37,6 @@ pub unsafe fn test_0() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -68,11 +66,6 @@ pub union p4_5_members_of_same_union_HasTwoIntMembers { pub first: i32, pub second: i32, } -impl Default for p4_5_members_of_same_union_HasTwoIntMembers { - fn default() -> Self { - unsafe { std::mem::zeroed() } - } -} pub unsafe fn test_2() { let mut first_pm: isize = 0_isize; let mut second_pm: isize = 0_isize; @@ -88,7 +81,6 @@ pub unsafe fn test_2() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] 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 0d1cf85134..839af6c946 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 @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] 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 a39ed60c79..85bd16b594 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 @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -50,7 +49,6 @@ pub unsafe fn test_0() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -95,7 +93,6 @@ pub unsafe fn test_7() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -132,7 +129,6 @@ pub static mut moveCount_10: std::cell::LazyCell = std::cell::LazyCell::new ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, DestructibleUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -162,7 +158,6 @@ impl p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves { TriviallyDefaultConstructibleUnsafe, DestructibleUnsafe, MemberwiseUnsafe, - Default, )] #[memberwise(copy_constructor, move_constructor)] #[derive(ConversionsUnsafe)] @@ -175,7 +170,7 @@ pub unsafe fn test_11() { let mut pm: isize = (::std::mem::offset_of!(p6_data_member_of_rvalue_is_xvalue_HoldsCounted, member) as isize); let mut holder: p6_data_member_of_rvalue_is_xvalue_HoldsCounted = - ::default(); + unsafe { ::zero_init() }; object_unsafe!( from_lvalue, p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves::constructor_2( 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 aa155229ac..d386f9b67f 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 @@ -35,11 +35,6 @@ impl p1_default_member_initializer_names_object_Holder { assert!(({ this.with(|__s| __s.self_.clone()).with(|__s| __s.value) } == { value })); } } -impl Default for p1_default_member_initializer_names_object_Holder { - fn default() -> Self { - { ::zero_init() } - } -} pub fn test_0() { object!( holder, @@ -56,7 +51,6 @@ pub fn test_0() { FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -96,7 +90,6 @@ pub fn test_1() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] 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 23e5e94649..ea1e769108 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 @@ -31,11 +31,6 @@ impl p1_default_member_initializer_names_object_Holder { assert!((((*(*this).self_).value) == (value))); } } -impl Default for p1_default_member_initializer_names_object_Holder { - fn default() -> Self { - unsafe { ::zero_init() } - } -} pub unsafe fn test_0() { object_unsafe!( holder, @@ -52,7 +47,6 @@ pub unsafe fn test_0() { ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -86,7 +80,6 @@ pub unsafe fn test_1() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] 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 76311ce8ab..6f39b637d2 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 @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -45,11 +44,6 @@ impl p16_rebind_member_Alloc_std_pair_const_int__int__ { field!(this, id).write(0); } } -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 } } - } -} pub fn test_0() { let m: Value, Value)>> = Rc::new(RefCell::new(Map::new())); let n: Value, Value)>> = Rc::new(RefCell::new(Map::new())); @@ -83,7 +77,6 @@ pub fn test_0() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] 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 82820a63f9..fc735866f0 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 @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -40,11 +39,6 @@ impl p16_rebind_member_Alloc_std_pair_const_int__int__ { (&raw mut (*this).id).write(0); } } -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 } } - } -} pub unsafe fn test_0() { let mut m: UnsafeMap = UnsafeMap::new(); let mut n: UnsafeMap = UnsafeMap::new(); @@ -78,7 +72,6 @@ pub unsafe fn test_0() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/std/library/requirements/utility.requirements/out/refcount/utility.arg.requirements.rs b/tests/std/library/requirements/utility.requirements/out/refcount/utility.arg.requirements.rs index b59ba33b07..a8152aabb4 100644 --- a/tests/std/library/requirements/utility.requirements/out/refcount/utility.arg.requirements.rs +++ b/tests/std/library/requirements/utility.requirements/out/refcount/utility.arg.requirements.rs @@ -19,7 +19,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -180,7 +179,6 @@ pub fn test_1() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -209,7 +207,6 @@ impl LessThanComparable for table29_other_operator_shapes_Weight { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -236,7 +233,6 @@ impl LessThanComparable for table29_other_operator_shapes_Height { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, PartiallyOrderedWith, )] #[three_way(table29_other_operator_shapes_Depth::operator_cmp)] @@ -341,7 +337,6 @@ pub fn test_2() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/std/library/requirements/utility.requirements/out/unsafe/utility.arg.requirements.rs b/tests/std/library/requirements/utility.requirements/out/unsafe/utility.arg.requirements.rs index e20798e882..bf33731e76 100644 --- a/tests/std/library/requirements/utility.requirements/out/unsafe/utility.arg.requirements.rs +++ b/tests/std/library/requirements/utility.requirements/out/unsafe/utility.arg.requirements.rs @@ -16,7 +16,6 @@ pub static mut less_calls_0: std::cell::LazyCell = std::cell::LazyCell::new ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -138,7 +137,6 @@ pub unsafe fn test_1() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -167,7 +165,6 @@ impl LessThanComparableUnsafe for table29_other_operator_shapes_Weight { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -191,7 +188,6 @@ impl LessThanComparableUnsafe for table29_other_operator_shapes_Height { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, PartiallyOrderedWithUnsafe, )] #[three_way(table29_other_operator_shapes_Depth::operator_cmp)] @@ -283,7 +279,6 @@ pub unsafe fn test_2() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/std/support/cmp/out/refcount/cmp.concept.rs b/tests/std/support/cmp/out/refcount/cmp.concept.rs index c974b14ce7..2684f92516 100644 --- a/tests/std/support/cmp/out/refcount/cmp.concept.rs +++ b/tests/std/support/cmp/out/refcount/cmp.concept.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, PartiallyOrderedWith, )] #[three_way(ThreeWayComparable::three_way)] @@ -112,7 +111,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, PartiallyOrderedWith, )] #[three_way(ThreeWayComparable::three_way)] @@ -176,7 +174,6 @@ pub fn test_2() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, PartiallyOrderedWith, )] #[three_way(ThreeWayComparable::three_way)] @@ -239,7 +236,6 @@ pub fn test_3() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, PartiallyOrderedWith, )] #[three_way(p1_three_way_without_equality_Rank::operator_cmp)] diff --git a/tests/std/support/cmp/out/unsafe/cmp.concept.rs b/tests/std/support/cmp/out/unsafe/cmp.concept.rs index 126c5aa0a9..63022eecaf 100644 --- a/tests/std/support/cmp/out/unsafe/cmp.concept.rs +++ b/tests/std/support/cmp/out/unsafe/cmp.concept.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, PartiallyOrderedWithUnsafe, )] #[three_way(ThreeWayComparableUnsafe::three_way)] @@ -101,7 +100,6 @@ pub static mut three_way_calls_1: std::cell::LazyCell = ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, PartiallyOrderedWithUnsafe, )] #[three_way(ThreeWayComparableUnsafe::three_way)] @@ -168,7 +166,6 @@ pub unsafe fn test_2() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, PartiallyOrderedWithUnsafe, )] #[three_way(ThreeWayComparableUnsafe::three_way)] @@ -223,7 +220,6 @@ pub unsafe fn test_3() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, PartiallyOrderedWithUnsafe, )] #[three_way(p1_three_way_without_equality_Rank::operator_cmp)] diff --git a/tests/std/temp/out/refcount/temp.type.rs b/tests/std/temp/out/refcount/temp.type.rs index 4664d4c625..bb9314d582 100644 --- a/tests/std/temp/out/refcount/temp.type.rs +++ b/tests/std/temp/out/refcount/temp.type.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -40,7 +39,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -60,7 +58,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -80,7 +77,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/std/temp/out/unsafe/temp.type.rs b/tests/std/temp/out/unsafe/temp.type.rs index 38d9fb7e60..f0f1e7164c 100644 --- a/tests/std/temp/out/unsafe/temp.type.rs +++ b/tests/std/temp/out/unsafe/temp.type.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -33,7 +32,6 @@ pub static mut count_0: std::cell::LazyCell = std::cell::LazyCell::new(|| u ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -49,7 +47,6 @@ pub static mut count_1: std::cell::LazyCell = std::cell::LazyCell::new(|| u ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -65,7 +62,6 @@ pub static mut count_2: std::cell::LazyCell = std::cell::LazyCell::new(|| u ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] 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 a5ab8c271b..77d674bf68 100644 --- a/tests/std/temp/temp.spec/out/refcount/temp.inst.rs +++ b/tests/std/temp/temp.spec/out/refcount/temp.inst.rs @@ -37,12 +37,7 @@ impl p2_reference_does_not_instantiate_Member { field!(this, value).write(2); } } -impl Default for p2_reference_does_not_instantiate_Member { - fn default() -> Self { - { p2_reference_does_not_instantiate_Member { value: 1 } } - } -} -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise)] #[memberwise(move_constructor)] #[derive(Conversions)] #[conversions(move)] 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 2c251655b9..7c214cbe3f 100644 --- a/tests/std/temp/temp.spec/out/unsafe/temp.inst.rs +++ b/tests/std/temp/temp.spec/out/unsafe/temp.inst.rs @@ -34,13 +34,8 @@ impl p2_reference_does_not_instantiate_Member { (&raw mut (*this).value).write(2); } } -impl Default for p2_reference_does_not_instantiate_Member { - fn default() -> Self { - unsafe { p2_reference_does_not_instantiate_Member { value: 1 } } - } -} #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, MemberwiseUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, MemberwiseUnsafe)] #[memberwise(move_constructor)] #[derive(ConversionsUnsafe)] #[conversions(move)] diff --git a/tests/std/utilities/utility/out/refcount/forward-helpers.rs b/tests/std/utilities/utility/out/refcount/forward-helpers.rs index 956068cc7e..f2c5bcdff9 100644 --- a/tests/std/utilities/utility/out/refcount/forward-helpers.rs +++ b/tests/std/utilities/utility/out/refcount/forward-helpers.rs @@ -14,9 +14,7 @@ pub fn test_0() { lvalue.write(2); assert!(({ ((*value.borrow()) == 2) })); } -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Default, Conversions, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Conversions)] #[conversions(copy, move)] #[constructor(constructor_1, i32)] #[constructor(constructor_2, LvalueRef>)] @@ -56,20 +54,6 @@ impl p6_forward_like_Holder { p6_forward_like_Movable::constructor_1(field_ptr!(this, member), 1); } } -impl Default for p6_forward_like_Holder { - fn default() -> Self { - { - p6_forward_like_Holder { - member: { - let __v: Value = - Rc::new(RefCell::new(ZeroInitialization::zero_init())); - p6_forward_like_Movable::constructor_1(__v.as_pointer(), 1); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }, - } - } - } -} pub fn take_1(__return: Ptr, self_: Ptr) { p6_forward_like_Movable::constructor_2( __return.clone(), @@ -95,9 +79,7 @@ pub fn test_3() { })); assert!(({ (*moved.borrow()).value } == 1) && ({ (*holder.borrow()).member.value } == 0)); } -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Default, Conversions, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Conversions)] #[conversions(move)] #[constructor(constructor_1, i32)] #[constructor(constructor_2, RvalueRef)] @@ -186,11 +168,6 @@ impl p10_forward_in_template_A { field!(other, value).write(0); } } -impl Default for p10_forward_in_template_A { - fn default() -> Self { - { ::zero_init() } - } -} pub fn make_5(__return: Ptr, source: Ptr) { p10_forward_in_template_A::constructor_2(__return.clone(), LvalueRef::bind((source).clone())); return; @@ -218,9 +195,7 @@ pub fn test_7() { ); assert!(({ (*a.borrow()).value } == 0)); } -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Default, Conversions, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Conversions)] #[conversions(copy, move)] #[constructor(constructor_1, i32)] #[constructor(constructor_2, LvalueRef>)] @@ -247,9 +222,7 @@ impl p11_move_if_noexcept_NoexceptMove { field!(other, value).write(0); } } -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Default, Conversions, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Conversions)] #[conversions(copy, move)] #[constructor(constructor_1, i32)] #[constructor(constructor_2, LvalueRef>)] diff --git a/tests/std/utilities/utility/out/refcount/forward.rs b/tests/std/utilities/utility/out/refcount/forward.rs index b72d0f16fb..1d78a46303 100644 --- a/tests/std/utilities/utility/out/refcount/forward.rs +++ b/tests/std/utilities/utility/out/refcount/forward.rs @@ -22,7 +22,6 @@ pub fn test_0() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -59,9 +58,7 @@ pub fn test_1() { ); assert!(({ (*element.borrow()).x } == 5) && ({ (*element.borrow()).y } == 6)); } -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Default, Conversions, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Conversions)] #[conversions(move)] #[constructor(constructor_1, i32)] #[constructor(constructor_2, RvalueRef)] 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 8a788a26cf..db6ce05fc9 100644 --- a/tests/std/utilities/utility/out/refcount/utility.as.const.rs +++ b/tests/std/utilities/utility/out/refcount/utility.as.const.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/std/utilities/utility/out/unsafe/forward-helpers.rs b/tests/std/utilities/utility/out/unsafe/forward-helpers.rs index 2a8a93039b..7c9a50edfb 100644 --- a/tests/std/utilities/utility/out/unsafe/forward-helpers.rs +++ b/tests/std/utilities/utility/out/unsafe/forward-helpers.rs @@ -15,9 +15,7 @@ pub unsafe fn test_0() { assert!(((value) == (2))); } #[repr(C)] -#[derive( - FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, Default, ConversionsUnsafe, -)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, ConversionsUnsafe)] #[conversions(copy, move)] #[constructor(constructor_1, i32)] #[constructor(constructor_2, LvalueRefUnsafe>)] @@ -56,19 +54,6 @@ impl p6_forward_like_Holder { p6_forward_like_Movable::constructor_1(&raw mut (*this).member, 1); } } -impl Default for p6_forward_like_Holder { - fn default() -> Self { - unsafe { - p6_forward_like_Holder { - member: { - let mut __v: p6_forward_like_Movable = ZeroInitializationUnsafe::zero_init(); - p6_forward_like_Movable::constructor_1(&raw mut __v, 1); - __v - }, - } - } - } -} pub unsafe fn take_1(__return: *mut p6_forward_like_Movable, self_: *mut p6_forward_like_Holder) { p6_forward_like_Movable::constructor_2(__return, LvalueRefUnsafe::bind(&(*self_).member)); return; @@ -89,9 +74,7 @@ pub unsafe fn test_3() { assert!(((moved.value) == (1)) && ((holder.member.value) == (0))); } #[repr(C)] -#[derive( - FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, Default, ConversionsUnsafe, -)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, ConversionsUnsafe)] #[conversions(move)] #[constructor(constructor_1, i32)] #[constructor(constructor_2, RvalueRefUnsafe)] @@ -178,11 +161,6 @@ impl p10_forward_in_template_A { (*other).value = 0; } } -impl Default for p10_forward_in_template_A { - fn default() -> Self { - unsafe { ::zero_init() } - } -} pub unsafe fn make_5( __return: *mut p10_forward_in_template_A, source: *mut p10_forward_in_template_A, @@ -211,9 +189,7 @@ pub unsafe fn test_7() { assert!(((a.value) == (0))); } #[repr(C)] -#[derive( - FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, Default, ConversionsUnsafe, -)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, ConversionsUnsafe)] #[conversions(copy, move)] #[constructor(constructor_1, i32)] #[constructor(constructor_2, LvalueRefUnsafe>)] @@ -242,9 +218,7 @@ impl p11_move_if_noexcept_NoexceptMove { } } #[repr(C)] -#[derive( - FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, Default, ConversionsUnsafe, -)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, ConversionsUnsafe)] #[conversions(copy, move)] #[constructor(constructor_1, i32)] #[constructor(constructor_2, LvalueRefUnsafe>)] diff --git a/tests/std/utilities/utility/out/unsafe/forward.rs b/tests/std/utilities/utility/out/unsafe/forward.rs index caa94a1e5e..2828cebf6f 100644 --- a/tests/std/utilities/utility/out/unsafe/forward.rs +++ b/tests/std/utilities/utility/out/unsafe/forward.rs @@ -21,7 +21,6 @@ pub unsafe fn test_0() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -50,9 +49,7 @@ pub unsafe fn test_1() { assert!(((element.x) == (5)) && ((element.y) == (6))); } #[repr(C)] -#[derive( - FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, Default, ConversionsUnsafe, -)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, ConversionsUnsafe)] #[conversions(move)] #[constructor(constructor_1, i32)] #[constructor(constructor_2, RvalueRefUnsafe)] 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 d70473ad09..b838244f86 100644 --- a/tests/std/utilities/utility/out/unsafe/utility.as.const.rs +++ b/tests/std/utilities/utility/out/unsafe/utility.as.const.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/ub/out/refcount/ctor_ref_member.rs b/tests/ub/out/refcount/ctor_ref_member.rs index 576aa62fed..a6aa3f1b1a 100644 --- a/tests/ub/out/refcount/ctor_ref_member.rs +++ b/tests/ub/out/refcount/ctor_ref_member.rs @@ -15,7 +15,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/ub/out/refcount/self_referencing_initializer.rs b/tests/ub/out/refcount/self_referencing_initializer.rs index c41ddd2eae..5e1f5e1194 100644 --- a/tests/ub/out/refcount/self_referencing_initializer.rs +++ b/tests/ub/out/refcount/self_referencing_initializer.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -34,7 +33,7 @@ pub fn main() { fn main_0() -> i32 { let mut x: i32 = 0_i32; x = (x + 1); - let mut p: pair = ::default(); + let mut p: pair = { ::zero_init() }; p = pair { a: 1, b: (p.a + 1) }; return (x + p.b); } diff --git a/tests/ub/out/refcount/ub6.rs b/tests/ub/out/refcount/ub6.rs index 502c6d37e5..d62fcfc833 100644 --- a/tests/ub/out/refcount/ub6.rs +++ b/tests/ub/out/refcount/ub6.rs @@ -15,7 +15,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/ub/out/unsafe/ctor_ref_member.rs b/tests/ub/out/unsafe/ctor_ref_member.rs index f63545f21a..ff5159542e 100644 --- a/tests/ub/out/unsafe/ctor_ref_member.rs +++ b/tests/ub/out/unsafe/ctor_ref_member.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/ub/out/unsafe/self_referencing_initializer.rs b/tests/ub/out/unsafe/self_referencing_initializer.rs index 54d99126f4..4c621eed7a 100644 --- a/tests/ub/out/unsafe/self_referencing_initializer.rs +++ b/tests/ub/out/unsafe/self_referencing_initializer.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -32,7 +31,7 @@ pub fn main() { unsafe fn main_0() -> i32 { let mut x: i32 = 0_i32; x = ((x) + (1)); - let mut p: pair = ::default(); + let mut p: pair = unsafe { ::zero_init() }; p = pair { a: 1, b: ((p.a) + (1)), diff --git a/tests/ub/out/unsafe/ub6.rs b/tests/ub/out/unsafe/ub6.rs index 8578975d3d..397e9cc9a0 100644 --- a/tests/ub/out/unsafe/ub6.rs +++ b/tests/ub/out/unsafe/ub6.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/05_new.rs b/tests/unit/out/refcount/05_new.rs index 9719605c62..71aec2675c 100644 --- a/tests/unit/out/refcount/05_new.rs +++ b/tests/unit/out/refcount/05_new.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -32,7 +31,6 @@ pub struct A {} FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -54,8 +52,8 @@ fn main_0() -> i32 { let mut c: Ptr = Ptr::alloc(3); c.delete(); D::operator_call( - Rc::new(RefCell::new(::default())).as_pointer(), - Ptr::alloc(::default()), + Rc::new(RefCell::new({ ::zero_init() })).as_pointer(), + Ptr::alloc({ ::zero_init() }), ); return 0; } diff --git a/tests/unit/out/refcount/10_struct.rs b/tests/unit/out/refcount/10_struct.rs index 2aab41cbe5..7b63ca909f 100644 --- a/tests/unit/out/refcount/10_struct.rs +++ b/tests/unit/out/refcount/10_struct.rs @@ -15,7 +15,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -36,7 +35,6 @@ pub struct GraphNode { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -81,15 +79,6 @@ impl Partial { field!(this, p).write((q).clone()); } } -impl Default for Partial { - fn default() -> Self { - { - Partial { - p: Ptr::::null(), - } - } - } -} #[derive( Copy, Clone, @@ -100,7 +89,6 @@ impl Default for Partial { FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -116,7 +104,6 @@ impl Declared {} FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/addr_of_global.rs b/tests/unit/out/refcount/addr_of_global.rs index 7c3f0b1230..7c2e181937 100644 --- a/tests/unit/out/refcount/addr_of_global.rs +++ b/tests/unit/out/refcount/addr_of_global.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -34,7 +33,6 @@ pub struct Inner { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/anonymous-struct.rs b/tests/unit/out/refcount/anonymous-struct.rs index e3de675ff5..6c891512a0 100644 --- a/tests/unit/out/refcount/anonymous-struct.rs +++ b/tests/unit/out/refcount/anonymous-struct.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -37,7 +36,6 @@ pub struct Outer_Named { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -58,7 +56,6 @@ pub struct anon_0 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -79,7 +76,6 @@ pub struct anon_1 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -100,7 +96,6 @@ pub struct anon_2 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -119,7 +114,6 @@ pub struct anon_4 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -138,7 +132,6 @@ pub struct anon_5 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -163,7 +156,6 @@ pub struct anon_3 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -190,7 +182,7 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let mut o: Outer = ::default(); + let mut o: Outer = { ::zero_init() }; o.named.a = 1; o.named.b = 2; o.anonymous_named_0.c = 3; @@ -213,7 +205,7 @@ fn main_0() -> i32 { assert!((o.anon_3.i == 9)); assert!((o.anon_3.inner_named.j == 10)); assert!((o.anon_3.anon_5.k == 11)); - let mut s: anon_6 = ::default(); + let mut s: anon_6 = { ::zero_init() }; s.x = 1; s.z = 2; assert!( @@ -240,7 +232,6 @@ fn main_0() -> i32 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/anonymous-struct_c.rs b/tests/unit/out/refcount/anonymous-struct_c.rs index 1edb3cd3f0..8996cd9fd2 100644 --- a/tests/unit/out/refcount/anonymous-struct_c.rs +++ b/tests/unit/out/refcount/anonymous-struct_c.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(8)] pub struct Named { @@ -35,7 +34,6 @@ pub struct Named { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(8)] pub struct anon_0 { @@ -54,7 +52,6 @@ pub struct anon_0 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(8)] pub struct anon_1 { @@ -73,7 +70,6 @@ pub struct anon_1 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(8)] pub struct anon_2 { @@ -92,7 +88,6 @@ pub struct anon_2 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(4)] pub struct anon_4 { @@ -109,7 +104,6 @@ pub struct anon_4 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(4)] pub struct anon_5 { @@ -126,7 +120,6 @@ pub struct anon_5 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(12)] pub struct anon_3 { @@ -149,7 +142,6 @@ pub struct anon_3 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(44)] pub struct Outer { @@ -176,10 +168,10 @@ pub fn main() { fn main_0() -> i32 { let mut o: Outer = Outer { named: Named { a: 0, b: 0_i32 }, - anon0: ::default(), - anon1: ::default(), - anon_2: ::default(), - anon_3: ::default(), + anon0: { ::zero_init() }, + anon1: { ::zero_init() }, + anon_2: { ::zero_init() }, + anon_3: { ::zero_init() }, }; o.named.a = 1; o.named.b = 2; @@ -203,7 +195,7 @@ fn main_0() -> i32 { assert!((o.anon_3.i == 9)); assert!((o.anon_3.inner_named.j == 10)); assert!((o.anon_3.anon_5.k == 11)); - let mut s: anon_6 = ::default(); + let mut s: anon_6 = { ::zero_init() }; s.x = 1; s.z = 2; assert!( @@ -230,7 +222,6 @@ fn main_0() -> i32 { FnPtrArg, TriviallyDefaultConstructible, 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 722900ac17..e7e125ee1d 100644 --- a/tests/unit/out/refcount/anonymous_enum.rs +++ b/tests/unit/out/refcount/anonymous_enum.rs @@ -22,7 +22,6 @@ pub const anon_1_SECOND_B: anon_1 = 1; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -47,7 +46,6 @@ pub const anon_2_FIELD_B: anon_2 = 1; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -70,7 +68,7 @@ fn main_0() -> i32 { assert!(((td as i32) == (TdEnum_TD_A as i32))); td = TdEnum_TD_B; assert!(((td as i32) == (TdEnum_TD_B as i32))); - let mut w: WithAnonField = ::default(); + let mut w: WithAnonField = { ::zero_init() }; w.field = anon_2_FIELD_A; assert!(((w.field as i32) == (anon_2_FIELD_A as i32))); w.field = anon_2_FIELD_B; diff --git a/tests/unit/out/refcount/anonymous_enum_c.rs b/tests/unit/out/refcount/anonymous_enum_c.rs index c348d852a2..b39692b8c0 100644 --- a/tests/unit/out/refcount/anonymous_enum_c.rs +++ b/tests/unit/out/refcount/anonymous_enum_c.rs @@ -22,7 +22,6 @@ pub const anon_1_SECOND_B: anon_1 = 1; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(4)] pub struct S { @@ -45,7 +44,6 @@ pub const anon_2_FIELD_B: anon_2 = 1; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(8)] pub struct WithAnonField { @@ -66,7 +64,7 @@ fn main_0() -> i32 { assert!(((td as u32) == ((TdEnum_enum_TD_A as i32) as u32))); td = TdEnum_enum_TD_B; assert!(((td as u32) == ((TdEnum_enum_TD_B as i32) as u32))); - let mut w: WithAnonField = ::default(); + let mut w: WithAnonField = { ::zero_init() }; w.field = anon_2_FIELD_A; assert!(((w.field as u32) == ((anon_2_FIELD_A as i32) as u32))); w.field = anon_2_FIELD_B; diff --git a/tests/unit/out/refcount/any.rs b/tests/unit/out/refcount/any.rs index 84ba9fcf17..39f458fdce 100644 --- a/tests/unit/out/refcount/any.rs +++ b/tests/unit/out/refcount/any.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/array_const_init.rs b/tests/unit/out/refcount/array_const_init.rs index 4e1c28e929..f9876970ec 100644 --- a/tests/unit/out/refcount/array_const_init.rs +++ b/tests/unit/out/refcount/array_const_init.rs @@ -29,17 +29,6 @@ pub struct S { #[array_len(4)] pub buf: Box<[i8]>, } -impl Default for S { - fn default() -> Self { - { - S { - head: 0_i32, - tail: (0..3).map(|_| 0_i32).collect::>(), - buf: (0..4).map(|_| 0_i8).collect::>(), - } - } - } -} thread_local!( pub static s_0: Value = Rc::new(RefCell::new(S { head: 5, @@ -57,7 +46,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(8)] pub struct P { @@ -140,9 +128,9 @@ fn main_0() -> i32 { assert!(((d[(0) as usize] == 0_f64) && (d[(3) as usize] == 0_f64))); let mut p: [P; 4] = [ P { x: 1, y: 2 }, -

::default(), -

::default(), -

::default(), + {

::zero_init() }, + {

::zero_init() }, + {

::zero_init() }, ]; assert!(((p[(0) as usize].x == 1) && (p[(0) as usize].y == 2))); assert!(((p[(3) as usize].x == 0) && (p[(3) as usize].y == 0))); diff --git a/tests/unit/out/refcount/array_field_addr.rs b/tests/unit/out/refcount/array_field_addr.rs index 0beecd6e81..b39e396e06 100644 --- a/tests/unit/out/refcount/array_field_addr.rs +++ b/tests/unit/out/refcount/array_field_addr.rs @@ -27,17 +27,6 @@ pub struct S { #[offset(8)] pub after: i32, } -impl Default for S { - fn default() -> Self { - { - S { - before: 0_i32, - mask: (0..4).map(|_| 0_u8).collect::>(), - after: 0_i32, - } - } - } -} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); diff --git a/tests/unit/out/refcount/array_of_noncopy_struct.rs b/tests/unit/out/refcount/array_of_noncopy_struct.rs index 4eae87808a..4acdc87a75 100644 --- a/tests/unit/out/refcount/array_of_noncopy_struct.rs +++ b/tests/unit/out/refcount/array_of_noncopy_struct.rs @@ -36,16 +36,6 @@ impl NonCopy { field!(this, tag).write(0); } } -impl Default for NonCopy { - fn default() -> Self { - { - NonCopy { - data: Default::default(), - tag: 0, - } - } - } -} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); diff --git a/tests/unit/out/refcount/array_reference.rs b/tests/unit/out/refcount/array_reference.rs index cf494f4667..b664bf4f14 100644 --- a/tests/unit/out/refcount/array_reference.rs +++ b/tests/unit/out/refcount/array_reference.rs @@ -69,7 +69,6 @@ pub fn pick_10(s: Ptr) -> Ptr { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/as_const.rs b/tests/unit/out/refcount/as_const.rs index d777f68105..b23dc27a0b 100644 --- a/tests/unit/out/refcount/as_const.rs +++ b/tests/unit/out/refcount/as_const.rs @@ -19,7 +19,6 @@ pub const Overload_kConstOverload: Overload = 2; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/assign_rhs_first.rs b/tests/unit/out/refcount/assign_rhs_first.rs index f96301dad8..3338db6ea3 100644 --- a/tests/unit/out/refcount/assign_rhs_first.rs +++ b/tests/unit/out/refcount/assign_rhs_first.rs @@ -24,7 +24,6 @@ pub fn advance_1() -> i32 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/assignment_single_eval.rs b/tests/unit/out/refcount/assignment_single_eval.rs index bbd2ca8fbe..6677de9e02 100644 --- a/tests/unit/out/refcount/assignment_single_eval.rs +++ b/tests/unit/out/refcount/assignment_single_eval.rs @@ -819,7 +819,6 @@ pub fn test_reference_members_9() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -838,7 +837,6 @@ pub struct Slot_6 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -857,7 +855,6 @@ pub struct Slot_8 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -934,7 +931,6 @@ pub fn test_pointer_elements_11() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -980,7 +976,6 @@ pub fn test_reference_pointer_13() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -1090,7 +1085,6 @@ pub fn test_reference_subfields_18() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -1108,7 +1102,6 @@ pub struct Index_16 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -1128,7 +1121,6 @@ pub struct Slot_17 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -1146,7 +1138,6 @@ pub struct Index_19 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -1201,7 +1192,6 @@ pub fn observe_24(mut assigned: i32, mut stored: Ptr) -> i32 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -1220,7 +1210,6 @@ pub struct GlobalRecord_Inner { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -1405,7 +1394,7 @@ pub fn test_borrows_29() { ) }) ); - let first: Value = >::default(); + let first: Value = { >::zero_init() }; *first.borrow_mut() = Link_33 { next: (first.as_pointer()), }; @@ -1478,7 +1467,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -1496,7 +1484,6 @@ pub struct Record_32 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -1520,7 +1507,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -1537,7 +1523,7 @@ impl IndexedBinding { } } pub fn test_binding_35() { - let owner: Value = Rc::new(RefCell::new(::default())); + let owner: Value = Rc::new(RefCell::new({ ::zero_init() })); let __decomp_36: Ptr = owner.as_pointer(); let value: Ptr = ({ IndexedBinding::get_1_0((__decomp_36).clone()) }); let mut result: u32 = ({ @@ -1778,7 +1764,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -2151,7 +2136,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -2394,7 +2378,6 @@ pub fn test_stable_containers_58() { Memberwise, CopyConstructible, Swappable, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(Conversions)] @@ -2421,7 +2404,6 @@ impl Counts_59 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -2745,7 +2727,6 @@ fn main_0() -> i32 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -2775,16 +2756,6 @@ pub struct Owner_63 { #[offset(8)] pub index: i32, } -impl Default for Owner_63 { - fn default() -> Self { - { - Owner_63 { - values: (0..2).map(|_| 0_i32).collect::>(), - index: 0_i32, - } - } - } -} pub fn __cpp2rust_init_globals() { let _ = global_22.with(|_| ()); let _ = global_record_25.with(|_| ()); diff --git a/tests/unit/out/refcount/bounded_struct_ptr.rs b/tests/unit/out/refcount/bounded_struct_ptr.rs index 5ddee4f361..ea2dc97338 100644 --- a/tests/unit/out/refcount/bounded_struct_ptr.rs +++ b/tests/unit/out/refcount/bounded_struct_ptr.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/bst.rs b/tests/unit/out/refcount/bst.rs index 318586c3f3..2c863ff4ee 100644 --- a/tests/unit/out/refcount/bst.rs +++ b/tests/unit/out/refcount/bst.rs @@ -15,7 +15,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/c_struct.rs b/tests/unit/out/refcount/c_struct.rs index e1370c5c1b..aa841850c8 100644 --- a/tests/unit/out/refcount/c_struct.rs +++ b/tests/unit/out/refcount/c_struct.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(8)] pub struct Point { @@ -35,7 +34,6 @@ pub struct Point { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(16)] pub struct Line { @@ -55,7 +53,6 @@ pub struct Line { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(16)] pub struct Node { @@ -79,7 +76,6 @@ pub const Color_BLUE: Color = 2; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(8)] pub struct Inner { @@ -98,7 +94,6 @@ pub struct Inner { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(16)] pub struct Container { @@ -147,7 +142,7 @@ fn main_0() -> i32 { assert!((c.inner.b == 6)); assert!(((c.color as u32) == ((Color_GREEN as i32) as u32))); assert!((c.count == 42)); - let mut c2: Container = ::default(); + let mut c2: Container = { ::zero_init() }; c2.color = Color_BLUE; assert!(((c2.color as u32) == 2_u32)); return 0; diff --git a/tests/unit/out/refcount/cast.rs b/tests/unit/out/refcount/cast.rs index 831c3621ea..386e4c13d2 100644 --- a/tests/unit/out/refcount/cast.rs +++ b/tests/unit/out/refcount/cast.rs @@ -20,7 +20,6 @@ pub const E_C: E = 2; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -41,7 +40,6 @@ pub struct Pair { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -76,19 +74,6 @@ pub struct Grid { #[array_len(2, 3)] pub cells: Box<[Box<[i32]>]>, } -impl Default for Grid { - fn default() -> Self { - { - Grid { - h: 0_i32, - row: (0..3).map(|_| 0_i32).collect::>(), - cells: (0..2) - .map(|_| (0..3).map(|_| 0_i32).collect::>()) - .collect::]>>(), - } - } - } -} #[derive( Clone, Record, @@ -100,7 +85,6 @@ impl Default for Grid { Memberwise, CopyConstructible, Swappable, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(Conversions)] @@ -271,14 +255,14 @@ pub fn over_aligned_3() { let c: Value = Rc::new(RefCell::new(('c' as i8))); assert!(((c.as_pointer()).to_int() != 0_usize)); let w: Value> = Rc::new(RefCell::new( - (0..3).map(|_| ::default()).collect::>(), + (0..3).map(|_| ::zero_init()).collect::>(), )); let mut iw: usize = w.decay().to_int(); assert!(((iw as u64).wrapping_rem((64usize as u64)) == 0_u64)); assert!((((w.decay().offset(1)).to_int()).wrapping_sub(iw) == 64usize)); let mut h: Ptr = Ptr::alloc_array( (0..2_usize) - .map(|_| ::default()) + .map(|_| ::zero_init()) .collect::>(), ); assert!(((h.to_int() as u64).wrapping_rem((64usize as u64)) == 0_u64)); @@ -340,7 +324,7 @@ pub fn vector_capacity_4() { ); } pub fn nested_5() { - let g: Value = Rc::new(RefCell::new(::default())); + let g: Value = Rc::new(RefCell::new({ ::zero_init() })); let mut ig: usize = (g.as_pointer()).to_int(); assert!( ((array_field_ptr!(g.as_pointer(), row).offset((2) as isize)).to_int() 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 2be7893600..4272e0b922 100644 --- a/tests/unit/out/refcount/cast_array_to_pointer_decay.rs +++ b/tests/unit/out/refcount/cast_array_to_pointer_decay.rs @@ -35,15 +35,6 @@ pub struct Row { #[array_len(3)] pub a: Box<[i32]>, } -impl Default for Row { - fn default() -> Self { - { - Row { - a: (0..3).map(|_| 0_i32).collect::>(), - } - } - } -} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); diff --git a/tests/unit/out/refcount/class.rs b/tests/unit/out/refcount/class.rs index 01d48a3621..ffecfaf4e1 100644 --- a/tests/unit/out/refcount/class.rs +++ b/tests/unit/out/refcount/class.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -60,7 +59,6 @@ impl Pair { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -89,7 +87,6 @@ impl Route { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -118,7 +115,6 @@ impl Counter { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/class_template_lazy_member.rs b/tests/unit/out/refcount/class_template_lazy_member.rs index 541685d7cb..1401a90068 100644 --- a/tests/unit/out/refcount/class_template_lazy_member.rs +++ b/tests/unit/out/refcount/class_template_lazy_member.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -35,7 +34,6 @@ pub struct Point { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -59,7 +57,6 @@ impl Box_int_ { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -84,7 +81,6 @@ impl Box_Point_ { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -108,7 +104,6 @@ impl Deduced_int_ { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/class_templates.rs b/tests/unit/out/refcount/class_templates.rs index 69d4095d39..678e58d173 100644 --- a/tests/unit/out/refcount/class_templates.rs +++ b/tests/unit/out/refcount/class_templates.rs @@ -17,7 +17,6 @@ use std::rc::{Rc, Weak}; Memberwise, CopyConstructible, Swappable, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(Conversions)] @@ -64,7 +63,6 @@ impl MyContainer_int_ { Memberwise, CopyConstructible, Swappable, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(Conversions)] @@ -111,7 +109,6 @@ impl MyContainer_char_ { Memberwise, CopyConstructible, Swappable, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(Conversions)] @@ -157,7 +154,6 @@ impl MyContainer_float_ { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -184,7 +180,6 @@ impl Boxed_short_ { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -211,7 +206,6 @@ impl Boxed_int_ { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -238,7 +232,6 @@ impl Boxed_long_ { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -264,7 +257,6 @@ impl Outer_int__Inner_int_ { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -291,7 +283,6 @@ impl Outer_int_ { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -317,7 +308,6 @@ impl Outer_long__Inner_int_ { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -343,7 +333,6 @@ impl Outer_long__Inner_char_ { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -370,7 +359,6 @@ impl Outer_long_ { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/clone_vs_move.rs b/tests/unit/out/refcount/clone_vs_move.rs index 01f08719fe..717560622a 100644 --- a/tests/unit/out/refcount/clone_vs_move.rs +++ b/tests/unit/out/refcount/clone_vs_move.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -55,19 +54,6 @@ pub struct Foo { #[byte_size(4)] pub bar: Bar, } -impl Default for Foo { - fn default() -> Self { - { - Foo { - x: 0_i32, - y: >::default(), - z: Ptr::::null(), - a: (0..3).map(|_| 0_i32).collect::>(), - bar: ::default(), - } - } - } -} #[derive( Clone, Record, @@ -77,7 +63,6 @@ impl Default for Foo { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/comma_operator.rs b/tests/unit/out/refcount/comma_operator.rs index c4bf0369ef..fb28c255c7 100644 --- a/tests/unit/out/refcount/comma_operator.rs +++ b/tests/unit/out/refcount/comma_operator.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/complex_function.rs b/tests/unit/out/refcount/complex_function.rs index cdaf1ef018..9c4025350c 100644 --- a/tests/unit/out/refcount/complex_function.rs +++ b/tests/unit/out/refcount/complex_function.rs @@ -25,7 +25,6 @@ pub fn bar_2(x: Ptr) -> Ptr { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -43,7 +42,6 @@ pub struct X1 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -67,7 +65,6 @@ impl X2 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -91,7 +88,6 @@ impl X3 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/compound_assign_paren.rs b/tests/unit/out/refcount/compound_assign_paren.rs index bcb31b9e27..d622676b69 100644 --- a/tests/unit/out/refcount/compound_assign_paren.rs +++ b/tests/unit/out/refcount/compound_assign_paren.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/concepts.rs b/tests/unit/out/refcount/concepts.rs index 4d2bb260fd..d48cb8f20d 100644 --- a/tests/unit/out/refcount/concepts.rs +++ b/tests/unit/out/refcount/concepts.rs @@ -21,7 +21,6 @@ const _: () = assert!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/constexpr_function.rs b/tests/unit/out/refcount/constexpr_function.rs index 3f53ea24b1..260195be5b 100644 --- a/tests/unit/out/refcount/constexpr_function.rs +++ b/tests/unit/out/refcount/constexpr_function.rs @@ -31,7 +31,6 @@ pub fn half_3(mut x: f64) -> f64 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -73,7 +72,6 @@ pub fn imm_7(mut b: bool) -> bool { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/constructor.rs b/tests/unit/out/refcount/constructor.rs index 7fbe88c197..c16ea8f306 100644 --- a/tests/unit/out/refcount/constructor.rs +++ b/tests/unit/out/refcount/constructor.rs @@ -93,17 +93,6 @@ impl Point { }; } } -impl Default for Point { - fn default() -> Self { - { - { - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - Point::constructor_3(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); diff --git a/tests/unit/out/refcount/container_element_receiver.rs b/tests/unit/out/refcount/container_element_receiver.rs index c4bb6c21e0..06174883e0 100644 --- a/tests/unit/out/refcount/container_element_receiver.rs +++ b/tests/unit/out/refcount/container_element_receiver.rs @@ -19,7 +19,6 @@ use std::rc::{Rc, Weak}; CopyAssignable, MoveAssignable, Swappable, - Default, )] #[memberwise(move_constructor)] #[derive(Conversions)] diff --git a/tests/unit/out/refcount/container_field_addr.rs b/tests/unit/out/refcount/container_field_addr.rs index c4cac46cc0..9080d2125c 100644 --- a/tests/unit/out/refcount/container_field_addr.rs +++ b/tests/unit/out/refcount/container_field_addr.rs @@ -17,7 +17,6 @@ use std::rc::{Rc, Weak}; Memberwise, CopyConstructible, Swappable, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(Conversions)] diff --git a/tests/unit/out/refcount/conversion_operator_same_translation.rs b/tests/unit/out/refcount/conversion_operator_same_translation.rs index 95557778f6..65d8f965ec 100644 --- a/tests/unit/out/refcount/conversion_operator_same_translation.rs +++ b/tests/unit/out/refcount/conversion_operator_same_translation.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -45,7 +44,6 @@ impl S { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/copy_assign.rs b/tests/unit/out/refcount/copy_assign.rs index 4f00ada430..2499c8dcc3 100644 --- a/tests/unit/out/refcount/copy_assign.rs +++ b/tests/unit/out/refcount/copy_assign.rs @@ -18,7 +18,6 @@ thread_local!( MoveConstructible, MoveAssignable, Swappable, - Default, Conversions, )] #[conversions(copy)] @@ -85,18 +84,6 @@ impl NonConstAssign { return (this).clone(); } } -impl Default for NonConstAssign { - fn default() -> Self { - { - { - let __v: Value = - Rc::new(RefCell::new(ZeroInitialization::zero_init())); - NonConstAssign::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} #[derive( Copy, Clone, @@ -129,18 +116,6 @@ impl CopyAssignable for RefQualified { return (this).clone(); } } -impl Default for RefQualified { - fn default() -> Self { - { - { - let __v: Value = - Rc::new(RefCell::new(ZeroInitialization::zero_init())); - RefQualified::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} #[derive( Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Memberwise, Swappable, )] @@ -158,18 +133,6 @@ pub struct Holder { pub arr: Box<[Partial]>, } impl Holder {} -impl Default for Holder { - fn default() -> Self { - { - Holder { - p: ::default(), - arr: (0..2) - .map(|_| ::default()) - .collect::>(), - } - } - } -} thread_local!( pub static copies_1: Value = Rc::new(RefCell::new(0)); ); @@ -183,7 +146,6 @@ thread_local!( MoveConstructible, MoveAssignable, Swappable, - Default, )] #[memberwise(copy_assign)] #[derive(Conversions)] @@ -222,18 +184,6 @@ pub struct HasCopyCounted { pub arr: Box<[CopyCounted]>, } impl HasCopyCounted {} -impl Default for HasCopyCounted { - fn default() -> Self { - { - HasCopyCounted { - c: ::default(), - arr: (0..2) - .map(|_| ::default()) - .collect::>(), - } - } - } -} #[derive( Clone, Record, @@ -244,7 +194,6 @@ impl Default for HasCopyCounted { Destructible, CopyConstructible, Movable, - Default, Conversions, )] #[conversions(copy)] @@ -285,7 +234,6 @@ thread_local!( DefaultInitializable, MoveConstructible, Swappable, - Default, Conversions, )] #[conversions(copy)] @@ -334,14 +282,7 @@ impl MoveAssignable for Swapped { } } #[derive( - Record, - ByteRepr, - ZeroInitialization, - FnPtrArg, - DefaultInitializable, - Memberwise, - Swappable, - Default, + Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Memberwise, Swappable, )] #[memberwise(copy_constructor, move_constructor, copy_assign, move_assign)] #[derive(Conversions)] @@ -394,17 +335,6 @@ impl MoveAssignable for VoidAssign { Ptr::clone(&this.clone()) } } -impl Default for VoidAssign { - fn default() -> Self { - { - { - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - VoidAssign::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} #[derive( Copy, Clone, @@ -417,7 +347,6 @@ impl Default for VoidAssign { Memberwise, CopyConstructible, Movable, - Default, )] #[memberwise(copy_assign)] #[derive(Conversions)] diff --git a/tests/unit/out/refcount/copy_ctor.rs b/tests/unit/out/refcount/copy_ctor.rs index 36d2db9828..c6f17cc0d4 100644 --- a/tests/unit/out/refcount/copy_ctor.rs +++ b/tests/unit/out/refcount/copy_ctor.rs @@ -19,7 +19,6 @@ thread_local!( MoveConstructible, MoveAssignable, Swappable, - Default, )] #[memberwise(copy_assign)] #[derive(Conversions)] @@ -76,17 +75,6 @@ impl NonConst { field!(this, mark).write((o.with(|__s| __s.mark) + 10)); } } -impl Default for NonConst { - fn default() -> Self { - { - { - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - NonConst::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} #[derive( Record, ByteRepr, @@ -97,7 +85,6 @@ impl Default for NonConst { MoveConstructible, MoveAssignable, Swappable, - Default, )] #[memberwise(copy_assign)] #[derive(Conversions)] @@ -136,21 +123,7 @@ pub struct Holder { pub arr: Box<[Counted]>, } impl Holder {} -impl Default for Holder { - fn default() -> Self { - { - Holder { - c: ::default(), - arr: (0..2) - .map(|_| ::default()) - .collect::>(), - } - } - } -} -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Memberwise, Default, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Memberwise)] #[memberwise(move_constructor)] #[derive(Conversions)] #[conversions(copy, move)] @@ -170,9 +143,7 @@ impl Box_int_ { field!(this, val).write(o.with(|__s| __s.val)); } } -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Memberwise, Default, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Memberwise)] #[memberwise(copy_constructor, move_constructor)] #[derive(Conversions)] #[conversions(copy, move)] @@ -193,7 +164,6 @@ impl Owner {} MoveConstructible, MoveAssignable, Swappable, - Default, )] #[memberwise(copy_assign)] #[derive(Conversions)] @@ -256,11 +226,6 @@ impl CopyAssignable for Tracked { return (this).clone(); } } -impl Default for Tracked { - fn default() -> Self { - { Tracked { copied_from: 0 } } - } -} pub fn touch_1(mut t: Ptr) { field!(t, copied_from).with_mut(|__v| { __v.prefix_inc(); @@ -299,17 +264,6 @@ impl SelfPtr { field!(this, self_).write((this).clone()); } } -impl Default for SelfPtr { - fn default() -> Self { - { - { - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - SelfPtr::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} #[derive( Copy, Clone, @@ -320,7 +274,6 @@ impl Default for SelfPtr { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -342,17 +295,6 @@ impl Derived { Counted::constructor_1(field_ptr!(this, c), 20); } } -impl Default for Derived { - fn default() -> Self { - { - { - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - Derived::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); diff --git a/tests/unit/out/refcount/copy_move_defaulted.rs b/tests/unit/out/refcount/copy_move_defaulted.rs index 99e7082ee2..687f0bf5eb 100644 --- a/tests/unit/out/refcount/copy_move_defaulted.rs +++ b/tests/unit/out/refcount/copy_move_defaulted.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -88,17 +87,6 @@ pub struct Implicit { #[array_len(2)] pub arr: Box<[i32]>, } -impl Default for Implicit { - fn default() -> Self { - { - Implicit { - v: 0_i32, - inner: ::default(), - arr: (0..2).map(|_| 0_i32).collect::>(), - } - } - } -} #[derive( Copy, Clone, @@ -111,7 +99,6 @@ impl Default for Implicit { Memberwise, CopyConstructible, Swappable, - Default, )] #[memberwise(copy_assign)] #[derive(Conversions)] @@ -142,14 +129,7 @@ impl MoveAssignable for DefaultCopyUserMove { } } #[derive( - Record, - ByteRepr, - ZeroInitialization, - FnPtrArg, - DefaultInitializable, - Memberwise, - Swappable, - Default, + Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Memberwise, Swappable, )] #[memberwise(move_constructor, move_assign)] #[derive(Conversions)] @@ -219,11 +199,6 @@ impl Buffer { ); } } -impl Default for Buffer { - fn default() -> Self { - { ::zero_init() } - } -} #[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Swappable)] #[memberwise(move_constructor, move_assign)] #[derive(Conversions)] @@ -252,18 +227,6 @@ impl Owner { field!(this, p).write(None); } } -impl Default for Owner { - fn default() -> Self { - { - Owner { - data: Default::default(), - n: 0_i32, - arr: (0..2).map(|_| 0_i32).collect::>(), - p: None, - } - } - } -} #[derive( Clone, Record, @@ -275,7 +238,6 @@ impl Default for Owner { Memberwise, CopyConstructible, Swappable, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(Conversions)] @@ -352,16 +314,7 @@ impl MoveAssignable for SeesThis { return (this).clone(); } } -impl Default for SeesThis { - fn default() -> Self { - { - SeesThis { - self_: Ptr::::null(), - } - } - } -} -#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Default)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise)] #[memberwise(copy_assign, move_assign)] #[derive(Conversions)] #[constructor(constructor_1)] @@ -410,14 +363,7 @@ impl MoveAssignable for Counted_int_ { return (this).clone(); } } -impl Default for Counted_int_ { - fn default() -> Self { - { Counted_int_ { v: 0_i32, moves: 0 } } - } -} -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Swappable, Default, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Swappable)] #[memberwise(move_constructor, move_assign)] #[derive(Conversions)] #[conversions(move)] @@ -483,21 +429,7 @@ impl MoveAssignable for CtorSeesThis { return (this).clone(); } } -impl Default for CtorSeesThis { - fn default() -> Self { - { - { - let __v: Value = - Rc::new(RefCell::new(ZeroInitialization::zero_init())); - CtorSeesThis::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Swappable, Default, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Swappable)] #[memberwise(copy_constructor, move_constructor, copy_assign, move_assign)] #[derive(Conversions)] #[conversions(copy, move)] @@ -537,18 +469,6 @@ impl InitsCtorSeesThis { CtorSeesThis::constructor_2(field_ptr!(this, y), 2); } } -impl Default for InitsCtorSeesThis { - fn default() -> Self { - { - { - let __v: Value = - Rc::new(RefCell::new(ZeroInitialization::zero_init())); - InitsCtorSeesThis::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} #[derive( Record, ByteRepr, @@ -590,18 +510,6 @@ impl Constructor<()> for OutOfLineDefaulted { } } } -impl Default for OutOfLineDefaulted { - fn default() -> Self { - { - { - let __v: Value = - Rc::new(RefCell::new(ZeroInitialization::zero_init())); - OutOfLineDefaulted::construct(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} impl OutOfLineDefaulted {} impl OutOfLineDefaulted {} #[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Conversions)] @@ -624,17 +532,6 @@ impl OutOfLineAssign { field!(this, w).write(Vec::new()); } } -impl Default for OutOfLineAssign { - fn default() -> Self { - { - OutOfLineAssign { - s: ::default(), - v: 1, - w: Default::default(), - } - } - } -} impl CopyAssignable for OutOfLineAssign { fn copy_assign( this: Ptr, diff --git a/tests/unit/out/refcount/copy_move_deleted.rs b/tests/unit/out/refcount/copy_move_deleted.rs index 3779e7dc33..7dfea3d983 100644 --- a/tests/unit/out/refcount/copy_move_deleted.rs +++ b/tests/unit/out/refcount/copy_move_deleted.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, - DefaultInitializable, - Swappable, - Default, - Conversions, + Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Swappable, Conversions, )] #[conversions(move)] #[constructor(constructor_1, i32)] @@ -69,18 +62,6 @@ impl MoveAssignable for PrivateCopy { return (this).clone(); } } -impl Default for PrivateCopy { - fn default() -> Self { - { - { - let __v: Value = - Rc::new(RefCell::new(ZeroInitialization::zero_init())); - PrivateCopy::constructor_2(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} #[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Conversions)] #[constructor(constructor_1)] #[byte_size(4)] @@ -93,26 +74,8 @@ impl Immovable { field!(this, v).write(0); } } -impl Default for Immovable { - fn default() -> Self { - { - { - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - Immovable::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} #[derive( - Record, - ByteRepr, - ZeroInitialization, - FnPtrArg, - DefaultInitializable, - Memberwise, - Swappable, - Default, + Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Memberwise, Swappable, )] #[memberwise(move_constructor, move_assign)] #[derive(Conversions)] @@ -126,9 +89,7 @@ pub struct Container { pub tag: i32, } impl Container {} -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Swappable, Default, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Swappable)] #[memberwise(move_constructor, move_assign)] #[derive(Conversions)] #[conversions(move)] diff --git a/tests/unit/out/refcount/default.rs b/tests/unit/out/refcount/default.rs index 6f657c55a8..fc70582db2 100644 --- a/tests/unit/out/refcount/default.rs +++ b/tests/unit/out/refcount/default.rs @@ -37,23 +37,6 @@ pub struct Pointers { #[offset(136)] pub x5: i32, } -impl Default for Pointers { - fn default() -> Self { - { - Pointers { - x1: Ptr::::null(), - x2: Ptr::::null(), - x3: (0..5) - .map(|_| Ptr::::null()) - .collect::]>>(), - x4: (0..10) - .map(|_| Ptr::::null()) - .collect::]>>(), - x5: 0_i32, - } - } - } -} #[derive( Clone, Record, @@ -84,22 +67,6 @@ pub struct SmallArrays { #[array_len(2)] pub p: Box<[Pointers]>, } -impl Default for SmallArrays { - fn default() -> Self { - { - SmallArrays { - a: (0..32).map(|_| 0_i32).collect::>(), - f: FnPtr:: i32>::null(), - fs: (0..2) - .map(|_| FnPtr:: i32>::null()) - .collect:: i32>]>>(), - p: (0..2) - .map(|_| ::default()) - .collect::>(), - } - } - } -} #[derive( Clone, Record, @@ -119,15 +86,6 @@ pub struct BigArray { #[array_len(33)] pub a: Box<[i32]>, } -impl Default for BigArray { - fn default() -> Self { - { - BigArray { - a: (0..33).map(|_| 0_i32).collect::>(), - } - } - } -} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); @@ -135,19 +93,19 @@ pub fn main() { fn main_0() -> i32 { let mut default_pointers: Ptr = Ptr::alloc_array( (0..10_usize) - .map(|_| ::default()) + .map(|_| ::zero_init()) .collect::>(), ); default_pointers.delete(); let mut small: Ptr = Ptr::alloc_array( (0..2_usize) - .map(|_| ::default()) + .map(|_| ::zero_init()) .collect::>(), ); small.delete(); let mut big: Ptr = Ptr::alloc_array( (0..2_usize) - .map(|_| ::default()) + .map(|_| ::zero_init()) .collect::>(), ); big.delete(); diff --git a/tests/unit/out/refcount/default_function_arguments.rs b/tests/unit/out/refcount/default_function_arguments.rs index ed9a024b22..d457ab43e1 100644 --- a/tests/unit/out/refcount/default_function_arguments.rs +++ b/tests/unit/out/refcount/default_function_arguments.rs @@ -42,17 +42,6 @@ impl Constructor<()> for Bar { } } } -impl Default for Bar { - fn default() -> Self { - { - { - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - Bar::constructor_1(__v.as_pointer(), 1); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} thread_local!( pub static counter_2: Value = Rc::new(RefCell::new(0)); ); @@ -91,7 +80,6 @@ pub fn first_9(r: Ptr) -> i32 { FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/default_in_statics.rs b/tests/unit/out/refcount/default_in_statics.rs index 53c1045bd0..7a6c59c283 100644 --- a/tests/unit/out/refcount/default_in_statics.rs +++ b/tests/unit/out/refcount/default_in_statics.rs @@ -15,7 +15,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -66,24 +65,6 @@ pub struct Outer { #[byte_size(8)] pub fn_: FnPtr i32>, } -impl Default for Outer { - fn default() -> Self { - { - Outer { - p1: Ptr::::null(), - p2: Ptr::::null(), - arr: (0..3) - .map(|_| Ptr::::null()) - .collect::]>>(), - cp: Ptr::::null(), - pp: Ptr::>::null(), - inner: ::default(), - x: 0_i32, - fn_: FnPtr:: i32>::null(), - } - } - } -} #[derive( Clone, Record, @@ -93,7 +74,6 @@ impl Default for Outer { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -119,11 +99,13 @@ thread_local!( Rc::new(RefCell::new(FnPtr:: i32>::null())); ); thread_local!( - pub static static_outer_1: Value = Rc::new(RefCell::new(::default())); + pub static static_outer_1: Value = Rc::new(RefCell::new({ ::zero_init() })); ); thread_local!( pub static static_inner_array_2: Value> = Rc::new(RefCell::new( - (0..2).map(|_| ::default()).collect::>(), + (0..2) + .map(|_| ::zero_init()) + .collect::>(), )); ); thread_local!( @@ -160,7 +142,7 @@ pub fn check_local_static_5() { assert!(({ (*local_p_8.with(Value::clone).borrow()).is_null() })); } thread_local!( - static local_outer_6: Value = Rc::new(RefCell::new(::default())); + static local_outer_6: Value = Rc::new(RefCell::new({ ::zero_init() })); ); thread_local!( static local_fn_7: Value i32>> = diff --git a/tests/unit/out/refcount/destructor.rs b/tests/unit/out/refcount/destructor.rs index bc17b6fa88..445b535524 100644 --- a/tests/unit/out/refcount/destructor.rs +++ b/tests/unit/out/refcount/destructor.rs @@ -314,48 +314,46 @@ pub fn main() { } fn main_0() -> i32 { { - let s: Value = Rc::new(RefCell::new(::default_constructed())); + let s: Value = Rc::new(RefCell::new({ ::zero_init() })); let _dtor_s = std::mem::DropGuard::new(s.clone(), |__p| Destructible::destroy(__p.as_pointer())); } assert!((global_0.with(|rc| *rc.borrow()) == 1)); { - let s: Value = Rc::new(RefCell::new(::default_constructed())); + let s: Value = Rc::new(RefCell::new({ ::zero_init() })); let _dtor_s = std::mem::DropGuard::new(s.clone(), |__p| Destructible::destroy(__p.as_pointer())); } assert!((global_0.with(|rc| *rc.borrow()) == 2)); { - let d: Value = Rc::new(RefCell::new(::default_constructed())); + let d: Value = Rc::new(RefCell::new({ ::zero_init() })); let _dtor_d = std::mem::DropGuard::new(d.clone(), |__p| Destructible::destroy(__p.as_pointer())); } assert!((global_0.with(|rc| *rc.borrow()) == 3)); { - let o: Value = Rc::new(RefCell::new(::default_constructed())); + let o: Value = Rc::new(RefCell::new({ ::zero_init() })); let _dtor_o = std::mem::DropGuard::new(o.clone(), |__p| Destructible::destroy(__p.as_pointer())); } assert!((global_0.with(|rc| *rc.borrow()) == 4)); { - let am: Value = Rc::new(RefCell::new(::default_constructed())); + let am: Value = Rc::new(RefCell::new({ ::zero_init() })); let _dtor_am = std::mem::DropGuard::new(am.clone(), |__p| Destructible::destroy(__p.as_pointer())); } assert!((global_0.with(|rc| *rc.borrow()) == 7)); { - let e: Value = Rc::new(RefCell::new(::default_constructed())); + let e: Value = Rc::new(RefCell::new({ ::zero_init() })); let _dtor_e = std::mem::DropGuard::new(e.clone(), |__p| Destructible::destroy(__p.as_pointer())); } assert!((global_0.with(|rc| *rc.borrow()) == 8)); { - let tc: Value = - Rc::new(RefCell::new(::default_constructed())); + let tc: Value = Rc::new(RefCell::new({ ::zero_init() })); let _dtor_tc = std::mem::DropGuard::new(tc.clone(), |__p| Destructible::destroy(__p.as_pointer())); - let ti: Value = - Rc::new(RefCell::new(::default_constructed())); + let ti: Value = Rc::new(RefCell::new({ ::zero_init() })); let _dtor_ti = std::mem::DropGuard::new(ti.clone(), |__p| Destructible::destroy(__p.as_pointer())); } @@ -402,7 +400,7 @@ fn main_0() -> i32 { ); let mut before: i32 = global_0.with(|rc| *rc.borrow()); { - let cs: Value = Rc::new(RefCell::new(::default_constructed())); + let cs: Value = Rc::new(RefCell::new({ ::zero_init() })); let _dtor_cs = std::mem::DropGuard::new(cs.clone(), |__p| Destructible::destroy(__p.as_pointer())); } diff --git a/tests/unit/out/refcount/destructor_params.rs b/tests/unit/out/refcount/destructor_params.rs index b791c8fdae..7e0a5bcf76 100644 --- a/tests/unit/out/refcount/destructor_params.rs +++ b/tests/unit/out/refcount/destructor_params.rs @@ -57,7 +57,6 @@ pub fn with_default_3(s: ParameterObject) -> i32 { FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/doubly_linked_list.rs b/tests/unit/out/refcount/doubly_linked_list.rs index e9a847d3d9..cc694aa3f0 100644 --- a/tests/unit/out/refcount/doubly_linked_list.rs +++ b/tests/unit/out/refcount/doubly_linked_list.rs @@ -15,7 +15,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/enum_default_in_static.rs b/tests/unit/out/refcount/enum_default_in_static.rs index d0d934c149..29b50a2cac 100644 --- a/tests/unit/out/refcount/enum_default_in_static.rs +++ b/tests/unit/out/refcount/enum_default_in_static.rs @@ -20,7 +20,6 @@ pub const Mode_MODE_TWO: Mode = 2; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(8)] pub struct Config { @@ -30,7 +29,7 @@ pub struct Config { pub mode: Mode, } thread_local!( - pub static config_0: Value = >::default(); + pub static config_0: Value = { >::zero_init() }; ); pub fn main() { __cpp2rust_init_globals(); diff --git a/tests/unit/out/refcount/enum_int_interop.rs b/tests/unit/out/refcount/enum_int_interop.rs index 3c053eb092..cbf68c4a4c 100644 --- a/tests/unit/out/refcount/enum_int_interop.rs +++ b/tests/unit/out/refcount/enum_int_interop.rs @@ -28,7 +28,6 @@ pub const Tag_TAG_TWO: Tag = 2; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/enum_int_interop_c.rs b/tests/unit/out/refcount/enum_int_interop_c.rs index d56a7cf2be..ff2f49e8bc 100644 --- a/tests/unit/out/refcount/enum_int_interop_c.rs +++ b/tests/unit/out/refcount/enum_int_interop_c.rs @@ -28,7 +28,6 @@ pub const Tag_enum_TAG_TWO: Tag_enum = 2; FnPtrArg, TriviallyDefaultConstructible, 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 2db50121d3..557cfbb795 100644 --- a/tests/unit/out/refcount/enum_underlying_type.rs +++ b/tests/unit/out/refcount/enum_underlying_type.rs @@ -48,15 +48,6 @@ impl HoldsEmpty { field!(this, e).write(::default()); } } -impl Default for HoldsEmpty { - fn default() -> Self { - { - HoldsEmpty { - e: ::default(), - } - } - } -} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); diff --git a/tests/unit/out/refcount/exprs.rs b/tests/unit/out/refcount/exprs.rs index bfc3ccee0f..2b85506ce6 100644 --- a/tests/unit/out/refcount/exprs.rs +++ b/tests/unit/out/refcount/exprs.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -34,7 +33,6 @@ pub struct X { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/fft.rs b/tests/unit/out/refcount/fft.rs index e83258f355..579f54d9ca 100644 --- a/tests/unit/out/refcount/fft.rs +++ b/tests/unit/out/refcount/fft.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -51,7 +50,7 @@ pub fn Neg_2(mut z1: Complex) -> Complex { pub fn fft_3(a: Ptr>>>, mut N: i32) -> Option>> { let mut y: Option>> = Some(Rc::new(RefCell::new( (0..(N as usize)) - .map(|_| ::default()) + .map(|_| ::zero_init()) .collect::>(), ))); if (N == 1) { @@ -63,7 +62,7 @@ pub fn fft_3(a: Ptr>>>, mut N: i32) -> Option>> = Some(Rc::new(RefCell::new( (0..(N as usize)) - .map(|_| ::default()) + .map(|_| ::zero_init()) .collect::>(), ))); { @@ -84,13 +83,13 @@ pub fn fft_3(a: Ptr>>>, mut N: i32) -> Option>>> = Rc::new(RefCell::new(Some(Rc::new(RefCell::new( (0..((N / 2) as usize)) - .map(|_| ::default()) + .map(|_| ::zero_init()) .collect::>(), ))))); let A1: Value>>> = Rc::new(RefCell::new(Some(Rc::new(RefCell::new( (0..((N / 2) as usize)) - .map(|_| ::default()) + .map(|_| ::zero_init()) .collect::>(), ))))); { @@ -175,7 +174,7 @@ fn main_0() -> i32 { let a: Value>>> = Rc::new(RefCell::new(Some(Rc::new(RefCell::new( (0..(N as usize)) - .map(|_| ::default()) + .map(|_| ::zero_init()) .collect::>(), ))))); { diff --git a/tests/unit/out/refcount/field_aliasing.rs b/tests/unit/out/refcount/field_aliasing.rs index 7e17c2ef68..deb009dcd0 100644 --- a/tests/unit/out/refcount/field_aliasing.rs +++ b/tests/unit/out/refcount/field_aliasing.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(8)] pub struct In { @@ -49,18 +48,6 @@ pub struct S { #[array_len(4)] pub arr: Box<[i32]>, } -impl Default for S { - fn default() -> Self { - { - S { - in_: ::default(), - total: 0_i32, - n: 0_i32, - arr: (0..4).map(|_| 0_i32).collect::>(), - } - } - } -} #[derive( Clone, Record, @@ -70,7 +57,6 @@ impl Default for S { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(16)] pub struct Node { @@ -105,7 +91,7 @@ fn main_0() -> i32 { && (q.with(|__s| __s.n) == 1)) ); libcc2rs::free_refcount((p).to_any()); - let s: Value = >::default(); + let s: Value = { >::zero_init() }; (*s.borrow_mut()).x = 1; (*s.borrow_mut()).self_ = (s.as_pointer()); field!({ (*s.borrow()).self_.clone() }, x).write(({ (*s.borrow()).x } + 1)); diff --git a/tests/unit/out/refcount/field_array_elem_ptr.rs b/tests/unit/out/refcount/field_array_elem_ptr.rs index 586d4d520c..2ff59f3454 100644 --- a/tests/unit/out/refcount/field_array_elem_ptr.rs +++ b/tests/unit/out/refcount/field_array_elem_ptr.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -54,18 +53,6 @@ pub struct Shape { #[offset(44)] pub tail: i32, } -impl Default for Shape { - fn default() -> Self { - { - Shape { - id: 0_i32, - coords: (0..4).map(|_| 0_i32).collect::>(), - points: (0..3).map(|_| ::default()).collect::>(), - tail: 0_i32, - } - } - } -} pub fn sum_0(mut p: Ptr, mut n: i32) -> i32 { let mut s: i32 = 0; { diff --git a/tests/unit/out/refcount/field_pointers_malloced_struct.rs b/tests/unit/out/refcount/field_pointers_malloced_struct.rs index 6fd9214c78..ab042a58f2 100644 --- a/tests/unit/out/refcount/field_pointers_malloced_struct.rs +++ b/tests/unit/out/refcount/field_pointers_malloced_struct.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/field_reinterpret_write_through.rs b/tests/unit/out/refcount/field_reinterpret_write_through.rs index d4a33fd864..1023f7501f 100644 --- a/tests/unit/out/refcount/field_reinterpret_write_through.rs +++ b/tests/unit/out/refcount/field_reinterpret_write_through.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(8)] pub struct In { @@ -53,19 +52,6 @@ pub struct S { #[offset(32)] pub tail: i64, } -impl Default for S { - fn default() -> Self { - { - S { - x: 0_i32, - in_: ::default(), - bytes: (0..4).map(|_| 0_u8).collect::>(), - arr: (0..3).map(|_| 0_i32).collect::>(), - tail: 0_i64, - } - } - } -} pub fn set_bytes_0(mut p: Ptr, mut n: usize, mut v: u8) { { let mut i: usize = 0_usize; @@ -1118,7 +1104,7 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let local: Value = >::default(); + let local: Value = { >::zero_init() }; { let mut __tmp_3 = { (local.as_pointer()).to_any() }; __tmp_3.memset((0) as u8, 40usize); @@ -1126,7 +1112,7 @@ fn main_0() -> i32 { }; ({ check_struct_3((local.as_pointer())) }); let arr: Value> = Rc::new(RefCell::new( - (0..2).map(|_| ::default()).collect::>(), + (0..2).map(|_| ::zero_init()).collect::>(), )); { let mut __tmp_4 = { (arr.decay()).to_any() }; diff --git a/tests/unit/out/refcount/find.rs b/tests/unit/out/refcount/find.rs index f665062c8d..f41771e569 100644 --- a/tests/unit/out/refcount/find.rs +++ b/tests/unit/out/refcount/find.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] 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 dedbeb550e..a42e743bc5 100644 --- a/tests/unit/out/refcount/first_field_ptr_covers_struct.rs +++ b/tests/unit/out/refcount/first_field_ptr_covers_struct.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(4)] pub struct In { @@ -35,7 +34,6 @@ pub struct In { FnPtrArg, TriviallyDefaultConstructible, 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 2ae2ba0ab5..3291c5a1f7 100644 --- a/tests/unit/out/refcount/first_member_downcast.rs +++ b/tests/unit/out/refcount/first_member_downcast.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(4)] pub struct base { @@ -33,7 +32,6 @@ pub struct base { FnPtrArg, TriviallyDefaultConstructible, 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 9cc982b938..a4a54cfc17 100644 --- a/tests/unit/out/refcount/flex_array_member_incomplete.rs +++ b/tests/unit/out/refcount/flex_array_member_incomplete.rs @@ -25,16 +25,6 @@ pub struct F { #[array_len(0)] pub tail: Box<[i8]>, } -impl Default for F { - fn default() -> Self { - { - F { - n: 0_i32, - tail: Box::<[i8]>::default(), - } - } - } -} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_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 6e100bd2cf..383410e180 100644 --- a/tests/unit/out/refcount/flex_array_member_sibling_write.rs +++ b/tests/unit/out/refcount/flex_array_member_sibling_write.rs @@ -25,16 +25,6 @@ pub struct S { #[array_len(1)] pub name: Box<[i8]>, } -impl Default for S { - fn default() -> Self { - { - S { - n: 0_i32, - name: (0..1).map(|_| 0_i8).collect::>(), - } - } - } -} #[derive( Copy, Clone, @@ -45,7 +35,6 @@ impl Default for S { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(8)] pub struct E { @@ -75,17 +64,6 @@ pub struct T { #[array_len(1)] pub a: Box<[E]>, } -impl Default for T { - fn default() -> Self { - { - T { - n: 0_i32, - cap: 0_i32, - a: (0..1).map(|_| ::default()).collect::>(), - } - } - } -} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); diff --git a/tests/unit/out/refcount/fn_ptr.rs b/tests/unit/out/refcount/fn_ptr.rs index de9aea0872..3c35d262d7 100644 --- a/tests/unit/out/refcount/fn_ptr.rs +++ b/tests/unit/out/refcount/fn_ptr.rs @@ -37,7 +37,6 @@ pub fn identity_hash_6(mut v: bool) -> usize { FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/fn_ptr_cast.rs b/tests/unit/out/refcount/fn_ptr_cast.rs index 6c7a6e4834..4b05e48407 100644 --- a/tests/unit/out/refcount/fn_ptr_cast.rs +++ b/tests/unit/out/refcount/fn_ptr_cast.rs @@ -33,7 +33,6 @@ pub fn test_double_cast_2() { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -44,7 +43,7 @@ pub struct Command { pub data: AnyPtr, } pub fn test_void_ptr_to_fn_3() { - let mut cmd: Command = ::default(); + let mut cmd: Command = { ::zero_init() }; cmd.data = FnPtr:: i32>::new(double_it_0).to_any(); let mut fn_: FnPtr i32> = cmd .data diff --git a/tests/unit/out/refcount/fn_ptr_stable_sort.rs b/tests/unit/out/refcount/fn_ptr_stable_sort.rs index 7e8ac3b925..c62a4de769 100644 --- a/tests/unit/out/refcount/fn_ptr_stable_sort.rs +++ b/tests/unit/out/refcount/fn_ptr_stable_sort.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/fn_ptr_struct.rs b/tests/unit/out/refcount/fn_ptr_struct.rs index 22c991bf97..5dee5fe351 100644 --- a/tests/unit/out/refcount/fn_ptr_struct.rs +++ b/tests/unit/out/refcount/fn_ptr_struct.rs @@ -15,7 +15,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -43,7 +42,6 @@ pub fn negate_1(mut x: i32) -> i32 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -60,9 +58,7 @@ impl S { return (x + 3); } } -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Default, Conversions, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Conversions)] #[conversions(move)] #[constructor(constructor_1, i32)] #[constructor(constructor_2, RvalueRef)] diff --git a/tests/unit/out/refcount/fn_ptr_typedef_cast.rs b/tests/unit/out/refcount/fn_ptr_typedef_cast.rs index ee141633e2..a22e5d3b7c 100644 --- a/tests/unit/out/refcount/fn_ptr_typedef_cast.rs +++ b/tests/unit/out/refcount/fn_ptr_typedef_cast.rs @@ -28,7 +28,6 @@ pub fn via_size_t_return_3(mut b: u64) -> usize { FnPtrArg, TriviallyDefaultConstructible, 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 3c29459b04..3b1db6e92e 100644 --- a/tests/unit/out/refcount/fn_ptr_vtable.rs +++ b/tests/unit/out/refcount/fn_ptr_vtable.rs @@ -15,7 +15,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/fn_ref.rs b/tests/unit/out/refcount/fn_ref.rs index d73522be9b..d0b70b3994 100644 --- a/tests/unit/out/refcount/fn_ref.rs +++ b/tests/unit/out/refcount/fn_ref.rs @@ -30,7 +30,6 @@ pub fn call_forwarded_4(f: FnPtr i32>, mut x: i32) -> i32 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs b/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs index ab3ac134d4..9949a008fb 100644 --- a/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs +++ b/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs @@ -17,7 +17,6 @@ use std::rc::{Rc, Weak}; Memberwise, CopyConstructible, Swappable, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(Conversions)] diff --git a/tests/unit/out/refcount/forward_basic.rs b/tests/unit/out/refcount/forward_basic.rs index 9102d7ef1b..d47055eed8 100644 --- a/tests/unit/out/refcount/forward_basic.rs +++ b/tests/unit/out/refcount/forward_basic.rs @@ -9,9 +9,7 @@ use std::rc::{Rc, Weak}; pub type Overload = u32; pub const Overload_kLvalueOverload: Overload = 1; pub const Overload_kRvalueOverload: Overload = 2; -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Default, Conversions, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Conversions)] #[conversions(copy, move)] #[constructor(constructor_1, i32)] #[constructor(constructor_2, LvalueRef>)] @@ -63,9 +61,7 @@ impl Holder { Tracked::constructor_3(field_ptr!(this, t), RvalueRef::bind((x).clone())); } } -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Memberwise, Default, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Memberwise)] #[memberwise(copy_constructor, move_constructor)] #[derive(Conversions)] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/forward_decltype.rs b/tests/unit/out/refcount/forward_decltype.rs index 75903e0673..3e04412069 100644 --- a/tests/unit/out/refcount/forward_decltype.rs +++ b/tests/unit/out/refcount/forward_decltype.rs @@ -9,9 +9,7 @@ use std::rc::{Rc, Weak}; pub type Overload = u32; pub const Overload_kLvalueOverload: Overload = 1; pub const Overload_kRvalueOverload: Overload = 2; -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Default, Conversions, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Conversions)] #[conversions(copy, move)] #[constructor(constructor_1, i32)] #[constructor(constructor_2, LvalueRef>)] diff --git a/tests/unit/out/refcount/forward_explicit.rs b/tests/unit/out/refcount/forward_explicit.rs index 3d55c011d1..cfb9a45fcb 100644 --- a/tests/unit/out/refcount/forward_explicit.rs +++ b/tests/unit/out/refcount/forward_explicit.rs @@ -11,9 +11,7 @@ pub const Overload_kLvalueOverload: Overload = 1; pub const Overload_kRvalueOverload: Overload = 2; pub const Overload_kIntLvalueOverload: Overload = 3; pub const Overload_kIntRvalueOverload: Overload = 4; -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Default, Conversions, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Conversions)] #[conversions(copy, move)] #[constructor(constructor_1, i32)] #[constructor(constructor_2, LvalueRef>)] diff --git a/tests/unit/out/refcount/forward_pack.rs b/tests/unit/out/refcount/forward_pack.rs index 83247cb240..1769f0d4d9 100644 --- a/tests/unit/out/refcount/forward_pack.rs +++ b/tests/unit/out/refcount/forward_pack.rs @@ -11,9 +11,7 @@ pub const Overload_kLvalueOverload: Overload = 1; pub const Overload_kRvalueOverload: Overload = 2; pub const Overload_kIntLvalueOverload: Overload = 3; pub const Overload_kIntRvalueOverload: Overload = 4; -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Default, Conversions, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Conversions)] #[conversions(copy, move)] #[constructor(constructor_1, i32)] #[constructor(constructor_2, LvalueRef>)] @@ -103,9 +101,7 @@ impl Pair { Tracked::constructor_3(field_ptr!(this, b), RvalueRef::bind((y).clone())); } } -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Memberwise, Default, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Memberwise)] #[memberwise(copy_constructor, move_constructor)] #[derive(Conversions)] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/friend.rs b/tests/unit/out/refcount/friend.rs index b2098a0d9d..ef3b10911f 100644 --- a/tests/unit/out/refcount/friend.rs +++ b/tests/unit/out/refcount/friend.rs @@ -25,7 +25,6 @@ pub fn scaled_2(v: Ptr, mut k: f64) -> f64 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -47,7 +46,6 @@ pub fn get_3(w: Ptr) -> i32 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -69,7 +67,6 @@ pub fn get_4(w: Ptr) -> i64 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -88,7 +85,6 @@ pub struct W_long_ { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/function_overloading.rs b/tests/unit/out/refcount/function_overloading.rs index 60a3a5951d..3fcf08ec27 100644 --- a/tests/unit/out/refcount/function_overloading.rs +++ b/tests/unit/out/refcount/function_overloading.rs @@ -31,7 +31,6 @@ pub fn bar_4(x: Ptr) -> i32 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -65,8 +64,8 @@ fn main_0() -> i32 { out += ({ foo_2((x.as_pointer()), (x.as_pointer())) }); let mut bar: i32 = 5; out += ((bar + ({ foo_0(0) })) + ({ foo_1((x.as_pointer())) })); - let foo1: Value = Rc::new(RefCell::new(::default())); - let foo2: Value = Rc::new(RefCell::new(::default())); + let foo1: Value = Rc::new(RefCell::new({ ::zero_init() })); + let foo2: Value = Rc::new(RefCell::new({ ::zero_init() })); ({ Foo::foo_2(foo1.as_pointer()) }); ({ Foo::method_3(foo1.as_pointer(), 1) }); ({ Foo::foo_1(foo2.as_pointer()) }); diff --git a/tests/unit/out/refcount/global_call_temporaries.rs b/tests/unit/out/refcount/global_call_temporaries.rs index 91d788b618..ccd29a7917 100644 --- a/tests/unit/out/refcount/global_call_temporaries.rs +++ b/tests/unit/out/refcount/global_call_temporaries.rs @@ -113,7 +113,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/global_init_side_effect.rs b/tests/unit/out/refcount/global_init_side_effect.rs index f1f34df9ee..ab093d44c9 100644 --- a/tests/unit/out/refcount/global_init_side_effect.rs +++ b/tests/unit/out/refcount/global_init_side_effect.rs @@ -19,7 +19,6 @@ thread_local!( FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/global_non_const_init.rs b/tests/unit/out/refcount/global_non_const_init.rs index 3e989d0e15..1e2d2eed92 100644 --- a/tests/unit/out/refcount/global_non_const_init.rs +++ b/tests/unit/out/refcount/global_non_const_init.rs @@ -59,17 +59,6 @@ impl Ctor { field!(this, v).write(x); } } -impl Default for Ctor { - fn default() -> Self { - { - { - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - Ctor::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} thread_local!( pub static default_ctor_7: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); @@ -108,7 +97,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -156,17 +144,6 @@ impl Singleton { return s_15.with(|v| v.as_pointer()); } } -impl Default for Singleton { - fn default() -> Self { - { - { - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - Singleton::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} thread_local!( static s_15: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); diff --git a/tests/unit/out/refcount/global_pointers.rs b/tests/unit/out/refcount/global_pointers.rs index 72794e1869..bf5cfd24b0 100644 --- a/tests/unit/out/refcount/global_pointers.rs +++ b/tests/unit/out/refcount/global_pointers.rs @@ -15,7 +15,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/global_without_initializer.rs b/tests/unit/out/refcount/global_without_initializer.rs index 5368ea07f3..9581a3fb13 100644 --- a/tests/unit/out/refcount/global_without_initializer.rs +++ b/tests/unit/out/refcount/global_without_initializer.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/goto_aggregate_default.rs b/tests/unit/out/refcount/goto_aggregate_default.rs index e42b37f3b9..2801750a74 100644 --- a/tests/unit/out/refcount/goto_aggregate_default.rs +++ b/tests/unit/out/refcount/goto_aggregate_default.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(8)] pub struct Point { @@ -30,7 +29,7 @@ pub fn agg_0(mut n: i32) -> i32 { let mut buf256: [u8; 256] = [0_u8; 256]; let mut arr64: [i32; 64] = [0_i32; 64]; let mut longs: [i64; 33] = [0_i64; 33]; - let mut p: Point = ::default(); + let mut p: Point = { ::zero_init() }; let mut ptr: Ptr = Ptr::::null(); let mut fp: FnPtr i32> = FnPtr:: i32>::null(); let mut file: Ptr = Ptr::null(); diff --git a/tests/unit/out/refcount/goto_cleanup.rs b/tests/unit/out/refcount/goto_cleanup.rs index 72d277e6a2..297f4de95c 100644 --- a/tests/unit/out/refcount/goto_cleanup.rs +++ b/tests/unit/out/refcount/goto_cleanup.rs @@ -85,7 +85,6 @@ pub fn from_switch_2(mut n: i32) -> i32 { FnPtrArg, TriviallyDefaultConstructible, 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 22b3208ef7..906d75d481 100644 --- a/tests/unit/out/refcount/huffman.rs +++ b/tests/unit/out/refcount/huffman.rs @@ -15,7 +15,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -58,9 +57,7 @@ pub fn Swap_0(a: Ptr, b: Ptr) { right: (t.right).clone(), }); } -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Swappable, Default, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Swappable)] #[memberwise(move_constructor, move_assign)] #[derive(Conversions)] #[conversions(move)] @@ -259,7 +256,7 @@ pub fn AllocMinHeap_1(mut capacity: i32) -> Option> { next: 0, alloc: Some(Rc::new(RefCell::new( (0..10000_usize) - .map(|_| ::default()) + .map(|_| ::zero_init()) .collect::>(), ))), }))); 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 b5e695214e..c1dc46cb1f 100644 --- a/tests/unit/out/refcount/immutable-deref-on-func-call.rs +++ b/tests/unit/out/refcount/immutable-deref-on-func-call.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -37,7 +36,7 @@ pub fn main() { fn main_0() -> i32 { let mut arr: Ptr = Ptr::alloc_array( (0..2_usize) - .map(|_| ::default()) + .map(|_| ::zero_init()) .collect::>(), ); field!(elem!(arr, 0), value).write(1); diff --git a/tests/unit/out/refcount/implicit_autoref.rs b/tests/unit/out/refcount/implicit_autoref.rs index f30d5b13c8..b1ca3a62fd 100644 --- a/tests/unit/out/refcount/implicit_autoref.rs +++ b/tests/unit/out/refcount/implicit_autoref.rs @@ -17,7 +17,6 @@ use std::rc::{Rc, Weak}; Memberwise, CopyConstructible, Swappable, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(Conversions)] diff --git a/tests/unit/out/refcount/init.rs b/tests/unit/out/refcount/init.rs index 89b82c13f4..e1c115c9ce 100644 --- a/tests/unit/out/refcount/init.rs +++ b/tests/unit/out/refcount/init.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -38,7 +37,7 @@ fn main_0() -> i32 { let g: Ptr = x.as_pointer(); let mut q: Ptr = (x.as_pointer()); let mut z: Ptr = (p).clone(); - let xx: Value = Rc::new(RefCell::new(::default())); + let xx: Value = Rc::new(RefCell::new({ ::zero_init() })); let mut zz: Ptr = (xx.as_pointer()); (*xx.borrow_mut()).x = 1; q = (field_ptr!(xx.as_pointer(), x)); diff --git a/tests/unit/out/refcount/kruskal.rs b/tests/unit/out/refcount/kruskal.rs index 0c2b885a5c..0c9565c60c 100644 --- a/tests/unit/out/refcount/kruskal.rs +++ b/tests/unit/out/refcount/kruskal.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -112,9 +111,7 @@ pub fn quicksort_1(arr: Ptr>>>, mut start: i32, mut end ({ quicksort_1((arr).clone(), start, (p - 1)) }); ({ quicksort_1((arr).clone(), (p + 1), end) }); } -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Swappable, Default, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Swappable)] #[memberwise(move_constructor, move_assign)] #[derive(Conversions)] #[conversions(move)] @@ -238,9 +235,7 @@ impl DisjointSet { field!(this, n).write(0_i32); } } -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Swappable, Default, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Swappable)] #[memberwise(move_constructor, move_assign)] #[derive(Conversions)] #[conversions(move)] @@ -320,7 +315,7 @@ fn main_0() -> i32 { let graph: Value = Rc::new(RefCell::new(Graph { edges: Some(Rc::new(RefCell::new( (0..(E as usize)) - .map(|_| ::default()) + .map(|_| ::zero_init()) .collect::>(), ))), V: V, diff --git a/tests/unit/out/refcount/lambda_as_field.rs b/tests/unit/out/refcount/lambda_as_field.rs index 55c942e682..a967cd5079 100644 --- a/tests/unit/out/refcount/lambda_as_field.rs +++ b/tests/unit/out/refcount/lambda_as_field.rs @@ -81,20 +81,6 @@ impl Holder__lambda_at_lambda_as_field_cpp_39_12__ { return ({ (*this.upgrade().deref()).f.call(x) }); } } -impl Default for Holder__lambda_at_lambda_as_field_cpp_39_12__ { - fn default() -> Self { - { - Holder__lambda_at_lambda_as_field_cpp_39_12__ { - f: FnPtr:: i32>::new(|mut x: i32| -> i32 { - { - return (x + 1); - } - }), - calls: 0_i32, - } - } - } -} #[derive( Clone, Record, @@ -104,7 +90,6 @@ impl Default for Holder__lambda_at_lambda_as_field_cpp_39_12__ { FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -148,11 +133,6 @@ impl Moving__lambda_at_lambda_as_field_cpp_64_12__ { field!(this, moves).write((o.with(|__s| __s.moves) + 1)); } } -impl Default for Moving__lambda_at_lambda_as_field_cpp_64_12__ { - fn default() -> Self { - { ::zero_init() } - } -} pub fn wrap_0(fn_: FnPtr i32>) -> FnPtr i32> { let fn_: Value i32>> = Rc::new(RefCell::new(fn_)); return lambda!( diff --git a/tests/unit/out/refcount/lambda_capture_copy_ctor.rs b/tests/unit/out/refcount/lambda_capture_copy_ctor.rs index 8fc8d569db..82ce0d709d 100644 --- a/tests/unit/out/refcount/lambda_capture_copy_ctor.rs +++ b/tests/unit/out/refcount/lambda_capture_copy_ctor.rs @@ -34,17 +34,6 @@ impl Counted { field!(this, moves).write((o.with(|__s| __s.moves) + 1)); } } -impl Default for Counted { - fn default() -> Self { - { - { - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - Counted::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} thread_local!( pub static drops_0: Value = Rc::new(RefCell::new(0)); ); diff --git a/tests/unit/out/refcount/lambda_capture_ref.rs b/tests/unit/out/refcount/lambda_capture_ref.rs index 6a13250210..97d230b176 100644 --- a/tests/unit/out/refcount/lambda_capture_ref.rs +++ b/tests/unit/out/refcount/lambda_capture_ref.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/lambda_capture_star_this.rs b/tests/unit/out/refcount/lambda_capture_star_this.rs index 5f0cc56787..8402f8fe78 100644 --- a/tests/unit/out/refcount/lambda_capture_star_this.rs +++ b/tests/unit/out/refcount/lambda_capture_star_this.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/lambda_capture_this.rs b/tests/unit/out/refcount/lambda_capture_this.rs index 44e5c89ccd..c559455ffa 100644 --- a/tests/unit/out/refcount/lambda_capture_this.rs +++ b/tests/unit/out/refcount/lambda_capture_this.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/lambda_capture_value.rs b/tests/unit/out/refcount/lambda_capture_value.rs index b0a6c97a82..3a348bd34c 100644 --- a/tests/unit/out/refcount/lambda_capture_value.rs +++ b/tests/unit/out/refcount/lambda_capture_value.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/lambda_decltype_type.rs b/tests/unit/out/refcount/lambda_decltype_type.rs index 8ff9412094..10f312efff 100644 --- a/tests/unit/out/refcount/lambda_decltype_type.rs +++ b/tests/unit/out/refcount/lambda_decltype_type.rs @@ -51,21 +51,6 @@ impl Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { )); } } -impl Default for Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { - fn default() -> Self { - { - Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { - items: (0..4).map(|_| 0_i32).collect::>(), - size: 0, - cmp: FnPtr:: bool>::new(|mut a: i32, mut b: i32| -> bool { - { - return (a > b); - } - }), - } - } - } -} #[derive( Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Conversions, )] @@ -111,21 +96,6 @@ impl Sorted__lambda_at_lambda_decltype_type_cpp_19_23__ { )); } } -impl Default for Sorted__lambda_at_lambda_decltype_type_cpp_19_23__ { - fn default() -> Self { - { - Sorted__lambda_at_lambda_decltype_type_cpp_19_23__ { - items: (0..4).map(|_| 0_i32).collect::>(), - size: 0, - cmp: FnPtr:: bool>::new(|mut a: i32, mut b: i32| -> bool { - { - return (a < b); - } - }), - } - } - } -} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); diff --git a/tests/unit/out/refcount/lambda_generic_explicit_args.rs b/tests/unit/out/refcount/lambda_generic_explicit_args.rs index 5d81e380fc..f3c5bb8648 100644 --- a/tests/unit/out/refcount/lambda_generic_explicit_args.rs +++ b/tests/unit/out/refcount/lambda_generic_explicit_args.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/lambda_immediate_init.rs b/tests/unit/out/refcount/lambda_immediate_init.rs index 45d71a6fd0..8a185bc1af 100644 --- a/tests/unit/out/refcount/lambda_immediate_init.rs +++ b/tests/unit/out/refcount/lambda_immediate_init.rs @@ -44,23 +44,6 @@ impl S { ); } } -impl Default for S { - fn default() -> Self { - { - S { - j: 10, - k: (({ - FnPtr:: i32>::new(|| -> i32 { - { - return 3; - } - }) - .call() - }) + 1), - } - } - } -} thread_local!( pub static g_1: Value = Rc::new(RefCell::new( ({ diff --git a/tests/unit/out/refcount/lambda_nested.rs b/tests/unit/out/refcount/lambda_nested.rs index c10784772e..50183168d1 100644 --- a/tests/unit/out/refcount/lambda_nested.rs +++ b/tests/unit/out/refcount/lambda_nested.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/lambda_static_local.rs b/tests/unit/out/refcount/lambda_static_local.rs index 32edd6b930..e2ab3f0fed 100644 --- a/tests/unit/out/refcount/lambda_static_local.rs +++ b/tests/unit/out/refcount/lambda_static_local.rs @@ -88,7 +88,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/libc_struct_without_default.rs b/tests/unit/out/refcount/libc_struct_without_default.rs index cbe1a2dcb5..9bc59a7434 100644 --- a/tests/unit/out/refcount/libc_struct_without_default.rs +++ b/tests/unit/out/refcount/libc_struct_without_default.rs @@ -40,16 +40,6 @@ impl UserDefined { field!(this, v).write(Vec::new()); } } -impl Default for UserDefined { - fn default() -> Self { - { - UserDefined { - a: Box::<[i32]>::from(std::array::from_fn::<_, 1, _>(|_| 0_i32)), - v: Default::default(), - } - } - } -} #[derive( Clone, Record, @@ -68,15 +58,6 @@ pub struct FieldIsLibcType { #[byte_size(16)] pub addr: libcc2rs::Sockaddr, } -impl Default for FieldIsLibcType { - fn default() -> Self { - { - FieldIsLibcType { - addr: Default::default(), - } - } - } -} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); @@ -106,7 +87,7 @@ fn main_0() -> i32 { 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) })); - let mut filt: FieldIsLibcType = ::default(); + let mut filt: FieldIsLibcType = { ::zero_init() }; filt.addr.sa_family = 2_u16; assert!(((filt.addr.sa_family as i32) == 2)); return 0; diff --git a/tests/unit/out/refcount/linked_list.rs b/tests/unit/out/refcount/linked_list.rs index 14eb33d736..bc50932410 100644 --- a/tests/unit/out/refcount/linked_list.rs +++ b/tests/unit/out/refcount/linked_list.rs @@ -15,7 +15,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/local_anon_struct_collision.rs b/tests/unit/out/refcount/local_anon_struct_collision.rs index 54d8b3a425..9f7cd960e3 100644 --- a/tests/unit/out/refcount/local_anon_struct_collision.rs +++ b/tests/unit/out/refcount/local_anon_struct_collision.rs @@ -7,7 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn first_0() -> i32 { - let mut p: anon_1 = ::default(); + let mut p: anon_1 = { ::zero_init() }; p.x = 1; p.y = 2; return (p.x + p.y); @@ -22,7 +22,6 @@ pub fn first_0() -> i32 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(8)] pub struct anon_1 { @@ -32,7 +31,7 @@ pub struct anon_1 { pub y: i32, } pub fn second_2() -> i32 { - let mut q: anon_3 = ::default(); + let mut q: anon_3 = { ::zero_init() }; q.a = 10_i64; q.b = 20_i64; return ((q.a + q.b) as i32); @@ -47,7 +46,6 @@ pub fn second_2() -> i32 { FnPtrArg, TriviallyDefaultConstructible, 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 2b72bcbf2f..f9764429ec 100644 --- a/tests/unit/out/refcount/local_record_template.rs +++ b/tests/unit/out/refcount/local_record_template.rs @@ -39,7 +39,6 @@ pub fn wrap_10(mut v: i64) -> i32 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -58,7 +57,6 @@ pub struct Local_5 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -81,7 +79,6 @@ pub fn other_11() -> i32 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -115,7 +112,6 @@ fn main_0() -> i32 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/map_key_copy_ctor.rs b/tests/unit/out/refcount/map_key_copy_ctor.rs index c8c3306cea..b228f0378c 100644 --- a/tests/unit/out/refcount/map_key_copy_ctor.rs +++ b/tests/unit/out/refcount/map_key_copy_ctor.rs @@ -15,9 +15,7 @@ thread_local!( thread_local!( pub static made_2: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Default, Conversions, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Conversions)] #[conversions(copy, move)] #[constructor(constructor_1, i32)] #[constructor(constructor_2, LvalueRef>)] diff --git a/tests/unit/out/refcount/map_try_emplace.rs b/tests/unit/out/refcount/map_try_emplace.rs index 9d4c95638a..2b13f14ee1 100644 --- a/tests/unit/out/refcount/map_try_emplace.rs +++ b/tests/unit/out/refcount/map_try_emplace.rs @@ -49,17 +49,6 @@ impl Item { field!(other, value).write(-1_i32); } } -impl Default for Item { - fn default() -> Self { - { - { - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - Item::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} pub fn argument_4(item: Ptr) -> Ptr { (*calls_0.with(Value::clone).borrow_mut()).prefix_inc(); return (item).clone(); @@ -98,17 +87,6 @@ impl RefItem { (*made_1.with(Value::clone).borrow_mut()).prefix_inc(); } } -impl Default for RefItem { - fn default() -> Self { - { - { - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - RefItem::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} pub fn reference_5(counter: Ptr) -> Ptr { (*calls_0.with(Value::clone).borrow_mut()).prefix_inc(); return (counter).clone(); diff --git a/tests/unit/out/refcount/max.rs b/tests/unit/out/refcount/max.rs index 754e499b86..a1e7e29170 100644 --- a/tests/unit/out/refcount/max.rs +++ b/tests/unit/out/refcount/max.rs @@ -30,7 +30,6 @@ pub fn pick_3(mut i: i32) -> Ptr { MoveConstructible, MoveAssignable, Swappable, - Default, )] #[memberwise(copy_assign)] #[derive(Conversions)] diff --git a/tests/unit/out/refcount/memcpy_struct_bytes.rs b/tests/unit/out/refcount/memcpy_struct_bytes.rs index f4bfdf8820..3195e30f26 100644 --- a/tests/unit/out/refcount/memcpy_struct_bytes.rs +++ b/tests/unit/out/refcount/memcpy_struct_bytes.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(8)] pub struct point { @@ -40,7 +39,7 @@ fn main_0() -> i32 { ); (__tmp_0).clone() }; - let dst: Value = >::default(); + let dst: Value = { >::zero_init() }; { let mut __tmp_1 = { (dst.as_pointer()).to_any() }; __tmp_1.memcpy(&(buf.decay()).to_any(), 8usize); diff --git a/tests/unit/out/refcount/memcpy_struct_layouts.rs b/tests/unit/out/refcount/memcpy_struct_layouts.rs index 79f7c8cd1a..532e8aef04 100644 --- a/tests/unit/out/refcount/memcpy_struct_layouts.rs +++ b/tests/unit/out/refcount/memcpy_struct_layouts.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(8)] pub struct packed { @@ -39,7 +38,6 @@ pub struct packed { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(12)] pub struct reordered { @@ -60,7 +58,6 @@ pub struct reordered { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(16)] pub struct tail { @@ -79,7 +76,6 @@ pub struct tail { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(24)] pub struct nested { @@ -108,16 +104,6 @@ pub struct array { #[offset(4)] pub x: i32, } -impl Default for array { - fn default() -> Self { - { - array { - name: (0..3).map(|_| 0_i8).collect::>(), - x: 0_i32, - } - } - } -} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); @@ -148,7 +134,7 @@ fn main_0() -> i32 { ); let p2: Value> = Rc::new(RefCell::new( (0..2) - .map(|_| ::default()) + .map(|_| ::zero_init()) .collect::>(), )); { @@ -184,7 +170,7 @@ fn main_0() -> i32 { ); let r2: Value> = Rc::new(RefCell::new( (0..2) - .map(|_| ::default()) + .map(|_| ::zero_init()) .collect::>(), )); { @@ -223,7 +209,7 @@ fn main_0() -> i32 { ); let n2: Value> = Rc::new(RefCell::new( (0..2) - .map(|_| ::default()) + .map(|_| ::zero_init()) .collect::>(), )); { @@ -258,7 +244,9 @@ fn main_0() -> i32 { }) ); let a2: Value> = Rc::new(RefCell::new( - (0..2).map(|_| ::default()).collect::>(), + (0..2) + .map(|_| ::zero_init()) + .collect::>(), )); { let mut __tmp_7 = { (a2.decay()).to_any() }; diff --git a/tests/unit/out/refcount/memcpy_struct_struct.rs b/tests/unit/out/refcount/memcpy_struct_struct.rs index 9481df496d..448a83e2bf 100644 --- a/tests/unit/out/refcount/memcpy_struct_struct.rs +++ b/tests/unit/out/refcount/memcpy_struct_struct.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/memset_struct_tail.rs b/tests/unit/out/refcount/memset_struct_tail.rs index 9debd268ff..f869742279 100644 --- a/tests/unit/out/refcount/memset_struct_tail.rs +++ b/tests/unit/out/refcount/memset_struct_tail.rs @@ -31,19 +31,6 @@ pub struct S { #[offset(24)] pub last: i32, } -impl Default for S { - fn default() -> Self { - { - S { - keep: 0_i32, - a: 0_i32, - b: 0_i64, - c: (0..5).map(|_| 0_i8).collect::>(), - last: 0_i32, - } - } - } -} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); diff --git a/tests/unit/out/refcount/move_assign.rs b/tests/unit/out/refcount/move_assign.rs index b091e740be..cccda90354 100644 --- a/tests/unit/out/refcount/move_assign.rs +++ b/tests/unit/out/refcount/move_assign.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, - DefaultInitializable, - Swappable, - Default, - Conversions, + Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Swappable, Conversions, )] #[conversions(move)] #[constructor(constructor_1, i32)] @@ -65,18 +58,6 @@ impl ConstMoveAssign { return (this).clone(); } } -impl Default for ConstMoveAssign { - fn default() -> Self { - { - { - let __v: Value = - Rc::new(RefCell::new(ZeroInitialization::zero_init())); - ConstMoveAssign::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} pub fn make_0(__return: Ptr, mut v: i32) { object!(m, MoveOnly::constructor_1(v)); MoveOnly::constructor_3(__return.clone(), RvalueRef::bind(m.as_pointer())); diff --git a/tests/unit/out/refcount/move_ctor.rs b/tests/unit/out/refcount/move_ctor.rs index d1b1faf1c4..99dedef373 100644 --- a/tests/unit/out/refcount/move_ctor.rs +++ b/tests/unit/out/refcount/move_ctor.rs @@ -6,9 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Default, Conversions, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Conversions)] #[conversions(move)] #[constructor(constructor_1, i32)] #[constructor(constructor_3, RvalueRef)] @@ -50,20 +48,7 @@ impl ConstMove { field!(this, mark).write((o.with(|__s| __s.mark) + 10)); } } -impl Default for ConstMove { - fn default() -> Self { - { - { - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - ConstMove::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Default, Conversions, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Conversions)] #[conversions(copy, move)] #[constructor(constructor_1, i32)] #[constructor(constructor_2, LvalueRef>)] @@ -97,9 +82,7 @@ impl ThrowingMove { field!(o, v).write(0); } } -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Default, Conversions, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Conversions)] #[conversions(copy, move)] #[constructor(constructor_1, i32)] #[constructor(constructor_2, LvalueRef>)] diff --git a/tests/unit/out/refcount/move_this.rs b/tests/unit/out/refcount/move_this.rs index a3f1965027..ba6056f2f2 100644 --- a/tests/unit/out/refcount/move_this.rs +++ b/tests/unit/out/refcount/move_this.rs @@ -6,9 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Default, Conversions, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Conversions)] #[conversions(copy, move)] #[constructor(constructor_1, i32)] #[constructor(constructor_2, LvalueRef>)] diff --git a/tests/unit/out/refcount/nested_structs.rs b/tests/unit/out/refcount/nested_structs.rs index ba856f8057..f1b873d673 100644 --- a/tests/unit/out/refcount/nested_structs.rs +++ b/tests/unit/out/refcount/nested_structs.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -35,7 +34,6 @@ pub struct Level0_Level1_1_Level2_1_Level3_1 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -56,7 +54,6 @@ pub struct Level0_Level1_1_Level2_1_Level3_2 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -75,7 +72,6 @@ pub struct Level0_Level1_1_Level2_1 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -94,7 +90,6 @@ pub struct Level0_Level1_1 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -115,7 +110,6 @@ pub struct Level0_Level1_2 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/new.rs b/tests/unit/out/refcount/new.rs index 70b58d0ede..ff2b8a6bd3 100644 --- a/tests/unit/out/refcount/new.rs +++ b/tests/unit/out/refcount/new.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -40,7 +39,7 @@ fn main_0() -> i32 { y.write(9); assert!(((y.read()) == 9)); y.delete(); - let mut p: Ptr = Ptr::alloc(::default()); + let mut p: Ptr = Ptr::alloc({ ::zero_init() }); field!(p, x).write(1); field!(p, y).write(2); assert!((({ p.with(|__s| __s.x) } + { p.with(|__s| __s.y) }) == 3)); diff --git a/tests/unit/out/refcount/new_bst.rs b/tests/unit/out/refcount/new_bst.rs index 912c97f12f..641a161204 100644 --- a/tests/unit/out/refcount/new_bst.rs +++ b/tests/unit/out/refcount/new_bst.rs @@ -15,7 +15,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/new_struct.rs b/tests/unit/out/refcount/new_struct.rs index 500d0aa66f..8d91ce9e8d 100644 --- a/tests/unit/out/refcount/new_struct.rs +++ b/tests/unit/out/refcount/new_struct.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -37,7 +36,6 @@ pub struct Pair { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -63,7 +61,7 @@ fn main_0() -> i32 { let mut t: Triple = Triple { a: 1, b: 0_i32, - p: ::default(), + p: { ::zero_init() }, }; assert!((t.a == 1)); assert!((t.b == 0)); @@ -71,7 +69,7 @@ fn main_0() -> i32 { let mut q: Ptr = Ptr::alloc(Triple { a: 2, b: 3, - p: ::default(), + p: { ::zero_init() }, }); assert!((q.with(|__s| __s.a) == 2)); assert!((q.with(|__s| __s.b) == 3)); diff --git a/tests/unit/out/refcount/nttp_distinct_specializations.rs b/tests/unit/out/refcount/nttp_distinct_specializations.rs index 0aff173c99..b3c2c6a327 100644 --- a/tests/unit/out/refcount/nttp_distinct_specializations.rs +++ b/tests/unit/out/refcount/nttp_distinct_specializations.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -42,7 +41,6 @@ impl S_2_ { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -66,7 +64,6 @@ impl S_1_ { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/offsetof.rs b/tests/unit/out/refcount/offsetof.rs index a3be2b5e09..d4ef992d55 100644 --- a/tests/unit/out/refcount/offsetof.rs +++ b/tests/unit/out/refcount/offsetof.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -50,16 +49,6 @@ pub struct Frame { #[array_len(64)] pub body: Box<[i8]>, } -impl Default for Frame { - fn default() -> Self { - { - Frame { - tag: 0_u16, - body: (0..64).map(|_| 0_i8).collect::>(), - } - } - } -} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); diff --git a/tests/unit/out/refcount/opaque_forward_decl.rs b/tests/unit/out/refcount/opaque_forward_decl.rs index c253a00c35..a10e21a25a 100644 --- a/tests/unit/out/refcount/opaque_forward_decl.rs +++ b/tests/unit/out/refcount/opaque_forward_decl.rs @@ -15,7 +15,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, 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 dd60c43296..e24ea35975 100644 --- a/tests/unit/out/refcount/opaque_record_copy.rs +++ b/tests/unit/out/refcount/opaque_record_copy.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -32,7 +31,6 @@ pub struct Probe {} FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -49,7 +47,7 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let mut a: Wrapper_Probe_ = ::default(); + let mut a: Wrapper_Probe_ = { ::zero_init() }; a.tag = 3; let mut b: Wrapper_Probe_ = a; assert!((b.tag == 3)); diff --git a/tests/unit/out/refcount/opaque_then_defined.rs b/tests/unit/out/refcount/opaque_then_defined.rs index 6d8dc545f9..c3a2d644b9 100644 --- a/tests/unit/out/refcount/opaque_then_defined.rs +++ b/tests/unit/out/refcount/opaque_then_defined.rs @@ -15,7 +15,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(16)] pub struct list { @@ -34,7 +33,6 @@ pub struct list { FnPtrArg, TriviallyDefaultConstructible, 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 fbfe6b0329..2e55f348ab 100644 --- a/tests/unit/out/refcount/operator_arithmetic_free.rs +++ b/tests/unit/out/refcount/operator_arithmetic_free.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/operator_arithmetic_member.rs b/tests/unit/out/refcount/operator_arithmetic_member.rs index 8b8915f4cb..4e345c2220 100644 --- a/tests/unit/out/refcount/operator_arithmetic_member.rs +++ b/tests/unit/out/refcount/operator_arithmetic_member.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/operator_bitwise_free.rs b/tests/unit/out/refcount/operator_bitwise_free.rs index 27a0128cfa..3581534ced 100644 --- a/tests/unit/out/refcount/operator_bitwise_free.rs +++ b/tests/unit/out/refcount/operator_bitwise_free.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/operator_bitwise_member.rs b/tests/unit/out/refcount/operator_bitwise_member.rs index b2177ac0fb..8c74256471 100644 --- a/tests/unit/out/refcount/operator_bitwise_member.rs +++ b/tests/unit/out/refcount/operator_bitwise_member.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/operator_comparison_defaulted.rs b/tests/unit/out/refcount/operator_comparison_defaulted.rs index 5a2c77a088..d4d1a4cd70 100644 --- a/tests/unit/out/refcount/operator_comparison_defaulted.rs +++ b/tests/unit/out/refcount/operator_comparison_defaulted.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -37,7 +36,6 @@ pub struct Eq { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, PartiallyOrderedWith, )] #[three_way(ThreeWayComparable::three_way)] @@ -89,7 +87,6 @@ impl LessThanComparable for Cmp { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, PartiallyOrderedWith, )] #[three_way(ThreeWayComparable::three_way)] @@ -130,7 +127,6 @@ impl LessThanComparable for Both { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, PartiallyOrderedWith, )] #[three_way(OrdOnly::operator_cmp)] @@ -170,7 +166,6 @@ impl LessThanComparable for OrdOnly { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, PartiallyOrderedWith, )] #[three_way(ThreeWayComparable::three_way)] @@ -211,7 +206,6 @@ impl LessThanComparable for Inner { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, PartiallyOrderedWith, )] #[three_way(ThreeWayComparable::three_way)] @@ -263,7 +257,6 @@ impl LessThanComparable for Outer { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -301,7 +294,6 @@ impl LessThanComparable for Secondary { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, PartiallyOrderedWith, )] #[three_way(ThreeWayComparable::three_way)] diff --git a/tests/unit/out/refcount/operator_comparison_free.rs b/tests/unit/out/refcount/operator_comparison_free.rs index 8601f21645..8ff3420b92 100644 --- a/tests/unit/out/refcount/operator_comparison_free.rs +++ b/tests/unit/out/refcount/operator_comparison_free.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -46,7 +45,6 @@ pub fn operator_lt_1(mut a: i32, b: Ptr) -> bool { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/operator_comparison_member.rs b/tests/unit/out/refcount/operator_comparison_member.rs index acadd8cc62..7183aa9e73 100644 --- a/tests/unit/out/refcount/operator_comparison_member.rs +++ b/tests/unit/out/refcount/operator_comparison_member.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/operator_comparison_mixed.rs b/tests/unit/out/refcount/operator_comparison_mixed.rs index 76333aa36a..d5387bb116 100644 --- a/tests/unit/out/refcount/operator_comparison_mixed.rs +++ b/tests/unit/out/refcount/operator_comparison_mixed.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/operator_comparison_nonbool.rs b/tests/unit/out/refcount/operator_comparison_nonbool.rs index fe5d82ba36..6549c0c2f9 100644 --- a/tests/unit/out/refcount/operator_comparison_nonbool.rs +++ b/tests/unit/out/refcount/operator_comparison_nonbool.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -58,7 +57,6 @@ pub fn operator_ge_3(mut a: X, mut b: X) -> i32 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -77,7 +75,6 @@ pub struct Result { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -103,7 +100,6 @@ impl Custom { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -148,7 +144,6 @@ impl LessThanComparable for Mixed { FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -177,7 +172,6 @@ impl MyBool { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -209,14 +203,7 @@ pub fn operator_lt_6(mut a: Boolish, mut b: Boolish) -> MyBool { }; } #[derive( - Record, - ByteRepr, - ZeroInitialization, - FnPtrArg, - DefaultInitializable, - Memberwise, - MoveAssignable, - Default, + Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Memberwise, MoveAssignable, )] #[memberwise(copy_assign)] #[derive(Conversions)] @@ -252,7 +239,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/operator_comparison_noncopyable.rs b/tests/unit/out/refcount/operator_comparison_noncopyable.rs index 100f191845..751ca2a5a5 100644 --- a/tests/unit/out/refcount/operator_comparison_noncopyable.rs +++ b/tests/unit/out/refcount/operator_comparison_noncopyable.rs @@ -11,9 +11,7 @@ impl LessThanComparable for S { return ({ x.with(|__s| __s.data_) } < { y.with(|__s| __s.data_) }); } } -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Memberwise, Default, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Memberwise)] #[memberwise(move_constructor)] #[derive(Conversions)] #[conversions(move)] diff --git a/tests/unit/out/refcount/operator_compound_assignment_free.rs b/tests/unit/out/refcount/operator_compound_assignment_free.rs index a41d9466f0..7c124fdb86 100644 --- a/tests/unit/out/refcount/operator_compound_assignment_free.rs +++ b/tests/unit/out/refcount/operator_compound_assignment_free.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/operator_compound_assignment_member.rs b/tests/unit/out/refcount/operator_compound_assignment_member.rs index 752e0a4e1f..cd34f85903 100644 --- a/tests/unit/out/refcount/operator_compound_assignment_member.rs +++ b/tests/unit/out/refcount/operator_compound_assignment_member.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/operator_friend.rs b/tests/unit/out/refcount/operator_friend.rs index 73a37d4914..19e620358c 100644 --- a/tests/unit/out/refcount/operator_friend.rs +++ b/tests/unit/out/refcount/operator_friend.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -52,7 +51,6 @@ impl ThreeWayComparable for DefaultedOrd { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, PartiallyOrderedWith, )] #[three_way(ThreeWayComparable::three_way)] @@ -88,7 +86,6 @@ pub fn operator_add_0(x: Ptr, y: Ptr) -> Inline { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -107,7 +104,6 @@ pub struct Inline { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -131,7 +127,6 @@ impl LessThanComparable for Tmpl_int_ { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -150,7 +145,6 @@ pub struct Tmpl_int_ { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -169,7 +163,6 @@ pub struct Tmpl_long_ { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/operator_less_than.rs b/tests/unit/out/refcount/operator_less_than.rs index 92681a1bd6..aa43806a99 100644 --- a/tests/unit/out/refcount/operator_less_than.rs +++ b/tests/unit/out/refcount/operator_less_than.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/operator_logical_free.rs b/tests/unit/out/refcount/operator_logical_free.rs index aadf9531f8..4a29c615eb 100644 --- a/tests/unit/out/refcount/operator_logical_free.rs +++ b/tests/unit/out/refcount/operator_logical_free.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/operator_logical_member.rs b/tests/unit/out/refcount/operator_logical_member.rs index cbb4b85656..ecf83a281e 100644 --- a/tests/unit/out/refcount/operator_logical_member.rs +++ b/tests/unit/out/refcount/operator_logical_member.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/operator_member_pointer_free.rs b/tests/unit/out/refcount/operator_member_pointer_free.rs index ddd80ba8d8..c360ee46ca 100644 --- a/tests/unit/out/refcount/operator_member_pointer_free.rs +++ b/tests/unit/out/refcount/operator_member_pointer_free.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -47,16 +46,6 @@ pub struct S { #[byte_size(4)] pub inner: Inner, } -impl Default for S { - fn default() -> Self { - { - S { - data: (0..3).map(|_| 0_i32).collect::>(), - inner: ::default(), - } - } - } -} pub fn operator_deref_0(s: Ptr) -> Ptr { return field_ptr!(s, inner); } diff --git a/tests/unit/out/refcount/operator_member_pointer_member.rs b/tests/unit/out/refcount/operator_member_pointer_member.rs index abb506ed45..3f949e7753 100644 --- a/tests/unit/out/refcount/operator_member_pointer_member.rs +++ b/tests/unit/out/refcount/operator_member_pointer_member.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -35,7 +34,6 @@ pub struct Inner { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -88,16 +86,6 @@ impl S { return (array_field_ptr!(this, data).offset((0) as isize)); } } -impl Default for S { - fn default() -> Self { - { - S { - data: (0..3).map(|_| 0_i32).collect::>(), - inner: ::default(), - } - } - } -} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); @@ -121,7 +109,7 @@ fn main_0() -> i32 { assert!(((p.read()) == 1)); p.write(5); assert!(((array_elem!(s.as_pointer(), data, 0).read()) == 5)); - let t: Value = Rc::new(RefCell::new(
::default())); + let t: Value
= Rc::new(RefCell::new({
::zero_init() })); assert!(((({ Table::operator_index(1,) }).read()) == 8)); ({ Table::operator_index(1) }).write(80); assert!( diff --git a/tests/unit/out/refcount/operator_other_free.rs b/tests/unit/out/refcount/operator_other_free.rs index 1dc7af38ef..9117cfd15b 100644 --- a/tests/unit/out/refcount/operator_other_free.rs +++ b/tests/unit/out/refcount/operator_other_free.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/operator_other_member.rs b/tests/unit/out/refcount/operator_other_member.rs index e933c0b1ef..df868eb6d4 100644 --- a/tests/unit/out/refcount/operator_other_member.rs +++ b/tests/unit/out/refcount/operator_other_member.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -37,7 +36,6 @@ impl Static { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -93,7 +91,7 @@ fn main_0() -> i32 { assert!(({ S::to_bool(s.as_pointer(),) })); assert!(!({ S::to_bool(z.as_pointer(),) })); assert!(({ S::to_bool(s.as_pointer(),) }) && (!({ S::to_bool(z.as_pointer(),) }))); - let st: Value = Rc::new(RefCell::new(::default())); + let st: Value = Rc::new(RefCell::new({ ::zero_init() })); assert!((({ Static::operator_call(6, 7,) }) == 42)); assert!((({ S::operator_call_1(Rc::new(RefCell::new(S { v: 5 })).as_pointer(),) }) == 5)); assert!((({ S::operator_call_3(Rc::new(RefCell::new(S { v: 5 })).as_pointer(), 1, 1,) }) == 7)); diff --git a/tests/unit/out/refcount/operator_overloads.rs b/tests/unit/out/refcount/operator_overloads.rs index b74cfdd244..8ec5b71855 100644 --- a/tests/unit/out/refcount/operator_overloads.rs +++ b/tests/unit/out/refcount/operator_overloads.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/operator_qualifiers.rs b/tests/unit/out/refcount/operator_qualifiers.rs index 93b109eb64..9294e15ffc 100644 --- a/tests/unit/out/refcount/operator_qualifiers.rs +++ b/tests/unit/out/refcount/operator_qualifiers.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/operator_three_way.rs b/tests/unit/out/refcount/operator_three_way.rs index 3174e5eb07..6f8bf3ae8f 100644 --- a/tests/unit/out/refcount/operator_three_way.rs +++ b/tests/unit/out/refcount/operator_three_way.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, PartiallyOrderedWith, )] #[three_way(ThreeWayComparable::three_way)] diff --git a/tests/unit/out/refcount/operator_traits.rs b/tests/unit/out/refcount/operator_traits.rs index 1d662beb1d..1aff2b6578 100644 --- a/tests/unit/out/refcount/operator_traits.rs +++ b/tests/unit/out/refcount/operator_traits.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -40,7 +39,6 @@ impl LessThanComparable for Lt { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -59,7 +57,6 @@ pub struct Eq { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, PartiallyOrderedWith, )] #[three_way(ThreeWayComparable::three_way)] @@ -94,7 +91,6 @@ impl LessThanComparable for Cmp { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -118,7 +114,6 @@ impl LessThanComparable for Free { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/overload_mangling.rs b/tests/unit/out/refcount/overload_mangling.rs index cba600c702..3d20ed0ebb 100644 --- a/tests/unit/out/refcount/overload_mangling.rs +++ b/tests/unit/out/refcount/overload_mangling.rs @@ -29,7 +29,6 @@ pub fn twice_2(mut n: i32) -> i32 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -59,7 +58,6 @@ impl Access_S_ { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -155,7 +153,6 @@ impl S { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -238,7 +235,7 @@ fn main_0() -> i32 { }) == 107) ); assert!(({ ((*z.borrow()) == 6) })); - let a: Value = Rc::new(RefCell::new(::default())); + let a: Value = Rc::new(RefCell::new({ ::zero_init() })); let mut cs: Ptr = (s.as_pointer()); let cr: Ptr = s.as_pointer(); assert!((({ Access_S_::get_1(a.as_pointer(), (s.as_pointer()),) }) == 100)); diff --git a/tests/unit/out/refcount/pair_converting_construction.rs b/tests/unit/out/refcount/pair_converting_construction.rs index bf4a93e669..b8c53a1a82 100644 --- a/tests/unit/out/refcount/pair_converting_construction.rs +++ b/tests/unit/out/refcount/pair_converting_construction.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -41,7 +40,6 @@ impl Celsius { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -66,7 +64,6 @@ impl Meters { FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -92,7 +89,6 @@ impl Label { FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -127,7 +123,6 @@ impl Owner { FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -172,17 +167,6 @@ impl Constructor<()> for Fallback { } } } -impl Default for Fallback { - fn default() -> Self { - { - { - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - Fallback::constructor_1(__v.as_pointer(), -1_i32); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} #[derive( Copy, Clone, @@ -193,7 +177,6 @@ impl Default for Fallback { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -212,7 +195,6 @@ pub struct Counter { FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -245,7 +227,6 @@ impl Tag { FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -265,7 +246,6 @@ pub struct Tag { FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/pod.rs b/tests/unit/out/refcount/pod.rs index 7cea2fe3a6..bf825d73b7 100644 --- a/tests/unit/out/refcount/pod.rs +++ b/tests/unit/out/refcount/pod.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/pointer_array.rs b/tests/unit/out/refcount/pointer_array.rs index b70895f7b6..d69d7c59e8 100644 --- a/tests/unit/out/refcount/pointer_array.rs +++ b/tests/unit/out/refcount/pointer_array.rs @@ -25,17 +25,6 @@ pub struct StackArray { #[array_len(3)] pub arr: Box<[Ptr]>, } -impl Default for StackArray { - fn default() -> Self { - { - StackArray { - arr: (0..3) - .map(|_| Ptr::::null()) - .collect::]>>(), - } - } - } -} pub fn IncrementAll_0(s: Ptr) { { let mut i: i32 = 0; diff --git a/tests/unit/out/refcount/pointers.rs b/tests/unit/out/refcount/pointers.rs index fbb28b42b8..e6b8af35f4 100644 --- a/tests/unit/out/refcount/pointers.rs +++ b/tests/unit/out/refcount/pointers.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/ptr_cast_init.rs b/tests/unit/out/refcount/ptr_cast_init.rs index 87969f89ab..c98a17ab58 100644 --- a/tests/unit/out/refcount/ptr_cast_init.rs +++ b/tests/unit/out/refcount/ptr_cast_init.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(8)] pub struct header { @@ -35,7 +34,6 @@ pub struct header { FnPtrArg, TriviallyDefaultConstructible, 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 3a5e4706fa..5e541f4a09 100644 --- a/tests/unit/out/refcount/push_emplace_back.rs +++ b/tests/unit/out/refcount/push_emplace_back.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -34,7 +33,6 @@ pub struct Chunk { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -58,7 +56,6 @@ pub struct Writer { Memberwise, CopyConstructible, Swappable, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(Conversions)] @@ -193,17 +190,6 @@ impl Pair { field!(this, second).write((b * 2)); } } -impl Default for Pair { - fn default() -> Self { - { - { - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - Pair::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} pub fn emplace_ctor_args_7(mut pairs: Ptr>) { { pairs.with_mut(|__v: &mut Vec| { @@ -386,16 +372,6 @@ impl Bytes { field!(this, b).write((0..3).map(|_| 0_u8).collect::>()); } } -impl Default for Bytes { - fn default() -> Self { - { - Bytes { - v: Default::default(), - b: (0..3).map(|_| 0_u8).collect::>(), - } - } - } -} pub fn emplace_from_element_14(mut v: Ptr>>) { let p: Value> = Rc::new(RefCell::new((v).decay().offset(0_usize).decay())); { @@ -441,16 +417,6 @@ pub struct Plain { #[array_len(2)] pub b: Box<[f64]>, } -impl Default for Plain { - fn default() -> Self { - { - Plain { - a: 0_i32, - b: (0..2).map(|_| 0_f64).collect::>(), - } - } - } -} pub fn emplace_plain_15(mut v: Ptr>) { let p: Value = Rc::new(RefCell::new(Plain { a: 1, @@ -474,7 +440,6 @@ thread_local!( FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -568,7 +533,7 @@ fn main_0() -> i32 { let chunks: Value> = Rc::new(RefCell::new(Vec::new())); ({ shrink_through_ptr_2((chunks.as_pointer())) }); assert!(({ (*chunks.borrow()).is_empty() })); - let w: Value = Rc::new(RefCell::new(::default())); + let w: Value = Rc::new(RefCell::new({ ::zero_init() })); (*w.borrow_mut()).chunk.data = 42; (*w.borrow_mut()).output = (chunks.as_pointer()); ({ nested_push_move_3((w.as_pointer())) }); diff --git a/tests/unit/out/refcount/random.rs b/tests/unit/out/refcount/random.rs index 3b97b9b0e4..0a72f5471f 100644 --- a/tests/unit/out/refcount/random.rs +++ b/tests/unit/out/refcount/random.rs @@ -64,23 +64,6 @@ impl Pair { return (field_ptr!(this, x)); } } -impl Default for Pair { - fn default() -> Self { - { - Pair { - x: 0_i32, - y: 0_i32, - a: (0..5).map(|_| 0_i32).collect::>(), - r: >::default(), - p: Ptr::::null(), - pair: Ptr::::null(), - ap: (0..2) - .map(|_| Ptr::::null()) - .collect::]>>(), - } - } - } -} pub fn zero_0() -> i32 { return 0; } @@ -94,7 +77,6 @@ pub fn zero_0() -> i32 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -275,8 +257,8 @@ fn main_0() -> i32 { (*y1.borrow_mut()).pair = (y2.as_pointer()); (*y2.borrow_mut()).pair = (y3.as_pointer()); ({ Pair::method({ (*y1.borrow()).pair.clone() }.with(|__s| __s.pair.clone())) }); - let mut x: X1 = ::default(); - let mut y: X1 = ::default(); + let mut x: X1 = { ::zero_init() }; + let mut y: X1 = { ::zero_init() }; let __rhs = (({ zero_0() }) + { (*y1.borrow()).x }); (*x1.borrow_mut()) = __rhs; let __rhs = (({ zero_0() }) + 5); diff --git a/tests/unit/out/refcount/reference_wrapper.rs b/tests/unit/out/refcount/reference_wrapper.rs index f2a8101f4d..8b7d2c3972 100644 --- a/tests/unit/out/refcount/reference_wrapper.rs +++ b/tests/unit/out/refcount/reference_wrapper.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/references.rs b/tests/unit/out/refcount/references.rs index 9210cd9bbb..f2db39fe22 100644 --- a/tests/unit/out/refcount/references.rs +++ b/tests/unit/out/refcount/references.rs @@ -29,17 +29,6 @@ pub struct Pair { #[array_len(2)] pub arr: Box<[i32]>, } -impl Default for Pair { - fn default() -> Self { - { - Pair { - x: 0_i32, - y: 0_i32, - arr: (0..2).map(|_| 0_i32).collect::>(), - } - } - } -} #[derive( Clone, Record, @@ -49,7 +38,6 @@ impl Default for Pair { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/refs_as_args.rs b/tests/unit/out/refcount/refs_as_args.rs index df7af17bdb..268f115eed 100644 --- a/tests/unit/out/refcount/refs_as_args.rs +++ b/tests/unit/out/refcount/refs_as_args.rs @@ -40,7 +40,6 @@ pub fn more_refs_0(x1: i32, x2: i32, r1: Ptr, r2: Ptr) { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/reinterpret_cast_ptr_cmp.rs b/tests/unit/out/refcount/reinterpret_cast_ptr_cmp.rs index f78e16c444..cdfeb100cc 100644 --- a/tests/unit/out/refcount/reinterpret_cast_ptr_cmp.rs +++ b/tests/unit/out/refcount/reinterpret_cast_ptr_cmp.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -48,16 +47,6 @@ pub struct W { #[array_len(3)] pub arr: Box<[S]>, } -impl Default for W { - fn default() -> Self { - { - W { - h: 0_i32, - arr: (0..3).map(|_| ::default()).collect::>(), - } - } - } -} #[derive( Clone, Record, @@ -80,20 +69,8 @@ pub struct P { #[array_len(3)] pub arr: Box<[Ptr]>, } -impl Default for P { - fn default() -> Self { - { - P { - a: Ptr::::null(), - arr: (0..3) - .map(|_| Ptr::::null()) - .collect::]>>(), - } - } - } -} pub fn typed_0() { - let w: Value = Rc::new(RefCell::new(::default())); + let w: Value = Rc::new(RefCell::new({ ::zero_init() })); let mut p: Ptr = (array_field_ptr!(w.as_pointer(), arr).offset((2) as isize)); let mut q: Ptr = ((w.as_pointer()) .reinterpret_cast::() @@ -123,7 +100,7 @@ pub fn typed_0() { assert!(({ (ptrs.decay().offset(1)) } < { (f).clone() })); assert!(({ (f).clone() } < { (ptrs.decay().offset(3)) })); assert!((((f).clone() - ptrs.decay()) as i64 == 2_i64)); - let s: Value

= Rc::new(RefCell::new(

::default())); + let s: Value

= Rc::new(RefCell::new({

::zero_init() })); let mut a: Ptr> = (field_ptr!(s.as_pointer(), a)); let mut b: Ptr> = (array_field_ptr!(s.as_pointer(), arr).offset((1) as isize)); assert!(({ (a).clone() } < { (b).clone() })); diff --git a/tests/unit/out/refcount/reinterpret_cast_struct.rs b/tests/unit/out/refcount/reinterpret_cast_struct.rs index 2b7528881e..8c749ecf85 100644 --- a/tests/unit/out/refcount/reinterpret_cast_struct.rs +++ b/tests/unit/out/refcount/reinterpret_cast_struct.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -32,7 +31,7 @@ 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() })); (*p.borrow_mut()).x = 67305985; (*p.borrow_mut()).y = 134678021; let mut bytes: Ptr = (p.as_pointer()).reinterpret_cast::(); 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 abd2f86917..3940cda984 100644 --- a/tests/unit/out/refcount/reinterpret_cast_struct_to_struct.rs +++ b/tests/unit/out/refcount/reinterpret_cast_struct_to_struct.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -37,7 +36,6 @@ pub struct Point { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/reserved_keywords.rs b/tests/unit/out/refcount/reserved_keywords.rs index 34f8f95b8a..b53a8d68d9 100644 --- a/tests/unit/out/refcount/reserved_keywords.rs +++ b/tests/unit/out/refcount/reserved_keywords.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -109,7 +108,6 @@ pub struct S { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -128,7 +126,6 @@ pub struct type_ { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/return_move.rs b/tests/unit/out/refcount/return_move.rs index 7800c9a920..75f74d7ed3 100644 --- a/tests/unit/out/refcount/return_move.rs +++ b/tests/unit/out/refcount/return_move.rs @@ -15,7 +15,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -36,7 +35,6 @@ pub struct node { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -87,7 +85,7 @@ pub fn address_taken_8(n: Ptr) -> Ptr { }; } pub fn ret_struct_9(mut a: i32, mut n: Ptr) -> pair_t { - let mut p: pair_t = ::default(); + let mut p: pair_t = { ::zero_init() }; p.a = a; p.n = (n).clone(); return p; diff --git a/tests/unit/out/refcount/rvalue_rule_arg_move.rs b/tests/unit/out/refcount/rvalue_rule_arg_move.rs index f431b93143..1baf02ffdd 100644 --- a/tests/unit/out/refcount/rvalue_rule_arg_move.rs +++ b/tests/unit/out/refcount/rvalue_rule_arg_move.rs @@ -13,14 +13,7 @@ thread_local!( pub static moves_1: Value = Rc::new(RefCell::new(0)); ); #[derive( - Record, - ByteRepr, - ZeroInitialization, - FnPtrArg, - DefaultInitializable, - Memberwise, - Swappable, - Default, + Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Memberwise, Swappable, )] #[memberwise(copy_assign, move_assign)] #[derive(Conversions)] diff --git a/tests/unit/out/refcount/rvalue_struct.rs b/tests/unit/out/refcount/rvalue_struct.rs index 4ee92b4ff3..ece376ec2b 100644 --- a/tests/unit/out/refcount/rvalue_struct.rs +++ b/tests/unit/out/refcount/rvalue_struct.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/scalar_builtin_construct_destruct.rs b/tests/unit/out/refcount/scalar_builtin_construct_destruct.rs index e0f14181ad..4f020a93a0 100644 --- a/tests/unit/out/refcount/scalar_builtin_construct_destruct.rs +++ b/tests/unit/out/refcount/scalar_builtin_construct_destruct.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/size_t_static_member.rs b/tests/unit/out/refcount/size_t_static_member.rs index 2f0c828ffc..bcd6e2fad5 100644 --- a/tests/unit/out/refcount/size_t_static_member.rs +++ b/tests/unit/out/refcount/size_t_static_member.rs @@ -19,7 +19,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -38,7 +37,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/size_t_template_param.rs b/tests/unit/out/refcount/size_t_template_param.rs index 2e2ac9adeb..559c614ea6 100644 --- a/tests/unit/out/refcount/size_t_template_param.rs +++ b/tests/unit/out/refcount/size_t_template_param.rs @@ -20,7 +20,6 @@ pub fn array_ref_0(a: Ptr) -> u64 { FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -46,7 +45,6 @@ impl PtrCtor_unsigned_long_ { FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/static_local.rs b/tests/unit/out/refcount/static_local.rs index 2f46b5c455..5e8d036ece 100644 --- a/tests/unit/out/refcount/static_local.rs +++ b/tests/unit/out/refcount/static_local.rs @@ -27,8 +27,8 @@ thread_local!( static kX2_5: Value = Rc::new(RefCell::new(2)); ); pub fn from_local_class_6() -> i32 { - return (({ S_8::get(Rc::new(RefCell::new(::default())).as_pointer()) }) - + ({ S_8::get(Rc::new(RefCell::new(::default())).as_pointer()) })); + return (({ S_8::get(Rc::new(RefCell::new({ ::zero_init() })).as_pointer()) }) + + ({ S_8::get(Rc::new(RefCell::new({ ::zero_init() })).as_pointer()) })); } thread_local!( static x_7: Value = Rc::new(RefCell::new(3)); @@ -43,7 +43,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/static_var_in_class.rs b/tests/unit/out/refcount/static_var_in_class.rs index d3ecaa4ac6..2edec319bb 100644 --- a/tests/unit/out/refcount/static_var_in_class.rs +++ b/tests/unit/out/refcount/static_var_in_class.rs @@ -19,7 +19,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -45,7 +44,6 @@ pub const anon_3_kValue: anon_3 = 3; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -64,10 +62,10 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let c: Value = Rc::new(RefCell::new(::default())); + let c: Value = Rc::new(RefCell::new({ ::zero_init() })); assert!((({ C::get(c.as_pointer(),) }) == 1)); assert!((inner_const_1.with(|rc| *rc.borrow()) == 2)); - let s: Value = Rc::new(RefCell::new(::default())); + let s: Value = Rc::new(RefCell::new({ ::zero_init() })); let mut p: Ptr = (s.as_pointer()); assert!((inner_const_1.with(|rc| *rc.borrow()) == 2)); assert!((inner_const_1.with(|rc| *rc.borrow()) == 2)); diff --git a/tests/unit/out/refcount/stdcopy.rs b/tests/unit/out/refcount/stdcopy.rs index 3a312a4201..ec7716c910 100644 --- a/tests/unit/out/refcount/stdcopy.rs +++ b/tests/unit/out/refcount/stdcopy.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/strdup.rs b/tests/unit/out/refcount/strdup.rs index 1135a0239a..52dd6928b1 100644 --- a/tests/unit/out/refcount/strdup.rs +++ b/tests/unit/out/refcount/strdup.rs @@ -15,7 +15,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, 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 faecbb65d5..d2ac54626b 100644 --- a/tests/unit/out/refcount/string_literal_ptr_init.rs +++ b/tests/unit/out/refcount/string_literal_ptr_init.rs @@ -15,7 +15,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, 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 3218503167..292654acf7 100644 --- a/tests/unit/out/refcount/string_substr.rs +++ b/tests/unit/out/refcount/string_substr.rs @@ -15,7 +15,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/struct_2d_array_field.rs b/tests/unit/out/refcount/struct_2d_array_field.rs index 8ac998a96b..6338f662af 100644 --- a/tests/unit/out/refcount/struct_2d_array_field.rs +++ b/tests/unit/out/refcount/struct_2d_array_field.rs @@ -25,18 +25,6 @@ pub struct table { #[offset(32)] pub count: usize, } -impl Default for table { - fn default() -> Self { - { - table { - rows: (0..3) - .map(|_| (0..10).map(|_| 0_i8).collect::>()) - .collect::]>>(), - count: 0_usize, - } - } - } -} thread_local!( pub static T1_0: Value

= Rc::new(RefCell::new(table { rows: Box::new([ @@ -202,7 +190,7 @@ fn main_0() -> i32 { let mut p: Ptr = array_field_ptr!(local.as_pointer(), rows).offset(2).decay(); assert!((((elem!(p, 0).read()) as i32) == ('t' as i32))); assert!(({ (*local.borrow()).count } == 3_usize)); - let copy: Value
= >::default(); + let copy: Value
= { >::zero_init() }; { let mut __tmp_0 = { (array_field_ptr!(copy.as_pointer(), rows)).to_any() }; __tmp_0.memcpy( diff --git a/tests/unit/out/refcount/struct_ctor.rs b/tests/unit/out/refcount/struct_ctor.rs index efeff6d618..471de057ec 100644 --- a/tests/unit/out/refcount/struct_ctor.rs +++ b/tests/unit/out/refcount/struct_ctor.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -59,7 +58,6 @@ pub fn foo_0(x: Ptr) -> Ptr { FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -102,17 +100,6 @@ impl Ptr_ { Value_::constructor_1(field_ptr!(this, v2), 22); } } -impl Default for Ptr_ { - fn default() -> Self { - { - { - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - Ptr_::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); diff --git a/tests/unit/out/refcount/struct_member_array_adjacency.rs b/tests/unit/out/refcount/struct_member_array_adjacency.rs index 62c22118f0..423b4fd5ab 100644 --- a/tests/unit/out/refcount/struct_member_array_adjacency.rs +++ b/tests/unit/out/refcount/struct_member_array_adjacency.rs @@ -27,22 +27,12 @@ pub struct pair { #[array_len(4)] pub b: Box<[i32]>, } -impl Default for pair { - fn default() -> Self { - { - pair { - a: (0..4).map(|_| 0_i32).collect::>(), - b: (0..4).map(|_| 0_i32).collect::>(), - } - } - } -} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let s: Value = >::default(); + let s: Value = { >::zero_init() }; assert!( (array_field_ptr!(s.as_pointer(), a).offset((4) as isize) == array_field_ptr!(s.as_pointer(), b)) diff --git a/tests/unit/out/refcount/struct_ptr.rs b/tests/unit/out/refcount/struct_ptr.rs index e82556be4d..1d4d20b12c 100644 --- a/tests/unit/out/refcount/struct_ptr.rs +++ b/tests/unit/out/refcount/struct_ptr.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -30,7 +29,7 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let obj: Value = Rc::new(RefCell::new(::default())); + let obj: Value = Rc::new(RefCell::new({ ::zero_init() })); let mut ptr: Ptr = (obj.as_pointer()); field!(ptr, x).write(2); let mut c: bool = false; diff --git a/tests/unit/out/refcount/structured_binding_copy_ctor.rs b/tests/unit/out/refcount/structured_binding_copy_ctor.rs index b015c29c02..f8d15e7f00 100644 --- a/tests/unit/out/refcount/structured_binding_copy_ctor.rs +++ b/tests/unit/out/refcount/structured_binding_copy_ctor.rs @@ -19,7 +19,6 @@ thread_local!( MoveConstructible, MoveAssignable, Swappable, - Default, )] #[memberwise(copy_assign)] #[derive(Conversions)] diff --git a/tests/unit/out/refcount/structured_binding_element_ctor.rs b/tests/unit/out/refcount/structured_binding_element_ctor.rs index 2c555331a3..7f786fcf51 100644 --- a/tests/unit/out/refcount/structured_binding_element_ctor.rs +++ b/tests/unit/out/refcount/structured_binding_element_ctor.rs @@ -12,9 +12,7 @@ thread_local!( thread_local!( pub static moves_1: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Default, Conversions, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Conversions)] #[conversions(copy, move)] #[constructor(constructor_1, i32)] #[constructor(constructor_2, LvalueRef>)] @@ -40,9 +38,7 @@ impl Elem { (*moves_1.with(Value::clone).borrow_mut()).prefix_inc(); } } -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Memberwise, Default, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Memberwise)] #[memberwise(copy_constructor, move_constructor)] #[derive(Conversions)] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/structured_binding_move_ctor.rs b/tests/unit/out/refcount/structured_binding_move_ctor.rs index f284322384..ae738556ec 100644 --- a/tests/unit/out/refcount/structured_binding_move_ctor.rs +++ b/tests/unit/out/refcount/structured_binding_move_ctor.rs @@ -12,9 +12,7 @@ thread_local!( thread_local!( pub static moves_1: Value = Rc::new(RefCell::new(0)); ); -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Default, Conversions, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Conversions)] #[conversions(copy, move)] #[constructor(constructor_1, i32, i32)] #[constructor(constructor_2, LvalueRef>)] @@ -57,7 +55,6 @@ impl Movable { Memberwise, CopyConstructible, Swappable, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(Conversions)] diff --git a/tests/unit/out/refcount/structured_binding_range_for.rs b/tests/unit/out/refcount/structured_binding_range_for.rs index 4f6e53e1d6..470bdfedaa 100644 --- a/tests/unit/out/refcount/structured_binding_range_for.rs +++ b/tests/unit/out/refcount/structured_binding_range_for.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/structured_binding_ref.rs b/tests/unit/out/refcount/structured_binding_ref.rs index 420c71dd97..f672fbebac 100644 --- a/tests/unit/out/refcount/structured_binding_ref.rs +++ b/tests/unit/out/refcount/structured_binding_ref.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/structured_binding_trivial.rs b/tests/unit/out/refcount/structured_binding_trivial.rs index 9cd943158c..2c6333c92c 100644 --- a/tests/unit/out/refcount/structured_binding_trivial.rs +++ b/tests/unit/out/refcount/structured_binding_trivial.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/tag_vs_identifier_collision.rs b/tests/unit/out/refcount/tag_vs_identifier_collision.rs index f86e8dbb0a..6756e981e4 100644 --- a/tests/unit/out/refcount/tag_vs_identifier_collision.rs +++ b/tests/unit/out/refcount/tag_vs_identifier_collision.rs @@ -20,7 +20,6 @@ pub const widget_enum_MODE_DONE: widget_enum = 2; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(8)] pub struct widget { @@ -39,7 +38,6 @@ pub struct widget { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(8)] pub struct point_struct { @@ -72,13 +70,6 @@ impl point { this.reinterpret_cast() } } -impl Default for point { - fn default() -> Self { - point { - __bytes: Box::from([0u8; 4]), - } - } -} #[derive( VaArg, FnPtrArg, @@ -103,13 +94,6 @@ impl slot_union { this.reinterpret_cast() } } -impl Default for slot_union { - fn default() -> Self { - slot_union { - __bytes: Box::from([0u8; 4]), - } - } -} pub type slot = u32; pub const slot_SLOT_A: slot = 0; pub const slot_SLOT_B: slot = 1; @@ -123,7 +107,6 @@ pub const slot_SLOT_B: slot = 1; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(4)] pub struct Inner { @@ -140,7 +123,6 @@ pub struct Inner { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(4)] pub struct Outer { @@ -158,7 +140,6 @@ pub struct Outer { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(4)] pub struct Inner_struct { @@ -173,31 +154,31 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let w: Value = >::default(); + let w: Value = { >::zero_init() }; (*w.borrow_mut()).id = 7; (*w.borrow_mut()).mode = widget_enum_MODE_ACTIVE; assert!((({ is_active_0((w.as_pointer()),) }) != 0)); (*w.borrow_mut()).mode = widget_enum_MODE_DONE; assert!((({ (*w.borrow()).mode } as u32) == ((widget_enum_MODE_DONE as i32) as u32))); - let mut p: point_struct = ::default(); + let mut p: point_struct = { ::zero_init() }; p.x = 3; p.y = 4; assert!(((p.x + p.y) == 7)); - let up: Value = >::default(); + let up: Value = { >::zero_init() }; point::whole(up.as_pointer()).write(5); assert!(((point::whole(up.as_pointer()).read()) == 5)); - let b: Value = >::default(); + let b: Value = { >::zero_init() }; slot_union::i(b.as_pointer()).write(9); assert!(((slot_union::i(b.as_pointer()).read()) == 9)); let mut e: slot = slot_SLOT_B; assert!(((e as u32) == ((slot_SLOT_B as i32) as u32))); - let mut inner_tag: Inner = ::default(); + let mut inner_tag: Inner = { ::zero_init() }; inner_tag.tag_field = 11; assert!((inner_tag.tag_field == 11)); - let mut inner_typedef: Inner_struct = ::default(); + let mut inner_typedef: Inner_struct = { ::zero_init() }; inner_typedef.typedef_field = 22; assert!((inner_typedef.typedef_field == 22)); - let mut o: Outer = ::default(); + let mut o: Outer = { ::zero_init() }; o.field.tag_field = 33; assert!((o.field.tag_field == 33)); assert!(({ (*w.borrow()).id } == 7)); diff --git a/tests/unit/out/refcount/template_default_arg.rs b/tests/unit/out/refcount/template_default_arg.rs index c326db0757..57e88a53ad 100644 --- a/tests/unit/out/refcount/template_default_arg.rs +++ b/tests/unit/out/refcount/template_default_arg.rs @@ -33,17 +33,6 @@ impl A { field!(this, v).write(v); } } -impl Default for A { - fn default() -> Self { - { - { - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - A::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} #[derive( Copy, Clone, @@ -67,17 +56,6 @@ impl B { field!(this, v).write(2); } } -impl Default for B { - fn default() -> Self { - { - { - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - B::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} #[derive( Copy, Clone, @@ -88,7 +66,6 @@ impl Default for B { FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -125,7 +102,6 @@ pub fn always_given_3(mut x: NoDefault) -> i32 { FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/template_static_member.rs b/tests/unit/out/refcount/template_static_member.rs index 4a3e57b40f..f9b6071881 100644 --- a/tests/unit/out/refcount/template_static_member.rs +++ b/tests/unit/out/refcount/template_static_member.rs @@ -19,7 +19,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -38,7 +37,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -57,7 +55,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -79,7 +76,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -101,7 +97,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/temporary_field_addr.rs b/tests/unit/out/refcount/temporary_field_addr.rs index ab371a0ab0..3112f76ff6 100644 --- a/tests/unit/out/refcount/temporary_field_addr.rs +++ b/tests/unit/out/refcount/temporary_field_addr.rs @@ -17,7 +17,6 @@ use std::rc::{Rc, Weak}; Memberwise, CopyConstructible, Swappable, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(Conversions)] @@ -70,17 +69,6 @@ impl Outer { field!(this, name).write((0..8).map(|_| 0_i8).collect::>()); } } -impl Default for Outer { - fn default() -> Self { - { - Outer { - values: Default::default(), - inner: ::default(), - name: (0..8).map(|_| 0_i8).collect::>(), - } - } - } -} pub fn make_0(__return: Ptr, calls: Ptr) { calls.with_mut(|__v| { __v.prefix_inc(); diff --git a/tests/unit/out/refcount/temporary_field_ctor_arg.rs b/tests/unit/out/refcount/temporary_field_ctor_arg.rs index b908d68d41..3f28bfe157 100644 --- a/tests/unit/out/refcount/temporary_field_ctor_arg.rs +++ b/tests/unit/out/refcount/temporary_field_ctor_arg.rs @@ -17,7 +17,6 @@ use std::rc::{Rc, Weak}; Memberwise, CopyConstructible, Swappable, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(Conversions)] @@ -50,7 +49,6 @@ pub fn make_0(__return: Ptr) { FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/temporary_field_two_args.rs b/tests/unit/out/refcount/temporary_field_two_args.rs index d528835867..cd07c340a4 100644 --- a/tests/unit/out/refcount/temporary_field_two_args.rs +++ b/tests/unit/out/refcount/temporary_field_two_args.rs @@ -17,7 +17,6 @@ use std::rc::{Rc, Weak}; Memberwise, CopyConstructible, Swappable, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(Conversions)] @@ -45,7 +44,6 @@ impl Inner { Memberwise, CopyConstructible, Swappable, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(Conversions)] diff --git a/tests/unit/out/refcount/this.rs b/tests/unit/out/refcount/this.rs index cf648bb3b7..c8a8e84ea2 100644 --- a/tests/unit/out/refcount/this.rs +++ b/tests/unit/out/refcount/this.rs @@ -15,7 +15,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -125,7 +124,6 @@ pub fn bump_0(mut p: Ptr) { FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/typedef-anon-struct.rs b/tests/unit/out/refcount/typedef-anon-struct.rs index c9e1dd91e9..798b01e4ea 100644 --- a/tests/unit/out/refcount/typedef-anon-struct.rs +++ b/tests/unit/out/refcount/typedef-anon-struct.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -38,7 +37,6 @@ pub struct Outer_RunInfo { Memberwise, CopyConstructible, Swappable, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(Conversions)] @@ -61,7 +59,7 @@ pub fn main() { } fn main_0() -> i32 { object!(o, Outer::constructor_1()); - let info: Value = Rc::new(RefCell::new(::default())); + let info: Value = Rc::new(RefCell::new({ ::zero_init() })); (*info.borrow_mut()).block_idx = 1; (*info.borrow_mut()).num_extra_zero_runs = 2; CopyConstructible::push_copied( diff --git a/tests/unit/out/refcount/types.rs b/tests/unit/out/refcount/types.rs index 6eda079e67..cbdb728a66 100644 --- a/tests/unit/out/refcount/types.rs +++ b/tests/unit/out/refcount/types.rs @@ -36,7 +36,7 @@ fn main_0() -> i32 { let mut xc8: u8 = 66_u8; let mut xc16: u16 = 67_u16; let mut xc32: u32 = 68_u32; - let xnp: Value = Rc::new(RefCell::new(Default::default())); + let xnp: Value = Rc::new(RefCell::new(Ptr::<()>::null().to_any())); assert!( ((((((((((((xu8 as i32) + (xu16 as i32)) as u32).wrapping_add(xu32)) as u64) .wrapping_add(xu64)) 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 113098923a..7c1a778569 100644 --- a/tests/unit/out/refcount/unary_expr_or_type_trait.rs +++ b/tests/unit/out/refcount/unary_expr_or_type_trait.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -41,7 +40,7 @@ pub fn main() { } fn main_0() -> i32 { let mut arr: [i64; 4] = [0_i64; 4]; - let mut s: S = ::default(); + let mut s: S = { ::zero_init() }; assert!((::std::mem::size_of::() == 4_usize)); assert!((::std::mem::size_of::<[i64; 4]>() == 32_usize)); assert!((16usize == 16_usize)); diff --git a/tests/unit/out/refcount/unboxed_records.rs b/tests/unit/out/refcount/unboxed_records.rs index 9bc761e053..528f582e68 100644 --- a/tests/unit/out/refcount/unboxed_records.rs +++ b/tests/unit/out/refcount/unboxed_records.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -57,19 +56,6 @@ pub struct Cookie { #[array_len(4)] pub arr: Box<[i32]>, } -impl Default for Cookie { - fn default() -> Self { - { - Cookie { - x: 0_i32, - data: Ptr::::null(), - in_: Ptr::::null(), - inner: ::default(), - arr: (0..4).map(|_| 0_i32).collect::>(), - } - } - } -} #[derive( Copy, Clone, @@ -98,11 +84,6 @@ impl Counter { field!(this, n).write(0); } } -impl Default for Counter { - fn default() -> Self { - { Counter { n: 0 } } - } -} pub fn set_0(mut p: Ptr, mut v: i32) { p.write(v); } @@ -140,7 +121,7 @@ pub fn main() { fn main_0() -> i32 { let data: Value> = Rc::new(RefCell::new(Box::new([0, 0, 0, 0]))); let in_: Value> = Rc::new(RefCell::new(Box::new([1, 2, 3, 4]))); - let cookie: Value = Rc::new(RefCell::new(::default())); + let cookie: Value = Rc::new(RefCell::new({ ::zero_init() })); (*cookie.borrow_mut()).x = 2; (*cookie.borrow_mut()).data = data.decay(); (*cookie.borrow_mut()).in_ = in_.decay(); @@ -154,7 +135,7 @@ fn main_0() -> i32 { }) ); assert!((({ get_1(cookie.as_pointer(),) }) == 2)); - let mut local: Inner = ::default(); + let mut local: Inner = { ::zero_init() }; local.a = 4; local.b = (local.a * 2); local.a.postfix_inc(); diff --git a/tests/unit/out/refcount/union_addrof_external.rs b/tests/unit/out/refcount/union_addrof_external.rs index 6987c6e70c..99e632318d 100644 --- a/tests/unit/out/refcount/union_addrof_external.rs +++ b/tests/unit/out/refcount/union_addrof_external.rs @@ -29,18 +29,6 @@ pub struct record { #[array_len(8)] pub pad: Box<[i8]>, } -impl Default for record { - fn default() -> Self { - { - record { - code: 0_u16, - lo: 0_u16, - hi: 0_u32, - pad: (0..8).map(|_| 0_i8).collect::>(), - } - } - } -} #[derive( VaArg, FnPtrArg, @@ -65,13 +53,6 @@ impl anon_0 { this.reinterpret_cast() } } -impl Default for anon_0 { - fn default() -> Self { - anon_0 { - __bytes: Box::from([0u8; 128]), - } - } -} #[derive( Clone, Record, @@ -81,7 +62,6 @@ impl Default for anon_0 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(128)] pub struct Container { @@ -114,7 +94,7 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let c: Value = >::default(); + let c: Value = { >::zero_init() }; { let mut __tmp_0 = { (c.as_pointer()).to_any() }; __tmp_0.memset((0) as u8, 128usize); diff --git a/tests/unit/out/refcount/union_basic.rs b/tests/unit/out/refcount/union_basic.rs index 0dc7a5de49..99d195fde2 100644 --- a/tests/unit/out/refcount/union_basic.rs +++ b/tests/unit/out/refcount/union_basic.rs @@ -30,13 +30,6 @@ impl basic { this.reinterpret_cast() } } -impl Default for basic { - fn default() -> Self { - basic { - __bytes: Box::from([0u8; 4]), - } - } -} #[derive( VaArg, FnPtrArg, @@ -54,13 +47,6 @@ pub struct empty { __bytes: Box<[u8]>, } impl empty {} -impl Default for empty { - fn default() -> Self { - empty { - __bytes: Box::from([0u8; 1]), - } - } -} #[derive( VaArg, FnPtrArg, @@ -85,20 +71,13 @@ impl underscores { this.reinterpret_cast() } } -impl Default for underscores { - fn default() -> Self { - underscores { - __bytes: Box::from([0u8; 8]), - } - } -} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let u: Value = Rc::new(RefCell::new(::default())); - let e: Value = Rc::new(RefCell::new(::default())); + let u: Value = Rc::new(RefCell::new({ ::zero_init() })); + let e: Value = Rc::new(RefCell::new({ ::zero_init() })); basic::i(u.as_pointer()).write(42); assert!(((basic::i(u.as_pointer()).read()) == 42)); basic::f(u.as_pointer()).write(3.14_f32); @@ -119,25 +98,25 @@ fn main_0() -> i32 { assert!(((pf.read()) == 1_f32)); assert!(({ (((*buf.borrow())[(3) as usize] as i32) == 63) })); let braced: Value = Rc::new(RefCell::new({ - let __u: Value = Rc::new(RefCell::new(::default())); + let __u: Value = Rc::new(RefCell::new({ ::zero_init() })); basic::i(__u.as_pointer()).write(5); Rc::try_unwrap(__u).ok().unwrap().into_inner() })); assert!(((basic::i(braced.as_pointer()).read()) == 5)); let copied: Value = Rc::new(RefCell::new({ - let __u: Value = Rc::new(RefCell::new(::default())); + let __u: Value = Rc::new(RefCell::new({ ::zero_init() })); basic::i(__u.as_pointer()).write(7); Rc::try_unwrap(__u).ok().unwrap().into_inner() })); assert!(((basic::i(copied.as_pointer()).read()) == 7)); { - let anon_0: Value = Rc::new(RefCell::new(::default())); + let anon_0: Value = Rc::new(RefCell::new({ ::zero_init() })); anon_0::ai(anon_0.as_pointer()).write(11); assert!(((anon_0::ai(anon_0.as_pointer()).read()) == 11)); anon_0::ai(anon_0.as_pointer()).write(1065353216); assert!(((anon_0::af(anon_0.as_pointer()).read()) == 1_f32)); } - let us: Value = Rc::new(RefCell::new(::default())); + let us: Value = Rc::new(RefCell::new({ ::zero_init() })); underscores::__(us.as_pointer()).write(5); assert!(((underscores::__(us.as_pointer()).read()) == 5)); underscores::___(us.as_pointer()).write(2.5_f64); @@ -171,11 +150,4 @@ impl anon_0 { this.reinterpret_cast() } } -impl Default for anon_0 { - fn default() -> Self { - anon_0 { - __bytes: Box::from([0u8; 4]), - } - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/union_cross_arm_cast.rs b/tests/unit/out/refcount/union_cross_arm_cast.rs index d4871fa382..9c62d42fa1 100644 --- a/tests/unit/out/refcount/union_cross_arm_cast.rs +++ b/tests/unit/out/refcount/union_cross_arm_cast.rs @@ -25,16 +25,6 @@ pub struct shape_a { #[array_len(14)] pub pad: Box<[i8]>, } -impl Default for shape_a { - fn default() -> Self { - { - shape_a { - code: 0_u16, - pad: (0..14).map(|_| 0_i8).collect::>(), - } - } - } -} #[derive( Clone, Record, @@ -60,19 +50,6 @@ pub struct shape_b { #[offset(24)] pub tail: u32, } -impl Default for shape_b { - fn default() -> Self { - { - shape_b { - code: 0_u16, - lo: 0_u16, - mid: 0_u32, - fill: (0..16).map(|_| 0_u8).collect::>(), - tail: 0_u32, - } - } - } -} #[derive( VaArg, FnPtrArg, @@ -100,13 +77,6 @@ impl anon_0 { this.reinterpret_cast() } } -impl Default for anon_0 { - fn default() -> Self { - anon_0 { - __bytes: Box::from([0u8; 64]), - } - } -} #[derive( Clone, Record, @@ -116,7 +86,6 @@ impl Default for anon_0 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(68)] pub struct Container { @@ -131,7 +100,7 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let c: Value = >::default(); + let c: Value = { >::zero_init() }; { let mut __tmp_0 = { (c.as_pointer()).to_any() }; __tmp_0.memset((0) as u8, 68usize); diff --git a/tests/unit/out/refcount/union_field_alignment.rs b/tests/unit/out/refcount/union_field_alignment.rs index f2f47c1f1b..3fb5b18716 100644 --- a/tests/unit/out/refcount/union_field_alignment.rs +++ b/tests/unit/out/refcount/union_field_alignment.rs @@ -30,13 +30,6 @@ impl anon_0 { this.reinterpret_cast() } } -impl Default for anon_0 { - fn default() -> Self { - anon_0 { - __bytes: Box::from([0u8; 8]), - } - } -} #[derive( Clone, Record, @@ -46,7 +39,6 @@ impl Default for anon_0 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(16)] pub struct node { @@ -62,7 +54,7 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let n: Value = >::default(); + let n: Value = { >::zero_init() }; (*n.borrow_mut()).next = Ptr::::null(); elem!(anon_0::bytes(field_ptr!(n.as_pointer(), x)), 0).write(171_u8); assert!((((elem!(anon_0::bytes(field_ptr!(n.as_pointer(), x)), 0).read()) as i32) == 171)); diff --git a/tests/unit/out/refcount/union_flex_array_member.rs b/tests/unit/out/refcount/union_flex_array_member.rs index 0cc7bfa269..cd225ef3b0 100644 --- a/tests/unit/out/refcount/union_flex_array_member.rs +++ b/tests/unit/out/refcount/union_flex_array_member.rs @@ -30,13 +30,6 @@ impl anon_0 { this.reinterpret_cast() } } -impl Default for anon_0 { - fn default() -> Self { - anon_0 { - __bytes: Box::from([0u8; 8]), - } - } -} #[derive( Clone, Record, @@ -46,7 +39,6 @@ impl Default for anon_0 { FnPtrArg, TriviallyDefaultConstructible, 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 74c3826b41..5ba4e7a629 100644 --- a/tests/unit/out/refcount/union_memset_memcpy.rs +++ b/tests/unit/out/refcount/union_memset_memcpy.rs @@ -25,16 +25,6 @@ pub struct shape_a { #[array_len(14)] pub pad: Box<[i8]>, } -impl Default for shape_a { - fn default() -> Self { - { - shape_a { - code: 0_u16, - pad: (0..14).map(|_| 0_i8).collect::>(), - } - } - } -} #[derive( Clone, Record, @@ -58,18 +48,6 @@ pub struct shape_b { #[array_len(8)] pub fill: Box<[i8]>, } -impl Default for shape_b { - fn default() -> Self { - { - shape_b { - code: 0_u16, - lo: 0_u16, - hi: 0_u32, - fill: (0..8).map(|_| 0_i8).collect::>(), - } - } - } -} #[derive( VaArg, FnPtrArg, @@ -97,13 +75,6 @@ impl anon_0 { this.reinterpret_cast() } } -impl Default for anon_0 { - fn default() -> Self { - anon_0 { - __bytes: Box::from([0u8; 256]), - } - } -} #[derive( Clone, Record, @@ -113,7 +84,6 @@ impl Default for anon_0 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(256)] pub struct Container { @@ -126,7 +96,7 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let c: Value = >::default(); + let c: Value = { >::zero_init() }; { let mut __tmp_0 = { (c.as_pointer()).to_any() }; __tmp_0.memset((0) as u8, 256usize); diff --git a/tests/unit/out/refcount/union_nested.rs b/tests/unit/out/refcount/union_nested.rs index 85282bf7c9..93abfffa69 100644 --- a/tests/unit/out/refcount/union_nested.rs +++ b/tests/unit/out/refcount/union_nested.rs @@ -25,16 +25,6 @@ pub struct record { #[array_len(14)] pub pad: Box<[i8]>, } -impl Default for record { - fn default() -> Self { - { - record { - code: 0_u16, - pad: (0..14).map(|_| 0_i8).collect::>(), - } - } - } -} #[derive( VaArg, FnPtrArg, @@ -59,13 +49,6 @@ impl anon_0 { this.reinterpret_cast() } } -impl Default for anon_0 { - fn default() -> Self { - anon_0 { - __bytes: Box::from([0u8; 128]), - } - } -} #[derive( Clone, Record, @@ -75,7 +58,6 @@ impl Default for anon_0 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(128)] pub struct inner { @@ -107,13 +89,6 @@ impl anon_1 { this.reinterpret_cast() } } -impl Default for anon_1 { - fn default() -> Self { - anon_1 { - __bytes: Box::from([0u8; 128]), - } - } -} #[derive( Clone, Record, @@ -123,7 +98,6 @@ impl Default for anon_1 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(144)] pub struct Outer { @@ -144,7 +118,7 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let ex: Value = >::default(); + let ex: Value = { >::zero_init() }; { let mut __tmp_0 = { (ex.as_pointer()).to_any() }; __tmp_0.memset((0) as u8, 144usize); diff --git a/tests/unit/out/refcount/union_pointer_pun_address.rs b/tests/unit/out/refcount/union_pointer_pun_address.rs index 69aea799ce..d52f62bc4e 100644 --- a/tests/unit/out/refcount/union_pointer_pun_address.rs +++ b/tests/unit/out/refcount/union_pointer_pun_address.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(4)] pub struct node_a { @@ -32,7 +31,6 @@ pub struct node_a { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(16)] pub struct node_b { @@ -49,7 +47,7 @@ pub fn main() { } fn main_0() -> i32 { let a: Value = Rc::new(RefCell::new(node_a { n: 123 })); - let ptr: Value = >::default(); + let ptr: Value = { >::zero_init() }; anon_0::to_a(ptr.as_pointer()).write((a.as_pointer())); let mut out: Ptr = (anon_0::to_b(ptr.as_pointer()).read()); assert!(({ (out).to_any() } == { (a.as_pointer()).to_any() })); @@ -79,11 +77,4 @@ impl anon_0 { this.reinterpret_cast() } } -impl Default for anon_0 { - fn default() -> Self { - anon_0 { - __bytes: Box::from([0u8; 8]), - } - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/union_pointer_pun_writethrough.rs b/tests/unit/out/refcount/union_pointer_pun_writethrough.rs index c256754f30..702a99466c 100644 --- a/tests/unit/out/refcount/union_pointer_pun_writethrough.rs +++ b/tests/unit/out/refcount/union_pointer_pun_writethrough.rs @@ -12,7 +12,7 @@ pub fn main() { } fn main_0() -> i32 { let x: Value = Rc::new(RefCell::new((-1_i32 as i64))); - let pp: Value = >::default(); + let pp: Value = { >::zero_init() }; anon_0::as_signed(pp.as_pointer()).write((x.as_pointer())); (anon_0::as_unsigned(pp.as_pointer()).read()).write(42_u64); assert!(({ ((*x.borrow()) == 42_i64) })); @@ -42,11 +42,4 @@ impl anon_0 { this.reinterpret_cast() } } -impl Default for anon_0 { - fn default() -> Self { - anon_0 { - __bytes: Box::from([0u8; 8]), - } - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/union_struct_dual_use.rs b/tests/unit/out/refcount/union_struct_dual_use.rs index 734892b9fe..7c1eeebd68 100644 --- a/tests/unit/out/refcount/union_struct_dual_use.rs +++ b/tests/unit/out/refcount/union_struct_dual_use.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(8)] pub struct Inner { @@ -52,13 +51,6 @@ impl anon_1 { this.reinterpret_cast() } } -impl Default for anon_1 { - fn default() -> Self { - anon_1 { - __bytes: Box::from([0u8; 16]), - } - } -} #[derive( Clone, Record, @@ -68,7 +60,6 @@ impl Default for anon_1 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(16)] pub struct Outer { @@ -81,11 +72,11 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let standalone: Value = >::default(); + let standalone: Value = { >::zero_init() }; (*standalone.borrow_mut()).a = 3; (*standalone.borrow_mut()).b = 4; assert!((({ sum_inner_0((standalone.as_pointer()),) }) == 7)); - let outer: Value = >::default(); + let outer: Value = { >::zero_init() }; { let mut __tmp_0 = { (outer.as_pointer()).to_any() }; __tmp_0.memset((0) as u8, 16usize); diff --git a/tests/unit/out/refcount/union_tagged_many_arms.rs b/tests/unit/out/refcount/union_tagged_many_arms.rs index 83cc27c144..6c9228b14e 100644 --- a/tests/unit/out/refcount/union_tagged_many_arms.rs +++ b/tests/unit/out/refcount/union_tagged_many_arms.rs @@ -45,13 +45,6 @@ impl anon_0 { this.reinterpret_cast() } } -impl Default for anon_0 { - fn default() -> Self { - anon_0 { - __bytes: Box::from([0u8; 8]), - } - } -} #[derive( Clone, Record, @@ -61,7 +54,6 @@ impl Default for anon_0 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(16)] pub struct Slot { @@ -76,15 +68,15 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let a: Value = >::default(); + let a: Value = { >::zero_init() }; (*a.borrow_mut()).tag = Tag_enum_T_NUM_S; anon_0::signed_n(field_ptr!(a.as_pointer(), payload)).write((-7_i32 as i64)); assert!(((anon_0::signed_n(field_ptr!(a.as_pointer(), payload)).read()) == (-7_i32 as i64))); - let b: Value = >::default(); + let b: Value = { >::zero_init() }; (*b.borrow_mut()).tag = Tag_enum_T_NUM_U; anon_0::unsigned_n(field_ptr!(b.as_pointer(), payload)).write(3735928559_u64); assert!(((anon_0::unsigned_n(field_ptr!(b.as_pointer(), payload)).read()) == 3735928559_u64)); - let c: Value = >::default(); + let c: Value = { >::zero_init() }; (*c.borrow_mut()).tag = Tag_enum_T_TEXT; anon_0::text(field_ptr!(c.as_pointer(), payload)) .write(Ptr::::from_string_literal(b"hello")); @@ -96,12 +88,12 @@ fn main_0() -> i32 { .read()) as i32) == ('h' as i32)) ); - let d: Value = >::default(); + let d: Value = { >::zero_init() }; (*d.borrow_mut()).tag = Tag_enum_T_FLOAT; anon_0::f(field_ptr!(d.as_pointer(), payload)).write(1.5_f64); assert!(((anon_0::f(field_ptr!(d.as_pointer(), payload)).read()) == 1.5_f64)); let x: Value = Rc::new(RefCell::new(0)); - let e: Value = >::default(); + let e: Value = { >::zero_init() }; (*e.borrow_mut()).tag = Tag_enum_T_REF; anon_0::handle(field_ptr!(e.as_pointer(), payload)).write((x.as_pointer()).to_any()); assert!( diff --git a/tests/unit/out/refcount/union_tagged_simple.rs b/tests/unit/out/refcount/union_tagged_simple.rs index 8ecd6d388a..444780bddb 100644 --- a/tests/unit/out/refcount/union_tagged_simple.rs +++ b/tests/unit/out/refcount/union_tagged_simple.rs @@ -33,13 +33,6 @@ impl anon_0 { this.reinterpret_cast() } } -impl Default for anon_0 { - fn default() -> Self { - anon_0 { - __bytes: Box::from([0u8; 8]), - } - } -} #[derive( Clone, Record, @@ -49,7 +42,6 @@ impl Default for anon_0 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(24)] pub struct Event { @@ -68,13 +60,13 @@ pub fn main() { } fn main_0() -> i32 { let dummy: Value = Rc::new(RefCell::new(0)); - let m1: Value = >::default(); + let m1: Value = { >::zero_init() }; (*m1.borrow_mut()).kind = Kind_enum_KIND_DONE; (*m1.borrow_mut()).handle = (dummy.as_pointer()).to_any(); anon_0::code(field_ptr!(m1.as_pointer(), payload)).write(42); assert!((({ (*m1.borrow()).kind } as u32) == ((Kind_enum_KIND_DONE as i32) as u32))); assert!(((anon_0::code(field_ptr!(m1.as_pointer(), payload)).read()) == 42)); - let m2: Value = >::default(); + let m2: Value = { >::zero_init() }; (*m2.borrow_mut()).kind = Kind_enum_KIND_NONE; (*m2.borrow_mut()).handle = (dummy.as_pointer()).to_any(); anon_0::obj(field_ptr!(m2.as_pointer(), payload)).write((dummy.as_pointer()).to_any()); diff --git a/tests/unit/out/refcount/union_tagged_struct_arms.rs b/tests/unit/out/refcount/union_tagged_struct_arms.rs index 38b2f15ac3..8f0842ebf3 100644 --- a/tests/unit/out/refcount/union_tagged_struct_arms.rs +++ b/tests/unit/out/refcount/union_tagged_struct_arms.rs @@ -19,7 +19,6 @@ pub const Choice_enum_C_INTEGERS: Choice_enum = 3; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(24)] pub struct anon_1 { @@ -41,7 +40,6 @@ pub struct anon_1 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(16)] pub struct anon_2 { @@ -64,7 +62,6 @@ pub struct anon_2 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(40)] pub struct anon_3 { @@ -106,13 +103,6 @@ impl anon_0 { this.reinterpret_cast() } } -impl Default for anon_0 { - fn default() -> Self { - anon_0 { - __bytes: Box::from([0u8; 40]), - } - } -} #[derive( Clone, Record, @@ -122,7 +112,6 @@ impl Default for anon_0 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(48)] pub struct Branch { @@ -139,7 +128,7 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let p_list: Value = >::default(); + let p_list: Value = { >::zero_init() }; (*p_list.borrow_mut()).choice = Choice_enum_C_LIST; (*p_list.borrow_mut()).index = 0; field!(anon_0::list(field_ptr!(p_list.as_pointer(), v)), items) @@ -159,7 +148,7 @@ fn main_0() -> i32 { .read()) as i32) == ('b' as i32)) ); - let p_letters: Value = >::default(); + let p_letters: Value = { >::zero_init() }; (*p_letters.borrow_mut()).choice = Choice_enum_C_LETTERS; (*p_letters.borrow_mut()).index = 1; field!(anon_0::letters(field_ptr!(p_letters.as_pointer(), v)), lo).write(('a' as i32)); @@ -171,7 +160,7 @@ fn main_0() -> i32 { - anon_0::letters(field_ptr!(p_letters.as_pointer(), v)).with(|__s| __s.lo)) == 25) ); - let p_integers: Value = >::default(); + let p_integers: Value = { >::zero_init() }; (*p_integers.borrow_mut()).choice = Choice_enum_C_INTEGERS; (*p_integers.borrow_mut()).index = 2; field!(anon_0::integers(field_ptr!(p_integers.as_pointer(), v)), lo).write(1_i64); 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 4193557584..8d315f5fed 100644 --- a/tests/unit/out/refcount/union_void_ptr_sized_deref.rs +++ b/tests/unit/out/refcount/union_void_ptr_sized_deref.rs @@ -40,13 +40,6 @@ impl anon_0 { this.reinterpret_cast() } } -impl Default for anon_0 { - fn default() -> Self { - anon_0 { - __bytes: Box::from([0u8; 8]), - } - } -} #[derive( Clone, Record, @@ -56,7 +49,6 @@ impl Default for anon_0 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(16)] pub struct Sink { @@ -99,7 +91,7 @@ fn main_0() -> i32 { let buf64: Value = Rc::new(RefCell::new(0_i64)); let buf32: Value = Rc::new(RefCell::new(0)); let buf16: Value = Rc::new(RefCell::new(0_i16)); - let s: Value = >::default(); + let s: Value = { >::zero_init() }; (*s.borrow_mut()).width = Width_enum_W_64; anon_0::handle(field_ptr!(s.as_pointer(), out)).write((buf64.as_pointer()).to_any()); ({ write_count_1((s.as_pointer()), 1234605616436508552_i64) }); diff --git a/tests/unit/out/refcount/unique_ptr.rs b/tests/unit/out/refcount/unique_ptr.rs index b8555ff7db..eacb1f4279 100644 --- a/tests/unit/out/refcount/unique_ptr.rs +++ b/tests/unit/out/refcount/unique_ptr.rs @@ -6,9 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Swappable, Default, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Swappable)] #[memberwise(move_constructor, move_assign)] #[derive(Conversions)] #[conversions(move)] @@ -41,7 +39,6 @@ impl SafePointer { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -116,7 +113,7 @@ pub fn DoStuffWithSafePointer_0(safe_ptr: Ptr>>) { } pub fn Consume_1(mut safe_ptr: Option>) -> i32 { let mut x: Option> = safe_ptr.take(); - let mut p: Option> = Ptr::alloc(::default()).to_owned_opt(); + let mut p: Option> = Ptr::alloc({ ::zero_init() }).to_owned_opt(); return ((x .as_pointer() .with(|__s| (__s).ptr.clone()) @@ -162,7 +159,7 @@ pub fn RndStuff_2() { } let x3: Value>>> = Rc::new(RefCell::new(Some(Rc::new(RefCell::new( (0..10_usize) - .map(|_| ::default()) + .map(|_| ::zero_init()) .collect::>(), ))))); { @@ -191,7 +188,7 @@ pub fn RndStuff_2() { x3.as_pointer().write( Ptr::alloc_array( (0..50_usize) - .map(|_| ::default()) + .map(|_| ::zero_init()) .collect::>(), ) .to_owned_opt(), diff --git a/tests/unit/out/refcount/unique_ptr_const_deref.rs b/tests/unit/out/refcount/unique_ptr_const_deref.rs index af51ec923f..865e4354e9 100644 --- a/tests/unit/out/refcount/unique_ptr_const_deref.rs +++ b/tests/unit/out/refcount/unique_ptr_const_deref.rs @@ -6,9 +6,7 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Swappable, Default, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Swappable)] #[memberwise(move_constructor, move_assign)] #[derive(Conversions)] #[conversions(move)] diff --git a/tests/unit/out/refcount/unique_ptr_field_reset.rs b/tests/unit/out/refcount/unique_ptr_field_reset.rs index 6a752b9461..2ab306ea0a 100644 --- a/tests/unit/out/refcount/unique_ptr_field_reset.rs +++ b/tests/unit/out/refcount/unique_ptr_field_reset.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -25,9 +24,7 @@ pub struct Data { #[offset(0)] pub v: i32, } -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Swappable, Default, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Swappable)] #[memberwise(move_constructor, move_assign)] #[derive(Conversions)] #[conversions(move)] diff --git a/tests/unit/out/refcount/unique_ptr_nested.rs b/tests/unit/out/refcount/unique_ptr_nested.rs index 1935680037..12c36113f5 100644 --- a/tests/unit/out/refcount/unique_ptr_nested.rs +++ b/tests/unit/out/refcount/unique_ptr_nested.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -27,9 +26,7 @@ pub struct Inner { #[offset(4)] pub y: i32, } -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Swappable, Default, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Swappable)] #[memberwise(move_constructor, move_assign)] #[derive(Conversions)] #[conversions(move)] diff --git a/tests/unit/out/refcount/unique_ptr_struct.rs b/tests/unit/out/refcount/unique_ptr_struct.rs index 25ab325abf..cddf8ae352 100644 --- a/tests/unit/out/refcount/unique_ptr_struct.rs +++ b/tests/unit/out/refcount/unique_ptr_struct.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/va_arg_mixed_types.rs b/tests/unit/out/refcount/va_arg_mixed_types.rs index 15514399be..e6aa650efb 100644 --- a/tests/unit/out/refcount/va_arg_mixed_types.rs +++ b/tests/unit/out/refcount/va_arg_mixed_types.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, 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 b3b8484a2f..c9aa3482f4 100644 --- a/tests/unit/out/refcount/va_arg_non_primitive_ptrs.rs +++ b/tests/unit/out/refcount/va_arg_non_primitive_ptrs.rs @@ -15,7 +15,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, 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 bff2e8b664..4ab5dd9905 100644 --- a/tests/unit/out/refcount/va_arg_struct_ctx.rs +++ b/tests/unit/out/refcount/va_arg_struct_ctx.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, )] #[byte_size(8)] pub struct context { @@ -58,13 +57,6 @@ impl value { this.reinterpret_cast() } } -impl Default for value { - fn default() -> Self { - value { - __bytes: Box::from([0u8; 8]), - } - } -} pub fn pick_1(use_long: i32, __args: Box<[VaArg]>) -> i64 { let __args: Value> = Rc::new(RefCell::new(__args.into())); let use_long: Value = Rc::new(RefCell::new(use_long)); @@ -81,7 +73,7 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let ctx: Value = >::default(); + let ctx: Value = { >::zero_init() }; (*ctx.borrow_mut()).verbose = 1; (*ctx.borrow_mut()).last_error = 0; ({ @@ -101,7 +93,7 @@ fn main_0() -> i32 { ) }); assert!(({ (*ctx.borrow()).last_error } == 42)); - let v: Value = >::default(); + let v: Value = { >::zero_init() }; value::l(v.as_pointer()).write((1_i64 << 40)); assert!(({ (({ pick_1(1, Box::new([((*v.borrow()).clone()).into(),])) }) == (1_i64 << 40)) })); value::i(v.as_pointer()).write(7); diff --git a/tests/unit/out/refcount/va_arg_void_ptr.rs b/tests/unit/out/refcount/va_arg_void_ptr.rs index f852755b22..b8830ddff5 100644 --- a/tests/unit/out/refcount/va_arg_void_ptr.rs +++ b/tests/unit/out/refcount/va_arg_void_ptr.rs @@ -15,7 +15,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, 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 fc4a2b93e2..1441301b03 100644 --- a/tests/unit/out/refcount/va_list_field.rs +++ b/tests/unit/out/refcount/va_list_field.rs @@ -84,7 +84,6 @@ pub fn sum_ptr_2(n: i32, __args: Box<[VaArg]>) -> i32 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/vector.rs b/tests/unit/out/refcount/vector.rs index 7d9809b4eb..046d9bdbde 100644 --- a/tests/unit/out/refcount/vector.rs +++ b/tests/unit/out/refcount/vector.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -37,7 +36,6 @@ pub fn copy_0(mut copy_vector: Vec) {} Memberwise, CopyConstructible, Swappable, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(Conversions)] @@ -68,7 +66,6 @@ impl Foo { FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/vector_iter_range_ctor.rs b/tests/unit/out/refcount/vector_iter_range_ctor.rs index 258b666ca4..8a8f94734b 100644 --- a/tests/unit/out/refcount/vector_iter_range_ctor.rs +++ b/tests/unit/out/refcount/vector_iter_range_ctor.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, DefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -41,7 +40,6 @@ impl Degrees { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/vector_subscript_direct.rs b/tests/unit/out/refcount/vector_subscript_direct.rs index 1b9a9a024e..ca4f9ae71d 100644 --- a/tests/unit/out/refcount/vector_subscript_direct.rs +++ b/tests/unit/out/refcount/vector_subscript_direct.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -43,7 +42,6 @@ impl Point { Memberwise, CopyConstructible, Swappable, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(Conversions)] diff --git a/tests/unit/out/refcount/vector_with_allocator.rs b/tests/unit/out/refcount/vector_with_allocator.rs index a3c027a626..3d4e4ddfd8 100644 --- a/tests/unit/out/refcount/vector_with_allocator.rs +++ b/tests/unit/out/refcount/vector_with_allocator.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -40,7 +39,6 @@ impl TestAllocator_int_ { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/unit/out/refcount/void_cast.rs b/tests/unit/out/refcount/void_cast.rs index 65c08c7ed9..be3a29e09b 100644 --- a/tests/unit/out/refcount/void_cast.rs +++ b/tests/unit/out/refcount/void_cast.rs @@ -18,7 +18,6 @@ pub fn unused_param_0(mut x: i32) {} Memberwise, CopyConstructible, Swappable, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(Conversions)] @@ -54,7 +53,6 @@ pub fn bump_and_return_4() -> i32 { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -63,9 +61,7 @@ pub struct Holder { #[offset(0)] pub field: i32, } -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Swappable, Default, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Swappable)] #[memberwise(move_constructor, move_assign)] #[derive(Conversions)] #[conversions(move)] diff --git a/tests/unit/out/unsafe/05_new.rs b/tests/unit/out/unsafe/05_new.rs index 15c795f57f..42bc515ce4 100644 --- a/tests/unit/out/unsafe/05_new.rs +++ b/tests/unit/out/unsafe/05_new.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -29,7 +28,6 @@ pub struct A {} ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -68,8 +66,8 @@ unsafe fn main_0() -> i32 { }; (unsafe { D::operator_call( - &::default(), - (Box::leak(Box::new(::default())) as *mut A).cast_const(), + &unsafe { ::zero_init() }, + (Box::leak(Box::new(unsafe { ::zero_init() })) as *mut A).cast_const(), ) }); return 0; diff --git a/tests/unit/out/unsafe/10_struct.rs b/tests/unit/out/unsafe/10_struct.rs index 3a1746e7b8..2182c878c7 100644 --- a/tests/unit/out/unsafe/10_struct.rs +++ b/tests/unit/out/unsafe/10_struct.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -32,7 +31,6 @@ pub struct GraphNode { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -77,15 +75,6 @@ impl Partial { (&raw mut (*this).p).write(q); } } -impl Default for Partial { - fn default() -> Self { - unsafe { - Partial { - p: std::ptr::null_mut(), - } - } - } -} #[repr(C)] #[derive( Copy, @@ -95,7 +84,6 @@ impl Default for Partial { ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -110,7 +98,6 @@ impl Declared {} ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/addr_of_global.rs b/tests/unit/out/unsafe/addr_of_global.rs index 7a6ba57664..3a959bc6be 100644 --- a/tests/unit/out/unsafe/addr_of_global.rs +++ b/tests/unit/out/unsafe/addr_of_global.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -31,7 +30,6 @@ pub struct Inner { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/anonymous-struct.rs b/tests/unit/out/unsafe/anonymous-struct.rs index d5e0bb02e4..91589246cb 100644 --- a/tests/unit/out/unsafe/anonymous-struct.rs +++ b/tests/unit/out/unsafe/anonymous-struct.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -32,7 +31,6 @@ pub struct Outer_Named { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -49,7 +47,6 @@ pub struct anon_0 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -66,7 +63,6 @@ pub struct anon_1 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -83,7 +79,6 @@ pub struct anon_2 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -99,7 +94,6 @@ pub struct anon_4 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -115,7 +109,6 @@ pub struct anon_5 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -133,7 +126,6 @@ pub struct anon_3 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -151,7 +143,7 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut o: Outer = ::default(); + let mut o: Outer = unsafe { ::zero_init() }; o.named.a = 1; o.named.b = 2; o.anonymous_named_0.c = 3; @@ -174,7 +166,7 @@ unsafe fn main_0() -> i32 { assert!(((o.anon_3.i) == (9))); assert!(((o.anon_3.inner_named.j) == (10))); assert!(((o.anon_3.anon_5.k) == (11))); - let mut s: anon_6 = ::default(); + let mut s: anon_6 = unsafe { ::zero_init() }; s.x = 1; s.z = 2; assert!( @@ -200,7 +192,6 @@ unsafe fn main_0() -> i32 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/anonymous-struct_c.rs b/tests/unit/out/unsafe/anonymous-struct_c.rs index b0a56bd075..589b41c04d 100644 --- a/tests/unit/out/unsafe/anonymous-struct_c.rs +++ b/tests/unit/out/unsafe/anonymous-struct_c.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct Named { pub a: i32, @@ -30,7 +29,6 @@ pub struct Named { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct anon_0 { pub c: i32, @@ -45,7 +43,6 @@ pub struct anon_0 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct anon_1 { pub g: i32, @@ -60,7 +57,6 @@ pub struct anon_1 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct anon_2 { pub e: i32, @@ -75,7 +71,6 @@ pub struct anon_2 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct anon_4 { pub j: i32, @@ -89,7 +84,6 @@ pub struct anon_4 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct anon_5 { pub k: i32, @@ -103,7 +97,6 @@ pub struct anon_5 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct anon_3 { pub i: i32, @@ -119,7 +112,6 @@ pub struct anon_3 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct Outer { pub named: Named, @@ -137,10 +129,10 @@ pub fn main() { unsafe fn main_0() -> i32 { let mut o: Outer = Outer { named: Named { a: 0, b: 0_i32 }, - anon0: ::default(), - anon1: ::default(), - anon_2: ::default(), - anon_3: ::default(), + anon0: unsafe { ::zero_init() }, + anon1: unsafe { ::zero_init() }, + anon_2: unsafe { ::zero_init() }, + anon_3: unsafe { ::zero_init() }, }; o.named.a = 1; o.named.b = 2; @@ -164,7 +156,7 @@ unsafe fn main_0() -> i32 { assert!(((o.anon_3.i) == (9))); assert!(((o.anon_3.inner_named.j) == (10))); assert!(((o.anon_3.anon_5.k) == (11))); - let mut s: anon_6 = ::default(); + let mut s: anon_6 = unsafe { ::zero_init() }; s.x = 1; s.z = 2; assert!( @@ -190,7 +182,6 @@ unsafe fn main_0() -> i32 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, 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 8f10b7516a..fe948a8acc 100644 --- a/tests/unit/out/unsafe/anonymous_enum.rs +++ b/tests/unit/out/unsafe/anonymous_enum.rs @@ -21,7 +21,6 @@ pub const anon_1_SECOND_B: anon_1 = 1; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -43,7 +42,6 @@ pub const anon_2_FIELD_B: anon_2 = 1; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -65,7 +63,7 @@ unsafe fn main_0() -> i32 { assert!(((td as i32) == (TdEnum_TD_A as i32))); td = TdEnum_TD_B; assert!(((td as i32) == (TdEnum_TD_B as i32))); - let mut w: WithAnonField = ::default(); + let mut w: WithAnonField = unsafe { ::zero_init() }; w.field = anon_2_FIELD_A; assert!(((w.field as i32) == (anon_2_FIELD_A as i32))); w.field = anon_2_FIELD_B; diff --git a/tests/unit/out/unsafe/anonymous_enum_c.rs b/tests/unit/out/unsafe/anonymous_enum_c.rs index 74794bce29..d16612d96a 100644 --- a/tests/unit/out/unsafe/anonymous_enum_c.rs +++ b/tests/unit/out/unsafe/anonymous_enum_c.rs @@ -21,7 +21,6 @@ pub const anon_1_SECOND_B: anon_1 = 1; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct S { pub a: i32, @@ -41,7 +40,6 @@ pub const anon_2_FIELD_B: anon_2 = 1; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct WithAnonField { pub a: i32, @@ -61,7 +59,7 @@ unsafe fn main_0() -> i32 { assert!(((td as u32) == ((TdEnum_enum_TD_A as i32) as u32))); td = TdEnum_enum_TD_B; assert!(((td as u32) == ((TdEnum_enum_TD_B as i32) as u32))); - let mut w: WithAnonField = ::default(); + let mut w: WithAnonField = unsafe { ::zero_init() }; w.field = anon_2_FIELD_A; assert!(((w.field as u32) == ((anon_2_FIELD_A as i32) as u32))); w.field = anon_2_FIELD_B; diff --git a/tests/unit/out/unsafe/any.rs b/tests/unit/out/unsafe/any.rs index 6aa4d696a0..1e20735408 100644 --- a/tests/unit/out/unsafe/any.rs +++ b/tests/unit/out/unsafe/any.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/array_const_init.rs b/tests/unit/out/unsafe/array_const_init.rs index 4c1845c3e7..5dcad783a8 100644 --- a/tests/unit/out/unsafe/array_const_init.rs +++ b/tests/unit/out/unsafe/array_const_init.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct S { pub head: i32, @@ -38,7 +37,6 @@ pub static mut s_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct P { pub x: i32, @@ -123,9 +121,9 @@ unsafe fn main_0() -> i32 { assert!((((d[(0) as usize]) == (0_f64)) && ((d[(3) as usize]) == (0_f64)))); let mut p: [P; 4] = [ P { x: 1, y: 2 }, -

::default(), -

::default(), -

::default(), + unsafe {

::zero_init() }, + unsafe {

::zero_init() }, + unsafe {

::zero_init() }, ]; assert!((((p[(0) as usize].x) == (1)) && ((p[(0) as usize].y) == (2)))); assert!((((p[(3) as usize].x) == (0)) && ((p[(3) as usize].y) == (0)))); diff --git a/tests/unit/out/unsafe/array_field_addr.rs b/tests/unit/out/unsafe/array_field_addr.rs index 268f5269a2..4bd44772cf 100644 --- a/tests/unit/out/unsafe/array_field_addr.rs +++ b/tests/unit/out/unsafe/array_field_addr.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, 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 2525d2f09d..38d0292793 100644 --- a/tests/unit/out/unsafe/array_of_noncopy_struct.rs +++ b/tests/unit/out/unsafe/array_of_noncopy_struct.rs @@ -31,16 +31,6 @@ impl NonCopy { (&raw mut (*this).tag).write(0); } } -impl Default for NonCopy { - fn default() -> Self { - unsafe { - NonCopy { - data: Default::default(), - tag: 0, - } - } - } -} pub fn main() { unsafe { __cpp2rust_init_globals(); diff --git a/tests/unit/out/unsafe/array_reference.rs b/tests/unit/out/unsafe/array_reference.rs index c68b203715..4a6ddb347a 100644 --- a/tests/unit/out/unsafe/array_reference.rs +++ b/tests/unit/out/unsafe/array_reference.rs @@ -65,7 +65,6 @@ pub unsafe fn pick_10(s: *const [libc::c_char; 5]) -> *const [libc::c_char; 5] { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/as_const.rs b/tests/unit/out/unsafe/as_const.rs index 4e5e74334d..3ea0014cf4 100644 --- a/tests/unit/out/unsafe/as_const.rs +++ b/tests/unit/out/unsafe/as_const.rs @@ -18,7 +18,6 @@ pub const Overload_kConstOverload: Overload = 2; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/assign_rhs_first.rs b/tests/unit/out/unsafe/assign_rhs_first.rs index d0f7762a62..08c425ead7 100644 --- a/tests/unit/out/unsafe/assign_rhs_first.rs +++ b/tests/unit/out/unsafe/assign_rhs_first.rs @@ -21,7 +21,6 @@ pub unsafe fn advance_1() -> i32 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/assignment_single_eval.rs b/tests/unit/out/unsafe/assignment_single_eval.rs index ebf3f25628..cc57084d1a 100644 --- a/tests/unit/out/unsafe/assignment_single_eval.rs +++ b/tests/unit/out/unsafe/assignment_single_eval.rs @@ -844,7 +844,6 @@ pub unsafe fn test_reference_members_9() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -860,7 +859,6 @@ pub struct Slot_6 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -876,7 +874,6 @@ pub struct Slot_8 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -936,7 +933,6 @@ pub unsafe fn test_pointer_elements_11() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -973,7 +969,6 @@ pub unsafe fn test_reference_pointer_13() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -1057,7 +1052,6 @@ pub unsafe fn test_reference_subfields_18() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -1073,7 +1067,6 @@ pub struct Index_16 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -1089,7 +1082,6 @@ pub struct Slot_17 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -1105,7 +1097,6 @@ pub struct Index_19 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -1156,7 +1147,6 @@ pub unsafe fn observe_24(mut assigned: i32, mut stored: *const i32) -> i32 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -1172,7 +1162,6 @@ pub struct GlobalRecord_Inner { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -1386,7 +1375,7 @@ pub unsafe fn test_borrows_29() { }), ) }); - let mut first: Link_33 = ::default(); + let mut first: Link_33 = unsafe { ::zero_init() }; first = Link_33 { next: (&mut first as *mut Link_33), }; @@ -1449,7 +1438,6 @@ static mut flag_31: std::cell::LazyCell = std::cell::LazyCell::new(|| unsa ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -1465,7 +1453,6 @@ pub struct Record_32 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -1483,7 +1470,6 @@ pub static mut selected_values_34: std::cell::LazyCell<[u32; 3]> = ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -1496,7 +1482,7 @@ impl IndexedBinding { } } pub unsafe fn test_binding_35() { - let mut owner: IndexedBinding = ::default(); + let mut owner: IndexedBinding = unsafe { ::zero_init() }; let __decomp_36: *mut IndexedBinding = &mut owner; let value: *mut u32 = (unsafe { IndexedBinding::get_1_0(&raw mut (*__decomp_36)) }); let mut result: u32 = (match ( @@ -1713,7 +1699,6 @@ pub static mut global_rows_46: std::cell::LazyCell<[[u32; 2]; 2]> = ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -1983,7 +1968,6 @@ pub static mut scoped_pointers_53: std::cell::LazyCell<[*mut u32; 1]> = ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -2159,7 +2143,6 @@ pub unsafe fn test_stable_containers_58() { MemberwiseUnsafe, CopyConstructibleUnsafe, SwappableUnsafe, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(ConversionsUnsafe)] @@ -2182,7 +2165,6 @@ impl Counts_59 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -2495,7 +2477,6 @@ unsafe fn main_0() -> i32 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -2511,7 +2492,6 @@ pub struct Index_62 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/bounded_struct_ptr.rs b/tests/unit/out/unsafe/bounded_struct_ptr.rs index 55e6c1e43b..3f9a117c97 100644 --- a/tests/unit/out/unsafe/bounded_struct_ptr.rs +++ b/tests/unit/out/unsafe/bounded_struct_ptr.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/bst.rs b/tests/unit/out/unsafe/bst.rs index 37605e38a8..b7ad903f49 100644 --- a/tests/unit/out/unsafe/bst.rs +++ b/tests/unit/out/unsafe/bst.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/c_struct.rs b/tests/unit/out/unsafe/c_struct.rs index 00cfcdd988..f5863affa9 100644 --- a/tests/unit/out/unsafe/c_struct.rs +++ b/tests/unit/out/unsafe/c_struct.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct Point { pub x: i32, @@ -30,7 +29,6 @@ pub struct Point { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct Line { pub start: Point, @@ -45,7 +43,6 @@ pub struct Line { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct Node { pub value: i32, @@ -64,7 +61,6 @@ pub const Color_BLUE: Color = 2; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct Inner { pub a: i32, @@ -79,7 +75,6 @@ pub struct Inner { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct Container { pub inner: Inner, @@ -125,7 +120,7 @@ unsafe fn main_0() -> i32 { assert!(((c.inner.b) == (6))); assert!(((c.color as u32) == ((Color_GREEN as i32) as u32))); assert!(((c.count) == (42))); - let mut c2: Container = ::default(); + let mut c2: Container = unsafe { ::zero_init() }; c2.color = Color_BLUE; assert!(((c2.color as u32) == (2_u32))); return 0; diff --git a/tests/unit/out/unsafe/cast.rs b/tests/unit/out/unsafe/cast.rs index 49f7e8d1f1..a9a68c5a25 100644 --- a/tests/unit/out/unsafe/cast.rs +++ b/tests/unit/out/unsafe/cast.rs @@ -19,7 +19,6 @@ pub const E_C: E = 2; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -36,7 +35,6 @@ pub struct Pair { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -52,7 +50,6 @@ pub struct Wide { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -71,7 +68,6 @@ pub struct Grid { MemberwiseUnsafe, CopyConstructibleUnsafe, SwappableUnsafe, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(ConversionsUnsafe)] @@ -220,7 +216,7 @@ pub unsafe fn order_physical_2() { pub unsafe fn over_aligned_3() { let mut c: libc::c_char = ('c' as libc::c_char); assert!((((&mut c as *mut libc::c_char) as usize) != (0_usize))); - let mut w: [Wide; 3] = [::default(); 3]; + let mut w: [Wide; 3] = [unsafe { ::zero_init() }; 3]; let mut iw: usize = (w.as_mut_ptr() as usize); assert!((((iw as u64).wrapping_rem((::std::mem::align_of::() as u64))) == (0_u64))); assert!( @@ -229,7 +225,7 @@ pub unsafe fn over_aligned_3() { ); let mut h: *mut Wide = Box::leak( (0..2_usize) - .map(|_| ::default()) + .map(|_| unsafe { ::zero_init() }) .collect::>(), ) .as_mut_ptr(); @@ -292,7 +288,7 @@ pub unsafe fn vector_capacity_4() { ); } pub unsafe fn nested_5() { - let mut g: Grid = ::default(); + let mut g: Grid = unsafe { ::zero_init() }; let mut ig: usize = ((&mut g as *mut Grid) as usize); assert!( (((&mut g.row[(2) as usize] as *mut i32) as *mut i32 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 8af40a1171..8fbe0cc808 100644 --- a/tests/unit/out/unsafe/cast_array_to_pointer_decay.rs +++ b/tests/unit/out/unsafe/cast_array_to_pointer_decay.rs @@ -25,7 +25,6 @@ pub unsafe fn strlen_1(mut s: *mut libc::c_char) -> i32 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/class.rs b/tests/unit/out/unsafe/class.rs index fd2a3eea1b..06ee0106c8 100644 --- a/tests/unit/out/unsafe/class.rs +++ b/tests/unit/out/unsafe/class.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -61,7 +60,6 @@ impl Pair { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -85,7 +83,6 @@ impl Route { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -108,7 +105,6 @@ impl Counter { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/class_template_lazy_member.rs b/tests/unit/out/unsafe/class_template_lazy_member.rs index 489f9a4684..8387666a64 100644 --- a/tests/unit/out/unsafe/class_template_lazy_member.rs +++ b/tests/unit/out/unsafe/class_template_lazy_member.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -31,7 +30,6 @@ pub struct Point { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -52,7 +50,6 @@ impl Box_int_ { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -73,7 +70,6 @@ impl Box_Point_ { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -94,7 +90,6 @@ impl Deduced_int_ { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/class_templates.rs b/tests/unit/out/unsafe/class_templates.rs index f8e23d09af..8f983f240f 100644 --- a/tests/unit/out/unsafe/class_templates.rs +++ b/tests/unit/out/unsafe/class_templates.rs @@ -16,7 +16,6 @@ use std::rc::Rc; MemberwiseUnsafe, CopyConstructibleUnsafe, SwappableUnsafe, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(ConversionsUnsafe)] @@ -59,7 +58,6 @@ impl MyContainer_int_ { MemberwiseUnsafe, CopyConstructibleUnsafe, SwappableUnsafe, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(ConversionsUnsafe)] @@ -102,7 +100,6 @@ impl MyContainer_char_ { MemberwiseUnsafe, CopyConstructibleUnsafe, SwappableUnsafe, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(ConversionsUnsafe)] @@ -144,7 +141,6 @@ impl MyContainer_float_ { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -168,7 +164,6 @@ impl Boxed_short_ { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -192,7 +187,6 @@ impl Boxed_int_ { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -216,7 +210,6 @@ impl Boxed_long_ { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -238,7 +231,6 @@ impl Outer_int__Inner_int_ { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -259,7 +251,6 @@ impl Outer_int_ { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -281,7 +272,6 @@ impl Outer_long__Inner_int_ { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -303,7 +293,6 @@ impl Outer_long__Inner_char_ { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -324,7 +313,6 @@ impl Outer_long_ { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/clone_vs_move.rs b/tests/unit/out/unsafe/clone_vs_move.rs index 5f4a43f0d3..300b816b88 100644 --- a/tests/unit/out/unsafe/clone_vs_move.rs +++ b/tests/unit/out/unsafe/clone_vs_move.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -31,7 +30,6 @@ pub struct Bar { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -51,7 +49,6 @@ pub struct Foo { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/comma_operator.rs b/tests/unit/out/unsafe/comma_operator.rs index e45b678f5b..b4d8389b70 100644 --- a/tests/unit/out/unsafe/comma_operator.rs +++ b/tests/unit/out/unsafe/comma_operator.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/complex_function.rs b/tests/unit/out/unsafe/complex_function.rs index e7fd5acef1..d46677eb19 100644 --- a/tests/unit/out/unsafe/complex_function.rs +++ b/tests/unit/out/unsafe/complex_function.rs @@ -24,7 +24,6 @@ pub unsafe fn bar_2(x: *mut i32) -> *mut i32 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -40,7 +39,6 @@ pub struct X1 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -61,7 +59,6 @@ impl X2 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -82,7 +79,6 @@ impl X3 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/compound_assign_paren.rs b/tests/unit/out/unsafe/compound_assign_paren.rs index f7fb2d99ac..e30222c16b 100644 --- a/tests/unit/out/unsafe/compound_assign_paren.rs +++ b/tests/unit/out/unsafe/compound_assign_paren.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/concepts.rs b/tests/unit/out/unsafe/concepts.rs index 1a49420df5..bb4c65f2b7 100644 --- a/tests/unit/out/unsafe/concepts.rs +++ b/tests/unit/out/unsafe/concepts.rs @@ -20,7 +20,6 @@ const _: () = assert!( ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/constexpr_function.rs b/tests/unit/out/unsafe/constexpr_function.rs index e3ad223505..e023810b37 100644 --- a/tests/unit/out/unsafe/constexpr_function.rs +++ b/tests/unit/out/unsafe/constexpr_function.rs @@ -30,7 +30,6 @@ pub unsafe fn half_3(mut x: f64) -> f64 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -68,7 +67,6 @@ pub unsafe fn imm_7(mut b: bool) -> bool { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/constructor.rs b/tests/unit/out/unsafe/constructor.rs index 9e158e1fb5..e33f82f0d6 100644 --- a/tests/unit/out/unsafe/constructor.rs +++ b/tests/unit/out/unsafe/constructor.rs @@ -78,17 +78,6 @@ impl Point { (*this).x += 100; } } -impl Default for Point { - fn default() -> Self { - unsafe { - { - let mut __v: Point = ZeroInitializationUnsafe::zero_init(); - Point::constructor_3(&raw mut __v); - __v - } - } - } -} pub fn main() { unsafe { __cpp2rust_init_globals(); diff --git a/tests/unit/out/unsafe/container_element_receiver.rs b/tests/unit/out/unsafe/container_element_receiver.rs index c7b686a2e7..740df5a93c 100644 --- a/tests/unit/out/unsafe/container_element_receiver.rs +++ b/tests/unit/out/unsafe/container_element_receiver.rs @@ -18,7 +18,6 @@ use std::rc::Rc; CopyAssignableUnsafe, MoveAssignableUnsafe, SwappableUnsafe, - Default, )] #[memberwise(move_constructor)] #[derive(ConversionsUnsafe)] diff --git a/tests/unit/out/unsafe/container_field_addr.rs b/tests/unit/out/unsafe/container_field_addr.rs index 8d7181e194..90a61c55e6 100644 --- a/tests/unit/out/unsafe/container_field_addr.rs +++ b/tests/unit/out/unsafe/container_field_addr.rs @@ -16,7 +16,6 @@ use std::rc::Rc; MemberwiseUnsafe, CopyConstructibleUnsafe, SwappableUnsafe, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(ConversionsUnsafe)] diff --git a/tests/unit/out/unsafe/conversion_operator_same_translation.rs b/tests/unit/out/unsafe/conversion_operator_same_translation.rs index 4c1a73b75e..5055a3c4f4 100644 --- a/tests/unit/out/unsafe/conversion_operator_same_translation.rs +++ b/tests/unit/out/unsafe/conversion_operator_same_translation.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -41,7 +40,6 @@ impl S { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/copy_assign.rs b/tests/unit/out/unsafe/copy_assign.rs index 405d122f4c..69c367c046 100644 --- a/tests/unit/out/unsafe/copy_assign.rs +++ b/tests/unit/out/unsafe/copy_assign.rs @@ -15,7 +15,6 @@ pub static mut assigns_0: std::cell::LazyCell = std::cell::LazyCell::new(|| MoveConstructibleUnsafe, MoveAssignableUnsafe, SwappableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy)] @@ -82,17 +81,6 @@ impl NonConstAssign { return &mut (*this); } } -impl Default for NonConstAssign { - fn default() -> Self { - unsafe { - { - let mut __v: NonConstAssign = ZeroInitializationUnsafe::zero_init(); - NonConstAssign::constructor_1(&raw mut __v); - __v - } - } - } -} #[repr(C)] #[derive( Copy, @@ -125,17 +113,6 @@ impl CopyAssignableUnsafe for RefQualified { return &mut (*this); } } -impl Default for RefQualified { - fn default() -> Self { - unsafe { - { - let mut __v: RefQualified = ZeroInitializationUnsafe::zero_init(); - RefQualified::constructor_1(&raw mut __v); - __v - } - } - } -} #[repr(C)] #[derive( FnPtrArg, @@ -143,7 +120,6 @@ impl Default for RefQualified { DefaultInitializableUnsafe, MemberwiseUnsafe, SwappableUnsafe, - Default, )] #[memberwise(copy_constructor, move_constructor, copy_assign, move_assign)] #[derive(ConversionsUnsafe)] @@ -163,7 +139,6 @@ pub static mut copies_1: std::cell::LazyCell = std::cell::LazyCell::new(|| MoveConstructibleUnsafe, MoveAssignableUnsafe, SwappableUnsafe, - Default, )] #[memberwise(copy_assign)] #[derive(ConversionsUnsafe)] @@ -190,7 +165,6 @@ impl CopyCounted { DefaultInitializableUnsafe, MemberwiseUnsafe, SwappableUnsafe, - Default, )] #[memberwise(copy_constructor, move_constructor, move_assign, copy_assign)] #[derive(ConversionsUnsafe)] @@ -209,7 +183,6 @@ impl HasCopyCounted {} DestructibleUnsafe, CopyConstructibleUnsafe, MovableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy)] @@ -242,7 +215,6 @@ pub static mut swap_copies_2: std::cell::LazyCell = std::cell::LazyCell::ne DefaultInitializableUnsafe, MoveConstructibleUnsafe, SwappableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy)] @@ -297,7 +269,6 @@ impl MoveAssignableUnsafe for Swapped { DefaultInitializableUnsafe, MemberwiseUnsafe, SwappableUnsafe, - Default, )] #[memberwise(copy_constructor, move_constructor, copy_assign, move_assign)] #[derive(ConversionsUnsafe)] @@ -344,17 +315,6 @@ impl MoveAssignableUnsafe for VoidAssign { this } } -impl Default for VoidAssign { - fn default() -> Self { - unsafe { - { - let mut __v: VoidAssign = ZeroInitializationUnsafe::zero_init(); - VoidAssign::constructor_1(&raw mut __v); - __v - } - } - } -} #[repr(C)] #[derive( Copy, @@ -366,7 +326,6 @@ impl Default for VoidAssign { MemberwiseUnsafe, CopyConstructibleUnsafe, MovableUnsafe, - Default, )] #[memberwise(copy_assign)] #[derive(ConversionsUnsafe)] diff --git a/tests/unit/out/unsafe/copy_ctor.rs b/tests/unit/out/unsafe/copy_ctor.rs index e3052cb205..b13e9d88fa 100644 --- a/tests/unit/out/unsafe/copy_ctor.rs +++ b/tests/unit/out/unsafe/copy_ctor.rs @@ -16,7 +16,6 @@ pub static mut copies_0: std::cell::LazyCell = std::cell::LazyCell::new(|| MoveConstructibleUnsafe, MoveAssignableUnsafe, SwappableUnsafe, - Default, )] #[memberwise(copy_assign)] #[derive(ConversionsUnsafe)] @@ -68,17 +67,6 @@ impl NonConst { (&raw mut (*this).mark).write((((*o).mark) + (10))); } } -impl Default for NonConst { - fn default() -> Self { - unsafe { - { - let mut __v: NonConst = ZeroInitializationUnsafe::zero_init(); - NonConst::constructor_1(&raw mut __v); - __v - } - } - } -} #[repr(C)] #[derive( FnPtrArg, @@ -88,7 +76,6 @@ impl Default for NonConst { MoveConstructibleUnsafe, MoveAssignableUnsafe, SwappableUnsafe, - Default, )] #[memberwise(copy_assign)] #[derive(ConversionsUnsafe)] @@ -115,7 +102,6 @@ impl Ignored { DefaultInitializableUnsafe, MemberwiseUnsafe, SwappableUnsafe, - Default, )] #[memberwise(copy_constructor, move_constructor, move_assign, copy_assign)] #[derive(ConversionsUnsafe)] @@ -126,9 +112,7 @@ pub struct Holder { } impl Holder {} #[repr(C)] -#[derive( - FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, MemberwiseUnsafe, Default, -)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, MemberwiseUnsafe)] #[memberwise(move_constructor)] #[derive(ConversionsUnsafe)] #[conversions(copy, move)] @@ -147,9 +131,7 @@ impl Box_int_ { } } #[repr(C)] -#[derive( - FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, MemberwiseUnsafe, Default, -)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, MemberwiseUnsafe)] #[memberwise(copy_constructor, move_constructor)] #[derive(ConversionsUnsafe)] #[conversions(copy, move)] @@ -166,7 +148,6 @@ impl Owner {} MoveConstructibleUnsafe, MoveAssignableUnsafe, SwappableUnsafe, - Default, )] #[memberwise(copy_assign)] #[derive(ConversionsUnsafe)] @@ -220,11 +201,6 @@ impl CopyAssignableUnsafe for Tracked { return &mut (*this); } } -impl Default for Tracked { - fn default() -> Self { - unsafe { Tracked { copied_from: 0 } } - } -} pub unsafe fn touch_1(mut t: *const Tracked) { (*(&raw const (*t).copied_from).cast_mut()).prefix_inc(); } @@ -259,17 +235,6 @@ impl SelfPtr { (&raw mut (*this).self_).write(this); } } -impl Default for SelfPtr { - fn default() -> Self { - unsafe { - { - let mut __v: SelfPtr = ZeroInitializationUnsafe::zero_init(); - SelfPtr::constructor_1(&raw mut __v); - __v - } - } - } -} #[repr(C)] #[derive( Copy, @@ -279,7 +244,6 @@ impl Default for SelfPtr { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -300,17 +264,6 @@ impl Derived { Counted::constructor_1(&raw mut (*this).c, 20); } } -impl Default for Derived { - fn default() -> Self { - unsafe { - { - let mut __v: Derived = ZeroInitializationUnsafe::zero_init(); - Derived::constructor_1(&raw mut __v); - __v - } - } - } -} pub fn main() { unsafe { __cpp2rust_init_globals(); diff --git a/tests/unit/out/unsafe/copy_move_defaulted.rs b/tests/unit/out/unsafe/copy_move_defaulted.rs index c7a1b84532..0ea1c8c644 100644 --- a/tests/unit/out/unsafe/copy_move_defaulted.rs +++ b/tests/unit/out/unsafe/copy_move_defaulted.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -62,7 +61,6 @@ impl DestructibleUnsafe for Explicit { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -82,7 +80,6 @@ pub struct Implicit { MemberwiseUnsafe, CopyConstructibleUnsafe, SwappableUnsafe, - Default, )] #[memberwise(copy_assign)] #[derive(ConversionsUnsafe)] @@ -120,7 +117,6 @@ impl MoveAssignableUnsafe for DefaultCopyUserMove { DefaultInitializableUnsafe, MemberwiseUnsafe, SwappableUnsafe, - Default, )] #[memberwise(move_constructor, move_assign)] #[derive(ConversionsUnsafe)] @@ -156,7 +152,6 @@ impl CopyAssignableUnsafe for UserCopyDefaultMove { DefaultInitializableUnsafe, MemberwiseUnsafe, SwappableUnsafe, - Default, )] #[memberwise(move_constructor, move_assign)] #[derive(ConversionsUnsafe)] @@ -181,12 +176,7 @@ impl Buffer { } #[repr(C)] #[derive( - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - MemberwiseUnsafe, - SwappableUnsafe, - Default, + FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, MemberwiseUnsafe, SwappableUnsafe, )] #[memberwise(move_constructor, move_assign)] #[derive(ConversionsUnsafe)] @@ -216,7 +206,6 @@ impl Owner { MemberwiseUnsafe, CopyConstructibleUnsafe, SwappableUnsafe, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(ConversionsUnsafe)] @@ -285,17 +274,8 @@ impl MoveAssignableUnsafe for SeesThis { return &mut (*this); } } -impl Default for SeesThis { - fn default() -> Self { - unsafe { - SeesThis { - self_: std::ptr::null_mut(), - } - } - } -} #[repr(C)] -#[derive(FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, MemberwiseUnsafe, Default)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, MemberwiseUnsafe)] #[memberwise(copy_assign, move_assign)] #[derive(ConversionsUnsafe)] #[constructor(constructor_1)] @@ -339,19 +319,9 @@ impl MoveAssignableUnsafe for Counted_int_ { return &mut (*this); } } -impl Default for Counted_int_ { - fn default() -> Self { - unsafe { Counted_int_ { v: 0_i32, moves: 0 } } - } -} #[repr(C)] #[derive( - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - MemberwiseUnsafe, - SwappableUnsafe, - Default, + FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, MemberwiseUnsafe, SwappableUnsafe, )] #[memberwise(move_constructor, move_assign)] #[derive(ConversionsUnsafe)] @@ -418,25 +388,9 @@ impl MoveAssignableUnsafe for CtorSeesThis { return &mut (*this); } } -impl Default for CtorSeesThis { - fn default() -> Self { - unsafe { - { - let mut __v: CtorSeesThis = ZeroInitializationUnsafe::zero_init(); - CtorSeesThis::constructor_1(&raw mut __v); - __v - } - } - } -} #[repr(C)] #[derive( - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - MemberwiseUnsafe, - SwappableUnsafe, - Default, + FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, MemberwiseUnsafe, SwappableUnsafe, )] #[memberwise(copy_constructor, move_constructor, copy_assign, move_assign)] #[derive(ConversionsUnsafe)] @@ -470,17 +424,6 @@ impl InitsCtorSeesThis { CtorSeesThis::constructor_2(&raw mut (*this).y, 2); } } -impl Default for InitsCtorSeesThis { - fn default() -> Self { - unsafe { - { - let mut __v: InitsCtorSeesThis = ZeroInitializationUnsafe::zero_init(); - InitsCtorSeesThis::constructor_1(&raw mut __v); - __v - } - } - } -} #[repr(C)] #[derive( FnPtrArg, @@ -517,17 +460,6 @@ impl ConstructorUnsafe<()> for OutOfLineDefaulted { } } } -impl Default for OutOfLineDefaulted { - fn default() -> Self { - unsafe { - { - let mut __v: OutOfLineDefaulted = ZeroInitializationUnsafe::zero_init(); - OutOfLineDefaulted::construct(&raw mut __v); - __v - } - } - } -} impl OutOfLineDefaulted {} impl OutOfLineDefaulted {} #[repr(C)] @@ -545,17 +477,6 @@ impl OutOfLineAssign { (&raw mut (*this).w).write(Vec::new()); } } -impl Default for OutOfLineAssign { - fn default() -> Self { - unsafe { - OutOfLineAssign { - s: ::default(), - v: 1, - w: Default::default(), - } - } - } -} impl CopyAssignableUnsafe for OutOfLineAssign { unsafe fn copy_assign( this: *mut Self, diff --git a/tests/unit/out/unsafe/copy_move_deleted.rs b/tests/unit/out/unsafe/copy_move_deleted.rs index 3824cb5879..e4bda15fac 100644 --- a/tests/unit/out/unsafe/copy_move_deleted.rs +++ b/tests/unit/out/unsafe/copy_move_deleted.rs @@ -12,7 +12,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, DefaultInitializableUnsafe, SwappableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(move)] @@ -67,17 +66,6 @@ impl MoveAssignableUnsafe for PrivateCopy { return &mut (*this); } } -impl Default for PrivateCopy { - fn default() -> Self { - unsafe { - { - let mut __v: PrivateCopy = ZeroInitializationUnsafe::zero_init(); - PrivateCopy::constructor_2(&raw mut __v); - __v - } - } - } -} #[repr(C)] #[derive(FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, ConversionsUnsafe)] #[constructor(constructor_1)] @@ -89,17 +77,6 @@ impl Immovable { (&raw mut (*this).v).write(0); } } -impl Default for Immovable { - fn default() -> Self { - unsafe { - { - let mut __v: Immovable = ZeroInitializationUnsafe::zero_init(); - Immovable::constructor_1(&raw mut __v); - __v - } - } - } -} #[repr(C)] #[derive( FnPtrArg, @@ -107,7 +84,6 @@ impl Default for Immovable { DefaultInitializableUnsafe, MemberwiseUnsafe, SwappableUnsafe, - Default, )] #[memberwise(move_constructor, move_assign)] #[derive(ConversionsUnsafe)] @@ -119,12 +95,7 @@ pub struct Container { impl Container {} #[repr(C)] #[derive( - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - MemberwiseUnsafe, - SwappableUnsafe, - Default, + FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, MemberwiseUnsafe, SwappableUnsafe, )] #[memberwise(move_constructor, move_assign)] #[derive(ConversionsUnsafe)] diff --git a/tests/unit/out/unsafe/default.rs b/tests/unit/out/unsafe/default.rs index 961b1b4023..562ecaeb06 100644 --- a/tests/unit/out/unsafe/default.rs +++ b/tests/unit/out/unsafe/default.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -35,7 +34,6 @@ pub struct Pointers { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -60,11 +58,6 @@ pub struct SmallArrays { pub struct BigArray { pub a: [i32; 33], } -impl Default for BigArray { - fn default() -> Self { - unsafe { BigArray { a: [0_i32; 33] } } - } -} pub fn main() { unsafe { __cpp2rust_init_globals(); @@ -74,7 +67,7 @@ pub fn main() { unsafe fn main_0() -> i32 { let mut default_pointers: *mut Pointers = Box::leak( (0..10_usize) - .map(|_| ::default()) + .map(|_| unsafe { ::zero_init() }) .collect::>(), ) .as_mut_ptr(); @@ -90,7 +83,7 @@ unsafe fn main_0() -> i32 { }; let mut small: *mut SmallArrays = Box::leak( (0..2_usize) - .map(|_| ::default()) + .map(|_| unsafe { ::zero_init() }) .collect::>(), ) .as_mut_ptr(); @@ -106,7 +99,7 @@ unsafe fn main_0() -> i32 { }; let mut big: *mut BigArray = Box::leak( (0..2_usize) - .map(|_| ::default()) + .map(|_| unsafe { ::zero_init() }) .collect::>(), ) .as_mut_ptr(); diff --git a/tests/unit/out/unsafe/default_function_arguments.rs b/tests/unit/out/unsafe/default_function_arguments.rs index 23bb7e5c10..0a459aa2dd 100644 --- a/tests/unit/out/unsafe/default_function_arguments.rs +++ b/tests/unit/out/unsafe/default_function_arguments.rs @@ -39,17 +39,6 @@ impl ConstructorUnsafe<()> for Bar { } } } -impl Default for Bar { - fn default() -> Self { - unsafe { - { - let mut __v: Bar = ZeroInitializationUnsafe::zero_init(); - Bar::constructor_1(&raw mut __v, 1); - __v - } - } - } -} pub static mut counter_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub unsafe fn next_3() -> i32 { return (*(*std::cell::LazyCell::force_mut(&mut *&raw mut counter_2)).prefix_inc()); @@ -85,7 +74,6 @@ pub unsafe fn first_9(r: *mut [i32; 3]) -> i32 { ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/default_in_statics.rs b/tests/unit/out/unsafe/default_in_statics.rs index 0f0c778393..c83745d566 100644 --- a/tests/unit/out/unsafe/default_in_statics.rs +++ b/tests/unit/out/unsafe/default_in_statics.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -32,7 +31,6 @@ pub struct Inner { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -55,7 +53,6 @@ pub struct Outer { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -69,9 +66,9 @@ pub struct Foo { pub static mut static_fn_0: std::cell::LazyCell i32>> = std::cell::LazyCell::new(|| unsafe { None }); pub static mut static_outer_1: std::cell::LazyCell = - std::cell::LazyCell::new(|| unsafe { ::default() }); + std::cell::LazyCell::new(|| unsafe { unsafe { ::zero_init() } }); pub static mut static_inner_array_2: std::cell::LazyCell<[Inner; 2]> = - std::cell::LazyCell::new(|| unsafe { [::default(); 2] }); + std::cell::LazyCell::new(|| unsafe { [unsafe { ::zero_init() }; 2] }); pub static mut static_foo_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { Foo { s1: c"hello".as_ptr(), @@ -107,7 +104,7 @@ pub unsafe fn check_local_static_5() { assert!((*std::cell::LazyCell::force_mut(&mut *&raw mut local_p_8)).is_null()); } static mut local_outer_6: std::cell::LazyCell = - std::cell::LazyCell::new(|| unsafe { ::default() }); + std::cell::LazyCell::new(|| unsafe { unsafe { ::zero_init() } }); static mut local_fn_7: std::cell::LazyCell i32>> = std::cell::LazyCell::new(|| unsafe { None }); static mut local_p_8: std::cell::LazyCell<*mut i32> = diff --git a/tests/unit/out/unsafe/destructor.rs b/tests/unit/out/unsafe/destructor.rs index c4907e839b..40e14e3c89 100644 --- a/tests/unit/out/unsafe/destructor.rs +++ b/tests/unit/out/unsafe/destructor.rs @@ -259,53 +259,53 @@ pub fn main() { } unsafe fn main_0() -> i32 { { - let mut s: S = ::default_constructed(); + let mut s: S = unsafe { ::zero_init() }; let _dtor_s = std::mem::DropGuard::new(&raw mut s, |__p| unsafe { DestructibleUnsafe::destroy(__p) }); } assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) == (1))); { - let mut s: S = ::default_constructed(); + let mut s: S = unsafe { ::zero_init() }; let _dtor_s = std::mem::DropGuard::new(&raw mut s, |__p| unsafe { DestructibleUnsafe::destroy(__p) }); } assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) == (2))); { - let mut d: Defaulted = ::default_constructed(); + let mut d: Defaulted = unsafe { ::zero_init() }; let _dtor_d = std::mem::DropGuard::new(&raw mut d, |__p| unsafe { DestructibleUnsafe::destroy(__p) }); } assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) == (3))); { - let mut o: Outer = ::default_constructed(); + let mut o: Outer = unsafe { ::zero_init() }; let _dtor_o = std::mem::DropGuard::new(&raw mut o, |__p| unsafe { DestructibleUnsafe::destroy(__p) }); } assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) == (4))); { - let mut am: ArrayMember = ::default_constructed(); + let mut am: ArrayMember = unsafe { ::zero_init() }; let _dtor_am = std::mem::DropGuard::new(&raw mut am, |__p| unsafe { DestructibleUnsafe::destroy(__p) }); } assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) == (7))); { - let mut e: EmptyBody = ::default_constructed(); + let mut e: EmptyBody = unsafe { ::zero_init() }; let _dtor_e = std::mem::DropGuard::new(&raw mut e, |__p| unsafe { DestructibleUnsafe::destroy(__p) }); } assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) == (8))); { - let mut tc: Templated_char_ = ::default_constructed(); + let mut tc: Templated_char_ = unsafe { ::zero_init() }; let _dtor_tc = std::mem::DropGuard::new(&raw mut tc, |__p| unsafe { DestructibleUnsafe::destroy(__p) }); - let mut ti: Templated_int_ = ::default_constructed(); + let mut ti: Templated_int_ = unsafe { ::zero_init() }; let _dtor_ti = std::mem::DropGuard::new(&raw mut ti, |__p| unsafe { DestructibleUnsafe::destroy(__p) }); @@ -341,7 +341,7 @@ unsafe fn main_0() -> i32 { assert!((((*std::cell::LazyCell::force_mut(&mut *&raw mut order_1))[(2) as usize]) == (1))); let mut before: i32 = (*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)); { - let mut cs: S = ::default_constructed(); + let mut cs: S = unsafe { ::zero_init() }; let _dtor_cs = std::mem::DropGuard::new(&raw mut cs, |__p| unsafe { DestructibleUnsafe::destroy(__p) }); diff --git a/tests/unit/out/unsafe/destructor_params.rs b/tests/unit/out/unsafe/destructor_params.rs index b0e4935fc0..7e177303dc 100644 --- a/tests/unit/out/unsafe/destructor_params.rs +++ b/tests/unit/out/unsafe/destructor_params.rs @@ -49,7 +49,6 @@ pub unsafe fn with_default_3(s: ParameterObjectUnsafe) -> i32 { ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/doubly_linked_list.rs b/tests/unit/out/unsafe/doubly_linked_list.rs index fca0f3445f..dbcb10f225 100644 --- a/tests/unit/out/unsafe/doubly_linked_list.rs +++ b/tests/unit/out/unsafe/doubly_linked_list.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/enum_default_in_static.rs b/tests/unit/out/unsafe/enum_default_in_static.rs index 4b5e366821..5686e5b436 100644 --- a/tests/unit/out/unsafe/enum_default_in_static.rs +++ b/tests/unit/out/unsafe/enum_default_in_static.rs @@ -19,14 +19,13 @@ pub const Mode_MODE_TWO: Mode = 2; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct Config { pub count: i32, pub mode: Mode, } pub static mut config_0: std::cell::LazyCell = - std::cell::LazyCell::new(|| unsafe { ::default() }); + std::cell::LazyCell::new(|| unsafe { unsafe { ::zero_init() } }); pub fn main() { unsafe { __cpp2rust_init_globals(); diff --git a/tests/unit/out/unsafe/enum_int_interop.rs b/tests/unit/out/unsafe/enum_int_interop.rs index c94e18bbda..931ad902eb 100644 --- a/tests/unit/out/unsafe/enum_int_interop.rs +++ b/tests/unit/out/unsafe/enum_int_interop.rs @@ -28,7 +28,6 @@ pub const Tag_TAG_TWO: Tag = 2; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/enum_int_interop_c.rs b/tests/unit/out/unsafe/enum_int_interop_c.rs index c2b02f1435..b16b323dc2 100644 --- a/tests/unit/out/unsafe/enum_int_interop_c.rs +++ b/tests/unit/out/unsafe/enum_int_interop_c.rs @@ -28,7 +28,6 @@ pub const Tag_enum_TAG_TWO: Tag_enum = 2; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, 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 2cb2f2a65f..5d068e7a62 100644 --- a/tests/unit/out/unsafe/enum_underlying_type.rs +++ b/tests/unit/out/unsafe/enum_underlying_type.rs @@ -45,11 +45,6 @@ impl HoldsEmpty { (&raw mut (*this).e).write(false); } } -impl Default for HoldsEmpty { - fn default() -> Self { - unsafe { HoldsEmpty { e: false } } - } -} pub fn main() { unsafe { __cpp2rust_init_globals(); diff --git a/tests/unit/out/unsafe/exprs.rs b/tests/unit/out/unsafe/exprs.rs index c2a6006a8d..6c150b258f 100644 --- a/tests/unit/out/unsafe/exprs.rs +++ b/tests/unit/out/unsafe/exprs.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -31,7 +30,6 @@ pub struct X { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/fft.rs b/tests/unit/out/unsafe/fft.rs index c472658993..0ecdeefea4 100644 --- a/tests/unit/out/unsafe/fft.rs +++ b/tests/unit/out/unsafe/fft.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -47,7 +46,7 @@ pub unsafe fn Neg_2(mut z1: Complex) -> Complex { pub unsafe fn fft_3(a: *mut Option>, mut N: i32) -> Option> { let mut y: Option> = Some( (0..(N as usize)) - .map(|_| ::default()) + .map(|_| unsafe { ::zero_init() }) .collect::>(), ); if ((N) == (1)) { @@ -69,7 +68,7 @@ pub unsafe fn fft_3(a: *mut Option>, mut N: i32) -> Option> = Some( (0..(N as usize)) - .map(|_| ::default()) + .map(|_| unsafe { ::zero_init() }) .collect::>(), ); { @@ -90,12 +89,12 @@ pub unsafe fn fft_3(a: *mut Option>, mut N: i32) -> Option> = Some( (0..(((N) / (2)) as usize)) - .map(|_| ::default()) + .map(|_| unsafe { ::zero_init() }) .collect::>(), ); let mut A1: Option> = Some( (0..(((N) / (2)) as usize)) - .map(|_| ::default()) + .map(|_| unsafe { ::zero_init() }) .collect::>(), ); { @@ -208,7 +207,7 @@ unsafe fn main_0() -> i32 { let mut N: i32 = 4; let mut a: Option> = Some( (0..(N as usize)) - .map(|_| ::default()) + .map(|_| unsafe { ::zero_init() }) .collect::>(), ); { diff --git a/tests/unit/out/unsafe/field_aliasing.rs b/tests/unit/out/unsafe/field_aliasing.rs index 5f3bd26f5a..9e3cc5d644 100644 --- a/tests/unit/out/unsafe/field_aliasing.rs +++ b/tests/unit/out/unsafe/field_aliasing.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct In { pub x: i32, @@ -30,7 +29,6 @@ pub struct In { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct S { pub in_: In, @@ -47,7 +45,6 @@ pub struct S { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct Node { pub x: i32, @@ -78,7 +75,7 @@ unsafe fn main_0() -> i32 { && (((*q).n) == (1))) ); libcc2rs::free_unsafe((p as *mut ::libc::c_void)); - let mut s: Node = ::default(); + let mut s: Node = unsafe { ::zero_init() }; s.x = 1; s.self_ = (&mut s as *mut Node); (*s.self_).x = ((s.x) + (1)); diff --git a/tests/unit/out/unsafe/field_array_elem_ptr.rs b/tests/unit/out/unsafe/field_array_elem_ptr.rs index 2a770876c4..fdac884c13 100644 --- a/tests/unit/out/unsafe/field_array_elem_ptr.rs +++ b/tests/unit/out/unsafe/field_array_elem_ptr.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -32,7 +31,6 @@ pub struct Point { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/field_pointers_malloced_struct.rs b/tests/unit/out/unsafe/field_pointers_malloced_struct.rs index 691ef1594b..e33de41ac7 100644 --- a/tests/unit/out/unsafe/field_pointers_malloced_struct.rs +++ b/tests/unit/out/unsafe/field_pointers_malloced_struct.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/field_reinterpret_write_through.rs b/tests/unit/out/unsafe/field_reinterpret_write_through.rs index 8e75578838..f64375461f 100644 --- a/tests/unit/out/unsafe/field_reinterpret_write_through.rs +++ b/tests/unit/out/unsafe/field_reinterpret_write_through.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct In { pub a: i16, @@ -30,7 +29,6 @@ pub struct In { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct S { pub x: i32, @@ -1053,7 +1051,7 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut local: S = ::default(); + let mut local: S = unsafe { ::zero_init() }; { let mut __tmp_4 = { ((&mut local as *mut S) as *mut ::libc::c_void) }; let byte_0 = __tmp_4 as *mut u8; @@ -1063,7 +1061,7 @@ unsafe fn main_0() -> i32 { __tmp_4 }; (unsafe { check_struct_3((&mut local as *mut S)) }); - let mut arr: [S; 2] = [::default(); 2]; + let mut arr: [S; 2] = [unsafe { ::zero_init() }; 2]; { let mut __tmp_5 = { (arr.as_mut_ptr() as *mut ::libc::c_void) }; let byte_0 = __tmp_5 as *mut u8; diff --git a/tests/unit/out/unsafe/find.rs b/tests/unit/out/unsafe/find.rs index c673c84678..f88ea19c79 100644 --- a/tests/unit/out/unsafe/find.rs +++ b/tests/unit/out/unsafe/find.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] 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 0c54613d31..92b77b7d29 100644 --- a/tests/unit/out/unsafe/first_field_ptr_covers_struct.rs +++ b/tests/unit/out/unsafe/first_field_ptr_covers_struct.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct In { pub a: i16, @@ -30,7 +29,6 @@ pub struct In { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, 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 d3f4ab0bee..f48b8a4b2d 100644 --- a/tests/unit/out/unsafe/first_member_downcast.rs +++ b/tests/unit/out/unsafe/first_member_downcast.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct base { pub kind: i32, @@ -29,7 +28,6 @@ pub struct base { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, 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 8750661ff8..995b104bdb 100644 --- a/tests/unit/out/unsafe/flex_array_member_incomplete.rs +++ b/tests/unit/out/unsafe/flex_array_member_incomplete.rs @@ -20,11 +20,6 @@ pub struct F { pub n: i32, pub tail: [libc::c_char; 0], } -impl Default for F { - fn default() -> Self { - unsafe { F { n: 0_i32, tail: [] } } - } -} pub fn main() { unsafe { __cpp2rust_init_globals(); 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 752bdf1574..a5526cc771 100644 --- a/tests/unit/out/unsafe/flex_array_member_sibling_write.rs +++ b/tests/unit/out/unsafe/flex_array_member_sibling_write.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct S { pub n: i32, @@ -30,7 +29,6 @@ pub struct S { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct E { pub id: i32, @@ -45,7 +43,6 @@ pub struct E { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, 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 5e494ad054..29fa1807d8 100644 --- a/tests/unit/out/unsafe/fn_ptr.rs +++ b/tests/unit/out/unsafe/fn_ptr.rs @@ -40,7 +40,6 @@ pub unsafe fn identity_hash_6(mut v: bool) -> usize { ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/fn_ptr_cast.rs b/tests/unit/out/unsafe/fn_ptr_cast.rs index b223df991e..4af6c5512d 100644 --- a/tests/unit/out/unsafe/fn_ptr_cast.rs +++ b/tests/unit/out/unsafe/fn_ptr_cast.rs @@ -38,7 +38,6 @@ pub unsafe fn test_double_cast_2() { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -46,7 +45,7 @@ pub struct Command { pub data: *mut ::libc::c_void, } pub unsafe fn test_void_ptr_to_fn_3() { - let mut cmd: Command = ::default(); + let mut cmd: Command = unsafe { ::zero_init() }; cmd.data = std::mem::transmute:: i32>, *mut ::libc::c_void>(Some( double_it_0, )); diff --git a/tests/unit/out/unsafe/fn_ptr_stable_sort.rs b/tests/unit/out/unsafe/fn_ptr_stable_sort.rs index e2bac77010..a27d6aeab7 100644 --- a/tests/unit/out/unsafe/fn_ptr_stable_sort.rs +++ b/tests/unit/out/unsafe/fn_ptr_stable_sort.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/fn_ptr_struct.rs b/tests/unit/out/unsafe/fn_ptr_struct.rs index 8ebe5a40f9..6eb296eacf 100644 --- a/tests/unit/out/unsafe/fn_ptr_struct.rs +++ b/tests/unit/out/unsafe/fn_ptr_struct.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -38,7 +37,6 @@ pub unsafe fn negate_1(mut x: i32) -> i32 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -55,9 +53,7 @@ impl S { } } #[repr(C)] -#[derive( - FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, Default, ConversionsUnsafe, -)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, ConversionsUnsafe)] #[conversions(move)] #[constructor(constructor_1, i32)] #[constructor(constructor_2, RvalueRefUnsafe)] diff --git a/tests/unit/out/unsafe/fn_ptr_typedef_cast.rs b/tests/unit/out/unsafe/fn_ptr_typedef_cast.rs index f9c0c8fd7e..456bd89bc2 100644 --- a/tests/unit/out/unsafe/fn_ptr_typedef_cast.rs +++ b/tests/unit/out/unsafe/fn_ptr_typedef_cast.rs @@ -27,7 +27,6 @@ pub unsafe fn via_size_t_return_3(mut b: u64) -> usize { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, 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 28abdff5b6..c4e1dc111a 100644 --- a/tests/unit/out/unsafe/fn_ptr_vtable.rs +++ b/tests/unit/out/unsafe/fn_ptr_vtable.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/fn_ref.rs b/tests/unit/out/unsafe/fn_ref.rs index 272e78474b..bd0e201392 100644 --- a/tests/unit/out/unsafe/fn_ref.rs +++ b/tests/unit/out/unsafe/fn_ref.rs @@ -30,7 +30,6 @@ pub unsafe fn call_forwarded_4(f: Option i32>, mut x: i32) -> ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/foreach_disjoint_field_borrow.rs b/tests/unit/out/unsafe/foreach_disjoint_field_borrow.rs index 4a89daab57..5ab502fa5a 100644 --- a/tests/unit/out/unsafe/foreach_disjoint_field_borrow.rs +++ b/tests/unit/out/unsafe/foreach_disjoint_field_borrow.rs @@ -16,7 +16,6 @@ use std::rc::Rc; MemberwiseUnsafe, CopyConstructibleUnsafe, SwappableUnsafe, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(ConversionsUnsafe)] diff --git a/tests/unit/out/unsafe/forward_basic.rs b/tests/unit/out/unsafe/forward_basic.rs index a43ba113a2..a8a39022d4 100644 --- a/tests/unit/out/unsafe/forward_basic.rs +++ b/tests/unit/out/unsafe/forward_basic.rs @@ -10,9 +10,7 @@ pub type Overload = u32; pub const Overload_kLvalueOverload: Overload = 1; pub const Overload_kRvalueOverload: Overload = 2; #[repr(C)] -#[derive( - FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, Default, ConversionsUnsafe, -)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, ConversionsUnsafe)] #[conversions(copy, move)] #[constructor(constructor_1, i32)] #[constructor(constructor_2, LvalueRefUnsafe>)] @@ -61,9 +59,7 @@ impl Holder { } } #[repr(C)] -#[derive( - FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, MemberwiseUnsafe, Default, -)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, MemberwiseUnsafe)] #[memberwise(copy_constructor, move_constructor)] #[derive(ConversionsUnsafe)] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/forward_decltype.rs b/tests/unit/out/unsafe/forward_decltype.rs index 7111d34853..a2b236d09f 100644 --- a/tests/unit/out/unsafe/forward_decltype.rs +++ b/tests/unit/out/unsafe/forward_decltype.rs @@ -10,9 +10,7 @@ pub type Overload = u32; pub const Overload_kLvalueOverload: Overload = 1; pub const Overload_kRvalueOverload: Overload = 2; #[repr(C)] -#[derive( - FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, Default, ConversionsUnsafe, -)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, ConversionsUnsafe)] #[conversions(copy, move)] #[constructor(constructor_1, i32)] #[constructor(constructor_2, LvalueRefUnsafe>)] diff --git a/tests/unit/out/unsafe/forward_explicit.rs b/tests/unit/out/unsafe/forward_explicit.rs index a49ede2127..6831204be4 100644 --- a/tests/unit/out/unsafe/forward_explicit.rs +++ b/tests/unit/out/unsafe/forward_explicit.rs @@ -12,9 +12,7 @@ pub const Overload_kRvalueOverload: Overload = 2; pub const Overload_kIntLvalueOverload: Overload = 3; pub const Overload_kIntRvalueOverload: Overload = 4; #[repr(C)] -#[derive( - FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, Default, ConversionsUnsafe, -)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, ConversionsUnsafe)] #[conversions(copy, move)] #[constructor(constructor_1, i32)] #[constructor(constructor_2, LvalueRefUnsafe>)] diff --git a/tests/unit/out/unsafe/forward_pack.rs b/tests/unit/out/unsafe/forward_pack.rs index 21a28f6080..0c53b41866 100644 --- a/tests/unit/out/unsafe/forward_pack.rs +++ b/tests/unit/out/unsafe/forward_pack.rs @@ -12,9 +12,7 @@ pub const Overload_kRvalueOverload: Overload = 2; pub const Overload_kIntLvalueOverload: Overload = 3; pub const Overload_kIntRvalueOverload: Overload = 4; #[repr(C)] -#[derive( - FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, Default, ConversionsUnsafe, -)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, ConversionsUnsafe)] #[conversions(copy, move)] #[constructor(constructor_1, i32)] #[constructor(constructor_2, LvalueRefUnsafe>)] @@ -103,9 +101,7 @@ impl Pair { } } #[repr(C)] -#[derive( - FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, MemberwiseUnsafe, Default, -)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, MemberwiseUnsafe)] #[memberwise(copy_constructor, move_constructor)] #[derive(ConversionsUnsafe)] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/friend.rs b/tests/unit/out/unsafe/friend.rs index 1572274b47..ff74143f1e 100644 --- a/tests/unit/out/unsafe/friend.rs +++ b/tests/unit/out/unsafe/friend.rs @@ -24,7 +24,6 @@ pub unsafe fn scaled_2(v: *const V, mut k: f64) -> f64 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -43,7 +42,6 @@ pub unsafe fn get_3(w: *const W_int_) -> i32 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -62,7 +60,6 @@ pub unsafe fn get_4(w: *const W_long_) -> i64 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -78,7 +75,6 @@ pub struct W_long_ { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/function_overloading.rs b/tests/unit/out/unsafe/function_overloading.rs index b1a5f87c1f..327940a538 100644 --- a/tests/unit/out/unsafe/function_overloading.rs +++ b/tests/unit/out/unsafe/function_overloading.rs @@ -30,7 +30,6 @@ pub unsafe fn bar_4(x: *mut i32) -> i32 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -74,8 +73,8 @@ unsafe fn main_0() -> i32 { }); let mut bar: i32 = 5; out += (((bar) + (unsafe { foo_0(0) })) + (unsafe { foo_1((&mut x as *mut i32)) })); - let mut foo1: Foo = ::default(); - let foo2: Foo = ::default(); + let mut foo1: Foo = unsafe { ::zero_init() }; + let foo2: Foo = unsafe { ::zero_init() }; (unsafe { Foo::foo_2(&raw mut foo1) }); (unsafe { Foo::method_3(&raw mut foo1, 1) }); (unsafe { Foo::foo_1(&raw const foo2) }); diff --git a/tests/unit/out/unsafe/global_call_temporaries.rs b/tests/unit/out/unsafe/global_call_temporaries.rs index 901f1d1e13..4055512f1d 100644 --- a/tests/unit/out/unsafe/global_call_temporaries.rs +++ b/tests/unit/out/unsafe/global_call_temporaries.rs @@ -97,7 +97,6 @@ pub static mut call_assigned_6: std::cell::LazyCell = std::cell::LazyCell:: ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/global_init_side_effect.rs b/tests/unit/out/unsafe/global_init_side_effect.rs index 037d1c716c..9695de6b02 100644 --- a/tests/unit/out/unsafe/global_init_side_effect.rs +++ b/tests/unit/out/unsafe/global_init_side_effect.rs @@ -16,7 +16,6 @@ pub static mut total_0: std::cell::LazyCell = std::cell::LazyCell::new(|| u ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/global_non_const_init.rs b/tests/unit/out/unsafe/global_non_const_init.rs index 610423735b..7929d9233a 100644 --- a/tests/unit/out/unsafe/global_non_const_init.rs +++ b/tests/unit/out/unsafe/global_non_const_init.rs @@ -51,17 +51,6 @@ impl Ctor { (&raw mut (*this).v).write(x); } } -impl Default for Ctor { - fn default() -> Self { - unsafe { - { - let mut __v: Ctor = ZeroInitializationUnsafe::zero_init(); - Ctor::constructor_1(&raw mut __v); - __v - } - } - } -} pub static mut default_ctor_7: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { { let mut __v: Ctor = ZeroInitializationUnsafe::zero_init(); @@ -100,7 +89,6 @@ pub static mut inline_member_11: std::cell::LazyCell = std::cell::LazyCell ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -143,17 +131,6 @@ impl Singleton { return &mut (*std::cell::LazyCell::force_mut(&mut *&raw mut s_15)); } } -impl Default for Singleton { - fn default() -> Self { - unsafe { - { - let mut __v: Singleton = ZeroInitializationUnsafe::zero_init(); - Singleton::constructor_1(&raw mut __v); - __v - } - } - } -} static mut s_15: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { { let mut __v: Singleton = ZeroInitializationUnsafe::zero_init(); diff --git a/tests/unit/out/unsafe/global_pointers.rs b/tests/unit/out/unsafe/global_pointers.rs index a6ab209fd5..c5a48603f6 100644 --- a/tests/unit/out/unsafe/global_pointers.rs +++ b/tests/unit/out/unsafe/global_pointers.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/global_without_initializer.rs b/tests/unit/out/unsafe/global_without_initializer.rs index bea625254b..02819118c0 100644 --- a/tests/unit/out/unsafe/global_without_initializer.rs +++ b/tests/unit/out/unsafe/global_without_initializer.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/goto_aggregate_default.rs b/tests/unit/out/unsafe/goto_aggregate_default.rs index dae9dd1997..acfd0ab79d 100644 --- a/tests/unit/out/unsafe/goto_aggregate_default.rs +++ b/tests/unit/out/unsafe/goto_aggregate_default.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct Point { pub x: i32, @@ -26,7 +25,7 @@ pub unsafe fn agg_0(mut n: i32) -> i32 { let mut buf256: [u8; 256] = [0_u8; 256]; let mut arr64: [i32; 64] = [0_i32; 64]; let mut longs: [i64; 33] = [0_i64; 33]; - let mut p: Point = ::default(); + let mut p: Point = unsafe { ::zero_init() }; let mut ptr: *mut i32 = std::ptr::null_mut(); let mut fp: Option i32> = None; let mut file: *mut ::libc::FILE = std::ptr::null_mut(); diff --git a/tests/unit/out/unsafe/goto_cleanup.rs b/tests/unit/out/unsafe/goto_cleanup.rs index 17ac7a507a..77d335380f 100644 --- a/tests/unit/out/unsafe/goto_cleanup.rs +++ b/tests/unit/out/unsafe/goto_cleanup.rs @@ -85,7 +85,6 @@ pub unsafe fn from_switch_2(mut n: i32) -> i32 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, 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 cb7efdb49b..a7a0d04611 100644 --- a/tests/unit/out/unsafe/huffman.rs +++ b/tests/unit/out/unsafe/huffman.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -52,12 +51,7 @@ pub unsafe fn Swap_0(a: *mut MinHeapNode, b: *mut MinHeapNode) { } #[repr(C)] #[derive( - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - MemberwiseUnsafe, - SwappableUnsafe, - Default, + FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, MemberwiseUnsafe, SwappableUnsafe, )] #[memberwise(move_constructor, move_assign)] #[derive(ConversionsUnsafe)] @@ -280,7 +274,7 @@ pub unsafe fn AllocMinHeap_1(mut capacity: i32) -> Option> { next: 0, alloc: Some( (0..10000_usize) - .map(|_| ::default()) + .map(|_| unsafe { ::zero_init() }) .collect::>(), ), })); 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 8ab42f850f..41101b5fb2 100644 --- a/tests/unit/out/unsafe/immutable-deref-on-func-call.rs +++ b/tests/unit/out/unsafe/immutable-deref-on-func-call.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -36,7 +35,7 @@ pub fn main() { unsafe fn main_0() -> i32 { let mut arr: *mut Item = Box::leak( (0..2_usize) - .map(|_| ::default()) + .map(|_| unsafe { ::zero_init() }) .collect::>(), ) .as_mut_ptr(); diff --git a/tests/unit/out/unsafe/implicit_autoref.rs b/tests/unit/out/unsafe/implicit_autoref.rs index f064c49e32..ae18ea1581 100644 --- a/tests/unit/out/unsafe/implicit_autoref.rs +++ b/tests/unit/out/unsafe/implicit_autoref.rs @@ -16,7 +16,6 @@ use std::rc::Rc; MemberwiseUnsafe, CopyConstructibleUnsafe, SwappableUnsafe, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(ConversionsUnsafe)] diff --git a/tests/unit/out/unsafe/init.rs b/tests/unit/out/unsafe/init.rs index 0f36941bdf..5b3306f82a 100644 --- a/tests/unit/out/unsafe/init.rs +++ b/tests/unit/out/unsafe/init.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -37,7 +36,7 @@ unsafe fn main_0() -> i32 { let g: *mut i32 = &mut x; let mut q: *mut i32 = (&mut x as *mut i32); let mut z: *mut i32 = p; - let mut xx: X = ::default(); + let mut xx: X = unsafe { ::zero_init() }; let mut zz: *mut X = (&mut xx as *mut X); xx.x = 1; q = (&mut xx.x as *mut i32); diff --git a/tests/unit/out/unsafe/kruskal.rs b/tests/unit/out/unsafe/kruskal.rs index 7028ca1939..fd7fd488e3 100644 --- a/tests/unit/out/unsafe/kruskal.rs +++ b/tests/unit/out/unsafe/kruskal.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -176,12 +175,7 @@ pub unsafe fn quicksort_1(arr: *mut Option>, mut start: i32, mut end } #[repr(C)] #[derive( - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - MemberwiseUnsafe, - SwappableUnsafe, - Default, + FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, MemberwiseUnsafe, SwappableUnsafe, )] #[memberwise(move_constructor, move_assign)] #[derive(ConversionsUnsafe)] @@ -304,12 +298,7 @@ impl DisjointSet { } #[repr(C)] #[derive( - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - MemberwiseUnsafe, - SwappableUnsafe, - Default, + FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, MemberwiseUnsafe, SwappableUnsafe, )] #[memberwise(move_constructor, move_assign)] #[derive(ConversionsUnsafe)] @@ -394,7 +383,7 @@ unsafe fn main_0() -> i32 { let mut graph: Graph = Graph { edges: Some( (0..(E as usize)) - .map(|_| ::default()) + .map(|_| unsafe { ::zero_init() }) .collect::>(), ), V: V, diff --git a/tests/unit/out/unsafe/lambda_as_field.rs b/tests/unit/out/unsafe/lambda_as_field.rs index cd0356b6f9..80ec74c5bc 100644 --- a/tests/unit/out/unsafe/lambda_as_field.rs +++ b/tests/unit/out/unsafe/lambda_as_field.rs @@ -68,20 +68,6 @@ impl Holder__lambda_at_lambda_as_field_cpp_39_12__ { return (unsafe { (*this).f.call(x) }); } } -impl Default for Holder__lambda_at_lambda_as_field_cpp_39_12__ { - fn default() -> Self { - unsafe { - Holder__lambda_at_lambda_as_field_cpp_39_12__ { - f: FnPtr:: i32>::new(|mut x: i32| -> i32 { - unsafe { - return ((x) + (1)); - } - }), - calls: 0_i32, - } - } - } -} #[repr(C)] #[derive( Clone, @@ -90,7 +76,6 @@ impl Default for Holder__lambda_at_lambda_as_field_cpp_39_12__ { ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -126,11 +111,6 @@ impl Moving__lambda_at_lambda_as_field_cpp_64_12__ { (&raw mut (*this).moves).write((((*o).moves) + (1))); } } -impl Default for Moving__lambda_at_lambda_as_field_cpp_64_12__ { - fn default() -> Self { - unsafe { ::zero_init() } - } -} pub unsafe fn wrap_0(mut fn_: FnPtr i32>) -> FnPtr i32> { return lambda_unsafe!( { diff --git a/tests/unit/out/unsafe/lambda_capture_copy_ctor.rs b/tests/unit/out/unsafe/lambda_capture_copy_ctor.rs index a3d0d20e44..95d8384515 100644 --- a/tests/unit/out/unsafe/lambda_capture_copy_ctor.rs +++ b/tests/unit/out/unsafe/lambda_capture_copy_ctor.rs @@ -32,17 +32,6 @@ impl Counted { (&raw mut (*this).moves).write((((*o).moves) + (1))); } } -impl Default for Counted { - fn default() -> Self { - unsafe { - { - let mut __v: Counted = ZeroInitializationUnsafe::zero_init(); - Counted::constructor_1(&raw mut __v); - __v - } - } - } -} pub static mut drops_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] #[derive(FnPtrArg, ZeroInitializationUnsafe, ConversionsUnsafe)] diff --git a/tests/unit/out/unsafe/lambda_capture_ref.rs b/tests/unit/out/unsafe/lambda_capture_ref.rs index 70a8492246..c6922c0f2f 100644 --- a/tests/unit/out/unsafe/lambda_capture_ref.rs +++ b/tests/unit/out/unsafe/lambda_capture_ref.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/lambda_capture_star_this.rs b/tests/unit/out/unsafe/lambda_capture_star_this.rs index d2de505594..a693b3d88f 100644 --- a/tests/unit/out/unsafe/lambda_capture_star_this.rs +++ b/tests/unit/out/unsafe/lambda_capture_star_this.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/lambda_capture_this.rs b/tests/unit/out/unsafe/lambda_capture_this.rs index 25e3fc0593..0a8524052e 100644 --- a/tests/unit/out/unsafe/lambda_capture_this.rs +++ b/tests/unit/out/unsafe/lambda_capture_this.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/lambda_capture_value.rs b/tests/unit/out/unsafe/lambda_capture_value.rs index 3f53a18ed6..d3faefb8f6 100644 --- a/tests/unit/out/unsafe/lambda_capture_value.rs +++ b/tests/unit/out/unsafe/lambda_capture_value.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/lambda_decltype_type.rs b/tests/unit/out/unsafe/lambda_decltype_type.rs index 359658656c..5e2c0f2553 100644 --- a/tests/unit/out/unsafe/lambda_decltype_type.rs +++ b/tests/unit/out/unsafe/lambda_decltype_type.rs @@ -44,21 +44,6 @@ impl Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { )); } } -impl Default for Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { - fn default() -> Self { - unsafe { - Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { - items: [0_i32; 4], - size: 0, - cmp: FnPtr:: bool>::new(|mut a: i32, mut b: i32| -> bool { - unsafe { - return ((a) > (b)); - } - }), - } - } - } -} #[repr(C)] #[derive( Clone, VaArg, FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, ConversionsUnsafe, @@ -97,21 +82,6 @@ impl Sorted__lambda_at_lambda_decltype_type_cpp_19_23__ { )); } } -impl Default for Sorted__lambda_at_lambda_decltype_type_cpp_19_23__ { - fn default() -> Self { - unsafe { - Sorted__lambda_at_lambda_decltype_type_cpp_19_23__ { - items: [0_i32; 4], - size: 0, - cmp: FnPtr:: bool>::new(|mut a: i32, mut b: i32| -> bool { - unsafe { - return ((a) < (b)); - } - }), - } - } - } -} pub fn main() { unsafe { __cpp2rust_init_globals(); diff --git a/tests/unit/out/unsafe/lambda_generic_explicit_args.rs b/tests/unit/out/unsafe/lambda_generic_explicit_args.rs index d7dd2a6d11..28bf439972 100644 --- a/tests/unit/out/unsafe/lambda_generic_explicit_args.rs +++ b/tests/unit/out/unsafe/lambda_generic_explicit_args.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/lambda_immediate_init.rs b/tests/unit/out/unsafe/lambda_immediate_init.rs index b938db43ce..eded55df01 100644 --- a/tests/unit/out/unsafe/lambda_immediate_init.rs +++ b/tests/unit/out/unsafe/lambda_immediate_init.rs @@ -40,23 +40,6 @@ impl S { ); } } -impl Default for S { - fn default() -> Self { - unsafe { - S { - j: 10, - k: ((unsafe { - FnPtr:: i32>::new(|| -> i32 { - unsafe { - return 3; - } - }) - .call() - }) + (1)), - } - } - } -} pub static mut g_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { (unsafe { FnPtr:: i32>::new(|| -> i32 { diff --git a/tests/unit/out/unsafe/lambda_nested.rs b/tests/unit/out/unsafe/lambda_nested.rs index 9a276cf17e..e0197eccc5 100644 --- a/tests/unit/out/unsafe/lambda_nested.rs +++ b/tests/unit/out/unsafe/lambda_nested.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/lambda_static_local.rs b/tests/unit/out/unsafe/lambda_static_local.rs index 08d48ccff2..073cdb7c4a 100644 --- a/tests/unit/out/unsafe/lambda_static_local.rs +++ b/tests/unit/out/unsafe/lambda_static_local.rs @@ -76,7 +76,6 @@ static mut calls_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsaf ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/libc_struct_without_default.rs b/tests/unit/out/unsafe/libc_struct_without_default.rs index eee5baa317..8de8e834f8 100644 --- a/tests/unit/out/unsafe/libc_struct_without_default.rs +++ b/tests/unit/out/unsafe/libc_struct_without_default.rs @@ -31,16 +31,6 @@ impl UserDefined { (&raw mut (*this).v).write(Vec::new()); } } -impl Default for UserDefined { - fn default() -> Self { - unsafe { - UserDefined { - a: std::array::from_fn::<_, 1, _>(|_| 0_i32), - v: Default::default(), - } - } - } -} #[repr(C)] #[derive( Copy, @@ -56,15 +46,6 @@ impl Default for UserDefined { pub struct FieldIsLibcType { pub addr: libc::sockaddr, } -impl Default for FieldIsLibcType { - fn default() -> Self { - unsafe { - FieldIsLibcType { - addr: std::mem::zeroed(), - } - } - } -} pub fn main() { unsafe { __cpp2rust_init_globals(); @@ -96,7 +77,7 @@ unsafe fn main_0() -> i32 { ud.a[(0_usize)] = 3; assert!(((ud.a[(0_usize)]) == (3))); assert!(((ud.v.len()) == (0_usize))); - let mut filt: FieldIsLibcType = ::default(); + let mut filt: FieldIsLibcType = unsafe { ::zero_init() }; filt.addr.sa_family = (2 as libc::sa_family_t); assert!(((filt.addr.sa_family as i32) == (2))); return 0; diff --git a/tests/unit/out/unsafe/linked_list.rs b/tests/unit/out/unsafe/linked_list.rs index b5e917018d..e4d8abdea5 100644 --- a/tests/unit/out/unsafe/linked_list.rs +++ b/tests/unit/out/unsafe/linked_list.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/local_anon_struct_collision.rs b/tests/unit/out/unsafe/local_anon_struct_collision.rs index 6bc09413c4..5f29852560 100644 --- a/tests/unit/out/unsafe/local_anon_struct_collision.rs +++ b/tests/unit/out/unsafe/local_anon_struct_collision.rs @@ -7,7 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub unsafe fn first_0() -> i32 { - let mut p: anon_1 = ::default(); + let mut p: anon_1 = unsafe { ::zero_init() }; p.x = 1; p.y = 2; return ((p.x) + (p.y)); @@ -21,14 +21,13 @@ pub unsafe fn first_0() -> i32 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct anon_1 { pub x: i32, pub y: i32, } pub unsafe fn second_2() -> i32 { - let mut q: anon_3 = ::default(); + let mut q: anon_3 = unsafe { ::zero_init() }; q.a = 10_i64; q.b = 20_i64; return (((q.a) + (q.b)) as i32); @@ -42,7 +41,6 @@ pub unsafe fn second_2() -> i32 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, 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 3c54b068d8..65b51ff32e 100644 --- a/tests/unit/out/unsafe/local_record_template.rs +++ b/tests/unit/out/unsafe/local_record_template.rs @@ -38,7 +38,6 @@ pub unsafe fn wrap_10(mut v: i64) -> i32 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -54,7 +53,6 @@ pub struct Local_5 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -74,7 +72,6 @@ pub unsafe fn other_11() -> i32 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -106,7 +103,6 @@ unsafe fn main_0() -> i32 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/map_key_copy_ctor.rs b/tests/unit/out/unsafe/map_key_copy_ctor.rs index 716f383024..7f79eedc9b 100644 --- a/tests/unit/out/unsafe/map_key_copy_ctor.rs +++ b/tests/unit/out/unsafe/map_key_copy_ctor.rs @@ -10,9 +10,7 @@ pub static mut copies_0: std::cell::LazyCell = std::cell::LazyCell::new(|| pub static mut moves_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut made_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, Default, ConversionsUnsafe, -)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, ConversionsUnsafe)] #[conversions(copy, move)] #[constructor(constructor_1, i32)] #[constructor(constructor_2, LvalueRefUnsafe>)] diff --git a/tests/unit/out/unsafe/map_try_emplace.rs b/tests/unit/out/unsafe/map_try_emplace.rs index 8e174ec643..9fda60634f 100644 --- a/tests/unit/out/unsafe/map_try_emplace.rs +++ b/tests/unit/out/unsafe/map_try_emplace.rs @@ -40,17 +40,6 @@ impl Item { (*other).value = -1_i32; } } -impl Default for Item { - fn default() -> Self { - unsafe { - { - let mut __v: Item = ZeroInitializationUnsafe::zero_init(); - Item::constructor_1(&raw mut __v); - __v - } - } - } -} pub unsafe fn argument_4(item: *mut Item) -> *mut Item { (*std::cell::LazyCell::force_mut(&mut *&raw mut calls_0)).prefix_inc(); return item; @@ -84,17 +73,6 @@ impl RefItem { (*std::cell::LazyCell::force_mut(&mut *&raw mut made_1)).prefix_inc(); } } -impl Default for RefItem { - fn default() -> Self { - unsafe { - { - let mut __v: RefItem = ZeroInitializationUnsafe::zero_init(); - RefItem::constructor_1(&raw mut __v); - __v - } - } - } -} pub unsafe fn reference_5(counter: *mut i32) -> *mut i32 { (*std::cell::LazyCell::force_mut(&mut *&raw mut calls_0)).prefix_inc(); return counter; diff --git a/tests/unit/out/unsafe/max.rs b/tests/unit/out/unsafe/max.rs index 52daa3f512..2618adf3db 100644 --- a/tests/unit/out/unsafe/max.rs +++ b/tests/unit/out/unsafe/max.rs @@ -25,7 +25,6 @@ pub unsafe fn pick_3(mut i: i32) -> *mut i32 { MoveConstructibleUnsafe, MoveAssignableUnsafe, SwappableUnsafe, - Default, )] #[memberwise(copy_assign)] #[derive(ConversionsUnsafe)] diff --git a/tests/unit/out/unsafe/memcpy_struct_bytes.rs b/tests/unit/out/unsafe/memcpy_struct_bytes.rs index 2009639c7e..c95fcbb6cf 100644 --- a/tests/unit/out/unsafe/memcpy_struct_bytes.rs +++ b/tests/unit/out/unsafe/memcpy_struct_bytes.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct point { pub x: i32, @@ -38,7 +37,7 @@ unsafe fn main_0() -> i32 { } __tmp_0 }; - let mut dst: point = ::default(); + let mut dst: point = unsafe { ::zero_init() }; { let mut __tmp_2 = { ((&mut dst as *mut point) as *mut ::libc::c_void) }; let mut __tmp_3 = { (buf.as_mut_ptr() as *const ::libc::c_void) }; diff --git a/tests/unit/out/unsafe/memcpy_struct_layouts.rs b/tests/unit/out/unsafe/memcpy_struct_layouts.rs index a5b4b4e426..cd141664b4 100644 --- a/tests/unit/out/unsafe/memcpy_struct_layouts.rs +++ b/tests/unit/out/unsafe/memcpy_struct_layouts.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct packed { pub a: i32, @@ -32,7 +31,6 @@ pub struct packed { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct reordered { pub a: libc::c_char, @@ -48,7 +46,6 @@ pub struct reordered { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct tail { pub a: libc::c_char, @@ -63,7 +60,6 @@ pub struct tail { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct nested { pub t: tail, @@ -78,7 +74,6 @@ pub struct nested { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct array { pub name: [libc::c_char; 3], @@ -117,7 +112,7 @@ unsafe fn main_0() -> i32 { assert!( ((buf[((::std::mem::size_of::() as usize).wrapping_add(4_usize))] as i32) == (6)) ); - let mut p2: [packed; 2] = [::default(); 2]; + let mut p2: [packed; 2] = [unsafe { ::zero_init() }; 2]; { let mut __tmp_2 = { (p2.as_mut_ptr() as *mut ::libc::c_void) }; let mut __tmp_3 = { (buf.as_mut_ptr() as *const ::libc::c_void) }; @@ -159,7 +154,7 @@ unsafe fn main_0() -> i32 { ((buf[((::std::mem::size_of::() as usize).wrapping_add(8_usize))] as i32) == (6)) ); - let mut r2: [reordered; 2] = [::default(); 2]; + let mut r2: [reordered; 2] = [unsafe { ::zero_init() }; 2]; { let mut __tmp_6 = { (r2.as_mut_ptr() as *mut ::libc::c_void) }; let mut __tmp_7 = { (buf.as_mut_ptr() as *const ::libc::c_void) }; @@ -203,7 +198,7 @@ unsafe fn main_0() -> i32 { assert!( ((buf[((::std::mem::size_of::() as usize).wrapping_add(16_usize))] as i32) == (6)) ); - let mut n2: [nested; 2] = [::default(); 2]; + let mut n2: [nested; 2] = [unsafe { ::zero_init() }; 2]; { let mut __tmp_10 = { (n2.as_mut_ptr() as *mut ::libc::c_void) }; let mut __tmp_11 = { (buf.as_mut_ptr() as *const ::libc::c_void) }; @@ -242,7 +237,7 @@ unsafe fn main_0() -> i32 { ((buf[((::std::mem::size_of::() as usize).wrapping_add(1_usize))] as i32) == ('d' as i32)) ); - let mut a2: [array; 2] = [::default(); 2]; + let mut a2: [array; 2] = [unsafe { ::zero_init() }; 2]; { let mut __tmp_14 = { (a2.as_mut_ptr() as *mut ::libc::c_void) }; let mut __tmp_15 = { (buf.as_mut_ptr() as *const ::libc::c_void) }; diff --git a/tests/unit/out/unsafe/memcpy_struct_struct.rs b/tests/unit/out/unsafe/memcpy_struct_struct.rs index e2a8ed6756..d2bebd14c3 100644 --- a/tests/unit/out/unsafe/memcpy_struct_struct.rs +++ b/tests/unit/out/unsafe/memcpy_struct_struct.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/memset_struct_tail.rs b/tests/unit/out/unsafe/memset_struct_tail.rs index cd756001e9..2146fa0efe 100644 --- a/tests/unit/out/unsafe/memset_struct_tail.rs +++ b/tests/unit/out/unsafe/memset_struct_tail.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, 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 215170a416..50f3947a0b 100644 --- a/tests/unit/out/unsafe/move_assign.rs +++ b/tests/unit/out/unsafe/move_assign.rs @@ -12,7 +12,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, DefaultInitializableUnsafe, SwappableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(move)] @@ -67,17 +66,6 @@ impl ConstMoveAssign { return &mut (*this); } } -impl Default for ConstMoveAssign { - fn default() -> Self { - unsafe { - { - let mut __v: ConstMoveAssign = ZeroInitializationUnsafe::zero_init(); - ConstMoveAssign::constructor_1(&raw mut __v); - __v - } - } - } -} pub unsafe fn make_0(__return: *mut MoveOnly, mut v: i32) { object_unsafe!(m, MoveOnly::constructor_1(v)); MoveOnly::constructor_3(__return, RvalueRefUnsafe::bind(&mut m)); diff --git a/tests/unit/out/unsafe/move_ctor.rs b/tests/unit/out/unsafe/move_ctor.rs index 560f78c913..bebc1ba94b 100644 --- a/tests/unit/out/unsafe/move_ctor.rs +++ b/tests/unit/out/unsafe/move_ctor.rs @@ -7,9 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, Default, ConversionsUnsafe, -)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, ConversionsUnsafe)] #[conversions(move)] #[constructor(constructor_1, i32)] #[constructor(constructor_3, RvalueRefUnsafe)] @@ -48,21 +46,8 @@ impl ConstMove { (&raw mut (*this).mark).write((((*o).mark) + (10))); } } -impl Default for ConstMove { - fn default() -> Self { - unsafe { - { - let mut __v: ConstMove = ZeroInitializationUnsafe::zero_init(); - ConstMove::constructor_1(&raw mut __v); - __v - } - } - } -} #[repr(C)] -#[derive( - FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, Default, ConversionsUnsafe, -)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, ConversionsUnsafe)] #[conversions(copy, move)] #[constructor(constructor_1, i32)] #[constructor(constructor_2, LvalueRefUnsafe>)] @@ -93,9 +78,7 @@ impl ThrowingMove { } } #[repr(C)] -#[derive( - FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, Default, ConversionsUnsafe, -)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, ConversionsUnsafe)] #[conversions(copy, move)] #[constructor(constructor_1, i32)] #[constructor(constructor_2, LvalueRefUnsafe>)] diff --git a/tests/unit/out/unsafe/move_this.rs b/tests/unit/out/unsafe/move_this.rs index bf79529233..33d1658373 100644 --- a/tests/unit/out/unsafe/move_this.rs +++ b/tests/unit/out/unsafe/move_this.rs @@ -7,9 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] -#[derive( - FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, Default, ConversionsUnsafe, -)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, ConversionsUnsafe)] #[conversions(copy, move)] #[constructor(constructor_1, i32)] #[constructor(constructor_2, LvalueRefUnsafe>)] diff --git a/tests/unit/out/unsafe/nested_structs.rs b/tests/unit/out/unsafe/nested_structs.rs index bfb1764e3f..2c5ecf6797 100644 --- a/tests/unit/out/unsafe/nested_structs.rs +++ b/tests/unit/out/unsafe/nested_structs.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -31,7 +30,6 @@ pub struct Level0_Level1_1_Level2_1_Level3_1 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -48,7 +46,6 @@ pub struct Level0_Level1_1_Level2_1_Level3_2 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -64,7 +61,6 @@ pub struct Level0_Level1_1_Level2_1 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -80,7 +76,6 @@ pub struct Level0_Level1_1 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -97,7 +92,6 @@ pub struct Level0_Level1_2 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/new.rs b/tests/unit/out/unsafe/new.rs index 374d0c37ce..5ff648dc5e 100644 --- a/tests/unit/out/unsafe/new.rs +++ b/tests/unit/out/unsafe/new.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -48,7 +47,7 @@ unsafe fn main_0() -> i32 { ::std::mem::drop(Box::from_raw(__p)) } }; - let mut p: *mut Pair = (Box::leak(Box::new(::default())) as *mut Pair); + let mut p: *mut Pair = (Box::leak(Box::new(unsafe { ::zero_init() })) as *mut Pair); (*p).x = 1; (*p).y = 2; assert!(((((*p).x) + ((*p).y)) == (3))); diff --git a/tests/unit/out/unsafe/new_bst.rs b/tests/unit/out/unsafe/new_bst.rs index 7837ddd131..8ed40091be 100644 --- a/tests/unit/out/unsafe/new_bst.rs +++ b/tests/unit/out/unsafe/new_bst.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/new_struct.rs b/tests/unit/out/unsafe/new_struct.rs index 0ffe4e02f1..1de8290e5b 100644 --- a/tests/unit/out/unsafe/new_struct.rs +++ b/tests/unit/out/unsafe/new_struct.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -32,7 +31,6 @@ pub struct Pair { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -60,7 +58,7 @@ unsafe fn main_0() -> i32 { let mut t: Triple = Triple { a: 1, b: 0_i32, - p: ::default(), + p: unsafe { ::zero_init() }, }; assert!(((t.a) == (1))); assert!(((t.b) == (0))); @@ -68,7 +66,7 @@ unsafe fn main_0() -> i32 { let mut q: *mut Triple = (Box::leak(Box::new(Triple { a: 2, b: 3, - p: ::default(), + p: unsafe { ::zero_init() }, })) as *mut Triple); assert!((((*q).a) == (2))); assert!((((*q).b) == (3))); diff --git a/tests/unit/out/unsafe/nttp_distinct_specializations.rs b/tests/unit/out/unsafe/nttp_distinct_specializations.rs index 2e455c7a70..1683763153 100644 --- a/tests/unit/out/unsafe/nttp_distinct_specializations.rs +++ b/tests/unit/out/unsafe/nttp_distinct_specializations.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -37,7 +36,6 @@ impl S_2_ { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -58,7 +56,6 @@ impl S_1_ { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/offsetof.rs b/tests/unit/out/unsafe/offsetof.rs index 034870dd88..79d9559235 100644 --- a/tests/unit/out/unsafe/offsetof.rs +++ b/tests/unit/out/unsafe/offsetof.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -40,16 +39,6 @@ pub struct Frame { pub tag: u16, pub body: [libc::c_char; 64], } -impl Default for Frame { - fn default() -> Self { - unsafe { - Frame { - tag: 0_u16, - body: [(0 as libc::c_char); 64], - } - } - } -} pub fn main() { unsafe { __cpp2rust_init_globals(); diff --git a/tests/unit/out/unsafe/opaque_forward_decl.rs b/tests/unit/out/unsafe/opaque_forward_decl.rs index 54d591d405..e4bc807b8f 100644 --- a/tests/unit/out/unsafe/opaque_forward_decl.rs +++ b/tests/unit/out/unsafe/opaque_forward_decl.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, 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 6c3042bf02..c4fceeb3b0 100644 --- a/tests/unit/out/unsafe/opaque_record_copy.rs +++ b/tests/unit/out/unsafe/opaque_record_copy.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -29,7 +28,6 @@ pub struct Probe {} ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -44,7 +42,7 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut a: Wrapper_Probe_ = ::default(); + let mut a: Wrapper_Probe_ = unsafe { ::zero_init() }; a.tag = 3; let mut b: Wrapper_Probe_ = a; assert!(((b.tag) == (3))); diff --git a/tests/unit/out/unsafe/opaque_then_defined.rs b/tests/unit/out/unsafe/opaque_then_defined.rs index fabebaf001..3d1f41b5ab 100644 --- a/tests/unit/out/unsafe/opaque_then_defined.rs +++ b/tests/unit/out/unsafe/opaque_then_defined.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct list { pub head: *mut node, @@ -30,7 +29,6 @@ pub struct list { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, 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 7a9dccd758..2a1b5d3aed 100644 --- a/tests/unit/out/unsafe/operator_arithmetic_free.rs +++ b/tests/unit/out/unsafe/operator_arithmetic_free.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/operator_arithmetic_member.rs b/tests/unit/out/unsafe/operator_arithmetic_member.rs index 681ebd8169..4b9247476a 100644 --- a/tests/unit/out/unsafe/operator_arithmetic_member.rs +++ b/tests/unit/out/unsafe/operator_arithmetic_member.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/operator_bitwise_free.rs b/tests/unit/out/unsafe/operator_bitwise_free.rs index 57a7d648ba..c8e80316eb 100644 --- a/tests/unit/out/unsafe/operator_bitwise_free.rs +++ b/tests/unit/out/unsafe/operator_bitwise_free.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/operator_bitwise_member.rs b/tests/unit/out/unsafe/operator_bitwise_member.rs index 351eaa5d27..f223eb45b4 100644 --- a/tests/unit/out/unsafe/operator_bitwise_member.rs +++ b/tests/unit/out/unsafe/operator_bitwise_member.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/operator_comparison_defaulted.rs b/tests/unit/out/unsafe/operator_comparison_defaulted.rs index 94ba85e9ea..d523c202be 100644 --- a/tests/unit/out/unsafe/operator_comparison_defaulted.rs +++ b/tests/unit/out/unsafe/operator_comparison_defaulted.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -32,7 +31,6 @@ pub struct Eq { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, PartiallyOrderedWithUnsafe, )] #[three_way(ThreeWayComparableUnsafe::three_way)] @@ -76,7 +74,6 @@ impl LessThanComparableUnsafe for Cmp { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, PartiallyOrderedWithUnsafe, )] #[three_way(ThreeWayComparableUnsafe::three_way)] @@ -112,7 +109,6 @@ impl LessThanComparableUnsafe for Both { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, PartiallyOrderedWithUnsafe, )] #[three_way(OrdOnly::operator_cmp)] @@ -147,7 +143,6 @@ impl LessThanComparableUnsafe for OrdOnly { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, PartiallyOrderedWithUnsafe, )] #[three_way(ThreeWayComparableUnsafe::three_way)] @@ -183,7 +178,6 @@ impl LessThanComparableUnsafe for Inner { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, PartiallyOrderedWithUnsafe, )] #[three_way(ThreeWayComparableUnsafe::three_way)] @@ -229,7 +223,6 @@ impl LessThanComparableUnsafe for Outer { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -265,7 +258,6 @@ impl LessThanComparableUnsafe for Secondary { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, PartiallyOrderedWithUnsafe, )] #[three_way(ThreeWayComparableUnsafe::three_way)] diff --git a/tests/unit/out/unsafe/operator_comparison_free.rs b/tests/unit/out/unsafe/operator_comparison_free.rs index 3f29909619..f082324a16 100644 --- a/tests/unit/out/unsafe/operator_comparison_free.rs +++ b/tests/unit/out/unsafe/operator_comparison_free.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -42,7 +41,6 @@ pub unsafe fn operator_lt_1(mut a: i32, b: *const S) -> bool { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/operator_comparison_member.rs b/tests/unit/out/unsafe/operator_comparison_member.rs index 4e3b54c8b4..5ec1353c02 100644 --- a/tests/unit/out/unsafe/operator_comparison_member.rs +++ b/tests/unit/out/unsafe/operator_comparison_member.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/operator_comparison_mixed.rs b/tests/unit/out/unsafe/operator_comparison_mixed.rs index a19dca88fe..2a46635877 100644 --- a/tests/unit/out/unsafe/operator_comparison_mixed.rs +++ b/tests/unit/out/unsafe/operator_comparison_mixed.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/operator_comparison_nonbool.rs b/tests/unit/out/unsafe/operator_comparison_nonbool.rs index d267606bf5..53e1ba94a8 100644 --- a/tests/unit/out/unsafe/operator_comparison_nonbool.rs +++ b/tests/unit/out/unsafe/operator_comparison_nonbool.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -54,7 +53,6 @@ pub unsafe fn operator_ge_3(mut a: X, mut b: X) -> i32 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -70,7 +68,6 @@ pub struct Result { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -93,7 +90,6 @@ impl Custom { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -127,7 +123,6 @@ impl LessThanComparableUnsafe for Mixed { ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -153,7 +148,6 @@ impl MyBool { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -189,7 +183,6 @@ pub unsafe fn operator_lt_6(mut a: Boolish, mut b: Boolish) -> MyBool { DefaultInitializableUnsafe, MemberwiseUnsafe, MoveAssignableUnsafe, - Default, )] #[memberwise(copy_assign)] #[derive(ConversionsUnsafe)] @@ -222,7 +215,6 @@ pub static mut ref_true_8: std::cell::LazyCell = std::cell::LazyCell::n ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/operator_comparison_noncopyable.rs b/tests/unit/out/unsafe/operator_comparison_noncopyable.rs index d2172b3b03..ea0637ac01 100644 --- a/tests/unit/out/unsafe/operator_comparison_noncopyable.rs +++ b/tests/unit/out/unsafe/operator_comparison_noncopyable.rs @@ -12,9 +12,7 @@ impl LessThanComparableUnsafe for S { } } #[repr(C)] -#[derive( - FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, MemberwiseUnsafe, Default, -)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, MemberwiseUnsafe)] #[memberwise(move_constructor)] #[derive(ConversionsUnsafe)] #[conversions(move)] diff --git a/tests/unit/out/unsafe/operator_compound_assignment_free.rs b/tests/unit/out/unsafe/operator_compound_assignment_free.rs index d07f94df86..a180bde94e 100644 --- a/tests/unit/out/unsafe/operator_compound_assignment_free.rs +++ b/tests/unit/out/unsafe/operator_compound_assignment_free.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/operator_compound_assignment_member.rs b/tests/unit/out/unsafe/operator_compound_assignment_member.rs index bd8b89492b..a8eaf7dd0f 100644 --- a/tests/unit/out/unsafe/operator_compound_assignment_member.rs +++ b/tests/unit/out/unsafe/operator_compound_assignment_member.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/operator_friend.rs b/tests/unit/out/unsafe/operator_friend.rs index 1d43aabf16..62e33bc3a1 100644 --- a/tests/unit/out/unsafe/operator_friend.rs +++ b/tests/unit/out/unsafe/operator_friend.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -48,7 +47,6 @@ impl ThreeWayComparableUnsafe for DefaultedOrd { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, PartiallyOrderedWithUnsafe, )] #[three_way(ThreeWayComparableUnsafe::three_way)] @@ -81,7 +79,6 @@ pub unsafe fn operator_add_0(x: *const Inline, y: *const Inline) -> Inline { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -97,7 +94,6 @@ pub struct Inline { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -118,7 +114,6 @@ impl LessThanComparableUnsafe for Tmpl_int_ { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -134,7 +129,6 @@ pub struct Tmpl_int_ { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -150,7 +144,6 @@ pub struct Tmpl_long_ { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/operator_less_than.rs b/tests/unit/out/unsafe/operator_less_than.rs index a80f6bd106..0c9faafe39 100644 --- a/tests/unit/out/unsafe/operator_less_than.rs +++ b/tests/unit/out/unsafe/operator_less_than.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/operator_logical_free.rs b/tests/unit/out/unsafe/operator_logical_free.rs index 440d7d9a09..57fa6d30e5 100644 --- a/tests/unit/out/unsafe/operator_logical_free.rs +++ b/tests/unit/out/unsafe/operator_logical_free.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/operator_logical_member.rs b/tests/unit/out/unsafe/operator_logical_member.rs index 5de075709d..5aab222b25 100644 --- a/tests/unit/out/unsafe/operator_logical_member.rs +++ b/tests/unit/out/unsafe/operator_logical_member.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/operator_member_pointer_free.rs b/tests/unit/out/unsafe/operator_member_pointer_free.rs index 9daac8ade1..5912bae537 100644 --- a/tests/unit/out/unsafe/operator_member_pointer_free.rs +++ b/tests/unit/out/unsafe/operator_member_pointer_free.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -31,7 +30,6 @@ pub struct Inner { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/operator_member_pointer_member.rs b/tests/unit/out/unsafe/operator_member_pointer_member.rs index c44182e765..902645dc28 100644 --- a/tests/unit/out/unsafe/operator_member_pointer_member.rs +++ b/tests/unit/out/unsafe/operator_member_pointer_member.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -31,7 +30,6 @@ pub struct Inner { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -52,7 +50,6 @@ pub static mut table_0: std::cell::LazyCell<[i32; 3]> = ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -102,7 +99,7 @@ unsafe fn main_0() -> i32 { assert!(((*p) == (1))); (*p) = 5; assert!(((s.data[(0) as usize]) == (5))); - let mut t: Table =

::default(); + let mut t: Table = unsafe {
::zero_init() }; assert!(((*(unsafe { Table::operator_index(1,) })) == (8))); (*(unsafe { Table::operator_index(1) })) = 80; assert!((((*std::cell::LazyCell::force_mut(&mut *&raw mut table_0))[(1) as usize]) == (80))); diff --git a/tests/unit/out/unsafe/operator_other_free.rs b/tests/unit/out/unsafe/operator_other_free.rs index 05b8c9c5da..d622a21ef3 100644 --- a/tests/unit/out/unsafe/operator_other_free.rs +++ b/tests/unit/out/unsafe/operator_other_free.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/operator_other_member.rs b/tests/unit/out/unsafe/operator_other_member.rs index d14ee5c86c..ba8c37a2bd 100644 --- a/tests/unit/out/unsafe/operator_other_member.rs +++ b/tests/unit/out/unsafe/operator_other_member.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -34,7 +33,6 @@ impl Static { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -90,7 +88,7 @@ unsafe fn main_0() -> i32 { assert!((unsafe { S::to_bool(&raw const s,) })); assert!(!(unsafe { S::to_bool(&raw const z,) })); assert!((unsafe { S::to_bool(&raw const s,) }) && (!(unsafe { S::to_bool(&raw const z,) }))); - let mut st: Static = ::default(); + let mut st: Static = unsafe { ::zero_init() }; assert!(((unsafe { Static::operator_call(6, 7,) }) == (42))); assert!(((unsafe { S::operator_call_1(&S { v: 5 },) }) == (5))); assert!(((unsafe { S::operator_call_3(&S { v: 5 }, 1, 1,) }) == (7))); diff --git a/tests/unit/out/unsafe/operator_overloads.rs b/tests/unit/out/unsafe/operator_overloads.rs index 1f690397e0..8255e5a0f5 100644 --- a/tests/unit/out/unsafe/operator_overloads.rs +++ b/tests/unit/out/unsafe/operator_overloads.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/operator_qualifiers.rs b/tests/unit/out/unsafe/operator_qualifiers.rs index a177054c4d..d4c3c20670 100644 --- a/tests/unit/out/unsafe/operator_qualifiers.rs +++ b/tests/unit/out/unsafe/operator_qualifiers.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/operator_three_way.rs b/tests/unit/out/unsafe/operator_three_way.rs index adab99e390..9e82a997b0 100644 --- a/tests/unit/out/unsafe/operator_three_way.rs +++ b/tests/unit/out/unsafe/operator_three_way.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, PartiallyOrderedWithUnsafe, )] #[three_way(ThreeWayComparableUnsafe::three_way)] diff --git a/tests/unit/out/unsafe/operator_traits.rs b/tests/unit/out/unsafe/operator_traits.rs index befbfad472..9cbdbfd17a 100644 --- a/tests/unit/out/unsafe/operator_traits.rs +++ b/tests/unit/out/unsafe/operator_traits.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -36,7 +35,6 @@ impl LessThanComparableUnsafe for Lt { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -52,7 +50,6 @@ pub struct Eq { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, PartiallyOrderedWithUnsafe, )] #[three_way(ThreeWayComparableUnsafe::three_way)] @@ -81,7 +78,6 @@ impl LessThanComparableUnsafe for Cmp { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -102,7 +98,6 @@ impl LessThanComparableUnsafe for Free { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/overload_mangling.rs b/tests/unit/out/unsafe/overload_mangling.rs index 005bf039cc..221e93e98c 100644 --- a/tests/unit/out/unsafe/overload_mangling.rs +++ b/tests/unit/out/unsafe/overload_mangling.rs @@ -24,7 +24,6 @@ pub unsafe fn twice_2(mut n: i32) -> i32 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -52,7 +51,6 @@ impl Access_S_ { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -149,7 +147,6 @@ impl S { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -212,7 +209,7 @@ unsafe fn main_0() -> i32 { }) == (107)) ); assert!(((z) == (6))); - let mut a: Access_S_ = ::default(); + let mut a: Access_S_ = unsafe { ::zero_init() }; let mut cs: *const S = (&mut s as *mut S).cast_const(); let cr: *const S = &s; assert!(((unsafe { Access_S_::get_1(&raw mut a, (&mut s as *mut S),) }) == (100))); diff --git a/tests/unit/out/unsafe/pair_converting_construction.rs b/tests/unit/out/unsafe/pair_converting_construction.rs index 2674a4d16b..2a4597e250 100644 --- a/tests/unit/out/unsafe/pair_converting_construction.rs +++ b/tests/unit/out/unsafe/pair_converting_construction.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -37,7 +36,6 @@ impl Celsius { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -59,7 +57,6 @@ impl Meters { ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -82,7 +79,6 @@ impl Label { ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -113,7 +109,6 @@ impl Owner { ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -153,17 +148,6 @@ impl ConstructorUnsafe<()> for Fallback { } } } -impl Default for Fallback { - fn default() -> Self { - unsafe { - { - let mut __v: Fallback = ZeroInitializationUnsafe::zero_init(); - Fallback::constructor_1(&raw mut __v, -1_i32); - __v - } - } - } -} #[repr(C)] #[derive( Copy, @@ -173,7 +157,6 @@ impl Default for Fallback { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -189,7 +172,6 @@ pub struct Counter { ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -219,7 +201,6 @@ impl Tag { ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -236,7 +217,6 @@ pub struct Tag { ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/pod.rs b/tests/unit/out/unsafe/pod.rs index 3f28ae3ae9..dabf5105b6 100644 --- a/tests/unit/out/unsafe/pod.rs +++ b/tests/unit/out/unsafe/pod.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/pointer_array.rs b/tests/unit/out/unsafe/pointer_array.rs index 8d3ed9a99f..e3196b4309 100644 --- a/tests/unit/out/unsafe/pointer_array.rs +++ b/tests/unit/out/unsafe/pointer_array.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/pointers.rs b/tests/unit/out/unsafe/pointers.rs index 658a98e4d9..dae0b184dc 100644 --- a/tests/unit/out/unsafe/pointers.rs +++ b/tests/unit/out/unsafe/pointers.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/ptr_cast_init.rs b/tests/unit/out/unsafe/ptr_cast_init.rs index 2d789809c0..89dd6b4858 100644 --- a/tests/unit/out/unsafe/ptr_cast_init.rs +++ b/tests/unit/out/unsafe/ptr_cast_init.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct header { pub tag: i32, @@ -30,7 +29,6 @@ pub struct header { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, 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 3c4e44ba37..f48b9699c7 100644 --- a/tests/unit/out/unsafe/push_emplace_back.rs +++ b/tests/unit/out/unsafe/push_emplace_back.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -31,7 +30,6 @@ pub struct Chunk { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -49,7 +47,6 @@ pub struct Writer { MemberwiseUnsafe, CopyConstructibleUnsafe, SwappableUnsafe, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(ConversionsUnsafe)] @@ -163,17 +160,6 @@ impl Pair { (&raw mut (*this).second).write(((b) * (2))); } } -impl Default for Pair { - fn default() -> Self { - unsafe { - { - let mut __v: Pair = ZeroInitializationUnsafe::zero_init(); - Pair::constructor_1(&raw mut __v); - __v - } - } - } -} pub unsafe fn emplace_ctor_args_7(mut pairs: *mut Vec) { (*pairs).push_mut({ let mut __v: Pair = ZeroInitializationUnsafe::zero_init(); @@ -254,7 +240,6 @@ pub unsafe fn emplace_ref_self_read_13(values: *mut Vec) -> *mut i64 { MemberwiseUnsafe, CopyConstructibleUnsafe, SwappableUnsafe, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(ConversionsUnsafe)] @@ -296,7 +281,6 @@ pub unsafe fn emplace_from_element_14(mut v: *mut Vec>) { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -322,7 +306,6 @@ pub static mut all_counted_16: std::cell::LazyCell<*mut Vec> = ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -385,7 +368,7 @@ unsafe fn main_0() -> i32 { let mut chunks: Vec = Vec::new(); (unsafe { shrink_through_ptr_2((&mut chunks as *mut Vec)) }); assert!(chunks.is_empty()); - let mut w: Writer = ::default(); + let mut w: Writer = unsafe { ::zero_init() }; w.chunk.data = 42; w.output = (&mut chunks as *mut Vec); (unsafe { nested_push_move_3((&mut w as *mut Writer)) }); diff --git a/tests/unit/out/unsafe/random.rs b/tests/unit/out/unsafe/random.rs index 24f6193f2b..30df31afe1 100644 --- a/tests/unit/out/unsafe/random.rs +++ b/tests/unit/out/unsafe/random.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -60,7 +59,6 @@ pub unsafe fn zero_0() -> i32 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -223,8 +221,8 @@ unsafe fn main_0() -> i32 { y1.pair = (&mut y2 as *mut Pair); y2.pair = (&mut y3 as *mut Pair); (unsafe { Pair::method(&raw mut (*(*y1.pair).pair)) }); - let mut x: X1 = ::default(); - let mut y: X1 = ::default(); + let mut x: X1 = unsafe { ::zero_init() }; + let mut y: X1 = unsafe { ::zero_init() }; x1 = ((unsafe { zero_0() }) + (y1.x)); y1.x = ((unsafe { zero_0() }) + (5)); let mut ptr2ptr_1: *mut *mut i32 = (&mut px1 as *mut *mut i32); diff --git a/tests/unit/out/unsafe/reference_wrapper.rs b/tests/unit/out/unsafe/reference_wrapper.rs index d020e1cb30..6dd364dcbf 100644 --- a/tests/unit/out/unsafe/reference_wrapper.rs +++ b/tests/unit/out/unsafe/reference_wrapper.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/references.rs b/tests/unit/out/unsafe/references.rs index 87af1b0b6e..2016e04ad8 100644 --- a/tests/unit/out/unsafe/references.rs +++ b/tests/unit/out/unsafe/references.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -33,7 +32,6 @@ pub struct Pair { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/refs_as_args.rs b/tests/unit/out/unsafe/refs_as_args.rs index 6a7f10b69d..d14d66629c 100644 --- a/tests/unit/out/unsafe/refs_as_args.rs +++ b/tests/unit/out/unsafe/refs_as_args.rs @@ -26,7 +26,6 @@ pub unsafe fn more_refs_0(mut x1: i32, mut x2: i32, r1: *mut i32, r2: *const i32 ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/reinterpret_cast_ptr_cmp.rs b/tests/unit/out/unsafe/reinterpret_cast_ptr_cmp.rs index 8dd5192d0d..9f36ee68b7 100644 --- a/tests/unit/out/unsafe/reinterpret_cast_ptr_cmp.rs +++ b/tests/unit/out/unsafe/reinterpret_cast_ptr_cmp.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -32,7 +31,6 @@ pub struct S { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -49,7 +47,6 @@ pub struct W { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -58,7 +55,7 @@ pub struct P { pub arr: [*mut i32; 3], } pub unsafe fn typed_0() { - let mut w: W = ::default(); + let mut w: W = unsafe { ::zero_init() }; let mut p: *mut S = (&mut w.arr[(2) as usize] as *mut S); let mut q: *mut S = ((((&mut w as *mut W) as *mut libc::c_char) .offset((::std::mem::size_of::()) as isize) @@ -89,7 +86,7 @@ pub unsafe fn typed_0() { ((((f as usize - ptrs.as_mut_ptr() as usize) / ::std::mem::size_of::<*mut i32>()) as i64) == (2_i64)) ); - let mut s: P =

::default(); + let mut s: P = unsafe {

::zero_init() }; let mut a: *mut *mut i32 = (&mut s.a as *mut *mut i32); let mut b: *mut *mut i32 = (&mut s.arr[(1) as usize] as *mut *mut i32); assert!(((a) < (b))); diff --git a/tests/unit/out/unsafe/reinterpret_cast_struct.rs b/tests/unit/out/unsafe/reinterpret_cast_struct.rs index e8be11c742..8d9a76d9e9 100644 --- a/tests/unit/out/unsafe/reinterpret_cast_struct.rs +++ b/tests/unit/out/unsafe/reinterpret_cast_struct.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -30,7 +29,7 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut p: Point = ::default(); + let mut p: Point = unsafe { ::zero_init() }; p.x = 67305985; p.y = 134678021; let mut bytes: *mut u8 = ((&mut p as *mut Point) as *mut u8); 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 1f470f8072..5953c7701f 100644 --- a/tests/unit/out/unsafe/reinterpret_cast_struct_to_struct.rs +++ b/tests/unit/out/unsafe/reinterpret_cast_struct_to_struct.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -32,7 +31,6 @@ pub struct Point { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/reserved_keywords.rs b/tests/unit/out/unsafe/reserved_keywords.rs index d1e0ee0a77..3a0063c213 100644 --- a/tests/unit/out/unsafe/reserved_keywords.rs +++ b/tests/unit/out/unsafe/reserved_keywords.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -68,7 +67,6 @@ pub struct S { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -84,7 +82,6 @@ pub struct type_ { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/return_move.rs b/tests/unit/out/unsafe/return_move.rs index 7aa61bf3dc..e5e391763f 100644 --- a/tests/unit/out/unsafe/return_move.rs +++ b/tests/unit/out/unsafe/return_move.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -32,7 +31,6 @@ pub struct node { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -77,7 +75,7 @@ pub unsafe fn address_taken_8(mut n: *mut node) -> *mut node { }; } pub unsafe fn ret_struct_9(mut a: i32, mut n: *mut node) -> pair_t { - let mut p: pair_t = ::default(); + let mut p: pair_t = unsafe { ::zero_init() }; p.a = a; p.n = n; return p; diff --git a/tests/unit/out/unsafe/rvalue_rule_arg_move.rs b/tests/unit/out/unsafe/rvalue_rule_arg_move.rs index 5432d79c1e..676fe806fa 100644 --- a/tests/unit/out/unsafe/rvalue_rule_arg_move.rs +++ b/tests/unit/out/unsafe/rvalue_rule_arg_move.rs @@ -15,7 +15,6 @@ pub static mut moves_1: std::cell::LazyCell = std::cell::LazyCell::new(|| u DefaultInitializableUnsafe, MemberwiseUnsafe, SwappableUnsafe, - Default, )] #[memberwise(copy_assign, move_assign)] #[derive(ConversionsUnsafe)] diff --git a/tests/unit/out/unsafe/rvalue_struct.rs b/tests/unit/out/unsafe/rvalue_struct.rs index c786ba21a5..1c0303f9b3 100644 --- a/tests/unit/out/unsafe/rvalue_struct.rs +++ b/tests/unit/out/unsafe/rvalue_struct.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/scalar_builtin_construct_destruct.rs b/tests/unit/out/unsafe/scalar_builtin_construct_destruct.rs index 20ff4e81c4..3af7775911 100644 --- a/tests/unit/out/unsafe/scalar_builtin_construct_destruct.rs +++ b/tests/unit/out/unsafe/scalar_builtin_construct_destruct.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/size_t_static_member.rs b/tests/unit/out/unsafe/size_t_static_member.rs index 9a0d31b545..03afbad331 100644 --- a/tests/unit/out/unsafe/size_t_static_member.rs +++ b/tests/unit/out/unsafe/size_t_static_member.rs @@ -16,7 +16,6 @@ pub static mut c_0: std::cell::LazyCell = std::cell::LazyCell::new(|| uns ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -32,7 +31,6 @@ pub static mut table_size_1: std::cell::LazyCell = ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/size_t_template_param.rs b/tests/unit/out/unsafe/size_t_template_param.rs index 07f6e47a40..41ec08a671 100644 --- a/tests/unit/out/unsafe/size_t_template_param.rs +++ b/tests/unit/out/unsafe/size_t_template_param.rs @@ -19,7 +19,6 @@ pub unsafe fn array_ref_0(a: *mut [u64; 3]) -> u64 { ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -42,7 +41,6 @@ impl PtrCtor_unsigned_long_ { ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/static_local.rs b/tests/unit/out/unsafe/static_local.rs index 07433d91ea..bd66951774 100644 --- a/tests/unit/out/unsafe/static_local.rs +++ b/tests/unit/out/unsafe/static_local.rs @@ -18,7 +18,8 @@ static mut static_b_3: std::cell::LazyCell = std::cell::LazyCell::new(|| u static mut kX1_4: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 1 }); static mut kX2_5: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 2 }); pub unsafe fn from_local_class_6() -> i32 { - return ((unsafe { S_8::get(&::default()) }) + (unsafe { S_8::get(&::default()) })); + return ((unsafe { S_8::get(&unsafe { ::zero_init() }) }) + + (unsafe { S_8::get(&unsafe { ::zero_init() }) })); } static mut x_7: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 3 }); #[repr(C)] @@ -30,7 +31,6 @@ static mut x_7: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/static_var_in_class.rs b/tests/unit/out/unsafe/static_var_in_class.rs index 61b816275e..b3d64f0d6f 100644 --- a/tests/unit/out/unsafe/static_var_in_class.rs +++ b/tests/unit/out/unsafe/static_var_in_class.rs @@ -16,7 +16,6 @@ static mut inner_const_0: std::cell::LazyCell = std::cell::LazyCell::new(|| ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -38,7 +37,6 @@ pub const anon_3_kValue: anon_3 = 3; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -56,10 +54,10 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut c: C = ::default(); + let mut c: C = unsafe { ::zero_init() }; assert!(((unsafe { C::get(&raw mut c,) }) == (1))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut inner_const_1)) == (2))); - let mut s: S = ::default(); + let mut s: S = unsafe { ::zero_init() }; let mut p: *mut S = (&mut s as *mut S); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut inner_const_1)) == (2))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut inner_const_1)) == (2))); diff --git a/tests/unit/out/unsafe/stdcopy.rs b/tests/unit/out/unsafe/stdcopy.rs index 7ca1020bed..64859e7d79 100644 --- a/tests/unit/out/unsafe/stdcopy.rs +++ b/tests/unit/out/unsafe/stdcopy.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/strdup.rs b/tests/unit/out/unsafe/strdup.rs index 6956bfcdf4..3de03852d5 100644 --- a/tests/unit/out/unsafe/strdup.rs +++ b/tests/unit/out/unsafe/strdup.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, 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 2e80d468b6..5baf27c2eb 100644 --- a/tests/unit/out/unsafe/string_literal_ptr_init.rs +++ b/tests/unit/out/unsafe/string_literal_ptr_init.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, 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 b8ddb79023..051ab0c50e 100644 --- a/tests/unit/out/unsafe/string_substr.rs +++ b/tests/unit/out/unsafe/string_substr.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/struct_2d_array_field.rs b/tests/unit/out/unsafe/struct_2d_array_field.rs index 029a03a6c9..1b347a1a1f 100644 --- a/tests/unit/out/unsafe/struct_2d_array_field.rs +++ b/tests/unit/out/unsafe/struct_2d_array_field.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct table { pub rows: [[libc::c_char; 10]; 3], @@ -104,7 +103,7 @@ unsafe fn main_0() -> i32 { let mut p: *const libc::c_char = (local.rows[(2) as usize].as_mut_ptr()).cast_const(); assert!((((*p.offset((0) as isize)) as i32) == ('t' as i32))); assert!(((local.count) == (3_usize))); - let mut copy: table =

::default(); + let mut copy: table = unsafe {
::zero_init() }; { let mut __tmp_0 = { ((&mut copy.rows as *mut [[libc::c_char; 10]; 3]) as *mut ::libc::c_void) }; diff --git a/tests/unit/out/unsafe/struct_ctor.rs b/tests/unit/out/unsafe/struct_ctor.rs index 0cf44f6ffe..2c2857b3e7 100644 --- a/tests/unit/out/unsafe/struct_ctor.rs +++ b/tests/unit/out/unsafe/struct_ctor.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -50,7 +49,6 @@ pub unsafe fn foo_0(x: *mut i32) -> *mut i32 { ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -85,17 +83,6 @@ impl Ptr_ { Value_::constructor_1(&raw mut (*this).v2, 22); } } -impl Default for Ptr_ { - fn default() -> Self { - unsafe { - { - let mut __v: Ptr_ = ZeroInitializationUnsafe::zero_init(); - Ptr_::constructor_1(&raw mut __v); - __v - } - } - } -} pub fn main() { unsafe { __cpp2rust_init_globals(); diff --git a/tests/unit/out/unsafe/struct_member_array_adjacency.rs b/tests/unit/out/unsafe/struct_member_array_adjacency.rs index 6f27ef0fe8..2ca75ffb3b 100644 --- a/tests/unit/out/unsafe/struct_member_array_adjacency.rs +++ b/tests/unit/out/unsafe/struct_member_array_adjacency.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct pair { pub a: [i32; 4], @@ -28,7 +27,7 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut s: pair = ::default(); + let mut s: pair = unsafe { ::zero_init() }; assert!(((s.a.as_mut_ptr().offset((4) as isize)) == (s.b.as_mut_ptr()))); return 0; } diff --git a/tests/unit/out/unsafe/struct_ptr.rs b/tests/unit/out/unsafe/struct_ptr.rs index dd8bc8ee8d..1e9f475d03 100644 --- a/tests/unit/out/unsafe/struct_ptr.rs +++ b/tests/unit/out/unsafe/struct_ptr.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -29,7 +28,7 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut obj: XX = ::default(); + let mut obj: XX = unsafe { ::zero_init() }; let mut ptr: *mut XX = (&mut obj as *mut XX); (*ptr).x = 2; let mut c: bool = false; diff --git a/tests/unit/out/unsafe/structured_binding_copy_ctor.rs b/tests/unit/out/unsafe/structured_binding_copy_ctor.rs index afb7188eb3..199292d250 100644 --- a/tests/unit/out/unsafe/structured_binding_copy_ctor.rs +++ b/tests/unit/out/unsafe/structured_binding_copy_ctor.rs @@ -16,7 +16,6 @@ pub static mut copies_0: std::cell::LazyCell = std::cell::LazyCell::new(|| MoveConstructibleUnsafe, MoveAssignableUnsafe, SwappableUnsafe, - Default, )] #[memberwise(copy_assign)] #[derive(ConversionsUnsafe)] diff --git a/tests/unit/out/unsafe/structured_binding_element_ctor.rs b/tests/unit/out/unsafe/structured_binding_element_ctor.rs index 9c88a0824e..b791bae633 100644 --- a/tests/unit/out/unsafe/structured_binding_element_ctor.rs +++ b/tests/unit/out/unsafe/structured_binding_element_ctor.rs @@ -9,9 +9,7 @@ use std::rc::Rc; pub static mut copies_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut moves_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, Default, ConversionsUnsafe, -)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, ConversionsUnsafe)] #[conversions(copy, move)] #[constructor(constructor_1, i32)] #[constructor(constructor_2, LvalueRefUnsafe>)] @@ -36,9 +34,7 @@ impl Elem { } } #[repr(C)] -#[derive( - FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, MemberwiseUnsafe, Default, -)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, MemberwiseUnsafe)] #[memberwise(copy_constructor, move_constructor)] #[derive(ConversionsUnsafe)] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/structured_binding_move_ctor.rs b/tests/unit/out/unsafe/structured_binding_move_ctor.rs index 5a2cc0cf9f..1e00438a85 100644 --- a/tests/unit/out/unsafe/structured_binding_move_ctor.rs +++ b/tests/unit/out/unsafe/structured_binding_move_ctor.rs @@ -9,9 +9,7 @@ use std::rc::Rc; pub static mut copies_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); pub static mut moves_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] -#[derive( - FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, Default, ConversionsUnsafe, -)] +#[derive(FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, ConversionsUnsafe)] #[conversions(copy, move)] #[constructor(constructor_1, i32, i32)] #[constructor(constructor_2, LvalueRefUnsafe>)] @@ -50,7 +48,6 @@ impl Movable { MemberwiseUnsafe, CopyConstructibleUnsafe, SwappableUnsafe, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(ConversionsUnsafe)] diff --git a/tests/unit/out/unsafe/structured_binding_range_for.rs b/tests/unit/out/unsafe/structured_binding_range_for.rs index 5b26cd7cef..a1b27f67f1 100644 --- a/tests/unit/out/unsafe/structured_binding_range_for.rs +++ b/tests/unit/out/unsafe/structured_binding_range_for.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/structured_binding_ref.rs b/tests/unit/out/unsafe/structured_binding_ref.rs index 24101cca1f..39240ff760 100644 --- a/tests/unit/out/unsafe/structured_binding_ref.rs +++ b/tests/unit/out/unsafe/structured_binding_ref.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/structured_binding_trivial.rs b/tests/unit/out/unsafe/structured_binding_trivial.rs index 1c53d5aa8e..634ea0f74d 100644 --- a/tests/unit/out/unsafe/structured_binding_trivial.rs +++ b/tests/unit/out/unsafe/structured_binding_trivial.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/tag_vs_identifier_collision.rs b/tests/unit/out/unsafe/tag_vs_identifier_collision.rs index 4519752d15..e4e7b40b9e 100644 --- a/tests/unit/out/unsafe/tag_vs_identifier_collision.rs +++ b/tests/unit/out/unsafe/tag_vs_identifier_collision.rs @@ -19,7 +19,6 @@ pub const widget_enum_MODE_DONE: widget_enum = 2; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct widget { pub id: i32, @@ -34,7 +33,6 @@ pub struct widget { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct point_struct { pub x: i32, @@ -54,11 +52,6 @@ pub union point { pub whole: i32, pub half: i16, } -impl Default for point { - fn default() -> Self { - unsafe { std::mem::zeroed() } - } -} #[repr(C)] #[derive( Copy, @@ -73,11 +66,6 @@ pub union slot_union { pub i: i32, pub u: u32, } -impl Default for slot_union { - fn default() -> Self { - unsafe { std::mem::zeroed() } - } -} pub type slot = u32; pub const slot_SLOT_A: slot = 0; pub const slot_SLOT_B: slot = 1; @@ -90,7 +78,6 @@ pub const slot_SLOT_B: slot = 1; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct Inner { pub tag_field: i32, @@ -104,7 +91,6 @@ pub struct Inner { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct Outer { pub field: Inner, @@ -118,7 +104,6 @@ pub struct Outer { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct Inner_struct { pub typedef_field: i32, @@ -133,31 +118,31 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut w: widget = ::default(); + let mut w: widget = unsafe { ::zero_init() }; w.id = 7; w.mode = widget_enum_MODE_ACTIVE; assert!(((unsafe { is_active_0((&mut w as *mut widget),) }) != 0)); w.mode = widget_enum_MODE_DONE; assert!(((w.mode as u32) == ((widget_enum_MODE_DONE as i32) as u32))); - let mut p: point_struct = ::default(); + let mut p: point_struct = unsafe { ::zero_init() }; p.x = 3; p.y = 4; assert!((((p.x) + (p.y)) == (7))); - let mut up: point = ::default(); + let mut up: point = unsafe { ::zero_init() }; up.whole = 5; assert!(((up.whole) == (5))); - let mut b: slot_union = ::default(); + let mut b: slot_union = unsafe { ::zero_init() }; b.i = 9; assert!(((b.i) == (9))); let mut e: slot = slot_SLOT_B; assert!(((e as u32) == ((slot_SLOT_B as i32) as u32))); - let mut inner_tag: Inner = ::default(); + let mut inner_tag: Inner = unsafe { ::zero_init() }; inner_tag.tag_field = 11; assert!(((inner_tag.tag_field) == (11))); - let mut inner_typedef: Inner_struct = ::default(); + let mut inner_typedef: Inner_struct = unsafe { ::zero_init() }; inner_typedef.typedef_field = 22; assert!(((inner_typedef.typedef_field) == (22))); - let mut o: Outer = ::default(); + let mut o: Outer = unsafe { ::zero_init() }; o.field.tag_field = 33; assert!(((o.field.tag_field) == (33))); assert!(((w.id) == (7))); diff --git a/tests/unit/out/unsafe/template_default_arg.rs b/tests/unit/out/unsafe/template_default_arg.rs index 592373cf79..f4e3b7e309 100644 --- a/tests/unit/out/unsafe/template_default_arg.rs +++ b/tests/unit/out/unsafe/template_default_arg.rs @@ -30,17 +30,6 @@ impl A { (&raw mut (*this).v).write(v); } } -impl Default for A { - fn default() -> Self { - unsafe { - { - let mut __v: A = ZeroInitializationUnsafe::zero_init(); - A::constructor_1(&raw mut __v); - __v - } - } - } -} #[repr(C)] #[derive( Copy, @@ -61,17 +50,6 @@ impl B { (&raw mut (*this).v).write(2); } } -impl Default for B { - fn default() -> Self { - unsafe { - { - let mut __v: B = ZeroInitializationUnsafe::zero_init(); - B::constructor_1(&raw mut __v); - __v - } - } - } -} #[repr(C)] #[derive( Copy, @@ -81,7 +59,6 @@ impl Default for B { ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -115,7 +92,6 @@ pub unsafe fn always_given_3(mut x: NoDefault) -> i32 { ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/template_static_member.rs b/tests/unit/out/unsafe/template_static_member.rs index c873d53a4f..61ebe0a7e0 100644 --- a/tests/unit/out/unsafe/template_static_member.rs +++ b/tests/unit/out/unsafe/template_static_member.rs @@ -16,7 +16,6 @@ pub static mut s_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsaf ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -32,7 +31,6 @@ pub static mut s_1: std::cell::LazyCell = ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -47,7 +45,6 @@ pub static mut s_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsaf ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -63,7 +60,6 @@ pub static mut hi_4: std::cell::LazyCell = std::cell::LazyCell::new(|| unsa ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -80,7 +76,6 @@ pub static mut hi_6: std::cell::LazyCell = std::cell::LazyCell::new(|| unsa ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/temporary_field_addr.rs b/tests/unit/out/unsafe/temporary_field_addr.rs index b8206f7d9c..74cd88661e 100644 --- a/tests/unit/out/unsafe/temporary_field_addr.rs +++ b/tests/unit/out/unsafe/temporary_field_addr.rs @@ -16,7 +16,6 @@ use std::rc::Rc; MemberwiseUnsafe, CopyConstructibleUnsafe, SwappableUnsafe, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(ConversionsUnsafe)] @@ -40,7 +39,6 @@ impl Inner { MemberwiseUnsafe, CopyConstructibleUnsafe, SwappableUnsafe, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(ConversionsUnsafe)] diff --git a/tests/unit/out/unsafe/temporary_field_ctor_arg.rs b/tests/unit/out/unsafe/temporary_field_ctor_arg.rs index ca5082b431..a9aba21ce9 100644 --- a/tests/unit/out/unsafe/temporary_field_ctor_arg.rs +++ b/tests/unit/out/unsafe/temporary_field_ctor_arg.rs @@ -16,7 +16,6 @@ use std::rc::Rc; MemberwiseUnsafe, CopyConstructibleUnsafe, SwappableUnsafe, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(ConversionsUnsafe)] @@ -45,7 +44,6 @@ pub unsafe fn make_0(__return: *mut Outer) { ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/temporary_field_two_args.rs b/tests/unit/out/unsafe/temporary_field_two_args.rs index f23edc40f5..075cd0403b 100644 --- a/tests/unit/out/unsafe/temporary_field_two_args.rs +++ b/tests/unit/out/unsafe/temporary_field_two_args.rs @@ -16,7 +16,6 @@ use std::rc::Rc; MemberwiseUnsafe, CopyConstructibleUnsafe, SwappableUnsafe, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(ConversionsUnsafe)] @@ -40,7 +39,6 @@ impl Inner { MemberwiseUnsafe, CopyConstructibleUnsafe, SwappableUnsafe, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(ConversionsUnsafe)] diff --git a/tests/unit/out/unsafe/this.rs b/tests/unit/out/unsafe/this.rs index 471e7670b3..ced63adb1a 100644 --- a/tests/unit/out/unsafe/this.rs +++ b/tests/unit/out/unsafe/this.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -124,7 +123,6 @@ pub unsafe fn bump_0(mut p: *mut S) { ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/typedef-anon-struct.rs b/tests/unit/out/unsafe/typedef-anon-struct.rs index 111a77f22b..263a317175 100644 --- a/tests/unit/out/unsafe/typedef-anon-struct.rs +++ b/tests/unit/out/unsafe/typedef-anon-struct.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -33,7 +32,6 @@ pub struct Outer_RunInfo { MemberwiseUnsafe, CopyConstructibleUnsafe, SwappableUnsafe, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(ConversionsUnsafe)] @@ -55,7 +53,7 @@ pub fn main() { } unsafe fn main_0() -> i32 { object_unsafe!(o, Outer::constructor_1()); - let mut info: Outer_RunInfo = ::default(); + let mut info: Outer_RunInfo = unsafe { ::zero_init() }; info.block_idx = 1; info.num_extra_zero_runs = 2; o.runs.push_copied(&mut info); diff --git a/tests/unit/out/unsafe/types.rs b/tests/unit/out/unsafe/types.rs index db83187b82..bcbdaea4be 100644 --- a/tests/unit/out/unsafe/types.rs +++ b/tests/unit/out/unsafe/types.rs @@ -41,7 +41,7 @@ unsafe fn main_0() -> i32 { let mut xc8: u8 = 66_u8; let mut xc16: u16 = 67_u16; let mut xc32: u32 = 68_u32; - let mut xnp: *mut ::libc::c_void = Default::default(); + let mut xnp: *mut ::libc::c_void = std::ptr::null_mut(); assert!( (((((((((((((xu8 as i32) + (xu16 as i32)) as u32).wrapping_add(xu32)) as u64) .wrapping_add(xu64)) 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 be0622e922..0cf7d51122 100644 --- a/tests/unit/out/unsafe/unary_expr_or_type_trait.rs +++ b/tests/unit/out/unsafe/unary_expr_or_type_trait.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -39,7 +38,7 @@ pub fn main() { } unsafe fn main_0() -> i32 { let mut arr: [i64; 4] = [0_i64; 4]; - let mut s: S = ::default(); + let mut s: S = unsafe { ::zero_init() }; assert!(((::std::mem::size_of::()) == (4_usize))); assert!(((::std::mem::size_of::<[i64; 4]>()) == (32_usize))); assert!(((::std::mem::size_of::()) == (16_usize))); diff --git a/tests/unit/out/unsafe/unboxed_records.rs b/tests/unit/out/unsafe/unboxed_records.rs index ad4045ab72..2581dfc387 100644 --- a/tests/unit/out/unsafe/unboxed_records.rs +++ b/tests/unit/out/unsafe/unboxed_records.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -32,7 +31,6 @@ pub struct Inner { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -66,11 +64,6 @@ impl Counter { (&raw mut (*this).n).write(0); } } -impl Default for Counter { - fn default() -> Self { - unsafe { Counter { n: 0 } } - } -} pub unsafe fn set_0(mut p: *mut i32, mut v: i32) { (*p) = v; } @@ -113,7 +106,7 @@ pub fn main() { unsafe fn main_0() -> i32 { let mut data: [i32; 4] = [0, 0, 0, 0]; let mut in_: [i32; 4] = [1, 2, 3, 4]; - let mut cookie: Cookie = ::default(); + let mut cookie: Cookie = unsafe { ::zero_init() }; cookie.x = 2; cookie.data = data.as_mut_ptr(); cookie.in_ = (in_.as_mut_ptr()).cast_const(); @@ -125,7 +118,7 @@ unsafe fn main_0() -> i32 { && ((data[(3) as usize]) == (8)) ); assert!(((unsafe { get_1(&cookie,) }) == (2))); - let mut local: Inner = ::default(); + let mut local: Inner = unsafe { ::zero_init() }; local.a = 4; local.b = ((local.a) * (2)); local.a.postfix_inc(); diff --git a/tests/unit/out/unsafe/union_addrof_external.rs b/tests/unit/out/unsafe/union_addrof_external.rs index 074e9570c5..606ed0dd4a 100644 --- a/tests/unit/out/unsafe/union_addrof_external.rs +++ b/tests/unit/out/unsafe/union_addrof_external.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct record { pub code: u16, @@ -37,11 +36,6 @@ pub union anon_0 { pub h: record, pub raw_: [libc::c_char; 128], } -impl Default for anon_0 { - fn default() -> Self { - unsafe { std::mem::zeroed() } - } -} #[repr(C)] #[derive( Copy, @@ -51,7 +45,6 @@ impl Default for anon_0 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct Container { pub view: anon_0, @@ -86,7 +79,7 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut c: Container = ::default(); + let mut c: Container = unsafe { ::zero_init() }; { let mut __tmp_1 = { ((&mut c as *mut Container) as *mut ::libc::c_void) }; let byte_0 = __tmp_1 as *mut u8; diff --git a/tests/unit/out/unsafe/union_basic.rs b/tests/unit/out/unsafe/union_basic.rs index 3db1c405cc..9f48674804 100644 --- a/tests/unit/out/unsafe/union_basic.rs +++ b/tests/unit/out/unsafe/union_basic.rs @@ -20,11 +20,6 @@ pub union basic { pub i: i32, pub f: f32, } -impl Default for basic { - fn default() -> Self { - unsafe { std::mem::zeroed() } - } -} #[repr(C)] #[derive( Copy, @@ -38,11 +33,6 @@ impl Default for basic { pub union empty { __empty: u8, } -impl Default for empty { - fn default() -> Self { - unsafe { std::mem::zeroed() } - } -} #[repr(C)] #[derive( Copy, @@ -57,11 +47,6 @@ pub union underscores { pub __: i32, pub ___: f64, } -impl Default for underscores { - fn default() -> Self { - unsafe { std::mem::zeroed() } - } -} pub fn main() { unsafe { __cpp2rust_init_globals(); @@ -69,8 +54,8 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut u: basic = ::default(); - let mut e: empty = ::default(); + let mut u: basic = unsafe { ::zero_init() }; + let mut e: empty = unsafe { ::zero_init() }; u.i = 42; assert!(((u.i) == (42))); u.f = 3.14_f32; @@ -98,13 +83,13 @@ unsafe fn main_0() -> i32 { let mut copied: basic = basic { i: 7 }; assert!(((copied.i) == (7))); { - let mut anon_0: anon_0 = ::default(); + let mut anon_0: anon_0 = unsafe { ::zero_init() }; anon_0.ai = 11; assert!(((anon_0.ai) == (11))); anon_0.ai = 1065353216; assert!(((anon_0.af) == (1_f32))); } - let mut us: underscores = ::default(); + let mut us: underscores = unsafe { ::zero_init() }; us.__ = 5; assert!(((us.__) == (5))); us.___ = 2.5_f64; @@ -128,9 +113,4 @@ pub union anon_0 { pub ai: i32, pub af: f32, } -impl Default for anon_0 { - fn default() -> Self { - unsafe { std::mem::zeroed() } - } -} pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/union_cross_arm_cast.rs b/tests/unit/out/unsafe/union_cross_arm_cast.rs index 4c6f8cb4ab..3f76c032f1 100644 --- a/tests/unit/out/unsafe/union_cross_arm_cast.rs +++ b/tests/unit/out/unsafe/union_cross_arm_cast.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct shape_a { pub code: u16, @@ -30,7 +29,6 @@ pub struct shape_a { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct shape_b { pub code: u16, @@ -54,11 +52,6 @@ pub union anon_0 { pub b: shape_b, pub raw_: [libc::c_char; 64], } -impl Default for anon_0 { - fn default() -> Self { - unsafe { std::mem::zeroed() } - } -} #[repr(C)] #[derive( Copy, @@ -68,7 +61,6 @@ impl Default for anon_0 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct Container { pub len: u32, @@ -81,7 +73,7 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut c: Container = ::default(); + let mut c: Container = unsafe { ::zero_init() }; { let mut __tmp_0 = { ((&mut c as *mut Container) as *mut ::libc::c_void) }; let byte_0 = __tmp_0 as *mut u8; diff --git a/tests/unit/out/unsafe/union_field_alignment.rs b/tests/unit/out/unsafe/union_field_alignment.rs index 770621d105..e892dfedd3 100644 --- a/tests/unit/out/unsafe/union_field_alignment.rs +++ b/tests/unit/out/unsafe/union_field_alignment.rs @@ -20,11 +20,6 @@ pub union anon_0 { pub bytes: [u8; 1], pub aligner: *mut ::libc::c_void, } -impl Default for anon_0 { - fn default() -> Self { - unsafe { std::mem::zeroed() } - } -} #[repr(C)] #[derive( Copy, @@ -34,7 +29,6 @@ impl Default for anon_0 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct node { pub next: *mut node, @@ -47,7 +41,7 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut n: node = ::default(); + let mut n: node = unsafe { ::zero_init() }; n.next = std::ptr::null_mut(); (*n.x.bytes.as_mut_ptr().add((0) as usize)) = 171_u8; assert!((((*n.x.bytes.as_mut_ptr().add((0) as usize)) as i32) == (171))); diff --git a/tests/unit/out/unsafe/union_flex_array_member.rs b/tests/unit/out/unsafe/union_flex_array_member.rs index 5dd0cae24b..69ec9b71a1 100644 --- a/tests/unit/out/unsafe/union_flex_array_member.rs +++ b/tests/unit/out/unsafe/union_flex_array_member.rs @@ -20,11 +20,6 @@ pub union anon_0 { pub bytes: [u8; 1], pub aligner: *mut ::libc::c_void, } -impl Default for anon_0 { - fn default() -> Self { - unsafe { std::mem::zeroed() } - } -} #[repr(C)] #[derive( Copy, @@ -34,7 +29,6 @@ impl Default for anon_0 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, 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 002f4c8e92..70167889cd 100644 --- a/tests/unit/out/unsafe/union_memset_memcpy.rs +++ b/tests/unit/out/unsafe/union_memset_memcpy.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct shape_a { pub code: u16, @@ -30,7 +29,6 @@ pub struct shape_a { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct shape_b { pub code: u16, @@ -53,11 +51,6 @@ pub union anon_0 { pub b: shape_b, pub raw_: [libc::c_char; 256], } -impl Default for anon_0 { - fn default() -> Self { - unsafe { std::mem::zeroed() } - } -} #[repr(C)] #[derive( Copy, @@ -67,7 +60,6 @@ impl Default for anon_0 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct Container { pub view: anon_0, @@ -79,7 +71,7 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut c: Container = ::default(); + let mut c: Container = unsafe { ::zero_init() }; { let mut __tmp_0 = { ((&mut c as *mut Container) as *mut ::libc::c_void) }; let byte_0 = __tmp_0 as *mut u8; diff --git a/tests/unit/out/unsafe/union_nested.rs b/tests/unit/out/unsafe/union_nested.rs index d01e16aaf6..91cfc3df91 100644 --- a/tests/unit/out/unsafe/union_nested.rs +++ b/tests/unit/out/unsafe/union_nested.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct record { pub code: u16, @@ -35,11 +34,6 @@ pub union anon_0 { pub h: record, pub raw_: [libc::c_char; 128], } -impl Default for anon_0 { - fn default() -> Self { - unsafe { std::mem::zeroed() } - } -} #[repr(C)] #[derive( Copy, @@ -49,7 +43,6 @@ impl Default for anon_0 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct inner { pub view: anon_0, @@ -68,11 +61,6 @@ pub union anon_1 { pub h: record, pub nested: inner, } -impl Default for anon_1 { - fn default() -> Self { - unsafe { std::mem::zeroed() } - } -} #[repr(C)] #[derive( Copy, @@ -82,7 +70,6 @@ impl Default for anon_1 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct Outer { pub kind: i32, @@ -98,7 +85,7 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut ex: Outer = ::default(); + let mut ex: Outer = unsafe { ::zero_init() }; { let mut __tmp_0 = { ((&mut ex as *mut Outer) as *mut ::libc::c_void) }; let byte_0 = __tmp_0 as *mut u8; diff --git a/tests/unit/out/unsafe/union_pointer_pun_address.rs b/tests/unit/out/unsafe/union_pointer_pun_address.rs index 800d16877e..ac8a43a0a4 100644 --- a/tests/unit/out/unsafe/union_pointer_pun_address.rs +++ b/tests/unit/out/unsafe/union_pointer_pun_address.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct node_a { pub n: i32, @@ -29,7 +28,6 @@ pub struct node_a { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct node_b { pub data: *mut ::libc::c_void, @@ -43,7 +41,7 @@ pub fn main() { } unsafe fn main_0() -> i32 { let mut a: node_a = node_a { n: 123 }; - let mut ptr: anon_0 = ::default(); + let mut ptr: anon_0 = unsafe { ::zero_init() }; ptr.to_a = (&mut a as *mut node_a); let mut out: *mut node_b = ptr.to_b; assert!(((out as *mut ::libc::c_void) == ((&mut a as *mut node_a) as *mut ::libc::c_void))); @@ -63,9 +61,4 @@ pub union anon_0 { pub to_a: *mut node_a, pub to_b: *mut node_b, } -impl Default for anon_0 { - fn default() -> Self { - unsafe { std::mem::zeroed() } - } -} pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/union_pointer_pun_writethrough.rs b/tests/unit/out/unsafe/union_pointer_pun_writethrough.rs index abf73be7db..b1badaf09c 100644 --- a/tests/unit/out/unsafe/union_pointer_pun_writethrough.rs +++ b/tests/unit/out/unsafe/union_pointer_pun_writethrough.rs @@ -14,7 +14,7 @@ pub fn main() { } unsafe fn main_0() -> i32 { let mut x: i64 = (-1_i32 as i64); - let mut pp: anon_0 = ::default(); + let mut pp: anon_0 = unsafe { ::zero_init() }; pp.as_signed = (&mut x as *mut i64); (*pp.as_unsigned) = 42_u64; assert!(((x) == (42_i64))); @@ -34,9 +34,4 @@ pub union anon_0 { pub as_unsigned: *mut u64, pub as_signed: *mut i64, } -impl Default for anon_0 { - fn default() -> Self { - unsafe { std::mem::zeroed() } - } -} pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/union_struct_dual_use.rs b/tests/unit/out/unsafe/union_struct_dual_use.rs index eb77ee61b0..3f8a8f217e 100644 --- a/tests/unit/out/unsafe/union_struct_dual_use.rs +++ b/tests/unit/out/unsafe/union_struct_dual_use.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct Inner { pub a: i32, @@ -38,11 +37,6 @@ pub union anon_1 { pub inner: Inner, pub raw_: [libc::c_char; 16], } -impl Default for anon_1 { - fn default() -> Self { - unsafe { std::mem::zeroed() } - } -} #[repr(C)] #[derive( Copy, @@ -52,7 +46,6 @@ impl Default for anon_1 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct Outer { pub u: anon_1, @@ -64,11 +57,11 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut standalone: Inner = ::default(); + let mut standalone: Inner = unsafe { ::zero_init() }; standalone.a = 3; standalone.b = 4; assert!(((unsafe { sum_inner_0((&mut standalone as *mut Inner),) }) == (7))); - let mut outer: Outer = ::default(); + let mut outer: Outer = unsafe { ::zero_init() }; { let mut __tmp_0 = { ((&mut outer as *mut Outer) as *mut ::libc::c_void) }; let byte_0 = __tmp_0 as *mut u8; diff --git a/tests/unit/out/unsafe/union_tagged_many_arms.rs b/tests/unit/out/unsafe/union_tagged_many_arms.rs index 2b2c7abcde..5ec788b3f1 100644 --- a/tests/unit/out/unsafe/union_tagged_many_arms.rs +++ b/tests/unit/out/unsafe/union_tagged_many_arms.rs @@ -29,11 +29,6 @@ pub union anon_0 { pub unsigned_n: u64, pub f: f64, } -impl Default for anon_0 { - fn default() -> Self { - unsafe { std::mem::zeroed() } - } -} #[repr(C)] #[derive( Copy, @@ -43,7 +38,6 @@ impl Default for anon_0 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct Slot { pub tag: Tag_enum, @@ -56,24 +50,24 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut a: Slot = ::default(); + let mut a: Slot = unsafe { ::zero_init() }; a.tag = Tag_enum_T_NUM_S; a.payload.signed_n = (-7_i32 as i64); assert!(((a.payload.signed_n) == (-7_i32 as i64))); - let mut b: Slot = ::default(); + let mut b: Slot = unsafe { ::zero_init() }; b.tag = Tag_enum_T_NUM_U; b.payload.unsigned_n = 3735928559_u64; assert!(((b.payload.unsigned_n) == (3735928559_u64))); - let mut c: Slot = ::default(); + let mut c: Slot = unsafe { ::zero_init() }; c.tag = Tag_enum_T_TEXT; c.payload.text = (c"hello".as_ptr().cast_mut()).cast_const(); assert!((((*c.payload.text.offset((0) as isize)) as i32) == ('h' as i32))); - let mut d: Slot = ::default(); + let mut d: Slot = unsafe { ::zero_init() }; d.tag = Tag_enum_T_FLOAT; d.payload.f = 1.5_f64; assert!(((d.payload.f) == (1.5_f64))); let mut x: i32 = 0; - let mut e: Slot = ::default(); + let mut e: Slot = unsafe { ::zero_init() }; e.tag = Tag_enum_T_REF; e.payload.handle = ((&mut x as *mut i32) as *mut ::libc::c_void); assert!(((e.payload.handle) == ((&mut x as *mut i32) as *mut ::libc::c_void))); diff --git a/tests/unit/out/unsafe/union_tagged_simple.rs b/tests/unit/out/unsafe/union_tagged_simple.rs index 0797efcf2a..323419f7dc 100644 --- a/tests/unit/out/unsafe/union_tagged_simple.rs +++ b/tests/unit/out/unsafe/union_tagged_simple.rs @@ -23,11 +23,6 @@ pub union anon_0 { pub obj: *mut ::libc::c_void, pub code: i32, } -impl Default for anon_0 { - fn default() -> Self { - unsafe { std::mem::zeroed() } - } -} #[repr(C)] #[derive( Copy, @@ -37,7 +32,6 @@ impl Default for anon_0 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct Event { pub kind: Kind_enum, @@ -52,13 +46,13 @@ pub fn main() { } unsafe fn main_0() -> i32 { let mut dummy: i32 = 0; - let mut m1: Event = ::default(); + let mut m1: Event = unsafe { ::zero_init() }; m1.kind = Kind_enum_KIND_DONE; m1.handle = ((&mut dummy as *mut i32) as *mut ::libc::c_void); m1.payload.code = 42; assert!(((m1.kind as u32) == ((Kind_enum_KIND_DONE as i32) as u32))); assert!(((m1.payload.code) == (42))); - let mut m2: Event = ::default(); + let mut m2: Event = unsafe { ::zero_init() }; m2.kind = Kind_enum_KIND_NONE; m2.handle = ((&mut dummy as *mut i32) as *mut ::libc::c_void); m2.payload.obj = ((&mut dummy as *mut i32) as *mut ::libc::c_void); diff --git a/tests/unit/out/unsafe/union_tagged_struct_arms.rs b/tests/unit/out/unsafe/union_tagged_struct_arms.rs index 50de080c50..fdf337fa9d 100644 --- a/tests/unit/out/unsafe/union_tagged_struct_arms.rs +++ b/tests/unit/out/unsafe/union_tagged_struct_arms.rs @@ -19,7 +19,6 @@ pub const Choice_enum_C_INTEGERS: Choice_enum = 3; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct anon_1 { pub items: *mut *mut libc::c_char, @@ -35,7 +34,6 @@ pub struct anon_1 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct anon_2 { pub lo: i32, @@ -52,7 +50,6 @@ pub struct anon_2 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct anon_3 { pub lo: i64, @@ -76,11 +73,6 @@ pub union anon_0 { pub letters: anon_2, pub integers: anon_3, } -impl Default for anon_0 { - fn default() -> Self { - unsafe { std::mem::zeroed() } - } -} #[repr(C)] #[derive( Copy, @@ -90,7 +82,6 @@ impl Default for anon_0 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct Branch { pub choice: Choice_enum, @@ -104,7 +95,7 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut p_list: Branch = ::default(); + let mut p_list: Branch = unsafe { ::zero_init() }; p_list.choice = Choice_enum_C_LIST; p_list.index = 0; p_list.v.list.items = (*std::cell::LazyCell::force_mut(&mut *&raw mut items_4)).as_mut_ptr(); @@ -115,7 +106,7 @@ unsafe fn main_0() -> i32 { (((*(*p_list.v.list.items.offset((1) as isize)).offset((0) as isize)) as i32) == ('b' as i32)) ); - let mut p_letters: Branch = ::default(); + let mut p_letters: Branch = unsafe { ::zero_init() }; p_letters.choice = Choice_enum_C_LETTERS; p_letters.index = 1; p_letters.v.letters.lo = ('a' as i32); @@ -123,7 +114,7 @@ unsafe fn main_0() -> i32 { p_letters.v.letters.curr = ('m' as i32); p_letters.v.letters.step = 1_u8; assert!((((p_letters.v.letters.hi) - (p_letters.v.letters.lo)) == (25))); - let mut p_integers: Branch = ::default(); + let mut p_integers: Branch = unsafe { ::zero_init() }; p_integers.choice = Choice_enum_C_INTEGERS; p_integers.index = 2; p_integers.v.integers.lo = 1_i64; 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 404e5b9cb3..cb4d73594a 100644 --- a/tests/unit/out/unsafe/union_void_ptr_sized_deref.rs +++ b/tests/unit/out/unsafe/union_void_ptr_sized_deref.rs @@ -26,11 +26,6 @@ pub union anon_0 { pub signed_n: i64, pub f: f64, } -impl Default for anon_0 { - fn default() -> Self { - unsafe { std::mem::zeroed() } - } -} #[repr(C)] #[derive( Copy, @@ -40,7 +35,6 @@ impl Default for anon_0 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct Sink { pub width: Width_enum, @@ -75,7 +69,7 @@ unsafe fn main_0() -> i32 { let mut buf64: i64 = 0_i64; let mut buf32: i32 = 0; let mut buf16: i16 = 0_i16; - let mut s: Sink = ::default(); + let mut s: Sink = unsafe { ::zero_init() }; s.width = Width_enum_W_64; s.out.handle = ((&mut buf64 as *mut i64) as *mut ::libc::c_void); (unsafe { write_count_1((&mut s as *mut Sink), 1234605616436508552_i64) }); diff --git a/tests/unit/out/unsafe/unique_ptr.rs b/tests/unit/out/unsafe/unique_ptr.rs index 45b54ebaa8..ff5faf37ed 100644 --- a/tests/unit/out/unsafe/unique_ptr.rs +++ b/tests/unit/out/unsafe/unique_ptr.rs @@ -8,12 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - MemberwiseUnsafe, - SwappableUnsafe, - Default, + FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, MemberwiseUnsafe, SwappableUnsafe, )] #[memberwise(move_constructor, move_assign)] #[derive(ConversionsUnsafe)] @@ -43,7 +38,6 @@ impl SafePointer { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -147,7 +141,7 @@ pub unsafe fn DoStuffWithSafePointer_0(safe_ptr: *mut Option>) pub unsafe fn Consume_1(mut safe_ptr: Option>) -> i32 { let mut x: Option> = safe_ptr.take(); let mut p: Option> = Some(Box::from_raw( - (Box::leak(Box::new(::default())) as *mut Pair), + (Box::leak(Box::new(unsafe { ::zero_init() })) as *mut Pair), )); return ((*(*x.as_deref().map_or(::std::ptr::null_mut(), |v| { v as *const SafePointer as *mut SafePointer @@ -204,7 +198,7 @@ pub unsafe fn RndStuff_2() { } let mut x3: Option> = Some( (0..10_usize) - .map(|_| ::default()) + .map(|_| unsafe { ::zero_init() }) .collect::>(), ); { @@ -244,7 +238,7 @@ pub unsafe fn RndStuff_2() { } x3 = Some(Box::from_raw(Box::leak( (0..50_usize) - .map(|_| ::default()) + .map(|_| unsafe { ::zero_init() }) .collect::>(), ))); { diff --git a/tests/unit/out/unsafe/unique_ptr_const_deref.rs b/tests/unit/out/unsafe/unique_ptr_const_deref.rs index f8dd9749e8..ddde751f25 100644 --- a/tests/unit/out/unsafe/unique_ptr_const_deref.rs +++ b/tests/unit/out/unsafe/unique_ptr_const_deref.rs @@ -8,12 +8,7 @@ use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; #[repr(C)] #[derive( - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - MemberwiseUnsafe, - SwappableUnsafe, - Default, + FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, MemberwiseUnsafe, SwappableUnsafe, )] #[memberwise(move_constructor, move_assign)] #[derive(ConversionsUnsafe)] diff --git a/tests/unit/out/unsafe/unique_ptr_field_reset.rs b/tests/unit/out/unsafe/unique_ptr_field_reset.rs index 794691a49b..fdb8b8660a 100644 --- a/tests/unit/out/unsafe/unique_ptr_field_reset.rs +++ b/tests/unit/out/unsafe/unique_ptr_field_reset.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -24,12 +23,7 @@ pub struct Data { } #[repr(C)] #[derive( - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - MemberwiseUnsafe, - SwappableUnsafe, - Default, + FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, MemberwiseUnsafe, SwappableUnsafe, )] #[memberwise(move_constructor, move_assign)] #[derive(ConversionsUnsafe)] diff --git a/tests/unit/out/unsafe/unique_ptr_nested.rs b/tests/unit/out/unsafe/unique_ptr_nested.rs index a0dddc0a8d..7817e13019 100644 --- a/tests/unit/out/unsafe/unique_ptr_nested.rs +++ b/tests/unit/out/unsafe/unique_ptr_nested.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -25,12 +24,7 @@ pub struct Inner { } #[repr(C)] #[derive( - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - MemberwiseUnsafe, - SwappableUnsafe, - Default, + FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, MemberwiseUnsafe, SwappableUnsafe, )] #[memberwise(move_constructor, move_assign)] #[derive(ConversionsUnsafe)] diff --git a/tests/unit/out/unsafe/unique_ptr_struct.rs b/tests/unit/out/unsafe/unique_ptr_struct.rs index 78047726f7..357d982fc1 100644 --- a/tests/unit/out/unsafe/unique_ptr_struct.rs +++ b/tests/unit/out/unsafe/unique_ptr_struct.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/va_arg_mixed_types.rs b/tests/unit/out/unsafe/va_arg_mixed_types.rs index a49854d2a7..3cf303e10d 100644 --- a/tests/unit/out/unsafe/va_arg_mixed_types.rs +++ b/tests/unit/out/unsafe/va_arg_mixed_types.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, 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 ca56031b25..a32cd9ad4d 100644 --- a/tests/unit/out/unsafe/va_arg_non_primitive_ptrs.rs +++ b/tests/unit/out/unsafe/va_arg_non_primitive_ptrs.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, 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 234eabf4d5..3babc7bf84 100644 --- a/tests/unit/out/unsafe/va_arg_struct_ctx.rs +++ b/tests/unit/out/unsafe/va_arg_struct_ctx.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, )] pub struct context { pub verbose: i32, @@ -46,11 +45,6 @@ pub union value { pub i: i32, pub l: i64, } -impl Default for value { - fn default() -> Self { - unsafe { std::mem::zeroed() } - } -} pub unsafe fn pick_1(mut use_long: i32, __args: Box<[VaArg]>) -> i64 { let mut ap: *const VaArg = ::std::ptr::null(); ap = __args.as_ptr(); @@ -67,7 +61,7 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut ctx: context = ::default(); + let mut ctx: context = unsafe { ::zero_init() }; ctx.verbose = 1; ctx.last_error = 0; (unsafe { @@ -87,7 +81,7 @@ unsafe fn main_0() -> i32 { ) }); assert!(((ctx.last_error) == (42))); - let mut v: value = ::default(); + let mut v: value = unsafe { ::zero_init() }; v.l = ((1_i64) << (40)); assert!(((unsafe { pick_1(1, Box::new([(v).into(),])) }) == ((1_i64) << (40)))); v.i = 7; diff --git a/tests/unit/out/unsafe/va_arg_void_ptr.rs b/tests/unit/out/unsafe/va_arg_void_ptr.rs index 02d10525e7..0896c98dc8 100644 --- a/tests/unit/out/unsafe/va_arg_void_ptr.rs +++ b/tests/unit/out/unsafe/va_arg_void_ptr.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, 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 7011b782b9..e71f574aed 100644 --- a/tests/unit/out/unsafe/va_list_field.rs +++ b/tests/unit/out/unsafe/va_list_field.rs @@ -75,7 +75,6 @@ pub unsafe fn sum_ptr_2(mut n: i32, __args: Box<[VaArg]>) -> i32 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/vector.rs b/tests/unit/out/unsafe/vector.rs index 44560dac26..3d56780295 100644 --- a/tests/unit/out/unsafe/vector.rs +++ b/tests/unit/out/unsafe/vector.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -33,7 +32,6 @@ pub unsafe fn copy_0(mut copy_vector: Vec) {} MemberwiseUnsafe, CopyConstructibleUnsafe, SwappableUnsafe, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(ConversionsUnsafe)] @@ -58,7 +56,6 @@ impl Foo { ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/vector_iter_range_ctor.rs b/tests/unit/out/unsafe/vector_iter_range_ctor.rs index 202b307dc7..8e8a5fae5f 100644 --- a/tests/unit/out/unsafe/vector_iter_range_ctor.rs +++ b/tests/unit/out/unsafe/vector_iter_range_ctor.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, DefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -37,7 +36,6 @@ impl Degrees { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/vector_subscript_direct.rs b/tests/unit/out/unsafe/vector_subscript_direct.rs index 05d58cc823..aa1c512d27 100644 --- a/tests/unit/out/unsafe/vector_subscript_direct.rs +++ b/tests/unit/out/unsafe/vector_subscript_direct.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -38,7 +37,6 @@ impl Point { MemberwiseUnsafe, CopyConstructibleUnsafe, SwappableUnsafe, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(ConversionsUnsafe)] diff --git a/tests/unit/out/unsafe/vector_with_allocator.rs b/tests/unit/out/unsafe/vector_with_allocator.rs index 1ba3b4e042..a75c324c55 100644 --- a/tests/unit/out/unsafe/vector_with_allocator.rs +++ b/tests/unit/out/unsafe/vector_with_allocator.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -46,7 +45,6 @@ impl TestAllocator_int_ { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/unit/out/unsafe/void_cast.rs b/tests/unit/out/unsafe/void_cast.rs index 73b2c93ee8..2c6ade5828 100644 --- a/tests/unit/out/unsafe/void_cast.rs +++ b/tests/unit/out/unsafe/void_cast.rs @@ -17,7 +17,6 @@ pub unsafe fn unused_param_0(mut x: i32) {} MemberwiseUnsafe, CopyConstructibleUnsafe, SwappableUnsafe, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(ConversionsUnsafe)] @@ -48,7 +47,6 @@ pub unsafe fn bump_and_return_4() -> i32 { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -57,12 +55,7 @@ pub struct Holder { } #[repr(C)] #[derive( - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - MemberwiseUnsafe, - SwappableUnsafe, - Default, + FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, MemberwiseUnsafe, SwappableUnsafe, )] #[memberwise(move_constructor, move_assign)] #[derive(ConversionsUnsafe)] From 4b8b7b782471660b549835ece5f676018f177867 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Fri, 4 Dec 2026 19:58:20 +0000 Subject: [PATCH 02/14] Remove last pieces of Default from converter --- cpp2rust/converter/converter.cpp | 114 ++---------------- cpp2rust/converter/converter.h | 14 +-- cpp2rust/converter/lex.h | 1 - .../converter/models/converter_refcount.cpp | 16 +-- .../converter/models/converter_refcount.h | 4 +- 5 files changed, 15 insertions(+), 134 deletions(-) diff --git a/cpp2rust/converter/converter.cpp b/cpp2rust/converter/converter.cpp index fa688b9c02..eb02d0b843 100644 --- a/cpp2rust/converter/converter.cpp +++ b/cpp2rust/converter/converter.cpp @@ -936,56 +936,6 @@ void Converter::EmitScopedDestructor(const clang::VarDecl *decl) { GetNamedDeclAsString(decl))); } -bool Converter::RecordDerivesDefault(const clang::RecordDecl *decl) { - if (RecordNeedsDestruction(decl)) { - return false; - } - if (auto cxx_decl = clang::dyn_cast(decl)) { - if (GetUserDefinedDefaultConstructor(cxx_decl)) { - return false; - } - } - - for (auto f : decl->fields()) { - if (f->hasInClassInitializer() || !TypeDerivesDefault(f->getType())) { - return false; - } - } - - return true; -} - -bool Converter::TypeDerivesDefault(clang::QualType qual_type) { - // Rust only implements Default for arrays of up to 32 elements - if (auto *array_type = ctx_.getAsConstantArrayType(qual_type)) { - return array_type->getSize().ule(32) && - TypeDerivesDefault(array_type->getElementType()); - } - if (qual_type->isArrayType() || qual_type->isMemberPointerType()) { - return false; - } - - auto *cxx_record = qual_type->getAsCXXRecordDecl(); - if (IsStdDecl(cxx_record, "array") || IsStdDecl(cxx_record, "basic_string")) { - return false; - } - - // libc types do not implement Default - if (auto record = qual_type->getAsRecordDecl()) { - if (ctx_.getSourceManager().isInSystemHeader(record->getLocation()) && - qual_type.isPODType(ctx_)) { - return false; - } - } - - if (auto lambda = AsLambdaClass(qual_type); - lambda && lambda->captures().empty()) { - return false; - } - - return true; -} - bool Converter::IsPassThroughRule(clang::Expr *expr) { const auto *rule = RuleRegistry::GetExprRule(ctx_, expr); if (!rule || rule->body.size() != 1) { @@ -4768,7 +4718,7 @@ bool Converter::VisitCXXNullPtrLiteralExpr(clang::CXXNullPtrLiteralExpr *expr) { return false; } -void Converter::EmitNullPointer() { EmitFresh(token::kDefault); } +void Converter::EmitNullPointer() { EmitFresh("std::ptr::null_mut()"); } bool Converter::VisitVAArgExpr(clang::VAArgExpr *expr) { auto va_list_expr = expr->getSubExpr(); @@ -5317,6 +5267,10 @@ bool Converter::VisitImplicitValueInitExpr(clang::ImplicitValueInitExpr *expr) { } else if (elem_ty->isMemberDataPointerType()) { StrCat(std::format("[{}; {}]", GetDefaultAsString(elem_ty), arr_ty->getSize().getZExtValue())); + } else if (elem_ty->isRecordType()) { + StrCat(std::format("std::array::from_fn::<_, {}, _>(|_| {})", + arr_ty->getSize().getZExtValue(), + GetDefaultAsString(elem_ty))); } else { StrCat( std::format("std::array::from_fn::<_, {}, _>(|_| Default::default())", @@ -5521,10 +5475,13 @@ std::string Converter::GetDefaultAsString(clang::QualType qual_type) { : "std::ptr::null_mut()"; } - // A type without Default is constructed by its default constructor. if (auto *record = qual_type->getAsRecordDecl(); - record && RecordNeedsDestruction(record)) { - return std::format("<{}>::default_constructed()", + record && IsUserDefinedDecl(record)) { + auto *cxx = clang::dyn_cast(record); + assert((!cxx || !cxx->hasDefaultConstructor() || + cxx->hasTrivialDefaultConstructor()) && + "a non-trivial default constructor constructs into storage"); + return std::format("{} {{ <{}>::zero_init() }}", keyword_unsafe_, ToString(qual_type.getUnqualifiedType())); } @@ -5631,10 +5588,6 @@ Converter::GetStructAttributes(const clang::RecordDecl *decl) { AddSpecialMemberDerives(decl, struct_attrs); - if (RecordDerivesDefault(decl)) { - struct_attrs.emplace_back("Default"); - } - return struct_attrs; } @@ -6321,38 +6274,12 @@ bool Converter::RecordImplementsClone(const clang::RecordDecl *decl) { GetUserDefinedCopyConstructor(decl) != nullptr; } -void Converter::AddDefaultTraitForUnion(const clang::RecordDecl *decl) { - EmitDefaultImpl(decl, [&] { StrCat("unsafe { std::mem::zeroed() }"); }); -} - 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; - } - if (RecordDerivesDefault(decl) || RecordNeedsDestruction(decl)) { - return; - } - EmitDefaultImpl(decl, [&] { - StrCat(keyword_unsafe_); - PushBrace unsafe_brace(*this); - auto *cxx = clang::dyn_cast(decl); - if (cxx && !cxx->hasDefaultConstructor()) { - StrCat(std::format("<{}>::zero_init()", GetRecordName(decl))); - return; - } - if (auto *default_ctor = - cxx ? GetUserDefinedDefaultConstructor(cxx) : nullptr) { - Convert(MakeDefaultConstructExpr(cxx, default_ctor)); - } else { - EmitDefaultStructLiteral(decl); - } - }); } clang::CXXConstructExpr * @@ -6382,25 +6309,6 @@ void Converter::AddDefaultConstructibleTrait(const clang::CXXRecordDecl *decl, } } -void Converter::EmitDefaultImpl(const clang::RecordDecl *decl, - llvm::function_ref body) { - StrCat(std::format("impl Default for {}", GetRecordName(decl))); - PushBrace impl_brace(*this); - StrCat("fn default() -> Self"); - PushBrace fn_brace(*this); - body(); -} - -void Converter::EmitDefaultStructLiteral(const clang::RecordDecl *decl) { - StrCat(GetRecordName(decl)); - PushBrace brace(*this); - for (auto *field : decl->fields()) { - StrCat(GetNamedDeclAsString(field), token::kColon); - ConvertFieldInit(field, field->getInClassInitializer()); - StrCat(token::kComma); - } -} - void Converter::ConvertFieldInit(const clang::FieldDecl *field, clang::Expr *init) { if (init) { diff --git a/cpp2rust/converter/converter.h b/cpp2rust/converter/converter.h index 44dbc79de1..93aaa76b1e 100644 --- a/cpp2rust/converter/converter.h +++ b/cpp2rust/converter/converter.h @@ -631,7 +631,7 @@ class Converter : public clang::RecursiveASTVisitor { // The value of expr, an integer constant expression. void EmitEvaluatedInt(clang::Expr *expr); - void EmitNullPointer(); + virtual void EmitNullPointer(); bool VisitCXXNoexceptExpr(clang::CXXNoexceptExpr *expr); @@ -1033,8 +1033,6 @@ class Converter : public clang::RecursiveASTVisitor { std::string GetCopyOrMoveSourceType(const RecordTrait &trait, std::string_view self = "Self") const; - virtual void AddDefaultTraitForUnion(const clang::RecordDecl *decl); - clang::CXXConstructExpr * MakeDefaultConstructExpr(const clang::CXXRecordDecl *decl, clang::CXXConstructorDecl *ctor); @@ -1042,12 +1040,6 @@ class Converter : public clang::RecursiveASTVisitor { 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. - void EmitDefaultImpl(const clang::RecordDecl *decl, - llvm::function_ref body); - virtual void EmitByteSizeAttr(const clang::RecordDecl *decl); virtual void @@ -1213,10 +1205,6 @@ class Converter : public clang::RecursiveASTVisitor { bool ExprMapsValueToPointer(const clang::CallExpr *expr) const; - virtual bool RecordDerivesDefault(const clang::RecordDecl *decl); - - virtual bool TypeDerivesDefault(clang::QualType qual_type); - bool RecordDerivesCopy(clang::QualType type); bool IsPassThroughRule(clang::Expr *expr); diff --git a/cpp2rust/converter/lex.h b/cpp2rust/converter/lex.h index 93b3b4a8d2..2868a742ff 100644 --- a/cpp2rust/converter/lex.h +++ b/cpp2rust/converter/lex.h @@ -63,7 +63,6 @@ inline constexpr const char kMut[] = "mut"; } // namespace keyword namespace token { -inline constexpr const char kDefault[] = "Default::default()"; inline constexpr const char kIgnoreRule[] = "libcc2rs::IgnoreRule"; } // namespace token } // namespace cpp2rust diff --git a/cpp2rust/converter/models/converter_refcount.cpp b/cpp2rust/converter/models/converter_refcount.cpp index 3435b57a9b..802c5dfe5a 100644 --- a/cpp2rust/converter/models/converter_refcount.cpp +++ b/cpp2rust/converter/models/converter_refcount.cpp @@ -745,12 +745,8 @@ void ConverterRefCount::AddDefaultTrait(const clang::RecordDecl *decl) { Converter::AddDefaultTrait(decl); } -void ConverterRefCount::AddDefaultTraitForUnion(const clang::RecordDecl *decl) { - EmitDefaultImpl(decl, [&] { - StrCat(std::format("{} {{ __bytes: Box::from([0u8; {}]) }}", - GetRecordName(decl), - ctx_.getASTRecordLayout(decl).getSize().getQuantity())); - }); +void ConverterRefCount::EmitNullPointer() { + EmitFresh("Ptr::<()>::null().to_any()"); } void ConverterRefCount::EmitRustUnion(clang::RecordDecl *decl) { @@ -2346,9 +2342,6 @@ ConverterRefCount::GetStructAttributes(const clang::RecordDecl *decl) { AddSpecialMemberDerives(decl, attrs); - if (RecordDerivesDefault(decl)) { - attrs.emplace_back("Default"); - } return attrs; } @@ -2357,11 +2350,6 @@ ConverterRefCount::GetRecordTraitSpelling(const RecordTrait &trait) const { return trait.refcount; } -bool ConverterRefCount::TypeDerivesDefault(clang::QualType qual_type) { - // Arrays are translated to Value>, whose Default is empty - return !qual_type->isArrayType() && Converter::TypeDerivesDefault(qual_type); -} - std::string ConverterRefCount::ConvertVarInitValue(clang::QualType qual_type, clang::Expr *expr) { if (auto lambda = clang::dyn_cast( diff --git a/cpp2rust/converter/models/converter_refcount.h b/cpp2rust/converter/models/converter_refcount.h index b65cd7cfbd..066bd83c1d 100644 --- a/cpp2rust/converter/models/converter_refcount.h +++ b/cpp2rust/converter/models/converter_refcount.h @@ -81,7 +81,7 @@ class ConverterRefCount final : public Converter { void AddDefaultTrait(const clang::RecordDecl *decl) override; - void AddDefaultTraitForUnion(const clang::RecordDecl *decl) override; + void EmitNullPointer() override; std::string GetSelfMaybeWithMut(const clang::CXXMethodDecl *decl) override; @@ -325,8 +325,6 @@ class ConverterRefCount final : public Converter { std::vector GetStructAttributes(const clang::RecordDecl *decl) override; - bool TypeDerivesDefault(clang::QualType qual_type) override; - bool Convert(clang::QualType qual_type) override; bool Convert(clang::Expr *expr, From b931530c0fb11a5787331305c5efaf6061e98a01 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Fri, 4 Dec 2026 20:09:12 +0000 Subject: [PATCH 03/14] Update tests --- tests/std/basic/out/refcount/basic.def.odr.rs | 41 +++--------- tests/std/basic/out/unsafe/basic.def.odr.rs | 42 +++--------- .../class.mem.general-unsupported.cpp | 36 ----------- .../std/class/class.mem/class.mem.general.cpp | 29 +++++++++ .../out/refcount/class.mem.general.rs | 53 +++++++++++++++ .../class.mem/out/unsafe/class.mem.general.rs | 45 +++++++++++++ .../out/refcount/field_method_receiver.rs | 33 ++++------ tests/unit/out/refcount/field_pointers.rs | 44 +++++-------- .../refcount/in_class_field_initializer.rs | 24 +------ tests/unit/out/refcount/init_list.rs | 17 +---- tests/unit/out/refcount/polymorphism.rs | 16 +++-- .../unit/out/refcount/struct_default_ctor.rs | 64 +++++++------------ tests/unit/out/refcount/unboxed_locals.rs | 12 ++-- .../unit/out/unsafe/field_method_receiver.rs | 20 ++++-- tests/unit/out/unsafe/field_pointers.rs | 16 +++-- .../out/unsafe/in_class_field_initializer.rs | 24 +------ tests/unit/out/unsafe/init_list.rs | 17 +---- tests/unit/out/unsafe/polymorphism.rs | 16 +++-- tests/unit/out/unsafe/struct_default_ctor.rs | 56 +++++++--------- tests/unit/out/unsafe/unboxed_locals.rs | 12 ++-- 20 files changed, 282 insertions(+), 335 deletions(-) delete mode 100644 tests/std/class/class.mem/class.mem.general-unsupported.cpp diff --git a/tests/std/basic/out/refcount/basic.def.odr.rs b/tests/std/basic/out/refcount/basic.def.odr.rs index 4aa16c4365..9ded0a1d71 100644 --- a/tests/std/basic/out/refcount/basic.def.odr.rs +++ b/tests/std/basic/out/refcount/basic.def.odr.rs @@ -19,7 +19,6 @@ thread_local!( MoveConstructible, MoveAssignable, Swappable, - Default, )] #[memberwise(copy_assign)] #[derive(Conversions)] @@ -253,17 +252,21 @@ pub trait p4_1_pure_virtual_without_definition_HasPureVirtual { ZeroInitialization, VaArg, FnPtrArg, - DefaultInitializable, + Destructible, Copyable, - Default, Conversions, )] #[conversions(copy, move)] +#[constructor(constructor_1)] #[byte_size(8)] pub struct p4_1_pure_virtual_without_definition_OverridesPureVirtual {} +impl p4_1_pure_virtual_without_definition_OverridesPureVirtual { + pub fn constructor_1(this: Ptr) {} +} pub fn test_11() { - let d: Value = Rc::new( - RefCell::new(::default()), + object!( + d, + p4_1_pure_virtual_without_definition_OverridesPureVirtual::constructor_1() ); let mut p: PtrDyn = (d.as_pointer()).to_dyn::(|w| w); @@ -381,7 +384,6 @@ thread_local!( MoveConstructible, MoveAssignable, Swappable, - Default, )] #[memberwise(copy_assign)] #[derive(Conversions)] @@ -660,18 +662,6 @@ impl p9_unused_copy_constructor_HasUndefinedCopyCtor { (*ctor_calls_29.with(Value::clone).borrow_mut()).prefix_inc(); } } -impl Default for p9_unused_copy_constructor_HasUndefinedCopyCtor { - fn default() -> Self { - { - { - let __v: Value = - Rc::new(RefCell::new(ZeroInitialization::zero_init())); - p9_unused_copy_constructor_HasUndefinedCopyCtor::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} pub fn read_30(object: Ptr) -> i32 { return object.with(|__s| __s.value); } @@ -708,20 +698,6 @@ impl p9_unused_implicit_assignment_HasUndefinedCopyAssignment { (*m_ctors_32.with(Value::clone).borrow_mut()).prefix_inc(); } } -impl Default for p9_unused_implicit_assignment_HasUndefinedCopyAssignment { - fn default() -> Self { - { - { - let __v: Value = - Rc::new(RefCell::new(ZeroInitialization::zero_init())); - p9_unused_implicit_assignment_HasUndefinedCopyAssignment::constructor_1( - __v.as_pointer(), - ); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} #[derive( Copy, Clone, @@ -732,7 +708,6 @@ impl Default for p9_unused_implicit_assignment_HasUndefinedCopyAssignment { FnPtrArg, Destructible, Copyable, - Default, Conversions, )] #[conversions(copy, move)] diff --git a/tests/std/basic/out/unsafe/basic.def.odr.rs b/tests/std/basic/out/unsafe/basic.def.odr.rs index 96d07ff20f..2d30428bf2 100644 --- a/tests/std/basic/out/unsafe/basic.def.odr.rs +++ b/tests/std/basic/out/unsafe/basic.def.odr.rs @@ -16,7 +16,6 @@ pub static mut copyCount_0: std::cell::LazyCell = std::cell::LazyCell::new( MoveConstructibleUnsafe, MoveAssignableUnsafe, SwappableUnsafe, - Default, )] #[memberwise(copy_assign)] #[derive(ConversionsUnsafe)] @@ -206,16 +205,21 @@ pub unsafe trait p4_1_pure_virtual_without_definition_HasPureVirtual { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultInitializableUnsafe, + DestructibleUnsafe, CopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] +#[constructor(constructor_1)] pub struct p4_1_pure_virtual_without_definition_OverridesPureVirtual {} +impl p4_1_pure_virtual_without_definition_OverridesPureVirtual { + pub unsafe fn constructor_1(this: *mut Self) {} +} pub unsafe fn test_11() { - let mut d: p4_1_pure_virtual_without_definition_OverridesPureVirtual = - ::default(); + object_unsafe!( + d, + p4_1_pure_virtual_without_definition_OverridesPureVirtual::constructor_1() + ); let mut p: *mut dyn p4_1_pure_virtual_without_definition_HasPureVirtual = (&mut d as *mut p4_1_pure_virtual_without_definition_OverridesPureVirtual); (unsafe { (*p).f() }); @@ -333,7 +337,6 @@ pub static mut copies_18: std::cell::LazyCell = std::cell::LazyCell::new(|| MoveConstructibleUnsafe, MoveAssignableUnsafe, SwappableUnsafe, - Default, )] #[memberwise(copy_assign)] #[derive(ConversionsUnsafe)] @@ -593,18 +596,6 @@ impl p9_unused_copy_constructor_HasUndefinedCopyCtor { (*std::cell::LazyCell::force_mut(&mut *&raw mut ctor_calls_29)).prefix_inc(); } } -impl Default for p9_unused_copy_constructor_HasUndefinedCopyCtor { - fn default() -> Self { - unsafe { - { - let mut __v: p9_unused_copy_constructor_HasUndefinedCopyCtor = - ZeroInitializationUnsafe::zero_init(); - p9_unused_copy_constructor_HasUndefinedCopyCtor::constructor_1(&raw mut __v); - __v - } - } - } -} pub unsafe fn read_30(object: *const p9_unused_copy_constructor_HasUndefinedCopyCtor) -> i32 { return (*object).value; } @@ -637,20 +628,6 @@ impl p9_unused_implicit_assignment_HasUndefinedCopyAssignment { (*std::cell::LazyCell::force_mut(&mut *&raw mut m_ctors_32)).prefix_inc(); } } -impl Default for p9_unused_implicit_assignment_HasUndefinedCopyAssignment { - fn default() -> Self { - unsafe { - { - let mut __v: p9_unused_implicit_assignment_HasUndefinedCopyAssignment = - ZeroInitializationUnsafe::zero_init(); - p9_unused_implicit_assignment_HasUndefinedCopyAssignment::constructor_1( - &raw mut __v, - ); - __v - } - } - } -} #[repr(C)] #[derive( Copy, @@ -660,7 +637,6 @@ impl Default for p9_unused_implicit_assignment_HasUndefinedCopyAssignment { ZeroInitializationUnsafe, DestructibleUnsafe, CopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] diff --git a/tests/std/class/class.mem/class.mem.general-unsupported.cpp b/tests/std/class/class.mem/class.mem.general-unsupported.cpp deleted file mode 100644 index d9ec9528f0..0000000000 --- a/tests/std/class/class.mem/class.mem.general-unsupported.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// no-compile: refcount, unsafe -// ADDITIONAL_COMPILE_FLAGS: -std=c++23 -#include - -// N4950 [class.mem.general]/7.5: a default member initializer within the -// member-specification of a class is a complete-class context. -namespace p7_5_default_member_initializer_names_later_member { -static int member_calls; - -int base = 100; -int scaled(int amount) { return amount * 1000; } - -struct HasLaterInitializerOperands { - int first = base + 1; - int second = scaled(first); - - static inline int base = 4; - int scaled(int amount) const { - ++member_calls; - return amount * 10; - } -}; - -void test() { - HasLaterInitializerOperands object; - assert(object.first == 5); - assert(object.second == 50); - assert(member_calls == 1); - assert(base == 100); -} -} // namespace p7_5_default_member_initializer_names_later_member - -int main() { - p7_5_default_member_initializer_names_later_member::test(); - return 0; -} diff --git a/tests/std/class/class.mem/class.mem.general.cpp b/tests/std/class/class.mem/class.mem.general.cpp index c4a31c54de..f3b318f21b 100644 --- a/tests/std/class/class.mem/class.mem.general.cpp +++ b/tests/std/class/class.mem/class.mem.general.cpp @@ -50,8 +50,37 @@ void test() { } } // namespace p7_2_default_argument_names_later_member +// N4950 [class.mem.general]/7.5: a default member initializer within the +// member-specification of a class is a complete-class context. +namespace p7_5_default_member_initializer_names_later_member { +static int member_calls; + +int base = 100; +int scaled(int amount) { return amount * 1000; } + +struct HasLaterInitializerOperands { + int first = base + 1; + int second = scaled(first); + + static inline int base = 4; + int scaled(int amount) const { + ++member_calls; + return amount * 10; + } +}; + +void test() { + HasLaterInitializerOperands object; + assert(object.first == 5); + assert(object.second == 50); + assert(member_calls == 1); + assert(base == 100); +} +} // namespace p7_5_default_member_initializer_names_later_member + int main() { p7_1_function_body_names_later_member::test(); p7_2_default_argument_names_later_member::test(); + p7_5_default_member_initializer_names_later_member::test(); return 0; } 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 53d8db8bf2..87b7a77713 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 @@ -119,6 +119,55 @@ pub fn test_6() { ); assert!((step_4.with(|rc| *rc.borrow()) == 100)); } +thread_local!( + pub static member_calls_7: Value = Rc::new(RefCell::new(0_i32)); +); +thread_local!( + pub static base_8: Value = Rc::new(RefCell::new(100)); +); +pub fn scaled_9(mut amount: i32) -> i32 { + return (amount * 1000); +} +thread_local!( + pub static base_10: Value = Rc::new(RefCell::new(4)); +); +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyCopyable, + Conversions, +)] +#[conversions(copy, move)] +#[constructor(constructor_1)] +#[byte_size(8)] +pub struct p7_5_default_member_initializer_names_later_member_HasLaterInitializerOperands { + #[offset(0)] + pub first: i32, + #[offset(4)] + pub second: i32, +} +impl p7_5_default_member_initializer_names_later_member_HasLaterInitializerOperands { + pub fn scaled(this: Ptr, mut amount: i32) -> i32 { + (*member_calls_7.with(Value::clone).borrow_mut()).prefix_inc(); + return (amount * 10); + } + pub fn constructor_1(this: Ptr) { + field!(this, first).write((base_10.with(|rc| *rc.borrow()) + 1)); + field!(this, second).write(( { p7_5_default_member_initializer_names_later_member_HasLaterInitializerOperands :: scaled ( this.clone() , this .with(|__s| __s . first ) , ) } ) ); + } +} +pub fn test_11() { + object!(object, p7_5_default_member_initializer_names_later_member_HasLaterInitializerOperands::constructor_1()); + assert!(({ (*object.borrow()).first } == 5)); + assert!(({ (*object.borrow()).second } == 50)); + assert!((member_calls_7.with(|rc| *rc.borrow()) == 1)); + assert!((base_8.with(|rc| *rc.borrow()) == 100)); +} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); @@ -126,10 +175,14 @@ pub fn main() { fn main_0() -> i32 { ({ test_3() }); ({ test_6() }); + ({ test_11() }); return 0; } pub fn __cpp2rust_init_globals() { let _ = stock_0.with(|_| ()); let _ = step_4.with(|_| ()); let _ = step_5.with(|_| ()); + let _ = member_calls_7.with(|_| ()); + let _ = base_8.with(|_| ()); + let _ = base_10.with(|_| ()); } 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 05d45ba1dc..3562e42e05 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 @@ -102,6 +102,47 @@ pub unsafe fn test_6() { ); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut step_4)) == (100))); } +pub static mut member_calls_7: std::cell::LazyCell = + std::cell::LazyCell::new(|| unsafe { 0_i32 }); +pub static mut base_8: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 100 }); +pub unsafe fn scaled_9(mut amount: i32) -> i32 { + return ((amount) * (1000)); +} +pub static mut base_10: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 4 }); +#[repr(C)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + TriviallyCopyableUnsafe, + ConversionsUnsafe, +)] +#[conversions(copy, move)] +#[constructor(constructor_1)] +pub struct p7_5_default_member_initializer_names_later_member_HasLaterInitializerOperands { + pub first: i32, + pub second: i32, +} +impl p7_5_default_member_initializer_names_later_member_HasLaterInitializerOperands { + pub unsafe fn scaled(this: *const Self, mut amount: i32) -> i32 { + (*std::cell::LazyCell::force_mut(&mut *&raw mut member_calls_7)).prefix_inc(); + return ((amount) * (10)); + } + pub unsafe fn constructor_1(this: *mut Self) { + (&raw mut (*this).first) + .write(((*std::cell::LazyCell::force_mut(&mut *&raw mut base_10)) + (1))); + (&raw mut (*this).second).write(( unsafe { let _amount: i32 = ( * this ) . first ; p7_5_default_member_initializer_names_later_member_HasLaterInitializerOperands :: scaled ( ( this ) .cast_const() , _amount , ) } ) ); + } +} +pub unsafe fn test_11() { + object_unsafe!(object, p7_5_default_member_initializer_names_later_member_HasLaterInitializerOperands::constructor_1()); + assert!(((object.first) == (5))); + assert!(((object.second) == (50))); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut member_calls_7)) == (1))); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut base_8)) == (100))); +} pub fn main() { unsafe { __cpp2rust_init_globals(); @@ -111,10 +152,14 @@ pub fn main() { unsafe fn main_0() -> i32 { (unsafe { test_3() }); (unsafe { test_6() }); + (unsafe { test_11() }); return 0; } pub unsafe fn __cpp2rust_init_globals() { std::cell::LazyCell::force(&*&raw const stock_0); std::cell::LazyCell::force(&*&raw const step_4); std::cell::LazyCell::force(&*&raw const step_5); + std::cell::LazyCell::force(&*&raw const member_calls_7); + std::cell::LazyCell::force(&*&raw const base_8); + std::cell::LazyCell::force(&*&raw const base_10); } diff --git a/tests/unit/out/refcount/field_method_receiver.rs b/tests/unit/out/refcount/field_method_receiver.rs index b2f2329ea7..556af05fd7 100644 --- a/tests/unit/out/refcount/field_method_receiver.rs +++ b/tests/unit/out/refcount/field_method_receiver.rs @@ -16,7 +16,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -82,29 +81,15 @@ impl S { } pub fn constructor_1(this: Ptr) { field!(this, tag).write(0_i32); - field!(this, c).write(::default()); + field!(this, c).write({ ::zero_init() }); field!(this, arr).write( (0..2) - .map(|_| ::default()) + .map(|_| ::zero_init()) .collect::>(), ); field!(this, v).write(Vec::new()); } } -impl Default for S { - fn default() -> Self { - { - S { - tag: 0_i32, - c: ::default(), - arr: (0..2) - .map(|_| ::default()) - .collect::>(), - v: Default::default(), - } - } - } -} pub fn run_0(mut o: Ptr) { ({ Counter::add(field_ptr!(o, c), 2) }); assert!((({ Counter::get(field_ptr!(o, c),) }) == 2)); @@ -144,10 +129,20 @@ 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(S { + tag: 0_i32, + c: { ::zero_init() }, + arr: Box::new([{ ::zero_init() }; 2]), + v: Vec::new(), + })); (*local.borrow_mut()).tag = 1; ({ run_0((local.as_pointer())) }); - let mut heap: Ptr = Ptr::alloc(::default()); + let mut heap: Ptr = Ptr::alloc(S { + tag: 0_i32, + c: { ::zero_init() }, + arr: Box::new([{ ::zero_init() }; 2]), + v: Vec::new(), + }); field!(heap, tag).write(1); ({ run_0((heap).clone()) }); heap.delete(); diff --git a/tests/unit/out/refcount/field_pointers.rs b/tests/unit/out/refcount/field_pointers.rs index b4007c4652..5ca76785a1 100644 --- a/tests/unit/out/refcount/field_pointers.rs +++ b/tests/unit/out/refcount/field_pointers.rs @@ -27,16 +27,6 @@ pub struct Inner { #[array_len(8)] pub name: Box<[i8]>, } -impl Default for Inner { - fn default() -> Self { - { - Inner { - a: 0_i32, - name: (0..8).map(|_| 0_i8).collect::>(), - } - } - } -} #[derive( Copy, Clone, @@ -47,7 +37,6 @@ impl Default for Inner { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -111,27 +100,17 @@ impl Outer { } pub fn constructor_1(this: Ptr) { field!(this, x).write(0_i32); - field!(this, inner).write(::default()); - field!(this, items).write((0..3).map(|_| ::default()).collect::>()); + field!(this, inner).write({ ::zero_init() }); + field!(this, items).write( + (0..3) + .map(|_| ::zero_init()) + .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 { - fn default() -> Self { - { - Outer { - x: 0_i32, - inner: ::default(), - items: (0..3).map(|_| ::default()).collect::>(), - v: Default::default(), - cursor: Ptr::::null(), - buf: (0..4).map(|_| 0_i32).collect::>(), - } - } - } -} pub fn set_0(mut p: Ptr, mut value: i32) { p.write(value); } @@ -144,7 +123,16 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let o: Value = Rc::new(RefCell::new(::default())); + let o: Value = Rc::new(RefCell::new(Outer { + x: 0_i32, + inner: { ::zero_init() }, + items: Box::new([{ ::zero_init() }, { ::zero_init() }, { + ::zero_init() + }]), + v: Vec::new(), + cursor: Ptr::::null(), + buf: Box::new([0; 4]), + })); (*o.borrow_mut()).x = 1; let mut px: Ptr = (field_ptr!(o.as_pointer(), x)); px.write(2); diff --git a/tests/unit/out/refcount/in_class_field_initializer.rs b/tests/unit/out/refcount/in_class_field_initializer.rs index a4404eedc0..6224e45185 100644 --- a/tests/unit/out/refcount/in_class_field_initializer.rs +++ b/tests/unit/out/refcount/in_class_field_initializer.rs @@ -32,11 +32,6 @@ impl Inner { field!(this, y).write(4); } } -impl Default for Inner { - fn default() -> Self { - { Inner { x: 3, y: 4 } } - } -} #[derive( Copy, Clone, @@ -67,22 +62,10 @@ impl S { pub fn constructor_1(this: Ptr) { field!(this, a).write(1); field!(this, b).write(2_i8); - field!(this, c).write(::default()); + field!(this, c).write(Inner { x: 3, y: 4 }); Inner::constructor_1(field_ptr!(this, d)); } } -impl Default for S { - fn default() -> Self { - { - S { - a: 1, - b: 2_i8, - c: ::default(), - d: ::default(), - } - } - } -} #[derive( Copy, Clone, @@ -110,11 +93,6 @@ impl Boxed_int_ { field!(this, tag).write(t); } } -impl Default for Boxed_int_ { - fn default() -> Self { - { ::zero_init() } - } -} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); diff --git a/tests/unit/out/refcount/init_list.rs b/tests/unit/out/refcount/init_list.rs index 0e4e1e348d..9609a591cb 100644 --- a/tests/unit/out/refcount/init_list.rs +++ b/tests/unit/out/refcount/init_list.rs @@ -19,7 +19,6 @@ pub fn f_0(list: Vec) { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -58,15 +57,6 @@ impl Holder { field!(this, p).write(Pair { a: 0, b: 0 }); } } -impl Default for Holder { - fn default() -> Self { - { - Holder { - p: Pair { a: 0, b: 0 }, - } - } - } -} pub fn sum_1(p: Ptr) -> i32 { return ({ p.with(|__s| __s.a) } + { p.with(|__s| __s.b) }); } @@ -93,11 +83,6 @@ impl Seven { field!(this, v).write(7); } } -impl Default for Seven { - fn default() -> Self { - { Seven { v: 7 } } - } -} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); @@ -115,7 +100,7 @@ fn main_0() -> i32 { Holder::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)); - let mut sevens: [Seven; 4] = [::default(); 4]; + let mut sevens: [Seven; 4] = [Seven { v: 7 }; 4]; { let mut i: i32 = 0; 'loop_: while (i < 4) { diff --git a/tests/unit/out/refcount/polymorphism.rs b/tests/unit/out/refcount/polymorphism.rs index 74467e5cd4..faf82ceef0 100644 --- a/tests/unit/out/refcount/polymorphism.rs +++ b/tests/unit/out/refcount/polymorphism.rs @@ -17,14 +17,17 @@ pub trait Animal { ZeroInitialization, VaArg, FnPtrArg, - DefaultInitializable, + Destructible, Copyable, - Default, Conversions, )] #[conversions(copy, move)] +#[constructor(constructor_1)] #[byte_size(8)] pub struct Dog {} +impl Dog { + pub fn constructor_1(this: Ptr) {} +} #[derive( Copy, Clone, @@ -33,28 +36,29 @@ pub struct Dog {} ZeroInitialization, VaArg, FnPtrArg, - DefaultInitializable, + Destructible, Copyable, - Default, Conversions, )] #[conversions(copy, move)] +#[constructor(constructor_1)] #[byte_size(8)] pub struct Cat {} impl Cat { fn meow(this: Ptr) -> bool { return true; } + pub fn constructor_1(this: Ptr) {} } pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let dog: Value = Rc::new(RefCell::new(::default())); + object!(dog, Dog::constructor_1()); let mut animal: PtrDyn = (dog.as_pointer()).to_dyn::(|w| w); let mut eat1: bool = ({ (*animal.upgrade().deref()).bark() }); - let cat: Value = Rc::new(RefCell::new(::default())); + object!(cat, Cat::constructor_1()); animal = (cat.as_pointer()).to_dyn::(|w| w); let mut eat2: bool = ({ (*animal.upgrade().deref()).bark() }); assert!((eat1) && (!(eat2))); diff --git a/tests/unit/out/refcount/struct_default_ctor.rs b/tests/unit/out/refcount/struct_default_ctor.rs index cbe377b96f..d24fb6812f 100644 --- a/tests/unit/out/refcount/struct_default_ctor.rs +++ b/tests/unit/out/refcount/struct_default_ctor.rs @@ -32,17 +32,6 @@ impl S { field!(this, b).write(true); } } -impl Default for S { - fn default() -> Self { - { - { - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - S::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} #[derive( Copy, Clone, @@ -52,7 +41,6 @@ impl Default for S { VaArg, FnPtrArg, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -83,15 +71,6 @@ impl Holder { }))); } } -impl Default for Holder { - fn default() -> Self { - { - Holder { - items: (0..2).map(|_| ::default()).collect::>(), - } - } - } -} thread_local!( pub static kInit_0: Value = Rc::new(RefCell::new(3)); ); @@ -118,15 +97,6 @@ impl FromStatic { field!(this, v).write(kInit_0.with(|rc| *rc.borrow())); } } -impl Default for FromStatic { - fn default() -> Self { - { - FromStatic { - v: kInit_0.with(|rc| *rc.borrow()), - } - } - } -} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); @@ -137,18 +107,32 @@ fn main_0() -> i32 { object!(s, S::constructor_1()); assert!(({ (*s.borrow()).a } == 11)); assert!((({ (*s.borrow()).b } as i32) == (true as i32))); - let mut h: Ptr = Ptr::alloc_array( - (0..1_usize) - .map(|_| ::default()) - .collect::>(), - ); + let mut h: Ptr = { + let __n = (1_usize) as usize; + let __p = Ptr::alloc_array( + (0..__n) + .map(|_| ::zero_init()) + .collect::>(), + ); + for __i in 0..__n { + Holder::constructor_1(__p.offset(__i)); + } + __p + }; assert!((array_elem!(h.offset((0) as isize), items, 1).with(|__s| __s.a) == 11)); h.delete(); - let mut fs: Ptr = Ptr::alloc_array( - (0..2_usize) - .map(|_| ::default()) - .collect::>(), - ); + let mut fs: Ptr = { + let __n = (2_usize) as usize; + let __p = Ptr::alloc_array( + (0..__n) + .map(|_| ::zero_init()) + .collect::>(), + ); + for __i in 0..__n { + FromStatic::constructor_1(__p.offset(__i)); + } + __p + }; assert!((elem!(fs, 1).with(|__s| __s.v) == 3)); fs.delete(); return 0; diff --git a/tests/unit/out/refcount/unboxed_locals.rs b/tests/unit/out/refcount/unboxed_locals.rs index 2430ac05fb..64c2fc9413 100644 --- a/tests/unit/out/refcount/unboxed_locals.rs +++ b/tests/unit/out/refcount/unboxed_locals.rs @@ -24,7 +24,6 @@ pub fn inc_1(r: Ptr) { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -75,19 +74,20 @@ pub trait Shape { ZeroInitialization, VaArg, FnPtrArg, - DefaultInitializable, + Destructible, Copyable, Conversions, )] #[conversions(copy, move)] +#[constructor(constructor_1)] #[byte_size(16)] pub struct Square { #[offset(8)] pub side: i32, } -impl Default for Square { - fn default() -> Self { - { Square { side: 2 } } +impl Square { + pub fn constructor_1(this: Ptr) { + field!(this, side).write(2); } } pub fn main() { @@ -204,7 +204,7 @@ fn main_0() -> i32 { )); ({ set_0(data.decay(), 8) }); assert!(({ (*data.borrow())[0_usize] } == 8)); - let square: Value = Rc::new(RefCell::new(::default())); + object!(square, Square::constructor_1()); let mut shape: PtrDyn = (square.as_pointer()).to_dyn::(|w| w); assert!((({ (*shape.upgrade().deref_mut()).scale(3,) }) == 6)); return 0; diff --git a/tests/unit/out/unsafe/field_method_receiver.rs b/tests/unit/out/unsafe/field_method_receiver.rs index c3d8cccdc3..72f842041f 100644 --- a/tests/unit/out/unsafe/field_method_receiver.rs +++ b/tests/unit/out/unsafe/field_method_receiver.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -47,7 +46,6 @@ impl Counter { MemberwiseUnsafe, CopyConstructibleUnsafe, SwappableUnsafe, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(ConversionsUnsafe)] @@ -68,8 +66,8 @@ impl S { } pub unsafe fn constructor_1(this: *mut Self) { (&raw mut (*this).tag).write(0_i32); - (&raw mut (*this).c).write(::default()); - (&raw mut (*this).arr).write([::default(); 2]); + (&raw mut (*this).c).write(unsafe { ::zero_init() }); + (&raw mut (*this).arr).write([unsafe { ::zero_init() }; 2]); (&raw mut (*this).v).write(Vec::new()); } } @@ -109,10 +107,20 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut local: S = ::default(); + let mut local: S = S { + tag: 0_i32, + c: unsafe { ::zero_init() }, + arr: [unsafe { ::zero_init() }; 2], + v: Vec::new(), + }; local.tag = 1; (unsafe { run_0((&mut local as *mut S)) }); - let mut heap: *mut S = (Box::leak(Box::new(::default())) as *mut S); + let mut heap: *mut S = (Box::leak(Box::new(S { + tag: 0_i32, + c: unsafe { ::zero_init() }, + arr: [unsafe { ::zero_init() }; 2], + v: Vec::new(), + })) as *mut S); (*heap).tag = 1; (unsafe { run_0(heap) }); { diff --git a/tests/unit/out/unsafe/field_pointers.rs b/tests/unit/out/unsafe/field_pointers.rs index f501b40dac..a675bdd4ed 100644 --- a/tests/unit/out/unsafe/field_pointers.rs +++ b/tests/unit/out/unsafe/field_pointers.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -32,7 +31,6 @@ pub struct Inner { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -50,7 +48,6 @@ pub struct Header { MemberwiseUnsafe, CopyConstructibleUnsafe, SwappableUnsafe, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(ConversionsUnsafe)] @@ -79,8 +76,8 @@ impl Outer { } pub unsafe fn constructor_1(this: *mut Self) { (&raw mut (*this).x).write(0_i32); - (&raw mut (*this).inner).write(::default()); - (&raw mut (*this).items).write([::default(); 3]); + (&raw mut (*this).inner).write(unsafe { ::zero_init() }); + (&raw mut (*this).items).write([unsafe { ::zero_init() }; 3]); (&raw mut (*this).v).write(Vec::new()); (&raw mut (*this).cursor).write(std::ptr::null_mut()); (&raw mut (*this).buf).write([0_i32; 4]); @@ -100,7 +97,14 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut o: Outer = ::default(); + let mut o: Outer = Outer { + x: 0_i32, + inner: unsafe { ::zero_init() }, + items: [unsafe { ::zero_init() }; 3], + v: Vec::new(), + cursor: std::ptr::null_mut(), + buf: [0; 4], + }; o.x = 1; let mut px: *mut i32 = (&mut o.x as *mut i32); (*px) = 2; diff --git a/tests/unit/out/unsafe/in_class_field_initializer.rs b/tests/unit/out/unsafe/in_class_field_initializer.rs index 2f0295ed62..3ee21b529f 100644 --- a/tests/unit/out/unsafe/in_class_field_initializer.rs +++ b/tests/unit/out/unsafe/in_class_field_initializer.rs @@ -28,11 +28,6 @@ impl Inner { (&raw mut (*this).y).write(4); } } -impl Default for Inner { - fn default() -> Self { - unsafe { Inner { x: 3, y: 4 } } - } -} #[repr(C)] #[derive( Copy, @@ -55,22 +50,10 @@ impl S { pub unsafe fn constructor_1(this: *mut Self) { (&raw mut (*this).a).write(1); (&raw mut (*this).b).write((2 as libc::c_char)); - (&raw mut (*this).c).write(::default()); + (&raw mut (*this).c).write(Inner { x: 3, y: 4 }); Inner::constructor_1(&raw mut (*this).d); } } -impl Default for S { - fn default() -> Self { - unsafe { - S { - a: 1, - b: (2 as libc::c_char), - c: ::default(), - d: ::default(), - } - } - } -} #[repr(C)] #[derive( Copy, @@ -94,11 +77,6 @@ impl Boxed_int_ { (&raw mut (*this).tag).write(t); } } -impl Default for Boxed_int_ { - fn default() -> Self { - unsafe { ::zero_init() } - } -} pub fn main() { unsafe { __cpp2rust_init_globals(); diff --git a/tests/unit/out/unsafe/init_list.rs b/tests/unit/out/unsafe/init_list.rs index 1d8f5874e8..0f596ef3f5 100644 --- a/tests/unit/out/unsafe/init_list.rs +++ b/tests/unit/out/unsafe/init_list.rs @@ -16,7 +16,6 @@ pub unsafe fn f_0(mut list: Vec) {} ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -48,15 +47,6 @@ impl Holder { (&raw mut (*this).p).write(Pair { a: 0, b: 0 }); } } -impl Default for Holder { - fn default() -> Self { - unsafe { - Holder { - p: Pair { a: 0, b: 0 }, - } - } - } -} pub unsafe fn sum_1(p: *const Pair) -> i32 { return (((*p).a) + ((*p).b)); } @@ -80,11 +70,6 @@ impl Seven { (&raw mut (*this).v).write(7); } } -impl Default for Seven { - fn default() -> Self { - unsafe { Seven { v: 7 } } - } -} pub fn main() { unsafe { __cpp2rust_init_globals(); @@ -104,7 +89,7 @@ unsafe fn main_0() -> i32 { (unsafe { Holder::operator_assign_1(&raw mut h, &mut p) }); assert!(((h.p.a) == (1)) && ((h.p.b) == (2))); assert!(((unsafe { sum_1(&p,) }) == (3))); - let mut sevens: [Seven; 4] = [::default(); 4]; + let mut sevens: [Seven; 4] = [Seven { v: 7 }; 4]; { let mut i: i32 = 0; 'loop_: while ((i) < (4)) { diff --git a/tests/unit/out/unsafe/polymorphism.rs b/tests/unit/out/unsafe/polymorphism.rs index 571b2aac32..451c36ed86 100644 --- a/tests/unit/out/unsafe/polymorphism.rs +++ b/tests/unit/out/unsafe/polymorphism.rs @@ -16,13 +16,16 @@ pub unsafe trait Animal { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultInitializableUnsafe, + DestructibleUnsafe, CopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] +#[constructor(constructor_1)] pub struct Dog {} +impl Dog { + pub unsafe fn constructor_1(this: *mut Self) {} +} #[repr(C)] #[derive( Copy, @@ -30,17 +33,18 @@ pub struct Dog {} VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultInitializableUnsafe, + DestructibleUnsafe, CopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] +#[constructor(constructor_1)] pub struct Cat {} impl Cat { unsafe fn meow(this: *const Self) -> bool { return true; } + pub unsafe fn constructor_1(this: *mut Self) {} } pub fn main() { unsafe { @@ -49,10 +53,10 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut dog: Dog = ::default(); + object_unsafe!(dog, Dog::constructor_1()); let mut animal: *mut dyn Animal = (&mut dog as *mut Dog); let mut eat1: bool = (unsafe { (*(animal).cast_const()).bark() }); - let mut cat: Cat = ::default(); + object_unsafe!(cat, Cat::constructor_1()); animal = (&mut cat as *mut Cat); let mut eat2: bool = (unsafe { (*(animal).cast_const()).bark() }); assert!((eat1) && (!(eat2))); diff --git a/tests/unit/out/unsafe/struct_default_ctor.rs b/tests/unit/out/unsafe/struct_default_ctor.rs index d6b88c62e6..cd6b7bc69c 100644 --- a/tests/unit/out/unsafe/struct_default_ctor.rs +++ b/tests/unit/out/unsafe/struct_default_ctor.rs @@ -28,17 +28,6 @@ impl S { (&raw mut (*this).b).write(true); } } -impl Default for S { - fn default() -> Self { - unsafe { - { - let mut __v: S = ZeroInitializationUnsafe::zero_init(); - S::constructor_1(&raw mut __v); - __v - } - } - } -} #[repr(C)] #[derive( Copy, @@ -47,7 +36,6 @@ impl Default for S { FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -63,7 +51,6 @@ impl Declared {} FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -101,15 +88,6 @@ impl FromStatic { (&raw mut (*this).v).write((*std::cell::LazyCell::force_mut(&mut *&raw mut kInit_0))); } } -impl Default for FromStatic { - fn default() -> Self { - unsafe { - FromStatic { - v: (*std::cell::LazyCell::force_mut(&mut *&raw mut kInit_0)), - } - } - } -} pub fn main() { unsafe { __cpp2rust_init_globals(); @@ -122,11 +100,18 @@ unsafe fn main_0() -> i32 { object_unsafe!(s, S::constructor_1()); assert!(((s.a) == (11))); assert!(((s.b as i32) == (true as i32))); - let mut h: *mut Holder = Box::leak( - (0..1_usize) - .map(|_| ::default()) - .collect::>(), - ) + let mut h: *mut Holder = { + let __n = (1_usize) as usize; + let __p: &mut [Holder] = Box::leak( + (0..__n) + .map(|_| ::zero_init()) + .collect::>(), + ); + for __i in 0..__n { + Holder::constructor_1(&raw mut __p[__i]); + } + __p + } .as_mut_ptr(); assert!((((*h.offset((0) as isize)).items[(1) as usize].a) == (11))); { @@ -139,11 +124,18 @@ unsafe fn main_0() -> i32 { ))) } }; - let mut fs: *mut FromStatic = Box::leak( - (0..2_usize) - .map(|_| ::default()) - .collect::>(), - ) + let mut fs: *mut FromStatic = { + let __n = (2_usize) as usize; + let __p: &mut [FromStatic] = Box::leak( + (0..__n) + .map(|_| ::zero_init()) + .collect::>(), + ); + for __i in 0..__n { + FromStatic::constructor_1(&raw mut __p[__i]); + } + __p + } .as_mut_ptr(); assert!((((*fs.offset((1) as isize)).v) == (3))); { diff --git a/tests/unit/out/unsafe/unboxed_locals.rs b/tests/unit/out/unsafe/unboxed_locals.rs index 748a99e85b..3563fb6fb8 100644 --- a/tests/unit/out/unsafe/unboxed_locals.rs +++ b/tests/unit/out/unsafe/unboxed_locals.rs @@ -21,7 +21,6 @@ pub unsafe fn inc_1(r: *mut i32) { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -68,17 +67,18 @@ pub unsafe trait Shape { VaArg, FnPtrArg, ZeroInitializationUnsafe, - DefaultInitializableUnsafe, + DestructibleUnsafe, CopyableUnsafe, ConversionsUnsafe, )] #[conversions(copy, move)] +#[constructor(constructor_1)] pub struct Square { pub side: i32, } -impl Default for Square { - fn default() -> Self { - unsafe { Square { side: 2 } } +impl Square { + pub unsafe fn constructor_1(this: *mut Self) { + (&raw mut (*this).side).write(2); } } pub fn main() { @@ -186,7 +186,7 @@ unsafe fn main_0() -> i32 { let mut data: Vec = Vec::from_fn(2_usize, |_| copy_constructed_unsafe(&mut 0)); (unsafe { set_0(data.as_mut_ptr(), 8) }); assert!(((data[(0_usize)]) == (8))); - let mut square: Square = ::default(); + object_unsafe!(square, Square::constructor_1()); let mut shape: *mut dyn Shape = (&mut square as *mut Square); assert!(((unsafe { (*shape).scale(3,) }) == (6))); return 0; From d6aaabdc1a15629401f7f5162d1d35d2ce89fe20 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Fri, 4 Dec 2026 20:09:47 +0000 Subject: [PATCH 04/14] Fix initialization of array new --- cpp2rust/converter/converter.cpp | 27 ++++++++++--------- cpp2rust/converter/converter.h | 4 --- cpp2rust/converter/converter_lib.cpp | 25 +++++++++++++++++ cpp2rust/converter/converter_lib.h | 8 ++++++ .../converter/models/converter_refcount.cpp | 13 +++++++++ 5 files changed, 61 insertions(+), 16 deletions(-) diff --git a/cpp2rust/converter/converter.cpp b/cpp2rust/converter/converter.cpp index eb02d0b843..108d85678a 100644 --- a/cpp2rust/converter/converter.cpp +++ b/cpp2rust/converter/converter.cpp @@ -4754,6 +4754,20 @@ bool Converter::VisitCXXNewExpr(clang::CXXNewExpr *expr) { StrCat("Box::leak(Box::new("); Convert(init); StrCat("))"); + } else if (auto *construct = GetArrayNewElementConstruct(ctx_, expr)) { + PushBrace block(*this); + auto record_name = GetRecordName(construct->getConstructor()->getParent()); + StrCat(std::format( + "let __n = ({0}) as usize; let __p: &mut [{1}] = " + "Box::leak((0..__n).map(|_| <{1}>::zero_init()).collect::>" + "());", + ToString(*expr->getArraySize()), record_name)); + StrCat("for __i in 0..__n"); + { + PushBrace loop(*this); + ConstructInPlace(construct, construct, "&raw mut __p[__i]"); + } + StrCat("__p"); } else { assert(expr->getArraySize().has_value()); auto array_size_as_string = ToString(*expr->getArraySize()); @@ -6282,17 +6296,6 @@ void Converter::AddDefaultTrait(const clang::RecordDecl *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); @@ -6304,7 +6307,7 @@ void Converter::AddDefaultConstructibleTrait(const clang::CXXRecordDecl *decl, PushBrace fn_brace(*this); StrCat(keyword_unsafe_); PushBrace unsafe_brace(*this); - auto *construct = MakeDefaultConstructExpr(decl, ctor); + auto *construct = MakeDefaultConstructExpr(ctx_, decl, ctor); ConstructInPlace(construct, construct, spelling.receiver); } } diff --git a/cpp2rust/converter/converter.h b/cpp2rust/converter/converter.h index 93aaa76b1e..9eb50f5069 100644 --- a/cpp2rust/converter/converter.h +++ b/cpp2rust/converter/converter.h @@ -1033,10 +1033,6 @@ class Converter : public clang::RecursiveASTVisitor { std::string GetCopyOrMoveSourceType(const RecordTrait &trait, std::string_view self = "Self") const; - clang::CXXConstructExpr * - MakeDefaultConstructExpr(const clang::CXXRecordDecl *decl, - clang::CXXConstructorDecl *ctor); - void AddDefaultConstructibleTrait(const clang::CXXRecordDecl *decl, clang::CXXConstructorDecl *ctor); diff --git a/cpp2rust/converter/converter_lib.cpp b/cpp2rust/converter/converter_lib.cpp index 88fc850a5f..33f05d8af9 100644 --- a/cpp2rust/converter/converter_lib.cpp +++ b/cpp2rust/converter/converter_lib.cpp @@ -2651,6 +2651,31 @@ clang::CXXConstructExpr *MakeConstructExpr(clang::ASTContext &ctx, clang::SourceRange()); } +clang::CXXConstructExpr * +MakeDefaultConstructExpr(clang::ASTContext &ctx, + 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); +} + +clang::CXXConstructExpr *GetArrayNewElementConstruct(clang::ASTContext &ctx, + clang::CXXNewExpr *expr) { + auto *record = expr->getAllocatedType()->getAsCXXRecordDecl(); + auto *construct = + clang::dyn_cast_or_null(expr->getInitializer()); + if (!record || !construct || construct->getConstructor()->isTrivial()) { + return nullptr; + } + auto *element = + MakeDefaultConstructExpr(ctx, record, construct->getConstructor()); + return GetInPlaceConstruct(element) ? element : nullptr; +} + std::optional> GetTemplateArgs(clang::QualType qual_type, clang::Expr *expr) { if (auto ty = clang::dyn_cast(qual_type)) { diff --git a/cpp2rust/converter/converter_lib.h b/cpp2rust/converter/converter_lib.h index 51b08bcb1c..c95df6684c 100644 --- a/cpp2rust/converter/converter_lib.h +++ b/cpp2rust/converter/converter_lib.h @@ -559,6 +559,14 @@ clang::CXXConstructExpr *MakeConstructExpr(clang::ASTContext &ctx, clang::CXXConstructorDecl *ctor, llvm::ArrayRef args); +clang::CXXConstructExpr * +MakeDefaultConstructExpr(clang::ASTContext &ctx, + const clang::CXXRecordDecl *decl, + clang::CXXConstructorDecl *ctor); + +clang::CXXConstructExpr *GetArrayNewElementConstruct(clang::ASTContext &ctx, + clang::CXXNewExpr *expr); + std::optional> GetTemplateArgs(clang::QualType qual_type, clang::Expr *expr = nullptr); diff --git a/cpp2rust/converter/models/converter_refcount.cpp b/cpp2rust/converter/models/converter_refcount.cpp index 802c5dfe5a..087c72eb69 100644 --- a/cpp2rust/converter/models/converter_refcount.cpp +++ b/cpp2rust/converter/models/converter_refcount.cpp @@ -2020,6 +2020,19 @@ bool ConverterRefCount::VisitCXXNewExpr(clang::CXXNewExpr *expr) { PushConversionKind push(*this, ConversionKind::FullRefCount); Convert(init); StrCat(')'); + } else if (auto *construct = GetArrayNewElementConstruct(ctx_, expr)) { + PushBrace block(*this); + auto record_name = GetRecordName(construct->getConstructor()->getParent()); + StrCat(std::format( + "let __n = ({0}) as usize; let __p = Ptr::alloc_array((0..__n).map(|_| " + "<{1}>::zero_init()).collect::>());", + ToString(*expr->getArraySize()), record_name)); + StrCat("for __i in 0..__n"); + { + PushBrace loop(*this); + ConstructInPlace(construct, construct, "__p.offset(__i)"); + } + StrCat("__p"); } else { auto array_size_as_string = ToString(*expr->getArraySize()); auto alloc_type = expr->getAllocatedType(); From 1f50d02dfcf486a5f4217f5c7da3eeca0d757004 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Fri, 4 Dec 2026 20:10:03 +0000 Subject: [PATCH 05/14] Fix default initialization of initalization list --- cpp2rust/converter/converter.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cpp2rust/converter/converter.cpp b/cpp2rust/converter/converter.cpp index 108d85678a..c086361a62 100644 --- a/cpp2rust/converter/converter.cpp +++ b/cpp2rust/converter/converter.cpp @@ -4583,7 +4583,9 @@ void Converter::ConvertScalarInitList(clang::InitListExpr *expr) { void Converter::ConvertRecordInitList(clang::InitListExpr *expr, bool is_empty) { auto qual_type = expr->getType(); - if (is_empty) { + auto *cxx = qual_type->getAsCXXRecordDecl(); + if (is_empty && (!cxx || cxx->isUnion() || !IsUserDefinedDecl(cxx) || + cxx->hasTrivialDefaultConstructor())) { StrCat(GetDefaultAsString(qual_type)); return; } From b70f91f86a1e2a2537c3fc92b165a97427efe4e7 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Fri, 4 Dec 2026 20:10:13 +0000 Subject: [PATCH 06/14] Bases are convertible --- cpp2rust/converter/converter_lib.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cpp2rust/converter/converter_lib.cpp b/cpp2rust/converter/converter_lib.cpp index 33f05d8af9..14b5ba2c2e 100644 --- a/cpp2rust/converter/converter_lib.cpp +++ b/cpp2rust/converter/converter_lib.cpp @@ -991,10 +991,10 @@ bool IsConvertibleCopyConstructor(const clang::CXXConstructorDecl *ctor) { } bool IsConvertibleDefaultConstructor(const clang::CXXConstructorDecl *ctor) { + auto *parent = ctor->getParent(); return ctor->isDefaultConstructor() && !ctor->isUserProvided() && - !ctor->isDeleted() && - IsConvertibleImplicitMemberParent(ctor->getParent()) && - !ctor->isTrivial(); + !ctor->isDeleted() && IsUserDefinedDecl(parent) && + !parent->isAbstract() && !ctor->isTrivial(); } // Whether moving a field of decl isn't a copy: the field is a record with a From 7eabad6e22f82852e54b5210151314f70d34550d Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Fri, 4 Dec 2026 20:27:22 +0000 Subject: [PATCH 07/14] Update tests --- .../out/refcount/basic.scope.pdecl.rs | 2 +- .../out/refcount/basic.types.general.rs | 63 +++++++---- .../out/unsafe/basic.types.general.rs | 107 +++++++++++------- .../dcl.init/out/refcount/dcl.init.general.rs | 31 +++-- .../dcl.init/out/unsafe/dcl.init.general.rs | 32 +++--- .../dcl.meaning/out/refcount/dcl.array.rs | 25 ++-- .../dcl.meaning/out/refcount/dcl.mptr.rs | 38 ++++--- .../dcl.meaning/out/unsafe/dcl.array.rs | 44 ++++--- .../dcl.meaning/out/unsafe/dcl.mptr.rs | 64 ++++++----- tests/std/expr/conv/out/refcount/conv.mem.rs | 14 ++- tests/std/expr/conv/out/unsafe/conv.mem.rs | 14 ++- ...nterpret.cast-p10-result-is-unspecified.rs | 7 +- .../out/refcount/expr.reinterpret.cast.rs | 22 ++-- ...nterpret.cast-p10-result-is-unspecified.rs | 7 +- .../out/unsafe/expr.reinterpret.cast.rs | 21 ++-- .../expr.compound/out/refcount/expr.cond.rs | 16 ++- .../expr.compound/out/refcount/expr.eq.rs | 28 +++-- ...ptr.oper-p6-null-pointer-to-data-member.rs | 2 +- .../out/refcount/expr.mptr.oper.rs | 22 ++-- .../expr.compound/out/unsafe/expr.cond.rs | 19 ++-- .../expr/expr.compound/out/unsafe/expr.eq.rs | 32 ++++-- ...ptr.oper-p6-null-pointer-to-data-member.rs | 4 +- .../out/unsafe/expr.mptr.oper.rs | 42 ++++--- .../refcount/self_referencing_initializer.rs | 2 +- .../out/refcount/assignment_single_eval.rs | 2 +- .../out/refcount/goto_aggregate_default.rs | 2 +- .../out/refcount/inline_container_fields.rs | 57 ++++------ tests/unit/out/refcount/map.rs | 19 +--- tests/unit/out/refcount/map_key_identity.rs | 56 ++++----- .../out/refcount/map_try_emplace_lvalues.rs | 80 +++---------- .../refcount/self_referencing_initializer.rs | 22 +--- tests/unit/out/refcount/sort_no_copy.rs | 29 +---- tests/unit/out/refcount/swap_map_no_copy.rs | 61 +++------- .../out/unsafe/inline_container_fields.rs | 42 +++---- tests/unit/out/unsafe/map.rs | 19 +--- tests/unit/out/unsafe/map_key_identity.rs | 35 +++--- .../out/unsafe/map_try_emplace_lvalues.rs | 74 +++--------- .../unsafe/self_referencing_initializer.rs | 22 +--- tests/unit/out/unsafe/sort_no_copy.rs | 21 +--- tests/unit/out/unsafe/swap_map_no_copy.rs | 60 +++------- 40 files changed, 589 insertions(+), 670 deletions(-) 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 13b764c00b..d8c3cf728a 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 @@ -47,7 +47,7 @@ pub fn test_1() { let mut outer: Ptr = (node.as_pointer()); { let node: Value = - { >::zero_init() }; + >::zero_init(); *node.borrow_mut() = p1_own_address_in_initializer_SelfLinked { next: (node.as_pointer()), value: 7, 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 8ba56005be..b9d5ac08c0 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 @@ -27,30 +27,38 @@ pub struct p2_pointer_to_data_member_bytes_round_trip_HasTwoInts { pub second: i32, } pub fn test_0() { - let pm: Value = Rc::new(RefCell::new( - (offset_of_field!( + let pm: Value = Rc::new(RefCell::new(DataMemberPointer::from_offset( + offset_of_field!( p2_pointer_to_data_member_bytes_round_trip_HasTwoInts, second - ) as isize), - )); + ) as isize, + ))); let bytes: Value> = Rc::new(RefCell::new((0..8).map(|_| 0_u8).collect::>())); { let mut __tmp_0 = { (bytes.decay()).to_any() }; - __tmp_0.memcpy(&(pm.as_pointer()).to_any(), ::std::mem::size_of::()); + __tmp_0.memcpy( + &(pm.as_pointer()).to_any(), + ::std::mem::size_of::(), + ); (__tmp_0).clone() }; - (*pm.borrow_mut()) = - (offset_of_field!(p2_pointer_to_data_member_bytes_round_trip_HasTwoInts, first) as isize); + (*pm.borrow_mut()) = DataMemberPointer::from_offset(offset_of_field!( + p2_pointer_to_data_member_bytes_round_trip_HasTwoInts, + first + ) as isize); { let mut __tmp_1 = { (pm.as_pointer()).to_any() }; - __tmp_1.memcpy(&(bytes.decay()).to_any(), ::std::mem::size_of::()); + __tmp_1.memcpy( + &(bytes.decay()).to_any(), + ::std::mem::size_of::(), + ); (__tmp_1).clone() }; assert!( ({ ((*pm.borrow()) - == (offset_of_field!( + == DataMemberPointer::from_offset(offset_of_field!( p2_pointer_to_data_member_bytes_round_trip_HasTwoInts, second ) as isize)) @@ -63,23 +71,28 @@ pub fn test_0() { }, )); assert!(({ (((obj.as_pointer()).member::((*pm.borrow())).read()) == 4) })); - let null_pm: Value = Rc::new(RefCell::new(-1_isize)); + let null_pm: Value = Rc::new(RefCell::new(DataMemberPointer::null())); { let mut __tmp_2 = { (bytes.decay()).to_any() }; __tmp_2.memcpy( &(null_pm.as_pointer()).to_any(), - ::std::mem::size_of::(), + ::std::mem::size_of::(), ); (__tmp_2).clone() }; - (*null_pm.borrow_mut()) = - (offset_of_field!(p2_pointer_to_data_member_bytes_round_trip_HasTwoInts, first) as isize); + (*null_pm.borrow_mut()) = DataMemberPointer::from_offset(offset_of_field!( + p2_pointer_to_data_member_bytes_round_trip_HasTwoInts, + first + ) as isize); { let mut __tmp_3 = { (null_pm.as_pointer()).to_any() }; - __tmp_3.memcpy(&(bytes.decay()).to_any(), ::std::mem::size_of::()); + __tmp_3.memcpy( + &(bytes.decay()).to_any(), + ::std::mem::size_of::(), + ); (__tmp_3).clone() }; - assert!(({ ((*null_pm.borrow()) == -1_isize) })); + assert!(({ (*null_pm.borrow()).is_null() })); } #[derive( Copy, @@ -102,14 +115,14 @@ pub struct p3_pointer_to_data_member_bytes_copied_to_other_object_HasTwoInts { pub second: i32, } pub fn test_1() { - let source: Value = Rc::new(RefCell::new( - (offset_of_field!( + let source: Value = Rc::new(RefCell::new(DataMemberPointer::from_offset( + offset_of_field!( p3_pointer_to_data_member_bytes_copied_to_other_object_HasTwoInts, second - ) as isize), - )); - let destination: Value = Rc::new(RefCell::new( - (offset_of_field!( + ) as isize, + ))); + let destination: Value = Rc::new(RefCell::new( + DataMemberPointer::from_offset(offset_of_field!( p3_pointer_to_data_member_bytes_copied_to_other_object_HasTwoInts, first ) as isize), @@ -118,7 +131,7 @@ pub fn test_1() { let mut __tmp_4 = { (destination.as_pointer()).to_any() }; __tmp_4.memcpy( &(source.as_pointer()).to_any(), - ::std::mem::size_of::(), + ::std::mem::size_of::(), ); (__tmp_4).clone() }; @@ -138,16 +151,16 @@ pub fn test_1() { == 4) }) ); - let null_source: Value = Rc::new(RefCell::new(-1_isize)); + let null_source: Value = Rc::new(RefCell::new(DataMemberPointer::null())); { let mut __tmp_5 = { (destination.as_pointer()).to_any() }; __tmp_5.memcpy( &(null_source.as_pointer()).to_any(), - ::std::mem::size_of::(), + ::std::mem::size_of::(), ); (__tmp_5).clone() }; - assert!(({ ((*destination.borrow()) == -1_isize) })); + assert!(({ (*destination.borrow()).is_null() })); } pub fn main() { __cpp2rust_init_globals(); 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 c3a641ca56..e5b4d18f96 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 @@ -23,35 +23,45 @@ pub struct p2_pointer_to_data_member_bytes_round_trip_HasTwoInts { pub second: i32, } pub unsafe fn test_0() { - let mut pm: isize = (::std::mem::offset_of!( + let mut pm: DataMemberPointer = DataMemberPointer::from_offset(::std::mem::offset_of!( p2_pointer_to_data_member_bytes_round_trip_HasTwoInts, second ) as isize); let mut bytes: [u8; 8] = [0_u8; 8]; { let mut __tmp_0 = { (bytes.as_mut_ptr() as *mut ::libc::c_void) }; - let mut __tmp_1 = { ((&mut pm as *mut isize) as *const ::libc::c_void) }; - if ::std::mem::size_of::() != 0 { - ::std::ptr::copy_nonoverlapping(__tmp_1, __tmp_0, ::std::mem::size_of::()) + let mut __tmp_1 = { ((&mut pm as *mut DataMemberPointer) as *const ::libc::c_void) }; + if ::std::mem::size_of::() != 0 { + ::std::ptr::copy_nonoverlapping( + __tmp_1, + __tmp_0, + ::std::mem::size_of::(), + ) } __tmp_0 }; - pm = (::std::mem::offset_of!(p2_pointer_to_data_member_bytes_round_trip_HasTwoInts, first) - as isize); + pm = DataMemberPointer::from_offset(::std::mem::offset_of!( + p2_pointer_to_data_member_bytes_round_trip_HasTwoInts, + first + ) as isize); { - let mut __tmp_2 = { ((&mut pm as *mut isize) as *mut ::libc::c_void) }; + let mut __tmp_2 = { ((&mut pm as *mut DataMemberPointer) as *mut ::libc::c_void) }; let mut __tmp_3 = { (bytes.as_mut_ptr() as *const ::libc::c_void) }; - if ::std::mem::size_of::() != 0 { - ::std::ptr::copy_nonoverlapping(__tmp_3, __tmp_2, ::std::mem::size_of::()) + if ::std::mem::size_of::() != 0 { + ::std::ptr::copy_nonoverlapping( + __tmp_3, + __tmp_2, + ::std::mem::size_of::(), + ) } __tmp_2 }; assert!( ((pm) - == (::std::mem::offset_of!( + == (DataMemberPointer::from_offset(::std::mem::offset_of!( p2_pointer_to_data_member_bytes_round_trip_HasTwoInts, second - ) as isize)) + ) as isize))) ); let mut obj: p2_pointer_to_data_member_bytes_round_trip_HasTwoInts = p2_pointer_to_data_member_bytes_round_trip_HasTwoInts { @@ -60,30 +70,40 @@ pub unsafe fn test_0() { }; assert!( ((*(&mut obj as *mut p2_pointer_to_data_member_bytes_round_trip_HasTwoInts) - .wrapping_byte_offset(pm) + .wrapping_byte_offset((pm).offset()) .cast::()) == (4)) ); - let mut null_pm: isize = -1_isize; + let mut null_pm: DataMemberPointer = DataMemberPointer::null(); { let mut __tmp_4 = { (bytes.as_mut_ptr() as *mut ::libc::c_void) }; - let mut __tmp_5 = { ((&mut null_pm as *mut isize) as *const ::libc::c_void) }; - if ::std::mem::size_of::() != 0 { - ::std::ptr::copy_nonoverlapping(__tmp_5, __tmp_4, ::std::mem::size_of::()) + let mut __tmp_5 = { ((&mut null_pm as *mut DataMemberPointer) as *const ::libc::c_void) }; + if ::std::mem::size_of::() != 0 { + ::std::ptr::copy_nonoverlapping( + __tmp_5, + __tmp_4, + ::std::mem::size_of::(), + ) } __tmp_4 }; - null_pm = (::std::mem::offset_of!(p2_pointer_to_data_member_bytes_round_trip_HasTwoInts, first) - as isize); + null_pm = DataMemberPointer::from_offset(::std::mem::offset_of!( + p2_pointer_to_data_member_bytes_round_trip_HasTwoInts, + first + ) as isize); { - let mut __tmp_6 = { ((&mut null_pm as *mut isize) as *mut ::libc::c_void) }; + let mut __tmp_6 = { ((&mut null_pm as *mut DataMemberPointer) as *mut ::libc::c_void) }; let mut __tmp_7 = { (bytes.as_mut_ptr() as *const ::libc::c_void) }; - if ::std::mem::size_of::() != 0 { - ::std::ptr::copy_nonoverlapping(__tmp_7, __tmp_6, ::std::mem::size_of::()) + if ::std::mem::size_of::() != 0 { + ::std::ptr::copy_nonoverlapping( + __tmp_7, + __tmp_6, + ::std::mem::size_of::(), + ) } __tmp_6 }; - assert!(((null_pm) == -1_isize)); + assert!((null_pm).is_null()); } #[repr(C)] #[derive( @@ -102,19 +122,24 @@ pub struct p3_pointer_to_data_member_bytes_copied_to_other_object_HasTwoInts { pub second: i32, } pub unsafe fn test_1() { - let mut source: isize = (::std::mem::offset_of!( + let mut source: DataMemberPointer = DataMemberPointer::from_offset(::std::mem::offset_of!( p3_pointer_to_data_member_bytes_copied_to_other_object_HasTwoInts, second ) as isize); - let mut destination: isize = (::std::mem::offset_of!( - p3_pointer_to_data_member_bytes_copied_to_other_object_HasTwoInts, - first - ) as isize); + let mut destination: DataMemberPointer = + DataMemberPointer::from_offset(::std::mem::offset_of!( + p3_pointer_to_data_member_bytes_copied_to_other_object_HasTwoInts, + first + ) as isize); { - let mut __tmp_8 = { ((&mut destination as *mut isize) as *mut ::libc::c_void) }; - let mut __tmp_9 = { ((&mut source as *mut isize) as *const ::libc::c_void) }; - if ::std::mem::size_of::() != 0 { - ::std::ptr::copy_nonoverlapping(__tmp_9, __tmp_8, ::std::mem::size_of::()) + let mut __tmp_8 = { ((&mut destination as *mut DataMemberPointer) as *mut ::libc::c_void) }; + let mut __tmp_9 = { ((&mut source as *mut DataMemberPointer) as *const ::libc::c_void) }; + if ::std::mem::size_of::() != 0 { + ::std::ptr::copy_nonoverlapping( + __tmp_9, + __tmp_8, + ::std::mem::size_of::(), + ) } __tmp_8 }; @@ -126,20 +151,26 @@ pub unsafe fn test_1() { }; assert!( ((*(&mut obj as *mut p3_pointer_to_data_member_bytes_copied_to_other_object_HasTwoInts) - .wrapping_byte_offset(destination) + .wrapping_byte_offset((destination).offset()) .cast::()) == (4)) ); - let mut null_source: isize = -1_isize; + let mut null_source: DataMemberPointer = DataMemberPointer::null(); { - let mut __tmp_10 = { ((&mut destination as *mut isize) as *mut ::libc::c_void) }; - let mut __tmp_11 = { ((&mut null_source as *mut isize) as *const ::libc::c_void) }; - if ::std::mem::size_of::() != 0 { - ::std::ptr::copy_nonoverlapping(__tmp_11, __tmp_10, ::std::mem::size_of::()) + let mut __tmp_10 = + { ((&mut destination as *mut DataMemberPointer) as *mut ::libc::c_void) }; + let mut __tmp_11 = + { ((&mut null_source as *mut DataMemberPointer) as *const ::libc::c_void) }; + if ::std::mem::size_of::() != 0 { + ::std::ptr::copy_nonoverlapping( + __tmp_11, + __tmp_10, + ::std::mem::size_of::(), + ) } __tmp_10 }; - assert!(((destination) == -1_isize)); + assert!((destination).is_null()); } pub fn main() { unsafe { 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 ecafa6f090..8bc75fba85 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 @@ -43,32 +43,39 @@ pub struct p6_1_zero_initialized_pointer_to_member_HasTwoInts { pub struct p6_1_zero_initialized_pointer_to_member_HoldsSelector { #[offset(0)] #[byte_size(8)] - pub selector: isize, + pub selector: DataMemberPointer, } thread_local!( - pub static static_pm_0: Value = Rc::new(RefCell::new(-1_isize)); + pub static static_pm_0: Value = + Rc::new(RefCell::new(DataMemberPointer::null())); ); pub fn test_1() { - assert!(((static_pm_0.with(|rc| *rc.borrow())) == -1_isize)); + assert!((static_pm_0.with(|rc| *rc.borrow())).is_null()); assert!( (static_pm_0.with(|rc| *rc.borrow()) - != (offset_of_field!(p6_1_zero_initialized_pointer_to_member_HasTwoInts, first) - as isize)) + != DataMemberPointer::from_offset(offset_of_field!( + p6_1_zero_initialized_pointer_to_member_HasTwoInts, + first + ) as isize)) ); - let mut value_initialized: isize = -1_isize; - assert!(((value_initialized) == -1_isize)); + let mut value_initialized: DataMemberPointer = DataMemberPointer::null(); + assert!((value_initialized).is_null()); assert!( (value_initialized - != (offset_of_field!(p6_1_zero_initialized_pointer_to_member_HasTwoInts, first) - as isize)) + != DataMemberPointer::from_offset(offset_of_field!( + p6_1_zero_initialized_pointer_to_member_HasTwoInts, + first + ) as isize)) ); let mut holder: p6_1_zero_initialized_pointer_to_member_HoldsSelector = { ::zero_init() }; - assert!(((holder.selector) == -1_isize)); + assert!((holder.selector).is_null()); assert!( (holder.selector - != (offset_of_field!(p6_1_zero_initialized_pointer_to_member_HasTwoInts, first) - as isize)) + != DataMemberPointer::from_offset(offset_of_field!( + p6_1_zero_initialized_pointer_to_member_HasTwoInts, + first + ) as isize)) ); } pub type p6_1_zero_initialized_scalars_Color = i32; 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 188693525c..ac96f457df 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 @@ -35,31 +35,37 @@ pub struct p6_1_zero_initialized_pointer_to_member_HasTwoInts { )] #[conversions(copy, move)] pub struct p6_1_zero_initialized_pointer_to_member_HoldsSelector { - pub selector: isize, + pub selector: DataMemberPointer, } -pub static mut static_pm_0: std::cell::LazyCell = - std::cell::LazyCell::new(|| unsafe { -1_isize }); +pub static mut static_pm_0: std::cell::LazyCell = + std::cell::LazyCell::new(|| unsafe { DataMemberPointer::null() }); pub unsafe fn test_1() { - assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut static_pm_0)) == -1_isize)); + assert!((*std::cell::LazyCell::force_mut(&mut *&raw mut static_pm_0)).is_null()); assert!( ((*std::cell::LazyCell::force_mut(&mut *&raw mut static_pm_0)) - != (::std::mem::offset_of!(p6_1_zero_initialized_pointer_to_member_HasTwoInts, first) - as isize)) + != (DataMemberPointer::from_offset(::std::mem::offset_of!( + p6_1_zero_initialized_pointer_to_member_HasTwoInts, + first + ) as isize))) ); - let mut value_initialized: isize = -1_isize; - assert!(((value_initialized) == -1_isize)); + let mut value_initialized: DataMemberPointer = DataMemberPointer::null(); + assert!((value_initialized).is_null()); assert!( ((value_initialized) - != (::std::mem::offset_of!(p6_1_zero_initialized_pointer_to_member_HasTwoInts, first) - as isize)) + != (DataMemberPointer::from_offset(::std::mem::offset_of!( + p6_1_zero_initialized_pointer_to_member_HasTwoInts, + first + ) as isize))) ); let mut holder: p6_1_zero_initialized_pointer_to_member_HoldsSelector = unsafe { ::zero_init() }; - assert!(((holder.selector) == -1_isize)); + assert!((holder.selector).is_null()); assert!( ((holder.selector) - != (::std::mem::offset_of!(p6_1_zero_initialized_pointer_to_member_HasTwoInts, first) - as isize)) + != (DataMemberPointer::from_offset(::std::mem::offset_of!( + p6_1_zero_initialized_pointer_to_member_HasTwoInts, + first + ) as isize))) ); } pub type p6_1_zero_initialized_scalars_Color = 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 189011b9a5..95d88cc9f9 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 @@ -29,10 +29,19 @@ pub struct p6_array_of_pointers_to_data_members_HasThreeInts { pub third: i32, } pub fn test_0() { - let members: Value> = Rc::new(RefCell::new(Box::new([ - (offset_of_field!(p6_array_of_pointers_to_data_members_HasThreeInts, third) as isize), - (offset_of_field!(p6_array_of_pointers_to_data_members_HasThreeInts, first) as isize), - (offset_of_field!(p6_array_of_pointers_to_data_members_HasThreeInts, second) as isize), + let members: Value> = Rc::new(RefCell::new(Box::new([ + DataMemberPointer::from_offset(offset_of_field!( + p6_array_of_pointers_to_data_members_HasThreeInts, + third + ) as isize), + DataMemberPointer::from_offset(offset_of_field!( + p6_array_of_pointers_to_data_members_HasThreeInts, + first + ) as isize), + DataMemberPointer::from_offset(offset_of_field!( + p6_array_of_pointers_to_data_members_HasThreeInts, + second + ) as isize), ]))); let obj: Value = Rc::new(RefCell::new( p6_array_of_pointers_to_data_members_HasThreeInts { @@ -65,7 +74,7 @@ pub fn test_0() { == 5) }) ); - let mut element: Ptr = members.decay(); + let mut element: Ptr = members.decay(); assert!(({ element.offset((1) as isize) } == { (members.decay().offset(1)) })); assert!( (((obj.as_pointer()) @@ -77,8 +86,10 @@ pub fn test_0() { element.prefix_inc(); assert!(({ (element).clone() } == { (members.decay().offset(2)) })); assert!((((obj.as_pointer()).member::((element.read())).read()) == 5)); - (*members.borrow_mut())[(2) as usize] = - (offset_of_field!(p6_array_of_pointers_to_data_members_HasThreeInts, third) as isize); + (*members.borrow_mut())[(2) as usize] = DataMemberPointer::from_offset(offset_of_field!( + p6_array_of_pointers_to_data_members_HasThreeInts, + third + ) as isize); assert!((((obj.as_pointer()).member::((element.read())).read()) == 6)); } pub fn main() { 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 701d1a7bc6..c0caba7c8f 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 @@ -28,8 +28,10 @@ pub struct p2_pointer_to_array_member_HasIntArray { pub elements: Box<[i32]>, } pub fn test_0() { - let mut pm: isize = - (offset_of_field!(p2_pointer_to_array_member_HasIntArray, elements) as isize); + let mut pm: DataMemberPointer = DataMemberPointer::from_offset(offset_of_field!( + p2_pointer_to_array_member_HasIntArray, + elements + ) as isize); let obj: Value = Rc::new(RefCell::new(p2_pointer_to_array_member_HasIntArray { before: 1, @@ -62,7 +64,10 @@ pub struct p2_pointer_to_data_member_HasTwoInts { pub second: i32, } pub fn test_1() { - let mut pm: isize = (offset_of_field!(p2_pointer_to_data_member_HasTwoInts, first) as isize); + let mut pm: DataMemberPointer = DataMemberPointer::from_offset(offset_of_field!( + p2_pointer_to_data_member_HasTwoInts, + first + ) as isize); let obj: Value = Rc::new(RefCell::new(p2_pointer_to_data_member_HasTwoInts { first: 3, @@ -72,14 +77,17 @@ pub fn test_1() { (obj.as_pointer()).member::(pm).write(5); assert!(({ (*obj.borrow()).first } == 5)); assert!(({ (*obj.borrow()).second } == 4)); - pm = (offset_of_field!(p2_pointer_to_data_member_HasTwoInts, second) as isize); + pm = DataMemberPointer::from_offset(offset_of_field!( + p2_pointer_to_data_member_HasTwoInts, + second + ) as isize); assert!((((obj.as_pointer()).member::(pm).read()) == 4)); (obj.as_pointer()).member::(pm).write(6); assert!(({ (*obj.borrow()).first } == 5)); assert!(({ (*obj.borrow()).second } == 6)); } thread_local!( - pub static pm_2: Value = Rc::new(RefCell::new(-1_isize)); + pub static pm_2: Value = Rc::new(RefCell::new(DataMemberPointer::null())); ); #[derive( Copy, @@ -102,9 +110,9 @@ pub struct p2_pointer_to_member_of_incomplete_class_CompletedLater { pub second: i32, } pub fn test_3() { - assert!(((pm_2.with(|rc| *rc.borrow())) == -1_isize)); + assert!((pm_2.with(|rc| *rc.borrow())).is_null()); pm_2.with(|rc| { - *rc.borrow_mut() = (offset_of_field!( + *rc.borrow_mut() = DataMemberPointer::from_offset(offset_of_field!( p2_pointer_to_member_of_incomplete_class_CompletedLater, second ) as isize) @@ -159,17 +167,17 @@ pub struct p2_pointer_to_member_of_pointer_to_member_type_HasTwoInts { pub struct p2_pointer_to_member_of_pointer_to_member_type_HoldsSelector { #[offset(0)] #[byte_size(8)] - pub selector: isize, + pub selector: DataMemberPointer, } pub fn test_4() { - let mut pm: isize = (offset_of_field!( + let mut pm: DataMemberPointer = DataMemberPointer::from_offset(offset_of_field!( p2_pointer_to_member_of_pointer_to_member_type_HoldsSelector, selector ) as isize); let holder: Value = Rc::new(RefCell::new( p2_pointer_to_member_of_pointer_to_member_type_HoldsSelector { - selector: (offset_of_field!( + selector: DataMemberPointer::from_offset(offset_of_field!( p2_pointer_to_member_of_pointer_to_member_type_HasTwoInts, second ) as isize), @@ -183,16 +191,16 @@ pub fn test_4() { ); assert!( (((obj.as_pointer()) - .member::(((holder.as_pointer()).member::(pm).read())) + .member::(((holder.as_pointer()).member::(pm).read())) .read()) == 4) ); - (holder.as_pointer()).member::(pm).write( - (offset_of_field!( + (holder.as_pointer()) + .member::(pm) + .write(DataMemberPointer::from_offset(offset_of_field!( p2_pointer_to_member_of_pointer_to_member_type_HasTwoInts, first - ) as isize), - ); + ) as isize)); assert!( (((obj.as_pointer()) .member::(({ (*holder.borrow()).selector })) 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 2683b9b44b..22c4036df9 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 @@ -24,11 +24,19 @@ pub struct p6_array_of_pointers_to_data_members_HasThreeInts { pub third: i32, } pub unsafe fn test_0() { - let mut members: [isize; 3] = [ - (::std::mem::offset_of!(p6_array_of_pointers_to_data_members_HasThreeInts, third) as isize), - (::std::mem::offset_of!(p6_array_of_pointers_to_data_members_HasThreeInts, first) as isize), - (::std::mem::offset_of!(p6_array_of_pointers_to_data_members_HasThreeInts, second) - as isize), + let mut members: [DataMemberPointer; 3] = [ + DataMemberPointer::from_offset(::std::mem::offset_of!( + p6_array_of_pointers_to_data_members_HasThreeInts, + third + ) as isize), + DataMemberPointer::from_offset(::std::mem::offset_of!( + p6_array_of_pointers_to_data_members_HasThreeInts, + first + ) as isize), + DataMemberPointer::from_offset(::std::mem::offset_of!( + p6_array_of_pointers_to_data_members_HasThreeInts, + second + ) as isize), ]; let mut obj: p6_array_of_pointers_to_data_members_HasThreeInts = p6_array_of_pointers_to_data_members_HasThreeInts { @@ -38,44 +46,48 @@ pub unsafe fn test_0() { }; assert!( ((*(&mut obj as *mut p6_array_of_pointers_to_data_members_HasThreeInts) - .wrapping_byte_offset(members[(0) as usize]) + .wrapping_byte_offset((members[(0) as usize]).offset()) .cast::()) == (6)) ); assert!( ((*(&mut obj as *mut p6_array_of_pointers_to_data_members_HasThreeInts) - .wrapping_byte_offset(members[(1) as usize]) + .wrapping_byte_offset((members[(1) as usize]).offset()) .cast::()) == (4)) ); assert!( ((*(&mut obj as *mut p6_array_of_pointers_to_data_members_HasThreeInts) - .wrapping_byte_offset(members[(2) as usize]) + .wrapping_byte_offset((members[(2) as usize]).offset()) .cast::()) == (5)) ); - let mut element: *mut isize = members.as_mut_ptr(); - assert!(((element.offset((1) as isize)) == (&mut members[(1) as usize] as *mut isize))); + let mut element: *mut DataMemberPointer = members.as_mut_ptr(); + assert!( + ((element.offset((1) as isize)) == (&mut members[(1) as usize] as *mut DataMemberPointer)) + ); assert!( ((*(&mut obj as *mut p6_array_of_pointers_to_data_members_HasThreeInts) - .wrapping_byte_offset((*element.offset((1) as isize))) + .wrapping_byte_offset((*element.offset((1) as isize)).offset()) .cast::()) == (4)) ); element.prefix_inc(); element.prefix_inc(); - assert!(((element) == (&mut members[(2) as usize] as *mut isize))); + assert!(((element) == (&mut members[(2) as usize] as *mut DataMemberPointer))); assert!( ((*(&mut obj as *mut p6_array_of_pointers_to_data_members_HasThreeInts) - .wrapping_byte_offset((*element)) + .wrapping_byte_offset((*element).offset()) .cast::()) == (5)) ); - members[(2) as usize] = - (::std::mem::offset_of!(p6_array_of_pointers_to_data_members_HasThreeInts, third) as isize); + members[(2) as usize] = DataMemberPointer::from_offset(::std::mem::offset_of!( + p6_array_of_pointers_to_data_members_HasThreeInts, + third + ) as isize); assert!( ((*(&mut obj as *mut p6_array_of_pointers_to_data_members_HasThreeInts) - .wrapping_byte_offset((*element)) + .wrapping_byte_offset((*element).offset()) .cast::()) == (6)) ); 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 bbe384b3ac..c80d3ed299 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 @@ -23,26 +23,28 @@ pub struct p2_pointer_to_array_member_HasIntArray { pub elements: [i32; 3], } pub unsafe fn test_0() { - let mut pm: isize = - (::std::mem::offset_of!(p2_pointer_to_array_member_HasIntArray, elements) as isize); + let mut pm: DataMemberPointer = DataMemberPointer::from_offset(::std::mem::offset_of!( + p2_pointer_to_array_member_HasIntArray, + elements + ) as isize); let mut obj: p2_pointer_to_array_member_HasIntArray = p2_pointer_to_array_member_HasIntArray { before: 1, elements: [2, 3, 4], }; assert!( (((*(&mut obj as *mut p2_pointer_to_array_member_HasIntArray) - .wrapping_byte_offset(pm) + .wrapping_byte_offset((pm).offset()) .cast::<[i32; 3]>())[(0) as usize]) == (2)) ); assert!( (((*(&mut obj as *mut p2_pointer_to_array_member_HasIntArray) - .wrapping_byte_offset(pm) + .wrapping_byte_offset((pm).offset()) .cast::<[i32; 3]>())[(2) as usize]) == (4)) ); (*(&mut obj as *mut p2_pointer_to_array_member_HasIntArray) - .wrapping_byte_offset(pm) + .wrapping_byte_offset((pm).offset()) .cast::<[i32; 3]>())[(1) as usize] = 7; assert!(((obj.elements[(1) as usize]) == (7))); assert!(((obj.before) == (1))); @@ -64,37 +66,43 @@ pub struct p2_pointer_to_data_member_HasTwoInts { pub second: i32, } pub unsafe fn test_1() { - let mut pm: isize = - (::std::mem::offset_of!(p2_pointer_to_data_member_HasTwoInts, first) as isize); + let mut pm: DataMemberPointer = DataMemberPointer::from_offset(::std::mem::offset_of!( + p2_pointer_to_data_member_HasTwoInts, + first + ) as isize); let mut obj: p2_pointer_to_data_member_HasTwoInts = p2_pointer_to_data_member_HasTwoInts { first: 3, second: 4, }; assert!( ((*(&mut obj as *mut p2_pointer_to_data_member_HasTwoInts) - .wrapping_byte_offset(pm) + .wrapping_byte_offset((pm).offset()) .cast::()) == (3)) ); (*(&mut obj as *mut p2_pointer_to_data_member_HasTwoInts) - .wrapping_byte_offset(pm) + .wrapping_byte_offset((pm).offset()) .cast::()) = 5; assert!(((obj.first) == (5))); assert!(((obj.second) == (4))); - pm = (::std::mem::offset_of!(p2_pointer_to_data_member_HasTwoInts, second) as isize); + pm = DataMemberPointer::from_offset(::std::mem::offset_of!( + p2_pointer_to_data_member_HasTwoInts, + second + ) as isize); assert!( ((*(&mut obj as *mut p2_pointer_to_data_member_HasTwoInts) - .wrapping_byte_offset(pm) + .wrapping_byte_offset((pm).offset()) .cast::()) == (4)) ); (*(&mut obj as *mut p2_pointer_to_data_member_HasTwoInts) - .wrapping_byte_offset(pm) + .wrapping_byte_offset((pm).offset()) .cast::()) = 6; assert!(((obj.first) == (5))); assert!(((obj.second) == (6))); } -pub static mut pm_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { -1_isize }); +pub static mut pm_2: std::cell::LazyCell = + std::cell::LazyCell::new(|| unsafe { DataMemberPointer::null() }); #[repr(C)] #[derive( Copy, @@ -112,11 +120,12 @@ pub struct p2_pointer_to_member_of_incomplete_class_CompletedLater { pub second: i32, } pub unsafe fn test_3() { - assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut pm_2)) == -1_isize)); - (*std::cell::LazyCell::force_mut(&mut *&raw mut pm_2)) = (::std::mem::offset_of!( - p2_pointer_to_member_of_incomplete_class_CompletedLater, - second - ) as isize); + assert!((*std::cell::LazyCell::force_mut(&mut *&raw mut pm_2)).is_null()); + (*std::cell::LazyCell::force_mut(&mut *&raw mut pm_2)) = + DataMemberPointer::from_offset(::std::mem::offset_of!( + p2_pointer_to_member_of_incomplete_class_CompletedLater, + second + ) as isize); let mut obj: p2_pointer_to_member_of_incomplete_class_CompletedLater = p2_pointer_to_member_of_incomplete_class_CompletedLater { first: 3, @@ -124,7 +133,7 @@ pub unsafe fn test_3() { }; assert!( ((*(&mut obj as *mut p2_pointer_to_member_of_incomplete_class_CompletedLater) - .wrapping_byte_offset((*std::cell::LazyCell::force_mut(&mut *&raw mut pm_2))) + .wrapping_byte_offset((*std::cell::LazyCell::force_mut(&mut *&raw mut pm_2)).offset()) .cast::()) == (4)) ); @@ -158,16 +167,16 @@ pub struct p2_pointer_to_member_of_pointer_to_member_type_HasTwoInts { )] #[conversions(copy, move)] pub struct p2_pointer_to_member_of_pointer_to_member_type_HoldsSelector { - pub selector: isize, + pub selector: DataMemberPointer, } pub unsafe fn test_4() { - let mut pm: isize = (::std::mem::offset_of!( + let mut pm: DataMemberPointer = DataMemberPointer::from_offset(::std::mem::offset_of!( p2_pointer_to_member_of_pointer_to_member_type_HoldsSelector, selector ) as isize); let mut holder: p2_pointer_to_member_of_pointer_to_member_type_HoldsSelector = p2_pointer_to_member_of_pointer_to_member_type_HoldsSelector { - selector: (::std::mem::offset_of!( + selector: DataMemberPointer::from_offset(::std::mem::offset_of!( p2_pointer_to_member_of_pointer_to_member_type_HasTwoInts, second ) as isize), @@ -182,21 +191,22 @@ pub unsafe fn test_4() { .wrapping_byte_offset( (*(&mut holder as *mut p2_pointer_to_member_of_pointer_to_member_type_HoldsSelector) - .wrapping_byte_offset(pm) - .cast::()) + .wrapping_byte_offset((pm).offset()) + .cast::()) + .offset() ) .cast::()) == (4)) ); (*(&mut holder as *mut p2_pointer_to_member_of_pointer_to_member_type_HoldsSelector) - .wrapping_byte_offset(pm) - .cast::()) = (::std::mem::offset_of!( + .wrapping_byte_offset((pm).offset()) + .cast::()) = DataMemberPointer::from_offset(::std::mem::offset_of!( p2_pointer_to_member_of_pointer_to_member_type_HasTwoInts, first ) as isize); assert!( ((*(&mut obj as *mut p2_pointer_to_member_of_pointer_to_member_type_HasTwoInts) - .wrapping_byte_offset((holder.selector)) + .wrapping_byte_offset((holder.selector).offset()) .cast::()) == (3)) ); diff --git a/tests/std/expr/conv/out/refcount/conv.mem.rs b/tests/std/expr/conv/out/refcount/conv.mem.rs index 0181a66075..41db6d1855 100644 --- a/tests/std/expr/conv/out/refcount/conv.mem.rs +++ b/tests/std/expr/conv/out/refcount/conv.mem.rs @@ -27,11 +27,15 @@ pub struct p1_null_distinct_from_first_member_HasTwoInts { pub second: i32, } pub fn test_0() { - let mut null_pm: isize = -1_isize; - let mut first_pm: isize = - (offset_of_field!(p1_null_distinct_from_first_member_HasTwoInts, first) as isize); - let mut second_pm: isize = - (offset_of_field!(p1_null_distinct_from_first_member_HasTwoInts, second) as isize); + let mut null_pm: DataMemberPointer = DataMemberPointer::null(); + let mut first_pm: DataMemberPointer = DataMemberPointer::from_offset(offset_of_field!( + p1_null_distinct_from_first_member_HasTwoInts, + first + ) as isize); + let mut second_pm: DataMemberPointer = DataMemberPointer::from_offset(offset_of_field!( + p1_null_distinct_from_first_member_HasTwoInts, + second + ) as isize); assert!((first_pm != null_pm)); assert!((second_pm != null_pm)); } diff --git a/tests/std/expr/conv/out/unsafe/conv.mem.rs b/tests/std/expr/conv/out/unsafe/conv.mem.rs index 0fc7ff3087..de9aff27e7 100644 --- a/tests/std/expr/conv/out/unsafe/conv.mem.rs +++ b/tests/std/expr/conv/out/unsafe/conv.mem.rs @@ -23,11 +23,15 @@ pub struct p1_null_distinct_from_first_member_HasTwoInts { pub second: i32, } pub unsafe fn test_0() { - let mut null_pm: isize = -1_isize; - let mut first_pm: isize = - (::std::mem::offset_of!(p1_null_distinct_from_first_member_HasTwoInts, first) as isize); - let mut second_pm: isize = - (::std::mem::offset_of!(p1_null_distinct_from_first_member_HasTwoInts, second) as isize); + let mut null_pm: DataMemberPointer = DataMemberPointer::null(); + let mut first_pm: DataMemberPointer = DataMemberPointer::from_offset(::std::mem::offset_of!( + p1_null_distinct_from_first_member_HasTwoInts, + first + ) as isize); + let mut second_pm: DataMemberPointer = DataMemberPointer::from_offset(::std::mem::offset_of!( + p1_null_distinct_from_first_member_HasTwoInts, + second + ) as isize); assert!(((first_pm) != (null_pm))); assert!(((second_pm) != (null_pm))); } 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 05326b559f..152a98e7fd 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 @@ -51,7 +51,10 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let mut converted: isize = (offset_of_field!(HasTwoInts, second) as isize); - return ((converted == (offset_of_field!(AlsoHasTwoInts, second) as isize)) as i32); + let mut converted: DataMemberPointer = + DataMemberPointer::from_offset(offset_of_field!(HasTwoInts, second) as isize); + return ((converted + == DataMemberPointer::from_offset(offset_of_field!(AlsoHasTwoInts, second) as isize)) + as i32); } pub fn __cpp2rust_init_globals() {} 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 5fe13248e2..c39bf887af 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 @@ -55,9 +55,9 @@ pub struct p10_null_converts_to_null_HasChar { pub character: i8, } pub fn test_1() { - let mut pm: isize = -1_isize; - let mut converted: isize = pm; - assert!(((converted) == -1_isize)); + let mut pm: DataMemberPointer = DataMemberPointer::null(); + let mut converted: DataMemberPointer = pm; + assert!((converted).is_null()); } #[derive( Copy, @@ -98,10 +98,18 @@ pub struct p10_2_data_member_round_trip_HasChar { pub character: i8, } pub fn test_2() { - let mut converted: isize = - (offset_of_field!(p10_2_data_member_round_trip_HasTwoInts, second) as isize); - let mut back: isize = converted; - assert!((back == (offset_of_field!(p10_2_data_member_round_trip_HasTwoInts, second) as isize))); + let mut converted: DataMemberPointer = DataMemberPointer::from_offset(offset_of_field!( + p10_2_data_member_round_trip_HasTwoInts, + second + ) as isize); + let mut back: DataMemberPointer = converted; + assert!( + (back + == DataMemberPointer::from_offset(offset_of_field!( + p10_2_data_member_round_trip_HasTwoInts, + second + ) as isize)) + ); let obj: Value = Rc::new(RefCell::new(p10_2_data_member_round_trip_HasTwoInts { first: 3, 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 cc76608d43..b411d748c4 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 @@ -45,7 +45,10 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut converted: isize = (::std::mem::offset_of!(HasTwoInts, second) as isize); - return (((converted) == (::std::mem::offset_of!(AlsoHasTwoInts, second) as isize)) as i32); + let mut converted: DataMemberPointer = + DataMemberPointer::from_offset(::std::mem::offset_of!(HasTwoInts, second) as isize); + return (((converted) + == (DataMemberPointer::from_offset(::std::mem::offset_of!(AlsoHasTwoInts, second) as isize))) + as i32); } pub unsafe fn __cpp2rust_init_globals() {} 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 92d44ac68e..02f5780cb6 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 @@ -48,9 +48,9 @@ pub struct p10_null_converts_to_null_HasChar { pub character: libc::c_char, } pub unsafe fn test_1() { - let mut pm: isize = -1_isize; - let mut converted: isize = pm; - assert!(((converted) == -1_isize)); + let mut pm: DataMemberPointer = DataMemberPointer::null(); + let mut converted: DataMemberPointer = pm; + assert!((converted).is_null()); } #[repr(C)] #[derive( @@ -84,12 +84,17 @@ pub struct p10_2_data_member_round_trip_HasChar { pub character: libc::c_char, } pub unsafe fn test_2() { - let mut converted: isize = - (::std::mem::offset_of!(p10_2_data_member_round_trip_HasTwoInts, second) as isize); - let mut back: isize = converted; + let mut converted: DataMemberPointer = DataMemberPointer::from_offset(::std::mem::offset_of!( + p10_2_data_member_round_trip_HasTwoInts, + second + ) as isize); + let mut back: DataMemberPointer = converted; assert!( ((back) - == (::std::mem::offset_of!(p10_2_data_member_round_trip_HasTwoInts, second) as isize)) + == (DataMemberPointer::from_offset(::std::mem::offset_of!( + p10_2_data_member_round_trip_HasTwoInts, + second + ) as isize))) ); let mut obj: p10_2_data_member_round_trip_HasTwoInts = p10_2_data_member_round_trip_HasTwoInts { @@ -98,7 +103,7 @@ pub unsafe fn test_2() { }; assert!( ((*(&mut obj as *mut p10_2_data_member_round_trip_HasTwoInts) - .wrapping_byte_offset(back) + .wrapping_byte_offset((back).offset()) .cast::()) == (4)) ); 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 ad54829b5b..b8b3a34af4 100644 --- a/tests/std/expr/expr.compound/out/refcount/expr.cond.rs +++ b/tests/std/expr/expr.compound/out/refcount/expr.cond.rs @@ -26,11 +26,14 @@ pub struct p7_4_pointer_to_member_and_null_HasTwoInts { #[offset(4)] pub second: i32, } -pub fn second_or_null_0(mut choose_second: bool) -> isize { +pub fn second_or_null_0(mut choose_second: bool) -> DataMemberPointer { return if choose_second { - (offset_of_field!(p7_4_pointer_to_member_and_null_HasTwoInts, second) as isize) + DataMemberPointer::from_offset(offset_of_field!( + p7_4_pointer_to_member_and_null_HasTwoInts, + second + ) as isize) } else { - -1_isize + DataMemberPointer::null() }; } pub fn test_1() { @@ -39,10 +42,13 @@ pub fn test_1() { first: 3, second: 4, })); - assert!((({ second_or_null_0(false,) }) == -1_isize)); + assert!(({ second_or_null_0(false,) }).is_null()); assert!( (({ second_or_null_0(true,) }) - == (offset_of_field!(p7_4_pointer_to_member_and_null_HasTwoInts, second) as isize)) + == DataMemberPointer::from_offset(offset_of_field!( + p7_4_pointer_to_member_and_null_HasTwoInts, + second + ) as isize)) ); assert!( (((obj.as_pointer()) 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 fd2782f3cc..ecb22ae67b 100644 --- a/tests/std/expr/expr.compound/out/refcount/expr.eq.rs +++ b/tests/std/expr/expr.compound/out/refcount/expr.eq.rs @@ -27,8 +27,8 @@ pub struct p4_1_both_null_HasTwoInts { pub second: i32, } pub fn test_0() { - let mut first_null: isize = -1_isize; - let mut second_null: isize = -1_isize; + let mut first_null: DataMemberPointer = DataMemberPointer::null(); + let mut second_null: DataMemberPointer = DataMemberPointer::null(); assert!((first_null == second_null)); assert!(!(first_null != second_null)); } @@ -53,8 +53,9 @@ pub struct p4_2_one_null_HasTwoInts { pub second: i32, } pub fn test_1() { - let mut null_pm: isize = -1_isize; - let mut first_pm: isize = (offset_of_field!(p4_2_one_null_HasTwoInts, first) as isize); + let mut null_pm: DataMemberPointer = DataMemberPointer::null(); + let mut first_pm: DataMemberPointer = + DataMemberPointer::from_offset(offset_of_field!(p4_2_one_null_HasTwoInts, first) as isize); assert!((first_pm != null_pm)); assert!(!(first_pm == null_pm)); assert!((null_pm != first_pm)); @@ -85,8 +86,8 @@ impl p4_5_members_of_same_union_HasTwoIntMembers { } } pub fn test_2() { - let mut first_pm: isize = 0_isize; - let mut second_pm: isize = 0_isize; + let mut first_pm: DataMemberPointer = DataMemberPointer::from_offset(0); + let mut second_pm: DataMemberPointer = DataMemberPointer::from_offset(0); assert!((first_pm == second_pm)); assert!(!(first_pm != second_pm)); } @@ -111,9 +112,18 @@ pub struct p4_6_data_members_HasTwoInts { pub second: i32, } pub fn test_3() { - let mut first_pm: isize = (offset_of_field!(p4_6_data_members_HasTwoInts, first) as isize); - let mut also_first_pm: isize = (offset_of_field!(p4_6_data_members_HasTwoInts, first) as isize); - let mut second_pm: isize = (offset_of_field!(p4_6_data_members_HasTwoInts, second) as isize); + let mut first_pm: DataMemberPointer = DataMemberPointer::from_offset(offset_of_field!( + p4_6_data_members_HasTwoInts, + first + ) as isize); + let mut also_first_pm: DataMemberPointer = DataMemberPointer::from_offset(offset_of_field!( + p4_6_data_members_HasTwoInts, + first + ) as isize); + let mut second_pm: DataMemberPointer = DataMemberPointer::from_offset(offset_of_field!( + p4_6_data_members_HasTwoInts, + second + ) as isize); assert!((first_pm == also_first_pm)); assert!(!(first_pm != also_first_pm)); assert!((first_pm != second_pm)); 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 f8a86cc01e..feecf3d38e 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 @@ -31,7 +31,7 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let mut pm: isize = -1_isize; + let mut pm: DataMemberPointer = DataMemberPointer::null(); let obj: Value = Rc::new(RefCell::new(HasTwoInts { first: 3, second: 4, 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 85b550508d..4ee9ee7055 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 @@ -27,7 +27,8 @@ pub struct p3_arrow_star_HasTwoInts { pub second: i32, } pub fn test_0() { - let mut pm: isize = (offset_of_field!(p3_arrow_star_HasTwoInts, second) as isize); + let mut pm: DataMemberPointer = + DataMemberPointer::from_offset(offset_of_field!(p3_arrow_star_HasTwoInts, second) as isize); let obj: Value = Rc::new(RefCell::new(p3_arrow_star_HasTwoInts { first: 3, second: 4, @@ -77,11 +78,14 @@ pub fn select_object_5() -> Ptr { }); return object_4.with(|v| v.as_pointer()); } -pub fn select_member_6() -> isize { +pub fn select_member_6() -> DataMemberPointer { member_stamp_3.with(|rc| { *rc.borrow_mut() = { (*(*sequence_1.with(Value::clone).borrow_mut()).prefix_inc()) } }); - return (offset_of_field!(p4_object_expression_sequenced_first_HasValue, value) as isize); + return DataMemberPointer::from_offset(offset_of_field!( + p4_object_expression_sequenced_first_HasValue, + value + ) as isize); } pub fn test_7() { assert!( @@ -114,8 +118,10 @@ pub struct p6_data_member_of_lvalue_is_lvalue_HasTwoInts { pub second: i32, } pub fn test_8() { - let mut pm: isize = - (offset_of_field!(p6_data_member_of_lvalue_is_lvalue_HasTwoInts, second) as isize); + let mut pm: DataMemberPointer = DataMemberPointer::from_offset(offset_of_field!( + p6_data_member_of_lvalue_is_lvalue_HasTwoInts, + second + ) as isize); let obj: Value = Rc::new(RefCell::new( p6_data_member_of_lvalue_is_lvalue_HasTwoInts { first: 3, @@ -184,8 +190,10 @@ pub struct p6_data_member_of_rvalue_is_xvalue_HoldsCounted { } impl p6_data_member_of_rvalue_is_xvalue_HoldsCounted {} pub fn test_11() { - let mut pm: isize = - (offset_of_field!(p6_data_member_of_rvalue_is_xvalue_HoldsCounted, member) as isize); + let mut pm: DataMemberPointer = DataMemberPointer::from_offset(offset_of_field!( + p6_data_member_of_rvalue_is_xvalue_HoldsCounted, + member + ) as isize); let holder: Value = Rc::new(RefCell::new({ ::zero_init() })); 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 cbe1c05bae..cdf55f1735 100644 --- a/tests/std/expr/expr.compound/out/unsafe/expr.cond.rs +++ b/tests/std/expr/expr.compound/out/unsafe/expr.cond.rs @@ -22,11 +22,14 @@ pub struct p7_4_pointer_to_member_and_null_HasTwoInts { pub first: i32, pub second: i32, } -pub unsafe fn second_or_null_0(mut choose_second: bool) -> isize { +pub unsafe fn second_or_null_0(mut choose_second: bool) -> DataMemberPointer { return if choose_second { - (::std::mem::offset_of!(p7_4_pointer_to_member_and_null_HasTwoInts, second) as isize) + DataMemberPointer::from_offset(::std::mem::offset_of!( + p7_4_pointer_to_member_and_null_HasTwoInts, + second + ) as isize) } else { - -1_isize + DataMemberPointer::null() }; } pub unsafe fn test_1() { @@ -35,15 +38,17 @@ pub unsafe fn test_1() { first: 3, second: 4, }; - assert!(((unsafe { second_or_null_0(false,) }) == -1_isize)); + assert!((unsafe { second_or_null_0(false,) }).is_null()); assert!( ((unsafe { second_or_null_0(true,) }) - == (::std::mem::offset_of!(p7_4_pointer_to_member_and_null_HasTwoInts, second) - as isize)) + == (DataMemberPointer::from_offset(::std::mem::offset_of!( + p7_4_pointer_to_member_and_null_HasTwoInts, + second + ) as isize))) ); assert!( ((*(&mut obj as *mut p7_4_pointer_to_member_and_null_HasTwoInts) - .wrapping_byte_offset((unsafe { second_or_null_0(true,) })) + .wrapping_byte_offset((unsafe { second_or_null_0(true,) }).offset()) .cast::()) == (4)) ); 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 c781058f90..017ae97c03 100644 --- a/tests/std/expr/expr.compound/out/unsafe/expr.eq.rs +++ b/tests/std/expr/expr.compound/out/unsafe/expr.eq.rs @@ -23,8 +23,8 @@ pub struct p4_1_both_null_HasTwoInts { pub second: i32, } pub unsafe fn test_0() { - let mut first_null: isize = -1_isize; - let mut second_null: isize = -1_isize; + let mut first_null: DataMemberPointer = DataMemberPointer::null(); + let mut second_null: DataMemberPointer = DataMemberPointer::null(); assert!(((first_null) == (second_null))); assert!(!((first_null) != (second_null))); } @@ -45,8 +45,11 @@ pub struct p4_2_one_null_HasTwoInts { pub second: i32, } pub unsafe fn test_1() { - let mut null_pm: isize = -1_isize; - let mut first_pm: isize = (::std::mem::offset_of!(p4_2_one_null_HasTwoInts, first) as isize); + let mut null_pm: DataMemberPointer = DataMemberPointer::null(); + let mut first_pm: DataMemberPointer = DataMemberPointer::from_offset(::std::mem::offset_of!( + p4_2_one_null_HasTwoInts, + first + ) as isize); assert!(((first_pm) != (null_pm))); assert!(!((first_pm) == (null_pm))); assert!(((null_pm) != (first_pm))); @@ -67,8 +70,8 @@ pub union p4_5_members_of_same_union_HasTwoIntMembers { pub second: i32, } pub unsafe fn test_2() { - let mut first_pm: isize = 0_isize; - let mut second_pm: isize = 0_isize; + let mut first_pm: DataMemberPointer = DataMemberPointer::from_offset(0); + let mut second_pm: DataMemberPointer = DataMemberPointer::from_offset(0); assert!(((first_pm) == (second_pm))); assert!(!((first_pm) != (second_pm))); } @@ -89,12 +92,17 @@ pub struct p4_6_data_members_HasTwoInts { pub second: i32, } pub unsafe fn test_3() { - let mut first_pm: isize = - (::std::mem::offset_of!(p4_6_data_members_HasTwoInts, first) as isize); - let mut also_first_pm: isize = - (::std::mem::offset_of!(p4_6_data_members_HasTwoInts, first) as isize); - let mut second_pm: isize = - (::std::mem::offset_of!(p4_6_data_members_HasTwoInts, second) as isize); + let mut first_pm: DataMemberPointer = DataMemberPointer::from_offset(::std::mem::offset_of!( + p4_6_data_members_HasTwoInts, + first + ) as isize); + let mut also_first_pm: DataMemberPointer = DataMemberPointer::from_offset( + ::std::mem::offset_of!(p4_6_data_members_HasTwoInts, first) as isize, + ); + let mut second_pm: DataMemberPointer = DataMemberPointer::from_offset(::std::mem::offset_of!( + p4_6_data_members_HasTwoInts, + second + ) as isize); assert!(((first_pm) == (also_first_pm))); assert!(!((first_pm) != (also_first_pm))); assert!(((first_pm) != (second_pm))); 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 839af6c946..5a1e2282c9 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 @@ -29,13 +29,13 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut pm: isize = -1_isize; + let mut pm: DataMemberPointer = DataMemberPointer::null(); let mut obj: HasTwoInts = HasTwoInts { first: 3, second: 4, }; return (*(&mut obj as *mut HasTwoInts) - .wrapping_byte_offset(pm) + .wrapping_byte_offset((pm).offset()) .cast::()); } pub unsafe fn __cpp2rust_init_globals() {} 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 85bd16b594..055ae7785f 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 @@ -23,20 +23,23 @@ pub struct p3_arrow_star_HasTwoInts { pub second: i32, } pub unsafe fn test_0() { - let mut pm: isize = (::std::mem::offset_of!(p3_arrow_star_HasTwoInts, second) as isize); + let mut pm: DataMemberPointer = DataMemberPointer::from_offset(::std::mem::offset_of!( + p3_arrow_star_HasTwoInts, + second + ) as isize); let mut obj: p3_arrow_star_HasTwoInts = p3_arrow_star_HasTwoInts { first: 3, second: 4, }; let mut p: *mut p3_arrow_star_HasTwoInts = (&mut obj as *mut p3_arrow_star_HasTwoInts); - assert!(((*(p).wrapping_byte_offset(pm).cast::()) == (4))); - (*(p).wrapping_byte_offset(pm).cast::()) = 5; + assert!(((*(p).wrapping_byte_offset((pm).offset()).cast::()) == (4))); + (*(p).wrapping_byte_offset((pm).offset()).cast::()) = 5; assert!(((obj.second) == (5))); assert!(((obj.first) == (3))); assert!( - ((&mut (*(p).wrapping_byte_offset(pm).cast::()) as *mut i32) + ((&mut (*(p).wrapping_byte_offset((pm).offset()).cast::()) as *mut i32) == (&mut (*(&mut (*p) as *mut p3_arrow_star_HasTwoInts) - .wrapping_byte_offset(pm) + .wrapping_byte_offset((pm).offset()) .cast::()) as *mut i32)) ); } @@ -69,15 +72,18 @@ pub unsafe fn select_object_5() -> *mut p4_object_expression_sequenced_first_Has (*(*std::cell::LazyCell::force_mut(&mut *&raw mut sequence_1)).prefix_inc()); return &mut (*std::cell::LazyCell::force_mut(&mut *&raw mut object_4)); } -pub unsafe fn select_member_6() -> isize { +pub unsafe fn select_member_6() -> DataMemberPointer { (*std::cell::LazyCell::force_mut(&mut *&raw mut member_stamp_3)) = (*(*std::cell::LazyCell::force_mut(&mut *&raw mut sequence_1)).prefix_inc()); - return (::std::mem::offset_of!(p4_object_expression_sequenced_first_HasValue, value) as isize); + return DataMemberPointer::from_offset(::std::mem::offset_of!( + p4_object_expression_sequenced_first_HasValue, + value + ) as isize); } pub unsafe fn test_7() { assert!( ((*(unsafe { select_object_5() }) - .wrapping_byte_offset((unsafe { select_member_6() })) + .wrapping_byte_offset((unsafe { select_member_6() }).offset()) .cast::()) == (7)) ); @@ -101,8 +107,10 @@ pub struct p6_data_member_of_lvalue_is_lvalue_HasTwoInts { pub second: i32, } pub unsafe fn test_8() { - let mut pm: isize = - (::std::mem::offset_of!(p6_data_member_of_lvalue_is_lvalue_HasTwoInts, second) as isize); + let mut pm: DataMemberPointer = DataMemberPointer::from_offset(::std::mem::offset_of!( + p6_data_member_of_lvalue_is_lvalue_HasTwoInts, + second + ) as isize); let mut obj: p6_data_member_of_lvalue_is_lvalue_HasTwoInts = p6_data_member_of_lvalue_is_lvalue_HasTwoInts { first: 3, @@ -110,12 +118,12 @@ pub unsafe fn test_8() { }; assert!( ((&mut (*(&mut obj as *mut p6_data_member_of_lvalue_is_lvalue_HasTwoInts) - .wrapping_byte_offset(pm) + .wrapping_byte_offset((pm).offset()) .cast::()) as *mut i32) == (&mut obj.second as *mut i32)) ); let ref_: *mut i32 = &mut (*(&mut obj as *mut p6_data_member_of_lvalue_is_lvalue_HasTwoInts) - .wrapping_byte_offset(pm) + .wrapping_byte_offset((pm).offset()) .cast::()); (*ref_) = 5; assert!(((obj.second) == (5))); @@ -167,8 +175,10 @@ pub struct p6_data_member_of_rvalue_is_xvalue_HoldsCounted { } impl p6_data_member_of_rvalue_is_xvalue_HoldsCounted {} pub unsafe fn test_11() { - let mut pm: isize = - (::std::mem::offset_of!(p6_data_member_of_rvalue_is_xvalue_HoldsCounted, member) as isize); + let mut pm: DataMemberPointer = DataMemberPointer::from_offset(::std::mem::offset_of!( + p6_data_member_of_rvalue_is_xvalue_HoldsCounted, + member + ) as isize); let mut holder: p6_data_member_of_rvalue_is_xvalue_HoldsCounted = unsafe { ::zero_init() }; object_unsafe!( @@ -176,7 +186,7 @@ pub unsafe fn test_11() { p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves::constructor_2( LvalueRefUnsafe::bind( &(*(&mut holder as *mut p6_data_member_of_rvalue_is_xvalue_HoldsCounted) - .wrapping_byte_offset(pm) + .wrapping_byte_offset((pm).offset()) .cast::()) ) ) @@ -188,7 +198,7 @@ pub unsafe fn test_11() { p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves::constructor_3( RvalueRefUnsafe::bind( &mut (*(&mut holder as *mut p6_data_member_of_rvalue_is_xvalue_HoldsCounted) - .wrapping_byte_offset(pm) + .wrapping_byte_offset((pm).offset()) .cast::()) ) ) diff --git a/tests/ub/out/refcount/self_referencing_initializer.rs b/tests/ub/out/refcount/self_referencing_initializer.rs index 5e1f5e1194..3ff172336e 100644 --- a/tests/ub/out/refcount/self_referencing_initializer.rs +++ b/tests/ub/out/refcount/self_referencing_initializer.rs @@ -33,7 +33,7 @@ pub fn main() { fn main_0() -> i32 { let mut x: i32 = 0_i32; x = (x + 1); - let mut p: pair = { ::zero_init() }; + let mut p: pair = ::zero_init(); p = pair { a: 1, b: (p.a + 1) }; return (x + p.b); } diff --git a/tests/unit/out/refcount/assignment_single_eval.rs b/tests/unit/out/refcount/assignment_single_eval.rs index 6677de9e02..ea6ae5e5ad 100644 --- a/tests/unit/out/refcount/assignment_single_eval.rs +++ b/tests/unit/out/refcount/assignment_single_eval.rs @@ -1394,7 +1394,7 @@ pub fn test_borrows_29() { ) }) ); - let first: Value = { >::zero_init() }; + let first: Value = >::zero_init(); *first.borrow_mut() = Link_33 { next: (first.as_pointer()), }; diff --git a/tests/unit/out/refcount/goto_aggregate_default.rs b/tests/unit/out/refcount/goto_aggregate_default.rs index 2801750a74..5474d40a6b 100644 --- a/tests/unit/out/refcount/goto_aggregate_default.rs +++ b/tests/unit/out/refcount/goto_aggregate_default.rs @@ -29,7 +29,7 @@ pub fn agg_0(mut n: i32) -> i32 { let mut buf256: [u8; 256] = [0_u8; 256]; let mut arr64: [i32; 64] = [0_i32; 64]; let mut longs: [i64; 33] = [0_i64; 33]; - let mut p: Point = { ::zero_init() }; + let mut p: Point = ::zero_init(); let mut ptr: Ptr = Ptr::::null(); let mut fp: FnPtr i32> = FnPtr:: i32>::null(); let mut file: Ptr = Ptr::null(); diff --git a/tests/unit/out/refcount/inline_container_fields.rs b/tests/unit/out/refcount/inline_container_fields.rs index 2fe567d0e7..efb7c8fd44 100644 --- a/tests/unit/out/refcount/inline_container_fields.rs +++ b/tests/unit/out/refcount/inline_container_fields.rs @@ -41,17 +41,6 @@ impl Elem { field!(this, coeffs).write(Vec::new()); } } -impl Default for Elem { - fn default() -> Self { - { - Elem { - id: 0_i32, - hist: (0..4).map(|_| 0_i32).collect::>(), - coeffs: Default::default(), - } - } - } -} #[derive( Clone, Record, @@ -102,21 +91,6 @@ impl State { field!(this, rows).write(Vec::new()); } } -impl Default for State { - fn default() -> Self { - { - State { - count: 0_i32, - grid: (0..2) - .map(|_| (0..3).map(|_| 0_i32).collect::>()) - .collect::]>>(), - arr: Box::<[i32]>::from(std::array::from_fn::<_, 3, _>(|_| 0_i32)), - elems: Default::default(), - rows: Default::default(), - } - } - } -} pub fn sum_0(mut p: Ptr, mut n: i32) -> i32 { let mut s: i32 = 0; { @@ -149,7 +123,8 @@ pub fn fill_1(mut s: Ptr) { } } elem!(field_ref!(s, arr).decay(), 1_usize).write(7); - field!(s, elems).with_mut(|__v: &mut Vec| __v.resize_with(3_usize, || ::default())); + field!(s, elems) + .with_mut(|__v: &mut Vec| __v.resize_with(3_usize, || ::default_constructed())); { let mut i: i32 = 0; 'loop_: while (i < 3) { @@ -231,17 +206,18 @@ impl MoveAssignable for Counted { return (this).clone(); } } -impl Default for Counted { - fn default() -> Self { - { Counted { v: 0 } } - } -} 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(State { + count: 0_i32, + grid: Box::new(std::array::from_fn::<_, 2, _>(|_| Default::default())), + arr: Box::<[i32]>::from(std::array::from_fn::<_, 3, _>(|_| 0_i32)), + elems: Vec::new(), + rows: Vec::new(), + })); ({ fill_1((s.as_pointer())) }); assert!( ({ @@ -341,8 +317,9 @@ fn main_0() -> i32 { && ((index!(field!(vec_elem!(p, elems, 3_usize), hist), 0).read()) == 100) }) ); - let elems: Value> = - Rc::new(RefCell::new(Vec::from_fn(2_usize, |_| ::default()))); + let elems: Value> = Rc::new(RefCell::new(Vec::from_fn(2_usize, |_| { + ::default_constructed() + }))); let mut first: Ptr = (elems.decay().offset(0_usize)); (*elems.borrow_mut())[1_usize] .coeffs @@ -376,7 +353,13 @@ fn main_0() -> i32 { ((elem!(field_ref!(moved.as_pointer(), arr).decay(), 1_usize).read()) == 7) && ((elem!(field_ref!(t.as_pointer(), arr).decay(), 1_usize).read()) == 7) ); - let assigned: Value = Rc::new(RefCell::new(::default())); + let assigned: Value = Rc::new(RefCell::new(State { + count: 0_i32, + grid: Box::new(std::array::from_fn::<_, 2, _>(|_| Default::default())), + arr: Box::<[i32]>::from(std::array::from_fn::<_, 3, _>(|_| 0_i32)), + elems: Vec::new(), + rows: Vec::new(), + })); assign!(assigned = RvalueRef(moved)); assert!( ({ @@ -405,7 +388,7 @@ fn main_0() -> i32 { 3, _, >(|_| { - ::default() + ::default_constructed() })))); (*ca.borrow_mut())[1_usize].v = 5; let cb: Value> = Rc::new(RefCell::new({ diff --git a/tests/unit/out/refcount/map.rs b/tests/unit/out/refcount/map.rs index d4c16f8bde..4a4078cb8e 100644 --- a/tests/unit/out/refcount/map.rs +++ b/tests/unit/out/refcount/map.rs @@ -46,17 +46,6 @@ impl Point { field!(this, y).write(y); } } -impl Default for Point { - fn default() -> Self { - { - { - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - Point::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); @@ -847,7 +836,7 @@ fn main_0() -> i32 { (*points.borrow_mut()).subscript_move( __tmp_65, |__k| cpp_move!(__k), - || ::default(), + || ::default_constructed(), ) }) } @@ -862,7 +851,7 @@ fn main_0() -> i32 { (*points.borrow_mut()).subscript_move( __tmp_66, |__k| cpp_move!(__k), - || ::default(), + || ::default_constructed(), ) }) } @@ -895,7 +884,7 @@ fn main_0() -> i32 { (*points.borrow_mut()).subscript_move( __tmp_68, |__k| cpp_move!(__k), - || ::default(), + || ::default_constructed(), ) }) } @@ -910,7 +899,7 @@ fn main_0() -> i32 { (*points.borrow_mut()).subscript_move( __tmp_69, |__k| cpp_move!(__k), - || ::default(), + || ::default_constructed(), ) }) } diff --git a/tests/unit/out/refcount/map_key_identity.rs b/tests/unit/out/refcount/map_key_identity.rs index 9140286dc0..de80a5991a 100644 --- a/tests/unit/out/refcount/map_key_identity.rs +++ b/tests/unit/out/refcount/map_key_identity.rs @@ -19,7 +19,6 @@ thread_local!( FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -59,17 +58,6 @@ impl Mapped { (*default_constructions_0.with(Value::clone).borrow_mut()).prefix_inc(); } } -impl Default for Mapped { - fn default() -> Self { - { - { - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - Mapped::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); @@ -93,8 +81,10 @@ fn main_0() -> i32 { != 0 }; let distinct: Value, Value)>> = Rc::new(RefCell::new(Map::new())); - let a: Ptr = - ({ (*distinct.borrow_mut()).subscript(distinct_a.as_pointer(), || ::default()) }); + let a: Ptr = ({ + (*distinct.borrow_mut()) + .subscript(distinct_a.as_pointer(), || ::default_constructed()) + }); field!(a, value).write(11); let a_it: Value, Value)>> = Rc::new(RefCell::new(distinct.as_pointer().with( @@ -104,8 +94,10 @@ fn main_0() -> i32 { .1 .as_pointer()); ok = { ((ok as i32) & ((default_constructions_0.with(|rc| *rc.borrow()) == 1) as i32)) != 0 }; - let b: Ptr = - ({ (*distinct.borrow_mut()).subscript(distinct_b.as_pointer(), || ::default()) }); + let b: Ptr = ({ + (*distinct.borrow_mut()) + .subscript(distinct_b.as_pointer(), || ::default_constructed()) + }); field!(b, value).write(22); let b_it: Value, Value)>> = Rc::new(RefCell::new(distinct.as_pointer().with( @@ -235,7 +227,9 @@ fn main_0() -> i32 { Rc::new(RefCell::new(Map::new())); let mut before_equivalent: i32 = default_constructions_0.with(|rc| *rc.borrow()); let first: Ptr = ({ - (*equivalent.borrow_mut()).subscript(equivalent_a.as_pointer(), || ::default()) + (*equivalent.borrow_mut()).subscript(equivalent_a.as_pointer(), || { + ::default_constructed() + }) }); field!(first, value).write(31); let first_it: Value, Value)>> = @@ -252,7 +246,9 @@ fn main_0() -> i32 { != 0 }; let second: Ptr = ({ - (*equivalent.borrow_mut()).subscript(equivalent_b.as_pointer(), || ::default()) + (*equivalent.borrow_mut()).subscript(equivalent_b.as_pointer(), || { + ::default_constructed() + }) }); let mut reused: bool = (default_constructions_0.with(|rc| *rc.borrow()) == (before_equivalent + 1)); @@ -359,8 +355,10 @@ fn main_0() -> i32 { order: 4, identity: 10, })); - let later: Ptr = - ({ (*equivalent.borrow_mut()).subscript(later_key.as_pointer(), || ::default()) }); + let later: Ptr = ({ + (*equivalent.borrow_mut()) + .subscript(later_key.as_pointer(), || ::default_constructed()) + }); field!(later, value).write(41); ok = { ((ok as i32) @@ -415,8 +413,10 @@ fn main_0() -> i32 { })); let mut before_matching: i32 = default_constructions_0.with(|rc| *rc.borrow()); let matching: Value, Value)>> = Rc::new(RefCell::new(Map::new())); - let matched: Ptr = - ({ (*matching.borrow_mut()).subscript(matching_a.as_pointer(), || ::default()) }); + let matched: Ptr = ({ + (*matching.borrow_mut()) + .subscript(matching_a.as_pointer(), || ::default_constructed()) + }); field!(matched, value).write(51); let matched_it: Value, Value)>> = Rc::new(RefCell::new(matching.as_pointer().with( @@ -431,8 +431,10 @@ fn main_0() -> i32 { & ((default_constructions_0.with(|rc| *rc.borrow()) == (before_matching + 1)) as i32)) != 0 }; - let matched_again: Ptr = - ({ (*matching.borrow_mut()).subscript(matching_b.as_pointer(), || ::default()) }); + let matched_again: Ptr = ({ + (*matching.borrow_mut()) + .subscript(matching_b.as_pointer(), || ::default_constructed()) + }); ok = { ((ok as i32) & ((default_constructions_0.with(|rc| *rc.borrow()) == (before_matching + 1)) as i32)) @@ -468,8 +470,10 @@ fn main_0() -> i32 { as i32)) != 0 }; - let other: Ptr = - ({ (*matching.borrow_mut()).subscript(matching_c.as_pointer(), || ::default()) }); + let other: Ptr = ({ + (*matching.borrow_mut()) + .subscript(matching_c.as_pointer(), || ::default_constructed()) + }); field!(other, value).write(61); ok = { ((ok as i32) diff --git a/tests/unit/out/refcount/map_try_emplace_lvalues.rs b/tests/unit/out/refcount/map_try_emplace_lvalues.rs index 9ee23c4dd4..fe8f5fb932 100644 --- a/tests/unit/out/refcount/map_try_emplace_lvalues.rs +++ b/tests/unit/out/refcount/map_try_emplace_lvalues.rs @@ -46,17 +46,6 @@ impl Item { (*made_0.with(Value::clone).borrow_mut()).prefix_inc(); } } -impl Default for Item { - fn default() -> Self { - { - { - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - Item::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} pub fn receiver_2( m: Ptr, Value)>>, ) -> Ptr, Value)>> { @@ -91,27 +80,8 @@ impl Temporary { (*temporary_calls_4.with(Value::clone).borrow_mut()).prefix_inc(); } } -impl Default for Temporary { - fn default() -> Self { - { - { - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - Temporary::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} #[derive( - Clone, - Record, - ByteRepr, - ZeroInitialization, - VaArg, - FnPtrArg, - TriviallyCopyable, - Default, - Conversions, + Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Conversions, )] #[conversions(copy, move)] #[constructor(constructor_1)] @@ -163,17 +133,6 @@ impl Owner { return field_ptr!(this.with(|__s| __s.ptr.clone()).as_pointer(), n); } } -impl Default for Owner { - fn default() -> Self { - { - { - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - Owner::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} #[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Conversions)] #[constructor(constructor_1)] #[byte_size(4)] @@ -186,11 +145,6 @@ impl Noncopy { field!(this, n).write(5); } } -impl Default for Noncopy { - fn default() -> Self { - { Noncopy { n: 5 } } - } -} #[derive( Clone, Record, ByteRepr, ZeroInitialization, VaArg, FnPtrArg, TriviallyCopyable, Conversions, )] @@ -215,17 +169,6 @@ impl Held { field!(this, ptr).write((n).clone()); } } -impl Default for Held { - fn default() -> Self { - { - { - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - Held::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} thread_local!( pub static global_values_7: Value, Value)>> = Rc::new(RefCell::new(Map::new())); @@ -1302,7 +1245,9 @@ fn main_0() -> i32 { field!( ({ (*selected.borrow_mut()) - .subscript(k.as_pointer(), || ::default()) + .subscript(k.as_pointer(), || { + ::default_constructed() + }) }), value ) @@ -1798,7 +1743,9 @@ fn main_0() -> i32 { }; value = (({ (*references.borrow_mut()) - .subscript(key.as_pointer(), || ::default()) + .subscript(key.as_pointer(), || { + ::default_constructed() + }) }) .with(|__s| __s.ptr.clone()) .read()) @@ -1910,7 +1857,9 @@ fn main_0() -> i32 { value = (elem!( ({ (*arrays.borrow_mut()) - .subscript(key.as_pointer(), || ::default()) + .subscript(key.as_pointer(), || { + ::default_constructed() + }) }) .with(|__s| __s.ptr.clone()), 1 @@ -2311,7 +2260,9 @@ fn main_0() -> i32 { }; value = (({ (*references.borrow_mut()) - .subscript(key.as_pointer(), || ::default()) + .subscript(key.as_pointer(), || { + ::default_constructed() + }) }) .with(|__s| __s.ptr.clone()) .read()) @@ -2377,8 +2328,9 @@ fn main_0() -> i32 { } }; value = (({ - (*owners.borrow_mut()) - .subscript(key.as_pointer(), || ::default()) + (*owners.borrow_mut()).subscript(key.as_pointer(), || { + ::default_constructed() + }) }) .with(|__s| __s.ptr.clone()) .read()) diff --git a/tests/unit/out/refcount/self_referencing_initializer.rs b/tests/unit/out/refcount/self_referencing_initializer.rs index e240f356e6..6248cb0ffa 100644 --- a/tests/unit/out/refcount/self_referencing_initializer.rs +++ b/tests/unit/out/refcount/self_referencing_initializer.rs @@ -15,7 +15,6 @@ use std::rc::{Rc, Weak}; FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -34,7 +33,6 @@ pub struct list_head { FnPtrArg, TriviallyDefaultConstructible, TriviallyCopyable, - Default, Conversions, )] #[conversions(copy, move)] @@ -65,16 +63,6 @@ impl node_with_defaults { field!(this, value).write(3); } } -impl Default for node_with_defaults { - fn default() -> Self { - { - node_with_defaults { - next: Ptr::::null(), - value: 3, - } - } - } -} pub fn init_0(mut l: Ptr) -> Ptr { field!(l, next).write(Ptr::::null()); return l; @@ -84,12 +72,12 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let list: Value = >::default(); + let list: Value = >::zero_init(); *list.borrow_mut() = list_head { next: (list.as_pointer()), }; assert!(({ { (*list.borrow()).next.clone() } } == { (list.as_pointer()) })); - let n: Value = >::default(); + let n: Value = >::zero_init(); *n.borrow_mut() = node { value: 42, value_ptr: (field_ptr!(n.as_pointer(), value)), @@ -99,7 +87,7 @@ fn main_0() -> i32 { assert!(({ (*n.borrow()).value } == 7)); let arr: Value> = Rc::new(RefCell::new( (0..2) - .map(|_| ::default()) + .map(|_| ::zero_init()) .collect::>(), )); *arr.borrow_mut() = Box::new([ @@ -112,14 +100,14 @@ fn main_0() -> i32 { ]); assert!(({ { (*arr.borrow())[(0) as usize].next.clone() } } == { (arr.decay().offset(1)) })); assert!(({ { (*arr.borrow())[(1) as usize].next.clone() } } == { (arr.decay().offset(0)) })); - let d: Value = >::default(); + let d: Value = >::zero_init(); *d.borrow_mut() = node_with_defaults { next: (d.as_pointer()), value: 3, }; assert!(({ { (*d.borrow()).next.clone() } } == { (d.as_pointer()) })); assert!(({ (*d.borrow()).value } == 3)); - let called: Value = >::default(); + let called: Value = >::zero_init(); *called.borrow_mut() = list_head { next: ({ init_0((called.as_pointer())) }), }; diff --git a/tests/unit/out/refcount/sort_no_copy.rs b/tests/unit/out/refcount/sort_no_copy.rs index a9e08862ee..6dd9f3302a 100644 --- a/tests/unit/out/refcount/sort_no_copy.rs +++ b/tests/unit/out/refcount/sort_no_copy.rs @@ -52,17 +52,6 @@ impl MoveAssignable for Tracked { return (this).clone(); } } -impl Default for Tracked { - fn default() -> Self { - { - { - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - Tracked::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} impl LessThanComparable for Tracked { fn less(a: Ptr, b: Ptr) -> bool { return ({ a.with(|__s| __s.v) } < { b.with(|__s| __s.v) }); @@ -72,14 +61,7 @@ pub fn greater_1(a: Ptr, b: Ptr) -> bool { return ({ a.with(|__s| __s.v) } > { b.with(|__s| __s.v) }); } #[derive( - Record, - ByteRepr, - ZeroInitialization, - FnPtrArg, - DefaultInitializable, - Memberwise, - Swappable, - Default, + Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Memberwise, Swappable, )] #[memberwise(move_constructor, move_assign)] #[derive(Conversions)] @@ -100,9 +82,7 @@ impl LessThanComparable for MoveOnly { return ({ a.with(|__s| __s.v) } < { b.with(|__s| __s.v) }); } } -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Swappable, Default, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Swappable)] #[memberwise(copy_constructor, move_constructor, copy_assign, move_assign)] #[derive(Conversions)] #[conversions(copy, move)] @@ -358,8 +338,9 @@ fn main_0() -> i32 { }) ); assert!((copies_0.with(|rc| *rc.borrow()) == 0)); - let bag_vec: Value> = - Rc::new(RefCell::new(Vec::from_fn(3_usize, |_| ::default()))); + let bag_vec: Value> = Rc::new(RefCell::new(Vec::from_fn(3_usize, |_| { + ::default_constructed() + }))); match ( field_ref!(bag_vec.decay().offset(1_usize), items).as_pointer(), { diff --git a/tests/unit/out/refcount/swap_map_no_copy.rs b/tests/unit/out/refcount/swap_map_no_copy.rs index 841a656559..4fe76668eb 100644 --- a/tests/unit/out/refcount/swap_map_no_copy.rs +++ b/tests/unit/out/refcount/swap_map_no_copy.rs @@ -52,20 +52,7 @@ impl MoveAssignable for Tracked { return (this).clone(); } } -impl Default for Tracked { - fn default() -> Self { - { - { - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - Tracked::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - } - } - } -} -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Swappable, Default, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Swappable)] #[memberwise(copy_constructor, move_constructor, copy_assign, move_assign)] #[derive(Conversions)] #[conversions(copy, move)] @@ -115,20 +102,6 @@ impl Arrays { }))); } } -impl Default for Arrays { - fn default() -> Self { - { - Arrays { - a: (0..2) - .map(|_| ::default()) - .collect::>(), - b: (0..2) - .map(|_| ::default()) - .collect::>(), - } - } - } -} thread_local!( pub static copy_only_copies_1: Value = Rc::new(RefCell::new(0)); ); @@ -289,9 +262,7 @@ pub fn swapped_once_6() -> bool { }); return ok; } -#[derive( - Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Swappable, Default, -)] +#[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Swappable)] #[memberwise(move_constructor, move_assign)] #[derive(Conversions)] #[conversions(move)] @@ -328,7 +299,7 @@ fn main_0() -> i32 { (*m1.borrow_mut()).subscript_move( __tmp_0, |__k| cpp_move!(__k), - || ::default(), + || ::default_constructed(), ) }) } @@ -345,7 +316,7 @@ fn main_0() -> i32 { (*m1.borrow_mut()).subscript_move( __tmp_1, |__k| cpp_move!(__k), - || ::default(), + || ::default_constructed(), ) }) } @@ -363,7 +334,7 @@ fn main_0() -> i32 { (*m2.borrow_mut()).subscript_move( __tmp_2, |__k| cpp_move!(__k), - || ::default(), + || ::default_constructed(), ) }) } @@ -378,7 +349,7 @@ fn main_0() -> i32 { (*m1.borrow_mut()).subscript_move( __tmp_3, |__k| cpp_move!(__k), - || ::default(), + || ::default_constructed(), ) }) } @@ -389,7 +360,7 @@ fn main_0() -> i32 { (*m1.borrow_mut()).subscript_move( __tmp_4, |__k| cpp_move!(__k), - || ::default(), + || ::default_constructed(), ) }) } @@ -402,7 +373,7 @@ fn main_0() -> i32 { (*m1.borrow_mut()).subscript_move( __tmp_5, |__k| cpp_move!(__k), - || ::default(), + || ::default_constructed(), ) }) } @@ -415,7 +386,7 @@ fn main_0() -> i32 { (*m1.borrow_mut()).subscript_move( __tmp_6, |__k| cpp_move!(__k), - || ::default(), + || ::default_constructed(), ) }) } @@ -433,7 +404,7 @@ fn main_0() -> i32 { (*m1.borrow_mut()).subscript_move( __tmp_7, |__k| cpp_move!(__k), - || ::default(), + || ::default_constructed(), ) }) } @@ -449,7 +420,7 @@ fn main_0() -> i32 { (*m2.borrow_mut()).subscript_move( __tmp_8, |__k| cpp_move!(__k), - || ::default(), + || ::default_constructed(), ) }) } @@ -462,7 +433,7 @@ fn main_0() -> i32 { (*m2.borrow_mut()).subscript_move( __tmp_9, |__k| cpp_move!(__k), - || ::default(), + || ::default_constructed(), ) }) } @@ -665,7 +636,7 @@ fn main_0() -> i32 { (*maps.borrow_mut())[(0) as usize].subscript_move( __tmp_18, |__k| cpp_move!(__k), - || ::default(), + || ::default_constructed(), ) }) } @@ -682,7 +653,7 @@ fn main_0() -> i32 { (*maps.borrow_mut())[(1) as usize].subscript_move( __tmp_19, |__k| cpp_move!(__k), - || ::default(), + || ::default_constructed(), ) }) } @@ -698,7 +669,7 @@ fn main_0() -> i32 { (*maps.borrow_mut())[(0) as usize].subscript_move( __tmp_20, |__k| cpp_move!(__k), - || ::default(), + || ::default_constructed(), ) }) } @@ -714,7 +685,7 @@ fn main_0() -> i32 { (*maps.borrow_mut())[(1) as usize].subscript_move( __tmp_21, |__k| cpp_move!(__k), - || ::default(), + || ::default_constructed(), ) }) } diff --git a/tests/unit/out/unsafe/inline_container_fields.rs b/tests/unit/out/unsafe/inline_container_fields.rs index 19128f8439..5f574b24e9 100644 --- a/tests/unit/out/unsafe/inline_container_fields.rs +++ b/tests/unit/out/unsafe/inline_container_fields.rs @@ -16,7 +16,6 @@ use std::rc::Rc; MemberwiseUnsafe, CopyConstructibleUnsafe, SwappableUnsafe, - Default, )] #[memberwise(move_constructor, copy_assign, move_assign)] #[derive(ConversionsUnsafe)] @@ -65,19 +64,6 @@ impl State { (&raw mut (*this).rows).write(Vec::new()); } } -impl Default for State { - fn default() -> Self { - unsafe { - State { - count: 0_i32, - grid: [[0_i32; 3]; 2], - arr: std::array::from_fn::<_, 3, _>(|_| 0_i32), - elems: Default::default(), - rows: Default::default(), - } - } - } -} pub unsafe fn sum_0(mut p: *const i32, mut n: i32) -> i32 { let mut s: i32 = 0; { @@ -110,7 +96,8 @@ pub unsafe fn fill_1(mut s: *mut State) { } } (&mut (*s)).arr[(1_usize)] = 7; - (*s).elems.resize_with(3_usize, || ::default()); + (*s).elems + .resize_with(3_usize, || ::default_constructed()); { let mut i: i32 = 0; 'loop_: while ((i) < (3)) { @@ -187,11 +174,6 @@ impl MoveAssignableUnsafe for Counted { return &mut (*this); } } -impl Default for Counted { - fn default() -> Self { - unsafe { Counted { v: 0 } } - } -} pub fn main() { unsafe { __cpp2rust_init_globals(); @@ -199,7 +181,13 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut s: State = ::default(); + let mut s: State = State { + count: 0_i32, + grid: std::array::from_fn::<_, 2, _>(|_| Default::default()), + arr: std::array::from_fn::<_, 3, _>(|_| 0_i32), + elems: Vec::new(), + rows: Vec::new(), + }; (unsafe { fill_1((&mut s as *mut State)) }); assert!( ((s.grid[(1) as usize][(2) as usize]) == (5)) @@ -253,7 +241,7 @@ unsafe fn main_0() -> i32 { (((*p).elems.len()) == (4_usize)) && (((&mut (*p)).elems[(3_usize)].hist[(0) as usize]) == (100)) ); - let mut elems: Vec = Vec::from_fn(2_usize, |_| ::default()); + let mut elems: Vec = Vec::from_fn(2_usize, |_| ::default_constructed()); let mut first: *mut Elem = (&mut elems[(0_usize)] as *mut Elem); elems[(1_usize)].coeffs.resize_with(2_usize, || 0_i16); elems[(1_usize)].coeffs[(1_usize)] = 4_i16; @@ -270,7 +258,13 @@ unsafe fn main_0() -> i32 { ); assert!((((moved.elems.len()) == (4_usize)) && (t.elems.is_empty())) && (t.rows.is_empty())); assert!(((moved.arr[(1_usize)]) == (7)) && ((t.arr[(1_usize)]) == (7))); - let mut assigned: State = ::default(); + let mut assigned: State = State { + count: 0_i32, + grid: std::array::from_fn::<_, 2, _>(|_| Default::default()), + arr: std::array::from_fn::<_, 3, _>(|_| 0_i32), + elems: Vec::new(), + rows: Vec::new(), + }; assign_unsafe!(assigned = RvalueRefUnsafe(moved)); assert!( ((assigned.grid[(0) as usize][(0) as usize]) == (100)) @@ -280,7 +274,7 @@ unsafe fn main_0() -> i32 { ((assigned.elems[(2_usize)].coeffs[(1_usize)] as i32) == (7)) && (moved.elems.is_empty()) ); assert!(((assigned.arr[(1_usize)]) == (7)) && ((moved.arr[(1_usize)]) == (7))); - let mut ca: [Counted; 3] = std::array::from_fn::<_, 3, _>(|_| ::default()); + let mut ca: [Counted; 3] = std::array::from_fn::<_, 3, _>(|_| ::default_constructed()); ca[(1_usize)].v = 5; let mut cb: [Counted; 3] = std::array::from_fn(|__i| move_constructed_unsafe(&raw mut ca[__i])); assert!( diff --git a/tests/unit/out/unsafe/map.rs b/tests/unit/out/unsafe/map.rs index e7a22f483a..d5952ee0c2 100644 --- a/tests/unit/out/unsafe/map.rs +++ b/tests/unit/out/unsafe/map.rs @@ -42,17 +42,6 @@ impl Point { (&raw mut (*this).y).write(y); } } -impl Default for Point { - fn default() -> Self { - unsafe { - { - let mut __v: Point = ZeroInitializationUnsafe::zero_init(); - Point::constructor_1(&raw mut __v); - __v - } - } - } -} pub fn main() { unsafe { __cpp2rust_init_globals(); @@ -498,7 +487,7 @@ unsafe fn main_0() -> i32 { (*points.subscript_move( &mut __tmp_31, |__k| cpp_move_unsafe!(__k), - || ::default(), + || ::default_constructed(), )) .x }) == (3)) @@ -512,7 +501,7 @@ unsafe fn main_0() -> i32 { (*points.subscript_move( &mut __tmp_32, |__k| cpp_move_unsafe!(__k), - || ::default(), + || ::default_constructed(), )) .y }) == (4)) @@ -531,7 +520,7 @@ unsafe fn main_0() -> i32 { (*points.subscript_move( &mut __tmp_33, |__k| cpp_move_unsafe!(__k), - || ::default(), + || ::default_constructed(), )) .x }) == (5)) @@ -545,7 +534,7 @@ unsafe fn main_0() -> i32 { (*points.subscript_move( &mut __tmp_34, |__k| cpp_move_unsafe!(__k), - || ::default(), + || ::default_constructed(), )) .y }) == (6)) diff --git a/tests/unit/out/unsafe/map_key_identity.rs b/tests/unit/out/unsafe/map_key_identity.rs index fe4f9c4623..cbf8688d82 100644 --- a/tests/unit/out/unsafe/map_key_identity.rs +++ b/tests/unit/out/unsafe/map_key_identity.rs @@ -17,7 +17,6 @@ pub static mut default_constructions_0: std::cell::LazyCell = ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -51,17 +50,6 @@ impl Mapped { (*std::cell::LazyCell::force_mut(&mut *&raw mut default_constructions_0)).prefix_inc(); } } -impl Default for Mapped { - fn default() -> Self { - unsafe { - { - let mut __v: Mapped = ZeroInitializationUnsafe::zero_init(); - Mapped::constructor_1(&raw mut __v); - __v - } - } - } -} pub fn main() { unsafe { __cpp2rust_init_globals(); @@ -85,7 +73,8 @@ unsafe fn main_0() -> i32 { }) as i32)) != 0; let mut distinct: UnsafeMap = UnsafeMap::new(); - let a: *mut Mapped = &mut (*distinct.subscript(&distinct_a, || ::default())); + let a: *mut Mapped = + &mut (*distinct.subscript(&distinct_a, || ::default_constructed())); (*a).value = 11; let mut a_it: UnsafeBidirectionalIterator<(Key, Mapped)> = distinct.find(&distinct_a); let mut a_value: *mut Mapped = (&mut (*a_it.iter_deref()).1 as *mut Mapped); @@ -93,7 +82,8 @@ unsafe fn main_0() -> i32 { & (((*std::cell::LazyCell::force_mut(&mut *&raw mut default_constructions_0)) == (1)) as i32)) != 0; - let b: *mut Mapped = &mut (*distinct.subscript(&distinct_b, || ::default())); + let b: *mut Mapped = + &mut (*distinct.subscript(&distinct_b, || ::default_constructed())); (*b).value = 22; let mut b_it: UnsafeBidirectionalIterator<(Key, Mapped)> = distinct.find(&distinct_b); ok = ((ok as i32) @@ -152,7 +142,8 @@ unsafe fn main_0() -> i32 { let mut equivalent: UnsafeMap = UnsafeMap::new(); let before_equivalent: i32 = (*std::cell::LazyCell::force_mut(&mut *&raw mut default_constructions_0)); - let first: *mut Mapped = &mut (*equivalent.subscript(&equivalent_a, || ::default())); + let first: *mut Mapped = + &mut (*equivalent.subscript(&equivalent_a, || ::default_constructed())); (*first).value = 31; let mut first_it: UnsafeBidirectionalIterator<(Key, Mapped)> = equivalent.find(&equivalent_a); let mut first_value: *mut Mapped = (&mut (*first_it.iter_deref()).1 as *mut Mapped); @@ -160,7 +151,8 @@ unsafe fn main_0() -> i32 { & (((*std::cell::LazyCell::force_mut(&mut *&raw mut default_constructions_0)) == ((before_equivalent) + (1))) as i32)) != 0; - let second: *mut Mapped = &mut (*equivalent.subscript(&equivalent_b, || ::default())); + let second: *mut Mapped = + &mut (*equivalent.subscript(&equivalent_b, || ::default_constructed())); let reused: bool = ((*std::cell::LazyCell::force_mut(&mut *&raw mut default_constructions_0)) == ((before_equivalent) + (1))); ok = ((ok as i32) & (reused as i32)) != 0; @@ -210,7 +202,8 @@ unsafe fn main_0() -> i32 { order: 4, identity: 10, }; - let later: *mut Mapped = &mut (*equivalent.subscript(&later_key, || ::default())); + let later: *mut Mapped = + &mut (*equivalent.subscript(&later_key, || ::default_constructed())); (*later).value = 41; ok = ((ok as i32) & (((*std::cell::LazyCell::force_mut(&mut *&raw mut default_constructions_0)) @@ -244,7 +237,8 @@ unsafe fn main_0() -> i32 { let before_matching: i32 = (*std::cell::LazyCell::force_mut(&mut *&raw mut default_constructions_0)); let mut matching: UnsafeMap = UnsafeMap::new(); - let matched: *mut Mapped = &mut (*matching.subscript(&matching_a, || ::default())); + let matched: *mut Mapped = + &mut (*matching.subscript(&matching_a, || ::default_constructed())); (*matched).value = 51; let mut matched_it: UnsafeBidirectionalIterator<(Key, Mapped)> = matching.find(&matching_a); let mut matched_value: *mut Mapped = (&mut (*matched_it.iter_deref()).1 as *mut Mapped); @@ -253,7 +247,7 @@ unsafe fn main_0() -> i32 { == ((before_matching) + (1))) as i32)) != 0; let matched_again: *mut Mapped = - &mut (*matching.subscript(&matching_b, || ::default())); + &mut (*matching.subscript(&matching_b, || ::default_constructed())); ok = ((ok as i32) & (((*std::cell::LazyCell::force_mut(&mut *&raw mut default_constructions_0)) == ((before_matching) + (1))) as i32)) @@ -268,7 +262,8 @@ unsafe fn main_0() -> i32 { & (((&mut (*matched_it.iter_deref()).1 as *mut Mapped) == (matched_value)) as i32)) != 0; ok = ((ok as i32) & ((((*matched_it.iter_deref()).1.value) == (51)) as i32)) != 0; - let other: *mut Mapped = &mut (*matching.subscript(&matching_c, || ::default())); + let other: *mut Mapped = + &mut (*matching.subscript(&matching_c, || ::default_constructed())); (*other).value = 61; ok = ((ok as i32) & (((*std::cell::LazyCell::force_mut(&mut *&raw mut default_constructions_0)) diff --git a/tests/unit/out/unsafe/map_try_emplace_lvalues.rs b/tests/unit/out/unsafe/map_try_emplace_lvalues.rs index 96e0eacc66..b70dbb7553 100644 --- a/tests/unit/out/unsafe/map_try_emplace_lvalues.rs +++ b/tests/unit/out/unsafe/map_try_emplace_lvalues.rs @@ -37,17 +37,6 @@ impl Item { (*std::cell::LazyCell::force_mut(&mut *&raw mut made_0)).prefix_inc(); } } -impl Default for Item { - fn default() -> Self { - unsafe { - { - let mut __v: Item = ZeroInitializationUnsafe::zero_init(); - Item::constructor_1(&raw mut __v); - __v - } - } - } -} pub unsafe fn receiver_2(m: *mut UnsafeMap) -> *mut UnsafeMap { (*std::cell::LazyCell::force_mut(&mut *&raw mut visits_1)).prefix_inc(); return m; @@ -81,17 +70,6 @@ impl Temporary { (*std::cell::LazyCell::force_mut(&mut *&raw mut temporary_calls_4)).prefix_inc(); } } -impl Default for Temporary { - fn default() -> Self { - unsafe { - { - let mut __v: Temporary = ZeroInitializationUnsafe::zero_init(); - Temporary::constructor_1(&raw mut __v); - __v - } - } - } -} #[repr(C)] #[derive( Copy, @@ -100,7 +78,6 @@ impl Default for Temporary { FnPtrArg, ZeroInitializationUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -153,17 +130,6 @@ impl Owner { .n; } } -impl Default for Owner { - fn default() -> Self { - unsafe { - { - let mut __v: Owner = ZeroInitializationUnsafe::zero_init(); - Owner::constructor_1(&raw mut __v); - __v - } - } - } -} #[repr(C)] #[derive(FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, ConversionsUnsafe)] #[constructor(constructor_1)] @@ -175,11 +141,6 @@ impl Noncopy { (&raw mut (*this).n).write(5); } } -impl Default for Noncopy { - fn default() -> Self { - unsafe { Noncopy { n: 5 } } - } -} #[repr(C)] #[derive( Copy, @@ -208,17 +169,6 @@ impl Held { (&raw mut (*this).ptr).write((*n).as_ptr()); } } -impl Default for Held { - fn default() -> Self { - unsafe { - { - let mut __v: Held = ZeroInitializationUnsafe::zero_init(); - Held::constructor_1(&raw mut __v); - __v - } - } - } -} pub static mut global_values_7: std::cell::LazyCell> = std::cell::LazyCell::new(|| unsafe { UnsafeMap::new() }); pub static mut global_key_8: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); @@ -739,7 +689,8 @@ unsafe fn main_0() -> i32 { keys.as_ptr().offset((3_i64) as isize), ) { let mut k: i32 = (*k); - (*selected.subscript(&k, || ::default())).value = 42; + (*selected.subscript(&k, || ::default_constructed())) + .value = 42; } } let mut a: i32 = 0; @@ -1005,8 +956,9 @@ unsafe fn main_0() -> i32 { __v }), }; - value = - (*(*references.subscript(&key, || ::default())).ptr) + value = (*(*references + .subscript(&key, || ::default_constructed())) + .ptr) } }; assert!( @@ -1062,9 +1014,10 @@ unsafe fn main_0() -> i32 { __v }), }; - value = (*(*arrays.subscript(&key, || ::default())) - .ptr - .offset((1) as isize)) + value = (*(*arrays + .subscript(&key, || ::default_constructed())) + .ptr + .offset((1) as isize)) } }; assert!( @@ -1309,8 +1262,9 @@ unsafe fn main_0() -> i32 { __v }), }; - value = - (*(*references.subscript(&key, || ::default())).ptr) + value = (*(*references + .subscript(&key, || ::default_constructed())) + .ptr) } }; assert!( @@ -1350,7 +1304,9 @@ unsafe fn main_0() -> i32 { __v }), }; - value = (*(*owners.subscript(&key, || ::default())).ptr) + value = (*(*owners + .subscript(&key, || ::default_constructed())) + .ptr) } }; assert!(((value) == (5))); diff --git a/tests/unit/out/unsafe/self_referencing_initializer.rs b/tests/unit/out/unsafe/self_referencing_initializer.rs index 30d5c979ec..d63dff2639 100644 --- a/tests/unit/out/unsafe/self_referencing_initializer.rs +++ b/tests/unit/out/unsafe/self_referencing_initializer.rs @@ -15,7 +15,6 @@ use std::rc::Rc; ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -31,7 +30,6 @@ pub struct list_head { ZeroInitializationUnsafe, TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, - Default, ConversionsUnsafe, )] #[conversions(copy, move)] @@ -61,16 +59,6 @@ impl node_with_defaults { (&raw mut (*this).value).write(3); } } -impl Default for node_with_defaults { - fn default() -> Self { - unsafe { - node_with_defaults { - next: std::ptr::null_mut(), - value: 3, - } - } - } -} pub unsafe fn init_0(mut l: *mut list_head) -> *mut list_head { (*l).next = std::ptr::null_mut(); return l; @@ -82,12 +70,12 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut list: list_head = ::default(); + let mut list: list_head = unsafe { ::zero_init() }; list = list_head { next: (&mut list as *mut list_head), }; assert!(((list.next) == (&mut list as *mut list_head))); - let mut n: node = ::default(); + let mut n: node = unsafe { ::zero_init() }; n = node { value: 42, value_ptr: (&mut n.value as *mut i32), @@ -95,7 +83,7 @@ unsafe fn main_0() -> i32 { assert!(((n.value_ptr) == (&mut n.value as *mut i32))); (*n.value_ptr) = 7; assert!(((n.value) == (7))); - let mut arr: [list_head; 2] = [::default(); 2]; + let mut arr: [list_head; 2] = [unsafe { ::zero_init() }; 2]; arr = [ list_head { next: (&mut arr[(1) as usize] as *mut list_head), @@ -106,14 +94,14 @@ unsafe fn main_0() -> i32 { ]; assert!(((arr[(0) as usize].next) == (&mut arr[(1) as usize] as *mut list_head))); assert!(((arr[(1) as usize].next) == (&mut arr[(0) as usize] as *mut list_head))); - let mut d: node_with_defaults = ::default(); + let mut d: node_with_defaults = unsafe { ::zero_init() }; d = node_with_defaults { next: (&mut d as *mut node_with_defaults), value: 3, }; assert!(((d.next) == (&mut d as *mut node_with_defaults))); assert!(((d.value) == (3))); - let mut called: list_head = ::default(); + let mut called: list_head = unsafe { ::zero_init() }; called = list_head { next: (unsafe { init_0((&mut called as *mut list_head)) }), }; diff --git a/tests/unit/out/unsafe/sort_no_copy.rs b/tests/unit/out/unsafe/sort_no_copy.rs index c58ce47980..e068978fe8 100644 --- a/tests/unit/out/unsafe/sort_no_copy.rs +++ b/tests/unit/out/unsafe/sort_no_copy.rs @@ -51,17 +51,6 @@ impl MoveAssignableUnsafe for Tracked { return &mut (*this); } } -impl Default for Tracked { - fn default() -> Self { - unsafe { - { - let mut __v: Tracked = ZeroInitializationUnsafe::zero_init(); - Tracked::constructor_1(&raw mut __v); - __v - } - } - } -} impl LessThanComparableUnsafe for Tracked { unsafe fn less(a: *const Tracked, b: *const Tracked) -> bool { return (((*a).v) < ((*b).v)); @@ -77,7 +66,6 @@ pub unsafe fn greater_1(a: *const Tracked, b: *const Tracked) -> bool { DefaultInitializableUnsafe, MemberwiseUnsafe, SwappableUnsafe, - Default, )] #[memberwise(move_constructor, move_assign)] #[derive(ConversionsUnsafe)] @@ -98,12 +86,7 @@ impl LessThanComparableUnsafe for MoveOnly { } #[repr(C)] #[derive( - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - MemberwiseUnsafe, - SwappableUnsafe, - Default, + FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, MemberwiseUnsafe, SwappableUnsafe, )] #[memberwise(copy_constructor, move_constructor, copy_assign, move_assign)] #[derive(ConversionsUnsafe)] @@ -392,7 +375,7 @@ unsafe fn main_0() -> i32 { && ((bags[(2) as usize].items.len()) == (2_usize)) ); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (0))); - let mut bag_vec: Vec = Vec::from_fn(3_usize, |_| ::default()); + let mut bag_vec: Vec = Vec::from_fn(3_usize, |_| ::default_constructed()); bag_vec[(1_usize)].items.push_mut({ let mut __v: Tracked = ZeroInitializationUnsafe::zero_init(); Tracked::constructor_2(&raw mut __v, 4); diff --git a/tests/unit/out/unsafe/swap_map_no_copy.rs b/tests/unit/out/unsafe/swap_map_no_copy.rs index 37acfaaf99..11f11c1168 100644 --- a/tests/unit/out/unsafe/swap_map_no_copy.rs +++ b/tests/unit/out/unsafe/swap_map_no_copy.rs @@ -51,25 +51,9 @@ impl MoveAssignableUnsafe for Tracked { return &mut (*this); } } -impl Default for Tracked { - fn default() -> Self { - unsafe { - { - let mut __v: Tracked = ZeroInitializationUnsafe::zero_init(); - Tracked::constructor_1(&raw mut __v); - __v - } - } - } -} #[repr(C)] #[derive( - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - MemberwiseUnsafe, - SwappableUnsafe, - Default, + FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, MemberwiseUnsafe, SwappableUnsafe, )] #[memberwise(copy_constructor, move_constructor, copy_assign, move_assign)] #[derive(ConversionsUnsafe)] @@ -87,12 +71,7 @@ impl Pair { } #[repr(C)] #[derive( - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - MemberwiseUnsafe, - SwappableUnsafe, - Default, + FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, MemberwiseUnsafe, SwappableUnsafe, )] #[memberwise(copy_constructor, move_constructor, copy_assign, move_assign)] #[derive(ConversionsUnsafe)] @@ -266,12 +245,7 @@ pub unsafe fn swapped_once_6() -> bool { } #[repr(C)] #[derive( - FnPtrArg, - ZeroInitializationUnsafe, - DestructibleUnsafe, - MemberwiseUnsafe, - SwappableUnsafe, - Default, + FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, MemberwiseUnsafe, SwappableUnsafe, )] #[memberwise(move_constructor, move_assign)] #[derive(ConversionsUnsafe)] @@ -313,7 +287,7 @@ unsafe fn main_0() -> i32 { &raw mut (*m1.subscript_move( &mut __tmp_0, |__k| cpp_move_unsafe!(__k), - || ::default(), + || ::default_constructed(), )) }) = RvalueRefUnsafe(_o) ) @@ -330,7 +304,7 @@ unsafe fn main_0() -> i32 { &raw mut (*m1.subscript_move( &mut __tmp_1, |__k| cpp_move_unsafe!(__k), - || ::default(), + || ::default_constructed(), )) }) = RvalueRefUnsafe(_o) ) @@ -348,7 +322,7 @@ unsafe fn main_0() -> i32 { &raw mut (*m2.subscript_move( &mut __tmp_2, |__k| cpp_move_unsafe!(__k), - || ::default(), + || ::default_constructed(), )) }) = RvalueRefUnsafe(_o) ) @@ -364,7 +338,7 @@ unsafe fn main_0() -> i32 { &mut (*m1.subscript_move( &mut __tmp_3, |__k| cpp_move_unsafe!(__k), - || ::default(), + || ::default_constructed(), )) }; let __b: *mut _ = { @@ -372,7 +346,7 @@ unsafe fn main_0() -> i32 { &mut (*m1.subscript_move( &mut __tmp_4, |__k| cpp_move_unsafe!(__k), - || ::default(), + || ::default_constructed(), )) }; SwappableUnsafe::swap(&mut *__a, __b) @@ -386,7 +360,7 @@ unsafe fn main_0() -> i32 { (*m1.subscript_move( &mut __tmp_5, |__k| cpp_move_unsafe!(__k), - || ::default(), + || ::default_constructed(), )) .v }) == (20)) @@ -397,7 +371,7 @@ unsafe fn main_0() -> i32 { (*m1.subscript_move( &mut __tmp_6, |__k| cpp_move_unsafe!(__k), - || ::default(), + || ::default_constructed(), )) .v }) == (10)) @@ -418,7 +392,7 @@ unsafe fn main_0() -> i32 { (*m1.subscript_move( &mut __tmp_7, |__k| cpp_move_unsafe!(__k), - || ::default(), + || ::default_constructed(), )) .v }) == (30)) @@ -433,7 +407,7 @@ unsafe fn main_0() -> i32 { (*m2.subscript_move( &mut __tmp_8, |__k| cpp_move_unsafe!(__k), - || ::default(), + || ::default_constructed(), )) .v }) == (20)) @@ -445,7 +419,7 @@ unsafe fn main_0() -> i32 { (*m2.subscript_move( &mut __tmp_9, |__k| cpp_move_unsafe!(__k), - || ::default(), + || ::default_constructed(), )) .v }) == (10)) @@ -622,7 +596,7 @@ unsafe fn main_0() -> i32 { &raw mut (*maps[(0) as usize].subscript_move( &mut __tmp_10, |__k| cpp_move_unsafe!(__k), - || ::default(), + || ::default_constructed(), )) }) = RvalueRefUnsafe(_o) ) @@ -639,7 +613,7 @@ unsafe fn main_0() -> i32 { &raw mut (*maps[(1) as usize].subscript_move( &mut __tmp_11, |__k| cpp_move_unsafe!(__k), - || ::default(), + || ::default_constructed(), )) }) = RvalueRefUnsafe(_o) ) @@ -659,7 +633,7 @@ unsafe fn main_0() -> i32 { (*maps[(0) as usize].subscript_move( &mut __tmp_12, |__k| cpp_move_unsafe!(__k), - || ::default(), + || ::default_constructed(), )) .v }) == (2)) @@ -674,7 +648,7 @@ unsafe fn main_0() -> i32 { (*maps[(1) as usize].subscript_move( &mut __tmp_13, |__k| cpp_move_unsafe!(__k), - || ::default(), + || ::default_constructed(), )) .v }) == (1)) From ac6eb25f144f32b32959dac8718ae710292c75ff Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Fri, 4 Dec 2026 20:27:39 +0000 Subject: [PATCH 08/14] Add DataMemberPointer --- cpp2rust/converter/converter.cpp | 29 ++++--- .../converter/models/converter_refcount.cpp | 2 +- libcc2rs-macros/src/initialization.rs | 21 ++++- libcc2rs/src/cmp.rs | 4 +- libcc2rs/src/constructor.rs | 25 ++++++ libcc2rs/src/fn_ptr.rs | 7 ++ libcc2rs/src/initialization.rs | 7 ++ libcc2rs/src/lib.rs | 1 + libcc2rs/src/member_ptr.rs | 78 ++++++++++++++++++- 9 files changed, 150 insertions(+), 24 deletions(-) diff --git a/cpp2rust/converter/converter.cpp b/cpp2rust/converter/converter.cpp index c086361a62..d5c28970d7 100644 --- a/cpp2rust/converter/converter.cpp +++ b/cpp2rust/converter/converter.cpp @@ -507,7 +507,7 @@ bool Converter::VisitMemberPointerType(clang::MemberPointerType *type) { if (type->isMemberFunctionPointer()) { llvm::report_fatal_error("pointers to member functions are not supported"); } - StrCat("isize"); + StrCat("DataMemberPointer"); return false; } @@ -5479,7 +5479,7 @@ std::string Converter::GetDefaultAsString(clang::QualType qual_type) { } if (qual_type->isMemberDataPointerType()) { - return "-1_isize"; + return "DataMemberPointer::null()"; } if (qual_type->isPointerType()) { @@ -5527,6 +5527,11 @@ std::string Converter::ConvertVarDefaultInit(const clang::VarDecl *decl) { return GetDefaultAsString(decl->getType()); } +std::string Converter::ConvertVarZeroInit(const clang::VarDecl *decl) { + return std::format("unsafe {{ <{}>::zero_init() }}", + ToString(decl->getType())); +} + std::string Converter::GetOverloadedFunctionName(const clang::CXXMethodDecl *decl) { auto name = GetFunctionBaseName(decl); @@ -5677,15 +5682,6 @@ void Converter::ConvertUnsignedArithOperand(clang::Expr *expr, } void Converter::ConvertEqualsNullPtr(clang::Expr *expr) { - if (expr->getType()->isMemberPointerType()) { - PushParen outer(*this); - { - PushParen inner(*this); - Convert(expr); - } - EmitFresh("== -1_isize"); - return; - } StrCat('('); Convert(expr); EmitFresh(expr->getType()->isFunctionPointerType() ? ").is_none()" @@ -6433,10 +6429,11 @@ std::string Converter::GetMemberPtrAsString(const clang::ValueDecl *member) { offsets.push_back(GetFieldOffsetAsString(field)); } if (offsets.empty()) { - return "0_isize"; + return "DataMemberPointer::from_offset(0)"; } if (offsets.size() == 1) { - return std::format("({} as isize)", offsets.front()); + return std::format("DataMemberPointer::from_offset({} as isize)", + offsets.front()); } std::string sum; for (const auto &offset : offsets) { @@ -6445,7 +6442,7 @@ std::string Converter::GetMemberPtrAsString(const clang::ValueDecl *member) { } sum += offset; } - return std::format("(({}) as isize)", sum); + return std::format("DataMemberPointer::from_offset(({}) as isize)", sum); } std::string Converter::GetFieldOffsetAsString(const clang::FieldDecl *field) { @@ -6482,8 +6479,8 @@ std::string Converter::ConvertMemberPtrObject(clang::BinaryOperator *expr) { std::string Converter::GetMemberOfObjectAsString(std::string object, std::string member, clang::QualType type) { - return std::format("{}.wrapping_byte_offset({}).cast::<{}>()", object, member, - ToString(type)); + return std::format("{}.wrapping_byte_offset(({}).offset()).cast::<{}>()", + object, member, ToString(type)); } void Converter::EmitDeref(std::string inner, clang::QualType pointee_type) { diff --git a/cpp2rust/converter/models/converter_refcount.cpp b/cpp2rust/converter/models/converter_refcount.cpp index 087c72eb69..662cecc8d9 100644 --- a/cpp2rust/converter/models/converter_refcount.cpp +++ b/cpp2rust/converter/models/converter_refcount.cpp @@ -2294,7 +2294,7 @@ std::string ConverterRefCount::GetDefaultAsString(clang::QualType qual_type) { } if (qual_type->isMemberDataPointerType()) { - return BoxValue("-1_isize"); + return BoxValue("DataMemberPointer::null()"); } if (!qual_type->isPointerType()) { diff --git a/libcc2rs-macros/src/initialization.rs b/libcc2rs-macros/src/initialization.rs index 91381d7acf..60e7b602e8 100644 --- a/libcc2rs-macros/src/initialization.rs +++ b/libcc2rs-macros/src/initialization.rs @@ -59,10 +59,29 @@ pub fn expand_unsafe(input: TokenStream) -> TokenStream { let input = parse_macro_input!(input as DeriveInput); let name = &input.ident; let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl(); + let value = match &input.data { + Data::Struct(data) => { + let value = quote!(::libcc2rs::ZeroInitializationUnsafe::zero_init()); + let values = std::iter::repeat_n(value, data.fields.len()); + let fields = match &data.fields { + Fields::Named(fields) => { + let idents = fields.named.iter().map(|field| &field.ident); + quote!({ #(#idents: #values,)* }) + } + Fields::Unnamed(fields) => { + let indices = (0..fields.unnamed.len()).map(Index::from); + quote!({ #(#indices: #values,)* }) + } + Fields::Unit => quote!({}), + }; + quote!(Self #fields) + } + _ => quote!(::std::mem::MaybeUninit::zeroed().assume_init()), + }; quote! { impl #impl_generics ::libcc2rs::ZeroInitializationUnsafe for #name #ty_generics #where_clause { unsafe fn zero_init() -> Self { - unsafe { ::std::mem::MaybeUninit::zeroed().assume_init() } + unsafe { #value } } } } diff --git a/libcc2rs/src/cmp.rs b/libcc2rs/src/cmp.rs index c6875abcf7..d400b7faed 100644 --- a/libcc2rs/src/cmp.rs +++ b/libcc2rs/src/cmp.rs @@ -242,7 +242,7 @@ macro_rules! impl_weakly_equality_comparable_with_unsafe { impl_weakly_equality_comparable_with!( <> bool, <> i8, <> i16, <> i32, <> i64, <> i128, <> isize, <> u8, <> u16, <> u32, <> u64, <> u128, <> usize, <> f32, <> f64, - Ptr, Option, + Ptr, Option, <> crate::DataMemberPointer, ); impl WeaklyEqualityComparableWith for Vec { @@ -282,7 +282,7 @@ where impl_weakly_equality_comparable_with_unsafe!( <> bool, <> i8, <> i16, <> i32, <> i64, <> i128, <> isize, <> u8, <> u16, <> u32, <> u64, <> u128, <> usize, <> f32, <> f64, - *mut T, *const T, Option, + *mut T, *const T, Option, <> crate::DataMemberPointer, ); impl WeaklyEqualityComparableWithUnsafe for Vec { diff --git a/libcc2rs/src/constructor.rs b/libcc2rs/src/constructor.rs index 2fcbe074f7..d547671e00 100644 --- a/libcc2rs/src/constructor.rs +++ b/libcc2rs/src/constructor.rs @@ -7,6 +7,7 @@ use crate::capture::{ use crate::conversion::{Constructor, ConstructorUnsafe}; use crate::fn_ptr::{FnPtr, FnSig}; use crate::initialization::ZeroInitialization; +use crate::member_ptr::DataMemberPointer; use crate::rc::{AsPointer, Ptr, Value}; use crate::reference::{Const, LvalueRef, LvalueRefUnsafe, RvalueRef, RvalueRefUnsafe}; use crate::reinterpret::ByteRepr; @@ -574,6 +575,13 @@ macro_rules! impl_default_by_zeroed { impl $crate::TriviallyDefaultConstructibleUnsafe for $ty {} + + impl $crate::ZeroInitializationUnsafe for $ty { + #[inline] + unsafe fn zero_init() -> Self { + unsafe { std::mem::zeroed() } + } + } )*}; } pub(crate) use impl_default_by_zeroed; @@ -654,6 +662,22 @@ impl ConstructorUnsafe<()> for FnPtr { } } +impl TriviallyDefaultConstructible for DataMemberPointer {} + +impl TriviallyDefaultConstructibleUnsafe for DataMemberPointer {} + +impl Constructor<()> for DataMemberPointer { + fn constructor(this: Ptr, _: ()) { + this.write(DataMemberPointer::null()); + } +} + +impl ConstructorUnsafe<()> for DataMemberPointer { + unsafe fn constructor(this: *mut Self, _: ()) { + unsafe { std::ptr::write(this, DataMemberPointer::null()) } + } +} + impl Constructor<()> for Box<[T]> { fn constructor(this: Ptr, _: ()) { let len = this.with(|elems| elems.len()); @@ -702,6 +726,7 @@ impl_trivial_copy_move!( f32, f64, AnyPtr, + DataMemberPointer, crate::VaArg, std::rc::Rc, ); diff --git a/libcc2rs/src/fn_ptr.rs b/libcc2rs/src/fn_ptr.rs index c149582224..45c2685667 100644 --- a/libcc2rs/src/fn_ptr.rs +++ b/libcc2rs/src/fn_ptr.rs @@ -514,6 +514,13 @@ impl crate::ZeroInitialization for FnPtr { } } +impl crate::ZeroInitializationUnsafe for FnPtr { + #[inline] + unsafe fn zero_init() -> Self { + FnPtr::null() + } +} + impl FnPtrArg for FnPtr { #[inline] fn to_repr(self) -> ArgRepr { diff --git a/libcc2rs/src/initialization.rs b/libcc2rs/src/initialization.rs index 926f4a0197..4590946f36 100644 --- a/libcc2rs/src/initialization.rs +++ b/libcc2rs/src/initialization.rs @@ -87,6 +87,13 @@ impl ZeroInitializatio } } +impl ZeroInitializationUnsafe for [T; N] { + #[inline] + unsafe fn zero_init() -> Self { + std::array::from_fn(|_| unsafe { T::zero_init() }) + } +} + impl ZeroInitializationUnsafe for *mut T { #[inline] unsafe fn zero_init() -> Self { diff --git a/libcc2rs/src/lib.rs b/libcc2rs/src/lib.rs index 171a021a11..5d95c4f44e 100644 --- a/libcc2rs/src/lib.rs +++ b/libcc2rs/src/lib.rs @@ -23,6 +23,7 @@ pub mod __field { } mod member_ptr; +pub use member_ptr::DataMemberPointer; mod cstr; pub use cstr::CChar; diff --git a/libcc2rs/src/member_ptr.rs b/libcc2rs/src/member_ptr.rs index 4c7f4347ca..db1382f43e 100644 --- a/libcc2rs/src/member_ptr.rs +++ b/libcc2rs/src/member_ptr.rs @@ -4,10 +4,80 @@ use std::any::TypeId; use crate::Record; +use crate::fn_ptr_arg::{ArgRepr, FnPtrArg}; +use crate::initialization::{ZeroInitialization, ZeroInitializationUnsafe}; use crate::rc::Ptr; use crate::reinterpret::ByteRepr; -const NULL: isize = -1; +#[derive(Clone, Copy, PartialEq, Eq)] +pub struct DataMemberPointer(isize); + +impl DataMemberPointer { + #[inline] + pub const fn null() -> Self { + DataMemberPointer(-1) + } + + #[inline] + pub const fn from_offset(offset: isize) -> Self { + DataMemberPointer(offset) + } + + #[inline] + pub fn is_null(self) -> bool { + self.0 == -1 + } + + #[inline] + pub fn offset(self) -> isize { + if self.is_null() { + panic!("ub: null member pointer"); + } + self.0 + } +} + +impl ByteRepr for DataMemberPointer { + #[inline] + fn byte_size() -> usize { + std::mem::size_of::() + } + #[inline] + fn to_bytes(&self, buf: &mut [u8]) { + buf.copy_from_slice(&self.0.to_ne_bytes()); + } + #[inline] + fn from_bytes(buf: &[u8]) -> Self { + let mut a = [0u8; std::mem::size_of::()]; + a.copy_from_slice(buf); + DataMemberPointer(isize::from_ne_bytes(a)) + } +} + +impl ZeroInitialization for DataMemberPointer { + #[inline] + fn zero_init() -> Self { + Self::null() + } +} + +impl ZeroInitializationUnsafe for DataMemberPointer { + #[inline] + unsafe fn zero_init() -> Self { + Self::null() + } +} + +impl FnPtrArg for DataMemberPointer { + #[inline] + fn to_repr(self) -> ArgRepr { + self.0.to_repr() + } + #[inline] + fn from_repr(r: ArgRepr) -> Self { + DataMemberPointer(isize::from_repr(r)) + } +} fn member_of(object: &C, offset: usize) -> &T { object @@ -25,11 +95,11 @@ fn member_of_mut(object: &mut C, offset: usize) -> &mut T impl Ptr { #[inline] - pub fn member(&self, member: isize) -> Ptr { - if member == NULL { + pub fn member(&self, member: DataMemberPointer) -> Ptr { + if member.is_null() { panic!("ub: null member pointer"); } - let offset = member as usize; + let offset = member.0 as usize; self.field_ptr_at( move |object| member_of(object, offset), move |object| member_of_mut(object, offset), From 4ec17d2eaba62c7295c915e14ca4a461f54f441b Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Fri, 4 Dec 2026 20:30:16 +0000 Subject: [PATCH 09/14] Fix default through zero_init --- cpp2rust/converter/converter.cpp | 12 ++++++++++-- cpp2rust/converter/converter.h | 2 ++ cpp2rust/converter/models/converter_refcount.cpp | 12 ++++++++++++ cpp2rust/converter/models/converter_refcount.h | 2 ++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/cpp2rust/converter/converter.cpp b/cpp2rust/converter/converter.cpp index d5c28970d7..5dbf445e75 100644 --- a/cpp2rust/converter/converter.cpp +++ b/cpp2rust/converter/converter.cpp @@ -638,7 +638,11 @@ void Converter::EmitHoistedDecls(clang::CompoundStmt *body) { void Converter::EmitHoistedDecl(clang::VarDecl *decl) { hoisted_decls_.insert(decl); if (ConvertVarDeclSkipInit(decl)) { - StrCat(token::kAssign, ConvertVarDefaultInit(decl), token::kSemiColon); + auto *record = decl->getType()->getAsRecordDecl(); + StrCat(token::kAssign, + record && IsUserDefinedDecl(record) ? ConvertVarZeroInit(decl) + : ConvertVarDefaultInit(decl), + token::kSemiColon); } } @@ -7448,7 +7452,11 @@ std::string Converter::ConvertGenericCall( } if (call.method == "default_constructed") { assert(call_args.empty() && "default_constructed takes no arguments"); - return GetUnboxedDefaultAsString(type); + auto *cxx = type->getAsCXXRecordDecl(); + if (!cxx || cxx->isUnion() || !IsUserDefinedDecl(cxx) || + cxx->hasTrivialDefaultConstructor()) { + return GetUnboxedDefaultAsString(type); + } } return std::format("<{}>::{}({})", GetUnboxedTypeAsString(type), call.method, diff --git a/cpp2rust/converter/converter.h b/cpp2rust/converter/converter.h index 9eb50f5069..54d5e1cf8e 100644 --- a/cpp2rust/converter/converter.h +++ b/cpp2rust/converter/converter.h @@ -925,6 +925,8 @@ class Converter : public clang::RecursiveASTVisitor { virtual std::string ConvertVarDefaultInit(const clang::VarDecl *decl); + virtual std::string ConvertVarZeroInit(const clang::VarDecl *decl); + virtual std::string GetOverloadedFunctionName(const clang::CXXMethodDecl *decl); diff --git a/cpp2rust/converter/models/converter_refcount.cpp b/cpp2rust/converter/models/converter_refcount.cpp index 662cecc8d9..fce231cae9 100644 --- a/cpp2rust/converter/models/converter_refcount.cpp +++ b/cpp2rust/converter/models/converter_refcount.cpp @@ -2189,6 +2189,12 @@ bool ConverterRefCount::VisitCXXConstructExpr(clang::CXXConstructExpr *expr) { bool ConverterRefCount::VisitImplicitValueInitExpr( clang::ImplicitValueInitExpr *expr) { + if (auto *array_type = ctx_.getAsConstantArrayType(expr->getType()); + array_type && array_type->getElementType()->isArrayType()) { + PushConversionKind push(*this, ConversionKind::Pointee); + EmitFresh(GetDefaultAsString(expr->getType())); + return false; + } PushConversionKind push(*this, ConversionKind::Unboxed); if (ctx_.getAsConstantArrayType(expr->getType())) { StrCat("Box::new("); @@ -2324,6 +2330,12 @@ ConverterRefCount::ConvertVarDefaultInit(const clang::VarDecl *decl) { return GetDefaultAsString(decl->getType()); } +std::string +ConverterRefCount::ConvertVarZeroInit(const clang::VarDecl *decl) { + PushConversionKind push(*this, VarConversionKind(decl)); + return std::format("<{}>::zero_init()", ToString(decl->getType())); +} + std::vector ConverterRefCount::GetStructAttributes(const clang::RecordDecl *decl) { std::vector attrs; diff --git a/cpp2rust/converter/models/converter_refcount.h b/cpp2rust/converter/models/converter_refcount.h index 066bd83c1d..a9cde4f7c0 100644 --- a/cpp2rust/converter/models/converter_refcount.h +++ b/cpp2rust/converter/models/converter_refcount.h @@ -322,6 +322,8 @@ class ConverterRefCount final : public Converter { std::string ConvertVarDefaultInit(const clang::VarDecl *decl) override; + std::string ConvertVarZeroInit(const clang::VarDecl *decl) override; + std::vector GetStructAttributes(const clang::RecordDecl *decl) override; From 02d7945fbeb8e11c6553ce53a1c33e5be5dca38d Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Fri, 4 Dec 2026 20:30:33 +0000 Subject: [PATCH 10/14] Update tests --- tests/unit/out/refcount/inline_container_fields.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/unit/out/refcount/inline_container_fields.rs b/tests/unit/out/refcount/inline_container_fields.rs index efb7c8fd44..32edac2df3 100644 --- a/tests/unit/out/refcount/inline_container_fields.rs +++ b/tests/unit/out/refcount/inline_container_fields.rs @@ -213,7 +213,9 @@ pub fn main() { fn main_0() -> i32 { let s: Value = Rc::new(RefCell::new(State { count: 0_i32, - grid: Box::new(std::array::from_fn::<_, 2, _>(|_| Default::default())), + grid: (0..2) + .map(|_| (0..3).map(|_| 0_i32).collect::>()) + .collect::]>>(), arr: Box::<[i32]>::from(std::array::from_fn::<_, 3, _>(|_| 0_i32)), elems: Vec::new(), rows: Vec::new(), @@ -355,7 +357,9 @@ fn main_0() -> i32 { ); let assigned: Value = Rc::new(RefCell::new(State { count: 0_i32, - grid: Box::new(std::array::from_fn::<_, 2, _>(|_| Default::default())), + grid: (0..2) + .map(|_| (0..3).map(|_| 0_i32).collect::>()) + .collect::]>>(), arr: Box::<[i32]>::from(std::array::from_fn::<_, 3, _>(|_| 0_i32)), elems: Vec::new(), rows: Vec::new(), From 61f1394e7543bba4cd1c21e5beb7c7bd04720523 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Fri, 4 Dec 2026 20:30:39 +0000 Subject: [PATCH 11/14] Format --- cpp2rust/converter/converter.cpp | 3 ++- cpp2rust/converter/models/converter_refcount.cpp | 14 +++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/cpp2rust/converter/converter.cpp b/cpp2rust/converter/converter.cpp index 5dbf445e75..b154118500 100644 --- a/cpp2rust/converter/converter.cpp +++ b/cpp2rust/converter/converter.cpp @@ -4762,7 +4762,8 @@ bool Converter::VisitCXXNewExpr(clang::CXXNewExpr *expr) { StrCat("))"); } else if (auto *construct = GetArrayNewElementConstruct(ctx_, expr)) { PushBrace block(*this); - auto record_name = GetRecordName(construct->getConstructor()->getParent()); + auto record_name = + GetRecordName(construct->getConstructor()->getParent()); StrCat(std::format( "let __n = ({0}) as usize; let __p: &mut [{1}] = " "Box::leak((0..__n).map(|_| <{1}>::zero_init()).collect::>" diff --git a/cpp2rust/converter/models/converter_refcount.cpp b/cpp2rust/converter/models/converter_refcount.cpp index fce231cae9..79b8245781 100644 --- a/cpp2rust/converter/models/converter_refcount.cpp +++ b/cpp2rust/converter/models/converter_refcount.cpp @@ -2022,11 +2022,12 @@ bool ConverterRefCount::VisitCXXNewExpr(clang::CXXNewExpr *expr) { StrCat(')'); } else if (auto *construct = GetArrayNewElementConstruct(ctx_, expr)) { PushBrace block(*this); - auto record_name = GetRecordName(construct->getConstructor()->getParent()); - StrCat(std::format( - "let __n = ({0}) as usize; let __p = Ptr::alloc_array((0..__n).map(|_| " - "<{1}>::zero_init()).collect::>());", - ToString(*expr->getArraySize()), record_name)); + auto record_name = + GetRecordName(construct->getConstructor()->getParent()); + StrCat(std::format("let __n = ({0}) as usize; let __p = " + "Ptr::alloc_array((0..__n).map(|_| " + "<{1}>::zero_init()).collect::>());", + ToString(*expr->getArraySize()), record_name)); StrCat("for __i in 0..__n"); { PushBrace loop(*this); @@ -2330,8 +2331,7 @@ ConverterRefCount::ConvertVarDefaultInit(const clang::VarDecl *decl) { return GetDefaultAsString(decl->getType()); } -std::string -ConverterRefCount::ConvertVarZeroInit(const clang::VarDecl *decl) { +std::string ConverterRefCount::ConvertVarZeroInit(const clang::VarDecl *decl) { PushConversionKind push(*this, VarConversionKind(decl)); return std::format("<{}>::zero_init()", ToString(decl->getType())); } From 5fffbb5db0c0199c491e874c7af6dedbee33e561 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Fri, 4 Dec 2026 20:58:30 +0000 Subject: [PATCH 12/14] Don't remove assert in release build --- cpp2rust/converter/converter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp2rust/converter/converter.cpp b/cpp2rust/converter/converter.cpp index b154118500..96e480569c 100644 --- a/cpp2rust/converter/converter.cpp +++ b/cpp2rust/converter/converter.cpp @@ -5499,7 +5499,7 @@ std::string Converter::GetDefaultAsString(clang::QualType qual_type) { if (auto *record = qual_type->getAsRecordDecl(); record && IsUserDefinedDecl(record)) { auto *cxx = clang::dyn_cast(record); - assert((!cxx || !cxx->hasDefaultConstructor() || + ENSURE((!cxx || !cxx->hasDefaultConstructor() || cxx->hasTrivialDefaultConstructor()) && "a non-trivial default constructor constructs into storage"); return std::format("{} {{ <{}>::zero_init() }}", keyword_unsafe_, From bdbd8260bb4dd00b12a28097f8e2e6c0479b8814 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Sat, 5 Dec 2026 10:45:40 +0000 Subject: [PATCH 13/14] Use Default for TriviallyDefaultInitializable --- cpp2rust/converter/converter.cpp | 13 ++++-- cpp2rust/converter/converter_lib.cpp | 5 ++ cpp2rust/converter/converter_lib.h | 2 + libcc2rs-macros/src/constructor.rs | 17 ++++++- rules/dirent/shim.rs | 12 ----- rules/ifaddrs/shim.rs | 8 +--- rules/ip/shim.rs | 16 +------ rules/netdb/shim.rs | 8 +--- rules/poll/shim.rs | 8 +--- rules/pwd/shim.rs | 8 +--- rules/socket/shim.rs | 46 +------------------ rules/stat/shim.rs | 4 +- rules/termios/shim.rs | 23 +--------- rules/time/shim.rs | 24 ++-------- .../out/refcount/cross_tu_tag_collision.rs | 2 +- .../out/unsafe/cross_tu_tag_collision.rs | 2 +- .../p16-default-argument-lambda-in-class.rs | 4 +- .../p16-default-argument-lambda-in-class.rs | 4 +- .../basic.link/out/refcount/basic.link.rs | 8 ++-- .../basic/basic.link/out/unsafe/basic.link.rs | 8 ++-- .../out/refcount/basic.scope.pdecl.rs | 2 +- .../out/refcount/basic.scope.scope.rs | 39 +++++++--------- .../out/unsafe/basic.scope.pdecl.rs | 2 +- .../out/unsafe/basic.scope.scope.rs | 20 ++++---- .../dcl.init.general-p6.2-padding-bits.rs | 40 ++++++++-------- .../dcl.init/out/refcount/dcl.init.general.rs | 25 ++++------ .../dcl.init.general-p6.2-padding-bits.rs | 35 ++++++-------- .../dcl.init/out/unsafe/dcl.init.general.rs | 25 ++++------ .../out/refcount/expr.mptr.oper.rs | 6 +-- .../out/unsafe/expr.mptr.oper.rs | 2 +- .../refcount/self_referencing_initializer.rs | 2 +- .../unsafe/self_referencing_initializer.rs | 2 +- tests/unit/out/refcount/05_new.rs | 4 +- tests/unit/out/refcount/anonymous-struct.rs | 4 +- tests/unit/out/refcount/anonymous-struct_c.rs | 10 ++-- tests/unit/out/refcount/anonymous_enum.rs | 2 +- tests/unit/out/refcount/anonymous_enum_c.rs | 2 +- tests/unit/out/refcount/array_const_init.rs | 6 +-- .../out/refcount/assignment_single_eval.rs | 4 +- tests/unit/out/refcount/c_struct.rs | 2 +- tests/unit/out/refcount/cast.rs | 6 +-- tests/unit/out/refcount/default.rs | 6 +-- tests/unit/out/refcount/default_in_statics.rs | 8 ++-- tests/unit/out/refcount/destructor.rs | 18 ++++---- .../out/refcount/enum_default_in_static.rs | 2 +- tests/unit/out/refcount/fft.rs | 10 ++-- tests/unit/out/refcount/field_aliasing.rs | 2 +- .../out/refcount/field_method_receiver.rs | 12 ++--- tests/unit/out/refcount/field_pointers.rs | 14 ++---- .../field_reinterpret_write_through.rs | 4 +- tests/unit/out/refcount/fn_ptr_cast.rs | 2 +- .../unit/out/refcount/function_overloading.rs | 4 +- .../out/refcount/goto_aggregate_default.rs | 2 +- tests/unit/out/refcount/huffman.rs | 2 +- .../refcount/immutable-deref-on-func-call.rs | 2 +- tests/unit/out/refcount/init.rs | 2 +- tests/unit/out/refcount/kruskal.rs | 2 +- .../refcount/libc_struct_without_default.rs | 2 +- .../refcount/local_anon_struct_collision.rs | 4 +- .../unit/out/refcount/memcpy_struct_bytes.rs | 2 +- .../out/refcount/memcpy_struct_layouts.rs | 10 ++-- tests/unit/out/refcount/new.rs | 2 +- tests/unit/out/refcount/new_struct.rs | 4 +- tests/unit/out/refcount/opaque_record_copy.rs | 2 +- .../operator_member_pointer_member.rs | 2 +- .../out/refcount/operator_other_member.rs | 2 +- tests/unit/out/refcount/overload_mangling.rs | 2 +- tests/unit/out/refcount/push_emplace_back.rs | 2 +- tests/unit/out/refcount/random.rs | 4 +- .../out/refcount/reinterpret_cast_ptr_cmp.rs | 4 +- .../out/refcount/reinterpret_cast_struct.rs | 2 +- tests/unit/out/refcount/return_move.rs | 2 +- .../refcount/self_referencing_initializer.rs | 8 ++-- tests/unit/out/refcount/static_local.rs | 4 +- .../unit/out/refcount/static_var_in_class.rs | 4 +- .../out/refcount/struct_2d_array_field.rs | 2 +- .../refcount/struct_member_array_adjacency.rs | 2 +- tests/unit/out/refcount/struct_ptr.rs | 2 +- .../refcount/tag_vs_identifier_collision.rs | 14 +++--- .../unit/out/refcount/typedef-anon-struct.rs | 2 +- .../out/refcount/unary_expr_or_type_trait.rs | 2 +- tests/unit/out/refcount/unboxed_records.rs | 4 +- .../out/refcount/union_addrof_external.rs | 2 +- tests/unit/out/refcount/union_basic.rs | 12 ++--- .../unit/out/refcount/union_cross_arm_cast.rs | 2 +- .../out/refcount/union_field_alignment.rs | 2 +- .../unit/out/refcount/union_memset_memcpy.rs | 2 +- tests/unit/out/refcount/union_nested.rs | 2 +- .../out/refcount/union_pointer_pun_address.rs | 2 +- .../union_pointer_pun_writethrough.rs | 2 +- .../out/refcount/union_struct_dual_use.rs | 4 +- .../out/refcount/union_tagged_many_arms.rs | 10 ++-- .../unit/out/refcount/union_tagged_simple.rs | 4 +- .../out/refcount/union_tagged_struct_arms.rs | 6 +-- .../refcount/union_void_ptr_sized_deref.rs | 2 +- tests/unit/out/refcount/unique_ptr.rs | 6 +-- tests/unit/out/refcount/va_arg_struct_ctx.rs | 4 +- tests/unit/out/unsafe/05_new.rs | 4 +- tests/unit/out/unsafe/anonymous-struct.rs | 4 +- tests/unit/out/unsafe/anonymous-struct_c.rs | 10 ++-- tests/unit/out/unsafe/anonymous_enum.rs | 2 +- tests/unit/out/unsafe/anonymous_enum_c.rs | 2 +- tests/unit/out/unsafe/array_const_init.rs | 6 +-- .../unit/out/unsafe/assignment_single_eval.rs | 4 +- tests/unit/out/unsafe/c_struct.rs | 2 +- tests/unit/out/unsafe/cast.rs | 6 +-- tests/unit/out/unsafe/default.rs | 6 +-- tests/unit/out/unsafe/default_in_statics.rs | 6 +-- tests/unit/out/unsafe/destructor.rs | 18 ++++---- .../unit/out/unsafe/enum_default_in_static.rs | 2 +- tests/unit/out/unsafe/fft.rs | 10 ++-- tests/unit/out/unsafe/field_aliasing.rs | 2 +- .../unit/out/unsafe/field_method_receiver.rs | 12 ++--- tests/unit/out/unsafe/field_pointers.rs | 8 ++-- .../unsafe/field_reinterpret_write_through.rs | 4 +- tests/unit/out/unsafe/fn_ptr_cast.rs | 2 +- tests/unit/out/unsafe/function_overloading.rs | 4 +- .../unit/out/unsafe/goto_aggregate_default.rs | 2 +- tests/unit/out/unsafe/huffman.rs | 2 +- .../unsafe/immutable-deref-on-func-call.rs | 2 +- tests/unit/out/unsafe/init.rs | 2 +- tests/unit/out/unsafe/kruskal.rs | 2 +- .../out/unsafe/libc_struct_without_default.rs | 2 +- .../out/unsafe/local_anon_struct_collision.rs | 4 +- tests/unit/out/unsafe/memcpy_struct_bytes.rs | 2 +- .../unit/out/unsafe/memcpy_struct_layouts.rs | 8 ++-- tests/unit/out/unsafe/new.rs | 2 +- tests/unit/out/unsafe/new_struct.rs | 4 +- tests/unit/out/unsafe/opaque_record_copy.rs | 2 +- .../unsafe/operator_member_pointer_member.rs | 2 +- .../unit/out/unsafe/operator_other_member.rs | 2 +- tests/unit/out/unsafe/overload_mangling.rs | 2 +- tests/unit/out/unsafe/push_emplace_back.rs | 2 +- tests/unit/out/unsafe/random.rs | 4 +- .../out/unsafe/reinterpret_cast_ptr_cmp.rs | 4 +- .../out/unsafe/reinterpret_cast_struct.rs | 2 +- tests/unit/out/unsafe/return_move.rs | 2 +- .../unsafe/self_referencing_initializer.rs | 8 ++-- tests/unit/out/unsafe/static_local.rs | 3 +- tests/unit/out/unsafe/static_var_in_class.rs | 4 +- .../unit/out/unsafe/struct_2d_array_field.rs | 2 +- .../unsafe/struct_member_array_adjacency.rs | 2 +- tests/unit/out/unsafe/struct_ptr.rs | 2 +- .../out/unsafe/tag_vs_identifier_collision.rs | 14 +++--- tests/unit/out/unsafe/typedef-anon-struct.rs | 2 +- .../out/unsafe/unary_expr_or_type_trait.rs | 2 +- tests/unit/out/unsafe/unboxed_records.rs | 4 +- .../unit/out/unsafe/union_addrof_external.rs | 2 +- tests/unit/out/unsafe/union_basic.rs | 8 ++-- tests/unit/out/unsafe/union_cross_arm_cast.rs | 2 +- .../unit/out/unsafe/union_field_alignment.rs | 2 +- tests/unit/out/unsafe/union_memset_memcpy.rs | 2 +- tests/unit/out/unsafe/union_nested.rs | 2 +- .../out/unsafe/union_pointer_pun_address.rs | 2 +- .../unsafe/union_pointer_pun_writethrough.rs | 2 +- .../unit/out/unsafe/union_struct_dual_use.rs | 4 +- .../unit/out/unsafe/union_tagged_many_arms.rs | 10 ++-- tests/unit/out/unsafe/union_tagged_simple.rs | 4 +- .../out/unsafe/union_tagged_struct_arms.rs | 6 +-- .../out/unsafe/union_void_ptr_sized_deref.rs | 2 +- tests/unit/out/unsafe/unique_ptr.rs | 6 +-- tests/unit/out/unsafe/va_arg_struct_ctx.rs | 4 +- 162 files changed, 411 insertions(+), 564 deletions(-) diff --git a/cpp2rust/converter/converter.cpp b/cpp2rust/converter/converter.cpp index 96e480569c..7a7de55051 100644 --- a/cpp2rust/converter/converter.cpp +++ b/cpp2rust/converter/converter.cpp @@ -640,8 +640,10 @@ void Converter::EmitHoistedDecl(clang::VarDecl *decl) { if (ConvertVarDeclSkipInit(decl)) { auto *record = decl->getType()->getAsRecordDecl(); StrCat(token::kAssign, - record && IsUserDefinedDecl(record) ? ConvertVarZeroInit(decl) - : ConvertVarDefaultInit(decl), + record && IsUserDefinedDecl(record) && + !IsTriviallyDefaultConstructible(record) + ? ConvertVarZeroInit(decl) + : ConvertVarDefaultInit(decl), token::kSemiColon); } } @@ -5502,6 +5504,10 @@ std::string Converter::GetDefaultAsString(clang::QualType qual_type) { ENSURE((!cxx || !cxx->hasDefaultConstructor() || cxx->hasTrivialDefaultConstructor()) && "a non-trivial default constructor constructs into storage"); + if (IsTriviallyDefaultConstructible(record)) { + return std::format("<{}>::default()", + ToString(qual_type.getUnqualifiedType())); + } return std::format("{} {{ <{}>::zero_init() }}", keyword_unsafe_, ToString(qual_type.getUnqualifiedType())); } @@ -6216,8 +6222,7 @@ void Converter::AddSpecialMemberDerives(const clang::RecordDecl *decl, provided_trait->refcount.name); } }; - auto *cxx = clang::dyn_cast(decl); - bool trivial_default = !cxx || cxx->hasTrivialDefaultConstructor(); + bool trivial_default = IsTriviallyDefaultConstructible(decl); if (trivial_default) { attrs.emplace_back(GetCopyOrMoveTraitName(kTriviallyDefaultConstructible)); } diff --git a/cpp2rust/converter/converter_lib.cpp b/cpp2rust/converter/converter_lib.cpp index 14b5ba2c2e..6069bc9f98 100644 --- a/cpp2rust/converter/converter_lib.cpp +++ b/cpp2rust/converter/converter_lib.cpp @@ -2809,6 +2809,11 @@ bool RefersToPointer(const clang::Stmt *stmt) { return std::ranges::any_of(GetAllVars(stmt), IsPointerVar); } +bool IsTriviallyDefaultConstructible(const clang::RecordDecl *decl) { + auto *cxx = clang::dyn_cast(decl); + return !cxx || cxx->hasTrivialDefaultConstructor(); +} + bool DefaultInitHasSideEffects(const clang::ASTContext &ctx, clang::QualType type) { auto *record = ctx.getBaseElementType(type)->getAsCXXRecordDecl(); diff --git a/cpp2rust/converter/converter_lib.h b/cpp2rust/converter/converter_lib.h index c95df6684c..e7e4364c3b 100644 --- a/cpp2rust/converter/converter_lib.h +++ b/cpp2rust/converter/converter_lib.h @@ -589,6 +589,8 @@ bool RefersToPointer(const clang::Stmt *stmt); bool DefaultInitHasSideEffects(const clang::ASTContext &ctx, clang::QualType type); +bool IsTriviallyDefaultConstructible(const clang::RecordDecl *decl); + bool ReferencesThis(const clang::Stmt *stmt); // Whether evaluating `stmt` reads a value from memory, e.g., a pointer. diff --git a/libcc2rs-macros/src/constructor.rs b/libcc2rs-macros/src/constructor.rs index eec3c20f48..95ca28d50f 100644 --- a/libcc2rs-macros/src/constructor.rs +++ b/libcc2rs-macros/src/constructor.rs @@ -42,8 +42,21 @@ pub fn expand_trivially_default_constructible(input: TokenStream, is_unsafe: boo } else { quote!(::libcc2rs::TriviallyDefaultConstructible) }; - let marker: TokenStream = - quote!(impl #impl_generics #tr for #name #ty_generics #where_clause {}).into(); + let zero_init = if is_unsafe { + quote!(unsafe { ::zero_init() }) + } else { + quote!(::zero_init()) + }; + let marker: TokenStream = quote! { + impl #impl_generics #tr for #name #ty_generics #where_clause {} + + impl #impl_generics ::std::default::Default for #name #ty_generics #where_clause { + fn default() -> Self { + #zero_init + } + } + } + .into(); impls.extend(marker); impls } diff --git a/rules/dirent/shim.rs b/rules/dirent/shim.rs index ae8f1cb6a1..e7fc0ece4b 100644 --- a/rules/dirent/shim.rs +++ b/rules/dirent/shim.rs @@ -26,18 +26,6 @@ pub struct Dirent { pub d_name: Box<[i8]>, } -impl Default for Dirent { - fn default() -> Self { - Self { - d_ino: 0, - d_off: 0, - d_reclen: 0, - d_type: 0, - d_name: vec![0i8; size_of_field!(::libc::dirent, d_name)].into_boxed_slice(), - } - } -} - impl Dirent { pub fn from_entry(ino: u64, name: &[u8], d_type: u8) -> Self { let mut de = Dirent { diff --git a/rules/ifaddrs/shim.rs b/rules/ifaddrs/shim.rs index f3f1c35480..7973888922 100644 --- a/rules/ifaddrs/shim.rs +++ b/rules/ifaddrs/shim.rs @@ -9,13 +9,7 @@ use crate::{ use std::mem::{offset_of, size_of}; #[derive( - Clone, - Default, - Record, - ByteRepr, - ZeroInitialization, - TriviallyDefaultConstructible, - TriviallyCopyable, + Clone, 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 782d43192e..38779b0967 100644 --- a/rules/ip/shim.rs +++ b/rules/ip/shim.rs @@ -5,13 +5,7 @@ use crate::TriviallyDefaultConstructible; use crate::{ByteRepr, Ptr, Record, TriviallyCopyable, ZeroInitialization}; #[derive( - Clone, - Default, - Record, - ByteRepr, - ZeroInitialization, - TriviallyDefaultConstructible, - TriviallyCopyable, + Clone, Record, ByteRepr, ZeroInitialization, TriviallyDefaultConstructible, TriviallyCopyable, )] #[byte_size(4)] pub struct InAddr { @@ -36,14 +30,6 @@ impl In6Addr { } } -impl Default for In6Addr { - fn default() -> Self { - Self { - s6_addr: vec![0u8; 16].into_boxed_slice(), - } - } -} - impl ByteRepr for ::libc::in_addr {} impl ByteRepr for ::libc::in6_addr {} diff --git a/rules/netdb/shim.rs b/rules/netdb/shim.rs index 3462fee9af..d0708d6ab2 100644 --- a/rules/netdb/shim.rs +++ b/rules/netdb/shim.rs @@ -6,13 +6,7 @@ use crate::{ByteRepr, Ptr, Record, Sockaddr, TriviallyCopyable, ZeroInitializati use std::mem::{offset_of, size_of}; #[derive( - Clone, - Default, - Record, - ByteRepr, - ZeroInitialization, - TriviallyDefaultConstructible, - TriviallyCopyable, + Clone, 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 61d6e8569f..f5b4edf61d 100644 --- a/rules/poll/shim.rs +++ b/rules/poll/shim.rs @@ -6,13 +6,7 @@ use crate::{ByteRepr, Record, TriviallyCopyable, ZeroInitialization}; use std::mem::{offset_of, size_of}; #[derive( - Clone, - Default, - Record, - ByteRepr, - ZeroInitialization, - TriviallyDefaultConstructible, - TriviallyCopyable, + Clone, 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 05d22c24e1..1aef9de3c4 100644 --- a/rules/pwd/shim.rs +++ b/rules/pwd/shim.rs @@ -6,13 +6,7 @@ use crate::{ByteRepr, Ptr, Record, TriviallyCopyable, ZeroInitialization}; use std::mem::{offset_of, size_of}; #[derive( - Clone, - Default, - Record, - ByteRepr, - ZeroInitialization, - TriviallyDefaultConstructible, - TriviallyCopyable, + Clone, 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 faed480f7c..dc6ad385c5 100644 --- a/rules/socket/shim.rs +++ b/rules/socket/shim.rs @@ -36,13 +36,7 @@ pub struct SockaddrIn { } #[derive( - Clone, - Default, - Record, - ByteRepr, - ZeroInitialization, - TriviallyDefaultConstructible, - TriviallyCopyable, + Clone, Record, ByteRepr, ZeroInitialization, TriviallyDefaultConstructible, TriviallyCopyable, )] #[byte_size(28)] pub struct SockaddrIn6 { @@ -197,44 +191,6 @@ impl SockaddrIn6 { } } -impl Default for Sockaddr { - fn default() -> Self { - Self { - sa_family: 0, - sa_data: vec![0i8; 14].into_boxed_slice(), - } - } -} - -impl Default for SockaddrIn { - fn default() -> Self { - Self { - sin_family: 0, - sin_port: 0, - sin_addr: InAddr::default(), - sin_zero: vec![0u8; 8].into_boxed_slice(), - } - } -} - -impl Default for SockaddrUn { - fn default() -> Self { - Self { - sun_family: 0, - sun_path: vec![0i8; 108].into_boxed_slice(), - } - } -} - -impl Default for SockaddrStorage { - fn default() -> Self { - Self { - ss_family: 0, - __pad: vec![0u8; 126].into_boxed_slice(), - } - } -} - impl ByteRepr for ::libc::sockaddr {} impl ByteRepr for ::libc::sockaddr_in {} impl ByteRepr for ::libc::sockaddr_in6 {} diff --git a/rules/stat/shim.rs b/rules/stat/shim.rs index 2643e8ec7a..cfea6f90d1 100644 --- a/rules/stat/shim.rs +++ b/rules/stat/shim.rs @@ -5,9 +5,7 @@ use crate::TriviallyDefaultConstructible; use crate::{ByteRepr, Record, TriviallyCopyable, ZeroInitialization}; use std::mem::{offset_of, size_of}; -#[derive( - Clone, Default, Record, ZeroInitialization, TriviallyDefaultConstructible, TriviallyCopyable, -)] +#[derive(Clone, 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 a5dfbc66cd..db114eb28f 100644 --- a/rules/termios/shim.rs +++ b/rules/termios/shim.rs @@ -31,21 +31,6 @@ pub struct Termios { pub c_ospeed: u32, } -impl Default for Termios { - fn default() -> Self { - Self { - c_iflag: 0, - c_oflag: 0, - c_cflag: 0, - c_lflag: 0, - c_line: 0, - c_cc: vec![0u8; 32].into_boxed_slice(), - c_ispeed: 0, - c_ospeed: 0, - } - } -} - impl Termios { #[allow(clippy::unnecessary_cast)] pub fn from_libc(t: &::libc::termios) -> Self { @@ -109,13 +94,7 @@ impl Termios { } #[derive( - Clone, - Default, - Record, - ByteRepr, - ZeroInitialization, - TriviallyDefaultConstructible, - TriviallyCopyable, + Clone, 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 c30e468c1f..88a4bc392e 100644 --- a/rules/time/shim.rs +++ b/rules/time/shim.rs @@ -6,13 +6,7 @@ use crate::{ByteRepr, Ptr, Record, TriviallyCopyable, ZeroInitialization}; use std::mem::{offset_of, size_of}; #[derive( - Clone, - Default, - Record, - ByteRepr, - ZeroInitialization, - TriviallyDefaultConstructible, - TriviallyCopyable, + Clone, Record, ByteRepr, ZeroInitialization, TriviallyDefaultConstructible, TriviallyCopyable, )] #[byte_size(size_of::<::libc::tm>())] pub struct Tm { @@ -75,13 +69,7 @@ impl Tm { } #[derive( - Clone, - Default, - Record, - ByteRepr, - ZeroInitialization, - TriviallyDefaultConstructible, - TriviallyCopyable, + Clone, Record, ByteRepr, ZeroInitialization, TriviallyDefaultConstructible, TriviallyCopyable, )] #[byte_size(size_of::<::libc::timeval>())] pub struct Timeval { @@ -92,13 +80,7 @@ pub struct Timeval { } #[derive( - Clone, - Default, - Record, - ByteRepr, - ZeroInitialization, - TriviallyDefaultConstructible, - TriviallyCopyable, + Clone, Record, ByteRepr, ZeroInitialization, TriviallyDefaultConstructible, TriviallyCopyable, )] #[byte_size(size_of::<::libc::timespec>())] pub struct Timespec { diff --git a/tests/multi-file/cross_tu_tag_collision/out/refcount/cross_tu_tag_collision.rs b/tests/multi-file/cross_tu_tag_collision/out/refcount/cross_tu_tag_collision.rs index 688b785051..ce984b7f41 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 @@ -23,7 +23,7 @@ pub struct widget { pub id: i32, } pub fn a_value_0() -> i32 { - let mut w: widget = { ::zero_init() }; + let mut w: widget = ::default(); w.id = 11; return w.id; } 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 324a56c295..1d2874c29f 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 @@ -20,7 +20,7 @@ pub struct widget { pub id: i32, } pub unsafe fn a_value_0() -> i32 { - let mut w: widget = unsafe { ::zero_init() }; + let mut w: widget = ::default(); w.id = 11; return w.id; } 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 a56c3cfe30..3cb5b1142e 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 @@ -164,7 +164,7 @@ pub fn main() { } fn main_0() -> i32 { assert!((ctorCount_0.with(|rc| *rc.borrow()) == 0)); - let x: Value = Rc::new(RefCell::new({ ::zero_init() })); + let x: Value = Rc::new(RefCell::new(::default())); ({ X::h( x.as_pointer(), @@ -182,7 +182,7 @@ fn main_0() -> i32 { return 0; } pub fn b_call_6() { - let x: Value = Rc::new(RefCell::new({ ::zero_init() })); + let x: Value = Rc::new(RefCell::new(::default())); ({ X::h( x.as_pointer(), 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 3b8785dde5..d99048ebe4 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 @@ -150,7 +150,7 @@ pub fn main() { } unsafe fn main_0() -> i32 { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut ctorCount_0)) == (0))); - let mut x: X = unsafe { ::zero_init() }; + let mut x: X = ::default(); (unsafe { X::h( &raw mut x, @@ -172,7 +172,7 @@ unsafe fn main_0() -> i32 { return 0; } pub unsafe fn b_call_6() { - let mut x: X = unsafe { ::zero_init() }; + let mut x: X = ::default(); (unsafe { X::h( &raw mut x, 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 b5ff7e17cf..5023ded136 100644 --- a/tests/std/basic/basic.link/out/refcount/basic.link.rs +++ b/tests/std/basic/basic.link/out/refcount/basic.link.rs @@ -54,7 +54,7 @@ impl anon_13 { } } thread_local!( - pub static anon_13: Value = Rc::new(RefCell::new({ ::zero_init() })); + pub static anon_13: Value = Rc::new(RefCell::new(::default())); ); pub fn test_14() { anon_13::whole(anon_13.with(|v| v.as_pointer())).write(5); @@ -141,7 +141,7 @@ thread_local!( pub static total_32: Value = Rc::new(RefCell::new(10)); ); pub fn test_33() { - let tally: Value = Rc::new(RefCell::new({ ::zero_init() })); + let tally: Value = Rc::new(RefCell::new(::default())); assert!((({ Tally_31::add(tally.as_pointer(), 1,) }) == 11)); assert!((({ add_in_b_34(1,) }) == 102)); assert!((total_32.with(|rc| *rc.borrow()) == 11)); @@ -359,7 +359,7 @@ impl anon_62 { } } thread_local!( - pub static anon_62: Value = Rc::new(RefCell::new({ ::zero_init() })); + pub static anon_62: Value = Rc::new(RefCell::new(::default())); ); pub fn set_whole_in_b_15(mut value: i32) { anon_62::whole(anon_62.with(|v| v.as_pointer())).write(value); @@ -450,7 +450,7 @@ thread_local!( pub static total_68: Value = Rc::new(RefCell::new(100)); ); pub fn add_in_b_34(mut amount: i32) -> i32 { - let tally: Value = Rc::new(RefCell::new({ ::zero_init() })); + let tally: Value = Rc::new(RefCell::new(::default())); return ({ Tally_67::add(tally.as_pointer(), amount) }); } 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 6ac0d83eb4..94d72cdcf7 100644 --- a/tests/std/basic/basic.link/out/unsafe/basic.link.rs +++ b/tests/std/basic/basic.link/out/unsafe/basic.link.rs @@ -51,7 +51,7 @@ pub union anon_13 { pub fraction: f32, } pub static mut anon_13: std::cell::LazyCell = - std::cell::LazyCell::new(|| unsafe { unsafe { ::zero_init() } }); + std::cell::LazyCell::new(|| unsafe { ::default() }); pub unsafe fn test_14() { (*std::cell::LazyCell::force_mut(&mut *&raw mut anon_13)).whole = 5; (unsafe { set_whole_in_b_15(6) }); @@ -126,7 +126,7 @@ impl Tally_31 { } pub static mut total_32: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 10 }); pub unsafe fn test_33() { - let mut tally: Tally_31 = unsafe { ::zero_init() }; + let mut tally: Tally_31 = ::default(); assert!(((unsafe { Tally_31::add(&raw mut tally, 1,) }) == (11))); assert!(((unsafe { add_in_b_34(1,) }) == (102))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut total_32)) == (11))); @@ -311,7 +311,7 @@ pub union anon_62 { pub fraction: f32, } pub static mut anon_62: std::cell::LazyCell = - std::cell::LazyCell::new(|| unsafe { unsafe { ::zero_init() } }); + std::cell::LazyCell::new(|| unsafe { ::default() }); pub unsafe fn set_whole_in_b_15(mut value: i32) { (*std::cell::LazyCell::force_mut(&mut *&raw mut anon_62)).whole = value; } @@ -386,7 +386,7 @@ impl Tally_67 { } pub static mut total_68: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 100 }); pub unsafe fn add_in_b_34(mut amount: i32) -> i32 { - let mut tally: Tally_67 = unsafe { ::zero_init() }; + let mut tally: Tally_67 = ::default(); return (unsafe { Tally_67::add(&raw mut tally, amount) }); } pub static mut balance_35: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 50 }); 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 d8c3cf728a..6a610fc542 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 @@ -47,7 +47,7 @@ pub fn test_1() { let mut outer: Ptr = (node.as_pointer()); { let node: Value = - >::zero_init(); + >::default(); *node.borrow_mut() = p1_own_address_in_initializer_SelfLinked { next: (node.as_pointer()), value: 7, 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 19a6cb5df8..45ffc0d373 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 @@ -74,10 +74,9 @@ pub fn test_5() { assert!(((p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum_Size_small as i32) == 3)); assert!(((p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum_Size_large as i32) == 8)); assert!(((p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum_Size_large as i32) == 8)); - let object: Value = - Rc::new(RefCell::new({ - ::zero_init() - })); + let object: Value = Rc::new( + RefCell::new(::default()), + ); assert!( (({ p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum::scale(object.as_pointer(), 2) @@ -141,7 +140,7 @@ impl anon_8 { } } thread_local!( - pub static anon_8: Value = Rc::new(RefCell::new({ ::zero_init() })); + pub static anon_8: Value = Rc::new(RefCell::new(::default())); ); #[derive( VaArg, @@ -197,10 +196,9 @@ pub fn test_10() { assert!(((anon_8::namespace_count(anon_8.with(|v| v.as_pointer())).read()) == 4)); anon_8::namespace_ratio(anon_8.with(|v| v.as_pointer())).write(0.25_f64); assert!(((anon_8::namespace_ratio(anon_8.with(|v| v.as_pointer())).read()) == 0.25_f64)); - let object: Value = - Rc::new(RefCell::new({ - ::zero_init() - })); + let object: Value = Rc::new( + RefCell::new(::default()), + ); (*object.borrow_mut()).tag = 1; anon_9::member_count(field_ptr!(object.as_pointer(), anon_9)).write(6); assert!(((anon_9::member_count(field_ptr!(object.as_pointer(), anon_9)).read()) == 6)); @@ -214,7 +212,7 @@ pub fn test_10() { anon_9::member_ratio(field_ptr!(object.as_pointer(), anon_9)).write(0.5_f64); assert!(((anon_9::member_ratio(field_ptr!(object.as_pointer(), anon_9)).read()) == 0.5_f64)); assert!(({ (*object.borrow()).tag } == 1)); - let anon_11: Value = Rc::new(RefCell::new({ ::zero_init() })); + let anon_11: Value = Rc::new(RefCell::new(::default())); anon_11::block_count(anon_11.as_pointer()).write(9); assert!(((anon_11::block_count(anon_11.as_pointer()).read()) == 9)); anon_11::block_ratio(anon_11.as_pointer()).write(0.75_f64); @@ -399,10 +397,9 @@ impl p3_2_ref_qualified_members_are_distinct_HasRefQualifiedOverloads { } } pub fn test_18() { - let object: Value = - Rc::new(RefCell::new({ - ::zero_init() - })); + let object: Value = Rc::new( + RefCell::new(::default()), + ); assert!( (({ p3_2_ref_qualified_members_are_distinct_HasRefQualifiedOverloads::get_1( @@ -415,9 +412,9 @@ pub fn test_18() { assert!( (({ p3_2_ref_qualified_members_are_distinct_HasRefQualifiedOverloads::get_2( - Rc::new(RefCell::new({ - ::zero_init() - })) + Rc::new(RefCell::new( + ::default(), + )) .as_pointer(), ) }) == 4) @@ -533,11 +530,7 @@ impl p3_4_ref_qualified_member_templates_are_distinct_HasRefQualifiedTemplateOve } } pub fn test_22() { - let object: Value< - p3_4_ref_qualified_member_templates_are_distinct_HasRefQualifiedTemplateOverloads, - > = Rc::new(RefCell::new({ - ::zero_init() - })); + let object : Value = Rc::new(RefCell::new(::default() )) ; assert!( (({ p3_4_ref_qualified_member_templates_are_distinct_HasRefQualifiedTemplateOverloads :: get_1_int ( object .as_pointer() , 10 , ) @@ -547,7 +540,7 @@ pub fn test_22() { assert!((rvalue_calls_21.with(|rc| *rc.borrow()) == 0)); assert!( (({ - p3_4_ref_qualified_member_templates_are_distinct_HasRefQualifiedTemplateOverloads :: get_2_int ( Rc::new(RefCell::new( { ::zero_init() } )).as_pointer() , 10 , ) + p3_4_ref_qualified_member_templates_are_distinct_HasRefQualifiedTemplateOverloads :: get_2_int ( Rc::new(RefCell::new(::default() )).as_pointer() , 10 , ) }) == 14) ); assert!((lvalue_calls_20.with(|rc| *rc.borrow()) == 1)); 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 53eba697a8..6effd98287 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 @@ -44,7 +44,7 @@ pub unsafe fn test_1() { (&mut node as *mut p1_own_address_in_initializer_SelfLinked); { let mut node: p1_own_address_in_initializer_SelfLinked = - unsafe { ::zero_init() }; + ::default(); node = p1_own_address_in_initializer_SelfLinked { next: (&mut node as *mut p1_own_address_in_initializer_SelfLinked), value: 7, 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 be87d8c08c..07e4dad65e 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 @@ -70,7 +70,7 @@ pub unsafe fn test_5() { assert!(((p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum_Size_large as i32) == (8))); assert!(((p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum_Size_large as i32) == (8))); let mut object: p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum = - unsafe { ::zero_init() }; + ::default(); assert!( ((unsafe { p2_11_unscoped_enumerator_in_both_scopes_HasUnscopedEnum::scale(&raw const object, 2) @@ -120,7 +120,7 @@ pub union anon_8 { pub namespace_ratio: f64, } pub static mut anon_8: std::cell::LazyCell = - std::cell::LazyCell::new(|| unsafe { unsafe { ::zero_init() } }); + std::cell::LazyCell::new(|| unsafe { ::default() }); #[repr(C)] #[derive( Copy, @@ -164,7 +164,7 @@ pub unsafe fn test_10() { (((*std::cell::LazyCell::force_mut(&mut *&raw mut anon_8)).namespace_ratio) == (0.25_f64)) ); let mut object: p2_13_anonymous_union_members_in_parent_scope_HasAnonymousUnion = - unsafe { ::zero_init() }; + ::default(); object.tag = 1; object.anon_9.member_count = 6; assert!(((object.anon_9.member_count) == (6))); @@ -178,7 +178,7 @@ pub unsafe fn test_10() { object.anon_9.member_ratio = 0.5_f64; assert!(((object.anon_9.member_ratio) == (0.5_f64))); assert!(((object.tag) == (1))); - let mut anon_11: anon_11 = unsafe { ::zero_init() }; + let mut anon_11: anon_11 = ::default(); anon_11.block_count = 9; assert!(((anon_11.block_count) == (9))); anon_11.block_ratio = 0.75_f64; @@ -336,7 +336,7 @@ impl p3_2_ref_qualified_members_are_distinct_HasRefQualifiedOverloads { } pub unsafe fn test_18() { let mut object: p3_2_ref_qualified_members_are_distinct_HasRefQualifiedOverloads = - unsafe { ::zero_init() }; + ::default(); assert!( ((unsafe { p3_2_ref_qualified_members_are_distinct_HasRefQualifiedOverloads::get_1(&raw mut object) @@ -346,9 +346,9 @@ pub unsafe fn test_18() { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut rvalue_calls_17)) == (0))); assert!( ((unsafe { - p3_2_ref_qualified_members_are_distinct_HasRefQualifiedOverloads::get_2(&mut unsafe { - ::zero_init() - }) + p3_2_ref_qualified_members_are_distinct_HasRefQualifiedOverloads::get_2( + &mut ::default(), + ) }) == (4)) ); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut lvalue_calls_16)) == (1))); @@ -448,7 +448,7 @@ impl p3_4_ref_qualified_member_templates_are_distinct_HasRefQualifiedTemplateOve } } pub unsafe fn test_22() { - let mut object : p3_4_ref_qualified_member_templates_are_distinct_HasRefQualifiedTemplateOverloads = unsafe { ::zero_init() } ; + let mut object : p3_4_ref_qualified_member_templates_are_distinct_HasRefQualifiedTemplateOverloads = ::default() ; assert!( ((unsafe { p3_4_ref_qualified_member_templates_are_distinct_HasRefQualifiedTemplateOverloads :: get_1_int ( &raw mut object , 10 , ) @@ -458,7 +458,7 @@ pub unsafe fn test_22() { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut rvalue_calls_21)) == (0))); assert!( ((unsafe { - p3_4_ref_qualified_member_templates_are_distinct_HasRefQualifiedTemplateOverloads :: get_2_int ( &mut unsafe { ::zero_init() } , 10 , ) + p3_4_ref_qualified_member_templates_are_distinct_HasRefQualifiedTemplateOverloads :: get_2_int ( &mut ::default() , 10 , ) }) == (14)) ); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut lvalue_calls_20)) == (1))); 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 ff442ebdfb..fa920d0aec 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 @@ -70,28 +70,25 @@ pub struct p6_2_zero_initialized_padding_HoldsPadded { pub small: i16, } thread_local!( - pub static static_padded_0: Value = - Rc::new(RefCell::new({ - ::zero_init() - })); + pub static static_padded_0: Value = Rc::new( + RefCell::new(::default()), + ); ); thread_local!( - pub static static_tail_padded_1: Value = - Rc::new(RefCell::new({ - ::zero_init() - })); + pub static static_tail_padded_1: Value = Rc::new( + RefCell::new(::default()), + ); ); thread_local!( - pub static static_holds_padded_2: Value = - Rc::new(RefCell::new({ - ::zero_init() - })); + pub static static_holds_padded_2: Value = Rc::new( + RefCell::new(::default()), + ); ); thread_local!( pub static static_padded_array_3: Value> = Rc::new(RefCell::new( (0..2) - .map(|_| ::zero_init()) + .map(|_| ::default()) .collect::>(), )); ); @@ -131,19 +128,18 @@ pub fn test_5() { (16usize as u64), ) }); - let value_padded: Value = Rc::new(RefCell::new({ - ::zero_init() - })); + let value_padded: Value = Rc::new(RefCell::new( + ::default(), + )); ({ check_zero_bytes_4( (value_padded.as_pointer()).reinterpret_cast::(), (8usize as u64), ) }); - let value_holds_padded: Value = - Rc::new(RefCell::new({ - ::zero_init() - })); + let value_holds_padded: Value = Rc::new( + RefCell::new(::default()), + ); ({ check_zero_bytes_4( (value_holds_padded.as_pointer()).reinterpret_cast::(), @@ -151,11 +147,11 @@ pub fn test_5() { ) }); let mut heap_padded: Ptr = - Ptr::alloc({ ::zero_init() }); + Ptr::alloc(::default()); ({ check_zero_bytes_4(heap_padded.reinterpret_cast::(), (8usize as u64)) }); heap_padded.delete(); let mut heap_tail_padded: Ptr = - Ptr::alloc({ ::zero_init() }); + Ptr::alloc(::default()); ({ check_zero_bytes_4(heap_tail_padded.reinterpret_cast::(), (8usize as u64)) }); heap_tail_padded.delete(); } 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 8bc75fba85..2a45940fda 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 @@ -68,7 +68,7 @@ pub fn test_1() { ) as isize)) ); let mut holder: p6_1_zero_initialized_pointer_to_member_HoldsSelector = - { ::zero_init() }; + ::default(); assert!((holder.selector).is_null()); assert!( (holder.selector @@ -188,9 +188,8 @@ pub struct p6_2_zero_initialized_class_Outer { pub inners: Box<[p6_2_zero_initialized_class_Inner]>, } thread_local!( - pub static static_outer_13: Value = Rc::new(RefCell::new({ - ::zero_init() - })); + pub static static_outer_13: Value = + Rc::new(RefCell::new(::default())); ); pub fn check_14(outer: Ptr) { assert!(((outer.with(|__s| __s.letter) as i32) == (('\0' as i8) as i32))); @@ -220,12 +219,11 @@ pub fn check_14(outer: Ptr) { } pub fn test_15() { ({ check_14(static_outer_13.with(|v| v.as_pointer())) }); - let value_outer: Value = Rc::new(RefCell::new({ - ::zero_init() - })); + let value_outer: Value = + Rc::new(RefCell::new(::default())); ({ check_14(value_outer.as_pointer()) }); let mut heap_outer: Ptr = - Ptr::alloc({ ::zero_init() }); + Ptr::alloc(::default()); ({ check_14((heap_outer).clone()) }); heap_outer.delete(); } @@ -255,9 +253,7 @@ impl p6_3_zero_initialized_union_Number { } thread_local!( pub static static_number_16: Value = - Rc::new(RefCell::new({ - ::zero_init() - })); + Rc::new(RefCell::new(::default())); ); pub fn test_17() { assert!( @@ -265,9 +261,8 @@ pub fn test_17() { .read()) == 0) ); - let value_number: Value = Rc::new(RefCell::new({ - ::zero_init() - })); + let value_number: Value = + Rc::new(RefCell::new(::default())); assert!(((p6_3_zero_initialized_union_Number::integer(value_number.as_pointer()).read()) == 0)); } #[derive( @@ -305,7 +300,7 @@ thread_local!( pub static static_pairs_20: Value> = Rc::new(RefCell::new( (0..2) - .map(|_| ::zero_init()) + .map(|_| ::default()) .collect::>(), )); ); 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 01248ef864..eef227dd5e 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 @@ -56,23 +56,15 @@ pub struct p6_2_zero_initialized_padding_HoldsPadded { pub small: i16, } pub static mut static_padded_0: std::cell::LazyCell = - std::cell::LazyCell::new(|| unsafe { - unsafe { ::zero_init() } - }); + std::cell::LazyCell::new(|| unsafe { ::default() }); pub static mut static_tail_padded_1: std::cell::LazyCell = - std::cell::LazyCell::new(|| unsafe { - unsafe { ::zero_init() } - }); + std::cell::LazyCell::new(|| unsafe { ::default() }); pub static mut static_holds_padded_2: std::cell::LazyCell< p6_2_zero_initialized_padding_HoldsPadded, -> = std::cell::LazyCell::new(|| unsafe { - unsafe { ::zero_init() } -}); +> = std::cell::LazyCell::new(|| unsafe { ::default() }); pub static mut static_padded_array_3: std::cell::LazyCell< [p6_2_zero_initialized_padding_Padded; 2], -> = std::cell::LazyCell::new(|| unsafe { - [unsafe { ::zero_init() }; 2] -}); +> = std::cell::LazyCell::new(|| unsafe { [::default(); 2] }); pub unsafe fn check_zero_bytes_4(mut bytes: *const u8, mut size: u64) { { let mut i: u64 = 0_u64; @@ -115,7 +107,7 @@ pub unsafe fn test_5() { check_zero_bytes_4(_bytes, _size) }); let mut value_padded: p6_2_zero_initialized_padding_Padded = - unsafe { ::zero_init() }; + ::default(); (unsafe { check_zero_bytes_4( ((&mut value_padded as *mut p6_2_zero_initialized_padding_Padded) as *const u8), @@ -123,7 +115,7 @@ pub unsafe fn test_5() { ) }); let mut value_holds_padded: p6_2_zero_initialized_padding_HoldsPadded = - unsafe { ::zero_init() }; + ::default(); (unsafe { check_zero_bytes_4( ((&mut value_holds_padded as *mut p6_2_zero_initialized_padding_HoldsPadded) @@ -131,10 +123,9 @@ pub unsafe fn test_5() { (::std::mem::size_of::() as u64), ) }); - let mut heap_padded: *mut p6_2_zero_initialized_padding_Padded = (Box::leak(Box::new(unsafe { - ::zero_init() - })) - as *mut p6_2_zero_initialized_padding_Padded); + let mut heap_padded: *mut p6_2_zero_initialized_padding_Padded = + (Box::leak(Box::new(::default())) + as *mut p6_2_zero_initialized_padding_Padded); (unsafe { check_zero_bytes_4( (heap_padded as *const u8), @@ -147,10 +138,10 @@ pub unsafe fn test_5() { ::std::mem::drop(Box::from_raw(__p)) } }; - let mut heap_tail_padded: *mut p6_2_zero_initialized_padding_TailPadded = - (Box::leak(Box::new(unsafe { - ::zero_init() - })) as *mut p6_2_zero_initialized_padding_TailPadded); + let mut heap_tail_padded: *mut p6_2_zero_initialized_padding_TailPadded = (Box::leak(Box::new( + ::default(), + )) + as *mut p6_2_zero_initialized_padding_TailPadded); (unsafe { check_zero_bytes_4( (heap_tail_padded as *const u8), 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 ac96f457df..0fba58047c 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 @@ -58,7 +58,7 @@ pub unsafe fn test_1() { ) as isize))) ); let mut holder: p6_1_zero_initialized_pointer_to_member_HoldsSelector = - unsafe { ::zero_init() }; + ::default(); assert!((holder.selector).is_null()); assert!( ((holder.selector) @@ -163,9 +163,7 @@ pub struct p6_2_zero_initialized_class_Outer { pub inners: [p6_2_zero_initialized_class_Inner; 2], } pub static mut static_outer_13: std::cell::LazyCell = - std::cell::LazyCell::new(|| unsafe { - unsafe { ::zero_init() } - }); + std::cell::LazyCell::new(|| unsafe { ::default() }); pub unsafe fn check_14(outer: *const p6_2_zero_initialized_class_Outer) { assert!((((*outer).letter as i32) == (('\0' as libc::c_char) as i32))); assert!((((*outer).inner.number) == (0))); @@ -195,12 +193,11 @@ pub unsafe fn check_14(outer: *const p6_2_zero_initialized_class_Outer) { pub unsafe fn test_15() { (unsafe { check_14(&(*std::cell::LazyCell::force_mut(&mut *&raw mut static_outer_13))) }); let mut value_outer: p6_2_zero_initialized_class_Outer = - unsafe { ::zero_init() }; + ::default(); (unsafe { check_14(&value_outer) }); - let mut heap_outer: *mut p6_2_zero_initialized_class_Outer = (Box::leak(Box::new(unsafe { - ::zero_init() - })) - as *mut p6_2_zero_initialized_class_Outer); + let mut heap_outer: *mut p6_2_zero_initialized_class_Outer = + (Box::leak(Box::new(::default())) + as *mut p6_2_zero_initialized_class_Outer); (unsafe { check_14(&(*heap_outer)) }); { let __p = heap_outer; @@ -224,13 +221,11 @@ pub union p6_3_zero_initialized_union_Number { pub bytes: [libc::c_char; 8], } pub static mut static_number_16: std::cell::LazyCell = - std::cell::LazyCell::new(|| unsafe { - unsafe { ::zero_init() } - }); + std::cell::LazyCell::new(|| unsafe { ::default() }); pub unsafe fn test_17() { assert!((((*std::cell::LazyCell::force_mut(&mut *&raw mut static_number_16)).integer) == (0))); let mut value_number: p6_3_zero_initialized_union_Number = - unsafe { ::zero_init() }; + ::default(); assert!(((value_number.integer) == (0))); } #[repr(C)] @@ -254,9 +249,7 @@ pub static mut static_numbers_18: std::cell::LazyCell<[i32; 4]> = pub static mut static_matrix_19: std::cell::LazyCell<[[i32; 3]; 2]> = std::cell::LazyCell::new(|| unsafe { [[0_i32; 3]; 2] }); pub static mut static_pairs_20: std::cell::LazyCell<[p6_4_zero_initialized_array_Pair; 2]> = - std::cell::LazyCell::new(|| unsafe { - [unsafe { ::zero_init() }; 2] - }); + std::cell::LazyCell::new(|| unsafe { [::default(); 2] }); pub unsafe fn test_21() { { let mut i: i32 = 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 4ee9ee7055..49ac296e45 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 @@ -194,9 +194,9 @@ pub fn test_11() { p6_data_member_of_rvalue_is_xvalue_HoldsCounted, member ) as isize); - let holder: Value = Rc::new(RefCell::new({ - ::zero_init() - })); + let holder: Value = Rc::new(RefCell::new( + ::default(), + )); object!( from_lvalue, p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves::constructor_2(LvalueRef::bind( 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 055ae7785f..9839cf4287 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 @@ -180,7 +180,7 @@ pub unsafe fn test_11() { member ) as isize); let mut holder: p6_data_member_of_rvalue_is_xvalue_HoldsCounted = - unsafe { ::zero_init() }; + ::default(); object_unsafe!( from_lvalue, p6_data_member_of_rvalue_is_xvalue_CountsCopiesAndMoves::constructor_2( diff --git a/tests/ub/out/refcount/self_referencing_initializer.rs b/tests/ub/out/refcount/self_referencing_initializer.rs index 3ff172336e..4820a231ab 100644 --- a/tests/ub/out/refcount/self_referencing_initializer.rs +++ b/tests/ub/out/refcount/self_referencing_initializer.rs @@ -33,7 +33,7 @@ pub fn main() { fn main_0() -> i32 { let mut x: i32 = 0_i32; x = (x + 1); - let mut p: pair = ::zero_init(); + let mut p: pair = ::default(); p = pair { a: 1, b: (p.a + 1) }; return (x + p.b); } diff --git a/tests/ub/out/unsafe/self_referencing_initializer.rs b/tests/ub/out/unsafe/self_referencing_initializer.rs index 4c621eed7a..c3e6a08ba0 100644 --- a/tests/ub/out/unsafe/self_referencing_initializer.rs +++ b/tests/ub/out/unsafe/self_referencing_initializer.rs @@ -31,7 +31,7 @@ pub fn main() { unsafe fn main_0() -> i32 { let mut x: i32 = 0_i32; x = ((x) + (1)); - let mut p: pair = unsafe { ::zero_init() }; + let mut p: pair = ::default(); p = pair { a: 1, b: ((p.a) + (1)), diff --git a/tests/unit/out/refcount/05_new.rs b/tests/unit/out/refcount/05_new.rs index 71aec2675c..0105521efb 100644 --- a/tests/unit/out/refcount/05_new.rs +++ b/tests/unit/out/refcount/05_new.rs @@ -52,8 +52,8 @@ fn main_0() -> i32 { let mut c: Ptr = Ptr::alloc(3); c.delete(); D::operator_call( - Rc::new(RefCell::new({ ::zero_init() })).as_pointer(), - Ptr::alloc({ ::zero_init() }), + Rc::new(RefCell::new(::default())).as_pointer(), + Ptr::alloc(::default()), ); return 0; } diff --git a/tests/unit/out/refcount/anonymous-struct.rs b/tests/unit/out/refcount/anonymous-struct.rs index 6c891512a0..4662b44c8c 100644 --- a/tests/unit/out/refcount/anonymous-struct.rs +++ b/tests/unit/out/refcount/anonymous-struct.rs @@ -182,7 +182,7 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let mut o: Outer = { ::zero_init() }; + let mut o: Outer = ::default(); o.named.a = 1; o.named.b = 2; o.anonymous_named_0.c = 3; @@ -205,7 +205,7 @@ fn main_0() -> i32 { assert!((o.anon_3.i == 9)); assert!((o.anon_3.inner_named.j == 10)); assert!((o.anon_3.anon_5.k == 11)); - let mut s: anon_6 = { ::zero_init() }; + let mut s: anon_6 = ::default(); s.x = 1; s.z = 2; assert!( diff --git a/tests/unit/out/refcount/anonymous-struct_c.rs b/tests/unit/out/refcount/anonymous-struct_c.rs index 8996cd9fd2..205dc692a2 100644 --- a/tests/unit/out/refcount/anonymous-struct_c.rs +++ b/tests/unit/out/refcount/anonymous-struct_c.rs @@ -168,10 +168,10 @@ pub fn main() { fn main_0() -> i32 { let mut o: Outer = Outer { named: Named { a: 0, b: 0_i32 }, - anon0: { ::zero_init() }, - anon1: { ::zero_init() }, - anon_2: { ::zero_init() }, - anon_3: { ::zero_init() }, + anon0: ::default(), + anon1: ::default(), + anon_2: ::default(), + anon_3: ::default(), }; o.named.a = 1; o.named.b = 2; @@ -195,7 +195,7 @@ fn main_0() -> i32 { assert!((o.anon_3.i == 9)); assert!((o.anon_3.inner_named.j == 10)); assert!((o.anon_3.anon_5.k == 11)); - let mut s: anon_6 = { ::zero_init() }; + let mut s: anon_6 = ::default(); s.x = 1; s.z = 2; assert!( diff --git a/tests/unit/out/refcount/anonymous_enum.rs b/tests/unit/out/refcount/anonymous_enum.rs index e7e125ee1d..7a5036af33 100644 --- a/tests/unit/out/refcount/anonymous_enum.rs +++ b/tests/unit/out/refcount/anonymous_enum.rs @@ -68,7 +68,7 @@ fn main_0() -> i32 { assert!(((td as i32) == (TdEnum_TD_A as i32))); td = TdEnum_TD_B; assert!(((td as i32) == (TdEnum_TD_B as i32))); - let mut w: WithAnonField = { ::zero_init() }; + let mut w: WithAnonField = ::default(); w.field = anon_2_FIELD_A; assert!(((w.field as i32) == (anon_2_FIELD_A as i32))); w.field = anon_2_FIELD_B; diff --git a/tests/unit/out/refcount/anonymous_enum_c.rs b/tests/unit/out/refcount/anonymous_enum_c.rs index b39692b8c0..312473f380 100644 --- a/tests/unit/out/refcount/anonymous_enum_c.rs +++ b/tests/unit/out/refcount/anonymous_enum_c.rs @@ -64,7 +64,7 @@ fn main_0() -> i32 { assert!(((td as u32) == ((TdEnum_enum_TD_A as i32) as u32))); td = TdEnum_enum_TD_B; assert!(((td as u32) == ((TdEnum_enum_TD_B as i32) as u32))); - let mut w: WithAnonField = { ::zero_init() }; + let mut w: WithAnonField = ::default(); w.field = anon_2_FIELD_A; assert!(((w.field as u32) == ((anon_2_FIELD_A as i32) as u32))); w.field = anon_2_FIELD_B; diff --git a/tests/unit/out/refcount/array_const_init.rs b/tests/unit/out/refcount/array_const_init.rs index f9876970ec..1b2d88afc6 100644 --- a/tests/unit/out/refcount/array_const_init.rs +++ b/tests/unit/out/refcount/array_const_init.rs @@ -128,9 +128,9 @@ fn main_0() -> i32 { assert!(((d[(0) as usize] == 0_f64) && (d[(3) as usize] == 0_f64))); let mut p: [P; 4] = [ P { x: 1, y: 2 }, - {

::zero_init() }, - {

::zero_init() }, - {

::zero_init() }, +

::default(), +

::default(), +

::default(), ]; assert!(((p[(0) as usize].x == 1) && (p[(0) as usize].y == 2))); assert!(((p[(3) as usize].x == 0) && (p[(3) as usize].y == 0))); diff --git a/tests/unit/out/refcount/assignment_single_eval.rs b/tests/unit/out/refcount/assignment_single_eval.rs index ea6ae5e5ad..d27ef271e1 100644 --- a/tests/unit/out/refcount/assignment_single_eval.rs +++ b/tests/unit/out/refcount/assignment_single_eval.rs @@ -1394,7 +1394,7 @@ pub fn test_borrows_29() { ) }) ); - let first: Value = >::zero_init(); + let first: Value = >::default(); *first.borrow_mut() = Link_33 { next: (first.as_pointer()), }; @@ -1523,7 +1523,7 @@ impl IndexedBinding { } } pub fn test_binding_35() { - let owner: Value = Rc::new(RefCell::new({ ::zero_init() })); + let owner: Value = Rc::new(RefCell::new(::default())); let __decomp_36: Ptr = owner.as_pointer(); let value: Ptr = ({ IndexedBinding::get_1_0((__decomp_36).clone()) }); let mut result: u32 = ({ diff --git a/tests/unit/out/refcount/c_struct.rs b/tests/unit/out/refcount/c_struct.rs index aa841850c8..e97f918020 100644 --- a/tests/unit/out/refcount/c_struct.rs +++ b/tests/unit/out/refcount/c_struct.rs @@ -142,7 +142,7 @@ fn main_0() -> i32 { assert!((c.inner.b == 6)); assert!(((c.color as u32) == ((Color_GREEN as i32) as u32))); assert!((c.count == 42)); - let mut c2: Container = { ::zero_init() }; + let mut c2: Container = ::default(); c2.color = Color_BLUE; assert!(((c2.color as u32) == 2_u32)); return 0; diff --git a/tests/unit/out/refcount/cast.rs b/tests/unit/out/refcount/cast.rs index 386e4c13d2..d7bfb31fc9 100644 --- a/tests/unit/out/refcount/cast.rs +++ b/tests/unit/out/refcount/cast.rs @@ -255,14 +255,14 @@ pub fn over_aligned_3() { let c: Value = Rc::new(RefCell::new(('c' as i8))); assert!(((c.as_pointer()).to_int() != 0_usize)); let w: Value> = Rc::new(RefCell::new( - (0..3).map(|_| ::zero_init()).collect::>(), + (0..3).map(|_| ::default()).collect::>(), )); let mut iw: usize = w.decay().to_int(); assert!(((iw as u64).wrapping_rem((64usize as u64)) == 0_u64)); assert!((((w.decay().offset(1)).to_int()).wrapping_sub(iw) == 64usize)); let mut h: Ptr = Ptr::alloc_array( (0..2_usize) - .map(|_| ::zero_init()) + .map(|_| ::default()) .collect::>(), ); assert!(((h.to_int() as u64).wrapping_rem((64usize as u64)) == 0_u64)); @@ -324,7 +324,7 @@ pub fn vector_capacity_4() { ); } pub fn nested_5() { - let g: Value = Rc::new(RefCell::new({ ::zero_init() })); + let g: Value = Rc::new(RefCell::new(::default())); let mut ig: usize = (g.as_pointer()).to_int(); assert!( ((array_field_ptr!(g.as_pointer(), row).offset((2) as isize)).to_int() diff --git a/tests/unit/out/refcount/default.rs b/tests/unit/out/refcount/default.rs index fc70582db2..356c6c8ac4 100644 --- a/tests/unit/out/refcount/default.rs +++ b/tests/unit/out/refcount/default.rs @@ -93,19 +93,19 @@ pub fn main() { fn main_0() -> i32 { let mut default_pointers: Ptr = Ptr::alloc_array( (0..10_usize) - .map(|_| ::zero_init()) + .map(|_| ::default()) .collect::>(), ); default_pointers.delete(); let mut small: Ptr = Ptr::alloc_array( (0..2_usize) - .map(|_| ::zero_init()) + .map(|_| ::default()) .collect::>(), ); small.delete(); let mut big: Ptr = Ptr::alloc_array( (0..2_usize) - .map(|_| ::zero_init()) + .map(|_| ::default()) .collect::>(), ); big.delete(); diff --git a/tests/unit/out/refcount/default_in_statics.rs b/tests/unit/out/refcount/default_in_statics.rs index 7a6c59c283..185016d08c 100644 --- a/tests/unit/out/refcount/default_in_statics.rs +++ b/tests/unit/out/refcount/default_in_statics.rs @@ -99,13 +99,11 @@ thread_local!( Rc::new(RefCell::new(FnPtr:: i32>::null())); ); thread_local!( - pub static static_outer_1: Value = Rc::new(RefCell::new({ ::zero_init() })); + pub static static_outer_1: Value = Rc::new(RefCell::new(::default())); ); thread_local!( pub static static_inner_array_2: Value> = Rc::new(RefCell::new( - (0..2) - .map(|_| ::zero_init()) - .collect::>(), + (0..2).map(|_| ::default()).collect::>(), )); ); thread_local!( @@ -142,7 +140,7 @@ pub fn check_local_static_5() { assert!(({ (*local_p_8.with(Value::clone).borrow()).is_null() })); } thread_local!( - static local_outer_6: Value = Rc::new(RefCell::new({ ::zero_init() })); + static local_outer_6: Value = Rc::new(RefCell::new(::default())); ); thread_local!( static local_fn_7: Value i32>> = diff --git a/tests/unit/out/refcount/destructor.rs b/tests/unit/out/refcount/destructor.rs index 445b535524..0d391fe2dc 100644 --- a/tests/unit/out/refcount/destructor.rs +++ b/tests/unit/out/refcount/destructor.rs @@ -314,46 +314,46 @@ pub fn main() { } fn main_0() -> i32 { { - let s: Value = Rc::new(RefCell::new({ ::zero_init() })); + let s: Value = Rc::new(RefCell::new(::default())); let _dtor_s = std::mem::DropGuard::new(s.clone(), |__p| Destructible::destroy(__p.as_pointer())); } assert!((global_0.with(|rc| *rc.borrow()) == 1)); { - let s: Value = Rc::new(RefCell::new({ ::zero_init() })); + let s: Value = Rc::new(RefCell::new(::default())); let _dtor_s = std::mem::DropGuard::new(s.clone(), |__p| Destructible::destroy(__p.as_pointer())); } assert!((global_0.with(|rc| *rc.borrow()) == 2)); { - let d: Value = Rc::new(RefCell::new({ ::zero_init() })); + let d: Value = Rc::new(RefCell::new(::default())); let _dtor_d = std::mem::DropGuard::new(d.clone(), |__p| Destructible::destroy(__p.as_pointer())); } assert!((global_0.with(|rc| *rc.borrow()) == 3)); { - let o: Value = Rc::new(RefCell::new({ ::zero_init() })); + let o: Value = Rc::new(RefCell::new(::default())); let _dtor_o = std::mem::DropGuard::new(o.clone(), |__p| Destructible::destroy(__p.as_pointer())); } assert!((global_0.with(|rc| *rc.borrow()) == 4)); { - let am: Value = Rc::new(RefCell::new({ ::zero_init() })); + let am: Value = Rc::new(RefCell::new(::default())); let _dtor_am = std::mem::DropGuard::new(am.clone(), |__p| Destructible::destroy(__p.as_pointer())); } assert!((global_0.with(|rc| *rc.borrow()) == 7)); { - let e: Value = Rc::new(RefCell::new({ ::zero_init() })); + let e: Value = Rc::new(RefCell::new(::default())); let _dtor_e = std::mem::DropGuard::new(e.clone(), |__p| Destructible::destroy(__p.as_pointer())); } assert!((global_0.with(|rc| *rc.borrow()) == 8)); { - let tc: Value = Rc::new(RefCell::new({ ::zero_init() })); + let tc: Value = Rc::new(RefCell::new(::default())); let _dtor_tc = std::mem::DropGuard::new(tc.clone(), |__p| Destructible::destroy(__p.as_pointer())); - let ti: Value = Rc::new(RefCell::new({ ::zero_init() })); + let ti: Value = Rc::new(RefCell::new(::default())); let _dtor_ti = std::mem::DropGuard::new(ti.clone(), |__p| Destructible::destroy(__p.as_pointer())); } @@ -400,7 +400,7 @@ fn main_0() -> i32 { ); let mut before: i32 = global_0.with(|rc| *rc.borrow()); { - let cs: Value = Rc::new(RefCell::new({ ::zero_init() })); + let cs: Value = Rc::new(RefCell::new(::default())); let _dtor_cs = std::mem::DropGuard::new(cs.clone(), |__p| Destructible::destroy(__p.as_pointer())); } diff --git a/tests/unit/out/refcount/enum_default_in_static.rs b/tests/unit/out/refcount/enum_default_in_static.rs index 29b50a2cac..237491803b 100644 --- a/tests/unit/out/refcount/enum_default_in_static.rs +++ b/tests/unit/out/refcount/enum_default_in_static.rs @@ -29,7 +29,7 @@ pub struct Config { pub mode: Mode, } thread_local!( - pub static config_0: Value = { >::zero_init() }; + pub static config_0: Value = >::default(); ); pub fn main() { __cpp2rust_init_globals(); diff --git a/tests/unit/out/refcount/fft.rs b/tests/unit/out/refcount/fft.rs index 579f54d9ca..18888cd669 100644 --- a/tests/unit/out/refcount/fft.rs +++ b/tests/unit/out/refcount/fft.rs @@ -50,7 +50,7 @@ pub fn Neg_2(mut z1: Complex) -> Complex { pub fn fft_3(a: Ptr>>>, mut N: i32) -> Option>> { let mut y: Option>> = Some(Rc::new(RefCell::new( (0..(N as usize)) - .map(|_| ::zero_init()) + .map(|_| ::default()) .collect::>(), ))); if (N == 1) { @@ -62,7 +62,7 @@ pub fn fft_3(a: Ptr>>>, mut N: i32) -> Option>> = Some(Rc::new(RefCell::new( (0..(N as usize)) - .map(|_| ::zero_init()) + .map(|_| ::default()) .collect::>(), ))); { @@ -83,13 +83,13 @@ pub fn fft_3(a: Ptr>>>, mut N: i32) -> Option>>> = Rc::new(RefCell::new(Some(Rc::new(RefCell::new( (0..((N / 2) as usize)) - .map(|_| ::zero_init()) + .map(|_| ::default()) .collect::>(), ))))); let A1: Value>>> = Rc::new(RefCell::new(Some(Rc::new(RefCell::new( (0..((N / 2) as usize)) - .map(|_| ::zero_init()) + .map(|_| ::default()) .collect::>(), ))))); { @@ -174,7 +174,7 @@ fn main_0() -> i32 { let a: Value>>> = Rc::new(RefCell::new(Some(Rc::new(RefCell::new( (0..(N as usize)) - .map(|_| ::zero_init()) + .map(|_| ::default()) .collect::>(), ))))); { diff --git a/tests/unit/out/refcount/field_aliasing.rs b/tests/unit/out/refcount/field_aliasing.rs index deb009dcd0..6ebf970f2e 100644 --- a/tests/unit/out/refcount/field_aliasing.rs +++ b/tests/unit/out/refcount/field_aliasing.rs @@ -91,7 +91,7 @@ fn main_0() -> i32 { && (q.with(|__s| __s.n) == 1)) ); libcc2rs::free_refcount((p).to_any()); - let s: Value = { >::zero_init() }; + let s: Value = >::default(); (*s.borrow_mut()).x = 1; (*s.borrow_mut()).self_ = (s.as_pointer()); field!({ (*s.borrow()).self_.clone() }, x).write(({ (*s.borrow()).x } + 1)); diff --git a/tests/unit/out/refcount/field_method_receiver.rs b/tests/unit/out/refcount/field_method_receiver.rs index 556af05fd7..ccf8ac4aaa 100644 --- a/tests/unit/out/refcount/field_method_receiver.rs +++ b/tests/unit/out/refcount/field_method_receiver.rs @@ -81,10 +81,10 @@ impl S { } pub fn constructor_1(this: Ptr) { field!(this, tag).write(0_i32); - field!(this, c).write({ ::zero_init() }); + field!(this, c).write(::default()); field!(this, arr).write( (0..2) - .map(|_| ::zero_init()) + .map(|_| ::default()) .collect::>(), ); field!(this, v).write(Vec::new()); @@ -131,16 +131,16 @@ pub fn main() { fn main_0() -> i32 { let local: Value = Rc::new(RefCell::new(S { tag: 0_i32, - c: { ::zero_init() }, - arr: Box::new([{ ::zero_init() }; 2]), + c: ::default(), + arr: Box::new([::default(); 2]), v: Vec::new(), })); (*local.borrow_mut()).tag = 1; ({ run_0((local.as_pointer())) }); let mut heap: Ptr = Ptr::alloc(S { tag: 0_i32, - c: { ::zero_init() }, - arr: Box::new([{ ::zero_init() }; 2]), + c: ::default(), + arr: Box::new([::default(); 2]), v: Vec::new(), }); field!(heap, tag).write(1); diff --git a/tests/unit/out/refcount/field_pointers.rs b/tests/unit/out/refcount/field_pointers.rs index 5ca76785a1..e3682ad936 100644 --- a/tests/unit/out/refcount/field_pointers.rs +++ b/tests/unit/out/refcount/field_pointers.rs @@ -100,12 +100,8 @@ impl Outer { } pub fn constructor_1(this: Ptr) { field!(this, x).write(0_i32); - field!(this, inner).write({ ::zero_init() }); - field!(this, items).write( - (0..3) - .map(|_| ::zero_init()) - .collect::>(), - ); + 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::>()); @@ -125,10 +121,8 @@ pub fn main() { fn main_0() -> i32 { let o: Value = Rc::new(RefCell::new(Outer { x: 0_i32, - inner: { ::zero_init() }, - items: Box::new([{ ::zero_init() }, { ::zero_init() }, { - ::zero_init() - }]), + inner: ::default(), + items: Box::new([::default(), ::default(), ::default()]), v: Vec::new(), cursor: Ptr::::null(), buf: Box::new([0; 4]), diff --git a/tests/unit/out/refcount/field_reinterpret_write_through.rs b/tests/unit/out/refcount/field_reinterpret_write_through.rs index 1023f7501f..6e3a110374 100644 --- a/tests/unit/out/refcount/field_reinterpret_write_through.rs +++ b/tests/unit/out/refcount/field_reinterpret_write_through.rs @@ -1104,7 +1104,7 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let local: Value = { >::zero_init() }; + let local: Value = >::default(); { let mut __tmp_3 = { (local.as_pointer()).to_any() }; __tmp_3.memset((0) as u8, 40usize); @@ -1112,7 +1112,7 @@ fn main_0() -> i32 { }; ({ check_struct_3((local.as_pointer())) }); let arr: Value> = Rc::new(RefCell::new( - (0..2).map(|_| ::zero_init()).collect::>(), + (0..2).map(|_| ::default()).collect::>(), )); { let mut __tmp_4 = { (arr.decay()).to_any() }; diff --git a/tests/unit/out/refcount/fn_ptr_cast.rs b/tests/unit/out/refcount/fn_ptr_cast.rs index 4b05e48407..631cb00da5 100644 --- a/tests/unit/out/refcount/fn_ptr_cast.rs +++ b/tests/unit/out/refcount/fn_ptr_cast.rs @@ -43,7 +43,7 @@ pub struct Command { pub data: AnyPtr, } pub fn test_void_ptr_to_fn_3() { - let mut cmd: Command = { ::zero_init() }; + let mut cmd: Command = ::default(); cmd.data = FnPtr:: i32>::new(double_it_0).to_any(); let mut fn_: FnPtr i32> = cmd .data diff --git a/tests/unit/out/refcount/function_overloading.rs b/tests/unit/out/refcount/function_overloading.rs index 3fcf08ec27..424003af47 100644 --- a/tests/unit/out/refcount/function_overloading.rs +++ b/tests/unit/out/refcount/function_overloading.rs @@ -64,8 +64,8 @@ fn main_0() -> i32 { out += ({ foo_2((x.as_pointer()), (x.as_pointer())) }); let mut bar: i32 = 5; out += ((bar + ({ foo_0(0) })) + ({ foo_1((x.as_pointer())) })); - let foo1: Value = Rc::new(RefCell::new({ ::zero_init() })); - let foo2: Value = Rc::new(RefCell::new({ ::zero_init() })); + let foo1: Value = Rc::new(RefCell::new(::default())); + let foo2: Value = Rc::new(RefCell::new(::default())); ({ Foo::foo_2(foo1.as_pointer()) }); ({ Foo::method_3(foo1.as_pointer(), 1) }); ({ Foo::foo_1(foo2.as_pointer()) }); diff --git a/tests/unit/out/refcount/goto_aggregate_default.rs b/tests/unit/out/refcount/goto_aggregate_default.rs index 5474d40a6b..4fd037fb82 100644 --- a/tests/unit/out/refcount/goto_aggregate_default.rs +++ b/tests/unit/out/refcount/goto_aggregate_default.rs @@ -29,7 +29,7 @@ pub fn agg_0(mut n: i32) -> i32 { let mut buf256: [u8; 256] = [0_u8; 256]; let mut arr64: [i32; 64] = [0_i32; 64]; let mut longs: [i64; 33] = [0_i64; 33]; - let mut p: Point = ::zero_init(); + let mut p: Point = ::default(); let mut ptr: Ptr = Ptr::::null(); let mut fp: FnPtr i32> = FnPtr:: i32>::null(); let mut file: Ptr = Ptr::null(); diff --git a/tests/unit/out/refcount/huffman.rs b/tests/unit/out/refcount/huffman.rs index 906d75d481..76cfddedf3 100644 --- a/tests/unit/out/refcount/huffman.rs +++ b/tests/unit/out/refcount/huffman.rs @@ -256,7 +256,7 @@ pub fn AllocMinHeap_1(mut capacity: i32) -> Option> { next: 0, alloc: Some(Rc::new(RefCell::new( (0..10000_usize) - .map(|_| ::zero_init()) + .map(|_| ::default()) .collect::>(), ))), }))); 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 c1dc46cb1f..1a06b317de 100644 --- a/tests/unit/out/refcount/immutable-deref-on-func-call.rs +++ b/tests/unit/out/refcount/immutable-deref-on-func-call.rs @@ -36,7 +36,7 @@ pub fn main() { fn main_0() -> i32 { let mut arr: Ptr = Ptr::alloc_array( (0..2_usize) - .map(|_| ::zero_init()) + .map(|_| ::default()) .collect::>(), ); field!(elem!(arr, 0), value).write(1); diff --git a/tests/unit/out/refcount/init.rs b/tests/unit/out/refcount/init.rs index e1c115c9ce..b95c246b56 100644 --- a/tests/unit/out/refcount/init.rs +++ b/tests/unit/out/refcount/init.rs @@ -37,7 +37,7 @@ fn main_0() -> i32 { let g: Ptr = x.as_pointer(); let mut q: Ptr = (x.as_pointer()); let mut z: Ptr = (p).clone(); - let xx: Value = Rc::new(RefCell::new({ ::zero_init() })); + let xx: Value = Rc::new(RefCell::new(::default())); let mut zz: Ptr = (xx.as_pointer()); (*xx.borrow_mut()).x = 1; q = (field_ptr!(xx.as_pointer(), x)); diff --git a/tests/unit/out/refcount/kruskal.rs b/tests/unit/out/refcount/kruskal.rs index 0c9565c60c..620da014e1 100644 --- a/tests/unit/out/refcount/kruskal.rs +++ b/tests/unit/out/refcount/kruskal.rs @@ -315,7 +315,7 @@ fn main_0() -> i32 { let graph: Value = Rc::new(RefCell::new(Graph { edges: Some(Rc::new(RefCell::new( (0..(E as usize)) - .map(|_| ::zero_init()) + .map(|_| ::default()) .collect::>(), ))), V: V, diff --git a/tests/unit/out/refcount/libc_struct_without_default.rs b/tests/unit/out/refcount/libc_struct_without_default.rs index 9bc59a7434..e229405084 100644 --- a/tests/unit/out/refcount/libc_struct_without_default.rs +++ b/tests/unit/out/refcount/libc_struct_without_default.rs @@ -87,7 +87,7 @@ fn main_0() -> i32 { 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) })); - let mut filt: FieldIsLibcType = { ::zero_init() }; + let mut filt: FieldIsLibcType = ::default(); filt.addr.sa_family = 2_u16; assert!(((filt.addr.sa_family as i32) == 2)); return 0; diff --git a/tests/unit/out/refcount/local_anon_struct_collision.rs b/tests/unit/out/refcount/local_anon_struct_collision.rs index 9f7cd960e3..72b6b3bdbd 100644 --- a/tests/unit/out/refcount/local_anon_struct_collision.rs +++ b/tests/unit/out/refcount/local_anon_struct_collision.rs @@ -7,7 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; pub fn first_0() -> i32 { - let mut p: anon_1 = { ::zero_init() }; + let mut p: anon_1 = ::default(); p.x = 1; p.y = 2; return (p.x + p.y); @@ -31,7 +31,7 @@ pub struct anon_1 { pub y: i32, } pub fn second_2() -> i32 { - let mut q: anon_3 = { ::zero_init() }; + let mut q: anon_3 = ::default(); q.a = 10_i64; q.b = 20_i64; return ((q.a + q.b) as i32); diff --git a/tests/unit/out/refcount/memcpy_struct_bytes.rs b/tests/unit/out/refcount/memcpy_struct_bytes.rs index 3195e30f26..cb7b6f9be8 100644 --- a/tests/unit/out/refcount/memcpy_struct_bytes.rs +++ b/tests/unit/out/refcount/memcpy_struct_bytes.rs @@ -39,7 +39,7 @@ fn main_0() -> i32 { ); (__tmp_0).clone() }; - let dst: Value = { >::zero_init() }; + let dst: Value = >::default(); { let mut __tmp_1 = { (dst.as_pointer()).to_any() }; __tmp_1.memcpy(&(buf.decay()).to_any(), 8usize); diff --git a/tests/unit/out/refcount/memcpy_struct_layouts.rs b/tests/unit/out/refcount/memcpy_struct_layouts.rs index 532e8aef04..113c244176 100644 --- a/tests/unit/out/refcount/memcpy_struct_layouts.rs +++ b/tests/unit/out/refcount/memcpy_struct_layouts.rs @@ -134,7 +134,7 @@ fn main_0() -> i32 { ); let p2: Value> = Rc::new(RefCell::new( (0..2) - .map(|_| ::zero_init()) + .map(|_| ::default()) .collect::>(), )); { @@ -170,7 +170,7 @@ fn main_0() -> i32 { ); let r2: Value> = Rc::new(RefCell::new( (0..2) - .map(|_| ::zero_init()) + .map(|_| ::default()) .collect::>(), )); { @@ -209,7 +209,7 @@ fn main_0() -> i32 { ); let n2: Value> = Rc::new(RefCell::new( (0..2) - .map(|_| ::zero_init()) + .map(|_| ::default()) .collect::>(), )); { @@ -244,9 +244,7 @@ fn main_0() -> i32 { }) ); let a2: Value> = Rc::new(RefCell::new( - (0..2) - .map(|_| ::zero_init()) - .collect::>(), + (0..2).map(|_| ::default()).collect::>(), )); { let mut __tmp_7 = { (a2.decay()).to_any() }; diff --git a/tests/unit/out/refcount/new.rs b/tests/unit/out/refcount/new.rs index ff2b8a6bd3..ffceefaded 100644 --- a/tests/unit/out/refcount/new.rs +++ b/tests/unit/out/refcount/new.rs @@ -39,7 +39,7 @@ fn main_0() -> i32 { y.write(9); assert!(((y.read()) == 9)); y.delete(); - let mut p: Ptr = Ptr::alloc({ ::zero_init() }); + let mut p: Ptr = Ptr::alloc(::default()); field!(p, x).write(1); field!(p, y).write(2); assert!((({ p.with(|__s| __s.x) } + { p.with(|__s| __s.y) }) == 3)); diff --git a/tests/unit/out/refcount/new_struct.rs b/tests/unit/out/refcount/new_struct.rs index 8d91ce9e8d..b25e2d9da2 100644 --- a/tests/unit/out/refcount/new_struct.rs +++ b/tests/unit/out/refcount/new_struct.rs @@ -61,7 +61,7 @@ fn main_0() -> i32 { let mut t: Triple = Triple { a: 1, b: 0_i32, - p: { ::zero_init() }, + p: ::default(), }; assert!((t.a == 1)); assert!((t.b == 0)); @@ -69,7 +69,7 @@ fn main_0() -> i32 { let mut q: Ptr = Ptr::alloc(Triple { a: 2, b: 3, - p: { ::zero_init() }, + p: ::default(), }); assert!((q.with(|__s| __s.a) == 2)); assert!((q.with(|__s| __s.b) == 3)); diff --git a/tests/unit/out/refcount/opaque_record_copy.rs b/tests/unit/out/refcount/opaque_record_copy.rs index e24ea35975..6e058b2071 100644 --- a/tests/unit/out/refcount/opaque_record_copy.rs +++ b/tests/unit/out/refcount/opaque_record_copy.rs @@ -47,7 +47,7 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let mut a: Wrapper_Probe_ = { ::zero_init() }; + let mut a: Wrapper_Probe_ = ::default(); a.tag = 3; let mut b: Wrapper_Probe_ = a; assert!((b.tag == 3)); diff --git a/tests/unit/out/refcount/operator_member_pointer_member.rs b/tests/unit/out/refcount/operator_member_pointer_member.rs index 3f949e7753..4b53598c39 100644 --- a/tests/unit/out/refcount/operator_member_pointer_member.rs +++ b/tests/unit/out/refcount/operator_member_pointer_member.rs @@ -109,7 +109,7 @@ fn main_0() -> i32 { assert!(((p.read()) == 1)); p.write(5); assert!(((array_elem!(s.as_pointer(), data, 0).read()) == 5)); - let t: Value

= Rc::new(RefCell::new({
::zero_init() })); + let t: Value
= Rc::new(RefCell::new(
::default())); assert!(((({ Table::operator_index(1,) }).read()) == 8)); ({ Table::operator_index(1) }).write(80); assert!( diff --git a/tests/unit/out/refcount/operator_other_member.rs b/tests/unit/out/refcount/operator_other_member.rs index df868eb6d4..65ba54a398 100644 --- a/tests/unit/out/refcount/operator_other_member.rs +++ b/tests/unit/out/refcount/operator_other_member.rs @@ -91,7 +91,7 @@ fn main_0() -> i32 { assert!(({ S::to_bool(s.as_pointer(),) })); assert!(!({ S::to_bool(z.as_pointer(),) })); assert!(({ S::to_bool(s.as_pointer(),) }) && (!({ S::to_bool(z.as_pointer(),) }))); - let st: Value = Rc::new(RefCell::new({ ::zero_init() })); + let st: Value = Rc::new(RefCell::new(::default())); assert!((({ Static::operator_call(6, 7,) }) == 42)); assert!((({ S::operator_call_1(Rc::new(RefCell::new(S { v: 5 })).as_pointer(),) }) == 5)); assert!((({ S::operator_call_3(Rc::new(RefCell::new(S { v: 5 })).as_pointer(), 1, 1,) }) == 7)); diff --git a/tests/unit/out/refcount/overload_mangling.rs b/tests/unit/out/refcount/overload_mangling.rs index 3d20ed0ebb..1217324453 100644 --- a/tests/unit/out/refcount/overload_mangling.rs +++ b/tests/unit/out/refcount/overload_mangling.rs @@ -235,7 +235,7 @@ fn main_0() -> i32 { }) == 107) ); assert!(({ ((*z.borrow()) == 6) })); - let a: Value = Rc::new(RefCell::new({ ::zero_init() })); + let a: Value = Rc::new(RefCell::new(::default())); let mut cs: Ptr = (s.as_pointer()); let cr: Ptr = s.as_pointer(); assert!((({ Access_S_::get_1(a.as_pointer(), (s.as_pointer()),) }) == 100)); diff --git a/tests/unit/out/refcount/push_emplace_back.rs b/tests/unit/out/refcount/push_emplace_back.rs index 5e541f4a09..63380659fc 100644 --- a/tests/unit/out/refcount/push_emplace_back.rs +++ b/tests/unit/out/refcount/push_emplace_back.rs @@ -533,7 +533,7 @@ fn main_0() -> i32 { let chunks: Value> = Rc::new(RefCell::new(Vec::new())); ({ shrink_through_ptr_2((chunks.as_pointer())) }); assert!(({ (*chunks.borrow()).is_empty() })); - let w: Value = Rc::new(RefCell::new({ ::zero_init() })); + let w: Value = Rc::new(RefCell::new(::default())); (*w.borrow_mut()).chunk.data = 42; (*w.borrow_mut()).output = (chunks.as_pointer()); ({ nested_push_move_3((w.as_pointer())) }); diff --git a/tests/unit/out/refcount/random.rs b/tests/unit/out/refcount/random.rs index 0a72f5471f..0f223cb7d3 100644 --- a/tests/unit/out/refcount/random.rs +++ b/tests/unit/out/refcount/random.rs @@ -257,8 +257,8 @@ fn main_0() -> i32 { (*y1.borrow_mut()).pair = (y2.as_pointer()); (*y2.borrow_mut()).pair = (y3.as_pointer()); ({ Pair::method({ (*y1.borrow()).pair.clone() }.with(|__s| __s.pair.clone())) }); - let mut x: X1 = { ::zero_init() }; - let mut y: X1 = { ::zero_init() }; + let mut x: X1 = ::default(); + let mut y: X1 = ::default(); let __rhs = (({ zero_0() }) + { (*y1.borrow()).x }); (*x1.borrow_mut()) = __rhs; let __rhs = (({ zero_0() }) + 5); diff --git a/tests/unit/out/refcount/reinterpret_cast_ptr_cmp.rs b/tests/unit/out/refcount/reinterpret_cast_ptr_cmp.rs index cdfeb100cc..07a4d606c9 100644 --- a/tests/unit/out/refcount/reinterpret_cast_ptr_cmp.rs +++ b/tests/unit/out/refcount/reinterpret_cast_ptr_cmp.rs @@ -70,7 +70,7 @@ pub struct P { pub arr: Box<[Ptr]>, } pub fn typed_0() { - let w: Value = Rc::new(RefCell::new({ ::zero_init() })); + let w: Value = Rc::new(RefCell::new(::default())); let mut p: Ptr = (array_field_ptr!(w.as_pointer(), arr).offset((2) as isize)); let mut q: Ptr = ((w.as_pointer()) .reinterpret_cast::() @@ -100,7 +100,7 @@ pub fn typed_0() { assert!(({ (ptrs.decay().offset(1)) } < { (f).clone() })); assert!(({ (f).clone() } < { (ptrs.decay().offset(3)) })); assert!((((f).clone() - ptrs.decay()) as i64 == 2_i64)); - let s: Value

= Rc::new(RefCell::new({

::zero_init() })); + let s: Value

= Rc::new(RefCell::new(

::default())); let mut a: Ptr> = (field_ptr!(s.as_pointer(), a)); let mut b: Ptr> = (array_field_ptr!(s.as_pointer(), arr).offset((1) as isize)); assert!(({ (a).clone() } < { (b).clone() })); diff --git a/tests/unit/out/refcount/reinterpret_cast_struct.rs b/tests/unit/out/refcount/reinterpret_cast_struct.rs index 8c749ecf85..717fa4a749 100644 --- a/tests/unit/out/refcount/reinterpret_cast_struct.rs +++ b/tests/unit/out/refcount/reinterpret_cast_struct.rs @@ -31,7 +31,7 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let p: Value = Rc::new(RefCell::new({ ::zero_init() })); + let p: Value = Rc::new(RefCell::new(::default())); (*p.borrow_mut()).x = 67305985; (*p.borrow_mut()).y = 134678021; let mut bytes: Ptr = (p.as_pointer()).reinterpret_cast::(); diff --git a/tests/unit/out/refcount/return_move.rs b/tests/unit/out/refcount/return_move.rs index 75f74d7ed3..1c32a27ffa 100644 --- a/tests/unit/out/refcount/return_move.rs +++ b/tests/unit/out/refcount/return_move.rs @@ -85,7 +85,7 @@ pub fn address_taken_8(n: Ptr) -> Ptr { }; } pub fn ret_struct_9(mut a: i32, mut n: Ptr) -> pair_t { - let mut p: pair_t = { ::zero_init() }; + let mut p: pair_t = ::default(); p.a = a; p.n = (n).clone(); return p; diff --git a/tests/unit/out/refcount/self_referencing_initializer.rs b/tests/unit/out/refcount/self_referencing_initializer.rs index 6248cb0ffa..8fbf64c23d 100644 --- a/tests/unit/out/refcount/self_referencing_initializer.rs +++ b/tests/unit/out/refcount/self_referencing_initializer.rs @@ -72,12 +72,12 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let list: Value = >::zero_init(); + let list: Value = >::default(); *list.borrow_mut() = list_head { next: (list.as_pointer()), }; assert!(({ { (*list.borrow()).next.clone() } } == { (list.as_pointer()) })); - let n: Value = >::zero_init(); + let n: Value = >::default(); *n.borrow_mut() = node { value: 42, value_ptr: (field_ptr!(n.as_pointer(), value)), @@ -87,7 +87,7 @@ fn main_0() -> i32 { assert!(({ (*n.borrow()).value } == 7)); let arr: Value> = Rc::new(RefCell::new( (0..2) - .map(|_| ::zero_init()) + .map(|_| ::default()) .collect::>(), )); *arr.borrow_mut() = Box::new([ @@ -107,7 +107,7 @@ fn main_0() -> i32 { }; assert!(({ { (*d.borrow()).next.clone() } } == { (d.as_pointer()) })); assert!(({ (*d.borrow()).value } == 3)); - let called: Value = >::zero_init(); + let called: Value = >::default(); *called.borrow_mut() = list_head { next: ({ init_0((called.as_pointer())) }), }; diff --git a/tests/unit/out/refcount/static_local.rs b/tests/unit/out/refcount/static_local.rs index 5e8d036ece..90dd5d28a9 100644 --- a/tests/unit/out/refcount/static_local.rs +++ b/tests/unit/out/refcount/static_local.rs @@ -27,8 +27,8 @@ thread_local!( static kX2_5: Value = Rc::new(RefCell::new(2)); ); pub fn from_local_class_6() -> i32 { - return (({ S_8::get(Rc::new(RefCell::new({ ::zero_init() })).as_pointer()) }) - + ({ S_8::get(Rc::new(RefCell::new({ ::zero_init() })).as_pointer()) })); + return (({ S_8::get(Rc::new(RefCell::new(::default())).as_pointer()) }) + + ({ S_8::get(Rc::new(RefCell::new(::default())).as_pointer()) })); } thread_local!( static x_7: Value = Rc::new(RefCell::new(3)); diff --git a/tests/unit/out/refcount/static_var_in_class.rs b/tests/unit/out/refcount/static_var_in_class.rs index 2edec319bb..70a3d61951 100644 --- a/tests/unit/out/refcount/static_var_in_class.rs +++ b/tests/unit/out/refcount/static_var_in_class.rs @@ -62,10 +62,10 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let c: Value = Rc::new(RefCell::new({ ::zero_init() })); + let c: Value = Rc::new(RefCell::new(::default())); assert!((({ C::get(c.as_pointer(),) }) == 1)); assert!((inner_const_1.with(|rc| *rc.borrow()) == 2)); - let s: Value = Rc::new(RefCell::new({ ::zero_init() })); + let s: Value = Rc::new(RefCell::new(::default())); let mut p: Ptr = (s.as_pointer()); assert!((inner_const_1.with(|rc| *rc.borrow()) == 2)); assert!((inner_const_1.with(|rc| *rc.borrow()) == 2)); diff --git a/tests/unit/out/refcount/struct_2d_array_field.rs b/tests/unit/out/refcount/struct_2d_array_field.rs index 6338f662af..23e005d3e3 100644 --- a/tests/unit/out/refcount/struct_2d_array_field.rs +++ b/tests/unit/out/refcount/struct_2d_array_field.rs @@ -190,7 +190,7 @@ fn main_0() -> i32 { let mut p: Ptr = array_field_ptr!(local.as_pointer(), rows).offset(2).decay(); assert!((((elem!(p, 0).read()) as i32) == ('t' as i32))); assert!(({ (*local.borrow()).count } == 3_usize)); - let copy: Value

= { >::zero_init() }; + let copy: Value
= >::default(); { let mut __tmp_0 = { (array_field_ptr!(copy.as_pointer(), rows)).to_any() }; __tmp_0.memcpy( diff --git a/tests/unit/out/refcount/struct_member_array_adjacency.rs b/tests/unit/out/refcount/struct_member_array_adjacency.rs index 423b4fd5ab..5696afc7ff 100644 --- a/tests/unit/out/refcount/struct_member_array_adjacency.rs +++ b/tests/unit/out/refcount/struct_member_array_adjacency.rs @@ -32,7 +32,7 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let s: Value = { >::zero_init() }; + let s: Value = >::default(); assert!( (array_field_ptr!(s.as_pointer(), a).offset((4) as isize) == array_field_ptr!(s.as_pointer(), b)) diff --git a/tests/unit/out/refcount/struct_ptr.rs b/tests/unit/out/refcount/struct_ptr.rs index 1d4d20b12c..96c99b3380 100644 --- a/tests/unit/out/refcount/struct_ptr.rs +++ b/tests/unit/out/refcount/struct_ptr.rs @@ -29,7 +29,7 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let obj: Value = Rc::new(RefCell::new({ ::zero_init() })); + let obj: Value = Rc::new(RefCell::new(::default())); let mut ptr: Ptr = (obj.as_pointer()); field!(ptr, x).write(2); let mut c: bool = false; diff --git a/tests/unit/out/refcount/tag_vs_identifier_collision.rs b/tests/unit/out/refcount/tag_vs_identifier_collision.rs index 6756e981e4..5feb2cd74c 100644 --- a/tests/unit/out/refcount/tag_vs_identifier_collision.rs +++ b/tests/unit/out/refcount/tag_vs_identifier_collision.rs @@ -154,31 +154,31 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let w: Value = { >::zero_init() }; + let w: Value = >::default(); (*w.borrow_mut()).id = 7; (*w.borrow_mut()).mode = widget_enum_MODE_ACTIVE; assert!((({ is_active_0((w.as_pointer()),) }) != 0)); (*w.borrow_mut()).mode = widget_enum_MODE_DONE; assert!((({ (*w.borrow()).mode } as u32) == ((widget_enum_MODE_DONE as i32) as u32))); - let mut p: point_struct = { ::zero_init() }; + let mut p: point_struct = ::default(); p.x = 3; p.y = 4; assert!(((p.x + p.y) == 7)); - let up: Value = { >::zero_init() }; + let up: Value = >::default(); point::whole(up.as_pointer()).write(5); assert!(((point::whole(up.as_pointer()).read()) == 5)); - let b: Value = { >::zero_init() }; + let b: Value = >::default(); slot_union::i(b.as_pointer()).write(9); assert!(((slot_union::i(b.as_pointer()).read()) == 9)); let mut e: slot = slot_SLOT_B; assert!(((e as u32) == ((slot_SLOT_B as i32) as u32))); - let mut inner_tag: Inner = { ::zero_init() }; + let mut inner_tag: Inner = ::default(); inner_tag.tag_field = 11; assert!((inner_tag.tag_field == 11)); - let mut inner_typedef: Inner_struct = { ::zero_init() }; + let mut inner_typedef: Inner_struct = ::default(); inner_typedef.typedef_field = 22; assert!((inner_typedef.typedef_field == 22)); - let mut o: Outer = { ::zero_init() }; + let mut o: Outer = ::default(); o.field.tag_field = 33; assert!((o.field.tag_field == 33)); assert!(({ (*w.borrow()).id } == 7)); diff --git a/tests/unit/out/refcount/typedef-anon-struct.rs b/tests/unit/out/refcount/typedef-anon-struct.rs index 798b01e4ea..ce59cc6a85 100644 --- a/tests/unit/out/refcount/typedef-anon-struct.rs +++ b/tests/unit/out/refcount/typedef-anon-struct.rs @@ -59,7 +59,7 @@ pub fn main() { } fn main_0() -> i32 { object!(o, Outer::constructor_1()); - let info: Value = Rc::new(RefCell::new({ ::zero_init() })); + let info: Value = Rc::new(RefCell::new(::default())); (*info.borrow_mut()).block_idx = 1; (*info.borrow_mut()).num_extra_zero_runs = 2; CopyConstructible::push_copied( 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 7c1a778569..f738c39685 100644 --- a/tests/unit/out/refcount/unary_expr_or_type_trait.rs +++ b/tests/unit/out/refcount/unary_expr_or_type_trait.rs @@ -40,7 +40,7 @@ pub fn main() { } fn main_0() -> i32 { let mut arr: [i64; 4] = [0_i64; 4]; - let mut s: S = { ::zero_init() }; + let mut s: S = ::default(); assert!((::std::mem::size_of::() == 4_usize)); assert!((::std::mem::size_of::<[i64; 4]>() == 32_usize)); assert!((16usize == 16_usize)); diff --git a/tests/unit/out/refcount/unboxed_records.rs b/tests/unit/out/refcount/unboxed_records.rs index 528f582e68..52566651fd 100644 --- a/tests/unit/out/refcount/unboxed_records.rs +++ b/tests/unit/out/refcount/unboxed_records.rs @@ -121,7 +121,7 @@ pub fn main() { fn main_0() -> i32 { let data: Value> = Rc::new(RefCell::new(Box::new([0, 0, 0, 0]))); let in_: Value> = Rc::new(RefCell::new(Box::new([1, 2, 3, 4]))); - let cookie: Value = Rc::new(RefCell::new({ ::zero_init() })); + let cookie: Value = Rc::new(RefCell::new(::default())); (*cookie.borrow_mut()).x = 2; (*cookie.borrow_mut()).data = data.decay(); (*cookie.borrow_mut()).in_ = in_.decay(); @@ -135,7 +135,7 @@ fn main_0() -> i32 { }) ); assert!((({ get_1(cookie.as_pointer(),) }) == 2)); - let mut local: Inner = { ::zero_init() }; + let mut local: Inner = ::default(); local.a = 4; local.b = (local.a * 2); local.a.postfix_inc(); diff --git a/tests/unit/out/refcount/union_addrof_external.rs b/tests/unit/out/refcount/union_addrof_external.rs index 99e632318d..52319db37c 100644 --- a/tests/unit/out/refcount/union_addrof_external.rs +++ b/tests/unit/out/refcount/union_addrof_external.rs @@ -94,7 +94,7 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let c: Value = { >::zero_init() }; + let c: Value = >::default(); { let mut __tmp_0 = { (c.as_pointer()).to_any() }; __tmp_0.memset((0) as u8, 128usize); diff --git a/tests/unit/out/refcount/union_basic.rs b/tests/unit/out/refcount/union_basic.rs index 99d195fde2..cfe40992d1 100644 --- a/tests/unit/out/refcount/union_basic.rs +++ b/tests/unit/out/refcount/union_basic.rs @@ -76,8 +76,8 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let u: Value = Rc::new(RefCell::new({ ::zero_init() })); - let e: Value = Rc::new(RefCell::new({ ::zero_init() })); + let u: Value = Rc::new(RefCell::new(::default())); + let e: Value = Rc::new(RefCell::new(::default())); basic::i(u.as_pointer()).write(42); assert!(((basic::i(u.as_pointer()).read()) == 42)); basic::f(u.as_pointer()).write(3.14_f32); @@ -98,25 +98,25 @@ fn main_0() -> i32 { assert!(((pf.read()) == 1_f32)); assert!(({ (((*buf.borrow())[(3) as usize] as i32) == 63) })); let braced: Value = Rc::new(RefCell::new({ - let __u: Value = Rc::new(RefCell::new({ ::zero_init() })); + let __u: Value = Rc::new(RefCell::new(::default())); basic::i(__u.as_pointer()).write(5); Rc::try_unwrap(__u).ok().unwrap().into_inner() })); assert!(((basic::i(braced.as_pointer()).read()) == 5)); let copied: Value = Rc::new(RefCell::new({ - let __u: Value = Rc::new(RefCell::new({ ::zero_init() })); + let __u: Value = Rc::new(RefCell::new(::default())); basic::i(__u.as_pointer()).write(7); Rc::try_unwrap(__u).ok().unwrap().into_inner() })); assert!(((basic::i(copied.as_pointer()).read()) == 7)); { - let anon_0: Value = Rc::new(RefCell::new({ ::zero_init() })); + let anon_0: Value = Rc::new(RefCell::new(::default())); anon_0::ai(anon_0.as_pointer()).write(11); assert!(((anon_0::ai(anon_0.as_pointer()).read()) == 11)); anon_0::ai(anon_0.as_pointer()).write(1065353216); assert!(((anon_0::af(anon_0.as_pointer()).read()) == 1_f32)); } - let us: Value = Rc::new(RefCell::new({ ::zero_init() })); + let us: Value = Rc::new(RefCell::new(::default())); underscores::__(us.as_pointer()).write(5); assert!(((underscores::__(us.as_pointer()).read()) == 5)); underscores::___(us.as_pointer()).write(2.5_f64); diff --git a/tests/unit/out/refcount/union_cross_arm_cast.rs b/tests/unit/out/refcount/union_cross_arm_cast.rs index 9c62d42fa1..121b82898e 100644 --- a/tests/unit/out/refcount/union_cross_arm_cast.rs +++ b/tests/unit/out/refcount/union_cross_arm_cast.rs @@ -100,7 +100,7 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let c: Value = { >::zero_init() }; + let c: Value = >::default(); { let mut __tmp_0 = { (c.as_pointer()).to_any() }; __tmp_0.memset((0) as u8, 68usize); diff --git a/tests/unit/out/refcount/union_field_alignment.rs b/tests/unit/out/refcount/union_field_alignment.rs index 3fb5b18716..81b3469150 100644 --- a/tests/unit/out/refcount/union_field_alignment.rs +++ b/tests/unit/out/refcount/union_field_alignment.rs @@ -54,7 +54,7 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let n: Value = { >::zero_init() }; + let n: Value = >::default(); (*n.borrow_mut()).next = Ptr::::null(); elem!(anon_0::bytes(field_ptr!(n.as_pointer(), x)), 0).write(171_u8); assert!((((elem!(anon_0::bytes(field_ptr!(n.as_pointer(), x)), 0).read()) as i32) == 171)); diff --git a/tests/unit/out/refcount/union_memset_memcpy.rs b/tests/unit/out/refcount/union_memset_memcpy.rs index 5ba4e7a629..3e0ead3de8 100644 --- a/tests/unit/out/refcount/union_memset_memcpy.rs +++ b/tests/unit/out/refcount/union_memset_memcpy.rs @@ -96,7 +96,7 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let c: Value = { >::zero_init() }; + let c: Value = >::default(); { let mut __tmp_0 = { (c.as_pointer()).to_any() }; __tmp_0.memset((0) as u8, 256usize); diff --git a/tests/unit/out/refcount/union_nested.rs b/tests/unit/out/refcount/union_nested.rs index 93abfffa69..02109bcd0d 100644 --- a/tests/unit/out/refcount/union_nested.rs +++ b/tests/unit/out/refcount/union_nested.rs @@ -118,7 +118,7 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let ex: Value = { >::zero_init() }; + let ex: Value = >::default(); { let mut __tmp_0 = { (ex.as_pointer()).to_any() }; __tmp_0.memset((0) as u8, 144usize); diff --git a/tests/unit/out/refcount/union_pointer_pun_address.rs b/tests/unit/out/refcount/union_pointer_pun_address.rs index d52f62bc4e..1956fff003 100644 --- a/tests/unit/out/refcount/union_pointer_pun_address.rs +++ b/tests/unit/out/refcount/union_pointer_pun_address.rs @@ -47,7 +47,7 @@ pub fn main() { } fn main_0() -> i32 { let a: Value = Rc::new(RefCell::new(node_a { n: 123 })); - let ptr: Value = { >::zero_init() }; + let ptr: Value = >::default(); anon_0::to_a(ptr.as_pointer()).write((a.as_pointer())); let mut out: Ptr = (anon_0::to_b(ptr.as_pointer()).read()); assert!(({ (out).to_any() } == { (a.as_pointer()).to_any() })); diff --git a/tests/unit/out/refcount/union_pointer_pun_writethrough.rs b/tests/unit/out/refcount/union_pointer_pun_writethrough.rs index 702a99466c..f73852ebbc 100644 --- a/tests/unit/out/refcount/union_pointer_pun_writethrough.rs +++ b/tests/unit/out/refcount/union_pointer_pun_writethrough.rs @@ -12,7 +12,7 @@ pub fn main() { } fn main_0() -> i32 { let x: Value = Rc::new(RefCell::new((-1_i32 as i64))); - let pp: Value = { >::zero_init() }; + let pp: Value = >::default(); anon_0::as_signed(pp.as_pointer()).write((x.as_pointer())); (anon_0::as_unsigned(pp.as_pointer()).read()).write(42_u64); assert!(({ ((*x.borrow()) == 42_i64) })); diff --git a/tests/unit/out/refcount/union_struct_dual_use.rs b/tests/unit/out/refcount/union_struct_dual_use.rs index 7c1eeebd68..660d5bbd93 100644 --- a/tests/unit/out/refcount/union_struct_dual_use.rs +++ b/tests/unit/out/refcount/union_struct_dual_use.rs @@ -72,11 +72,11 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let standalone: Value = { >::zero_init() }; + let standalone: Value = >::default(); (*standalone.borrow_mut()).a = 3; (*standalone.borrow_mut()).b = 4; assert!((({ sum_inner_0((standalone.as_pointer()),) }) == 7)); - let outer: Value = { >::zero_init() }; + let outer: Value = >::default(); { let mut __tmp_0 = { (outer.as_pointer()).to_any() }; __tmp_0.memset((0) as u8, 16usize); diff --git a/tests/unit/out/refcount/union_tagged_many_arms.rs b/tests/unit/out/refcount/union_tagged_many_arms.rs index 6c9228b14e..c78f508927 100644 --- a/tests/unit/out/refcount/union_tagged_many_arms.rs +++ b/tests/unit/out/refcount/union_tagged_many_arms.rs @@ -68,15 +68,15 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let a: Value = { >::zero_init() }; + let a: Value = >::default(); (*a.borrow_mut()).tag = Tag_enum_T_NUM_S; anon_0::signed_n(field_ptr!(a.as_pointer(), payload)).write((-7_i32 as i64)); assert!(((anon_0::signed_n(field_ptr!(a.as_pointer(), payload)).read()) == (-7_i32 as i64))); - let b: Value = { >::zero_init() }; + let b: Value = >::default(); (*b.borrow_mut()).tag = Tag_enum_T_NUM_U; anon_0::unsigned_n(field_ptr!(b.as_pointer(), payload)).write(3735928559_u64); assert!(((anon_0::unsigned_n(field_ptr!(b.as_pointer(), payload)).read()) == 3735928559_u64)); - let c: Value = { >::zero_init() }; + let c: Value = >::default(); (*c.borrow_mut()).tag = Tag_enum_T_TEXT; anon_0::text(field_ptr!(c.as_pointer(), payload)) .write(Ptr::::from_string_literal(b"hello")); @@ -88,12 +88,12 @@ fn main_0() -> i32 { .read()) as i32) == ('h' as i32)) ); - let d: Value = { >::zero_init() }; + let d: Value = >::default(); (*d.borrow_mut()).tag = Tag_enum_T_FLOAT; anon_0::f(field_ptr!(d.as_pointer(), payload)).write(1.5_f64); assert!(((anon_0::f(field_ptr!(d.as_pointer(), payload)).read()) == 1.5_f64)); let x: Value = Rc::new(RefCell::new(0)); - let e: Value = { >::zero_init() }; + let e: Value = >::default(); (*e.borrow_mut()).tag = Tag_enum_T_REF; anon_0::handle(field_ptr!(e.as_pointer(), payload)).write((x.as_pointer()).to_any()); assert!( diff --git a/tests/unit/out/refcount/union_tagged_simple.rs b/tests/unit/out/refcount/union_tagged_simple.rs index 444780bddb..5c5aa3e294 100644 --- a/tests/unit/out/refcount/union_tagged_simple.rs +++ b/tests/unit/out/refcount/union_tagged_simple.rs @@ -60,13 +60,13 @@ pub fn main() { } fn main_0() -> i32 { let dummy: Value = Rc::new(RefCell::new(0)); - let m1: Value = { >::zero_init() }; + let m1: Value = >::default(); (*m1.borrow_mut()).kind = Kind_enum_KIND_DONE; (*m1.borrow_mut()).handle = (dummy.as_pointer()).to_any(); anon_0::code(field_ptr!(m1.as_pointer(), payload)).write(42); assert!((({ (*m1.borrow()).kind } as u32) == ((Kind_enum_KIND_DONE as i32) as u32))); assert!(((anon_0::code(field_ptr!(m1.as_pointer(), payload)).read()) == 42)); - let m2: Value = { >::zero_init() }; + let m2: Value = >::default(); (*m2.borrow_mut()).kind = Kind_enum_KIND_NONE; (*m2.borrow_mut()).handle = (dummy.as_pointer()).to_any(); anon_0::obj(field_ptr!(m2.as_pointer(), payload)).write((dummy.as_pointer()).to_any()); diff --git a/tests/unit/out/refcount/union_tagged_struct_arms.rs b/tests/unit/out/refcount/union_tagged_struct_arms.rs index 8f0842ebf3..d018cb0f4d 100644 --- a/tests/unit/out/refcount/union_tagged_struct_arms.rs +++ b/tests/unit/out/refcount/union_tagged_struct_arms.rs @@ -128,7 +128,7 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let p_list: Value = { >::zero_init() }; + let p_list: Value = >::default(); (*p_list.borrow_mut()).choice = Choice_enum_C_LIST; (*p_list.borrow_mut()).index = 0; field!(anon_0::list(field_ptr!(p_list.as_pointer(), v)), items) @@ -148,7 +148,7 @@ fn main_0() -> i32 { .read()) as i32) == ('b' as i32)) ); - let p_letters: Value = { >::zero_init() }; + let p_letters: Value = >::default(); (*p_letters.borrow_mut()).choice = Choice_enum_C_LETTERS; (*p_letters.borrow_mut()).index = 1; field!(anon_0::letters(field_ptr!(p_letters.as_pointer(), v)), lo).write(('a' as i32)); @@ -160,7 +160,7 @@ fn main_0() -> i32 { - anon_0::letters(field_ptr!(p_letters.as_pointer(), v)).with(|__s| __s.lo)) == 25) ); - let p_integers: Value = { >::zero_init() }; + let p_integers: Value = >::default(); (*p_integers.borrow_mut()).choice = Choice_enum_C_INTEGERS; (*p_integers.borrow_mut()).index = 2; field!(anon_0::integers(field_ptr!(p_integers.as_pointer(), v)), lo).write(1_i64); 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 8d315f5fed..5b9806a2ca 100644 --- a/tests/unit/out/refcount/union_void_ptr_sized_deref.rs +++ b/tests/unit/out/refcount/union_void_ptr_sized_deref.rs @@ -91,7 +91,7 @@ fn main_0() -> i32 { let buf64: Value = Rc::new(RefCell::new(0_i64)); let buf32: Value = Rc::new(RefCell::new(0)); let buf16: Value = Rc::new(RefCell::new(0_i16)); - let s: Value = { >::zero_init() }; + let s: Value = >::default(); (*s.borrow_mut()).width = Width_enum_W_64; anon_0::handle(field_ptr!(s.as_pointer(), out)).write((buf64.as_pointer()).to_any()); ({ write_count_1((s.as_pointer()), 1234605616436508552_i64) }); diff --git a/tests/unit/out/refcount/unique_ptr.rs b/tests/unit/out/refcount/unique_ptr.rs index eacb1f4279..e62213609d 100644 --- a/tests/unit/out/refcount/unique_ptr.rs +++ b/tests/unit/out/refcount/unique_ptr.rs @@ -113,7 +113,7 @@ pub fn DoStuffWithSafePointer_0(safe_ptr: Ptr>>) { } pub fn Consume_1(mut safe_ptr: Option>) -> i32 { let mut x: Option> = safe_ptr.take(); - let mut p: Option> = Ptr::alloc({ ::zero_init() }).to_owned_opt(); + let mut p: Option> = Ptr::alloc(::default()).to_owned_opt(); return ((x .as_pointer() .with(|__s| (__s).ptr.clone()) @@ -159,7 +159,7 @@ pub fn RndStuff_2() { } let x3: Value>>> = Rc::new(RefCell::new(Some(Rc::new(RefCell::new( (0..10_usize) - .map(|_| ::zero_init()) + .map(|_| ::default()) .collect::>(), ))))); { @@ -188,7 +188,7 @@ pub fn RndStuff_2() { x3.as_pointer().write( Ptr::alloc_array( (0..50_usize) - .map(|_| ::zero_init()) + .map(|_| ::default()) .collect::>(), ) .to_owned_opt(), diff --git a/tests/unit/out/refcount/va_arg_struct_ctx.rs b/tests/unit/out/refcount/va_arg_struct_ctx.rs index 4ab5dd9905..df67927634 100644 --- a/tests/unit/out/refcount/va_arg_struct_ctx.rs +++ b/tests/unit/out/refcount/va_arg_struct_ctx.rs @@ -73,7 +73,7 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let ctx: Value = { >::zero_init() }; + let ctx: Value = >::default(); (*ctx.borrow_mut()).verbose = 1; (*ctx.borrow_mut()).last_error = 0; ({ @@ -93,7 +93,7 @@ fn main_0() -> i32 { ) }); assert!(({ (*ctx.borrow()).last_error } == 42)); - let v: Value = { >::zero_init() }; + let v: Value = >::default(); value::l(v.as_pointer()).write((1_i64 << 40)); assert!(({ (({ pick_1(1, Box::new([((*v.borrow()).clone()).into(),])) }) == (1_i64 << 40)) })); value::i(v.as_pointer()).write(7); diff --git a/tests/unit/out/unsafe/05_new.rs b/tests/unit/out/unsafe/05_new.rs index 42bc515ce4..3499c17df3 100644 --- a/tests/unit/out/unsafe/05_new.rs +++ b/tests/unit/out/unsafe/05_new.rs @@ -66,8 +66,8 @@ unsafe fn main_0() -> i32 { }; (unsafe { D::operator_call( - &unsafe { ::zero_init() }, - (Box::leak(Box::new(unsafe { ::zero_init() })) as *mut A).cast_const(), + &::default(), + (Box::leak(Box::new(::default())) as *mut A).cast_const(), ) }); return 0; diff --git a/tests/unit/out/unsafe/anonymous-struct.rs b/tests/unit/out/unsafe/anonymous-struct.rs index 91589246cb..d2197cec3a 100644 --- a/tests/unit/out/unsafe/anonymous-struct.rs +++ b/tests/unit/out/unsafe/anonymous-struct.rs @@ -143,7 +143,7 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut o: Outer = unsafe { ::zero_init() }; + let mut o: Outer = ::default(); o.named.a = 1; o.named.b = 2; o.anonymous_named_0.c = 3; @@ -166,7 +166,7 @@ unsafe fn main_0() -> i32 { assert!(((o.anon_3.i) == (9))); assert!(((o.anon_3.inner_named.j) == (10))); assert!(((o.anon_3.anon_5.k) == (11))); - let mut s: anon_6 = unsafe { ::zero_init() }; + let mut s: anon_6 = ::default(); s.x = 1; s.z = 2; assert!( diff --git a/tests/unit/out/unsafe/anonymous-struct_c.rs b/tests/unit/out/unsafe/anonymous-struct_c.rs index 589b41c04d..4d264d67cb 100644 --- a/tests/unit/out/unsafe/anonymous-struct_c.rs +++ b/tests/unit/out/unsafe/anonymous-struct_c.rs @@ -129,10 +129,10 @@ pub fn main() { unsafe fn main_0() -> i32 { let mut o: Outer = Outer { named: Named { a: 0, b: 0_i32 }, - anon0: unsafe { ::zero_init() }, - anon1: unsafe { ::zero_init() }, - anon_2: unsafe { ::zero_init() }, - anon_3: unsafe { ::zero_init() }, + anon0: ::default(), + anon1: ::default(), + anon_2: ::default(), + anon_3: ::default(), }; o.named.a = 1; o.named.b = 2; @@ -156,7 +156,7 @@ unsafe fn main_0() -> i32 { assert!(((o.anon_3.i) == (9))); assert!(((o.anon_3.inner_named.j) == (10))); assert!(((o.anon_3.anon_5.k) == (11))); - let mut s: anon_6 = unsafe { ::zero_init() }; + let mut s: anon_6 = ::default(); s.x = 1; s.z = 2; assert!( diff --git a/tests/unit/out/unsafe/anonymous_enum.rs b/tests/unit/out/unsafe/anonymous_enum.rs index fe948a8acc..a591273c9f 100644 --- a/tests/unit/out/unsafe/anonymous_enum.rs +++ b/tests/unit/out/unsafe/anonymous_enum.rs @@ -63,7 +63,7 @@ unsafe fn main_0() -> i32 { assert!(((td as i32) == (TdEnum_TD_A as i32))); td = TdEnum_TD_B; assert!(((td as i32) == (TdEnum_TD_B as i32))); - let mut w: WithAnonField = unsafe { ::zero_init() }; + let mut w: WithAnonField = ::default(); w.field = anon_2_FIELD_A; assert!(((w.field as i32) == (anon_2_FIELD_A as i32))); w.field = anon_2_FIELD_B; diff --git a/tests/unit/out/unsafe/anonymous_enum_c.rs b/tests/unit/out/unsafe/anonymous_enum_c.rs index d16612d96a..e5af35ceb3 100644 --- a/tests/unit/out/unsafe/anonymous_enum_c.rs +++ b/tests/unit/out/unsafe/anonymous_enum_c.rs @@ -59,7 +59,7 @@ unsafe fn main_0() -> i32 { assert!(((td as u32) == ((TdEnum_enum_TD_A as i32) as u32))); td = TdEnum_enum_TD_B; assert!(((td as u32) == ((TdEnum_enum_TD_B as i32) as u32))); - let mut w: WithAnonField = unsafe { ::zero_init() }; + let mut w: WithAnonField = ::default(); w.field = anon_2_FIELD_A; assert!(((w.field as u32) == ((anon_2_FIELD_A as i32) as u32))); w.field = anon_2_FIELD_B; diff --git a/tests/unit/out/unsafe/array_const_init.rs b/tests/unit/out/unsafe/array_const_init.rs index 5dcad783a8..2ff1123949 100644 --- a/tests/unit/out/unsafe/array_const_init.rs +++ b/tests/unit/out/unsafe/array_const_init.rs @@ -121,9 +121,9 @@ unsafe fn main_0() -> i32 { assert!((((d[(0) as usize]) == (0_f64)) && ((d[(3) as usize]) == (0_f64)))); let mut p: [P; 4] = [ P { x: 1, y: 2 }, - unsafe {

::zero_init() }, - unsafe {

::zero_init() }, - unsafe {

::zero_init() }, +

::default(), +

::default(), +

::default(), ]; assert!((((p[(0) as usize].x) == (1)) && ((p[(0) as usize].y) == (2)))); assert!((((p[(3) as usize].x) == (0)) && ((p[(3) as usize].y) == (0)))); diff --git a/tests/unit/out/unsafe/assignment_single_eval.rs b/tests/unit/out/unsafe/assignment_single_eval.rs index cc57084d1a..06dc567c15 100644 --- a/tests/unit/out/unsafe/assignment_single_eval.rs +++ b/tests/unit/out/unsafe/assignment_single_eval.rs @@ -1375,7 +1375,7 @@ pub unsafe fn test_borrows_29() { }), ) }); - let mut first: Link_33 = unsafe { ::zero_init() }; + let mut first: Link_33 = ::default(); first = Link_33 { next: (&mut first as *mut Link_33), }; @@ -1482,7 +1482,7 @@ impl IndexedBinding { } } pub unsafe fn test_binding_35() { - let mut owner: IndexedBinding = unsafe { ::zero_init() }; + let mut owner: IndexedBinding = ::default(); let __decomp_36: *mut IndexedBinding = &mut owner; let value: *mut u32 = (unsafe { IndexedBinding::get_1_0(&raw mut (*__decomp_36)) }); let mut result: u32 = (match ( diff --git a/tests/unit/out/unsafe/c_struct.rs b/tests/unit/out/unsafe/c_struct.rs index f5863affa9..3766c56432 100644 --- a/tests/unit/out/unsafe/c_struct.rs +++ b/tests/unit/out/unsafe/c_struct.rs @@ -120,7 +120,7 @@ unsafe fn main_0() -> i32 { assert!(((c.inner.b) == (6))); assert!(((c.color as u32) == ((Color_GREEN as i32) as u32))); assert!(((c.count) == (42))); - let mut c2: Container = unsafe { ::zero_init() }; + let mut c2: Container = ::default(); c2.color = Color_BLUE; assert!(((c2.color as u32) == (2_u32))); return 0; diff --git a/tests/unit/out/unsafe/cast.rs b/tests/unit/out/unsafe/cast.rs index a9a68c5a25..b1c9052aa9 100644 --- a/tests/unit/out/unsafe/cast.rs +++ b/tests/unit/out/unsafe/cast.rs @@ -216,7 +216,7 @@ pub unsafe fn order_physical_2() { pub unsafe fn over_aligned_3() { let mut c: libc::c_char = ('c' as libc::c_char); assert!((((&mut c as *mut libc::c_char) as usize) != (0_usize))); - let mut w: [Wide; 3] = [unsafe { ::zero_init() }; 3]; + let mut w: [Wide; 3] = [::default(); 3]; let mut iw: usize = (w.as_mut_ptr() as usize); assert!((((iw as u64).wrapping_rem((::std::mem::align_of::() as u64))) == (0_u64))); assert!( @@ -225,7 +225,7 @@ pub unsafe fn over_aligned_3() { ); let mut h: *mut Wide = Box::leak( (0..2_usize) - .map(|_| unsafe { ::zero_init() }) + .map(|_| ::default()) .collect::>(), ) .as_mut_ptr(); @@ -288,7 +288,7 @@ pub unsafe fn vector_capacity_4() { ); } pub unsafe fn nested_5() { - let mut g: Grid = unsafe { ::zero_init() }; + let mut g: Grid = ::default(); let mut ig: usize = ((&mut g as *mut Grid) as usize); assert!( (((&mut g.row[(2) as usize] as *mut i32) as *mut i32 as usize) diff --git a/tests/unit/out/unsafe/default.rs b/tests/unit/out/unsafe/default.rs index 562ecaeb06..08b5c205e2 100644 --- a/tests/unit/out/unsafe/default.rs +++ b/tests/unit/out/unsafe/default.rs @@ -67,7 +67,7 @@ pub fn main() { unsafe fn main_0() -> i32 { let mut default_pointers: *mut Pointers = Box::leak( (0..10_usize) - .map(|_| unsafe { ::zero_init() }) + .map(|_| ::default()) .collect::>(), ) .as_mut_ptr(); @@ -83,7 +83,7 @@ unsafe fn main_0() -> i32 { }; let mut small: *mut SmallArrays = Box::leak( (0..2_usize) - .map(|_| unsafe { ::zero_init() }) + .map(|_| ::default()) .collect::>(), ) .as_mut_ptr(); @@ -99,7 +99,7 @@ unsafe fn main_0() -> i32 { }; let mut big: *mut BigArray = Box::leak( (0..2_usize) - .map(|_| unsafe { ::zero_init() }) + .map(|_| ::default()) .collect::>(), ) .as_mut_ptr(); diff --git a/tests/unit/out/unsafe/default_in_statics.rs b/tests/unit/out/unsafe/default_in_statics.rs index c83745d566..a21bf7b055 100644 --- a/tests/unit/out/unsafe/default_in_statics.rs +++ b/tests/unit/out/unsafe/default_in_statics.rs @@ -66,9 +66,9 @@ pub struct Foo { pub static mut static_fn_0: std::cell::LazyCell i32>> = std::cell::LazyCell::new(|| unsafe { None }); pub static mut static_outer_1: std::cell::LazyCell = - std::cell::LazyCell::new(|| unsafe { unsafe { ::zero_init() } }); + std::cell::LazyCell::new(|| unsafe { ::default() }); pub static mut static_inner_array_2: std::cell::LazyCell<[Inner; 2]> = - std::cell::LazyCell::new(|| unsafe { [unsafe { ::zero_init() }; 2] }); + std::cell::LazyCell::new(|| unsafe { [::default(); 2] }); pub static mut static_foo_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { Foo { s1: c"hello".as_ptr(), @@ -104,7 +104,7 @@ pub unsafe fn check_local_static_5() { assert!((*std::cell::LazyCell::force_mut(&mut *&raw mut local_p_8)).is_null()); } static mut local_outer_6: std::cell::LazyCell = - std::cell::LazyCell::new(|| unsafe { unsafe { ::zero_init() } }); + std::cell::LazyCell::new(|| unsafe { ::default() }); static mut local_fn_7: std::cell::LazyCell i32>> = std::cell::LazyCell::new(|| unsafe { None }); static mut local_p_8: std::cell::LazyCell<*mut i32> = diff --git a/tests/unit/out/unsafe/destructor.rs b/tests/unit/out/unsafe/destructor.rs index 40e14e3c89..0635be1661 100644 --- a/tests/unit/out/unsafe/destructor.rs +++ b/tests/unit/out/unsafe/destructor.rs @@ -259,53 +259,53 @@ pub fn main() { } unsafe fn main_0() -> i32 { { - let mut s: S = unsafe { ::zero_init() }; + let mut s: S = ::default(); let _dtor_s = std::mem::DropGuard::new(&raw mut s, |__p| unsafe { DestructibleUnsafe::destroy(__p) }); } assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) == (1))); { - let mut s: S = unsafe { ::zero_init() }; + let mut s: S = ::default(); let _dtor_s = std::mem::DropGuard::new(&raw mut s, |__p| unsafe { DestructibleUnsafe::destroy(__p) }); } assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) == (2))); { - let mut d: Defaulted = unsafe { ::zero_init() }; + let mut d: Defaulted = ::default(); let _dtor_d = std::mem::DropGuard::new(&raw mut d, |__p| unsafe { DestructibleUnsafe::destroy(__p) }); } assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) == (3))); { - let mut o: Outer = unsafe { ::zero_init() }; + let mut o: Outer = ::default(); let _dtor_o = std::mem::DropGuard::new(&raw mut o, |__p| unsafe { DestructibleUnsafe::destroy(__p) }); } assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) == (4))); { - let mut am: ArrayMember = unsafe { ::zero_init() }; + let mut am: ArrayMember = ::default(); let _dtor_am = std::mem::DropGuard::new(&raw mut am, |__p| unsafe { DestructibleUnsafe::destroy(__p) }); } assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) == (7))); { - let mut e: EmptyBody = unsafe { ::zero_init() }; + let mut e: EmptyBody = ::default(); let _dtor_e = std::mem::DropGuard::new(&raw mut e, |__p| unsafe { DestructibleUnsafe::destroy(__p) }); } assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)) == (8))); { - let mut tc: Templated_char_ = unsafe { ::zero_init() }; + let mut tc: Templated_char_ = ::default(); let _dtor_tc = std::mem::DropGuard::new(&raw mut tc, |__p| unsafe { DestructibleUnsafe::destroy(__p) }); - let mut ti: Templated_int_ = unsafe { ::zero_init() }; + let mut ti: Templated_int_ = ::default(); let _dtor_ti = std::mem::DropGuard::new(&raw mut ti, |__p| unsafe { DestructibleUnsafe::destroy(__p) }); @@ -341,7 +341,7 @@ unsafe fn main_0() -> i32 { assert!((((*std::cell::LazyCell::force_mut(&mut *&raw mut order_1))[(2) as usize]) == (1))); let mut before: i32 = (*std::cell::LazyCell::force_mut(&mut *&raw mut global_0)); { - let mut cs: S = unsafe { ::zero_init() }; + let mut cs: S = ::default(); let _dtor_cs = std::mem::DropGuard::new(&raw mut cs, |__p| unsafe { DestructibleUnsafe::destroy(__p) }); diff --git a/tests/unit/out/unsafe/enum_default_in_static.rs b/tests/unit/out/unsafe/enum_default_in_static.rs index 5686e5b436..b15584db38 100644 --- a/tests/unit/out/unsafe/enum_default_in_static.rs +++ b/tests/unit/out/unsafe/enum_default_in_static.rs @@ -25,7 +25,7 @@ pub struct Config { pub mode: Mode, } pub static mut config_0: std::cell::LazyCell = - std::cell::LazyCell::new(|| unsafe { unsafe { ::zero_init() } }); + std::cell::LazyCell::new(|| unsafe { ::default() }); pub fn main() { unsafe { __cpp2rust_init_globals(); diff --git a/tests/unit/out/unsafe/fft.rs b/tests/unit/out/unsafe/fft.rs index 0ecdeefea4..0ce83224dc 100644 --- a/tests/unit/out/unsafe/fft.rs +++ b/tests/unit/out/unsafe/fft.rs @@ -46,7 +46,7 @@ pub unsafe fn Neg_2(mut z1: Complex) -> Complex { pub unsafe fn fft_3(a: *mut Option>, mut N: i32) -> Option> { let mut y: Option> = Some( (0..(N as usize)) - .map(|_| unsafe { ::zero_init() }) + .map(|_| ::default()) .collect::>(), ); if ((N) == (1)) { @@ -68,7 +68,7 @@ pub unsafe fn fft_3(a: *mut Option>, mut N: i32) -> Option> = Some( (0..(N as usize)) - .map(|_| unsafe { ::zero_init() }) + .map(|_| ::default()) .collect::>(), ); { @@ -89,12 +89,12 @@ pub unsafe fn fft_3(a: *mut Option>, mut N: i32) -> Option> = Some( (0..(((N) / (2)) as usize)) - .map(|_| unsafe { ::zero_init() }) + .map(|_| ::default()) .collect::>(), ); let mut A1: Option> = Some( (0..(((N) / (2)) as usize)) - .map(|_| unsafe { ::zero_init() }) + .map(|_| ::default()) .collect::>(), ); { @@ -207,7 +207,7 @@ unsafe fn main_0() -> i32 { let mut N: i32 = 4; let mut a: Option> = Some( (0..(N as usize)) - .map(|_| unsafe { ::zero_init() }) + .map(|_| ::default()) .collect::>(), ); { diff --git a/tests/unit/out/unsafe/field_aliasing.rs b/tests/unit/out/unsafe/field_aliasing.rs index 9e3cc5d644..6be843be4f 100644 --- a/tests/unit/out/unsafe/field_aliasing.rs +++ b/tests/unit/out/unsafe/field_aliasing.rs @@ -75,7 +75,7 @@ unsafe fn main_0() -> i32 { && (((*q).n) == (1))) ); libcc2rs::free_unsafe((p as *mut ::libc::c_void)); - let mut s: Node = unsafe { ::zero_init() }; + let mut s: Node = ::default(); s.x = 1; s.self_ = (&mut s as *mut Node); (*s.self_).x = ((s.x) + (1)); diff --git a/tests/unit/out/unsafe/field_method_receiver.rs b/tests/unit/out/unsafe/field_method_receiver.rs index 72f842041f..126c14067c 100644 --- a/tests/unit/out/unsafe/field_method_receiver.rs +++ b/tests/unit/out/unsafe/field_method_receiver.rs @@ -66,8 +66,8 @@ impl S { } pub unsafe fn constructor_1(this: *mut Self) { (&raw mut (*this).tag).write(0_i32); - (&raw mut (*this).c).write(unsafe { ::zero_init() }); - (&raw mut (*this).arr).write([unsafe { ::zero_init() }; 2]); + (&raw mut (*this).c).write(::default()); + (&raw mut (*this).arr).write([::default(); 2]); (&raw mut (*this).v).write(Vec::new()); } } @@ -109,16 +109,16 @@ pub fn main() { unsafe fn main_0() -> i32 { let mut local: S = S { tag: 0_i32, - c: unsafe { ::zero_init() }, - arr: [unsafe { ::zero_init() }; 2], + c: ::default(), + arr: [::default(); 2], v: Vec::new(), }; local.tag = 1; (unsafe { run_0((&mut local as *mut S)) }); let mut heap: *mut S = (Box::leak(Box::new(S { tag: 0_i32, - c: unsafe { ::zero_init() }, - arr: [unsafe { ::zero_init() }; 2], + c: ::default(), + arr: [::default(); 2], v: Vec::new(), })) as *mut S); (*heap).tag = 1; diff --git a/tests/unit/out/unsafe/field_pointers.rs b/tests/unit/out/unsafe/field_pointers.rs index a675bdd4ed..9934690338 100644 --- a/tests/unit/out/unsafe/field_pointers.rs +++ b/tests/unit/out/unsafe/field_pointers.rs @@ -76,8 +76,8 @@ impl Outer { } pub unsafe fn constructor_1(this: *mut Self) { (&raw mut (*this).x).write(0_i32); - (&raw mut (*this).inner).write(unsafe { ::zero_init() }); - (&raw mut (*this).items).write([unsafe { ::zero_init() }; 3]); + (&raw mut (*this).inner).write(::default()); + (&raw mut (*this).items).write([::default(); 3]); (&raw mut (*this).v).write(Vec::new()); (&raw mut (*this).cursor).write(std::ptr::null_mut()); (&raw mut (*this).buf).write([0_i32; 4]); @@ -99,8 +99,8 @@ pub fn main() { unsafe fn main_0() -> i32 { let mut o: Outer = Outer { x: 0_i32, - inner: unsafe { ::zero_init() }, - items: [unsafe { ::zero_init() }; 3], + inner: ::default(), + items: [::default(); 3], v: Vec::new(), cursor: std::ptr::null_mut(), buf: [0; 4], diff --git a/tests/unit/out/unsafe/field_reinterpret_write_through.rs b/tests/unit/out/unsafe/field_reinterpret_write_through.rs index f64375461f..81b32af630 100644 --- a/tests/unit/out/unsafe/field_reinterpret_write_through.rs +++ b/tests/unit/out/unsafe/field_reinterpret_write_through.rs @@ -1051,7 +1051,7 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut local: S = unsafe { ::zero_init() }; + let mut local: S = ::default(); { let mut __tmp_4 = { ((&mut local as *mut S) as *mut ::libc::c_void) }; let byte_0 = __tmp_4 as *mut u8; @@ -1061,7 +1061,7 @@ unsafe fn main_0() -> i32 { __tmp_4 }; (unsafe { check_struct_3((&mut local as *mut S)) }); - let mut arr: [S; 2] = [unsafe { ::zero_init() }; 2]; + let mut arr: [S; 2] = [::default(); 2]; { let mut __tmp_5 = { (arr.as_mut_ptr() as *mut ::libc::c_void) }; let byte_0 = __tmp_5 as *mut u8; diff --git a/tests/unit/out/unsafe/fn_ptr_cast.rs b/tests/unit/out/unsafe/fn_ptr_cast.rs index 4af6c5512d..bec520da14 100644 --- a/tests/unit/out/unsafe/fn_ptr_cast.rs +++ b/tests/unit/out/unsafe/fn_ptr_cast.rs @@ -45,7 +45,7 @@ pub struct Command { pub data: *mut ::libc::c_void, } pub unsafe fn test_void_ptr_to_fn_3() { - let mut cmd: Command = unsafe { ::zero_init() }; + let mut cmd: Command = ::default(); cmd.data = std::mem::transmute:: i32>, *mut ::libc::c_void>(Some( double_it_0, )); diff --git a/tests/unit/out/unsafe/function_overloading.rs b/tests/unit/out/unsafe/function_overloading.rs index 327940a538..23c2ea787f 100644 --- a/tests/unit/out/unsafe/function_overloading.rs +++ b/tests/unit/out/unsafe/function_overloading.rs @@ -73,8 +73,8 @@ unsafe fn main_0() -> i32 { }); let mut bar: i32 = 5; out += (((bar) + (unsafe { foo_0(0) })) + (unsafe { foo_1((&mut x as *mut i32)) })); - let mut foo1: Foo = unsafe { ::zero_init() }; - let foo2: Foo = unsafe { ::zero_init() }; + let mut foo1: Foo = ::default(); + let foo2: Foo = ::default(); (unsafe { Foo::foo_2(&raw mut foo1) }); (unsafe { Foo::method_3(&raw mut foo1, 1) }); (unsafe { Foo::foo_1(&raw const foo2) }); diff --git a/tests/unit/out/unsafe/goto_aggregate_default.rs b/tests/unit/out/unsafe/goto_aggregate_default.rs index acfd0ab79d..47d35880e3 100644 --- a/tests/unit/out/unsafe/goto_aggregate_default.rs +++ b/tests/unit/out/unsafe/goto_aggregate_default.rs @@ -25,7 +25,7 @@ pub unsafe fn agg_0(mut n: i32) -> i32 { let mut buf256: [u8; 256] = [0_u8; 256]; let mut arr64: [i32; 64] = [0_i32; 64]; let mut longs: [i64; 33] = [0_i64; 33]; - let mut p: Point = unsafe { ::zero_init() }; + let mut p: Point = ::default(); let mut ptr: *mut i32 = std::ptr::null_mut(); let mut fp: Option i32> = None; let mut file: *mut ::libc::FILE = std::ptr::null_mut(); diff --git a/tests/unit/out/unsafe/huffman.rs b/tests/unit/out/unsafe/huffman.rs index a7a0d04611..509bc5f399 100644 --- a/tests/unit/out/unsafe/huffman.rs +++ b/tests/unit/out/unsafe/huffman.rs @@ -274,7 +274,7 @@ pub unsafe fn AllocMinHeap_1(mut capacity: i32) -> Option> { next: 0, alloc: Some( (0..10000_usize) - .map(|_| unsafe { ::zero_init() }) + .map(|_| ::default()) .collect::>(), ), })); 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 41101b5fb2..732d42fcb5 100644 --- a/tests/unit/out/unsafe/immutable-deref-on-func-call.rs +++ b/tests/unit/out/unsafe/immutable-deref-on-func-call.rs @@ -35,7 +35,7 @@ pub fn main() { unsafe fn main_0() -> i32 { let mut arr: *mut Item = Box::leak( (0..2_usize) - .map(|_| unsafe { ::zero_init() }) + .map(|_| ::default()) .collect::>(), ) .as_mut_ptr(); diff --git a/tests/unit/out/unsafe/init.rs b/tests/unit/out/unsafe/init.rs index 5b3306f82a..0f00969d13 100644 --- a/tests/unit/out/unsafe/init.rs +++ b/tests/unit/out/unsafe/init.rs @@ -36,7 +36,7 @@ unsafe fn main_0() -> i32 { let g: *mut i32 = &mut x; let mut q: *mut i32 = (&mut x as *mut i32); let mut z: *mut i32 = p; - let mut xx: X = unsafe { ::zero_init() }; + let mut xx: X = ::default(); let mut zz: *mut X = (&mut xx as *mut X); xx.x = 1; q = (&mut xx.x as *mut i32); diff --git a/tests/unit/out/unsafe/kruskal.rs b/tests/unit/out/unsafe/kruskal.rs index fd7fd488e3..7e0ffdd725 100644 --- a/tests/unit/out/unsafe/kruskal.rs +++ b/tests/unit/out/unsafe/kruskal.rs @@ -383,7 +383,7 @@ unsafe fn main_0() -> i32 { let mut graph: Graph = Graph { edges: Some( (0..(E as usize)) - .map(|_| unsafe { ::zero_init() }) + .map(|_| ::default()) .collect::>(), ), V: V, diff --git a/tests/unit/out/unsafe/libc_struct_without_default.rs b/tests/unit/out/unsafe/libc_struct_without_default.rs index 8de8e834f8..0d4b89cd57 100644 --- a/tests/unit/out/unsafe/libc_struct_without_default.rs +++ b/tests/unit/out/unsafe/libc_struct_without_default.rs @@ -77,7 +77,7 @@ unsafe fn main_0() -> i32 { ud.a[(0_usize)] = 3; assert!(((ud.a[(0_usize)]) == (3))); assert!(((ud.v.len()) == (0_usize))); - let mut filt: FieldIsLibcType = unsafe { ::zero_init() }; + let mut filt: FieldIsLibcType = ::default(); filt.addr.sa_family = (2 as libc::sa_family_t); assert!(((filt.addr.sa_family as i32) == (2))); return 0; diff --git a/tests/unit/out/unsafe/local_anon_struct_collision.rs b/tests/unit/out/unsafe/local_anon_struct_collision.rs index 5f29852560..68bde68f1c 100644 --- a/tests/unit/out/unsafe/local_anon_struct_collision.rs +++ b/tests/unit/out/unsafe/local_anon_struct_collision.rs @@ -7,7 +7,7 @@ use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; pub unsafe fn first_0() -> i32 { - let mut p: anon_1 = unsafe { ::zero_init() }; + let mut p: anon_1 = ::default(); p.x = 1; p.y = 2; return ((p.x) + (p.y)); @@ -27,7 +27,7 @@ pub struct anon_1 { pub y: i32, } pub unsafe fn second_2() -> i32 { - let mut q: anon_3 = unsafe { ::zero_init() }; + let mut q: anon_3 = ::default(); q.a = 10_i64; q.b = 20_i64; return (((q.a) + (q.b)) as i32); diff --git a/tests/unit/out/unsafe/memcpy_struct_bytes.rs b/tests/unit/out/unsafe/memcpy_struct_bytes.rs index c95fcbb6cf..48854dadf5 100644 --- a/tests/unit/out/unsafe/memcpy_struct_bytes.rs +++ b/tests/unit/out/unsafe/memcpy_struct_bytes.rs @@ -37,7 +37,7 @@ unsafe fn main_0() -> i32 { } __tmp_0 }; - let mut dst: point = unsafe { ::zero_init() }; + let mut dst: point = ::default(); { let mut __tmp_2 = { ((&mut dst as *mut point) as *mut ::libc::c_void) }; let mut __tmp_3 = { (buf.as_mut_ptr() as *const ::libc::c_void) }; diff --git a/tests/unit/out/unsafe/memcpy_struct_layouts.rs b/tests/unit/out/unsafe/memcpy_struct_layouts.rs index cd141664b4..f2176c68df 100644 --- a/tests/unit/out/unsafe/memcpy_struct_layouts.rs +++ b/tests/unit/out/unsafe/memcpy_struct_layouts.rs @@ -112,7 +112,7 @@ unsafe fn main_0() -> i32 { assert!( ((buf[((::std::mem::size_of::() as usize).wrapping_add(4_usize))] as i32) == (6)) ); - let mut p2: [packed; 2] = [unsafe { ::zero_init() }; 2]; + let mut p2: [packed; 2] = [::default(); 2]; { let mut __tmp_2 = { (p2.as_mut_ptr() as *mut ::libc::c_void) }; let mut __tmp_3 = { (buf.as_mut_ptr() as *const ::libc::c_void) }; @@ -154,7 +154,7 @@ unsafe fn main_0() -> i32 { ((buf[((::std::mem::size_of::() as usize).wrapping_add(8_usize))] as i32) == (6)) ); - let mut r2: [reordered; 2] = [unsafe { ::zero_init() }; 2]; + let mut r2: [reordered; 2] = [::default(); 2]; { let mut __tmp_6 = { (r2.as_mut_ptr() as *mut ::libc::c_void) }; let mut __tmp_7 = { (buf.as_mut_ptr() as *const ::libc::c_void) }; @@ -198,7 +198,7 @@ unsafe fn main_0() -> i32 { assert!( ((buf[((::std::mem::size_of::() as usize).wrapping_add(16_usize))] as i32) == (6)) ); - let mut n2: [nested; 2] = [unsafe { ::zero_init() }; 2]; + let mut n2: [nested; 2] = [::default(); 2]; { let mut __tmp_10 = { (n2.as_mut_ptr() as *mut ::libc::c_void) }; let mut __tmp_11 = { (buf.as_mut_ptr() as *const ::libc::c_void) }; @@ -237,7 +237,7 @@ unsafe fn main_0() -> i32 { ((buf[((::std::mem::size_of::() as usize).wrapping_add(1_usize))] as i32) == ('d' as i32)) ); - let mut a2: [array; 2] = [unsafe { ::zero_init() }; 2]; + let mut a2: [array; 2] = [::default(); 2]; { let mut __tmp_14 = { (a2.as_mut_ptr() as *mut ::libc::c_void) }; let mut __tmp_15 = { (buf.as_mut_ptr() as *const ::libc::c_void) }; diff --git a/tests/unit/out/unsafe/new.rs b/tests/unit/out/unsafe/new.rs index 5ff648dc5e..054a7b3e63 100644 --- a/tests/unit/out/unsafe/new.rs +++ b/tests/unit/out/unsafe/new.rs @@ -47,7 +47,7 @@ unsafe fn main_0() -> i32 { ::std::mem::drop(Box::from_raw(__p)) } }; - let mut p: *mut Pair = (Box::leak(Box::new(unsafe { ::zero_init() })) as *mut Pair); + let mut p: *mut Pair = (Box::leak(Box::new(::default())) as *mut Pair); (*p).x = 1; (*p).y = 2; assert!(((((*p).x) + ((*p).y)) == (3))); diff --git a/tests/unit/out/unsafe/new_struct.rs b/tests/unit/out/unsafe/new_struct.rs index 1de8290e5b..ba8b132cca 100644 --- a/tests/unit/out/unsafe/new_struct.rs +++ b/tests/unit/out/unsafe/new_struct.rs @@ -58,7 +58,7 @@ unsafe fn main_0() -> i32 { let mut t: Triple = Triple { a: 1, b: 0_i32, - p: unsafe { ::zero_init() }, + p: ::default(), }; assert!(((t.a) == (1))); assert!(((t.b) == (0))); @@ -66,7 +66,7 @@ unsafe fn main_0() -> i32 { let mut q: *mut Triple = (Box::leak(Box::new(Triple { a: 2, b: 3, - p: unsafe { ::zero_init() }, + p: ::default(), })) as *mut Triple); assert!((((*q).a) == (2))); assert!((((*q).b) == (3))); diff --git a/tests/unit/out/unsafe/opaque_record_copy.rs b/tests/unit/out/unsafe/opaque_record_copy.rs index c4fceeb3b0..d85b67666a 100644 --- a/tests/unit/out/unsafe/opaque_record_copy.rs +++ b/tests/unit/out/unsafe/opaque_record_copy.rs @@ -42,7 +42,7 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut a: Wrapper_Probe_ = unsafe { ::zero_init() }; + let mut a: Wrapper_Probe_ = ::default(); a.tag = 3; let mut b: Wrapper_Probe_ = a; assert!(((b.tag) == (3))); diff --git a/tests/unit/out/unsafe/operator_member_pointer_member.rs b/tests/unit/out/unsafe/operator_member_pointer_member.rs index 902645dc28..6245e1e08c 100644 --- a/tests/unit/out/unsafe/operator_member_pointer_member.rs +++ b/tests/unit/out/unsafe/operator_member_pointer_member.rs @@ -99,7 +99,7 @@ unsafe fn main_0() -> i32 { assert!(((*p) == (1))); (*p) = 5; assert!(((s.data[(0) as usize]) == (5))); - let mut t: Table = unsafe {

::zero_init() }; + let mut t: Table =
::default(); assert!(((*(unsafe { Table::operator_index(1,) })) == (8))); (*(unsafe { Table::operator_index(1) })) = 80; assert!((((*std::cell::LazyCell::force_mut(&mut *&raw mut table_0))[(1) as usize]) == (80))); diff --git a/tests/unit/out/unsafe/operator_other_member.rs b/tests/unit/out/unsafe/operator_other_member.rs index ba8c37a2bd..a65549e356 100644 --- a/tests/unit/out/unsafe/operator_other_member.rs +++ b/tests/unit/out/unsafe/operator_other_member.rs @@ -88,7 +88,7 @@ unsafe fn main_0() -> i32 { assert!((unsafe { S::to_bool(&raw const s,) })); assert!(!(unsafe { S::to_bool(&raw const z,) })); assert!((unsafe { S::to_bool(&raw const s,) }) && (!(unsafe { S::to_bool(&raw const z,) }))); - let mut st: Static = unsafe { ::zero_init() }; + let mut st: Static = ::default(); assert!(((unsafe { Static::operator_call(6, 7,) }) == (42))); assert!(((unsafe { S::operator_call_1(&S { v: 5 },) }) == (5))); assert!(((unsafe { S::operator_call_3(&S { v: 5 }, 1, 1,) }) == (7))); diff --git a/tests/unit/out/unsafe/overload_mangling.rs b/tests/unit/out/unsafe/overload_mangling.rs index 221e93e98c..b3d099e8aa 100644 --- a/tests/unit/out/unsafe/overload_mangling.rs +++ b/tests/unit/out/unsafe/overload_mangling.rs @@ -209,7 +209,7 @@ unsafe fn main_0() -> i32 { }) == (107)) ); assert!(((z) == (6))); - let mut a: Access_S_ = unsafe { ::zero_init() }; + let mut a: Access_S_ = ::default(); let mut cs: *const S = (&mut s as *mut S).cast_const(); let cr: *const S = &s; assert!(((unsafe { Access_S_::get_1(&raw mut a, (&mut s as *mut S),) }) == (100))); diff --git a/tests/unit/out/unsafe/push_emplace_back.rs b/tests/unit/out/unsafe/push_emplace_back.rs index f48b9699c7..3c4f26d942 100644 --- a/tests/unit/out/unsafe/push_emplace_back.rs +++ b/tests/unit/out/unsafe/push_emplace_back.rs @@ -368,7 +368,7 @@ unsafe fn main_0() -> i32 { let mut chunks: Vec = Vec::new(); (unsafe { shrink_through_ptr_2((&mut chunks as *mut Vec)) }); assert!(chunks.is_empty()); - let mut w: Writer = unsafe { ::zero_init() }; + let mut w: Writer = ::default(); w.chunk.data = 42; w.output = (&mut chunks as *mut Vec); (unsafe { nested_push_move_3((&mut w as *mut Writer)) }); diff --git a/tests/unit/out/unsafe/random.rs b/tests/unit/out/unsafe/random.rs index 30df31afe1..f89e2b1649 100644 --- a/tests/unit/out/unsafe/random.rs +++ b/tests/unit/out/unsafe/random.rs @@ -221,8 +221,8 @@ unsafe fn main_0() -> i32 { y1.pair = (&mut y2 as *mut Pair); y2.pair = (&mut y3 as *mut Pair); (unsafe { Pair::method(&raw mut (*(*y1.pair).pair)) }); - let mut x: X1 = unsafe { ::zero_init() }; - let mut y: X1 = unsafe { ::zero_init() }; + let mut x: X1 = ::default(); + let mut y: X1 = ::default(); x1 = ((unsafe { zero_0() }) + (y1.x)); y1.x = ((unsafe { zero_0() }) + (5)); let mut ptr2ptr_1: *mut *mut i32 = (&mut px1 as *mut *mut i32); diff --git a/tests/unit/out/unsafe/reinterpret_cast_ptr_cmp.rs b/tests/unit/out/unsafe/reinterpret_cast_ptr_cmp.rs index 9f36ee68b7..f77b1f973d 100644 --- a/tests/unit/out/unsafe/reinterpret_cast_ptr_cmp.rs +++ b/tests/unit/out/unsafe/reinterpret_cast_ptr_cmp.rs @@ -55,7 +55,7 @@ pub struct P { pub arr: [*mut i32; 3], } pub unsafe fn typed_0() { - let mut w: W = unsafe { ::zero_init() }; + let mut w: W = ::default(); let mut p: *mut S = (&mut w.arr[(2) as usize] as *mut S); let mut q: *mut S = ((((&mut w as *mut W) as *mut libc::c_char) .offset((::std::mem::size_of::()) as isize) @@ -86,7 +86,7 @@ pub unsafe fn typed_0() { ((((f as usize - ptrs.as_mut_ptr() as usize) / ::std::mem::size_of::<*mut i32>()) as i64) == (2_i64)) ); - let mut s: P = unsafe {

::zero_init() }; + let mut s: P =

::default(); let mut a: *mut *mut i32 = (&mut s.a as *mut *mut i32); let mut b: *mut *mut i32 = (&mut s.arr[(1) as usize] as *mut *mut i32); assert!(((a) < (b))); diff --git a/tests/unit/out/unsafe/reinterpret_cast_struct.rs b/tests/unit/out/unsafe/reinterpret_cast_struct.rs index 8d9a76d9e9..f4fc41080d 100644 --- a/tests/unit/out/unsafe/reinterpret_cast_struct.rs +++ b/tests/unit/out/unsafe/reinterpret_cast_struct.rs @@ -29,7 +29,7 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut p: Point = unsafe { ::zero_init() }; + let mut p: Point = ::default(); p.x = 67305985; p.y = 134678021; let mut bytes: *mut u8 = ((&mut p as *mut Point) as *mut u8); diff --git a/tests/unit/out/unsafe/return_move.rs b/tests/unit/out/unsafe/return_move.rs index e5e391763f..63ac26572d 100644 --- a/tests/unit/out/unsafe/return_move.rs +++ b/tests/unit/out/unsafe/return_move.rs @@ -75,7 +75,7 @@ pub unsafe fn address_taken_8(mut n: *mut node) -> *mut node { }; } pub unsafe fn ret_struct_9(mut a: i32, mut n: *mut node) -> pair_t { - let mut p: pair_t = unsafe { ::zero_init() }; + let mut p: pair_t = ::default(); p.a = a; p.n = n; return p; diff --git a/tests/unit/out/unsafe/self_referencing_initializer.rs b/tests/unit/out/unsafe/self_referencing_initializer.rs index d63dff2639..4284d0f162 100644 --- a/tests/unit/out/unsafe/self_referencing_initializer.rs +++ b/tests/unit/out/unsafe/self_referencing_initializer.rs @@ -70,12 +70,12 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut list: list_head = unsafe { ::zero_init() }; + let mut list: list_head = ::default(); list = list_head { next: (&mut list as *mut list_head), }; assert!(((list.next) == (&mut list as *mut list_head))); - let mut n: node = unsafe { ::zero_init() }; + let mut n: node = ::default(); n = node { value: 42, value_ptr: (&mut n.value as *mut i32), @@ -83,7 +83,7 @@ unsafe fn main_0() -> i32 { assert!(((n.value_ptr) == (&mut n.value as *mut i32))); (*n.value_ptr) = 7; assert!(((n.value) == (7))); - let mut arr: [list_head; 2] = [unsafe { ::zero_init() }; 2]; + let mut arr: [list_head; 2] = [::default(); 2]; arr = [ list_head { next: (&mut arr[(1) as usize] as *mut list_head), @@ -101,7 +101,7 @@ unsafe fn main_0() -> i32 { }; assert!(((d.next) == (&mut d as *mut node_with_defaults))); assert!(((d.value) == (3))); - let mut called: list_head = unsafe { ::zero_init() }; + let mut called: list_head = ::default(); called = list_head { next: (unsafe { init_0((&mut called as *mut list_head)) }), }; diff --git a/tests/unit/out/unsafe/static_local.rs b/tests/unit/out/unsafe/static_local.rs index bd66951774..695416d24e 100644 --- a/tests/unit/out/unsafe/static_local.rs +++ b/tests/unit/out/unsafe/static_local.rs @@ -18,8 +18,7 @@ static mut static_b_3: std::cell::LazyCell = std::cell::LazyCell::new(|| u static mut kX1_4: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 1 }); static mut kX2_5: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 2 }); pub unsafe fn from_local_class_6() -> i32 { - return ((unsafe { S_8::get(&unsafe { ::zero_init() }) }) - + (unsafe { S_8::get(&unsafe { ::zero_init() }) })); + return ((unsafe { S_8::get(&::default()) }) + (unsafe { S_8::get(&::default()) })); } static mut x_7: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 3 }); #[repr(C)] diff --git a/tests/unit/out/unsafe/static_var_in_class.rs b/tests/unit/out/unsafe/static_var_in_class.rs index b3d64f0d6f..ca8a058c54 100644 --- a/tests/unit/out/unsafe/static_var_in_class.rs +++ b/tests/unit/out/unsafe/static_var_in_class.rs @@ -54,10 +54,10 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut c: C = unsafe { ::zero_init() }; + let mut c: C = ::default(); assert!(((unsafe { C::get(&raw mut c,) }) == (1))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut inner_const_1)) == (2))); - let mut s: S = unsafe { ::zero_init() }; + let mut s: S = ::default(); let mut p: *mut S = (&mut s as *mut S); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut inner_const_1)) == (2))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut inner_const_1)) == (2))); diff --git a/tests/unit/out/unsafe/struct_2d_array_field.rs b/tests/unit/out/unsafe/struct_2d_array_field.rs index 1b347a1a1f..1a9a185392 100644 --- a/tests/unit/out/unsafe/struct_2d_array_field.rs +++ b/tests/unit/out/unsafe/struct_2d_array_field.rs @@ -103,7 +103,7 @@ unsafe fn main_0() -> i32 { let mut p: *const libc::c_char = (local.rows[(2) as usize].as_mut_ptr()).cast_const(); assert!((((*p.offset((0) as isize)) as i32) == ('t' as i32))); assert!(((local.count) == (3_usize))); - let mut copy: table = unsafe {

::zero_init() }; + let mut copy: table =
::default(); { let mut __tmp_0 = { ((&mut copy.rows as *mut [[libc::c_char; 10]; 3]) as *mut ::libc::c_void) }; diff --git a/tests/unit/out/unsafe/struct_member_array_adjacency.rs b/tests/unit/out/unsafe/struct_member_array_adjacency.rs index 2ca75ffb3b..96f67cdaad 100644 --- a/tests/unit/out/unsafe/struct_member_array_adjacency.rs +++ b/tests/unit/out/unsafe/struct_member_array_adjacency.rs @@ -27,7 +27,7 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut s: pair = unsafe { ::zero_init() }; + let mut s: pair = ::default(); assert!(((s.a.as_mut_ptr().offset((4) as isize)) == (s.b.as_mut_ptr()))); return 0; } diff --git a/tests/unit/out/unsafe/struct_ptr.rs b/tests/unit/out/unsafe/struct_ptr.rs index 1e9f475d03..94f40894c1 100644 --- a/tests/unit/out/unsafe/struct_ptr.rs +++ b/tests/unit/out/unsafe/struct_ptr.rs @@ -28,7 +28,7 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut obj: XX = unsafe { ::zero_init() }; + let mut obj: XX = ::default(); let mut ptr: *mut XX = (&mut obj as *mut XX); (*ptr).x = 2; let mut c: bool = false; diff --git a/tests/unit/out/unsafe/tag_vs_identifier_collision.rs b/tests/unit/out/unsafe/tag_vs_identifier_collision.rs index e4e7b40b9e..bf9f975ce4 100644 --- a/tests/unit/out/unsafe/tag_vs_identifier_collision.rs +++ b/tests/unit/out/unsafe/tag_vs_identifier_collision.rs @@ -118,31 +118,31 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut w: widget = unsafe { ::zero_init() }; + let mut w: widget = ::default(); w.id = 7; w.mode = widget_enum_MODE_ACTIVE; assert!(((unsafe { is_active_0((&mut w as *mut widget),) }) != 0)); w.mode = widget_enum_MODE_DONE; assert!(((w.mode as u32) == ((widget_enum_MODE_DONE as i32) as u32))); - let mut p: point_struct = unsafe { ::zero_init() }; + let mut p: point_struct = ::default(); p.x = 3; p.y = 4; assert!((((p.x) + (p.y)) == (7))); - let mut up: point = unsafe { ::zero_init() }; + let mut up: point = ::default(); up.whole = 5; assert!(((up.whole) == (5))); - let mut b: slot_union = unsafe { ::zero_init() }; + let mut b: slot_union = ::default(); b.i = 9; assert!(((b.i) == (9))); let mut e: slot = slot_SLOT_B; assert!(((e as u32) == ((slot_SLOT_B as i32) as u32))); - let mut inner_tag: Inner = unsafe { ::zero_init() }; + let mut inner_tag: Inner = ::default(); inner_tag.tag_field = 11; assert!(((inner_tag.tag_field) == (11))); - let mut inner_typedef: Inner_struct = unsafe { ::zero_init() }; + let mut inner_typedef: Inner_struct = ::default(); inner_typedef.typedef_field = 22; assert!(((inner_typedef.typedef_field) == (22))); - let mut o: Outer = unsafe { ::zero_init() }; + let mut o: Outer = ::default(); o.field.tag_field = 33; assert!(((o.field.tag_field) == (33))); assert!(((w.id) == (7))); diff --git a/tests/unit/out/unsafe/typedef-anon-struct.rs b/tests/unit/out/unsafe/typedef-anon-struct.rs index 263a317175..9a651b0e2a 100644 --- a/tests/unit/out/unsafe/typedef-anon-struct.rs +++ b/tests/unit/out/unsafe/typedef-anon-struct.rs @@ -53,7 +53,7 @@ pub fn main() { } unsafe fn main_0() -> i32 { object_unsafe!(o, Outer::constructor_1()); - let mut info: Outer_RunInfo = unsafe { ::zero_init() }; + let mut info: Outer_RunInfo = ::default(); info.block_idx = 1; info.num_extra_zero_runs = 2; o.runs.push_copied(&mut info); 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 0cf7d51122..c38d4e22a3 100644 --- a/tests/unit/out/unsafe/unary_expr_or_type_trait.rs +++ b/tests/unit/out/unsafe/unary_expr_or_type_trait.rs @@ -38,7 +38,7 @@ pub fn main() { } unsafe fn main_0() -> i32 { let mut arr: [i64; 4] = [0_i64; 4]; - let mut s: S = unsafe { ::zero_init() }; + let mut s: S = ::default(); assert!(((::std::mem::size_of::()) == (4_usize))); assert!(((::std::mem::size_of::<[i64; 4]>()) == (32_usize))); assert!(((::std::mem::size_of::()) == (16_usize))); diff --git a/tests/unit/out/unsafe/unboxed_records.rs b/tests/unit/out/unsafe/unboxed_records.rs index 2581dfc387..29a95a73dc 100644 --- a/tests/unit/out/unsafe/unboxed_records.rs +++ b/tests/unit/out/unsafe/unboxed_records.rs @@ -106,7 +106,7 @@ pub fn main() { unsafe fn main_0() -> i32 { let mut data: [i32; 4] = [0, 0, 0, 0]; let mut in_: [i32; 4] = [1, 2, 3, 4]; - let mut cookie: Cookie = unsafe { ::zero_init() }; + let mut cookie: Cookie = ::default(); cookie.x = 2; cookie.data = data.as_mut_ptr(); cookie.in_ = (in_.as_mut_ptr()).cast_const(); @@ -118,7 +118,7 @@ unsafe fn main_0() -> i32 { && ((data[(3) as usize]) == (8)) ); assert!(((unsafe { get_1(&cookie,) }) == (2))); - let mut local: Inner = unsafe { ::zero_init() }; + let mut local: Inner = ::default(); local.a = 4; local.b = ((local.a) * (2)); local.a.postfix_inc(); diff --git a/tests/unit/out/unsafe/union_addrof_external.rs b/tests/unit/out/unsafe/union_addrof_external.rs index 606ed0dd4a..b0143bbcc1 100644 --- a/tests/unit/out/unsafe/union_addrof_external.rs +++ b/tests/unit/out/unsafe/union_addrof_external.rs @@ -79,7 +79,7 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut c: Container = unsafe { ::zero_init() }; + let mut c: Container = ::default(); { let mut __tmp_1 = { ((&mut c as *mut Container) as *mut ::libc::c_void) }; let byte_0 = __tmp_1 as *mut u8; diff --git a/tests/unit/out/unsafe/union_basic.rs b/tests/unit/out/unsafe/union_basic.rs index 9f48674804..a81ef0c5fc 100644 --- a/tests/unit/out/unsafe/union_basic.rs +++ b/tests/unit/out/unsafe/union_basic.rs @@ -54,8 +54,8 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut u: basic = unsafe { ::zero_init() }; - let mut e: empty = unsafe { ::zero_init() }; + let mut u: basic = ::default(); + let mut e: empty = ::default(); u.i = 42; assert!(((u.i) == (42))); u.f = 3.14_f32; @@ -83,13 +83,13 @@ unsafe fn main_0() -> i32 { let mut copied: basic = basic { i: 7 }; assert!(((copied.i) == (7))); { - let mut anon_0: anon_0 = unsafe { ::zero_init() }; + let mut anon_0: anon_0 = ::default(); anon_0.ai = 11; assert!(((anon_0.ai) == (11))); anon_0.ai = 1065353216; assert!(((anon_0.af) == (1_f32))); } - let mut us: underscores = unsafe { ::zero_init() }; + let mut us: underscores = ::default(); us.__ = 5; assert!(((us.__) == (5))); us.___ = 2.5_f64; diff --git a/tests/unit/out/unsafe/union_cross_arm_cast.rs b/tests/unit/out/unsafe/union_cross_arm_cast.rs index 3f76c032f1..caf353a767 100644 --- a/tests/unit/out/unsafe/union_cross_arm_cast.rs +++ b/tests/unit/out/unsafe/union_cross_arm_cast.rs @@ -73,7 +73,7 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut c: Container = unsafe { ::zero_init() }; + let mut c: Container = ::default(); { let mut __tmp_0 = { ((&mut c as *mut Container) as *mut ::libc::c_void) }; let byte_0 = __tmp_0 as *mut u8; diff --git a/tests/unit/out/unsafe/union_field_alignment.rs b/tests/unit/out/unsafe/union_field_alignment.rs index e892dfedd3..716524aa50 100644 --- a/tests/unit/out/unsafe/union_field_alignment.rs +++ b/tests/unit/out/unsafe/union_field_alignment.rs @@ -41,7 +41,7 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut n: node = unsafe { ::zero_init() }; + let mut n: node = ::default(); n.next = std::ptr::null_mut(); (*n.x.bytes.as_mut_ptr().add((0) as usize)) = 171_u8; assert!((((*n.x.bytes.as_mut_ptr().add((0) as usize)) as i32) == (171))); diff --git a/tests/unit/out/unsafe/union_memset_memcpy.rs b/tests/unit/out/unsafe/union_memset_memcpy.rs index 70167889cd..c2c505deac 100644 --- a/tests/unit/out/unsafe/union_memset_memcpy.rs +++ b/tests/unit/out/unsafe/union_memset_memcpy.rs @@ -71,7 +71,7 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut c: Container = unsafe { ::zero_init() }; + let mut c: Container = ::default(); { let mut __tmp_0 = { ((&mut c as *mut Container) as *mut ::libc::c_void) }; let byte_0 = __tmp_0 as *mut u8; diff --git a/tests/unit/out/unsafe/union_nested.rs b/tests/unit/out/unsafe/union_nested.rs index 91cfc3df91..263962e6f2 100644 --- a/tests/unit/out/unsafe/union_nested.rs +++ b/tests/unit/out/unsafe/union_nested.rs @@ -85,7 +85,7 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut ex: Outer = unsafe { ::zero_init() }; + let mut ex: Outer = ::default(); { let mut __tmp_0 = { ((&mut ex as *mut Outer) as *mut ::libc::c_void) }; let byte_0 = __tmp_0 as *mut u8; diff --git a/tests/unit/out/unsafe/union_pointer_pun_address.rs b/tests/unit/out/unsafe/union_pointer_pun_address.rs index ac8a43a0a4..e72b0ad653 100644 --- a/tests/unit/out/unsafe/union_pointer_pun_address.rs +++ b/tests/unit/out/unsafe/union_pointer_pun_address.rs @@ -41,7 +41,7 @@ pub fn main() { } unsafe fn main_0() -> i32 { let mut a: node_a = node_a { n: 123 }; - let mut ptr: anon_0 = unsafe { ::zero_init() }; + let mut ptr: anon_0 = ::default(); ptr.to_a = (&mut a as *mut node_a); let mut out: *mut node_b = ptr.to_b; assert!(((out as *mut ::libc::c_void) == ((&mut a as *mut node_a) as *mut ::libc::c_void))); diff --git a/tests/unit/out/unsafe/union_pointer_pun_writethrough.rs b/tests/unit/out/unsafe/union_pointer_pun_writethrough.rs index b1badaf09c..22d954cc58 100644 --- a/tests/unit/out/unsafe/union_pointer_pun_writethrough.rs +++ b/tests/unit/out/unsafe/union_pointer_pun_writethrough.rs @@ -14,7 +14,7 @@ pub fn main() { } unsafe fn main_0() -> i32 { let mut x: i64 = (-1_i32 as i64); - let mut pp: anon_0 = unsafe { ::zero_init() }; + let mut pp: anon_0 = ::default(); pp.as_signed = (&mut x as *mut i64); (*pp.as_unsigned) = 42_u64; assert!(((x) == (42_i64))); diff --git a/tests/unit/out/unsafe/union_struct_dual_use.rs b/tests/unit/out/unsafe/union_struct_dual_use.rs index 3f8a8f217e..8470abf224 100644 --- a/tests/unit/out/unsafe/union_struct_dual_use.rs +++ b/tests/unit/out/unsafe/union_struct_dual_use.rs @@ -57,11 +57,11 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut standalone: Inner = unsafe { ::zero_init() }; + let mut standalone: Inner = ::default(); standalone.a = 3; standalone.b = 4; assert!(((unsafe { sum_inner_0((&mut standalone as *mut Inner),) }) == (7))); - let mut outer: Outer = unsafe { ::zero_init() }; + let mut outer: Outer = ::default(); { let mut __tmp_0 = { ((&mut outer as *mut Outer) as *mut ::libc::c_void) }; let byte_0 = __tmp_0 as *mut u8; diff --git a/tests/unit/out/unsafe/union_tagged_many_arms.rs b/tests/unit/out/unsafe/union_tagged_many_arms.rs index 5ec788b3f1..49fdbd7443 100644 --- a/tests/unit/out/unsafe/union_tagged_many_arms.rs +++ b/tests/unit/out/unsafe/union_tagged_many_arms.rs @@ -50,24 +50,24 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut a: Slot = unsafe { ::zero_init() }; + let mut a: Slot = ::default(); a.tag = Tag_enum_T_NUM_S; a.payload.signed_n = (-7_i32 as i64); assert!(((a.payload.signed_n) == (-7_i32 as i64))); - let mut b: Slot = unsafe { ::zero_init() }; + let mut b: Slot = ::default(); b.tag = Tag_enum_T_NUM_U; b.payload.unsigned_n = 3735928559_u64; assert!(((b.payload.unsigned_n) == (3735928559_u64))); - let mut c: Slot = unsafe { ::zero_init() }; + let mut c: Slot = ::default(); c.tag = Tag_enum_T_TEXT; c.payload.text = (c"hello".as_ptr().cast_mut()).cast_const(); assert!((((*c.payload.text.offset((0) as isize)) as i32) == ('h' as i32))); - let mut d: Slot = unsafe { ::zero_init() }; + let mut d: Slot = ::default(); d.tag = Tag_enum_T_FLOAT; d.payload.f = 1.5_f64; assert!(((d.payload.f) == (1.5_f64))); let mut x: i32 = 0; - let mut e: Slot = unsafe { ::zero_init() }; + let mut e: Slot = ::default(); e.tag = Tag_enum_T_REF; e.payload.handle = ((&mut x as *mut i32) as *mut ::libc::c_void); assert!(((e.payload.handle) == ((&mut x as *mut i32) as *mut ::libc::c_void))); diff --git a/tests/unit/out/unsafe/union_tagged_simple.rs b/tests/unit/out/unsafe/union_tagged_simple.rs index 323419f7dc..f75ecf15b5 100644 --- a/tests/unit/out/unsafe/union_tagged_simple.rs +++ b/tests/unit/out/unsafe/union_tagged_simple.rs @@ -46,13 +46,13 @@ pub fn main() { } unsafe fn main_0() -> i32 { let mut dummy: i32 = 0; - let mut m1: Event = unsafe { ::zero_init() }; + let mut m1: Event = ::default(); m1.kind = Kind_enum_KIND_DONE; m1.handle = ((&mut dummy as *mut i32) as *mut ::libc::c_void); m1.payload.code = 42; assert!(((m1.kind as u32) == ((Kind_enum_KIND_DONE as i32) as u32))); assert!(((m1.payload.code) == (42))); - let mut m2: Event = unsafe { ::zero_init() }; + let mut m2: Event = ::default(); m2.kind = Kind_enum_KIND_NONE; m2.handle = ((&mut dummy as *mut i32) as *mut ::libc::c_void); m2.payload.obj = ((&mut dummy as *mut i32) as *mut ::libc::c_void); diff --git a/tests/unit/out/unsafe/union_tagged_struct_arms.rs b/tests/unit/out/unsafe/union_tagged_struct_arms.rs index fdf337fa9d..beb1ad2c73 100644 --- a/tests/unit/out/unsafe/union_tagged_struct_arms.rs +++ b/tests/unit/out/unsafe/union_tagged_struct_arms.rs @@ -95,7 +95,7 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut p_list: Branch = unsafe { ::zero_init() }; + let mut p_list: Branch = ::default(); p_list.choice = Choice_enum_C_LIST; p_list.index = 0; p_list.v.list.items = (*std::cell::LazyCell::force_mut(&mut *&raw mut items_4)).as_mut_ptr(); @@ -106,7 +106,7 @@ unsafe fn main_0() -> i32 { (((*(*p_list.v.list.items.offset((1) as isize)).offset((0) as isize)) as i32) == ('b' as i32)) ); - let mut p_letters: Branch = unsafe { ::zero_init() }; + let mut p_letters: Branch = ::default(); p_letters.choice = Choice_enum_C_LETTERS; p_letters.index = 1; p_letters.v.letters.lo = ('a' as i32); @@ -114,7 +114,7 @@ unsafe fn main_0() -> i32 { p_letters.v.letters.curr = ('m' as i32); p_letters.v.letters.step = 1_u8; assert!((((p_letters.v.letters.hi) - (p_letters.v.letters.lo)) == (25))); - let mut p_integers: Branch = unsafe { ::zero_init() }; + let mut p_integers: Branch = ::default(); p_integers.choice = Choice_enum_C_INTEGERS; p_integers.index = 2; p_integers.v.integers.lo = 1_i64; 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 cb4d73594a..be006923f8 100644 --- a/tests/unit/out/unsafe/union_void_ptr_sized_deref.rs +++ b/tests/unit/out/unsafe/union_void_ptr_sized_deref.rs @@ -69,7 +69,7 @@ unsafe fn main_0() -> i32 { let mut buf64: i64 = 0_i64; let mut buf32: i32 = 0; let mut buf16: i16 = 0_i16; - let mut s: Sink = unsafe { ::zero_init() }; + let mut s: Sink = ::default(); s.width = Width_enum_W_64; s.out.handle = ((&mut buf64 as *mut i64) as *mut ::libc::c_void); (unsafe { write_count_1((&mut s as *mut Sink), 1234605616436508552_i64) }); diff --git a/tests/unit/out/unsafe/unique_ptr.rs b/tests/unit/out/unsafe/unique_ptr.rs index ff5faf37ed..0403bf511f 100644 --- a/tests/unit/out/unsafe/unique_ptr.rs +++ b/tests/unit/out/unsafe/unique_ptr.rs @@ -141,7 +141,7 @@ pub unsafe fn DoStuffWithSafePointer_0(safe_ptr: *mut Option>) pub unsafe fn Consume_1(mut safe_ptr: Option>) -> i32 { let mut x: Option> = safe_ptr.take(); let mut p: Option> = Some(Box::from_raw( - (Box::leak(Box::new(unsafe { ::zero_init() })) as *mut Pair), + (Box::leak(Box::new(::default())) as *mut Pair), )); return ((*(*x.as_deref().map_or(::std::ptr::null_mut(), |v| { v as *const SafePointer as *mut SafePointer @@ -198,7 +198,7 @@ pub unsafe fn RndStuff_2() { } let mut x3: Option> = Some( (0..10_usize) - .map(|_| unsafe { ::zero_init() }) + .map(|_| ::default()) .collect::>(), ); { @@ -238,7 +238,7 @@ pub unsafe fn RndStuff_2() { } x3 = Some(Box::from_raw(Box::leak( (0..50_usize) - .map(|_| unsafe { ::zero_init() }) + .map(|_| ::default()) .collect::>(), ))); { diff --git a/tests/unit/out/unsafe/va_arg_struct_ctx.rs b/tests/unit/out/unsafe/va_arg_struct_ctx.rs index 3babc7bf84..24885426f9 100644 --- a/tests/unit/out/unsafe/va_arg_struct_ctx.rs +++ b/tests/unit/out/unsafe/va_arg_struct_ctx.rs @@ -61,7 +61,7 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut ctx: context = unsafe { ::zero_init() }; + let mut ctx: context = ::default(); ctx.verbose = 1; ctx.last_error = 0; (unsafe { @@ -81,7 +81,7 @@ unsafe fn main_0() -> i32 { ) }); assert!(((ctx.last_error) == (42))); - let mut v: value = unsafe { ::zero_init() }; + let mut v: value = ::default(); v.l = ((1_i64) << (40)); assert!(((unsafe { pick_1(1, Box::new([(v).into(),])) }) == ((1_i64) << (40)))); v.i = 7; From d174b0a6adce85ca4579e817cd27d1e86526fd01 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Sat, 5 Dec 2026 13:29:31 +0000 Subject: [PATCH 14/14] Use Default::default where possible --- cpp2rust/converter/converter.cpp | 58 ++++++---- cpp2rust/converter/converter.h | 3 + cpp2rust/converter/converter_lib.cpp | 82 +++++++++++++- cpp2rust/converter/converter_lib.h | 7 ++ .../converter/models/converter_refcount.cpp | 13 ++- .../converter/models/converter_refcount.h | 3 + .../out/refcount/defaulted_move_cross_tu.rs | 9 +- .../out/unsafe/defaulted_move_cross_tu.rs | 9 +- .../template_method_late_instantiation.rs | 9 +- .../template_method_late_instantiation.rs | 9 +- .../basic.link/out/refcount/basic.link.rs | 62 +++++++--- .../basic/basic.link/out/unsafe/basic.link.rs | 52 +++++++-- .../out/refcount/basic.scope.class.rs | 26 +++-- .../out/refcount/basic.scope.scope.rs | 73 ++++++++---- .../out/unsafe/basic.scope.class.rs | 26 +++-- .../out/unsafe/basic.scope.scope.rs | 66 +++++++---- .../out/refcount/class.mem.general.rs | 24 ++-- .../class.mem/out/unsafe/class.mem.general.rs | 26 +++-- .../dcl.init/out/refcount/dcl.init.general.rs | 70 +++++++----- .../dcl.init/out/unsafe/dcl.init.general.rs | 69 +++++++----- .../out/refcount/dcl.fct.default.rs | 26 +++-- .../dcl.meaning/out/unsafe/dcl.fct.default.rs | 26 +++-- .../allocator.requirements.general.rs | 7 +- .../unsafe/allocator.requirements.general.rs | 7 +- .../temp/temp.spec/out/refcount/temp.inst.rs | 30 +++-- .../temp/temp.spec/out/unsafe/temp.inst.rs | 24 +++- tests/unit/out/refcount/10_struct.rs | 15 ++- .../out/refcount/array_of_noncopy_struct.rs | 25 +++-- .../out/refcount/assignment_single_eval.rs | 7 +- tests/unit/out/refcount/cast.rs | 15 ++- tests/unit/out/refcount/class_templates.rs | 27 ++++- .../unit/out/refcount/container_field_addr.rs | 21 ++-- tests/unit/out/refcount/copy_assign.rs | 59 +++++++--- tests/unit/out/refcount/copy_ctor.rs | 22 +++- .../unit/out/refcount/copy_move_defaulted.rs | 106 +++++++++++++----- tests/unit/out/refcount/copy_move_deleted.rs | 27 ++++- .../unit/out/refcount/enum_underlying_type.rs | 17 ++- .../out/refcount/field_method_receiver.rs | 23 ++-- tests/unit/out/refcount/field_pointers.rs | 21 +++- .../refcount/foreach_disjoint_field_borrow.rs | 15 ++- .../out/refcount/global_non_const_init.rs | 26 +++-- tests/unit/out/refcount/huffman.rs | 19 +++- tests/unit/out/refcount/implicit_autoref.rs | 9 +- .../refcount/in_class_field_initializer.rs | 10 +- tests/unit/out/refcount/init_list.rs | 7 +- .../out/refcount/inline_container_fields.rs | 49 +++++--- tests/unit/out/refcount/kruskal.rs | 30 ++++- .../out/refcount/lambda_capture_copy_ctor.rs | 57 +++++----- .../unit/out/refcount/lambda_decltype_type.rs | 64 ++++++----- .../out/refcount/lambda_immediate_init.rs | 33 +++--- .../refcount/libc_struct_without_default.rs | 17 ++- tests/unit/out/refcount/map.rs | 8 +- tests/unit/out/refcount/map_try_emplace.rs | 14 ++- .../out/refcount/map_try_emplace_lvalues.rs | 66 +++++++---- tests/unit/out/refcount/move_assign.rs | 15 ++- tests/unit/out/refcount/move_ctor.rs | 11 +- tests/unit/out/refcount/push_emplace_back.rs | 57 ++++++---- .../refcount/self_referencing_initializer.rs | 15 ++- tests/unit/out/refcount/sort_no_copy.rs | 24 ++-- .../unit/out/refcount/struct_default_ctor.rs | 74 ++++++------ .../refcount/structured_binding_move_ctor.rs | 13 ++- tests/unit/out/refcount/swap_map_no_copy.rs | 54 ++++++--- .../unit/out/refcount/template_default_arg.rs | 34 +++--- .../unit/out/refcount/temporary_field_addr.rs | 22 +++- .../out/refcount/temporary_field_ctor_arg.rs | 7 +- .../out/refcount/temporary_field_two_args.rs | 20 +++- .../unit/out/refcount/typedef-anon-struct.rs | 9 +- tests/unit/out/refcount/unboxed_records.rs | 9 +- tests/unit/out/refcount/unique_ptr.rs | 7 +- .../out/refcount/unique_ptr_const_deref.rs | 9 +- .../out/refcount/unique_ptr_field_reset.rs | 15 ++- tests/unit/out/refcount/unique_ptr_nested.rs | 7 +- tests/unit/out/refcount/vector.rs | 15 ++- .../out/refcount/vector_subscript_direct.rs | 15 ++- tests/unit/out/refcount/void_cast.rs | 16 ++- tests/unit/out/unsafe/10_struct.rs | 13 ++- .../out/unsafe/array_of_noncopy_struct.rs | 19 ++-- .../unit/out/unsafe/assignment_single_eval.rs | 7 +- tests/unit/out/unsafe/cast.rs | 15 ++- tests/unit/out/unsafe/class_templates.rs | 27 ++++- tests/unit/out/unsafe/container_field_addr.rs | 21 ++-- tests/unit/out/unsafe/copy_assign.rs | 59 +++++++--- tests/unit/out/unsafe/copy_ctor.rs | 22 +++- tests/unit/out/unsafe/copy_move_defaulted.rs | 106 +++++++++++++----- tests/unit/out/unsafe/copy_move_deleted.rs | 27 ++++- tests/unit/out/unsafe/enum_underlying_type.rs | 9 +- .../unit/out/unsafe/field_method_receiver.rs | 17 ++- tests/unit/out/unsafe/field_pointers.rs | 21 +++- .../unsafe/foreach_disjoint_field_borrow.rs | 15 ++- .../unit/out/unsafe/global_non_const_init.rs | 32 +++--- tests/unit/out/unsafe/huffman.rs | 19 +++- tests/unit/out/unsafe/implicit_autoref.rs | 9 +- .../out/unsafe/in_class_field_initializer.rs | 10 +- tests/unit/out/unsafe/init_list.rs | 7 +- .../out/unsafe/inline_container_fields.rs | 41 +++++-- tests/unit/out/unsafe/kruskal.rs | 30 ++++- .../out/unsafe/lambda_capture_copy_ctor.rs | 48 ++++---- tests/unit/out/unsafe/lambda_decltype_type.rs | 62 +++++----- .../unit/out/unsafe/lambda_immediate_init.rs | 31 +++-- .../out/unsafe/libc_struct_without_default.rs | 15 ++- tests/unit/out/unsafe/map.rs | 8 +- tests/unit/out/unsafe/map_try_emplace.rs | 14 ++- .../out/unsafe/map_try_emplace_lvalues.rs | 60 ++++++---- tests/unit/out/unsafe/move_assign.rs | 15 ++- tests/unit/out/unsafe/move_ctor.rs | 11 +- tests/unit/out/unsafe/push_emplace_back.rs | 53 ++++++--- .../unsafe/self_referencing_initializer.rs | 15 ++- tests/unit/out/unsafe/sort_no_copy.rs | 20 ++-- tests/unit/out/unsafe/struct_default_ctor.rs | 70 ++++++------ .../unsafe/structured_binding_move_ctor.rs | 13 ++- tests/unit/out/unsafe/swap_map_no_copy.rs | 50 ++++++--- tests/unit/out/unsafe/template_default_arg.rs | 34 +++--- tests/unit/out/unsafe/temporary_field_addr.rs | 22 +++- .../out/unsafe/temporary_field_ctor_arg.rs | 7 +- .../out/unsafe/temporary_field_two_args.rs | 20 +++- tests/unit/out/unsafe/typedef-anon-struct.rs | 9 +- tests/unit/out/unsafe/unboxed_records.rs | 9 +- tests/unit/out/unsafe/unique_ptr.rs | 7 +- .../unit/out/unsafe/unique_ptr_const_deref.rs | 9 +- .../unit/out/unsafe/unique_ptr_field_reset.rs | 15 ++- tests/unit/out/unsafe/unique_ptr_nested.rs | 7 +- tests/unit/out/unsafe/vector.rs | 15 ++- .../out/unsafe/vector_subscript_direct.rs | 15 ++- tests/unit/out/unsafe/void_cast.rs | 16 ++- 124 files changed, 2286 insertions(+), 983 deletions(-) diff --git a/cpp2rust/converter/converter.cpp b/cpp2rust/converter/converter.cpp index 7a7de55051..a14a3c0650 100644 --- a/cpp2rust/converter/converter.cpp +++ b/cpp2rust/converter/converter.cpp @@ -641,7 +641,7 @@ void Converter::EmitHoistedDecl(clang::VarDecl *decl) { auto *record = decl->getType()->getAsRecordDecl(); StrCat(token::kAssign, record && IsUserDefinedDecl(record) && - !IsTriviallyDefaultConstructible(record) + !HasValueDefaultConstructor(record) ? ConvertVarZeroInit(decl) : ConvertVarDefaultInit(decl), token::kSemiColon); @@ -1503,6 +1503,11 @@ bool Converter::VisitCXXConstructorDecl(clang::CXXConstructorDecl *decl) { void Converter::ConvertCXXConstructorBody(clang::CXXConstructorDecl *decl) { EmitFunctionPreamble(decl); + if (ConstructsDefaultValue(decl)) { + StrCat(std::format("{}(::default());", + GetConstructorWrite())); + return; + } EmitConstructorInit(decl); ConvertBodyStmts(decl->getBody()); } @@ -1533,16 +1538,7 @@ void Converter::EmitConstructorFieldInits(clang::CXXConstructorDecl *decl) { for (const auto *field : record_decl->fields()) { auto field_name = GetNamedDeclAsString(field); - const clang::CXXCtorInitializer *ctor_initializer = nullptr; - for (const auto *init : definition->inits()) { - if (init->isMemberInitializer() && init->getMember() == field) { - ctor_initializer = init; - break; - } - } - - auto *init = ctor_initializer ? ctor_initializer->getInit() - : field->getInClassInitializer(); + auto *init = GetFieldInitializer(definition, field); if (auto *construct = init ? GetPlacementInitializer(init) : nullptr) { ConstructInPlace(init, construct, GetFieldPlacementReceiver(field_name)); continue; @@ -5090,9 +5086,10 @@ bool Converter::VisitCXXConstructExpr(clang::CXXConstructExpr *expr) { return false; } - if (ctor->isDefaultConstructor() && - !(ctor->isUserProvided() && IsUserDefinedDecl(ctor)) && - !IsConvertibleDefaultConstructor(ctor)) { + if ((ctor->isDefaultConstructor() && + !(ctor->isUserProvided() && IsUserDefinedDecl(ctor)) && + !IsConvertibleDefaultConstructor(ctor)) || + (ConstructsDefaultValue(ctor) && in_place_.expr != expr)) { EmitFresh(GetDefaultAsString(expr->getType())); return false; } @@ -5502,9 +5499,9 @@ std::string Converter::GetDefaultAsString(clang::QualType qual_type) { record && IsUserDefinedDecl(record)) { auto *cxx = clang::dyn_cast(record); ENSURE((!cxx || !cxx->hasDefaultConstructor() || - cxx->hasTrivialDefaultConstructor()) && - "a non-trivial default constructor constructs into storage"); - if (IsTriviallyDefaultConstructible(record)) { + HasValueDefaultConstructor(cxx)) && + "a default constructor that uses this constructs into storage"); + if (HasValueDefaultConstructor(record)) { return std::format("<{}>::default()", ToString(qual_type.getUnqualifiedType())); } @@ -6297,11 +6294,34 @@ bool Converter::RecordImplementsClone(const clang::RecordDecl *decl) { } void Converter::AddDefaultTrait(const clang::RecordDecl *decl) { - if (auto *default_ctor = GetConvertedDefaultConstructor(decl); - default_ctor && !GetRecordTrait(default_ctor)) { + auto *default_ctor = GetConvertedDefaultConstructor(decl); + if (default_ctor && !GetRecordTrait(default_ctor)) { AddDefaultConstructibleTrait(clang::cast(decl), default_ctor); } + if (default_ctor && !IsTriviallyDefaultConstructible(decl) && + HasValueDefaultConstructor(decl)) { + StrCat(keyword::kImpl, "Default for", GetRecordName(decl)); + PushBrace impl_brace(*this); + StrCat("fn default() -> Self"); + PushBrace fn_brace(*this); + StrCat(keyword_unsafe_); + PushBrace unsafe_brace(*this); + ConvertDefaultValue(clang::cast(decl), default_ctor); + } +} + +void Converter::ConvertDefaultValue(const clang::CXXRecordDecl *decl, + const clang::CXXConstructorDecl *ctor) { + auto *definition = + clang::cast(ctor->getDefinition()); + StrCat(GetRecordName(decl)); + PushBrace brace(*this); + for (const auto *field : decl->fields()) { + StrCat(GetNamedDeclAsString(field), token::kColon); + ConvertFieldInit(field, GetFieldInitializer(definition, field)); + StrCat(token::kComma); + } } void Converter::AddDefaultConstructibleTrait(const clang::CXXRecordDecl *decl, diff --git a/cpp2rust/converter/converter.h b/cpp2rust/converter/converter.h index 54d5e1cf8e..5b549b22b3 100644 --- a/cpp2rust/converter/converter.h +++ b/cpp2rust/converter/converter.h @@ -1025,6 +1025,9 @@ class Converter : public clang::RecursiveASTVisitor { virtual void AddDefaultTrait(const clang::RecordDecl *decl); + virtual void ConvertDefaultValue(const clang::CXXRecordDecl *decl, + const clang::CXXConstructorDecl *ctor); + // The CopyAssignable and MoveAssignable impls that call a copy assignment // operator that isn't their method (GetWrappedCopyAssignment). void AddAssignmentTraits(const clang::CXXRecordDecl *decl); diff --git a/cpp2rust/converter/converter_lib.cpp b/cpp2rust/converter/converter_lib.cpp index 6069bc9f98..d48b71add7 100644 --- a/cpp2rust/converter/converter_lib.cpp +++ b/cpp2rust/converter/converter_lib.cpp @@ -1383,7 +1383,8 @@ const clang::CXXConstructExpr *GetInPlaceConstruct(const clang::Expr *init) { if (ctor->isCopyOrMoveConstructor()) { return IsConvertibleCopyOrMoveConstructor(ctor) ? construct : nullptr; } - return ctor->isUserProvided() || IsConvertibleDefaultConstructor(ctor) + return (ctor->isUserProvided() || IsConvertibleDefaultConstructor(ctor)) && + !ConstructsDefaultValue(ctor) ? construct : nullptr; } @@ -2814,6 +2815,85 @@ bool IsTriviallyDefaultConstructible(const clang::RecordDecl *decl) { return !cxx || cxx->hasTrivialDefaultConstructor(); } +clang::Expr *GetFieldInitializer(const clang::CXXConstructorDecl *ctor, + const clang::FieldDecl *field) { + for (const auto *init : ctor->inits()) { + if (init->isMemberInitializer() && init->getMember() == field) { + return init->getInit(); + } + } + return field->getInClassInitializer(); +} + +static bool IsValueDefaultFieldInit(const clang::FieldDecl *field, + const clang::Expr *init) { + if (auto *default_init = clang::dyn_cast_or_null( + init ? init->IgnoreImplicit() : nullptr)) { + init = default_init->getExpr(); + } + if (init && ReferencesThis(init)) { + return false; + } + auto *record = + field->getType()->getBaseElementTypeUnsafe()->getAsRecordDecl(); + if (!record || !IsUserDefinedDecl(record)) { + return true; + } + if (!HasValueDefaultConstructor(record)) { + return false; + } + if (!init) { + return true; + } + init = init->IgnoreImplicit(); + if (auto *construct = clang::dyn_cast(init)) { + return construct->getConstructor()->isDefaultConstructor() && + construct->getNumArgs() == 0; + } + if (auto *list = clang::dyn_cast(init)) { + return list->getNumInits() == 0; + } + return clang::isa(init); +} + +bool ConstructsDefaultValue(const clang::CXXConstructorDecl *ctor) { + auto *parent = ctor->getParent(); + if (!ctor->isDefaultConstructor() || !IsUserDefinedDecl(parent)) { + return false; + } + auto *default_ctor = GetConvertedDefaultConstructor(parent); + return default_ctor && + default_ctor->getCanonicalDecl() == ctor->getCanonicalDecl() && + HasValueDefaultConstructor(parent); +} + +bool HasValueDefaultConstructor(const clang::RecordDecl *decl) { + if (IsTriviallyDefaultConstructible(decl)) { + return true; + } + auto *cxx = clang::cast(decl); + auto *ctor = GetConvertedDefaultConstructor(cxx); + if (!ctor || ctor->getNumParams() != 0 || cxx->isPolymorphic() || + cxx->getNumBases() != 0) { + return false; + } + auto *definition = + clang::dyn_cast_or_null(ctor->getDefinition()); + if (!definition) { + return false; + } + if (auto *body = definition->getBody()) { + auto *compound = clang::dyn_cast(body); + if (!compound || !compound->body_empty()) { + return false; + } + } + return llvm::all_of(cxx->fields(), [&](const clang::FieldDecl *field) { + return IsValueDefaultFieldInit(field, + GetFieldInitializer(definition, field)); + }); +} + bool DefaultInitHasSideEffects(const clang::ASTContext &ctx, clang::QualType type) { auto *record = ctx.getBaseElementType(type)->getAsCXXRecordDecl(); diff --git a/cpp2rust/converter/converter_lib.h b/cpp2rust/converter/converter_lib.h index e7e4364c3b..f43938fbc9 100644 --- a/cpp2rust/converter/converter_lib.h +++ b/cpp2rust/converter/converter_lib.h @@ -591,6 +591,13 @@ bool DefaultInitHasSideEffects(const clang::ASTContext &ctx, bool IsTriviallyDefaultConstructible(const clang::RecordDecl *decl); +clang::Expr *GetFieldInitializer(const clang::CXXConstructorDecl *ctor, + const clang::FieldDecl *field); + +bool HasValueDefaultConstructor(const clang::RecordDecl *decl); + +bool ConstructsDefaultValue(const clang::CXXConstructorDecl *ctor); + bool ReferencesThis(const clang::Stmt *stmt); // Whether evaluating `stmt` reads a value from memory, e.g., a pointer. diff --git a/cpp2rust/converter/models/converter_refcount.cpp b/cpp2rust/converter/models/converter_refcount.cpp index 79b8245781..56350bbd14 100644 --- a/cpp2rust/converter/models/converter_refcount.cpp +++ b/cpp2rust/converter/models/converter_refcount.cpp @@ -745,6 +745,12 @@ void ConverterRefCount::AddDefaultTrait(const clang::RecordDecl *decl) { Converter::AddDefaultTrait(decl); } +void ConverterRefCount::ConvertDefaultValue( + const clang::CXXRecordDecl *decl, const clang::CXXConstructorDecl *ctor) { + PushConversionKind push(*this, ConversionKind::Unboxed); + Converter::ConvertDefaultValue(decl, ctor); +} + void ConverterRefCount::EmitNullPointer() { EmitFresh("Ptr::<()>::null().to_any()"); } @@ -2172,9 +2178,10 @@ bool ConverterRefCount::VisitCXXConstructExpr(clang::CXXConstructExpr *expr) { return false; } - if (ctor->isDefaultConstructor() && - !(ctor->isUserProvided() && IsUserDefinedDecl(ctor)) && - !IsConvertibleDefaultConstructor(ctor)) { + if ((ctor->isDefaultConstructor() && + !(ctor->isUserProvided() && IsUserDefinedDecl(ctor)) && + !IsConvertibleDefaultConstructor(ctor)) || + (ConstructsDefaultValue(ctor) && in_place_.expr != expr)) { EmitFresh(GetDefaultAsString(expr->getType())); return false; } diff --git a/cpp2rust/converter/models/converter_refcount.h b/cpp2rust/converter/models/converter_refcount.h index a9cde4f7c0..16d5c5e48a 100644 --- a/cpp2rust/converter/models/converter_refcount.h +++ b/cpp2rust/converter/models/converter_refcount.h @@ -81,6 +81,9 @@ class ConverterRefCount final : public Converter { void AddDefaultTrait(const clang::RecordDecl *decl) override; + void ConvertDefaultValue(const clang::CXXRecordDecl *decl, + const clang::CXXConstructorDecl *ctor) override; + void EmitNullPointer() override; std::string GetSelfMaybeWithMut(const clang::CXXMethodDecl *decl) override; 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 72c848bcd4..f95187b346 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 @@ -61,7 +61,12 @@ impl T { return (((*this.upgrade().deref()).v.len()) as i32); } pub fn constructor_1(this: Ptr) { - field!(this, v).write(Vec::new()); + this.write(::default()); + } +} +impl Default for T { + fn default() -> Self { + { T { v: Vec::new() } } } } pub fn sum_0(s: Ptr) -> i32 { @@ -100,7 +105,7 @@ pub fn shuffle_1(mut x: i32) -> i32 { u.clone(), RvalueRef::bind(t.as_pointer()) )); - object!(w, T::constructor_1()); + let w: Value = Rc::new(RefCell::new(::default())); assign!(w = RvalueRef(u)); assert!( ((({ T::size(t.as_pointer(),) }) == 0) && (({ T::size(u.as_pointer(),) }) == 0)) 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 64869a0ac2..dc9da839f6 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 @@ -53,7 +53,12 @@ impl T { return (((*this).v.len()) as i32); } pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).v).write(Vec::new()); + this.write(::default()); + } +} +impl Default for T { + fn default() -> Self { + unsafe { T { v: Vec::new() } } } } pub unsafe fn sum_0(s: *const S) -> i32 { @@ -92,7 +97,7 @@ pub unsafe fn shuffle_1(mut x: i32) -> i32 { u, RvalueRefUnsafe::bind(&mut t) )); - object_unsafe!(w, T::constructor_1()); + let mut w: T = ::default(); assign_unsafe!(w = RvalueRefUnsafe(u)); assert!( (((unsafe { T::size(&raw const t,) }) == (0)) 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 1d14c1bb49..1828a85db4 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 @@ -29,7 +29,12 @@ impl S_int_ { field!(this, x).write(v); } pub fn constructor_1(this: Ptr) { - field!(this, x).write(0); + this.write(::default()); + } +} +impl Default for S_int_ { + fn default() -> Self { + { S_int_ { x: 0 } } } } pub fn main() { @@ -37,7 +42,7 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - object!(p, S_int_::constructor_1()); + let p: Value = Rc::new(RefCell::new(::default())); ({ S_int_::set(p.as_pointer(), 3) }); assert!((({ f_0((p.as_pointer()),) }) == 3)); return 0; diff --git a/tests/multi-file/template_method_late_instantiation/out/unsafe/template_method_late_instantiation.rs b/tests/multi-file/template_method_late_instantiation/out/unsafe/template_method_late_instantiation.rs index c28a2d0c94..9dc09a3583 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 @@ -26,7 +26,12 @@ impl S_int_ { (*this).x = v; } pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).x).write(0); + this.write(::default()); + } +} +impl Default for S_int_ { + fn default() -> Self { + unsafe { S_int_ { x: 0 } } } } pub fn main() { @@ -36,7 +41,7 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - object_unsafe!(p, S_int_::constructor_1()); + let mut p: S_int_ = ::default(); (unsafe { S_int_::set(&raw mut p, 3) }); assert!(((unsafe { f_0((&mut p as *mut S_int_),) }) == (3))); return 0; 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 5023ded136..c93bfcc621 100644 --- a/tests/std/basic/basic.link/out/refcount/basic.link.rs +++ b/tests/std/basic/basic.link/out/refcount/basic.link.rs @@ -88,7 +88,12 @@ pub struct Record_19 { } impl Record_19 { pub fn constructor_1(this: Ptr) { - field!(this, id).write(100); + this.write(::default()); + } +} +impl Default for Record_19 { + fn default() -> Self { + { Record_19 { id: 100 } } } } thread_local!( @@ -98,8 +103,8 @@ pub fn test_21() { assert!((({ bump_18() }) == 2)); assert!((({ bump_in_b_22() }) == 51)); assert!((counter_17.with(|rc| *rc.borrow()) == 2)); - object!(record, Record_19::constructor_1()); - assert!(({ (*record.borrow()).id } == 100)); + let mut record: Record_19 = ::default(); + assert!((record.id == 100)); assert!((({ record_id_in_b_23() }) == 200)); assert!((depth_20.with(|rc| *rc.borrow()) == 3)); assert!((({ depth_in_b_24() }) == 4)); @@ -214,12 +219,12 @@ thread_local!( static count_48: Value = Rc::new(RefCell::new(1)); ); pub fn first_key_51() -> i32 { - object!(entry, Entry_52::constructor_1()); - return { (*entry.borrow()).key }; + let mut entry: Entry_52 = ::default(); + return entry.key; } pub fn second_key_plus_value_53() -> i32 { - object!(entry, Entry_54::constructor_1()); - return ({ (*entry.borrow()).key } + { (*entry.borrow()).value }); + let mut entry: Entry_54 = ::default(); + return (entry.key + entry.value); } pub fn test_55() { assert!((({ first_key_51() }) == 1)); @@ -246,7 +251,12 @@ pub struct Entry_52 { } impl Entry_52 { pub fn constructor_1(this: Ptr) { - field!(this, key).write(1); + this.write(::default()); + } +} +impl Default for Entry_52 { + fn default() -> Self { + { Entry_52 { key: 1 } } } } #[derive( @@ -271,8 +281,12 @@ pub struct Entry_54 { } impl Entry_54 { pub fn constructor_1(this: Ptr) { - field!(this, key).write(2); - field!(this, value).write(30); + this.write(::default()); + } +} +impl Default for Entry_54 { + fn default() -> Self { + { Entry_54 { key: 2, value: 30 } } } } pub fn test_58() { @@ -395,8 +409,17 @@ pub struct Record_65 { } impl Record_65 { pub fn constructor_1(this: Ptr) { - field!(this, id).write(200_i64); - field!(this, extra).write(1); + this.write(::default()); + } +} +impl Default for Record_65 { + fn default() -> Self { + { + Record_65 { + id: 200_i64, + extra: 1, + } + } } } thread_local!( @@ -406,8 +429,8 @@ pub fn bump_in_b_22() -> i32 { return ({ bump_64() }); } pub fn record_id_in_b_23() -> i32 { - object!(record, Record_65::constructor_1()); - return ({ (*record.borrow()).id } as i32); + let mut record: Record_65 = ::default(); + return (record.id as i32); } pub fn depth_in_b_24() -> i32 { return depth_66.with(|rc| *rc.borrow()); @@ -482,8 +505,8 @@ thread_local!( static count_70: Value = Rc::new(RefCell::new(0)); ); pub fn key_in_b_56() -> i32 { - object!(entry, Entry_71::constructor_1()); - return ({ (*entry.borrow()).key } as i32); + let mut entry: Entry_71 = ::default(); + return (entry.key as i32); } #[derive( Copy, @@ -505,7 +528,12 @@ pub struct Entry_71 { } impl Entry_71 { pub fn constructor_1(this: Ptr) { - field!(this, key).write(400_i64); + this.write(::default()); + } +} +impl Default for Entry_71 { + fn default() -> Self { + { Entry_71 { key: 400_i64 } } } } 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 94d72cdcf7..47cdeb836a 100644 --- a/tests/std/basic/basic.link/out/unsafe/basic.link.rs +++ b/tests/std/basic/basic.link/out/unsafe/basic.link.rs @@ -79,7 +79,12 @@ pub struct Record_19 { } impl Record_19 { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).id).write(100); + this.write(::default()); + } +} +impl Default for Record_19 { + fn default() -> Self { + unsafe { Record_19 { id: 100 } } } } pub static mut depth_20: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 3 }); @@ -87,7 +92,7 @@ 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))); - object_unsafe!(record, Record_19::constructor_1()); + let mut record: Record_19 = ::default(); assert!(((record.id) == (100))); assert!(((unsafe { record_id_in_b_23() }) == (200))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut depth_20)) == (3))); @@ -191,11 +196,11 @@ 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 { - object_unsafe!(entry, Entry_52::constructor_1()); + let mut entry: Entry_52 = ::default(); return entry.key; } pub unsafe fn second_key_plus_value_53() -> i32 { - object_unsafe!(entry, Entry_54::constructor_1()); + let mut entry: Entry_54 = ::default(); return ((entry.key) + (entry.value)); } pub unsafe fn test_55() { @@ -220,7 +225,12 @@ pub struct Entry_52 { } impl Entry_52 { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).key).write(1); + this.write(::default()); + } +} +impl Default for Entry_52 { + fn default() -> Self { + unsafe { Entry_52 { key: 1 } } } } #[repr(C)] @@ -241,8 +251,12 @@ pub struct Entry_54 { } impl Entry_54 { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).key).write(2); - (&raw mut (*this).value).write(30); + this.write(::default()); + } +} +impl Default for Entry_54 { + fn default() -> Self { + unsafe { Entry_54 { key: 2, value: 30 } } } } pub unsafe fn test_58() { @@ -340,8 +354,17 @@ pub struct Record_65 { } impl Record_65 { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).id).write(200_i64); - (&raw mut (*this).extra).write(1); + this.write(::default()); + } +} +impl Default for Record_65 { + fn default() -> Self { + unsafe { + Record_65 { + id: 200_i64, + extra: 1, + } + } } } pub static mut depth_66: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 4 }); @@ -349,7 +372,7 @@ pub unsafe fn bump_in_b_22() -> i32 { return (unsafe { bump_64() }); } pub unsafe fn record_id_in_b_23() -> i32 { - object_unsafe!(record, Record_65::constructor_1()); + let mut record: Record_65 = ::default(); return (record.id as i32); } pub unsafe fn depth_in_b_24() -> i32 { @@ -410,7 +433,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 { - object_unsafe!(entry, Entry_71::constructor_1()); + let mut entry: Entry_71 = ::default(); return (entry.key as i32); } #[repr(C)] @@ -430,7 +453,12 @@ pub struct Entry_71 { } impl Entry_71 { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).key).write(400_i64); + this.write(::default()); + } +} +impl Default for Entry_71 { + fn default() -> Self { + unsafe { Entry_71 { key: 400_i64 } } } } pub static mut table_57: std::cell::LazyCell<[i32; 3]> = 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 0df086d016..ff32925db4 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 @@ -39,14 +39,18 @@ impl p1_member_hides_namespace_variable_HasBalance { return balance_0.with(|rc| *rc.borrow()); } pub fn constructor_1(this: Ptr) { - field!(this, balance).write(7); + this.write(::default()); + } +} +impl Default for p1_member_hides_namespace_variable_HasBalance { + fn default() -> Self { + { p1_member_hides_namespace_variable_HasBalance { balance: 7 } } } } pub fn test_1() { - object!( - object, - p1_member_hides_namespace_variable_HasBalance::constructor_1() - ); + let object: Value = Rc::new(RefCell::new( + ::default(), + )); assert!( (({ p1_member_hides_namespace_variable_HasBalance::deposit(object.as_pointer(), 3,) }) == 10) @@ -84,7 +88,12 @@ pub struct p1_out_of_class_definition_is_in_class_scope_HasStaticTotal { } impl p1_out_of_class_definition_is_in_class_scope_HasStaticTotal { pub fn constructor_1(this: Ptr) { - field!(this, held).write(1); + this.write(::default()); + } +} +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 } } } } thread_local!( @@ -104,9 +113,8 @@ impl p1_out_of_class_definition_is_in_class_scope_HasStaticTotal { } pub fn test_5() { assert!((total_4.with(|rc| *rc.borrow()) == 7)); - object!( - object, - p1_out_of_class_definition_is_in_class_scope_HasStaticTotal::constructor_1() + let object: Value = Rc::new( + RefCell::new(::default()), ); assert!( (({ 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 45ffc0d373..dbec0de591 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 @@ -276,14 +276,22 @@ impl p3_2_const_qualified_member_is_distinct_HasConstOverload { return 2; } pub fn constructor_1(this: Ptr) { - field!(this, plain_calls).write(0); - field!(this, const_calls).write(0); + this.write(::default()); + } +} +impl Default for p3_2_const_qualified_member_is_distinct_HasConstOverload { + fn default() -> Self { + { + p3_2_const_qualified_member_is_distinct_HasConstOverload { + plain_calls: 0, + const_calls: 0, + } + } } } pub fn test_12() { - object!( - object, - p3_2_const_qualified_member_is_distinct_HasConstOverload::constructor_1() + let object: Value = Rc::new( + RefCell::new(::default()), ); let view: Ptr = object.as_pointer(); assert!( @@ -337,11 +345,24 @@ impl p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverl return ((this.with(|__s| __s.base) + amount) + 100); } pub fn constructor_1(this: Ptr) { - field!(this, base).write(10); + this.write(::default()); + } +} +impl Default for p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload { + fn default() -> Self { + { + p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload { + base: 10, + } + } } } pub fn test_15() { - object!(object, p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload::constructor_1()); + let object: Value< + p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload, + > = Rc::new(RefCell::new( + ::default(), + )); assert!( (({ p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload::pick_1( @@ -352,16 +373,11 @@ pub fn test_15() { ); assert!((explicit_calls_13.with(|rc| *rc.borrow()) == 1)); assert!((rvalue_calls_14.with(|rc| *rc.borrow()) == 0)); - { - let __tmp_0: Value< - p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload, - > = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - assert!( - (({ - p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload :: pick_2 ( { p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload::constructor_1(__tmp_0.as_pointer()) ; __tmp_0.as_pointer() } , 2 , ) - }) == 112) - ) - }; + assert!( + (({ + p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload :: pick_2 ( Rc::new(RefCell::new(::default() )).as_pointer() , 2 , ) + }) == 112) + ); assert!((explicit_calls_13.with(|rc| *rc.borrow()) == 1)); assert!((rvalue_calls_14.with(|rc| *rc.borrow()) == 1)); } @@ -453,8 +469,7 @@ pub struct p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOv } impl p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload { pub fn constructor_1(this: Ptr) { - field!(this, plain_calls).write(0); - field!(this, const_calls).write(0); + this.write(::default()); } pub fn get_1_int(this: Ptr, mut value: i32) -> i32 { field!(this, plain_calls).with_mut(|__v| { @@ -469,12 +484,22 @@ impl p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload return (value + 2); } } +impl Default for p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload { + fn default() -> Self { + { + p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload { + plain_calls: 0, + const_calls: 0, + } + } + } +} pub fn test_19() { - object!( - object, - p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload::constructor_1( - ) - ); + let object: Value = + Rc::new(RefCell::new( + ::default( + ), + )); let view: Ptr = object.as_pointer(); assert!( 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 fa6e4d3f37..b42c194248 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 @@ -32,14 +32,17 @@ impl p1_member_hides_namespace_variable_HasBalance { return (*std::cell::LazyCell::force_mut(&mut *&raw mut balance_0)); } pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).balance).write(7); + this.write(::default()); + } +} +impl Default for p1_member_hides_namespace_variable_HasBalance { + fn default() -> Self { + unsafe { p1_member_hides_namespace_variable_HasBalance { balance: 7 } } } } pub unsafe fn test_1() { - object_unsafe!( - object, - p1_member_hides_namespace_variable_HasBalance::constructor_1() - ); + let mut object: p1_member_hides_namespace_variable_HasBalance = + ::default(); assert!( ((unsafe { p1_member_hides_namespace_variable_HasBalance::deposit(&raw mut object, 3,) }) == (10)) @@ -72,7 +75,12 @@ pub struct p1_out_of_class_definition_is_in_class_scope_HasStaticTotal { } impl p1_out_of_class_definition_is_in_class_scope_HasStaticTotal { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).held).write(1); + this.write(::default()); + } +} +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 } } } } pub static mut initial_3: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 6 }); @@ -89,10 +97,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))); - object_unsafe!( - object, - p1_out_of_class_definition_is_in_class_scope_HasStaticTotal::constructor_1() - ); + let mut object: p1_out_of_class_definition_is_in_class_scope_HasStaticTotal = + ::default(); assert!( ((unsafe { p1_out_of_class_definition_is_in_class_scope_HasStaticTotal::add(&raw mut object, 4) 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 07e4dad65e..237d1740ce 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 @@ -224,15 +224,22 @@ impl p3_2_const_qualified_member_is_distinct_HasConstOverload { return 2; } pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).plain_calls).write(0); - (&raw mut (*this).const_calls).write(0); + this.write(::default()); + } +} +impl Default for p3_2_const_qualified_member_is_distinct_HasConstOverload { + fn default() -> Self { + unsafe { + p3_2_const_qualified_member_is_distinct_HasConstOverload { + plain_calls: 0, + const_calls: 0, + } + } } } pub unsafe fn test_12() { - object_unsafe!( - object, - p3_2_const_qualified_member_is_distinct_HasConstOverload::constructor_1() - ); + let mut object: p3_2_const_qualified_member_is_distinct_HasConstOverload = + ::default(); let view: *const p3_2_const_qualified_member_is_distinct_HasConstOverload = &object; assert!( ((unsafe { @@ -281,11 +288,21 @@ impl p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverl return ((((*this).base) + (amount)) + (100)); } pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).base).write(10); + this.write(::default()); + } +} +impl Default for p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload { + fn default() -> Self { + unsafe { + p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload { + base: 10, + } + } } } pub unsafe fn test_15() { - object_unsafe!(object, p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload::constructor_1()); + let mut object: p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload = + ::default(); assert!( ((unsafe { p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload::pick_1( @@ -296,14 +313,11 @@ 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))); - { - let mut __tmp_0: p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload = ZeroInitializationUnsafe::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::constructor_1(&raw mut __tmp_0) ; & mut __tmp_0 } ) , 2 , ) - }) == (112)) - ) - }; + assert!( + ((unsafe { + p3_2_explicit_object_and_rvalue_members_are_distinct_HasExplicitObjectOverload :: pick_2 ( &mut ::default() , 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))); } @@ -379,8 +393,7 @@ pub struct p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOv } impl p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).plain_calls).write(0); - (&raw mut (*this).const_calls).write(0); + this.write(::default()); } pub unsafe fn get_1_int(this: *mut Self, mut value: i32) -> i32 { (*this).plain_calls.prefix_inc(); @@ -391,12 +404,19 @@ impl p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload return ((value) + (2)); } } +impl Default for p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload { + fn default() -> Self { + unsafe { + p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload { + plain_calls: 0, + const_calls: 0, + } + } + } +} pub unsafe fn test_19() { - object_unsafe!( - object, - p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload::constructor_1( - ) - ); + let mut object: p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload = + ::default(); let view: *const p3_4_const_qualified_member_templates_are_distinct_HasConstTemplateOverload = &object; assert!( 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 87b7a77713..c49d7dda38 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 @@ -45,13 +45,17 @@ impl p7_1_function_body_names_later_member_HasLaterMembers { return 2; } pub fn constructor_1(this: Ptr) { - field!(this, stock).write(9); + this.write(::default()); + } +} +impl Default for p7_1_function_body_names_later_member_HasLaterMembers { + fn default() -> Self { + { p7_1_function_body_names_later_member_HasLaterMembers { stock: 9 } } } } pub fn test_3() { - object!( - object, - p7_1_function_body_names_later_member_HasLaterMembers::constructor_1() + let object: Value = Rc::new( + RefCell::new(::default()), ); assert!( (({ @@ -93,13 +97,17 @@ impl p7_2_default_argument_names_later_member_HasLaterStaticStep { return this.with(|__s| __s.total); } pub fn constructor_1(this: Ptr) { - field!(this, total).write(1); + this.write(::default()); + } +} +impl Default for p7_2_default_argument_names_later_member_HasLaterStaticStep { + fn default() -> Self { + { p7_2_default_argument_names_later_member_HasLaterStaticStep { total: 1 } } } } pub fn test_6() { - object!( - object, - p7_2_default_argument_names_later_member_HasLaterStaticStep::constructor_1() + let object: Value = Rc::new( + RefCell::new(::default()), ); assert!( (({ 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 3562e42e05..6be6a953d6 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 @@ -40,14 +40,17 @@ impl p7_1_function_body_names_later_member_HasLaterMembers { return 2; } pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).stock).write(9); + this.write(::default()); + } +} +impl Default for p7_1_function_body_names_later_member_HasLaterMembers { + fn default() -> Self { + unsafe { p7_1_function_body_names_later_member_HasLaterMembers { stock: 9 } } } } pub unsafe fn test_3() { - object_unsafe!( - object, - p7_1_function_body_names_later_member_HasLaterMembers::constructor_1() - ); + let mut object: p7_1_function_body_names_later_member_HasLaterMembers = + ::default(); assert!( ((unsafe { p7_1_function_body_names_later_member_HasLaterMembers::take(&raw mut object, 3) @@ -79,14 +82,17 @@ impl p7_2_default_argument_names_later_member_HasLaterStaticStep { return (*this).total; } pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).total).write(1); + this.write(::default()); + } +} +impl Default for p7_2_default_argument_names_later_member_HasLaterStaticStep { + fn default() -> Self { + unsafe { p7_2_default_argument_names_later_member_HasLaterStaticStep { total: 1 } } } } pub unsafe fn test_6() { - object_unsafe!( - object, - p7_2_default_argument_names_later_member_HasLaterStaticStep::constructor_1() - ); + let mut object: p7_2_default_argument_names_later_member_HasLaterStaticStep = + ::default(); 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.rs b/tests/std/dcl.dcl/dcl.decl/dcl.init/out/refcount/dcl.init.general.rs index 2a45940fda..7738362b99 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 @@ -403,8 +403,17 @@ pub struct p9_1_2_zero_then_default_initialized_WithDefaultMember { } impl p9_1_2_zero_then_default_initialized_WithDefaultMember { pub fn constructor_1(this: Ptr) { - field!(this, zeroed).write(0_i32); - field!(this, five).write(5); + this.write(::default()); + } +} +impl Default for p9_1_2_zero_then_default_initialized_WithDefaultMember { + fn default() -> Self { + { + p9_1_2_zero_then_default_initialized_WithDefaultMember { + zeroed: 0_i32, + five: 5, + } + } } } #[derive( @@ -427,7 +436,12 @@ pub struct p9_1_2_zero_then_default_initialized_LeavesMemberAlone { } impl p9_1_2_zero_then_default_initialized_LeavesMemberAlone { pub fn constructor_1(this: Ptr) { - field!(this, untouched).write(0_i32); + this.write(::default()); + } +} +impl Default for p9_1_2_zero_then_default_initialized_LeavesMemberAlone { + fn default() -> Self { + { p9_1_2_zero_then_default_initialized_LeavesMemberAlone { untouched: 0_i32 } } } } #[derive( @@ -453,39 +467,35 @@ pub struct p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAlone { } impl p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAlone { pub fn constructor_1(this: Ptr) { - field!(this, number).write(0_i32); - p9_1_2_zero_then_default_initialized_LeavesMemberAlone::constructor_1(field_ptr!( - this, member - )); + this.write(::default()); + } +} +impl Default for p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAlone { + fn default() -> Self { + { + p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAlone { + number: 0_i32, + member: ::default(), + } + } } } pub fn test_22() { - object!( - value, - p9_1_2_zero_then_default_initialized_WithDefaultMember::constructor_1() - ); - 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_WithDefaultMember::constructor_1(__p.clone()); - __p - }; + 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()); assert!((heap.with(|__s| __s.zeroed) == 0)); assert!((heap.with(|__s| __s.five) == 5)); heap.delete(); - object!( - holder, - p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAlone::constructor_1() - ); - 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_HoldsLeavesMemberAlone::constructor_1(__p.clone()); - __p - }; + let mut holder: p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAlone = + ::default(); + assert!((holder.number == 0)); + assert!((holder.member.untouched == 0)); + let mut heap_holder: Ptr = + Ptr::alloc(::default()); assert!((heap_holder.with(|__s| __s.number) == 0)); assert!((heap_holder.with(|__s| __s.member.untouched) == 0)); heap_holder.delete(); 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 0fba58047c..f29ba2819d 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 @@ -346,8 +346,17 @@ pub struct p9_1_2_zero_then_default_initialized_WithDefaultMember { } impl p9_1_2_zero_then_default_initialized_WithDefaultMember { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).zeroed).write(0_i32); - (&raw mut (*this).five).write(5); + this.write(::default()); + } +} +impl Default for p9_1_2_zero_then_default_initialized_WithDefaultMember { + fn default() -> Self { + unsafe { + p9_1_2_zero_then_default_initialized_WithDefaultMember { + zeroed: 0_i32, + five: 5, + } + } } } #[repr(C)] @@ -367,7 +376,12 @@ pub struct p9_1_2_zero_then_default_initialized_LeavesMemberAlone { } impl p9_1_2_zero_then_default_initialized_LeavesMemberAlone { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).untouched).write(0_i32); + this.write(::default()); + } +} +impl Default for p9_1_2_zero_then_default_initialized_LeavesMemberAlone { + fn default() -> Self { + unsafe { p9_1_2_zero_then_default_initialized_LeavesMemberAlone { untouched: 0_i32 } } } } #[repr(C)] @@ -388,26 +402,28 @@ pub struct p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAlone { } impl p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAlone { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).number).write(0_i32); - p9_1_2_zero_then_default_initialized_LeavesMemberAlone::constructor_1( - &raw mut (*this).member, - ); + this.write(::default()); + } +} +impl Default for p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAlone { + fn default() -> Self { + unsafe { + p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAlone { + number: 0_i32, + member: ::default(), + } + } } } pub unsafe fn test_22() { - object_unsafe!( - value, - p9_1_2_zero_then_default_initialized_WithDefaultMember::constructor_1() - ); + let mut value: p9_1_2_zero_then_default_initialized_WithDefaultMember = + ::default(); 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::constructor_1(__p); - __p - }; + 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); assert!((((*heap).zeroed) == (0))); assert!((((*heap).five) == (5))); { @@ -416,19 +432,14 @@ pub unsafe fn test_22() { ::std::mem::drop(Box::from_raw(__p)) } }; - object_unsafe!( - holder, - p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAlone::constructor_1() - ); + let mut holder: p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAlone = + ::default(); 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::constructor_1(__p); - __p - }; + let mut heap_holder: *mut p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAlone = + (Box::leak(Box::new( + ::default(), + )) as *mut p9_1_2_zero_then_default_initialized_HoldsLeavesMemberAlone); assert!((((*heap_holder).number) == (0))); assert!((((*heap_holder).member.untouched) == (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 e2bbf1496c..35fa40799d 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 @@ -80,13 +80,17 @@ impl p9_static_member_hides_namespace_variable_HasStaticStep { return this.with(|__s| __s.total); } pub fn constructor_1(this: Ptr) { - field!(this, total).write(1); + this.write(::default()); + } +} +impl Default for p9_static_member_hides_namespace_variable_HasStaticStep { + fn default() -> Self { + { p9_static_member_hides_namespace_variable_HasStaticStep { total: 1 } } } } pub fn test_11() { - object!( - object, - p9_static_member_hides_namespace_variable_HasStaticStep::constructor_1() + let object: Value = Rc::new( + RefCell::new(::default()), ); assert!( (({ @@ -191,7 +195,12 @@ impl p9_evaluated_each_time_called_Account { base_15.with(|rc| *rc.borrow_mut() = value); } pub fn constructor_1(this: Ptr) { - field!(this, balance).write(0); + this.write(::default()); + } +} +impl Default for p9_evaluated_each_time_called_Account { + fn default() -> Self { + { p9_evaluated_each_time_called_Account { balance: 0 } } } } pub fn test_17() { @@ -217,10 +226,9 @@ pub fn test_17() { assert!(({ (*b.borrow()).id } == 40)); assert!(({ (*c.borrow()).id } == 5)); assert!((defaults_evaluated_12.with(|rc| *rc.borrow()) == 5)); - object!( - account, - p9_evaluated_each_time_called_Account::constructor_1() - ); + let account: Value = Rc::new(RefCell::new( + ::default(), + )); assert!( (({ p9_evaluated_each_time_called_Account::deposit( 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 d87afd0e65..c742d6b71b 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 @@ -74,14 +74,17 @@ impl p9_static_member_hides_namespace_variable_HasStaticStep { return (*this).total; } pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).total).write(1); + this.write(::default()); + } +} +impl Default for p9_static_member_hides_namespace_variable_HasStaticStep { + fn default() -> Self { + unsafe { p9_static_member_hides_namespace_variable_HasStaticStep { total: 1 } } } } pub unsafe fn test_11() { - object_unsafe!( - object, - p9_static_member_hides_namespace_variable_HasStaticStep::constructor_1() - ); + let mut object: p9_static_member_hides_namespace_variable_HasStaticStep = + ::default(); assert!( ((unsafe { p9_static_member_hides_namespace_variable_HasStaticStep::advance( @@ -174,7 +177,12 @@ impl p9_evaluated_each_time_called_Account { (*std::cell::LazyCell::force_mut(&mut *&raw mut base_15)) = value; } pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).balance).write(0); + this.write(::default()); + } +} +impl Default for p9_evaluated_each_time_called_Account { + fn default() -> Self { + unsafe { p9_evaluated_each_time_called_Account { balance: 0 } } } } pub unsafe fn test_17() { @@ -202,10 +210,8 @@ pub unsafe fn test_17() { assert!(((b.id) == (40))); assert!(((c.id) == (5))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut defaults_evaluated_12)) == (5))); - object_unsafe!( - account, - p9_evaluated_each_time_called_Account::constructor_1() - ); + let mut account: p9_evaluated_each_time_called_Account = + ::default(); assert!( ((unsafe { p9_evaluated_each_time_called_Account::deposit( 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 6f39b637d2..f7d9c44ae8 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 @@ -41,7 +41,12 @@ pub struct p16_rebind_member_Alloc_std_pair_const_int__int__ { } impl p16_rebind_member_Alloc_std_pair_const_int__int__ { pub fn constructor_1(this: Ptr) { - field!(this, id).write(0); + this.write(::default()); + } +} +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 } } } } pub fn test_0() { 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 fc735866f0..8f7a7efc5a 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 @@ -36,7 +36,12 @@ pub struct p16_rebind_member_Alloc_std_pair_const_int__int__ { } impl p16_rebind_member_Alloc_std_pair_const_int__int__ { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).id).write(0); + this.write(::default()); + } +} +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 } } } } pub unsafe fn test_0() { 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 77d674bf68..3303a0e133 100644 --- a/tests/std/temp/temp.spec/out/refcount/temp.inst.rs +++ b/tests/std/temp/temp.spec/out/refcount/temp.inst.rs @@ -27,7 +27,7 @@ pub struct p2_reference_does_not_instantiate_Member { } impl p2_reference_does_not_instantiate_Member { pub fn constructor_1(this: Ptr) { - field!(this, value).write(1); + this.write(::default()); } pub fn constructor_2( this: Ptr, @@ -37,6 +37,11 @@ impl p2_reference_does_not_instantiate_Member { field!(this, value).write(2); } } +impl Default for p2_reference_does_not_instantiate_Member { + fn default() -> Self { + { p2_reference_does_not_instantiate_Member { value: 1 } } + } +} #[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise)] #[memberwise(move_constructor)] #[derive(Conversions)] @@ -50,17 +55,24 @@ pub struct p2_reference_does_not_instantiate_Holder { } impl p2_reference_does_not_instantiate_Holder { pub fn constructor_1(this: Ptr) { - p2_reference_does_not_instantiate_Member::constructor_1(field_ptr!(this, member)); + this.write(::default()); + } +} +impl Default for p2_reference_does_not_instantiate_Holder { + fn default() -> Self { + { + p2_reference_does_not_instantiate_Holder { + member: ::default(), + } + } } } pub fn test_0() { - object!( - holder, - p2_reference_does_not_instantiate_Holder::constructor_1() - ); - assert!(({ (*holder.borrow()).member.value } == 1)); - (*holder.borrow_mut()).member.value = 3; - assert!(({ (*holder.borrow()).member.value } == 3)); + let mut holder: p2_reference_does_not_instantiate_Holder = + ::default(); + assert!((holder.member.value == 1)); + holder.member.value = 3; + assert!((holder.member.value == 3)); } pub fn main() { __cpp2rust_init_globals(); 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 7c214cbe3f..476d662ac8 100644 --- a/tests/std/temp/temp.spec/out/unsafe/temp.inst.rs +++ b/tests/std/temp/temp.spec/out/unsafe/temp.inst.rs @@ -24,7 +24,7 @@ pub struct p2_reference_does_not_instantiate_Member { } impl p2_reference_does_not_instantiate_Member { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).value).write(1); + this.write(::default()); } pub unsafe fn constructor_2( this: *mut Self, @@ -34,6 +34,11 @@ impl p2_reference_does_not_instantiate_Member { (&raw mut (*this).value).write(2); } } +impl Default for p2_reference_does_not_instantiate_Member { + fn default() -> Self { + unsafe { p2_reference_does_not_instantiate_Member { value: 1 } } + } +} #[repr(C)] #[derive(FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, MemberwiseUnsafe)] #[memberwise(move_constructor)] @@ -45,14 +50,21 @@ pub struct p2_reference_does_not_instantiate_Holder { } impl p2_reference_does_not_instantiate_Holder { pub unsafe fn constructor_1(this: *mut Self) { - p2_reference_does_not_instantiate_Member::constructor_1(&raw mut (*this).member); + this.write(::default()); + } +} +impl Default for p2_reference_does_not_instantiate_Holder { + fn default() -> Self { + unsafe { + p2_reference_does_not_instantiate_Holder { + member: ::default(), + } + } } } pub unsafe fn test_0() { - object_unsafe!( - holder, - p2_reference_does_not_instantiate_Holder::constructor_1() - ); + let mut holder: p2_reference_does_not_instantiate_Holder = + ::default(); assert!(((holder.member.value) == (1))); holder.member.value = 3; assert!(((holder.member.value) == (3))); diff --git a/tests/unit/out/refcount/10_struct.rs b/tests/unit/out/refcount/10_struct.rs index 7b63ca909f..184ffb30a2 100644 --- a/tests/unit/out/refcount/10_struct.rs +++ b/tests/unit/out/refcount/10_struct.rs @@ -72,13 +72,22 @@ pub struct Partial { } impl Partial { pub fn constructor_1(this: Ptr) { - field!(this, p).write(Ptr::::null()); + this.write(::default()); } pub fn constructor_2(this: Ptr, q: Pointer) { let mut q = q.as_pointer(); field!(this, p).write((q).clone()); } } +impl Default for Partial { + fn default() -> Self { + { + Partial { + p: Ptr::::null(), + } + } + } +} #[derive( Copy, Clone, @@ -129,8 +138,8 @@ fn main_0() -> i32 { if ({ { (*it.borrow()).p.clone() } } != { arr.decay() }) { return 1; } - object!(def, Partial::constructor_1()); - if !(({ (*def.borrow()).p.clone() }).is_null()) { + let mut def: Partial = ::default(); + if !((def.p).is_null()) { return 1; } let mut s: S = S { diff --git a/tests/unit/out/refcount/array_of_noncopy_struct.rs b/tests/unit/out/refcount/array_of_noncopy_struct.rs index 4acdc87a75..5edbf45cc2 100644 --- a/tests/unit/out/refcount/array_of_noncopy_struct.rs +++ b/tests/unit/out/refcount/array_of_noncopy_struct.rs @@ -32,8 +32,17 @@ pub struct NonCopy { } impl NonCopy { pub fn constructor_1(this: Ptr) { - field!(this, data).write(Vec::new()); - field!(this, tag).write(0); + this.write(::default()); + } +} +impl Default for NonCopy { + fn default() -> Self { + { + NonCopy { + data: Vec::new(), + tag: 0, + } + } } } pub fn main() { @@ -41,13 +50,11 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - let arr: Value> = Rc::new(RefCell::new(Box::new( - std::array::from_fn::<_, 3, _>(|_| { - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - NonCopy::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }), - ))); + let arr: Value> = Rc::new(RefCell::new( + (0..3) + .map(|_| ::default()) + .collect::>(), + )); (*arr.borrow_mut())[(0) as usize].tag = 7; ({ let __tmp_0: Value = Rc::new(RefCell::new(42)); diff --git a/tests/unit/out/refcount/assignment_single_eval.rs b/tests/unit/out/refcount/assignment_single_eval.rs index d27ef271e1..c1c818ecd7 100644 --- a/tests/unit/out/refcount/assignment_single_eval.rs +++ b/tests/unit/out/refcount/assignment_single_eval.rs @@ -2391,7 +2391,12 @@ pub struct Counts_59 { } impl Counts_59 { pub fn constructor_1(this: Ptr) { - field!(this, counts).write(Vec::new()); + this.write(::default()); + } +} +impl Default for Counts_59 { + fn default() -> Self { + { Counts_59 { counts: Vec::new() } } } } #[derive( diff --git a/tests/unit/out/refcount/cast.rs b/tests/unit/out/refcount/cast.rs index d7bfb31fc9..84383a3fbb 100644 --- a/tests/unit/out/refcount/cast.rs +++ b/tests/unit/out/refcount/cast.rs @@ -100,8 +100,17 @@ pub struct Bag { } impl Bag { pub fn constructor_1(this: Ptr) { - field!(this, n).write(0_i32); - field!(this, items).write(Vec::new()); + this.write(::default()); + } +} +impl Default for Bag { + fn default() -> Self { + { + Bag { + n: 0_i32, + items: Vec::new(), + } + } } } pub fn adjacent_arrays_0() { @@ -373,7 +382,7 @@ 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)) })); - object!(b, Bag::constructor_1()); + let b: Value = Rc::new(RefCell::new(::default())); if 4_usize > (*b.borrow()).items.capacity() as usize { let len_0 = (*b.borrow()).items.len(); (*b.borrow_mut()) diff --git a/tests/unit/out/refcount/class_templates.rs b/tests/unit/out/refcount/class_templates.rs index 678e58d173..d94ff07b64 100644 --- a/tests/unit/out/refcount/class_templates.rs +++ b/tests/unit/out/refcount/class_templates.rs @@ -49,7 +49,12 @@ impl MyContainer_int_ { CopyConstructible::push_copied(&field_ref!(this, vec_).as_pointer(), (item).clone()); } pub fn constructor_1(this: Ptr) { - field!(this, vec_).write(Vec::new()); + this.write(::default()); + } +} +impl Default for MyContainer_int_ { + fn default() -> Self { + { MyContainer_int_ { vec_: Vec::new() } } } } #[derive( @@ -95,7 +100,12 @@ impl MyContainer_char_ { CopyConstructible::push_copied(&field_ref!(this, vec_).as_pointer(), (item).clone()); } pub fn constructor_1(this: Ptr) { - field!(this, vec_).write(Vec::new()); + this.write(::default()); + } +} +impl Default for MyContainer_char_ { + fn default() -> Self { + { MyContainer_char_ { vec_: Vec::new() } } } } #[derive( @@ -141,7 +151,12 @@ impl MyContainer_float_ { CopyConstructible::push_copied(&field_ref!(this, vec_).as_pointer(), (item).clone()); } pub fn constructor_1(this: Ptr) { - field!(this, vec_).write(Vec::new()); + this.write(::default()); + } +} +impl Default for MyContainer_float_ { + fn default() -> Self { + { MyContainer_float_ { vec_: Vec::new() } } } } #[derive( @@ -406,7 +421,7 @@ 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_::plus(bl.as_pointer(), 1_i64,) }) == 8_i64)); - object!(imc, MyContainer_int_::constructor_1()); + let imc: Value = Rc::new(RefCell::new(::default())); assert!(({ MyContainer_int_::empty(imc.as_pointer(),) })); ({ let _item: Value = Rc::new(RefCell::new(1)); @@ -418,7 +433,7 @@ fn main_0() -> i32 { ); ({ MyContainer_int_::pop_back(imc.as_pointer()) }); assert!(({ MyContainer_int_::empty(imc.as_pointer(),) })); - object!(cmc, MyContainer_char_::constructor_1()); + let cmc: Value = Rc::new(RefCell::new(::default())); assert!(({ MyContainer_char_::empty(cmc.as_pointer(),) })); ({ let _item: Value = Rc::new(RefCell::new(('a' as i8))); @@ -431,7 +446,7 @@ fn main_0() -> i32 { ); ({ MyContainer_char_::pop_back(cmc.as_pointer()) }); assert!(({ MyContainer_char_::empty(cmc.as_pointer(),) })); - object!(fmc, MyContainer_float_::constructor_1()); + let fmc: Value = Rc::new(RefCell::new(::default())); assert!(({ MyContainer_float_::empty(fmc.as_pointer(),) })); ({ let _item: Value = Rc::new(RefCell::new((1_f64 as f32))); diff --git a/tests/unit/out/refcount/container_field_addr.rs b/tests/unit/out/refcount/container_field_addr.rs index 9080d2125c..0dbcef6bb7 100644 --- a/tests/unit/out/refcount/container_field_addr.rs +++ b/tests/unit/out/refcount/container_field_addr.rs @@ -32,8 +32,17 @@ pub struct S { } impl S { pub fn constructor_1(this: Ptr) { - field!(this, tag).write(0_i32); - field!(this, v).write(Vec::new()); + this.write(::default()); + } +} +impl Default for S { + fn default() -> Self { + { + S { + tag: 0_i32, + v: Vec::new(), + } + } } } pub fn add_0(mut v: Ptr>, k: i32) { @@ -60,14 +69,10 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - object!(local, S::constructor_1()); + let local: Value = Rc::new(RefCell::new(::default())); (*local.borrow_mut()).tag = 7; ({ run_1((local.as_pointer())) }); - let mut heap: Ptr = { - let __p = Ptr::alloc(::zero_init()); - S::constructor_1(__p.clone()); - __p - }; + let mut heap: Ptr = Ptr::alloc(::default()); field!(heap, tag).write(7); ({ run_1((heap).clone()) }); heap.delete(); diff --git a/tests/unit/out/refcount/copy_assign.rs b/tests/unit/out/refcount/copy_assign.rs index 2499c8dcc3..577cd0ef3d 100644 --- a/tests/unit/out/refcount/copy_assign.rs +++ b/tests/unit/out/refcount/copy_assign.rs @@ -73,7 +73,7 @@ pub struct NonConstAssign { } impl NonConstAssign { pub fn constructor_1(this: Ptr) { - field!(this, mark).write(0); + this.write(::default()); } pub fn operator_assign_2(this: Ptr, o: Ptr) -> Ptr { field!(this, mark).write((o.with(|__s| __s.mark) + 1)); @@ -84,6 +84,11 @@ impl NonConstAssign { return (this).clone(); } } +impl Default for NonConstAssign { + fn default() -> Self { + { NonConstAssign { mark: 0 } } + } +} #[derive( Copy, Clone, @@ -106,7 +111,7 @@ pub struct RefQualified { } impl RefQualified { pub fn constructor_1(this: Ptr) { - field!(this, mark).write(0); + this.write(::default()); } } impl CopyAssignable for RefQualified { @@ -116,6 +121,11 @@ impl CopyAssignable for RefQualified { return (this).clone(); } } +impl Default for RefQualified { + fn default() -> Self { + { RefQualified { mark: 0 } } + } +} #[derive( Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Memberwise, Swappable, )] @@ -206,7 +216,7 @@ pub struct ExplicitOperatorCall { } impl ExplicitOperatorCall { pub fn constructor_1(this: Ptr) { - field!(this, w).write(Vec::new()); + this.write(::default()); } } impl CopyAssignable for ExplicitOperatorCall { @@ -223,6 +233,11 @@ impl CopyAssignable for ExplicitOperatorCall { return (this).clone(); } } +impl Default for ExplicitOperatorCall { + fn default() -> Self { + { ExplicitOperatorCall { w: Vec::new() } } + } +} thread_local!( pub static swap_copies_2: Value = Rc::new(RefCell::new(0)); ); @@ -317,7 +332,7 @@ pub struct VoidAssign { } impl VoidAssign { pub fn constructor_1(this: Ptr) { - field!(this, x).write(0); + this.write(::default()); } pub fn copy_assign(this: Ptr, o: Ptr) { field!(this, x).write((o.with(|__s| __s.x) + 5)); @@ -335,6 +350,11 @@ impl MoveAssignable for VoidAssign { Ptr::clone(&this.clone()) } } +impl Default for VoidAssign { + fn default() -> Self { + { VoidAssign { x: 0 } } + } +} #[derive( Copy, Clone, @@ -360,7 +380,16 @@ pub struct HoldsVoidAssign { } impl HoldsVoidAssign { pub fn constructor_1(this: Ptr) { - VoidAssign::constructor_1(field_ptr!(this, v)); + this.write(::default()); + } +} +impl Default for HoldsVoidAssign { + fn default() -> Self { + { + HoldsVoidAssign { + v: ::default(), + } + } } } pub fn main() { @@ -420,16 +449,16 @@ fn main_0() -> i32 { && (array_elem!(h.as_pointer(), arr, 1).with(|__s| __s.keep) == 60) ); assert!((assigns_0.with(|rc| *rc.borrow()) == 8)); - object!(n, NonConstAssign::constructor_1()); - object!(n1, NonConstAssign::constructor_1()); - object!(n2, NonConstAssign::constructor_1()); - object!(cn, NonConstAssign::constructor_1()); + let n: Value = Rc::new(RefCell::new(::default())); + let n1: Value = Rc::new(RefCell::new(::default())); + let n2: Value = Rc::new(RefCell::new(::default())); + let cn: Value = Rc::new(RefCell::new(::default())); NonConstAssign::operator_assign_2(n1.as_pointer(), n.as_pointer()); NonConstAssign::operator_assign_3(n2.as_pointer(), cn.as_pointer()); assert!(({ (*n1.borrow()).mark } == 1)); assert!(({ (*n2.borrow()).mark } == 10)); - object!(r, RefQualified::constructor_1()); - object!(r1, RefQualified::constructor_1()); + let r: Value = Rc::new(RefCell::new(::default())); + let r1: Value = Rc::new(RefCell::new(::default())); assign!(r1 = r); assert!(({ (*r1.borrow()).mark } == 1)); let h2: Value = Rc::new(RefCell::new(Holder { @@ -511,8 +540,8 @@ fn main_0() -> i32 { && (array_elem!(hc1.as_pointer(), arr, 1).with(|__s| __s.v) == 6) ); assert!((copies_1.with(|rc| *rc.borrow()) == 0)); - object!(e1, ExplicitOperatorCall::constructor_1()); - object!(e2, ExplicitOperatorCall::constructor_1()); + let e1: Value = Rc::new(RefCell::new(::default())); + let e2: Value = Rc::new(RefCell::new(::default())); ({ let __tmp_1: Value = Rc::new(RefCell::new(5)); MoveConstructible::push_moved( @@ -552,8 +581,8 @@ fn main_0() -> i32 { })); assign!(hs1 = hs2); assert!(({ (*hs1.borrow()).s.v } == 4) && (swap_copies_2.with(|rc| *rc.borrow()) == 2)); - object!(hv1, HoldsVoidAssign::constructor_1()); - object!(hv2, HoldsVoidAssign::constructor_1()); + let hv1: Value = Rc::new(RefCell::new(::default())); + let hv2: Value = Rc::new(RefCell::new(::default())); assign!(hv1 = hv2); assert!(({ (*hv1.borrow()).v.x } == 5)); return 0; diff --git a/tests/unit/out/refcount/copy_ctor.rs b/tests/unit/out/refcount/copy_ctor.rs index c6f17cc0d4..5d006bf4fc 100644 --- a/tests/unit/out/refcount/copy_ctor.rs +++ b/tests/unit/out/refcount/copy_ctor.rs @@ -64,7 +64,7 @@ pub struct NonConst { } impl NonConst { pub fn constructor_1(this: Ptr) { - field!(this, mark).write(0); + this.write(::default()); } pub fn constructor_2(this: Ptr, o: LvalueRef) { let o = o.as_pointer(); @@ -75,6 +75,11 @@ impl NonConst { field!(this, mark).write((o.with(|__s| __s.mark) + 10)); } } +impl Default for NonConst { + fn default() -> Self { + { NonConst { mark: 0 } } + } +} #[derive( Record, ByteRepr, @@ -207,7 +212,7 @@ pub struct Tracked { } impl Tracked { pub fn constructor_1(this: Ptr) { - field!(this, copied_from).write(0); + this.write(::default()); } pub fn constructor_2(this: Ptr, o: LvalueRef>) { let o = o.as_pointer(); @@ -226,6 +231,11 @@ impl CopyAssignable for Tracked { return (this).clone(); } } +impl Default for Tracked { + fn default() -> Self { + { Tracked { copied_from: 0 } } + } +} pub fn touch_1(mut t: Ptr) { field!(t, copied_from).with_mut(|__v| { __v.prefix_inc(); @@ -383,20 +393,20 @@ fn main_0() -> i32 { ); assert!(({ (*ol2.borrow()).v } == 105)); assert!((copies_0.with(|rc| *rc.borrow()) == 12)); - object!(n, NonConst::constructor_1()); + let n: Value = Rc::new(RefCell::new(::default())); object!(n1, NonConst::constructor_2(LvalueRef::bind(n.as_pointer()))); - object!(cn, NonConst::constructor_1()); + let cn: Value = Rc::new(RefCell::new(::default())); object!( n2, NonConst::constructor_3(LvalueRef::bind(cn.as_pointer())) ); assert!(({ (*n1.borrow()).mark } == 1)); assert!(({ (*n2.borrow()).mark } == 10)); - object!(t1, Tracked::constructor_1()); + let t1: Value = Rc::new(RefCell::new(::default())); object!(t2, Tracked::constructor_2(LvalueRef::bind(t1.as_pointer()))); assign!(t2 = t1); assert!(({ (*t1.borrow()).copied_from } == 2)); - object!(ct, Tracked::constructor_1()); + let ct: Value = Rc::new(RefCell::new(::default())); object!(t3, Tracked::constructor_2(LvalueRef::bind(ct.as_pointer()))); ({ touch_1((ct.as_pointer())) }); assert!(({ (*ct.borrow()).copied_from } == 2)); diff --git a/tests/unit/out/refcount/copy_move_defaulted.rs b/tests/unit/out/refcount/copy_move_defaulted.rs index 687f0bf5eb..c272d44ffd 100644 --- a/tests/unit/out/refcount/copy_move_defaulted.rs +++ b/tests/unit/out/refcount/copy_move_defaulted.rs @@ -221,10 +221,19 @@ pub struct Owner { } impl Owner { pub fn constructor_1(this: Ptr) { - 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); + this.write(::default()); + } +} +impl Default for Owner { + fn default() -> Self { + { + Owner { + data: Vec::new(), + n: 0_i32, + arr: (0..2).map(|_| 0_i32).collect::>(), + p: None, + } + } } } #[derive( @@ -251,7 +260,12 @@ pub struct Copyable { } impl Copyable { pub fn constructor_1(this: Ptr) { - field!(this, data).write(Vec::new()); + this.write(::default()); + } +} +impl Default for Copyable { + fn default() -> Self { + { Copyable { data: Vec::new() } } } } #[derive( @@ -297,7 +311,7 @@ pub struct SeesThis { } impl SeesThis { pub fn constructor_1(this: Ptr) { - field!(this, self_).write(Ptr::::null()); + this.write(::default()); } } impl CopyAssignable for SeesThis { @@ -314,6 +328,15 @@ impl MoveAssignable for SeesThis { return (this).clone(); } } +impl Default for SeesThis { + fn default() -> Self { + { + SeesThis { + self_: Ptr::::null(), + } + } + } +} #[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise)] #[memberwise(copy_assign, move_assign)] #[derive(Conversions)] @@ -329,8 +352,17 @@ pub struct HasSeesThis { } impl HasSeesThis { pub fn constructor_1(this: Ptr) { - SeesThis::constructor_1(field_ptr!(this, s)); - field!(this, v).write(Vec::new()); + this.write(::default()); + } +} +impl Default for HasSeesThis { + fn default() -> Self { + { + HasSeesThis { + s: ::default(), + v: Vec::new(), + } + } } } #[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Swappable, Conversions)] @@ -346,8 +378,7 @@ pub struct Counted_int_ { } impl Counted_int_ { pub fn constructor_1(this: Ptr) { - field!(this, v).write(0_i32); - field!(this, moves).write(0); + this.write(::default()); } pub fn constructor_2(this: Ptr, o: RvalueRef) { let o = o.as_pointer(); @@ -363,6 +394,11 @@ impl MoveAssignable for Counted_int_ { return (this).clone(); } } +impl Default for Counted_int_ { + fn default() -> Self { + { Counted_int_ { v: 0_i32, moves: 0 } } + } +} #[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Swappable)] #[memberwise(move_constructor, move_assign)] #[derive(Conversions)] @@ -379,8 +415,17 @@ pub struct HasCounted { } impl HasCounted { pub fn constructor_1(this: Ptr) { - Counted_int_::constructor_1(field_ptr!(this, c)); - field!(this, w).write(Vec::new()); + this.write(::default()); + } +} +impl Default for HasCounted { + fn default() -> Self { + { + HasCounted { + c: ::default(), + w: Vec::new(), + } + } } } #[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Swappable, Conversions)] @@ -527,9 +572,18 @@ pub struct OutOfLineAssign { } impl OutOfLineAssign { pub fn constructor_1(this: Ptr) { - SeesThis::constructor_1(field_ptr!(this, s)); - field!(this, v).write(1); - field!(this, w).write(Vec::new()); + this.write(::default()); + } +} +impl Default for OutOfLineAssign { + fn default() -> Self { + { + OutOfLineAssign { + s: ::default(), + v: 1, + w: Vec::new(), + } + } } } impl CopyAssignable for OutOfLineAssign { @@ -712,7 +766,7 @@ fn main_0() -> i32 { && ((*bufs.borrow())[0_usize].data.is_empty()) }) ); - object!(o1, Owner::constructor_1()); + let o1: Value = Rc::new(RefCell::new(::default())); ({ let __tmp_3: Value = Rc::new(RefCell::new(5)); MoveConstructible::push_moved( @@ -740,7 +794,7 @@ fn main_0() -> i32 { && (({ (*o1.borrow()).p.clone() }.as_pointer()).is_null()) }) ); - object!(o3, Owner::constructor_1()); + let o3: Value = Rc::new(RefCell::new(::default())); assign!(o3 = RvalueRef(o2)); assert!( ((({ (*o3.borrow()).n } == 5) @@ -766,7 +820,7 @@ fn main_0() -> i32 { }); assert!(({ (c2.data.len() == 2_usize) && ((*c3.borrow()).data.len() == 2_usize) })); assert!(({ (*c1.borrow()).data.is_empty() })); - object!(c4, Copyable::constructor_1()); + let c4: Value = Rc::new(RefCell::new(::default())); assign!(c4 = RvalueRef(c3)); assert!( ({ @@ -795,14 +849,14 @@ fn main_0() -> i32 { && (({ (*h3.borrow()).p.clone() }.as_pointer().read()) == 9)) && (({ (*h2.borrow()).p.clone() }.as_pointer()).is_null()) ); - object!(t1, HasSeesThis::constructor_1()); - object!(t2, HasSeesThis::constructor_1()); - object!(t3, HasSeesThis::constructor_1()); + let t1: Value = Rc::new(RefCell::new(::default())); + let t2: Value = Rc::new(RefCell::new(::default())); + let t3: Value = Rc::new(RefCell::new(::default())); assign!(t2 = RvalueRef(t1)); assert!(({ { (*t2.borrow()).s.self_.clone() } } == { (field_ptr!(t2.as_pointer(), s)) })); assign!(t3 = t2); assert!(({ { (*t3.borrow()).s.self_.clone() } } == { (field_ptr!(t3.as_pointer(), s)) })); - object!(k1, HasCounted::constructor_1()); + let k1: Value = Rc::new(RefCell::new(::default())); object!(k2, HasCounted, |k2| { ::move_constructor( k2.clone(), @@ -810,7 +864,7 @@ fn main_0() -> i32 { ) }); assert!(({ (*k2.borrow()).c.moves } == 1)); - object!(k3, HasCounted::constructor_1()); + let k3: Value = Rc::new(RefCell::new(::default())); assign!(k3 = RvalueRef(k2)); assert!(({ (*k3.borrow()).c.moves } == 2)); { @@ -878,9 +932,9 @@ fn main_0() -> i32 { ({ (*o2.borrow()).v } == 2) && ({ { (*o2.borrow()).x.self_.clone() } } == { (field_ptr!(o2.as_pointer(), x)) }) ); - object!(a1, OutOfLineAssign::constructor_1()); - object!(a2, OutOfLineAssign::constructor_1()); - object!(a3, OutOfLineAssign::constructor_1()); + let a1: Value = Rc::new(RefCell::new(::default())); + let a2: Value = Rc::new(RefCell::new(::default())); + let a3: Value = Rc::new(RefCell::new(::default())); (*a1.borrow_mut()).v = 3; ({ let __tmp_4: Value = Rc::new(RefCell::new(4)); diff --git a/tests/unit/out/refcount/copy_move_deleted.rs b/tests/unit/out/refcount/copy_move_deleted.rs index 7dfea3d983..95f7c873e6 100644 --- a/tests/unit/out/refcount/copy_move_deleted.rs +++ b/tests/unit/out/refcount/copy_move_deleted.rs @@ -46,7 +46,7 @@ pub struct PrivateCopy { } impl PrivateCopy { pub fn constructor_2(this: Ptr) { - field!(this, v).write(0); + this.write(::default()); } pub fn constructor_3(this: Ptr, o: RvalueRef) { let o = o.as_pointer(); @@ -62,6 +62,11 @@ impl MoveAssignable for PrivateCopy { return (this).clone(); } } +impl Default for PrivateCopy { + fn default() -> Self { + { PrivateCopy { v: 0 } } + } +} #[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Conversions)] #[constructor(constructor_1)] #[byte_size(4)] @@ -71,7 +76,12 @@ pub struct Immovable { } impl Immovable { pub fn constructor_1(this: Ptr) { - field!(this, v).write(0); + this.write(::default()); + } +} +impl Default for Immovable { + fn default() -> Self { + { Immovable { v: 0 } } } } #[derive( @@ -102,7 +112,12 @@ pub struct VecHolder { } impl VecHolder { pub fn constructor_1(this: Ptr) { - field!(this, items).write(Vec::new()); + this.write(::default()); + } +} +impl Default for VecHolder { + fn default() -> Self { + { VecHolder { items: Vec::new() } } } } pub fn bump_0(mut p: Ptr) { @@ -123,7 +138,7 @@ fn main_0() -> i32 { assert!(({ (*a.borrow()).v } == 1) && ({ (*b.borrow()).v } == 0)); ({ bump_0((a.as_pointer())) }); assert!(({ (*a.borrow()).v } == 2)); - object!(p, PrivateCopy::constructor_2()); + let p: Value = Rc::new(RefCell::new(::default())); (*p.borrow_mut()).v = 3; object!( q, @@ -132,7 +147,7 @@ fn main_0() -> i32 { assert!(({ (*q.borrow()).v } == 3) && ({ (*p.borrow()).v } == 0)); assign!(p = RvalueRef(q)); assert!(({ (*p.borrow()).v } == 3) && ({ (*q.borrow()).v } == 0)); - object!(im, Immovable::constructor_1()); + let im: Value = Rc::new(RefCell::new(::default())); (*im.borrow_mut()).v = 4; ({ bump_ref_1(im.as_pointer()) }); let mut pim: Ptr = (im.as_pointer()); @@ -155,7 +170,7 @@ fn main_0() -> i32 { (({ (*d.borrow()).inner.v } == 6) && ({ (*d.borrow()).tag } == 7)) && ({ (*c.borrow()).inner.v } == 0) ); - object!(h, VecHolder::constructor_1()); + let h: Value = Rc::new(RefCell::new(::default())); object!(h2, VecHolder, |h2| { ::move_constructor( h2.clone(), diff --git a/tests/unit/out/refcount/enum_underlying_type.rs b/tests/unit/out/refcount/enum_underlying_type.rs index 557cfbb795..9858a32841 100644 --- a/tests/unit/out/refcount/enum_underlying_type.rs +++ b/tests/unit/out/refcount/enum_underlying_type.rs @@ -45,7 +45,16 @@ pub struct HoldsEmpty { } impl HoldsEmpty { pub fn constructor_1(this: Ptr) { - field!(this, e).write(::default()); + this.write(::default()); + } +} +impl Default for HoldsEmpty { + fn default() -> Self { + { + HoldsEmpty { + e: ::default(), + } + } } } pub fn main() { @@ -79,10 +88,10 @@ fn main_0() -> i32 { let mut sc: Scoped = Scoped_NEG; assert!(((sc as i32) == -2_i32)); assert!((((Scoped_POS as i8) as i32) == 2)); - object!(he, HoldsEmpty::constructor_1()); - assert!(!({ (*he.borrow()).e })); + let mut he: HoldsEmpty = ::default(); + assert!(!(he.e)); let mut ev: Empty = ::default(); - assert!(((ev as i32) == ({ (*he.borrow()).e } as i32))); + assert!(((ev as i32) == (he.e as i32))); return 0; } pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/field_method_receiver.rs b/tests/unit/out/refcount/field_method_receiver.rs index ccf8ac4aaa..b0b5df617d 100644 --- a/tests/unit/out/refcount/field_method_receiver.rs +++ b/tests/unit/out/refcount/field_method_receiver.rs @@ -80,14 +80,21 @@ impl S { ({ Counter::add(field_ptr!(this, c), this.with(|__s| __s.tag)) }); } pub fn constructor_1(this: Ptr) { - 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()); + this.write(::default()); + } +} +impl Default for S { + fn default() -> Self { + { + S { + tag: 0_i32, + c: ::default(), + arr: (0..2) + .map(|_| ::default()) + .collect::>(), + v: Vec::new(), + } + } } } pub fn run_0(mut o: Ptr) { diff --git a/tests/unit/out/refcount/field_pointers.rs b/tests/unit/out/refcount/field_pointers.rs index e3682ad936..014efefc6e 100644 --- a/tests/unit/out/refcount/field_pointers.rs +++ b/tests/unit/out/refcount/field_pointers.rs @@ -99,12 +99,21 @@ impl Outer { }); } pub fn constructor_1(this: Ptr) { - 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::>()); + this.write(::default()); + } +} +impl Default for Outer { + fn default() -> Self { + { + Outer { + x: 0_i32, + inner: ::default(), + items: (0..3).map(|_| ::default()).collect::>(), + v: Vec::new(), + cursor: Ptr::::null(), + buf: (0..4).map(|_| 0_i32).collect::>(), + } + } } } pub fn set_0(mut p: Ptr, mut value: i32) { diff --git a/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs b/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs index 9949a008fb..13540da7cc 100644 --- a/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs +++ b/tests/unit/out/refcount/foreach_disjoint_field_borrow.rs @@ -32,8 +32,17 @@ pub struct S { } impl S { pub fn constructor_1(this: Ptr) { - field!(this, v).write(Vec::new()); - field!(this, a).write(0_i32); + this.write(::default()); + } +} +impl Default for S { + fn default() -> Self { + { + S { + v: Vec::new(), + a: 0_i32, + } + } } } pub fn main() { @@ -41,7 +50,7 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - object!(s, S::constructor_1()); + let s: Value = Rc::new(RefCell::new(::default())); ({ let __tmp_0: Value = Rc::new(RefCell::new(1)); MoveConstructible::push_moved( diff --git a/tests/unit/out/refcount/global_non_const_init.rs b/tests/unit/out/refcount/global_non_const_init.rs index 1e2d2eed92..2adf0bdd3a 100644 --- a/tests/unit/out/refcount/global_non_const_init.rs +++ b/tests/unit/out/refcount/global_non_const_init.rs @@ -53,18 +53,19 @@ pub struct Ctor { } impl Ctor { pub fn constructor_1(this: Ptr) { - field!(this, v).write(({ next_0() })); + this.write(::default()); } pub fn constructor_2(this: Ptr, mut x: i32) { field!(this, v).write(x); } } +impl Default for Ctor { + fn default() -> Self { + { Ctor { v: ({ next_0() }) } } + } +} thread_local!( - pub static default_ctor_7: Value = Rc::new(RefCell::new({ - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - Ctor::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - })); + pub static default_ctor_7: Value = Rc::new(RefCell::new(::default())); ); thread_local!( pub static arg_ctor_8: Value = Rc::new(RefCell::new({ @@ -138,18 +139,19 @@ pub struct Singleton { } impl Singleton { pub fn constructor_1(this: Ptr) { - field!(this, hits).write(0); + this.write(::default()); } pub fn instance() -> Ptr { return s_15.with(|v| v.as_pointer()); } } +impl Default for Singleton { + fn default() -> Self { + { Singleton { hits: 0 } } + } +} thread_local!( - static s_15: Value = Rc::new(RefCell::new({ - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - Singleton::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - })); + static s_15: Value = Rc::new(RefCell::new(::default())); ); pub fn main() { __cpp2rust_init_globals(); diff --git a/tests/unit/out/refcount/huffman.rs b/tests/unit/out/refcount/huffman.rs index 76cfddedf3..a93a19a1ab 100644 --- a/tests/unit/out/refcount/huffman.rs +++ b/tests/unit/out/refcount/huffman.rs @@ -237,11 +237,20 @@ impl MinHeap { } } pub fn constructor_1(this: Ptr) { - 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); + this.write(::default()); + } +} +impl Default for MinHeap { + fn default() -> Self { + { + MinHeap { + size: 0_i32, + capacity: 0_i32, + arr: None, + next: 0_i32, + alloc: None, + } + } } } pub fn AllocMinHeap_1(mut capacity: i32) -> Option> { diff --git a/tests/unit/out/refcount/implicit_autoref.rs b/tests/unit/out/refcount/implicit_autoref.rs index b1ca3a62fd..b1b3b5551b 100644 --- a/tests/unit/out/refcount/implicit_autoref.rs +++ b/tests/unit/out/refcount/implicit_autoref.rs @@ -30,7 +30,12 @@ pub struct Holder { } impl Holder { pub fn constructor_1(this: Ptr) { - field!(this, v).write(Vec::new()); + this.write(::default()); + } +} +impl Default for Holder { + fn default() -> Self { + { Holder { v: Vec::new() } } } } pub fn write_through_0(mut p: Ptr) { @@ -53,7 +58,7 @@ 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); - object!(h, Holder::constructor_1()); + let h: Value = Rc::new(RefCell::new(::default())); ({ let __tmp_2: Value = Rc::new(RefCell::new(40)); MoveConstructible::push_moved( diff --git a/tests/unit/out/refcount/in_class_field_initializer.rs b/tests/unit/out/refcount/in_class_field_initializer.rs index 6224e45185..41bafafe18 100644 --- a/tests/unit/out/refcount/in_class_field_initializer.rs +++ b/tests/unit/out/refcount/in_class_field_initializer.rs @@ -28,8 +28,12 @@ pub struct Inner { } impl Inner { pub fn constructor_1(this: Ptr) { - field!(this, x).write(3); - field!(this, y).write(4); + this.write(::default()); + } +} +impl Default for Inner { + fn default() -> Self { + { Inner { x: 3, y: 4 } } } } #[derive( @@ -63,7 +67,7 @@ impl S { field!(this, a).write(1); field!(this, b).write(2_i8); field!(this, c).write(Inner { x: 3, y: 4 }); - Inner::constructor_1(field_ptr!(this, d)); + field!(this, d).write(::default()); } } #[derive( diff --git a/tests/unit/out/refcount/init_list.rs b/tests/unit/out/refcount/init_list.rs index 9609a591cb..0d74dc458b 100644 --- a/tests/unit/out/refcount/init_list.rs +++ b/tests/unit/out/refcount/init_list.rs @@ -80,7 +80,12 @@ pub struct Seven { } impl Seven { pub fn constructor_1(this: Ptr) { - field!(this, v).write(7); + this.write(::default()); + } +} +impl Default for Seven { + fn default() -> Self { + { Seven { v: 7 } } } } pub fn main() { diff --git a/tests/unit/out/refcount/inline_container_fields.rs b/tests/unit/out/refcount/inline_container_fields.rs index 32edac2df3..e5d44f3ca6 100644 --- a/tests/unit/out/refcount/inline_container_fields.rs +++ b/tests/unit/out/refcount/inline_container_fields.rs @@ -36,9 +36,18 @@ pub struct Elem { } impl Elem { pub fn constructor_1(this: Ptr) { - field!(this, id).write(0_i32); - field!(this, hist).write((0..4).map(|_| 0_i32).collect::>()); - field!(this, coeffs).write(Vec::new()); + this.write(::default()); + } +} +impl Default for Elem { + fn default() -> Self { + { + Elem { + id: 0_i32, + hist: (0..4).map(|_| 0_i32).collect::>(), + coeffs: Vec::new(), + } + } } } #[derive( @@ -78,17 +87,22 @@ pub struct State { } impl State { pub fn constructor_1(this: Ptr) { - 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()); + this.write(::default()); + } +} +impl Default for State { + fn default() -> Self { + { + State { + count: 0_i32, + grid: (0..2) + .map(|_| (0..3).map(|_| 0_i32).collect::>()) + .collect::]>>(), + arr: Box::<[i32]>::from(std::array::from_fn::<_, 3, _>(|_| 0_i32)), + elems: Vec::new(), + rows: Vec::new(), + } + } } } pub fn sum_0(mut p: Ptr, mut n: i32) -> i32 { @@ -175,7 +189,7 @@ pub struct Counted { } impl Counted { pub fn constructor_1(this: Ptr) { - field!(this, v).write(0); + this.write(::default()); } pub fn constructor_2(this: Ptr, o: LvalueRef>) { let o = o.as_pointer(); @@ -206,6 +220,11 @@ impl MoveAssignable for Counted { return (this).clone(); } } +impl Default for Counted { + fn default() -> Self { + { Counted { v: 0 } } + } +} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); diff --git a/tests/unit/out/refcount/kruskal.rs b/tests/unit/out/refcount/kruskal.rs index 620da014e1..e524ba4cb9 100644 --- a/tests/unit/out/refcount/kruskal.rs +++ b/tests/unit/out/refcount/kruskal.rs @@ -230,9 +230,18 @@ impl DisjointSet { } } pub fn constructor_1(this: Ptr) { - field!(this, rank).write(None); - field!(this, parent).write(None); - field!(this, n).write(0_i32); + this.write(::default()); + } +} +impl Default for DisjointSet { + fn default() -> Self { + { + DisjointSet { + rank: None, + parent: None, + n: 0_i32, + } + } } } #[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Swappable)] @@ -252,9 +261,18 @@ pub struct Graph { } impl Graph { pub fn constructor_1(this: Ptr) { - field!(this, edges).write(None); - field!(this, V).write(0_i32); - field!(this, E).write(0_i32); + this.write(::default()); + } +} +impl Default for Graph { + fn default() -> Self { + { + Graph { + edges: None, + V: 0_i32, + E: 0_i32, + } + } } } pub fn MSTKruskal_2(graph: Ptr) -> f64 { diff --git a/tests/unit/out/refcount/lambda_capture_copy_ctor.rs b/tests/unit/out/refcount/lambda_capture_copy_ctor.rs index 82ce0d709d..f163582bc1 100644 --- a/tests/unit/out/refcount/lambda_capture_copy_ctor.rs +++ b/tests/unit/out/refcount/lambda_capture_copy_ctor.rs @@ -20,8 +20,7 @@ pub struct Counted { } impl Counted { pub fn constructor_1(this: Ptr) { - field!(this, copies).write(0); - field!(this, moves).write(0); + this.write(::default()); } pub fn constructor_2(this: Ptr, o: LvalueRef>) { let o = o.as_pointer(); @@ -34,6 +33,16 @@ impl Counted { field!(this, moves).write((o.with(|__s| __s.moves) + 1)); } } +impl Default for Counted { + fn default() -> Self { + { + Counted { + copies: 0, + moves: 0, + } + } + } +} thread_local!( pub static drops_0: Value = Rc::new(RefCell::new(0)); ); @@ -45,7 +54,9 @@ thread_local!( #[byte_size(1)] pub struct Dropped {} impl Dropped { - pub fn constructor_1(this: Ptr) {} + pub fn constructor_1(this: Ptr) { + this.write(::default()); + } pub fn constructor_2(this: Ptr, _a0: LvalueRef>) { let _a0 = _a0.as_pointer(); } @@ -58,12 +69,17 @@ impl Destructible for Dropped { (*drops_0.with(Value::clone).borrow_mut()).postfix_inc(); } } +impl Default for Dropped { + fn default() -> Self { + { Dropped {} } + } +} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - object!(c, Counted::constructor_1()); + let c: Value = Rc::new(RefCell::new(::default())); let f: Value i32>> = Rc::new(RefCell::new(lambda!( { let c: Value = Rc::new(RefCell::new({ @@ -110,13 +126,11 @@ fn main_0() -> i32 { .with(|__s| __s.copies) }; assert!((returned == 2)); - let arr: Value> = Rc::new(RefCell::new(Box::new( - std::array::from_fn::<_, 2, _>(|_| { - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - Counted::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }), - ))); + let arr: Value> = Rc::new(RefCell::new( + (0..2) + .map(|_| ::default()) + .collect::>(), + )); let a: Value i32>> = Rc::new(RefCell::new(lambda!( { let arr: Value> = Rc::new(RefCell::new(Box::new( @@ -145,12 +159,7 @@ fn main_0() -> i32 { { let m: Value> = Rc::new(RefCell::new(lambda!( { - let d: Value = Rc::new(RefCell::new({ - let __v: Value = - Rc::new(RefCell::new(ZeroInitialization::zero_init())); - Dropped::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - })); + let d: Value = Rc::new(RefCell::new(::default())); }, || {} ))); @@ -164,12 +173,7 @@ fn main_0() -> i32 { { let k: Value> = Rc::new(RefCell::new(lambda!( { - let d: Value = Rc::new(RefCell::new({ - let __v: Value = - Rc::new(RefCell::new(ZeroInitialization::zero_init())); - Dropped::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - })); + let d: Value = Rc::new(RefCell::new(::default())); }, || {} ))); @@ -183,12 +187,7 @@ fn main_0() -> i32 { { let inner: Value> = Rc::new(RefCell::new(lambda!( { - let d: Value = Rc::new(RefCell::new({ - let __v: Value = - Rc::new(RefCell::new(ZeroInitialization::zero_init())); - Dropped::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - })); + let d: Value = Rc::new(RefCell::new(::default())); }, || {} ))); diff --git a/tests/unit/out/refcount/lambda_decltype_type.rs b/tests/unit/out/refcount/lambda_decltype_type.rs index 10f312efff..20d6eb10da 100644 --- a/tests/unit/out/refcount/lambda_decltype_type.rs +++ b/tests/unit/out/refcount/lambda_decltype_type.rs @@ -40,15 +40,22 @@ impl Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { field!(this, size).with_mut(|__v| __v.postfix_inc()); } pub fn constructor_1(this: Ptr) { - 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); - } - }, - )); + this.write(::default()); + } +} +impl Default for Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { + fn default() -> Self { + { + Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { + items: (0..4).map(|_| 0_i32).collect::>(), + size: 0, + cmp: FnPtr:: bool>::new(|mut a: i32, mut b: i32| -> bool { + { + return (a > b); + } + }), + } + } } } #[derive( @@ -85,15 +92,22 @@ impl Sorted__lambda_at_lambda_decltype_type_cpp_19_23__ { field!(this, size).with_mut(|__v| __v.postfix_inc()); } pub fn constructor_1(this: Ptr) { - 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); - } - }, - )); + this.write(::default()); + } +} +impl Default for Sorted__lambda_at_lambda_decltype_type_cpp_19_23__ { + fn default() -> Self { + { + Sorted__lambda_at_lambda_decltype_type_cpp_19_23__ { + items: (0..4).map(|_| 0_i32).collect::>(), + size: 0, + cmp: FnPtr:: bool>::new(|mut a: i32, mut b: i32| -> bool { + { + return (a < b); + } + }), + } + } } } pub fn main() { @@ -109,20 +123,18 @@ fn main_0() -> i32 { } }, ))); - object!( - desc, - Sorted__lambda_at_lambda_decltype_type_cpp_22_18__::constructor_1() - ); + let desc: Value = Rc::new(RefCell::new( + ::default(), + )); ({ Sorted__lambda_at_lambda_decltype_type_cpp_22_18__::insert(desc.as_pointer(), 2) }); ({ Sorted__lambda_at_lambda_decltype_type_cpp_22_18__::insert(desc.as_pointer(), 7) }); ({ Sorted__lambda_at_lambda_decltype_type_cpp_22_18__::insert(desc.as_pointer(), 4) }); assert!(((array_elem!(desc.as_pointer(), items, 0).read()) == 7)); assert!(((array_elem!(desc.as_pointer(), items, 1).read()) == 4)); assert!(((array_elem!(desc.as_pointer(), items, 2).read()) == 2)); - object!( - asc, - Sorted__lambda_at_lambda_decltype_type_cpp_19_23__::constructor_1() - ); + let asc: Value = Rc::new(RefCell::new( + ::default(), + )); ({ Sorted__lambda_at_lambda_decltype_type_cpp_19_23__::insert(asc.as_pointer(), 2) }); ({ Sorted__lambda_at_lambda_decltype_type_cpp_19_23__::insert(asc.as_pointer(), 7) }); ({ Sorted__lambda_at_lambda_decltype_type_cpp_19_23__::insert(asc.as_pointer(), 4) }); diff --git a/tests/unit/out/refcount/lambda_immediate_init.rs b/tests/unit/out/refcount/lambda_immediate_init.rs index 8a185bc1af..1a242de822 100644 --- a/tests/unit/out/refcount/lambda_immediate_init.rs +++ b/tests/unit/out/refcount/lambda_immediate_init.rs @@ -31,17 +31,24 @@ pub struct S { } impl S { pub fn constructor_1(this: Ptr) { - field!(this, j).write(10); - field!(this, k).write( - (({ - FnPtr:: i32>::new(|| -> i32 { - { - return 3; - } - }) - .call() - }) + 1), - ); + this.write(::default()); + } +} +impl Default for S { + fn default() -> Self { + { + S { + j: 10, + k: (({ + FnPtr:: i32>::new(|| -> i32 { + { + return 3; + } + }) + .call() + }) + 1), + } + } } } thread_local!( @@ -86,8 +93,8 @@ fn main_0() -> i32 { }) == 237) ); assert!((({ pick_0(1,) }) == 1)); - object!(s, S::constructor_1()); - assert!(({ (*s.borrow()).k } == 4)); + let mut s: S = ::default(); + assert!((s.k == 4)); assert!((g_1.with(|rc| *rc.borrow()) == 10)); let a: Value = Rc::new(RefCell::new(2)); let mut c: i32 = ({ diff --git a/tests/unit/out/refcount/libc_struct_without_default.rs b/tests/unit/out/refcount/libc_struct_without_default.rs index e229405084..b2df0db18e 100644 --- a/tests/unit/out/refcount/libc_struct_without_default.rs +++ b/tests/unit/out/refcount/libc_struct_without_default.rs @@ -34,10 +34,17 @@ pub struct UserDefined { } impl UserDefined { pub fn constructor_1(this: Ptr) { - field!(this, a).write(Box::<[i32]>::from(std::array::from_fn::<_, 1, _>(|_| { - 0_i32 - }))); - field!(this, v).write(Vec::new()); + this.write(::default()); + } +} +impl Default for UserDefined { + fn default() -> Self { + { + UserDefined { + a: Box::<[i32]>::from(std::array::from_fn::<_, 1, _>(|_| 0_i32)), + v: Vec::new(), + } + } } } #[derive( @@ -83,7 +90,7 @@ 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))); - object!(ud, UserDefined::constructor_1()); + let ud: Value = Rc::new(RefCell::new(::default())); 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) })); diff --git a/tests/unit/out/refcount/map.rs b/tests/unit/out/refcount/map.rs index 4a4078cb8e..c72268722a 100644 --- a/tests/unit/out/refcount/map.rs +++ b/tests/unit/out/refcount/map.rs @@ -38,14 +38,18 @@ pub struct Point { } impl Point { pub fn constructor_1(this: Ptr) { - field!(this, x).write(0); - field!(this, y).write(0); + this.write(::default()); } pub fn constructor_2(this: Ptr, mut x: i32, mut y: i32) { field!(this, x).write(x); field!(this, y).write(y); } } +impl Default for Point { + fn default() -> Self { + { Point { x: 0, y: 0 } } + } +} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); diff --git a/tests/unit/out/refcount/map_try_emplace.rs b/tests/unit/out/refcount/map_try_emplace.rs index 2b13f14ee1..bf6fd867e1 100644 --- a/tests/unit/out/refcount/map_try_emplace.rs +++ b/tests/unit/out/refcount/map_try_emplace.rs @@ -31,7 +31,7 @@ pub struct Item { } impl Item { pub fn constructor_1(this: Ptr) { - field!(this, value).write(0); + this.write(::default()); } pub fn constructor_2(this: Ptr, mut value: i32) { field!(this, value).write(value); @@ -49,6 +49,11 @@ impl Item { field!(other, value).write(-1_i32); } } +impl Default for Item { + fn default() -> Self { + { Item { value: 0 } } + } +} pub fn argument_4(item: Ptr) -> Ptr { (*calls_0.with(Value::clone).borrow_mut()).prefix_inc(); return (item).clone(); @@ -74,7 +79,7 @@ pub struct RefItem { } impl RefItem { pub fn constructor_1(this: Ptr) { - field!(this, value).write(0); + this.write(::default()); } pub fn constructor_2(this: Ptr, counter: LvalueRef, mut amount: i32) { let counter = counter.as_pointer(); @@ -87,6 +92,11 @@ impl RefItem { (*made_1.with(Value::clone).borrow_mut()).prefix_inc(); } } +impl Default for RefItem { + fn default() -> Self { + { RefItem { value: 0 } } + } +} pub fn reference_5(counter: Ptr) -> Ptr { (*calls_0.with(Value::clone).borrow_mut()).prefix_inc(); return (counter).clone(); diff --git a/tests/unit/out/refcount/map_try_emplace_lvalues.rs b/tests/unit/out/refcount/map_try_emplace_lvalues.rs index fe8f5fb932..c544e2e8b5 100644 --- a/tests/unit/out/refcount/map_try_emplace_lvalues.rs +++ b/tests/unit/out/refcount/map_try_emplace_lvalues.rs @@ -33,7 +33,7 @@ pub struct Item { } impl Item { pub fn constructor_1(this: Ptr) { - field!(this, value).write(0); + this.write(::default()); } pub fn constructor_2(this: Ptr, counter: LvalueRef, mut amount: i32) { let counter = counter.as_pointer(); @@ -46,6 +46,11 @@ impl Item { (*made_0.with(Value::clone).borrow_mut()).prefix_inc(); } } +impl Default for Item { + fn default() -> Self { + { Item { value: 0 } } + } +} pub fn receiver_2( m: Ptr, Value)>>, ) -> Ptr, Value)>> { @@ -123,16 +128,26 @@ pub struct Owner { } impl Owner { pub fn constructor_1(this: Ptr) { - field!(this, ptr).write(Some(Rc::new(RefCell::new({ - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - Temporary::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - })))); + this.write(::default()); } pub fn value(this: Ptr) -> Ptr { return field_ptr!(this.with(|__s| __s.ptr.clone()).as_pointer(), n); } } +impl Default for Owner { + fn default() -> Self { + { + Owner { + ptr: Some(Rc::new(RefCell::new({ + let __v: Value = + Rc::new(RefCell::new(ZeroInitialization::zero_init())); + Temporary::constructor_1(__v.as_pointer()); + Rc::try_unwrap(__v).ok().unwrap().into_inner() + }))), + } + } + } +} #[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Conversions)] #[constructor(constructor_1)] #[byte_size(4)] @@ -142,7 +157,12 @@ pub struct Noncopy { } impl Noncopy { pub fn constructor_1(this: Ptr) { - field!(this, n).write(5); + this.write(::default()); + } +} +impl Default for Noncopy { + fn default() -> Self { + { Noncopy { n: 5 } } } } #[derive( @@ -159,7 +179,7 @@ pub struct Held { } impl Held { pub fn constructor_1(this: Ptr) { - field!(this, ptr).write(Ptr::::null()); + this.write(::default()); } pub fn constructor_2(this: Ptr, n: LvalueRef>) { let n = n.as_pointer(); @@ -169,6 +189,15 @@ impl Held { field!(this, ptr).write((n).clone()); } } +impl Default for Held { + fn default() -> Self { + { + Held { + ptr: Ptr::::null(), + } + } + } +} thread_local!( pub static global_values_7: Value, Value)>> = Rc::new(RefCell::new(Map::new())); @@ -2283,12 +2312,11 @@ fn main_0() -> i32 { let owners: Value, Value)>> = Rc::new(RefCell::new(Map::new())); { - let __tmp_109: Value = - Rc::new(RefCell::new(ZeroInitialization::zero_init())); + let __tmp_109: Value; { match (({ Owner::value({ - Owner::constructor_1(__tmp_109.as_pointer()); + __tmp_109 = Rc::new(RefCell::new(::default())); __tmp_109.as_pointer() }) }),) @@ -2365,11 +2393,9 @@ fn main_0() -> i32 { )> = Rc::new(RefCell::new({ let __tmp_111: Value>>; match ({ - __tmp_111 = Rc::new(RefCell::new(Some(Rc::new(RefCell::new({ - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - Noncopy::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }))))); + __tmp_111 = Rc::new(RefCell::new(Some(Rc::new(RefCell::new( + ::default(), + ))))); __tmp_111.as_pointer() },) { @@ -2405,11 +2431,9 @@ fn main_0() -> i32 { )> = Rc::new(RefCell::new({ let __tmp_113: Value>>; match ({ - __tmp_113 = Rc::new(RefCell::new(Some(Rc::new(RefCell::new({ - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - Noncopy::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }))))); + __tmp_113 = Rc::new(RefCell::new(Some(Rc::new(RefCell::new( + ::default(), + ))))); __tmp_113.as_pointer() },) { diff --git a/tests/unit/out/refcount/move_assign.rs b/tests/unit/out/refcount/move_assign.rs index cccda90354..9bcaaf667e 100644 --- a/tests/unit/out/refcount/move_assign.rs +++ b/tests/unit/out/refcount/move_assign.rs @@ -47,7 +47,7 @@ pub struct ConstMoveAssign { } impl ConstMoveAssign { pub fn constructor_1(this: Ptr) { - field!(this, mark).write(0); + this.write(::default()); } pub fn operator_assign_2(this: Ptr, o: Ptr) -> Ptr { field!(this, mark).write((o.with(|__s| __s.mark) + 1)); @@ -58,6 +58,11 @@ impl ConstMoveAssign { return (this).clone(); } } +impl Default for ConstMoveAssign { + fn default() -> Self { + { ConstMoveAssign { mark: 0 } } + } +} pub fn make_0(__return: Ptr, mut v: i32) { object!(m, MoveOnly::constructor_1(v)); MoveOnly::constructor_3(__return.clone(), RvalueRef::bind(m.as_pointer())); @@ -112,10 +117,10 @@ fn main_0() -> i32 { assign!(*vec_.decay().offset(0_usize) = RvalueRef(d)); assert!(({ (*vec_.borrow())[0_usize].v } == 8)); assert!(({ (*d.borrow()).v } == 0)); - object!(m, ConstMoveAssign::constructor_1()); - object!(m1, ConstMoveAssign::constructor_1()); - object!(m2, ConstMoveAssign::constructor_1()); - object!(cm, ConstMoveAssign::constructor_1()); + let m: Value = Rc::new(RefCell::new(::default())); + let m1: Value = Rc::new(RefCell::new(::default())); + let m2: Value = Rc::new(RefCell::new(::default())); + let cm: Value = Rc::new(RefCell::new(::default())); ConstMoveAssign::operator_assign_2(m1.as_pointer(), m.as_pointer()); ConstMoveAssign::operator_assign_3(m2.as_pointer(), cm.as_pointer()); assert!(({ (*m1.borrow()).mark } == 1)); diff --git a/tests/unit/out/refcount/move_ctor.rs b/tests/unit/out/refcount/move_ctor.rs index 99dedef373..b815204354 100644 --- a/tests/unit/out/refcount/move_ctor.rs +++ b/tests/unit/out/refcount/move_ctor.rs @@ -37,7 +37,7 @@ pub struct ConstMove { } impl ConstMove { pub fn constructor_1(this: Ptr) { - field!(this, mark).write(0); + this.write(::default()); } pub fn constructor_2(this: Ptr, o: RvalueRef) { let o = o.as_pointer(); @@ -48,6 +48,11 @@ impl ConstMove { field!(this, mark).write((o.with(|__s| __s.mark) + 10)); } } +impl Default for ConstMove { + fn default() -> Self { + { ConstMove { mark: 0 } } + } +} #[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Conversions)] #[conversions(copy, move)] #[constructor(constructor_1, i32)] @@ -172,12 +177,12 @@ fn main_0() -> i32 { MoveConstructible::push_moved(&vec_.as_pointer(), f.as_pointer()); assert!(({ (*vec_.borrow())[0_usize].v } == 7) && ({ (*vec_.borrow())[1_usize].v } == 8)); assert!(({ (*f.borrow()).v } == 0)); - object!(m, ConstMove::constructor_1()); + let m: Value = Rc::new(RefCell::new(::default())); object!( m1, ConstMove::constructor_2(RvalueRef::bind(m.as_pointer())) ); - object!(cm, ConstMove::constructor_1()); + let cm: Value = Rc::new(RefCell::new(::default())); object!( m2, ConstMove::constructor_3(RvalueRef::bind(cm.as_pointer())) diff --git a/tests/unit/out/refcount/push_emplace_back.rs b/tests/unit/out/refcount/push_emplace_back.rs index 63380659fc..9f732d4b3f 100644 --- a/tests/unit/out/refcount/push_emplace_back.rs +++ b/tests/unit/out/refcount/push_emplace_back.rs @@ -72,8 +72,17 @@ pub struct JPEGData { } impl JPEGData { pub fn constructor_1(this: Ptr) { - field!(this, com_data).write(Vec::new()); - field!(this, app_data).write(Vec::new()); + this.write(::default()); + } +} +impl Default for JPEGData { + fn default() -> Self { + { + JPEGData { + com_data: Vec::new(), + app_data: Vec::new(), + } + } } } pub fn push_param_0(mut dest: Ptr>>) { @@ -178,8 +187,7 @@ pub struct Pair { } impl Pair { pub fn constructor_1(this: Ptr) { - field!(this, first).write(-1_i32); - field!(this, second).write(-1_i32); + this.write(::default()); } pub fn constructor_2(this: Ptr, mut a: i32) { field!(this, first).write(a); @@ -190,15 +198,19 @@ impl Pair { field!(this, second).write((b * 2)); } } +impl Default for Pair { + fn default() -> Self { + { + Pair { + first: -1_i32, + second: -1_i32, + } + } + } +} pub fn emplace_ctor_args_7(mut pairs: Ptr>) { { - pairs.with_mut(|__v: &mut Vec| { - __v.push({ - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - Pair::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }) - }); + pairs.with_mut(|__v: &mut Vec| __v.push(::default())); }; { let mut __tmp_4 = { @@ -233,13 +245,7 @@ pub fn emplace_deque_8(mut queue: Ptr>) { queue.with_mut(|__v: &mut Vec| __v.push(__tmp_6)); }; { - queue.with_mut(|__v: &mut Vec| { - __v.push({ - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - Pair::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }) - }); + queue.with_mut(|__v: &mut Vec| __v.push(::default())); }; } pub fn emplace_scalar_9(mut values: Ptr>, x: i32) { @@ -368,8 +374,17 @@ pub struct Bytes { } impl Bytes { pub fn constructor_1(this: Ptr) { - field!(this, v).write(Vec::new()); - field!(this, b).write((0..3).map(|_| 0_u8).collect::>()); + this.write(::default()); + } +} +impl Default for Bytes { + fn default() -> Self { + { + Bytes { + v: Vec::new(), + b: (0..3).map(|_| 0_u8).collect::>(), + } + } } } pub fn emplace_from_element_14(mut v: Ptr>>) { @@ -506,7 +521,7 @@ 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() })); - object!(jpg, JPEGData::constructor_1()); + let jpg: Value = Rc::new(RefCell::new(::default())); ({ push_local_from_field_1((jpg.as_pointer()), true) }); assert!(({ ((*jpg.borrow()).com_data.len() == 1_usize) })); assert!( diff --git a/tests/unit/out/refcount/self_referencing_initializer.rs b/tests/unit/out/refcount/self_referencing_initializer.rs index 8fbf64c23d..d7290198a4 100644 --- a/tests/unit/out/refcount/self_referencing_initializer.rs +++ b/tests/unit/out/refcount/self_referencing_initializer.rs @@ -59,8 +59,17 @@ pub struct node_with_defaults { } impl node_with_defaults { pub fn constructor_1(this: Ptr) { - field!(this, next).write(Ptr::::null()); - field!(this, value).write(3); + this.write(::default()); + } +} +impl Default for node_with_defaults { + fn default() -> Self { + { + node_with_defaults { + next: Ptr::::null(), + value: 3, + } + } } } pub fn init_0(mut l: Ptr) -> Ptr { @@ -100,7 +109,7 @@ fn main_0() -> i32 { ]); assert!(({ { (*arr.borrow())[(0) as usize].next.clone() } } == { (arr.decay().offset(1)) })); assert!(({ { (*arr.borrow())[(1) as usize].next.clone() } } == { (arr.decay().offset(0)) })); - let d: Value = >::zero_init(); + let d: Value = >::default(); *d.borrow_mut() = node_with_defaults { next: (d.as_pointer()), value: 3, diff --git a/tests/unit/out/refcount/sort_no_copy.rs b/tests/unit/out/refcount/sort_no_copy.rs index 6dd9f3302a..ae0a85157c 100644 --- a/tests/unit/out/refcount/sort_no_copy.rs +++ b/tests/unit/out/refcount/sort_no_copy.rs @@ -22,7 +22,7 @@ pub struct Tracked { } impl Tracked { pub fn constructor_1(this: Ptr) { - field!(this, v).write(0); + this.write(::default()); } pub fn constructor_2(this: Ptr, mut v: i32) { field!(this, v).write(v); @@ -52,6 +52,11 @@ impl MoveAssignable for Tracked { return (this).clone(); } } +impl Default for Tracked { + fn default() -> Self { + { Tracked { v: 0 } } + } +} impl LessThanComparable for Tracked { fn less(a: Ptr, b: Ptr) -> bool { return ({ a.with(|__s| __s.v) } < { b.with(|__s| __s.v) }); @@ -95,7 +100,12 @@ pub struct Bag { } impl Bag { pub fn constructor_1(this: Ptr) { - field!(this, items).write(Vec::new()); + this.write(::default()); + } +} +impl Default for Bag { + fn default() -> Self { + { Bag { items: Vec::new() } } } } impl LessThanComparable for Bag { @@ -286,13 +296,9 @@ 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(Box::new(std::array::from_fn::<_, 3, _>( - |_| { - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - Bag::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }, - )))); + let bags: Value> = Rc::new(RefCell::new( + (0..3).map(|_| ::default()).collect::>(), + )); { let mut __tmp_9 = { { diff --git a/tests/unit/out/refcount/struct_default_ctor.rs b/tests/unit/out/refcount/struct_default_ctor.rs index d24fb6812f..7ddc45785b 100644 --- a/tests/unit/out/refcount/struct_default_ctor.rs +++ b/tests/unit/out/refcount/struct_default_ctor.rs @@ -28,8 +28,12 @@ pub struct S { } impl S { pub fn constructor_1(this: Ptr) { - field!(this, a).write(11); - field!(this, b).write(true); + this.write(::default()); + } +} +impl Default for S { + fn default() -> Self { + { S { a: 11, b: true } } } } #[derive( @@ -64,11 +68,16 @@ pub struct Holder { } impl Holder { pub fn constructor_1(this: Ptr) { - field!(this, items).write(Box::new(std::array::from_fn::<_, 2, _>(|_| { - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - S::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }))); + this.write(::default()); + } +} +impl Default for Holder { + fn default() -> Self { + { + Holder { + items: (0..2).map(|_| ::default()).collect::>(), + } + } } } thread_local!( @@ -94,7 +103,16 @@ pub struct FromStatic { } impl FromStatic { pub fn constructor_1(this: Ptr) { - field!(this, v).write(kInit_0.with(|rc| *rc.borrow())); + this.write(::default()); + } +} +impl Default for FromStatic { + fn default() -> Self { + { + FromStatic { + v: kInit_0.with(|rc| *rc.borrow()), + } + } } } pub fn main() { @@ -104,35 +122,21 @@ pub fn main() { fn main_0() -> i32 { let mut d: Ptr = Ptr::::null(); assert!((d).is_null()); - object!(s, S::constructor_1()); - assert!(({ (*s.borrow()).a } == 11)); - assert!((({ (*s.borrow()).b } as i32) == (true as i32))); - let mut h: Ptr = { - let __n = (1_usize) as usize; - let __p = Ptr::alloc_array( - (0..__n) - .map(|_| ::zero_init()) - .collect::>(), - ); - for __i in 0..__n { - Holder::constructor_1(__p.offset(__i)); - } - __p - }; + let mut s: S = ::default(); + assert!((s.a == 11)); + assert!(((s.b as i32) == (true as i32))); + let mut h: Ptr = Ptr::alloc_array( + (0..1_usize) + .map(|_| ::default()) + .collect::>(), + ); assert!((array_elem!(h.offset((0) as isize), items, 1).with(|__s| __s.a) == 11)); h.delete(); - let mut fs: Ptr = { - let __n = (2_usize) as usize; - let __p = Ptr::alloc_array( - (0..__n) - .map(|_| ::zero_init()) - .collect::>(), - ); - for __i in 0..__n { - FromStatic::constructor_1(__p.offset(__i)); - } - __p - }; + let mut fs: Ptr = Ptr::alloc_array( + (0..2_usize) + .map(|_| ::default()) + .collect::>(), + ); assert!((elem!(fs, 1).with(|__s| __s.v) == 3)); fs.delete(); return 0; diff --git a/tests/unit/out/refcount/structured_binding_move_ctor.rs b/tests/unit/out/refcount/structured_binding_move_ctor.rs index ae738556ec..22c1eb228b 100644 --- a/tests/unit/out/refcount/structured_binding_move_ctor.rs +++ b/tests/unit/out/refcount/structured_binding_move_ctor.rs @@ -78,8 +78,17 @@ impl Holder { return; } pub fn constructor_1(this: Ptr) { - field!(this, xs).write(Vec::new()); - field!(this, ys).write(Vec::new()); + this.write(::default()); + } +} +impl Default for Holder { + fn default() -> Self { + { + Holder { + xs: Vec::new(), + ys: Vec::new(), + } + } } } pub fn main() { diff --git a/tests/unit/out/refcount/swap_map_no_copy.rs b/tests/unit/out/refcount/swap_map_no_copy.rs index 4fe76668eb..1c4d184823 100644 --- a/tests/unit/out/refcount/swap_map_no_copy.rs +++ b/tests/unit/out/refcount/swap_map_no_copy.rs @@ -22,7 +22,7 @@ pub struct Tracked { } impl Tracked { pub fn constructor_1(this: Ptr) { - field!(this, v).write(0); + this.write(::default()); } pub fn constructor_2(this: Ptr, mut v: i32) { field!(this, v).write(v); @@ -52,6 +52,11 @@ impl MoveAssignable for Tracked { return (this).clone(); } } +impl Default for Tracked { + fn default() -> Self { + { Tracked { v: 0 } } + } +} #[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Swappable)] #[memberwise(copy_constructor, move_constructor, copy_assign, move_assign)] #[derive(Conversions)] @@ -68,8 +73,17 @@ pub struct Pair { } impl Pair { pub fn constructor_1(this: Ptr) { - Tracked::constructor_1(field_ptr!(this, x)); - Tracked::constructor_1(field_ptr!(this, y)); + this.write(::default()); + } +} +impl Default for Pair { + fn default() -> Self { + { + Pair { + x: ::default(), + y: ::default(), + } + } } } #[derive(Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Swappable)] @@ -90,16 +104,21 @@ pub struct Arrays { } impl Arrays { pub fn constructor_1(this: Ptr) { - field!(this, a).write(Box::new(std::array::from_fn::<_, 2, _>(|_| { - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - Tracked::constructor_1(__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(ZeroInitialization::zero_init())); - Tracked::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }))); + this.write(::default()); + } +} +impl Default for Arrays { + fn default() -> Self { + { + Arrays { + a: (0..2) + .map(|_| ::default()) + .collect::>(), + b: (0..2) + .map(|_| ::default()) + .collect::>(), + } + } } } thread_local!( @@ -275,7 +294,12 @@ pub struct Owner { } impl Owner { pub fn constructor_1(this: Ptr) { - field!(this, p).write(None); + this.write(::default()); + } +} +impl Default for Owner { + fn default() -> Self { + { Owner { p: None } } } } pub fn main() { @@ -550,7 +574,7 @@ fn main_0() -> i32 { && ({ (*pairs.borrow())[(1) as usize].y.v } == 8) ); assert!((copies_0.with(|rc| *rc.borrow()) == 0)); - object!(arrays, Arrays::constructor_1()); + let arrays: Value = Rc::new(RefCell::new(::default())); field!(array_elem!(arrays.as_pointer(), a, 0), v).write(1); field!(array_elem!(arrays.as_pointer(), b, 1), v).write(2); Swappable::swap( diff --git a/tests/unit/out/refcount/template_default_arg.rs b/tests/unit/out/refcount/template_default_arg.rs index 57e88a53ad..09dbfcd621 100644 --- a/tests/unit/out/refcount/template_default_arg.rs +++ b/tests/unit/out/refcount/template_default_arg.rs @@ -27,12 +27,17 @@ pub struct A { } impl A { pub fn constructor_1(this: Ptr) { - field!(this, v).write(1); + this.write(::default()); } pub fn constructor_2(this: Ptr, mut v: i32) { field!(this, v).write(v); } } +impl Default for A { + fn default() -> Self { + { A { v: 1 } } + } +} #[derive( Copy, Clone, @@ -53,7 +58,12 @@ pub struct B { } impl B { pub fn constructor_1(this: Ptr) { - field!(this, v).write(2); + this.write(::default()); + } +} +impl Default for B { + fn default() -> Self { + { B { v: 2 } } } } #[derive( @@ -124,15 +134,7 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - assert!( - (({ - used_0({ - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - A::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }) - }) == 1) - ); + assert!((({ used_0(::default(),) }) == 1)); assert!( (({ used_0({ @@ -142,15 +144,7 @@ fn main_0() -> i32 { }) }) == 5) ); - assert!( - (({ - used_1({ - let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); - B::constructor_1(__v.as_pointer()); - Rc::try_unwrap(__v).ok().unwrap().into_inner() - }) - }) == 2) - ); + assert!((({ used_1(::default(),) }) == 2)); assert!( (({ scaled_2( diff --git a/tests/unit/out/refcount/temporary_field_addr.rs b/tests/unit/out/refcount/temporary_field_addr.rs index 3112f76ff6..4a217d6546 100644 --- a/tests/unit/out/refcount/temporary_field_addr.rs +++ b/tests/unit/out/refcount/temporary_field_addr.rs @@ -30,7 +30,12 @@ pub struct Inner { } impl Inner { pub fn constructor_1(this: Ptr) { - field!(this, values).write(Vec::new()); + this.write(::default()); + } +} +impl Default for Inner { + fn default() -> Self { + { Inner { values: Vec::new() } } } } #[derive( @@ -64,9 +69,18 @@ pub struct Outer { } impl Outer { pub fn constructor_1(this: Ptr) { - field!(this, values).write(Vec::new()); - Inner::constructor_1(field_ptr!(this, inner)); - field!(this, name).write((0..8).map(|_| 0_i8).collect::>()); + this.write(::default()); + } +} +impl Default for Outer { + fn default() -> Self { + { + Outer { + values: Vec::new(), + inner: ::default(), + name: (0..8).map(|_| 0_i8).collect::>(), + } + } } } pub fn make_0(__return: Ptr, calls: Ptr) { diff --git a/tests/unit/out/refcount/temporary_field_ctor_arg.rs b/tests/unit/out/refcount/temporary_field_ctor_arg.rs index 3f28bfe157..2b52f4ad4c 100644 --- a/tests/unit/out/refcount/temporary_field_ctor_arg.rs +++ b/tests/unit/out/refcount/temporary_field_ctor_arg.rs @@ -30,7 +30,12 @@ pub struct Outer { } impl Outer { pub fn constructor_1(this: Ptr) { - field!(this, values).write(Vec::new()); + this.write(::default()); + } +} +impl Default for Outer { + fn default() -> Self { + { Outer { values: Vec::new() } } } } pub fn make_0(__return: Ptr) { diff --git a/tests/unit/out/refcount/temporary_field_two_args.rs b/tests/unit/out/refcount/temporary_field_two_args.rs index cd07c340a4..4792103db8 100644 --- a/tests/unit/out/refcount/temporary_field_two_args.rs +++ b/tests/unit/out/refcount/temporary_field_two_args.rs @@ -30,7 +30,12 @@ pub struct Inner { } impl Inner { pub fn constructor_1(this: Ptr) { - field!(this, values).write(Vec::new()); + this.write(::default()); + } +} +impl Default for Inner { + fn default() -> Self { + { Inner { values: Vec::new() } } } } #[derive( @@ -60,8 +65,17 @@ pub struct Outer { } impl Outer { pub fn constructor_1(this: Ptr) { - field!(this, values).write(Vec::new()); - Inner::constructor_1(field_ptr!(this, inner)); + this.write(::default()); + } +} +impl Default for Outer { + fn default() -> Self { + { + Outer { + values: Vec::new(), + inner: ::default(), + } + } } } pub fn make_0(__return: Ptr) { diff --git a/tests/unit/out/refcount/typedef-anon-struct.rs b/tests/unit/out/refcount/typedef-anon-struct.rs index ce59cc6a85..4f9b561f6e 100644 --- a/tests/unit/out/refcount/typedef-anon-struct.rs +++ b/tests/unit/out/refcount/typedef-anon-struct.rs @@ -50,7 +50,12 @@ pub struct Outer { } impl Outer { pub fn constructor_1(this: Ptr) { - field!(this, runs).write(Vec::new()); + this.write(::default()); + } +} +impl Default for Outer { + fn default() -> Self { + { Outer { runs: Vec::new() } } } } pub fn main() { @@ -58,7 +63,7 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - object!(o, Outer::constructor_1()); + let o: Value = Rc::new(RefCell::new(::default())); let info: Value = Rc::new(RefCell::new(::default())); (*info.borrow_mut()).block_idx = 1; (*info.borrow_mut()).num_extra_zero_runs = 2; diff --git a/tests/unit/out/refcount/unboxed_records.rs b/tests/unit/out/refcount/unboxed_records.rs index 52566651fd..0473770956 100644 --- a/tests/unit/out/refcount/unboxed_records.rs +++ b/tests/unit/out/refcount/unboxed_records.rs @@ -81,7 +81,12 @@ impl Counter { }); } pub fn constructor_1(this: Ptr) { - field!(this, n).write(0); + this.write(::default()); + } +} +impl Default for Counter { + fn default() -> Self { + { Counter { n: 0 } } } } pub fn set_0(mut p: Ptr, mut v: i32) { @@ -143,7 +148,7 @@ 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)); - object!(counter, Counter::constructor_1()); + let counter: Value = Rc::new(RefCell::new(::default())); ({ Counter::inc(counter.as_pointer()) }); assert!(({ (*counter.borrow()).n } == 1)); return 0; diff --git a/tests/unit/out/refcount/unique_ptr.rs b/tests/unit/out/refcount/unique_ptr.rs index e62213609d..873eeec91b 100644 --- a/tests/unit/out/refcount/unique_ptr.rs +++ b/tests/unit/out/refcount/unique_ptr.rs @@ -26,7 +26,12 @@ impl SafePointer { }); } pub fn constructor_1(this: Ptr) { - field!(this, ptr).write(None); + this.write(::default()); + } +} +impl Default for SafePointer { + fn default() -> Self { + { SafePointer { ptr: None } } } } #[derive( diff --git a/tests/unit/out/refcount/unique_ptr_const_deref.rs b/tests/unit/out/refcount/unique_ptr_const_deref.rs index 865e4354e9..0854af109a 100644 --- a/tests/unit/out/refcount/unique_ptr_const_deref.rs +++ b/tests/unit/out/refcount/unique_ptr_const_deref.rs @@ -19,7 +19,12 @@ pub struct Holder { } impl Holder { pub fn constructor_1(this: Ptr) { - field!(this, val).write(None); + this.write(::default()); + } +} +impl Default for Holder { + fn default() -> Self { + { Holder { val: None } } } } pub fn read_val_0(mut h: Ptr) -> i32 { @@ -33,7 +38,7 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - object!(h, Holder::constructor_1()); + let h: Value = Rc::new(RefCell::new(::default())); { (*h.borrow_mut()).val = Some(Rc::new(RefCell::new(10))).take(); }; diff --git a/tests/unit/out/refcount/unique_ptr_field_reset.rs b/tests/unit/out/refcount/unique_ptr_field_reset.rs index 2ab306ea0a..10f27499dc 100644 --- a/tests/unit/out/refcount/unique_ptr_field_reset.rs +++ b/tests/unit/out/refcount/unique_ptr_field_reset.rs @@ -42,8 +42,17 @@ impl Holder { field_ptr!(this, data).write(p.to_owned_opt()); } pub fn constructor_1(this: Ptr) { - field!(this, data).write(None); - field!(this, n).write(0_i32); + this.write(::default()); + } +} +impl Default for Holder { + fn default() -> Self { + { + Holder { + data: None, + n: 0_i32, + } + } } } thread_local!( @@ -62,7 +71,7 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - object!(h, Holder::constructor_1()); + let h: Value = Rc::new(RefCell::new(::default())); (*h.borrow_mut()).n = 1; let mut hp: Ptr = (h.as_pointer()); field_ptr!(hp, data).write(Ptr::alloc(Data { v: 3 }).to_owned_opt()); diff --git a/tests/unit/out/refcount/unique_ptr_nested.rs b/tests/unit/out/refcount/unique_ptr_nested.rs index 12c36113f5..e9f7f6fde2 100644 --- a/tests/unit/out/refcount/unique_ptr_nested.rs +++ b/tests/unit/out/refcount/unique_ptr_nested.rs @@ -39,7 +39,12 @@ pub struct Outer { } impl Outer { pub fn constructor_1(this: Ptr) { - field!(this, inner).write(None); + this.write(::default()); + } +} +impl Default for Outer { + fn default() -> Self { + { Outer { inner: None } } } } pub fn main() { diff --git a/tests/unit/out/refcount/vector.rs b/tests/unit/out/refcount/vector.rs index 046d9bdbde..51acda23b6 100644 --- a/tests/unit/out/refcount/vector.rs +++ b/tests/unit/out/refcount/vector.rs @@ -52,8 +52,17 @@ pub struct Foo { } impl Foo { pub fn constructor_1(this: Ptr) { - field!(this, a).write(Vec::new()); - field!(this, b).write(Vec::new()); + this.write(::default()); + } +} +impl Default for Foo { + fn default() -> Self { + { + Foo { + a: Vec::new(), + b: Vec::new(), + } + } } } #[derive( @@ -555,7 +564,7 @@ fn main_0() -> i32 { && ({ (*v11.borrow())[2_usize] } == 3) }) ); - object!(foo, Foo::constructor_1()); + let foo: Value = Rc::new(RefCell::new(::default())); ({ let __tmp_22: Value = Rc::new(RefCell::new(5)); MoveConstructible::push_moved( diff --git a/tests/unit/out/refcount/vector_subscript_direct.rs b/tests/unit/out/refcount/vector_subscript_direct.rs index ca4f9ae71d..f0205013c5 100644 --- a/tests/unit/out/refcount/vector_subscript_direct.rs +++ b/tests/unit/out/refcount/vector_subscript_direct.rs @@ -58,8 +58,17 @@ pub struct Holder { } impl Holder { pub fn constructor_1(this: Ptr) { - field!(this, values).write(Vec::new()); - field!(this, points).write(Vec::new()); + this.write(::default()); + } +} +impl Default for Holder { + fn default() -> Self { + { + Holder { + values: Vec::new(), + points: Vec::new(), + } + } } } pub fn push_and_index_0(v: Ptr>) -> i32 { @@ -118,7 +127,7 @@ 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))); - object!(h, Holder::constructor_1()); + let h: Value = Rc::new(RefCell::new(::default())); (*h.borrow_mut()).values.resize_with(2_usize, || 0_i32); vec_elem!(h.as_pointer(), values, 1_usize).write(6); ({ diff --git a/tests/unit/out/refcount/void_cast.rs b/tests/unit/out/refcount/void_cast.rs index be3a29e09b..3c929d5552 100644 --- a/tests/unit/out/refcount/void_cast.rs +++ b/tests/unit/out/refcount/void_cast.rs @@ -31,7 +31,12 @@ pub struct NonTrivial { } impl NonTrivial { pub fn constructor_1(this: Ptr) { - field!(this, data).write(Vec::new()); + this.write(::default()); + } +} +impl Default for NonTrivial { + fn default() -> Self { + { NonTrivial { data: Vec::new() } } } } pub fn unused_ref_param_1(x: Ptr) {} @@ -74,7 +79,12 @@ pub struct NonCopyable { } impl NonCopyable { pub fn constructor_1(this: Ptr) { - field!(this, value).write(None); + this.write(::default()); + } +} +impl Default for NonCopyable { + fn default() -> Self { + { NonCopyable { value: None } } } } pub fn unused_noncopyable_param_5(x: Ptr) {} @@ -125,7 +135,7 @@ 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()); - object!(nt, NonTrivial::constructor_1()); + let nt: Value = Rc::new(RefCell::new(::default())); ({ unused_ref_param_1(nt.as_pointer()) }); ({ unused_ptr_param_2((nt.as_pointer())) }); let g: Value = Rc::new(RefCell::new(NonCopyable { diff --git a/tests/unit/out/unsafe/10_struct.rs b/tests/unit/out/unsafe/10_struct.rs index 2182c878c7..ed3b7198d9 100644 --- a/tests/unit/out/unsafe/10_struct.rs +++ b/tests/unit/out/unsafe/10_struct.rs @@ -68,13 +68,22 @@ pub struct Partial { } impl Partial { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).p).write(std::ptr::null_mut()); + this.write(::default()); } pub unsafe fn constructor_2(this: *mut Self, q: PointerUnsafe) { let mut q = (q.as_ptr() as *mut i32); (&raw mut (*this).p).write(q); } } +impl Default for Partial { + fn default() -> Self { + unsafe { + Partial { + p: std::ptr::null_mut(), + } + } + } +} #[repr(C)] #[derive( Copy, @@ -124,7 +133,7 @@ unsafe fn main_0() -> i32 { if ((it.p) != (arr.as_mut_ptr())) { return 1; } - object_unsafe!(def, Partial::constructor_1()); + let mut def: Partial = ::default(); if !((def.p).is_null()) { return 1; } diff --git a/tests/unit/out/unsafe/array_of_noncopy_struct.rs b/tests/unit/out/unsafe/array_of_noncopy_struct.rs index 38d0292793..37fbbc9653 100644 --- a/tests/unit/out/unsafe/array_of_noncopy_struct.rs +++ b/tests/unit/out/unsafe/array_of_noncopy_struct.rs @@ -27,8 +27,17 @@ pub struct NonCopy { } impl NonCopy { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).data).write(Vec::new()); - (&raw mut (*this).tag).write(0); + this.write(::default()); + } +} +impl Default for NonCopy { + fn default() -> Self { + unsafe { + NonCopy { + data: Vec::new(), + tag: 0, + } + } } } pub fn main() { @@ -38,11 +47,7 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let mut arr: [NonCopy; 3] = std::array::from_fn::<_, 3, _>(|_| { - let mut __v: NonCopy = ZeroInitializationUnsafe::zero_init(); - NonCopy::constructor_1(&raw mut __v); - __v - }); + let mut arr: [NonCopy; 3] = std::array::from_fn::<_, 3, _>(|_| ::default()); arr[(0) as usize].tag = 7; { let mut __tmp_0: i32 = 42; diff --git a/tests/unit/out/unsafe/assignment_single_eval.rs b/tests/unit/out/unsafe/assignment_single_eval.rs index 06dc567c15..d39ad47781 100644 --- a/tests/unit/out/unsafe/assignment_single_eval.rs +++ b/tests/unit/out/unsafe/assignment_single_eval.rs @@ -2153,7 +2153,12 @@ pub struct Counts_59 { } impl Counts_59 { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).counts).write(Vec::new()); + this.write(::default()); + } +} +impl Default for Counts_59 { + fn default() -> Self { + unsafe { Counts_59 { counts: Vec::new() } } } } #[repr(C)] diff --git a/tests/unit/out/unsafe/cast.rs b/tests/unit/out/unsafe/cast.rs index b1c9052aa9..4bc3dca4f2 100644 --- a/tests/unit/out/unsafe/cast.rs +++ b/tests/unit/out/unsafe/cast.rs @@ -79,8 +79,17 @@ pub struct Bag { } impl Bag { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).n).write(0_i32); - (&raw mut (*this).items).write(Vec::new()); + this.write(::default()); + } +} +impl Default for Bag { + fn default() -> Self { + unsafe { + Bag { + n: 0_i32, + items: Vec::new(), + } + } } } pub unsafe fn adjacent_arrays_0() { @@ -325,7 +334,7 @@ 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))); - object_unsafe!(b, Bag::constructor_1()); + let mut b: Bag = ::default(); 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/class_templates.rs b/tests/unit/out/unsafe/class_templates.rs index 8f983f240f..200252f974 100644 --- a/tests/unit/out/unsafe/class_templates.rs +++ b/tests/unit/out/unsafe/class_templates.rs @@ -45,7 +45,12 @@ impl MyContainer_int_ { (*this).vec_.push_copied(item); } pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).vec_).write(Vec::new()); + this.write(::default()); + } +} +impl Default for MyContainer_int_ { + fn default() -> Self { + unsafe { MyContainer_int_ { vec_: Vec::new() } } } } #[repr(C)] @@ -87,7 +92,12 @@ impl MyContainer_char_ { (*this).vec_.push_copied(item); } pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).vec_).write(Vec::new()); + this.write(::default()); + } +} +impl Default for MyContainer_char_ { + fn default() -> Self { + unsafe { MyContainer_char_ { vec_: Vec::new() } } } } #[repr(C)] @@ -129,7 +139,12 @@ impl MyContainer_float_ { (*this).vec_.push_copied(item); } pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).vec_).write(Vec::new()); + this.write(::default()); + } +} +impl Default for MyContainer_float_ { + fn default() -> Self { + unsafe { MyContainer_float_ { vec_: Vec::new() } } } } #[repr(C)] @@ -359,7 +374,7 @@ 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(&raw const bl, 1_i64,) }) == (8_i64))); - object_unsafe!(imc, MyContainer_int_::constructor_1()); + let mut imc: MyContainer_int_ = ::default(); assert!((unsafe { MyContainer_int_::empty(&raw const imc,) })); (unsafe { let mut _item: i32 = 1; @@ -371,7 +386,7 @@ unsafe fn main_0() -> i32 { ); (unsafe { MyContainer_int_::pop_back(&raw mut imc) }); assert!((unsafe { MyContainer_int_::empty(&raw const imc,) })); - object_unsafe!(cmc, MyContainer_char_::constructor_1()); + let mut cmc: MyContainer_char_ = ::default(); assert!((unsafe { MyContainer_char_::empty(&raw const cmc,) })); (unsafe { let mut _item: libc::c_char = ('a' as libc::c_char); @@ -384,7 +399,7 @@ unsafe fn main_0() -> i32 { ); (unsafe { MyContainer_char_::pop_back(&raw mut cmc) }); assert!((unsafe { MyContainer_char_::empty(&raw const cmc,) })); - object_unsafe!(fmc, MyContainer_float_::constructor_1()); + let mut fmc: MyContainer_float_ = ::default(); assert!((unsafe { MyContainer_float_::empty(&raw const fmc,) })); (unsafe { let mut _item: f32 = (1_f64 as f32); diff --git a/tests/unit/out/unsafe/container_field_addr.rs b/tests/unit/out/unsafe/container_field_addr.rs index 90a61c55e6..9184fdca7f 100644 --- a/tests/unit/out/unsafe/container_field_addr.rs +++ b/tests/unit/out/unsafe/container_field_addr.rs @@ -27,8 +27,17 @@ pub struct S { } impl S { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).tag).write(0_i32); - (&raw mut (*this).v).write(Vec::new()); + this.write(::default()); + } +} +impl Default for S { + fn default() -> Self { + unsafe { + S { + tag: 0_i32, + v: Vec::new(), + } + } } } pub unsafe fn add_0(mut v: *mut Vec, mut k: i32) { @@ -57,14 +66,10 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - object_unsafe!(local, S::constructor_1()); + let mut local: S = ::default(); 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::constructor_1(__p); - __p - }; + let mut heap: *mut S = (Box::leak(Box::new(::default())) as *mut S); (*heap).tag = 7; (unsafe { run_1(heap) }); { diff --git a/tests/unit/out/unsafe/copy_assign.rs b/tests/unit/out/unsafe/copy_assign.rs index 69c367c046..debf6b87bf 100644 --- a/tests/unit/out/unsafe/copy_assign.rs +++ b/tests/unit/out/unsafe/copy_assign.rs @@ -64,7 +64,7 @@ pub struct NonConstAssign { } impl NonConstAssign { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).mark).write(0); + this.write(::default()); } pub unsafe fn operator_assign_2( this: *mut Self, @@ -81,6 +81,11 @@ impl NonConstAssign { return &mut (*this); } } +impl Default for NonConstAssign { + fn default() -> Self { + unsafe { NonConstAssign { mark: 0 } } + } +} #[repr(C)] #[derive( Copy, @@ -100,7 +105,7 @@ pub struct RefQualified { } impl RefQualified { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).mark).write(0); + this.write(::default()); } } impl CopyAssignableUnsafe for RefQualified { @@ -113,6 +118,11 @@ impl CopyAssignableUnsafe for RefQualified { return &mut (*this); } } +impl Default for RefQualified { + fn default() -> Self { + unsafe { RefQualified { mark: 0 } } + } +} #[repr(C)] #[derive( FnPtrArg, @@ -192,7 +202,7 @@ pub struct ExplicitOperatorCall { } impl ExplicitOperatorCall { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).w).write(Vec::new()); + this.write(::default()); } } impl CopyAssignableUnsafe for ExplicitOperatorCall { @@ -207,6 +217,11 @@ impl CopyAssignableUnsafe for ExplicitOperatorCall { return &mut (*this); } } +impl Default for ExplicitOperatorCall { + fn default() -> Self { + unsafe { ExplicitOperatorCall { w: Vec::new() } } + } +} pub static mut swap_copies_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] #[derive( @@ -297,7 +312,7 @@ pub struct VoidAssign { } impl VoidAssign { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).x).write(0); + this.write(::default()); } pub unsafe fn copy_assign(this: *mut Self, o: *const VoidAssign) { (*this).x = (((*o).x) + (5)); @@ -315,6 +330,11 @@ impl MoveAssignableUnsafe for VoidAssign { this } } +impl Default for VoidAssign { + fn default() -> Self { + unsafe { VoidAssign { x: 0 } } + } +} #[repr(C)] #[derive( Copy, @@ -336,7 +356,16 @@ pub struct HoldsVoidAssign { } impl HoldsVoidAssign { pub unsafe fn constructor_1(this: *mut Self) { - VoidAssign::constructor_1(&raw mut (*this).v); + this.write(::default()); + } +} +impl Default for HoldsVoidAssign { + fn default() -> Self { + unsafe { + HoldsVoidAssign { + v: ::default(), + } + } } } pub fn main() { @@ -398,16 +427,16 @@ unsafe fn main_0() -> i32 { assert!(((h.p.v) == (2)) && ((h.p.keep) == (40))); assert!(((h.arr[(1) as usize].v) == (2)) && ((h.arr[(1) as usize].keep) == (60))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut assigns_0)) == (8))); - object_unsafe!(n, NonConstAssign::constructor_1()); - object_unsafe!(n1, NonConstAssign::constructor_1()); - object_unsafe!(n2, NonConstAssign::constructor_1()); - object_unsafe!(cn, NonConstAssign::constructor_1()); + let mut n: NonConstAssign = ::default(); + let mut n1: NonConstAssign = ::default(); + let mut n2: NonConstAssign = ::default(); + let cn: NonConstAssign = ::default(); (unsafe { NonConstAssign::operator_assign_2(&raw mut n1, &mut n) }); (unsafe { NonConstAssign::operator_assign_3(&raw mut n2, &cn) }); assert!(((n1.mark) == (1))); assert!(((n2.mark) == (10))); - object_unsafe!(r, RefQualified::constructor_1()); - object_unsafe!(r1, RefQualified::constructor_1()); + let mut r: RefQualified = ::default(); + let mut r1: RefQualified = ::default(); assign_unsafe!(r1 = r); assert!(((r1.mark) == (1))); let mut h2: Holder = Holder { @@ -481,8 +510,8 @@ unsafe fn main_0() -> i32 { && ((hc1.arr[(1) as usize].v) == (6)) ); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_1)) == (0))); - object_unsafe!(e1, ExplicitOperatorCall::constructor_1()); - object_unsafe!(e2, ExplicitOperatorCall::constructor_1()); + let mut e1: ExplicitOperatorCall = ::default(); + let mut e2: ExplicitOperatorCall = ::default(); { let mut __tmp_0: i32 = 5; e1.w.push_moved(&mut __tmp_0) @@ -521,8 +550,8 @@ unsafe fn main_0() -> i32 { ((hs1.s.v) == (4)) && ((*std::cell::LazyCell::force_mut(&mut *&raw mut swap_copies_2)) == (2)) ); - object_unsafe!(hv1, HoldsVoidAssign::constructor_1()); - object_unsafe!(hv2, HoldsVoidAssign::constructor_1()); + let mut hv1: HoldsVoidAssign = ::default(); + let mut hv2: HoldsVoidAssign = ::default(); assign_unsafe!(hv1 = hv2); assert!(((hv1.v.x) == (5))); return 0; diff --git a/tests/unit/out/unsafe/copy_ctor.rs b/tests/unit/out/unsafe/copy_ctor.rs index b13e9d88fa..33325125a8 100644 --- a/tests/unit/out/unsafe/copy_ctor.rs +++ b/tests/unit/out/unsafe/copy_ctor.rs @@ -56,7 +56,7 @@ pub struct NonConst { } impl NonConst { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).mark).write(0); + this.write(::default()); } pub unsafe fn constructor_2(this: *mut Self, o: LvalueRefUnsafe) { let o = (o.as_ptr() as *mut NonConst); @@ -67,6 +67,11 @@ impl NonConst { (&raw mut (*this).mark).write((((*o).mark) + (10))); } } +impl Default for NonConst { + fn default() -> Self { + unsafe { NonConst { mark: 0 } } + } +} #[repr(C)] #[derive( FnPtrArg, @@ -186,7 +191,7 @@ pub struct Tracked { } impl Tracked { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).copied_from).write(0); + this.write(::default()); } pub unsafe fn constructor_2(this: *mut Self, o: LvalueRefUnsafe>) { let o = (o.as_ptr() as *const Tracked); @@ -201,6 +206,11 @@ impl CopyAssignableUnsafe for Tracked { return &mut (*this); } } +impl Default for Tracked { + fn default() -> Self { + unsafe { Tracked { copied_from: 0 } } + } +} pub unsafe fn touch_1(mut t: *const Tracked) { (*(&raw const (*t).copied_from).cast_mut()).prefix_inc(); } @@ -345,17 +355,17 @@ unsafe fn main_0() -> i32 { object_unsafe!(ol2, OutOfLine::constructor_2(LvalueRefUnsafe::bind(&ol1))); assert!(((ol2.v) == (105))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (12))); - object_unsafe!(n, NonConst::constructor_1()); + let mut n: NonConst = ::default(); object_unsafe!(n1, NonConst::constructor_2(LvalueRefUnsafe::bind(&mut n))); - object_unsafe!(cn, NonConst::constructor_1()); + let cn: NonConst = ::default(); object_unsafe!(n2, NonConst::constructor_3(LvalueRefUnsafe::bind(&cn))); assert!(((n1.mark) == (1))); assert!(((n2.mark) == (10))); - object_unsafe!(t1, Tracked::constructor_1()); + let mut t1: Tracked = ::default(); object_unsafe!(t2, Tracked::constructor_2(LvalueRefUnsafe::bind(&t1))); assign_unsafe!(t2 = t1); assert!(((t1.copied_from) == (2))); - object_unsafe!(ct, Tracked::constructor_1()); + let ct: Tracked = ::default(); object_unsafe!(t3, Tracked::constructor_2(LvalueRefUnsafe::bind(&ct))); (unsafe { touch_1((&ct as *const Tracked)) }); assert!(((ct.copied_from) == (2))); diff --git a/tests/unit/out/unsafe/copy_move_defaulted.rs b/tests/unit/out/unsafe/copy_move_defaulted.rs index 0ea1c8c644..ccd8b7f86f 100644 --- a/tests/unit/out/unsafe/copy_move_defaulted.rs +++ b/tests/unit/out/unsafe/copy_move_defaulted.rs @@ -190,10 +190,19 @@ pub struct Owner { } impl Owner { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).data).write(Vec::new()); - (&raw mut (*this).n).write(0_i32); - (&raw mut (*this).arr).write([0_i32; 2]); - (&raw mut (*this).p).write(None); + this.write(::default()); + } +} +impl Default for Owner { + fn default() -> Self { + unsafe { + Owner { + data: Vec::new(), + n: 0_i32, + arr: [0_i32; 2], + p: None, + } + } } } #[repr(C)] @@ -216,7 +225,12 @@ pub struct Copyable { } impl Copyable { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).data).write(Vec::new()); + this.write(::default()); + } +} +impl Default for Copyable { + fn default() -> Self { + unsafe { Copyable { data: Vec::new() } } } } #[repr(C)] @@ -257,7 +271,7 @@ pub struct SeesThis { } impl SeesThis { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).self_).write(std::ptr::null_mut()); + this.write(::default()); } } impl CopyAssignableUnsafe for SeesThis { @@ -274,6 +288,15 @@ impl MoveAssignableUnsafe for SeesThis { return &mut (*this); } } +impl Default for SeesThis { + fn default() -> Self { + unsafe { + SeesThis { + self_: std::ptr::null_mut(), + } + } + } +} #[repr(C)] #[derive(FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, MemberwiseUnsafe)] #[memberwise(copy_assign, move_assign)] @@ -285,8 +308,17 @@ pub struct HasSeesThis { } impl HasSeesThis { pub unsafe fn constructor_1(this: *mut Self) { - SeesThis::constructor_1(&raw mut (*this).s); - (&raw mut (*this).v).write(Vec::new()); + this.write(::default()); + } +} +impl Default for HasSeesThis { + fn default() -> Self { + unsafe { + HasSeesThis { + s: ::default(), + v: Vec::new(), + } + } } } #[repr(C)] @@ -302,8 +334,7 @@ pub struct Counted_int_ { } impl Counted_int_ { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).v).write(0_i32); - (&raw mut (*this).moves).write(0); + this.write(::default()); } pub unsafe fn constructor_2(this: *mut Self, o: RvalueRefUnsafe) { let o = (o.as_ptr() as *mut Counted_int_); @@ -319,6 +350,11 @@ impl MoveAssignableUnsafe for Counted_int_ { return &mut (*this); } } +impl Default for Counted_int_ { + fn default() -> Self { + unsafe { Counted_int_ { v: 0_i32, moves: 0 } } + } +} #[repr(C)] #[derive( FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, MemberwiseUnsafe, SwappableUnsafe, @@ -333,8 +369,17 @@ pub struct HasCounted { } impl HasCounted { pub unsafe fn constructor_1(this: *mut Self) { - Counted_int_::constructor_1(&raw mut (*this).c); - (&raw mut (*this).w).write(Vec::new()); + this.write(::default()); + } +} +impl Default for HasCounted { + fn default() -> Self { + unsafe { + HasCounted { + c: ::default(), + w: Vec::new(), + } + } } } #[repr(C)] @@ -472,9 +517,18 @@ pub struct OutOfLineAssign { } impl OutOfLineAssign { pub unsafe fn constructor_1(this: *mut Self) { - SeesThis::constructor_1(&raw mut (*this).s); - (&raw mut (*this).v).write(1); - (&raw mut (*this).w).write(Vec::new()); + this.write(::default()); + } +} +impl Default for OutOfLineAssign { + fn default() -> Self { + unsafe { + OutOfLineAssign { + s: ::default(), + v: 1, + w: Vec::new(), + } + } } } impl CopyAssignableUnsafe for OutOfLineAssign { @@ -636,7 +690,7 @@ unsafe fn main_0() -> i32 { (((bufs[(1_usize)].n) == (3)) && ((bufs[(1_usize)].data.len()) == (3_usize))) && (bufs[(0_usize)].data.is_empty()) ); - object_unsafe!(o1, Owner::constructor_1()); + let mut o1: Owner = ::default(); { let mut __tmp_2: i32 = 5; o1.data.push_moved(&mut __tmp_2) @@ -671,7 +725,7 @@ unsafe fn main_0() -> i32 { .map_or(::std::ptr::null_mut(), |v| v as *mut i32)) .is_null()) ); - object_unsafe!(o3, Owner::constructor_1()); + let mut o3: Owner = ::default(); assign_unsafe!(o3 = RvalueRefUnsafe(o2)); assert!( ((((o3.n) == (5)) && ((o3.data[(0_usize)]) == (5))) && ((o3.arr[(0) as usize]) == (5))) @@ -698,7 +752,7 @@ unsafe fn main_0() -> i32 { }); assert!(((c2.data.len()) == (2_usize)) && ((c3.data.len()) == (2_usize))); assert!(c1.data.is_empty()); - object_unsafe!(c4, Copyable::constructor_1()); + let mut c4: Copyable = ::default(); assign_unsafe!(c4 = RvalueRefUnsafe(c3)); assert!(((c4.data[(1_usize)]) == (2)) && (c3.data.is_empty())); object_unsafe!(h1, Holder::constructor_1(4)); @@ -741,14 +795,14 @@ unsafe fn main_0() -> i32 { .map_or(::std::ptr::null_mut(), |v| v as *mut i32)) .is_null()) ); - object_unsafe!(t1, HasSeesThis::constructor_1()); - object_unsafe!(t2, HasSeesThis::constructor_1()); - object_unsafe!(t3, HasSeesThis::constructor_1()); + let mut t1: HasSeesThis = ::default(); + let mut t2: HasSeesThis = ::default(); + let mut t3: HasSeesThis = ::default(); assign_unsafe!(t2 = RvalueRefUnsafe(t1)); assert!(((t2.s.self_) == (&mut t2.s as *mut SeesThis))); assign_unsafe!(t3 = t2); assert!(((t3.s.self_) == (&mut t3.s as *mut SeesThis))); - object_unsafe!(k1, HasCounted::constructor_1()); + let mut k1: HasCounted = ::default(); object_unsafe!(k2, HasCounted, |k2| { ::move_constructor( k2, @@ -756,7 +810,7 @@ unsafe fn main_0() -> i32 { ) }); assert!(((k2.c.moves) == (1))); - object_unsafe!(k3, HasCounted::constructor_1()); + let mut k3: HasCounted = ::default(); assign_unsafe!(k3 = RvalueRefUnsafe(k2)); assert!(((k3.c.moves) == (2))); { @@ -809,9 +863,9 @@ unsafe fn main_0() -> i32 { OutOfLineDefaulted::constructor_2(LvalueRefUnsafe::bind(&o1)) ); assert!(((o2.v) == (2)) && ((o2.x.self_) == (&mut o2.x as *mut CtorSeesThis))); - object_unsafe!(a1, OutOfLineAssign::constructor_1()); - object_unsafe!(a2, OutOfLineAssign::constructor_1()); - object_unsafe!(a3, OutOfLineAssign::constructor_1()); + let mut a1: OutOfLineAssign = ::default(); + let mut a2: OutOfLineAssign = ::default(); + let mut a3: OutOfLineAssign = ::default(); a1.v = 3; { let mut __tmp_5: i32 = 4; diff --git a/tests/unit/out/unsafe/copy_move_deleted.rs b/tests/unit/out/unsafe/copy_move_deleted.rs index e4bda15fac..b7ea293982 100644 --- a/tests/unit/out/unsafe/copy_move_deleted.rs +++ b/tests/unit/out/unsafe/copy_move_deleted.rs @@ -50,7 +50,7 @@ pub struct PrivateCopy { } impl PrivateCopy { pub unsafe fn constructor_2(this: *mut Self) { - (&raw mut (*this).v).write(0); + this.write(::default()); } pub unsafe fn constructor_3(this: *mut Self, o: RvalueRefUnsafe) { let o = (o.as_ptr() as *mut PrivateCopy); @@ -66,6 +66,11 @@ impl MoveAssignableUnsafe for PrivateCopy { return &mut (*this); } } +impl Default for PrivateCopy { + fn default() -> Self { + unsafe { PrivateCopy { v: 0 } } + } +} #[repr(C)] #[derive(FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, ConversionsUnsafe)] #[constructor(constructor_1)] @@ -74,7 +79,12 @@ pub struct Immovable { } impl Immovable { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).v).write(0); + this.write(::default()); + } +} +impl Default for Immovable { + fn default() -> Self { + unsafe { Immovable { v: 0 } } } } #[repr(C)] @@ -106,7 +116,12 @@ pub struct VecHolder { } impl VecHolder { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).items).write(Vec::new()); + this.write(::default()); + } +} +impl Default for VecHolder { + fn default() -> Self { + unsafe { VecHolder { items: Vec::new() } } } } pub unsafe fn bump_0(mut p: *mut NoCopy) { @@ -129,13 +144,13 @@ unsafe fn main_0() -> i32 { assert!(((a.v) == (1)) && ((b.v) == (0))); (unsafe { bump_0((&mut a as *mut NoCopy)) }); assert!(((a.v) == (2))); - object_unsafe!(p, PrivateCopy::constructor_2()); + let mut p: PrivateCopy = ::default(); p.v = 3; object_unsafe!(q, PrivateCopy::constructor_3(RvalueRefUnsafe::bind(&mut p))); assert!(((q.v) == (3)) && ((p.v) == (0))); assign_unsafe!(p = RvalueRefUnsafe(q)); assert!(((p.v) == (3)) && ((q.v) == (0))); - object_unsafe!(im, Immovable::constructor_1()); + let mut im: Immovable = ::default(); im.v = 4; (unsafe { bump_ref_1(&mut im) }); let mut pim: *mut Immovable = (&mut im as *mut Immovable); @@ -152,7 +167,7 @@ unsafe fn main_0() -> i32 { ::move_constructor(d, RvalueRefUnsafe::bind(&mut c)) }); assert!((((d.inner.v) == (6)) && ((d.tag) == (7))) && ((c.inner.v) == (0))); - object_unsafe!(h, VecHolder::constructor_1()); + let mut h: VecHolder = ::default(); object_unsafe!(h2, VecHolder, |h2| { ::move_constructor(h2, RvalueRefUnsafe::bind(&mut h)) }); diff --git a/tests/unit/out/unsafe/enum_underlying_type.rs b/tests/unit/out/unsafe/enum_underlying_type.rs index 5d068e7a62..2725230001 100644 --- a/tests/unit/out/unsafe/enum_underlying_type.rs +++ b/tests/unit/out/unsafe/enum_underlying_type.rs @@ -42,7 +42,12 @@ pub struct HoldsEmpty { } impl HoldsEmpty { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).e).write(false); + this.write(::default()); + } +} +impl Default for HoldsEmpty { + fn default() -> Self { + unsafe { HoldsEmpty { e: false } } } } pub fn main() { @@ -78,7 +83,7 @@ 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))); - object_unsafe!(he, HoldsEmpty::constructor_1()); + let mut he: HoldsEmpty = ::default(); assert!(!(he.e)); let mut ev: Empty = false; assert!(((ev as i32) == (he.e as i32))); diff --git a/tests/unit/out/unsafe/field_method_receiver.rs b/tests/unit/out/unsafe/field_method_receiver.rs index 126c14067c..45ddcdc514 100644 --- a/tests/unit/out/unsafe/field_method_receiver.rs +++ b/tests/unit/out/unsafe/field_method_receiver.rs @@ -65,10 +65,19 @@ impl S { }); } pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).tag).write(0_i32); - (&raw mut (*this).c).write(::default()); - (&raw mut (*this).arr).write([::default(); 2]); - (&raw mut (*this).v).write(Vec::new()); + this.write(::default()); + } +} +impl Default for S { + fn default() -> Self { + unsafe { + S { + tag: 0_i32, + c: ::default(), + arr: [::default(); 2], + v: Vec::new(), + } + } } } pub unsafe fn run_0(mut o: *mut S) { diff --git a/tests/unit/out/unsafe/field_pointers.rs b/tests/unit/out/unsafe/field_pointers.rs index 9934690338..7baaac7f9b 100644 --- a/tests/unit/out/unsafe/field_pointers.rs +++ b/tests/unit/out/unsafe/field_pointers.rs @@ -75,12 +75,21 @@ impl Outer { }; } pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).x).write(0_i32); - (&raw mut (*this).inner).write(::default()); - (&raw mut (*this).items).write([::default(); 3]); - (&raw mut (*this).v).write(Vec::new()); - (&raw mut (*this).cursor).write(std::ptr::null_mut()); - (&raw mut (*this).buf).write([0_i32; 4]); + this.write(::default()); + } +} +impl Default for Outer { + fn default() -> Self { + unsafe { + Outer { + x: 0_i32, + inner: ::default(), + items: [::default(); 3], + v: Vec::new(), + cursor: std::ptr::null_mut(), + buf: [0_i32; 4], + } + } } } pub unsafe fn set_0(mut p: *mut i32, mut value: i32) { diff --git a/tests/unit/out/unsafe/foreach_disjoint_field_borrow.rs b/tests/unit/out/unsafe/foreach_disjoint_field_borrow.rs index 5ab502fa5a..9b11cd3154 100644 --- a/tests/unit/out/unsafe/foreach_disjoint_field_borrow.rs +++ b/tests/unit/out/unsafe/foreach_disjoint_field_borrow.rs @@ -27,8 +27,17 @@ pub struct S { } impl S { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).v).write(Vec::new()); - (&raw mut (*this).a).write(0_i32); + this.write(::default()); + } +} +impl Default for S { + fn default() -> Self { + unsafe { + S { + v: Vec::new(), + a: 0_i32, + } + } } } pub fn main() { @@ -38,7 +47,7 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - object_unsafe!(s, S::constructor_1()); + let mut s: S = ::default(); { let mut __tmp_0: i32 = 1; s.v.push_moved(&mut __tmp_0) diff --git a/tests/unit/out/unsafe/global_non_const_init.rs b/tests/unit/out/unsafe/global_non_const_init.rs index 7929d9233a..44a0780f32 100644 --- a/tests/unit/out/unsafe/global_non_const_init.rs +++ b/tests/unit/out/unsafe/global_non_const_init.rs @@ -45,19 +45,23 @@ pub struct Ctor { } impl Ctor { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).v).write((unsafe { next_0() })); + this.write(::default()); } pub unsafe fn constructor_2(this: *mut Self, mut x: i32) { (&raw mut (*this).v).write(x); } } -pub static mut default_ctor_7: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { - { - let mut __v: Ctor = ZeroInitializationUnsafe::zero_init(); - Ctor::constructor_1(&raw mut __v); - __v +impl Default for Ctor { + fn default() -> Self { + unsafe { + Ctor { + v: (unsafe { next_0() }), + } + } } -}); +} +pub static mut default_ctor_7: std::cell::LazyCell = + std::cell::LazyCell::new(|| unsafe { ::default() }); pub static mut arg_ctor_8: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { { let mut __v: Ctor = ZeroInitializationUnsafe::zero_init(); @@ -125,19 +129,19 @@ pub struct Singleton { } impl Singleton { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).hits).write(0); + this.write(::default()); } pub unsafe fn instance() -> *mut Singleton { return &mut (*std::cell::LazyCell::force_mut(&mut *&raw mut s_15)); } } -static mut s_15: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { - { - let mut __v: Singleton = ZeroInitializationUnsafe::zero_init(); - Singleton::constructor_1(&raw mut __v); - __v +impl Default for Singleton { + fn default() -> Self { + unsafe { Singleton { hits: 0 } } } -}); +} +static mut s_15: std::cell::LazyCell = + std::cell::LazyCell::new(|| unsafe { ::default() }); pub fn main() { unsafe { __cpp2rust_init_globals(); diff --git a/tests/unit/out/unsafe/huffman.rs b/tests/unit/out/unsafe/huffman.rs index 509bc5f399..d83a24c073 100644 --- a/tests/unit/out/unsafe/huffman.rs +++ b/tests/unit/out/unsafe/huffman.rs @@ -255,11 +255,20 @@ impl MinHeap { } } pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).size).write(0_i32); - (&raw mut (*this).capacity).write(0_i32); - (&raw mut (*this).arr).write(None); - (&raw mut (*this).next).write(0_i32); - (&raw mut (*this).alloc).write(None); + this.write(::default()); + } +} +impl Default for MinHeap { + fn default() -> Self { + unsafe { + MinHeap { + size: 0_i32, + capacity: 0_i32, + arr: None, + next: 0_i32, + alloc: None, + } + } } } pub unsafe fn AllocMinHeap_1(mut capacity: i32) -> Option> { diff --git a/tests/unit/out/unsafe/implicit_autoref.rs b/tests/unit/out/unsafe/implicit_autoref.rs index ae18ea1581..25ee0cd4ce 100644 --- a/tests/unit/out/unsafe/implicit_autoref.rs +++ b/tests/unit/out/unsafe/implicit_autoref.rs @@ -26,7 +26,12 @@ pub struct Holder { } impl Holder { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).v).write(Vec::new()); + this.write(::default()); + } +} +impl Default for Holder { + fn default() -> Self { + unsafe { Holder { v: Vec::new() } } } } pub unsafe fn write_through_0(mut p: *mut i32) { @@ -51,7 +56,7 @@ 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; - object_unsafe!(h, Holder::constructor_1()); + let mut h: Holder = ::default(); { let mut __tmp_2: i32 = 40; h.v.push_moved(&mut __tmp_2) diff --git a/tests/unit/out/unsafe/in_class_field_initializer.rs b/tests/unit/out/unsafe/in_class_field_initializer.rs index 3ee21b529f..925bf52be8 100644 --- a/tests/unit/out/unsafe/in_class_field_initializer.rs +++ b/tests/unit/out/unsafe/in_class_field_initializer.rs @@ -24,8 +24,12 @@ pub struct Inner { } impl Inner { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).x).write(3); - (&raw mut (*this).y).write(4); + this.write(::default()); + } +} +impl Default for Inner { + fn default() -> Self { + unsafe { Inner { x: 3, y: 4 } } } } #[repr(C)] @@ -51,7 +55,7 @@ impl S { (&raw mut (*this).a).write(1); (&raw mut (*this).b).write((2 as libc::c_char)); (&raw mut (*this).c).write(Inner { x: 3, y: 4 }); - Inner::constructor_1(&raw mut (*this).d); + (&raw mut (*this).d).write(::default()); } } #[repr(C)] diff --git a/tests/unit/out/unsafe/init_list.rs b/tests/unit/out/unsafe/init_list.rs index 0f596ef3f5..5420cb4f0c 100644 --- a/tests/unit/out/unsafe/init_list.rs +++ b/tests/unit/out/unsafe/init_list.rs @@ -67,7 +67,12 @@ pub struct Seven { } impl Seven { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).v).write(7); + this.write(::default()); + } +} +impl Default for Seven { + fn default() -> Self { + unsafe { Seven { v: 7 } } } } pub fn main() { diff --git a/tests/unit/out/unsafe/inline_container_fields.rs b/tests/unit/out/unsafe/inline_container_fields.rs index 5f574b24e9..b18384d559 100644 --- a/tests/unit/out/unsafe/inline_container_fields.rs +++ b/tests/unit/out/unsafe/inline_container_fields.rs @@ -28,9 +28,18 @@ pub struct Elem { } impl Elem { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).id).write(0_i32); - (&raw mut (*this).hist).write([0_i32; 4]); - (&raw mut (*this).coeffs).write(Vec::new()); + this.write(::default()); + } +} +impl Default for Elem { + fn default() -> Self { + unsafe { + Elem { + id: 0_i32, + hist: [0_i32; 4], + coeffs: Vec::new(), + } + } } } #[repr(C)] @@ -57,11 +66,20 @@ pub struct State { } impl State { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).count).write(0_i32); - (&raw mut (*this).grid).write([[0_i32; 3]; 2]); - (&raw mut (*this).arr).write(std::array::from_fn::<_, 3, _>(|_| 0_i32)); - (&raw mut (*this).elems).write(Vec::new()); - (&raw mut (*this).rows).write(Vec::new()); + this.write(::default()); + } +} +impl Default for State { + fn default() -> Self { + unsafe { + State { + count: 0_i32, + grid: [[0_i32; 3]; 2], + arr: std::array::from_fn::<_, 3, _>(|_| 0_i32), + elems: Vec::new(), + rows: Vec::new(), + } + } } } pub unsafe fn sum_0(mut p: *const i32, mut n: i32) -> i32 { @@ -143,7 +161,7 @@ pub struct Counted { } impl Counted { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).v).write(0); + this.write(::default()); } pub unsafe fn constructor_2(this: *mut Self, o: LvalueRefUnsafe>) { let o = (o.as_ptr() as *const Counted); @@ -174,6 +192,11 @@ impl MoveAssignableUnsafe for Counted { return &mut (*this); } } +impl Default for Counted { + fn default() -> Self { + unsafe { Counted { v: 0 } } + } +} pub fn main() { unsafe { __cpp2rust_init_globals(); diff --git a/tests/unit/out/unsafe/kruskal.rs b/tests/unit/out/unsafe/kruskal.rs index 7e0ffdd725..d2b2761e30 100644 --- a/tests/unit/out/unsafe/kruskal.rs +++ b/tests/unit/out/unsafe/kruskal.rs @@ -291,9 +291,18 @@ impl DisjointSet { } } pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).rank).write(None); - (&raw mut (*this).parent).write(None); - (&raw mut (*this).n).write(0_i32); + this.write(::default()); + } +} +impl Default for DisjointSet { + fn default() -> Self { + unsafe { + DisjointSet { + rank: None, + parent: None, + n: 0_i32, + } + } } } #[repr(C)] @@ -311,9 +320,18 @@ pub struct Graph { } impl Graph { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).edges).write(None); - (&raw mut (*this).V).write(0_i32); - (&raw mut (*this).E).write(0_i32); + this.write(::default()); + } +} +impl Default for Graph { + fn default() -> Self { + unsafe { + Graph { + edges: None, + V: 0_i32, + E: 0_i32, + } + } } } pub unsafe fn MSTKruskal_2(graph: *mut Graph) -> f64 { diff --git a/tests/unit/out/unsafe/lambda_capture_copy_ctor.rs b/tests/unit/out/unsafe/lambda_capture_copy_ctor.rs index 95d8384515..f411bf5785 100644 --- a/tests/unit/out/unsafe/lambda_capture_copy_ctor.rs +++ b/tests/unit/out/unsafe/lambda_capture_copy_ctor.rs @@ -18,8 +18,7 @@ pub struct Counted { } impl Counted { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).copies).write(0); - (&raw mut (*this).moves).write(0); + this.write(::default()); } pub unsafe fn constructor_2(this: *mut Self, o: LvalueRefUnsafe>) { let o = (o.as_ptr() as *const Counted); @@ -32,6 +31,16 @@ impl Counted { (&raw mut (*this).moves).write((((*o).moves) + (1))); } } +impl Default for Counted { + fn default() -> Self { + unsafe { + Counted { + copies: 0, + moves: 0, + } + } + } +} pub static mut drops_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] #[derive(FnPtrArg, ZeroInitializationUnsafe, ConversionsUnsafe)] @@ -41,7 +50,9 @@ pub static mut drops_0: std::cell::LazyCell = std::cell::LazyCell::new(|| u #[constructor(constructor_3, RvalueRefUnsafe)] pub struct Dropped {} impl Dropped { - pub unsafe fn constructor_1(this: *mut Self) {} + pub unsafe fn constructor_1(this: *mut Self) { + this.write(::default()); + } pub unsafe fn constructor_2(this: *mut Self, _a0: LvalueRefUnsafe>) { let _a0 = (_a0.as_ptr() as *const Dropped); } @@ -54,6 +65,11 @@ impl DestructibleUnsafe for Dropped { (*std::cell::LazyCell::force_mut(&mut *&raw mut drops_0)).postfix_inc(); } } +impl Default for Dropped { + fn default() -> Self { + unsafe { Dropped {} } + } +} pub fn main() { unsafe { __cpp2rust_init_globals(); @@ -61,7 +77,7 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - object_unsafe!(c, Counted::constructor_1()); + let mut c: Counted = ::default(); let mut f: FnPtr i32> = lambda_unsafe!( { let c: Counted = { @@ -104,11 +120,7 @@ unsafe fn main_0() -> i32 { .copies }; assert!(((returned) == (2))); - let mut arr: [Counted; 2] = std::array::from_fn::<_, 2, _>(|_| { - let mut __v: Counted = ZeroInitializationUnsafe::zero_init(); - Counted::constructor_1(&raw mut __v); - __v - }); + let mut arr: [Counted; 2] = std::array::from_fn::<_, 2, _>(|_| ::default()); let mut a: FnPtr i32> = lambda_unsafe!( { let arr: [Counted; 2] = std::array::from_fn::<_, 2, _>(|__i: usize| { @@ -129,11 +141,7 @@ unsafe fn main_0() -> i32 { { let mut m: FnPtr = lambda_unsafe!( { - let d: Dropped = { - let mut __v: Dropped = ZeroInitializationUnsafe::zero_init(); - Dropped::constructor_1(&raw mut __v); - __v - }; + let d: Dropped = ::default(); }, || {} ); @@ -149,11 +157,7 @@ unsafe fn main_0() -> i32 { { let mut k: FnPtr = lambda_unsafe!( { - let d: Dropped = { - let mut __v: Dropped = ZeroInitializationUnsafe::zero_init(); - Dropped::constructor_1(&raw mut __v); - __v - }; + let d: Dropped = ::default(); }, || {} ); @@ -169,11 +173,7 @@ unsafe fn main_0() -> i32 { { let mut inner: FnPtr = lambda_unsafe!( { - let d: Dropped = { - let mut __v: Dropped = ZeroInitializationUnsafe::zero_init(); - Dropped::constructor_1(&raw mut __v); - __v - }; + let d: Dropped = ::default(); }, || {} ); diff --git a/tests/unit/out/unsafe/lambda_decltype_type.rs b/tests/unit/out/unsafe/lambda_decltype_type.rs index 5e2c0f2553..ecad63ae1c 100644 --- a/tests/unit/out/unsafe/lambda_decltype_type.rs +++ b/tests/unit/out/unsafe/lambda_decltype_type.rs @@ -33,15 +33,22 @@ impl Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { (*this).size.postfix_inc(); } pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).items).write([0_i32; 4]); - (&raw mut (*this).size).write(0); - (&raw mut (*this).cmp).write(FnPtr:: bool>::new( - |mut a: i32, mut b: i32| -> bool { - unsafe { - return ((a) > (b)); - } - }, - )); + this.write(::default()); + } +} +impl Default for Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { + fn default() -> Self { + unsafe { + Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ { + items: [0_i32; 4], + size: 0, + cmp: FnPtr:: bool>::new(|mut a: i32, mut b: i32| -> bool { + unsafe { + return ((a) > (b)); + } + }), + } + } } } #[repr(C)] @@ -71,15 +78,22 @@ impl Sorted__lambda_at_lambda_decltype_type_cpp_19_23__ { (*this).size.postfix_inc(); } pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).items).write([0_i32; 4]); - (&raw mut (*this).size).write(0); - (&raw mut (*this).cmp).write(FnPtr:: bool>::new( - |mut a: i32, mut b: i32| -> bool { - unsafe { - return ((a) < (b)); - } - }, - )); + this.write(::default()); + } +} +impl Default for Sorted__lambda_at_lambda_decltype_type_cpp_19_23__ { + fn default() -> Self { + unsafe { + Sorted__lambda_at_lambda_decltype_type_cpp_19_23__ { + items: [0_i32; 4], + size: 0, + cmp: FnPtr:: bool>::new(|mut a: i32, mut b: i32| -> bool { + unsafe { + return ((a) < (b)); + } + }), + } + } } } pub fn main() { @@ -95,20 +109,16 @@ unsafe fn main_0() -> i32 { return ((a) > (b)); } }); - object_unsafe!( - desc, - Sorted__lambda_at_lambda_decltype_type_cpp_22_18__::constructor_1() - ); + let mut desc: Sorted__lambda_at_lambda_decltype_type_cpp_22_18__ = + ::default(); (unsafe { Sorted__lambda_at_lambda_decltype_type_cpp_22_18__::insert(&raw mut desc, 2) }); (unsafe { Sorted__lambda_at_lambda_decltype_type_cpp_22_18__::insert(&raw mut desc, 7) }); (unsafe { Sorted__lambda_at_lambda_decltype_type_cpp_22_18__::insert(&raw mut desc, 4) }); assert!(((desc.items[(0) as usize]) == (7))); assert!(((desc.items[(1) as usize]) == (4))); assert!(((desc.items[(2) as usize]) == (2))); - object_unsafe!( - asc, - Sorted__lambda_at_lambda_decltype_type_cpp_19_23__::constructor_1() - ); + let mut asc: Sorted__lambda_at_lambda_decltype_type_cpp_19_23__ = + ::default(); (unsafe { Sorted__lambda_at_lambda_decltype_type_cpp_19_23__::insert(&raw mut asc, 2) }); (unsafe { Sorted__lambda_at_lambda_decltype_type_cpp_19_23__::insert(&raw mut asc, 7) }); (unsafe { Sorted__lambda_at_lambda_decltype_type_cpp_19_23__::insert(&raw mut asc, 4) }); diff --git a/tests/unit/out/unsafe/lambda_immediate_init.rs b/tests/unit/out/unsafe/lambda_immediate_init.rs index eded55df01..b07f5c53f9 100644 --- a/tests/unit/out/unsafe/lambda_immediate_init.rs +++ b/tests/unit/out/unsafe/lambda_immediate_init.rs @@ -27,17 +27,24 @@ pub struct S { } impl S { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).j).write(10); - (&raw mut (*this).k).write( - ((unsafe { - FnPtr:: i32>::new(|| -> i32 { - unsafe { - return 3; - } - }) - .call() - }) + (1)), - ); + this.write(::default()); + } +} +impl Default for S { + fn default() -> Self { + unsafe { + S { + j: 10, + k: ((unsafe { + FnPtr:: i32>::new(|| -> i32 { + unsafe { + return 3; + } + }) + .call() + }) + (1)), + } + } } } pub static mut g_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { @@ -82,7 +89,7 @@ unsafe fn main_0() -> i32 { }) == (237)) ); assert!(((unsafe { pick_0(1,) }) == (1))); - object_unsafe!(s, S::constructor_1()); + let mut s: S = ::default(); 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/libc_struct_without_default.rs b/tests/unit/out/unsafe/libc_struct_without_default.rs index 0d4b89cd57..10e25eb6f0 100644 --- a/tests/unit/out/unsafe/libc_struct_without_default.rs +++ b/tests/unit/out/unsafe/libc_struct_without_default.rs @@ -27,8 +27,17 @@ pub struct UserDefined { } impl UserDefined { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).a).write(std::array::from_fn::<_, 1, _>(|_| 0_i32)); - (&raw mut (*this).v).write(Vec::new()); + this.write(::default()); + } +} +impl Default for UserDefined { + fn default() -> Self { + unsafe { + UserDefined { + a: std::array::from_fn::<_, 1, _>(|_| 0_i32), + v: Vec::new(), + } + } } } #[repr(C)] @@ -73,7 +82,7 @@ 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))); - object_unsafe!(ud, UserDefined::constructor_1()); + let mut ud: UserDefined = ::default(); ud.a[(0_usize)] = 3; assert!(((ud.a[(0_usize)]) == (3))); assert!(((ud.v.len()) == (0_usize))); diff --git a/tests/unit/out/unsafe/map.rs b/tests/unit/out/unsafe/map.rs index d5952ee0c2..c826947ba9 100644 --- a/tests/unit/out/unsafe/map.rs +++ b/tests/unit/out/unsafe/map.rs @@ -34,14 +34,18 @@ pub struct Point { } impl Point { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).x).write(0); - (&raw mut (*this).y).write(0); + this.write(::default()); } pub unsafe fn constructor_2(this: *mut Self, mut x: i32, mut y: i32) { (&raw mut (*this).x).write(x); (&raw mut (*this).y).write(y); } } +impl Default for Point { + fn default() -> Self { + unsafe { Point { x: 0, y: 0 } } + } +} pub fn main() { unsafe { __cpp2rust_init_globals(); diff --git a/tests/unit/out/unsafe/map_try_emplace.rs b/tests/unit/out/unsafe/map_try_emplace.rs index 9fda60634f..0af4fb439c 100644 --- a/tests/unit/out/unsafe/map_try_emplace.rs +++ b/tests/unit/out/unsafe/map_try_emplace.rs @@ -22,7 +22,7 @@ pub struct Item { } impl Item { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).value).write(0); + this.write(::default()); } pub unsafe fn constructor_2(this: *mut Self, mut value: i32) { (&raw mut (*this).value).write(value); @@ -40,6 +40,11 @@ impl Item { (*other).value = -1_i32; } } +impl Default for Item { + fn default() -> Self { + unsafe { Item { value: 0 } } + } +} pub unsafe fn argument_4(item: *mut Item) -> *mut Item { (*std::cell::LazyCell::force_mut(&mut *&raw mut calls_0)).prefix_inc(); return item; @@ -62,7 +67,7 @@ pub struct RefItem { } impl RefItem { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).value).write(0); + this.write(::default()); } pub unsafe fn constructor_2(this: *mut Self, counter: LvalueRefUnsafe, mut amount: i32) { let counter = (counter.as_ptr() as *mut i32); @@ -73,6 +78,11 @@ impl RefItem { (*std::cell::LazyCell::force_mut(&mut *&raw mut made_1)).prefix_inc(); } } +impl Default for RefItem { + fn default() -> Self { + unsafe { RefItem { value: 0 } } + } +} pub unsafe fn reference_5(counter: *mut i32) -> *mut i32 { (*std::cell::LazyCell::force_mut(&mut *&raw mut calls_0)).prefix_inc(); return counter; diff --git a/tests/unit/out/unsafe/map_try_emplace_lvalues.rs b/tests/unit/out/unsafe/map_try_emplace_lvalues.rs index b70dbb7553..c17bb86ebc 100644 --- a/tests/unit/out/unsafe/map_try_emplace_lvalues.rs +++ b/tests/unit/out/unsafe/map_try_emplace_lvalues.rs @@ -26,7 +26,7 @@ pub struct Item { } impl Item { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).value).write(0); + this.write(::default()); } pub unsafe fn constructor_2(this: *mut Self, counter: LvalueRefUnsafe, mut amount: i32) { let counter = (counter.as_ptr() as *mut i32); @@ -37,6 +37,11 @@ impl Item { (*std::cell::LazyCell::force_mut(&mut *&raw mut made_0)).prefix_inc(); } } +impl Default for Item { + fn default() -> Self { + unsafe { Item { value: 0 } } + } +} pub unsafe fn receiver_2(m: *mut UnsafeMap) -> *mut UnsafeMap { (*std::cell::LazyCell::force_mut(&mut *&raw mut visits_1)).prefix_inc(); return m; @@ -117,11 +122,7 @@ pub struct Owner { } impl Owner { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).ptr).write(Some(Box::new({ - let mut __v: Temporary = ZeroInitializationUnsafe::zero_init(); - Temporary::constructor_1(&raw mut __v); - __v - }))); + this.write(::default()); } pub unsafe fn value(this: *mut Self) -> *const i32 { return &(*(*this).ptr.as_deref().map_or(::std::ptr::null_mut(), |v| { @@ -130,6 +131,19 @@ impl Owner { .n; } } +impl Default for Owner { + fn default() -> Self { + unsafe { + Owner { + ptr: Some(Box::new({ + let mut __v: Temporary = ZeroInitializationUnsafe::zero_init(); + Temporary::constructor_1(&raw mut __v); + __v + })), + } + } + } +} #[repr(C)] #[derive(FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, ConversionsUnsafe)] #[constructor(constructor_1)] @@ -138,7 +152,12 @@ pub struct Noncopy { } impl Noncopy { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).n).write(5); + this.write(::default()); + } +} +impl Default for Noncopy { + fn default() -> Self { + unsafe { Noncopy { n: 5 } } } } #[repr(C)] @@ -159,7 +178,7 @@ pub struct Held { } impl Held { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).ptr).write(std::ptr::null()); + this.write(::default()); } pub unsafe fn constructor_2(this: *mut Self, n: LvalueRefUnsafe>) { let n = (n.as_ptr() as *const i32); @@ -169,6 +188,15 @@ impl Held { (&raw mut (*this).ptr).write((*n).as_ptr()); } } +impl Default for Held { + fn default() -> Self { + unsafe { + Held { + ptr: std::ptr::null(), + } + } + } +} pub static mut global_values_7: std::cell::LazyCell> = std::cell::LazyCell::new(|| unsafe { UnsafeMap::new() }); pub static mut global_key_8: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); @@ -1283,12 +1311,12 @@ unsafe fn main_0() -> i32 { ); let mut owners: UnsafeMap = UnsafeMap::new(); { - let mut __tmp_101: Owner = ZeroInitializationUnsafe::zero_init(); + let mut __tmp_101: Owner; { match (((unsafe { Owner::value( &mut (*{ - Owner::constructor_1(&raw mut __tmp_101); + __tmp_101 = ::default(); &mut __tmp_101 }), ) @@ -1325,11 +1353,7 @@ unsafe fn main_0() -> i32 { ) = { let mut __tmp_103: Option>; match (({ - __tmp_103 = Some(Box::new({ - let mut __v: Noncopy = ZeroInitializationUnsafe::zero_init(); - Noncopy::constructor_1(&raw mut __v); - __v - })); + __tmp_103 = Some(Box::new(::default())); &mut __tmp_103 } as *mut Option>),) { @@ -1342,11 +1366,7 @@ unsafe fn main_0() -> i32 { ) = { let mut __tmp_105: Option>; match (({ - __tmp_105 = Some(Box::new({ - let mut __v: Noncopy = ZeroInitializationUnsafe::zero_init(); - Noncopy::constructor_1(&raw mut __v); - __v - })); + __tmp_105 = Some(Box::new(::default())); &mut __tmp_105 } as *mut Option>),) { diff --git a/tests/unit/out/unsafe/move_assign.rs b/tests/unit/out/unsafe/move_assign.rs index 50f3947a0b..3c417be76a 100644 --- a/tests/unit/out/unsafe/move_assign.rs +++ b/tests/unit/out/unsafe/move_assign.rs @@ -49,7 +49,7 @@ pub struct ConstMoveAssign { } impl ConstMoveAssign { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).mark).write(0); + this.write(::default()); } pub unsafe fn operator_assign_2( this: *mut Self, @@ -66,6 +66,11 @@ impl ConstMoveAssign { return &mut (*this); } } +impl Default for ConstMoveAssign { + fn default() -> Self { + unsafe { ConstMoveAssign { mark: 0 } } + } +} pub unsafe fn make_0(__return: *mut MoveOnly, mut v: i32) { object_unsafe!(m, MoveOnly::constructor_1(v)); MoveOnly::constructor_3(__return, RvalueRefUnsafe::bind(&mut m)); @@ -123,10 +128,10 @@ unsafe fn main_0() -> i32 { assign_unsafe!(vec_[(0_usize)] = RvalueRefUnsafe(d)); assert!(((vec_[(0_usize)].v) == (8))); assert!(((d.v) == (0))); - object_unsafe!(m, ConstMoveAssign::constructor_1()); - object_unsafe!(m1, ConstMoveAssign::constructor_1()); - object_unsafe!(m2, ConstMoveAssign::constructor_1()); - object_unsafe!(cm, ConstMoveAssign::constructor_1()); + let mut m: ConstMoveAssign = ::default(); + let mut m1: ConstMoveAssign = ::default(); + let mut m2: ConstMoveAssign = ::default(); + let cm: ConstMoveAssign = ::default(); (unsafe { ConstMoveAssign::operator_assign_2(&raw mut m1, &mut m) }); (unsafe { ConstMoveAssign::operator_assign_3(&raw 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 bebc1ba94b..12dbfed85f 100644 --- a/tests/unit/out/unsafe/move_ctor.rs +++ b/tests/unit/out/unsafe/move_ctor.rs @@ -35,7 +35,7 @@ pub struct ConstMove { } impl ConstMove { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).mark).write(0); + this.write(::default()); } pub unsafe fn constructor_2(this: *mut Self, o: RvalueRefUnsafe) { let o = (o.as_ptr() as *mut ConstMove); @@ -46,6 +46,11 @@ impl ConstMove { (&raw mut (*this).mark).write((((*o).mark) + (10))); } } +impl Default for ConstMove { + fn default() -> Self { + unsafe { ConstMove { mark: 0 } } + } +} #[repr(C)] #[derive(FnPtrArg, ZeroInitializationUnsafe, DefaultInitializableUnsafe, ConversionsUnsafe)] #[conversions(copy, move)] @@ -166,9 +171,9 @@ unsafe fn main_0() -> i32 { vec_.push_moved(&mut f); assert!(((vec_[(0_usize)].v) == (7)) && ((vec_[(1_usize)].v) == (8))); assert!(((f.v) == (0))); - object_unsafe!(m, ConstMove::constructor_1()); + let mut m: ConstMove = ::default(); object_unsafe!(m1, ConstMove::constructor_2(RvalueRefUnsafe::bind(&mut m))); - object_unsafe!(cm, ConstMove::constructor_1()); + let cm: ConstMove = ::default(); object_unsafe!(m2, ConstMove::constructor_3(RvalueRefUnsafe::bind(&cm))); assert!(((m1.mark) == (1))); assert!(((m2.mark) == (10))); diff --git a/tests/unit/out/unsafe/push_emplace_back.rs b/tests/unit/out/unsafe/push_emplace_back.rs index 3c4f26d942..0f4fa3952f 100644 --- a/tests/unit/out/unsafe/push_emplace_back.rs +++ b/tests/unit/out/unsafe/push_emplace_back.rs @@ -58,8 +58,17 @@ pub struct JPEGData { } impl JPEGData { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).com_data).write(Vec::new()); - (&raw mut (*this).app_data).write(Vec::new()); + this.write(::default()); + } +} +impl Default for JPEGData { + fn default() -> Self { + unsafe { + JPEGData { + com_data: Vec::new(), + app_data: Vec::new(), + } + } } } pub unsafe fn push_param_0(mut dest: *mut Vec>) { @@ -148,8 +157,7 @@ pub struct Pair { } impl Pair { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).first).write(-1_i32); - (&raw mut (*this).second).write(-1_i32); + this.write(::default()); } pub unsafe fn constructor_2(this: *mut Self, mut a: i32) { (&raw mut (*this).first).write(a); @@ -160,12 +168,18 @@ impl Pair { (&raw mut (*this).second).write(((b) * (2))); } } +impl Default for Pair { + fn default() -> Self { + unsafe { + Pair { + first: -1_i32, + second: -1_i32, + } + } + } +} pub unsafe fn emplace_ctor_args_7(mut pairs: *mut Vec) { - (*pairs).push_mut({ - let mut __v: Pair = ZeroInitializationUnsafe::zero_init(); - Pair::constructor_1(&raw mut __v); - __v - }); + (*pairs).push_mut(::default()); (*pairs).push_mut({ let mut __v: Pair = ZeroInitializationUnsafe::zero_init(); Pair::constructor_2(&raw mut __v, 3); @@ -183,11 +197,7 @@ pub unsafe fn emplace_deque_8(mut queue: *mut Vec) { Pair::constructor_3(&raw mut __v, 6, 7); __v }); - (*queue).push_mut({ - let mut __v: Pair = ZeroInitializationUnsafe::zero_init(); - Pair::constructor_1(&raw mut __v); - __v - }); + (*queue).push_mut(::default()); } pub unsafe fn emplace_scalar_9(mut values: *mut Vec, mut x: i32) { (*values).push_mut(0_i64); @@ -251,8 +261,17 @@ pub struct Bytes { } impl Bytes { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).v).write(Vec::new()); - (&raw mut (*this).b).write([0_u8; 3]); + this.write(::default()); + } +} +impl Default for Bytes { + fn default() -> Self { + unsafe { + Bytes { + v: Vec::new(), + b: [0_u8; 3], + } + } } } pub unsafe fn emplace_from_element_14(mut v: *mut Vec>) { @@ -357,7 +376,7 @@ 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()); - object_unsafe!(jpg, JPEGData::constructor_1()); + let mut jpg: JPEGData = ::default(); (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/self_referencing_initializer.rs b/tests/unit/out/unsafe/self_referencing_initializer.rs index 4284d0f162..3390f42ad0 100644 --- a/tests/unit/out/unsafe/self_referencing_initializer.rs +++ b/tests/unit/out/unsafe/self_referencing_initializer.rs @@ -55,8 +55,17 @@ pub struct node_with_defaults { } impl node_with_defaults { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).next).write(std::ptr::null_mut()); - (&raw mut (*this).value).write(3); + this.write(::default()); + } +} +impl Default for node_with_defaults { + fn default() -> Self { + unsafe { + node_with_defaults { + next: std::ptr::null_mut(), + value: 3, + } + } } } pub unsafe fn init_0(mut l: *mut list_head) -> *mut list_head { @@ -94,7 +103,7 @@ unsafe fn main_0() -> i32 { ]; assert!(((arr[(0) as usize].next) == (&mut arr[(1) as usize] as *mut list_head))); assert!(((arr[(1) as usize].next) == (&mut arr[(0) as usize] as *mut list_head))); - let mut d: node_with_defaults = unsafe { ::zero_init() }; + let mut d: node_with_defaults = ::default(); d = node_with_defaults { next: (&mut d as *mut node_with_defaults), value: 3, diff --git a/tests/unit/out/unsafe/sort_no_copy.rs b/tests/unit/out/unsafe/sort_no_copy.rs index e068978fe8..802a94c03b 100644 --- a/tests/unit/out/unsafe/sort_no_copy.rs +++ b/tests/unit/out/unsafe/sort_no_copy.rs @@ -21,7 +21,7 @@ pub struct Tracked { } impl Tracked { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).v).write(0); + this.write(::default()); } pub unsafe fn constructor_2(this: *mut Self, mut v: i32) { (&raw mut (*this).v).write(v); @@ -51,6 +51,11 @@ impl MoveAssignableUnsafe for Tracked { return &mut (*this); } } +impl Default for Tracked { + fn default() -> Self { + unsafe { Tracked { v: 0 } } + } +} impl LessThanComparableUnsafe for Tracked { unsafe fn less(a: *const Tracked, b: *const Tracked) -> bool { return (((*a).v) < ((*b).v)); @@ -97,7 +102,12 @@ pub struct Bag { } impl Bag { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).items).write(Vec::new()); + this.write(::default()); + } +} +impl Default for Bag { + fn default() -> Self { + unsafe { Bag { items: Vec::new() } } } } impl LessThanComparableUnsafe for Bag { @@ -324,11 +334,7 @@ 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, _>(|_| { - let mut __v: Bag = ZeroInitializationUnsafe::zero_init(); - Bag::constructor_1(&raw mut __v); - __v - }); + let mut bags: [Bag; 3] = std::array::from_fn::<_, 3, _>(|_| ::default()); bags[(0) as usize].items.push_mut({ let mut __v: Tracked = ZeroInitializationUnsafe::zero_init(); Tracked::constructor_2(&raw mut __v, 1); diff --git a/tests/unit/out/unsafe/struct_default_ctor.rs b/tests/unit/out/unsafe/struct_default_ctor.rs index cd6b7bc69c..4b69a6f999 100644 --- a/tests/unit/out/unsafe/struct_default_ctor.rs +++ b/tests/unit/out/unsafe/struct_default_ctor.rs @@ -24,8 +24,12 @@ pub struct S { } impl S { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).a).write(11); - (&raw mut (*this).b).write(true); + this.write(::default()); + } +} +impl Default for S { + fn default() -> Self { + unsafe { S { a: 11, b: true } } } } #[repr(C)] @@ -60,11 +64,16 @@ pub struct Holder { } impl Holder { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).items).write(std::array::from_fn::<_, 2, _>(|_| { - let mut __v: S = ZeroInitializationUnsafe::zero_init(); - S::constructor_1(&raw mut __v); - __v - })); + this.write(::default()); + } +} +impl Default for Holder { + fn default() -> Self { + unsafe { + Holder { + items: [::default(); 2], + } + } } } pub static mut kInit_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 3 }); @@ -85,7 +94,16 @@ pub struct FromStatic { } impl FromStatic { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).v).write((*std::cell::LazyCell::force_mut(&mut *&raw mut kInit_0))); + this.write(::default()); + } +} +impl Default for FromStatic { + fn default() -> Self { + unsafe { + FromStatic { + v: (*std::cell::LazyCell::force_mut(&mut *&raw mut kInit_0)), + } + } } } pub fn main() { @@ -97,21 +115,14 @@ pub fn main() { unsafe fn main_0() -> i32 { let mut d: *mut Declared = std::ptr::null_mut(); assert!((d).is_null()); - object_unsafe!(s, S::constructor_1()); + let mut s: S = ::default(); assert!(((s.a) == (11))); assert!(((s.b as i32) == (true as i32))); - let mut h: *mut Holder = { - let __n = (1_usize) as usize; - let __p: &mut [Holder] = Box::leak( - (0..__n) - .map(|_| ::zero_init()) - .collect::>(), - ); - for __i in 0..__n { - Holder::constructor_1(&raw mut __p[__i]); - } - __p - } + let mut h: *mut Holder = Box::leak( + (0..1_usize) + .map(|_| ::default()) + .collect::>(), + ) .as_mut_ptr(); assert!((((*h.offset((0) as isize)).items[(1) as usize].a) == (11))); { @@ -124,18 +135,11 @@ unsafe fn main_0() -> i32 { ))) } }; - let mut fs: *mut FromStatic = { - let __n = (2_usize) as usize; - let __p: &mut [FromStatic] = Box::leak( - (0..__n) - .map(|_| ::zero_init()) - .collect::>(), - ); - for __i in 0..__n { - FromStatic::constructor_1(&raw mut __p[__i]); - } - __p - } + let mut fs: *mut FromStatic = Box::leak( + (0..2_usize) + .map(|_| ::default()) + .collect::>(), + ) .as_mut_ptr(); assert!((((*fs.offset((1) as isize)).v) == (3))); { diff --git a/tests/unit/out/unsafe/structured_binding_move_ctor.rs b/tests/unit/out/unsafe/structured_binding_move_ctor.rs index 1e00438a85..d9a943d9b1 100644 --- a/tests/unit/out/unsafe/structured_binding_move_ctor.rs +++ b/tests/unit/out/unsafe/structured_binding_move_ctor.rs @@ -66,8 +66,17 @@ impl Holder { return; } pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).xs).write(Vec::new()); - (&raw mut (*this).ys).write(Vec::new()); + this.write(::default()); + } +} +impl Default for Holder { + fn default() -> Self { + unsafe { + Holder { + xs: Vec::new(), + ys: Vec::new(), + } + } } } pub fn main() { diff --git a/tests/unit/out/unsafe/swap_map_no_copy.rs b/tests/unit/out/unsafe/swap_map_no_copy.rs index 11f11c1168..2320a6e415 100644 --- a/tests/unit/out/unsafe/swap_map_no_copy.rs +++ b/tests/unit/out/unsafe/swap_map_no_copy.rs @@ -21,7 +21,7 @@ pub struct Tracked { } impl Tracked { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).v).write(0); + this.write(::default()); } pub unsafe fn constructor_2(this: *mut Self, mut v: i32) { (&raw mut (*this).v).write(v); @@ -51,6 +51,11 @@ impl MoveAssignableUnsafe for Tracked { return &mut (*this); } } +impl Default for Tracked { + fn default() -> Self { + unsafe { Tracked { v: 0 } } + } +} #[repr(C)] #[derive( FnPtrArg, ZeroInitializationUnsafe, DestructibleUnsafe, MemberwiseUnsafe, SwappableUnsafe, @@ -65,8 +70,17 @@ pub struct Pair { } impl Pair { pub unsafe fn constructor_1(this: *mut Self) { - Tracked::constructor_1(&raw mut (*this).x); - Tracked::constructor_1(&raw mut (*this).y); + this.write(::default()); + } +} +impl Default for Pair { + fn default() -> Self { + unsafe { + Pair { + x: ::default(), + y: ::default(), + } + } } } #[repr(C)] @@ -83,16 +97,17 @@ pub struct Arrays { } impl Arrays { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).a).write(std::array::from_fn::<_, 2, _>(|_| { - let mut __v: Tracked = ZeroInitializationUnsafe::zero_init(); - Tracked::constructor_1(&raw mut __v); - __v - })); - (&raw mut (*this).b).write(std::array::from_fn::<_, 2, _>(|_| { - let mut __v: Tracked = ZeroInitializationUnsafe::zero_init(); - Tracked::constructor_1(&raw mut __v); - __v - })); + this.write(::default()); + } +} +impl Default for Arrays { + fn default() -> Self { + unsafe { + Arrays { + a: std::array::from_fn::<_, 2, _>(|_| ::default()), + b: std::array::from_fn::<_, 2, _>(|_| ::default()), + } + } } } pub static mut copy_only_copies_1: std::cell::LazyCell = @@ -256,7 +271,12 @@ pub struct Owner { } impl Owner { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).p).write(None); + this.write(::default()); + } +} +impl Default for Owner { + fn default() -> Self { + unsafe { Owner { p: None } } } } pub fn main() { @@ -538,7 +558,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))); - object_unsafe!(arrays, Arrays::constructor_1()); + let mut arrays: Arrays = ::default(); 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 f4e3b7e309..abf55d4574 100644 --- a/tests/unit/out/unsafe/template_default_arg.rs +++ b/tests/unit/out/unsafe/template_default_arg.rs @@ -24,12 +24,17 @@ pub struct A { } impl A { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).v).write(1); + this.write(::default()); } pub unsafe fn constructor_2(this: *mut Self, mut v: i32) { (&raw mut (*this).v).write(v); } } +impl Default for A { + fn default() -> Self { + unsafe { A { v: 1 } } + } +} #[repr(C)] #[derive( Copy, @@ -47,7 +52,12 @@ pub struct B { } impl B { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).v).write(2); + this.write(::default()); + } +} +impl Default for B { + fn default() -> Self { + unsafe { B { v: 2 } } } } #[repr(C)] @@ -114,15 +124,7 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - assert!( - ((unsafe { - used_0({ - let mut __v: A = ZeroInitializationUnsafe::zero_init(); - A::constructor_1(&raw mut __v); - __v - }) - }) == (1)) - ); + assert!(((unsafe { used_0(::default(),) }) == (1))); assert!( ((unsafe { used_0({ @@ -132,15 +134,7 @@ unsafe fn main_0() -> i32 { }) }) == (5)) ); - assert!( - ((unsafe { - used_1({ - let mut __v: B = ZeroInitializationUnsafe::zero_init(); - B::constructor_1(&raw mut __v); - __v - }) - }) == (2)) - ); + assert!(((unsafe { used_1(::default(),) }) == (2))); assert!( ((unsafe { scaled_2( diff --git a/tests/unit/out/unsafe/temporary_field_addr.rs b/tests/unit/out/unsafe/temporary_field_addr.rs index 74cd88661e..e6f04946fc 100644 --- a/tests/unit/out/unsafe/temporary_field_addr.rs +++ b/tests/unit/out/unsafe/temporary_field_addr.rs @@ -26,7 +26,12 @@ pub struct Inner { } impl Inner { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).values).write(Vec::new()); + this.write(::default()); + } +} +impl Default for Inner { + fn default() -> Self { + unsafe { Inner { values: Vec::new() } } } } #[repr(C)] @@ -51,9 +56,18 @@ pub struct Outer { } impl Outer { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).values).write(Vec::new()); - Inner::constructor_1(&raw mut (*this).inner); - (&raw mut (*this).name).write([(0 as libc::c_char); 8]); + this.write(::default()); + } +} +impl Default for Outer { + fn default() -> Self { + unsafe { + Outer { + values: Vec::new(), + inner: ::default(), + name: [(0 as libc::c_char); 8], + } + } } } pub unsafe fn make_0(__return: *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 a9aba21ce9..822b0f0192 100644 --- a/tests/unit/out/unsafe/temporary_field_ctor_arg.rs +++ b/tests/unit/out/unsafe/temporary_field_ctor_arg.rs @@ -26,7 +26,12 @@ pub struct Outer { } impl Outer { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).values).write(Vec::new()); + this.write(::default()); + } +} +impl Default for Outer { + fn default() -> Self { + unsafe { Outer { values: Vec::new() } } } } pub unsafe fn make_0(__return: *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 075cd0403b..c317df027d 100644 --- a/tests/unit/out/unsafe/temporary_field_two_args.rs +++ b/tests/unit/out/unsafe/temporary_field_two_args.rs @@ -26,7 +26,12 @@ pub struct Inner { } impl Inner { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).values).write(Vec::new()); + this.write(::default()); + } +} +impl Default for Inner { + fn default() -> Self { + unsafe { Inner { values: Vec::new() } } } } #[repr(C)] @@ -50,8 +55,17 @@ pub struct Outer { } impl Outer { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).values).write(Vec::new()); - Inner::constructor_1(&raw mut (*this).inner); + this.write(::default()); + } +} +impl Default for Outer { + fn default() -> Self { + unsafe { + Outer { + values: Vec::new(), + inner: ::default(), + } + } } } pub unsafe fn make_0(__return: *mut Outer) { diff --git a/tests/unit/out/unsafe/typedef-anon-struct.rs b/tests/unit/out/unsafe/typedef-anon-struct.rs index 9a651b0e2a..7b7b668509 100644 --- a/tests/unit/out/unsafe/typedef-anon-struct.rs +++ b/tests/unit/out/unsafe/typedef-anon-struct.rs @@ -42,7 +42,12 @@ pub struct Outer { } impl Outer { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).runs).write(Vec::new()); + this.write(::default()); + } +} +impl Default for Outer { + fn default() -> Self { + unsafe { Outer { runs: Vec::new() } } } } pub fn main() { @@ -52,7 +57,7 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - object_unsafe!(o, Outer::constructor_1()); + let mut o: Outer = ::default(); let mut info: Outer_RunInfo = ::default(); info.block_idx = 1; info.num_extra_zero_runs = 2; diff --git a/tests/unit/out/unsafe/unboxed_records.rs b/tests/unit/out/unsafe/unboxed_records.rs index 29a95a73dc..b68e66589d 100644 --- a/tests/unit/out/unsafe/unboxed_records.rs +++ b/tests/unit/out/unsafe/unboxed_records.rs @@ -61,7 +61,12 @@ impl Counter { (*this).n.prefix_inc(); } pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).n).write(0); + this.write(::default()); + } +} +impl Default for Counter { + fn default() -> Self { + unsafe { Counter { n: 0 } } } } pub unsafe fn set_0(mut p: *mut i32, mut v: i32) { @@ -126,7 +131,7 @@ 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))); - object_unsafe!(counter, Counter::constructor_1()); + let mut counter: Counter = ::default(); (unsafe { Counter::inc(&raw 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 0403bf511f..21e7b88e24 100644 --- a/tests/unit/out/unsafe/unique_ptr.rs +++ b/tests/unit/out/unsafe/unique_ptr.rs @@ -26,7 +26,12 @@ impl SafePointer { .prefix_inc(); } pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).ptr).write(None); + this.write(::default()); + } +} +impl Default for SafePointer { + fn default() -> Self { + unsafe { SafePointer { ptr: None } } } } #[repr(C)] diff --git a/tests/unit/out/unsafe/unique_ptr_const_deref.rs b/tests/unit/out/unsafe/unique_ptr_const_deref.rs index ddde751f25..f7555921bd 100644 --- a/tests/unit/out/unsafe/unique_ptr_const_deref.rs +++ b/tests/unit/out/unsafe/unique_ptr_const_deref.rs @@ -19,7 +19,12 @@ pub struct Holder { } impl Holder { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).val).write(None); + this.write(::default()); + } +} +impl Default for Holder { + fn default() -> Self { + unsafe { Holder { val: None } } } } pub unsafe fn read_val_0(mut h: *const Holder) -> i32 { @@ -41,7 +46,7 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - object_unsafe!(h, Holder::constructor_1()); + let mut h: Holder = ::default(); { 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 fdb8b8660a..0c223ae1fc 100644 --- a/tests/unit/out/unsafe/unique_ptr_field_reset.rs +++ b/tests/unit/out/unsafe/unique_ptr_field_reset.rs @@ -42,8 +42,17 @@ impl Holder { }; } pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).data).write(None); - (&raw mut (*this).n).write(0_i32); + this.write(::default()); + } +} +impl Default for Holder { + fn default() -> Self { + unsafe { + Holder { + data: None, + n: 0_i32, + } + } } } pub static mut trace_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); @@ -64,7 +73,7 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - object_unsafe!(h, Holder::constructor_1()); + let mut h: Holder = ::default(); 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 7817e13019..5e8d972288 100644 --- a/tests/unit/out/unsafe/unique_ptr_nested.rs +++ b/tests/unit/out/unsafe/unique_ptr_nested.rs @@ -35,7 +35,12 @@ pub struct Outer { } impl Outer { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).inner).write(None); + this.write(::default()); + } +} +impl Default for Outer { + fn default() -> Self { + unsafe { Outer { inner: None } } } } pub fn main() { diff --git a/tests/unit/out/unsafe/vector.rs b/tests/unit/out/unsafe/vector.rs index 3d56780295..af58aec23d 100644 --- a/tests/unit/out/unsafe/vector.rs +++ b/tests/unit/out/unsafe/vector.rs @@ -43,8 +43,17 @@ pub struct Foo { } impl Foo { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).a).write(Vec::new()); - (&raw mut (*this).b).write(Vec::new()); + this.write(::default()); + } +} +impl Default for Foo { + fn default() -> Self { + unsafe { + Foo { + a: Vec::new(), + b: Vec::new(), + } + } } } #[repr(C)] @@ -425,7 +434,7 @@ unsafe fn main_0() -> i32 { ((((v10.len()) == (1_usize)) && ((v10[(0_usize)]) == (4))) && ((v11.len()) == (3_usize))) && ((v11[(2_usize)]) == (3)) ); - object_unsafe!(foo, Foo::constructor_1()); + let mut foo: Foo = ::default(); { let mut __tmp_15: i32 = 5; foo.a.push_moved(&mut __tmp_15) diff --git a/tests/unit/out/unsafe/vector_subscript_direct.rs b/tests/unit/out/unsafe/vector_subscript_direct.rs index aa1c512d27..4f82a1000b 100644 --- a/tests/unit/out/unsafe/vector_subscript_direct.rs +++ b/tests/unit/out/unsafe/vector_subscript_direct.rs @@ -48,8 +48,17 @@ pub struct Holder { } impl Holder { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).values).write(Vec::new()); - (&raw mut (*this).points).write(Vec::new()); + this.write(::default()); + } +} +impl Default for Holder { + fn default() -> Self { + unsafe { + Holder { + values: Vec::new(), + points: Vec::new(), + } + } } } pub unsafe fn push_and_index_0(v: *mut Vec) -> i32 { @@ -112,7 +121,7 @@ unsafe fn main_0() -> i32 { (*p) = 9; assert!(((v[(2_usize)]) == (9))); assert!(((unsafe { sum_ref_1(&v,) }) == (((((3) + (0)) + (9)) + (42)) + (5)))); - object_unsafe!(h, Holder::constructor_1()); + let mut h: Holder = ::default(); h.values.resize_with(2_usize, || 0_i32); h.values[(1_usize)] = 6; { diff --git a/tests/unit/out/unsafe/void_cast.rs b/tests/unit/out/unsafe/void_cast.rs index 2c6ade5828..41bb55cc60 100644 --- a/tests/unit/out/unsafe/void_cast.rs +++ b/tests/unit/out/unsafe/void_cast.rs @@ -27,7 +27,12 @@ pub struct NonTrivial { } impl NonTrivial { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).data).write(Vec::new()); + this.write(::default()); + } +} +impl Default for NonTrivial { + fn default() -> Self { + unsafe { NonTrivial { data: Vec::new() } } } } pub unsafe fn unused_ref_param_1(x: *const NonTrivial) {} @@ -66,7 +71,12 @@ pub struct NonCopyable { } impl NonCopyable { pub unsafe fn constructor_1(this: *mut Self) { - (&raw mut (*this).value).write(None); + this.write(::default()); + } +} +impl Default for NonCopyable { + fn default() -> Self { + unsafe { NonCopyable { value: None } } } } pub unsafe fn unused_noncopyable_param_5(x: *const NonCopyable) {} @@ -119,7 +129,7 @@ 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); - object_unsafe!(nt, NonTrivial::constructor_1()); + let mut nt: NonTrivial = ::default(); (unsafe { unused_ref_param_1(&nt) }); (unsafe { unused_ptr_param_2((&mut nt as *mut NonTrivial).cast_const()) }); let mut g: NonCopyable = NonCopyable {