.emit();
return;
}
- match obligation.predicate.kind() {
- ty::PredicateKind::Trait(ref trait_predicate, _) => {
- let trait_predicate = self.resolve_vars_if_possible(trait_predicate);
+
+ match obligation.predicate.skip_binders() {
+ ty::PredicateAtom::Trait(trait_predicate, _) => {
+ let trait_predicate = ty::Binder::bind(trait_predicate);
+ let trait_predicate = self.resolve_vars_if_possible(&trait_predicate);
if self.tcx.sess.has_errors() && trait_predicate.references_error() {
return;
);
trait_pred
});
- let unit_obligation = Obligation {
- predicate: ty::PredicateKind::Trait(
- predicate,
- hir::Constness::NotConst,
- )
- .to_predicate(self.tcx),
- ..obligation.clone()
- };
+ let unit_obligation =
+ obligation.with(predicate.without_const().to_predicate(tcx));
if self.predicate_may_hold(&unit_obligation) {
err.note(
"the trait is implemented for `()`. \
err
}
- ty::PredicateKind::Subtype(ref predicate) => {
+ ty::PredicateAtom::Subtype(predicate) => {
// Errors for Subtype predicates show up as
// `FulfillmentErrorCode::CodeSubtypeError`,
// not selection error.
span_bug!(span, "subtype requirement gave wrong error: `{:?}`", predicate)
}
- ty::PredicateKind::RegionOutlives(ref predicate) => {
- let predicate = self.resolve_vars_if_possible(predicate);
+ ty::PredicateAtom::RegionOutlives(predicate) => {
+ let predicate = ty::Binder::bind(predicate);
+ let predicate = self.resolve_vars_if_possible(&predicate);
let err = self
.region_outlives_predicate(&obligation.cause, predicate)
.err()
)
}
- ty::PredicateKind::Projection(..) | ty::PredicateKind::TypeOutlives(..) => {
+ ty::PredicateAtom::Projection(..) | ty::PredicateAtom::TypeOutlives(..) => {
let predicate = self.resolve_vars_if_possible(&obligation.predicate);
struct_span_err!(
self.tcx.sess,
)
}
- &ty::PredicateKind::ObjectSafe(trait_def_id) => {
+ ty::PredicateAtom::ObjectSafe(trait_def_id) => {
let violations = self.tcx.object_safety_violations(trait_def_id);
report_object_safety_error(self.tcx, span, trait_def_id, violations)
}
- &ty::PredicateKind::ClosureKind(closure_def_id, closure_substs, kind) => {
+ ty::PredicateAtom::ClosureKind(closure_def_id, closure_substs, kind) => {
let found_kind = self.closure_kind(closure_substs).unwrap();
let closure_span =
self.tcx.sess.source_map().guess_head_span(
return;
}
- ty::PredicateKind::WellFormed(ty) => {
+ ty::PredicateAtom::WellFormed(ty) => {
if !self.tcx.sess.opts.debugging_opts.chalk {
// WF predicates cannot themselves make
// errors. They can only block due to
}
}
- ty::PredicateKind::ConstEvaluatable(..) => {
+ ty::PredicateAtom::ConstEvaluatable(..) => {
// Errors for `ConstEvaluatable` predicates show up as
// `SelectionError::ConstEvalFailure`,
// not `Unimplemented`.
)
}
- ty::PredicateKind::ConstEquate(..) => {
+ ty::PredicateAtom::ConstEquate(..) => {
// Errors for `ConstEquate` predicates show up as
// `SelectionError::ConstEvalFailure`,
// not `Unimplemented`.
return true;
}
- let (cond, error) = match (cond.kind(), error.kind()) {
- (ty::PredicateKind::Trait(..), ty::PredicateKind::Trait(error, _)) => (cond, error),
+ // FIXME: It should be possible to deal with `ForAll` in a cleaner way.
+ let (cond, error) = match (cond.skip_binders(), error.skip_binders()) {
+ (ty::PredicateAtom::Trait(..), ty::PredicateAtom::Trait(error, _)) => {
+ (cond, ty::Binder::bind(error))
+ }
_ => {
// FIXME: make this work in other cases too.
return false;
};
for obligation in super::elaborate_predicates(self.tcx, std::iter::once(cond)) {
- if let ty::PredicateKind::Trait(implication, _) = obligation.predicate.kind() {
+ if let ty::PredicateAtom::Trait(implication, _) = obligation.predicate.skip_binders() {
let error = error.to_poly_trait_ref();
- let implication = implication.to_poly_trait_ref();
+ let implication = ty::Binder::bind(implication).to_poly_trait_ref();
// FIXME: I'm just not taking associated types at all here.
// Eventually I'll need to implement param-env-aware
// `Γ₁ ⊦ φ₁ => Γ₂ ⊦ φ₂` logic.
//
// this can fail if the problem was higher-ranked, in which
// cause I have no idea for a good error message.
- if let ty::PredicateKind::Projection(ref data) = predicate.kind() {
+ if let ty::PredicateAtom::Projection(data) = predicate.skip_binders() {
let mut selcx = SelectionContext::new(self);
let (data, _) = self.replace_bound_vars_with_fresh_vars(
obligation.cause.span,
infer::LateBoundRegionConversionTime::HigherRankedType,
- data,
+ &ty::Binder::bind(data),
);
let mut obligations = vec![];
let normalized_ty = super::normalize_projection_type(
return;
}
- let mut err = match predicate.kind() {
- ty::PredicateKind::Trait(ref data, _) => {
- let trait_ref = data.to_poly_trait_ref();
+ let mut err = match predicate.skip_binders() {
+ ty::PredicateAtom::Trait(data, _) => {
+ let trait_ref = ty::Binder::bind(data.trait_ref);
let self_ty = trait_ref.skip_binder().self_ty();
debug!("self_ty {:?} {:?} trait_ref {:?}", self_ty, self_ty.kind, trait_ref);
err
}
- ty::PredicateKind::WellFormed(arg) => {
+ ty::PredicateAtom::WellFormed(arg) => {
// Same hacky approach as above to avoid deluging user
// with error messages.
if arg.references_error() || self.tcx.sess.has_errors() {
}
}
- ty::PredicateKind::Subtype(ref data) => {
+ ty::PredicateAtom::Subtype(data) => {
if data.references_error() || self.tcx.sess.has_errors() {
// no need to overload user in such cases
return;
}
- let SubtypePredicate { a_is_expected: _, a, b } = data.skip_binder();
+ let SubtypePredicate { a_is_expected: _, a, b } = data;
// both must be type variables, or the other would've been instantiated
assert!(a.is_ty_var() && b.is_ty_var());
self.need_type_info_err(body_id, span, a, ErrorCode::E0282)
}
- ty::PredicateKind::Projection(ref data) => {
- let trait_ref = data.to_poly_trait_ref(self.tcx);
+ ty::PredicateAtom::Projection(data) => {
+ let trait_ref = ty::Binder::bind(data).to_poly_trait_ref(self.tcx);
let self_ty = trait_ref.skip_binder().self_ty();
- let ty = data.skip_binder().ty;
+ let ty = data.ty;
if predicate.references_error() {
return;
}
obligation: &PredicateObligation<'tcx>,
) {
let (pred, item_def_id, span) =
- match (obligation.predicate.kind(), &obligation.cause.code.peel_derives()) {
+ match (obligation.predicate.skip_binders(), obligation.cause.code.peel_derives()) {
(
- ty::PredicateKind::Trait(pred, _),
- ObligationCauseCode::BindingObligation(item_def_id, span),
+ ty::PredicateAtom::Trait(pred, _),
+ &ObligationCauseCode::BindingObligation(item_def_id, span),
) => (pred, item_def_id, span),
_ => return,
};
let node = match (
- self.tcx.hir().get_if_local(*item_def_id),
+ self.tcx.hir().get_if_local(item_def_id),
Some(pred.def_id()) == self.tcx.lang_items().sized_trait(),
) {
(Some(node), true) => node,
None => return,
};
for param in generics.params {
- if param.span != *span
+ if param.span != span
|| param.bounds.iter().any(|bound| {
bound.trait_ref().and_then(|trait_ref| trait_ref.trait_def_id())
== self.tcx.lang_items().sized_trait()