Skip to content

Commit 3dea68d

Browse files
committed
Review changes
1 parent 66c1799 commit 3dea68d

Some content is hidden

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

67 files changed

+584
-593
lines changed

compiler/rustc_infer/src/infer/canonical/query_response.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -530,10 +530,10 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
530530

531531
let atom = match k1.unpack() {
532532
GenericArgKind::Lifetime(r1) => {
533-
ty::PredicateAtom::RegionOutlives(ty::OutlivesPredicate(r1, r2))
533+
ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(r1, r2))
534534
}
535535
GenericArgKind::Type(t1) => {
536-
ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(t1, r2))
536+
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(t1, r2))
537537
}
538538
GenericArgKind::Const(..) => {
539539
// Consts cannot outlive one another, so we don't expect to
@@ -663,7 +663,7 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for QueryTypeRelatingDelegate<'_, 'tcx> {
663663
self.obligations.push(Obligation {
664664
cause: self.cause.clone(),
665665
param_env: self.param_env,
666-
predicate: ty::PredicateAtom::RegionOutlives(ty::OutlivesPredicate(sup, sub))
666+
predicate: ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(sup, sub))
667667
.to_predicate(self.infcx.tcx),
668668
recursion_depth: 0,
669669
});

compiler/rustc_infer/src/infer/combine.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
358358
self.obligations.push(Obligation::new(
359359
self.trace.cause.clone(),
360360
self.param_env,
361-
ty::PredicateAtom::WellFormed(b_ty.into()).to_predicate(self.infcx.tcx),
361+
ty::PredicateKind::WellFormed(b_ty.into()).to_predicate(self.infcx.tcx),
362362
));
363363
}
364364

