Skip to content

Commit 653f56a

Browse files
committed
wf
1 parent c1d244f commit 653f56a

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

src/librustc_trait_selection/traits/wf.rs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -88,33 +88,35 @@ pub fn predicate_obligations<'a, 'tcx>(
8888
infcx: &InferCtxt<'a, 'tcx>,
8989
param_env: ty::ParamEnv<'tcx>,
9090
body_id: hir::HirId,
91-
predicate: ty::Predicate<'tcx>,
91+
predicate: &'tcx ty::PredicateKint<'tcx>,
9292
span: Span,
9393
) -> Vec<traits::PredicateObligation<'tcx>> {
9494
let mut wf = WfPredicates { infcx, param_env, body_id, span, out: vec![], item: None };
9595

96-
// (*) ok to skip binders, because wf code is prepared for it
97-
match predicate.kind() {
98-
ty::PredicateKind::Trait(t, _) => {
99-
wf.compute_trait_ref(&t.skip_binder().trait_ref, Elaborate::None); // (*)
96+
match predicate {
97+
ty::PredicateKint::ForAll(binder) => {
98+
// It's ok to skip the binder here because wf code is prepared for it
99+
return predicate_obligations(infcx, param_env, body_id, *binder.skip_binder(), span);
100100
}
101-
ty::PredicateKind::RegionOutlives(..) => {}
102-
ty::PredicateKind::TypeOutlives(t) => {
103-
wf.compute(t.skip_binder().0.into());
101+
ty::PredicateKint::Trait(t, _) => {
102+
wf.compute_trait_ref(&t.trait_ref, Elaborate::None);
104103
}
105-
ty::PredicateKind::Projection(t) => {
106-
let t = t.skip_binder(); // (*)
104+
ty::PredicateKint::RegionOutlives(..) => {}
105+
&ty::PredicateKint::TypeOutlives(ty::OutlivesPredicate(ty, _reg)) => {
106+
wf.compute(ty.into());
107+
}
108+
ty::PredicateKint::Projection(t) => {
107109
wf.compute_projection(t.projection_ty);
108110
wf.compute(t.ty.into());
109111
}
110-
&ty::PredicateKind::WellFormed(arg) => {
112+
&ty::PredicateKint::WellFormed(arg) => {
111113
wf.compute(arg);
112114
}
113-
ty::PredicateKind::ObjectSafe(_) => {}
114-
ty::PredicateKind::ClosureKind(..) => {}
115-
ty::PredicateKind::Subtype(data) => {
116-
wf.compute(data.skip_binder().a.into()); // (*)
117-
wf.compute(data.skip_binder().b.into()); // (*)
115+
ty::PredicateKint::ObjectSafe(_) => {}
116+
ty::PredicateKint::ClosureKind(..) => {}
117+
&ty::PredicateKint::Subtype(ty::SubtypePredicate { a, b, a_is_expected: _ }) => {
118+
wf.compute(a.into());
119+
wf.compute(b.into());
118120
}
119121
&ty::PredicateKind::ConstEvaluatable(def, substs) => {
120122
let obligations = wf.nominal_obligations(def.did, substs);
@@ -124,7 +126,7 @@ pub fn predicate_obligations<'a, 'tcx>(
124126
wf.compute(arg);
125127
}
126128
}
127-
&ty::PredicateKind::ConstEquate(c1, c2) => {
129+
&ty::PredicateKint::ConstEquate(c1, c2) => {
128130
wf.compute(c1.into());
129131
wf.compute(c2.into());
130132
}

src/librustc_typeck/check/wfcheck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ fn check_where_clauses<'tcx, 'fcx>(
829829
assert_eq!(predicates.predicates.len(), predicates.spans.len());
830830
let wf_obligations =
831831
predicates.predicates.iter().zip(predicates.spans.iter()).flat_map(|(&p, &sp)| {
832-
traits::wf::predicate_obligations(fcx, fcx.param_env, fcx.body_id, p, sp)
832+
traits::wf::predicate_obligations(fcx, fcx.param_env, fcx.body_id, p.kint(tcx), sp)
833833
});
834834

835835
for obligation in wf_obligations.chain(default_obligations) {

0 commit comments

Comments
 (0)