diff --git a/src/librustc/middle/subst.rs b/src/librustc/middle/subst.rs index 5e7284dbfd1de..b9b427a9691b5 100644 --- a/src/librustc/middle/subst.rs +++ b/src/librustc/middle/subst.rs @@ -271,6 +271,12 @@ impl VecPerParamSpace { } } + pub fn shrink_to_fit(&mut self) { + self.vecs.mut0().shrink_to_fit(); + self.vecs.mut1().shrink_to_fit(); + self.vecs.mut2().shrink_to_fit(); + } + pub fn params_from_type(types: Vec) -> VecPerParamSpace { VecPerParamSpace::empty().with_vec(TypeSpace, types) } diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index e3d94c73bb4e9..c59c2913ad5ac 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -4615,6 +4615,7 @@ pub fn construct_parameter_environment( push_types_from_defs(tcx, &mut types, space, generics.types.get_vec(space)); } + types.shrink_to_fit(); // map bound 'a => free 'a let mut regions = VecPerParamSpace::empty(); @@ -4622,6 +4623,7 @@ pub fn construct_parameter_environment( push_region_params(&mut regions, space, free_id, generics.regions.get_vec(space)); } + regions.shrink_to_fit(); let free_substs = Substs { types: types, @@ -4637,6 +4639,7 @@ pub fn construct_parameter_environment( push_bounds_from_defs(tcx, &mut bounds, space, &free_substs, generics.types.get_vec(space)); } + bounds.shrink_to_fit(); debug!("construct_parameter_environment: free_id={} \ free_subst={} \