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

@ -330,7 +330,8 @@ fn check_opaque_type_well_formed<'tcx>(
// Require the hidden type to be well-formed with only the generics of the opaque type. // Require the hidden type to be well-formed with only the generics of the opaque type.
// Defining use functions may have more bounds than the opaque type, which is ok, as long as the // Defining use functions may have more bounds than the opaque type, which is ok, as long as the
// hidden type is well formed even without those bounds. // hidden type is well formed even without those bounds.
let predicate = ty::Binder::dummy(ty::PredicateKind::WellFormed(definition_ty.into())); let predicate =
ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::WellFormed(definition_ty.into())));
ocx.register_obligation(Obligation::misc(tcx, definition_span, def_id, param_env, predicate)); ocx.register_obligation(Obligation::misc(tcx, definition_span, def_id, param_env, predicate));
// Check that all obligations are satisfied by the implementation's // Check that all obligations are satisfied by the implementation's

View file

@ -1419,9 +1419,11 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
// //
// See #91068 for an example. // See #91068 for an example.
self.prove_predicates( self.prove_predicates(
sig.inputs_and_output sig.inputs_and_output.iter().map(|ty| {
.iter() ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::WellFormed(
.map(|ty| ty::Binder::dummy(ty::PredicateKind::WellFormed(ty.into()))), ty.into(),
)))
}),
term_location.to_locations(), term_location.to_locations(),
ConstraintCategory::Boring, ConstraintCategory::Boring,
); );
@ -1850,7 +1852,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
let array_ty = rvalue.ty(body.local_decls(), tcx); let array_ty = rvalue.ty(body.local_decls(), tcx);
self.prove_predicate( self.prove_predicate(
ty::PredicateKind::WellFormed(array_ty.into()), ty::PredicateKind::Clause(ty::Clause::WellFormed(array_ty.into())),
Locations::Single(location), Locations::Single(location),
ConstraintCategory::Boring, ConstraintCategory::Boring,
); );

View file

@ -1527,10 +1527,11 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
ty::Clause::TypeOutlives(_) => { ty::Clause::TypeOutlives(_) => {
// Do nothing, we deal with regions separately // Do nothing, we deal with regions separately
} }
ty::Clause::RegionOutlives(_) | ty::Clause::ConstArgHasType(..) => bug!(), ty::Clause::RegionOutlives(_)
| ty::Clause::ConstArgHasType(..)
| ty::Clause::WellFormed(_) => bug!(),
}, },
ty::PredicateKind::WellFormed(_) ty::PredicateKind::AliasRelate(..)
| ty::PredicateKind::AliasRelate(..)
| ty::PredicateKind::ObjectSafe(_) | ty::PredicateKind::ObjectSafe(_)
| ty::PredicateKind::ClosureKind(_, _, _) | ty::PredicateKind::ClosureKind(_, _, _)
| ty::PredicateKind::Subtype(_) | ty::PredicateKind::Subtype(_)

View file

@ -439,7 +439,8 @@ fn check_opaque_meets_bounds<'tcx>(
// Additionally require the hidden type to be well-formed with only the generics of the opaque type. // Additionally require the hidden type to be well-formed with only the generics of the opaque type.
// Defining use functions may have more bounds than the opaque type, which is ok, as long as the // Defining use functions may have more bounds than the opaque type, which is ok, as long as the
// hidden type is well formed even without those bounds. // hidden type is well formed even without those bounds.
let predicate = ty::Binder::dummy(ty::PredicateKind::WellFormed(hidden_ty.into())); let predicate =
ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::WellFormed(hidden_ty.into())));
ocx.register_obligation(Obligation::new(tcx, misc_cause, param_env, predicate)); ocx.register_obligation(Obligation::new(tcx, misc_cause, param_env, predicate));
// Check that all obligations are satisfied by the implementation's // Check that all obligations are satisfied by the implementation's

View file

@ -321,7 +321,9 @@ fn compare_method_predicate_entailment<'tcx>(
infcx.tcx, infcx.tcx,
ObligationCause::dummy(), ObligationCause::dummy(),
param_env, param_env,
ty::Binder::dummy(ty::PredicateKind::WellFormed(unnormalized_impl_fty.into())), ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::WellFormed(
unnormalized_impl_fty.into(),
))),
)); ));
} }

View file

