self.infcx.tcx
}
- pub fn param_env(&self) -> &'cx ty::ParameterEnvironment<'gcx> {
+ pub fn param_env(&self) -> ty::ParamEnv<'gcx> {
self.infcx.param_env()
}
}
pub fn projection_mode(&self) -> Reveal {
- self.infcx.projection_mode()
+ self.param_env().reveal
}
/// Wraps the inference context's in_snapshot s.t. snapshot handling is only from the selection
fn filter_negative_impls(&self, candidate: SelectionCandidate<'tcx>)
-> SelectionResult<'tcx, SelectionCandidate<'tcx>> {
if let ImplCandidate(def_id) = candidate {
- if self.tcx().trait_impl_polarity(def_id) == hir::ImplPolarity::Negative {
+ if self.tcx().impl_polarity(def_id) == hir::ImplPolarity::Negative {
return Err(Unimplemented)
}
}
debug!("Retaining candidate #{}/{}: {:?}",
i, candidates.len(), candidates[i]);
i += 1;
+
+ // If there are *STILL* multiple candidates, give up
+ // and report ambiguity.
+ if i > 1 {
+ debug!("multiple matches, ambig");
+ return Ok(None);
+ }
}
}
}
- // If there are *STILL* multiple candidates, give up and
- // report ambiguity.
- if candidates.len() > 1 {
- debug!("multiple matches, ambig");
- return Ok(None);
- }
-
// If there are *NO* candidates, then there are no impls --
// that we know of, anyway. Note that in the case where there
// are unbound type variables within the obligation, it might
def_id={:?}, substs={:?}",
def_id, substs);
- let item_predicates = self.tcx().item_predicates(def_id);
- let bounds = item_predicates.instantiate(self.tcx(), substs);
+ let predicates_of = self.tcx().predicates_of(def_id);
+ let bounds = predicates_of.instantiate(self.tcx(), substs);
debug!("match_projection_obligation_against_definition_bounds: \
bounds={:?}",
bounds);
.iter()
.filter_map(|o| o.to_opt_poly_trait_ref());
+ // micro-optimization: filter out predicates relating to different
+ // traits.
+ let matching_bounds =
+ all_bounds.filter(|p| p.def_id() == stack.obligation.predicate.def_id());
+
let matching_bounds =
- all_bounds.filter(
+ matching_bounds.filter(
|bound| self.evaluate_where_clause(stack, bound.clone()).may_apply());
let param_candidates =
{
debug!("assemble_candidates_from_impls(obligation={:?})", obligation);
- let def = self.tcx().lookup_trait_def(obligation.predicate.def_id());
+ let def = self.tcx().trait_def(obligation.predicate.def_id());
def.for_each_relevant_impl(
self.tcx(),
ty::TyAdt(def, substs) => {
let sized_crit = def.sized_constraint(self.tcx());
// (*) binder moved here
- Where(ty::Binder(match sized_crit.sty {
- ty::TyTuple(tys, _) => tys.to_vec().subst(self.tcx(), substs),
- ty::TyBool => vec![],
- _ => vec![sized_crit.subst(self.tcx(), substs)]
- }))
+ Where(ty::Binder(
+ sized_crit.iter().map(|ty| ty.subst(self.tcx(), substs)).collect()
+ ))
}
ty::TyProjection(_) | ty::TyParam(_) | ty::TyAnon(..) => None,
// We can resolve the `impl Trait` to its concrete type,
// which enforces a DAG between the functions requiring
// the auto trait bounds in question.
- vec![self.tcx().item_type(def_id).subst(self.tcx(), substs)]
+ vec![self.tcx().type_of(def_id).subst(self.tcx(), substs)]
}
}
}
(&ty::TyAdt(def, substs_a), &ty::TyAdt(_, substs_b)) => {
let fields = def
.all_fields()
- .map(|f| tcx.item_type(f.did))
+ .map(|f| tcx.type_of(f.did))
.collect::<Vec<_>>();
// The last field of the structure has to exist and contain type parameters.
// obligation will normalize to `<$0 as Iterator>::Item = $1` and
// `$1: Copy`, so we must ensure the obligations are emitted in
// that order.
- let predicates = tcx.item_predicates(def_id);
+ let predicates = tcx.predicates_of(def_id);
assert_eq!(predicates.parent, None);
let predicates = predicates.predicates.iter().flat_map(|predicate| {
let predicate = normalize_with_depth(self, cause.clone(), recursion_depth,