Skip to content

Commit 5a2a251

Browse files
authored
Update as_temp.rs
1 parent 83388e8 commit 5a2a251

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/librustc_mir/build/expr/as_temp.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,10 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
8585

8686
unpack!(block = this.into(&Place::Local(temp), block, expr));
8787

88-
// In constants, temp_lifetime is None. We do not drop anything because
89-
// values with a destructor will simply be leaked in constants.
88+
// In constants, temp_lifetime is None for temporaries that live for the
89+
// entire constant. Thus we do not drop these temporaries and simply leak them.
90+
// Anything with a shorter lifetime (e.g the `&foo()` in `bar(&foo())` or anything
91+
// within a block will keep the regular drops just like runtime code.
9092
if let Some(temp_lifetime) = temp_lifetime {
9193
this.schedule_drop_storage_and_value(
9294
expr_span,

0 commit comments

Comments
 (0)