@ -81,7 +81,7 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
self.tcx(), self.tcx(),
cause, cause,
param_env, param_env,
ty::Binder::dummy(ty::PredicateKind::WellFormed(arg)), ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::WellFormed(arg))),
)); ));
} }
} }
@ -1876,7 +1876,8 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
// We lower empty bounds like `Vec<dyn Copy>:` as // We lower empty bounds like `Vec<dyn Copy>:` as
// `WellFormed(Vec<dyn Copy>)`, which will later get checked by // `WellFormed(Vec<dyn Copy>)`, which will later get checked by
// regular WF checking // regular WF checking
if let ty::PredicateKind::WellFormed(..) = pred.kind().skip_binder() { if let ty::PredicateKind::Clause(ty::Clause::WellFormed(..)) = pred.kind().skip_binder()
{
continue; continue;
} }
// Match the existing behavior. // Match the existing behavior.

View file

@ -219,7 +219,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
} else { } else {
let span = bound_pred.bounded_ty.span; let span = bound_pred.bounded_ty.span;
let predicate = ty::Binder::bind_with_vars( let predicate = ty::Binder::bind_with_vars(
ty::PredicateKind::WellFormed(ty.into()), ty::PredicateKind::Clause(ty::Clause::WellFormed(ty.into())),
bound_vars, bound_vars,
); );
predicates.insert((predicate.to_predicate(tcx), span)); predicates.insert((predicate.to_predicate(tcx), span));

View file

@ -79,7 +79,7 @@ fn diagnostic_hir_wf_check<'tcx>(
self.tcx, self.tcx,
cause, cause,
self.param_env, self.param_env,
ty::PredicateKind::WellFormed(tcx_ty.into()), ty::PredicateKind::Clause(ty::Clause::WellFormed(tcx_ty.into())),
)); ));
for error in ocx.select_all_or_error() { for error in ocx.select_all_or_error() {

View file

@ -542,7 +542,7 @@ fn trait_predicate_kind<'tcx>(
| ty::PredicateKind::Clause(ty::Clause::Projection(_)) | ty::PredicateKind::Clause(ty::Clause::Projection(_))
| ty::PredicateKind::Clause(ty::Clause::ConstArgHasType(..)) | ty::PredicateKind::Clause(ty::Clause::ConstArgHasType(..))
| ty::PredicateKind::AliasRelate(..) | ty::PredicateKind::AliasRelate(..)
| ty::PredicateKind::WellFormed(_) | ty::PredicateKind::Clause(ty::Clause::WellFormed(_))
| ty::PredicateKind::Subtype(_) | ty::PredicateKind::Subtype(_)
| ty::PredicateKind::Coerce(_) | ty::PredicateKind::Coerce(_)
| ty::PredicateKind::ObjectSafe(_) | ty::PredicateKind::ObjectSafe(_)

View file

@ -55,7 +55,7 @@ impl<'tcx> ExplicitPredicatesMap<'tcx> {
ty::PredicateKind::Clause(ty::Clause::Trait(..)) ty::PredicateKind::Clause(ty::Clause::Trait(..))
| ty::PredicateKind::Clause(ty::Clause::Projection(..)) | ty::PredicateKind::Clause(ty::Clause::Projection(..))
| ty::PredicateKind::Clause(ty::Clause::ConstArgHasType(..)) | ty::PredicateKind::Clause(ty::Clause::ConstArgHasType(..))
| ty::PredicateKind::WellFormed(..) | ty::PredicateKind::Clause(ty::Clause::WellFormed(..))
| ty::PredicateKind::AliasRelate(..) | ty::PredicateKind::AliasRelate(..)
| ty::PredicateKind::ObjectSafe(..) | ty::PredicateKind::ObjectSafe(..)
| ty::PredicateKind::ClosureKind(..) | ty::PredicateKind::ClosureKind(..)

View file

@ -483,7 +483,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.tcx, self.tcx,
cause, cause,
self.param_env, self.param_env,
ty::Binder::dummy(ty::PredicateKind::WellFormed(arg)), ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::WellFormed(arg))),
)); ));
} }
@ -668,7 +668,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
| ty::PredicateKind::Coerce(..) | ty::PredicateKind::Coerce(..)
| ty::PredicateKind::Clause(ty::Clause::RegionOutlives(..)) | ty::PredicateKind::Clause(ty::Clause::RegionOutlives(..))
| ty::PredicateKind::Clause(ty::Clause::TypeOutlives(..)) | ty::PredicateKind::Clause(ty::Clause::TypeOutlives(..))
| ty::PredicateKind::WellFormed(..) | ty::PredicateKind::Clause(ty::Clause::WellFormed(..))
| ty::PredicateKind::ObjectSafe(..) | ty::PredicateKind::ObjectSafe(..)
| ty::PredicateKind::AliasRelate(..) | ty::PredicateKind::AliasRelate(..)
| ty::PredicateKind::ConstEvaluatable(..) | ty::PredicateKind::ConstEvaluatable(..)

