Skip to content

Commit 8b8d01e

Browse files
Migrate caller bounds and predicates_of
1 parent 020c36e commit 8b8d01e

File tree

38 files changed

+162
-230
lines changed

38 files changed

+162
-230
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ dependencies = [
6767

6868
[[package]]
6969
name = "allocator-api2"
70-
version = "0.2.14"
70+
version = "0.2.15"
7171
source = "registry+https://github.com/rust-lang/crates.io-index"
72-
checksum = "c4f263788a35611fba42eb41ff811c5d0360c58b97402570312a350736e2542e"
72+
checksum = "56fc6cf8dc8c4158eed8649f9b8b0ea1518eb62b544fe9490d66fa0b349eafe9"
7373

7474
[[package]]
7575
name = "ammonia"

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ fn compare_method_predicate_entailment<'tcx>(
220220
// the new hybrid bounds we computed.
221221
let normalize_cause = traits::ObligationCause::misc(impl_m_span, impl_m_def_id);
222222
let param_env = ty::ParamEnv::new(
223-
tcx.mk_predicates(&hybrid_preds.predicates),
223+
tcx.mk_clauses(&hybrid_preds.predicates),
224224
Reveal::UserFacing,
225225
hir::Constness::NotConst,
226226
);
@@ -1835,7 +1835,7 @@ fn compare_type_predicate_entailment<'tcx>(
18351835
let impl_ty_span = tcx.def_span(impl_ty_def_id);
18361836
let normalize_cause = traits::ObligationCause::misc(impl_ty_span, impl_ty_def_id);
18371837
let param_env = ty::ParamEnv::new(
1838-
tcx.mk_predicates(&hybrid_preds.predicates),
1838+
tcx.mk_clauses(&hybrid_preds.predicates),
18391839
Reveal::UserFacing,
18401840
hir::Constness::NotConst,
18411841
);
@@ -2011,7 +2011,7 @@ pub(super) fn check_type_bounds<'tcx>(
20112011
.to_predicate(tcx),
20122012
),
20132013
};
2014-
ty::ParamEnv::new(tcx.mk_predicates(&predicates), Reveal::UserFacing, param_env.constness())
2014+
ty::ParamEnv::new(tcx.mk_clauses(&predicates), Reveal::UserFacing, param_env.constness())
20152015
};
20162016
debug!(?normalize_param_env);
20172017

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ fn augment_param_env<'tcx>(
498498
return param_env;
499499
}
500500

501-
let bounds = tcx.mk_predicates_from_iter(
501+
let bounds = tcx.mk_clauses_from_iter(
502502
param_env.caller_bounds().iter().chain(new_predicates.iter().cloned()),
503503
);
504504
// FIXME(compiler-errors): Perhaps there is a case where we need to normalize this

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

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,18 @@ pub fn explicit_outlives_bounds<'tcx>(
2020
param_env
2121
.caller_bounds()
2222
.into_iter()
23-
.map(ty::Predicate::kind)
23+
.map(ty::Clause::kind)
2424
.filter_map(ty::Binder::no_bound_vars)
2525
.filter_map(move |kind| match kind {
26-
ty::PredicateKind::Clause(ty::ClauseKind::Projection(..))
27-
| ty::PredicateKind::Clause(ty::ClauseKind::Trait(..))
28-
| ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(..))
29-
| ty::PredicateKind::AliasRelate(..)
30-
| ty::PredicateKind::Coerce(..)
31-
| ty::PredicateKind::Subtype(..)
32-
| ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(..))
33-
| ty::PredicateKind::ObjectSafe(..)
34-
| ty::PredicateKind::ClosureKind(..)
35-
| ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(..))
36-
| ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..))
37-
| ty::PredicateKind::ConstEquate(..)
38-
| ty::PredicateKind::Ambiguous
39-
| ty::PredicateKind::TypeWellFormedFromEnv(..) => None,
40-
ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(ty::OutlivesPredicate(
41-
r_a,
42-
r_b,
43-
))) => Some(OutlivesBound::RegionSubRegion(r_b, r_a)),
26+
ty::ClauseKind::RegionOutlives(ty::OutlivesPredicate(r_a, r_b)) => {
27+
Some(OutlivesBound::RegionSubRegion(r_b, r_a))
28+
}
29+
ty::ClauseKind::Trait(_)
30+
| ty::ClauseKind::TypeOutlives(_)
31+
| ty::ClauseKind::Projection(_)
32+
| ty::ClauseKind::ConstArgHasType(_, _)
33+
| ty::ClauseKind::WellFormed(_)
34+
| ty::ClauseKind::ConstEvaluatable(_) => None,
4435
})
4536
}
4637

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
223223
// parameter environments are already elaborated, so we don't
224224
// have to worry about that.
225225
let c_b = self.param_env.caller_bounds();
226-
let param_bounds = self.collect_outlives_from_predicate_list(erased_ty, c_b.into_iter());
226+
let param_bounds = self.collect_outlives_from_clause_list(erased_ty, c_b.into_iter());
227227

