Add comments to clarify function argument ownership
This commit is contained in:
parent
0473a4f1d8
commit
8ad7c284d7
@ -650,7 +650,9 @@ pub enum TerminatorKind<'tcx> {
|
||||
Call {
|
||||
/// The function that’s being called
|
||||
func: Operand<'tcx>,
|
||||
/// Arguments the function is called with
|
||||
/// Arguments the function is called with. These are owned by the callee, which is free to
|
||||
/// modify them. This is important as "by-value" arguments might be passed by-reference at
|
||||
/// the ABI level.
|
||||
args: Vec<Operand<'tcx>>,
|
||||
/// Destination for the return value. If some, the call is converging.
|
||||
destination: Option<(Lvalue<'tcx>, BasicBlock)>,
|
||||
|
@ -249,6 +249,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||
args.into_iter()
|
||||
.map(|arg| {
|
||||
let scope = this.local_scope();
|
||||
// Function arguments are owned by the callee, so we need as_temp()
|
||||
// instead of as_operand() to enforce copies
|
||||
let operand = unpack!(block = this.as_temp(block, scope, arg));
|
||||
Operand::Consume(Lvalue::Local(operand))
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user