View file

@ -452,7 +452,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
tcx, tcx,
obligation.cause, obligation.cause,
self.param_env, self.param_env,
ty::Binder::dummy(ty::PredicateKind::WellFormed(method_ty.into())), ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::WellFormed(method_ty.into()))),
)); ));
let callee = MethodCallee { def_id, substs, sig: fn_sig }; let callee = MethodCallee { def_id, substs, sig: fn_sig };

View file

@ -838,7 +838,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
| ty::PredicateKind::Coerce(..) | ty::PredicateKind::Coerce(..)
| ty::PredicateKind::Clause(ty::Clause::Projection(..)) | ty::PredicateKind::Clause(ty::Clause::Projection(..))
| ty::PredicateKind::Clause(ty::Clause::RegionOutlives(..)) | ty::PredicateKind::Clause(ty::Clause::RegionOutlives(..))
| ty::PredicateKind::WellFormed(..) | ty::PredicateKind::Clause(ty::Clause::WellFormed(..))
| ty::PredicateKind::ObjectSafe(..) | ty::PredicateKind::ObjectSafe(..)
| ty::PredicateKind::ClosureKind(..) | ty::PredicateKind::ClosureKind(..)
| ty::PredicateKind::Clause(ty::Clause::TypeOutlives(..)) | ty::PredicateKind::Clause(ty::Clause::TypeOutlives(..))

View file

@ -696,7 +696,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}; };
// Don't point out the span of `WellFormed` predicates. // Don't point out the span of `WellFormed` predicates.
if !matches!(p.kind().skip_binder(), ty::PredicateKind::Clause(_)) { if !matches!(
p.kind().skip_binder(),
ty::PredicateKind::Clause(ty::Clause::Projection(..) | ty::Clause::Trait(..))
) {
continue; continue;
}; };

View file

@ -417,7 +417,7 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
self.tcx(), self.tcx(),
self.trace.cause.clone(), self.trace.cause.clone(),
self.param_env, self.param_env,
ty::Binder::dummy(ty::PredicateKind::WellFormed(b_ty.into())), ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::WellFormed(b_ty.into()))),
)); ));
} }

View file

@ -29,7 +29,7 @@ pub fn explicit_outlives_bounds<'tcx>(
| ty::PredicateKind::AliasRelate(..) | ty::PredicateKind::AliasRelate(..)
| ty::PredicateKind::Coerce(..) | ty::PredicateKind::Coerce(..)
| ty::PredicateKind::Subtype(..) | ty::PredicateKind::Subtype(..)
| ty::PredicateKind::WellFormed(..) | ty::PredicateKind::Clause(ty::Clause::WellFormed(..))
| ty::PredicateKind::ObjectSafe(..) | ty::PredicateKind::ObjectSafe(..)
| ty::PredicateKind::ClosureKind(..) | ty::PredicateKind::ClosureKind(..)
| ty::PredicateKind::Clause(ty::Clause::TypeOutlives(..)) | ty::PredicateKind::Clause(ty::Clause::TypeOutlives(..))

View file

@ -227,7 +227,7 @@ impl<'tcx, O: Elaboratable<'tcx>> Elaborator<'tcx, O> {
debug!(?data, ?obligations, "super_predicates"); debug!(?data, ?obligations, "super_predicates");
self.extend_deduped(obligations); self.extend_deduped(obligations);
} }
ty::PredicateKind::WellFormed(..) => { ty::PredicateKind::Clause(ty::Clause::WellFormed(..)) => {
// Currently, we do not elaborate WF predicates, // Currently, we do not elaborate WF predicates,
// although we easily could. // although we easily could.
} }

