diff options
| author | Jonas Schievink <jonasschievink@gmail.com> | 2020-03-15 00:24:47 +0100 |
|---|---|---|
| committer | Jonas Schievink <jonasschievink@gmail.com> | 2020-04-17 20:30:23 +0200 |
| commit | 50c1c295ee730fa5fbc3baf4b57ceceedfbb20f2 (patch) | |
| tree | 8132c323617e2e846f392d1779fc215929fa9ab0 /src/librustc_ty | |
| parent | 8d67f576b56e8fc98a31123e5963f8d00e40611c (diff) | |
Make `needs_drop` less pessimistic on generators
Diffstat (limited to 'src/librustc_ty')
| -rw-r--r-- | src/librustc_ty/needs_drop.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/librustc_ty/needs_drop.rs b/src/librustc_ty/needs_drop.rs index 6b0104e164b..515cf6f2911 100644 --- a/src/librustc_ty/needs_drop.rs +++ b/src/librustc_ty/needs_drop.rs @@ -99,6 +99,23 @@ where } } + ty::Generator(def_id, substs, _) => { + let substs = substs.as_generator(); + for upvar_ty in substs.upvar_tys(def_id, tcx) { + queue_type(self, upvar_ty); + } + + let witness = substs.witness(def_id, tcx); + let interior_tys = match &witness.kind { + ty::GeneratorWitness(tys) => tcx.erase_late_bound_regions(tys), + _ => bug!(), + }; + + for interior_ty in interior_tys { + queue_type(self, interior_ty); + } + } + // Check for a `Drop` impl and whether this is a union or // `ManuallyDrop`. If it's a struct or enum without a `Drop` // impl then check whether the field types need `Drop`. |
