diff --git a/src/librustc/middle/traits/object_safety.rs b/src/librustc/middle/traits/object_safety.rs index c0399112c33..3c1c387ed26 100644 --- a/src/librustc/middle/traits/object_safety.rs +++ b/src/librustc/middle/traits/object_safety.rs @@ -126,7 +126,7 @@ fn trait_has_sized_self<'tcx>(tcx: &ty::ctxt<'tcx>, let param_env = ty::construct_parameter_environment(tcx, &trait_def.generics, ast::DUMMY_NODE_ID); - let predicates = param_env.caller_bounds.predicates.as_slice().to_vec(); + let predicates = param_env.caller_bounds.clone(); let sized_def_id = match tcx.lang_items.sized_trait() { Some(def_id) => def_id, None => { return false; /* No Sized trait, can't require it! */ } diff --git a/src/librustc/middle/traits/project.rs b/src/librustc/middle/traits/project.rs index c179153dbde..4fd58a63897 100644 --- a/src/librustc/middle/traits/project.rs +++ b/src/librustc/middle/traits/project.rs @@ -440,8 +440,7 @@ fn assemble_candidates_from_param_env<'cx,'tcx>( obligation_trait_ref: &Rc>, candidate_set: &mut ProjectionTyCandidateSet<'tcx>) { - let env_predicates = selcx.param_env().caller_bounds.predicates.clone(); - let env_predicates = env_predicates.iter().cloned().collect(); + let env_predicates = selcx.param_env().caller_bounds.clone(); assemble_candidates_from_predicates(selcx, obligation, obligation_trait_ref, candidate_set, env_predicates); } diff --git a/src/librustc/middle/traits/select.rs b/src/librustc/middle/traits/select.rs index b18cb86a2f4..272eaad09c9 100644 --- a/src/librustc/middle/traits/select.rs +++ b/src/librustc/middle/traits/select.rs @@ -951,7 +951,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { stack.obligation.repr(self.tcx())); let caller_trait_refs: Vec<_> = - self.param_env().caller_bounds.predicates.iter() + self.param_env().caller_bounds.iter() .filter_map(|o| o.to_opt_poly_trait_ref()) .collect(); diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 86cf030c828..fc7e13528e5 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -2100,7 +2100,7 @@ pub struct ParameterEnvironment<'a, 'tcx:'a> { /// Obligations that the caller must satisfy. This is basically /// the set of bounds on the in-scope type parameters, translated /// into Obligations. - pub caller_bounds: ty::GenericBounds<'tcx>, + pub caller_bounds: Vec>, /// Caches the results of trait selection. This cache is used /// for things that have to do with the parameters in scope. @@ -6258,7 +6258,7 @@ impl Variance { pub fn empty_parameter_environment<'a,'tcx>(cx: &'a ctxt<'tcx>) -> ParameterEnvironment<'a,'tcx> { ty::ParameterEnvironment { tcx: cx, free_substs: Substs::empty(), - caller_bounds: GenericBounds::empty(), + caller_bounds: Vec::new(), implicit_region_bound: ty::ReEmpty, selection_cache: traits::SelectionCache::new(), } } @@ -6296,6 +6296,7 @@ pub fn construct_parameter_environment<'a,'tcx>( let bounds = generics.to_bounds(tcx, &free_substs); let bounds = liberate_late_bound_regions(tcx, free_id_scope, &ty::Binder(bounds)); + let predicates = bounds.predicates.into_vec(); // // Compute region bounds. For now, these relations are stored in a @@ -6303,18 +6304,18 @@ pub fn construct_parameter_environment<'a,'tcx>( // crazy about this scheme, but it's convenient, at least. // - record_region_bounds(tcx, &bounds); + record_region_bounds(tcx, &*predicates); - debug!("construct_parameter_environment: free_id={:?} free_subst={:?} bounds={:?}", + debug!("construct_parameter_environment: free_id={:?} free_subst={:?} predicates={:?}", free_id, free_substs.repr(tcx), - bounds.repr(tcx)); + predicates.repr(tcx)); return ty::ParameterEnvironment { tcx: tcx, free_substs: free_substs, implicit_region_bound: ty::ReScope(free_id_scope), - caller_bounds: bounds, + caller_bounds: predicates, selection_cache: traits::SelectionCache::new(), }; @@ -6338,10 +6339,10 @@ pub fn construct_parameter_environment<'a,'tcx>( } } - fn record_region_bounds<'tcx>(tcx: &ty::ctxt<'tcx>, bounds: &GenericBounds<'tcx>) { - debug!("record_region_bounds(bounds={:?})", bounds.repr(tcx)); + fn record_region_bounds<'tcx>(tcx: &ty::ctxt<'tcx>, predicates: &[ty::Predicate<'tcx>]) { + debug!("record_region_bounds(predicates={:?})", predicates.repr(tcx)); - for predicate in bounds.predicates.iter() { + for predicate in predicates.iter() { match *predicate { Predicate::Projection(..) | Predicate::Trait(..) | diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index e3e5d67869f..a119359be11 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -245,7 +245,7 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>, let mut trait_param_env = impl_param_env.clone(); // The key step here is to update the caller_bounds's predicates to be // the new hybrid bounds we computed. - trait_param_env.caller_bounds.predicates = hybrid_preds; + trait_param_env.caller_bounds = hybrid_preds.into_vec(); debug!("compare_impl_method: trait_bounds={}", trait_param_env.caller_bounds.repr(tcx)); diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index 4c5a8144cbd..f58912944a0 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -343,7 +343,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { // FIXME -- Do we want to commit to this behavior for param bounds? let bounds: Vec<_> = - self.fcx.inh.param_env.caller_bounds.predicates + self.fcx.inh.param_env.caller_bounds .iter() .filter_map(|predicate| { match *predicate { @@ -697,8 +697,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { debug!("assemble_where_clause_candidates(trait_def_id={})", trait_def_id.repr(self.tcx())); - let caller_predicates = - self.fcx.inh.param_env.caller_bounds.predicates.as_slice().to_vec(); + let caller_predicates = self.fcx.inh.param_env.caller_bounds.clone(); for poly_bound in traits::elaborate_predicates(self.tcx(), caller_predicates) .filter_map(|p| p.to_opt_poly_trait_ref()) .filter(|b| b.def_id() == trait_def_id) diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index f2a3d660925..b039f3ab8e4 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -1482,7 +1482,7 @@ fn generic_must_outlive<'a, 'tcx>(rcx: &Rcx<'a, 'tcx>, let mut param_bounds = ty::required_region_bounds(rcx.tcx(), generic.to_ty(rcx.tcx()), - param_env.caller_bounds.predicates.as_slice().to_vec()); + param_env.caller_bounds.clone()); // In the case of a projection T::Foo, we may be able to extract bounds from the trait def: match *generic {