1
Fork 0

Move WF goal to clause

This commit is contained in:
Michael Goulet 2023-06-15 16:59:01 +00:00
parent a8a29070f0
commit 52d3fc93f2
37 changed files with 81 additions and 64 deletions

View file

@ -319,7 +319,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
ty::PredicateKind::ObjectSafe(trait_def_id) => {
self.compute_object_safe_goal(trait_def_id)
}
ty::PredicateKind::WellFormed(arg) => {
ty::PredicateKind::Clause(ty::Clause::WellFormed(arg)) => {
self.compute_well_formed_goal(Goal { param_env, predicate: arg })
}
ty::PredicateKind::Ambiguous => {

View file

@ -119,7 +119,6 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentCtxt<'tcx> {
)
}
ty::PredicateKind::Clause(_)
| ty::PredicateKind::WellFormed(_)
| ty::PredicateKind::ObjectSafe(_)
| ty::PredicateKind::ClosureKind(_, _, _)
| ty::PredicateKind::ConstEvaluatable(_)

View file

@ -826,7 +826,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
// we start out with a `ParamEnv` with no inference variables,
// and these don't correspond to adding any new bounds to
// the `ParamEnv`.
ty::PredicateKind::WellFormed(..)
ty::PredicateKind::Clause(ty::Clause::WellFormed(..))
| ty::PredicateKind::Clause(ty::Clause::ConstArgHasType(..))
| ty::PredicateKind::AliasRelate(..)
| ty::PredicateKind::ObjectSafe(..)

View file

@ -1048,7 +1048,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
self.report_closure_error(&obligation, closure_def_id, found_kind, kind)
}
ty::PredicateKind::WellFormed(ty) => {
ty::PredicateKind::Clause(ty::Clause::WellFormed(ty)) => {
match self.tcx.sess.opts.unstable_opts.trait_solver {
TraitSolver::Classic => {
// WF predicates cannot themselves make
@ -2415,7 +2415,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
err
}
ty::PredicateKind::WellFormed(arg) => {
ty::PredicateKind::Clause(ty::Clause::WellFormed(arg)) => {
// Same hacky approach as above to avoid deluging user
// with error messages.
if arg.references_error()

View file

@ -354,7 +354,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(_))
| ty::PredicateKind::Clause(ty::Clause::TypeOutlives(_))
| ty::PredicateKind::Clause(ty::Clause::ConstArgHasType(..))
| ty::PredicateKind::WellFormed(_)
| ty::PredicateKind::Clause(ty::Clause::WellFormed(_))
| ty::PredicateKind::ObjectSafe(_)
| ty::PredicateKind::ClosureKind(..)
| ty::PredicateKind::Subtype(_)
@ -433,7 +433,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
}
}
ty::PredicateKind::WellFormed(arg) => {
ty::PredicateKind::Clause(ty::Clause::WellFormed(arg)) => {
match wf::obligations(
self.selcx.infcx,
obligation.param_env,

View file

@ -310,7 +310,7 @@ fn predicate_references_self<'tcx>(
ty::PredicateKind::AliasRelate(..) => bug!("`AliasRelate` not allowed as assumption"),
ty::PredicateKind::WellFormed(..)
ty::PredicateKind::Clause(ty::Clause::WellFormed(..))
| ty::PredicateKind::ObjectSafe(..)
| ty::PredicateKind::Clause(ty::Clause::TypeOutlives(..))
| ty::PredicateKind::Clause(ty::Clause::RegionOutlives(..))
@ -361,7 +361,7 @@ fn generics_require_sized_self(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
| ty::PredicateKind::Subtype(..)
| ty::PredicateKind::Coerce(..)
| ty::PredicateKind::Clause(ty::Clause::RegionOutlives(..))
| ty::PredicateKind::WellFormed(..)
| ty::PredicateKind::Clause(ty::Clause::WellFormed(..))
| ty::PredicateKind::ObjectSafe(..)
| ty::PredicateKind::ClosureKind(..)
| ty::PredicateKind::Clause(ty::Clause::TypeOutlives(..))

View file

@ -67,7 +67,8 @@ fn relate_mir_and_user_ty<'tcx>(
ocx.eq(&cause, param_env, mir_ty, user_ty)?;
// FIXME(#104764): We should check well-formedness before normalization.
let predicate = ty::Binder::dummy(ty::PredicateKind::WellFormed(user_ty.into()));
let predicate =
ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::WellFormed(user_ty.into())));
ocx.register_obligation(Obligation::new(ocx.infcx.tcx, cause, param_env, predicate));
Ok(())
}
@ -119,7 +120,9 @@ fn relate_mir_and_user_substs<'tcx>(
let impl_self_ty = ocx.normalize(&cause, param_env, impl_self_ty);
ocx.eq(&cause, param_env, self_ty, impl_self_ty)?;
let predicate = ty::Binder::dummy(ty::PredicateKind::WellFormed(impl_self_ty.into()));
let predicate = ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::WellFormed(
impl_self_ty.into(),
)));
ocx.register_obligation(Obligation::new(tcx, cause.clone(), param_env, predicate));
}
@ -134,7 +137,7 @@ fn relate_mir_and_user_substs<'tcx>(
// them? This would only be relevant if some input
// type were ill-formed but did not appear in `ty`,
// which...could happen with normalization...
let predicate = ty::Binder::dummy(ty::PredicateKind::WellFormed(ty.into()));
let predicate = ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::WellFormed(ty.into())));
ocx.register_obligation(Obligation::new(tcx, cause, param_env, predicate));
Ok(())
}

