s/Clause/ClauseKind
This commit is contained in:
parent
18a6d911ca
commit
fca56a8d2c
101 changed files with 592 additions and 544 deletions
|
@ -343,7 +343,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
let format_pred = |pred: ty::Predicate<'tcx>| {
|
||||
let bound_predicate = pred.kind();
|
||||
match bound_predicate.skip_binder() {
|
||||
ty::PredicateKind::Clause(ty::Clause::Projection(pred)) => {
|
||||
ty::PredicateKind::Clause(ty::ClauseKind::Projection(pred)) => {
|
||||
let pred = bound_predicate.rebind(pred);
|
||||
// `<Foo as Iterator>::Item = String`.
|
||||
let projection_ty = pred.skip_binder().projection_ty;
|
||||
|
@ -364,7 +364,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
bound_span_label(projection_ty.self_ty(), &obligation, &quiet);
|
||||
Some((obligation, projection_ty.self_ty()))
|
||||
}
|
||||
ty::PredicateKind::Clause(ty::Clause::Trait(poly_trait_ref)) => {
|
||||
ty::PredicateKind::Clause(ty::ClauseKind::Trait(poly_trait_ref)) => {
|
||||
let p = poly_trait_ref.trait_ref;
|
||||
let self_ty = p.self_ty();
|
||||
let path = p.print_only_trait_path();
|
||||
|
|
|
@ -950,7 +950,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
let bound_pred = pred.kind();
|
||||
match bound_pred.skip_binder() {
|
||||
ty::PredicateKind::Clause(clause) => match clause {
|
||||
ty::Clause::Trait(trait_pred) => {
|
||||
ty::ClauseKind::Trait(trait_pred) => {
|
||||
assert_eq!(trait_pred.polarity, ty::ImplPolarity::Positive);
|
||||
trait_bounds.push((
|
||||
bound_pred.rebind(trait_pred.trait_ref),
|
||||
|
@ -958,16 +958,18 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
trait_pred.constness,
|
||||
));
|
||||
}
|
||||
ty::Clause::Projection(proj) => {
|
||||
ty::ClauseKind::Projection(proj) => {
|
||||
projection_bounds.push((bound_pred.rebind(proj), span));
|
||||
}
|
||||
ty::Clause::TypeOutlives(_) => {
|
||||
ty::ClauseKind::TypeOutlives(_) => {
|
||||
// Do nothing, we deal with regions separately
|
||||
}
|
||||
ty::Clause::RegionOutlives(_)
|
||||
| ty::Clause::ConstArgHasType(..)
|
||||
| ty::Clause::WellFormed(_)
|
||||
| ty::Clause::ConstEvaluatable(_) => bug!(),
|
||||
ty::ClauseKind::RegionOutlives(_)
|
||||
| ty::ClauseKind::ConstArgHasType(..)
|
||||
| ty::ClauseKind::WellFormed(_)
|
||||
| ty::ClauseKind::ConstEvaluatable(_) => {
|
||||
bug!()
|
||||
}
|
||||
},
|
||||
ty::PredicateKind::AliasRelate(..)
|
||||
| ty::PredicateKind::ObjectSafe(_)
|
||||
|
@ -1064,7 +1066,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
|
||||
let bound_predicate = pred.kind();
|
||||
match bound_predicate.skip_binder() {
|
||||
ty::PredicateKind::Clause(ty::Clause::Trait(pred)) => {
|
||||
ty::PredicateKind::Clause(ty::ClauseKind::Trait(pred)) => {
|
||||
let pred = bound_predicate.rebind(pred);
|
||||
associated_types.entry(span).or_default().extend(
|
||||
tcx.associated_items(pred.def_id())
|
||||
|
@ -1074,7 +1076,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
.map(|item| item.def_id),
|
||||
);
|
||||
}
|
||||
ty::PredicateKind::Clause(ty::Clause::Projection(pred)) => {
|
||||
ty::PredicateKind::Clause(ty::ClauseKind::Projection(pred)) => {
|
||||
let pred = bound_predicate.rebind(pred);
|
||||
// A `Self` within the original bound will be substituted with a
|
||||
// `trait_object_dummy_self`, so check for that.
|
||||
|
|
|
@ -24,7 +24,7 @@ use rustc_span::Span;
|
|||
/// include the self type (e.g., `trait_bounds`) but in others we do not
|
||||
#[derive(Default, PartialEq, Eq, Clone, Debug)]
|
||||
pub struct Bounds<'tcx> {
|
||||
pub predicates: Vec<(Binder<'tcx, ty::Clause<'tcx>>, Span)>,
|
||||
pub predicates: Vec<(Binder<'tcx, ty::ClauseKind<'tcx>>, Span)>,
|
||||
}
|
||||
|
||||
impl<'tcx> Bounds<'tcx> {
|
||||
|
@ -34,7 +34,7 @@ impl<'tcx> Bounds<'tcx> {
|
|||
region: ty::PolyTypeOutlivesPredicate<'tcx>,
|
||||
span: Span,
|
||||
) {
|
||||
self.predicates.push((region.map_bound(|p| ty::Clause::TypeOutlives(p)), span));
|
||||
self.predicates.push((region.map_bound(|p| ty::ClauseKind::TypeOutlives(p)), span));
|
||||
}
|
||||
|
||||
pub fn push_trait_bound(
|
||||
|
@ -47,7 +47,7 @@ impl<'tcx> Bounds<'tcx> {
|
|||
) {
|
||||
self.predicates.push((
|
||||
trait_ref.map_bound(|trait_ref| {
|
||||
ty::Clause::Trait(ty::TraitPredicate { trait_ref, constness, polarity })
|
||||
ty::ClauseKind::Trait(ty::TraitPredicate { trait_ref, constness, polarity })
|
||||
}),
|
||||
span,
|
||||
));
|
||||
|
@ -59,7 +59,7 @@ impl<'tcx> Bounds<'tcx> {
|
|||
projection: ty::PolyProjectionPredicate<'tcx>,
|
||||
span: Span,
|
||||
) {
|
||||
self.predicates.push((projection.map_bound(|proj| ty::Clause::Projection(proj)), span));
|
||||
self.predicates.push((projection.map_bound(|proj| ty::ClauseKind::Projection(proj)), span));
|
||||
}
|
||||
|
||||
pub fn push_sized(&mut self, tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, span: Span) {
|
||||
|
@ -69,13 +69,17 @@ impl<'tcx> Bounds<'tcx> {
|
|||
self.predicates.insert(
|
||||
0,
|
||||
(
|
||||
ty::Binder::dummy(ty::Clause::Trait(trait_ref.without_const().to_predicate(tcx))),
|
||||
ty::Binder::dummy(ty::ClauseKind::Trait(
|
||||
trait_ref.without_const().to_predicate(tcx),
|
||||
)),
|
||||
span,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
pub fn predicates(&self) -> impl Iterator<Item = (Binder<'tcx, ty::Clause<'tcx>>, Span)> + '_ {
|
||||
pub fn predicates(
|
||||
&self,
|
||||
) -> impl Iterator<Item = (Binder<'tcx, ty::ClauseKind<'tcx>>, Span)> + '_ {
|
||||
self.predicates.iter().cloned()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -440,7 +440,7 @@ fn check_opaque_meets_bounds<'tcx>(
|
|||
// Defining use functions may have more bounds than the opaque type, which is ok, as long as the
|
||||
// hidden type is well formed even without those bounds.
|
||||
let predicate =
|
||||
ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::WellFormed(hidden_ty.into())));
|
||||
ty::Binder::dummy(ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(hidden_ty.into())));
|
||||
ocx.register_obligation(Obligation::new(tcx, misc_cause, param_env, predicate));
|
||||
|
||||
// Check that all obligations are satisfied by the implementation's
|
||||
|
|
|
@ -321,7 +321,7 @@ fn compare_method_predicate_entailment<'tcx>(
|
|||
infcx.tcx,
|
||||
ObligationCause::dummy(),
|
||||
param_env,
|
||||
ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::WellFormed(
|
||||
ty::Binder::dummy(ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(
|
||||
unnormalized_impl_fty.into(),
|
||||
))),
|
||||
));
|
||||
|
|
|
@ -304,7 +304,7 @@ fn bounds_from_generic_predicates<'tcx>(
|
|||
debug!("predicate {:?}", predicate);
|
||||
let bound_predicate = predicate.kind();
|
||||
match bound_predicate.skip_binder() {
|
||||
ty::PredicateKind::Clause(ty::Clause::Trait(trait_predicate)) => {
|
||||
ty::PredicateKind::Clause(ty::ClauseKind::Trait(trait_predicate)) => {
|
||||
let entry = types.entry(trait_predicate.self_ty()).or_default();
|
||||
let def_id = trait_predicate.def_id();
|
||||
if Some(def_id) != tcx.lang_items().sized_trait() {
|
||||
|
@ -313,7 +313,7 @@ fn bounds_from_generic_predicates<'tcx>(
|
|||
entry.push(trait_predicate.def_id());
|
||||
}
|
||||
}
|
||||
ty::PredicateKind::Clause(ty::Clause::Projection(projection_pred)) => {
|
||||
ty::PredicateKind::Clause(ty::ClauseKind::Projection(projection_pred)) => {
|
||||
projections.push(bound_predicate.rebind(projection_pred));
|
||||
}
|
||||
_ => {}
|
||||
|
|
|
@ -81,7 +81,7 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
|
|||
self.tcx(),
|
||||
cause,
|
||||
param_env,
|
||||
ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::WellFormed(arg))),
|
||||
ty::Binder::dummy(ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(arg))),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -419,10 +419,9 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, associated_items: &[hir::TraitItemRe
|
|||
let mut unsatisfied_bounds: Vec<_> = required_bounds
|
||||
.into_iter()
|
||||
.filter(|clause| match clause.kind().skip_binder() {
|
||||
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(ty::OutlivesPredicate(
|
||||
a,
|
||||
b,
|
||||
))) => !region_known_to_outlive(
|
||||
ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(
|
||||
ty::OutlivesPredicate(a, b),
|
||||
)) => !region_known_to_outlive(
|
||||
tcx,
|
||||
gat_def_id.def_id,
|
||||
param_env,
|
||||
|
@ -430,7 +429,7 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, associated_items: &[hir::TraitItemRe
|
|||
a,
|
||||
b,
|
||||
),
|
||||
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(ty::OutlivesPredicate(
|
||||
ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(ty::OutlivesPredicate(
|
||||
a,
|
||||
b,
|
||||
))) => !ty_known_to_outlive(
|
||||
|
@ -574,7 +573,7 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable<TyCtxt<'tcx>>>(
|
|||
);
|
||||
// The predicate we expect to see. (In our example,
|
||||
// `Self: 'me`.)
|
||||
let clause = ty::PredicateKind::Clause(ty::Clause::TypeOutlives(
|
||||
let clause = ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(
|
||||
ty::OutlivesPredicate(ty_param, region_param),
|
||||
));
|
||||
let clause = tcx.mk_predicate(ty::Binder::dummy(clause));
|
||||
|
@ -623,7 +622,7 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable<TyCtxt<'tcx>>>(
|
|||
},
|
||||
);
|
||||
// The predicate we expect to see.
|
||||
let clause = ty::PredicateKind::Clause(ty::Clause::RegionOutlives(
|
||||
let clause = ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(
|
||||
ty::OutlivesPredicate(region_a_param, region_b_param),
|
||||
));
|
||||
let clause = tcx.mk_predicate(ty::Binder::dummy(clause));
|
||||
|
@ -1032,7 +1031,7 @@ fn check_type_defn<'tcx>(tcx: TyCtxt<'tcx>, item: &hir::Item<'tcx>, all_sized: b
|
|||
tcx,
|
||||
cause,
|
||||
wfcx.param_env,
|
||||
ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::ConstEvaluatable(
|
||||
ty::Binder::dummy(ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(
|
||||
ty::Const::from_anon_const(tcx, discr_def_id.expect_local()),
|
||||
))),
|
||||
));
|
||||
|
@ -1876,7 +1875,8 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
|
|||
// We lower empty bounds like `Vec<dyn Copy>:` as
|
||||
// `WellFormed(Vec<dyn Copy>)`, which will later get checked by
|
||||
// regular WF checking
|
||||
if let ty::PredicateKind::Clause(ty::Clause::WellFormed(..)) = pred.kind().skip_binder()
|
||||
if let ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(..)) =
|
||||
pred.kind().skip_binder()
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -571,7 +571,7 @@ fn infringing_fields_error(
|
|||
.or_default()
|
||||
.push(error.obligation.cause.span);
|
||||
}
|
||||
if let ty::PredicateKind::Clause(ty::Clause::Trait(ty::TraitPredicate {
|
||||
if let ty::PredicateKind::Clause(ty::ClauseKind::Trait(ty::TraitPredicate {
|
||||
trait_ref,
|
||||
polarity: ty::ImplPolarity::Positive,
|
||||
..
|
||||
|
|
|
@ -36,11 +36,13 @@ fn associated_type_bounds<'tcx>(
|
|||
|
||||
let bounds_from_parent = trait_predicates.predicates.iter().copied().filter(|(pred, _)| {
|
||||
match pred.kind().skip_binder() {
|
||||
ty::PredicateKind::Clause(ty::Clause::Trait(tr)) => tr.self_ty() == item_ty,
|
||||
ty::PredicateKind::Clause(ty::Clause::Projection(proj)) => {
|
||||
ty::PredicateKind::Clause(ty::ClauseKind::Trait(tr)) => tr.self_ty() == item_ty,
|
||||
ty::PredicateKind::Clause(ty::ClauseKind::Projection(proj)) => {
|
||||
proj.projection_ty.self_ty() == item_ty
|
||||
}
|
||||
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(outlives)) => outlives.0 == item_ty,
|
||||
ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(outlives)) => {
|
||||
outlives.0 == item_ty
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
});
|
||||
|
|
|
@ -190,7 +190,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
|
|||
let ct = tcx.mk_const(param_const, ct_ty);
|
||||
|
||||
let predicate = ty::Binder::dummy(ty::PredicateKind::Clause(
|
||||
ty::Clause::ConstArgHasType(ct, ct_ty),
|
||||
ty::ClauseKind::ConstArgHasType(ct, ct_ty),
|
||||
))
|
||||
.to_predicate(tcx);
|
||||
predicates.insert((predicate, param.span));
|
||||
|
@ -222,7 +222,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
|
|||
} else {
|
||||
let span = bound_pred.bounded_ty.span;
|
||||
let predicate = ty::Binder::bind_with_vars(
|
||||
ty::PredicateKind::Clause(ty::Clause::WellFormed(ty.into())),
|
||||
ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(ty.into())),
|
||||
bound_vars,
|
||||
);
|
||||
predicates.insert((predicate.to_predicate(tcx), span));
|
||||
|
@ -252,7 +252,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
|
|||
_ => bug!(),
|
||||
};
|
||||
let pred = ty::Binder::dummy(ty::PredicateKind::Clause(
|
||||
ty::Clause::RegionOutlives(ty::OutlivesPredicate(r1, r2)),
|
||||
ty::ClauseKind::RegionOutlives(ty::OutlivesPredicate(r1, r2)),
|
||||
))
|
||||
.to_predicate(icx.tcx);
|
||||
|
||||
|
@ -320,14 +320,14 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
|
|||
},
|
||||
);
|
||||
predicates.push((
|
||||
ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::RegionOutlives(
|
||||
ty::Binder::dummy(ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(
|
||||
ty::OutlivesPredicate(orig_region, dup_region),
|
||||
)))
|
||||
.to_predicate(icx.tcx),
|
||||
duplicate.span,
|
||||
));
|
||||
predicates.push((
|
||||
ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::RegionOutlives(
|
||||
ty::Binder::dummy(ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(
|
||||
ty::OutlivesPredicate(dup_region, orig_region),
|
||||
)))
|
||||
.to_predicate(icx.tcx),
|
||||
|
@ -358,8 +358,10 @@ fn const_evaluatable_predicates_of(
|
|||
if let ty::ConstKind::Unevaluated(_) = ct.kind() {
|
||||
let span = self.tcx.def_span(c.def_id);
|
||||
self.preds.insert((
|
||||
ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::ConstEvaluatable(ct)))
|
||||
.to_predicate(self.tcx),
|
||||
ty::Binder::dummy(ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(
|
||||
ct,
|
||||
)))
|
||||
.to_predicate(self.tcx),
|
||||
span,
|
||||
));
|
||||
}
|
||||
|
@ -449,11 +451,13 @@ pub(super) fn explicit_predicates_of<'tcx>(
|
|||
.iter()
|
||||
.copied()
|
||||
.filter(|(pred, _)| match pred.kind().skip_binder() {
|
||||
ty::PredicateKind::Clause(ty::Clause::Trait(tr)) => !is_assoc_item_ty(tr.self_ty()),
|
||||
ty::PredicateKind::Clause(ty::Clause::Projection(proj)) => {
|
||||
ty::PredicateKind::Clause(ty::ClauseKind::Trait(tr)) => {
|
||||
!is_assoc_item_ty(tr.self_ty())
|
||||
}
|
||||
ty::PredicateKind::Clause(ty::ClauseKind::Projection(proj)) => {
|
||||
!is_assoc_item_ty(proj.projection_ty.self_ty())
|
||||
}
|
||||
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(outlives)) => {
|
||||
ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(outlives)) => {
|
||||
!is_assoc_item_ty(outlives.0)
|
||||
}
|
||||
_ => true,
|
||||
|
@ -496,7 +500,7 @@ pub(super) fn explicit_predicates_of<'tcx>(
|
|||
.predicates
|
||||
.into_iter()
|
||||
.filter(|(pred, _)| {
|
||||
if let ty::PredicateKind::Clause(ty::Clause::ConstArgHasType(ct, _)) =
|
||||
if let ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(ct, _)) =
|
||||
pred.kind().skip_binder()
|
||||
{
|
||||
match ct.kind() {
|
||||
|
@ -677,7 +681,7 @@ pub(super) fn implied_predicates_with_filter(
|
|||
if matches!(filter, PredicateFilter::SelfOnly) {
|
||||
for &(pred, span) in implied_bounds {
|
||||
debug!("superbound: {:?}", pred);
|
||||
if let ty::PredicateKind::Clause(ty::Clause::Trait(bound)) = pred.kind().skip_binder()
|
||||
if let ty::PredicateKind::Clause(ty::ClauseKind::Trait(bound)) = pred.kind().skip_binder()
|
||||
&& bound.polarity == ty::ImplPolarity::Positive
|
||||
{
|
||||
tcx.at(span).super_predicates_of(bound.def_id());
|
||||
|
@ -774,7 +778,9 @@ pub(super) fn type_param_predicates(
|
|||
)
|
||||
.into_iter()
|
||||
.filter(|(predicate, _)| match predicate.kind().skip_binder() {
|
||||
ty::PredicateKind::Clause(ty::Clause::Trait(data)) => data.self_ty().is_param(index),
|
||||
ty::PredicateKind::Clause(ty::ClauseKind::Trait(data)) => {
|
||||
data.self_ty().is_param(index)
|
||||
}
|
||||
_ => false,
|
||||
}),
|
||||
);
|
||||
|
|
|
@ -1761,7 +1761,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
|||
let obligations = predicates.predicates.iter().filter_map(|&(pred, _)| {
|
||||
let bound_predicate = pred.kind();
|
||||
match bound_predicate.skip_binder() {
|
||||
ty::PredicateKind::Clause(ty::Clause::Trait(data)) => {
|
||||
ty::PredicateKind::Clause(ty::ClauseKind::Trait(data)) => {
|
||||
// The order here needs to match what we would get from `subst_supertrait`
|
||||
let pred_bound_vars = bound_predicate.bound_vars();
|
||||
let mut all_bound_vars = bound_vars.clone();
|
||||
|
|
|
@ -187,7 +187,7 @@ pub fn setup_constraining_predicates<'tcx>(
|
|||
for j in i..predicates.len() {
|
||||
// Note that we don't have to care about binders here,
|
||||
// as the impl trait ref never contains any late-bound regions.
|
||||
if let ty::PredicateKind::Clause(ty::Clause::Projection(projection)) =
|
||||
if let ty::PredicateKind::Clause(ty::ClauseKind::Projection(projection)) =
|
||||
predicates[j].0.kind().skip_binder()
|
||||
{
|
||||
// Special case: watch out for some kind of sneaky attempt
|
||||
|
|
|
@ -79,7 +79,7 @@ fn diagnostic_hir_wf_check<'tcx>(
|
|||
self.tcx,
|
||||
cause,
|
||||
self.param_env,
|
||||
ty::PredicateKind::Clause(ty::Clause::WellFormed(tcx_ty.into())),
|
||||
ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(tcx_ty.into())),
|
||||
));
|
||||
|
||||
for error in ocx.select_all_or_error() {
|
||||
|
|
|
@ -236,7 +236,7 @@ fn unconstrained_parent_impl_substs<'tcx>(
|
|||
// the functions in `cgp` add the constrained parameters to a list of
|
||||
// unconstrained parameters.
|
||||
for (predicate, _) in impl_generic_predicates.predicates.iter() {
|
||||
if let ty::PredicateKind::Clause(ty::Clause::Projection(proj)) =
|
||||
if let ty::PredicateKind::Clause(ty::ClauseKind::Projection(proj)) =
|
||||
predicate.kind().skip_binder()
|
||||
{
|
||||
let projection_ty = proj.projection_ty;
|
||||
|
@ -438,8 +438,8 @@ fn trait_predicates_eq<'tcx>(
|
|||
let pred2_kind = predicate2.kind().skip_binder();
|
||||
let (trait_pred1, trait_pred2) = match (pred1_kind, pred2_kind) {
|
||||
(
|
||||
ty::PredicateKind::Clause(ty::Clause::Trait(pred1)),
|
||||
ty::PredicateKind::Clause(ty::Clause::Trait(pred2)),
|
||||
ty::PredicateKind::Clause(ty::ClauseKind::Trait(pred1)),
|
||||
ty::PredicateKind::Clause(ty::ClauseKind::Trait(pred2)),
|
||||
) => (pred1, pred2),
|
||||
// Just use plain syntactic equivalence if either of the predicates aren't
|
||||
// trait predicates or have bound vars.
|
||||
|
@ -478,7 +478,7 @@ fn check_specialization_on<'tcx>(tcx: TyCtxt<'tcx>, predicate: ty::Predicate<'tc
|
|||
_ if predicate.is_global() => (),
|
||||
// We allow specializing on explicitly marked traits with no associated
|
||||
// items.
|
||||
ty::PredicateKind::Clause(ty::Clause::Trait(ty::TraitPredicate {
|
||||
ty::PredicateKind::Clause(ty::ClauseKind::Trait(ty::TraitPredicate {
|
||||
trait_ref,
|
||||
constness: _,
|
||||
polarity: _,
|
||||
|
@ -498,7 +498,7 @@ fn check_specialization_on<'tcx>(tcx: TyCtxt<'tcx>, predicate: ty::Predicate<'tc
|
|||
.emit();
|
||||
}
|
||||
}
|
||||
ty::PredicateKind::Clause(ty::Clause::Projection(ty::ProjectionPredicate {
|
||||
ty::PredicateKind::Clause(ty::ClauseKind::Projection(ty::ProjectionPredicate {
|
||||
projection_ty,
|
||||
term,
|
||||
})) => {
|
||||
|
@ -509,7 +509,7 @@ fn check_specialization_on<'tcx>(tcx: TyCtxt<'tcx>, predicate: ty::Predicate<'tc
|
|||
)
|
||||
.emit();
|
||||
}
|
||||
ty::PredicateKind::Clause(ty::Clause::ConstArgHasType(..)) => {
|
||||
ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(..)) => {
|
||||
// FIXME(min_specialization), FIXME(const_generics):
|
||||
// It probably isn't right to allow _every_ `ConstArgHasType` but I am somewhat unsure
|
||||
// about the actual rules that would be sound. Can't just always error here because otherwise
|
||||
|
@ -532,22 +532,22 @@ fn trait_predicate_kind<'tcx>(
|
|||
predicate: ty::Predicate<'tcx>,
|
||||
) -> Option<TraitSpecializationKind> {
|
||||
match predicate.kind().skip_binder() {
|
||||
ty::PredicateKind::Clause(ty::Clause::Trait(ty::TraitPredicate {
|
||||
ty::PredicateKind::Clause(ty::ClauseKind::Trait(ty::TraitPredicate {
|
||||
trait_ref,
|
||||
constness: _,
|
||||
polarity: _,
|
||||
})) => Some(tcx.trait_def(trait_ref.def_id).specialization_kind),
|
||||
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(_))
|
||||
| ty::PredicateKind::Clause(ty::Clause::TypeOutlives(_))
|
||||
| ty::PredicateKind::Clause(ty::Clause::Projection(_))
|
||||
| ty::PredicateKind::Clause(ty::Clause::ConstArgHasType(..))
|
||||
ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(_))
|
||||
| ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(_))
|
||||
| ty::PredicateKind::Clause(ty::ClauseKind::Projection(_))
|
||||
| ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(..))
|
||||
| ty::PredicateKind::AliasRelate(..)
|
||||
| ty::PredicateKind::Clause(ty::Clause::WellFormed(_))
|
||||
| ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(_))
|
||||
| ty::PredicateKind::Subtype(_)
|
||||
| ty::PredicateKind::Coerce(_)
|
||||
| ty::PredicateKind::ObjectSafe(_)
|
||||
| ty::PredicateKind::ClosureKind(..)
|
||||
| ty::PredicateKind::Clause(ty::Clause::ConstEvaluatable(..))
|
||||
| ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..))
|
||||
| ty::PredicateKind::ConstEquate(..)
|
||||
| ty::PredicateKind::Ambiguous
|
||||
| ty::PredicateKind::TypeWellFormedFromEnv(..) => None,
|
||||
|
|
|
@ -30,7 +30,7 @@ impl<'tcx> ExplicitPredicatesMap<'tcx> {
|
|||
// process predicates and convert to `RequiredPredicates` entry, see below
|
||||
for &(predicate, span) in predicates.predicates {
|
||||
match predicate.kind().skip_binder() {
|
||||
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(OutlivesPredicate(
|
||||
ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(OutlivesPredicate(
|
||||
ty,
|
||||
reg,
|
||||
))) => insert_outlives_predicate(
|
||||
|
@ -41,10 +41,9 @@ impl<'tcx> ExplicitPredicatesMap<'tcx> {
|
|||
&mut required_predicates,
|
||||
),
|
||||
|
||||
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(OutlivesPredicate(
|
||||
reg1,
|
||||
reg2,
|
||||
))) => insert_outlives_predicate(
|
||||
ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(
|
||||
OutlivesPredicate(reg1, reg2),
|
||||
)) => insert_outlives_predicate(
|
||||
tcx,
|
||||
reg1.into(),
|
||||
reg2,
|
||||
|
@ -52,16 +51,16 @@ impl<'tcx> ExplicitPredicatesMap<'tcx> {
|
|||
&mut required_predicates,
|
||||
),
|
||||
|
||||
ty::PredicateKind::Clause(ty::Clause::Trait(..))
|
||||
| ty::PredicateKind::Clause(ty::Clause::Projection(..))
|
||||
| ty::PredicateKind::Clause(ty::Clause::ConstArgHasType(..))
|
||||
| ty::PredicateKind::Clause(ty::Clause::WellFormed(..))
|
||||
ty::PredicateKind::Clause(ty::ClauseKind::Trait(..))
|
||||
| ty::PredicateKind::Clause(ty::ClauseKind::Projection(..))
|
||||
| ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(..))
|
||||
| ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(..))
|
||||
| ty::PredicateKind::AliasRelate(..)
|
||||
| ty::PredicateKind::ObjectSafe(..)
|
||||
| ty::PredicateKind::ClosureKind(..)
|
||||
| ty::PredicateKind::Subtype(..)
|
||||
| ty::PredicateKind::Coerce(..)
|
||||
| ty::PredicateKind::Clause(ty::Clause::ConstEvaluatable(..))
|
||||
| ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..))
|
||||
| ty::PredicateKind::ConstEquate(..)
|
||||
| ty::PredicateKind::Ambiguous
|
||||
| ty::PredicateKind::TypeWellFormedFromEnv(..) => (),
|
||||
|
|
|
@ -17,7 +17,7 @@ pub fn provide(providers: &mut Providers) {
|
|||
*providers = Providers { inferred_outlives_of, inferred_outlives_crate, ..*providers };
|
||||
}
|
||||
|
||||
fn inferred_outlives_of(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[(ty::Clause<'_>, Span)] {
|
||||
fn inferred_outlives_of(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[(ty::ClauseKind<'_>, Span)] {
|
||||
let id = tcx.hir().local_def_id_to_hir_id(item_def_id);
|
||||
|
||||
if matches!(tcx.def_kind(item_def_id), hir::def::DefKind::AnonConst)
|
||||
|
@ -53,8 +53,8 @@ fn inferred_outlives_of(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[(ty::Clau
|
|||
let mut pred: Vec<String> = predicates
|
||||
.iter()
|
||||
.map(|(out_pred, _)| match out_pred {
|
||||
ty::Clause::RegionOutlives(p) => p.to_string(),
|
||||
ty::Clause::TypeOutlives(p) => p.to_string(),
|
||||
ty::ClauseKind::RegionOutlives(p) => p.to_string(),
|
||||
ty::ClauseKind::TypeOutlives(p) => p.to_string(),
|
||||
err => bug!("unexpected clause {:?}", err),
|
||||
})
|
||||
.collect();
|
||||
|
@ -104,11 +104,11 @@ fn inferred_outlives_crate(tcx: TyCtxt<'_>, (): ()) -> CratePredicatesMap<'_> {
|
|||
|(ty::OutlivesPredicate(kind1, region2), &span)| {
|
||||
match kind1.unpack() {
|
||||
GenericArgKind::Type(ty1) => Some((
|
||||
ty::Clause::TypeOutlives(ty::OutlivesPredicate(ty1, *region2)),
|
||||
ty::ClauseKind::TypeOutlives(ty::OutlivesPredicate(ty1, *region2)),
|
||||
span,
|
||||
)),
|
||||
GenericArgKind::Lifetime(region1) => Some((
|
||||
ty::Clause::RegionOutlives(ty::OutlivesPredicate(
|
||||
ty::ClauseKind::RegionOutlives(ty::OutlivesPredicate(
|
||||
region1, *region2,
|
||||
)),
|
||||
span,
|
||||
|
|
|
@ -162,7 +162,7 @@ fn variance_of_opaque(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[ty::Varianc
|
|||
// which thus mentions `'a` and should thus accept hidden types that borrow 'a
|
||||
// instead of requiring an additional `+ 'a`.
|
||||
match pred.kind().skip_binder() {
|
||||
ty::PredicateKind::Clause(ty::Clause::Trait(ty::TraitPredicate {
|
||||
ty::PredicateKind::Clause(ty::ClauseKind::Trait(ty::TraitPredicate {
|
||||
trait_ref: ty::TraitRef { def_id: _, substs, .. },
|
||||
constness: _,
|
||||
polarity: _,
|
||||
|
@ -171,7 +171,7 @@ fn variance_of_opaque(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[ty::Varianc
|
|||
subst.visit_with(&mut collector);
|
||||
}
|
||||
}
|
||||
ty::PredicateKind::Clause(ty::Clause::Projection(ty::ProjectionPredicate {
|
||||
ty::PredicateKind::Clause(ty::ClauseKind::Projection(ty::ProjectionPredicate {
|
||||
projection_ty: ty::AliasTy { substs, .. },
|
||||
term,
|
||||
})) => {
|
||||
|
@ -180,7 +180,7 @@ fn variance_of_opaque(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[ty::Varianc
|
|||
}
|
||||
term.visit_with(&mut collector);
|
||||
}
|
||||
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(ty::OutlivesPredicate(
|
||||
ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(ty::OutlivesPredicate(
|
||||
_,
|
||||
region,
|
||||
))) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue