Skip to content

Commit 63a692a

Browse files
committed
Add relevant comments in the code
* document is_replace field in Drop terminator * clarify drop and replace of untracked value
1 parent f40842a commit 63a692a

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

compiler/rustc_middle/src/mir/syntax.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,14 @@ pub enum TerminatorKind<'tcx> {
577577
/// > The drop glue is executed if, among all statements executed within this `Body`, an assignment to
578578
/// > the place or one of its "parents" occurred more recently than a move out of it. This does not
579579
/// > consider indirect assignments.
580-
Drop { place: Place<'tcx>, target: BasicBlock, unwind: Option<BasicBlock>, is_replace: bool },
580+
Drop {
581+
place: Place<'tcx>,
582+
target: BasicBlock,
583+
unwind: Option<BasicBlock>,
584+
/// This field is only used for better diagnostic and to check MIR drop invariants.
585+
/// It has no effect on the semantics of the `Drop` terminator.
586+
is_replace: bool,
587+
},
581588

582589
/// Roughly speaking, evaluates the `func` operand and the arguments, and starts execution of
583590
/// the referred to function. The operand types must match the argument types of the function.

compiler/rustc_mir_transform/src/elaborate_drops.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,8 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
386386
&format!("drop of untracked value {:?}", bb),
387387
);
388388
}
389-
// If we cannot find it, it means it's a drop followed by a replace
390-
// -> unconditional dro
389+
// drop and replace behind a pointer/array/whatever. The location
390+
// must be initialized.
391391
Elaborator { ctxt: self }.patch().patch_terminator(
392392
bb,
393393
TerminatorKind::Drop {

0 commit comments

Comments
 (0)