View file

@ -137,7 +137,7 @@ pub fn compute_implied_outlives_bounds_inner<'tcx>(
| ty::PredicateKind::TypeWellFormedFromEnv(..) => {}
// We need to search through *all* WellFormed predicates
ty::PredicateKind::WellFormed(arg) => {
ty::PredicateKind::Clause(ty::Clause::WellFormed(arg)) => {
wf_args.push(arg);
}

View file

@ -674,7 +674,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
}
}
ty::PredicateKind::WellFormed(arg) => {
ty::PredicateKind::Clause(ty::Clause::WellFormed(arg)) => {
// So, there is a bit going on here. First, `WellFormed` predicates
// are coinductive, like trait predicates with auto traits.
// This means that we need to detect if we have recursively

View file

@ -160,7 +160,7 @@ pub fn predicate_obligations<'tcx>(
wf.compute(ct.into());
wf.compute(ty.into());
}
ty::PredicateKind::WellFormed(arg) => {
ty::PredicateKind::Clause(ty::Clause::WellFormed(arg)) => {
wf.compute(arg);
}
@ -386,7 +386,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
cause,
depth,
param_env,
ty::Binder::dummy(ty::PredicateKind::WellFormed(arg)),
ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::WellFormed(arg))),
)
}),
);
@ -478,7 +478,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
cause.clone(),
depth,
param_env,
ty::Binder::dummy(ty::PredicateKind::WellFormed(arg)),
ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::WellFormed(arg))),
)
}),
);
@ -541,7 +541,9 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
cause,
self.recursion_depth,
self.param_env,
ty::Binder::dummy(ty::PredicateKind::WellFormed(ct.into())),
ty::Binder::dummy(ty::PredicateKind::Clause(
ty::Clause::WellFormed(ct.into()),
)),
));
}
ty::ConstKind::Expr(_) => {
@ -784,7 +786,9 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
cause,
self.recursion_depth,
param_env,
ty::Binder::dummy(ty::PredicateKind::WellFormed(ty.into())),
ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::WellFormed(
ty.into(),
))),
));
}
}
@ -969,7 +973,7 @@ pub(crate) fn required_region_bounds<'tcx>(
| ty::PredicateKind::Clause(ty::Clause::ConstArgHasType(..))
| ty::PredicateKind::Subtype(..)
| ty::PredicateKind::Coerce(..)
| ty::PredicateKind::WellFormed(..)
| ty::PredicateKind::Clause(ty::Clause::WellFormed(..))
| ty::PredicateKind::ObjectSafe(..)
| ty::PredicateKind::ClosureKind(..)
| ty::PredicateKind::Clause(ty::Clause::RegionOutlives(..))