228228
// Next, collect regions we scraped from the well-formedness
229229
// constraints in the fn signature. To do that, we walk the list
@@ -307,15 +307,15 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
307307
/// when comparing `ty` for equality, so `ty` must be something
308308
/// that does not involve inference variables and where you
309309
/// otherwise want a precise match.
310-
fn collect_outlives_from_predicate_list(
310+
fn collect_outlives_from_clause_list(
311311
&self,
312312
erased_ty: Ty<'tcx>,
313-
predicates: impl Iterator<Item = ty::Predicate<'tcx>>,
313+
clauses: impl Iterator<Item = ty::Clause<'tcx>>,
314314
) -> impl Iterator<Item = ty::Binder<'tcx, ty::OutlivesPredicate<Ty<'tcx>, ty::Region<'tcx>>>>
315315
{
316316
let tcx = self.tcx;
317317
let param_env = self.param_env;
318-
predicates.filter_map(|p| p.to_opt_type_outlives()).filter(move |outlives_predicate| {
318+
clauses.filter_map(|p| p.as_type_outlives_clause()).filter(move |outlives_predicate| {
319319
super::test_type_match::can_match_erased_ty(
320320
tcx,
321321
param_env,

compiler/rustc_infer/src/traits/util.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ impl<'tcx, O: Elaboratable<'tcx>> Elaborator<'tcx, O> {
258258
pred = pred.without_const(tcx);
259259
}
260260
elaboratable.child_with_derived_cause(
261-
pred.subst_supertrait(tcx, &bound_predicate.rebind(data.trait_ref)),
261+
pred.subst_supertrait(tcx, &bound_predicate.rebind(data.trait_ref))
262+
.as_predicate(),
262263
span,
263264
bound_predicate.rebind(data),
264265
index,
@@ -440,7 +441,7 @@ pub fn transitive_bounds_that_define_assoc_item<'tcx>(
440441
tcx.super_predicates_that_define_assoc_item((trait_ref.def_id(), assoc_name));
441442
for (super_predicate, _) in super_predicates.predicates {
442443
let subst_predicate = super_predicate.subst_supertrait(tcx, &trait_ref);
443-
if let Some(binder) = subst_predicate.to_opt_poly_trait_pred() {
444+
if let Some(binder) = subst_predicate.as_trait_clause() {
444445
stack.push(binder.map_bound(|t| t.trait_ref));
445446
}
446447
}

compiler/rustc_metadata/src/rmeta/decoder.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -636,12 +636,6 @@ impl<'a, 'tcx> Decodable<DecodeContext<'a, 'tcx>> for Symbol {
636636
}
637637
}
638638

639-
impl<'a, 'tcx> Decodable<DecodeContext<'a, 'tcx>> for &'tcx [(ty::Predicate<'tcx>, Span)] {
640-
fn decode(d: &mut DecodeContext<'a, 'tcx>) -> Self {
641-
ty::codec::RefDecodable::decode(d)
642-
}
643-
}
644-
645639
impl<'a, 'tcx> Decodable<DecodeContext<'a, 'tcx>> for &'tcx [(ty::Clause<'tcx>, Span)] {
646640
fn decode(d: &mut DecodeContext<'a, 'tcx>) -> Self {
647641
ty::codec::RefDecodable::decode(d)

compiler/rustc_middle/src/query/keys.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ impl<'tcx> Key for (Ty<'tcx>, Ty<'tcx>) {
420420
}
421421
}
422422

423-
impl<'tcx> Key for &'tcx ty::List<ty::Predicate<'tcx>> {
423+
impl<'tcx> Key for &'tcx ty::List<ty::Clause<'tcx>> {
424424
type CacheSelector = DefaultCacheSelector<Self>;
425425

426426
fn default_span(&self, _: TyCtxt<'_>) -> Span {

compiler/rustc_middle/src/query/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2112,7 +2112,7 @@ rustc_queries! {
21122112
desc { "resolving instance `{}`", ty::Instance::new(key.value.0, key.value.1) }
21132113
}
21142114

2115-
query reveal_opaque_types_in_bounds(key: &'tcx ty::List<ty::Predicate<'tcx>>) -> &'tcx ty::List<ty::Predicate<'tcx>> {
2115+
query reveal_opaque_types_in_bounds(key: &'tcx ty::List<ty::Clause<'tcx>>) -> &'tcx ty::List<ty::Clause<'tcx>> {
21162116
desc { "revealing opaque types in `{:?}`", key }
21172117
}
21182118

compiler/rustc_middle/src/query/on_disk_cache.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -791,13 +791,6 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>>
791791
}
792792
}
793793

794-
impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for &'tcx [(ty::Predicate<'tcx>, Span)] {
795-
#[inline]
796-
fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Self {
797-
RefDecodable::decode(d)
798-
}
799-
}
800-
801794
impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for &'tcx [(ty::Clause<'tcx>, Span)] {
802795
#[inline]
803796
fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Self {

0 commit comments

Comments
 (0)