Skip to content

Commit 4dc0287

Browse files
committed
Explain why we can encounter a Goto terminator that we want to promote
1 parent f7629ef commit 4dc0287

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/librustc_mir/transform/promote_consts.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,13 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
332332
let operand = Operand::Copy(promoted_place(ty, span));
333333
mem::replace(&mut args[index], operand)
334334
}
335-
// already promoted out
335+
// We expected a `TerminatorKind::Call` for which we'd like to promote an
336+
// argument. Since `qualify_consts` saw a `TerminatorKind::Call` here, but
337+
// we are seeing a `Goto`, that means that the `promote_temps` method
338+
// already promoted this call away entirely. This case occurs when calling
339+
// a function requiring a constant argument and as that constant value
340+
// providing a value whose computation contains another call to a function
341+
// requiring a constant argument.
336342
TerminatorKind::Goto { .. } => return,
337343
_ => bug!()
338344
}

0 commit comments

Comments
 (0)