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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 3 additions & 2 deletions
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

Lines changed: 7 additions & 5 deletions
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

Lines changed: 7 additions & 6 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 11 additions & 9 deletions
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

Lines changed: 10 additions & 6 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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
));

0 commit comments

Comments
 (0)