mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-14 08:43:10 +00:00
Add some suggested comments around drops
This commit is contained in:
parent
ed5bc60d4e
commit
1917ffe314
@ -331,12 +331,16 @@ fn insert_entry_point<'tcx>(mir: &mut Mir<'tcx>,
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn elaborate_generator_drops<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
fn elaborate_generator_drops<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
def_id: DefId,
|
def_id: DefId,
|
||||||
mir: &mut Mir<'tcx>) {
|
mir: &mut Mir<'tcx>) {
|
||||||
use util::elaborate_drops::{elaborate_drop, Unwind};
|
use util::elaborate_drops::{elaborate_drop, Unwind};
|
||||||
use util::patch::MirPatch;
|
use util::patch::MirPatch;
|
||||||
use shim::DropShimElaborator;
|
use shim::DropShimElaborator;
|
||||||
|
|
||||||
|
// Note that `elaborate_drops` only drops the upvars of a generator, and
|
||||||
|
// this is ok because `open_drop` can only be reached within that own
|
||||||
|
// generator's resume function.
|
||||||
|
|
||||||
let param_env = tcx.param_env(def_id);
|
let param_env = tcx.param_env(def_id);
|
||||||
let gen = self_arg();
|
let gen = self_arg();
|
||||||
|
|
||||||
|
@ -752,6 +752,9 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D>
|
|||||||
fn open_drop<'a>(&mut self) -> BasicBlock {
|
fn open_drop<'a>(&mut self) -> BasicBlock {
|
||||||
let ty = self.lvalue_ty(self.lvalue);
|
let ty = self.lvalue_ty(self.lvalue);
|
||||||
match ty.sty {
|
match ty.sty {
|
||||||
|
// Note that `elaborate_drops` only drops the upvars of a generator,
|
||||||
|
// and this is ok because `open_drop` here can only be reached
|
||||||
|
// within that own generator's resume function.
|
||||||
ty::TyClosure(def_id, substs) |
|
ty::TyClosure(def_id, substs) |
|
||||||
ty::TyGenerator(def_id, substs, _) => {
|
ty::TyGenerator(def_id, substs, _) => {
|
||||||
let tys : Vec<_> = substs.upvar_tys(def_id, self.tcx()).collect();
|
let tys : Vec<_> = substs.upvar_tys(def_id, self.tcx()).collect();
|
||||||
|
Loading…
Reference in New Issue
Block a user