diff options
| author | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2017-08-11 07:35:01 +0200 |
|---|---|---|
| committer | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2017-08-11 07:35:01 +0200 |
| commit | 6601ab9b1b569f81df9afa199de77cc205132e0e (patch) | |
| tree | c2d3e266df575e1f09340a043de5da4600d87e59 | |
| parent | be9c64b0c78401358a93b66e357d3bb094ba6274 (diff) | |
Remove allocations
| -rw-r--r-- | src/librustc/ty/sty.rs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index 9898ce5d73d..2a310e1d5df 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -270,22 +270,20 @@ impl<'a, 'gcx, 'tcx> ClosureSubsts<'tcx> { /// It is calculated in rustc_mir::transform::generator::StateTransform. /// All the types here must be in the tuple in GeneratorInterior. pub fn state_tys(self, def_id: DefId, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> - impl Iterator<Item=Ty<'tcx>> + 'tcx + impl Iterator<Item=Ty<'tcx>> + 'a { let state = tcx.generator_layout(def_id).fields.iter(); - let state: Vec<_> = state.map(|d| d.ty.subst(tcx, self.substs)).collect(); - state.into_iter() + state.map(move |d| d.ty.subst(tcx, self.substs)) } /// This is the types of all the fields stored in a generator. /// It includes the upvars, state types and the state discriminant which is u32. pub fn field_tys(self, def_id: DefId, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> - impl Iterator<Item=Ty<'tcx>> + 'tcx + impl Iterator<Item=Ty<'tcx>> + 'a { let upvars = self.upvar_tys(def_id, tcx); let state = self.state_tys(def_id, tcx); - let tys: Vec<_> = upvars.chain(iter::once(tcx.types.u32)).chain(state).collect(); - tys.into_iter() + upvars.chain(iter::once(tcx.types.u32)).chain(state) } } |
