Skip to content

Commit f1dfc31

Browse files
committed
PredicateKint -> PredicateKind, the beginning of the end
1 parent 0f257a5 commit f1dfc31

File tree

47 files changed

+628
-669
lines changed

Some content is hidden

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

47 files changed

+628
-669
lines changed

src/librustc_infer/infer/canonical/query_response.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -531,12 +531,14 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
531531
GenericArg<'tcx>,
532532
ty::Region<'tcx>,
533533
>| match k1.unpack() {
534-
GenericArgKind::Lifetime(r1) => self.tcx.intern_predicate_kint(
535-
ty::PredicateKint::RegionOutlives(ty::OutlivesPredicate(r1, r2)),
536-
),
537-
GenericArgKind::Type(t1) => self.tcx.intern_predicate_kint(
538-
ty::PredicateKint::TypeOutlives(ty::OutlivesPredicate(t1, r2)),
539-
),
534+
GenericArgKind::Lifetime(r1) => {
535+
ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(r1, r2))
536+
.to_predicate(self.tcx)
537+
}
538+
GenericArgKind::Type(t1) => {
539+
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(t1, r2))
540+
.to_predicate(self.tcx)
541+
}
540542
GenericArgKind::Const(..) => {
541543
// Consts cannot outlive one another, so we don't expect to
542544
// ecounter this branch.
@@ -545,9 +547,9 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
545547
};
546548

547549
let predicate = if let Some(constraint) = constraint.no_bound_vars() {
548-
to_predicate(constraint).to_predicate(self.tcx)
550+
to_predicate(constraint)
549551
} else {
550-
ty::PredicateKint::ForAll(constraint.map_bound(to_predicate)).to_predicate(self.tcx)
552+
ty::PredicateKind::ForAll(constraint.map_bound(to_predicate)).to_predicate(self.tcx)
551553
};
552554

553555
Obligation::new(cause.clone(), param_env, predicate)
@@ -670,7 +672,7 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for QueryTypeRelatingDelegate<'_, 'tcx> {
670672
self.obligations.push(Obligation {
671673
cause: self.cause.clone(),
672674
param_env: self.param_env,
673-
predicate: ty::PredicateKint::RegionOutlives(ty::OutlivesPredicate(sup, sub))
675+
predicate: ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(sup, sub))
674676
.to_predicate(self.infcx.tcx),
675677
recursion_depth: 0,
676678
});

src/librustc_infer/infer/combine.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
307307
self.obligations.push(Obligation::new(
308308
self.trace.cause.clone(),
309309
self.param_env,
310-
ty::PredicateKint::WellFormed(b_ty.into()).to_predicate(self.infcx.tcx),
310+
ty::PredicateKind::WellFormed(b_ty.into()).to_predicate(self.infcx.tcx),
311311
));
312312
}
313313

