From 653f56af53c01c38f34f0926dd13ee391a290fa0 Mon Sep 17 00:00:00 2001 From: Bastian Kauschke Date: Wed, 17 Jun 2020 22:50:28 +0200 Subject: [PATCH] wf --- src/librustc_trait_selection/traits/wf.rs | 36 ++++++++++++----------- src/librustc_typeck/check/wfcheck.rs | 2 +- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/librustc_trait_selection/traits/wf.rs b/src/librustc_trait_selection/traits/wf.rs index 4eb1d1856fb..333f90d78a7 100644 --- a/src/librustc_trait_selection/traits/wf.rs +++ b/src/librustc_trait_selection/traits/wf.rs @@ -88,33 +88,35 @@ pub fn predicate_obligations<'a, 'tcx>( infcx: &InferCtxt<'a, 'tcx>, param_env: ty::ParamEnv<'tcx>, body_id: hir::HirId, - predicate: ty::Predicate<'tcx>, + predicate: &'tcx ty::PredicateKint<'tcx>, span: Span, ) -> Vec> { let mut wf = WfPredicates { infcx, param_env, body_id, span, out: vec![], item: None }; - // (*) ok to skip binders, because wf code is prepared for it - match predicate.kind() { - ty::PredicateKind::Trait(t, _) => { - wf.compute_trait_ref(&t.skip_binder().trait_ref, Elaborate::None); // (*) + match predicate { + ty::PredicateKint::ForAll(binder) => { + // It's ok to skip the binder here because wf code is prepared for it + return predicate_obligations(infcx, param_env, body_id, *binder.skip_binder(), span); } - ty::PredicateKind::RegionOutlives(..) => {} - ty::PredicateKind::TypeOutlives(t) => { - wf.compute(t.skip_binder().0.into()); + ty::PredicateKint::Trait(t, _) => { + wf.compute_trait_ref(&t.trait_ref, Elaborate::None); } - ty::PredicateKind::Projection(t) => { - let t = t.skip_binder(); // (*) + ty::PredicateKint::RegionOutlives(..) => {} + &ty::PredicateKint::TypeOutlives(ty::OutlivesPredicate(ty, _reg)) => { + wf.compute(ty.into()); + } + ty::PredicateKint::Projection(t) => { wf.compute_projection(t.projection_ty); wf.compute(t.ty.into()); } - &ty::PredicateKind::WellFormed(arg) => { + &ty::PredicateKint::WellFormed(arg) => { wf.compute(arg); } - ty::PredicateKind::ObjectSafe(_) => {} - ty::PredicateKind::ClosureKind(..) => {} - ty::PredicateKind::Subtype(data) => { - wf.compute(data.skip_binder().a.into()); // (*) - wf.compute(data.skip_binder().b.into()); // (*) + ty::PredicateKint::ObjectSafe(_) => {} + ty::PredicateKint::ClosureKind(..) => {} + &ty::PredicateKint::Subtype(ty::SubtypePredicate { a, b, a_is_expected: _ }) => { + wf.compute(a.into()); + wf.compute(b.into()); } &ty::PredicateKind::ConstEvaluatable(def, substs) => { let obligations = wf.nominal_obligations(def.did, substs); @@ -124,7 +126,7 @@ pub fn predicate_obligations<'a, 'tcx>( wf.compute(arg); } } - &ty::PredicateKind::ConstEquate(c1, c2) => { + &ty::PredicateKint::ConstEquate(c1, c2) => { wf.compute(c1.into()); wf.compute(c2.into()); } diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index dabae6cbc41..aa40d7de6e0 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -829,7 +829,7 @@ fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> bool { assert_eq!(predicates.predicates.len(), predicates.spans.len()); let wf_obligations = predicates.predicates.iter().zip(predicates.spans.iter()).flat_map(|(&p, &sp)| { - traits::wf::predicate_obligations(fcx, fcx.param_env, fcx.body_id, p, sp) + traits::wf::predicate_obligations(fcx, fcx.param_env, fcx.body_id, p.kint(tcx), sp) }); for obligation in wf_obligations.chain(default_obligations) { -- 2.44.0