@@ -327,25 +327,22 @@ impl Node for WhileNode {
327327 // builder.place_safepoint(ctx);
328328 // let terminator = self.body.emit_child(ctx, builder)?.get_term();
329329
330- let mut terminator = TerminatorEnum :: None ;
331330 // emit the code inside a child context because it belongs to a sub-block
332331 let mut child = ctx. new_child ( self . body . range ( ) . start , builder) ;
333332 if !skip_body || matches ! ( builder, BuilderEnum :: NoOp ( _) ) {
334333 if let Some ( mut def) = gen_def {
335334 def. emit ( & mut child, builder) ?;
336335 }
337- terminator = self . body . emit ( & mut child, builder) ?. get_term ( ) ;
336+ let terminator = self . body . emit ( & mut child, builder) ?. get_term ( ) ;
337+ if !terminator. is_return ( ) {
338+ builder. build_unconditional_branch ( cond_block) ;
339+ }
338340 }
339341 builder. build_dbg_location ( start) ;
340- builder. build_unconditional_branch ( cond_block) ;
341342 ctx. position_at_end ( after_block, builder) ;
342343 ctx. emit_comment_highlight ( & self . comments [ 0 ] ) ;
343344 NodeOutput :: default ( )
344- . with_term ( if terminator. is_return ( ) {
345- terminator
346- } else {
347- TerminatorEnum :: None
348- } )
345+ . with_term ( TerminatorEnum :: None )
349346 . to_result ( )
350347 }
351348}
@@ -434,16 +431,12 @@ impl Node for ForNode {
434431 builder. build_unconditional_branch ( cond_block) ;
435432 ctx. position_at_end ( body_block, builder) ;
436433 builder. place_safepoint ( ctx) ;
437- let terminator = self . body . emit_child ( ctx, builder) ? . get_term ( ) ;
434+ _ = self . body . emit_child ( ctx, builder) ;
438435 builder. build_unconditional_branch ( opt_block) ;
439436 ctx. position_at_end ( after_block, builder) ;
440437 ctx. emit_comment_highlight ( & self . comments [ 0 ] ) ;
441438 NodeOutput :: default ( )
442- . with_term ( if terminator == TerminatorEnum :: Return {
443- terminator
444- } else {
445- TerminatorEnum :: None
446- } )
439+ . with_term ( TerminatorEnum :: None )
447440 . to_result ( )
448441 }
449442}
0 commit comments