@@ -398,9 +398,9 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
398398
b: &'tcx ty::Const<'tcx>,
399399
) {
400400
let predicate = if a_is_expected {
401-
ty::PredicateKint::ConstEquate(a, b)
401+
ty::PredicateKind::ConstEquate(a, b)
402402
} else {
403-
ty::PredicateKint::ConstEquate(b, a)
403+
ty::PredicateKind::ConstEquate(b, a)
404404
};
405405
self.obligations.push(Obligation::new(
406406
self.trace.cause.clone(),

src/librustc_infer/infer/outlives/mod.rs

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,23 @@ pub fn explicit_outlives_bounds<'tcx>(
1111
param_env: ty::ParamEnv<'tcx>,
1212
) -> impl Iterator<Item = OutlivesBound<'tcx>> + 'tcx {
1313
debug!("explicit_outlives_bounds()");
14-
param_env.caller_bounds.into_iter().filter_map(move |predicate| match predicate.kind() {
15-
ty::PredicateKind::Projection(..)
16-
| ty::PredicateKind::Trait(..)
17-
| ty::PredicateKind::Subtype(..)
18-
| ty::PredicateKind::WellFormed(..)
19-
| ty::PredicateKind::ObjectSafe(..)
20-
| ty::PredicateKind::ClosureKind(..)
21-
| ty::PredicateKind::TypeOutlives(..)
22-
| ty::PredicateKind::ConstEvaluatable(..)
23-
| ty::PredicateKind::ConstEquate(..) => None,
24-
ty::PredicateKind::RegionOutlives(ref data) => data
25-
.no_bound_vars()
26-
.map(|ty::OutlivesPredicate(r_a, r_b)| OutlivesBound::RegionSubRegion(r_b, r_a)),
27-
})
14+
param_env
15+
.caller_bounds
16+
.into_iter()
17+
.filter_map(|pred| pred.ignore_qualifiers().no_bound_vars())
18+
.filter_map(|pred| match pred.kind() {
19+
ty::PredicateKind::Projection(..)
20+
| ty::PredicateKind::Trait(..)
21+
| ty::PredicateKind::Subtype(..)
22+
| ty::PredicateKind::WellFormed(..)
23+
| ty::PredicateKind::ObjectSafe(..)
24+
| ty::PredicateKind::ClosureKind(..)
25+
| ty::PredicateKind::TypeOutlives(..)
26+
| ty::PredicateKind::ConstEvaluatable(..)
27+
| ty::PredicateKind::ConstEquate(..) => None,
28+
ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(r_a, r_b)) => {
29+
Some(OutlivesBound::RegionSubRegion(r_b, r_a))
30+
}
31+
ty::PredicateKind::ForAll(_) => bug!("unexpected_predicate: {:?}", pred),
32+
})
2833
}

src/librustc_infer/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::PredicateKint::Subtype(ty::SubtypePredicate {
103+
ty::PredicateKind::Subtype(ty::SubtypePredicate {
104104
a_is_expected: self.a_is_expected,
105105
a,
106106
b,

src/librustc_infer/traits/util.rs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,34 @@ pub fn anonymize_predicate<'tcx>(
1010
tcx: TyCtxt<'tcx>,
1111
pred: ty::Predicate<'tcx>,
1212
) -> ty::Predicate<'tcx> {
13-
let kind = pred.kint(tcx);
13+
let kind = pred.kind();
1414
let new = match kind {
15-
ty::PredicateKint::ForAll(binder) => {
16-
ty::PredicateKint::ForAll(tcx.anonymize_late_bound_regions(binder))
15+
ty::PredicateKind::ForAll(binder) => {
16+
ty::PredicateKind::ForAll(tcx.anonymize_late_bound_regions(binder))
1717
}
18-
&ty::PredicateKint::Trait(data, constness) => ty::PredicateKint::Trait(data, constness),
18+
&ty::PredicateKind::Trait(data, constness) => ty::PredicateKind::Trait(data, constness),
1919

20-
&ty::PredicateKint::RegionOutlives(data) => ty::PredicateKint::RegionOutlives(data),
20+
&ty::PredicateKind::RegionOutlives(data) => ty::PredicateKind::RegionOutlives(data),
2121

22-
&ty::PredicateKint::TypeOutlives(data) => ty::PredicateKint::TypeOutlives(data),
22+
&ty::PredicateKind::TypeOutlives(data) => ty::PredicateKind::TypeOutlives(data),
2323

24-
&ty::PredicateKint::Projection(data) => ty::PredicateKint::Projection(data),
24+
&ty::PredicateKind::Projection(data) => ty::PredicateKind::Projection(data),
2525

26-
&ty::PredicateKint::WellFormed(data) => ty::PredicateKint::WellFormed(data),
26+
&ty::PredicateKind::WellFormed(data) => ty::PredicateKind::WellFormed(data),
2727

28-
&ty::PredicateKint::ObjectSafe(data) => ty::PredicateKint::ObjectSafe(data),
28+
&ty::PredicateKind::ObjectSafe(data) => ty::PredicateKind::ObjectSafe(data),
2929

30-
&ty::PredicateKint::ClosureKind(closure_def_id, closure_substs, kind) => {
31-
ty::PredicateKint::ClosureKind(closure_def_id, closure_substs, kind)
30+
&ty::PredicateKind::ClosureKind(closure_def_id, closure_substs, kind) => {
31+
ty::PredicateKind::ClosureKind(closure_def_id, closure_substs, kind)
3232
}
3333

34-
&ty::PredicateKint::Subtype(data) => ty::PredicateKint::Subtype(data),
34+
&ty::PredicateKind::Subtype(data) => ty::PredicateKind::Subtype(data),
3535

36-
&ty::PredicateKint::ConstEvaluatable(def_id, substs) => {
37-
ty::PredicateKint::ConstEvaluatable(def_id, substs)
36+
&ty::PredicateKind::ConstEvaluatable(def_id, substs) => {
37+
ty::PredicateKind::ConstEvaluatable(def_id, substs)
3838
}
3939

40-
&ty::PredicateKint::ConstEquate(c1, c2) => ty::PredicateKint::ConstEquate(c1, c2),
40+
&ty::PredicateKind::ConstEquate(c1, c2) => ty::PredicateKind::ConstEquate(c1, c2),
4141
};
4242

4343
if new != *kind { new.to_predicate(tcx) } else { pred }
@@ -151,16 +151,16 @@ impl Elaborator<'tcx> {
151151

152152
fn elaborate(&mut self, obligation: &PredicateObligation<'tcx>) {
153153
let tcx = self.visited.tcx;
154-
let pred = match obligation.predicate.kint(tcx) {
155-
// We have to be careful and rebind this whenever
154+
let pred = match obligation.predicate.kind() {
155+
// We have to be careful and rebind this when
156156
// dealing with a predicate further down.
157-
ty::PredicateKint::ForAll(binder) => binder.skip_binder(),
157+
ty::PredicateKind::ForAll(binder) => binder.skip_binder().kind(),
158158
pred => pred,
159159
};
160160

161161
match pred {
162-
ty::PredicateKint::ForAll(_) => bug!("unexpected predicate: {:?}", pred),
163-
ty::PredicateKint::Trait(ref data, _) => {
162+
ty::PredicateKind::ForAll(_) => bug!("unexpected predicate: {:?}", pred),
163+
ty::PredicateKind::Trait(data, _) => {
164164
// Get predicates declared on the trait.
165165
let predicates = tcx.super_predicates_of(data.def_id());
166166

@@ -181,36 +181,36 @@ impl Elaborator<'tcx> {
181181

182182
self.stack.extend(obligations);
183183
}
184-
ty::PredicateKint::WellFormed(..) => {
184+
ty::PredicateKind::WellFormed(..) => {
185185
// Currently, we do not elaborate WF predicates,
186186
// although we easily could.
187187
}
188-
ty::PredicateKint::ObjectSafe(..) => {
188+
ty::PredicateKind::ObjectSafe(..) => {
189189
// Currently, we do not elaborate object-safe
190190
// predicates.
191191
}
192-
ty::PredicateKint::Subtype(..) => {
192+
ty::PredicateKind::Subtype(..) => {
193193
// Currently, we do not "elaborate" predicates like `X <: Y`,
194194
// though conceivably we might.
195195
}
196-
ty::PredicateKint::Projection(..) => {
196+
ty::PredicateKind::Projection(..) => {
197197
// Nothing to elaborate in a projection predicate.
198198
}
199-
ty::PredicateKint::ClosureKind(..) => {
199+
ty::PredicateKind::ClosureKind(..) => {
200200
// Nothing to elaborate when waiting for a closure's kind to be inferred.
201201
}
202-
ty::PredicateKint::ConstEvaluatable(..) => {
202+
ty::PredicateKind::ConstEvaluatable(..) => {
203203
// Currently, we do not elaborate const-evaluatable
204204
// predicates.
205205
}
206-
ty::PredicateKint::ConstEquate(..) => {
206+
ty::PredicateKind::ConstEquate(..) => {
207207
// Currently, we do not elaborate const-equate
208208
// predicates.
209209
}
210-
ty::PredicateKint::RegionOutlives(..) => {
210+
ty::PredicateKind::RegionOutlives(..) => {
211211
// Nothing to elaborate from `'a: 'b`.
212212
}
213-
ty::PredicateKint::TypeOutlives(ty::OutlivesPredicate(ty_max, r_min)) => {
213+
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty_max, r_min)) => {
214214
// We know that `T: 'a` for some type `T`. We can
215215
// often elaborate this. For example, if we know that
216216
// `[U]: 'a`, that implies that `U: 'a`. Similarly, if
@@ -240,15 +240,15 @@ impl Elaborator<'tcx> {
240240
if r.is_late_bound() {
241241
None
242242
} else {
243-
Some(ty::PredicateKint::RegionOutlives(ty::OutlivesPredicate(
243+
Some(ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(
244244
r, r_min,
245245
)))
246246
}
247247
}
248248

249249
Component::Param(p) => {
250250
let ty = tcx.mk_ty_param(p.index, p.name);
251-
Some(ty::PredicateKint::TypeOutlives(ty::OutlivesPredicate(
251+
Some(ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(
252252
ty, r_min,
253253
)))
254254
}

src/librustc_lint/builtin.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,15 +1206,15 @@ declare_lint_pass!(
12061206
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TrivialConstraints {
12071207
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item<'tcx>) {
12081208
use rustc_middle::ty::fold::TypeFoldable;
1209-
use rustc_middle::ty::PredicateKint::*;
1209+
use rustc_middle::ty::PredicateKind::*;
12101210

12111211
if cx.tcx.features().trivial_bounds {
12121212
let def_id = cx.tcx.hir().local_def_id(item.hir_id);
12131213
let predicates = cx.tcx.predicates_of(def_id);
12141214
for &(predicate, span) in predicates.predicates {
12151215
// We don't actually look inside of the predicate,
12161216
// so it is safe to skip this binder here.
1217-
let predicate_kind_name = match predicate.kint(cx.tcx).ignore_qualifiers().skip_binder() {
1217+
let predicate_kind_name = match predicate.ignore_qualifiers().skip_binder().kind() {
12181218
Trait(..) => "Trait",
12191219
TypeOutlives(..) |
12201220
RegionOutlives(..) => "Lifetime",
@@ -1504,14 +1504,11 @@ impl ExplicitOutlivesRequirements {
15041504
) -> Vec<ty::Region<'tcx>> {
15051505
inferred_outlives
15061506
.iter()
1507-
.filter_map(|(pred, _)| match pred.kind() {
1508-
ty::PredicateKind::RegionOutlives(outlives) => {
1509-
let outlives = outlives.skip_binder();
1510-
match outlives.0 {
1511-
ty::ReEarlyBound(ebr) if ebr.index == index => Some(outlives.1),
1512-
_ => None,
1513-
}
1514-
}
1507+
.filter_map(|(pred, _)| match pred.ignore_qualifiers().skip_binder().kind() {
1508+
&ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(a, b)) => match a {
1509+
ty::ReEarlyBound(ebr) if ebr.index == index => Some(b),
1510+
_ => None,
1511+
},
15151512
_ => None,
15161513
})
15171514
.collect()
@@ -1523,10 +1520,9 @@ impl ExplicitOutlivesRequirements {
15231520
) -> Vec<ty::Region<'tcx>> {
15241521
inferred_outlives
15251522
.iter()
1526-
.filter_map(|(pred, _)| match pred.kind() {
1527-
ty::PredicateKind::TypeOutlives(outlives) => {
1528-
let outlives = outlives.skip_binder();
1529-
outlives.0.is_param(index).then_some(outlives.1)
1523+
.filter_map(|(pred, _)| match pred.ignore_qualifiers().skip_binder().kind() {
1524+
&ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(a, b)) => {
1525+
a.is_param(index).then_some(b)
15301526
}
15311527
_ => None,
15321528
})

src/librustc_lint/unused.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
147147
let mut has_emitted = false;
148148
for (predicate, _) in cx.tcx.predicates_of(def).predicates {
149149
// We only look at the `DefId`, so it is safe to skip the binder here.
150-
if let ty::PredicateKint::Trait(ref poly_trait_predicate, _) =
151-
predicate.kint(cx.tcx).ignore_qualifiers().skip_binder()
150+
if let ty::PredicateKind::Trait(ref poly_trait_predicate, _) =
151+
predicate.ignore_qualifiers().skip_binder().kind()
152152
{
153153
let def_id = poly_trait_predicate.trait_ref.def_id;
154154
let descr_pre =

src/librustc_middle/ty/codec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl<'tcx> EncodableWithShorthand for Ty<'tcx> {
3939
}
4040

4141
impl<'tcx> EncodableWithShorthand for ty::Predicate<'tcx> {
42-
type Variant = ty::PredicateKynd<'tcx>;
42+
type Variant = ty::PredicateKind<'tcx>;
4343
fn variant(&self) -> &Self::Variant {
4444
self.kind()
4545
}
@@ -195,7 +195,7 @@ where
195195
})
196196
} else {
197197
let tcx = decoder.tcx();
198-
Ok(tcx.mk_predicate(ty::PredicateKynd::decode(decoder)?))
198+
Ok(tcx.mk_predicate(ty::PredicateKind::decode(decoder)?))
199199
}
200200
}
201201

src/librustc_middle/ty/context.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ use crate::ty::{
2020
self, query, AdtDef, AdtKind, BindingMode, BoundVar, CanonicalPolyFnSig, Const, ConstVid,
2121
DefIdTree, ExistentialPredicate, FloatVar, FloatVid, GenericParamDefKind, InferConst, InferTy,
2222
IntVar, IntVid, List, ParamConst, ParamTy, PolyFnSig, Predicate, PredicateInner, PredicateKind,
23-
PredicateKint, ProjectionTy, Region, RegionKind, ReprOptions, TraitObjectVisitor, Ty, TyKind,
24-
TyS, TyVar, TyVid, TypeAndMut,
23+
ProjectionTy, Region, RegionKind, ReprOptions, TraitObjectVisitor, Ty, TyKind, TyS, TyVar,
24+
TyVid, TypeAndMut,
2525
};
2626
use rustc_ast::ast;
2727
use rustc_ast::expand::allocator::AllocatorKind;
@@ -79,7 +79,6 @@ pub struct CtxtInterners<'tcx> {
7979
region: InternedSet<'tcx, RegionKind>,
8080
existential_predicates: InternedSet<'tcx, List<ExistentialPredicate<'tcx>>>,
8181
predicate: InternedSet<'tcx, PredicateInner<'tcx>>,
82-
predicate_kint: InternedSet<'tcx, PredicateKint<'tcx>>,
8382
predicates: InternedSet<'tcx, List<Predicate<'tcx>>>,
8483
projs: InternedSet<'tcx, List<ProjectionKind>>,
8584
place_elems: InternedSet<'tcx, List<PlaceElem<'tcx>>>,
@@ -99,7 +98,6 @@ impl<'tcx> CtxtInterners<'tcx> {
9998
existential_predicates: Default::default(),
10099
canonical_var_infos: Default::default(),
101100
predicate: Default::default(),
102-
predicate_kint: Default::default(),
103101
predicates: Default::default(),
104102
projs: Default::default(),
105103
place_elems: Default::default(),
@@ -1628,7 +1626,6 @@ nop_lift! {type_; Ty<'a> => Ty<'tcx>}
16281626
nop_lift! {region; Region<'a> => Region<'tcx>}
16291627
nop_lift! {const_; &'a Const<'a> => &'tcx Const<'tcx>}
16301628
nop_lift! {predicate; &'a PredicateInner<'a> => &'tcx PredicateInner<'tcx>}
1631-
nop_lift! {predicate_kint; &'a PredicateKint<'a> => &'tcx PredicateKint<'tcx>}
16321629

16331630
nop_list_lift! {type_list; Ty<'a> => Ty<'tcx>}
16341631
nop_list_lift! {existential_predicates; ExistentialPredicate<'a> => ExistentialPredicate<'tcx>}
@@ -2041,8 +2038,8 @@ impl<'tcx> Borrow<Const<'tcx>> for Interned<'tcx, Const<'tcx>> {
20412038
}
20422039
}
20432040

2044-
impl<'tcx> Borrow<PredicateKint<'tcx>> for Interned<'tcx, PredicateKint<'tcx>> {
2045-
fn borrow<'a>(&'a self) -> &'a PredicateKint<'tcx> {
2041+
impl<'tcx> Borrow<PredicateKind<'tcx>> for Interned<'tcx, PredicateKind<'tcx>> {
2042+
fn borrow<'a>(&'a self) -> &'a PredicateKind<'tcx> {
20462043
&self.0
20472044
}
20482045
}
@@ -2076,7 +2073,6 @@ macro_rules! direct_interners {
20762073
direct_interners! {
20772074
region: mk_region(RegionKind),
20782075
const_: mk_const(Const<'tcx>),
2079-
predicate_kint: intern_predicate_kint(PredicateKint<'tcx>),
20802076
}
20812077

20822078
macro_rules! slice_interners {

0 commit comments

Comments
 (0)