Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
convert trivial predicates
  • Loading branch information
lcnr committed Jul 27, 2020
commit c1d244ffd881f59f1c8e5b7bdce38a1a80a0f7d6
6 changes: 2 additions & 4 deletions src/librustc_infer/infer/canonical/query_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -670,10 +670,8 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for QueryTypeRelatingDelegate<'_, 'tcx> {
self.obligations.push(Obligation {
cause: self.cause.clone(),
param_env: self.param_env,
predicate: ty::PredicateKind::RegionOutlives(ty::Binder::dummy(ty::OutlivesPredicate(
sup, sub,
)))
.to_predicate(self.infcx.tcx),
predicate: ty::PredicateKint::RegionOutlives(ty::OutlivesPredicate(sup, sub))
.to_predicate(self.infcx.tcx),
recursion_depth: 0,
});
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_infer/infer/combine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
self.obligations.push(Obligation::new(
self.trace.cause.clone(),
self.param_env,
ty::PredicateKind::WellFormed(b_ty.into()).to_predicate(self.infcx.tcx),
ty::PredicateKint::WellFormed(b_ty.into()).to_predicate(self.infcx.tcx),
));
}

Expand Down Expand Up @@ -400,9 +400,9 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
b: &'tcx ty::Const<'tcx>,
) {
let predicate = if a_is_expected {
ty::PredicateKind::ConstEquate(a, b)
ty::PredicateKint::ConstEquate(a, b)
} else {
ty::PredicateKind::ConstEquate(b, a)
ty::PredicateKint::ConstEquate(b, a)
};
self.obligations.push(Obligation::new(
self.trace.cause.clone(),
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_infer/infer/sub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ impl TypeRelation<'tcx> for Sub<'combine, 'infcx, 'tcx> {
self.fields.obligations.push(Obligation::new(
self.fields.trace.cause.clone(),
self.fields.param_env,
ty::PredicateKind::Subtype(ty::Binder::dummy(ty::SubtypePredicate {
ty::PredicateKint::Subtype(ty::SubtypePredicate {
a_is_expected: self.a_is_expected,
a,
b,
}))
})
.to_predicate(self.tcx()),
));

Expand Down
8 changes: 4 additions & 4 deletions src/librustc_infer/traits/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,16 +234,16 @@ impl Elaborator<'tcx> {
if r.is_late_bound() {
None
} else {
Some(ty::PredicateKind::RegionOutlives(ty::Binder::dummy(
ty::OutlivesPredicate(r, r_min),
Some(ty::PredicateKint::RegionOutlives(ty::OutlivesPredicate(
r, r_min,
)))
}
}

Component::Param(p) => {
let ty = tcx.mk_ty_param(p.index, p.name);
Some(ty::PredicateKind::TypeOutlives(ty::Binder::dummy(
ty::OutlivesPredicate(ty, r_min),
Some(ty::PredicateKint::TypeOutlives(ty::OutlivesPredicate(
ty, r_min,
)))
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc_middle/ty/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl<'tcx> EncodableWithShorthand for Ty<'tcx> {
}

impl<'tcx> EncodableWithShorthand for ty::Predicate<'tcx> {
type Variant = ty::PredicateKind<'tcx>;
type Variant = ty::PredicateKynd<'tcx>;
fn variant(&self) -> &Self::Variant {
self.kind()
}
Expand Down Expand Up @@ -195,7 +195,7 @@ where
})
} else {
let tcx = decoder.tcx();
Ok(tcx.mk_predicate(ty::PredicateKind::decode(decoder)?))
Ok(tcx.mk_predicate(ty::PredicateKynd::decode(decoder)?))
}
}

Expand Down
14 changes: 7 additions & 7 deletions src/librustc_mir/borrow_check/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ use rustc_middle::ty::cast::CastTy;
use rustc_middle::ty::fold::TypeFoldable;
use rustc_middle::ty::subst::{GenericArgKind, Subst, SubstsRef, UserSubsts};
use rustc_middle::ty::{
self, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations, RegionVid, ToPolyTraitRef,
ToPredicate, Ty, TyCtxt, UserType, UserTypeAnnotationIndex,
self, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations, RegionVid, ToPredicate, Ty,
TyCtxt, UserType, UserTypeAnnotationIndex,
};
use rustc_span::{Span, DUMMY_SP};
use rustc_target::abi::VariantIdx;
Expand Down Expand Up @@ -1021,7 +1021,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
}

self.prove_predicate(
ty::PredicateKind::WellFormed(inferred_ty.into()).to_predicate(self.tcx()),
ty::PredicateKint::WellFormed(inferred_ty.into()).to_predicate(self.tcx()),
Locations::All(span),
ConstraintCategory::TypeAnnotation,
);
Expand Down Expand Up @@ -1273,7 +1273,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
obligations.obligations.push(traits::Obligation::new(
ObligationCause::dummy(),
param_env,
ty::PredicateKind::WellFormed(revealed_ty.into()).to_predicate(infcx.tcx),
ty::PredicateKint::WellFormed(revealed_ty.into()).to_predicate(infcx.tcx),
));
obligations.add(
infcx
Expand Down Expand Up @@ -1617,7 +1617,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
self.check_call_dest(body, term, &sig, destination, term_location);

self.prove_predicates(
sig.inputs_and_output.iter().map(|ty| ty::PredicateKind::WellFormed(ty.into())),
sig.inputs_and_output.iter().map(|ty| ty::PredicateKint::WellFormed(ty.into())),
term_location.to_locations(),
ConstraintCategory::Boring,
);
Expand Down Expand Up @@ -2706,8 +2706,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
category: ConstraintCategory,
) {
self.prove_predicates(
Some(ty::PredicateKind::Trait(
trait_ref.to_poly_trait_ref().to_poly_trait_predicate(),
Some(ty::PredicateKint::Trait(
ty::TraitPredicate { trait_ref },
hir::Constness::NotConst,
)),
locations,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trait_selection/traits/select/confirmation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
obligations.push(Obligation::new(
obligation.cause.clone(),
obligation.param_env,
ty::PredicateKind::ClosureKind(closure_def_id, substs, kind)
ty::PredicateKint::ClosureKind(closure_def_id, substs, kind)
.to_predicate(self.tcx()),
));
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trait_selection/traits/wf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
traits::Obligation::new(
new_cause,
param_env,
ty::PredicateKind::WellFormed(arg).to_predicate(tcx),
ty::PredicateKint::WellFormed(arg).to_predicate(tcx),
)
}),
);
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_traits/type_op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl AscribeUserTypeCx<'me, 'tcx> {
self.relate(self_ty, Variance::Invariant, impl_self_ty)?;

self.prove_predicate(
ty::PredicateKind::WellFormed(impl_self_ty.into()).to_predicate(self.tcx()),
ty::PredicateKint::WellFormed(impl_self_ty.into()).to_predicate(self.tcx()),
);
}

Expand All @@ -155,7 +155,7 @@ impl AscribeUserTypeCx<'me, 'tcx> {
// them? This would only be relevant if some input
// type were ill-formed but did not appear in `ty`,
// which...could happen with normalization...
self.prove_predicate(ty::PredicateKind::WellFormed(ty.into()).to_predicate(self.tcx()));
self.prove_predicate(ty::PredicateKint::WellFormed(ty.into()).to_predicate(self.tcx()));
Ok(())
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/method/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
obligations.push(traits::Obligation::new(
cause,
self.param_env,
ty::PredicateKind::WellFormed(method_ty.into()).to_predicate(tcx),
ty::PredicateKint::WellFormed(method_ty.into()).to_predicate(tcx),
));

let callee = MethodCallee { def_id, substs: trait_ref.substs, sig: fn_sig };
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3612,7 +3612,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.register_predicate(traits::Obligation::new(
cause,
self.param_env,
ty::PredicateKind::WellFormed(arg).to_predicate(self.tcx),
ty::PredicateKint::WellFormed(arg).to_predicate(self.tcx),
));
}

Expand Down