Skip to content

Commit 5e482d6

Browse files
committed
wf
1 parent cd66ced commit 5e482d6

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

src/librustc_trait_selection/traits/wf.rs

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -88,43 +88,45 @@ 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
}
119-
&ty::PredicateKind::ConstEvaluatable(def_id, substs) => {
121+
&ty::PredicateKint::ConstEvaluatable(def_id, substs) => {
120122
let obligations = wf.nominal_obligations(def_id, substs);
121123
wf.out.extend(obligations);
122124

123125
for arg in substs.iter() {
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
@@ -817,7 +817,7 @@ fn check_where_clauses<'tcx, 'fcx>(
817817
assert_eq!(predicates.predicates.len(), predicates.spans.len());
818818
let wf_obligations =
819819
predicates.predicates.iter().zip(predicates.spans.iter()).flat_map(|(&p, &sp)| {
820-
traits::wf::predicate_obligations(fcx, fcx.param_env, fcx.body_id, p, sp)
820+
traits::wf::predicate_obligations(fcx, fcx.param_env, fcx.body_id, p.kint(tcx), sp)
821821
});
822822

823823
for obligation in wf_obligations.chain(default_obligations) {

0 commit comments

Comments
 (0)