From 7d27252756ab03f530dfd639353c76b8e3a21761 Mon Sep 17 00:00:00 2001 From: Perfloop Agent Date: Tue, 24 Nov 2026 16:34:07 +0000 Subject: [PATCH 1/2] Add a for-loop body destruction test Signed-off-by: Perfloop Agent --- tests/unit/for_body_destructor.cpp | 86 ++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 tests/unit/for_body_destructor.cpp diff --git a/tests/unit/for_body_destructor.cpp b/tests/unit/for_body_destructor.cpp new file mode 100644 index 0000000000..80cde195fc --- /dev/null +++ b/tests/unit/for_body_destructor.cpp @@ -0,0 +1,86 @@ +#include + +struct Guard { + int digit; + ~Guard() { std::printf("%d ", digit); } + explicit operator bool() const { return digit != 0; } +}; + +void step(int &i) { + std::printf("9 "); + ++i; +} + +int main() { + std::printf("normal/continue: "); + for (int i = 0; i < 2; step(i)) { + Guard first{1}; + Guard second{2}; + if (i == 0) + continue; + } + + std::printf("\nbreak: "); + for (int i = 0; i < 2; step(i)) { + Guard g{3}; + break; + } + + std::printf("\nnested for: "); + for (int i = 0; i < 1; step(i)) { + Guard outer{4}; + for (int j = 0; j < 2; step(j)) { + Guard inner{5}; + if (j == 0) + continue; + break; + } + continue; + } + + std::printf("\ninner while/do/range: "); + for (int i = 0; i < 1; step(i)) { + Guard outer{4}; + int j = 0; + while (++j < 3) { + Guard inner{5}; + if (j == 1) + continue; + break; + } + do { + Guard inner{6}; + continue; + } while (false); + int values[] = {1, 2}; + for (int value : values) { + Guard inner{value}; + if (value == 1) + continue; + break; + } + continue; + } + + std::printf("\ncondition: "); + for (int i = 2; Guard condition{i}; + --i, std::printf("inc%d ", condition.digit)) { + Guard body{4}; + if (i == 2) + continue; + } + + std::printf("\ninit/noncompound: "); + int i = 0; + for (Guard init{5}; i < 2; step(i)) + Guard body{6}; + + std::printf("\nno increment: "); + for (int j = 0; j < 2;) { + Guard g{++j}; + continue; + } + + std::printf("\n"); + return 0; +} From 9efc70bb4bfedbbd19b528b374bc09a487122a2d Mon Sep 17 00:00:00 2001 From: Perfloop Agent Date: Tue, 24 Nov 2026 16:46:33 +0000 Subject: [PATCH 2/2] End for-loop body lifetimes before the increment Signed-off-by: Perfloop Agent --- cpp2rust/converter/converter.cpp | 39 +- cpp2rust/converter/converter.h | 10 +- .../out/refcount/basic.scope.block.rs | 30 +- .../out/unsafe/basic.scope.block.rs | 30 +- .../expr.unary/out/refcount/expr.pre.incr.rs | 4 +- .../expr.unary/out/unsafe/expr.pre.incr.rs | 4 +- tests/ub/out/refcount/ub6.rs | 11 +- tests/ub/out/unsafe/ub6.rs | 14 +- tests/unit/out/refcount/alloc_array.rs | 4 +- tests/unit/out/refcount/array.rs | 8 +- tests/unit/out/refcount/array_2d_default.rs | 12 +- tests/unit/out/refcount/array_const_init.rs | 20 +- tests/unit/out/refcount/array_reference.rs | 4 +- tests/unit/out/refcount/bool_condition_int.rs | 4 +- .../unit/out/refcount/bool_condition_int_c.rs | 4 +- tests/unit/out/refcount/break.rs | 34 +- tests/unit/out/refcount/clone_vs_move.rs | 174 +- .../refcount/container_element_receiver.rs | 4 +- tests/unit/out/refcount/continue.rs | 51 +- tests/unit/out/refcount/copy_assign.rs | 16 +- tests/unit/out/refcount/default_in_statics.rs | 76 +- tests/unit/out/refcount/doubly_linked_list.rs | 8 +- .../refcount/emplace_hint_receiver_order.rs | 109 +- .../out/refcount/emplace_receiver_order.rs | 104 +- tests/unit/out/refcount/enum_increment.rs | 4 +- tests/unit/out/refcount/fft.rs | 140 +- .../unit/out/refcount/field_array_elem_ptr.rs | 4 +- tests/unit/out/refcount/field_pointers.rs | 4 +- .../field_reinterpret_write_through.rs | 10 +- .../refcount/first_field_ptr_covers_struct.rs | 4 +- .../out/refcount/fn_ptr_stdlib_compare.rs | 16 +- .../unit/out/refcount/for_body_destructor.rs | 198 ++ tests/unit/out/refcount/foreach.rs | 10 +- tests/unit/out/refcount/foreach_map.rs | 5 +- tests/unit/out/refcount/global_pointers.rs | 30 +- tests/unit/out/refcount/goto_cleanup.rs | 10 +- tests/unit/out/refcount/goto_loop_control.rs | 27 +- tests/unit/out/refcount/goto_nested_label.rs | 32 +- .../out/refcount/goto_nested_loop_control.rs | 90 +- tests/unit/out/refcount/huffman.rs | 102 +- tests/unit/out/refcount/ifaddrs.rs | 95 +- tests/unit/out/refcount/init_list.rs | 4 +- .../out/refcount/inline_container_fields.rs | 42 +- tests/unit/out/refcount/kruskal.rs | 79 +- .../out/refcount/lambda_immediate_init.rs | 4 +- tests/unit/out/refcount/lambda_to_fn_ptr.rs | 4 +- tests/unit/out/refcount/linked_list.rs | 4 +- .../unit/out/refcount/malloc_realloc_free.rs | 16 +- tests/unit/out/refcount/map-reallocation.rs | 12 +- tests/unit/out/refcount/map.rs | 40 +- tests/unit/out/refcount/map_try_emplace.rs | 327 +-- .../out/refcount/map_try_emplace_lvalues.rs | 2038 +++++++++-------- tests/unit/out/refcount/matmul.rs | 103 +- tests/unit/out/refcount/max.rs | 26 +- tests/unit/out/refcount/memset.rs | 4 +- tests/unit/out/refcount/nested_block_scope.rs | 10 +- tests/unit/out/refcount/new_alloc_array.rs | 8 +- tests/unit/out/refcount/new_array.rs | 8 +- tests/unit/out/refcount/null_in_statics.rs | 32 +- tests/unit/out/refcount/pointer_array.rs | 8 +- .../unit/out/refcount/pointer_call_offset.rs | 4 +- tests/unit/out/refcount/pointer_offset.rs | 24 +- .../unit/out/refcount/pointer_usize_arith.rs | 4 +- tests/unit/out/refcount/qsort_bsearch.rs | 4 +- .../out/refcount/reinterpret_cast_iterate.rs | 4 +- .../refcount/reinterpret_cast_large_array.rs | 4 +- tests/unit/out/refcount/rule_of_five.rs | 24 +- tests/unit/out/refcount/rule_of_three.rs | 16 +- tests/unit/out/refcount/size_t_ssize_t.rs | 8 +- tests/unit/out/refcount/socket_ip_name.rs | 72 +- .../unit/out/refcount/socket_recvfrom_name.rs | 9 +- tests/unit/out/refcount/socket_unix_name.rs | 81 +- tests/unit/out/refcount/sort.rs | 14 +- tests/unit/out/refcount/string.rs | 70 +- tests/unit/out/refcount/string_escape.rs | 18 +- .../refcount/string_literal_interior_null.rs | 4 +- .../unit/out/refcount/string_repeat_append.rs | 104 +- tests/unit/out/refcount/swap_map_no_copy.rs | 64 +- .../refcount/switch_continue_inside_switch.rs | 25 +- .../refcount/switch_for_in_switch_break.rs | 8 +- .../refcount/switch_for_in_switch_continue.rs | 9 +- .../refcount/switch_for_switch_for_break.rs | 40 +- tests/unit/out/refcount/switch_in_loop.rs | 34 +- .../refcount/unboxed_conditional_iterator.rs | 54 +- tests/unit/out/refcount/unboxed_locals.rs | 4 +- tests/unit/out/refcount/unboxed_records.rs | 6 +- .../out/refcount/union_flex_array_member.rs | 16 +- tests/unit/out/refcount/unique_ptr.rs | 50 +- tests/unit/out/refcount/va_arg_chain.rs | 4 +- tests/unit/out/refcount/va_arg_copy.rs | 8 +- tests/unit/out/refcount/va_arg_forward.rs | 4 +- .../unit/out/refcount/va_arg_mixed_int_ptr.rs | 14 +- tests/unit/out/refcount/va_arg_mixed_types.rs | 24 +- .../unit/out/refcount/va_arg_null_int_ptr.rs | 10 +- tests/unit/out/refcount/va_list_field.rs | 8 +- tests/unit/out/refcount/vector.rs | 46 +- .../out/refcount/vector_subscript_borrow.rs | 6 +- .../out/refcount/vector_subscript_direct.rs | 4 +- .../out/refcount/vector_with_allocator.rs | 8 +- tests/unit/out/unsafe/alloc_array.rs | 10 +- tests/unit/out/unsafe/array.rs | 8 +- tests/unit/out/unsafe/array_2d_default.rs | 12 +- tests/unit/out/unsafe/array_const_init.rs | 32 +- tests/unit/out/unsafe/array_reference.rs | 4 +- tests/unit/out/unsafe/bool_condition_int.rs | 4 +- tests/unit/out/unsafe/bool_condition_int_c.rs | 4 +- tests/unit/out/unsafe/break.rs | 34 +- tests/unit/out/unsafe/clone_vs_move.rs | 116 +- .../out/unsafe/container_element_receiver.rs | 4 +- tests/unit/out/unsafe/continue.rs | 51 +- tests/unit/out/unsafe/copy_assign.rs | 10 +- tests/unit/out/unsafe/default_in_statics.rs | 64 +- tests/unit/out/unsafe/doubly_linked_list.rs | 8 +- .../out/unsafe/emplace_hint_receiver_order.rs | 89 +- .../unit/out/unsafe/emplace_receiver_order.rs | 107 +- tests/unit/out/unsafe/enum_increment.rs | 4 +- tests/unit/out/unsafe/fft.rs | 214 +- tests/unit/out/unsafe/field_array_elem_ptr.rs | 4 +- tests/unit/out/unsafe/field_pointers.rs | 5 +- .../unsafe/field_reinterpret_write_through.rs | 10 +- .../unsafe/first_field_ptr_covers_struct.rs | 4 +- .../unit/out/unsafe/fn_ptr_stdlib_compare.rs | 16 +- tests/unit/out/unsafe/for_body_destructor.rs | 198 ++ tests/unit/out/unsafe/foreach.rs | 10 +- tests/unit/out/unsafe/foreach_map.rs | 4 +- tests/unit/out/unsafe/global_pointers.rs | 19 +- tests/unit/out/unsafe/goto_cleanup.rs | 10 +- tests/unit/out/unsafe/goto_loop_control.rs | 27 +- tests/unit/out/unsafe/goto_nested_label.rs | 32 +- .../out/unsafe/goto_nested_loop_control.rs | 90 +- tests/unit/out/unsafe/huffman.rs | 92 +- tests/unit/out/unsafe/ifaddrs.rs | 114 +- tests/unit/out/unsafe/init_list.rs | 4 +- .../out/unsafe/inline_container_fields.rs | 34 +- tests/unit/out/unsafe/kruskal.rs | 88 +- .../unit/out/unsafe/lambda_immediate_init.rs | 4 +- tests/unit/out/unsafe/lambda_to_fn_ptr.rs | 4 +- tests/unit/out/unsafe/linked_list.rs | 4 +- tests/unit/out/unsafe/malloc_realloc_free.rs | 16 +- tests/unit/out/unsafe/map-reallocation.rs | 8 +- tests/unit/out/unsafe/map.rs | 34 +- tests/unit/out/unsafe/map_try_emplace.rs | 169 +- .../out/unsafe/map_try_emplace_lvalues.rs | 1167 +++++----- tests/unit/out/unsafe/matmul.rs | 116 +- tests/unit/out/unsafe/max.rs | 22 +- tests/unit/out/unsafe/memset.rs | 4 +- tests/unit/out/unsafe/nested_block_scope.rs | 10 +- tests/unit/out/unsafe/new_alloc_array.rs | 8 +- tests/unit/out/unsafe/new_array.rs | 8 +- tests/unit/out/unsafe/null_in_statics.rs | 22 +- tests/unit/out/unsafe/pointer_array.rs | 4 +- tests/unit/out/unsafe/pointer_call_offset.rs | 4 +- tests/unit/out/unsafe/pointer_offset.rs | 24 +- tests/unit/out/unsafe/pointer_usize_arith.rs | 4 +- tests/unit/out/unsafe/qsort_bsearch.rs | 4 +- .../out/unsafe/reinterpret_cast_iterate.rs | 4 +- .../unsafe/reinterpret_cast_large_array.rs | 4 +- tests/unit/out/unsafe/rule_of_five.rs | 24 +- tests/unit/out/unsafe/rule_of_three.rs | 16 +- tests/unit/out/unsafe/size_t_ssize_t.rs | 8 +- tests/unit/out/unsafe/socket_ip_name.rs | 68 +- tests/unit/out/unsafe/socket_recvfrom_name.rs | 12 +- tests/unit/out/unsafe/socket_unix_name.rs | 100 +- tests/unit/out/unsafe/sort.rs | 4 +- tests/unit/out/unsafe/string.rs | 32 +- tests/unit/out/unsafe/string_escape.rs | 12 +- .../unsafe/string_literal_interior_null.rs | 4 +- tests/unit/out/unsafe/string_repeat_append.rs | 89 +- tests/unit/out/unsafe/swap_map_no_copy.rs | 40 +- .../unsafe/switch_continue_inside_switch.rs | 25 +- .../out/unsafe/switch_for_in_switch_break.rs | 8 +- .../unsafe/switch_for_in_switch_continue.rs | 9 +- .../out/unsafe/switch_for_switch_for_break.rs | 40 +- tests/unit/out/unsafe/switch_in_loop.rs | 34 +- .../unsafe/unboxed_conditional_iterator.rs | 48 +- tests/unit/out/unsafe/unboxed_locals.rs | 4 +- tests/unit/out/unsafe/unboxed_records.rs | 6 +- .../out/unsafe/union_flex_array_member.rs | 14 +- tests/unit/out/unsafe/unique_ptr.rs | 98 +- tests/unit/out/unsafe/va_arg_chain.rs | 4 +- tests/unit/out/unsafe/va_arg_copy.rs | 8 +- tests/unit/out/unsafe/va_arg_forward.rs | 4 +- tests/unit/out/unsafe/va_arg_mixed_int_ptr.rs | 14 +- tests/unit/out/unsafe/va_arg_mixed_types.rs | 24 +- tests/unit/out/unsafe/va_arg_null_int_ptr.rs | 10 +- tests/unit/out/unsafe/va_list_field.rs | 8 +- tests/unit/out/unsafe/vector.rs | 39 +- .../out/unsafe/vector_subscript_borrow.rs | 4 +- .../out/unsafe/vector_subscript_direct.rs | 4 +- .../unit/out/unsafe/vector_with_allocator.rs | 8 +- 190 files changed, 5287 insertions(+), 3949 deletions(-) create mode 100644 tests/unit/out/refcount/for_body_destructor.rs create mode 100644 tests/unit/out/unsafe/for_body_destructor.rs diff --git a/cpp2rust/converter/converter.cpp b/cpp2rust/converter/converter.cpp index 2cf4e59559..5b2fffa3c9 100644 --- a/cpp2rust/converter/converter.cpp +++ b/cpp2rust/converter/converter.cpp @@ -1576,9 +1576,9 @@ bool Converter::VisitAttributedStmt(clang::AttributedStmt *stmt) { } bool Converter::VisitWhileStmt(clang::WhileStmt *stmt) { - ScopedValue break_loop(break_switch_, false); + ScopedValue break_loop(break_label_, ""); StrCat("'loop_:"); - ScopedValue no_inc(curr_for_inc_, nullptr); + ScopedValue no_inc(continue_for_, false); if (auto *cond_var = stmt->getConditionVariableDeclStmt()) { StrCat(keyword::kLoop); PushBrace loop_brace(*this); @@ -1605,7 +1605,7 @@ void Converter::ConvertConditionVariableTest(clang::DeclStmt *cond_var, } bool Converter::VisitDoStmt(clang::DoStmt *stmt) { - ScopedValue break_loop(break_switch_, false); + ScopedValue break_loop(break_label_, ""); const char *control_var = "__do_while"; StrCat(keyword::kLet, "mut", control_var, token::kAssign, keyword::kTrue, token::kSemiColon); @@ -1617,14 +1617,14 @@ bool Converter::VisitDoStmt(clang::DoStmt *stmt) { { PushBrace loop_brace(*this); StrCat(control_var, token::kAssign, keyword::kFalse, token::kSemiColon); - ScopedValue no_inc(curr_for_inc_, nullptr); + ScopedValue no_inc(continue_for_, false); ConvertBodyStmts(stmt->getBody()); } return false; } bool Converter::VisitForStmt(clang::ForStmt *stmt) { - ScopedValue break_loop(break_switch_, false); + ScopedValue break_loop(break_label_, stmt->getInc() ? "'loop_" : ""); // The variables of the init statement are only visible in the for. PushBrace scope(*this, stmt->getInit() && clang::isa(stmt->getInit())); @@ -1647,7 +1647,14 @@ bool Converter::VisitForStmt(clang::ForStmt *stmt) { ConvertConditionVariableTest(cond_var, stmt->getCond()); } { - ScopedValue inc(curr_for_inc_, stmt->getInc()); + ScopedValue inc(continue_for_, stmt->getInc() != nullptr); + // Leaving the body, including via continue, destroys its locals before + // the increment. The condition variable stays alive through the + // increment. + if (continue_for_) { + StrCat("'for_body:"); + } + PushBrace body(*this, continue_for_); ConvertBodyStmts(stmt->getBody()); } Convert(stmt->getInc()); @@ -1657,7 +1664,7 @@ bool Converter::VisitForStmt(clang::ForStmt *stmt) { } bool Converter::VisitCXXForRangeStmt(clang::CXXForRangeStmt *stmt) { - ScopedValue break_loop(break_switch_, false); + ScopedValue break_loop(break_label_, ""); Convert(stmt->getInit()); Convert(stmt->getRangeStmt()); auto *begin = @@ -1672,7 +1679,7 @@ bool Converter::VisitCXXForRangeStmt(clang::CXXForRangeStmt *stmt) { ConvertFreshRValue(end->getInit()), ')'); { PushBrace brace(*this); - ScopedValue no_inc(curr_for_inc_, nullptr); + ScopedValue no_inc(continue_for_, false); Convert(stmt->getLoopVarStmt()); ConvertBodyStmts(stmt->getBody()); } @@ -1680,20 +1687,16 @@ bool Converter::VisitCXXForRangeStmt(clang::CXXForRangeStmt *stmt) { } bool Converter::VisitBreakStmt([[maybe_unused]] clang::BreakStmt *stmt) { - StrCat(keyword::kBreak); - if (break_switch_) { - StrCat("'switch"); - } + StrCat(keyword::kBreak, break_label_); return false; } bool Converter::VisitContinueStmt([[maybe_unused]] clang::ContinueStmt *stmt) { - if (curr_for_inc_) { - Convert(curr_for_inc_); - StrCat(token::kSemiColon); + if (continue_for_) { + StrCat(keyword::kBreak, "'for_body"); + } else { + StrCat(keyword::kContinue, "'loop_"); } - StrCat(keyword::kContinue); - StrCat("'loop_"); return false; } @@ -4524,7 +4527,7 @@ bool Converter::VisitSwitchStmt(clang::SwitchStmt *stmt) { return !arm.label.empty() || arm.has_fallthrough; }); - ScopedValue break_switch(break_switch_, !needs_switch_macro); + ScopedValue break_switch(break_label_, needs_switch_macro ? "" : "'switch"); // The variables of the init statement and of the condition are only // visible in the switch. diff --git a/cpp2rust/converter/converter.h b/cpp2rust/converter/converter.h index dc915806d5..df548824c5 100644 --- a/cpp2rust/converter/converter.h +++ b/cpp2rust/converter/converter.h @@ -1066,16 +1066,16 @@ class Converter : public clang::RecursiveASTVisitor { bool constant_evaluated_ = false; std::optional autoref_mut_; - // The increment of the innermost loop, which continue runs. - clang::Expr *curr_for_inc_ = nullptr; + // Whether continue exits 'for_body to run the for-loop increment. + bool continue_for_ = false; // The names of the iterators of range-based for loops. std::unordered_map range_iterator_names_; std::vector curr_init_type_; - // Whether break exits a switch labeled 'switch, rather than a loop or a - // switch! macro, which a plain break exits. - bool break_switch_ = false; + // Breaks in a for body must leave the loop, not just the labeled body. + // A switch! macro owns plain breaks; a plain match uses 'switch. + const char *break_label_ = ""; // Local variables hoisted outside a goto_block so that all labels can see and // use the variables. diff --git a/tests/std/basic/basic.scope/out/refcount/basic.scope.block.rs b/tests/std/basic/basic.scope/out/refcount/basic.scope.block.rs index cb0e495044..fbd6e1813e 100644 --- a/tests/std/basic/basic.scope/out/refcount/basic.scope.block.rs +++ b/tests/std/basic/basic.scope/out/refcount/basic.scope.block.rs @@ -133,8 +133,10 @@ pub fn test_8() { { let mut index: i32 = 0; 'loop_: while (index < 3) { - iterations.prefix_inc(); - sum += index; + 'for_body: { + iterations.prefix_inc(); + sum += index; + } index.prefix_inc(); } } @@ -151,9 +153,11 @@ pub fn test_9() { { let mut index: i32 = 0; 'loop_: while (index < 3) { - let scoped: Value = Rc::new(RefCell::new(LifetimeTracked::new())); - let _dtor_scoped = - std::mem::DropGuard::new(scoped.clone(), |__p| __p.as_pointer().destructor()); + 'for_body: { + let scoped: Value = Rc::new(RefCell::new(LifetimeTracked::new())); + let _dtor_scoped = + std::mem::DropGuard::new(scoped.clone(), |__p| __p.as_pointer().destructor()); + } index.prefix_inc(); } } @@ -224,12 +228,16 @@ pub fn test_12() { { let mut index: i32 = 0; 'loop_: while (index < 2) { - { - let mut index: i32 = 10; - 'loop_: while (index < 13) { - inner_iterations.prefix_inc(); - sum += index; - index.prefix_inc(); + 'for_body: { + { + let mut index: i32 = 10; + 'loop_: while (index < 13) { + 'for_body: { + inner_iterations.prefix_inc(); + sum += index; + } + index.prefix_inc(); + } } } { diff --git a/tests/std/basic/basic.scope/out/unsafe/basic.scope.block.rs b/tests/std/basic/basic.scope/out/unsafe/basic.scope.block.rs index 8d4e3a6bea..cfaf288d6e 100644 --- a/tests/std/basic/basic.scope/out/unsafe/basic.scope.block.rs +++ b/tests/std/basic/basic.scope/out/unsafe/basic.scope.block.rs @@ -121,8 +121,10 @@ pub unsafe fn test_8() { { let mut index: i32 = 0; 'loop_: while ((index) < (3)) { - iterations.prefix_inc(); - sum += index; + 'for_body: { + iterations.prefix_inc(); + sum += index; + } index.prefix_inc(); } } @@ -139,9 +141,11 @@ pub unsafe fn test_9() { { let mut index: i32 = 0; 'loop_: while ((index) < (3)) { - let mut scoped: LifetimeTracked = LifetimeTracked::new(); - let _dtor_scoped = - std::mem::DropGuard::new(&raw mut scoped, |__p| unsafe { (*__p).destructor() }); + 'for_body: { + let mut scoped: LifetimeTracked = LifetimeTracked::new(); + let _dtor_scoped = + std::mem::DropGuard::new(&raw mut scoped, |__p| unsafe { (*__p).destructor() }); + } index.prefix_inc(); } } @@ -208,12 +212,16 @@ pub unsafe fn test_12() { { let mut index: i32 = 0; 'loop_: while ((index) < (2)) { - { - let mut index: i32 = 10; - 'loop_: while ((index) < (13)) { - inner_iterations.prefix_inc(); - sum += index; - index.prefix_inc(); + 'for_body: { + { + let mut index: i32 = 10; + 'loop_: while ((index) < (13)) { + 'for_body: { + inner_iterations.prefix_inc(); + sum += index; + } + index.prefix_inc(); + } } } { 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 bbfb9f5d3a..900ddec18a 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 @@ -63,7 +63,9 @@ pub fn test_0() { { let mut k: i32 = 0; 'loop_: while (k < 3) { - sum += (*y.prefix_inc()); + 'for_body: { + sum += (*y.prefix_inc()); + } k.prefix_inc(); } } 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 f998fec549..6c3aa01462 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 @@ -43,7 +43,9 @@ pub unsafe fn test_0() { { let mut k: i32 = 0; 'loop_: while ((k) < (3)) { - sum += (*y.prefix_inc()); + 'for_body: { + sum += (*y.prefix_inc()); + } k.prefix_inc(); } } diff --git a/tests/ub/out/refcount/ub6.rs b/tests/ub/out/refcount/ub6.rs index b8972f30a1..d02ed6221a 100644 --- a/tests/ub/out/refcount/ub6.rs +++ b/tests/ub/out/refcount/ub6.rs @@ -41,10 +41,13 @@ pub fn any_2(arr: Ptr]>>>>, n1: Ptr) -> bool { { let mut i: i32 = 0; 'loop_: while ({ i } < { (n1.read()) }) { - let __rhs = (out) - || (((({ (*arr.upgrade().deref()).decay().offset((i as usize)) }).read()).read()) - == 0); - out = __rhs; + 'for_body: { + let __rhs = (out) + || (((({ (*arr.upgrade().deref()).decay().offset((i as usize)) }).read()) + .read()) + == 0); + out = __rhs; + } i.prefix_inc(); } } diff --git a/tests/ub/out/unsafe/ub6.rs b/tests/ub/out/unsafe/ub6.rs index 60d27b99b5..c29ed118c3 100644 --- a/tests/ub/out/unsafe/ub6.rs +++ b/tests/ub/out/unsafe/ub6.rs @@ -36,12 +36,14 @@ pub unsafe fn any_2(arr: *mut Option>, n1: *mut i32) -> bool { { let mut i: i32 = 0; 'loop_: while ((i) < (*n1)) { - out = (out) - || ((*(*(*arr) - .as_deref() - .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut *mut i32) - .add((i as usize)))) - == (0)); + 'for_body: { + out = (out) + || ((*(*(*arr) + .as_deref() + .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut *mut i32) + .add((i as usize)))) + == (0)); + } i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/alloc_array.rs b/tests/unit/out/refcount/alloc_array.rs index 69dff61448..99db86bdb6 100644 --- a/tests/unit/out/refcount/alloc_array.rs +++ b/tests/unit/out/refcount/alloc_array.rs @@ -13,7 +13,9 @@ pub fn All_0(arr: Ptr>>>, mut N: i32, mut element: i32) { let mut i: i32 = 0; 'loop_: while (i < N) { - all.decay().offset((i as usize)).write(element); + 'for_body: { + all.decay().offset((i as usize)).write(element); + } i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/array.rs b/tests/unit/out/refcount/array.rs index a61ca7805c..41fb06d3a2 100644 --- a/tests/unit/out/refcount/array.rs +++ b/tests/unit/out/refcount/array.rs @@ -17,7 +17,9 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < (*N.borrow())) { - arr1[(i) as usize] = { (i + arr2[(i) as usize]) }; + 'for_body: { + arr1[(i) as usize] = { (i + arr2[(i) as usize]) }; + } i.prefix_inc(); } } @@ -25,7 +27,9 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < (*N.borrow())) { - fatorial *= arr1[(i) as usize]; + 'for_body: { + fatorial *= arr1[(i) as usize]; + } i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/array_2d_default.rs b/tests/unit/out/refcount/array_2d_default.rs index cdb9730276..24b4d0c122 100644 --- a/tests/unit/out/refcount/array_2d_default.rs +++ b/tests/unit/out/refcount/array_2d_default.rs @@ -23,11 +23,13 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < 3) { - ({ - let _row: Ptr = grid.decay().offset(i).decay(); - let _c: i8 = ((('a' as i32) + i) as i8); - fill_row_0(_row, _c) - }); + 'for_body: { + ({ + let _row: Ptr = grid.decay().offset(i).decay(); + let _c: i8 = ((('a' as i32) + i) as i8); + fill_row_0(_row, _c) + }); + } i.postfix_inc(); } } diff --git a/tests/unit/out/refcount/array_const_init.rs b/tests/unit/out/refcount/array_const_init.rs index 4ea00f4b1d..f593dd57a7 100644 --- a/tests/unit/out/refcount/array_const_init.rs +++ b/tests/unit/out/refcount/array_const_init.rs @@ -67,14 +67,18 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < 3) { - assert!(((array_elem!(s_0.with(|v| v.as_pointer()), tail, i).read()) == 0)); + 'for_body: { + assert!(((array_elem!(s_0.with(|v| v.as_pointer()), tail, i).read()) == 0)); + } i.postfix_inc(); } } { let mut i: i32 = 0; 'loop_: while (i < 4) { - assert!((((array_elem!(s_0.with(|v| v.as_pointer()), buf, i).read()) as i32) == 0)); + 'for_body: { + assert!((((array_elem!(s_0.with(|v| v.as_pointer()), buf, i).read()) as i32) == 0)); + } i.postfix_inc(); } } @@ -82,7 +86,9 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < 10) { - assert!((a[(i) as usize] == 0)); + 'for_body: { + assert!((a[(i) as usize] == 0)); + } i.postfix_inc(); } } @@ -91,7 +97,9 @@ fn main_0() -> i32 { { let mut i: i32 = 1; 'loop_: while (i < 4) { - assert!((seven[(i) as usize] == 0)); + 'for_body: { + assert!((seven[(i) as usize] == 0)); + } i.postfix_inc(); } } @@ -100,7 +108,9 @@ fn main_0() -> i32 { { let mut i: i32 = 3; 'loop_: while (i < 6) { - assert!((b[(i) as usize] == 0)); + 'for_body: { + assert!((b[(i) as usize] == 0)); + } i.postfix_inc(); } } diff --git a/tests/unit/out/refcount/array_reference.rs b/tests/unit/out/refcount/array_reference.rs index bb958c6514..d7908a749c 100644 --- a/tests/unit/out/refcount/array_reference.rs +++ b/tests/unit/out/refcount/array_reference.rs @@ -27,7 +27,9 @@ pub fn fill_3(a: Ptr, mut v: i32) { { let mut i: i32 = 0; 'loop_: while (i < 3) { - elem!(a, i).write(v); + 'for_body: { + elem!(a, i).write(v); + } i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/bool_condition_int.rs b/tests/unit/out/refcount/bool_condition_int.rs index 25d0244d9e..96b0e121db 100644 --- a/tests/unit/out/refcount/bool_condition_int.rs +++ b/tests/unit/out/refcount/bool_condition_int.rs @@ -51,7 +51,9 @@ fn main_0() -> i32 { { let mut i: i32 = 5; 'loop_: while (i != 0) { - loop_count.prefix_inc(); + 'for_body: { + loop_count.prefix_inc(); + } i.prefix_dec(); } } diff --git a/tests/unit/out/refcount/bool_condition_int_c.rs b/tests/unit/out/refcount/bool_condition_int_c.rs index 33873f8fc6..ab47769c33 100644 --- a/tests/unit/out/refcount/bool_condition_int_c.rs +++ b/tests/unit/out/refcount/bool_condition_int_c.rs @@ -51,7 +51,9 @@ fn main_0() -> i32 { { let mut i: i32 = 5; 'loop_: while (i != 0) { - loop_count.prefix_inc(); + 'for_body: { + loop_count.prefix_inc(); + } i.prefix_dec(); } } diff --git a/tests/unit/out/refcount/break.rs b/tests/unit/out/refcount/break.rs index a969b69339..fb68beafc9 100644 --- a/tests/unit/out/refcount/break.rs +++ b/tests/unit/out/refcount/break.rs @@ -12,25 +12,29 @@ pub fn for_test_0(mut n: i32) -> i32 { let mut i: i32 = 0; let mut j: i32 = 0; 'loop_: while (i < n) { - x += 1; - if (x == 100) { - break; - } - { - let mut k: i32 = 0; - let mut w: i32 = 0; - 'loop_: while (w < j) { - break; - { + 'for_body: { + x += 1; + if (x == 100) { + break 'loop_; + } + { + let mut k: i32 = 0; + let mut w: i32 = 0; + 'loop_: while (w < j) { + 'for_body: { + break 'loop_; + } { - w += 1; - k += 1 + { + w += 1; + k += 1 + }; + i += k }; - i += k - }; + } } + x = { (x + 1) }; } - x = { (x + 1) }; { j = i; i += 1 diff --git a/tests/unit/out/refcount/clone_vs_move.rs b/tests/unit/out/refcount/clone_vs_move.rs index c47e6b29a3..aa79d410b1 100644 --- a/tests/unit/out/refcount/clone_vs_move.rs +++ b/tests/unit/out/refcount/clone_vs_move.rs @@ -130,10 +130,12 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < N) { - { - let a0_clone = i.clone(); - v1.push(a0_clone) - }; + 'for_body: { + { + let a0_clone = i.clone(); + v1.push(a0_clone) + }; + } i.prefix_inc(); } } @@ -141,22 +143,28 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < N) { - assert!((v2[(i as usize)] == i)); + 'for_body: { + assert!((v2[(i as usize)] == i)); + } i.prefix_inc(); } } { let mut i: i32 = 0; 'loop_: while (i < N) { - v2[(i as usize)].prefix_inc(); + 'for_body: { + v2[(i as usize)].prefix_inc(); + } i.prefix_inc(); } } { let mut i: i32 = 0; 'loop_: while (i < N) { - assert!((v2[(i as usize)] == (i + 1))); - assert!((v1[(i as usize)] == i)); + 'for_body: { + assert!((v2[(i as usize)] == (i + 1))); + assert!((v1[(i as usize)] == i)); + } i.prefix_inc(); } } @@ -164,10 +172,12 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < N) { - { - let __a1 = Vec::from_fn(10_usize, |_| 0_i32); - (*m1.borrow_mut()).push(__a1) - }; + 'for_body: { + { + let __a1 = Vec::from_fn(10_usize, |_| 0_i32); + (*m1.borrow_mut()).push(__a1) + }; + } i.prefix_inc(); } } @@ -175,14 +185,28 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < N) { - assert!(({ ((*m1.decay().offset((i as usize)).upgrade().deref()).len() == 10_usize) })); - assert!(({ ((*m2.decay().offset((i as usize)).upgrade().deref()).len() == 10_usize) })); - { - let mut j: i32 = 0; - 'loop_: while (j < 10) { - assert!(((index!(elem!(m1.decay(), (i as usize)), (j as usize)).read()) == 0)); - assert!(((index!(elem!(m2.decay(), (i as usize)), (j as usize)).read()) == 0)); - j.prefix_inc(); + 'for_body: { + assert!( + ({ ((*m1.decay().offset((i as usize)).upgrade().deref()).len() == 10_usize) }) + ); + assert!( + ({ ((*m2.decay().offset((i as usize)).upgrade().deref()).len() == 10_usize) }) + ); + { + let mut j: i32 = 0; + 'loop_: while (j < 10) { + 'for_body: { + assert!( + ((index!(elem!(m1.decay(), (i as usize)), (j as usize)).read()) + == 0) + ); + assert!( + ((index!(elem!(m2.decay(), (i as usize)), (j as usize)).read()) + == 0) + ); + } + j.prefix_inc(); + } } } i.prefix_inc(); @@ -191,12 +215,16 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < N) { - { - let mut j: i32 = 0; - 'loop_: while (j < 10) { - index!(elem!(m2.decay(), (i as usize)), (j as usize)) - .with_mut(|__v| __v.postfix_inc()); - j.prefix_inc(); + 'for_body: { + { + let mut j: i32 = 0; + 'loop_: while (j < 10) { + 'for_body: { + index!(elem!(m2.decay(), (i as usize)), (j as usize)) + .with_mut(|__v| __v.postfix_inc()); + } + j.prefix_inc(); + } } } i.prefix_inc(); @@ -205,14 +233,28 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < N) { - assert!(({ ((*m1.decay().offset((i as usize)).upgrade().deref()).len() == 10_usize) })); - assert!(({ ((*m2.decay().offset((i as usize)).upgrade().deref()).len() == 10_usize) })); - { - let mut j: i32 = 0; - 'loop_: while (j < 10) { - assert!(((index!(elem!(m1.decay(), (i as usize)), (j as usize)).read()) == 0)); - assert!(((index!(elem!(m2.decay(), (i as usize)), (j as usize)).read()) == 1)); - j.prefix_inc(); + 'for_body: { + assert!( + ({ ((*m1.decay().offset((i as usize)).upgrade().deref()).len() == 10_usize) }) + ); + assert!( + ({ ((*m2.decay().offset((i as usize)).upgrade().deref()).len() == 10_usize) }) + ); + { + let mut j: i32 = 0; + 'loop_: while (j < 10) { + 'for_body: { + assert!( + ((index!(elem!(m1.decay(), (i as usize)), (j as usize)).read()) + == 0) + ); + assert!( + ((index!(elem!(m2.decay(), (i as usize)), (j as usize)).read()) + == 1) + ); + } + j.prefix_inc(); + } } } i.prefix_inc(); @@ -222,8 +264,10 @@ fn main_0() -> i32 { { let i: Value = Rc::new(RefCell::new(0)); 'loop_: while ((*i.borrow()) < N) { - let __rhs = (*i.borrow()); - ({ (*map1.borrow_mut()).subscript(i.as_pointer(), || 0_i32) }).write(__rhs); + 'for_body: { + let __rhs = (*i.borrow()); + ({ (*map1.borrow_mut()).subscript(i.as_pointer(), || 0_i32) }).write(__rhs); + } (*i.borrow_mut()).prefix_inc(); } } @@ -232,33 +276,37 @@ fn main_0() -> i32 { { let i: Value = Rc::new(RefCell::new(0)); 'loop_: while ((*i.borrow()) < N) { - assert!( - ({ - ((({ (*map2.borrow_mut()).subscript(i.as_pointer(), || 0_i32) }).read()) - == (*i.borrow())) - }) - ); - ({ (*map2.borrow_mut()).subscript(i.as_pointer(), || 0_i32) }).with_mut(|__v| { - __v.prefix_inc(); - }); + 'for_body: { + assert!( + ({ + ((({ (*map2.borrow_mut()).subscript(i.as_pointer(), || 0_i32) }).read()) + == (*i.borrow())) + }) + ); + ({ (*map2.borrow_mut()).subscript(i.as_pointer(), || 0_i32) }).with_mut(|__v| { + __v.prefix_inc(); + }); + } (*i.borrow_mut()).prefix_inc(); } } { let i: Value = Rc::new(RefCell::new(0)); 'loop_: while ((*i.borrow()) < N) { - assert!( - ({ - ((({ (*map1.borrow_mut()).subscript(i.as_pointer(), || 0_i32) }).read()) - == (*i.borrow())) - }) - ); - assert!( - ({ - ((({ (*map2.borrow_mut()).subscript(i.as_pointer(), || 0_i32) }).read()) - == ((*i.borrow()) + 1)) - }) - ); + 'for_body: { + assert!( + ({ + ((({ (*map1.borrow_mut()).subscript(i.as_pointer(), || 0_i32) }).read()) + == (*i.borrow())) + }) + ); + assert!( + ({ + ((({ (*map2.borrow_mut()).subscript(i.as_pointer(), || 0_i32) }).read()) + == ((*i.borrow()) + 1)) + }) + ); + } (*i.borrow_mut()).prefix_inc(); } } @@ -321,16 +369,20 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < N) { - assert!((v4[(i as usize)] == (i + 1))); - v4[(i as usize)].prefix_inc(); + 'for_body: { + assert!((v4[(i as usize)] == (i + 1))); + v4[(i as usize)].prefix_inc(); + } i.prefix_inc(); } } { let mut i: i32 = 0; 'loop_: while (i < N) { - assert!((v4[(i as usize)] == (i + 2))); - assert!((v2[(i as usize)] == (i + 1))); + 'for_body: { + assert!((v4[(i as usize)] == (i + 2))); + assert!((v2[(i as usize)] == (i + 1))); + } i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/container_element_receiver.rs b/tests/unit/out/refcount/container_element_receiver.rs index 53976b9137..ebc969fe48 100644 --- a/tests/unit/out/refcount/container_element_receiver.rs +++ b/tests/unit/out/refcount/container_element_receiver.rs @@ -32,7 +32,9 @@ pub fn sum_1(v: Ptr>) -> i32 { { let it: Value> = Rc::new(RefCell::new(v.decay().begin())); 'loop_: while (*it.borrow()) != v.decay().end() { - total += (({ (*it.borrow()).iter_deref() }).read()); + 'for_body: { + total += (({ (*it.borrow()).iter_deref() }).read()); + } { (*it.borrow_mut()).iter_inc(); }; diff --git a/tests/unit/out/refcount/continue.rs b/tests/unit/out/refcount/continue.rs index 071faa7e1a..32fbd11ff4 100644 --- a/tests/unit/out/refcount/continue.rs +++ b/tests/unit/out/refcount/continue.rs @@ -24,42 +24,45 @@ fn main_0() -> i32 { { let mut j: i32 = 0; 'loop_: while (j < 10) { - if ((i % 2) == 0) { - j.postfix_inc(); - continue 'loop_; + 'for_body: { + if ((i % 2) == 0) { + break 'for_body; + } + out.prefix_inc(); } - out.prefix_inc(); j.postfix_inc(); } } { let mut k1: i32 = 0; 'loop_: while (k1 < 5) { - { - let mut k2: i32 = 0; - 'loop_: while (k2 < 5) { - let mut k3: i32 = 0; - 'loop_: while (k3 < 5) { - if ((((k1 + k2) + k3) % 2) == 0) { - k3.postfix_inc(); - continue 'loop_; + 'for_body: { + { + let mut k2: i32 = 0; + 'loop_: while (k2 < 5) { + 'for_body: { + let mut k3: i32 = 0; + 'loop_: while (k3 < 5) { + if ((((k1 + k2) + k3) % 2) == 0) { + k3.postfix_inc(); + continue 'loop_; + } + out.prefix_inc(); + k3.postfix_inc(); + } + if (((k1 + k2) % 2) == 0) { + break 'for_body; + } + out.prefix_inc(); } - out.prefix_inc(); - k3.postfix_inc(); - } - if (((k1 + k2) % 2) == 0) { k2.postfix_inc(); - continue 'loop_; } - out.prefix_inc(); - k2.postfix_inc(); } + if ((k1 % 2) == 0) { + break 'for_body; + } + out.prefix_inc(); } - if ((k1 % 2) == 0) { - k1.postfix_inc(); - continue 'loop_; - } - out.prefix_inc(); k1.postfix_inc(); } } diff --git a/tests/unit/out/refcount/copy_assign.rs b/tests/unit/out/refcount/copy_assign.rs index 053f78d9d4..22f1365481 100644 --- a/tests/unit/out/refcount/copy_assign.rs +++ b/tests/unit/out/refcount/copy_assign.rs @@ -285,13 +285,15 @@ impl HolderImpl for Ptr { { let mut __i0: usize = 0_usize; 'loop_: while (__i0 != 2_usize) { - ({ - let _o: Ptr = array_field_ptr!(_a0, arr).offset((__i0) as isize); - PartialImpl::copy_assign( - &array_field_ptr!((*self), arr).offset((__i0) as isize), - _o, - ) - }); + 'for_body: { + ({ + let _o: Ptr = array_field_ptr!(_a0, arr).offset((__i0) as isize); + PartialImpl::copy_assign( + &array_field_ptr!((*self), arr).offset((__i0) as isize), + _o, + ) + }); + } __i0.prefix_inc(); } } diff --git a/tests/unit/out/refcount/default_in_statics.rs b/tests/unit/out/refcount/default_in_statics.rs index bfd2e7ee14..688ca32c59 100644 --- a/tests/unit/out/refcount/default_in_statics.rs +++ b/tests/unit/out/refcount/default_in_statics.rs @@ -147,9 +147,11 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < 3) { - assert!( - (array_elem!(static_outer_1.with(|v| v.as_pointer()), arr, i).read()).is_null() - ); + 'for_body: { + assert!( + (array_elem!(static_outer_1.with(|v| v.as_pointer()), arr, i).read()).is_null() + ); + } i.prefix_inc(); } } @@ -167,16 +169,18 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < 2) { - assert!( - ({ + 'for_body: { + assert!( ({ - (*static_inner_array_2.with(Value::clone).borrow())[(i) as usize] - .name - .clone() + ({ + (*static_inner_array_2.with(Value::clone).borrow())[(i) as usize] + .name + .clone() + }) + .is_null() }) - .is_null() - }) - ); + ); + } i.prefix_inc(); } } @@ -187,36 +191,38 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < 2) { - assert!( - ({ + 'for_body: { + assert!( ({ - (*static_foo_array_4.with(Value::clone).borrow())[(i) as usize] - .s2 - .clone() + ({ + (*static_foo_array_4.with(Value::clone).borrow())[(i) as usize] + .s2 + .clone() + }) + .is_null() }) - .is_null() - }) - ); - assert!( - ({ + ); + assert!( ({ - (*static_foo_array_4.with(Value::clone).borrow())[(i) as usize] - .fn1 - .clone() + ({ + (*static_foo_array_4.with(Value::clone).borrow())[(i) as usize] + .fn1 + .clone() + }) + .is_null() }) - .is_null() - }) - ); - assert!( - ({ + ); + assert!( ({ - (*static_foo_array_4.with(Value::clone).borrow())[(i) as usize] - .fn2 - .clone() + ({ + (*static_foo_array_4.with(Value::clone).borrow())[(i) as usize] + .fn2 + .clone() + }) + .is_null() }) - .is_null() - }) - ); + ); + } i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/doubly_linked_list.rs b/tests/unit/out/refcount/doubly_linked_list.rs index 75ab874ca8..d2e519c04b 100644 --- a/tests/unit/out/refcount/doubly_linked_list.rs +++ b/tests/unit/out/refcount/doubly_linked_list.rs @@ -23,7 +23,9 @@ pub fn Find_0(mut head: Ptr, mut idx: i32) -> Ptr { { let mut i: i32 = 0; 'loop_: while (i < idx) { - curr = { curr.with(|__s| __s.next.clone()) }; + 'for_body: { + curr = { curr.with(|__s| __s.next.clone()) }; + } i.postfix_inc(); } } @@ -34,7 +36,9 @@ pub fn FindBack_1(mut tail: Ptr, mut idx: i32) -> Ptr { { let mut i: i32 = 0; 'loop_: while (i < idx) { - curr = { curr.with(|__s| __s.prev.clone()) }; + 'for_body: { + curr = { curr.with(|__s| __s.prev.clone()) }; + } i.postfix_inc(); } } diff --git a/tests/unit/out/refcount/emplace_hint_receiver_order.rs b/tests/unit/out/refcount/emplace_hint_receiver_order.rs index bade6ff448..fddd28a733 100644 --- a/tests/unit/out/refcount/emplace_hint_receiver_order.rs +++ b/tests/unit/out/refcount/emplace_hint_receiver_order.rs @@ -36,62 +36,65 @@ fn main_0() -> i32 { { let mut select_receiver: i32 = 1; 'loop_: while (select_receiver >= 0) { - let m: Value, Value>)>> = - Rc::new(RefCell::new(Map::new())); - let v: Value> = Rc::new(RefCell::new(Vec::from([1, 2, 3]))); - let a: Value = Rc::new(RefCell::new(0)); - let b: Value = Rc::new(RefCell::new(0)); - if (select_receiver != 0) { - { - let mut __tmp_0 = - { ({ receiver_0((m.as_pointer()), (v.as_pointer()), (a.as_pointer())) }) }; - let mut __tmp_1 = { - , Value>)>>::from( - ({ hint_1((m.as_pointer()), (v.as_pointer()), (b.as_pointer())) }), - ) + 'for_body: { + let m: Value, Value>)>> = + Rc::new(RefCell::new(Map::new())); + let v: Value> = Rc::new(RefCell::new(Vec::from([1, 2, 3]))); + let a: Value = Rc::new(RefCell::new(0)); + let b: Value = Rc::new(RefCell::new(0)); + if (select_receiver != 0) { + { + let mut __tmp_0 = { + ({ receiver_0((m.as_pointer()), (v.as_pointer()), (a.as_pointer())) }) + }; + let mut __tmp_1 = { + , Value>)>>::from( + ({ hint_1((m.as_pointer()), (v.as_pointer()), (b.as_pointer())) }), + ) + }; + let mut __tmp_2 = { + ( + Rc::new(RefCell::new(1)), + Rc::new(RefCell::new(({ (*v.borrow()).clone() }))), + ) + }; + let _ = (__tmp_1).clone(); + Map::emplace((__tmp_0).clone(), &__tmp_2.0.as_pointer(), || __tmp_2).0 }; - let mut __tmp_2 = { - ( - Rc::new(RefCell::new(1)), - Rc::new(RefCell::new(({ (*v.borrow()).clone() }))), - ) + } else { + { + let mut __tmp_3 = { + , Value>)>>::from( + ({ hint_1((m.as_pointer()), (v.as_pointer()), (b.as_pointer())) }), + ) + }; + let mut __tmp_4 = { + ( + Rc::new(RefCell::new(1)), + Rc::new(RefCell::new(({ (*v.borrow()).clone() }))), + ) + }; + let _ = (__tmp_3).clone(); + Map::emplace(m.as_pointer(), &__tmp_4.0.as_pointer(), || __tmp_4).0 }; - let _ = (__tmp_1).clone(); - Map::emplace((__tmp_0).clone(), &__tmp_2.0.as_pointer(), || __tmp_2).0 - }; - } else { - { - let mut __tmp_3 = { - , Value>)>>::from( - ({ hint_1((m.as_pointer()), (v.as_pointer()), (b.as_pointer())) }), - ) - }; - let mut __tmp_4 = { - ( - Rc::new(RefCell::new(1)), - Rc::new(RefCell::new(({ (*v.borrow()).clone() }))), - ) - }; - let _ = (__tmp_3).clone(); - Map::emplace(m.as_pointer(), &__tmp_4.0.as_pointer(), || __tmp_4).0 - }; + } + let inserted: Ptr> = ({ + let __tmp_5: Value = Rc::new(RefCell::new(1)); + (*m.borrow()) + .get(&__tmp_5.as_pointer()) + .expect("out of range!") + .borrow() + .1 + .as_pointer() + }); + printf!( + b"receiver=%d hint=%d source=%d inserted=%d\n", + (*a.borrow()), + (*b.borrow()), + { (*v.borrow())[2_usize] }, + (index!(inserted, 2_usize).read()) + ); } - let inserted: Ptr> = ({ - let __tmp_5: Value = Rc::new(RefCell::new(1)); - (*m.borrow()) - .get(&__tmp_5.as_pointer()) - .expect("out of range!") - .borrow() - .1 - .as_pointer() - }); - printf!( - b"receiver=%d hint=%d source=%d inserted=%d\n", - (*a.borrow()), - (*b.borrow()), - { (*v.borrow())[2_usize] }, - (index!(inserted, 2_usize).read()) - ); select_receiver.prefix_dec(); } } diff --git a/tests/unit/out/refcount/emplace_receiver_order.rs b/tests/unit/out/refcount/emplace_receiver_order.rs index 5b86707e11..1f85e96f87 100644 --- a/tests/unit/out/refcount/emplace_receiver_order.rs +++ b/tests/unit/out/refcount/emplace_receiver_order.rs @@ -21,62 +21,64 @@ fn main_0() -> i32 { { let mut bound: i32 = 0; 'loop_: while (bound < 2) { - let rows: Value>> = - Rc::new(RefCell::new(Vec::from([Vec::from([1, 2, 3])]))); - rows.with_mut(|__b0| { - if 2_usize > (*__b0).capacity() as usize { - let len_0 = (*__b0).len(); - (*__b0).reserve_exact(2_usize - len_0 as usize); - } - }); - let calls: Value = Rc::new(RefCell::new(0)); - if (bound != 0) { - let mut receiver: Ptr>> = - ({ select_rows_0((rows.as_pointer()), (calls.as_pointer())) }); - { - let mut __tmp_2 = { - { - let mut __tmp_0 = { rows.decay().offset(0_usize).decay() }; - let mut __tmp_1 = - { rows.decay().offset(0_usize).decay().offset((3) as isize) }; - let mut __v = Vec::new(); - let mut __it = (__tmp_0).clone(); - while __it != __tmp_1 { - __v.push((__it.iter_deref().read())); - __it.iter_inc(); + 'for_body: { + let rows: Value>> = + Rc::new(RefCell::new(Vec::from([Vec::from([1, 2, 3])]))); + rows.with_mut(|__b0| { + if 2_usize > (*__b0).capacity() as usize { + let len_0 = (*__b0).len(); + (*__b0).reserve_exact(2_usize - len_0 as usize); + } + }); + let calls: Value = Rc::new(RefCell::new(0)); + if (bound != 0) { + let mut receiver: Ptr>> = + ({ select_rows_0((rows.as_pointer()), (calls.as_pointer())) }); + { + let mut __tmp_2 = { + { + let mut __tmp_0 = { rows.decay().offset(0_usize).decay() }; + let mut __tmp_1 = + { rows.decay().offset(0_usize).decay().offset((3) as isize) }; + let mut __v = Vec::new(); + let mut __it = (__tmp_0).clone(); + while __it != __tmp_1 { + __v.push((__it.iter_deref().read())); + __it.iter_inc(); + } + __v } - __v - } + }; + receiver.with_mut(|__v: &mut Vec>| __v.push(__tmp_2)) }; - receiver.with_mut(|__v: &mut Vec>| __v.push(__tmp_2)) - }; - } else { - { - let mut __tmp_3 = - { ({ select_rows_0((rows.as_pointer()), (calls.as_pointer())) }) }; - let mut __tmp_6 = { - { - let mut __tmp_4 = { rows.decay().offset(0_usize).decay() }; - let mut __tmp_5 = - { rows.decay().offset(0_usize).decay().offset((3) as isize) }; - let mut __v = Vec::new(); - let mut __it = (__tmp_4).clone(); - while __it != __tmp_5 { - __v.push((__it.iter_deref().read())); - __it.iter_inc(); + } else { + { + let mut __tmp_3 = + { ({ select_rows_0((rows.as_pointer()), (calls.as_pointer())) }) }; + let mut __tmp_6 = { + { + let mut __tmp_4 = { rows.decay().offset(0_usize).decay() }; + let mut __tmp_5 = + { rows.decay().offset(0_usize).decay().offset((3) as isize) }; + let mut __v = Vec::new(); + let mut __it = (__tmp_4).clone(); + while __it != __tmp_5 { + __v.push((__it.iter_deref().read())); + __it.iter_inc(); + } + __v } - __v - } + }; + __tmp_3.with_mut(|__v: &mut Vec>| __v.push(__tmp_6)) }; - __tmp_3.with_mut(|__v: &mut Vec>| __v.push(__tmp_6)) - }; + } + printf!( + b"source=%d inserted=%d calls=%d\n", + (index!(elem!(rows.decay(), 0_usize), 2_usize).read()), + (index!(elem!(rows.decay(), 1_usize), 2_usize).read()), + (*calls.borrow()) + ); } - printf!( - b"source=%d inserted=%d calls=%d\n", - (index!(elem!(rows.decay(), 0_usize), 2_usize).read()), - (index!(elem!(rows.decay(), 1_usize), 2_usize).read()), - (*calls.borrow()) - ); bound.prefix_inc(); } } diff --git a/tests/unit/out/refcount/enum_increment.rs b/tests/unit/out/refcount/enum_increment.rs index f41d39862b..a397f0d937 100644 --- a/tests/unit/out/refcount/enum_increment.rs +++ b/tests/unit/out/refcount/enum_increment.rs @@ -20,7 +20,9 @@ fn main_0() -> i32 { { let mut c: color = color_RED; 'loop_: while ((c as u32) < ((color_COLOR_LAST as i32) as u32)) { - count.postfix_inc(); + 'for_body: { + count.postfix_inc(); + } c.postfix_inc(); } } diff --git a/tests/unit/out/refcount/fft.rs b/tests/unit/out/refcount/fft.rs index 8ba69d9f47..4cabd16d64 100644 --- a/tests/unit/out/refcount/fft.rs +++ b/tests/unit/out/refcount/fft.rs @@ -57,13 +57,15 @@ pub fn fft_3(a: Ptr>>>, mut N: i32) -> Option>>>, mut N: i32) -> Option>>>, mut N: i32) -> Option i32 { { let mut i: i32 = 0; 'loop_: while (i < N) { - let __rhs = Complex { - re: ((i as f64) + 1_f64), - img: 0_f64, - }; - ({ (*a.borrow()).decay().offset((i as usize)) }).write(__rhs); + 'for_body: { + let __rhs = Complex { + re: ((i as f64) + 1_f64), + img: 0_f64, + }; + ({ (*a.borrow()).decay().offset((i as usize)) }).write(__rhs); + } i.postfix_inc(); } } @@ -180,10 +190,12 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < N) { - let __rhs = ((b.decay().offset((i as usize)).with(|__s| __s.re).round()) as i32); - reals.decay().offset((i as usize)).write(__rhs); - let __rhs = ((b.decay().offset((i as usize)).with(|__s| __s.img).round()) as i32); - imgs.decay().offset((i as usize)).write(__rhs); + 'for_body: { + let __rhs = ((b.decay().offset((i as usize)).with(|__s| __s.re).round()) as i32); + reals.decay().offset((i as usize)).write(__rhs); + let __rhs = ((b.decay().offset((i as usize)).with(|__s| __s.img).round()) as i32); + imgs.decay().offset((i as usize)).write(__rhs); + } i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/field_array_elem_ptr.rs b/tests/unit/out/refcount/field_array_elem_ptr.rs index 835c43bb0d..72015b408c 100644 --- a/tests/unit/out/refcount/field_array_elem_ptr.rs +++ b/tests/unit/out/refcount/field_array_elem_ptr.rs @@ -45,7 +45,9 @@ pub fn sum_0(mut p: Ptr, mut n: i32) -> i32 { { let mut i: i32 = 0; 'loop_: while (i < n) { - s += { (elem!(p, i).read()) }; + 'for_body: { + s += { (elem!(p, i).read()) }; + } i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/field_pointers.rs b/tests/unit/out/refcount/field_pointers.rs index 205ff8ccdf..22fb971951 100644 --- a/tests/unit/out/refcount/field_pointers.rs +++ b/tests/unit/out/refcount/field_pointers.rs @@ -125,7 +125,9 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < 3) { - elem!(name, i).write({ (((('a' as i8) as i32) + i) as i8) }); + 'for_body: { + elem!(name, i).write({ (((('a' as i8) as i32) + i) as i8) }); + } i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/field_reinterpret_write_through.rs b/tests/unit/out/refcount/field_reinterpret_write_through.rs index fe994b60da..5fe2ac720d 100644 --- a/tests/unit/out/refcount/field_reinterpret_write_through.rs +++ b/tests/unit/out/refcount/field_reinterpret_write_through.rs @@ -48,7 +48,9 @@ pub fn set_bytes_0(mut p: Ptr, mut n: usize, mut v: u8) { { let mut i: usize = 0_usize; 'loop_: while (i < n) { - elem!(p, i).write({ v }); + 'for_body: { + elem!(p, i).write({ v }); + } i.postfix_inc(); } } @@ -57,8 +59,10 @@ pub fn all_bytes_1(mut p: Ptr, mut n: usize, mut v: u8) -> i32 { { let mut i: usize = 0_usize; 'loop_: while (i < n) { - if ({ ((elem!(p, i).read()) as i32) } != { (v as i32) }) { - return 0; + 'for_body: { + if ({ ((elem!(p, i).read()) as i32) } != { (v as i32) }) { + return 0; + } } i.postfix_inc(); } 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 416ee397dc..cf6b7a8bc4 100644 --- a/tests/unit/out/refcount/first_field_ptr_covers_struct.rs +++ b/tests/unit/out/refcount/first_field_ptr_covers_struct.rs @@ -62,7 +62,9 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < 4) { - elem!(bz, i).write(1_u8); + 'for_body: { + elem!(bz, i).write(1_u8); + } i.postfix_inc(); } } diff --git a/tests/unit/out/refcount/fn_ptr_stdlib_compare.rs b/tests/unit/out/refcount/fn_ptr_stdlib_compare.rs index faeec27385..1e474c9c76 100644 --- a/tests/unit/out/refcount/fn_ptr_stdlib_compare.rs +++ b/tests/unit/out/refcount/fn_ptr_stdlib_compare.rs @@ -63,14 +63,18 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < 10) { - assert!(({ (((*buf.borrow())[(i) as usize] as i32) == 0) })); + 'for_body: { + assert!(({ (((*buf.borrow())[(i) as usize] as i32) == 0) })); + } i.prefix_inc(); } } { let mut i: i32 = 10; 'loop_: while (i < 16) { - assert!(({ (((*buf.borrow())[(i) as usize] as i32) == (('X' as i8) as i32)) })); + 'for_body: { + assert!(({ (((*buf.borrow())[(i) as usize] as i32) == (('X' as i8) as i32)) })); + } i.prefix_inc(); } } @@ -107,14 +111,18 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < 10) { - assert!(({ (((*buf.borrow())[(i) as usize] as i32) == 0) })); + 'for_body: { + assert!(({ (((*buf.borrow())[(i) as usize] as i32) == 0) })); + } i.prefix_inc(); } } { let mut i: i32 = 10; 'loop_: while (i < 16) { - assert!(({ (((*buf.borrow())[(i) as usize] as i32) == (('X' as i8) as i32)) })); + 'for_body: { + assert!(({ (((*buf.borrow())[(i) as usize] as i32) == (('X' as i8) as i32)) })); + } i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/for_body_destructor.rs b/tests/unit/out/refcount/for_body_destructor.rs new file mode 100644 index 0000000000..60ff9056a1 --- /dev/null +++ b/tests/unit/out/refcount/for_body_destructor.rs @@ -0,0 +1,198 @@ +extern crate libcc2rs; +use libcc2rs::*; +use std::cell::RefCell; +use std::collections::BTreeMap; +use std::io::prelude::*; +use std::io::{Read, Seek, Write}; +use std::os::fd::AsFd; +use std::rc::{Rc, Weak}; +#[derive(Clone, Record, ByteRepr, VaArg, FnPtrArg, Destructor, Default)] +#[byte_size(4)] +pub struct Guard { + #[offset(0)] + pub digit: i32, +} +pub fn step_0(i: Ptr) { + printf!(b"9 "); + i.with_mut(|__v| { + __v.prefix_inc(); + }); +} +pub fn main() { + __cpp2rust_init_globals(); + libcc2rs::cpp2rust_exit(main_0()); +} +fn main_0() -> i32 { + printf!(b"normal/continue: "); + { + let i: Value = Rc::new(RefCell::new(0)); + 'loop_: while ((*i.borrow()) < 2) { + 'for_body: { + let first: Value = Rc::new(RefCell::new(Guard { digit: 1 })); + let _dtor_first = + std::mem::DropGuard::new(first.clone(), |__p| __p.as_pointer().destructor()); + let second: Value = Rc::new(RefCell::new(Guard { digit: 2 })); + let _dtor_second = + std::mem::DropGuard::new(second.clone(), |__p| __p.as_pointer().destructor()); + if ((*i.borrow()) == 0) { + break 'for_body; + } + } + ({ step_0(i.as_pointer()) }); + } + } + printf!(b"\nbreak: "); + { + let i: Value = Rc::new(RefCell::new(0)); + 'loop_: while ((*i.borrow()) < 2) { + 'for_body: { + let g: Value = Rc::new(RefCell::new(Guard { digit: 3 })); + let _dtor_g = + std::mem::DropGuard::new(g.clone(), |__p| __p.as_pointer().destructor()); + break 'loop_; + } + ({ step_0(i.as_pointer()) }); + } + } + printf!(b"\nnested for: "); + { + let i: Value = Rc::new(RefCell::new(0)); + 'loop_: while ((*i.borrow()) < 1) { + 'for_body: { + let outer: Value = Rc::new(RefCell::new(Guard { digit: 4 })); + let _dtor_outer = + std::mem::DropGuard::new(outer.clone(), |__p| __p.as_pointer().destructor()); + { + let j: Value = Rc::new(RefCell::new(0)); + 'loop_: while ((*j.borrow()) < 2) { + 'for_body: { + let inner: Value = Rc::new(RefCell::new(Guard { digit: 5 })); + let _dtor_inner = std::mem::DropGuard::new(inner.clone(), |__p| { + __p.as_pointer().destructor() + }); + if ((*j.borrow()) == 0) { + break 'for_body; + } + break 'loop_; + } + ({ step_0(j.as_pointer()) }); + } + } + break 'for_body; + } + ({ step_0(i.as_pointer()) }); + } + } + printf!(b"\ninner while/do/range: "); + { + let i: Value = Rc::new(RefCell::new(0)); + 'loop_: while ((*i.borrow()) < 1) { + 'for_body: { + let outer: Value = Rc::new(RefCell::new(Guard { digit: 4 })); + let _dtor_outer = + std::mem::DropGuard::new(outer.clone(), |__p| __p.as_pointer().destructor()); + let mut j: i32 = 0; + 'loop_: while ((*j.prefix_inc()) < 3) { + let inner: Value = Rc::new(RefCell::new(Guard { digit: 5 })); + let _dtor_inner = std::mem::DropGuard::new(inner.clone(), |__p| { + __p.as_pointer().destructor() + }); + if (j == 1) { + continue 'loop_; + } + break; + } + let mut __do_while = true; + 'loop_: while __do_while || (false) { + __do_while = false; + let inner: Value = Rc::new(RefCell::new(Guard { digit: 6 })); + let _dtor_inner = std::mem::DropGuard::new(inner.clone(), |__p| { + __p.as_pointer().destructor() + }); + continue 'loop_; + } + let values: Value> = Rc::new(RefCell::new(Box::new([1, 2]))); + 'loop_: for value in + IterRange::new(values.decay(), values.decay().offset((2_i64) as isize)) + { + let mut value: i32 = (value.read()); + let inner: Value = Rc::new(RefCell::new(Guard { digit: value })); + let _dtor_inner = std::mem::DropGuard::new(inner.clone(), |__p| { + __p.as_pointer().destructor() + }); + if (value == 1) { + continue 'loop_; + } + break; + } + break 'for_body; + } + ({ step_0(i.as_pointer()) }); + } + } + printf!(b"\ncondition: "); + { + let mut i: i32 = 2; + 'loop_: loop { + let condition: Value = Rc::new(RefCell::new(Guard { digit: i })); + let _dtor_condition = + std::mem::DropGuard::new(condition.clone(), |__p| __p.as_pointer().destructor()); + if !({ GuardImpl::to_bool(&condition.as_pointer()) }) { + break; + } + 'for_body: { + let body: Value = Rc::new(RefCell::new(Guard { digit: 4 })); + let _dtor_body = + std::mem::DropGuard::new(body.clone(), |__p| __p.as_pointer().destructor()); + if (i == 2) { + break 'for_body; + } + } + { + i.prefix_dec(); + printf!(b"inc%d ", { (*condition.borrow()).digit }) + }; + } + } + printf!(b"\ninit/noncompound: "); + let i: Value = Rc::new(RefCell::new(0)); + { + let init: Value = Rc::new(RefCell::new(Guard { digit: 5 })); + let _dtor_init = + std::mem::DropGuard::new(init.clone(), |__p| __p.as_pointer().destructor()); + 'loop_: while ((*i.borrow()) < 2) { + 'for_body: { + let body: Value = Rc::new(RefCell::new(Guard { digit: 6 })); + let _dtor_body = + std::mem::DropGuard::new(body.clone(), |__p| __p.as_pointer().destructor()); + } + ({ step_0(i.as_pointer()) }); + } + } + printf!(b"\nno increment: "); + { + let mut j: i32 = 0; + 'loop_: while (j < 2) { + let g: Value = Rc::new(RefCell::new(Guard { + digit: (*j.prefix_inc()), + })); + let _dtor_g = std::mem::DropGuard::new(g.clone(), |__p| __p.as_pointer().destructor()); + continue 'loop_; + } + } + printf!(b"\n"); + return 0; +} +pub trait GuardImpl { + fn destructor(&self); + fn to_bool(&self) -> bool; +} +impl GuardImpl for Ptr { + fn destructor(&self) { + printf!(b"%d ", (*self).with(|__s| __s.digit)); + } + fn to_bool(&self) -> bool { + return ((*self).with(|__s| __s.digit) != 0); + } +} +pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/foreach.rs b/tests/unit/out/refcount/foreach.rs index 5ebd772554..ba992d1209 100644 --- a/tests/unit/out/refcount/foreach.rs +++ b/tests/unit/out/refcount/foreach.rs @@ -15,10 +15,12 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < 10) { - { - let a0_clone = i.clone(); - (*v.borrow_mut()).push(a0_clone) - }; + 'for_body: { + { + let a0_clone = i.clone(); + (*v.borrow_mut()).push(a0_clone) + }; + } i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/foreach_map.rs b/tests/unit/out/refcount/foreach_map.rs index 613477c0ea..8602e41ab2 100644 --- a/tests/unit/out/refcount/foreach_map.rs +++ b/tests/unit/out/refcount/foreach_map.rs @@ -16,7 +16,10 @@ fn main_0() -> i32 { let i: Value = Rc::new(RefCell::new(0)); let mut k: i32 = 100; 'loop_: while ((*i.borrow()) < 100) { - ({ (*m.borrow_mut()).subscript(i.as_pointer(), || 0_f64) }).write(((k as f64) / 2_f64)); + 'for_body: { + ({ (*m.borrow_mut()).subscript(i.as_pointer(), || 0_f64) }) + .write(((k as f64) / 2_f64)); + } { (*i.borrow_mut()).prefix_inc(); k.prefix_dec() diff --git a/tests/unit/out/refcount/global_pointers.rs b/tests/unit/out/refcount/global_pointers.rs index c4a7a8477c..d8c3c88775 100644 --- a/tests/unit/out/refcount/global_pointers.rs +++ b/tests/unit/out/refcount/global_pointers.rs @@ -50,23 +50,25 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < 2) { - assert!( - ({ + 'for_body: { + assert!( ({ - (*entries_1.with(Value::clone).borrow())[(i) as usize] - .p - .clone() + ({ + (*entries_1.with(Value::clone).borrow())[(i) as usize] + .p + .clone() + }) + .is_null() + }) + ); + assert!( + ({ + let __idx0 = (i) as usize; + arr_of_pointers_2.with(|rc| rc.borrow()[__idx0].clone()) }) .is_null() - }) - ); - assert!( - ({ - let __idx0 = (i) as usize; - arr_of_pointers_2.with(|rc| rc.borrow()[__idx0].clone()) - }) - .is_null() - ); + ); + } i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/goto_cleanup.rs b/tests/unit/out/refcount/goto_cleanup.rs index 9069e93c76..85ba2ab652 100644 --- a/tests/unit/out/refcount/goto_cleanup.rs +++ b/tests/unit/out/refcount/goto_cleanup.rs @@ -33,11 +33,13 @@ pub fn from_loop_1(mut n: i32) -> i32 { { let mut i: i32 = 0; 'loop_: while (i < n) { - if (i == 3) { - ret = 7; - goto!('out); + 'for_body: { + if (i == 3) { + ret = 7; + goto!('out); + } + ret += i; } - ret += i; i.postfix_inc(); } } diff --git a/tests/unit/out/refcount/goto_loop_control.rs b/tests/unit/out/refcount/goto_loop_control.rs index 684e4749f0..3e9e4bf8a6 100644 --- a/tests/unit/out/refcount/goto_loop_control.rs +++ b/tests/unit/out/refcount/goto_loop_control.rs @@ -11,21 +11,22 @@ pub fn loopctl_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < 5) { - goto_block!({ - '__entry: { - if (i == 1) { - i.postfix_inc(); - continue 'loop_; + 'for_body: { + goto_block!({ + '__entry: { + if (i == 1) { + break 'for_body; + } + if (i == 4) { + break 'loop_; + } + goto!('add); } - if (i == 4) { - break; + 'add: { + sum += 1; } - goto!('add); - } - 'add: { - sum += 1; - } - }); + }); + } i.postfix_inc(); } } diff --git a/tests/unit/out/refcount/goto_nested_label.rs b/tests/unit/out/refcount/goto_nested_label.rs index 88ffbc82f7..0f9f8b06eb 100644 --- a/tests/unit/out/refcount/goto_nested_label.rs +++ b/tests/unit/out/refcount/goto_nested_label.rs @@ -11,23 +11,25 @@ pub fn scan_0(mut n: i32) -> i32 { { let mut i: i32 = 0; 'loop_: while (i < n) { - let mut j: i32 = 0_i32; - goto_block!({ - '__entry: { - j = 0; - 'loop_: while (j < 10) { - if (j == 5) { - goto!('next); + 'for_body: { + let mut j: i32 = 0_i32; + goto_block!({ + '__entry: { + j = 0; + 'loop_: while (j < 10) { + if (j == 5) { + goto!('next); + } + total += 1; + j.postfix_inc(); } - total += 1; - j.postfix_inc(); + total += 100; } - total += 100; - } - 'next: { - total += 1000; - } - }); + 'next: { + total += 1000; + } + }); + } i.postfix_inc(); } } diff --git a/tests/unit/out/refcount/goto_nested_loop_control.rs b/tests/unit/out/refcount/goto_nested_loop_control.rs index 9e7ccb7323..2934556f6d 100644 --- a/tests/unit/out/refcount/goto_nested_loop_control.rs +++ b/tests/unit/out/refcount/goto_nested_loop_control.rs @@ -16,23 +16,25 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < 3) { - goto_block!({ - '__entry: {} - 'outer: { - visits.postfix_inc(); - { - goto_block!({ - '__entry: {} - 'inner: { - if (i == 0) { - break; + 'for_body: { + goto_block!({ + '__entry: {} + 'outer: { + visits.postfix_inc(); + { + goto_block!({ + '__entry: {} + 'inner: { + if (i == 0) { + break 'loop_; + } } - } - }); + }); + } + tail.postfix_inc(); } - tail.postfix_inc(); - } - }); + }); + } i.postfix_inc(); } } @@ -43,37 +45,39 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < 3) { - switch!(match i { - __v if __v == 0 => { - { - goto_block!({ - '__entry: {} - 'switch_outer: { - visits.postfix_inc(); - { - goto_block!({ - '__entry: {} - 'switch_inner: { - if (i == 0) { - break; + 'for_body: { + switch!(match i { + __v if __v == 0 => { + { + goto_block!({ + '__entry: {} + 'switch_outer: { + visits.postfix_inc(); + { + goto_block!({ + '__entry: {} + 'switch_inner: { + if (i == 0) { + break; + } } - } - }); + }); + } + tail.postfix_inc(); } - tail.postfix_inc(); - } - }); + }); + } } - } - __v if __v == 1 => { - tail += 10; - break; - } - _ => { - tail += 100; - break; - } - }); + __v if __v == 1 => { + tail += 10; + break; + } + _ => { + tail += 100; + break; + } + }); + } i.postfix_inc(); } } diff --git a/tests/unit/out/refcount/huffman.rs b/tests/unit/out/refcount/huffman.rs index 87df5c4798..47ef40b9c5 100644 --- a/tests/unit/out/refcount/huffman.rs +++ b/tests/unit/out/refcount/huffman.rs @@ -134,34 +134,36 @@ pub fn CollectCode_3( { let mut i: i32 = 0; 'loop_: while (i < top) { - let __rhs = ((({ - (*out.upgrade().deref()) - .decay() - .offset(((next.read()) as usize)) - }) - .read()) - * 10); - ({ - (*out.upgrade().deref()) - .decay() - .offset(((next.read()) as usize)) - }) - .write(__rhs); - let __rhs = + 'for_body: { + let __rhs = ((({ + (*out.upgrade().deref()) + .decay() + .offset(((next.read()) as usize)) + }) + .read()) + * 10); ({ - (({ - (*out.upgrade().deref()) - .decay() - .offset(((next.read()) as usize)) - }) - .read()) - } + { (({ (*arr.upgrade().deref()).decay().offset((i as usize)) }).read()) }); - ({ - (*out.upgrade().deref()) - .decay() - .offset(((next.read()) as usize)) - }) - .write(__rhs); + (*out.upgrade().deref()) + .decay() + .offset(((next.read()) as usize)) + }) + .write(__rhs); + let __rhs = + ({ + (({ + (*out.upgrade().deref()) + .decay() + .offset(((next.read()) as usize)) + }) + .read()) + } + { (({ (*arr.upgrade().deref()).decay().offset((i as usize)) }).read()) }); + ({ + (*out.upgrade().deref()) + .decay() + .offset(((next.read()) as usize)) + }) + .write(__rhs); + } i.prefix_inc(); } } @@ -263,10 +265,12 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < size) { - let __rhs = arr1[(i) as usize]; - ({ (*data.borrow()).decay().offset((i as usize)) }).write(__rhs); - let __rhs = arr2[(i) as usize]; - ({ (*freq.borrow()).decay().offset((i as usize)) }).write(__rhs); + 'for_body: { + let __rhs = arr1[(i) as usize]; + ({ (*data.borrow()).decay().offset((i as usize)) }).write(__rhs); + let __rhs = arr2[(i) as usize]; + ({ (*freq.borrow()).decay().offset((i as usize)) }).write(__rhs); + } i.prefix_inc(); } } @@ -429,28 +433,32 @@ impl MinHeapImpl for Ptr { { let mut i: i32 = 0; 'loop_: while (i < n) { - (*self) - .with(|__s| __s.arr.clone()) - .decay() - .offset((field!((*self), size).with_mut(|__v| __v.postfix_inc()) as usize)) - .write( - ({ - let _data: i8 = - (({ (*data.upgrade().deref()).decay().offset((i as usize)) }) - .read()); - let _freq: i32 = - (({ (*freq.upgrade().deref()).decay().offset((i as usize)) }) - .read()); - MinHeapImpl::Alloc(self, _data, _freq) - }), - ); + 'for_body: { + (*self) + .with(|__s| __s.arr.clone()) + .decay() + .offset((field!((*self), size).with_mut(|__v| __v.postfix_inc()) as usize)) + .write( + ({ + let _data: i8 = + (({ (*data.upgrade().deref()).decay().offset((i as usize)) }) + .read()); + let _freq: i32 = + (({ (*freq.upgrade().deref()).decay().offset((i as usize)) }) + .read()); + MinHeapImpl::Alloc(self, _data, _freq) + }), + ); + } i.prefix_inc(); } } { let mut i: i32 = (((*self).with(|__s| __s.size) - 2) / 2); 'loop_: while (i >= 0) { - ({ MinHeapImpl::Heapify(self, i) }); + 'for_body: { + ({ MinHeapImpl::Heapify(self, i) }); + } i.prefix_dec(); } } diff --git a/tests/unit/out/refcount/ifaddrs.rs b/tests/unit/out/refcount/ifaddrs.rs index ba2ef6acf7..4923e3a625 100644 --- a/tests/unit/out/refcount/ifaddrs.rs +++ b/tests/unit/out/refcount/ifaddrs.rs @@ -40,54 +40,55 @@ fn main_0() -> i32 { let mut ifa: Ptr = Ptr::::null(); ifa = (*list.borrow()).clone(); 'loop_: while (!((ifa).is_null())) { - assert!((!((ifa.with(|__s| __s.ifa_name.clone())).is_null()))); - if ((ifa.with(|__s| __s.ifa_addr.clone())).is_null()) { - ifa = { ifa.with(|__s| __s.ifa_next.clone()) }; - continue 'loop_; - } - if ((ifa - .with(|__s| __s.ifa_addr.clone()) - .with(|__s| __s.sa_family) as i32) - != libc::AF_INET) - { - ifa = { ifa.with(|__s| __s.ifa_next.clone()) }; - continue 'loop_; - } - let mut sin: Ptr = ifa - .with(|__s| __s.ifa_addr.clone()) - .reinterpret_cast::(); - let lo_be: Value> = Rc::new(RefCell::new(Box::new([127_u8, 0_u8, 0_u8, 1_u8]))); - if ((field_ptr!(sin, sin_addr)) - .to_any() - .memcmp(&(lo_be.decay()).to_any(), 4_usize) - == 0) - { - found_loopback = 1; - assert!((ifa.with(|__s| __s.ifa_flags) != 0_u32)); - assert!((!((ifa.with(|__s| __s.ifa_netmask.clone())).is_null()))); - let mut mask: Ptr = ifa - .with(|__s| __s.ifa_netmask.clone()) + 'for_body: { + assert!((!((ifa.with(|__s| __s.ifa_name.clone())).is_null()))); + if ((ifa.with(|__s| __s.ifa_addr.clone())).is_null()) { + break 'for_body; + } + if ((ifa + .with(|__s| __s.ifa_addr.clone()) + .with(|__s| __s.sa_family) as i32) + != libc::AF_INET) + { + break 'for_body; + } + let mut sin: Ptr = ifa + .with(|__s| __s.ifa_addr.clone()) .reinterpret_cast::(); - let mask_be: Value> = - Rc::new(RefCell::new(Box::new([255_u8, 0_u8, 0_u8, 0_u8]))); - assert!( - ((field_ptr!(mask, sin_addr)) - .to_any() - .memcmp(&(mask_be.decay()).to_any(), 4_usize) - == 0) - ); - assert!( - (match ifa - .with(|__s| __s.ifa_name.clone()) - .with_c_bytes(nix::net::if_::if_nametoindex) - { - Ok(__i) => __i, - Err(__e) => { - libcc2rs::cpp2rust_errno().write(__e as i32); - 0 - } - } > 0_u32) - ); + let lo_be: Value> = + Rc::new(RefCell::new(Box::new([127_u8, 0_u8, 0_u8, 1_u8]))); + if ((field_ptr!(sin, sin_addr)) + .to_any() + .memcmp(&(lo_be.decay()).to_any(), 4_usize) + == 0) + { + found_loopback = 1; + assert!((ifa.with(|__s| __s.ifa_flags) != 0_u32)); + assert!((!((ifa.with(|__s| __s.ifa_netmask.clone())).is_null()))); + let mut mask: Ptr = + ifa.with(|__s| __s.ifa_netmask.clone()) + .reinterpret_cast::(); + let mask_be: Value> = + Rc::new(RefCell::new(Box::new([255_u8, 0_u8, 0_u8, 0_u8]))); + assert!( + ((field_ptr!(mask, sin_addr)) + .to_any() + .memcmp(&(mask_be.decay()).to_any(), 4_usize) + == 0) + ); + assert!( + (match ifa + .with(|__s| __s.ifa_name.clone()) + .with_c_bytes(nix::net::if_::if_nametoindex) + { + Ok(__i) => __i, + Err(__e) => { + libcc2rs::cpp2rust_errno().write(__e as i32); + 0 + } + } > 0_u32) + ); + } } ifa = { ifa.with(|__s| __s.ifa_next.clone()) }; } diff --git a/tests/unit/out/refcount/init_list.rs b/tests/unit/out/refcount/init_list.rs index 22d97bd9dd..f161ecffc0 100644 --- a/tests/unit/out/refcount/init_list.rs +++ b/tests/unit/out/refcount/init_list.rs @@ -68,7 +68,9 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < 4) { - assert!((sevens[(i) as usize].v == 7)); + 'for_body: { + assert!((sevens[(i) as usize].v == 7)); + } i.postfix_inc(); } } diff --git a/tests/unit/out/refcount/inline_container_fields.rs b/tests/unit/out/refcount/inline_container_fields.rs index 70bb089c17..6f97f26588 100644 --- a/tests/unit/out/refcount/inline_container_fields.rs +++ b/tests/unit/out/refcount/inline_container_fields.rs @@ -95,7 +95,9 @@ pub fn sum_0(mut p: Ptr, mut n: i32) -> i32 { { let mut i: i32 = 0; 'loop_: while (i < n) { - s += { (elem!(p, i).read()) }; + 'for_body: { + s += { (elem!(p, i).read()) }; + } i.prefix_inc(); } } @@ -105,11 +107,15 @@ pub fn fill_1(mut s: Ptr) { { let mut i: i32 = 0; 'loop_: while (i < 2) { - { - let mut j: i32 = 0; - 'loop_: while (j < 3) { - index!(index!(field!(s, grid), i), j).write({ ((i * 3) + j) }); - j.prefix_inc(); + 'for_body: { + { + let mut j: i32 = 0; + 'loop_: while (j < 3) { + 'for_body: { + index!(index!(field!(s, grid), i), j).write({ ((i * 3) + j) }); + } + j.prefix_inc(); + } } } i.prefix_inc(); @@ -120,12 +126,14 @@ pub fn fill_1(mut s: Ptr) { { let mut i: i32 = 0; 'loop_: while (i < 3) { - let __rhs = i; - field!(vec_elem!(s, elems, (i as usize)), id).write(__rhs); - let __rhs = (10 * i); - index!(field!(vec_elem!(s, elems, (i as usize)), hist), i).write(__rhs); - field!(vec_elem!(s, elems, (i as usize)), coeffs) - .with_mut(|__v: &mut Vec| __v.resize(4_usize, (i as i16))); + 'for_body: { + let __rhs = i; + field!(vec_elem!(s, elems, (i as usize)), id).write(__rhs); + let __rhs = (10 * i); + index!(field!(vec_elem!(s, elems, (i as usize)), hist), i).write(__rhs); + field!(vec_elem!(s, elems, (i as usize)), coeffs) + .with_mut(|__v: &mut Vec| __v.resize(4_usize, (i as i16))); + } i.prefix_inc(); } } @@ -204,10 +212,12 @@ fn main_0() -> i32 { { let mut k: i32 = 0; 'loop_: while (k < 4) { - { - let __rhs = { k }; - elem!(h, k).with_mut(|__v| *__v = *__v + __rhs) - }; + 'for_body: { + { + let __rhs = { k }; + elem!(h, k).with_mut(|__v| *__v = *__v + __rhs) + }; + } k.prefix_inc(); } } diff --git a/tests/unit/out/refcount/kruskal.rs b/tests/unit/out/refcount/kruskal.rs index 998e9db941..94fb576e50 100644 --- a/tests/unit/out/refcount/kruskal.rs +++ b/tests/unit/out/refcount/kruskal.rs @@ -22,11 +22,14 @@ pub fn partition_0(arr: Ptr>>>, mut start: i32, mut end { let mut i: i32 = (start + 1); 'loop_: while (i <= end) { - if ({ - ({ (*arr.upgrade().deref()).decay().offset((i as usize)) }).with(|__s| __s.weight) - } <= { pivot.with(|__s| __s.weight) }) - { - count.postfix_inc(); + 'for_body: { + if ({ + ({ (*arr.upgrade().deref()).decay().offset((i as usize)) }) + .with(|__s| __s.weight) + } <= { pivot.with(|__s| __s.weight) }) + { + count.postfix_inc(); + } } i.prefix_inc(); } @@ -178,26 +181,28 @@ pub fn MSTKruskal_2(graph: Ptr) -> f64 { { let mut i: i32 = 0; 'loop_: while ({ i } < { graph.with(|__s| __s.E) }) { - let mut x: i32 = graph - .with(|__s| __s.edges.clone()) - .decay() - .offset((i as usize)) - .with(|__s| __s.u); - let mut y: i32 = graph - .with(|__s| __s.edges.clone()) - .decay() - .offset((i as usize)) - .with(|__s| __s.v); - let mut w: f64 = graph - .with(|__s| __s.edges.clone()) - .decay() - .offset((i as usize)) - .with(|__s| __s.weight); - if (({ DisjointSetImpl::find(&set.as_pointer(), x) }) - != ({ DisjointSetImpl::find(&set.as_pointer(), y) })) - { - ({ DisjointSetImpl::merge(&set.as_pointer(), x, y) }); - total_weight += w; + 'for_body: { + let mut x: i32 = graph + .with(|__s| __s.edges.clone()) + .decay() + .offset((i as usize)) + .with(|__s| __s.u); + let mut y: i32 = graph + .with(|__s| __s.edges.clone()) + .decay() + .offset((i as usize)) + .with(|__s| __s.v); + let mut w: f64 = graph + .with(|__s| __s.edges.clone()) + .decay() + .offset((i as usize)) + .with(|__s| __s.weight); + if (({ DisjointSetImpl::find(&set.as_pointer(), x) }) + != ({ DisjointSetImpl::find(&set.as_pointer(), y) })) + { + ({ DisjointSetImpl::merge(&set.as_pointer(), x, y) }); + total_weight += w; + } } i.prefix_inc(); } @@ -275,17 +280,19 @@ impl DisjointSetImpl for Ptr { { let mut i: i32 = 0; 'loop_: while (i < (*self).with(|__s| __s.n)) { - let __rhs = i; - (*self) - .with(|__s| __s.parent.clone()) - .decay() - .offset((i as usize)) - .write(__rhs); - (*self) - .with(|__s| __s.rank.clone()) - .decay() - .offset((i as usize)) - .write(1); + 'for_body: { + let __rhs = i; + (*self) + .with(|__s| __s.parent.clone()) + .decay() + .offset((i as usize)) + .write(__rhs); + (*self) + .with(|__s| __s.rank.clone()) + .decay() + .offset((i as usize)) + .write(1); + } i.postfix_inc(); } } diff --git a/tests/unit/out/refcount/lambda_immediate_init.rs b/tests/unit/out/refcount/lambda_immediate_init.rs index afffb225f0..b8c8d87ea3 100644 --- a/tests/unit/out/refcount/lambda_immediate_init.rs +++ b/tests/unit/out/refcount/lambda_immediate_init.rs @@ -43,7 +43,9 @@ thread_local!( { let mut i: i32 = 1; 'loop_: while (i <= 4) { - s += i; + 'for_body: { + s += i; + } i.postfix_inc(); } } diff --git a/tests/unit/out/refcount/lambda_to_fn_ptr.rs b/tests/unit/out/refcount/lambda_to_fn_ptr.rs index 3ee5bc08b6..8052afb745 100644 --- a/tests/unit/out/refcount/lambda_to_fn_ptr.rs +++ b/tests/unit/out/refcount/lambda_to_fn_ptr.rs @@ -83,7 +83,9 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < (*n.borrow())) { - s += (*ap.borrow_mut()).arg::(); + 'for_body: { + s += (*ap.borrow_mut()).arg::(); + } i.postfix_inc(); } }; diff --git a/tests/unit/out/refcount/linked_list.rs b/tests/unit/out/refcount/linked_list.rs index e6a0967fbe..70e04b4246 100644 --- a/tests/unit/out/refcount/linked_list.rs +++ b/tests/unit/out/refcount/linked_list.rs @@ -20,7 +20,9 @@ pub fn Find_0(mut head: Ptr, mut idx: i32) -> Ptr { { let mut i: i32 = 0; 'loop_: while (i < idx) { - curr = { curr.with(|__s| __s.next.clone()) }; + 'for_body: { + curr = { curr.with(|__s| __s.next.clone()) }; + } i.postfix_inc(); } } diff --git a/tests/unit/out/refcount/malloc_realloc_free.rs b/tests/unit/out/refcount/malloc_realloc_free.rs index 3e2299611f..64fdb20bd2 100644 --- a/tests/unit/out/refcount/malloc_realloc_free.rs +++ b/tests/unit/out/refcount/malloc_realloc_free.rs @@ -26,7 +26,9 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < 4) { - elem!(arr, i).write({ (i * 10) }); + 'for_body: { + elem!(arr, i).write({ (i * 10) }); + } i.postfix_inc(); } } @@ -57,7 +59,9 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < 4) { - assert!(((elem!(zeros, i).read()) == 0)); + 'for_body: { + assert!(((elem!(zeros, i).read()) == 0)); + } i.postfix_inc(); } } @@ -84,7 +88,9 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < 4) { - elem!(arr, i).write({ (i * 10) }); + 'for_body: { + elem!(arr, i).write({ (i * 10) }); + } i.postfix_inc(); } } @@ -116,7 +122,9 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < 4) { - assert!(((elem!(zeros, i).read()) == 0)); + 'for_body: { + assert!(((elem!(zeros, i).read()) == 0)); + } i.postfix_inc(); } } diff --git a/tests/unit/out/refcount/map-reallocation.rs b/tests/unit/out/refcount/map-reallocation.rs index 35d272a190..bd01da73b4 100644 --- a/tests/unit/out/refcount/map-reallocation.rs +++ b/tests/unit/out/refcount/map-reallocation.rs @@ -47,16 +47,20 @@ fn main_0() -> i32 { { let i: Value = Rc::new(RefCell::new(0)); 'loop_: while ((*i.borrow()) < (*sentinel.borrow())) { - let __rhs = (*i.borrow()); - ({ (*m.borrow_mut()).subscript(i.as_pointer(), || 0_i32) }).write(__rhs); + 'for_body: { + let __rhs = (*i.borrow()); + ({ (*m.borrow_mut()).subscript(i.as_pointer(), || 0_i32) }).write(__rhs); + } (*i.borrow_mut()).prefix_inc(); } } { let i: Value = Rc::new(RefCell::new(((*sentinel.borrow()) + 1))); 'loop_: while ((*i.borrow()) <= N) { - let __rhs = (*i.borrow()); - ({ (*m.borrow_mut()).subscript(i.as_pointer(), || 0_i32) }).write(__rhs); + 'for_body: { + let __rhs = (*i.borrow()); + ({ (*m.borrow_mut()).subscript(i.as_pointer(), || 0_i32) }).write(__rhs); + } (*i.borrow_mut()).prefix_inc(); } } diff --git a/tests/unit/out/refcount/map.rs b/tests/unit/out/refcount/map.rs index 57d8f5252a..73ceea07ab 100644 --- a/tests/unit/out/refcount/map.rs +++ b/tests/unit/out/refcount/map.rs @@ -494,41 +494,49 @@ fn main_0() -> i32 { { let mut i: u32 = 60_u32; 'loop_: while (i > 30_u32) { - { - let __a1 = (i as i32); - (*indexes.borrow_mut()).push(__a1) - }; + 'for_body: { + { + let __a1 = (i as i32); + (*indexes.borrow_mut()).push(__a1) + }; + } i.prefix_dec(); } } { let mut i: u32 = 100_u32; 'loop_: while (i > 60_u32) { - { - let __a1 = (i as i32); - (*indexes.borrow_mut()).push(__a1) - }; + 'for_body: { + { + let __a1 = (i as i32); + (*indexes.borrow_mut()).push(__a1) + }; + } i.prefix_dec(); } } { let mut i: u32 = 30_u32; 'loop_: while (i > 0_u32) { - { - let __a1 = (i as i32); - (*indexes.borrow_mut()).push(__a1) - }; + 'for_body: { + { + let __a1 = (i as i32); + (*indexes.borrow_mut()).push(__a1) + }; + } i.prefix_dec(); } } { let mut i: u32 = 0_u32; 'loop_: while ((i as usize) < (*indexes.borrow()).len()) { - let __rhs = ((i).wrapping_rem(2_u32) != 0); - match (indexes.decay().offset((i as usize)),) { - (__tmp_41,) => ({ (*m2.borrow_mut()).subscript(__tmp_41, || false) }), + 'for_body: { + let __rhs = ((i).wrapping_rem(2_u32) != 0); + match (indexes.decay().offset((i as usize)),) { + (__tmp_41,) => ({ (*m2.borrow_mut()).subscript(__tmp_41, || false) }), + } + .write(__rhs); } - .write(__rhs); i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/map_try_emplace.rs b/tests/unit/out/refcount/map_try_emplace.rs index 712b41a1be..f64adfeced 100644 --- a/tests/unit/out/refcount/map_try_emplace.rs +++ b/tests/unit/out/refcount/map_try_emplace.rs @@ -169,168 +169,187 @@ fn main_0() -> i32 { { let mut subset: i32 = 0; 'loop_: while (subset < 8) { - { - let key: Value = Rc::new(RefCell::new(0)); - 'loop_: while ((*key.borrow()) < 3) { - { - let mut initial: i32 = 0; - 'loop_: while (initial < 3) { + 'for_body: { + { + let key: Value = Rc::new(RefCell::new(0)); + 'loop_: while ((*key.borrow()) < 3) { + 'for_body: { { - let mut post: i32 = 0; - 'loop_: while (post < 2) { - let m: Value, Value)>> = - Rc::new(RefCell::new(Map::new())); - let mut size: i32 = 0; - { - let k: Value = Rc::new(RefCell::new(0)); - 'loop_: while ((*k.borrow()) < 3) { - if ((subset & (1 << (*k.borrow()))) != 0) { - let __rhs = (10 + (*k.borrow())); - ({ - (*m.borrow_mut()) - .subscript(k.as_pointer(), || 0_i32) - }) - .write(__rhs); - size.prefix_inc(); - } - (*k.borrow_mut()).prefix_inc(); - } - } - let counter: Value = Rc::new(RefCell::new(initial)); - let result: Value<( - Value, Value)>>, - Value, - )> = Rc::new(RefCell::new({ - let __tmp_3: Value; - if (post != 0) { - match ({ - __tmp_3 = Rc::new(RefCell::new( - (*counter.borrow_mut()).postfix_inc(), - )); - __tmp_3.as_pointer() - },) - { - (__tmp_2,) => { - let (__it, __inserted) = Map::emplace( - m.as_pointer(), - &key.as_pointer(), - || { - ( - Rc::new(RefCell::new( - key.as_pointer().read(), - )), - Rc::new(RefCell::new( - (__tmp_2.read()), - )), - ) - }, - ); - ( - Rc::new(RefCell::new(__it)), - Rc::new(RefCell::new(__inserted)), - ) - } - } - } else { - match ({ - let __tmp_5 = counter.as_pointer(); - __tmp_5.with_mut(|__v| { - __v.prefix_inc(); - }); - __tmp_5 - },) - { - (__tmp_4,) => { - let (__it, __inserted) = Map::emplace( - m.as_pointer(), - &key.as_pointer(), - || { - ( - Rc::new(RefCell::new( - key.as_pointer().read(), - )), - Rc::new(RefCell::new( - (__tmp_4.read()), - )), - ) - }, - ); - ( - Rc::new(RefCell::new(__it)), - Rc::new(RefCell::new(__inserted)), - ) + let mut initial: i32 = 0; + 'loop_: while (initial < 3) { + 'for_body: { + { + let mut post: i32 = 0; + 'loop_: while (post < 2) { + 'for_body: { + let m: Value< + Map, Value)>, + > = Rc::new(RefCell::new(Map::new())); + let mut size: i32 = 0; + { + let k: Value = + Rc::new(RefCell::new(0)); + 'loop_: while ((*k.borrow()) < 3) { + 'for_body: { + if ((subset & (1 << (*k.borrow()))) + != 0) + { + let __rhs = + (10 + (*k.borrow())); + ({ + (*m.borrow_mut()).subscript( + k.as_pointer(), + || 0_i32, + ) + }) + .write(__rhs); + size.prefix_inc(); + } + } + (*k.borrow_mut()).prefix_inc(); + } + } + let counter: Value = + Rc::new(RefCell::new(initial)); + let result: Value<( + Value< + BidirectionalIterator<( + Value, + Value, + )>, + >, + Value, + )> = Rc::new(RefCell::new({ + let __tmp_3: Value; + if (post != 0) { + match ({ + __tmp_3 = Rc::new(RefCell::new( + (*counter.borrow_mut()) + .postfix_inc(), + )); + __tmp_3.as_pointer() + },) + { + (__tmp_2,) => { + let (__it, __inserted) = + Map::emplace( + m.as_pointer(), + &key.as_pointer(), + || { + (Rc::new(RefCell::new(key .as_pointer() .read())), Rc::new(RefCell::new((__tmp_2.read()) ))) + }, + ); + ( + Rc::new(RefCell::new(__it)), + Rc::new(RefCell::new( + __inserted, + )), + ) + } + } + } else { + match ({ + let __tmp_5 = counter.as_pointer(); + __tmp_5.with_mut(|__v| { + __v.prefix_inc(); + }); + __tmp_5 + },) + { + (__tmp_4,) => { + let (__it, __inserted) = + Map::emplace( + m.as_pointer(), + &key.as_pointer(), + || { + (Rc::new(RefCell::new(key .as_pointer() .read())), Rc::new(RefCell::new((__tmp_4.read()) ))) + }, + ); + ( + Rc::new(RefCell::new(__it)), + Rc::new(RefCell::new( + __inserted, + )), + ) + } + } + } + })); + let mut hit: bool = + ((subset & (1 << (*key.borrow()))) != 0); + ok = { + ((ok as i32) + & (((*counter.borrow()) + == (initial + 1)) + as i32)) + != 0 + }; + ok = { + ((ok as i32) + & ((((*(*result.borrow()).1.borrow()) + as i32) + == (!(hit) as i32)) + as i32)) + != 0 + }; + let mut found : bool = (*(*result.borrow()) .0.borrow()) == m .as_pointer() .with(|__m: &Map, Value)>| __m.find(&key .as_pointer() )) ; + ok = { ((ok as i32) & (found as i32)) != 0 }; + { + let rhs_0 = ((ok as i32) + & (((*(*({ + (*(*result.borrow()).0.borrow()) + .iter_deref() + }) + .upgrade() + .deref()) + .0 + .borrow()) + == (*key.borrow())) + as i32)) + != 0; + ok = rhs_0 + }; + { + let rhs_0 = ((ok as i32) + & (((*(*({ + (*(*result.borrow()).0.borrow()) + .iter_deref() + }) + .upgrade() + .deref()) + .1 + .borrow()) + == (if hit { + (10 + (*key.borrow())) + } else { + (initial + + (!(post != 0) as i32)) + })) + as i32)) + != 0; + ok = rhs_0 + }; + { + let rhs_0 = ((ok as i32) + & (((*m.borrow()).len() + == ((size + (!(hit) as i32)) + as usize)) + as i32)) + != 0; + ok = rhs_0 + }; + rows.prefix_inc(); } + post.prefix_inc(); } } - })); - let mut hit: bool = ((subset & (1 << (*key.borrow()))) != 0); - ok = { - ((ok as i32) - & (((*counter.borrow()) == (initial + 1)) as i32)) - != 0 - }; - ok = { - ((ok as i32) - & ((((*(*result.borrow()).1.borrow()) as i32) - == (!(hit) as i32)) - as i32)) - != 0 - }; - let mut found: bool = (*(*result.borrow()).0.borrow()) - == m.as_pointer().with( - |__m: &Map, Value)>| { - __m.find(&key.as_pointer()) - }, - ); - ok = { ((ok as i32) & (found as i32)) != 0 }; - { - let rhs_0 = ((ok as i32) - & (((*(*({ - (*(*result.borrow()).0.borrow()).iter_deref() - }) - .upgrade() - .deref()) - .0 - .borrow()) - == (*key.borrow())) - as i32)) - != 0; - ok = rhs_0 - }; - { - let rhs_0 = ((ok as i32) - & (((*(*({ - (*(*result.borrow()).0.borrow()).iter_deref() - }) - .upgrade() - .deref()) - .1 - .borrow()) - == (if hit { - (10 + (*key.borrow())) - } else { - (initial + (!(post != 0) as i32)) - })) - as i32)) - != 0; - ok = rhs_0 - }; - { - let rhs_0 = ((ok as i32) - & (((*m.borrow()).len() - == ((size + (!(hit) as i32)) as usize)) - as i32)) - != 0; - ok = rhs_0 - }; - rows.prefix_inc(); - post.prefix_inc(); + } + initial.prefix_inc(); } } - initial.prefix_inc(); } + (*key.borrow_mut()).prefix_inc(); } - (*key.borrow_mut()).prefix_inc(); } } subset.prefix_inc(); diff --git a/tests/unit/out/refcount/map_try_emplace_lvalues.rs b/tests/unit/out/refcount/map_try_emplace_lvalues.rs index e6c612c46a..906db21ba5 100644 --- a/tests/unit/out/refcount/map_try_emplace_lvalues.rs +++ b/tests/unit/out/refcount/map_try_emplace_lvalues.rs @@ -881,214 +881,220 @@ fn main_0() -> i32 { { let mut hit: i32 = 0; 'loop_: while (hit < 2) { - let values: Value, Value)>> = - Rc::new(RefCell::new(Map::new())); - let keys: Value> = Rc::new(RefCell::new(Box::new([0, 1, 2, 3, 4, 5]))); - if (hit != 0) { - 'loop_: for k in IterRange::new(keys.decay(), keys.decay().offset((6_i64) as isize)) - { - let k: Value = Rc::new(RefCell::new((k.read()))); - ({ (*values.borrow_mut()).subscript(k.as_pointer(), || 0_i32) }).write(42); - } - } - let moved: Value = Rc::new(RefCell::new(0)); - let forwarded: Value = Rc::new(RefCell::new(0)); - let xvalue: Value = Rc::new(RefCell::new(0)); - let lvalue: Value = Rc::new(RefCell::new(0)); - let assigned: Value = Rc::new(RefCell::new(0)); - let nested: Value = Rc::new(RefCell::new(0)); - let r0: Value<( - Value, Value)>>, - Value, - )> = Rc::new(RefCell::new( - match ({ - let __tmp_48 = moved.as_pointer(); - __tmp_48.with_mut(|__v| { - __v.prefix_inc(); - }); - __tmp_48 - },) - { - (__tmp_47,) => { - let (__it, __inserted) = - Map::emplace(values.as_pointer(), &keys.decay().offset(0), || { - ( - Rc::new(RefCell::new(keys.decay().offset(0).read())), - Rc::new(RefCell::new((__tmp_47.read()))), - ) - }); - ( - Rc::new(RefCell::new(__it)), - Rc::new(RefCell::new(__inserted)), - ) - } - }, - )); - let r1: Value<( - Value, Value)>>, - Value, - )> = Rc::new(RefCell::new( - match ({ - let __tmp_50 = forwarded.as_pointer(); - __tmp_50.with_mut(|__v| { - __v.prefix_inc(); - }); - __tmp_50 - },) - { - (__tmp_49,) => { - let (__it, __inserted) = - Map::emplace(values.as_pointer(), &keys.decay().offset(1), || { - ( - Rc::new(RefCell::new(keys.decay().offset(1).read())), - Rc::new(RefCell::new((__tmp_49.read()))), - ) - }); - ( - Rc::new(RefCell::new(__it)), - Rc::new(RefCell::new(__inserted)), - ) - } - }, - )); - let r2: Value<( - Value, Value)>>, - Value, - )> = Rc::new(RefCell::new( - match ({ - let __tmp_52 = xvalue.as_pointer(); - __tmp_52.with_mut(|__v| { - __v.prefix_inc(); - }); - __tmp_52 - },) - { - (__tmp_51,) => { - let (__it, __inserted) = - Map::emplace(values.as_pointer(), &keys.decay().offset(2), || { - ( - Rc::new(RefCell::new(keys.decay().offset(2).read())), - Rc::new(RefCell::new((__tmp_51.read()))), - ) - }); - ( - Rc::new(RefCell::new(__it)), - Rc::new(RefCell::new(__inserted)), - ) - } - }, - )); - let r3: Value<( - Value, Value)>>, - Value, - )> = Rc::new(RefCell::new( - match ({ - let __tmp_54 = lvalue.as_pointer(); - __tmp_54.with_mut(|__v| { - __v.prefix_inc(); - }); - __tmp_54 - },) - { - (__tmp_53,) => { - let (__it, __inserted) = - Map::emplace(values.as_pointer(), &keys.decay().offset(3), || { - ( - Rc::new(RefCell::new(keys.decay().offset(3).read())), - Rc::new(RefCell::new((__tmp_53.read()))), - ) - }); - ( - Rc::new(RefCell::new(__it)), - Rc::new(RefCell::new(__inserted)), - ) - } - }, - )); - let r4: Value<( - Value, Value)>>, - Value, - )> = Rc::new(RefCell::new( - match (match ({ 5 }, assigned.as_pointer()) { - (__tmp_57, __tmp_56) => { - __tmp_56.write(__tmp_57); - __tmp_56 - } - },) - { - (__tmp_55,) => { - let (__it, __inserted) = - Map::emplace(values.as_pointer(), &keys.decay().offset(4), || { - ( - Rc::new(RefCell::new(keys.decay().offset(4).read())), - Rc::new(RefCell::new((__tmp_55.read()))), - ) - }); - ( - Rc::new(RefCell::new(__it)), - Rc::new(RefCell::new(__inserted)), - ) - } - }, - )); - let r5: Value<( - Value, Value)>>, - Value, - )> = Rc::new(RefCell::new( - match (match ({ 1 }, nested.as_pointer()) { - (__tmp_60, __tmp_59) => { - __tmp_59 - .with_mut(|__v| *__v = (((*__v) as i32) + (__tmp_60 as i32)) as i32); - __tmp_59 + 'for_body: { + let values: Value, Value)>> = + Rc::new(RefCell::new(Map::new())); + let keys: Value> = Rc::new(RefCell::new(Box::new([0, 1, 2, 3, 4, 5]))); + if (hit != 0) { + 'loop_: for k in + IterRange::new(keys.decay(), keys.decay().offset((6_i64) as isize)) + { + let k: Value = Rc::new(RefCell::new((k.read()))); + ({ (*values.borrow_mut()).subscript(k.as_pointer(), || 0_i32) }).write(42); } - },) - { - (__tmp_58,) => { - let (__it, __inserted) = - Map::emplace(values.as_pointer(), &keys.decay().offset(5), || { - ( - Rc::new(RefCell::new(keys.decay().offset(5).read())), - Rc::new(RefCell::new((__tmp_58.read()))), - ) + } + let moved: Value = Rc::new(RefCell::new(0)); + let forwarded: Value = Rc::new(RefCell::new(0)); + let xvalue: Value = Rc::new(RefCell::new(0)); + let lvalue: Value = Rc::new(RefCell::new(0)); + let assigned: Value = Rc::new(RefCell::new(0)); + let nested: Value = Rc::new(RefCell::new(0)); + let r0: Value<( + Value, Value)>>, + Value, + )> = Rc::new(RefCell::new( + match ({ + let __tmp_48 = moved.as_pointer(); + __tmp_48.with_mut(|__v| { + __v.prefix_inc(); + }); + __tmp_48 + },) + { + (__tmp_47,) => { + let (__it, __inserted) = + Map::emplace(values.as_pointer(), &keys.decay().offset(0), || { + ( + Rc::new(RefCell::new(keys.decay().offset(0).read())), + Rc::new(RefCell::new((__tmp_47.read()))), + ) + }); + ( + Rc::new(RefCell::new(__it)), + Rc::new(RefCell::new(__inserted)), + ) + } + }, + )); + let r1: Value<( + Value, Value)>>, + Value, + )> = Rc::new(RefCell::new( + match ({ + let __tmp_50 = forwarded.as_pointer(); + __tmp_50.with_mut(|__v| { + __v.prefix_inc(); + }); + __tmp_50 + },) + { + (__tmp_49,) => { + let (__it, __inserted) = + Map::emplace(values.as_pointer(), &keys.decay().offset(1), || { + ( + Rc::new(RefCell::new(keys.decay().offset(1).read())), + Rc::new(RefCell::new((__tmp_49.read()))), + ) + }); + ( + Rc::new(RefCell::new(__it)), + Rc::new(RefCell::new(__inserted)), + ) + } + }, + )); + let r2: Value<( + Value, Value)>>, + Value, + )> = Rc::new(RefCell::new( + match ({ + let __tmp_52 = xvalue.as_pointer(); + __tmp_52.with_mut(|__v| { + __v.prefix_inc(); + }); + __tmp_52 + },) + { + (__tmp_51,) => { + let (__it, __inserted) = + Map::emplace(values.as_pointer(), &keys.decay().offset(2), || { + ( + Rc::new(RefCell::new(keys.decay().offset(2).read())), + Rc::new(RefCell::new((__tmp_51.read()))), + ) + }); + ( + Rc::new(RefCell::new(__it)), + Rc::new(RefCell::new(__inserted)), + ) + } + }, + )); + let r3: Value<( + Value, Value)>>, + Value, + )> = Rc::new(RefCell::new( + match ({ + let __tmp_54 = lvalue.as_pointer(); + __tmp_54.with_mut(|__v| { + __v.prefix_inc(); + }); + __tmp_54 + },) + { + (__tmp_53,) => { + let (__it, __inserted) = + Map::emplace(values.as_pointer(), &keys.decay().offset(3), || { + ( + Rc::new(RefCell::new(keys.decay().offset(3).read())), + Rc::new(RefCell::new((__tmp_53.read()))), + ) + }); + ( + Rc::new(RefCell::new(__it)), + Rc::new(RefCell::new(__inserted)), + ) + } + }, + )); + let r4: Value<( + Value, Value)>>, + Value, + )> = Rc::new(RefCell::new( + match (match ({ 5 }, assigned.as_pointer()) { + (__tmp_57, __tmp_56) => { + __tmp_56.write(__tmp_57); + __tmp_56 + } + },) + { + (__tmp_55,) => { + let (__it, __inserted) = + Map::emplace(values.as_pointer(), &keys.decay().offset(4), || { + ( + Rc::new(RefCell::new(keys.decay().offset(4).read())), + Rc::new(RefCell::new((__tmp_55.read()))), + ) + }); + ( + Rc::new(RefCell::new(__it)), + Rc::new(RefCell::new(__inserted)), + ) + } + }, + )); + let r5: Value<( + Value, Value)>>, + Value, + )> = Rc::new(RefCell::new( + match (match ({ 1 }, nested.as_pointer()) { + (__tmp_60, __tmp_59) => { + __tmp_59.with_mut(|__v| { + *__v = (((*__v) as i32) + (__tmp_60 as i32)) as i32 }); - ( - Rc::new(RefCell::new(__it)), - Rc::new(RefCell::new(__inserted)), - ) - } - }, - )); - assert!( - ({ - ((((((*moved.borrow()) == 1) && ((*forwarded.borrow()) == 1)) - && ((*xvalue.borrow()) == 1)) - && ((*lvalue.borrow()) == 1)) - && ((*assigned.borrow()) == 5)) - && ((*nested.borrow()) == 1) - }) - ); - assert!( - ({ - (((((((*(*r0.borrow()).1.borrow()) as i32) == (!(hit != 0) as i32)) - && (((*(*r1.borrow()).1.borrow()) as i32) == (!(hit != 0) as i32))) - && (((*(*r2.borrow()).1.borrow()) as i32) == (!(hit != 0) as i32))) - && (((*(*r3.borrow()).1.borrow()) as i32) == (!(hit != 0) as i32))) - && (((*(*r4.borrow()).1.borrow()) as i32) == (!(hit != 0) as i32))) - && (((*(*r5.borrow()).1.borrow()) as i32) == (!(hit != 0) as i32)) - }) - ); - 'loop_: for k in IterRange::new(keys.decay(), keys.decay().offset((6_i64) as isize)) { - let k: Value = Rc::new(RefCell::new((k.read()))); + __tmp_59 + } + },) + { + (__tmp_58,) => { + let (__it, __inserted) = + Map::emplace(values.as_pointer(), &keys.decay().offset(5), || { + ( + Rc::new(RefCell::new(keys.decay().offset(5).read())), + Rc::new(RefCell::new((__tmp_58.read()))), + ) + }); + ( + Rc::new(RefCell::new(__it)), + Rc::new(RefCell::new(__inserted)), + ) + } + }, + )); assert!( ({ - ((({ (*values.borrow_mut()).subscript(k.as_pointer(), || 0_i32) }).read()) - == (if (hit != 0) { - 42 - } else { - if ((*k.borrow()) == 4) { 5 } else { 1 } - })) + ((((((*moved.borrow()) == 1) && ((*forwarded.borrow()) == 1)) + && ((*xvalue.borrow()) == 1)) + && ((*lvalue.borrow()) == 1)) + && ((*assigned.borrow()) == 5)) + && ((*nested.borrow()) == 1) }) ); + assert!( + ({ + (((((((*(*r0.borrow()).1.borrow()) as i32) == (!(hit != 0) as i32)) + && (((*(*r1.borrow()).1.borrow()) as i32) == (!(hit != 0) as i32))) + && (((*(*r2.borrow()).1.borrow()) as i32) == (!(hit != 0) as i32))) + && (((*(*r3.borrow()).1.borrow()) as i32) == (!(hit != 0) as i32))) + && (((*(*r4.borrow()).1.borrow()) as i32) == (!(hit != 0) as i32))) + && (((*(*r5.borrow()).1.borrow()) as i32) == (!(hit != 0) as i32)) + }) + ); + 'loop_: for k in IterRange::new(keys.decay(), keys.decay().offset((6_i64) as isize)) + { + let k: Value = Rc::new(RefCell::new((k.read()))); + assert!( + ({ + ((({ (*values.borrow_mut()).subscript(k.as_pointer(), || 0_i32) }) + .read()) + == (if (hit != 0) { + 42 + } else { + if ((*k.borrow()) == 4) { 5 } else { 1 } + })) + }) + ); + } } hit.prefix_inc(); } @@ -1096,423 +1102,399 @@ fn main_0() -> i32 { { let mut hit: i32 = 0; 'loop_: while (hit < 2) { - { - let mut choose: i32 = 0; - 'loop_: while (choose < 2) { - let selected: Value, Value)>> = - Rc::new(RefCell::new(Map::new())); - let keys: Value> = Rc::new(RefCell::new(Box::new([0, 1, 2]))); - if (hit != 0) { - 'loop_: for k in - IterRange::new(keys.decay(), keys.decay().offset((3_i64) as isize)) - { - let k: Value = Rc::new(RefCell::new((k.read()))); - field!( - ({ - (*selected.borrow_mut()) - .subscript(k.as_pointer(), || ::default()) - }), - value - ) - .write(42); - } - } - let a: Value = Rc::new(RefCell::new(0)); - let b: Value = Rc::new(RefCell::new(0)); - let c: Value = Rc::new(RefCell::new(0)); - let d: Value = Rc::new(RefCell::new(0)); - let e: Value = Rc::new(RefCell::new(0)); - let f: Value = Rc::new(RefCell::new(0)); - let prefix: Value<( - Value, Value)>>, - Value, - )> = Rc::new(RefCell::new( - match (if (choose != 0) { - { - let __tmp_62 = a.as_pointer(); - __tmp_62.with_mut(|__v| { - __v.prefix_inc(); - }); - __tmp_62 - } - } else { - { - let __tmp_63 = b.as_pointer(); - __tmp_63.with_mut(|__v| { - __v.prefix_inc(); - }); - __tmp_63 + 'for_body: { + { + let mut choose: i32 = 0; + 'loop_: while (choose < 2) { + 'for_body: { + let selected: Value, Value)>> = + Rc::new(RefCell::new(Map::new())); + let keys: Value> = + Rc::new(RefCell::new(Box::new([0, 1, 2]))); + if (hit != 0) { + 'loop_: for k in IterRange::new( + keys.decay(), + keys.decay().offset((3_i64) as isize), + ) { + let k: Value = Rc::new(RefCell::new((k.read()))); + field!( + ({ + (*selected.borrow_mut()) + .subscript(k.as_pointer(), || ::default()) + }), + value + ) + .write(42); + } } - },) - { - (__tmp_61,) => { - let (__it, __inserted) = Map::emplace( - selected.as_pointer(), - &keys.decay().offset(0), - || { + let a: Value = Rc::new(RefCell::new(0)); + let b: Value = Rc::new(RefCell::new(0)); + let c: Value = Rc::new(RefCell::new(0)); + let d: Value = Rc::new(RefCell::new(0)); + let e: Value = Rc::new(RefCell::new(0)); + let f: Value = Rc::new(RefCell::new(0)); + let prefix: Value<( + Value, Value)>>, + Value, + )> = Rc::new(RefCell::new( + match (if (choose != 0) { + { + let __tmp_62 = a.as_pointer(); + __tmp_62.with_mut(|__v| { + __v.prefix_inc(); + }); + __tmp_62 + } + } else { + { + let __tmp_63 = b.as_pointer(); + __tmp_63.with_mut(|__v| { + __v.prefix_inc(); + }); + __tmp_63 + } + },) + { + (__tmp_61,) => { + let (__it, __inserted) = Map::emplace( + selected.as_pointer(), + &keys.decay().offset(0), + || { + ( + Rc::new(RefCell::new( + keys.decay().offset(0).read(), + )), + Rc::new(RefCell::new(Item::new_2( + { (__tmp_61).clone() }, + { 2 }, + ))), + ) + }, + ); ( - Rc::new(RefCell::new(keys.decay().offset(0).read())), - Rc::new(RefCell::new(Item::new_2( - { (__tmp_61).clone() }, - { 2 }, - ))), + Rc::new(RefCell::new(__it)), + Rc::new(RefCell::new(__inserted)), ) - }, - ); - ( - Rc::new(RefCell::new(__it)), - Rc::new(RefCell::new(__inserted)), - ) - } - }, - )); - let assignment: Value<( - Value, Value)>>, - Value, - )> = Rc::new(RefCell::new( - match (if (choose != 0) { - (match ({ 5 }, c.as_pointer()) { - (__tmp_66, __tmp_65) => { - __tmp_65.write(__tmp_66); - __tmp_65 - } - }) - } else { - (match ({ 6 }, d.as_pointer()) { - (__tmp_68, __tmp_67) => { - __tmp_67.write(__tmp_68); - __tmp_67 - } - }) - },) - { - (__tmp_64,) => { - let (__it, __inserted) = Map::emplace( - selected.as_pointer(), - &keys.decay().offset(1), - || { + } + }, + )); + let assignment: Value<( + Value, Value)>>, + Value, + )> = Rc::new(RefCell::new( + match (if (choose != 0) { + (match ({ 5 }, c.as_pointer()) { + (__tmp_66, __tmp_65) => { + __tmp_65.write(__tmp_66); + __tmp_65 + } + }) + } else { + (match ({ 6 }, d.as_pointer()) { + (__tmp_68, __tmp_67) => { + __tmp_67.write(__tmp_68); + __tmp_67 + } + }) + },) + { + (__tmp_64,) => { + let (__it, __inserted) = Map::emplace( + selected.as_pointer(), + &keys.decay().offset(1), + || { + ( + Rc::new(RefCell::new( + keys.decay().offset(1).read(), + )), + Rc::new(RefCell::new(Item::new_2( + { (__tmp_64).clone() }, + { 2 }, + ))), + ) + }, + ); ( - Rc::new(RefCell::new(keys.decay().offset(1).read())), - Rc::new(RefCell::new(Item::new_2( - { (__tmp_64).clone() }, - { 2 }, - ))), + Rc::new(RefCell::new(__it)), + Rc::new(RefCell::new(__inserted)), ) - }, - ); - ( - Rc::new(RefCell::new(__it)), - Rc::new(RefCell::new(__inserted)), - ) - } - }, - )); - let compound: Value<( - Value, Value)>>, - Value, - )> = Rc::new(RefCell::new( - match (if (choose != 0) { - (match ({ 1 }, e.as_pointer()) { - (__tmp_71, __tmp_70) => { - __tmp_70.with_mut(|__v| { - *__v = (((*__v) as i32) + (__tmp_71 as i32)) as i32 - }); - __tmp_70 - } - }) - } else { - (match ({ 2 }, f.as_pointer()) { - (__tmp_73, __tmp_72) => { - __tmp_72.with_mut(|__v| { - *__v = (((*__v) as i32) + (__tmp_73 as i32)) as i32 - }); - __tmp_72 - } - }) - },) - { - (__tmp_69,) => { - let (__it, __inserted) = Map::emplace( - selected.as_pointer(), - &keys.decay().offset(2), - || { + } + }, + )); + let compound: Value<( + Value, Value)>>, + Value, + )> = Rc::new(RefCell::new( + match (if (choose != 0) { + (match ({ 1 }, e.as_pointer()) { + (__tmp_71, __tmp_70) => { + __tmp_70.with_mut(|__v| { + *__v = (((*__v) as i32) + (__tmp_71 as i32)) as i32 + }); + __tmp_70 + } + }) + } else { + (match ({ 2 }, f.as_pointer()) { + (__tmp_73, __tmp_72) => { + __tmp_72.with_mut(|__v| { + *__v = (((*__v) as i32) + (__tmp_73 as i32)) as i32 + }); + __tmp_72 + } + }) + },) + { + (__tmp_69,) => { + let (__it, __inserted) = Map::emplace( + selected.as_pointer(), + &keys.decay().offset(2), + || { + ( + Rc::new(RefCell::new( + keys.decay().offset(2).read(), + )), + Rc::new(RefCell::new(Item::new_2( + { (__tmp_69).clone() }, + { 2 }, + ))), + ) + }, + ); ( - Rc::new(RefCell::new(keys.decay().offset(2).read())), - Rc::new(RefCell::new(Item::new_2( - { (__tmp_69).clone() }, - { 2 }, - ))), + Rc::new(RefCell::new(__it)), + Rc::new(RefCell::new(__inserted)), ) - }, - ); - ( - Rc::new(RefCell::new(__it)), - Rc::new(RefCell::new(__inserted)), - ) - } - }, - )); - assert!( - ({ - ((*a.borrow()) - == (if (choose != 0) { - (if (hit != 0) { 1 } else { 3 }) - } else { - 0 - })) - && ((*b.borrow()) - == (if (choose != 0) { - 0 - } else { - (if (hit != 0) { 1 } else { 3 }) - })) - }) - ); - assert!( - ({ - ((*c.borrow()) - == (if (choose != 0) { - (if (hit != 0) { 5 } else { 7 }) - } else { - 0 - })) - && ((*d.borrow()) - == (if (choose != 0) { - 0 - } else { - (if (hit != 0) { 6 } else { 8 }) - })) - }) - ); - assert!( - ({ - ((*e.borrow()) - == (if (choose != 0) { - (if (hit != 0) { 1 } else { 3 }) - } else { - 0 - })) - && ((*f.borrow()) - == (if (choose != 0) { - 0 - } else { - (if (hit != 0) { 2 } else { 4 }) - })) - }) - ); - assert!( - ({ - ((((*(*prefix.borrow()).1.borrow()) as i32) == (!(hit != 0) as i32)) - && (((*(*assignment.borrow()).1.borrow()) as i32) - == (!(hit != 0) as i32))) - && (((*(*compound.borrow()).1.borrow()) as i32) - == (!(hit != 0) as i32)) - }) - ); - assert!( - ({ - (({ (*(*prefix.borrow()).0.borrow()).iter_deref() }) - .with(|__s| (*__s.1.borrow()).value) - == (if (hit != 0) { 42 } else { 3 })) - }) - ); - assert!( - ({ - (({ (*(*assignment.borrow()).0.borrow()).iter_deref() }) - .with(|__s| (*__s.1.borrow()).value) - == (if (hit != 0) { - 42 - } else { - if (choose != 0) { 7 } else { 8 } - })) - }) - ); - assert!( - ({ - (({ (*(*compound.borrow()).0.borrow()).iter_deref() }) - .with(|__s| (*__s.1.borrow()).value) - == (if (hit != 0) { - 42 - } else { - if (choose != 0) { 3 } else { 4 } - })) - }) - ); - choose.prefix_inc(); - } - } - let values: Value, Value)>> = - Rc::new(RefCell::new(Map::new())); - let keys: Value> = Rc::new(RefCell::new(Box::new([0, 1, 2]))); - if (hit != 0) { - 'loop_: for k in IterRange::new(keys.decay(), keys.decay().offset((3_i64) as isize)) - { - let k: Value = Rc::new(RefCell::new((k.read()))); - ({ (*values.borrow_mut()).subscript(k.as_pointer(), || 0_i32) }).write(42); - } - } - let mut before: i32 = temporary_calls_4.with(|rc| *rc.borrow()); - let mut index: i32 = 0; - let member: Value<( - Value, Value)>>, - Value, - )> = Rc::new(RefCell::new({ - let __tmp_76: Value; - match ((match { - __tmp_76 = Rc::new(RefCell::new(({ make_temporary_5() }))); - __tmp_76.as_pointer() - } { - __tmp_75 => field_ptr!(__tmp_75, n), - }),) - { - (__tmp_74,) => { - let (__it, __inserted) = - Map::emplace(values.as_pointer(), &keys.decay().offset(0), || { - ( - Rc::new(RefCell::new(keys.decay().offset(0).read())), - Rc::new(RefCell::new((__tmp_74.read()))), - ) - }); - ( - Rc::new(RefCell::new(__it)), - Rc::new(RefCell::new(__inserted)), - ) + } + }, + )); + assert!( + ({ + ((*a.borrow()) + == (if (choose != 0) { + (if (hit != 0) { 1 } else { 3 }) + } else { + 0 + })) + && ((*b.borrow()) + == (if (choose != 0) { + 0 + } else { + (if (hit != 0) { 1 } else { 3 }) + })) + }) + ); + assert!( + ({ + ((*c.borrow()) + == (if (choose != 0) { + (if (hit != 0) { 5 } else { 7 }) + } else { + 0 + })) + && ((*d.borrow()) + == (if (choose != 0) { + 0 + } else { + (if (hit != 0) { 6 } else { 8 }) + })) + }) + ); + assert!( + ({ + ((*e.borrow()) + == (if (choose != 0) { + (if (hit != 0) { 1 } else { 3 }) + } else { + 0 + })) + && ((*f.borrow()) + == (if (choose != 0) { + 0 + } else { + (if (hit != 0) { 2 } else { 4 }) + })) + }) + ); + assert!( + ({ + ((((*(*prefix.borrow()).1.borrow()) as i32) + == (!(hit != 0) as i32)) + && (((*(*assignment.borrow()).1.borrow()) as i32) + == (!(hit != 0) as i32))) + && (((*(*compound.borrow()).1.borrow()) as i32) + == (!(hit != 0) as i32)) + }) + ); + assert!( + ({ + (({ (*(*prefix.borrow()).0.borrow()).iter_deref() }) + .with(|__s| (*__s.1.borrow()).value) + == (if (hit != 0) { 42 } else { 3 })) + }) + ); + assert!( + ({ + (({ (*(*assignment.borrow()).0.borrow()).iter_deref() }) + .with(|__s| (*__s.1.borrow()).value) + == (if (hit != 0) { + 42 + } else { + if (choose != 0) { 7 } else { 8 } + })) + }) + ); + assert!( + ({ + (({ (*(*compound.borrow()).0.borrow()).iter_deref() }) + .with(|__s| (*__s.1.borrow()).value) + == (if (hit != 0) { + 42 + } else { + if (choose != 0) { 3 } else { 4 } + })) + }) + ); + } + choose.prefix_inc(); } } - })); - let nested: Value<( - Value, Value)>>, - Value, - )> = Rc::new(RefCell::new({ - let __tmp_79: Value; - match ((match { - __tmp_79 = Rc::new(RefCell::new(({ make_nested_6() }))); - __tmp_79.as_pointer() - } { - __tmp_78 => field_ptr!(field_ptr!(__tmp_78, inner), n), - }),) - { - (__tmp_77,) => { - let (__it, __inserted) = - Map::emplace(values.as_pointer(), &keys.decay().offset(1), || { - ( - Rc::new(RefCell::new(keys.decay().offset(1).read())), - Rc::new(RefCell::new((__tmp_77.read()))), - ) - }); - ( - Rc::new(RefCell::new(__it)), - Rc::new(RefCell::new(__inserted)), - ) + let values: Value, Value)>> = + Rc::new(RefCell::new(Map::new())); + let keys: Value> = Rc::new(RefCell::new(Box::new([0, 1, 2]))); + if (hit != 0) { + 'loop_: for k in + IterRange::new(keys.decay(), keys.decay().offset((3_i64) as isize)) + { + let k: Value = Rc::new(RefCell::new((k.read()))); + ({ (*values.borrow_mut()).subscript(k.as_pointer(), || 0_i32) }).write(42); } } - })); - let element: Value<( - Value, Value)>>, - Value, - )> = Rc::new(RefCell::new({ - let __tmp_82: Value; - match ((match { - __tmp_82 = Rc::new(RefCell::new(({ make_temporary_5() }))); - __tmp_82.as_pointer() - } { - __tmp_81 => array_field_ptr!(__tmp_81, data), - }) - .offset((index.postfix_inc()) as isize),) - { - (__tmp_80,) => { - let (__it, __inserted) = - Map::emplace(values.as_pointer(), &keys.decay().offset(2), || { - ( - Rc::new(RefCell::new(keys.decay().offset(2).read())), - Rc::new(RefCell::new((__tmp_80.read()))), - ) - }); - ( - Rc::new(RefCell::new(__it)), - Rc::new(RefCell::new(__inserted)), - ) + let mut before: i32 = temporary_calls_4.with(|rc| *rc.borrow()); + let mut index: i32 = 0; + let member: Value<( + Value, Value)>>, + Value, + )> = Rc::new(RefCell::new({ + let __tmp_76: Value; + match ((match { + __tmp_76 = Rc::new(RefCell::new(({ make_temporary_5() }))); + __tmp_76.as_pointer() + } { + __tmp_75 => field_ptr!(__tmp_75, n), + }),) + { + (__tmp_74,) => { + let (__it, __inserted) = + Map::emplace(values.as_pointer(), &keys.decay().offset(0), || { + ( + Rc::new(RefCell::new(keys.decay().offset(0).read())), + Rc::new(RefCell::new((__tmp_74.read()))), + ) + }); + ( + Rc::new(RefCell::new(__it)), + Rc::new(RefCell::new(__inserted)), + ) + } } - } - })); - assert!((temporary_calls_4.with(|rc| *rc.borrow()) == (before + 3)) && (index == 1)); - assert!( - ({ - ((((*(*member.borrow()).1.borrow()) as i32) == (!(hit != 0) as i32)) - && (((*(*nested.borrow()).1.borrow()) as i32) == (!(hit != 0) as i32))) - && (((*(*element.borrow()).1.borrow()) as i32) == (!(hit != 0) as i32)) - }) - ); - assert!( - ({ - (((*(*({ (*(*member.borrow()).0.borrow()).iter_deref() }) - .upgrade() - .deref()) - .1 - .borrow()) - == (if (hit != 0) { 42 } else { 5 })) - && ((*(*({ (*(*nested.borrow()).0.borrow()).iter_deref() }) - .upgrade() - .deref()) - .1 - .borrow()) - == (if (hit != 0) { 42 } else { 5 }))) - && ((*(*({ (*(*element.borrow()).0.borrow()).iter_deref() }) - .upgrade() - .deref()) - .1 - .borrow()) - == (if (hit != 0) { 42 } else { 6 })) - }) - ); - { - let mut choose: i32 = 0; - 'loop_: while (choose < 2) { - let references: Value, Value)>> = - Rc::new(RefCell::new(Map::new())); - let ordinary: Value = Rc::new(RefCell::new(9)); - if (hit != 0) { - { + })); + let nested: Value<( + Value, Value)>>, + Value, + )> = Rc::new(RefCell::new({ + let __tmp_79: Value; + match ((match { + __tmp_79 = Rc::new(RefCell::new(({ make_nested_6() }))); + __tmp_79.as_pointer() + } { + __tmp_78 => field_ptr!(field_ptr!(__tmp_78, inner), n), + }),) + { + (__tmp_77,) => { let (__it, __inserted) = - Map::emplace(references.as_pointer(), &key.as_pointer(), || { + Map::emplace(values.as_pointer(), &keys.decay().offset(1), || { ( - Rc::new(RefCell::new(key.as_pointer().read())), - Rc::new(RefCell::new(Held::new_1({ - ordinary.as_pointer() - }))), + Rc::new(RefCell::new(keys.decay().offset(1).read())), + Rc::new(RefCell::new((__tmp_77.read()))), ) }); ( Rc::new(RefCell::new(__it)), Rc::new(RefCell::new(__inserted)), ) - }; + } } - before = temporary_calls_4.with(|rc| *rc.borrow()); - index = 0; - let mut value: i32 = 0; + })); + let element: Value<( + Value, Value)>>, + Value, + )> = Rc::new(RefCell::new({ + let __tmp_82: Value; + match ((match { + __tmp_82 = Rc::new(RefCell::new(({ make_temporary_5() }))); + __tmp_82.as_pointer() + } { + __tmp_81 => array_field_ptr!(__tmp_81, data), + }) + .offset((index.postfix_inc()) as isize),) { - let __tmp_85: Value; - let __tmp_87: Value; - { - match (if (choose != 0) { - (match { - __tmp_85 = Rc::new(RefCell::new(({ make_nested_6() }))); - __tmp_85.as_pointer() - } { - __tmp_84 => field_ptr!(field_ptr!(__tmp_84, inner), n), - }) - } else { - (match { - __tmp_87 = Rc::new(RefCell::new(({ make_temporary_5() }))); - __tmp_87.as_pointer() - } { - __tmp_86 => array_field_ptr!(__tmp_86, data), - }) - .offset((index.postfix_inc()) as isize) - },) - { - (__tmp_83,) => { + (__tmp_80,) => { + let (__it, __inserted) = + Map::emplace(values.as_pointer(), &keys.decay().offset(2), || { + ( + Rc::new(RefCell::new(keys.decay().offset(2).read())), + Rc::new(RefCell::new((__tmp_80.read()))), + ) + }); + ( + Rc::new(RefCell::new(__it)), + Rc::new(RefCell::new(__inserted)), + ) + } + } + })); + assert!( + (temporary_calls_4.with(|rc| *rc.borrow()) == (before + 3)) && (index == 1) + ); + assert!( + ({ + ((((*(*member.borrow()).1.borrow()) as i32) == (!(hit != 0) as i32)) + && (((*(*nested.borrow()).1.borrow()) as i32) == (!(hit != 0) as i32))) + && (((*(*element.borrow()).1.borrow()) as i32) == (!(hit != 0) as i32)) + }) + ); + assert!( + ({ + (((*(*({ (*(*member.borrow()).0.borrow()).iter_deref() }) + .upgrade() + .deref()) + .1 + .borrow()) + == (if (hit != 0) { 42 } else { 5 })) + && ((*(*({ (*(*nested.borrow()).0.borrow()).iter_deref() }) + .upgrade() + .deref()) + .1 + .borrow()) + == (if (hit != 0) { 42 } else { 5 }))) + && ((*(*({ (*(*element.borrow()).0.borrow()).iter_deref() }) + .upgrade() + .deref()) + .1 + .borrow()) + == (if (hit != 0) { 42 } else { 6 })) + }) + ); + { + let mut choose: i32 = 0; + 'loop_: while (choose < 2) { + 'for_body: { + let references: Value, Value)>> = + Rc::new(RefCell::new(Map::new())); + let ordinary: Value = Rc::new(RefCell::new(9)); + if (hit != 0) { + { let (__it, __inserted) = Map::emplace( references.as_pointer(), &key.as_pointer(), @@ -1520,7 +1502,7 @@ fn main_0() -> i32 { ( Rc::new(RefCell::new(key.as_pointer().read())), Rc::new(RefCell::new(Held::new_1({ - (__tmp_83).clone() + ordinary.as_pointer() }))), ) }, @@ -1529,73 +1511,81 @@ fn main_0() -> i32 { Rc::new(RefCell::new(__it)), Rc::new(RefCell::new(__inserted)), ) + }; + } + before = temporary_calls_4.with(|rc| *rc.borrow()); + index = 0; + let mut value: i32 = 0; + { + let __tmp_85: Value; + let __tmp_87: Value; + { + match (if (choose != 0) { + (match { + __tmp_85 = Rc::new(RefCell::new(({ make_nested_6() }))); + __tmp_85.as_pointer() + } { + __tmp_84 => field_ptr!(field_ptr!(__tmp_84, inner), n), + }) + } else { + (match { + __tmp_87 = + Rc::new(RefCell::new(({ make_temporary_5() }))); + __tmp_87.as_pointer() + } { + __tmp_86 => array_field_ptr!(__tmp_86, data), + }) + .offset((index.postfix_inc()) as isize) + },) + { + (__tmp_83,) => { + let (__it, __inserted) = Map::emplace( + references.as_pointer(), + &key.as_pointer(), + || { + ( + Rc::new(RefCell::new( + key.as_pointer().read(), + )), + Rc::new(RefCell::new(Held::new_1({ + (__tmp_83).clone() + }))), + ) + }, + ); + ( + Rc::new(RefCell::new(__it)), + Rc::new(RefCell::new(__inserted)), + ) + } + }; + let __rhs = (({ + (*references.borrow_mut()) + .subscript(key.as_pointer(), || ::default()) + }) + .with(|__s| __s.ptr.clone()) + .read()); + value = __rhs } }; - let __rhs = (({ - (*references.borrow_mut()) - .subscript(key.as_pointer(), || ::default()) - }) - .with(|__s| __s.ptr.clone()) - .read()); - value = __rhs - } - }; - assert!( - (temporary_calls_4.with(|rc| *rc.borrow()) == (before + 1)) - && (index == (if (choose != 0) { 0 } else { 1 })) - ); - assert!( - (value - == (if (hit != 0) { - 9 - } else { - if (choose != 0) { 5 } else { 6 } - })) - ); - let arrays: Value, Value)>> = - Rc::new(RefCell::new(Map::new())); - let ordinary_array: Value> = - Rc::new(RefCell::new(Box::new([9, 10]))); - if (hit != 0) { - { - let (__it, __inserted) = - Map::emplace(arrays.as_pointer(), &key.as_pointer(), || { - ( - Rc::new(RefCell::new(key.as_pointer().read())), - Rc::new(RefCell::new(Held::new_3( - { ordinary_array.decay() }, - { 0 }, - ))), - ) - }); - ( - Rc::new(RefCell::new(__it)), - Rc::new(RefCell::new(__inserted)), - ) - }; - } - before = temporary_calls_4.with(|rc| *rc.borrow()); - { - let __tmp_90: Value; - let __tmp_92: Value; - { - match (if (choose != 0) { - (match { - __tmp_90 = Rc::new(RefCell::new(({ make_nested_6() }))); - __tmp_90.as_pointer() - } { - __tmp_89 => array_field_ptr!(field_ptr!(__tmp_89, inner), data), - }) - } else { - (match { - __tmp_92 = Rc::new(RefCell::new(({ make_temporary_5() }))); - __tmp_92.as_pointer() - } { - __tmp_91 => array_field_ptr!(__tmp_91, data), - }) - },) - { - (__tmp_88,) => { + assert!( + (temporary_calls_4.with(|rc| *rc.borrow()) == (before + 1)) + && (index == (if (choose != 0) { 0 } else { 1 })) + ); + assert!( + (value + == (if (hit != 0) { + 9 + } else { + if (choose != 0) { 5 } else { 6 } + })) + ); + let arrays: Value, Value)>> = + Rc::new(RefCell::new(Map::new())); + let ordinary_array: Value> = + Rc::new(RefCell::new(Box::new([9, 10]))); + if (hit != 0) { + { let (__it, __inserted) = Map::emplace( arrays.as_pointer(), &key.as_pointer(), @@ -1603,7 +1593,7 @@ fn main_0() -> i32 { ( Rc::new(RefCell::new(key.as_pointer().read())), Rc::new(RefCell::new(Held::new_3( - { (__tmp_88).clone() }, + { ordinary_array.decay() }, { 0 }, ))), ) @@ -1613,25 +1603,73 @@ fn main_0() -> i32 { Rc::new(RefCell::new(__it)), Rc::new(RefCell::new(__inserted)), ) + }; + } + before = temporary_calls_4.with(|rc| *rc.borrow()); + { + let __tmp_90: Value; + let __tmp_92: Value; + { + match (if (choose != 0) { + (match { + __tmp_90 = Rc::new(RefCell::new(({ make_nested_6() }))); + __tmp_90.as_pointer() + } { + __tmp_89 => { + array_field_ptr!(field_ptr!(__tmp_89, inner), data) + } + }) + } else { + (match { + __tmp_92 = + Rc::new(RefCell::new(({ make_temporary_5() }))); + __tmp_92.as_pointer() + } { + __tmp_91 => array_field_ptr!(__tmp_91, data), + }) + },) + { + (__tmp_88,) => { + let (__it, __inserted) = Map::emplace( + arrays.as_pointer(), + &key.as_pointer(), + || { + ( + Rc::new(RefCell::new( + key.as_pointer().read(), + )), + Rc::new(RefCell::new(Held::new_3( + { (__tmp_88).clone() }, + { 0 }, + ))), + ) + }, + ); + ( + Rc::new(RefCell::new(__it)), + Rc::new(RefCell::new(__inserted)), + ) + } + }; + let __rhs = (elem!( + ({ + (*arrays.borrow_mut()) + .subscript(key.as_pointer(), || ::default()) + }) + .with(|__s| __s.ptr.clone()), + 1 + ) + .read()); + value = __rhs } }; - let __rhs = (elem!( - ({ - (*arrays.borrow_mut()) - .subscript(key.as_pointer(), || ::default()) - }) - .with(|__s| __s.ptr.clone()), - 1 - ) - .read()); - value = __rhs + assert!( + (temporary_calls_4.with(|rc| *rc.borrow()) == (before + 1)) + && (value == (if (hit != 0) { 10 } else { 7 })) + ); } - }; - assert!( - (temporary_calls_4.with(|rc| *rc.borrow()) == (before + 1)) - && (value == (if (hit != 0) { 10 } else { 7 })) - ); - choose.prefix_inc(); + choose.prefix_inc(); + } } } hit.prefix_inc(); @@ -1640,277 +1678,242 @@ fn main_0() -> i32 { { let mut hit: i32 = 0; 'loop_: while (hit < 2) { - let values: Value, Value)>> = - Rc::new(RefCell::new(Map::new())); - let keys: Value> = Rc::new(RefCell::new(Box::new([0, 1, 2, 3, 4, 5]))); - if (hit != 0) { - 'loop_: for k in IterRange::new(keys.decay(), keys.decay().offset((6_i64) as isize)) - { - let k: Value = Rc::new(RefCell::new((k.read()))); - ({ (*values.borrow_mut()).subscript(k.as_pointer(), || 0_i32) }).write(42); - } - } - let mut before: i32 = temporary_calls_4.with(|rc| *rc.borrow()); - let mut index: i32 = 0; - let arrow: Value<( - Value, Value)>>, - Value, - )> = Rc::new(RefCell::new({ - let mut __tmp_94: Option>; - match (field_ptr!( - (*{ - __tmp_94 = Some(Rc::new(RefCell::new(Temporary::new()))); - &mut __tmp_94 - }) - .as_pointer(), - n - ),) - { - (__tmp_93,) => { - let (__it, __inserted) = - Map::emplace(values.as_pointer(), &keys.decay().offset(0), || { - ( - Rc::new(RefCell::new(keys.decay().offset(0).read())), - Rc::new(RefCell::new((__tmp_93.read()))), - ) - }); - ( - Rc::new(RefCell::new(__it)), - Rc::new(RefCell::new(__inserted)), - ) + 'for_body: { + let values: Value, Value)>> = + Rc::new(RefCell::new(Map::new())); + let keys: Value> = Rc::new(RefCell::new(Box::new([0, 1, 2, 3, 4, 5]))); + if (hit != 0) { + 'loop_: for k in + IterRange::new(keys.decay(), keys.decay().offset((6_i64) as isize)) + { + let k: Value = Rc::new(RefCell::new((k.read()))); + ({ (*values.borrow_mut()).subscript(k.as_pointer(), || 0_i32) }).write(42); } } - })); - let nested: Value<( - Value, Value)>>, - Value, - )> = Rc::new(RefCell::new({ - let mut __tmp_96: Option>; - match (field_ptr!( - field_ptr!( + let mut before: i32 = temporary_calls_4.with(|rc| *rc.borrow()); + let mut index: i32 = 0; + let arrow: Value<( + Value, Value)>>, + Value, + )> = Rc::new(RefCell::new({ + let mut __tmp_94: Option>; + match (field_ptr!( (*{ - __tmp_96 = Some(Rc::new(RefCell::new(::default()))); - &mut __tmp_96 + __tmp_94 = Some(Rc::new(RefCell::new(Temporary::new()))); + &mut __tmp_94 }) .as_pointer(), - inner - ), - n - ),) - { - (__tmp_95,) => { - let (__it, __inserted) = - Map::emplace(values.as_pointer(), &keys.decay().offset(1), || { - ( - Rc::new(RefCell::new(keys.decay().offset(1).read())), - Rc::new(RefCell::new((__tmp_95.read()))), - ) - }); - ( - Rc::new(RefCell::new(__it)), - Rc::new(RefCell::new(__inserted)), - ) - } - } - })); - let element: Value<( - Value, Value)>>, - Value, - )> = Rc::new(RefCell::new({ - let mut __tmp_98: Option>; - match (array_field_ptr!( - (*{ - __tmp_98 = Some(Rc::new(RefCell::new(Temporary::new()))); - &mut __tmp_98 - }) - .as_pointer(), - data - ) - .offset((index.postfix_inc()) as isize),) - { - (__tmp_97,) => { - let (__it, __inserted) = - Map::emplace(values.as_pointer(), &keys.decay().offset(2), || { - ( - Rc::new(RefCell::new(keys.decay().offset(2).read())), - Rc::new(RefCell::new((__tmp_97.read()))), - ) - }); - ( - Rc::new(RefCell::new(__it)), - Rc::new(RefCell::new(__inserted)), - ) + n + ),) + { + (__tmp_93,) => { + let (__it, __inserted) = + Map::emplace(values.as_pointer(), &keys.decay().offset(0), || { + ( + Rc::new(RefCell::new(keys.decay().offset(0).read())), + Rc::new(RefCell::new((__tmp_93.read()))), + ) + }); + ( + Rc::new(RefCell::new(__it)), + Rc::new(RefCell::new(__inserted)), + ) + } } - } - })); - let get: Value<( - Value, Value)>>, - Value, - )> = Rc::new(RefCell::new({ - let mut __tmp_100: Option>; - match (field_ptr!( - (*{ - __tmp_100 = Some(Rc::new(RefCell::new(Temporary::new()))); - &mut __tmp_100 - }) - .as_pointer(), - n - ),) - { - (__tmp_99,) => { - let (__it, __inserted) = - Map::emplace(values.as_pointer(), &keys.decay().offset(3), || { - ( - Rc::new(RefCell::new(keys.decay().offset(3).read())), - Rc::new(RefCell::new((__tmp_99.read()))), - ) - }); - ( - Rc::new(RefCell::new(__it)), - Rc::new(RefCell::new(__inserted)), - ) + })); + let nested: Value<( + Value, Value)>>, + Value, + )> = Rc::new(RefCell::new({ + let mut __tmp_96: Option>; + match (field_ptr!( + field_ptr!( + (*{ + __tmp_96 = Some(Rc::new(RefCell::new(::default()))); + &mut __tmp_96 + }) + .as_pointer(), + inner + ), + n + ),) + { + (__tmp_95,) => { + let (__it, __inserted) = + Map::emplace(values.as_pointer(), &keys.decay().offset(1), || { + ( + Rc::new(RefCell::new(keys.decay().offset(1).read())), + Rc::new(RefCell::new((__tmp_95.read()))), + ) + }); + ( + Rc::new(RefCell::new(__it)), + Rc::new(RefCell::new(__inserted)), + ) + } } - } - })); - let deref: Value<( - Value, Value)>>, - Value, - )> = Rc::new(RefCell::new({ - let mut __tmp_102: Option>; - match (field_ptr!( - ((*{ - __tmp_102 = Some(Rc::new(RefCell::new(Temporary::new()))); - &mut __tmp_102 - }) - .as_pointer()), - n - ),) - { - (__tmp_101,) => { - let (__it, __inserted) = - Map::emplace(values.as_pointer(), &keys.decay().offset(4), || { - ( - Rc::new(RefCell::new(keys.decay().offset(4).read())), - Rc::new(RefCell::new((__tmp_101.read()))), - ) - }); - ( - Rc::new(RefCell::new(__it)), - Rc::new(RefCell::new(__inserted)), - ) + })); + let element: Value<( + Value, Value)>>, + Value, + )> = Rc::new(RefCell::new({ + let mut __tmp_98: Option>; + match (array_field_ptr!( + (*{ + __tmp_98 = Some(Rc::new(RefCell::new(Temporary::new()))); + &mut __tmp_98 + }) + .as_pointer(), + data + ) + .offset((index.postfix_inc()) as isize),) + { + (__tmp_97,) => { + let (__it, __inserted) = + Map::emplace(values.as_pointer(), &keys.decay().offset(2), || { + ( + Rc::new(RefCell::new(keys.decay().offset(2).read())), + Rc::new(RefCell::new((__tmp_97.read()))), + ) + }); + ( + Rc::new(RefCell::new(__it)), + Rc::new(RefCell::new(__inserted)), + ) + } } - } - })); - let indirect: Value<( - Value, Value)>>, - Value, - )> = Rc::new(RefCell::new({ - let mut __tmp_104: Option>>>; - match (field_ptr!( - ((*(*{ - __tmp_104 = Some(Rc::new(RefCell::new(Some(Rc::new(RefCell::new( - Temporary::new(), - )))))); - &mut __tmp_104 - }) - .as_pointer() - .upgrade() - .deref()) - .as_pointer()), - n - ),) - { - (__tmp_103,) => { - let (__it, __inserted) = - Map::emplace(values.as_pointer(), &keys.decay().offset(5), || { - ( - Rc::new(RefCell::new(keys.decay().offset(5).read())), - Rc::new(RefCell::new((__tmp_103.read()))), - ) - }); - ( - Rc::new(RefCell::new(__it)), - Rc::new(RefCell::new(__inserted)), - ) + })); + let get: Value<( + Value, Value)>>, + Value, + )> = Rc::new(RefCell::new({ + let mut __tmp_100: Option>; + match (field_ptr!( + (*{ + __tmp_100 = Some(Rc::new(RefCell::new(Temporary::new()))); + &mut __tmp_100 + }) + .as_pointer(), + n + ),) + { + (__tmp_99,) => { + let (__it, __inserted) = + Map::emplace(values.as_pointer(), &keys.decay().offset(3), || { + ( + Rc::new(RefCell::new(keys.decay().offset(3).read())), + Rc::new(RefCell::new((__tmp_99.read()))), + ) + }); + ( + Rc::new(RefCell::new(__it)), + Rc::new(RefCell::new(__inserted)), + ) + } } - } - })); - assert!((temporary_calls_4.with(|rc| *rc.borrow()) == (before + 6)) && (index == 1)); - assert!( - ({ - (((((((*(*arrow.borrow()).1.borrow()) as i32) == (!(hit != 0) as i32)) - && (((*(*nested.borrow()).1.borrow()) as i32) == (!(hit != 0) as i32))) - && (((*(*element.borrow()).1.borrow()) as i32) == (!(hit != 0) as i32))) - && (((*(*get.borrow()).1.borrow()) as i32) == (!(hit != 0) as i32))) - && (((*(*deref.borrow()).1.borrow()) as i32) == (!(hit != 0) as i32))) - && (((*(*indirect.borrow()).1.borrow()) as i32) == (!(hit != 0) as i32)) - }) - ); - 'loop_: for k in IterRange::new(keys.decay(), keys.decay().offset((6_i64) as isize)) { - let k: Value = Rc::new(RefCell::new((k.read()))); - assert!( - ({ - ((({ (*values.borrow_mut()).subscript(k.as_pointer(), || 0_i32) }).read()) - == (if (hit != 0) { - 42 - } else { - if ((*k.borrow()) == 2) { 6 } else { 5 } - })) - }) - ); - } - { - let mut choose: i32 = 0; - 'loop_: while (choose < 2) { - let references: Value, Value)>> = - Rc::new(RefCell::new(Map::new())); - let ordinary: Value = Rc::new(RefCell::new(9)); - if (hit != 0) { - { + })); + let deref: Value<( + Value, Value)>>, + Value, + )> = Rc::new(RefCell::new({ + let mut __tmp_102: Option>; + match (field_ptr!( + ((*{ + __tmp_102 = Some(Rc::new(RefCell::new(Temporary::new()))); + &mut __tmp_102 + }) + .as_pointer()), + n + ),) + { + (__tmp_101,) => { let (__it, __inserted) = - Map::emplace(references.as_pointer(), &key.as_pointer(), || { + Map::emplace(values.as_pointer(), &keys.decay().offset(4), || { ( - Rc::new(RefCell::new(key.as_pointer().read())), - Rc::new(RefCell::new(Held::new_1({ - ordinary.as_pointer() - }))), + Rc::new(RefCell::new(keys.decay().offset(4).read())), + Rc::new(RefCell::new((__tmp_101.read()))), ) }); ( Rc::new(RefCell::new(__it)), Rc::new(RefCell::new(__inserted)), ) - }; + } } - before = temporary_calls_4.with(|rc| *rc.borrow()); - index = 0; - let mut value: i32 = 0; + })); + let indirect: Value<( + Value, Value)>>, + Value, + )> = Rc::new(RefCell::new({ + let mut __tmp_104: Option>>>; + match (field_ptr!( + ((*(*{ + __tmp_104 = Some(Rc::new(RefCell::new(Some(Rc::new(RefCell::new( + Temporary::new(), + )))))); + &mut __tmp_104 + }) + .as_pointer() + .upgrade() + .deref()) + .as_pointer()), + n + ),) { - let mut __tmp_106: Option>; - let mut __tmp_107: Option>; - { - match (if (choose != 0) { - field_ptr!( - (*{ - __tmp_106 = Some(Rc::new(RefCell::new(Temporary::new()))); - &mut __tmp_106 - }) - .as_pointer(), - n - ) - } else { - array_field_ptr!( - (*{ - __tmp_107 = Some(Rc::new(RefCell::new(Temporary::new()))); - &mut __tmp_107 - }) - .as_pointer(), - data - ) - .offset((index.postfix_inc()) as isize) - },) - { - (__tmp_105,) => { + (__tmp_103,) => { + let (__it, __inserted) = + Map::emplace(values.as_pointer(), &keys.decay().offset(5), || { + ( + Rc::new(RefCell::new(keys.decay().offset(5).read())), + Rc::new(RefCell::new((__tmp_103.read()))), + ) + }); + ( + Rc::new(RefCell::new(__it)), + Rc::new(RefCell::new(__inserted)), + ) + } + } + })); + assert!( + (temporary_calls_4.with(|rc| *rc.borrow()) == (before + 6)) && (index == 1) + ); + assert!( + ({ + (((((((*(*arrow.borrow()).1.borrow()) as i32) == (!(hit != 0) as i32)) + && (((*(*nested.borrow()).1.borrow()) as i32) + == (!(hit != 0) as i32))) + && (((*(*element.borrow()).1.borrow()) as i32) + == (!(hit != 0) as i32))) + && (((*(*get.borrow()).1.borrow()) as i32) == (!(hit != 0) as i32))) + && (((*(*deref.borrow()).1.borrow()) as i32) == (!(hit != 0) as i32))) + && (((*(*indirect.borrow()).1.borrow()) as i32) == (!(hit != 0) as i32)) + }) + ); + 'loop_: for k in IterRange::new(keys.decay(), keys.decay().offset((6_i64) as isize)) + { + let k: Value = Rc::new(RefCell::new((k.read()))); + assert!( + ({ + ((({ (*values.borrow_mut()).subscript(k.as_pointer(), || 0_i32) }) + .read()) + == (if (hit != 0) { + 42 + } else { + if ((*k.borrow()) == 2) { 6 } else { 5 } + })) + }) + ); + } + { + let mut choose: i32 = 0; + 'loop_: while (choose < 2) { + 'for_body: { + let references: Value, Value)>> = + Rc::new(RefCell::new(Map::new())); + let ordinary: Value = Rc::new(RefCell::new(9)); + if (hit != 0) { + { let (__it, __inserted) = Map::emplace( references.as_pointer(), &key.as_pointer(), @@ -1918,7 +1921,7 @@ fn main_0() -> i32 { ( Rc::new(RefCell::new(key.as_pointer().read())), Rc::new(RefCell::new(Held::new_1({ - (__tmp_105).clone() + ordinary.as_pointer() }))), ) }, @@ -1927,71 +1930,126 @@ fn main_0() -> i32 { Rc::new(RefCell::new(__it)), Rc::new(RefCell::new(__inserted)), ) + }; + } + before = temporary_calls_4.with(|rc| *rc.borrow()); + index = 0; + let mut value: i32 = 0; + { + let mut __tmp_106: Option>; + let mut __tmp_107: Option>; + { + match (if (choose != 0) { + field_ptr!( + (*{ + __tmp_106 = + Some(Rc::new(RefCell::new(Temporary::new()))); + &mut __tmp_106 + }) + .as_pointer(), + n + ) + } else { + array_field_ptr!( + (*{ + __tmp_107 = + Some(Rc::new(RefCell::new(Temporary::new()))); + &mut __tmp_107 + }) + .as_pointer(), + data + ) + .offset((index.postfix_inc()) as isize) + },) + { + (__tmp_105,) => { + let (__it, __inserted) = Map::emplace( + references.as_pointer(), + &key.as_pointer(), + || { + ( + Rc::new(RefCell::new( + key.as_pointer().read(), + )), + Rc::new(RefCell::new(Held::new_1({ + (__tmp_105).clone() + }))), + ) + }, + ); + ( + Rc::new(RefCell::new(__it)), + Rc::new(RefCell::new(__inserted)), + ) + } + }; + let __rhs = (({ + (*references.borrow_mut()) + .subscript(key.as_pointer(), || ::default()) + }) + .with(|__s| __s.ptr.clone()) + .read()); + value = __rhs } }; - let __rhs = (({ - (*references.borrow_mut()) - .subscript(key.as_pointer(), || ::default()) - }) - .with(|__s| __s.ptr.clone()) - .read()); - value = __rhs - } - }; - assert!( - (temporary_calls_4.with(|rc| *rc.borrow()) == (before + 1)) - && (index == (if (choose != 0) { 0 } else { 1 })) - ); - assert!( - (value - == (if (hit != 0) { - 9 - } else { - if (choose != 0) { 5 } else { 6 } - })) - ); - let owners: Value, Value)>> = - Rc::new(RefCell::new(Map::new())); - { - let __tmp_109: Value; - { - match (({ - OwnerImpl::value(&{ - __tmp_109 = Rc::new(RefCell::new(Owner::new())); - __tmp_109.as_pointer() - }) - }),) + assert!( + (temporary_calls_4.with(|rc| *rc.borrow()) == (before + 1)) + && (index == (if (choose != 0) { 0 } else { 1 })) + ); + assert!( + (value + == (if (hit != 0) { + 9 + } else { + if (choose != 0) { 5 } else { 6 } + })) + ); + let owners: Value, Value)>> = + Rc::new(RefCell::new(Map::new())); { - (__tmp_108,) => { - let (__it, __inserted) = Map::emplace( - owners.as_pointer(), - &key.as_pointer(), - || { + let __tmp_109: Value; + { + match (({ + OwnerImpl::value(&{ + __tmp_109 = Rc::new(RefCell::new(Owner::new())); + __tmp_109.as_pointer() + }) + }),) + { + (__tmp_108,) => { + let (__it, __inserted) = Map::emplace( + owners.as_pointer(), + &key.as_pointer(), + || { + ( + Rc::new(RefCell::new( + key.as_pointer().read(), + )), + Rc::new(RefCell::new(Held::new_1({ + (__tmp_108).clone() + }))), + ) + }, + ); ( - Rc::new(RefCell::new(key.as_pointer().read())), - Rc::new(RefCell::new(Held::new_1({ - (__tmp_108).clone() - }))), + Rc::new(RefCell::new(__it)), + Rc::new(RefCell::new(__inserted)), ) - }, - ); - ( - Rc::new(RefCell::new(__it)), - Rc::new(RefCell::new(__inserted)), - ) + } + }; + let __rhs = (({ + (*owners.borrow_mut()) + .subscript(key.as_pointer(), || ::default()) + }) + .with(|__s| __s.ptr.clone()) + .read()); + value = __rhs } }; - let __rhs = (({ - (*owners.borrow_mut()) - .subscript(key.as_pointer(), || ::default()) - }) - .with(|__s| __s.ptr.clone()) - .read()); - value = __rhs + assert!((value == 5)); } - }; - assert!((value == 5)); - choose.prefix_inc(); + choose.prefix_inc(); + } } } hit.prefix_inc(); diff --git a/tests/unit/out/refcount/matmul.rs b/tests/unit/out/refcount/matmul.rs index a9ebafd2d1..83746b684b 100644 --- a/tests/unit/out/refcount/matmul.rs +++ b/tests/unit/out/refcount/matmul.rs @@ -17,27 +17,32 @@ pub fn matalloc_0( { let mut i: i32 = 0; 'loop_: while (i < n) { - match ( - m.decay().offset((i as usize)), - Rc::new(RefCell::new(Some(Rc::new(RefCell::new( - (0..(p as usize)).map(|_| 0_i32).collect::>(), - ))))) - .as_pointer(), - ) { - (__tmp_0, __tmp_1) => __tmp_0.with_mut(|__b0| { - (*__b0) = __tmp_1.with_mut(|__v: &mut Option>>| __v.take()); - }), - }; - { - let mut j: i32 = 0; - 'loop_: while (j < p) { - ({ - (*m.decay().offset((i as usize)).upgrade().deref()) - .decay() - .offset((j as usize)) - }) - .write(e); - j.prefix_inc(); + 'for_body: { + match ( + m.decay().offset((i as usize)), + Rc::new(RefCell::new(Some(Rc::new(RefCell::new( + (0..(p as usize)).map(|_| 0_i32).collect::>(), + ))))) + .as_pointer(), + ) { + (__tmp_0, __tmp_1) => __tmp_0.with_mut(|__b0| { + (*__b0) = + __tmp_1.with_mut(|__v: &mut Option>>| __v.take()); + }), + }; + { + let mut j: i32 = 0; + 'loop_: while (j < p) { + 'for_body: { + ({ + (*m.decay().offset((i as usize)).upgrade().deref()) + .decay() + .offset((j as usize)) + }) + .write(e); + } + j.prefix_inc(); + } } } i.prefix_inc(); @@ -57,35 +62,41 @@ pub fn matmul_1( { let mut i: i32 = 0; 'loop_: while (i < n1) { - { - let mut j: i32 = 0; - let mut sum: i32 = 0; - 'loop_: while (j < p2) { - { - let mut k: i32 = 0; - 'loop_: while (k < p1) { - sum += ((({ - (*m1.decay().offset((i as usize)).upgrade().deref()) + 'for_body: { + { + let mut j: i32 = 0; + let mut sum: i32 = 0; + 'loop_: while (j < p2) { + 'for_body: { + { + let mut k: i32 = 0; + 'loop_: while (k < p1) { + 'for_body: { + sum += ((({ + (*m1.decay().offset((i as usize)).upgrade().deref()) + .decay() + .offset((k as usize)) + }) + .read()) + * (({ + (*m2.decay().offset((k as usize)).upgrade().deref()) + .decay() + .offset((j as usize)) + }) + .read())); + } + k.prefix_inc(); + } + } + ({ + (*m3.decay().offset((i as usize)).upgrade().deref()) .decay() - .offset((k as usize)) + .offset((j as usize)) }) - .read()) - * (({ - (*m2.decay().offset((k as usize)).upgrade().deref()) - .decay() - .offset((j as usize)) - }) - .read())); - k.prefix_inc(); + .write(sum); } + j.prefix_inc(); } - ({ - (*m3.decay().offset((i as usize)).upgrade().deref()) - .decay() - .offset((j as usize)) - }) - .write(sum); - j.prefix_inc(); } } i.prefix_inc(); diff --git a/tests/unit/out/refcount/max.rs b/tests/unit/out/refcount/max.rs index d95d481467..607f43cdfe 100644 --- a/tests/unit/out/refcount/max.rs +++ b/tests/unit/out/refcount/max.rs @@ -190,20 +190,22 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < 3) { - let __rhs = (({ - let __tmp_13: Value = Rc::new(RefCell::new((largest as u64))); - (match (Rc::new(RefCell::new((({ size_of_2(i) }) as u64))).as_pointer(),) { - (__tmp_12,) => { - if CppLess::less(&__tmp_13.as_pointer(), &(__tmp_12).clone()) { - (__tmp_12).clone() - } else { - __tmp_13.as_pointer() + 'for_body: { + let __rhs = (({ + let __tmp_13: Value = Rc::new(RefCell::new((largest as u64))); + (match (Rc::new(RefCell::new((({ size_of_2(i) }) as u64))).as_pointer(),) { + (__tmp_12,) => { + if CppLess::less(&__tmp_13.as_pointer(), &(__tmp_12).clone()) { + (__tmp_12).clone() + } else { + __tmp_13.as_pointer() + } } } - } - .read()) - }) as usize); - largest = __rhs; + .read()) + }) as usize); + largest = __rhs; + } i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/memset.rs b/tests/unit/out/refcount/memset.rs index 8e95b6e40a..849a422cb0 100644 --- a/tests/unit/out/refcount/memset.rs +++ b/tests/unit/out/refcount/memset.rs @@ -26,7 +26,9 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < N) { - sum += { (elem!(arr, i).read()) }; + 'for_body: { + sum += { (elem!(arr, i).read()) }; + } i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/nested_block_scope.rs b/tests/unit/out/refcount/nested_block_scope.rs index 6253cf5eb3..cec9254c85 100644 --- a/tests/unit/out/refcount/nested_block_scope.rs +++ b/tests/unit/out/refcount/nested_block_scope.rs @@ -26,12 +26,14 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < 3) { - let mut y: i32 = i; - { - let mut y: i32 = 10; + 'for_body: { + let mut y: i32 = i; + { + let mut y: i32 = 10; + sum += y; + } sum += y; } - sum += y; i.postfix_inc(); } } diff --git a/tests/unit/out/refcount/new_alloc_array.rs b/tests/unit/out/refcount/new_alloc_array.rs index 15998d9575..06169975af 100644 --- a/tests/unit/out/refcount/new_alloc_array.rs +++ b/tests/unit/out/refcount/new_alloc_array.rs @@ -25,7 +25,9 @@ fn main_0() -> i32 { { let mut p1: Ptr = (array).clone(); 'loop_: while ((p1.read()) >= 0) { - p1.write(1); + 'for_body: { + p1.write(1); + } p1.prefix_inc(); } } @@ -33,7 +35,9 @@ fn main_0() -> i32 { { let mut p1: Ptr = (array).clone(); 'loop_: while ((p1.read()) >= 0) { - out += { (p1.read()) }; + 'for_body: { + out += { (p1.read()) }; + } p1.prefix_inc(); } } diff --git a/tests/unit/out/refcount/new_array.rs b/tests/unit/out/refcount/new_array.rs index 418a50d04c..a226e1f40b 100644 --- a/tests/unit/out/refcount/new_array.rs +++ b/tests/unit/out/refcount/new_array.rs @@ -11,7 +11,9 @@ pub fn sum_0(mut p: Ptr, mut n: i32) -> i32 { { let mut i: i32 = 0; 'loop_: while (i < n) { - total += { (elem!(p, i).read()) }; + 'for_body: { + total += { (elem!(p, i).read()) }; + } i.prefix_inc(); } } @@ -30,7 +32,9 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < 4) { - elem!(filled, i).write({ (i + 1) }); + 'for_body: { + elem!(filled, i).write({ (i + 1) }); + } i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/null_in_statics.rs b/tests/unit/out/refcount/null_in_statics.rs index b68c91c401..017c886ee5 100644 --- a/tests/unit/out/refcount/null_in_statics.rs +++ b/tests/unit/out/refcount/null_in_statics.rs @@ -49,13 +49,15 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < 4) { - assert!( - ({ - let __idx0 = (i) as usize; - arr_of_ptr_3.with(|rc| rc.borrow()[__idx0].clone()) - }) - .is_null() - ); + 'for_body: { + assert!( + ({ + let __idx0 = (i) as usize; + arr_of_ptr_3.with(|rc| rc.borrow()[__idx0].clone()) + }) + .is_null() + ); + } i.prefix_inc(); } } @@ -63,13 +65,15 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < 3) { - assert!( - ({ - let __idx0 = (i) as usize; - const_arr_of_ptr_5.with(|rc| rc.borrow()[__idx0].clone()) - }) - .is_null() - ); + 'for_body: { + assert!( + ({ + let __idx0 = (i) as usize; + const_arr_of_ptr_5.with(|rc| rc.borrow()[__idx0].clone()) + }) + .is_null() + ); + } i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/pointer_array.rs b/tests/unit/out/refcount/pointer_array.rs index 4a20b54e44..99d3db82ff 100644 --- a/tests/unit/out/refcount/pointer_array.rs +++ b/tests/unit/out/refcount/pointer_array.rs @@ -28,9 +28,11 @@ pub fn IncrementAll_0(s: Ptr) { { let mut i: i32 = 0; 'loop_: while (i < 3) { - { - (array_elem!(s, arr, i).read()).with_mut(|__v| *__v = *__v + 1) - }; + 'for_body: { + { + (array_elem!(s, arr, i).read()).with_mut(|__v| *__v = *__v + 1) + }; + } i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/pointer_call_offset.rs b/tests/unit/out/refcount/pointer_call_offset.rs index 236a24ec49..0758bd6d04 100644 --- a/tests/unit/out/refcount/pointer_call_offset.rs +++ b/tests/unit/out/refcount/pointer_call_offset.rs @@ -18,7 +18,9 @@ fn main_0() -> i32 { { let mut i: u32 = 0_u32; 'loop_: while (i < 10_u32) { - elem!(p1, i).write({ (i as i32) }); + 'for_body: { + elem!(p1, i).write({ (i as i32) }); + } i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/pointer_offset.rs b/tests/unit/out/refcount/pointer_offset.rs index 5626d8c4c6..16d046d86c 100644 --- a/tests/unit/out/refcount/pointer_offset.rs +++ b/tests/unit/out/refcount/pointer_offset.rs @@ -16,35 +16,45 @@ fn main_0() -> i32 { { let mut ptr: Ptr = (arr.decay().offset(0)); 'loop_: while ((ptr.read()) != 0) { - out += { (ptr.read()) }; + 'for_body: { + out += { (ptr.read()) }; + } ptr.prefix_inc(); } } { let mut ptr: Ptr = (arr.decay().offset(1)); 'loop_: while ((ptr.read()) != 4) { - out += { (ptr.read()) }; + 'for_body: { + out += { (ptr.read()) }; + } ptr.postfix_inc(); } } { let mut ptr: Ptr = (arr.decay().offset(4)); 'loop_: while ((ptr.read()) != 1) { - out += { (ptr.read()) }; + 'for_body: { + out += { (ptr.read()) }; + } ptr.postfix_dec(); } } { let mut ptr: Ptr = (arr.decay().offset(3)); 'loop_: while ((ptr.read()) != 2) { - out += { (ptr.read()) }; + 'for_body: { + out += { (ptr.read()) }; + } ptr.prefix_dec(); } } { let mut ptr: Ptr = (arr.decay().offset(0)); 'loop_: while ((ptr.read()) != 0) { - out += { (ptr.read()) }; + 'for_body: { + out += { (ptr.read()) }; + } ptr = { ptr.offset((1) as isize) }; } } @@ -52,7 +62,9 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < 5) { - out += { (elem!(ptr, i).read()) }; + 'for_body: { + out += { (elem!(ptr, i).read()) }; + } i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/pointer_usize_arith.rs b/tests/unit/out/refcount/pointer_usize_arith.rs index 86ef8e9a83..a4bd96f796 100644 --- a/tests/unit/out/refcount/pointer_usize_arith.rs +++ b/tests/unit/out/refcount/pointer_usize_arith.rs @@ -53,7 +53,9 @@ fn main_0() -> i32 { { let mut it: Ptr = (p).clone(); 'loop_: while ({ (it).clone() } != { (end).clone() }) { - sum += { (it.read()) }; + 'for_body: { + sum += { (it.read()) }; + } it.prefix_inc(); } } diff --git a/tests/unit/out/refcount/qsort_bsearch.rs b/tests/unit/out/refcount/qsort_bsearch.rs index 525bc23b5a..797963feed 100644 --- a/tests/unit/out/refcount/qsort_bsearch.rs +++ b/tests/unit/out/refcount/qsort_bsearch.rs @@ -47,7 +47,9 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < 7) { - assert!(({ ((*arr.borrow())[(i) as usize] <= (*arr.borrow())[(i + 1) as usize]) })); + 'for_body: { + assert!(({ ((*arr.borrow())[(i) as usize] <= (*arr.borrow())[(i + 1) as usize]) })); + } i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/reinterpret_cast_iterate.rs b/tests/unit/out/refcount/reinterpret_cast_iterate.rs index 22acc84b1f..0d5b9293bc 100644 --- a/tests/unit/out/refcount/reinterpret_cast_iterate.rs +++ b/tests/unit/out/refcount/reinterpret_cast_iterate.rs @@ -19,7 +19,9 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < 8) { - assert!(({ ((elem!(words, i).read()) as i32) } == { (((i + 1) as u16) as i32) })); + 'for_body: { + assert!(({ ((elem!(words, i).read()) as i32) } == { (((i + 1) as u16) as i32) })); + } i.postfix_inc(); } } diff --git a/tests/unit/out/refcount/reinterpret_cast_large_array.rs b/tests/unit/out/refcount/reinterpret_cast_large_array.rs index 717ec4629f..b0003968ec 100644 --- a/tests/unit/out/refcount/reinterpret_cast_large_array.rs +++ b/tests/unit/out/refcount/reinterpret_cast_large_array.rs @@ -17,7 +17,9 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < N) { - elem!(arr, i).write(0_u32); + 'for_body: { + elem!(arr, i).write(0_u32); + } i.postfix_inc(); } } diff --git a/tests/unit/out/refcount/rule_of_five.rs b/tests/unit/out/refcount/rule_of_five.rs index b7962902db..fd16015e5d 100644 --- a/tests/unit/out/refcount/rule_of_five.rs +++ b/tests/unit/out/refcount/rule_of_five.rs @@ -37,7 +37,9 @@ impl Buffer { { let mut i: i32 = 0; 'loop_: while (i < 4) { - array_elem!(this, data, i).write({ if (i < size) { i } else { -1_i32 } }); + 'for_body: { + array_elem!(this, data, i).write({ if (i < size) { i } else { -1_i32 } }); + } i.prefix_inc(); } } @@ -53,7 +55,9 @@ impl Buffer { { let mut i: i32 = 0; 'loop_: while (i < 4) { - array_elem!(this, data, i).write({ (array_elem!(o, data, i).read()) }); + 'for_body: { + array_elem!(this, data, i).write({ (array_elem!(o, data, i).read()) }); + } i.prefix_inc(); } } @@ -70,8 +74,10 @@ impl Buffer { { let mut i: i32 = 0; 'loop_: while (i < 4) { - array_elem!(this, data, i).write({ (array_elem!(o, data, i).read()) }); - array_elem!(o, data, i).write(-1_i32); + 'for_body: { + array_elem!(this, data, i).write({ (array_elem!(o, data, i).read()) }); + array_elem!(o, data, i).write(-1_i32); + } i.prefix_inc(); } } @@ -181,7 +187,9 @@ impl BufferImpl for Ptr { { let mut i: i32 = 0; 'loop_: while (i < 4) { - array_elem!((*self), data, i).write({ (array_elem!(o, data, i).read()) }); + 'for_body: { + array_elem!((*self), data, i).write({ (array_elem!(o, data, i).read()) }); + } i.prefix_inc(); } } @@ -196,8 +204,10 @@ impl BufferImpl for Ptr { { let mut i: i32 = 0; 'loop_: while (i < 4) { - array_elem!((*self), data, i).write({ (array_elem!(o, data, i).read()) }); - array_elem!(o, data, i).write(-1_i32); + 'for_body: { + array_elem!((*self), data, i).write({ (array_elem!(o, data, i).read()) }); + array_elem!(o, data, i).write(-1_i32); + } i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/rule_of_three.rs b/tests/unit/out/refcount/rule_of_three.rs index 20c136e639..b1bdcc7384 100644 --- a/tests/unit/out/refcount/rule_of_three.rs +++ b/tests/unit/out/refcount/rule_of_three.rs @@ -32,7 +32,9 @@ impl Buffer { { let mut i: i32 = 0; 'loop_: while (i < 4) { - array_elem!(this, data, i).write({ if (i < size) { i } else { -1_i32 } }); + 'for_body: { + array_elem!(this, data, i).write({ if (i < size) { i } else { -1_i32 } }); + } i.prefix_inc(); } } @@ -48,7 +50,9 @@ impl Buffer { { let mut i: i32 = 0; 'loop_: while (i < 4) { - array_elem!(this, data, i).write({ (array_elem!(o, data, i).read()) }); + 'for_body: { + array_elem!(this, data, i).write({ (array_elem!(o, data, i).read()) }); + } i.prefix_inc(); } } @@ -81,7 +85,9 @@ pub fn sum_2(b: Ptr) -> i32 { { let mut i: i32 = 0; 'loop_: while ({ i } < { b.with(|__s| __s.size) }) { - s += (array_elem!(b, data, i).read()); + 'for_body: { + s += (array_elem!(b, data, i).read()); + } i.prefix_inc(); } } @@ -152,7 +158,9 @@ impl BufferImpl for Ptr { { let mut i: i32 = 0; 'loop_: while (i < 4) { - array_elem!((*self), data, i).write({ (array_elem!(o, data, i).read()) }); + 'for_body: { + array_elem!((*self), data, i).write({ (array_elem!(o, data, i).read()) }); + } i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/size_t_ssize_t.rs b/tests/unit/out/refcount/size_t_ssize_t.rs index 5a16651571..e329c56467 100644 --- a/tests/unit/out/refcount/size_t_ssize_t.rs +++ b/tests/unit/out/refcount/size_t_ssize_t.rs @@ -99,7 +99,9 @@ fn main_0() -> i32 { { let mut i: usize = 0_usize; 'loop_: while (i < count) { - data[(i) as usize] = { (((i).wrapping_mul(2_usize)) as i32) }; + 'for_body: { + data[(i) as usize] = { (((i).wrapping_mul(2_usize)) as i32) }; + } i.postfix_inc(); } } @@ -107,7 +109,9 @@ fn main_0() -> i32 { { let mut i: usize = 0_usize; 'loop_: while (i < count) { - total = { (total).wrapping_add((data[(i) as usize] as usize)) }; + 'for_body: { + total = { (total).wrapping_add((data[(i) as usize] as usize)) }; + } i.postfix_inc(); } } diff --git a/tests/unit/out/refcount/socket_ip_name.rs b/tests/unit/out/refcount/socket_ip_name.rs index 04060a3d56..8945d002ea 100644 --- a/tests/unit/out/refcount/socket_ip_name.rs +++ b/tests/unit/out/refcount/socket_ip_name.rs @@ -41,7 +41,9 @@ pub fn check_buf_0( { let mut j: u32 = copied; 'loop_: while (j < size) { - assert!((((elem!(buf, j).read()) as i32) == 165)); + 'for_body: { + assert!((((elem!(buf, j).read()) as i32) == 165)); + } j.prefix_inc(); } } @@ -118,39 +120,41 @@ pub fn check_name_1(mut family: i32) { < (::std::mem::size_of::<[libc::socklen_t; 6]>() as usize) .wrapping_div((::std::mem::size_of::() as usize))) { - let out: Value> = - Rc::new(RefCell::new((0..136).map(|_| 0_u8).collect::>())); - ({ - let _buf: Ptr = out.decay(); - let _size: u32 = (::std::mem::size_of::<[u8; 136]>() as u32); - check_buf_0( - fd, - _buf, - _size, - capacities[(i) as usize], - (full.as_pointer()).to_any(), - actual, - ) - }); - let mut size: u32 = (if (capacities[(i) as usize] != 0) { - capacities[(i) as usize] - } else { - (1 as libc::socklen_t) - } as u32); - let mut small: Ptr = - libcc2rs::malloc_refcount((size as usize)).reinterpret_cast::(); - assert!(!(small).is_null()); - ({ - check_buf_0( - fd, - (small).clone(), - size, - capacities[(i) as usize], - (full.as_pointer()).to_any(), - actual, - ) - }); - libcc2rs::free_refcount((small).to_any()); + 'for_body: { + let out: Value> = + Rc::new(RefCell::new((0..136).map(|_| 0_u8).collect::>())); + ({ + let _buf: Ptr = out.decay(); + let _size: u32 = (::std::mem::size_of::<[u8; 136]>() as u32); + check_buf_0( + fd, + _buf, + _size, + capacities[(i) as usize], + (full.as_pointer()).to_any(), + actual, + ) + }); + let mut size: u32 = (if (capacities[(i) as usize] != 0) { + capacities[(i) as usize] + } else { + (1 as libc::socklen_t) + } as u32); + let mut small: Ptr = + libcc2rs::malloc_refcount((size as usize)).reinterpret_cast::(); + assert!(!(small).is_null()); + ({ + check_buf_0( + fd, + (small).clone(), + size, + capacities[(i) as usize], + (full.as_pointer()).to_any(), + actual, + ) + }); + libcc2rs::free_refcount((small).to_any()); + } i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/socket_recvfrom_name.rs b/tests/unit/out/refcount/socket_recvfrom_name.rs index 29a4f4536d..e90ffa5954 100644 --- a/tests/unit/out/refcount/socket_recvfrom_name.rs +++ b/tests/unit/out/refcount/socket_recvfrom_name.rs @@ -76,9 +76,12 @@ pub fn check_from_0( { let mut i: u32 = ((*len.borrow()) as u32); 'loop_: while ((i as usize) < 128usize) { - assert!( - (((elem!(((from.as_pointer()).reinterpret_cast::()), i).read()) as i32) == 165) - ); + 'for_body: { + assert!( + (((elem!(((from.as_pointer()).reinterpret_cast::()), i).read()) as i32) + == 165) + ); + } i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/socket_unix_name.rs b/tests/unit/out/refcount/socket_unix_name.rs index 513d5c0a11..5f4036df13 100644 --- a/tests/unit/out/refcount/socket_unix_name.rs +++ b/tests/unit/out/refcount/socket_unix_name.rs @@ -83,47 +83,52 @@ pub fn check_name_0(mut fd: i32, mut path: Ptr) { < (::std::mem::size_of::<[libc::socklen_t; 6]>() as usize) .wrapping_div((::std::mem::size_of::() as usize))) { - let out: Value> = - Rc::new(RefCell::new((0..136).map(|_| 0_u8).collect::>())); - { - let mut __tmp_3 = { (out.decay()).to_any() }; - __tmp_3.memset((165) as u8, ::std::mem::size_of::<[u8; 136]>()); - (__tmp_3).clone() - }; - let len: Value = Rc::new(RefCell::new(capacities[(i) as usize])); - assert!( - ({ - let mut __tmp_4 = { out.decay().reinterpret_cast::() }; - let mut __tmp_5 = { (len.as_pointer()) }; - match nix::sys::socket::getsockname::(fd) { - Ok(__ss) => { - Sockaddr::encode(&__ss, &__tmp_4, &__tmp_5); - 0 + 'for_body: { + let out: Value> = + Rc::new(RefCell::new((0..136).map(|_| 0_u8).collect::>())); + { + let mut __tmp_3 = { (out.decay()).to_any() }; + __tmp_3.memset((165) as u8, ::std::mem::size_of::<[u8; 136]>()); + (__tmp_3).clone() + }; + let len: Value = Rc::new(RefCell::new(capacities[(i) as usize])); + assert!( + ({ + let mut __tmp_4 = { out.decay().reinterpret_cast::() }; + let mut __tmp_5 = { (len.as_pointer()) }; + match nix::sys::socket::getsockname::(fd) + { + Ok(__ss) => { + Sockaddr::encode(&__ss, &__tmp_4, &__tmp_5); + 0 + } + Err(__e) => { + libcc2rs::cpp2rust_errno().write(__e as i32); + -1 + } } - Err(__e) => { - libcc2rs::cpp2rust_errno().write(__e as i32); - -1 + } == 0) + ); + assert!(({ ((*len.borrow()) == (*actual.borrow())) })); + let mut copied: u32 = (if (capacities[(i) as usize] < (*actual.borrow())) { + capacities[(i) as usize] + } else { + (*actual.borrow()) + } as u32); + assert!( + ((out.decay()) + .to_any() + .memcmp(&(full.as_pointer()).to_any(), (copied as usize)) + == 0) + ); + { + let mut j: u32 = copied; + 'loop_: while ((j as usize) < ::std::mem::size_of::<[u8; 136]>()) { + 'for_body: { + assert!(({ (((*out.borrow())[(j) as usize] as i32) == 165) })); } + j.prefix_inc(); } - } == 0) - ); - assert!(({ ((*len.borrow()) == (*actual.borrow())) })); - let mut copied: u32 = (if (capacities[(i) as usize] < (*actual.borrow())) { - capacities[(i) as usize] - } else { - (*actual.borrow()) - } as u32); - assert!( - ((out.decay()) - .to_any() - .memcmp(&(full.as_pointer()).to_any(), (copied as usize)) - == 0) - ); - { - let mut j: u32 = copied; - 'loop_: while ((j as usize) < ::std::mem::size_of::<[u8; 136]>()) { - assert!(({ (((*out.borrow())[(j) as usize] as i32) == 165) })); - j.prefix_inc(); } } i.prefix_inc(); diff --git a/tests/unit/out/refcount/sort.rs b/tests/unit/out/refcount/sort.rs index cfb8f8acf3..d92708451a 100644 --- a/tests/unit/out/refcount/sort.rs +++ b/tests/unit/out/refcount/sort.rs @@ -62,13 +62,15 @@ fn main_0() -> i32 { { let mut i: u32 = 0_u32; 'loop_: while ((i as usize) < ((*v.borrow()).len()).wrapping_sub(1_usize)) { - assert!( - ({ - ({ (*v.borrow())[(i as usize)] } < { - (*v.borrow())[(((i).wrapping_add(1_u32)) as usize)] + 'for_body: { + assert!( + ({ + ({ (*v.borrow())[(i as usize)] } < { + (*v.borrow())[(((i).wrapping_add(1_u32)) as usize)] + }) }) - }) - ); + ); + } i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/string.rs b/tests/unit/out/refcount/string.rs index 451b17926b..24d6905939 100644 --- a/tests/unit/out/refcount/string.rs +++ b/tests/unit/out/refcount/string.rs @@ -76,12 +76,14 @@ fn main_0() -> i32 { { let mut i: u32 = 0_u32; 'loop_: while ((i as usize) < ((*s2.borrow()).len() - 1)) { - assert!( - ({ - (((elem!(p2, i).read()) as i32) == (('a' as i8) as i32)) - && (({ (*s2.borrow())[(i as usize)] } as i32) == (('a' as i8) as i32)) - }) - ); + 'for_body: { + assert!( + ({ + (((elem!(p2, i).read()) as i32) == (('a' as i8) as i32)) + && (({ (*s2.borrow())[(i as usize)] } as i32) == (('a' as i8) as i32)) + }) + ); + } i.prefix_inc(); } } @@ -94,12 +96,14 @@ fn main_0() -> i32 { { let mut i: u32 = 2_u32; 'loop_: while ((i as usize) < ((*s2.borrow()).len() - 1)) { - assert!( - ({ - (((elem!(p2, i).read()) as i32) == (('a' as i8) as i32)) - && (({ (*s2.borrow())[(i as usize)] } as i32) == (('a' as i8) as i32)) - }) - ); + 'for_body: { + assert!( + ({ + (((elem!(p2, i).read()) as i32) == (('a' as i8) as i32)) + && (({ (*s2.borrow())[(i as usize)] } as i32) == (('a' as i8) as i32)) + }) + ); + } i.prefix_inc(); } } @@ -115,13 +119,15 @@ fn main_0() -> i32 { { let mut i: u32 = 0_u32; 'loop_: while ((i as usize) < ((*s3.borrow()).len() - 1)) { - assert!( - ({ - ({ ((elem!(p3, i).read()) as i32) } == { - ({ (*s3.borrow())[(i as usize)] } as i32) + 'for_body: { + assert!( + ({ + ({ ((elem!(p3, i).read()) as i32) } == { + ({ (*s3.borrow())[(i as usize)] } as i32) + }) }) - }) - ); + ); + } i.prefix_inc(); } } @@ -149,13 +155,15 @@ fn main_0() -> i32 { { let mut i: u32 = 0_u32; 'loop_: while ((i as usize) < ((*s4.borrow()).len() - 1)) { - assert!( - ({ - ({ ((elem!(p4, i).read()) as i32) } == { - ({ (*s4.borrow())[(i as usize)] } as i32) + 'for_body: { + assert!( + ({ + ({ ((elem!(p4, i).read()) as i32) } == { + ({ (*s4.borrow())[(i as usize)] } as i32) + }) }) - }) - ); + ); + } i.prefix_inc(); } } @@ -172,13 +180,15 @@ fn main_0() -> i32 { { let mut i: u32 = 0_u32; 'loop_: while ((i as usize) < ((*s5.borrow()).len() - 1)) { - assert!( - ({ - ({ ((elem!(p5, i).read()) as i32) } == { - ({ (*s5.borrow())[(i as usize)] } as i32) + 'for_body: { + assert!( + ({ + ({ ((elem!(p5, i).read()) as i32) } == { + ({ (*s5.borrow())[(i as usize)] } as i32) + }) }) - }) - ); + ); + } i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/string_escape.rs b/tests/unit/out/refcount/string_escape.rs index ad4cf6f28c..d23d400466 100644 --- a/tests/unit/out/refcount/string_escape.rs +++ b/tests/unit/out/refcount/string_escape.rs @@ -20,14 +20,16 @@ fn main_0() -> i32 { < (((::std::mem::size_of::<[i8; 41]>() as usize) .wrapping_div((::std::mem::size_of::() as usize))) as i32)) { - assert!( - ({ ((elem!(special, i).read()) as i32) } == { - (({ - let __idx0 = (i) as usize; - expected_0.with(|rc| rc.borrow()[__idx0]) - }) as i32) - }) - ); + 'for_body: { + assert!( + ({ ((elem!(special, i).read()) as i32) } == { + (({ + let __idx0 = (i) as usize; + expected_0.with(|rc| rc.borrow()[__idx0]) + }) as i32) + }) + ); + } i.postfix_inc(); } } diff --git a/tests/unit/out/refcount/string_literal_interior_null.rs b/tests/unit/out/refcount/string_literal_interior_null.rs index d145e94b83..130908ec32 100644 --- a/tests/unit/out/refcount/string_literal_interior_null.rs +++ b/tests/unit/out/refcount/string_literal_interior_null.rs @@ -11,7 +11,9 @@ pub fn sum_bytes_0(mut buf: Ptr, mut len: u32) -> i32 { { let mut i: u32 = 0_u32; 'loop_: while (i < len) { - sum += (((elem!(buf, i).read()) as u8) as i32); + 'for_body: { + sum += (((elem!(buf, i).read()) as u8) as i32); + } i.postfix_inc(); } } diff --git a/tests/unit/out/refcount/string_repeat_append.rs b/tests/unit/out/refcount/string_repeat_append.rs index 496d7c6221..7f3a2003c9 100644 --- a/tests/unit/out/refcount/string_repeat_append.rs +++ b/tests/unit/out/refcount/string_repeat_append.rs @@ -69,55 +69,67 @@ fn main_0() -> i32 { { let mut shrink: i32 = 0; 'loop_: while (shrink < 2) { - let s: Value> = Rc::new(RefCell::new( - vec![('x' as i8); (length) as usize] - .iter() - .cloned() - .chain(std::iter::once(0)) - .collect(), - )); - { - let mut i: usize = 0_usize; - 'loop_: while (i < length) { - let __rhs = initial[((i) - .wrapping_rem((::std::mem::size_of::<[i8; 5]>() as usize))) - as usize]; - (*s.borrow_mut())[i] = __rhs; - i.prefix_inc(); + 'for_body: { + let s: Value> = Rc::new(RefCell::new( + vec![('x' as i8); (length) as usize] + .iter() + .cloned() + .chain(std::iter::once(0)) + .collect(), + )); + { + let mut i: usize = 0_usize; + 'loop_: while (i < length) { + 'for_body: { + let __rhs = initial[((i).wrapping_rem( + (::std::mem::size_of::<[i8; 5]>() as usize), + )) + as usize]; + (*s.borrow_mut())[i] = __rhs; + } + i.prefix_inc(); + } } - } - if (shrink != 0) { - (*s.borrow_mut()).shrink_to_fit(); - } - s.with_mut(|__b0| { - (*__b0).pop(); - (*__b0).resize((*__b0).len() + count, character); - (*__b0).push(0); - }); - assert!(({ (((*s.borrow()).len() - 1) == (length).wrapping_add(count)) })); - let mut data: Ptr = s.decay(); - { - let mut i: usize = 0_usize; - 'loop_: while (i < (length).wrapping_add(count)) { - assert!( - ({ ((elem!(data, i).read()) as i32) } == { - ((if (i < length) { - initial[((i).wrapping_rem( - (::std::mem::size_of::<[i8; 5]>() as usize), - )) - as usize] - } else { - character - }) as i32) - }) - ); - i.prefix_inc(); + if (shrink != 0) { + (*s.borrow_mut()).shrink_to_fit(); + } + s.with_mut(|__b0| { + (*__b0).pop(); + (*__b0).resize((*__b0).len() + count, character); + (*__b0).push(0); + }); + assert!( + ({ (((*s.borrow()).len() - 1) == (length).wrapping_add(count)) }) + ); + let mut data: Ptr = s.decay(); + { + let mut i: usize = 0_usize; + 'loop_: while (i < (length).wrapping_add(count)) { + 'for_body: { + assert!( + ({ ((elem!(data, i).read()) as i32) } == { + ((if (i < length) { + initial[((i).wrapping_rem( + (::std::mem::size_of::<[i8; 5]>() as usize), + )) + as usize] + } else { + character + }) + as i32) + }) + ); + } + i.prefix_inc(); + } } + assert!( + ({ + (((elem!(data, ((*s.borrow()).len() - 1)).read()) as i32) == 0) + }) + ); + cases.prefix_inc(); } - assert!( - ({ (((elem!(data, ((*s.borrow()).len() - 1)).read()) as i32) == 0) }) - ); - cases.prefix_inc(); shrink.prefix_inc(); } } diff --git a/tests/unit/out/refcount/swap_map_no_copy.rs b/tests/unit/out/refcount/swap_map_no_copy.rs index b4179f9cb6..1e6b008c52 100644 --- a/tests/unit/out/refcount/swap_map_no_copy.rs +++ b/tests/unit/out/refcount/swap_map_no_copy.rs @@ -697,26 +697,30 @@ impl ArraysImpl for Ptr { { let mut __i0: usize = 0_usize; 'loop_: while (__i0 != 2_usize) { - ({ - let _o: Ptr = array_field_ptr!(_a0, a).offset((__i0) as isize); - TrackedImpl::copy_assign( - &array_field_ptr!((*self), a).offset((__i0) as isize), - _o, - ) - }); + 'for_body: { + ({ + let _o: Ptr = array_field_ptr!(_a0, a).offset((__i0) as isize); + TrackedImpl::copy_assign( + &array_field_ptr!((*self), a).offset((__i0) as isize), + _o, + ) + }); + } __i0.prefix_inc(); } } { let mut __i0: usize = 0_usize; 'loop_: while (__i0 != 2_usize) { - ({ - let _o: Ptr = array_field_ptr!(_a0, b).offset((__i0) as isize); - TrackedImpl::copy_assign( - &array_field_ptr!((*self), b).offset((__i0) as isize), - _o, - ) - }); + 'for_body: { + ({ + let _o: Ptr = array_field_ptr!(_a0, b).offset((__i0) as isize); + TrackedImpl::copy_assign( + &array_field_ptr!((*self), b).offset((__i0) as isize), + _o, + ) + }); + } __i0.prefix_inc(); } } @@ -726,26 +730,30 @@ impl ArraysImpl for Ptr { { let mut __i0: usize = 0_usize; 'loop_: while (__i0 != 2_usize) { - ({ - let _o: Ptr = array_field_ptr!(_a0, a).offset((__i0) as isize); - TrackedImpl::move_assign( - &array_field_ptr!((*self), a).offset((__i0) as isize), - _o, - ) - }); + 'for_body: { + ({ + let _o: Ptr = array_field_ptr!(_a0, a).offset((__i0) as isize); + TrackedImpl::move_assign( + &array_field_ptr!((*self), a).offset((__i0) as isize), + _o, + ) + }); + } __i0.prefix_inc(); } } { let mut __i0: usize = 0_usize; 'loop_: while (__i0 != 2_usize) { - ({ - let _o: Ptr = array_field_ptr!(_a0, b).offset((__i0) as isize); - TrackedImpl::move_assign( - &array_field_ptr!((*self), b).offset((__i0) as isize), - _o, - ) - }); + 'for_body: { + ({ + let _o: Ptr = array_field_ptr!(_a0, b).offset((__i0) as isize); + TrackedImpl::move_assign( + &array_field_ptr!((*self), b).offset((__i0) as isize), + _o, + ) + }); + } __i0.prefix_inc(); } } diff --git a/tests/unit/out/refcount/switch_continue_inside_switch.rs b/tests/unit/out/refcount/switch_continue_inside_switch.rs index 3f54e2061e..9375b72a20 100644 --- a/tests/unit/out/refcount/switch_continue_inside_switch.rs +++ b/tests/unit/out/refcount/switch_continue_inside_switch.rs @@ -11,19 +11,20 @@ pub fn continue_inside_switch_0(mut n: i32) -> i32 { { let mut i: i32 = 0; 'loop_: while (i < n) { - 'switch: { - match { i } { - __v if __v == 0 || __v == 2 || __v == 4 => { - i.prefix_inc(); - continue 'loop_; + 'for_body: { + 'switch: { + match { i } { + __v if __v == 0 || __v == 2 || __v == 4 => { + break 'for_body; + } + _ => { + r += i; + break 'switch; + } } - _ => { - r += i; - break 'switch; - } - } - }; - r += 1000; + }; + r += 1000; + } i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/switch_for_in_switch_break.rs b/tests/unit/out/refcount/switch_for_in_switch_break.rs index 1197bf00db..e64b36520c 100644 --- a/tests/unit/out/refcount/switch_for_in_switch_break.rs +++ b/tests/unit/out/refcount/switch_for_in_switch_break.rs @@ -14,10 +14,12 @@ pub fn for_in_switch_break_0(mut n: i32) -> i32 { { let mut i: i32 = 0; 'loop_: while (i < 10) { - if (i == 3) { - break; + 'for_body: { + if (i == 3) { + break 'loop_; + } + r += i; } - r += i; i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/switch_for_in_switch_continue.rs b/tests/unit/out/refcount/switch_for_in_switch_continue.rs index 0c5953ea68..ee93beaf80 100644 --- a/tests/unit/out/refcount/switch_for_in_switch_continue.rs +++ b/tests/unit/out/refcount/switch_for_in_switch_continue.rs @@ -14,11 +14,12 @@ pub fn for_in_switch_continue_0(mut n: i32) -> i32 { { let mut i: i32 = 0; 'loop_: while (i < 5) { - if ((i % 2) == 0) { - i.prefix_inc(); - continue 'loop_; + 'for_body: { + if ((i % 2) == 0) { + break 'for_body; + } + r += i; } - r += i; i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/switch_for_switch_for_break.rs b/tests/unit/out/refcount/switch_for_switch_for_break.rs index de14046601..4fe4a7b103 100644 --- a/tests/unit/out/refcount/switch_for_switch_for_break.rs +++ b/tests/unit/out/refcount/switch_for_switch_for_break.rs @@ -11,28 +11,32 @@ pub fn for_switch_for_break_0(mut n: i32) -> i32 { { let mut i: i32 = 0; 'loop_: while (i < n) { - 'switch: { - match { i } { - __v if __v == 1 => { - { - let mut j: i32 = 0; - 'loop_: while (j < 10) { - if (j == 2) { - break; + 'for_body: { + 'switch: { + match { i } { + __v if __v == 1 => { + { + let mut j: i32 = 0; + 'loop_: while (j < 10) { + 'for_body: { + if (j == 2) { + break 'loop_; + } + r += 1; + } + j.prefix_inc(); } - r += 1; - j.prefix_inc(); } + r += 100; + break 'switch; + } + _ => { + r += 10; + break 'switch; } - r += 100; - break 'switch; - } - _ => { - r += 10; - break 'switch; } - } - }; + }; + } i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/switch_in_loop.rs b/tests/unit/out/refcount/switch_in_loop.rs index 6bf47aa838..19be3f172d 100644 --- a/tests/unit/out/refcount/switch_in_loop.rs +++ b/tests/unit/out/refcount/switch_in_loop.rs @@ -11,23 +11,25 @@ pub fn switch_in_loop_0(mut n: i32) -> i32 { { let mut i: i32 = 0; 'loop_: while (i < n) { - 'switch: { - match { (i % 3) } { - __v if __v == 0 => { - r += 1; - break 'switch; + 'for_body: { + 'switch: { + match { (i % 3) } { + __v if __v == 0 => { + r += 1; + break 'switch; + } + __v if __v == 1 => { + r += 2; + break 'switch; + } + _ => { + r += 3; + break 'switch; + } } - __v if __v == 1 => { - r += 2; - break 'switch; - } - _ => { - r += 3; - break 'switch; - } - } - }; - r += 10; + }; + r += 10; + } i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/unboxed_conditional_iterator.rs b/tests/unit/out/refcount/unboxed_conditional_iterator.rs index f4df2c7e94..933f0b23d8 100644 --- a/tests/unit/out/refcount/unboxed_conditional_iterator.rs +++ b/tests/unit/out/refcount/unboxed_conditional_iterator.rs @@ -44,36 +44,40 @@ pub fn lehmer_3(mut sigma: Ptr, mut len: u32, mut code: Ptr) { { let mut i: u32 = 0_u32; 'loop_: while (i < len) { - let __rhs = i; - (*items.borrow_mut())[(i as usize)] = __rhs; + 'for_body: { + let __rhs = i; + (*items.borrow_mut())[(i as usize)] = __rhs; + } i.prefix_inc(); } } { let mut i: u32 = 0_u32; 'loop_: while (i < len) { - let it: Value> = Rc::new(RefCell::new({ - let mut __tmp_0 = { items.decay().begin() }; - let mut __tmp_1 = { items.decay().end() }; - let mut __it = (__tmp_0).clone(); - while __it != __tmp_1 - && !CppEq::equal(&__it.iter_deref(), &sigma.offset((i) as isize)) + 'for_body: { + let it: Value> = Rc::new(RefCell::new({ + let mut __tmp_0 = { items.decay().begin() }; + let mut __tmp_1 = { items.decay().end() }; + let mut __it = (__tmp_0).clone(); + while __it != __tmp_1 + && !CppEq::equal(&__it.iter_deref(), &sigma.offset((i) as isize)) + { + __it.iter_inc(); + } + __it + })); + assert!((*it.borrow()) != items.decay().end()); + let __rhs = (((*it.borrow()).iter_distance(&items.decay().begin())) as u32); + elem!(code, i).write(__rhs); { - __it.iter_inc(); - } - __it - })); - assert!((*it.borrow()) != items.decay().end()); - let __rhs = (((*it.borrow()).iter_distance(&items.decay().begin())) as u32); - elem!(code, i).write(__rhs); - { - let mut __tmp_2 = - { >::from(({ (*it.borrow()).clone() })) }; - items - .as_pointer() - .with_mut(|__v: &mut Vec| __v.remove(__tmp_2.index())); - (__tmp_2).clone() - }; + let mut __tmp_2 = + { >::from(({ (*it.borrow()).clone() })) }; + items + .as_pointer() + .with_mut(|__v: &mut Vec| __v.remove(__tmp_2.index())); + (__tmp_2).clone() + }; + } i.prefix_inc(); } } @@ -83,7 +87,9 @@ pub fn sum_4(v: Ptr>) -> i32 { { let it: Value> = Rc::new(RefCell::new(v.decay().begin())); 'loop_: while (*it.borrow()) != v.decay().end() { - s += (({ (*it.borrow()).iter_deref() }).read()); + 'for_body: { + s += (({ (*it.borrow()).iter_deref() }).read()); + } { (*it.borrow_mut()).iter_inc(); }; diff --git a/tests/unit/out/refcount/unboxed_locals.rs b/tests/unit/out/refcount/unboxed_locals.rs index 658e8c3426..5202abfa9d 100644 --- a/tests/unit/out/refcount/unboxed_locals.rs +++ b/tests/unit/out/refcount/unboxed_locals.rs @@ -35,7 +35,9 @@ pub fn sum_3(mut arr: Ptr, mut n: i32) -> i32 { { let mut i: i32 = 0; 'loop_: while (i < n) { - s += { (elem!(arr, i).read()) }; + 'for_body: { + s += { (elem!(arr, i).read()) }; + } i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/unboxed_records.rs b/tests/unit/out/refcount/unboxed_records.rs index 747de3edf8..c9ce989825 100644 --- a/tests/unit/out/refcount/unboxed_records.rs +++ b/tests/unit/out/refcount/unboxed_records.rs @@ -71,8 +71,10 @@ pub fn consume_3(cookie: Ptr) -> i32 { { let mut i: i32 = 0; 'loop_: while (i < 4) { - elem!(c.data, i).write({ ({ (elem!(c.in_, i).read()) } * { c.x }) }); - sum += { (elem!(c.data, i).read()) }; + 'for_body: { + elem!(c.data, i).write({ ({ (elem!(c.in_, i).read()) } * { c.x }) }); + sum += { (elem!(c.data, i).read()) }; + } i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/union_flex_array_member.rs b/tests/unit/out/refcount/union_flex_array_member.rs index 020063b604..240ef06b64 100644 --- a/tests/unit/out/refcount/union_flex_array_member.rs +++ b/tests/unit/out/refcount/union_flex_array_member.rs @@ -52,18 +52,22 @@ fn main_0() -> i32 { { let mut i: usize = 0_usize; 'loop_: while (i < tail_size) { - elem!(anon_0::bytes(field_ptr!(n, x)), i).write({ ((i & 255_usize) as u8) }); + 'for_body: { + elem!(anon_0::bytes(field_ptr!(n, x)), i).write({ ((i & 255_usize) as u8) }); + } i.postfix_inc(); } } { let mut i: usize = 0_usize; 'loop_: while (i < tail_size) { - assert!( - ({ ((elem!(anon_0::bytes(field_ptr!(n, x)), i).read()) as i32) } == { - (((i & 255_usize) as u8) as i32) - }) - ); + 'for_body: { + assert!( + ({ ((elem!(anon_0::bytes(field_ptr!(n, x)), i).read()) as i32) } == { + (((i & 255_usize) as u8) as i32) + }) + ); + } i.postfix_inc(); } } diff --git a/tests/unit/out/refcount/unique_ptr.rs b/tests/unit/out/refcount/unique_ptr.rs index 887cea09a9..b76b57bdb1 100644 --- a/tests/unit/out/refcount/unique_ptr.rs +++ b/tests/unit/out/refcount/unique_ptr.rs @@ -97,7 +97,9 @@ pub fn RndStuff_2() { { let mut i: i32 = 0; 'loop_: while (i < 100) { - ({ (*x2.borrow()).decay().offset((i as usize)) }).write(1); + 'for_body: { + ({ (*x2.borrow()).decay().offset((i as usize)) }).write(1); + } i.prefix_inc(); } } @@ -107,7 +109,9 @@ pub fn RndStuff_2() { { let mut i: i32 = 0; 'loop_: while (i < 200) { - ({ (*x2.borrow()).decay().offset((i as usize)) }).write(2); + 'for_body: { + ({ (*x2.borrow()).decay().offset((i as usize)) }).write(2); + } i.prefix_inc(); } } @@ -115,7 +119,9 @@ pub fn RndStuff_2() { { let mut i: i32 = 0; 'loop_: while (i < 200) { - assert!(((elem!(p2, i).read()) == 2)); + 'for_body: { + assert!(((elem!(p2, i).read()) == 2)); + } i.prefix_inc(); } } @@ -127,7 +133,9 @@ pub fn RndStuff_2() { { let mut i: i32 = 0; 'loop_: while (i < 10) { - ({ (*x3.borrow()).decay().offset((i as usize)) }).write(Pair { x: 1, y: 2 }); + 'for_body: { + ({ (*x3.borrow()).decay().offset((i as usize)) }).write(Pair { x: 1, y: 2 }); + } i.prefix_inc(); } } @@ -135,11 +143,13 @@ pub fn RndStuff_2() { { let mut i: i32 = 0; 'loop_: while (i < 10) { - assert!((elem!(p3_0, i).with(|__s| __s.x) == 1)); - assert!((elem!(p3_0, i).with(|__s| __s.y) == 2)); - ({ PairImpl::inc(&({ (*x3.borrow()).decay().offset((i as usize)) }), 10) }); - assert!((elem!(p3_0, i).with(|__s| __s.x) == 11)); - assert!((elem!(p3_0, i).with(|__s| __s.y) == 12)); + 'for_body: { + assert!((elem!(p3_0, i).with(|__s| __s.x) == 1)); + assert!((elem!(p3_0, i).with(|__s| __s.y) == 2)); + ({ PairImpl::inc(&({ (*x3.borrow()).decay().offset((i as usize)) }), 10) }); + assert!((elem!(p3_0, i).with(|__s| __s.x) == 11)); + assert!((elem!(p3_0, i).with(|__s| __s.y) == 12)); + } i.prefix_inc(); } } @@ -154,10 +164,12 @@ pub fn RndStuff_2() { { let mut i: i32 = 0; 'loop_: while (i < 50) { - ({ (*x3.borrow()).decay().offset((i as usize)) }).write(Pair { - x: -1_i32, - y: -2_i32, - }); + 'for_body: { + ({ (*x3.borrow()).decay().offset((i as usize)) }).write(Pair { + x: -1_i32, + y: -2_i32, + }); + } i.prefix_inc(); } } @@ -166,11 +178,13 @@ pub fn RndStuff_2() { { let mut i: i32 = 0; 'loop_: while (i < 50) { - assert!((elem!(p3_1, i).with(|__s| __s.x) == -1_i32)); - assert!((elem!(p3_1, i).with(|__s| __s.y) == -2_i32)); - ({ PairImpl::inc(&({ (*x3.borrow()).decay().offset((i as usize)) }), -10_i32) }); - assert!((elem!(p3_1, i).with(|__s| __s.x) == -11_i32)); - assert!((elem!(p3_1, i).with(|__s| __s.y) == -12_i32)); + 'for_body: { + assert!((elem!(p3_1, i).with(|__s| __s.x) == -1_i32)); + assert!((elem!(p3_1, i).with(|__s| __s.y) == -2_i32)); + ({ PairImpl::inc(&({ (*x3.borrow()).decay().offset((i as usize)) }), -10_i32) }); + assert!((elem!(p3_1, i).with(|__s| __s.x) == -11_i32)); + assert!((elem!(p3_1, i).with(|__s| __s.y) == -12_i32)); + } i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/va_arg_chain.rs b/tests/unit/out/refcount/va_arg_chain.rs index 43c3ff0a57..b75518dba5 100644 --- a/tests/unit/out/refcount/va_arg_chain.rs +++ b/tests/unit/out/refcount/va_arg_chain.rs @@ -11,7 +11,9 @@ pub fn extract_nth_0(mut n: i32, ap: Ptr) -> i32 { { let mut i: i32 = 0; 'loop_: while (i < n) { - (*ap.borrow_mut()).arg::(); + 'for_body: { + (*ap.borrow_mut()).arg::(); + } i.postfix_inc(); } } diff --git a/tests/unit/out/refcount/va_arg_copy.rs b/tests/unit/out/refcount/va_arg_copy.rs index 702193da6e..4471da35b9 100644 --- a/tests/unit/out/refcount/va_arg_copy.rs +++ b/tests/unit/out/refcount/va_arg_copy.rs @@ -17,7 +17,9 @@ pub fn sum_with_copy_0(count: i32, __args: Box<[VaArg]>) -> i32 { { let mut i: i32 = 0; 'loop_: while (i < (*count.borrow())) { - sum1 += (*ap.borrow_mut()).arg::(); + 'for_body: { + sum1 += (*ap.borrow_mut()).arg::(); + } i.postfix_inc(); } }; @@ -25,7 +27,9 @@ pub fn sum_with_copy_0(count: i32, __args: Box<[VaArg]>) -> i32 { { let mut i: i32 = 0; 'loop_: while (i < (*count.borrow())) { - sum2 += (*aq.borrow_mut()).arg::(); + 'for_body: { + sum2 += (*aq.borrow_mut()).arg::(); + } i.postfix_inc(); } }; diff --git a/tests/unit/out/refcount/va_arg_forward.rs b/tests/unit/out/refcount/va_arg_forward.rs index 8dbbc5aa6a..de9e93fac3 100644 --- a/tests/unit/out/refcount/va_arg_forward.rs +++ b/tests/unit/out/refcount/va_arg_forward.rs @@ -12,7 +12,9 @@ pub fn inner_0(mut count: i32, ap: Ptr) -> i32 { { let mut i: i32 = 0; 'loop_: while (i < count) { - total += (*ap.borrow_mut()).arg::(); + 'for_body: { + total += (*ap.borrow_mut()).arg::(); + } i.postfix_inc(); } } diff --git a/tests/unit/out/refcount/va_arg_mixed_int_ptr.rs b/tests/unit/out/refcount/va_arg_mixed_int_ptr.rs index 3880ac8c8a..6f2d9beefe 100644 --- a/tests/unit/out/refcount/va_arg_mixed_int_ptr.rs +++ b/tests/unit/out/refcount/va_arg_mixed_int_ptr.rs @@ -15,12 +15,14 @@ pub fn mixed_args_0(count: i32, __args: Box<[VaArg]>) -> i32 { { let mut i: i32 = 0; 'loop_: while (i < (*count.borrow())) { - let mut tag: i32 = (*ap.borrow_mut()).arg::(); - if (tag == 0) { - total += (*ap.borrow_mut()).arg::(); - } else { - let mut ptr: Ptr = (*ap.borrow_mut()).arg::>(); - total += { (ptr.read()) }; + 'for_body: { + let mut tag: i32 = (*ap.borrow_mut()).arg::(); + if (tag == 0) { + total += (*ap.borrow_mut()).arg::(); + } else { + let mut ptr: Ptr = (*ap.borrow_mut()).arg::>(); + total += { (ptr.read()) }; + } } i.postfix_inc(); } diff --git a/tests/unit/out/refcount/va_arg_mixed_types.rs b/tests/unit/out/refcount/va_arg_mixed_types.rs index fa179415b8..51d25a87de 100644 --- a/tests/unit/out/refcount/va_arg_mixed_types.rs +++ b/tests/unit/out/refcount/va_arg_mixed_types.rs @@ -23,17 +23,19 @@ pub fn sum_mixed_0(count: i32, __args: Box<[VaArg]>) -> i32 { { let mut i: i32 = 0; 'loop_: while (i < (*count.borrow())) { - let mut tag: i32 = (*ap.borrow_mut()).arg::(); - if (tag == 0) { - total += (*ap.borrow_mut()).arg::(); - } else if (tag == 1) { - total += ((*ap.borrow_mut()).arg::() as i32); - } else if (tag == 3) { - let mut p: pair = (*ap.borrow_mut()).arg::(); - total += (p.a * p.b); - } else { - let mut val: i64 = (*ap.borrow_mut()).arg::(); - total += (val as i32); + 'for_body: { + let mut tag: i32 = (*ap.borrow_mut()).arg::(); + if (tag == 0) { + total += (*ap.borrow_mut()).arg::(); + } else if (tag == 1) { + total += ((*ap.borrow_mut()).arg::() as i32); + } else if (tag == 3) { + let mut p: pair = (*ap.borrow_mut()).arg::(); + total += (p.a * p.b); + } else { + let mut val: i64 = (*ap.borrow_mut()).arg::(); + total += (val as i32); + } } i.postfix_inc(); } diff --git a/tests/unit/out/refcount/va_arg_null_int_ptr.rs b/tests/unit/out/refcount/va_arg_null_int_ptr.rs index e36ceaf059..cae50d74a4 100644 --- a/tests/unit/out/refcount/va_arg_null_int_ptr.rs +++ b/tests/unit/out/refcount/va_arg_null_int_ptr.rs @@ -15,10 +15,12 @@ pub fn first_nonnull_0(count: i32, __args: Box<[VaArg]>) -> i32 { { let mut i: i32 = 0; 'loop_: while (i < (*count.borrow())) { - let mut p: Ptr = (*ap.borrow_mut()).arg::>(); - if (!((p).is_null())) { - result = { (p.read()) }; - break; + 'for_body: { + let mut p: Ptr = (*ap.borrow_mut()).arg::>(); + if (!((p).is_null())) { + result = { (p.read()) }; + break 'loop_; + } } i.postfix_inc(); } diff --git a/tests/unit/out/refcount/va_list_field.rs b/tests/unit/out/refcount/va_list_field.rs index 0211f95466..5dd7dfeb52 100644 --- a/tests/unit/out/refcount/va_list_field.rs +++ b/tests/unit/out/refcount/va_list_field.rs @@ -17,7 +17,9 @@ pub fn sum_0(n: i32, __args: Box<[VaArg]>) -> i32 { { let mut i: i32 = 0; 'loop_: while (i < (*n.borrow())) { - total += { (*guard.borrow()).ap.clone() }.with_mut(|__v| __v.arg::()); + 'for_body: { + total += { (*guard.borrow()).ap.clone() }.with_mut(|__v| __v.arg::()); + } i.prefix_inc(); } } @@ -53,7 +55,9 @@ pub fn sum_ptr_2(n: i32, __args: Box<[VaArg]>) -> i32 { { let mut i: i32 = 0; 'loop_: while (i < (*n.borrow())) { - total += cursor.ap.with_mut(|__v| __v.arg::()); + 'for_body: { + total += cursor.ap.with_mut(|__v| __v.arg::()); + } i.prefix_inc(); } }; diff --git a/tests/unit/out/refcount/vector.rs b/tests/unit/out/refcount/vector.rs index 51cb378744..e1468ef8c3 100644 --- a/tests/unit/out/refcount/vector.rs +++ b/tests/unit/out/refcount/vector.rs @@ -161,13 +161,15 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < 4) { - { - let mut __tmp_10 = - { >::from(v2.decay().begin().iter_add(1_isize)) }; - v2.as_pointer() - .with_mut(|__v: &mut Vec| __v.remove(__tmp_10.index())); - (__tmp_10).clone() - }; + 'for_body: { + { + let mut __tmp_10 = + { >::from(v2.decay().begin().iter_add(1_isize)) }; + v2.as_pointer() + .with_mut(|__v: &mut Vec| __v.remove(__tmp_10.index())); + (__tmp_10).clone() + }; + } i.prefix_inc(); } } @@ -183,7 +185,9 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < 100) { - assert!(({ ({ (*v3.borrow())[(i as usize)] } == 1) })); + 'for_body: { + assert!(({ ({ (*v3.borrow())[(i as usize)] } == 1) })); + } i.prefix_inc(); } } @@ -192,7 +196,9 @@ fn main_0() -> i32 { { let mut i: u32 = 0_u32; 'loop_: while ((i as usize) < v4.len()) { - assert!((v4[(i as usize)]).is_null()); + 'for_body: { + assert!((v4[(i as usize)]).is_null()); + } i.prefix_inc(); } } @@ -201,7 +207,9 @@ fn main_0() -> i32 { { let mut i: u32 = 0_u32; 'loop_: while ((i as usize) < v5.len()) { - assert!((v5[(i as usize)]).is_null()); + 'for_body: { + assert!((v5[(i as usize)]).is_null()); + } i.prefix_inc(); } } @@ -210,7 +218,9 @@ fn main_0() -> i32 { { let mut i: u32 = 0_u32; 'loop_: while ((i as usize) < s2) { - assert!(({ ({ (*v6.borrow())[(i as usize)] } == 2_f64) })); + 'for_body: { + assert!(({ ({ (*v6.borrow())[(i as usize)] } == 2_f64) })); + } i.prefix_inc(); } } @@ -225,12 +235,14 @@ fn main_0() -> i32 { { let mut i: u32 = 0_u32; 'loop_: while (i < 200_u32) { - assert!( - ({ - ((*(*v7.borrow())[(i as usize)].0.borrow()).is_null()) - && ((*(*v7.borrow())[(i as usize)].1.borrow()) == 0) - }) - ); + 'for_body: { + assert!( + ({ + ((*(*v7.borrow())[(i as usize)].0.borrow()).is_null()) + && ((*(*v7.borrow())[(i as usize)].1.borrow()) == 0) + }) + ); + } i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/vector_subscript_borrow.rs b/tests/unit/out/refcount/vector_subscript_borrow.rs index 26595d9d94..01b8b4b57a 100644 --- a/tests/unit/out/refcount/vector_subscript_borrow.rs +++ b/tests/unit/out/refcount/vector_subscript_borrow.rs @@ -26,8 +26,10 @@ fn main_0() -> i32 { { let mut i: u32 = 0_u32; 'loop_: while ((i as usize) < items.len()) { - let __rhs = (i).wrapping_mul(2_u32); - items[(i as usize)] = __rhs; + 'for_body: { + let __rhs = (i).wrapping_mul(2_u32); + items[(i as usize)] = __rhs; + } i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/vector_subscript_direct.rs b/tests/unit/out/refcount/vector_subscript_direct.rs index dcb90e00c2..556ff5a363 100644 --- a/tests/unit/out/refcount/vector_subscript_direct.rs +++ b/tests/unit/out/refcount/vector_subscript_direct.rs @@ -44,7 +44,9 @@ pub fn sum_ref_1(v: Ptr>) -> i32 { { let mut i: usize = 0_usize; 'loop_: while ({ i } < { (*v.upgrade().deref()).len() }) { - s += (index!(v, i).read()); + 'for_body: { + s += (index!(v, i).read()); + } i.prefix_inc(); } } diff --git a/tests/unit/out/refcount/vector_with_allocator.rs b/tests/unit/out/refcount/vector_with_allocator.rs index 9ee95fecd2..9d167eddcb 100644 --- a/tests/unit/out/refcount/vector_with_allocator.rs +++ b/tests/unit/out/refcount/vector_with_allocator.rs @@ -126,7 +126,9 @@ fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while (i < 100) { - assert!(({ ({ (*v3.borrow())[(i as usize)] } == 1) })); + 'for_body: { + assert!(({ ({ (*v3.borrow())[(i as usize)] } == 1) })); + } i.prefix_inc(); } } @@ -135,7 +137,9 @@ fn main_0() -> i32 { { let mut i: u32 = 0_u32; 'loop_: while ((i as usize) < s2) { - assert!(({ ({ (*v6.borrow())[(i as usize)] } == 2_f64) })); + 'for_body: { + assert!(({ ({ (*v6.borrow())[(i as usize)] } == 2_f64) })); + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/alloc_array.rs b/tests/unit/out/unsafe/alloc_array.rs index 8ee6e48730..8833d59431 100644 --- a/tests/unit/out/unsafe/alloc_array.rs +++ b/tests/unit/out/unsafe/alloc_array.rs @@ -11,10 +11,12 @@ pub unsafe fn All_0(arr: *mut Option>, mut N: i32, mut element: i32) { let mut i: i32 = 0; 'loop_: while ((i) < (N)) { - (*all - .as_deref() - .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut i32) - .add((i as usize))) = element; + 'for_body: { + (*all + .as_deref() + .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut i32) + .add((i as usize))) = element; + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/array.rs b/tests/unit/out/unsafe/array.rs index c6cbc8ed83..ed9bef6322 100644 --- a/tests/unit/out/unsafe/array.rs +++ b/tests/unit/out/unsafe/array.rs @@ -19,7 +19,9 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (N)) { - arr1[(i) as usize] = ((i) + (arr2[(i) as usize])); + 'for_body: { + arr1[(i) as usize] = ((i) + (arr2[(i) as usize])); + } i.prefix_inc(); } } @@ -27,7 +29,9 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (N)) { - fatorial *= arr1[(i) as usize]; + 'for_body: { + fatorial *= arr1[(i) as usize]; + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/array_2d_default.rs b/tests/unit/out/unsafe/array_2d_default.rs index a68ce802e4..4306cfe5ef 100644 --- a/tests/unit/out/unsafe/array_2d_default.rs +++ b/tests/unit/out/unsafe/array_2d_default.rs @@ -21,11 +21,13 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (3)) { - (unsafe { - let _row: *mut libc::c_char = grid[(i) as usize].as_mut_ptr(); - let _c: libc::c_char = ((('a' as i32) + (i)) as libc::c_char); - fill_row_0(_row, _c) - }); + 'for_body: { + (unsafe { + let _row: *mut libc::c_char = grid[(i) as usize].as_mut_ptr(); + let _c: libc::c_char = ((('a' as i32) + (i)) as libc::c_char); + fill_row_0(_row, _c) + }); + } i.postfix_inc(); } } diff --git a/tests/unit/out/unsafe/array_const_init.rs b/tests/unit/out/unsafe/array_const_init.rs index d501ccb8c3..a33a95e53c 100644 --- a/tests/unit/out/unsafe/array_const_init.rs +++ b/tests/unit/out/unsafe/array_const_init.rs @@ -45,19 +45,25 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (3)) { - assert!( - (((*std::cell::LazyCell::force_mut(&mut *&raw mut s_0)).tail[(i) as usize]) == (0)) - ); + 'for_body: { + assert!( + (((*std::cell::LazyCell::force_mut(&mut *&raw mut s_0)).tail[(i) as usize]) + == (0)) + ); + } i.postfix_inc(); } } { let mut i: i32 = 0; 'loop_: while ((i) < (4)) { - assert!( - (((*std::cell::LazyCell::force_mut(&mut *&raw mut s_0)).buf[(i) as usize] as i32) - == (0)) - ); + 'for_body: { + assert!( + (((*std::cell::LazyCell::force_mut(&mut *&raw mut s_0)).buf[(i) as usize] + as i32) + == (0)) + ); + } i.postfix_inc(); } } @@ -65,7 +71,9 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (10)) { - assert!(((a[(i) as usize]) == (0))); + 'for_body: { + assert!(((a[(i) as usize]) == (0))); + } i.postfix_inc(); } } @@ -74,7 +82,9 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 1; 'loop_: while ((i) < (4)) { - assert!(((seven[(i) as usize]) == (0))); + 'for_body: { + assert!(((seven[(i) as usize]) == (0))); + } i.postfix_inc(); } } @@ -85,7 +95,9 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 3; 'loop_: while ((i) < (6)) { - assert!(((b[(i) as usize]) == (0))); + 'for_body: { + assert!(((b[(i) as usize]) == (0))); + } i.postfix_inc(); } } diff --git a/tests/unit/out/unsafe/array_reference.rs b/tests/unit/out/unsafe/array_reference.rs index 213a2f0a28..acaa8c26e7 100644 --- a/tests/unit/out/unsafe/array_reference.rs +++ b/tests/unit/out/unsafe/array_reference.rs @@ -27,7 +27,9 @@ pub unsafe fn fill_3(a: *mut [i32; 3], mut v: i32) { { let mut i: i32 = 0; 'loop_: while ((i) < (3)) { - (*a)[(i) as usize] = v; + 'for_body: { + (*a)[(i) as usize] = v; + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/bool_condition_int.rs b/tests/unit/out/unsafe/bool_condition_int.rs index 2bba051b4a..988300e4c7 100644 --- a/tests/unit/out/unsafe/bool_condition_int.rs +++ b/tests/unit/out/unsafe/bool_condition_int.rs @@ -53,7 +53,9 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 5; 'loop_: while (i != 0) { - loop_count.prefix_inc(); + 'for_body: { + loop_count.prefix_inc(); + } i.prefix_dec(); } } diff --git a/tests/unit/out/unsafe/bool_condition_int_c.rs b/tests/unit/out/unsafe/bool_condition_int_c.rs index d337da019b..921a10d8c5 100644 --- a/tests/unit/out/unsafe/bool_condition_int_c.rs +++ b/tests/unit/out/unsafe/bool_condition_int_c.rs @@ -53,7 +53,9 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 5; 'loop_: while (i != 0) { - loop_count.prefix_inc(); + 'for_body: { + loop_count.prefix_inc(); + } i.prefix_dec(); } } diff --git a/tests/unit/out/unsafe/break.rs b/tests/unit/out/unsafe/break.rs index f735951e2d..4f9c6ee4fc 100644 --- a/tests/unit/out/unsafe/break.rs +++ b/tests/unit/out/unsafe/break.rs @@ -12,25 +12,29 @@ pub unsafe fn for_test_0(n: i32) -> i32 { let mut i: i32 = 0; let mut j: i32 = 0; 'loop_: while ((i) < (n)) { - x += 1; - if ((x) == (100)) { - break; - } - { - let mut k: i32 = 0; - let mut w: i32 = 0; - 'loop_: while ((w) < (j)) { - break; - { + 'for_body: { + x += 1; + if ((x) == (100)) { + break 'loop_; + } + { + let mut k: i32 = 0; + let mut w: i32 = 0; + 'loop_: while ((w) < (j)) { + 'for_body: { + break 'loop_; + } { - w += 1; - k += 1 + { + w += 1; + k += 1 + }; + i += k }; - i += k - }; + } } + x = ((x) + (1)); } - x = ((x) + (1)); { j = i; i += 1 diff --git a/tests/unit/out/unsafe/clone_vs_move.rs b/tests/unit/out/unsafe/clone_vs_move.rs index c742d4410a..87162de2f2 100644 --- a/tests/unit/out/unsafe/clone_vs_move.rs +++ b/tests/unit/out/unsafe/clone_vs_move.rs @@ -99,10 +99,12 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (N)) { - { - let a0_clone = i.clone(); - v1.push(a0_clone) - }; + 'for_body: { + { + let a0_clone = i.clone(); + v1.push(a0_clone) + }; + } i.prefix_inc(); } } @@ -110,22 +112,28 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (N)) { - assert!(((v2[(i as usize)]) == (i))); + 'for_body: { + assert!(((v2[(i as usize)]) == (i))); + } i.prefix_inc(); } } { let mut i: i32 = 0; 'loop_: while ((i) < (N)) { - v2[(i as usize)].prefix_inc(); + 'for_body: { + v2[(i as usize)].prefix_inc(); + } i.prefix_inc(); } } { let mut i: i32 = 0; 'loop_: while ((i) < (N)) { - assert!(((v2[(i as usize)]) == ((i) + (1)))); - assert!(((v1[(i as usize)]) == (i))); + 'for_body: { + assert!(((v2[(i as usize)]) == ((i) + (1)))); + assert!(((v1[(i as usize)]) == (i))); + } i.prefix_inc(); } } @@ -133,10 +141,12 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (N)) { - { - let __a1 = Vec::from_fn(10_usize, |_| 0_i32); - m1.push(__a1) - }; + 'for_body: { + { + let __a1 = Vec::from_fn(10_usize, |_| 0_i32); + m1.push(__a1) + }; + } i.prefix_inc(); } } @@ -144,14 +154,18 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (N)) { - assert!(((m1[(i as usize)].len()) == (10_usize))); - assert!(((m2[(i as usize)].len()) == (10_usize))); - { - let mut j: i32 = 0; - 'loop_: while ((j) < (10)) { - assert!(((m1[(i as usize)][(j as usize)]) == (0))); - assert!(((m2[(i as usize)][(j as usize)]) == (0))); - j.prefix_inc(); + 'for_body: { + assert!(((m1[(i as usize)].len()) == (10_usize))); + assert!(((m2[(i as usize)].len()) == (10_usize))); + { + let mut j: i32 = 0; + 'loop_: while ((j) < (10)) { + 'for_body: { + assert!(((m1[(i as usize)][(j as usize)]) == (0))); + assert!(((m2[(i as usize)][(j as usize)]) == (0))); + } + j.prefix_inc(); + } } } i.prefix_inc(); @@ -160,11 +174,15 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (N)) { - { - let mut j: i32 = 0; - 'loop_: while ((j) < (10)) { - m2[(i as usize)][(j as usize)].postfix_inc(); - j.prefix_inc(); + 'for_body: { + { + let mut j: i32 = 0; + 'loop_: while ((j) < (10)) { + 'for_body: { + m2[(i as usize)][(j as usize)].postfix_inc(); + } + j.prefix_inc(); + } } } i.prefix_inc(); @@ -173,14 +191,18 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (N)) { - assert!(((m1[(i as usize)].len()) == (10_usize))); - assert!(((m2[(i as usize)].len()) == (10_usize))); - { - let mut j: i32 = 0; - 'loop_: while ((j) < (10)) { - assert!(((m1[(i as usize)][(j as usize)]) == (0))); - assert!(((m2[(i as usize)][(j as usize)]) == (1))); - j.prefix_inc(); + 'for_body: { + assert!(((m1[(i as usize)].len()) == (10_usize))); + assert!(((m2[(i as usize)].len()) == (10_usize))); + { + let mut j: i32 = 0; + 'loop_: while ((j) < (10)) { + 'for_body: { + assert!(((m1[(i as usize)][(j as usize)]) == (0))); + assert!(((m2[(i as usize)][(j as usize)]) == (1))); + } + j.prefix_inc(); + } } } i.prefix_inc(); @@ -190,7 +212,9 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (N)) { - (*map1.subscript(&i, || 0_i32)) = i; + 'for_body: { + (*map1.subscript(&i, || 0_i32)) = i; + } i.prefix_inc(); } } @@ -198,16 +222,20 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (N)) { - assert!(((*map2.subscript(&i, || 0_i32)) == (i))); - (*map2.subscript(&i, || 0_i32)).prefix_inc(); + 'for_body: { + assert!(((*map2.subscript(&i, || 0_i32)) == (i))); + (*map2.subscript(&i, || 0_i32)).prefix_inc(); + } i.prefix_inc(); } } { let mut i: i32 = 0; 'loop_: while ((i) < (N)) { - assert!(((*map1.subscript(&i, || 0_i32)) == (i))); - assert!(((*map2.subscript(&i, || 0_i32)) == ((i) + (1)))); + 'for_body: { + assert!(((*map1.subscript(&i, || 0_i32)) == (i))); + assert!(((*map2.subscript(&i, || 0_i32)) == ((i) + (1)))); + } i.prefix_inc(); } } @@ -258,16 +286,20 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (N)) { - assert!(((v4[(i as usize)]) == ((i) + (1)))); - v4[(i as usize)].prefix_inc(); + 'for_body: { + assert!(((v4[(i as usize)]) == ((i) + (1)))); + v4[(i as usize)].prefix_inc(); + } i.prefix_inc(); } } { let mut i: i32 = 0; 'loop_: while ((i) < (N)) { - assert!(((v4[(i as usize)]) == ((i) + (2)))); - assert!(((v2[(i as usize)]) == ((i) + (1)))); + 'for_body: { + assert!(((v4[(i as usize)]) == ((i) + (2)))); + assert!(((v2[(i as usize)]) == ((i) + (1)))); + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/container_element_receiver.rs b/tests/unit/out/unsafe/container_element_receiver.rs index 6c014cc676..db89bbdbe2 100644 --- a/tests/unit/out/unsafe/container_element_receiver.rs +++ b/tests/unit/out/unsafe/container_element_receiver.rs @@ -29,7 +29,9 @@ pub unsafe fn sum_1(v: *const Vec) -> i32 { { let mut it: UnsafeRandomAccessIterator = (*v).begin(); 'loop_: while it != (*v).end() { - total += (*it.iter_deref()); + 'for_body: { + total += (*it.iter_deref()); + } { it.iter_inc(); }; diff --git a/tests/unit/out/unsafe/continue.rs b/tests/unit/out/unsafe/continue.rs index c83b20ee77..12152afc0b 100644 --- a/tests/unit/out/unsafe/continue.rs +++ b/tests/unit/out/unsafe/continue.rs @@ -26,42 +26,45 @@ unsafe fn main_0() -> i32 { { let mut j: i32 = 0; 'loop_: while ((j) < (10)) { - if (((i) % (2)) == (0)) { - j.postfix_inc(); - continue 'loop_; + 'for_body: { + if (((i) % (2)) == (0)) { + break 'for_body; + } + out.prefix_inc(); } - out.prefix_inc(); j.postfix_inc(); } } { let mut k1: i32 = 0; 'loop_: while ((k1) < (5)) { - { - let mut k2: i32 = 0; - 'loop_: while ((k2) < (5)) { - let mut k3: i32 = 0; - 'loop_: while ((k3) < (5)) { - if (((((k1) + (k2)) + (k3)) % (2)) == (0)) { - k3.postfix_inc(); - continue 'loop_; + 'for_body: { + { + let mut k2: i32 = 0; + 'loop_: while ((k2) < (5)) { + 'for_body: { + let mut k3: i32 = 0; + 'loop_: while ((k3) < (5)) { + if (((((k1) + (k2)) + (k3)) % (2)) == (0)) { + k3.postfix_inc(); + continue 'loop_; + } + out.prefix_inc(); + k3.postfix_inc(); + } + if ((((k1) + (k2)) % (2)) == (0)) { + break 'for_body; + } + out.prefix_inc(); } - out.prefix_inc(); - k3.postfix_inc(); - } - if ((((k1) + (k2)) % (2)) == (0)) { k2.postfix_inc(); - continue 'loop_; } - out.prefix_inc(); - k2.postfix_inc(); } + if (((k1) % (2)) == (0)) { + break 'for_body; + } + out.prefix_inc(); } - if (((k1) % (2)) == (0)) { - k1.postfix_inc(); - continue 'loop_; - } - out.prefix_inc(); k1.postfix_inc(); } } diff --git a/tests/unit/out/unsafe/copy_assign.rs b/tests/unit/out/unsafe/copy_assign.rs index d79f78ef36..defed5039b 100644 --- a/tests/unit/out/unsafe/copy_assign.rs +++ b/tests/unit/out/unsafe/copy_assign.rs @@ -98,10 +98,12 @@ impl Holder { { let mut __i0: usize = 0_usize; 'loop_: while ((__i0) != (2_usize)) { - (unsafe { - let _o: *const Partial = &(*_a0).arr[(__i0)]; - Partial::copy_assign(&mut self.arr[(__i0)], _o) - }); + 'for_body: { + (unsafe { + let _o: *const Partial = &(*_a0).arr[(__i0)]; + Partial::copy_assign(&mut self.arr[(__i0)], _o) + }); + } __i0.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/default_in_statics.rs b/tests/unit/out/unsafe/default_in_statics.rs index 8941c1513f..8e754298b8 100644 --- a/tests/unit/out/unsafe/default_in_statics.rs +++ b/tests/unit/out/unsafe/default_in_statics.rs @@ -95,11 +95,13 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (3)) { - assert!( - ((*std::cell::LazyCell::force_mut(&mut *&raw mut static_outer_1)).arr - [(i) as usize]) - .is_null() - ); + 'for_body: { + assert!( + ((*std::cell::LazyCell::force_mut(&mut *&raw mut static_outer_1)).arr + [(i) as usize]) + .is_null() + ); + } i.prefix_inc(); } } @@ -112,12 +114,14 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (2)) { - assert!( - ((*std::cell::LazyCell::force_mut(&mut *&raw mut static_inner_array_2)) - [(i) as usize] - .name) - .is_null() - ); + 'for_body: { + assert!( + ((*std::cell::LazyCell::force_mut(&mut *&raw mut static_inner_array_2)) + [(i) as usize] + .name) + .is_null() + ); + } i.prefix_inc(); } } @@ -128,24 +132,26 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (2)) { - assert!( - ((*std::cell::LazyCell::force_mut(&mut *&raw mut static_foo_array_4)) - [(i) as usize] - .s2) - .is_null() - ); - assert!( - ((*std::cell::LazyCell::force_mut(&mut *&raw mut static_foo_array_4)) - [(i) as usize] - .fn1) - .is_none() - ); - assert!( - ((*std::cell::LazyCell::force_mut(&mut *&raw mut static_foo_array_4)) - [(i) as usize] - .fn2) - .is_none() - ); + 'for_body: { + assert!( + ((*std::cell::LazyCell::force_mut(&mut *&raw mut static_foo_array_4)) + [(i) as usize] + .s2) + .is_null() + ); + assert!( + ((*std::cell::LazyCell::force_mut(&mut *&raw mut static_foo_array_4)) + [(i) as usize] + .fn1) + .is_none() + ); + assert!( + ((*std::cell::LazyCell::force_mut(&mut *&raw mut static_foo_array_4)) + [(i) as usize] + .fn2) + .is_none() + ); + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/doubly_linked_list.rs b/tests/unit/out/unsafe/doubly_linked_list.rs index 93cc6d7fbf..6eeb637cb1 100644 --- a/tests/unit/out/unsafe/doubly_linked_list.rs +++ b/tests/unit/out/unsafe/doubly_linked_list.rs @@ -26,7 +26,9 @@ pub unsafe fn Find_0(mut head: *mut Node, mut idx: i32) -> *mut Node { { let mut i: i32 = 0; 'loop_: while ((i) < (idx)) { - curr = (*curr).next; + 'for_body: { + curr = (*curr).next; + } i.postfix_inc(); } } @@ -37,7 +39,9 @@ pub unsafe fn FindBack_1(mut tail: *mut Node, mut idx: i32) -> *mut Node { { let mut i: i32 = 0; 'loop_: while ((i) < (idx)) { - curr = (*curr).prev; + 'for_body: { + curr = (*curr).prev; + } i.postfix_inc(); } } diff --git a/tests/unit/out/unsafe/emplace_hint_receiver_order.rs b/tests/unit/out/unsafe/emplace_hint_receiver_order.rs index 0cfdb0816c..d0070a2e49 100644 --- a/tests/unit/out/unsafe/emplace_hint_receiver_order.rs +++ b/tests/unit/out/unsafe/emplace_hint_receiver_order.rs @@ -34,23 +34,40 @@ unsafe fn main_0() -> i32 { { let mut select_receiver: i32 = 1; 'loop_: while ((select_receiver) >= (0)) { - let mut m: UnsafeMap)> = UnsafeMap::new(); - let mut v: Vec = Vec::from([1, 2, 3]); - let mut a: i32 = 0; - let mut b: i32 = 0; - if (select_receiver != 0) { - { - let mut __tmp_0 = { - (unsafe { - receiver_0( - (&mut m as *mut UnsafeMap)>), - (&mut v as *mut Vec), - (&mut a as *mut i32), + 'for_body: { + let mut m: UnsafeMap)> = UnsafeMap::new(); + let mut v: Vec = Vec::from([1, 2, 3]); + let mut a: i32 = 0; + let mut b: i32 = 0; + if (select_receiver != 0) { + { + let mut __tmp_0 = { + (unsafe { + receiver_0( + (&mut m as *mut UnsafeMap)>), + (&mut v as *mut Vec), + (&mut a as *mut i32), + ) + }) + }; + let mut __tmp_1 = { + )>>::from( + (unsafe { + hint_1( + (&mut m as *mut UnsafeMap)>), + (&mut v as *mut Vec), + (&mut b as *mut i32), + ) + }), ) - }) + }; + let mut __tmp_2 = { (1, (v).clone()) }; + let _ = (__tmp_1).clone(); + (*__tmp_0).emplace(__tmp_2).0 }; - let mut __tmp_1 = { - )>>::from( + } else { + { + let _ = )>>::from( (unsafe { hint_1( (&mut m as *mut UnsafeMap)>), @@ -58,36 +75,22 @@ unsafe fn main_0() -> i32 { (&mut b as *mut i32), ) }), - ) + ); + m.emplace((1, (v).clone())).0 }; - let mut __tmp_2 = { (1, (v).clone()) }; - let _ = (__tmp_1).clone(); - (*__tmp_0).emplace(__tmp_2).0 - }; - } else { - { - let _ = )>>::from( - (unsafe { - hint_1( - (&mut m as *mut UnsafeMap)>), - (&mut v as *mut Vec), - (&mut b as *mut i32), - ) - }), - ); - m.emplace((1, (v).clone())).0 - }; + } + let inserted: *const Vec = &raw const (*m.get(&1).expect("out of range!")).1; + (unsafe { + libc::printf( + c"receiver=%d hint=%d source=%d inserted=%d\n".as_ptr() + as *const libc::c_char, + (a), + (b), + (v[(2_usize)]), + ((&(*inserted))[(2_usize)]), + ) + }); } - let inserted: *const Vec = &raw const (*m.get(&1).expect("out of range!")).1; - (unsafe { - libc::printf( - c"receiver=%d hint=%d source=%d inserted=%d\n".as_ptr() as *const libc::c_char, - (a), - (b), - (v[(2_usize)]), - ((&(*inserted))[(2_usize)]), - ) - }); select_receiver.prefix_dec(); } } diff --git a/tests/unit/out/unsafe/emplace_receiver_order.rs b/tests/unit/out/unsafe/emplace_receiver_order.rs index 2af011630b..10824fecc1 100644 --- a/tests/unit/out/unsafe/emplace_receiver_order.rs +++ b/tests/unit/out/unsafe/emplace_receiver_order.rs @@ -24,61 +24,64 @@ unsafe fn main_0() -> i32 { { let mut bound: i32 = 0; 'loop_: while ((bound) < (2)) { - let mut rows: Vec> = Vec::from([Vec::from([1, 2, 3])]); - if 2_usize > rows.capacity() as usize { - let len_0 = rows.len(); - rows.reserve_exact(2_usize - len_0 as usize); - }; - let mut calls: i32 = 0; - if (bound != 0) { - let mut receiver: *mut Vec> = (unsafe { - select_rows_0((&mut rows as *mut Vec>), (&mut calls as *mut i32)) - }); - (*receiver).push({ - let mut __tmp_0 = { rows[(0_usize)].as_mut_ptr() }; - let mut __tmp_1 = { rows[(0_usize)].as_mut_ptr().offset((3) as isize) }; - let mut __v = Vec::new(); - let mut __it = __tmp_0; - while __it != __tmp_1 { - __v.push((*__it.iter_deref())); - __it.iter_inc(); - } - __v - }); - } else { - { - let mut __tmp_2 = { - (unsafe { - select_rows_0( - (&mut rows as *mut Vec>), - (&mut calls as *mut i32), - ) - }) - }; - let mut __tmp_5 = { - { - let mut __tmp_3 = { rows[(0_usize)].as_mut_ptr() }; - let mut __tmp_4 = { rows[(0_usize)].as_mut_ptr().offset((3) as isize) }; - let mut __v = Vec::new(); - let mut __it = __tmp_3; - while __it != __tmp_4 { - __v.push((*__it.iter_deref())); - __it.iter_inc(); - } - __v + 'for_body: { + let mut rows: Vec> = Vec::from([Vec::from([1, 2, 3])]); + if 2_usize > rows.capacity() as usize { + let len_0 = rows.len(); + rows.reserve_exact(2_usize - len_0 as usize); + }; + let mut calls: i32 = 0; + if (bound != 0) { + let mut receiver: *mut Vec> = (unsafe { + select_rows_0((&mut rows as *mut Vec>), (&mut calls as *mut i32)) + }); + (*receiver).push({ + let mut __tmp_0 = { rows[(0_usize)].as_mut_ptr() }; + let mut __tmp_1 = { rows[(0_usize)].as_mut_ptr().offset((3) as isize) }; + let mut __v = Vec::new(); + let mut __it = __tmp_0; + while __it != __tmp_1 { + __v.push((*__it.iter_deref())); + __it.iter_inc(); } + __v + }); + } else { + { + let mut __tmp_2 = { + (unsafe { + select_rows_0( + (&mut rows as *mut Vec>), + (&mut calls as *mut i32), + ) + }) + }; + let mut __tmp_5 = { + { + let mut __tmp_3 = { rows[(0_usize)].as_mut_ptr() }; + let mut __tmp_4 = + { rows[(0_usize)].as_mut_ptr().offset((3) as isize) }; + let mut __v = Vec::new(); + let mut __it = __tmp_3; + while __it != __tmp_4 { + __v.push((*__it.iter_deref())); + __it.iter_inc(); + } + __v + } + }; + (*__tmp_2).push(__tmp_5) }; - (*__tmp_2).push(__tmp_5) - }; + } + (unsafe { + libc::printf( + c"source=%d inserted=%d calls=%d\n".as_ptr() as *const libc::c_char, + (rows[(0_usize)][(2_usize)]), + (rows[(1_usize)][(2_usize)]), + (calls), + ) + }); } - (unsafe { - libc::printf( - c"source=%d inserted=%d calls=%d\n".as_ptr() as *const libc::c_char, - (rows[(0_usize)][(2_usize)]), - (rows[(1_usize)][(2_usize)]), - (calls), - ) - }); bound.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/enum_increment.rs b/tests/unit/out/unsafe/enum_increment.rs index 5b9a5ce733..64c86763b3 100644 --- a/tests/unit/out/unsafe/enum_increment.rs +++ b/tests/unit/out/unsafe/enum_increment.rs @@ -22,7 +22,9 @@ unsafe fn main_0() -> i32 { { let mut c: color = color_RED; 'loop_: while ((c as u32) < ((color_COLOR_LAST as i32) as u32)) { - count.postfix_inc(); + 'for_body: { + count.postfix_inc(); + } c.postfix_inc(); } } diff --git a/tests/unit/out/unsafe/fft.rs b/tests/unit/out/unsafe/fft.rs index 8b958b9a49..473a10c669 100644 --- a/tests/unit/out/unsafe/fft.rs +++ b/tests/unit/out/unsafe/fft.rs @@ -64,14 +64,16 @@ pub unsafe fn fft_3(a: *mut Option>, mut N: i32) -> Option>, mut N: i32) -> Option>, mut N: i32) -> Option i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (N)) { - (*a.as_deref() - .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut Complex) - .add((i as usize))) = Complex { - re: ((i as f64) + (1_f64)), - img: 0_f64, - }; + 'for_body: { + (*a.as_deref() + .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut Complex) + .add((i as usize))) = Complex { + re: ((i as f64) + (1_f64)), + img: 0_f64, + }; + } i.postfix_inc(); } } @@ -213,24 +221,26 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (N)) { - (*reals - .as_deref() - .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut i32) - .add((i as usize))) = (((*b - .as_deref() - .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut Complex) - .add((i as usize))) - .re - .round()) as i32); - (*imgs - .as_deref() - .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut i32) - .add((i as usize))) = (((*b - .as_deref() - .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut Complex) - .add((i as usize))) - .img - .round()) as i32); + 'for_body: { + (*reals + .as_deref() + .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut i32) + .add((i as usize))) = (((*b + .as_deref() + .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut Complex) + .add((i as usize))) + .re + .round()) as i32); + (*imgs + .as_deref() + .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut i32) + .add((i as usize))) = (((*b + .as_deref() + .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut Complex) + .add((i as usize))) + .img + .round()) as i32); + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/field_array_elem_ptr.rs b/tests/unit/out/unsafe/field_array_elem_ptr.rs index c10d3b33db..29e82229e9 100644 --- a/tests/unit/out/unsafe/field_array_elem_ptr.rs +++ b/tests/unit/out/unsafe/field_array_elem_ptr.rs @@ -25,7 +25,9 @@ pub unsafe fn sum_0(mut p: *const i32, mut n: i32) -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (n)) { - s += (*p.offset((i) as isize)); + 'for_body: { + s += (*p.offset((i) as isize)); + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/field_pointers.rs b/tests/unit/out/unsafe/field_pointers.rs index 8827105de2..e09cda3974 100644 --- a/tests/unit/out/unsafe/field_pointers.rs +++ b/tests/unit/out/unsafe/field_pointers.rs @@ -111,7 +111,10 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (3)) { - (*name.offset((i) as isize)) = (((('a' as libc::c_char) as i32) + (i)) as libc::c_char); + 'for_body: { + (*name.offset((i) as isize)) = + (((('a' as libc::c_char) as i32) + (i)) as libc::c_char); + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/field_reinterpret_write_through.rs b/tests/unit/out/unsafe/field_reinterpret_write_through.rs index e8ceca408b..249fe723ff 100644 --- a/tests/unit/out/unsafe/field_reinterpret_write_through.rs +++ b/tests/unit/out/unsafe/field_reinterpret_write_through.rs @@ -25,7 +25,9 @@ pub unsafe fn set_bytes_0(mut p: *mut u8, mut n: usize, mut v: u8) { { let mut i: usize = 0_usize; 'loop_: while ((i) < (n)) { - (*p.offset((i) as isize)) = v; + 'for_body: { + (*p.offset((i) as isize)) = v; + } i.postfix_inc(); } } @@ -34,8 +36,10 @@ pub unsafe fn all_bytes_1(mut p: *const u8, mut n: usize, mut v: u8) -> i32 { { let mut i: usize = 0_usize; 'loop_: while ((i) < (n)) { - if (((*p.offset((i) as isize)) as i32) != (v as i32)) { - return 0; + 'for_body: { + if (((*p.offset((i) as isize)) as i32) != (v as i32)) { + return 0; + } } i.postfix_inc(); } 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 2432d9daa7..7fc43b65e1 100644 --- a/tests/unit/out/unsafe/first_field_ptr_covers_struct.rs +++ b/tests/unit/out/unsafe/first_field_ptr_covers_struct.rs @@ -62,7 +62,9 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (4)) { - (*bz.offset((i) as isize)) = 1_u8; + 'for_body: { + (*bz.offset((i) as isize)) = 1_u8; + } i.postfix_inc(); } } diff --git a/tests/unit/out/unsafe/fn_ptr_stdlib_compare.rs b/tests/unit/out/unsafe/fn_ptr_stdlib_compare.rs index 3c3d839827..471be3bc18 100644 --- a/tests/unit/out/unsafe/fn_ptr_stdlib_compare.rs +++ b/tests/unit/out/unsafe/fn_ptr_stdlib_compare.rs @@ -78,14 +78,18 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (10)) { - assert!(((buf[(i) as usize] as i32) == (0))); + 'for_body: { + assert!(((buf[(i) as usize] as i32) == (0))); + } i.prefix_inc(); } } { let mut i: i32 = 10; 'loop_: while ((i) < (16)) { - assert!(((buf[(i) as usize] as i32) == (('X' as libc::c_char) as i32))); + 'for_body: { + assert!(((buf[(i) as usize] as i32) == (('X' as libc::c_char) as i32))); + } i.prefix_inc(); } } @@ -117,14 +121,18 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (10)) { - assert!(((buf[(i) as usize] as i32) == (0))); + 'for_body: { + assert!(((buf[(i) as usize] as i32) == (0))); + } i.prefix_inc(); } } { let mut i: i32 = 10; 'loop_: while ((i) < (16)) { - assert!(((buf[(i) as usize] as i32) == (('X' as libc::c_char) as i32))); + 'for_body: { + assert!(((buf[(i) as usize] as i32) == (('X' as libc::c_char) as i32))); + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/for_body_destructor.rs b/tests/unit/out/unsafe/for_body_destructor.rs new file mode 100644 index 0000000000..c20ee7e57c --- /dev/null +++ b/tests/unit/out/unsafe/for_body_destructor.rs @@ -0,0 +1,198 @@ +extern crate libc; +use libc::*; +extern crate libcc2rs; +use libcc2rs::*; +use std::collections::BTreeMap; +use std::io::{Read, Seek, Write}; +use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; +use std::rc::Rc; +#[repr(C)] +#[derive(Clone, VaArg, FnPtrArg, DestructorUnsafe, Default)] +pub struct Guard { + pub digit: i32, +} +impl Guard { + pub unsafe fn destructor(&mut self) { + (unsafe { libc::printf(c"%d ".as_ptr() as *const libc::c_char, (self.digit)) }); + } + pub unsafe fn to_bool(&self) -> bool { + return ((self.digit) != (0)); + } +} +pub unsafe fn step_0(i: *mut i32) { + (unsafe { libc::printf(c"9 ".as_ptr() as *const libc::c_char) }); + (*i).prefix_inc(); +} +pub fn main() { + unsafe { + __cpp2rust_init_globals(); + libcc2rs::cpp2rust_exit(main_0() as i32); + } +} +unsafe fn main_0() -> i32 { + (unsafe { libc::printf(c"normal/continue: ".as_ptr() as *const libc::c_char) }); + { + let mut i: i32 = 0; + 'loop_: while ((i) < (2)) { + 'for_body: { + let mut first: Guard = Guard { digit: 1 }; + let _dtor_first = + std::mem::DropGuard::new(&raw mut first, |__p| unsafe { (*__p).destructor() }); + let mut second: Guard = Guard { digit: 2 }; + let _dtor_second = + std::mem::DropGuard::new(&raw mut second, |__p| unsafe { (*__p).destructor() }); + if ((i) == (0)) { + break 'for_body; + } + } + (unsafe { step_0(&mut i) }); + } + } + (unsafe { libc::printf(c"\nbreak: ".as_ptr() as *const libc::c_char) }); + { + let mut i: i32 = 0; + 'loop_: while ((i) < (2)) { + 'for_body: { + let mut g: Guard = Guard { digit: 3 }; + let _dtor_g = + std::mem::DropGuard::new(&raw mut g, |__p| unsafe { (*__p).destructor() }); + break 'loop_; + } + (unsafe { step_0(&mut i) }); + } + } + (unsafe { libc::printf(c"\nnested for: ".as_ptr() as *const libc::c_char) }); + { + let mut i: i32 = 0; + 'loop_: while ((i) < (1)) { + 'for_body: { + let mut outer: Guard = Guard { digit: 4 }; + let _dtor_outer = + std::mem::DropGuard::new(&raw mut outer, |__p| unsafe { (*__p).destructor() }); + { + let mut j: i32 = 0; + 'loop_: while ((j) < (2)) { + 'for_body: { + let mut inner: Guard = Guard { digit: 5 }; + let _dtor_inner = + std::mem::DropGuard::new(&raw mut inner, |__p| unsafe { + (*__p).destructor() + }); + if ((j) == (0)) { + break 'for_body; + } + break 'loop_; + } + (unsafe { step_0(&mut j) }); + } + } + break 'for_body; + } + (unsafe { step_0(&mut i) }); + } + } + (unsafe { libc::printf(c"\ninner while/do/range: ".as_ptr() as *const libc::c_char) }); + { + let mut i: i32 = 0; + 'loop_: while ((i) < (1)) { + 'for_body: { + let mut outer: Guard = Guard { digit: 4 }; + let _dtor_outer = + std::mem::DropGuard::new(&raw mut outer, |__p| unsafe { (*__p).destructor() }); + let mut j: i32 = 0; + 'loop_: while ((*j.prefix_inc()) < (3)) { + let mut inner: Guard = Guard { digit: 5 }; + let _dtor_inner = std::mem::DropGuard::new(&raw mut inner, |__p| unsafe { + (*__p).destructor() + }); + if ((j) == (1)) { + continue 'loop_; + } + break; + } + let mut __do_while = true; + 'loop_: while __do_while || (false) { + __do_while = false; + let mut inner: Guard = Guard { digit: 6 }; + let _dtor_inner = std::mem::DropGuard::new(&raw mut inner, |__p| unsafe { + (*__p).destructor() + }); + continue 'loop_; + } + let mut values: [i32; 2] = [1, 2]; + 'loop_: for value in IterRange::new( + values.as_mut_ptr(), + values.as_mut_ptr().offset((2_i64) as isize), + ) { + let mut value: i32 = (*value); + let mut inner: Guard = Guard { digit: value }; + let _dtor_inner = std::mem::DropGuard::new(&raw mut inner, |__p| unsafe { + (*__p).destructor() + }); + if ((value) == (1)) { + continue 'loop_; + } + break; + } + break 'for_body; + } + (unsafe { step_0(&mut i) }); + } + } + (unsafe { libc::printf(c"\ncondition: ".as_ptr() as *const libc::c_char) }); + { + let mut i: i32 = 2; + 'loop_: loop { + let mut condition: Guard = Guard { digit: i }; + let _dtor_condition = + std::mem::DropGuard::new(&raw mut condition, |__p| unsafe { (*__p).destructor() }); + if !(unsafe { Guard::to_bool(&condition) }) { + break; + } + 'for_body: { + let mut body: Guard = Guard { digit: 4 }; + let _dtor_body = + std::mem::DropGuard::new(&raw mut body, |__p| unsafe { (*__p).destructor() }); + if ((i) == (2)) { + break 'for_body; + } + } + { + i.prefix_dec(); + (unsafe { + libc::printf(c"inc%d ".as_ptr() as *const libc::c_char, (condition.digit)) + }) + }; + } + } + (unsafe { libc::printf(c"\ninit/noncompound: ".as_ptr() as *const libc::c_char) }); + let mut i: i32 = 0; + { + let mut init: Guard = Guard { digit: 5 }; + let _dtor_init = + std::mem::DropGuard::new(&raw mut init, |__p| unsafe { (*__p).destructor() }); + 'loop_: while ((i) < (2)) { + 'for_body: { + let mut body: Guard = Guard { digit: 6 }; + let _dtor_body = + std::mem::DropGuard::new(&raw mut body, |__p| unsafe { (*__p).destructor() }); + } + (unsafe { step_0(&mut i) }); + } + } + (unsafe { libc::printf(c"\nno increment: ".as_ptr() as *const libc::c_char) }); + { + let mut j: i32 = 0; + 'loop_: while ((j) < (2)) { + let mut g: Guard = Guard { + digit: (*j.prefix_inc()), + }; + let _dtor_g = + std::mem::DropGuard::new(&raw mut g, |__p| unsafe { (*__p).destructor() }); + continue 'loop_; + } + } + (unsafe { libc::printf(c"\n".as_ptr() as *const libc::c_char) }); + return 0; +} +pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/foreach.rs b/tests/unit/out/unsafe/foreach.rs index 7937f269eb..21d9979b60 100644 --- a/tests/unit/out/unsafe/foreach.rs +++ b/tests/unit/out/unsafe/foreach.rs @@ -17,10 +17,12 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (10)) { - { - let a0_clone = i.clone(); - v.push(a0_clone) - }; + 'for_body: { + { + let a0_clone = i.clone(); + v.push(a0_clone) + }; + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/foreach_map.rs b/tests/unit/out/unsafe/foreach_map.rs index 5a32028f6e..de79b665e6 100644 --- a/tests/unit/out/unsafe/foreach_map.rs +++ b/tests/unit/out/unsafe/foreach_map.rs @@ -18,7 +18,9 @@ unsafe fn main_0() -> i32 { let mut i: i32 = 0; let mut k: i32 = 100; 'loop_: while ((i) < (100)) { - (*m.subscript(&i, || 0_f64)) = ((k as f64) / (2_f64)); + 'for_body: { + (*m.subscript(&i, || 0_f64)) = ((k as f64) / (2_f64)); + } { i.prefix_inc(); k.prefix_dec() diff --git a/tests/unit/out/unsafe/global_pointers.rs b/tests/unit/out/unsafe/global_pointers.rs index 61ea26cf6b..d3a389252e 100644 --- a/tests/unit/out/unsafe/global_pointers.rs +++ b/tests/unit/out/unsafe/global_pointers.rs @@ -49,14 +49,17 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (2)) { - assert!( - ((*std::cell::LazyCell::force_mut(&mut *&raw mut entries_1))[(i) as usize].p) - .is_null() - ); - assert!( - ((*std::cell::LazyCell::force_mut(&mut *&raw mut arr_of_pointers_2))[(i) as usize]) - .is_null() - ); + 'for_body: { + assert!( + ((*std::cell::LazyCell::force_mut(&mut *&raw mut entries_1))[(i) as usize].p) + .is_null() + ); + assert!( + ((*std::cell::LazyCell::force_mut(&mut *&raw mut arr_of_pointers_2)) + [(i) as usize]) + .is_null() + ); + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/goto_cleanup.rs b/tests/unit/out/unsafe/goto_cleanup.rs index 1d6daee899..e0f62b3912 100644 --- a/tests/unit/out/unsafe/goto_cleanup.rs +++ b/tests/unit/out/unsafe/goto_cleanup.rs @@ -33,11 +33,13 @@ pub unsafe fn from_loop_1(mut n: i32) -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (n)) { - if ((i) == (3)) { - ret = 7; - goto!('out); + 'for_body: { + if ((i) == (3)) { + ret = 7; + goto!('out); + } + ret += i; } - ret += i; i.postfix_inc(); } } diff --git a/tests/unit/out/unsafe/goto_loop_control.rs b/tests/unit/out/unsafe/goto_loop_control.rs index 4c15b88e89..2f0dc995f7 100644 --- a/tests/unit/out/unsafe/goto_loop_control.rs +++ b/tests/unit/out/unsafe/goto_loop_control.rs @@ -11,21 +11,22 @@ pub unsafe fn loopctl_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (5)) { - goto_block!({ - '__entry: { - if ((i) == (1)) { - i.postfix_inc(); - continue 'loop_; + 'for_body: { + goto_block!({ + '__entry: { + if ((i) == (1)) { + break 'for_body; + } + if ((i) == (4)) { + break 'loop_; + } + goto!('add); } - if ((i) == (4)) { - break; + 'add: { + sum += 1; } - goto!('add); - } - 'add: { - sum += 1; - } - }); + }); + } i.postfix_inc(); } } diff --git a/tests/unit/out/unsafe/goto_nested_label.rs b/tests/unit/out/unsafe/goto_nested_label.rs index d36652fd8d..4a94a19baf 100644 --- a/tests/unit/out/unsafe/goto_nested_label.rs +++ b/tests/unit/out/unsafe/goto_nested_label.rs @@ -11,23 +11,25 @@ pub unsafe fn scan_0(mut n: i32) -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (n)) { - let mut j: i32 = 0_i32; - goto_block!({ - '__entry: { - j = 0; - 'loop_: while ((j) < (10)) { - if ((j) == (5)) { - goto!('next); + 'for_body: { + let mut j: i32 = 0_i32; + goto_block!({ + '__entry: { + j = 0; + 'loop_: while ((j) < (10)) { + if ((j) == (5)) { + goto!('next); + } + total += 1; + j.postfix_inc(); } - total += 1; - j.postfix_inc(); + total += 100; } - total += 100; - } - 'next: { - total += 1000; - } - }); + 'next: { + total += 1000; + } + }); + } i.postfix_inc(); } } diff --git a/tests/unit/out/unsafe/goto_nested_loop_control.rs b/tests/unit/out/unsafe/goto_nested_loop_control.rs index fd546fcce7..f010e01406 100644 --- a/tests/unit/out/unsafe/goto_nested_loop_control.rs +++ b/tests/unit/out/unsafe/goto_nested_loop_control.rs @@ -18,23 +18,25 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (3)) { - goto_block!({ - '__entry: {} - 'outer: { - visits.postfix_inc(); - { - goto_block!({ - '__entry: {} - 'inner: { - if ((i) == (0)) { - break; + 'for_body: { + goto_block!({ + '__entry: {} + 'outer: { + visits.postfix_inc(); + { + goto_block!({ + '__entry: {} + 'inner: { + if ((i) == (0)) { + break 'loop_; + } } - } - }); + }); + } + tail.postfix_inc(); } - tail.postfix_inc(); - } - }); + }); + } i.postfix_inc(); } } @@ -45,37 +47,39 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (3)) { - switch!(match i { - __v if __v == 0 => { - { - goto_block!({ - '__entry: {} - 'switch_outer: { - visits.postfix_inc(); - { - goto_block!({ - '__entry: {} - 'switch_inner: { - if ((i) == (0)) { - break; + 'for_body: { + switch!(match i { + __v if __v == 0 => { + { + goto_block!({ + '__entry: {} + 'switch_outer: { + visits.postfix_inc(); + { + goto_block!({ + '__entry: {} + 'switch_inner: { + if ((i) == (0)) { + break; + } } - } - }); + }); + } + tail.postfix_inc(); } - tail.postfix_inc(); - } - }); + }); + } } - } - __v if __v == 1 => { - tail += 10; - break; - } - _ => { - tail += 100; - break; - } - }); + __v if __v == 1 => { + tail += 10; + break; + } + _ => { + tail += 100; + break; + } + }); + } i.postfix_inc(); } } diff --git a/tests/unit/out/unsafe/huffman.rs b/tests/unit/out/unsafe/huffman.rs index 2476f07279..fe532093eb 100644 --- a/tests/unit/out/unsafe/huffman.rs +++ b/tests/unit/out/unsafe/huffman.rs @@ -202,30 +202,34 @@ impl MinHeap { { let mut i: i32 = 0; 'loop_: while ((i) < (n)) { - (*self - .arr - .as_deref() - .map_or(::std::ptr::null_mut(), |s| { - s.as_ptr() as *mut *mut MinHeapNode - }) - .add((self.size.postfix_inc() as usize))) = (unsafe { - let _data: libc::c_char = (*(*data) - .as_deref() - .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut libc::c_char) - .add((i as usize))); - let _freq: i32 = (*(*freq) + 'for_body: { + (*self + .arr .as_deref() - .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut i32) - .add((i as usize))); - MinHeap::Alloc(self, _data, _freq) - }); + .map_or(::std::ptr::null_mut(), |s| { + s.as_ptr() as *mut *mut MinHeapNode + }) + .add((self.size.postfix_inc() as usize))) = (unsafe { + let _data: libc::c_char = (*(*data) + .as_deref() + .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut libc::c_char) + .add((i as usize))); + let _freq: i32 = (*(*freq) + .as_deref() + .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut i32) + .add((i as usize))); + MinHeap::Alloc(self, _data, _freq) + }); + } i.prefix_inc(); } } { let mut i: i32 = (((self.size) - (2)) / (2)); 'loop_: while ((i) >= (0)) { - (unsafe { MinHeap::Heapify(self, i) }); + 'for_body: { + (unsafe { MinHeap::Heapify(self, i) }); + } i.prefix_dec(); } } @@ -345,25 +349,27 @@ pub unsafe fn CollectCode_3( { let mut i: i32 = 0; 'loop_: while ((i) < (top)) { - (*(*out) - .as_deref() - .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut i32) - .add(((*next) as usize))) = ((*(*out) - .as_deref() - .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut i32) - .add(((*next) as usize))) - * (10)); - (*(*out) - .as_deref() - .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut i32) - .add(((*next) as usize))) = ((*(*out) - .as_deref() - .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut i32) - .add(((*next) as usize))) - + (*(*arr) + 'for_body: { + (*(*out) .as_deref() .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut i32) - .add((i as usize)))); + .add(((*next) as usize))) = ((*(*out) + .as_deref() + .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut i32) + .add(((*next) as usize))) + * (10)); + (*(*out) + .as_deref() + .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut i32) + .add(((*next) as usize))) = ((*(*out) + .as_deref() + .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut i32) + .add(((*next) as usize))) + + (*(*arr) + .as_deref() + .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut i32) + .add((i as usize)))); + } i.prefix_inc(); } } @@ -466,14 +472,16 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (size)) { - (*data - .as_deref() - .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut libc::c_char) - .add((i as usize))) = arr1[(i) as usize]; - (*freq - .as_deref() - .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut i32) - .add((i as usize))) = arr2[(i) as usize]; + 'for_body: { + (*data + .as_deref() + .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut libc::c_char) + .add((i as usize))) = arr1[(i) as usize]; + (*freq + .as_deref() + .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut i32) + .add((i as usize))) = arr2[(i) as usize]; + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/ifaddrs.rs b/tests/unit/out/unsafe/ifaddrs.rs index feb96b45fc..39901d352d 100644 --- a/tests/unit/out/unsafe/ifaddrs.rs +++ b/tests/unit/out/unsafe/ifaddrs.rs @@ -20,65 +20,65 @@ unsafe fn main_0() -> i32 { let mut ifa: *mut libc::ifaddrs = std::ptr::null_mut(); ifa = list; 'loop_: while (!((ifa).is_null())) { - assert!((!(((*ifa).ifa_name).is_null()))); - if (((*ifa).ifa_addr).is_null()) { - ifa = (*ifa).ifa_next; - continue 'loop_; - } - if (((*(*ifa).ifa_addr).sa_family as i32) != (libc::AF_INET)) { - ifa = (*ifa).ifa_next; - continue 'loop_; - } - let mut sin: *mut ::libc::sockaddr_in = ((*ifa).ifa_addr as *mut ::libc::sockaddr_in); - let mut lo_be: [u8; 4] = [127_u8, 0_u8, 0_u8, 1_u8]; - if (({ - let sa = core::slice::from_raw_parts( - ((&mut (*sin).sin_addr as *mut ::libc::in_addr) as *const ::libc::c_void) - as *const u8, - 4_usize, - ); - let sb = core::slice::from_raw_parts( - (lo_be.as_mut_ptr() as *const ::libc::c_void) as *const u8, - 4_usize, - ); - let mut diff = 0_i32; - for (x, y) in sa.iter().zip(sb.iter()) { - if x != y { - diff = (*x as i32) - (*y as i32); - break; - } + 'for_body: { + assert!((!(((*ifa).ifa_name).is_null()))); + if (((*ifa).ifa_addr).is_null()) { + break 'for_body; } - diff - }) == (0)) - { - found_loopback = 1; - assert!((((*ifa).ifa_flags) != (0_u32))); - assert!((!(((*ifa).ifa_netmask).is_null()))); - let mut mask: *mut ::libc::sockaddr_in = - ((*ifa).ifa_netmask as *mut ::libc::sockaddr_in); - let mut mask_be: [u8; 4] = [255_u8, 0_u8, 0_u8, 0_u8]; - assert!( - (({ - let sa = core::slice::from_raw_parts( - ((&mut (*mask).sin_addr as *mut ::libc::in_addr) as *const ::libc::c_void) - as *const u8, - 4_usize, - ); - let sb = core::slice::from_raw_parts( - (mask_be.as_mut_ptr() as *const ::libc::c_void) as *const u8, - 4_usize, - ); - let mut diff = 0_i32; - for (x, y) in sa.iter().zip(sb.iter()) { - if x != y { - diff = (*x as i32) - (*y as i32); - break; - } + if (((*(*ifa).ifa_addr).sa_family as i32) != (libc::AF_INET)) { + break 'for_body; + } + let mut sin: *mut ::libc::sockaddr_in = ((*ifa).ifa_addr as *mut ::libc::sockaddr_in); + let mut lo_be: [u8; 4] = [127_u8, 0_u8, 0_u8, 1_u8]; + if (({ + let sa = core::slice::from_raw_parts( + ((&mut (*sin).sin_addr as *mut ::libc::in_addr) as *const ::libc::c_void) + as *const u8, + 4_usize, + ); + let sb = core::slice::from_raw_parts( + (lo_be.as_mut_ptr() as *const ::libc::c_void) as *const u8, + 4_usize, + ); + let mut diff = 0_i32; + for (x, y) in sa.iter().zip(sb.iter()) { + if x != y { + diff = (*x as i32) - (*y as i32); + break; } - diff - }) == (0)) - ); - assert!(((libc::if_nametoindex(((*ifa).ifa_name).cast_const())) > (0_u32))); + } + diff + }) == (0)) + { + found_loopback = 1; + assert!((((*ifa).ifa_flags) != (0_u32))); + assert!((!(((*ifa).ifa_netmask).is_null()))); + let mut mask: *mut ::libc::sockaddr_in = + ((*ifa).ifa_netmask as *mut ::libc::sockaddr_in); + let mut mask_be: [u8; 4] = [255_u8, 0_u8, 0_u8, 0_u8]; + assert!( + (({ + let sa = core::slice::from_raw_parts( + ((&mut (*mask).sin_addr as *mut ::libc::in_addr) + as *const ::libc::c_void) as *const u8, + 4_usize, + ); + let sb = core::slice::from_raw_parts( + (mask_be.as_mut_ptr() as *const ::libc::c_void) as *const u8, + 4_usize, + ); + let mut diff = 0_i32; + for (x, y) in sa.iter().zip(sb.iter()) { + if x != y { + diff = (*x as i32) - (*y as i32); + break; + } + } + diff + }) == (0)) + ); + assert!(((libc::if_nametoindex(((*ifa).ifa_name).cast_const())) > (0_u32))); + } } ifa = (*ifa).ifa_next; } diff --git a/tests/unit/out/unsafe/init_list.rs b/tests/unit/out/unsafe/init_list.rs index dcbc769fa1..ca8e0e678b 100644 --- a/tests/unit/out/unsafe/init_list.rs +++ b/tests/unit/out/unsafe/init_list.rs @@ -69,7 +69,9 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (4)) { - assert!(((sevens[(i) as usize].v) == (7))); + 'for_body: { + assert!(((sevens[(i) as usize].v) == (7))); + } i.postfix_inc(); } } diff --git a/tests/unit/out/unsafe/inline_container_fields.rs b/tests/unit/out/unsafe/inline_container_fields.rs index 9e09c201b3..57a96262be 100644 --- a/tests/unit/out/unsafe/inline_container_fields.rs +++ b/tests/unit/out/unsafe/inline_container_fields.rs @@ -103,7 +103,9 @@ pub unsafe fn sum_0(mut p: *const i32, mut n: i32) -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (n)) { - s += (*p.offset((i) as isize)); + 'for_body: { + s += (*p.offset((i) as isize)); + } i.prefix_inc(); } } @@ -113,11 +115,15 @@ pub unsafe fn fill_1(mut s: *mut State) { { let mut i: i32 = 0; 'loop_: while ((i) < (2)) { - { - let mut j: i32 = 0; - 'loop_: while ((j) < (3)) { - (*s).grid[(i) as usize][(j) as usize] = (((i) * (3)) + (j)); - j.prefix_inc(); + 'for_body: { + { + let mut j: i32 = 0; + 'loop_: while ((j) < (3)) { + 'for_body: { + (*s).grid[(i) as usize][(j) as usize] = (((i) * (3)) + (j)); + } + j.prefix_inc(); + } } } i.prefix_inc(); @@ -128,11 +134,13 @@ pub unsafe fn fill_1(mut s: *mut State) { { let mut i: i32 = 0; 'loop_: while ((i) < (3)) { - (&mut (*s)).elems[(i as usize)].id = i; - (&mut (*s)).elems[(i as usize)].hist[(i) as usize] = ((10) * (i)); - (&mut (*s)).elems[(i as usize)] - .coeffs - .resize(4_usize, (i as i16)); + 'for_body: { + (&mut (*s)).elems[(i as usize)].id = i; + (&mut (*s)).elems[(i as usize)].hist[(i) as usize] = ((10) * (i)); + (&mut (*s)).elems[(i as usize)] + .coeffs + .resize(4_usize, (i as i16)); + } i.prefix_inc(); } } @@ -205,7 +213,9 @@ unsafe fn main_0() -> i32 { { let mut k: i32 = 0; 'loop_: while ((k) < (4)) { - (*h.offset((k) as isize)) += k; + 'for_body: { + (*h.offset((k) as isize)) += k; + } k.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/kruskal.rs b/tests/unit/out/unsafe/kruskal.rs index 8251801723..63be916792 100644 --- a/tests/unit/out/unsafe/kruskal.rs +++ b/tests/unit/out/unsafe/kruskal.rs @@ -22,14 +22,16 @@ pub unsafe fn partition_0(arr: *mut Option>, mut start: i32, mut end { let mut i: i32 = ((start) + (1)); 'loop_: while ((i) <= (end)) { - if (((*(*arr) - .as_deref() - .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut Edge) - .add((i as usize))) - .weight) - <= ((*pivot).weight)) - { - count.postfix_inc(); + 'for_body: { + if (((*(*arr) + .as_deref() + .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut Edge) + .add((i as usize))) + .weight) + <= ((*pivot).weight)) + { + count.postfix_inc(); + } } i.prefix_inc(); } @@ -188,16 +190,18 @@ impl DisjointSet { { let mut i: i32 = 0; 'loop_: while ((i) < (self.n)) { - (*self - .parent - .as_deref() - .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut i32) - .add((i as usize))) = i; - (*self - .rank - .as_deref() - .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut i32) - .add((i as usize))) = 1; + 'for_body: { + (*self + .parent + .as_deref() + .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut i32) + .add((i as usize))) = i; + (*self + .rank + .as_deref() + .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut i32) + .add((i as usize))) = 1; + } i.postfix_inc(); } } @@ -353,29 +357,31 @@ pub unsafe fn MSTKruskal_2(graph: *mut Graph) -> f64 { { let mut i: i32 = 0; 'loop_: while ((i) < ((*graph).E)) { - let mut x: i32 = (*(*graph) - .edges - .as_deref() - .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut Edge) - .add((i as usize))) - .u; - let mut y: i32 = (*(*graph) - .edges - .as_deref() - .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut Edge) - .add((i as usize))) - .v; - let mut w: f64 = (*(*graph) - .edges - .as_deref() - .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut Edge) - .add((i as usize))) - .weight; - if ((unsafe { DisjointSet::find(&mut set, x) }) - != (unsafe { DisjointSet::find(&mut set, y) })) - { - (unsafe { DisjointSet::merge(&mut set, x, y) }); - total_weight += w; + 'for_body: { + let mut x: i32 = (*(*graph) + .edges + .as_deref() + .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut Edge) + .add((i as usize))) + .u; + let mut y: i32 = (*(*graph) + .edges + .as_deref() + .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut Edge) + .add((i as usize))) + .v; + let mut w: f64 = (*(*graph) + .edges + .as_deref() + .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut Edge) + .add((i as usize))) + .weight; + if ((unsafe { DisjointSet::find(&mut set, x) }) + != (unsafe { DisjointSet::find(&mut set, y) })) + { + (unsafe { DisjointSet::merge(&mut set, x, y) }); + total_weight += w; + } } i.prefix_inc(); } diff --git a/tests/unit/out/unsafe/lambda_immediate_init.rs b/tests/unit/out/unsafe/lambda_immediate_init.rs index 72bb85bf61..ed0d978020 100644 --- a/tests/unit/out/unsafe/lambda_immediate_init.rs +++ b/tests/unit/out/unsafe/lambda_immediate_init.rs @@ -40,7 +40,9 @@ pub static mut g_1: std::cell::LazyCell = std::cell::LazyCell::new(|| unsaf { let mut i: i32 = 1; 'loop_: while ((i) <= (4)) { - s += i; + 'for_body: { + s += i; + } i.postfix_inc(); } } diff --git a/tests/unit/out/unsafe/lambda_to_fn_ptr.rs b/tests/unit/out/unsafe/lambda_to_fn_ptr.rs index 8a34a75bfb..9c84283d68 100644 --- a/tests/unit/out/unsafe/lambda_to_fn_ptr.rs +++ b/tests/unit/out/unsafe/lambda_to_fn_ptr.rs @@ -95,7 +95,9 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (n)) { - s += ap.arg::(); + 'for_body: { + s += ap.arg::(); + } i.postfix_inc(); } }; diff --git a/tests/unit/out/unsafe/linked_list.rs b/tests/unit/out/unsafe/linked_list.rs index dfb3c81860..5e0acef85d 100644 --- a/tests/unit/out/unsafe/linked_list.rs +++ b/tests/unit/out/unsafe/linked_list.rs @@ -22,7 +22,9 @@ pub unsafe fn Find_0(mut head: *mut Node, mut idx: i32) -> *mut Node { { let mut i: i32 = 0; 'loop_: while ((i) < (idx)) { - curr = (*curr).next; + 'for_body: { + curr = (*curr).next; + } i.postfix_inc(); } } diff --git a/tests/unit/out/unsafe/malloc_realloc_free.rs b/tests/unit/out/unsafe/malloc_realloc_free.rs index d9a8aecb53..cae0bbd81d 100644 --- a/tests/unit/out/unsafe/malloc_realloc_free.rs +++ b/tests/unit/out/unsafe/malloc_realloc_free.rs @@ -26,7 +26,9 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (4)) { - (*arr.offset((i) as isize)) = ((i) * (10)); + 'for_body: { + (*arr.offset((i) as isize)) = ((i) * (10)); + } i.postfix_inc(); } } @@ -54,7 +56,9 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (4)) { - assert!(((*zeros.offset((i) as isize)) == (0))); + 'for_body: { + assert!(((*zeros.offset((i) as isize)) == (0))); + } i.postfix_inc(); } } @@ -81,7 +85,9 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (4)) { - (*arr.offset((i) as isize)) = ((i) * (10)); + 'for_body: { + (*arr.offset((i) as isize)) = ((i) * (10)); + } i.postfix_inc(); } } @@ -111,7 +117,9 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (4)) { - assert!(((*zeros.offset((i) as isize)) == (0))); + 'for_body: { + assert!(((*zeros.offset((i) as isize)) == (0))); + } i.postfix_inc(); } } diff --git a/tests/unit/out/unsafe/map-reallocation.rs b/tests/unit/out/unsafe/map-reallocation.rs index 1bedd1c837..fb998086d3 100644 --- a/tests/unit/out/unsafe/map-reallocation.rs +++ b/tests/unit/out/unsafe/map-reallocation.rs @@ -30,14 +30,18 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (sentinel)) { - (*m.subscript(&i, || 0_i32)) = i; + 'for_body: { + (*m.subscript(&i, || 0_i32)) = i; + } i.prefix_inc(); } } { let mut i: i32 = ((sentinel) + (1)); 'loop_: while ((i) <= (N)) { - (*m.subscript(&i, || 0_i32)) = i; + 'for_body: { + (*m.subscript(&i, || 0_i32)) = i; + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/map.rs b/tests/unit/out/unsafe/map.rs index 9690d193df..28699f0f2c 100644 --- a/tests/unit/out/unsafe/map.rs +++ b/tests/unit/out/unsafe/map.rs @@ -152,37 +152,45 @@ unsafe fn main_0() -> i32 { { let mut i: u32 = 60_u32; 'loop_: while ((i) > (30_u32)) { - { - let __a1 = (i as i32); - indexes.push(__a1) - }; + 'for_body: { + { + let __a1 = (i as i32); + indexes.push(__a1) + }; + } i.prefix_dec(); } } { let mut i: u32 = 100_u32; 'loop_: while ((i) > (60_u32)) { - { - let __a1 = (i as i32); - indexes.push(__a1) - }; + 'for_body: { + { + let __a1 = (i as i32); + indexes.push(__a1) + }; + } i.prefix_dec(); } } { let mut i: u32 = 30_u32; 'loop_: while ((i) > (0_u32)) { - { - let __a1 = (i as i32); - indexes.push(__a1) - }; + 'for_body: { + { + let __a1 = (i as i32); + indexes.push(__a1) + }; + } i.prefix_dec(); } } { let mut i: u32 = 0_u32; 'loop_: while ((i as usize) < (indexes.len())) { - (*m2.subscript(&indexes[(i as usize)], || false)) = ((i).wrapping_rem(2_u32) != 0); + 'for_body: { + (*m2.subscript(&indexes[(i as usize)], || false)) = ((i).wrapping_rem(2_u32) != 0); + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/map_try_emplace.rs b/tests/unit/out/unsafe/map_try_emplace.rs index 58bd2654cd..e32a166f94 100644 --- a/tests/unit/out/unsafe/map_try_emplace.rs +++ b/tests/unit/out/unsafe/map_try_emplace.rs @@ -133,85 +133,112 @@ unsafe fn main_0() -> i32 { { let mut subset: i32 = 0; 'loop_: while ((subset) < (8)) { - { - let mut key: i32 = 0; - 'loop_: while ((key) < (3)) { - { - let mut initial: i32 = 0; - 'loop_: while ((initial) < (3)) { + 'for_body: { + { + let mut key: i32 = 0; + 'loop_: while ((key) < (3)) { + 'for_body: { { - let mut post: i32 = 0; - 'loop_: while ((post) < (2)) { - let mut m: UnsafeMap = UnsafeMap::new(); - let mut size: i32 = 0; - { - let mut k: i32 = 0; - 'loop_: while ((k) < (3)) { - if (((subset) & ((1) << (k))) != 0) { - (*m.subscript(&k, || 0_i32)) = ((10) + (k)); - size.prefix_inc(); + let mut initial: i32 = 0; + 'loop_: while ((initial) < (3)) { + 'for_body: { + { + let mut post: i32 = 0; + 'loop_: while ((post) < (2)) { + 'for_body: { + let mut m: UnsafeMap = + UnsafeMap::new(); + let mut size: i32 = 0; + { + let mut k: i32 = 0; + 'loop_: while ((k) < (3)) { + 'for_body: { + if (((subset) & ((1) << (k))) != 0) + { + (*m.subscript(&k, || 0_i32)) = + ((10) + (k)); + size.prefix_inc(); + } + } + k.prefix_inc(); + } + } + let mut counter: i32 = initial; + let mut result: ( + UnsafeBidirectionalIterator<(i32, i32)>, + bool, + ) = { + let mut __tmp_3: i32; + if (post != 0) { + match (({ + __tmp_3 = counter.postfix_inc(); + &mut __tmp_3 + } + as *mut i32),) + { + (__tmp_2,) => m + .try_emplace(key, || { + (*__tmp_2) + }), + } + } else { + match (({ + let __tmp_5 = &mut counter; + (*__tmp_5).prefix_inc(); + __tmp_5 + } + as *mut i32),) + { + (__tmp_4,) => m + .try_emplace(key, || { + (*__tmp_4) + }), + } + } + }; + let mut hit: bool = + (((subset) & ((1) << (key))) != (0)); + ok = ((ok as i32) + & (((counter) == ((initial) + (1))) + as i32)) + != 0; + ok = ((ok as i32) + & ((((result.1) as i32) == (!(hit) as i32)) + as i32)) + != 0; + let mut found: bool = result.0 == m.find(&key); + ok = ((ok as i32) & (found as i32)) != 0; + ok = ((ok as i32) + & ((((*result.0.iter_deref()).0) == (key)) + as i32)) + != 0; + ok = ((ok as i32) + & ((((*result.0.iter_deref()).1) + == (if hit { + ((10) + (key)) + } else { + ((initial) + (!(post != 0) as i32)) + })) + as i32)) + != 0; + ok = ((ok as i32) + & (((m.len()) + == (((size) + (!(hit) as i32)) + as usize)) + as i32)) + != 0; + rows.prefix_inc(); + } + post.prefix_inc(); } - k.prefix_inc(); } } - let mut counter: i32 = initial; - let mut result: ( - UnsafeBidirectionalIterator<(i32, i32)>, - bool, - ) = { - let mut __tmp_3: i32; - if (post != 0) { - match (({ - __tmp_3 = counter.postfix_inc(); - &mut __tmp_3 - } - as *mut i32),) - { - (__tmp_2,) => m.try_emplace(key, || (*__tmp_2)), - } - } else { - match (({ - let __tmp_5 = &mut counter; - (*__tmp_5).prefix_inc(); - __tmp_5 - } - as *mut i32),) - { - (__tmp_4,) => m.try_emplace(key, || (*__tmp_4)), - } - } - }; - let mut hit: bool = (((subset) & ((1) << (key))) != (0)); - ok = ((ok as i32) & (((counter) == ((initial) + (1))) as i32)) - != 0; - ok = ((ok as i32) - & ((((result.1) as i32) == (!(hit) as i32)) as i32)) - != 0; - let mut found: bool = result.0 == m.find(&key); - ok = ((ok as i32) & (found as i32)) != 0; - ok = ((ok as i32) - & ((((*result.0.iter_deref()).0) == (key)) as i32)) - != 0; - ok = ((ok as i32) - & ((((*result.0.iter_deref()).1) - == (if hit { - ((10) + (key)) - } else { - ((initial) + (!(post != 0) as i32)) - })) as i32)) - != 0; - ok = ((ok as i32) - & (((m.len()) == (((size) + (!(hit) as i32)) as usize)) - as i32)) - != 0; - rows.prefix_inc(); - post.prefix_inc(); + initial.prefix_inc(); } } - initial.prefix_inc(); } + key.prefix_inc(); } - key.prefix_inc(); } } subset.prefix_inc(); diff --git a/tests/unit/out/unsafe/map_try_emplace_lvalues.rs b/tests/unit/out/unsafe/map_try_emplace_lvalues.rs index 1964142b87..1613225695 100644 --- a/tests/unit/out/unsafe/map_try_emplace_lvalues.rs +++ b/tests/unit/out/unsafe/map_try_emplace_lvalues.rs @@ -498,407 +498,427 @@ unsafe fn main_0() -> i32 { { let mut hit: i32 = 0; 'loop_: while ((hit) < (2)) { - let mut values: UnsafeMap = UnsafeMap::new(); - let keys: [i32; 6] = [0, 1, 2, 3, 4, 5]; - if (hit != 0) { - 'loop_: for k in - IterRange::new(keys.as_ptr(), keys.as_ptr().offset((6_i64) as isize)) + 'for_body: { + let mut values: UnsafeMap = UnsafeMap::new(); + let keys: [i32; 6] = [0, 1, 2, 3, 4, 5]; + if (hit != 0) { + 'loop_: for k in + IterRange::new(keys.as_ptr(), keys.as_ptr().offset((6_i64) as isize)) + { + let mut k: i32 = (*k); + (*values.subscript(&k, || 0_i32)) = 42; + } + } + let mut moved: i32 = 0; + let mut forwarded: i32 = 0; + let mut xvalue: i32 = 0; + let mut lvalue: i32 = 0; + let mut assigned: i32 = 0; + let mut nested: i32 = 0; + let mut r0: (UnsafeBidirectionalIterator<(i32, i32)>, bool) = match (({ + let __tmp_47 = &mut moved; + (*__tmp_47).prefix_inc(); + __tmp_47 + } + as *mut i32),) { - let mut k: i32 = (*k); - (*values.subscript(&k, || 0_i32)) = 42; + (__tmp_46,) => values.try_emplace(keys[(0) as usize], || (*__tmp_46)), + }; + let mut r1: (UnsafeBidirectionalIterator<(i32, i32)>, bool) = match (({ + let __tmp_49 = &mut forwarded; + (*__tmp_49).prefix_inc(); + __tmp_49 } - } - let mut moved: i32 = 0; - let mut forwarded: i32 = 0; - let mut xvalue: i32 = 0; - let mut lvalue: i32 = 0; - let mut assigned: i32 = 0; - let mut nested: i32 = 0; - let mut r0: (UnsafeBidirectionalIterator<(i32, i32)>, bool) = match (({ - let __tmp_47 = &mut moved; - (*__tmp_47).prefix_inc(); - __tmp_47 - } - as *mut i32),) - { - (__tmp_46,) => values.try_emplace(keys[(0) as usize], || (*__tmp_46)), - }; - let mut r1: (UnsafeBidirectionalIterator<(i32, i32)>, bool) = match (({ - let __tmp_49 = &mut forwarded; - (*__tmp_49).prefix_inc(); - __tmp_49 - } - as *mut i32),) - { - (__tmp_48,) => values.try_emplace(keys[(1) as usize], || (*__tmp_48)), - }; - let mut r2: (UnsafeBidirectionalIterator<(i32, i32)>, bool) = match (({ - let __tmp_51 = &mut xvalue; - (*__tmp_51).prefix_inc(); - __tmp_51 - } - as *mut i32),) - { - (__tmp_50,) => values.try_emplace(keys[(2) as usize], || (*__tmp_50)), - }; - let mut r3: (UnsafeBidirectionalIterator<(i32, i32)>, bool) = match (({ - let __tmp_53 = &mut lvalue; - (*__tmp_53).prefix_inc(); - __tmp_53 - } - as *mut i32),) - { - (__tmp_52,) => values.try_emplace(keys[(3) as usize], || (*__tmp_52)), - }; - let mut r4: (UnsafeBidirectionalIterator<(i32, i32)>, bool) = - match ((match ({ 5 }, (&mut assigned as *mut i32)) { - (__tmp_56, __tmp_55) => { - __tmp_55.write(__tmp_56); - __tmp_55 - } - } as *mut i32),) + as *mut i32),) { - (__tmp_54,) => values.try_emplace(keys[(4) as usize], || (*__tmp_54)), + (__tmp_48,) => values.try_emplace(keys[(1) as usize], || (*__tmp_48)), }; - let mut r5: (UnsafeBidirectionalIterator<(i32, i32)>, bool) = - match ((match ({ 1 }, (&mut nested as *mut i32)) { - (__tmp_59, __tmp_58) => { - __tmp_58.write((((*__tmp_58) as i32) + (__tmp_59 as i32)) as i32); - __tmp_58 - } - } as *mut i32),) + let mut r2: (UnsafeBidirectionalIterator<(i32, i32)>, bool) = match (({ + let __tmp_51 = &mut xvalue; + (*__tmp_51).prefix_inc(); + __tmp_51 + } + as *mut i32),) + { + (__tmp_50,) => values.try_emplace(keys[(2) as usize], || (*__tmp_50)), + }; + let mut r3: (UnsafeBidirectionalIterator<(i32, i32)>, bool) = match (({ + let __tmp_53 = &mut lvalue; + (*__tmp_53).prefix_inc(); + __tmp_53 + } + as *mut i32),) { - (__tmp_57,) => values.try_emplace(keys[(5) as usize], || (*__tmp_57)), + (__tmp_52,) => values.try_emplace(keys[(3) as usize], || (*__tmp_52)), }; - assert!( - ((((((moved) == (1)) && ((forwarded) == (1))) && ((xvalue) == (1))) - && ((lvalue) == (1))) - && ((assigned) == (5))) - && ((nested) == (1)) - ); - assert!( - (((((((r0.1) as i32) == (!(hit != 0) as i32)) - && (((r1.1) as i32) == (!(hit != 0) as i32))) - && (((r2.1) as i32) == (!(hit != 0) as i32))) - && (((r3.1) as i32) == (!(hit != 0) as i32))) - && (((r4.1) as i32) == (!(hit != 0) as i32))) - && (((r5.1) as i32) == (!(hit != 0) as i32)) - ); - 'loop_: for k in IterRange::new(keys.as_ptr(), keys.as_ptr().offset((6_i64) as isize)) { - let mut k: i32 = (*k); + let mut r4: (UnsafeBidirectionalIterator<(i32, i32)>, bool) = + match ((match ({ 5 }, (&mut assigned as *mut i32)) { + (__tmp_56, __tmp_55) => { + __tmp_55.write(__tmp_56); + __tmp_55 + } + } as *mut i32),) + { + (__tmp_54,) => values.try_emplace(keys[(4) as usize], || (*__tmp_54)), + }; + let mut r5: (UnsafeBidirectionalIterator<(i32, i32)>, bool) = + match ((match ({ 1 }, (&mut nested as *mut i32)) { + (__tmp_59, __tmp_58) => { + __tmp_58.write((((*__tmp_58) as i32) + (__tmp_59 as i32)) as i32); + __tmp_58 + } + } as *mut i32),) + { + (__tmp_57,) => values.try_emplace(keys[(5) as usize], || (*__tmp_57)), + }; assert!( - ((*values.subscript(&k, || 0_i32)) - == (if (hit != 0) { - 42 - } else { - if ((k) == (4)) { 5 } else { 1 } - })) + ((((((moved) == (1)) && ((forwarded) == (1))) && ((xvalue) == (1))) + && ((lvalue) == (1))) + && ((assigned) == (5))) + && ((nested) == (1)) ); - } - hit.prefix_inc(); - } - } - { - let mut hit: i32 = 0; - 'loop_: while ((hit) < (2)) { - { - let mut choose: i32 = 0; - 'loop_: while ((choose) < (2)) { - let mut selected: UnsafeMap = UnsafeMap::new(); - let keys: [i32; 3] = [0, 1, 2]; - if (hit != 0) { - 'loop_: for k in - IterRange::new(keys.as_ptr(), keys.as_ptr().offset((3_i64) as isize)) - { - let mut k: i32 = (*k); - (*selected.subscript(&k, || ::default())).value = 42; - } - } - let mut a: i32 = 0; - let mut b: i32 = 0; - let mut c: i32 = 0; - let mut d: i32 = 0; - let mut e: i32 = 0; - let mut f: i32 = 0; - let mut prefix: (UnsafeBidirectionalIterator<(i32, Item)>, bool) = - match ((if (choose != 0) { - ({ - let __tmp_61 = &mut a; - (*__tmp_61).prefix_inc(); - __tmp_61 - } as *mut i32) - } else { - ({ - let __tmp_62 = &mut b; - (*__tmp_62).prefix_inc(); - __tmp_62 - } as *mut i32) - } as *mut i32),) - { - (__tmp_60,) => selected.try_emplace(keys[(0) as usize], || { - Item::new_2({ __tmp_60 }, { 2 }) - }), - }; - let mut assignment: (UnsafeBidirectionalIterator<(i32, Item)>, bool) = - match ((if (choose != 0) { - ((match ({ 5 }, (&mut c as *mut i32)) { - (__tmp_65, __tmp_64) => { - __tmp_64.write(__tmp_65); - __tmp_64 - } - }) as *mut i32) - } else { - ((match ({ 6 }, (&mut d as *mut i32)) { - (__tmp_67, __tmp_66) => { - __tmp_66.write(__tmp_67); - __tmp_66 - } - }) as *mut i32) - } as *mut i32),) - { - (__tmp_63,) => selected.try_emplace(keys[(1) as usize], || { - Item::new_2({ __tmp_63 }, { 2 }) - }), - }; - let mut compound: (UnsafeBidirectionalIterator<(i32, Item)>, bool) = - match ((if (choose != 0) { - ((match ({ 1 }, (&mut e as *mut i32)) { - (__tmp_70, __tmp_69) => { - __tmp_69 - .write((((*__tmp_69) as i32) + (__tmp_70 as i32)) as i32); - __tmp_69 - } - }) as *mut i32) - } else { - ((match ({ 2 }, (&mut f as *mut i32)) { - (__tmp_72, __tmp_71) => { - __tmp_71 - .write((((*__tmp_71) as i32) + (__tmp_72 as i32)) as i32); - __tmp_71 - } - }) as *mut i32) - } as *mut i32),) - { - (__tmp_68,) => selected.try_emplace(keys[(2) as usize], || { - Item::new_2({ __tmp_68 }, { 2 }) - }), - }; - assert!( - ((a) == (if (choose != 0) { - (if (hit != 0) { 1 } else { 3 }) - } else { - 0 - })) && ((b) - == (if (choose != 0) { - 0 - } else { - (if (hit != 0) { 1 } else { 3 }) - })) - ); - assert!( - ((c) == (if (choose != 0) { - (if (hit != 0) { 5 } else { 7 }) - } else { - 0 - })) && ((d) - == (if (choose != 0) { - 0 - } else { - (if (hit != 0) { 6 } else { 8 }) - })) - ); - assert!( - ((e) == (if (choose != 0) { - (if (hit != 0) { 1 } else { 3 }) - } else { - 0 - })) && ((f) - == (if (choose != 0) { - 0 - } else { - (if (hit != 0) { 2 } else { 4 }) - })) - ); - assert!( - ((((prefix.1) as i32) == (!(hit != 0) as i32)) - && (((assignment.1) as i32) == (!(hit != 0) as i32))) - && (((compound.1) as i32) == (!(hit != 0) as i32)) - ); - assert!( - (((*prefix.0.iter_deref()).1.value) == (if (hit != 0) { 42 } else { 3 })) - ); - assert!( - (((*assignment.0.iter_deref()).1.value) - == (if (hit != 0) { - 42 - } else { - if (choose != 0) { 7 } else { 8 } - })) - ); + assert!( + (((((((r0.1) as i32) == (!(hit != 0) as i32)) + && (((r1.1) as i32) == (!(hit != 0) as i32))) + && (((r2.1) as i32) == (!(hit != 0) as i32))) + && (((r3.1) as i32) == (!(hit != 0) as i32))) + && (((r4.1) as i32) == (!(hit != 0) as i32))) + && (((r5.1) as i32) == (!(hit != 0) as i32)) + ); + 'loop_: for k in + IterRange::new(keys.as_ptr(), keys.as_ptr().offset((6_i64) as isize)) + { + let mut k: i32 = (*k); assert!( - (((*compound.0.iter_deref()).1.value) + ((*values.subscript(&k, || 0_i32)) == (if (hit != 0) { 42 } else { - if (choose != 0) { 3 } else { 4 } + if ((k) == (4)) { 5 } else { 1 } })) ); - choose.prefix_inc(); } } - let mut values: UnsafeMap = UnsafeMap::new(); - let keys: [i32; 3] = [0, 1, 2]; - if (hit != 0) { - 'loop_: for k in - IterRange::new(keys.as_ptr(), keys.as_ptr().offset((3_i64) as isize)) + hit.prefix_inc(); + } + } + { + let mut hit: i32 = 0; + 'loop_: while ((hit) < (2)) { + 'for_body: { { - let mut k: i32 = (*k); - (*values.subscript(&k, || 0_i32)) = 42; + let mut choose: i32 = 0; + 'loop_: while ((choose) < (2)) { + 'for_body: { + let mut selected: UnsafeMap = UnsafeMap::new(); + let keys: [i32; 3] = [0, 1, 2]; + if (hit != 0) { + 'loop_: for k in IterRange::new( + keys.as_ptr(), + keys.as_ptr().offset((3_i64) as isize), + ) { + let mut k: i32 = (*k); + (*selected.subscript(&k, || ::default())).value = 42; + } + } + let mut a: i32 = 0; + let mut b: i32 = 0; + let mut c: i32 = 0; + let mut d: i32 = 0; + let mut e: i32 = 0; + let mut f: i32 = 0; + let mut prefix: (UnsafeBidirectionalIterator<(i32, Item)>, bool) = + match ((if (choose != 0) { + ({ + let __tmp_61 = &mut a; + (*__tmp_61).prefix_inc(); + __tmp_61 + } as *mut i32) + } else { + ({ + let __tmp_62 = &mut b; + (*__tmp_62).prefix_inc(); + __tmp_62 + } as *mut i32) + } as *mut i32),) + { + (__tmp_60,) => selected.try_emplace(keys[(0) as usize], || { + Item::new_2({ __tmp_60 }, { 2 }) + }), + }; + let mut assignment: (UnsafeBidirectionalIterator<(i32, Item)>, bool) = + match ((if (choose != 0) { + ((match ({ 5 }, (&mut c as *mut i32)) { + (__tmp_65, __tmp_64) => { + __tmp_64.write(__tmp_65); + __tmp_64 + } + }) as *mut i32) + } else { + ((match ({ 6 }, (&mut d as *mut i32)) { + (__tmp_67, __tmp_66) => { + __tmp_66.write(__tmp_67); + __tmp_66 + } + }) as *mut i32) + } as *mut i32),) + { + (__tmp_63,) => selected.try_emplace(keys[(1) as usize], || { + Item::new_2({ __tmp_63 }, { 2 }) + }), + }; + let mut compound: (UnsafeBidirectionalIterator<(i32, Item)>, bool) = + match ((if (choose != 0) { + ((match ({ 1 }, (&mut e as *mut i32)) { + (__tmp_70, __tmp_69) => { + __tmp_69.write( + (((*__tmp_69) as i32) + (__tmp_70 as i32)) as i32, + ); + __tmp_69 + } + }) as *mut i32) + } else { + ((match ({ 2 }, (&mut f as *mut i32)) { + (__tmp_72, __tmp_71) => { + __tmp_71.write( + (((*__tmp_71) as i32) + (__tmp_72 as i32)) as i32, + ); + __tmp_71 + } + }) as *mut i32) + } as *mut i32),) + { + (__tmp_68,) => selected.try_emplace(keys[(2) as usize], || { + Item::new_2({ __tmp_68 }, { 2 }) + }), + }; + assert!( + ((a) == (if (choose != 0) { + (if (hit != 0) { 1 } else { 3 }) + } else { + 0 + })) && ((b) + == (if (choose != 0) { + 0 + } else { + (if (hit != 0) { 1 } else { 3 }) + })) + ); + assert!( + ((c) == (if (choose != 0) { + (if (hit != 0) { 5 } else { 7 }) + } else { + 0 + })) && ((d) + == (if (choose != 0) { + 0 + } else { + (if (hit != 0) { 6 } else { 8 }) + })) + ); + assert!( + ((e) == (if (choose != 0) { + (if (hit != 0) { 1 } else { 3 }) + } else { + 0 + })) && ((f) + == (if (choose != 0) { + 0 + } else { + (if (hit != 0) { 2 } else { 4 }) + })) + ); + assert!( + ((((prefix.1) as i32) == (!(hit != 0) as i32)) + && (((assignment.1) as i32) == (!(hit != 0) as i32))) + && (((compound.1) as i32) == (!(hit != 0) as i32)) + ); + assert!( + (((*prefix.0.iter_deref()).1.value) + == (if (hit != 0) { 42 } else { 3 })) + ); + assert!( + (((*assignment.0.iter_deref()).1.value) + == (if (hit != 0) { + 42 + } else { + if (choose != 0) { 7 } else { 8 } + })) + ); + assert!( + (((*compound.0.iter_deref()).1.value) + == (if (hit != 0) { + 42 + } else { + if (choose != 0) { 3 } else { 4 } + })) + ); + } + choose.prefix_inc(); + } } - } - let mut before: i32 = - (*std::cell::LazyCell::force_mut(&mut *&raw mut temporary_calls_4)); - let mut index: i32 = 0; - let mut member: (UnsafeBidirectionalIterator<(i32, i32)>, bool) = { - let mut __tmp_74: Temporary; - match ((&mut (*{ - __tmp_74 = (unsafe { make_temporary_5() }); - &mut __tmp_74 - }) - .n as *mut i32),) - { - (__tmp_73,) => values.try_emplace(keys[(0) as usize], || (*__tmp_73)), + let mut values: UnsafeMap = UnsafeMap::new(); + let keys: [i32; 3] = [0, 1, 2]; + if (hit != 0) { + 'loop_: for k in + IterRange::new(keys.as_ptr(), keys.as_ptr().offset((3_i64) as isize)) + { + let mut k: i32 = (*k); + (*values.subscript(&k, || 0_i32)) = 42; + } } - }; - let mut nested: (UnsafeBidirectionalIterator<(i32, i32)>, bool) = { - let mut __tmp_76: Nested; - match ((&mut (*&mut (*{ - __tmp_76 = (unsafe { make_nested_6() }); - &mut __tmp_76 - }) - .inner) + let mut before: i32 = + (*std::cell::LazyCell::force_mut(&mut *&raw mut temporary_calls_4)); + let mut index: i32 = 0; + let mut member: (UnsafeBidirectionalIterator<(i32, i32)>, bool) = { + let mut __tmp_74: Temporary; + match ((&mut (*{ + __tmp_74 = (unsafe { make_temporary_5() }); + &mut __tmp_74 + }) .n as *mut i32),) - { - (__tmp_75,) => values.try_emplace(keys[(1) as usize], || (*__tmp_75)), - } - }; - let mut element: (UnsafeBidirectionalIterator<(i32, i32)>, bool) = { - let mut __tmp_78: Temporary; - match ((&mut (*{ - __tmp_78 = (unsafe { make_temporary_5() }); - &mut __tmp_78 - }) - .data[(index.postfix_inc()) as usize] as *mut i32),) - { - (__tmp_77,) => values.try_emplace(keys[(2) as usize], || (*__tmp_77)), - } - }; - assert!( - ((*std::cell::LazyCell::force_mut(&mut *&raw mut temporary_calls_4)) - == ((before) + (3))) - && ((index) == (1)) - ); - assert!( - ((((member.1) as i32) == (!(hit != 0) as i32)) - && (((nested.1) as i32) == (!(hit != 0) as i32))) - && (((element.1) as i32) == (!(hit != 0) as i32)) - ); - assert!( - ((((*member.0.iter_deref()).1) == (if (hit != 0) { 42 } else { 5 })) - && (((*nested.0.iter_deref()).1) == (if (hit != 0) { 42 } else { 5 }))) - && (((*element.0.iter_deref()).1) == (if (hit != 0) { 42 } else { 6 })) - ); - { - let mut choose: i32 = 0; - 'loop_: while ((choose) < (2)) { - let mut references: UnsafeMap = UnsafeMap::new(); - let mut ordinary: i32 = 9; - if (hit != 0) { - references.try_emplace(key, || Held::new_1({ &ordinary })); + { + (__tmp_73,) => values.try_emplace(keys[(0) as usize], || (*__tmp_73)), } - before = (*std::cell::LazyCell::force_mut(&mut *&raw mut temporary_calls_4)); - index = 0; - let mut value: i32 = 0; + }; + let mut nested: (UnsafeBidirectionalIterator<(i32, i32)>, bool) = { + let mut __tmp_76: Nested; + match ((&mut (*&mut (*{ + __tmp_76 = (unsafe { make_nested_6() }); + &mut __tmp_76 + }) + .inner) + .n as *mut i32),) { - let mut __tmp_80: Nested; - let mut __tmp_81: Temporary; - { - match ((if (choose != 0) { - (&mut (*&mut (*{ - __tmp_80 = (unsafe { make_nested_6() }); - &mut __tmp_80 - }) - .inner) - .n as *mut i32) - } else { - (&mut (*{ - __tmp_81 = (unsafe { make_temporary_5() }); - &mut __tmp_81 - }) - .data[(index.postfix_inc()) as usize] - as *mut i32) - } as *mut i32),) + (__tmp_75,) => values.try_emplace(keys[(1) as usize], || (*__tmp_75)), + } + }; + let mut element: (UnsafeBidirectionalIterator<(i32, i32)>, bool) = { + let mut __tmp_78: Temporary; + match ((&mut (*{ + __tmp_78 = (unsafe { make_temporary_5() }); + &mut __tmp_78 + }) + .data[(index.postfix_inc()) as usize] as *mut i32),) + { + (__tmp_77,) => values.try_emplace(keys[(2) as usize], || (*__tmp_77)), + } + }; + assert!( + ((*std::cell::LazyCell::force_mut(&mut *&raw mut temporary_calls_4)) + == ((before) + (3))) + && ((index) == (1)) + ); + assert!( + ((((member.1) as i32) == (!(hit != 0) as i32)) + && (((nested.1) as i32) == (!(hit != 0) as i32))) + && (((element.1) as i32) == (!(hit != 0) as i32)) + ); + assert!( + ((((*member.0.iter_deref()).1) == (if (hit != 0) { 42 } else { 5 })) + && (((*nested.0.iter_deref()).1) == (if (hit != 0) { 42 } else { 5 }))) + && (((*element.0.iter_deref()).1) == (if (hit != 0) { 42 } else { 6 })) + ); + { + let mut choose: i32 = 0; + 'loop_: while ((choose) < (2)) { + 'for_body: { + let mut references: UnsafeMap = UnsafeMap::new(); + let mut ordinary: i32 = 9; + if (hit != 0) { + references.try_emplace(key, || Held::new_1({ &ordinary })); + } + before = + (*std::cell::LazyCell::force_mut(&mut *&raw mut temporary_calls_4)); + index = 0; + let mut value: i32 = 0; { - (__tmp_79,) => { - references.try_emplace(key, || Held::new_1({ __tmp_79 })) + let mut __tmp_80: Nested; + let mut __tmp_81: Temporary; + { + match ((if (choose != 0) { + (&mut (*&mut (*{ + __tmp_80 = (unsafe { make_nested_6() }); + &mut __tmp_80 + }) + .inner) + .n as *mut i32) + } else { + (&mut (*{ + __tmp_81 = (unsafe { make_temporary_5() }); + &mut __tmp_81 + }) + .data + [(index.postfix_inc()) as usize] + as *mut i32) + } as *mut i32),) + { + (__tmp_79,) => references + .try_emplace(key, || Held::new_1({ __tmp_79 })), + }; + value = + (*(*references.subscript(&key, || ::default())).ptr) } }; - value = (*(*references.subscript(&key, || ::default())).ptr) - } - }; - assert!( - ((*std::cell::LazyCell::force_mut(&mut *&raw mut temporary_calls_4)) - == ((before) + (1))) - && ((index) == (if (choose != 0) { 0 } else { 1 })) - ); - assert!( - ((value) - == (if (hit != 0) { - 9 - } else { - if (choose != 0) { 5 } else { 6 } - })) - ); - let mut arrays: UnsafeMap = UnsafeMap::new(); - let ordinary_array: [i32; 2] = [9, 10]; - if (hit != 0) { - arrays.try_emplace(key, || Held::new_3({ &ordinary_array }, { 0 })); - } - before = (*std::cell::LazyCell::force_mut(&mut *&raw mut temporary_calls_4)); - { - let mut __tmp_83: Nested; - let mut __tmp_84: Temporary; - { - match ((if (choose != 0) { - (&mut (*&mut (*{ - __tmp_83 = (unsafe { make_nested_6() }); - &mut __tmp_83 - }) - .inner) - .data as *mut [i32; 2]) - } else { - (&mut (*{ - __tmp_84 = (unsafe { make_temporary_5() }); - &mut __tmp_84 - }) - .data as *mut [i32; 2]) - } as *mut [i32; 2]),) + assert!( + ((*std::cell::LazyCell::force_mut( + &mut *&raw mut temporary_calls_4 + )) == ((before) + (1))) + && ((index) == (if (choose != 0) { 0 } else { 1 })) + ); + assert!( + ((value) + == (if (hit != 0) { + 9 + } else { + if (choose != 0) { 5 } else { 6 } + })) + ); + let mut arrays: UnsafeMap = UnsafeMap::new(); + let ordinary_array: [i32; 2] = [9, 10]; + if (hit != 0) { + arrays.try_emplace(key, || Held::new_3({ &ordinary_array }, { 0 })); + } + before = + (*std::cell::LazyCell::force_mut(&mut *&raw mut temporary_calls_4)); { - (__tmp_82,) => { - arrays.try_emplace(key, || Held::new_3({ __tmp_82 }, { 0 })) + let mut __tmp_83: Nested; + let mut __tmp_84: Temporary; + { + match ((if (choose != 0) { + (&mut (*&mut (*{ + __tmp_83 = (unsafe { make_nested_6() }); + &mut __tmp_83 + }) + .inner) + .data + as *mut [i32; 2]) + } else { + (&mut (*{ + __tmp_84 = (unsafe { make_temporary_5() }); + &mut __tmp_84 + }) + .data + as *mut [i32; 2]) + } as *mut [i32; 2]),) + { + (__tmp_82,) => arrays + .try_emplace(key, || Held::new_3({ __tmp_82 }, { 0 })), + }; + value = (*(*arrays.subscript(&key, || ::default())) + .ptr + .offset((1) as isize)) } }; - value = (*(*arrays.subscript(&key, || ::default())) - .ptr - .offset((1) as isize)) + assert!( + ((*std::cell::LazyCell::force_mut( + &mut *&raw mut temporary_calls_4 + )) == ((before) + (1))) + && ((value) == (if (hit != 0) { 10 } else { 7 })) + ); } - }; - assert!( - ((*std::cell::LazyCell::force_mut(&mut *&raw mut temporary_calls_4)) - == ((before) + (1))) - && ((value) == (if (hit != 0) { 10 } else { 7 })) - ); - choose.prefix_inc(); + choose.prefix_inc(); + } } } hit.prefix_inc(); @@ -907,216 +927,225 @@ unsafe fn main_0() -> i32 { { let mut hit: i32 = 0; 'loop_: while ((hit) < (2)) { - let mut values: UnsafeMap = UnsafeMap::new(); - let keys: [i32; 6] = [0, 1, 2, 3, 4, 5]; - if (hit != 0) { - 'loop_: for k in - IterRange::new(keys.as_ptr(), keys.as_ptr().offset((6_i64) as isize)) - { - let mut k: i32 = (*k); - (*values.subscript(&k, || 0_i32)) = 42; - } - } - let mut before: i32 = - (*std::cell::LazyCell::force_mut(&mut *&raw mut temporary_calls_4)); - let mut index: i32 = 0; - let mut arrow: (UnsafeBidirectionalIterator<(i32, i32)>, bool) = { - let mut __tmp_86: Option>; - match ((&mut (*(*{ - __tmp_86 = Some(Box::new(Temporary::new())); - &mut __tmp_86 - }) - .as_deref() - .map_or(::std::ptr::null_mut(), |v| { - v as *const Temporary as *mut Temporary - })) - .n as *mut i32),) - { - (__tmp_85,) => values.try_emplace(keys[(0) as usize], || (*__tmp_85)), + 'for_body: { + let mut values: UnsafeMap = UnsafeMap::new(); + let keys: [i32; 6] = [0, 1, 2, 3, 4, 5]; + if (hit != 0) { + 'loop_: for k in + IterRange::new(keys.as_ptr(), keys.as_ptr().offset((6_i64) as isize)) + { + let mut k: i32 = (*k); + (*values.subscript(&k, || 0_i32)) = 42; + } } - }; - let mut nested: (UnsafeBidirectionalIterator<(i32, i32)>, bool) = { - let mut __tmp_88: Option>; - match ((&mut (*&mut (*(*{ - __tmp_88 = Some(Box::new(::default())); - &mut __tmp_88 - }) - .as_deref() - .map_or(::std::ptr::null_mut(), |v| { - v as *const Nested as *mut Nested - })) - .inner) + let mut before: i32 = + (*std::cell::LazyCell::force_mut(&mut *&raw mut temporary_calls_4)); + let mut index: i32 = 0; + let mut arrow: (UnsafeBidirectionalIterator<(i32, i32)>, bool) = { + let mut __tmp_86: Option>; + match ((&mut (*(*{ + __tmp_86 = Some(Box::new(Temporary::new())); + &mut __tmp_86 + }) + .as_deref() + .map_or(::std::ptr::null_mut(), |v| { + v as *const Temporary as *mut Temporary + })) .n as *mut i32),) - { - (__tmp_87,) => values.try_emplace(keys[(1) as usize], || (*__tmp_87)), - } - }; - let mut element: (UnsafeBidirectionalIterator<(i32, i32)>, bool) = { - let mut __tmp_90: Option>; - match ((&mut (*(*{ - __tmp_90 = Some(Box::new(Temporary::new())); - &mut __tmp_90 - }) - .as_deref() - .map_or(::std::ptr::null_mut(), |v| { - v as *const Temporary as *mut Temporary - })) - .data[(index.postfix_inc()) as usize] as *mut i32),) - { - (__tmp_89,) => values.try_emplace(keys[(2) as usize], || (*__tmp_89)), - } - }; - let mut get: (UnsafeBidirectionalIterator<(i32, i32)>, bool) = { - let mut __tmp_92: Option>; - match ((&mut (*(*{ - __tmp_92 = Some(Box::new(Temporary::new())); - &mut __tmp_92 - }) - .as_deref_mut() - .map_or(::std::ptr::null_mut(), |v| v as *mut Temporary)) - .n as *mut i32),) - { - (__tmp_91,) => values.try_emplace(keys[(3) as usize], || (*__tmp_91)), - } - }; - let mut deref: (UnsafeBidirectionalIterator<(i32, i32)>, bool) = { - let mut __tmp_94: Option>; - match ((&mut (*((*{ - __tmp_94 = Some(Box::new(Temporary::new())); - &mut __tmp_94 - }) - .as_deref() - .map_or(::std::ptr::null_mut(), |v| { - v as *const Temporary as *mut Temporary - }))) - .n as *mut i32),) - { - (__tmp_93,) => values.try_emplace(keys[(4) as usize], || (*__tmp_93)), - } - }; - let mut indirect: (UnsafeBidirectionalIterator<(i32, i32)>, bool) = { - let mut __tmp_96: Option>>>; - match ((&mut (*((*(*{ - __tmp_96 = Some(Box::new(Some(Box::new(Temporary::new())))); - &mut __tmp_96 - }) - .as_deref() - .map_or(::std::ptr::null_mut(), |v| { - v as *const Option> as *mut Option> - })) - .as_deref() - .map_or(::std::ptr::null_mut(), |v| { - v as *const Temporary as *mut Temporary - }))) - .n as *mut i32),) - { - (__tmp_95,) => values.try_emplace(keys[(5) as usize], || (*__tmp_95)), - } - }; - assert!( - ((*std::cell::LazyCell::force_mut(&mut *&raw mut temporary_calls_4)) - == ((before) + (6))) - && ((index) == (1)) - ); - assert!( - (((((((arrow.1) as i32) == (!(hit != 0) as i32)) - && (((nested.1) as i32) == (!(hit != 0) as i32))) - && (((element.1) as i32) == (!(hit != 0) as i32))) - && (((get.1) as i32) == (!(hit != 0) as i32))) - && (((deref.1) as i32) == (!(hit != 0) as i32))) - && (((indirect.1) as i32) == (!(hit != 0) as i32)) - ); - 'loop_: for k in IterRange::new(keys.as_ptr(), keys.as_ptr().offset((6_i64) as isize)) { - let mut k: i32 = (*k); - assert!( - ((*values.subscript(&k, || 0_i32)) - == (if (hit != 0) { - 42 - } else { - if ((k) == (2)) { 6 } else { 5 } - })) - ); - } - { - let mut choose: i32 = 0; - 'loop_: while ((choose) < (2)) { - let mut references: UnsafeMap = UnsafeMap::new(); - let mut ordinary: i32 = 9; - if (hit != 0) { - references.try_emplace(key, || Held::new_1({ &ordinary })); + { + (__tmp_85,) => values.try_emplace(keys[(0) as usize], || (*__tmp_85)), } - before = (*std::cell::LazyCell::force_mut(&mut *&raw mut temporary_calls_4)); - index = 0; - let mut value: i32 = 0; + }; + let mut nested: (UnsafeBidirectionalIterator<(i32, i32)>, bool) = { + let mut __tmp_88: Option>; + match ((&mut (*&mut (*(*{ + __tmp_88 = Some(Box::new(::default())); + &mut __tmp_88 + }) + .as_deref() + .map_or(::std::ptr::null_mut(), |v| { + v as *const Nested as *mut Nested + })) + .inner) + .n as *mut i32),) { - let mut __tmp_98: Option>; - let mut __tmp_99: Option>; - { - match ((if (choose != 0) { - (&mut (*(*{ - __tmp_98 = Some(Box::new(Temporary::new())); - &mut __tmp_98 - }) - .as_deref() - .map_or(::std::ptr::null_mut(), |v| { - v as *const Temporary as *mut Temporary - })) - .n as *mut i32) - } else { - (&mut (*(*{ - __tmp_99 = Some(Box::new(Temporary::new())); - &mut __tmp_99 - }) - .as_deref() - .map_or(::std::ptr::null_mut(), |v| { - v as *const Temporary as *mut Temporary - })) - .data[(index.postfix_inc()) as usize] - as *mut i32) - } as *mut i32),) - { - (__tmp_97,) => { - references.try_emplace(key, || Held::new_1({ __tmp_97 })) - } - }; - value = (*(*references.subscript(&key, || ::default())).ptr) - } - }; - assert!( - ((*std::cell::LazyCell::force_mut(&mut *&raw mut temporary_calls_4)) - == ((before) + (1))) - && ((index) == (if (choose != 0) { 0 } else { 1 })) - ); + (__tmp_87,) => values.try_emplace(keys[(1) as usize], || (*__tmp_87)), + } + }; + let mut element: (UnsafeBidirectionalIterator<(i32, i32)>, bool) = { + let mut __tmp_90: Option>; + match ((&mut (*(*{ + __tmp_90 = Some(Box::new(Temporary::new())); + &mut __tmp_90 + }) + .as_deref() + .map_or(::std::ptr::null_mut(), |v| { + v as *const Temporary as *mut Temporary + })) + .data[(index.postfix_inc()) as usize] as *mut i32),) + { + (__tmp_89,) => values.try_emplace(keys[(2) as usize], || (*__tmp_89)), + } + }; + let mut get: (UnsafeBidirectionalIterator<(i32, i32)>, bool) = { + let mut __tmp_92: Option>; + match ((&mut (*(*{ + __tmp_92 = Some(Box::new(Temporary::new())); + &mut __tmp_92 + }) + .as_deref_mut() + .map_or(::std::ptr::null_mut(), |v| v as *mut Temporary)) + .n as *mut i32),) + { + (__tmp_91,) => values.try_emplace(keys[(3) as usize], || (*__tmp_91)), + } + }; + let mut deref: (UnsafeBidirectionalIterator<(i32, i32)>, bool) = { + let mut __tmp_94: Option>; + match ((&mut (*((*{ + __tmp_94 = Some(Box::new(Temporary::new())); + &mut __tmp_94 + }) + .as_deref() + .map_or(::std::ptr::null_mut(), |v| { + v as *const Temporary as *mut Temporary + }))) + .n as *mut i32),) + { + (__tmp_93,) => values.try_emplace(keys[(4) as usize], || (*__tmp_93)), + } + }; + let mut indirect: (UnsafeBidirectionalIterator<(i32, i32)>, bool) = { + let mut __tmp_96: Option>>>; + match ((&mut (*((*(*{ + __tmp_96 = Some(Box::new(Some(Box::new(Temporary::new())))); + &mut __tmp_96 + }) + .as_deref() + .map_or(::std::ptr::null_mut(), |v| { + v as *const Option> as *mut Option> + })) + .as_deref() + .map_or(::std::ptr::null_mut(), |v| { + v as *const Temporary as *mut Temporary + }))) + .n as *mut i32),) + { + (__tmp_95,) => values.try_emplace(keys[(5) as usize], || (*__tmp_95)), + } + }; + assert!( + ((*std::cell::LazyCell::force_mut(&mut *&raw mut temporary_calls_4)) + == ((before) + (6))) + && ((index) == (1)) + ); + assert!( + (((((((arrow.1) as i32) == (!(hit != 0) as i32)) + && (((nested.1) as i32) == (!(hit != 0) as i32))) + && (((element.1) as i32) == (!(hit != 0) as i32))) + && (((get.1) as i32) == (!(hit != 0) as i32))) + && (((deref.1) as i32) == (!(hit != 0) as i32))) + && (((indirect.1) as i32) == (!(hit != 0) as i32)) + ); + 'loop_: for k in + IterRange::new(keys.as_ptr(), keys.as_ptr().offset((6_i64) as isize)) + { + let mut k: i32 = (*k); assert!( - ((value) + ((*values.subscript(&k, || 0_i32)) == (if (hit != 0) { - 9 + 42 } else { - if (choose != 0) { 5 } else { 6 } + if ((k) == (2)) { 6 } else { 5 } })) ); - let mut owners: UnsafeMap = UnsafeMap::new(); - { - let mut __tmp_101: Owner; - { - match (((unsafe { - Owner::value( - &mut (*{ - __tmp_101 = Owner::new(); - &mut __tmp_101 - }), - ) - }) as *const i32),) + } + { + let mut choose: i32 = 0; + 'loop_: while ((choose) < (2)) { + 'for_body: { + let mut references: UnsafeMap = UnsafeMap::new(); + let mut ordinary: i32 = 9; + if (hit != 0) { + references.try_emplace(key, || Held::new_1({ &ordinary })); + } + before = + (*std::cell::LazyCell::force_mut(&mut *&raw mut temporary_calls_4)); + index = 0; + let mut value: i32 = 0; { - (__tmp_100,) => { - owners.try_emplace(key, || Held::new_1({ __tmp_100 })) + let mut __tmp_98: Option>; + let mut __tmp_99: Option>; + { + match ((if (choose != 0) { + (&mut (*(*{ + __tmp_98 = Some(Box::new(Temporary::new())); + &mut __tmp_98 + }) + .as_deref() + .map_or(::std::ptr::null_mut(), |v| { + v as *const Temporary as *mut Temporary + })) + .n as *mut i32) + } else { + (&mut (*(*{ + __tmp_99 = Some(Box::new(Temporary::new())); + &mut __tmp_99 + }) + .as_deref() + .map_or(::std::ptr::null_mut(), |v| { + v as *const Temporary as *mut Temporary + })) + .data + [(index.postfix_inc()) as usize] + as *mut i32) + } as *mut i32),) + { + (__tmp_97,) => references + .try_emplace(key, || Held::new_1({ __tmp_97 })), + }; + value = + (*(*references.subscript(&key, || ::default())).ptr) } }; - value = (*(*owners.subscript(&key, || ::default())).ptr) + assert!( + ((*std::cell::LazyCell::force_mut( + &mut *&raw mut temporary_calls_4 + )) == ((before) + (1))) + && ((index) == (if (choose != 0) { 0 } else { 1 })) + ); + assert!( + ((value) + == (if (hit != 0) { + 9 + } else { + if (choose != 0) { 5 } else { 6 } + })) + ); + let mut owners: UnsafeMap = UnsafeMap::new(); + { + let mut __tmp_101: Owner; + { + match (((unsafe { + Owner::value( + &mut (*{ + __tmp_101 = Owner::new(); + &mut __tmp_101 + }), + ) + }) as *const i32),) + { + (__tmp_100,) => { + owners.try_emplace(key, || Held::new_1({ __tmp_100 })) + } + }; + value = (*(*owners.subscript(&key, || ::default())).ptr) + } + }; + assert!(((value) == (5))); } - }; - assert!(((value) == (5))); - choose.prefix_inc(); + choose.prefix_inc(); + } } } hit.prefix_inc(); diff --git a/tests/unit/out/unsafe/matmul.rs b/tests/unit/out/unsafe/matmul.rs index 923eb8ef7e..5affe70288 100644 --- a/tests/unit/out/unsafe/matmul.rs +++ b/tests/unit/out/unsafe/matmul.rs @@ -12,32 +12,36 @@ pub unsafe fn matalloc_0(mut n: i32, mut p: i32, mut e: i32) -> Option> - }) - .add((i as usize)) as *mut Option>), - (&mut Some((0..(p as usize)).map(|_| 0_i32).collect::>()) - as *mut Option>), - ) { - (__tmp_0, __tmp_1) => { - (*__tmp_0) = (*__tmp_1).take(); - } - }; - { - let mut j: i32 = 0; - 'loop_: while ((j) < (p)) { - (*(*m - .as_deref() + 'for_body: { + match ( + (m.as_deref() .map_or(::std::ptr::null_mut(), |s| { s.as_ptr() as *mut Option> }) - .add((i as usize))) - .as_deref() - .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut i32) - .add((j as usize))) = e; - j.prefix_inc(); + .add((i as usize)) as *mut Option>), + (&mut Some((0..(p as usize)).map(|_| 0_i32).collect::>()) + as *mut Option>), + ) { + (__tmp_0, __tmp_1) => { + (*__tmp_0) = (*__tmp_1).take(); + } + }; + { + let mut j: i32 = 0; + 'loop_: while ((j) < (p)) { + 'for_body: { + (*(*m + .as_deref() + .map_or(::std::ptr::null_mut(), |s| { + s.as_ptr() as *mut Option> + }) + .add((i as usize))) + .as_deref() + .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut i32) + .add((j as usize))) = e; + } + j.prefix_inc(); + } } } i.prefix_inc(); @@ -57,14 +61,41 @@ pub unsafe fn matmul_1( { let mut i: i32 = 0; 'loop_: while ((i) < (n1)) { - { - let mut j: i32 = 0; - let mut sum: i32 = 0; - 'loop_: while ((j) < (p2)) { - { - let mut k: i32 = 0; - 'loop_: while ((k) < (p1)) { - sum += ((*(*m1 + 'for_body: { + { + let mut j: i32 = 0; + let mut sum: i32 = 0; + 'loop_: while ((j) < (p2)) { + 'for_body: { + { + let mut k: i32 = 0; + 'loop_: while ((k) < (p1)) { + 'for_body: { + sum += ((*(*m1 + .as_deref() + .map_or(::std::ptr::null_mut(), |s| { + s.as_ptr() as *mut Option> + }) + .add((i as usize))) + .as_deref() + .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut i32) + .add((k as usize))) + * (*(*m2 + .as_deref() + .map_or(::std::ptr::null_mut(), |s| { + s.as_ptr() as *mut Option> + }) + .add((k as usize))) + .as_deref() + .map_or(::std::ptr::null_mut(), |s| { + s.as_ptr() as *mut i32 + }) + .add((j as usize)))); + } + k.prefix_inc(); + } + } + (*(*m3 .as_deref() .map_or(::std::ptr::null_mut(), |s| { s.as_ptr() as *mut Option> @@ -72,29 +103,10 @@ pub unsafe fn matmul_1( .add((i as usize))) .as_deref() .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut i32) - .add((k as usize))) - * (*(*m2 - .as_deref() - .map_or(::std::ptr::null_mut(), |s| { - s.as_ptr() as *mut Option> - }) - .add((k as usize))) - .as_deref() - .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut i32) - .add((j as usize)))); - k.prefix_inc(); + .add((j as usize))) = sum; } + j.prefix_inc(); } - (*(*m3 - .as_deref() - .map_or(::std::ptr::null_mut(), |s| { - s.as_ptr() as *mut Option> - }) - .add((i as usize))) - .as_deref() - .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut i32) - .add((j as usize))) = sum; - j.prefix_inc(); } } i.prefix_inc(); diff --git a/tests/unit/out/unsafe/max.rs b/tests/unit/out/unsafe/max.rs index 20cd3b23a1..58f367d4ef 100644 --- a/tests/unit/out/unsafe/max.rs +++ b/tests/unit/out/unsafe/max.rs @@ -186,16 +186,18 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (3)) { - largest = (({ - let mut __tmp_9: u64 = (largest as u64); - (*match ((&mut ((unsafe { size_of_2(i) }) as u64) as *const u64),) { - (__tmp_8,) => { - let __a: *const _ = &mut __tmp_9; - let __b: *const _ = __tmp_8; - if *__a < *__b { __b } else { __a } - } - }) - }) as usize); + 'for_body: { + largest = (({ + let mut __tmp_9: u64 = (largest as u64); + (*match ((&mut ((unsafe { size_of_2(i) }) as u64) as *const u64),) { + (__tmp_8,) => { + let __a: *const _ = &mut __tmp_9; + let __b: *const _ = __tmp_8; + if *__a < *__b { __b } else { __a } + } + }) + }) as usize); + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/memset.rs b/tests/unit/out/unsafe/memset.rs index 4d47753189..d5f8fe1e9d 100644 --- a/tests/unit/out/unsafe/memset.rs +++ b/tests/unit/out/unsafe/memset.rs @@ -28,7 +28,9 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (N)) { - sum += (*arr.offset((i) as isize)); + 'for_body: { + sum += (*arr.offset((i) as isize)); + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/nested_block_scope.rs b/tests/unit/out/unsafe/nested_block_scope.rs index 08c66d6646..59948b68eb 100644 --- a/tests/unit/out/unsafe/nested_block_scope.rs +++ b/tests/unit/out/unsafe/nested_block_scope.rs @@ -28,12 +28,14 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (3)) { - let mut y: i32 = i; - { - let mut y: i32 = 10; + 'for_body: { + let mut y: i32 = i; + { + let mut y: i32 = 10; + sum += y; + } sum += y; } - sum += y; i.postfix_inc(); } } diff --git a/tests/unit/out/unsafe/new_alloc_array.rs b/tests/unit/out/unsafe/new_alloc_array.rs index c7477750eb..cecf376704 100644 --- a/tests/unit/out/unsafe/new_alloc_array.rs +++ b/tests/unit/out/unsafe/new_alloc_array.rs @@ -27,7 +27,9 @@ unsafe fn main_0() -> i32 { { let mut p1: *mut i32 = array; 'loop_: while ((*p1) >= (0)) { - (*p1) = 1; + 'for_body: { + (*p1) = 1; + } p1.prefix_inc(); } } @@ -35,7 +37,9 @@ unsafe fn main_0() -> i32 { { let mut p1: *mut i32 = array; 'loop_: while ((*p1) >= (0)) { - out += (*p1); + 'for_body: { + out += (*p1); + } p1.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/new_array.rs b/tests/unit/out/unsafe/new_array.rs index 768a1a1ad9..b73e6d615b 100644 --- a/tests/unit/out/unsafe/new_array.rs +++ b/tests/unit/out/unsafe/new_array.rs @@ -11,7 +11,9 @@ pub unsafe fn sum_0(mut p: *mut i32, mut n: i32) -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (n)) { - total += (*p.offset((i) as isize)); + 'for_body: { + total += (*p.offset((i) as isize)); + } i.prefix_inc(); } } @@ -41,7 +43,9 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (4)) { - (*filled.offset((i) as isize)) = ((i) + (1)); + 'for_body: { + (*filled.offset((i) as isize)) = ((i) + (1)); + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/null_in_statics.rs b/tests/unit/out/unsafe/null_in_statics.rs index 76e727b2f6..89790a7ae4 100644 --- a/tests/unit/out/unsafe/null_in_statics.rs +++ b/tests/unit/out/unsafe/null_in_statics.rs @@ -35,10 +35,12 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (4)) { - assert!( - ((*std::cell::LazyCell::force_mut(&mut *&raw mut arr_of_ptr_3))[(i) as usize]) - .is_null() - ); + 'for_body: { + assert!( + ((*std::cell::LazyCell::force_mut(&mut *&raw mut arr_of_ptr_3))[(i) as usize]) + .is_null() + ); + } i.prefix_inc(); } } @@ -46,11 +48,13 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (3)) { - assert!( - ((*std::cell::LazyCell::force_mut(&mut *&raw mut const_arr_of_ptr_5)) - [(i) as usize]) - .is_null() - ); + 'for_body: { + assert!( + ((*std::cell::LazyCell::force_mut(&mut *&raw mut const_arr_of_ptr_5)) + [(i) as usize]) + .is_null() + ); + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/pointer_array.rs b/tests/unit/out/unsafe/pointer_array.rs index 995cf4e932..a9de2aa742 100644 --- a/tests/unit/out/unsafe/pointer_array.rs +++ b/tests/unit/out/unsafe/pointer_array.rs @@ -15,7 +15,9 @@ pub unsafe fn IncrementAll_0(s: *mut StackArray) { { let mut i: i32 = 0; 'loop_: while ((i) < (3)) { - (*(*s).arr[(i) as usize]) += 1; + 'for_body: { + (*(*s).arr[(i) as usize]) += 1; + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/pointer_call_offset.rs b/tests/unit/out/unsafe/pointer_call_offset.rs index ce7c588923..4cb62ec6f0 100644 --- a/tests/unit/out/unsafe/pointer_call_offset.rs +++ b/tests/unit/out/unsafe/pointer_call_offset.rs @@ -21,7 +21,9 @@ unsafe fn main_0() -> i32 { { let mut i: u32 = 0_u32; 'loop_: while ((i) < (10_u32)) { - (*p1.offset((i) as isize)) = (i as i32); + 'for_body: { + (*p1.offset((i) as isize)) = (i as i32); + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/pointer_offset.rs b/tests/unit/out/unsafe/pointer_offset.rs index 7916338db8..81b4f9edf5 100644 --- a/tests/unit/out/unsafe/pointer_offset.rs +++ b/tests/unit/out/unsafe/pointer_offset.rs @@ -18,35 +18,45 @@ unsafe fn main_0() -> i32 { { let mut ptr: *const i32 = (&mut arr[(0) as usize] as *mut i32).cast_const(); 'loop_: while ((*ptr) != (0)) { - out += (*ptr); + 'for_body: { + out += (*ptr); + } ptr.prefix_inc(); } } { let mut ptr: *mut i32 = (&mut arr[(1) as usize] as *mut i32); 'loop_: while ((*ptr) != (4)) { - out += (*ptr); + 'for_body: { + out += (*ptr); + } ptr.postfix_inc(); } } { let mut ptr: *mut i32 = (&mut arr[(4) as usize] as *mut i32); 'loop_: while ((*ptr) != (1)) { - out += (*ptr); + 'for_body: { + out += (*ptr); + } ptr.postfix_dec(); } } { let mut ptr: *const i32 = (&mut arr[(3) as usize] as *mut i32).cast_const(); 'loop_: while ((*ptr) != (2)) { - out += (*ptr); + 'for_body: { + out += (*ptr); + } ptr.prefix_dec(); } } { let mut ptr: *mut i32 = (&mut arr[(0) as usize] as *mut i32); 'loop_: while ((*ptr) != (0)) { - out += (*ptr); + 'for_body: { + out += (*ptr); + } ptr = ptr.offset((1) as isize); } } @@ -54,7 +64,9 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (5)) { - out += (*ptr.offset((i) as isize)); + 'for_body: { + out += (*ptr.offset((i) as isize)); + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/pointer_usize_arith.rs b/tests/unit/out/unsafe/pointer_usize_arith.rs index 60808f72bd..72ea94632f 100644 --- a/tests/unit/out/unsafe/pointer_usize_arith.rs +++ b/tests/unit/out/unsafe/pointer_usize_arith.rs @@ -57,7 +57,9 @@ unsafe fn main_0() -> i32 { { let mut it: *mut i32 = p; 'loop_: while ((it) != (end)) { - sum += (*it); + 'for_body: { + sum += (*it); + } it.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/qsort_bsearch.rs b/tests/unit/out/unsafe/qsort_bsearch.rs index de375c13d4..49e600c3d1 100644 --- a/tests/unit/out/unsafe/qsort_bsearch.rs +++ b/tests/unit/out/unsafe/qsort_bsearch.rs @@ -34,7 +34,9 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (7)) { - assert!(((arr[(i) as usize]) <= (arr[((i) + (1)) as usize]))); + 'for_body: { + assert!(((arr[(i) as usize]) <= (arr[((i) + (1)) as usize]))); + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/reinterpret_cast_iterate.rs b/tests/unit/out/unsafe/reinterpret_cast_iterate.rs index a1d39f903f..3604d586b6 100644 --- a/tests/unit/out/unsafe/reinterpret_cast_iterate.rs +++ b/tests/unit/out/unsafe/reinterpret_cast_iterate.rs @@ -18,7 +18,9 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (8)) { - assert!((((*words.offset((i) as isize)) as i32) == ((((i) + (1)) as u16) as i32))); + 'for_body: { + assert!((((*words.offset((i) as isize)) as i32) == ((((i) + (1)) as u16) as i32))); + } i.postfix_inc(); } } diff --git a/tests/unit/out/unsafe/reinterpret_cast_large_array.rs b/tests/unit/out/unsafe/reinterpret_cast_large_array.rs index 9be075cfa9..3224ccbbaa 100644 --- a/tests/unit/out/unsafe/reinterpret_cast_large_array.rs +++ b/tests/unit/out/unsafe/reinterpret_cast_large_array.rs @@ -19,7 +19,9 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (N)) { - (*arr.offset((i) as isize)) = 0_u32; + 'for_body: { + (*arr.offset((i) as isize)) = 0_u32; + } i.postfix_inc(); } } diff --git a/tests/unit/out/unsafe/rule_of_five.rs b/tests/unit/out/unsafe/rule_of_five.rs index 377b182a30..296f86ad4a 100644 --- a/tests/unit/out/unsafe/rule_of_five.rs +++ b/tests/unit/out/unsafe/rule_of_five.rs @@ -34,7 +34,9 @@ impl Buffer { { let mut i: i32 = 0; 'loop_: while ((i) < (4)) { - this.data[(i) as usize] = if ((i) < (size)) { i } else { -1_i32 }; + 'for_body: { + this.data[(i) as usize] = if ((i) < (size)) { i } else { -1_i32 }; + } i.prefix_inc(); } } @@ -52,7 +54,9 @@ impl Buffer { { let mut i: i32 = 0; 'loop_: while ((i) < (4)) { - this.data[(i) as usize] = (*o).data[(i) as usize]; + 'for_body: { + this.data[(i) as usize] = (*o).data[(i) as usize]; + } i.prefix_inc(); } } @@ -68,8 +72,10 @@ impl Buffer { { let mut i: i32 = 0; 'loop_: while ((i) < (4)) { - this.data[(i) as usize] = (*o).data[(i) as usize]; - (*o).data[(i) as usize] = -1_i32; + 'for_body: { + this.data[(i) as usize] = (*o).data[(i) as usize]; + (*o).data[(i) as usize] = -1_i32; + } i.prefix_inc(); } } @@ -86,7 +92,9 @@ impl Buffer { { let mut i: i32 = 0; 'loop_: while ((i) < (4)) { - self.data[(i) as usize] = (*o).data[(i) as usize]; + 'for_body: { + self.data[(i) as usize] = (*o).data[(i) as usize]; + } i.prefix_inc(); } } @@ -101,8 +109,10 @@ impl Buffer { { let mut i: i32 = 0; 'loop_: while ((i) < (4)) { - self.data[(i) as usize] = (*o).data[(i) as usize]; - (*o).data[(i) as usize] = -1_i32; + 'for_body: { + self.data[(i) as usize] = (*o).data[(i) as usize]; + (*o).data[(i) as usize] = -1_i32; + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/rule_of_three.rs b/tests/unit/out/unsafe/rule_of_three.rs index ec5e6aa904..855560681d 100644 --- a/tests/unit/out/unsafe/rule_of_three.rs +++ b/tests/unit/out/unsafe/rule_of_three.rs @@ -24,7 +24,9 @@ impl Buffer { { let mut i: i32 = 0; 'loop_: while ((i) < (4)) { - this.data[(i) as usize] = if ((i) < (size)) { i } else { -1_i32 }; + 'for_body: { + this.data[(i) as usize] = if ((i) < (size)) { i } else { -1_i32 }; + } i.prefix_inc(); } } @@ -42,7 +44,9 @@ impl Buffer { { let mut i: i32 = 0; 'loop_: while ((i) < (4)) { - this.data[(i) as usize] = (*o).data[(i) as usize]; + 'for_body: { + this.data[(i) as usize] = (*o).data[(i) as usize]; + } i.prefix_inc(); } } @@ -58,7 +62,9 @@ impl Buffer { { let mut i: i32 = 0; 'loop_: while ((i) < (4)) { - self.data[(i) as usize] = (*o).data[(i) as usize]; + 'for_body: { + self.data[(i) as usize] = (*o).data[(i) as usize]; + } i.prefix_inc(); } } @@ -76,7 +82,9 @@ pub unsafe fn sum_2(b: *const Buffer) -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < ((*b).size)) { - s += (*b).data[(i) as usize]; + 'for_body: { + s += (*b).data[(i) as usize]; + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/size_t_ssize_t.rs b/tests/unit/out/unsafe/size_t_ssize_t.rs index 62c1cd587a..957fb85233 100644 --- a/tests/unit/out/unsafe/size_t_ssize_t.rs +++ b/tests/unit/out/unsafe/size_t_ssize_t.rs @@ -98,7 +98,9 @@ unsafe fn main_0() -> i32 { { let mut i: usize = 0_usize; 'loop_: while ((i) < (count)) { - data[(i)] = (((i).wrapping_mul(2_usize)) as i32); + 'for_body: { + data[(i)] = (((i).wrapping_mul(2_usize)) as i32); + } i.postfix_inc(); } } @@ -106,7 +108,9 @@ unsafe fn main_0() -> i32 { { let mut i: usize = 0_usize; 'loop_: while ((i) < (count)) { - total = (total).wrapping_add((data[(i)] as usize)); + 'for_body: { + total = (total).wrapping_add((data[(i)] as usize)); + } i.postfix_inc(); } } diff --git a/tests/unit/out/unsafe/socket_ip_name.rs b/tests/unit/out/unsafe/socket_ip_name.rs index 493c32239c..825a7c9850 100644 --- a/tests/unit/out/unsafe/socket_ip_name.rs +++ b/tests/unit/out/unsafe/socket_ip_name.rs @@ -50,7 +50,9 @@ pub unsafe fn check_buf_0( { let mut j: u32 = copied; 'loop_: while ((j) < (size)) { - assert!((((*buf.offset((j) as isize)) as i32) == (165))); + 'for_body: { + assert!((((*buf.offset((j) as isize)) as i32) == (165))); + } j.prefix_inc(); } } @@ -96,37 +98,39 @@ pub unsafe fn check_name_1(mut family: i32) { < ((::std::mem::size_of::<[libc::socklen_t; 6]>() as usize) .wrapping_div((::std::mem::size_of::() as usize)))) { - let mut out: [u8; 136] = [0_u8; 136]; - (unsafe { - let _buf: *mut u8 = out.as_mut_ptr(); - let _size: u32 = (::std::mem::size_of::<[u8; 136]>() as u32); - check_buf_0( - fd, - _buf, - _size, - capacities[(i) as usize], - ((&mut full as *mut libc::sockaddr_storage) as *const ::libc::c_void), - actual, - ) - }); - let mut size: u32 = (if (capacities[(i) as usize] != 0) { - capacities[(i) as usize] - } else { - (1 as libc::socklen_t) - } as u32); - let mut small: *mut u8 = (libcc2rs::malloc_unsafe((size as usize)) as *mut u8); - assert!(!(small).is_null()); - (unsafe { - check_buf_0( - fd, - small, - size, - capacities[(i) as usize], - ((&mut full as *mut libc::sockaddr_storage) as *const ::libc::c_void), - actual, - ) - }); - libcc2rs::free_unsafe((small as *mut ::libc::c_void)); + 'for_body: { + let mut out: [u8; 136] = [0_u8; 136]; + (unsafe { + let _buf: *mut u8 = out.as_mut_ptr(); + let _size: u32 = (::std::mem::size_of::<[u8; 136]>() as u32); + check_buf_0( + fd, + _buf, + _size, + capacities[(i) as usize], + ((&mut full as *mut libc::sockaddr_storage) as *const ::libc::c_void), + actual, + ) + }); + let mut size: u32 = (if (capacities[(i) as usize] != 0) { + capacities[(i) as usize] + } else { + (1 as libc::socklen_t) + } as u32); + let mut small: *mut u8 = (libcc2rs::malloc_unsafe((size as usize)) as *mut u8); + assert!(!(small).is_null()); + (unsafe { + check_buf_0( + fd, + small, + size, + capacities[(i) as usize], + ((&mut full as *mut libc::sockaddr_storage) as *const ::libc::c_void), + actual, + ) + }); + libcc2rs::free_unsafe((small as *mut ::libc::c_void)); + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/socket_recvfrom_name.rs b/tests/unit/out/unsafe/socket_recvfrom_name.rs index a9557f9afa..761a948375 100644 --- a/tests/unit/out/unsafe/socket_recvfrom_name.rs +++ b/tests/unit/out/unsafe/socket_recvfrom_name.rs @@ -69,11 +69,13 @@ pub unsafe fn check_from_0( { let mut i: u32 = (len as u32); 'loop_: while ((i as usize) < (::std::mem::size_of::())) { - assert!( - (((*((&mut from as *mut libc::sockaddr_storage) as *mut u8).offset((i) as isize)) - as i32) - == (165)) - ); + 'for_body: { + assert!( + (((*((&mut from as *mut libc::sockaddr_storage) as *mut u8) + .offset((i) as isize)) as i32) + == (165)) + ); + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/socket_unix_name.rs b/tests/unit/out/unsafe/socket_unix_name.rs index 4356ac5165..61da9be545 100644 --- a/tests/unit/out/unsafe/socket_unix_name.rs +++ b/tests/unit/out/unsafe/socket_unix_name.rs @@ -90,56 +90,60 @@ pub unsafe fn check_name_0(mut fd: i32, mut path: *const libc::c_char) { < ((::std::mem::size_of::<[libc::socklen_t; 6]>() as usize) .wrapping_div((::std::mem::size_of::() as usize)))) { - let mut out: [u8; 136] = [0_u8; 136]; - { - let mut __tmp_2 = { (out.as_mut_ptr() as *mut ::libc::c_void) }; - let byte_0 = __tmp_2 as *mut u8; - for offset in 0..::std::mem::size_of::<[u8; 136]>() { - *byte_0.offset(offset as isize) = 165 as u8; - } - __tmp_2 - }; - let mut len: libc::socklen_t = capacities[(i) as usize]; - assert!( - ((libc::getsockname( - fd, - (out.as_mut_ptr() as *mut libc::sockaddr), - (&mut len as *mut libc::socklen_t) - )) == (0)) - ); - assert!(((len) == (actual))); - let mut copied: u32 = (if ((capacities[(i) as usize]) < (actual)) { - capacities[(i) as usize] - } else { - actual - } as u32); - assert!( - (({ - let mut __tmp_3 = { (copied as usize) }; - let sa = core::slice::from_raw_parts( - (out.as_mut_ptr() as *const ::libc::c_void) as *const u8, - __tmp_3, - ); - let sb = core::slice::from_raw_parts( - ((&mut full as *mut libc::sockaddr_storage) as *const ::libc::c_void) - as *const u8, - __tmp_3, - ); - let mut diff = 0_i32; - for (x, y) in sa.iter().zip(sb.iter()) { - if x != y { - diff = (*x as i32) - (*y as i32); - break; + 'for_body: { + let mut out: [u8; 136] = [0_u8; 136]; + { + let mut __tmp_2 = { (out.as_mut_ptr() as *mut ::libc::c_void) }; + let byte_0 = __tmp_2 as *mut u8; + for offset in 0..::std::mem::size_of::<[u8; 136]>() { + *byte_0.offset(offset as isize) = 165 as u8; + } + __tmp_2 + }; + let mut len: libc::socklen_t = capacities[(i) as usize]; + assert!( + ((libc::getsockname( + fd, + (out.as_mut_ptr() as *mut libc::sockaddr), + (&mut len as *mut libc::socklen_t) + )) == (0)) + ); + assert!(((len) == (actual))); + let mut copied: u32 = (if ((capacities[(i) as usize]) < (actual)) { + capacities[(i) as usize] + } else { + actual + } as u32); + assert!( + (({ + let mut __tmp_3 = { (copied as usize) }; + let sa = core::slice::from_raw_parts( + (out.as_mut_ptr() as *const ::libc::c_void) as *const u8, + __tmp_3, + ); + let sb = core::slice::from_raw_parts( + ((&mut full as *mut libc::sockaddr_storage) as *const ::libc::c_void) + as *const u8, + __tmp_3, + ); + let mut diff = 0_i32; + for (x, y) in sa.iter().zip(sb.iter()) { + if x != y { + diff = (*x as i32) - (*y as i32); + break; + } + } + diff + }) == (0)) + ); + { + let mut j: u32 = copied; + 'loop_: while ((j as usize) < (::std::mem::size_of::<[u8; 136]>())) { + 'for_body: { + assert!(((out[(j) as usize] as i32) == (165))); } + j.prefix_inc(); } - diff - }) == (0)) - ); - { - let mut j: u32 = copied; - 'loop_: while ((j as usize) < (::std::mem::size_of::<[u8; 136]>())) { - assert!(((out[(j) as usize] as i32) == (165))); - j.prefix_inc(); } } i.prefix_inc(); diff --git a/tests/unit/out/unsafe/sort.rs b/tests/unit/out/unsafe/sort.rs index af0edd3afc..ad88a714c0 100644 --- a/tests/unit/out/unsafe/sort.rs +++ b/tests/unit/out/unsafe/sort.rs @@ -70,7 +70,9 @@ unsafe fn main_0() -> i32 { { let mut i: u32 = 0_u32; 'loop_: while ((i as usize) < ((v.len()).wrapping_sub(1_usize))) { - assert!(((v[(i as usize)]) < (v[(((i).wrapping_add(1_u32)) as usize)]))); + 'for_body: { + assert!(((v[(i as usize)]) < (v[(((i).wrapping_add(1_u32)) as usize)]))); + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/string.rs b/tests/unit/out/unsafe/string.rs index 3feb6f3cc1..02f64a50e9 100644 --- a/tests/unit/out/unsafe/string.rs +++ b/tests/unit/out/unsafe/string.rs @@ -96,10 +96,12 @@ unsafe fn main_0() -> i32 { { let mut i: u32 = 0_u32; 'loop_: while ((i as usize) < (s2.len() - 1)) { - assert!( - (((*p2.offset((i) as isize)) as i32) == (('a' as libc::c_char) as i32)) - && ((s2[(i as usize)] as i32) == (('a' as libc::c_char) as i32)) - ); + 'for_body: { + assert!( + (((*p2.offset((i) as isize)) as i32) == (('a' as libc::c_char) as i32)) + && ((s2[(i as usize)] as i32) == (('a' as libc::c_char) as i32)) + ); + } i.prefix_inc(); } } @@ -112,10 +114,12 @@ unsafe fn main_0() -> i32 { { let mut i: u32 = 2_u32; 'loop_: while ((i as usize) < (s2.len() - 1)) { - assert!( - (((*p2.offset((i) as isize)) as i32) == (('a' as libc::c_char) as i32)) - && ((s2[(i as usize)] as i32) == (('a' as libc::c_char) as i32)) - ); + 'for_body: { + assert!( + (((*p2.offset((i) as isize)) as i32) == (('a' as libc::c_char) as i32)) + && ((s2[(i as usize)] as i32) == (('a' as libc::c_char) as i32)) + ); + } i.prefix_inc(); } } @@ -135,7 +139,9 @@ unsafe fn main_0() -> i32 { { let mut i: u32 = 0_u32; 'loop_: while ((i as usize) < (s3.len() - 1)) { - assert!((((*p3.offset((i) as isize)) as i32) == (s3[(i as usize)] as i32))); + 'for_body: { + assert!((((*p3.offset((i) as isize)) as i32) == (s3[(i as usize)] as i32))); + } i.prefix_inc(); } } @@ -163,7 +169,9 @@ unsafe fn main_0() -> i32 { { let mut i: u32 = 0_u32; 'loop_: while ((i as usize) < (s4.len() - 1)) { - assert!((((*p4.offset((i) as isize)) as i32) == (s4[(i as usize)] as i32))); + 'for_body: { + assert!((((*p4.offset((i) as isize)) as i32) == (s4[(i as usize)] as i32))); + } i.prefix_inc(); } } @@ -185,7 +193,9 @@ unsafe fn main_0() -> i32 { { let mut i: u32 = 0_u32; 'loop_: while ((i as usize) < (s5.len() - 1)) { - assert!((((*p5.offset((i) as isize)) as i32) == (s5[(i as usize)] as i32))); + 'for_body: { + assert!((((*p5.offset((i) as isize)) as i32) == (s5[(i as usize)] as i32))); + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/string_escape.rs b/tests/unit/out/unsafe/string_escape.rs index 5000aa95f3..87799798b1 100644 --- a/tests/unit/out/unsafe/string_escape.rs +++ b/tests/unit/out/unsafe/string_escape.rs @@ -22,11 +22,13 @@ unsafe fn main_0() -> i32 { .wrapping_div((::std::mem::size_of::() as usize))) as i32)) { - assert!( - (((*special.offset((i) as isize)) as i32) - == ((*std::cell::LazyCell::force_mut(&mut *&raw mut expected_0))[(i) as usize] - as i32)) - ); + 'for_body: { + assert!( + (((*special.offset((i) as isize)) as i32) + == ((*std::cell::LazyCell::force_mut(&mut *&raw mut expected_0)) + [(i) as usize] as i32)) + ); + } i.postfix_inc(); } } diff --git a/tests/unit/out/unsafe/string_literal_interior_null.rs b/tests/unit/out/unsafe/string_literal_interior_null.rs index 7cc968866d..e436124231 100644 --- a/tests/unit/out/unsafe/string_literal_interior_null.rs +++ b/tests/unit/out/unsafe/string_literal_interior_null.rs @@ -11,7 +11,9 @@ pub unsafe fn sum_bytes_0(mut buf: *const libc::c_char, mut len: u32) -> i32 { { let mut i: u32 = 0_u32; 'loop_: while ((i) < (len)) { - sum += (((*buf.offset((i) as isize)) as u8) as i32); + 'for_body: { + sum += (((*buf.offset((i) as isize)) as u8) as i32); + } i.postfix_inc(); } } diff --git a/tests/unit/out/unsafe/string_repeat_append.rs b/tests/unit/out/unsafe/string_repeat_append.rs index 6e3deaaf61..4161af64cc 100644 --- a/tests/unit/out/unsafe/string_repeat_append.rs +++ b/tests/unit/out/unsafe/string_repeat_append.rs @@ -72,51 +72,58 @@ unsafe fn main_0() -> i32 { { let mut shrink: i32 = 0; 'loop_: while ((shrink) < (2)) { - let mut s: Vec = - vec![('x' as libc::c_char); (length) as usize] - .iter() - .cloned() - .chain(std::iter::once(0)) - .collect(); - { - let mut i: usize = 0_usize; - 'loop_: while ((i) < (length)) { - s[(i)] = initial[((i).wrapping_rem( - (::std::mem::size_of::<[libc::c_char; 5]>() as usize), - ))]; - i.prefix_inc(); + 'for_body: { + let mut s: Vec = + vec![('x' as libc::c_char); (length) as usize] + .iter() + .cloned() + .chain(std::iter::once(0)) + .collect(); + { + let mut i: usize = 0_usize; + 'loop_: while ((i) < (length)) { + 'for_body: { + s[(i)] = initial[((i).wrapping_rem( + (::std::mem::size_of::<[libc::c_char; 5]>() as usize), + ))]; + } + i.prefix_inc(); + } } - } - if (shrink != 0) { - s.shrink_to_fit(); - } - { - s.splice( - s.len() - 1..s.len() - 1, - ::std::vec::from_elem(character, count as usize), - ); - }; - assert!(((s.len() - 1) == ((length).wrapping_add(count)))); - let mut data: *const libc::c_char = (s.as_mut_ptr()).cast_const(); - { - let mut i: usize = 0_usize; - 'loop_: while ((i) < ((length).wrapping_add(count))) { - assert!( - (((*data.offset((i) as isize)) as i32) - == ((if ((i) < (length)) { - initial[((i).wrapping_rem( - (::std::mem::size_of::<[libc::c_char; 5]>() - as usize), - ))] - } else { - character - }) as i32)) + if (shrink != 0) { + s.shrink_to_fit(); + } + { + s.splice( + s.len() - 1..s.len() - 1, + ::std::vec::from_elem(character, count as usize), ); - i.prefix_inc(); + }; + assert!(((s.len() - 1) == ((length).wrapping_add(count)))); + let mut data: *const libc::c_char = (s.as_mut_ptr()).cast_const(); + { + let mut i: usize = 0_usize; + 'loop_: while ((i) < ((length).wrapping_add(count))) { + 'for_body: { + assert!( + (((*data.offset((i) as isize)) as i32) + == ((if ((i) < (length)) { + initial[((i).wrapping_rem( + (::std::mem::size_of::<[libc::c_char; 5]>() + as usize), + ))] + } else { + character + }) + as i32)) + ); + } + i.prefix_inc(); + } } + assert!((((*data.offset((s.len() - 1) as isize)) as i32) == (0))); + cases.prefix_inc(); } - assert!((((*data.offset((s.len() - 1) as isize)) as i32) == (0))); - cases.prefix_inc(); shrink.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/swap_map_no_copy.rs b/tests/unit/out/unsafe/swap_map_no_copy.rs index 51ccc91646..11750e8377 100644 --- a/tests/unit/out/unsafe/swap_map_no_copy.rs +++ b/tests/unit/out/unsafe/swap_map_no_copy.rs @@ -110,20 +110,24 @@ impl Arrays { { let mut __i0: usize = 0_usize; 'loop_: while ((__i0) != (2_usize)) { - (unsafe { - let _o: *const Tracked = &(*_a0).a[(__i0)]; - Tracked::copy_assign(&mut self.a[(__i0)], _o) - }); + 'for_body: { + (unsafe { + let _o: *const Tracked = &(*_a0).a[(__i0)]; + Tracked::copy_assign(&mut self.a[(__i0)], _o) + }); + } __i0.prefix_inc(); } } { let mut __i0: usize = 0_usize; 'loop_: while ((__i0) != (2_usize)) { - (unsafe { - let _o: *const Tracked = &(*_a0).b[(__i0)]; - Tracked::copy_assign(&mut self.b[(__i0)], _o) - }); + 'for_body: { + (unsafe { + let _o: *const Tracked = &(*_a0).b[(__i0)]; + Tracked::copy_assign(&mut self.b[(__i0)], _o) + }); + } __i0.prefix_inc(); } } @@ -133,20 +137,24 @@ impl Arrays { { let mut __i0: usize = 0_usize; 'loop_: while ((__i0) != (2_usize)) { - (unsafe { - let _o: *mut Tracked = &mut (*_a0).a[(__i0)]; - Tracked::move_assign(&mut self.a[(__i0)], _o) - }); + 'for_body: { + (unsafe { + let _o: *mut Tracked = &mut (*_a0).a[(__i0)]; + Tracked::move_assign(&mut self.a[(__i0)], _o) + }); + } __i0.prefix_inc(); } } { let mut __i0: usize = 0_usize; 'loop_: while ((__i0) != (2_usize)) { - (unsafe { - let _o: *mut Tracked = &mut (*_a0).b[(__i0)]; - Tracked::move_assign(&mut self.b[(__i0)], _o) - }); + 'for_body: { + (unsafe { + let _o: *mut Tracked = &mut (*_a0).b[(__i0)]; + Tracked::move_assign(&mut self.b[(__i0)], _o) + }); + } __i0.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/switch_continue_inside_switch.rs b/tests/unit/out/unsafe/switch_continue_inside_switch.rs index 89a5bb326e..5a1238c409 100644 --- a/tests/unit/out/unsafe/switch_continue_inside_switch.rs +++ b/tests/unit/out/unsafe/switch_continue_inside_switch.rs @@ -11,19 +11,20 @@ pub unsafe fn continue_inside_switch_0(mut n: i32) -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (n)) { - 'switch: { - match { i } { - __v if __v == 0 || __v == 2 || __v == 4 => { - i.prefix_inc(); - continue 'loop_; + 'for_body: { + 'switch: { + match { i } { + __v if __v == 0 || __v == 2 || __v == 4 => { + break 'for_body; + } + _ => { + r += i; + break 'switch; + } } - _ => { - r += i; - break 'switch; - } - } - }; - r += 1000; + }; + r += 1000; + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/switch_for_in_switch_break.rs b/tests/unit/out/unsafe/switch_for_in_switch_break.rs index a377d6a1f9..f541439994 100644 --- a/tests/unit/out/unsafe/switch_for_in_switch_break.rs +++ b/tests/unit/out/unsafe/switch_for_in_switch_break.rs @@ -14,10 +14,12 @@ pub unsafe fn for_in_switch_break_0(mut n: i32) -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (10)) { - if ((i) == (3)) { - break; + 'for_body: { + if ((i) == (3)) { + break 'loop_; + } + r += i; } - r += i; i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/switch_for_in_switch_continue.rs b/tests/unit/out/unsafe/switch_for_in_switch_continue.rs index 6a70f3fcaf..00931cff8b 100644 --- a/tests/unit/out/unsafe/switch_for_in_switch_continue.rs +++ b/tests/unit/out/unsafe/switch_for_in_switch_continue.rs @@ -14,11 +14,12 @@ pub unsafe fn for_in_switch_continue_0(mut n: i32) -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (5)) { - if (((i) % (2)) == (0)) { - i.prefix_inc(); - continue 'loop_; + 'for_body: { + if (((i) % (2)) == (0)) { + break 'for_body; + } + r += i; } - r += i; i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/switch_for_switch_for_break.rs b/tests/unit/out/unsafe/switch_for_switch_for_break.rs index fa16f91a12..bfaa878878 100644 --- a/tests/unit/out/unsafe/switch_for_switch_for_break.rs +++ b/tests/unit/out/unsafe/switch_for_switch_for_break.rs @@ -11,28 +11,32 @@ pub unsafe fn for_switch_for_break_0(mut n: i32) -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (n)) { - 'switch: { - match { i } { - __v if __v == 1 => { - { - let mut j: i32 = 0; - 'loop_: while ((j) < (10)) { - if ((j) == (2)) { - break; + 'for_body: { + 'switch: { + match { i } { + __v if __v == 1 => { + { + let mut j: i32 = 0; + 'loop_: while ((j) < (10)) { + 'for_body: { + if ((j) == (2)) { + break 'loop_; + } + r += 1; + } + j.prefix_inc(); } - r += 1; - j.prefix_inc(); } + r += 100; + break 'switch; + } + _ => { + r += 10; + break 'switch; } - r += 100; - break 'switch; - } - _ => { - r += 10; - break 'switch; } - } - }; + }; + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/switch_in_loop.rs b/tests/unit/out/unsafe/switch_in_loop.rs index 246ab41a5b..cfaa66cd28 100644 --- a/tests/unit/out/unsafe/switch_in_loop.rs +++ b/tests/unit/out/unsafe/switch_in_loop.rs @@ -11,23 +11,25 @@ pub unsafe fn switch_in_loop_0(mut n: i32) -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (n)) { - 'switch: { - match { ((i) % (3)) } { - __v if __v == 0 => { - r += 1; - break 'switch; + 'for_body: { + 'switch: { + match { ((i) % (3)) } { + __v if __v == 0 => { + r += 1; + break 'switch; + } + __v if __v == 1 => { + r += 2; + break 'switch; + } + _ => { + r += 3; + break 'switch; + } } - __v if __v == 1 => { - r += 2; - break 'switch; - } - _ => { - r += 3; - break 'switch; - } - } - }; - r += 10; + }; + r += 10; + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/unboxed_conditional_iterator.rs b/tests/unit/out/unsafe/unboxed_conditional_iterator.rs index bb1f0ae8c3..ac00d71ea8 100644 --- a/tests/unit/out/unsafe/unboxed_conditional_iterator.rs +++ b/tests/unit/out/unsafe/unboxed_conditional_iterator.rs @@ -41,32 +41,36 @@ pub unsafe fn lehmer_3(mut sigma: *const u32, mut len: u32, mut code: *mut u32) { let mut i: u32 = 0_u32; 'loop_: while ((i) < (len)) { - items[(i as usize)] = i; + 'for_body: { + items[(i as usize)] = i; + } i.prefix_inc(); } } { let mut i: u32 = 0_u32; 'loop_: while ((i) < (len)) { - let mut it: UnsafeRandomAccessIterator = { - let mut __tmp_0 = { items.begin() }; - let mut __tmp_1 = { items.end() }; - let mut __it = (__tmp_0).clone(); - while __it != __tmp_1 && *__it.iter_deref() != (*sigma.offset((i) as isize)) { - __it.iter_inc(); - } - __it - }; - assert!(it != items.end()); - (*code.offset((i) as isize)) = ((it.iter_distance(&items.begin())) as u32); - { - let mut __tmp_2 = { >::from((it).clone()) }; - let pos = __tmp_2 - .iter_distance(&UnsafeRandomAccessIterator::Vec(items.as_mut_ptr())) - as usize; - items.remove(pos); - (__tmp_2).clone() - }; + 'for_body: { + let mut it: UnsafeRandomAccessIterator = { + let mut __tmp_0 = { items.begin() }; + let mut __tmp_1 = { items.end() }; + let mut __it = (__tmp_0).clone(); + while __it != __tmp_1 && *__it.iter_deref() != (*sigma.offset((i) as isize)) { + __it.iter_inc(); + } + __it + }; + assert!(it != items.end()); + (*code.offset((i) as isize)) = ((it.iter_distance(&items.begin())) as u32); + { + let mut __tmp_2 = { >::from((it).clone()) }; + let pos = __tmp_2 + .iter_distance(&UnsafeRandomAccessIterator::Vec(items.as_mut_ptr())) + as usize; + items.remove(pos); + (__tmp_2).clone() + }; + } i.prefix_inc(); } } @@ -76,7 +80,9 @@ pub unsafe fn sum_4(v: *mut Vec) -> i32 { { let mut it: UnsafeRandomAccessIterator = (*v).begin(); 'loop_: while it != (*v).end() { - s += (*it.iter_deref()); + 'for_body: { + s += (*it.iter_deref()); + } { it.iter_inc(); }; diff --git a/tests/unit/out/unsafe/unboxed_locals.rs b/tests/unit/out/unsafe/unboxed_locals.rs index 6333c391b2..db4ab9243b 100644 --- a/tests/unit/out/unsafe/unboxed_locals.rs +++ b/tests/unit/out/unsafe/unboxed_locals.rs @@ -31,7 +31,9 @@ pub unsafe fn sum_3(mut arr: *const i32, mut n: i32) -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (n)) { - s += (*arr.offset((i) as isize)); + 'for_body: { + s += (*arr.offset((i) as isize)); + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/unboxed_records.rs b/tests/unit/out/unsafe/unboxed_records.rs index 2b1043ca06..e4ade4d178 100644 --- a/tests/unit/out/unsafe/unboxed_records.rs +++ b/tests/unit/out/unsafe/unboxed_records.rs @@ -51,8 +51,10 @@ pub unsafe fn consume_3(cookie: *const Cookie) -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (4)) { - (*c.data.offset((i) as isize)) = ((*c.in_.offset((i) as isize)) * (c.x)); - sum += (*c.data.offset((i) as isize)); + 'for_body: { + (*c.data.offset((i) as isize)) = ((*c.in_.offset((i) as isize)) * (c.x)); + sum += (*c.data.offset((i) as isize)); + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/union_flex_array_member.rs b/tests/unit/out/unsafe/union_flex_array_member.rs index 9022910e94..9a00be7cc3 100644 --- a/tests/unit/out/unsafe/union_flex_array_member.rs +++ b/tests/unit/out/unsafe/union_flex_array_member.rs @@ -39,17 +39,21 @@ unsafe fn main_0() -> i32 { { let mut i: usize = 0_usize; 'loop_: while ((i) < (tail_size)) { - (*(*n).x.bytes.as_mut_ptr().add((i) as usize)) = (((i) & (255_usize)) as u8); + 'for_body: { + (*(*n).x.bytes.as_mut_ptr().add((i) as usize)) = (((i) & (255_usize)) as u8); + } i.postfix_inc(); } } { let mut i: usize = 0_usize; 'loop_: while ((i) < (tail_size)) { - assert!( - (((*(*n).x.bytes.as_mut_ptr().add((i) as usize)) as i32) - == ((((i) & (255_usize)) as u8) as i32)) - ); + 'for_body: { + assert!( + (((*(*n).x.bytes.as_mut_ptr().add((i) as usize)) as i32) + == ((((i) & (255_usize)) as u8) as i32)) + ); + } i.postfix_inc(); } } diff --git a/tests/unit/out/unsafe/unique_ptr.rs b/tests/unit/out/unsafe/unique_ptr.rs index 0166afab88..052bf3ebd6 100644 --- a/tests/unit/out/unsafe/unique_ptr.rs +++ b/tests/unit/out/unsafe/unique_ptr.rs @@ -155,9 +155,11 @@ pub unsafe fn RndStuff_2() { { let mut i: i32 = 0; 'loop_: while ((i) < (100)) { - (*x2.as_deref() - .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut i32) - .add((i as usize))) = 1; + 'for_body: { + (*x2.as_deref() + .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut i32) + .add((i as usize))) = 1; + } i.prefix_inc(); } } @@ -167,9 +169,11 @@ pub unsafe fn RndStuff_2() { { let mut i: i32 = 0; 'loop_: while ((i) < (200)) { - (*x2.as_deref() - .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut i32) - .add((i as usize))) = 2; + 'for_body: { + (*x2.as_deref() + .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut i32) + .add((i as usize))) = 2; + } i.prefix_inc(); } } @@ -179,7 +183,9 @@ pub unsafe fn RndStuff_2() { { let mut i: i32 = 0; 'loop_: while ((i) < (200)) { - assert!(((*p2.offset((i) as isize)) == (2))); + 'for_body: { + assert!(((*p2.offset((i) as isize)) == (2))); + } i.prefix_inc(); } } @@ -191,9 +197,11 @@ pub unsafe fn RndStuff_2() { { let mut i: i32 = 0; 'loop_: while ((i) < (10)) { - (*x3.as_deref() - .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut Pair) - .add((i as usize))) = Pair { x: 1, y: 2 }; + 'for_body: { + (*x3.as_deref() + .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut Pair) + .add((i as usize))) = Pair { x: 1, y: 2 }; + } i.prefix_inc(); } } @@ -203,19 +211,21 @@ pub unsafe fn RndStuff_2() { { let mut i: i32 = 0; 'loop_: while ((i) < (10)) { - assert!((((*p3_0.offset((i) as isize)).x) == (1))); - assert!((((*p3_0.offset((i) as isize)).y) == (2))); - (unsafe { - Pair::inc( - &mut (*x3 - .as_deref() - .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut Pair) - .add((i as usize))), - 10, - ) - }); - assert!((((*p3_0.offset((i) as isize)).x) == (11))); - assert!((((*p3_0.offset((i) as isize)).y) == (12))); + 'for_body: { + assert!((((*p3_0.offset((i) as isize)).x) == (1))); + assert!((((*p3_0.offset((i) as isize)).y) == (2))); + (unsafe { + Pair::inc( + &mut (*x3 + .as_deref() + .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut Pair) + .add((i as usize))), + 10, + ) + }); + assert!((((*p3_0.offset((i) as isize)).x) == (11))); + assert!((((*p3_0.offset((i) as isize)).y) == (12))); + } i.prefix_inc(); } } @@ -227,12 +237,14 @@ pub unsafe fn RndStuff_2() { { let mut i: i32 = 0; 'loop_: while ((i) < (50)) { - (*x3.as_deref() - .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut Pair) - .add((i as usize))) = Pair { - x: -1_i32, - y: -2_i32, - }; + 'for_body: { + (*x3.as_deref() + .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut Pair) + .add((i as usize))) = Pair { + x: -1_i32, + y: -2_i32, + }; + } i.prefix_inc(); } } @@ -243,19 +255,21 @@ pub unsafe fn RndStuff_2() { { let mut i: i32 = 0; 'loop_: while ((i) < (50)) { - assert!((((*p3_1.offset((i) as isize)).x) == (-1_i32))); - assert!((((*p3_1.offset((i) as isize)).y) == (-2_i32))); - (unsafe { - Pair::inc( - &mut (*x3 - .as_deref() - .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut Pair) - .add((i as usize))), - -10_i32, - ) - }); - assert!((((*p3_1.offset((i) as isize)).x) == (-11_i32))); - assert!((((*p3_1.offset((i) as isize)).y) == (-12_i32))); + 'for_body: { + assert!((((*p3_1.offset((i) as isize)).x) == (-1_i32))); + assert!((((*p3_1.offset((i) as isize)).y) == (-2_i32))); + (unsafe { + Pair::inc( + &mut (*x3 + .as_deref() + .map_or(::std::ptr::null_mut(), |s| s.as_ptr() as *mut Pair) + .add((i as usize))), + -10_i32, + ) + }); + assert!((((*p3_1.offset((i) as isize)).x) == (-11_i32))); + assert!((((*p3_1.offset((i) as isize)).y) == (-12_i32))); + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/va_arg_chain.rs b/tests/unit/out/unsafe/va_arg_chain.rs index ad5a69e3f1..24dd1a33da 100644 --- a/tests/unit/out/unsafe/va_arg_chain.rs +++ b/tests/unit/out/unsafe/va_arg_chain.rs @@ -10,7 +10,9 @@ pub unsafe fn extract_nth_0(mut n: i32, mut ap: *const VaArg) -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (n)) { - ap.arg::(); + 'for_body: { + ap.arg::(); + } i.postfix_inc(); } } diff --git a/tests/unit/out/unsafe/va_arg_copy.rs b/tests/unit/out/unsafe/va_arg_copy.rs index e3b53efe46..4e5da13c04 100644 --- a/tests/unit/out/unsafe/va_arg_copy.rs +++ b/tests/unit/out/unsafe/va_arg_copy.rs @@ -15,7 +15,9 @@ pub unsafe fn sum_with_copy_0(mut count: i32, __args: Box<[VaArg]>) -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (count)) { - sum1 += ap.arg::(); + 'for_body: { + sum1 += ap.arg::(); + } i.postfix_inc(); } }; @@ -23,7 +25,9 @@ pub unsafe fn sum_with_copy_0(mut count: i32, __args: Box<[VaArg]>) -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (count)) { - sum2 += aq.arg::(); + 'for_body: { + sum2 += aq.arg::(); + } i.postfix_inc(); } }; diff --git a/tests/unit/out/unsafe/va_arg_forward.rs b/tests/unit/out/unsafe/va_arg_forward.rs index 2e7ed24003..6730c2710f 100644 --- a/tests/unit/out/unsafe/va_arg_forward.rs +++ b/tests/unit/out/unsafe/va_arg_forward.rs @@ -11,7 +11,9 @@ pub unsafe fn inner_0(mut count: i32, mut ap: *const VaArg) -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (count)) { - total += ap.arg::(); + 'for_body: { + total += ap.arg::(); + } i.postfix_inc(); } } diff --git a/tests/unit/out/unsafe/va_arg_mixed_int_ptr.rs b/tests/unit/out/unsafe/va_arg_mixed_int_ptr.rs index 4ca990729a..8012fc6673 100644 --- a/tests/unit/out/unsafe/va_arg_mixed_int_ptr.rs +++ b/tests/unit/out/unsafe/va_arg_mixed_int_ptr.rs @@ -13,12 +13,14 @@ pub unsafe fn mixed_args_0(mut count: i32, __args: Box<[VaArg]>) -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (count)) { - let mut tag: i32 = ap.arg::(); - if ((tag) == (0)) { - total += ap.arg::(); - } else { - let mut ptr: *mut i32 = ap.arg::<*mut i32>(); - total += (*ptr); + 'for_body: { + let mut tag: i32 = ap.arg::(); + if ((tag) == (0)) { + total += ap.arg::(); + } else { + let mut ptr: *mut i32 = ap.arg::<*mut i32>(); + total += (*ptr); + } } i.postfix_inc(); } diff --git a/tests/unit/out/unsafe/va_arg_mixed_types.rs b/tests/unit/out/unsafe/va_arg_mixed_types.rs index 2c7bd31bad..c4de4af6f0 100644 --- a/tests/unit/out/unsafe/va_arg_mixed_types.rs +++ b/tests/unit/out/unsafe/va_arg_mixed_types.rs @@ -19,17 +19,19 @@ pub unsafe fn sum_mixed_0(mut count: i32, __args: Box<[VaArg]>) -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (count)) { - let mut tag: i32 = ap.arg::(); - if ((tag) == (0)) { - total += ap.arg::(); - } else if ((tag) == (1)) { - total += (ap.arg::() as i32); - } else if ((tag) == (3)) { - let mut p: pair = ap.arg::(); - total += ((p.a) * (p.b)); - } else { - let mut val: i64 = ap.arg::(); - total += (val as i32); + 'for_body: { + let mut tag: i32 = ap.arg::(); + if ((tag) == (0)) { + total += ap.arg::(); + } else if ((tag) == (1)) { + total += (ap.arg::() as i32); + } else if ((tag) == (3)) { + let mut p: pair = ap.arg::(); + total += ((p.a) * (p.b)); + } else { + let mut val: i64 = ap.arg::(); + total += (val as i32); + } } i.postfix_inc(); } diff --git a/tests/unit/out/unsafe/va_arg_null_int_ptr.rs b/tests/unit/out/unsafe/va_arg_null_int_ptr.rs index 04e2e08a9b..cc191d8a68 100644 --- a/tests/unit/out/unsafe/va_arg_null_int_ptr.rs +++ b/tests/unit/out/unsafe/va_arg_null_int_ptr.rs @@ -13,10 +13,12 @@ pub unsafe fn first_nonnull_0(mut count: i32, __args: Box<[VaArg]>) -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (count)) { - let mut p: *mut i32 = ap.arg::<*mut i32>(); - if (!((p).is_null())) { - result = (*p); - break; + 'for_body: { + let mut p: *mut i32 = ap.arg::<*mut i32>(); + if (!((p).is_null())) { + result = (*p); + break 'loop_; + } } i.postfix_inc(); } diff --git a/tests/unit/out/unsafe/va_list_field.rs b/tests/unit/out/unsafe/va_list_field.rs index fea1a78f82..823d387731 100644 --- a/tests/unit/out/unsafe/va_list_field.rs +++ b/tests/unit/out/unsafe/va_list_field.rs @@ -16,7 +16,9 @@ pub unsafe fn sum_0(mut n: i32, __args: Box<[VaArg]>) -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (n)) { - total += (*guard.ap).arg::(); + 'for_body: { + total += (*guard.ap).arg::(); + } i.prefix_inc(); } } @@ -51,7 +53,9 @@ pub unsafe fn sum_ptr_2(mut n: i32, __args: Box<[VaArg]>) -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (n)) { - total += (*cursor.ap).arg::(); + 'for_body: { + total += (*cursor.ap).arg::(); + } i.prefix_inc(); } }; diff --git a/tests/unit/out/unsafe/vector.rs b/tests/unit/out/unsafe/vector.rs index 7f99b7acc8..16e263d845 100644 --- a/tests/unit/out/unsafe/vector.rs +++ b/tests/unit/out/unsafe/vector.rs @@ -169,14 +169,17 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (4)) { - { - let mut __tmp_6 = - { >::from(v2.begin().iter_add(1_isize)) }; - let pos = __tmp_6.iter_distance(&UnsafeRandomAccessIterator::Vec(v2.as_mut_ptr())) - as usize; - v2.remove(pos); - (__tmp_6).clone() - }; + 'for_body: { + { + let mut __tmp_6 = + { >::from(v2.begin().iter_add(1_isize)) }; + let pos = __tmp_6 + .iter_distance(&UnsafeRandomAccessIterator::Vec(v2.as_mut_ptr())) + as usize; + v2.remove(pos); + (__tmp_6).clone() + }; + } i.prefix_inc(); } } @@ -192,7 +195,9 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (100)) { - assert!(((v3[(i as usize)]) == (1))); + 'for_body: { + assert!(((v3[(i as usize)]) == (1))); + } i.prefix_inc(); } } @@ -201,7 +206,9 @@ unsafe fn main_0() -> i32 { { let mut i: u32 = 0_u32; 'loop_: while ((i as usize) < (v4.len())) { - assert!((v4[(i as usize)]).is_null()); + 'for_body: { + assert!((v4[(i as usize)]).is_null()); + } i.prefix_inc(); } } @@ -210,7 +217,9 @@ unsafe fn main_0() -> i32 { { let mut i: u32 = 0_u32; 'loop_: while ((i as usize) < (v5.len())) { - assert!((v5[(i as usize)]).is_null()); + 'for_body: { + assert!((v5[(i as usize)]).is_null()); + } i.prefix_inc(); } } @@ -219,7 +228,9 @@ unsafe fn main_0() -> i32 { { let mut i: u32 = 0_u32; 'loop_: while ((i as usize) < (s2)) { - assert!(((v6[(i as usize)]) == (2_f64))); + 'for_body: { + assert!(((v6[(i as usize)]) == (2_f64))); + } i.prefix_inc(); } } @@ -229,7 +240,9 @@ unsafe fn main_0() -> i32 { { let mut i: u32 = 0_u32; 'loop_: while ((i) < (200_u32)) { - assert!(((v7[(i as usize)].0).is_null()) && ((v7[(i as usize)].1) == (0))); + 'for_body: { + assert!(((v7[(i as usize)].0).is_null()) && ((v7[(i as usize)].1) == (0))); + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/vector_subscript_borrow.rs b/tests/unit/out/unsafe/vector_subscript_borrow.rs index 83c0ee8004..34ffb4636b 100644 --- a/tests/unit/out/unsafe/vector_subscript_borrow.rs +++ b/tests/unit/out/unsafe/vector_subscript_borrow.rs @@ -23,7 +23,9 @@ unsafe fn main_0() -> i32 { { let mut i: u32 = 0_u32; 'loop_: while ((i as usize) < (items.len())) { - items[(i as usize)] = (i).wrapping_mul(2_u32); + 'for_body: { + items[(i as usize)] = (i).wrapping_mul(2_u32); + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/vector_subscript_direct.rs b/tests/unit/out/unsafe/vector_subscript_direct.rs index e405ac0002..7ffcc859bf 100644 --- a/tests/unit/out/unsafe/vector_subscript_direct.rs +++ b/tests/unit/out/unsafe/vector_subscript_direct.rs @@ -53,7 +53,9 @@ pub unsafe fn sum_ref_1(v: *const Vec) -> i32 { { let mut i: usize = 0_usize; 'loop_: while ((i) < ((*v).len())) { - s += (&(*v))[(i)]; + 'for_body: { + s += (&(*v))[(i)]; + } i.prefix_inc(); } } diff --git a/tests/unit/out/unsafe/vector_with_allocator.rs b/tests/unit/out/unsafe/vector_with_allocator.rs index e6b38a7565..7a403da53a 100644 --- a/tests/unit/out/unsafe/vector_with_allocator.rs +++ b/tests/unit/out/unsafe/vector_with_allocator.rs @@ -158,7 +158,9 @@ unsafe fn main_0() -> i32 { { let mut i: i32 = 0; 'loop_: while ((i) < (100)) { - assert!(((v3[(i as usize)]) == (1))); + 'for_body: { + assert!(((v3[(i as usize)]) == (1))); + } i.prefix_inc(); } } @@ -167,7 +169,9 @@ unsafe fn main_0() -> i32 { { let mut i: u32 = 0_u32; 'loop_: while ((i as usize) < (s2)) { - assert!(((v6[(i as usize)]) == (2_f64))); + 'for_body: { + assert!(((v6[(i as usize)]) == (2_f64))); + } i.prefix_inc(); } }