View file

@ -1610,7 +1610,7 @@ impl<'tcx> LateLintPass<'tcx> for TrivialConstraints {
Clause(Clause::Projection(..)) | Clause(Clause::Projection(..)) |
AliasRelate(..) | AliasRelate(..) |
// Ignore bounds that a user can't type // Ignore bounds that a user can't type
WellFormed(..) | Clause(Clause::WellFormed(..)) |
ObjectSafe(..) | ObjectSafe(..) |
ClosureKind(..) | ClosureKind(..) |
Subtype(..) | Subtype(..) |

View file

@ -270,7 +270,7 @@ impl FlagComputation {
self.add_alias_ty(projection_ty); self.add_alias_ty(projection_ty);
self.add_term(term); self.add_term(term);
} }
ty::PredicateKind::WellFormed(arg) => { ty::PredicateKind::Clause(ty::Clause::WellFormed(arg)) => {
self.add_substs(slice::from_ref(&arg)); self.add_substs(slice::from_ref(&arg));
} }
ty::PredicateKind::ObjectSafe(_def_id) => {} ty::PredicateKind::ObjectSafe(_def_id) => {}

View file

@ -523,7 +523,7 @@ impl<'tcx> Predicate<'tcx> {
ty::PredicateKind::Clause(ty::Clause::Trait(data)) => { ty::PredicateKind::Clause(ty::Clause::Trait(data)) => {
tcx.trait_is_coinductive(data.def_id()) tcx.trait_is_coinductive(data.def_id())
} }
ty::PredicateKind::WellFormed(_) => true, ty::PredicateKind::Clause(ty::Clause::WellFormed(_)) => true,
_ => false, _ => false,
} }
} }
@ -536,7 +536,7 @@ impl<'tcx> Predicate<'tcx> {
#[inline] #[inline]
pub fn allow_normalization(self) -> bool { pub fn allow_normalization(self) -> bool {
match self.kind().skip_binder() { match self.kind().skip_binder() {
PredicateKind::WellFormed(_) => false, PredicateKind::Clause(Clause::WellFormed(_)) => false,
PredicateKind::Clause(Clause::Trait(_)) PredicateKind::Clause(Clause::Trait(_))
| PredicateKind::Clause(Clause::RegionOutlives(_)) | PredicateKind::Clause(Clause::RegionOutlives(_))
| PredicateKind::Clause(Clause::TypeOutlives(_)) | PredicateKind::Clause(Clause::TypeOutlives(_))
@ -584,6 +584,9 @@ pub enum Clause<'tcx> {
/// Ensures that a const generic argument to a parameter `const N: u8` /// Ensures that a const generic argument to a parameter `const N: u8`
/// is of type `u8`. /// is of type `u8`.
ConstArgHasType(Const<'tcx>, Ty<'tcx>), ConstArgHasType(Const<'tcx>, Ty<'tcx>),
/// No syntax: `T` well-formed.
WellFormed(GenericArg<'tcx>),
} }
impl<'tcx> Binder<'tcx, Clause<'tcx>> { impl<'tcx> Binder<'tcx, Clause<'tcx>> {
@ -610,9 +613,6 @@ pub enum PredicateKind<'tcx> {
/// Prove a clause /// Prove a clause
Clause(Clause<'tcx>), Clause(Clause<'tcx>),
/// No syntax: `T` well-formed.
WellFormed(GenericArg<'tcx>),
/// Trait must be object-safe. /// Trait must be object-safe.
ObjectSafe(DefId), ObjectSafe(DefId),
@ -1324,7 +1324,7 @@ impl<'tcx> Predicate<'tcx> {
| PredicateKind::Subtype(..) | PredicateKind::Subtype(..)
| PredicateKind::Coerce(..) | PredicateKind::Coerce(..)
| PredicateKind::Clause(Clause::RegionOutlives(..)) | PredicateKind::Clause(Clause::RegionOutlives(..))
| PredicateKind::WellFormed(..) | PredicateKind::Clause(Clause::WellFormed(..))
| PredicateKind::ObjectSafe(..) | PredicateKind::ObjectSafe(..)
| PredicateKind::ClosureKind(..) | PredicateKind::ClosureKind(..)
| PredicateKind::Clause(Clause::TypeOutlives(..)) | PredicateKind::Clause(Clause::TypeOutlives(..))
@ -1345,7 +1345,7 @@ impl<'tcx> Predicate<'tcx> {
| PredicateKind::Subtype(..) | PredicateKind::Subtype(..)
| PredicateKind::Coerce(..) | PredicateKind::Coerce(..)
| PredicateKind::Clause(Clause::RegionOutlives(..)) | PredicateKind::Clause(Clause::RegionOutlives(..))
| PredicateKind::WellFormed(..) | PredicateKind::Clause(Clause::WellFormed(..))
| PredicateKind::ObjectSafe(..) | PredicateKind::ObjectSafe(..)
| PredicateKind::ClosureKind(..) | PredicateKind::ClosureKind(..)
| PredicateKind::Clause(Clause::TypeOutlives(..)) | PredicateKind::Clause(Clause::TypeOutlives(..))
@ -1367,7 +1367,7 @@ impl<'tcx> Predicate<'tcx> {
| PredicateKind::Subtype(..) | PredicateKind::Subtype(..)
| PredicateKind::Coerce(..) | PredicateKind::Coerce(..)
| PredicateKind::Clause(Clause::RegionOutlives(..)) | PredicateKind::Clause(Clause::RegionOutlives(..))
| PredicateKind::WellFormed(..) | PredicateKind::Clause(Clause::WellFormed(..))
| PredicateKind::ObjectSafe(..) | PredicateKind::ObjectSafe(..)
| PredicateKind::ClosureKind(..) | PredicateKind::ClosureKind(..)
| PredicateKind::ConstEvaluatable(..) | PredicateKind::ConstEvaluatable(..)

View file

@ -2877,7 +2877,7 @@ define_print_and_forward_display! {
ty::PredicateKind::Clause(ty::Clause::ConstArgHasType(ct, ty)) => { ty::PredicateKind::Clause(ty::Clause::ConstArgHasType(ct, ty)) => {
p!("the constant `", print(ct), "` has type `", print(ty), "`") p!("the constant `", print(ct), "` has type `", print(ty), "`")
}, },
ty::PredicateKind::WellFormed(arg) => p!(print(arg), " well-formed"), ty::PredicateKind::Clause(ty::Clause::WellFormed(arg)) => p!(print(arg), " well-formed"),
ty::PredicateKind::ObjectSafe(trait_def_id) => { ty::PredicateKind::ObjectSafe(trait_def_id) => {
p!("the trait `", print_def_path(trait_def_id, &[]), "` is object-safe") p!("the trait `", print_def_path(trait_def_id, &[]), "` is object-safe")
} }

View file

@ -179,6 +179,7 @@ impl<'tcx> fmt::Debug for ty::Clause<'tcx> {
ty::Clause::RegionOutlives(ref pair) => pair.fmt(f), ty::Clause::RegionOutlives(ref pair) => pair.fmt(f),
ty::Clause::TypeOutlives(ref pair) => pair.fmt(f), ty::Clause::TypeOutlives(ref pair) => pair.fmt(f),
ty::Clause::Projection(ref pair) => pair.fmt(f), ty::Clause::Projection(ref pair) => pair.fmt(f),
ty::Clause::WellFormed(ref data) => write!(f, "WellFormed({:?})", data),
} }
} }
} }
@ -189,7 +190,6 @@ impl<'tcx> fmt::Debug for ty::PredicateKind<'tcx> {
ty::PredicateKind::Clause(ref a) => a.fmt(f), ty::PredicateKind::Clause(ref a) => a.fmt(f),
ty::PredicateKind::Subtype(ref pair) => pair.fmt(f), ty::PredicateKind::Subtype(ref pair) => pair.fmt(f),
ty::PredicateKind::Coerce(ref pair) => pair.fmt(f), ty::PredicateKind::Coerce(ref pair) => pair.fmt(f),
ty::PredicateKind::WellFormed(data) => write!(f, "WellFormed({:?})", data),
ty::PredicateKind::ObjectSafe(trait_def_id) => { ty::PredicateKind::ObjectSafe(trait_def_id) => {
write!(f, "ObjectSafe({:?})", trait_def_id) write!(f, "ObjectSafe({:?})", trait_def_id)
} }

View file

@ -183,7 +183,7 @@ where
ty.visit_with(self) ty.visit_with(self)
} }
ty::PredicateKind::ConstEvaluatable(ct) => ct.visit_with(self), ty::PredicateKind::ConstEvaluatable(ct) => ct.visit_with(self),
ty::PredicateKind::WellFormed(arg) => arg.visit_with(self), ty::PredicateKind::Clause(ty::Clause::WellFormed(arg)) => arg.visit_with(self),
ty::PredicateKind::ObjectSafe(_) ty::PredicateKind::ObjectSafe(_)
| ty::PredicateKind::ClosureKind(_, _, _) | ty::PredicateKind::ClosureKind(_, _, _)

View file

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

View file

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

View file

@ -826,7 +826,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
// we start out with a `ParamEnv` with no inference variables, // we start out with a `ParamEnv` with no inference variables,
// and these don't correspond to adding any new bounds to // and these don't correspond to adding any new bounds to
// the `ParamEnv`. // the `ParamEnv`.
ty::PredicateKind::WellFormed(..) ty::PredicateKind::Clause(ty::Clause::WellFormed(..))
| ty::PredicateKind::Clause(ty::Clause::ConstArgHasType(..)) | ty::PredicateKind::Clause(ty::Clause::ConstArgHasType(..))
| ty::PredicateKind::AliasRelate(..) | ty::PredicateKind::AliasRelate(..)
| ty::PredicateKind::ObjectSafe(..) | 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) 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 { match self.tcx.sess.opts.unstable_opts.trait_solver {
TraitSolver::Classic => { TraitSolver::Classic => {
// WF predicates cannot themselves make // WF predicates cannot themselves make
@ -2415,7 +2415,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
err err
} }
ty::PredicateKind::WellFormed(arg) => { ty::PredicateKind::Clause(ty::Clause::WellFormed(arg)) => {
// Same hacky approach as above to avoid deluging user // Same hacky approach as above to avoid deluging user
// with error messages. // with error messages.
if arg.references_error() 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::RegionOutlives(_))
| ty::PredicateKind::Clause(ty::Clause::TypeOutlives(_)) | ty::PredicateKind::Clause(ty::Clause::TypeOutlives(_))
| ty::PredicateKind::Clause(ty::Clause::ConstArgHasType(..)) | ty::PredicateKind::Clause(ty::Clause::ConstArgHasType(..))
| ty::PredicateKind::WellFormed(_) | ty::PredicateKind::Clause(ty::Clause::WellFormed(_))
| ty::PredicateKind::ObjectSafe(_) | ty::PredicateKind::ObjectSafe(_)
| ty::PredicateKind::ClosureKind(..) | ty::PredicateKind::ClosureKind(..)
| ty::PredicateKind::Subtype(_) | 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( match wf::obligations(
self.selcx.infcx, self.selcx.infcx,
obligation.param_env, 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::AliasRelate(..) => bug!("`AliasRelate` not allowed as assumption"),
ty::PredicateKind::WellFormed(..) ty::PredicateKind::Clause(ty::Clause::WellFormed(..))
| ty::PredicateKind::ObjectSafe(..) | ty::PredicateKind::ObjectSafe(..)
| ty::PredicateKind::Clause(ty::Clause::TypeOutlives(..)) | ty::PredicateKind::Clause(ty::Clause::TypeOutlives(..))
| ty::PredicateKind::Clause(ty::Clause::RegionOutlives(..)) | 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::Subtype(..)
| ty::PredicateKind::Coerce(..) | ty::PredicateKind::Coerce(..)
| ty::PredicateKind::Clause(ty::Clause::RegionOutlives(..)) | ty::PredicateKind::Clause(ty::Clause::RegionOutlives(..))
| ty::PredicateKind::WellFormed(..) | ty::PredicateKind::Clause(ty::Clause::WellFormed(..))
| ty::PredicateKind::ObjectSafe(..) | ty::PredicateKind::ObjectSafe(..)
| ty::PredicateKind::ClosureKind(..) | ty::PredicateKind::ClosureKind(..)
| ty::PredicateKind::Clause(ty::Clause::TypeOutlives(..)) | 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)?; ocx.eq(&cause, param_env, mir_ty, user_ty)?;
// FIXME(#104764): We should check well-formedness before normalization. // 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)); ocx.register_obligation(Obligation::new(ocx.infcx.tcx, cause, param_env, predicate));
Ok(()) Ok(())
} }
@ -119,7 +120,9 @@ fn relate_mir_and_user_substs<'tcx>(
let impl_self_ty = ocx.normalize(&cause, param_env, impl_self_ty); let impl_self_ty = ocx.normalize(&cause, param_env, impl_self_ty);
ocx.eq(&cause, param_env, self_ty, 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)); 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 // them? This would only be relevant if some input
// type were ill-formed but did not appear in `ty`, // type were ill-formed but did not appear in `ty`,
// which...could happen with normalization... // 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)); ocx.register_obligation(Obligation::new(tcx, cause, param_env, predicate));
Ok(()) Ok(())
} }

View file

@ -137,7 +137,7 @@ pub fn compute_implied_outlives_bounds_inner<'tcx>(
| ty::PredicateKind::TypeWellFormedFromEnv(..) => {} | ty::PredicateKind::TypeWellFormedFromEnv(..) => {}
// We need to search through *all* WellFormed predicates // We need to search through *all* WellFormed predicates
ty::PredicateKind::WellFormed(arg) => { ty::PredicateKind::Clause(ty::Clause::WellFormed(arg)) => {
wf_args.push(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 // So, there is a bit going on here. First, `WellFormed` predicates
// are coinductive, like trait predicates with auto traits. // are coinductive, like trait predicates with auto traits.
// This means that we need to detect if we have recursively // 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(ct.into());
wf.compute(ty.into()); wf.compute(ty.into());
} }
ty::PredicateKind::WellFormed(arg) => { ty::PredicateKind::Clause(ty::Clause::WellFormed(arg)) => {
wf.compute(arg); wf.compute(arg);
} }
@ -386,7 +386,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
cause, cause,
depth, depth,
param_env, 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(), cause.clone(),
depth, depth,
param_env, 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, cause,
self.recursion_depth, self.recursion_depth,
self.param_env, 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(_) => { ty::ConstKind::Expr(_) => {
@ -784,7 +786,9 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
cause, cause,
self.recursion_depth, self.recursion_depth,
param_env, 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::Clause(ty::Clause::ConstArgHasType(..))
| ty::PredicateKind::Subtype(..) | ty::PredicateKind::Subtype(..)
| ty::PredicateKind::Coerce(..) | ty::PredicateKind::Coerce(..)
| ty::PredicateKind::WellFormed(..) | ty::PredicateKind::Clause(ty::Clause::WellFormed(..))
| ty::PredicateKind::ObjectSafe(..) | ty::PredicateKind::ObjectSafe(..)
| ty::PredicateKind::ClosureKind(..) | ty::PredicateKind::ClosureKind(..)
| ty::PredicateKind::Clause(ty::Clause::RegionOutlives(..)) | ty::PredicateKind::Clause(ty::Clause::RegionOutlives(..))

View file

@ -122,7 +122,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::InEnvironment<chalk_ir::Goal<RustInterner<'
predicate.lower_into(interner), predicate.lower_into(interner),
)) ))
} }
ty::PredicateKind::WellFormed(arg) => match arg.unpack() { ty::PredicateKind::Clause(ty::Clause::WellFormed(arg)) => match arg.unpack() {
ty::GenericArgKind::Type(ty) => chalk_ir::DomainGoal::WellFormed( ty::GenericArgKind::Type(ty) => chalk_ir::DomainGoal::WellFormed(
chalk_ir::WellFormed::Ty(ty.lower_into(interner)), chalk_ir::WellFormed::Ty(ty.lower_into(interner)),
), ),
@ -192,7 +192,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData<RustInterner<'tcx>>> for ty::Predi
chalk_ir::WhereClause::AliasEq(predicate.lower_into(interner)), chalk_ir::WhereClause::AliasEq(predicate.lower_into(interner)),
)) ))
} }
ty::PredicateKind::WellFormed(arg) => match arg.unpack() { ty::PredicateKind::Clause(ty::Clause::WellFormed(arg)) => match arg.unpack() {
GenericArgKind::Type(ty) => match ty.kind() { GenericArgKind::Type(ty) => match ty.kind() {
// FIXME(chalk): In Chalk, a placeholder is WellFormed if it // FIXME(chalk): In Chalk, a placeholder is WellFormed if it
// `FromEnv`. However, when we "lower" Params, we don't update // `FromEnv`. However, when we "lower" Params, we don't update
@ -672,7 +672,7 @@ impl<'tcx> LowerInto<'tcx, Option<chalk_ir::QuantifiedWhereClause<RustInterner<'
ty::PredicateKind::Clause(ty::Clause::Projection(predicate)) => { ty::PredicateKind::Clause(ty::Clause::Projection(predicate)) => {
Some(chalk_ir::WhereClause::AliasEq(predicate.lower_into(interner))) Some(chalk_ir::WhereClause::AliasEq(predicate.lower_into(interner)))
} }
ty::PredicateKind::WellFormed(_ty) => None, ty::PredicateKind::Clause(ty::Clause::WellFormed(_ty)) => None,
ty::PredicateKind::Clause(ty::Clause::ConstArgHasType(..)) => None, ty::PredicateKind::Clause(ty::Clause::ConstArgHasType(..)) => None,
ty::PredicateKind::ObjectSafe(..) ty::PredicateKind::ObjectSafe(..)
@ -807,7 +807,7 @@ impl<'tcx> LowerInto<'tcx, Option<chalk_solve::rust_ir::QuantifiedInlineBound<Ru
)) ))
} }
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(_predicate)) => None, ty::PredicateKind::Clause(ty::Clause::TypeOutlives(_predicate)) => None,
ty::PredicateKind::WellFormed(_ty) => None, ty::PredicateKind::Clause(ty::Clause::WellFormed(_ty)) => None,
ty::PredicateKind::Clause(ty::Clause::ConstArgHasType(..)) => None, ty::PredicateKind::Clause(ty::Clause::ConstArgHasType(..)) => None,
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(..)) ty::PredicateKind::Clause(ty::Clause::RegionOutlives(..))

