File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
compiler/rustc_mir_transform/src Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -473,7 +473,18 @@ impl<'tcx> CloneShimBuilder<'tcx> {
473
473
where
474
474
I : IntoIterator < Item = Ty < ' tcx > > ,
475
475
{
476
+ // For an iterator of length n, create 2*n + 1 blocks.
476
477
for ( i, ity) in tys. into_iter ( ) . enumerate ( ) {
478
+ // Each iteration creates two blocks, referred to here as block 2*i and block 2*i + 1.
479
+ //
480
+ // Block 2*i attempts to clone the field. If successful it branches to 2*i + 2 (the
481
+ // next clone block). If unsuccessful it branches to the previous unwind block, which
482
+ // is initially the `unwind` argument passed to this function.
483
+ //
484
+ // Block 2*i + 1 is the unwind block for this iteration. It drops the cloned value
485
+ // created by block 2*i. We store this block in `unwind` so that the next clone block
486
+ // will unwind to it if cloning fails.
487
+
477
488
let field = Field :: new ( i) ;
478
489
let src_field = self . tcx . mk_place_field ( src, field, ity) ;
479
490
@@ -489,6 +500,7 @@ impl<'tcx> CloneShimBuilder<'tcx> {
489
500
) ;
490
501
unwind = next_unwind;
491
502
}
503
+ // If all clones succeed then we end up here.
492
504
self . block ( vec ! [ ] , TerminatorKind :: Goto { target } , false ) ;
493
505
unwind
494
506
}
You can’t perform that action at this time.
0 commit comments