Skip to content

Commit 52d3fc9

Browse files
Move WF goal to clause
1 parent a8a2907 commit 52d3fc9

File tree

37 files changed

+81
-64
lines changed

37 files changed

+81
-64
lines changed

compiler/rustc_borrowck/src/region_infer/opaque_types.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,8 @@ fn check_opaque_type_well_formed<'tcx>(
330330
// Require the hidden type to be well-formed with only the generics of the opaque type.
331331
// Defining use functions may have more bounds than the opaque type, which is ok, as long as the
332332
// hidden type is well formed even without those bounds.
333-
let predicate = ty::Binder::dummy(ty::PredicateKind::WellFormed(definition_ty.into()));
333+
let predicate =
334+
ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::WellFormed(definition_ty.into())));
334335
ocx.register_obligation(Obligation::misc(tcx, definition_span, def_id, param_env, predicate));
335336

336337
// Check that all obligations are satisfied by the implementation's

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,9 +1419,11 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
14191419
//
14201420
// See #91068 for an example.
14211421
self.prove_predicates(
1422-
sig.inputs_and_output
1423-
.iter()
1424-
.map(|ty| ty::Binder::dummy(ty::PredicateKind::WellFormed(ty.into()))),
1422+
sig.inputs_and_output.iter().map(|ty| {
1423+
ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::WellFormed(
1424+
ty.into(),
1425+
)))
1426+
}),
14251427
term_location.to_locations(),
14261428
ConstraintCategory::Boring,
14271429
);
@@ -1850,7 +1852,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
18501852

18511853
let array_ty = rvalue.ty(body.local_decls(), tcx);
18521854
self.prove_predicate(
1853-
ty::PredicateKind::WellFormed(array_ty.into()),
1855+
ty::PredicateKind::Clause(ty::Clause::WellFormed(array_ty.into())),
18541856
Locations::Single(location),
18551857
ConstraintCategory::Boring,
18561858
);

compiler/rustc_hir_analysis/src/astconv/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,10 +1527,11 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
15271527
ty::Clause::TypeOutlives(_) => {
15281528
// Do nothing, we deal with regions separately
15291529
}
1530-
ty::Clause::RegionOutlives(_) | ty::Clause::ConstArgHasType(..) => bug!(),
1530+
ty::Clause::RegionOutlives(_)
1531+
| ty::Clause::ConstArgHasType(..)
1532+
| ty::Clause::WellFormed(_) => bug!(),
15311533
},
1532-
ty::PredicateKind::WellFormed(_)
1533-
| ty::PredicateKind::AliasRelate(..)
1534+
ty::PredicateKind::AliasRelate(..)
15341535
| ty::PredicateKind::ObjectSafe(_)
15351536
| ty::PredicateKind::ClosureKind(_, _, _)
15361537
| ty::PredicateKind::Subtype(_)

compiler/rustc_hir_analysis/src/check/check.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,8 @@ fn check_opaque_meets_bounds<'tcx>(
439439
// Additionally require the hidden type to be well-formed with only the generics of the opaque type.
440440
// Defining use functions may have more bounds than the opaque type, which is ok, as long as the
441441
// hidden type is well formed even without those bounds.
442-
let predicate = ty::Binder::dummy(ty::PredicateKind::WellFormed(hidden_ty.into()));
442+
let predicate =
443+
ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::WellFormed(hidden_ty.into())));
443444
ocx.register_obligation(Obligation::new(tcx, misc_cause, param_env, predicate));
444445

445446
// Check that all obligations are satisfied by the implementation's

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,9 @@ fn compare_method_predicate_entailment<'tcx>(
321321
infcx.tcx,
322322
ObligationCause::dummy(),
323323
param_env,
324-
ty::Binder::dummy(ty::PredicateKind::WellFormed(unnormalized_impl_fty.into())),
324+
ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::WellFormed(
325+
unnormalized_impl_fty.into(),
326+
))),
325327
));
326328
}
327329

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
8181
self.tcx(),
8282
cause,
8383
param_env,
84-
ty::Binder::dummy(ty::PredicateKind::WellFormed(arg)),
84+
ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::WellFormed(arg))),
8585
));
8686
}
8787
}
@@ -1876,7 +1876,8 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
18761876
// We lower empty bounds like `Vec<dyn Copy>:` as
18771877
// `WellFormed(Vec<dyn Copy>)`, which will later get checked by
18781878
// regular WF checking
1879-
if let ty::PredicateKind::WellFormed(..) = pred.kind().skip_binder() {
1879+
if let ty::PredicateKind::Clause(ty::Clause::WellFormed(..)) = pred.kind().skip_binder()
1880+
{
18801881
continue;
18811882
}
18821883
// Match the existing behavior.

compiler/rustc_hir_analysis/src/collect/predicates_of.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
219219
} else {
220220
let span = bound_pred.bounded_ty.span;
221221
let predicate = ty::Binder::bind_with_vars(
222-
ty::PredicateKind::WellFormed(ty.into()),
222+
ty::PredicateKind::Clause(ty::Clause::WellFormed(ty.into())),
223223
bound_vars,
224224
);
225225
predicates.insert((predicate.to_predicate(tcx), span));

compiler/rustc_hir_analysis/src/hir_wf_check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ fn diagnostic_hir_wf_check<'tcx>(
7979
self.tcx,
8080
cause,
8181
self.param_env,
82-
ty::PredicateKind::WellFormed(tcx_ty.into()),
82+
ty::PredicateKind::Clause(ty::Clause::WellFormed(tcx_ty.into())),
8383
));
8484

8585
for error in ocx.select_all_or_error() {

compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ fn trait_predicate_kind<'tcx>(
542542
| ty::PredicateKind::Clause(ty::Clause::Projection(_))
543543
| ty::PredicateKind::Clause(ty::Clause::ConstArgHasType(..))
544544
| ty::PredicateKind::AliasRelate(..)
545-
| ty::PredicateKind::WellFormed(_)
545+
| ty::PredicateKind::Clause(ty::Clause::WellFormed(_))
546546
| ty::PredicateKind::Subtype(_)
547547
| ty::PredicateKind::Coerce(_)
548548
| ty::PredicateKind::ObjectSafe(_)

compiler/rustc_hir_analysis/src/outlives/explicit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl<'tcx> ExplicitPredicatesMap<'tcx> {
5555
ty::PredicateKind::Clause(ty::Clause::Trait(..))
5656
| ty::PredicateKind::Clause(ty::Clause::Projection(..))
5757
| ty::PredicateKind::Clause(ty::Clause::ConstArgHasType(..))
58-
| ty::PredicateKind::WellFormed(..)
58+
| ty::PredicateKind::Clause(ty::Clause::WellFormed(..))
5959
| ty::PredicateKind::AliasRelate(..)
6060
| ty::PredicateKind::ObjectSafe(..)
6161
| ty::PredicateKind::ClosureKind(..)

0 commit comments

Comments
 (0)