View file

@ -62,7 +62,7 @@ fn not_outlives_predicate(p: ty::Predicate<'_>) -> bool {
| ty::PredicateKind::Clause(ty::Clause::Projection(..)) | ty::PredicateKind::Clause(ty::Clause::Projection(..))
| ty::PredicateKind::Clause(ty::Clause::ConstArgHasType(..)) | ty::PredicateKind::Clause(ty::Clause::ConstArgHasType(..))
| ty::PredicateKind::AliasRelate(..) | ty::PredicateKind::AliasRelate(..)
| ty::PredicateKind::WellFormed(..) | ty::PredicateKind::Clause(ty::Clause::WellFormed(..))
| ty::PredicateKind::ObjectSafe(..) | ty::PredicateKind::ObjectSafe(..)
| ty::PredicateKind::ClosureKind(..) | ty::PredicateKind::ClosureKind(..)
| ty::PredicateKind::Subtype(..) | ty::PredicateKind::Subtype(..)

View file

@ -345,7 +345,7 @@ pub(crate) fn clean_predicate<'tcx>(
} }
// FIXME(generic_const_exprs): should this do something? // FIXME(generic_const_exprs): should this do something?
ty::PredicateKind::ConstEvaluatable(..) => None, ty::PredicateKind::ConstEvaluatable(..) => None,
ty::PredicateKind::WellFormed(..) => None, ty::PredicateKind::Clause(ty::Clause::WellFormed(..)) => None,
ty::PredicateKind::Clause(ty::Clause::ConstArgHasType(..)) => None, ty::PredicateKind::Clause(ty::Clause::ConstArgHasType(..)) => None,
ty::PredicateKind::Subtype(..) ty::PredicateKind::Subtype(..)

View file

@ -33,7 +33,7 @@ pub fn is_min_const_fn<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>, msrv: &Msrv)
| ty::Clause::Trait(..) | ty::Clause::Trait(..)
| ty::Clause::ConstArgHasType(..), | ty::Clause::ConstArgHasType(..),
) )
| ty::PredicateKind::WellFormed(_) | ty::PredicateKind::Clause(ty::Clause::WellFormed(_))
| ty::PredicateKind::ConstEvaluatable(..) | ty::PredicateKind::ConstEvaluatable(..)
| ty::PredicateKind::ConstEquate(..) | ty::PredicateKind::ConstEquate(..)
| ty::PredicateKind::TypeWellFormedFromEnv(..) => continue, | ty::PredicateKind::TypeWellFormedFromEnv(..) => continue,