1
Fork 0

Fix rebase

This commit is contained in:
Matthew Jasper 2020-08-14 21:41:20 +01:00
parent e29765250b
commit d08ab945de
29 changed files with 120 additions and 200 deletions

View file

@ -1225,18 +1225,19 @@ pub fn check_type_bounds<'tcx>(
let impl_ty_hir_id = tcx.hir().local_def_id_to_hir_id(impl_ty.def_id.expect_local());
let normalize_cause = traits::ObligationCause::misc(impl_ty_span, impl_ty_hir_id);
let cause = ObligationCause::new(
impl_ty_span,
impl_ty_hir_id,
ObligationCauseCode::ItemObligation(trait_ty.def_id),
);
let mk_cause = |span| {
ObligationCause::new(
impl_ty_span,
impl_ty_hir_id,
ObligationCauseCode::BindingObligation(trait_ty.def_id, span),
)
};
let obligations = tcx
.explicit_item_bounds(trait_ty.def_id)
.iter()
.map(|&(bound, span)| {
let concrete_ty_bound =
traits::subst_assoc_item_bound(tcx, bound, impl_ty_value, rebased_substs);
let concrete_ty_bound = bound.subst(tcx, rebased_substs);
debug!("check_type_bounds: concrete_ty_bound = {:?}", concrete_ty_bound);
traits::Obligation::new(mk_cause(span), param_env, concrete_ty_bound)
@ -1244,17 +1245,15 @@ pub fn check_type_bounds<'tcx>(
.collect();
debug!("check_type_bounds: item_bounds={:?}", obligations);
for obligation in util::elaborate_obligations(tcx, obligations) {
let concrete_ty_predicate = predicate.subst(tcx, rebased_substs);
debug!("compare_projection_bounds: concrete predicate = {:?}", concrete_ty_predicate);
for mut obligation in util::elaborate_obligations(tcx, obligations) {
let traits::Normalized { value: normalized_predicate, obligations } = traits::normalize(
&mut selcx,
normalize_param_env,
normalize_cause.clone(),
&concrete_ty_predicate,
&obligation.predicate,
);
debug!("compare_projection_bounds: normalized predicate = {:?}", normalized_predicate);
obligation.predicate = normalized_predicate;
inh.register_predicates(obligations);
inh.register_predicate(obligation);

View file

@ -2137,8 +2137,8 @@ fn explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredicat
// associated type:
// * It must use the identity substs of the item.
// * Since any generic parameters on the item are not in scope,
// this means that the item is not a GAT, and its identity substs
// are the same as the trait's.
// this means that the item is not a GAT, and its identity
// substs are the same as the trait's.
// * It must be an associated type for this trait (*not* a
// supertrait).
if let ty::Projection(projection) = ty.kind {
@ -2158,14 +2158,12 @@ fn explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredicat
.predicates
.iter()
.copied()
.filter(|(pred, _)| match pred.kind() {
ty::PredicateKind::Trait(tr, _) => !is_assoc_item_ty(tr.skip_binder().self_ty()),
ty::PredicateKind::Projection(proj) => {
!is_assoc_item_ty(proj.skip_binder().projection_ty.self_ty())
}
ty::PredicateKind::TypeOutlives(outlives) => {
!is_assoc_item_ty(outlives.skip_binder().0)
.filter(|(pred, _)| match pred.skip_binders() {
ty::PredicateAtom::Trait(tr, _) => !is_assoc_item_ty(tr.self_ty()),
ty::PredicateAtom::Projection(proj) => {
!is_assoc_item_ty(proj.projection_ty.self_ty())
}
ty::PredicateAtom::TypeOutlives(outlives) => !is_assoc_item_ty(outlives.0),
_ => true,
})
.collect();

View file

@ -37,12 +37,10 @@ fn associated_type_bounds<'tcx>(
let trait_predicates = tcx.trait_explicit_predicates_and_bounds(trait_def_id.expect_local());
let bounds_from_parent =
trait_predicates.predicates.iter().copied().filter(|(pred, _)| match pred.kind() {
ty::PredicateKind::Trait(tr, _) => tr.skip_binder().self_ty() == item_ty,
ty::PredicateKind::Projection(proj) => {
proj.skip_binder().projection_ty.self_ty() == item_ty
}
ty::PredicateKind::TypeOutlives(outlives) => outlives.skip_binder().0 == item_ty,
trait_predicates.predicates.iter().copied().filter(|(pred, _)| match pred.skip_binders() {
ty::PredicateAtom::Trait(tr, _) => tr.self_ty() == item_ty,
ty::PredicateAtom::Projection(proj) => proj.projection_ty.self_ty() == item_ty,
ty::PredicateAtom::TypeOutlives(outlives) => outlives.0 == item_ty,
_ => false,
});