@@ -451,9 +451,9 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
451451
b: &'tcx ty::Const<'tcx>,
452452
) {
453453
let predicate = if a_is_expected {
454-
ty::PredicateAtom::ConstEquate(a, b)
454+
ty::PredicateKind::ConstEquate(a, b)
455455
} else {
456-
ty::PredicateAtom::ConstEquate(b, a)
456+
ty::PredicateKind::ConstEquate(b, a)
457457
};
458458
self.obligations.push(Obligation::new(
459459
self.trace.cause.clone(),

compiler/rustc_infer/src/infer/error_reporting/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1706,8 +1706,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
17061706

17071707
for (predicate, _) in bounds {
17081708
let predicate = predicate.subst(self.tcx, substs);
1709-
if let ty::PredicateAtom::Projection(projection_predicate) =
1710-
predicate.skip_binders()
1709+
if let ty::PredicateKind::Projection(projection_predicate) =
1710+
predicate.kind().skip_binder()
17111711
{
17121712
if projection_predicate.projection_ty.item_def_id == item_def_id {
17131713
// We don't account for multiple `Future::Output = Ty` contraints.

compiler/rustc_infer/src/infer/outlives/mod.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,21 @@ pub fn explicit_outlives_bounds<'tcx>(
1515
param_env
1616
.caller_bounds()
1717
.into_iter()
18-
.map(ty::Predicate::skip_binders)
18+
.map(ty::Predicate::kind)
19+
.map(ty::Binder::skip_binder)
1920
.filter(|atom| !atom.has_escaping_bound_vars())
2021
.filter_map(move |atom| match atom {
21-
ty::PredicateAtom::Projection(..)
22-
| ty::PredicateAtom::Trait(..)
23-
| ty::PredicateAtom::Subtype(..)
24-
| ty::PredicateAtom::WellFormed(..)
25-
| ty::PredicateAtom::ObjectSafe(..)
26-
| ty::PredicateAtom::ClosureKind(..)
27-
| ty::PredicateAtom::TypeOutlives(..)
28-
| ty::PredicateAtom::ConstEvaluatable(..)
29-
| ty::PredicateAtom::ConstEquate(..)
30-
| ty::PredicateAtom::TypeWellFormedFromEnv(..) => None,
31-
ty::PredicateAtom::RegionOutlives(ty::OutlivesPredicate(r_a, r_b)) => {
22+
ty::PredicateKind::Projection(..)
23+
| ty::PredicateKind::Trait(..)
24+
| ty::PredicateKind::Subtype(..)
25+
| ty::PredicateKind::WellFormed(..)
26+
| ty::PredicateKind::ObjectSafe(..)
27+
| ty::PredicateKind::ClosureKind(..)
28+
| ty::PredicateKind::TypeOutlives(..)
29+
| ty::PredicateKind::ConstEvaluatable(..)
30+
| ty::PredicateKind::ConstEquate(..)
31+
| ty::PredicateKind::TypeWellFormedFromEnv(..) => None,
32+
ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(r_a, r_b)) => {
3233
Some(OutlivesBound::RegionSubRegion(r_b, r_a))
3334
}
3435
})

compiler/rustc_infer/src/infer/sub.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl TypeRelation<'tcx> for Sub<'combine, 'infcx, 'tcx> {
100100
self.fields.obligations.push(Obligation::new(
101101
self.fields.trace.cause.clone(),
102102
self.fields.param_env,
103-
ty::PredicateAtom::Subtype(ty::SubtypePredicate {
103+
ty::PredicateKind::Subtype(ty::SubtypePredicate {
104104
a_is_expected: self.a_is_expected,
105105
a,
106106
b,

compiler/rustc_infer/src/traits/util.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub fn anonymize_predicate<'tcx>(
99
tcx: TyCtxt<'tcx>,
1010
pred: ty::Predicate<'tcx>,
1111
) -> ty::Predicate<'tcx> {
12-
let new = tcx.anonymize_late_bound_regions(pred.bound_atom());
12+
let new = tcx.anonymize_late_bound_regions(pred.kind());
1313
tcx.reuse_or_mk_predicate(pred, new)
1414
}
1515

@@ -121,9 +121,9 @@ impl Elaborator<'tcx> {
121121
fn elaborate(&mut self, obligation: &PredicateObligation<'tcx>) {
122122
let tcx = self.visited.tcx;
123123

124-
let bound_predicate = obligation.predicate.bound_atom();
124+
let bound_predicate = obligation.predicate.kind();
125125
match bound_predicate.skip_binder() {
126-
ty::PredicateAtom::Trait(data, _) => {
126+
ty::PredicateKind::Trait(data, _) => {
127127
// Get predicates declared on the trait.
128128
let predicates = tcx.super_predicates_of(data.def_id());
129129

@@ -145,36 +145,36 @@ impl Elaborator<'tcx> {
145145

146146
self.stack.extend(obligations);
147147
}
148-
ty::PredicateAtom::WellFormed(..) => {
148+
ty::PredicateKind::WellFormed(..) => {
149149
// Currently, we do not elaborate WF predicates,
150150
// although we easily could.
151151
}
152-
ty::PredicateAtom::ObjectSafe(..) => {
152+
ty::PredicateKind::ObjectSafe(..) => {
153153
// Currently, we do not elaborate object-safe
154154
// predicates.
155155
}
156-
ty::PredicateAtom::Subtype(..) => {
156+
ty::PredicateKind::Subtype(..) => {
157157
// Currently, we do not "elaborate" predicates like `X <: Y`,
158158
// though conceivably we might.
159159
}
160-
ty::PredicateAtom::Projection(..) => {
160+
ty::PredicateKind::Projection(..) => {
161161
// Nothing to elaborate in a projection predicate.
162162
}
163-
ty::PredicateAtom::ClosureKind(..) => {
163+
ty::PredicateKind::ClosureKind(..) => {
164164
// Nothing to elaborate when waiting for a closure's kind to be inferred.
165165
}
166-
ty::PredicateAtom::ConstEvaluatable(..) => {
166+
ty::PredicateKind::ConstEvaluatable(..) => {
167167
// Currently, we do not elaborate const-evaluatable
168168
// predicates.
169169
}
170-
ty::PredicateAtom::ConstEquate(..) => {
170+
ty::PredicateKind::ConstEquate(..) => {
171171
// Currently, we do not elaborate const-equate
172172
// predicates.
173173
}
174-
ty::PredicateAtom::RegionOutlives(..) => {
174+
ty::PredicateKind::RegionOutlives(..) => {
175175
// Nothing to elaborate from `'a: 'b`.
176176
}
177-
ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(ty_max, r_min)) => {
177+
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty_max, r_min)) => {
178178
// We know that `T: 'a` for some type `T`. We can
179179
// often elaborate this. For example, if we know that
180180
// `[U]: 'a`, that implies that `U: 'a`. Similarly, if
@@ -204,15 +204,15 @@ impl Elaborator<'tcx> {
204204
if r.is_late_bound() {
205205
None
206206
} else {
207-
Some(ty::PredicateAtom::RegionOutlives(ty::OutlivesPredicate(
207+
Some(ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(
208208
r, r_min,
209209
)))
210210
}
211211
}
212212

213213
Component::Param(p) => {
214214
let ty = tcx.mk_ty_param(p.index, p.name);
215-
Some(ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(
215+
Some(ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(
216216
ty, r_min,
217217
)))
218218
}
@@ -237,7 +237,7 @@ impl Elaborator<'tcx> {
237237
}),
238238
);
239239
}
240-
ty::PredicateAtom::TypeWellFormedFromEnv(..) => {
240+
ty::PredicateKind::TypeWellFormedFromEnv(..) => {
241241
// Nothing to elaborate
242242
}
243243
}

compiler/rustc_lint/src/builtin.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,13 +1550,13 @@ declare_lint_pass!(
15501550
impl<'tcx> LateLintPass<'tcx> for TrivialConstraints {
15511551
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
15521552
use rustc_middle::ty::fold::TypeFoldable;
1553-
use rustc_middle::ty::PredicateAtom::*;
1553+
use rustc_middle::ty::PredicateKind::*;
15541554

15551555
if cx.tcx.features().trivial_bounds {
15561556
let def_id = cx.tcx.hir().local_def_id(item.hir_id);
15571557
let predicates = cx.tcx.predicates_of(def_id);
15581558
for &(predicate, span) in predicates.predicates {
1559-
let predicate_kind_name = match predicate.skip_binders() {
1559+
let predicate_kind_name = match predicate.kind().skip_binder() {
15601560
Trait(..) => "Trait",
15611561
TypeOutlives(..) |
15621562
RegionOutlives(..) => "Lifetime",
@@ -1936,8 +1936,8 @@ impl ExplicitOutlivesRequirements {
19361936
) -> Vec<ty::Region<'tcx>> {
19371937
inferred_outlives
19381938
.iter()
1939-
.filter_map(|(pred, _)| match pred.skip_binders() {
1940-
ty::PredicateAtom::RegionOutlives(ty::OutlivesPredicate(a, b)) => match a {
1939+
.filter_map(|(pred, _)| match pred.kind().skip_binder() {
1940+
ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(a, b)) => match a {
19411941
ty::ReEarlyBound(ebr) if ebr.index == index => Some(b),
19421942
_ => None,
19431943
},
@@ -1952,8 +1952,8 @@ impl ExplicitOutlivesRequirements {
19521952
) -> Vec<ty::Region<'tcx>> {
19531953
inferred_outlives
19541954
.iter()
1955-
.filter_map(|(pred, _)| match pred.skip_binders() {
1956-
ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(a, b)) => {
1955+
.filter_map(|(pred, _)| match pred.kind().skip_binder() {
1956+
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(a, b)) => {
19571957
a.is_param(index).then_some(b)
19581958
}
19591959
_ => None,

compiler/rustc_lint/src/traits.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ declare_lint_pass!(
4545

4646
impl<'tcx> LateLintPass<'tcx> for DropTraitConstraints {
4747
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
48-
use rustc_middle::ty::PredicateAtom::*;
48+
use rustc_middle::ty::PredicateKind::*;
4949

5050
let def_id = cx.tcx.hir().local_def_id(item.hir_id);
5151
let predicates = cx.tcx.explicit_predicates_of(def_id);
5252
for &(predicate, span) in predicates.predicates {
53-
let trait_predicate = match predicate.skip_binders() {
53+
let trait_predicate = match predicate.kind().skip_binder() {
5454
Trait(trait_predicate, _constness) => trait_predicate,
5555
_ => continue,
5656
};

compiler/rustc_lint/src/unused.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
202202
let mut has_emitted = false;
203203
for &(predicate, _) in cx.tcx.explicit_item_bounds(def) {
204204
// We only look at the `DefId`, so it is safe to skip the binder here.
205-
if let ty::PredicateAtom::Trait(ref poly_trait_predicate, _) =
206-
predicate.skip_binders()
205+
if let ty::PredicateKind::Trait(ref poly_trait_predicate, _) =
206+
predicate.kind().skip_binder()
207207
{
208208
let def_id = poly_trait_predicate.trait_ref.def_id;
209209
let descr_pre =

compiler/rustc_middle/src/ty/codec.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ impl<'tcx, E: TyEncoder<'tcx>> EncodableWithShorthand<'tcx, E> for Ty<'tcx> {
4444
}
4545

4646
impl<'tcx, E: TyEncoder<'tcx>> EncodableWithShorthand<'tcx, E> for ty::Predicate<'tcx> {
47-
type Variant = ty::Binder<ty::PredicateAtom<'tcx>>;
47+
type Variant = ty::Binder<ty::PredicateKind<'tcx>>;
4848
fn variant(&self) -> &Self::Variant {
49-
self.bound_atom_ref()
49+
self.kind_ref()
5050
}
5151
}
5252

@@ -226,9 +226,9 @@ impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for ty::Predicate<'tcx> {
226226
assert!(pos >= SHORTHAND_OFFSET);
227227
let shorthand = pos - SHORTHAND_OFFSET;
228228

229-
decoder.with_position(shorthand, ty::Binder::<ty::PredicateAtom<'tcx>>::decode)
229+
decoder.with_position(shorthand, ty::Binder::<ty::PredicateKind<'tcx>>::decode)
230230
} else {
231-
ty::Binder::<ty::PredicateAtom<'tcx>>::decode(decoder)
231+
ty::Binder::<ty::PredicateKind<'tcx>>::decode(decoder)
232232
}?;
233233
let predicate = decoder.tcx().mk_predicate(predicate_kind);
234234
Ok(predicate)

compiler/rustc_middle/src/ty/context.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::ty::TyKind::*;
1919
use crate::ty::{
2020
self, AdtDef, AdtKind, Binder, BindingMode, BoundVar, CanonicalPolyFnSig, Const, ConstVid,
2121
DefIdTree, ExistentialPredicate, FloatVar, FloatVid, GenericParamDefKind, InferConst, InferTy,
22-
IntVar, IntVid, List, ParamConst, ParamTy, PolyFnSig, Predicate, PredicateAtom, PredicateInner,
22+
IntVar, IntVid, List, ParamConst, ParamTy, PolyFnSig, Predicate, PredicateInner, PredicateKind,
2323
ProjectionTy, Region, RegionKind, ReprOptions, TraitObjectVisitor, Ty, TyKind, TyS, TyVar,
2424
TyVid, TypeAndMut, Visibility,
2525
};
@@ -133,7 +133,7 @@ impl<'tcx> CtxtInterners<'tcx> {
133133
}
134134

135135
#[inline(never)]
136-
fn intern_predicate(&self, binder: Binder<PredicateAtom<'tcx>>) -> &'tcx PredicateInner<'tcx> {
136+
fn intern_predicate(&self, binder: Binder<PredicateKind<'tcx>>) -> &'tcx PredicateInner<'tcx> {
137137
self.predicate
138138
.intern(binder, |binder| {
139139
let flags = super::flags::FlagComputation::for_predicate(binder);
@@ -1948,8 +1948,8 @@ impl<'tcx> Hash for Interned<'tcx, PredicateInner<'tcx>> {
19481948
}
19491949
}
19501950

1951-
impl<'tcx> Borrow<Binder<PredicateAtom<'tcx>>> for Interned<'tcx, PredicateInner<'tcx>> {
1952-
fn borrow<'a>(&'a self) -> &'a Binder<PredicateAtom<'tcx>> {
1951+
impl<'tcx> Borrow<Binder<PredicateKind<'tcx>>> for Interned<'tcx, PredicateInner<'tcx>> {
1952+
fn borrow<'a>(&'a self) -> &'a Binder<PredicateKind<'tcx>> {
19531953
&self.0.binder
19541954
}
19551955
}
@@ -2085,7 +2085,7 @@ impl<'tcx> TyCtxt<'tcx> {
20852085
}
20862086

20872087
#[inline]
2088-
pub fn mk_predicate(self, binder: Binder<PredicateAtom<'tcx>>) -> Predicate<'tcx> {
2088+
pub fn mk_predicate(self, binder: Binder<PredicateKind<'tcx>>) -> Predicate<'tcx> {
20892089
let inner = self.interners.intern_predicate(binder);
20902090
Predicate { inner }
20912091
}
@@ -2094,9 +2094,9 @@ impl<'tcx> TyCtxt<'tcx> {
20942094
pub fn reuse_or_mk_predicate(
20952095
self,
20962096
pred: Predicate<'tcx>,
2097-
binder: Binder<PredicateAtom<'tcx>>,
2097+
binder: Binder<PredicateKind<'tcx>>,
20982098
) -> Predicate<'tcx> {
2099-
if pred.bound_atom() != binder { self.mk_predicate(binder) } else { pred }
2099+
if pred.kind() != binder { self.mk_predicate(binder) } else { pred }
21002100
}
21012101

21022102
pub fn mk_mach_int(self, tm: ast::IntTy) -> Ty<'tcx> {

compiler/rustc_middle/src/ty/flags.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ impl FlagComputation {
2222
result
2323
}
2424

25-
pub fn for_predicate(binder: ty::Binder<ty::PredicateAtom<'_>>) -> FlagComputation {
25+
pub fn for_predicate(binder: ty::Binder<ty::PredicateKind<'_>>) -> FlagComputation {
2626
let mut result = FlagComputation::new();
2727
result.add_predicate(binder);
2828
result
@@ -204,46 +204,46 @@ impl FlagComputation {
204204
}
205205
}
206206

207-
fn add_predicate(&mut self, binder: ty::Binder<ty::PredicateAtom<'_>>) {
207+
fn add_predicate(&mut self, binder: ty::Binder<ty::PredicateKind<'_>>) {
208208
self.bound_computation(binder, |computation, atom| computation.add_predicate_atom(atom));
209209
}
210210

211-
fn add_predicate_atom(&mut self, atom: ty::PredicateAtom<'_>) {
211+
fn add_predicate_atom(&mut self, atom: ty::PredicateKind<'_>) {
212212
match atom {
213-
ty::PredicateAtom::Trait(trait_pred, _constness) => {
213+
ty::PredicateKind::Trait(trait_pred, _constness) => {
214214
self.add_substs(trait_pred.trait_ref.substs);
215215
}
216-
ty::PredicateAtom::RegionOutlives(ty::OutlivesPredicate(a, b)) => {
216+
ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(a, b)) => {
217217
self.add_region(a);
218218
self.add_region(b);
219219
}
220-
ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(ty, region)) => {
220+
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty, region)) => {
221221
self.add_ty(ty);
222222
self.add_region(region);
223223
}
224-
ty::PredicateAtom::Subtype(ty::SubtypePredicate { a_is_expected: _, a, b }) => {
224+
ty::PredicateKind::Subtype(ty::SubtypePredicate { a_is_expected: _, a, b }) => {
225225
self.add_ty(a);
226226
self.add_ty(b);
227227
}
228-
ty::PredicateAtom::Projection(ty::ProjectionPredicate { projection_ty, ty }) => {
228+
ty::PredicateKind::Projection(ty::ProjectionPredicate { projection_ty, ty }) => {
229229
self.add_projection_ty(projection_ty);
230230
self.add_ty(ty);
231231
}
232-
ty::PredicateAtom::WellFormed(arg) => {
232+
ty::PredicateKind::WellFormed(arg) => {
233233
self.add_substs(slice::from_ref(&arg));
234234
}
235-
ty::PredicateAtom::ObjectSafe(_def_id) => {}
236-
ty::PredicateAtom::ClosureKind(_def_id, substs, _kind) => {
235+
ty::PredicateKind::ObjectSafe(_def_id) => {}
236+
ty::PredicateKind::ClosureKind(_def_id, substs, _kind) => {
237237
self.add_substs(substs);
238238
}
239-
ty::PredicateAtom::ConstEvaluatable(_def_id, substs) => {
239+
ty::PredicateKind::ConstEvaluatable(_def_id, substs) => {
240240
self.add_substs(substs);
241241
}
242-
ty::PredicateAtom::ConstEquate(expected, found) => {
242+
ty::PredicateKind::ConstEquate(expected, found) => {
243243
self.add_const(expected);
244244
self.add_const(found);
245245
}
246-
ty::PredicateAtom::TypeWellFormedFromEnv(ty) => {
246+
ty::PredicateKind::TypeWellFormedFromEnv(ty) => {
247247
self.add_ty(ty);
248248
}
249249
}

0 commit comments

Comments
 (0)