Skip to content

Commit decc286

Browse files
committed
add doc for new fn alloc_ty_init.
(Note that it might be a good idea to replace *all* calls of `alloc_ty` with calls to `alloc_ty_init`, to encourage programmers to consider the appropriate value for the `init` flag when creating temporary values.)
1 parent 7706e23 commit decc286

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/librustc_trans/trans/base.rs

+12
Original file line numberDiff line numberDiff line change
@@ -1331,6 +1331,18 @@ pub fn alloc_ty<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
13311331
alloc_ty_init(bcx, t, InitAlloca::Uninit("all alloc_ty are uninit"), name)
13321332
}
13331333

1334+
/// This variant of `fn alloc_ty` does not necessarily assume that the
1335+
/// alloca should be created with no initial value. Instead the caller
1336+
/// controls that assumption via the `init` flag.
1337+
///
1338+
/// Note that if the alloca *is* initialized via `init`, then we will
1339+
/// also inject an `llvm.lifetime.start` before that initialization
1340+
/// occurs, and thus callers should not call_lifetime_start
1341+
/// themselves. But if `init` says "uninitialized", then callers are
1342+
/// in charge of choosing where to call_lifetime_start and
1343+
/// subsequently populate the alloca.
1344+
///
1345+
/// (See related discussion on PR #30823.)
13341346
pub fn alloc_ty_init<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
13351347
t: Ty<'tcx>,
13361348
init: InitAlloca,

0 commit comments

Comments
 (0)