Skip to content

Commit fca56a8

Browse files
s/Clause/ClauseKind
1 parent 18a6d91 commit fca56a8

File tree

101 files changed

+592
-544
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+592
-544
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
678678

679679
// Find out if the predicates show that the type is a Fn or FnMut
680680
let find_fn_kind_from_did = |(pred, _): (ty::Predicate<'tcx>, _)| {
681-
if let ty::PredicateKind::Clause(ty::Clause::Trait(pred)) = pred.kind().skip_binder()
681+
if let ty::PredicateKind::Clause(ty::ClauseKind::Trait(pred)) = pred.kind().skip_binder()
682682
&& pred.self_ty() == ty
683683
{
684684
if Some(pred.def_id()) == tcx.lang_items().fn_trait() {
@@ -775,7 +775,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
775775
let predicates: Result<Vec<_>, _> = errors
776776
.into_iter()
777777
.map(|err| match err.obligation.predicate.kind().skip_binder() {
778-
PredicateKind::Clause(ty::Clause::Trait(predicate)) => {
778+
PredicateKind::Clause(ty::ClauseKind::Trait(predicate)) => {
779779
match predicate.self_ty().kind() {
780780
ty::Param(param_ty) => Ok((
781781
generics.type_param(param_ty, tcx),

compiler/rustc_borrowck/src/diagnostics/region_name.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -939,8 +939,8 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
939939
{
940940
predicates.iter().any(|pred| {
941941
match pred.kind().skip_binder() {
942-
ty::PredicateKind::Clause(ty::Clause::Trait(data)) if data.self_ty() == ty => {}
943-
ty::PredicateKind::Clause(ty::Clause::Projection(data)) if data.projection_ty.self_ty() == ty => {}
942+
ty::PredicateKind::Clause(ty::ClauseKind::Trait(data)) if data.self_ty() == ty => {}
943+
ty::PredicateKind::Clause(ty::ClauseKind::Projection(data)) if data.projection_ty.self_ty() == ty => {}
944944
_ => return false,
945945
}
946946
tcx.any_free_region_meets(pred, |r| {

compiler/rustc_borrowck/src/region_infer/opaque_types.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,9 @@ 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 =
334-
ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::WellFormed(definition_ty.into())));
333+
let predicate = ty::Binder::dummy(ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(
334+
definition_ty.into(),
335+
)));
335336
ocx.register_obligation(Obligation::misc(tcx, definition_span, def_id, param_env, predicate));
336337

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

compiler/rustc_borrowck/src/type_check/canonical.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,13 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
8989
category: ConstraintCategory<'tcx>,
9090
) {
9191
self.prove_predicate(
92-
ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::Trait(ty::TraitPredicate {
93-
trait_ref,
94-
constness: ty::BoundConstness::NotConst,
95-
polarity: ty::ImplPolarity::Positive,
96-
}))),
92+
ty::Binder::dummy(ty::PredicateKind::Clause(ty::ClauseKind::Trait(
93+
ty::TraitPredicate {
94+
trait_ref,
95+
constness: ty::BoundConstness::NotConst,
96+
polarity: ty::ImplPolarity::Positive,
97+
},
98+
))),
9799
locations,
98100
category,
99101
);

compiler/rustc_borrowck/src/type_check/mod.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -1420,7 +1420,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
14201420
// See #91068 for an example.
14211421
self.prove_predicates(
14221422
sig.inputs_and_output.iter().map(|ty| {
1423-
ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::WellFormed(
1423+
ty::Binder::dummy(ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(
14241424
ty.into(),
14251425
)))
14261426
}),
@@ -1852,7 +1852,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
18521852

18531853
let array_ty = rvalue.ty(body.local_decls(), tcx);
18541854
self.prove_predicate(
1855-
ty::PredicateKind::Clause(ty::Clause::WellFormed(array_ty.into())),
1855+
ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(array_ty.into())),
18561856
Locations::Single(location),
18571857
ConstraintCategory::Boring,
18581858
);
@@ -2025,10 +2025,11 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
20252025
ConstraintCategory::Cast,
20262026
);
20272027

2028-
let outlives_predicate =
2029-
tcx.mk_predicate(Binder::dummy(ty::PredicateKind::Clause(
2030-
ty::Clause::TypeOutlives(ty::OutlivesPredicate(self_ty, *region)),
2031-
)));
2028+
let outlives_predicate = tcx.mk_predicate(Binder::dummy(
2029+
ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(
2030+
ty::OutlivesPredicate(self_ty, *region),
2031+
)),
2032+
));
20322033
self.prove_predicate(
20332034
outlives_predicate,
20342035
location.to_locations(),

compiler/rustc_hir_analysis/src/astconv/errors.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
343343
let format_pred = |pred: ty::Predicate<'tcx>| {
344344
let bound_predicate = pred.kind();
345345
match bound_predicate.skip_binder() {
346-
ty::PredicateKind::Clause(ty::Clause::Projection(pred)) => {
346+
ty::PredicateKind::Clause(ty::ClauseKind::Projection(pred)) => {
347347
let pred = bound_predicate.rebind(pred);
348348
// `<Foo as Iterator>::Item = String`.
349349
let projection_ty = pred.skip_binder().projection_ty;
@@ -364,7 +364,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
364364
bound_span_label(projection_ty.self_ty(), &obligation, &quiet);
365365
Some((obligation, projection_ty.self_ty()))
366366
}
367-
ty::PredicateKind::Clause(ty::Clause::Trait(poly_trait_ref)) => {
367+
ty::PredicateKind::Clause(ty::ClauseKind::Trait(poly_trait_ref)) => {
368368
let p = poly_trait_ref.trait_ref;
369369
let self_ty = p.self_ty();
370370
let path = p.print_only_trait_path();

compiler/rustc_hir_analysis/src/astconv/mod.rs

+11-9
Original file line numberDiff line numberDiff line change
@@ -950,24 +950,26 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
950950
let bound_pred = pred.kind();
951951
match bound_pred.skip_binder() {
952952
ty::PredicateKind::Clause(clause) => match clause {
953-
ty::Clause::Trait(trait_pred) => {
953+
ty::ClauseKind::Trait(trait_pred) => {
954954
assert_eq!(trait_pred.polarity, ty::ImplPolarity::Positive);
955955
trait_bounds.push((
956956
bound_pred.rebind(trait_pred.trait_ref),
957957
span,
958958
trait_pred.constness,
959959
));
960960
}
961-
ty::Clause::Projection(proj) => {
961+
ty::ClauseKind::Projection(proj) => {
962962
projection_bounds.push((bound_pred.rebind(proj), span));
963963
}
964-
ty::Clause::TypeOutlives(_) => {
964+
ty::ClauseKind::TypeOutlives(_) => {
965965
// Do nothing, we deal with regions separately
966966
}
967-
ty::Clause::RegionOutlives(_)
968-
| ty::Clause::ConstArgHasType(..)
969-
| ty::Clause::WellFormed(_)
970-
| ty::Clause::ConstEvaluatable(_) => bug!(),
967+
ty::ClauseKind::RegionOutlives(_)
968+
| ty::ClauseKind::ConstArgHasType(..)
969+
| ty::ClauseKind::WellFormed(_)
970+
| ty::ClauseKind::ConstEvaluatable(_) => {
971+
bug!()
972+
}
971973
},
972974
ty::PredicateKind::AliasRelate(..)
973975
| ty::PredicateKind::ObjectSafe(_)
@@ -1064,7 +1066,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
10641066

10651067
let bound_predicate = pred.kind();
10661068
match bound_predicate.skip_binder() {
1067-
ty::PredicateKind::Clause(ty::Clause::Trait(pred)) => {
1069+
ty::PredicateKind::Clause(ty::ClauseKind::Trait(pred)) => {
10681070
let pred = bound_predicate.rebind(pred);
10691071
associated_types.entry(span).or_default().extend(
10701072
tcx.associated_items(pred.def_id())
@@ -1074,7 +1076,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
10741076
.map(|item| item.def_id),
10751077
);
10761078
}
1077-
ty::PredicateKind::Clause(ty::Clause::Projection(pred)) => {
1079+
ty::PredicateKind::Clause(ty::ClauseKind::Projection(pred)) => {
10781080
let pred = bound_predicate.rebind(pred);
10791081
// A `Self` within the original bound will be substituted with a
10801082
// `trait_object_dummy_self`, so check for that.

compiler/rustc_hir_analysis/src/bounds.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use rustc_span::Span;
2424
/// include the self type (e.g., `trait_bounds`) but in others we do not
2525
#[derive(Default, PartialEq, Eq, Clone, Debug)]
2626
pub struct Bounds<'tcx> {
27-
pub predicates: Vec<(Binder<'tcx, ty::Clause<'tcx>>, Span)>,
27+
pub predicates: Vec<(Binder<'tcx, ty::ClauseKind<'tcx>>, Span)>,
2828
}
2929

3030
impl<'tcx> Bounds<'tcx> {
@@ -34,7 +34,7 @@ impl<'tcx> Bounds<'tcx> {
3434
region: ty::PolyTypeOutlivesPredicate<'tcx>,
3535
span: Span,
3636
) {
37-
self.predicates.push((region.map_bound(|p| ty::Clause::TypeOutlives(p)), span));
37+
self.predicates.push((region.map_bound(|p| ty::ClauseKind::TypeOutlives(p)), span));
3838
}
3939

4040
pub fn push_trait_bound(
@@ -47,7 +47,7 @@ impl<'tcx> Bounds<'tcx> {
4747
) {
4848
self.predicates.push((
4949
trait_ref.map_bound(|trait_ref| {
50-
ty::Clause::Trait(ty::TraitPredicate { trait_ref, constness, polarity })
50+
ty::ClauseKind::Trait(ty::TraitPredicate { trait_ref, constness, polarity })
5151
}),
5252
span,
5353
));
@@ -59,7 +59,7 @@ impl<'tcx> Bounds<'tcx> {
5959
projection: ty::PolyProjectionPredicate<'tcx>,
6060
span: Span,
6161
) {
62-
self.predicates.push((projection.map_bound(|proj| ty::Clause::Projection(proj)), span));
62+
self.predicates.push((projection.map_bound(|proj| ty::ClauseKind::Projection(proj)), span));
6363
}
6464

6565
pub fn push_sized(&mut self, tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, span: Span) {
@@ -69,13 +69,17 @@ impl<'tcx> Bounds<'tcx> {
6969
self.predicates.insert(
7070
0,
7171
(
72-
ty::Binder::dummy(ty::Clause::Trait(trait_ref.without_const().to_predicate(tcx))),
72+
ty::Binder::dummy(ty::ClauseKind::Trait(
73+
trait_ref.without_const().to_predicate(tcx),
74+
)),
7375
span,
7476
),
7577
);
7678
}
7779

78-
pub fn predicates(&self) -> impl Iterator<Item = (Binder<'tcx, ty::Clause<'tcx>>, Span)> + '_ {
80+
pub fn predicates(
81+
&self,
82+
) -> impl Iterator<Item = (Binder<'tcx, ty::ClauseKind<'tcx>>, Span)> + '_ {
7983
self.predicates.iter().cloned()
8084
}
8185
}

compiler/rustc_hir_analysis/src/check/check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ fn check_opaque_meets_bounds<'tcx>(
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.
442442
let predicate =
443-
ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::WellFormed(hidden_ty.into())));
443+
ty::Binder::dummy(ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(hidden_ty.into())));
444444
ocx.register_obligation(Obligation::new(tcx, misc_cause, param_env, predicate));
445445

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

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ fn compare_method_predicate_entailment<'tcx>(
321321
infcx.tcx,
322322
ObligationCause::dummy(),
323323
param_env,
324-
ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::WellFormed(
324+
ty::Binder::dummy(ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(
325325
unnormalized_impl_fty.into(),
326326
))),
327327
));

compiler/rustc_hir_analysis/src/check/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ fn bounds_from_generic_predicates<'tcx>(
304304
debug!("predicate {:?}", predicate);
305305
let bound_predicate = predicate.kind();
306306
match bound_predicate.skip_binder() {
307-
ty::PredicateKind::Clause(ty::Clause::Trait(trait_predicate)) => {
307+
ty::PredicateKind::Clause(ty::ClauseKind::Trait(trait_predicate)) => {
308308
let entry = types.entry(trait_predicate.self_ty()).or_default();
309309
let def_id = trait_predicate.def_id();
310310
if Some(def_id) != tcx.lang_items().sized_trait() {
@@ -313,7 +313,7 @@ fn bounds_from_generic_predicates<'tcx>(
313313
entry.push(trait_predicate.def_id());
314314
}
315315
}
316-
ty::PredicateKind::Clause(ty::Clause::Projection(projection_pred)) => {
316+
ty::PredicateKind::Clause(ty::ClauseKind::Projection(projection_pred)) => {
317317
projections.push(bound_predicate.rebind(projection_pred));
318318
}
319319
_ => {}

compiler/rustc_hir_analysis/src/check/wfcheck.rs

+10-10
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::Clause(ty::Clause::WellFormed(arg))),
84+
ty::Binder::dummy(ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(arg))),
8585
));
8686
}
8787
}
@@ -419,18 +419,17 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, associated_items: &[hir::TraitItemRe
419419
let mut unsatisfied_bounds: Vec<_> = required_bounds
420420
.into_iter()
421421
.filter(|clause| match clause.kind().skip_binder() {
422-
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(ty::OutlivesPredicate(
423-
a,
424-
b,
425-
))) => !region_known_to_outlive(
422+
ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(
423+
ty::OutlivesPredicate(a, b),
424+
)) => !region_known_to_outlive(
426425
tcx,
427426
gat_def_id.def_id,
428427
param_env,
429428
&FxIndexSet::default(),
430429
a,
431430
b,
432431
),
433-
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(ty::OutlivesPredicate(
432+
ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(ty::OutlivesPredicate(
434433
a,
435434
b,
436435
))) => !ty_known_to_outlive(
@@ -574,7 +573,7 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable<TyCtxt<'tcx>>>(
574573
);
575574
// The predicate we expect to see. (In our example,
576575
// `Self: 'me`.)
577-
let clause = ty::PredicateKind::Clause(ty::Clause::TypeOutlives(
576+
let clause = ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(
578577
ty::OutlivesPredicate(ty_param, region_param),
579578
));
580579
let clause = tcx.mk_predicate(ty::Binder::dummy(clause));
@@ -623,7 +622,7 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable<TyCtxt<'tcx>>>(
623622
},
624623
);
625624
// The predicate we expect to see.
626-
let clause = ty::PredicateKind::Clause(ty::Clause::RegionOutlives(
625+
let clause = ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(
627626
ty::OutlivesPredicate(region_a_param, region_b_param),
628627
));
629628
let clause = tcx.mk_predicate(ty::Binder::dummy(clause));
@@ -1032,7 +1031,7 @@ fn check_type_defn<'tcx>(tcx: TyCtxt<'tcx>, item: &hir::Item<'tcx>, all_sized: b
10321031
tcx,
10331032
cause,
10341033
wfcx.param_env,
1035-
ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::ConstEvaluatable(
1034+
ty::Binder::dummy(ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(
10361035
ty::Const::from_anon_const(tcx, discr_def_id.expect_local()),
10371036
))),
10381037
));
@@ -1876,7 +1875,8 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
18761875
// We lower empty bounds like `Vec<dyn Copy>:` as
18771876
// `WellFormed(Vec<dyn Copy>)`, which will later get checked by
18781877
// regular WF checking
1879-
if let ty::PredicateKind::Clause(ty::Clause::WellFormed(..)) = pred.kind().skip_binder()
1878+
if let ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(..)) =
1879+
pred.kind().skip_binder()
18801880
{
18811881
continue;
18821882
}

compiler/rustc_hir_analysis/src/coherence/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ fn infringing_fields_error(
571571
.or_default()
572572
.push(error.obligation.cause.span);
573573
}
574-
if let ty::PredicateKind::Clause(ty::Clause::Trait(ty::TraitPredicate {
574+
if let ty::PredicateKind::Clause(ty::ClauseKind::Trait(ty::TraitPredicate {
575575
trait_ref,
576576
polarity: ty::ImplPolarity::Positive,
577577
..

compiler/rustc_hir_analysis/src/collect/item_bounds.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@ fn associated_type_bounds<'tcx>(
3636

3737
let bounds_from_parent = trait_predicates.predicates.iter().copied().filter(|(pred, _)| {
3838
match pred.kind().skip_binder() {
39-
ty::PredicateKind::Clause(ty::Clause::Trait(tr)) => tr.self_ty() == item_ty,
40-
ty::PredicateKind::Clause(ty::Clause::Projection(proj)) => {
39+
ty::PredicateKind::Clause(ty::ClauseKind::Trait(tr)) => tr.self_ty() == item_ty,
40+
ty::PredicateKind::Clause(ty::ClauseKind::Projection(proj)) => {
4141
proj.projection_ty.self_ty() == item_ty
4242
}
43-
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(outlives)) => outlives.0 == item_ty,
43+
ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(outlives)) => {
44+
outlives.0 == item_ty
45+
}
4446
_ => false,
4547
}
4648
});

0 commit comments

Comments
 (0)