Remove ToPredicate impls that use Binder::dummy

This commit is contained in:
jackh726 2021-09-15 20:54:50 -04:00
parent 2c7bc5e33c
commit be76bdf905
27 changed files with 99 additions and 85 deletions

View file

@ -135,7 +135,7 @@ impl<'a, 'tcx> Autoderef<'a, 'tcx> {
let obligation = traits::Obligation::new(
cause.clone(),
self.param_env,
trait_ref.without_const().to_predicate(tcx),
ty::Binder::dummy(trait_ref).without_const().to_predicate(tcx),
);
if !self.infcx.predicate_may_hold(&obligation) {
debug!("overloaded_deref_ty: cannot match obligation");

View file

@ -120,7 +120,7 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'cx, 'tcx> {
cause: traits::ObligationCause::dummy(),
param_env,
recursion_depth: 0,
predicate: trait_ref.without_const().to_predicate(self.tcx),
predicate: ty::Binder::dummy(trait_ref).without_const().to_predicate(self.tcx),
};
self.evaluate_obligation(&obligation).unwrap_or(traits::EvaluationResult::EvaluatedToErr)
}

View file

@ -724,7 +724,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
let new_obligation = Obligation::new(
ObligationCause::dummy(),
param_env,
new_trait_ref.without_const().to_predicate(self.tcx),
ty::Binder::dummy(new_trait_ref).without_const().to_predicate(self.tcx),
);
if self.predicate_must_hold_modulo_regions(&new_obligation) {

View file

@ -405,7 +405,8 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
| ty::PredicateKind::Coerce(_)
| ty::PredicateKind::ConstEvaluatable(..)
| ty::PredicateKind::ConstEquate(..) => {
let pred = infcx.replace_bound_vars_with_placeholders(binder);
let pred =
ty::Binder::dummy(infcx.replace_bound_vars_with_placeholders(binder));
ProcessResult::Changed(mk_pending(vec![
obligation.with(pred.to_predicate(self.selcx.tcx())),
]))

View file

@ -139,7 +139,8 @@ pub fn type_known_to_meet_bound_modulo_regions<'a, 'tcx>(
infcx.tcx.def_path_str(def_id)
);
let trait_ref = ty::TraitRef { def_id, substs: infcx.tcx.mk_substs_trait(ty, &[]) };
let trait_ref =
ty::Binder::dummy(ty::TraitRef { def_id, substs: infcx.tcx.mk_substs_trait(ty, &[]) });
let obligation = Obligation {
param_env,
cause: ObligationCause::misc(span, hir::CRATE_HIR_ID),

View file

@ -671,10 +671,10 @@ fn receiver_is_dispatchable<'tcx>(
let param_env = tcx.param_env(method.def_id);
// Self: Unsize<U>
let unsize_predicate = ty::TraitRef {
let unsize_predicate = ty::Binder::dummy(ty::TraitRef {
def_id: unsize_did,
substs: tcx.mk_substs_trait(tcx.types.self_param, &[unsized_self_ty.into()]),
}
})
.without_const()
.to_predicate(tcx);
@ -689,7 +689,9 @@ fn receiver_is_dispatchable<'tcx>(
}
});
ty::TraitRef { def_id: unsize_did, substs }.without_const().to_predicate(tcx)
ty::Binder::dummy(ty::TraitRef { def_id: unsize_did, substs })
.without_const()
.to_predicate(tcx)
};
let caller_bounds: Vec<Predicate<'tcx>> = param_env
@ -703,10 +705,10 @@ fn receiver_is_dispatchable<'tcx>(
// Receiver: DispatchFromDyn<Receiver[Self => U]>
let obligation = {
let predicate = ty::TraitRef {
let predicate = ty::Binder::dummy(ty::TraitRef {
def_id: dispatch_from_dyn_did,
substs: tcx.mk_substs_trait(receiver_ty, &[unsized_receiver_ty.into()]),
}
})
.without_const()
.to_predicate(tcx);

View file

@ -646,7 +646,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
obligations.push(Obligation::new(
obligation.cause.clone(),
obligation.param_env,
ty::PredicateKind::ClosureKind(closure_def_id, substs, kind)
ty::Binder::dummy(ty::PredicateKind::ClosureKind(closure_def_id, substs, kind))
.to_predicate(self.tcx()),
));
}
@ -898,10 +898,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
);
// We can only make objects from sized types.
let tr = ty::TraitRef::new(
let tr = ty::Binder::dummy(ty::TraitRef::new(
tcx.require_lang_item(LangItem::Sized, None),
tcx.mk_substs_trait(source, &[]),
);
));
nested.push(predicate_to_obligation(tr.without_const().to_predicate(tcx)));
// If the type is `Foo + 'a`, ensure that the type

View file

@ -248,7 +248,7 @@ pub fn predicate_for_trait_ref<'tcx>(
cause,
param_env,
recursion_depth,
predicate: trait_ref.without_const().to_predicate(tcx),
predicate: ty::Binder::dummy(trait_ref).without_const().to_predicate(tcx),
}
}

View file

@ -349,7 +349,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
new_cause,
depth,
param_env,
ty::PredicateKind::WellFormed(arg).to_predicate(tcx),
ty::Binder::dummy(ty::PredicateKind::WellFormed(arg)).to_predicate(tcx),
)
}),
);
@ -399,7 +399,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
cause.clone(),
depth,
param_env,
ty::PredicateKind::WellFormed(arg).to_predicate(tcx),
ty::Binder::dummy(ty::PredicateKind::WellFormed(arg)).to_predicate(tcx),
)
}),
);
@ -416,7 +416,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
cause,
self.recursion_depth,
self.param_env,
trait_ref.without_const().to_predicate(self.infcx.tcx),
ty::Binder::dummy(trait_ref).without_const().to_predicate(self.infcx.tcx),
));
}
}
@ -443,9 +443,9 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
let obligations = self.nominal_obligations(uv.def.did, substs);
self.out.extend(obligations);
let predicate = ty::PredicateKind::ConstEvaluatable(
let predicate = ty::Binder::dummy(ty::PredicateKind::ConstEvaluatable(
ty::Unevaluated::new(uv.def, substs),
)
))
.to_predicate(self.tcx());
let cause = self.cause(traits::MiscObligation);
self.out.push(traits::Obligation::with_depth(
@ -469,8 +469,10 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
cause,
self.recursion_depth,
self.param_env,
ty::PredicateKind::WellFormed(resolved_constant.into())
.to_predicate(self.tcx()),
ty::Binder::dummy(ty::PredicateKind::WellFormed(
resolved_constant.into(),
))
.to_predicate(self.tcx()),
));
}
}
@ -556,8 +558,10 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
cause,
depth,
param_env,
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(rty, r))
.to_predicate(self.tcx()),
ty::Binder::dummy(ty::PredicateKind::TypeOutlives(
ty::OutlivesPredicate(rty, r),
))
.to_predicate(self.tcx()),
));
}
}
@ -646,7 +650,8 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
cause.clone(),
depth,
param_env,
ty::PredicateKind::ObjectSafe(did).to_predicate(tcx),
ty::Binder::dummy(ty::PredicateKind::ObjectSafe(did))
.to_predicate(tcx),
)
}));
}
@ -673,7 +678,8 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
cause,
self.recursion_depth,
param_env,
ty::PredicateKind::WellFormed(ty.into()).to_predicate(self.tcx()),
ty::Binder::dummy(ty::PredicateKind::WellFormed(ty.into()))
.to_predicate(self.tcx()),
));
} else {
// Yes, resolved, proceed with the result.