Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 1917ffe

Browse files
committed
Add some suggested comments around drops
1 parent ed5bc60 commit 1917ffe

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/librustc_mir/transform/generator.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,12 +331,16 @@ fn insert_entry_point<'tcx>(mir: &mut Mir<'tcx>,
331331
}
332332

333333
fn elaborate_generator_drops<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
334-
def_id: DefId,
335-
mir: &mut Mir<'tcx>) {
334+
def_id: DefId,
335+
mir: &mut Mir<'tcx>) {
336336
use util::elaborate_drops::{elaborate_drop, Unwind};
337337
use util::patch::MirPatch;
338338
use shim::DropShimElaborator;
339339

340+
// Note that `elaborate_drops` only drops the upvars of a generator, and
341+
// this is ok because `open_drop` can only be reached within that own
342+
// generator's resume function.
343+
340344
let param_env = tcx.param_env(def_id);
341345
let gen = self_arg();
342346

src/librustc_mir/util/elaborate_drops.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,9 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D>
752752
fn open_drop<'a>(&mut self) -> BasicBlock {
753753
let ty = self.lvalue_ty(self.lvalue);
754754
match ty.sty {
755+
// Note that `elaborate_drops` only drops the upvars of a generator,
756+
// and this is ok because `open_drop` here can only be reached
757+
// within that own generator's resume function.
755758
ty::TyClosure(def_id, substs) |
756759
ty::TyGenerator(def_id, substs, _) => {
757760
let tys : Vec<_> = substs.upvar_tys(def_id, self.tcx()).collect();

0 commit comments

Comments
 (0)