Change list of predicates in ParameterEnvironment to a Vec
.
This commit is contained in:
parent
a530cc9706
commit
c73a1d0a2c
7 changed files with 17 additions and 18 deletions
|
@ -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! */ }
|
||||
|
|
|
@ -440,8 +440,7 @@ fn assemble_candidates_from_param_env<'cx,'tcx>(
|
|||
obligation_trait_ref: &Rc<ty::TraitRef<'tcx>>,
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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<ty::Predicate<'tcx>>,
|
||||
|
||||
/// 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(..) |
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue