Introduce PredicateKind::Clause
This commit is contained in:
parent
42cc8e8f4e
commit
974e2837bb
75 changed files with 568 additions and 407 deletions
|
@ -666,15 +666,17 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
let tcx = self.infcx.tcx;
|
let tcx = self.infcx.tcx;
|
||||||
|
|
||||||
// Find out if the predicates show that the type is a Fn or FnMut
|
// Find out if the predicates show that the type is a Fn or FnMut
|
||||||
let find_fn_kind_from_did =
|
let find_fn_kind_from_did = |predicates: ty::EarlyBinder<
|
||||||
|predicates: ty::EarlyBinder<&[(ty::Predicate<'tcx>, Span)]>, substs| {
|
&[(ty::Predicate<'tcx>, Span)],
|
||||||
predicates.0.iter().find_map(|(pred, _)| {
|
>,
|
||||||
|
substs| {
|
||||||
|
predicates.0.iter().find_map(|(pred, _)| {
|
||||||
let pred = if let Some(substs) = substs {
|
let pred = if let Some(substs) = substs {
|
||||||
predicates.rebind(*pred).subst(tcx, substs).kind().skip_binder()
|
predicates.rebind(*pred).subst(tcx, substs).kind().skip_binder()
|
||||||
} else {
|
} else {
|
||||||
pred.kind().skip_binder()
|
pred.kind().skip_binder()
|
||||||
};
|
};
|
||||||
if let ty::PredicateKind::Trait(pred) = pred && pred.self_ty() == ty {
|
if let ty::PredicateKind::Clause(ty::Clause::Trait(pred)) = pred && pred.self_ty() == ty {
|
||||||
if Some(pred.def_id()) == tcx.lang_items().fn_trait() {
|
if Some(pred.def_id()) == tcx.lang_items().fn_trait() {
|
||||||
return Some(hir::Mutability::Not);
|
return Some(hir::Mutability::Not);
|
||||||
} else if Some(pred.def_id()) == tcx.lang_items().fn_mut_trait() {
|
} else if Some(pred.def_id()) == tcx.lang_items().fn_mut_trait() {
|
||||||
|
@ -683,7 +685,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
// If the type is opaque/param/closure, and it is Fn or FnMut, let's suggest (mutably)
|
// If the type is opaque/param/closure, and it is Fn or FnMut, let's suggest (mutably)
|
||||||
// borrowing the type, since `&mut F: FnMut` iff `F: FnMut` and similarly for `Fn`.
|
// borrowing the type, since `&mut F: FnMut` iff `F: FnMut` and similarly for `Fn`.
|
||||||
|
@ -784,13 +786,15 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
let predicates: Result<Vec<_>, _> = errors
|
let predicates: Result<Vec<_>, _> = errors
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|err| match err.obligation.predicate.kind().skip_binder() {
|
.map(|err| match err.obligation.predicate.kind().skip_binder() {
|
||||||
PredicateKind::Trait(predicate) => match predicate.self_ty().kind() {
|
PredicateKind::Clause(ty::Clause::Trait(predicate)) => {
|
||||||
ty::Param(param_ty) => Ok((
|
match predicate.self_ty().kind() {
|
||||||
generics.type_param(param_ty, tcx),
|
ty::Param(param_ty) => Ok((
|
||||||
predicate.trait_ref.print_only_trait_path().to_string(),
|
generics.type_param(param_ty, tcx),
|
||||||
)),
|
predicate.trait_ref.print_only_trait_path().to_string(),
|
||||||
_ => Err(()),
|
)),
|
||||||
},
|
_ => Err(()),
|
||||||
|
}
|
||||||
|
}
|
||||||
_ => Err(()),
|
_ => Err(()),
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
|
@ -959,8 +959,8 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
|
||||||
{
|
{
|
||||||
predicates.iter().any(|pred| {
|
predicates.iter().any(|pred| {
|
||||||
match pred.kind().skip_binder() {
|
match pred.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(data) if data.self_ty() == ty => {}
|
ty::PredicateKind::Clause(ty::Clause::Trait(data)) if data.self_ty() == ty => {}
|
||||||
ty::PredicateKind::Projection(data) if data.projection_ty.self_ty() == ty => {}
|
ty::PredicateKind::Clause(ty::Clause::Projection(data)) if data.projection_ty.self_ty() == ty => {}
|
||||||
_ => return false,
|
_ => return false,
|
||||||
}
|
}
|
||||||
tcx.any_free_region_meets(pred, |r| {
|
tcx.any_free_region_meets(pred, |r| {
|
||||||
|
|
|
@ -88,11 +88,11 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||||
category: ConstraintCategory<'tcx>,
|
category: ConstraintCategory<'tcx>,
|
||||||
) {
|
) {
|
||||||
self.prove_predicate(
|
self.prove_predicate(
|
||||||
ty::Binder::dummy(ty::PredicateKind::Trait(ty::TraitPredicate {
|
ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::Trait(ty::TraitPredicate {
|
||||||
trait_ref,
|
trait_ref,
|
||||||
constness: ty::BoundConstness::NotConst,
|
constness: ty::BoundConstness::NotConst,
|
||||||
polarity: ty::ImplPolarity::Positive,
|
polarity: ty::ImplPolarity::Positive,
|
||||||
})),
|
}))),
|
||||||
locations,
|
locations,
|
||||||
category,
|
category,
|
||||||
);
|
);
|
||||||
|
|
|
@ -2013,8 +2013,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||||
);
|
);
|
||||||
|
|
||||||
let outlives_predicate =
|
let outlives_predicate =
|
||||||
tcx.mk_predicate(Binder::dummy(ty::PredicateKind::TypeOutlives(
|
tcx.mk_predicate(Binder::dummy(ty::PredicateKind::Clause(
|
||||||
ty::OutlivesPredicate(self_ty, *region),
|
ty::Clause::TypeOutlives(ty::OutlivesPredicate(self_ty, *region)),
|
||||||
)));
|
)));
|
||||||
self.prove_predicate(
|
self.prove_predicate(
|
||||||
outlives_predicate,
|
outlives_predicate,
|
||||||
|
|
|
@ -1378,7 +1378,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
|
|
||||||
let bound_predicate = obligation.predicate.kind();
|
let bound_predicate = obligation.predicate.kind();
|
||||||
match bound_predicate.skip_binder() {
|
match bound_predicate.skip_binder() {
|
||||||
ty::PredicateKind::Trait(pred) => {
|
ty::PredicateKind::Clause(ty::Clause::Trait(pred)) => {
|
||||||
let pred = bound_predicate.rebind(pred);
|
let pred = bound_predicate.rebind(pred);
|
||||||
associated_types.entry(span).or_default().extend(
|
associated_types.entry(span).or_default().extend(
|
||||||
tcx.associated_items(pred.def_id())
|
tcx.associated_items(pred.def_id())
|
||||||
|
@ -1387,7 +1387,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
.map(|item| item.def_id),
|
.map(|item| item.def_id),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Projection(pred) => {
|
ty::PredicateKind::Clause(ty::Clause::Projection(pred)) => {
|
||||||
let pred = bound_predicate.rebind(pred);
|
let pred = bound_predicate.rebind(pred);
|
||||||
// A `Self` within the original bound will be substituted with a
|
// A `Self` within the original bound will be substituted with a
|
||||||
// `trait_object_dummy_self`, so check for that.
|
// `trait_object_dummy_self`, so check for that.
|
||||||
|
|
|
@ -183,19 +183,27 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
|
||||||
let predicate = predicate.kind();
|
let predicate = predicate.kind();
|
||||||
let p = p.kind();
|
let p = p.kind();
|
||||||
match (predicate.skip_binder(), p.skip_binder()) {
|
match (predicate.skip_binder(), p.skip_binder()) {
|
||||||
(ty::PredicateKind::Trait(a), ty::PredicateKind::Trait(b)) => {
|
(
|
||||||
relator.relate(predicate.rebind(a), p.rebind(b)).is_ok()
|
ty::PredicateKind::Clause(ty::Clause::Trait(a)),
|
||||||
}
|
ty::PredicateKind::Clause(ty::Clause::Trait(b)),
|
||||||
(ty::PredicateKind::Projection(a), ty::PredicateKind::Projection(b)) => {
|
) => relator.relate(predicate.rebind(a), p.rebind(b)).is_ok(),
|
||||||
relator.relate(predicate.rebind(a), p.rebind(b)).is_ok()
|
(
|
||||||
}
|
ty::PredicateKind::Clause(ty::Clause::Projection(a)),
|
||||||
|
ty::PredicateKind::Clause(ty::Clause::Projection(b)),
|
||||||
|
) => relator.relate(predicate.rebind(a), p.rebind(b)).is_ok(),
|
||||||
(
|
(
|
||||||
ty::PredicateKind::ConstEvaluatable(a),
|
ty::PredicateKind::ConstEvaluatable(a),
|
||||||
ty::PredicateKind::ConstEvaluatable(b),
|
ty::PredicateKind::ConstEvaluatable(b),
|
||||||
) => relator.relate(predicate.rebind(a), predicate.rebind(b)).is_ok(),
|
) => relator.relate(predicate.rebind(a), predicate.rebind(b)).is_ok(),
|
||||||
(
|
(
|
||||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty_a, lt_a)),
|
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(ty::OutlivesPredicate(
|
||||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty_b, lt_b)),
|
ty_a,
|
||||||
|
lt_a,
|
||||||
|
))),
|
||||||
|
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(ty::OutlivesPredicate(
|
||||||
|
ty_b,
|
||||||
|
lt_b,
|
||||||
|
))),
|
||||||
) => {
|
) => {
|
||||||
relator.relate(predicate.rebind(ty_a), p.rebind(ty_b)).is_ok()
|
relator.relate(predicate.rebind(ty_a), p.rebind(ty_b)).is_ok()
|
||||||
&& relator.relate(predicate.rebind(lt_a), p.rebind(lt_b)).is_ok()
|
&& relator.relate(predicate.rebind(lt_a), p.rebind(lt_b)).is_ok()
|
||||||
|
|
|
@ -309,7 +309,7 @@ fn bounds_from_generic_predicates<'tcx>(
|
||||||
debug!("predicate {:?}", predicate);
|
debug!("predicate {:?}", predicate);
|
||||||
let bound_predicate = predicate.kind();
|
let bound_predicate = predicate.kind();
|
||||||
match bound_predicate.skip_binder() {
|
match bound_predicate.skip_binder() {
|
||||||
ty::PredicateKind::Trait(trait_predicate) => {
|
ty::PredicateKind::Clause(ty::Clause::Trait(trait_predicate)) => {
|
||||||
let entry = types.entry(trait_predicate.self_ty()).or_default();
|
let entry = types.entry(trait_predicate.self_ty()).or_default();
|
||||||
let def_id = trait_predicate.def_id();
|
let def_id = trait_predicate.def_id();
|
||||||
if Some(def_id) != tcx.lang_items().sized_trait() {
|
if Some(def_id) != tcx.lang_items().sized_trait() {
|
||||||
|
@ -318,7 +318,7 @@ fn bounds_from_generic_predicates<'tcx>(
|
||||||
entry.push(trait_predicate.def_id());
|
entry.push(trait_predicate.def_id());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Projection(projection_pred) => {
|
ty::PredicateKind::Clause(ty::Clause::Projection(projection_pred)) => {
|
||||||
projections.push(bound_predicate.rebind(projection_pred));
|
projections.push(bound_predicate.rebind(projection_pred));
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|
|
@ -462,12 +462,16 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, associated_items: &[hir::TraitItemRe
|
||||||
let mut unsatisfied_bounds: Vec<_> = required_bounds
|
let mut unsatisfied_bounds: Vec<_> = required_bounds
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|clause| match clause.kind().skip_binder() {
|
.filter(|clause| match clause.kind().skip_binder() {
|
||||||
ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(a, b)) => {
|
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(ty::OutlivesPredicate(
|
||||||
|
a,
|
||||||
|
b,
|
||||||
|
))) => {
|
||||||
!region_known_to_outlive(tcx, gat_hir, param_env, &FxIndexSet::default(), a, b)
|
!region_known_to_outlive(tcx, gat_hir, param_env, &FxIndexSet::default(), a, b)
|
||||||
}
|
}
|
||||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(a, b)) => {
|
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(ty::OutlivesPredicate(
|
||||||
!ty_known_to_outlive(tcx, gat_hir, param_env, &FxIndexSet::default(), a, b)
|
a,
|
||||||
}
|
b,
|
||||||
|
))) => !ty_known_to_outlive(tcx, gat_hir, param_env, &FxIndexSet::default(), a, b),
|
||||||
_ => bug!("Unexpected PredicateKind"),
|
_ => bug!("Unexpected PredicateKind"),
|
||||||
})
|
})
|
||||||
.map(|clause| clause.to_string())
|
.map(|clause| clause.to_string())
|
||||||
|
@ -599,8 +603,9 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable<'tcx>>(
|
||||||
}));
|
}));
|
||||||
// The predicate we expect to see. (In our example,
|
// The predicate we expect to see. (In our example,
|
||||||
// `Self: 'me`.)
|
// `Self: 'me`.)
|
||||||
let clause =
|
let clause = ty::PredicateKind::Clause(ty::Clause::TypeOutlives(
|
||||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty_param, region_param));
|
ty::OutlivesPredicate(ty_param, region_param),
|
||||||
|
));
|
||||||
let clause = tcx.mk_predicate(ty::Binder::dummy(clause));
|
let clause = tcx.mk_predicate(ty::Binder::dummy(clause));
|
||||||
bounds.insert(clause);
|
bounds.insert(clause);
|
||||||
}
|
}
|
||||||
|
@ -636,9 +641,8 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable<'tcx>>(
|
||||||
name: region_b_param.name,
|
name: region_b_param.name,
|
||||||
}));
|
}));
|
||||||
// The predicate we expect to see.
|
// The predicate we expect to see.
|
||||||
let clause = ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(
|
let clause = ty::PredicateKind::Clause(ty::Clause::RegionOutlives(
|
||||||
region_a_param,
|
ty::OutlivesPredicate(region_a_param, region_b_param),
|
||||||
region_b_param,
|
|
||||||
));
|
));
|
||||||
let clause = tcx.mk_predicate(ty::Binder::dummy(clause));
|
let clause = tcx.mk_predicate(ty::Binder::dummy(clause));
|
||||||
bounds.insert(clause);
|
bounds.insert(clause);
|
||||||
|
|
|
@ -128,11 +128,11 @@ fn visit_implementation_of_copy(tcx: TyCtxt<'_>, impl_did: LocalDefId) {
|
||||||
.or_default()
|
.or_default()
|
||||||
.push(error.obligation.cause.span);
|
.push(error.obligation.cause.span);
|
||||||
}
|
}
|
||||||
if let ty::PredicateKind::Trait(ty::TraitPredicate {
|
if let ty::PredicateKind::Clause(ty::Clause::Trait(ty::TraitPredicate {
|
||||||
trait_ref,
|
trait_ref,
|
||||||
polarity: ty::ImplPolarity::Positive,
|
polarity: ty::ImplPolarity::Positive,
|
||||||
..
|
..
|
||||||
}) = error_predicate.kind().skip_binder()
|
})) = error_predicate.kind().skip_binder()
|
||||||
{
|
{
|
||||||
let ty = trait_ref.self_ty();
|
let ty = trait_ref.self_ty();
|
||||||
if let ty::Param(_) = ty.kind() {
|
if let ty::Param(_) = ty.kind() {
|
||||||
|
|
|
@ -35,9 +35,11 @@ fn associated_type_bounds<'tcx>(
|
||||||
|
|
||||||
let bounds_from_parent = trait_predicates.predicates.iter().copied().filter(|(pred, _)| {
|
let bounds_from_parent = trait_predicates.predicates.iter().copied().filter(|(pred, _)| {
|
||||||
match pred.kind().skip_binder() {
|
match pred.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(tr) => tr.self_ty() == item_ty,
|
ty::PredicateKind::Clause(ty::Clause::Trait(tr)) => tr.self_ty() == item_ty,
|
||||||
ty::PredicateKind::Projection(proj) => proj.projection_ty.self_ty() == item_ty,
|
ty::PredicateKind::Clause(ty::Clause::Projection(proj)) => {
|
||||||
ty::PredicateKind::TypeOutlives(outlives) => outlives.0 == item_ty,
|
proj.projection_ty.self_ty() == item_ty
|
||||||
|
}
|
||||||
|
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(outlives)) => outlives.0 == item_ty,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1558,7 +1558,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||||
let obligations = predicates.predicates.iter().filter_map(|&(pred, _)| {
|
let obligations = predicates.predicates.iter().filter_map(|&(pred, _)| {
|
||||||
let bound_predicate = pred.kind();
|
let bound_predicate = pred.kind();
|
||||||
match bound_predicate.skip_binder() {
|
match bound_predicate.skip_binder() {
|
||||||
ty::PredicateKind::Trait(data) => {
|
ty::PredicateKind::Clause(ty::Clause::Trait(data)) => {
|
||||||
// The order here needs to match what we would get from `subst_supertrait`
|
// The order here needs to match what we would get from `subst_supertrait`
|
||||||
let pred_bound_vars = bound_predicate.bound_vars();
|
let pred_bound_vars = bound_predicate.bound_vars();
|
||||||
let mut all_bound_vars = bound_vars.clone();
|
let mut all_bound_vars = bound_vars.clone();
|
||||||
|
|
|
@ -233,8 +233,8 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
|
||||||
}
|
}
|
||||||
_ => bug!(),
|
_ => bug!(),
|
||||||
};
|
};
|
||||||
let pred = ty::Binder::dummy(ty::PredicateKind::RegionOutlives(
|
let pred = ty::Binder::dummy(ty::PredicateKind::Clause(
|
||||||
ty::OutlivesPredicate(r1, r2),
|
ty::Clause::RegionOutlives(ty::OutlivesPredicate(r1, r2)),
|
||||||
))
|
))
|
||||||
.to_predicate(icx.tcx);
|
.to_predicate(icx.tcx);
|
||||||
|
|
||||||
|
@ -299,17 +299,15 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
|
||||||
name: duplicate.name.ident().name,
|
name: duplicate.name.ident().name,
|
||||||
}));
|
}));
|
||||||
predicates.push((
|
predicates.push((
|
||||||
ty::Binder::dummy(ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(
|
ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::RegionOutlives(
|
||||||
orig_region,
|
ty::OutlivesPredicate(orig_region, dup_region),
|
||||||
dup_region,
|
|
||||||
)))
|
)))
|
||||||
.to_predicate(icx.tcx),
|
.to_predicate(icx.tcx),
|
||||||
duplicate.span,
|
duplicate.span,
|
||||||
));
|
));
|
||||||
predicates.push((
|
predicates.push((
|
||||||
ty::Binder::dummy(ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(
|
ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::RegionOutlives(
|
||||||
dup_region,
|
ty::OutlivesPredicate(dup_region, orig_region),
|
||||||
orig_region,
|
|
||||||
)))
|
)))
|
||||||
.to_predicate(icx.tcx),
|
.to_predicate(icx.tcx),
|
||||||
duplicate.span,
|
duplicate.span,
|
||||||
|
@ -426,11 +424,13 @@ pub(super) fn explicit_predicates_of<'tcx>(
|
||||||
.iter()
|
.iter()
|
||||||
.copied()
|
.copied()
|
||||||
.filter(|(pred, _)| match pred.kind().skip_binder() {
|
.filter(|(pred, _)| match pred.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(tr) => !is_assoc_item_ty(tr.self_ty()),
|
ty::PredicateKind::Clause(ty::Clause::Trait(tr)) => !is_assoc_item_ty(tr.self_ty()),
|
||||||
ty::PredicateKind::Projection(proj) => {
|
ty::PredicateKind::Clause(ty::Clause::Projection(proj)) => {
|
||||||
!is_assoc_item_ty(proj.projection_ty.self_ty())
|
!is_assoc_item_ty(proj.projection_ty.self_ty())
|
||||||
}
|
}
|
||||||
ty::PredicateKind::TypeOutlives(outlives) => !is_assoc_item_ty(outlives.0),
|
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(outlives)) => {
|
||||||
|
!is_assoc_item_ty(outlives.0)
|
||||||
|
}
|
||||||
_ => true,
|
_ => true,
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
@ -566,7 +566,9 @@ pub(super) fn super_predicates_that_define_assoc_type(
|
||||||
// which will, in turn, reach indirect supertraits.
|
// which will, in turn, reach indirect supertraits.
|
||||||
for &(pred, span) in superbounds {
|
for &(pred, span) in superbounds {
|
||||||
debug!("superbound: {:?}", pred);
|
debug!("superbound: {:?}", pred);
|
||||||
if let ty::PredicateKind::Trait(bound) = pred.kind().skip_binder() {
|
if let ty::PredicateKind::Clause(ty::Clause::Trait(bound)) =
|
||||||
|
pred.kind().skip_binder()
|
||||||
|
{
|
||||||
tcx.at(span).super_predicates_of(bound.def_id());
|
tcx.at(span).super_predicates_of(bound.def_id());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -666,7 +668,7 @@ pub(super) fn type_param_predicates(
|
||||||
)
|
)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|(predicate, _)| match predicate.kind().skip_binder() {
|
.filter(|(predicate, _)| match predicate.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(data) => data.self_ty().is_param(index),
|
ty::PredicateKind::Clause(ty::Clause::Trait(data)) => data.self_ty().is_param(index),
|
||||||
_ => false,
|
_ => false,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
|
@ -187,7 +187,8 @@ pub fn setup_constraining_predicates<'tcx>(
|
||||||
for j in i..predicates.len() {
|
for j in i..predicates.len() {
|
||||||
// Note that we don't have to care about binders here,
|
// Note that we don't have to care about binders here,
|
||||||
// as the impl trait ref never contains any late-bound regions.
|
// as the impl trait ref never contains any late-bound regions.
|
||||||
if let ty::PredicateKind::Projection(projection) = predicates[j].0.kind().skip_binder()
|
if let ty::PredicateKind::Clause(ty::Clause::Projection(projection)) =
|
||||||
|
predicates[j].0.kind().skip_binder()
|
||||||
{
|
{
|
||||||
// Special case: watch out for some kind of sneaky attempt
|
// Special case: watch out for some kind of sneaky attempt
|
||||||
// to project out an associated type defined by this very
|
// to project out an associated type defined by this very
|
||||||
|
|
|
@ -214,7 +214,9 @@ fn unconstrained_parent_impl_substs<'tcx>(
|
||||||
// the functions in `cgp` add the constrained parameters to a list of
|
// the functions in `cgp` add the constrained parameters to a list of
|
||||||
// unconstrained parameters.
|
// unconstrained parameters.
|
||||||
for (predicate, _) in impl_generic_predicates.predicates.iter() {
|
for (predicate, _) in impl_generic_predicates.predicates.iter() {
|
||||||
if let ty::PredicateKind::Projection(proj) = predicate.kind().skip_binder() {
|
if let ty::PredicateKind::Clause(ty::Clause::Projection(proj)) =
|
||||||
|
predicate.kind().skip_binder()
|
||||||
|
{
|
||||||
let projection_ty = proj.projection_ty;
|
let projection_ty = proj.projection_ty;
|
||||||
let projected_ty = proj.term;
|
let projected_ty = proj.term;
|
||||||
|
|
||||||
|
@ -429,7 +431,10 @@ fn trait_predicates_eq<'tcx>(
|
||||||
let pred1_kind = predicate1.kind().skip_binder();
|
let pred1_kind = predicate1.kind().skip_binder();
|
||||||
let pred2_kind = predicate2.kind().skip_binder();
|
let pred2_kind = predicate2.kind().skip_binder();
|
||||||
let (trait_pred1, trait_pred2) = match (pred1_kind, pred2_kind) {
|
let (trait_pred1, trait_pred2) = match (pred1_kind, pred2_kind) {
|
||||||
(ty::PredicateKind::Trait(pred1), ty::PredicateKind::Trait(pred2)) => (pred1, pred2),
|
(
|
||||||
|
ty::PredicateKind::Clause(ty::Clause::Trait(pred1)),
|
||||||
|
ty::PredicateKind::Clause(ty::Clause::Trait(pred2)),
|
||||||
|
) => (pred1, pred2),
|
||||||
// Just use plain syntactic equivalence if either of the predicates aren't
|
// Just use plain syntactic equivalence if either of the predicates aren't
|
||||||
// trait predicates or have bound vars.
|
// trait predicates or have bound vars.
|
||||||
_ => return predicate1 == predicate2,
|
_ => return predicate1 == predicate2,
|
||||||
|
@ -467,7 +472,11 @@ fn check_specialization_on<'tcx>(tcx: TyCtxt<'tcx>, predicate: ty::Predicate<'tc
|
||||||
_ if predicate.is_global() => (),
|
_ if predicate.is_global() => (),
|
||||||
// We allow specializing on explicitly marked traits with no associated
|
// We allow specializing on explicitly marked traits with no associated
|
||||||
// items.
|
// items.
|
||||||
ty::PredicateKind::Trait(ty::TraitPredicate { trait_ref, constness: _, polarity: _ }) => {
|
ty::PredicateKind::Clause(ty::Clause::Trait(ty::TraitPredicate {
|
||||||
|
trait_ref,
|
||||||
|
constness: _,
|
||||||
|
polarity: _,
|
||||||
|
})) => {
|
||||||
if !matches!(
|
if !matches!(
|
||||||
trait_predicate_kind(tcx, predicate),
|
trait_predicate_kind(tcx, predicate),
|
||||||
Some(TraitSpecializationKind::Marker)
|
Some(TraitSpecializationKind::Marker)
|
||||||
|
@ -483,7 +492,10 @@ fn check_specialization_on<'tcx>(tcx: TyCtxt<'tcx>, predicate: ty::Predicate<'tc
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Projection(ty::ProjectionPredicate { projection_ty, term }) => {
|
ty::PredicateKind::Clause(ty::Clause::Projection(ty::ProjectionPredicate {
|
||||||
|
projection_ty,
|
||||||
|
term,
|
||||||
|
})) => {
|
||||||
tcx.sess
|
tcx.sess
|
||||||
.struct_span_err(
|
.struct_span_err(
|
||||||
span,
|
span,
|
||||||
|
@ -504,12 +516,14 @@ fn trait_predicate_kind<'tcx>(
|
||||||
predicate: ty::Predicate<'tcx>,
|
predicate: ty::Predicate<'tcx>,
|
||||||
) -> Option<TraitSpecializationKind> {
|
) -> Option<TraitSpecializationKind> {
|
||||||
match predicate.kind().skip_binder() {
|
match predicate.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(ty::TraitPredicate { trait_ref, constness: _, polarity: _ }) => {
|
ty::PredicateKind::Clause(ty::Clause::Trait(ty::TraitPredicate {
|
||||||
Some(tcx.trait_def(trait_ref.def_id).specialization_kind)
|
trait_ref,
|
||||||
}
|
constness: _,
|
||||||
ty::PredicateKind::RegionOutlives(_)
|
polarity: _,
|
||||||
| ty::PredicateKind::TypeOutlives(_)
|
})) => Some(tcx.trait_def(trait_ref.def_id).specialization_kind),
|
||||||
| ty::PredicateKind::Projection(_)
|
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(_))
|
||||||
|
| ty::PredicateKind::Clause(ty::Clause::TypeOutlives(_))
|
||||||
|
| ty::PredicateKind::Clause(ty::Clause::Projection(_))
|
||||||
| ty::PredicateKind::WellFormed(_)
|
| ty::PredicateKind::WellFormed(_)
|
||||||
| ty::PredicateKind::Subtype(_)
|
| ty::PredicateKind::Subtype(_)
|
||||||
| ty::PredicateKind::Coerce(_)
|
| ty::PredicateKind::Coerce(_)
|
||||||
|
|
|
@ -30,28 +30,30 @@ impl<'tcx> ExplicitPredicatesMap<'tcx> {
|
||||||
// process predicates and convert to `RequiredPredicates` entry, see below
|
// process predicates and convert to `RequiredPredicates` entry, see below
|
||||||
for &(predicate, span) in predicates.predicates {
|
for &(predicate, span) in predicates.predicates {
|
||||||
match predicate.kind().skip_binder() {
|
match predicate.kind().skip_binder() {
|
||||||
ty::PredicateKind::TypeOutlives(OutlivesPredicate(ty, reg)) => {
|
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(OutlivesPredicate(
|
||||||
insert_outlives_predicate(
|
ty,
|
||||||
tcx,
|
reg,
|
||||||
ty.into(),
|
))) => insert_outlives_predicate(
|
||||||
reg,
|
tcx,
|
||||||
span,
|
ty.into(),
|
||||||
&mut required_predicates,
|
reg,
|
||||||
)
|
span,
|
||||||
}
|
&mut required_predicates,
|
||||||
|
),
|
||||||
|
|
||||||
ty::PredicateKind::RegionOutlives(OutlivesPredicate(reg1, reg2)) => {
|
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(OutlivesPredicate(
|
||||||
insert_outlives_predicate(
|
reg1,
|
||||||
tcx,
|
reg2,
|
||||||
reg1.into(),
|
))) => insert_outlives_predicate(
|
||||||
reg2,
|
tcx,
|
||||||
span,
|
reg1.into(),
|
||||||
&mut required_predicates,
|
reg2,
|
||||||
)
|
span,
|
||||||
}
|
&mut required_predicates,
|
||||||
|
),
|
||||||
|
|
||||||
ty::PredicateKind::Trait(..)
|
ty::PredicateKind::Clause(ty::Clause::Trait(..))
|
||||||
| ty::PredicateKind::Projection(..)
|
| ty::PredicateKind::Clause(ty::Clause::Projection(..))
|
||||||
| ty::PredicateKind::WellFormed(..)
|
| ty::PredicateKind::WellFormed(..)
|
||||||
| ty::PredicateKind::ObjectSafe(..)
|
| ty::PredicateKind::ObjectSafe(..)
|
||||||
| ty::PredicateKind::ClosureKind(..)
|
| ty::PredicateKind::ClosureKind(..)
|
||||||
|
|
|
@ -51,8 +51,10 @@ fn inferred_outlives_of(tcx: TyCtxt<'_>, item_def_id: DefId) -> &[(ty::Predicate
|
||||||
let mut pred: Vec<String> = predicates
|
let mut pred: Vec<String> = predicates
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(out_pred, _)| match out_pred.kind().skip_binder() {
|
.map(|(out_pred, _)| match out_pred.kind().skip_binder() {
|
||||||
ty::PredicateKind::RegionOutlives(p) => p.to_string(),
|
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(p)) => {
|
||||||
ty::PredicateKind::TypeOutlives(p) => p.to_string(),
|
p.to_string()
|
||||||
|
}
|
||||||
|
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(p)) => p.to_string(),
|
||||||
err => bug!("unexpected predicate {:?}", err),
|
err => bug!("unexpected predicate {:?}", err),
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
@ -101,15 +103,17 @@ fn inferred_outlives_crate(tcx: TyCtxt<'_>, (): ()) -> CratePredicatesMap<'_> {
|
||||||
|(ty::OutlivesPredicate(kind1, region2), &span)| {
|
|(ty::OutlivesPredicate(kind1, region2), &span)| {
|
||||||
match kind1.unpack() {
|
match kind1.unpack() {
|
||||||
GenericArgKind::Type(ty1) => Some((
|
GenericArgKind::Type(ty1) => Some((
|
||||||
ty::Binder::dummy(ty::PredicateKind::TypeOutlives(
|
ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::TypeOutlives(
|
||||||
ty::OutlivesPredicate(ty1, *region2),
|
ty::OutlivesPredicate(ty1, *region2),
|
||||||
))
|
)))
|
||||||
.to_predicate(tcx),
|
.to_predicate(tcx),
|
||||||
span,
|
span,
|
||||||
)),
|
)),
|
||||||
GenericArgKind::Lifetime(region1) => Some((
|
GenericArgKind::Lifetime(region1) => Some((
|
||||||
ty::Binder::dummy(ty::PredicateKind::RegionOutlives(
|
ty::Binder::dummy(ty::PredicateKind::Clause(
|
||||||
ty::OutlivesPredicate(region1, *region2),
|
ty::Clause::RegionOutlives(ty::OutlivesPredicate(
|
||||||
|
region1, *region2,
|
||||||
|
)),
|
||||||
))
|
))
|
||||||
.to_predicate(tcx),
|
.to_predicate(tcx),
|
||||||
span,
|
span,
|
||||||
|
|
|
@ -123,25 +123,28 @@ 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
|
// which thus mentions `'a` and should thus accept hidden types that borrow 'a
|
||||||
// instead of requiring an additional `+ 'a`.
|
// instead of requiring an additional `+ 'a`.
|
||||||
match pred.kind().skip_binder() {
|
match pred.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(ty::TraitPredicate {
|
ty::PredicateKind::Clause(ty::Clause::Trait(ty::TraitPredicate {
|
||||||
trait_ref: ty::TraitRef { def_id: _, substs },
|
trait_ref: ty::TraitRef { def_id: _, substs },
|
||||||
constness: _,
|
constness: _,
|
||||||
polarity: _,
|
polarity: _,
|
||||||
}) => {
|
})) => {
|
||||||
for subst in &substs[1..] {
|
for subst in &substs[1..] {
|
||||||
subst.visit_with(&mut collector);
|
subst.visit_with(&mut collector);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Projection(ty::ProjectionPredicate {
|
ty::PredicateKind::Clause(ty::Clause::Projection(ty::ProjectionPredicate {
|
||||||
projection_ty: ty::ProjectionTy { substs, item_def_id: _ },
|
projection_ty: ty::ProjectionTy { substs, item_def_id: _ },
|
||||||
term,
|
term,
|
||||||
}) => {
|
})) => {
|
||||||
for subst in &substs[1..] {
|
for subst in &substs[1..] {
|
||||||
subst.visit_with(&mut collector);
|
subst.visit_with(&mut collector);
|
||||||
}
|
}
|
||||||
term.visit_with(&mut collector);
|
term.visit_with(&mut collector);
|
||||||
}
|
}
|
||||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(_, region)) => {
|
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(ty::OutlivesPredicate(
|
||||||
|
_,
|
||||||
|
region,
|
||||||
|
))) => {
|
||||||
region.visit_with(&mut collector);
|
region.visit_with(&mut collector);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
|
|
@ -539,17 +539,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
.subst_iter_copied(self.tcx, substs)
|
.subst_iter_copied(self.tcx, substs)
|
||||||
{
|
{
|
||||||
let pred = pred.kind().rebind(match pred.kind().skip_binder() {
|
let pred = pred.kind().rebind(match pred.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(trait_pred) => {
|
ty::PredicateKind::Clause(ty::Clause::Trait(trait_pred)) => {
|
||||||
assert_eq!(trait_pred.trait_ref.self_ty(), opaque_ty);
|
assert_eq!(trait_pred.trait_ref.self_ty(), opaque_ty);
|
||||||
ty::PredicateKind::Trait(trait_pred.with_self_type(self.tcx, ty))
|
ty::PredicateKind::Clause(ty::Clause::Trait(
|
||||||
|
trait_pred.with_self_type(self.tcx, ty),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Projection(mut proj_pred) => {
|
ty::PredicateKind::Clause(ty::Clause::Projection(mut proj_pred)) => {
|
||||||
assert_eq!(proj_pred.projection_ty.self_ty(), opaque_ty);
|
assert_eq!(proj_pred.projection_ty.self_ty(), opaque_ty);
|
||||||
proj_pred.projection_ty.substs = self.tcx.mk_substs_trait(
|
proj_pred.projection_ty.substs = self.tcx.mk_substs_trait(
|
||||||
ty,
|
ty,
|
||||||
proj_pred.projection_ty.substs.iter().skip(1),
|
proj_pred.projection_ty.substs.iter().skip(1),
|
||||||
);
|
);
|
||||||
ty::PredicateKind::Projection(proj_pred)
|
ty::PredicateKind::Clause(ty::Clause::Projection(proj_pred))
|
||||||
}
|
}
|
||||||
_ => continue,
|
_ => continue,
|
||||||
});
|
});
|
||||||
|
|
|
@ -212,7 +212,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
// Given a Projection predicate, we can potentially infer
|
// Given a Projection predicate, we can potentially infer
|
||||||
// the complete signature.
|
// the complete signature.
|
||||||
if expected_sig.is_none()
|
if expected_sig.is_none()
|
||||||
&& let ty::PredicateKind::Projection(proj_predicate) = bound_predicate.skip_binder()
|
&& let ty::PredicateKind::Clause(ty::Clause::Projection(proj_predicate)) = bound_predicate.skip_binder()
|
||||||
{
|
{
|
||||||
expected_sig = self.normalize_associated_types_in(
|
expected_sig = self.normalize_associated_types_in(
|
||||||
obligation.cause.span,
|
obligation.cause.span,
|
||||||
|
@ -228,10 +228,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
// like `F : Fn<A>`. Note that due to subtyping we could encounter
|
// like `F : Fn<A>`. Note that due to subtyping we could encounter
|
||||||
// many viable options, so pick the most restrictive.
|
// many viable options, so pick the most restrictive.
|
||||||
let trait_def_id = match bound_predicate.skip_binder() {
|
let trait_def_id = match bound_predicate.skip_binder() {
|
||||||
ty::PredicateKind::Projection(data) => {
|
ty::PredicateKind::Clause(ty::Clause::Projection(data)) => {
|
||||||
Some(data.projection_ty.trait_def_id(self.tcx))
|
Some(data.projection_ty.trait_def_id(self.tcx))
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Trait(data) => Some(data.def_id()),
|
ty::PredicateKind::Clause(ty::Clause::Trait(data)) => Some(data.def_id()),
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
if let Some(closure_kind) =
|
if let Some(closure_kind) =
|
||||||
|
@ -658,7 +658,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
// where R is the return type we are expecting. This type `T`
|
// where R is the return type we are expecting. This type `T`
|
||||||
// will be our output.
|
// will be our output.
|
||||||
let bound_predicate = predicate.kind();
|
let bound_predicate = predicate.kind();
|
||||||
if let ty::PredicateKind::Projection(proj_predicate) = bound_predicate.skip_binder() {
|
if let ty::PredicateKind::Clause(ty::Clause::Projection(proj_predicate)) =
|
||||||
|
bound_predicate.skip_binder()
|
||||||
|
{
|
||||||
self.deduce_future_output_from_projection(
|
self.deduce_future_output_from_projection(
|
||||||
span,
|
span,
|
||||||
bound_predicate.rebind(proj_predicate),
|
bound_predicate.rebind(proj_predicate),
|
||||||
|
|
|
@ -644,7 +644,9 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
||||||
debug!("coerce_unsized resolve step: {:?}", obligation);
|
debug!("coerce_unsized resolve step: {:?}", obligation);
|
||||||
let bound_predicate = obligation.predicate.kind();
|
let bound_predicate = obligation.predicate.kind();
|
||||||
let trait_pred = match bound_predicate.skip_binder() {
|
let trait_pred = match bound_predicate.skip_binder() {
|
||||||
ty::PredicateKind::Trait(trait_pred) if traits.contains(&trait_pred.def_id()) => {
|
ty::PredicateKind::Clause(ty::Clause::Trait(trait_pred))
|
||||||
|
if traits.contains(&trait_pred.def_id()) =>
|
||||||
|
{
|
||||||
if unsize_did == trait_pred.def_id() {
|
if unsize_did == trait_pred.def_id() {
|
||||||
let self_ty = trait_pred.self_ty();
|
let self_ty = trait_pred.self_ty();
|
||||||
let unsize_ty = trait_pred.trait_ref.substs[1].expect_ty();
|
let unsize_ty = trait_pred.trait_ref.substs[1].expect_ty();
|
||||||
|
@ -778,8 +780,8 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
||||||
self.tcx,
|
self.tcx,
|
||||||
self.cause.clone(),
|
self.cause.clone(),
|
||||||
self.param_env,
|
self.param_env,
|
||||||
ty::Binder::dummy(ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(
|
ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::TypeOutlives(
|
||||||
a, b_region,
|
ty::OutlivesPredicate(a, b_region),
|
||||||
))),
|
))),
|
||||||
),
|
),
|
||||||
])
|
])
|
||||||
|
|
|
@ -2824,7 +2824,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
) {
|
) {
|
||||||
for error in errors {
|
for error in errors {
|
||||||
match error.obligation.predicate.kind().skip_binder() {
|
match error.obligation.predicate.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(predicate)
|
ty::PredicateKind::Clause(ty::Clause::Trait(predicate))
|
||||||
if self.tcx.is_diagnostic_item(sym::SliceIndex, predicate.trait_ref.def_id) => {
|
if self.tcx.is_diagnostic_item(sym::SliceIndex, predicate.trait_ref.def_id) => {
|
||||||
}
|
}
|
||||||
_ => continue,
|
_ => continue,
|
||||||
|
|
|
@ -669,7 +669,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
self.fulfillment_cx.borrow().pending_obligations().into_iter().filter_map(
|
self.fulfillment_cx.borrow().pending_obligations().into_iter().filter_map(
|
||||||
move |obligation| match &obligation.predicate.kind().skip_binder() {
|
move |obligation| match &obligation.predicate.kind().skip_binder() {
|
||||||
ty::PredicateKind::Projection(data)
|
ty::PredicateKind::Clause(ty::Clause::Projection(data))
|
||||||
if self.self_type_matches_expected_vid(
|
if self.self_type_matches_expected_vid(
|
||||||
data.projection_ty.self_ty(),
|
data.projection_ty.self_ty(),
|
||||||
ty_var_root,
|
ty_var_root,
|
||||||
|
@ -677,18 +677,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
{
|
{
|
||||||
Some(obligation)
|
Some(obligation)
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Trait(data)
|
ty::PredicateKind::Clause(ty::Clause::Trait(data))
|
||||||
if self.self_type_matches_expected_vid(data.self_ty(), ty_var_root) =>
|
if self.self_type_matches_expected_vid(data.self_ty(), ty_var_root) =>
|
||||||
{
|
{
|
||||||
Some(obligation)
|
Some(obligation)
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::PredicateKind::Trait(..)
|
ty::PredicateKind::Clause(ty::Clause::Trait(..))
|
||||||
| ty::PredicateKind::Projection(..)
|
| ty::PredicateKind::Clause(ty::Clause::Projection(..))
|
||||||
| ty::PredicateKind::Subtype(..)
|
| ty::PredicateKind::Subtype(..)
|
||||||
| ty::PredicateKind::Coerce(..)
|
| ty::PredicateKind::Coerce(..)
|
||||||
| ty::PredicateKind::RegionOutlives(..)
|
| ty::PredicateKind::Clause(ty::Clause::RegionOutlives(..))
|
||||||
| ty::PredicateKind::TypeOutlives(..)
|
| ty::PredicateKind::Clause(ty::Clause::TypeOutlives(..))
|
||||||
| ty::PredicateKind::WellFormed(..)
|
| ty::PredicateKind::WellFormed(..)
|
||||||
| ty::PredicateKind::ObjectSafe(..)
|
| ty::PredicateKind::ObjectSafe(..)
|
||||||
| ty::PredicateKind::ConstEvaluatable(..)
|
| ty::PredicateKind::ConstEvaluatable(..)
|
||||||
|
@ -712,7 +712,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
let sized_did = self.tcx.lang_items().sized_trait();
|
let sized_did = self.tcx.lang_items().sized_trait();
|
||||||
self.obligations_for_self_ty(self_ty).any(|obligation| {
|
self.obligations_for_self_ty(self_ty).any(|obligation| {
|
||||||
match obligation.predicate.kind().skip_binder() {
|
match obligation.predicate.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(data) => Some(data.def_id()) == sized_did,
|
ty::PredicateKind::Clause(ty::Clause::Trait(data)) => {
|
||||||
|
Some(data.def_id()) == sized_did
|
||||||
|
}
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -1740,8 +1740,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
let generics = self.tcx.generics_of(def_id);
|
let generics = self.tcx.generics_of(def_id);
|
||||||
let predicate_substs = match unsubstituted_pred.kind().skip_binder() {
|
let predicate_substs = match unsubstituted_pred.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(pred) => pred.trait_ref.substs,
|
ty::PredicateKind::Clause(ty::Clause::Trait(pred)) => pred.trait_ref.substs,
|
||||||
ty::PredicateKind::Projection(pred) => pred.projection_ty.substs,
|
ty::PredicateKind::Clause(ty::Clause::Projection(pred)) => pred.projection_ty.substs,
|
||||||
_ => ty::List::empty(),
|
_ => ty::List::empty(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2113,7 +2113,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
for (predicate, span) in
|
for (predicate, span) in
|
||||||
std::iter::zip(instantiated.predicates, instantiated.spans)
|
std::iter::zip(instantiated.predicates, instantiated.spans)
|
||||||
{
|
{
|
||||||
if let ty::PredicateKind::Trait(pred) = predicate.kind().skip_binder()
|
if let ty::PredicateKind::Clause(ty::Clause::Trait(pred)) = predicate.kind().skip_binder()
|
||||||
&& pred.self_ty().peel_refs() == callee_ty
|
&& pred.self_ty().peel_refs() == callee_ty
|
||||||
&& ty::ClosureKind::from_def_id(self.tcx, pred.def_id()).is_some()
|
&& ty::ClosureKind::from_def_id(self.tcx, pred.def_id()).is_some()
|
||||||
{
|
{
|
||||||
|
|
|
@ -201,7 +201,9 @@ impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> {
|
||||||
predicates: tcx.arena.alloc_from_iter(
|
predicates: tcx.arena.alloc_from_iter(
|
||||||
self.param_env.caller_bounds().iter().filter_map(|predicate| {
|
self.param_env.caller_bounds().iter().filter_map(|predicate| {
|
||||||
match predicate.kind().skip_binder() {
|
match predicate.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(data) if data.self_ty().is_param(index) => {
|
ty::PredicateKind::Clause(ty::Clause::Trait(data))
|
||||||
|
if data.self_ty().is_param(index) =>
|
||||||
|
{
|
||||||
// HACK(eddyb) should get the original `Span`.
|
// HACK(eddyb) should get the original `Span`.
|
||||||
let span = tcx.def_span(def_id);
|
let span = tcx.def_span(def_id);
|
||||||
Some((predicate, span))
|
Some((predicate, span))
|
||||||
|
|
|
@ -173,7 +173,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
ty::Opaque(def_id, substs) => {
|
ty::Opaque(def_id, substs) => {
|
||||||
self.tcx.bound_item_bounds(def_id).subst(self.tcx, substs).iter().find_map(|pred| {
|
self.tcx.bound_item_bounds(def_id).subst(self.tcx, substs).iter().find_map(|pred| {
|
||||||
if let ty::PredicateKind::Projection(proj) = pred.kind().skip_binder()
|
if let ty::PredicateKind::Clause(ty::Clause::Projection(proj)) = pred.kind().skip_binder()
|
||||||
&& Some(proj.projection_ty.item_def_id) == self.tcx.lang_items().fn_once_output()
|
&& Some(proj.projection_ty.item_def_id) == self.tcx.lang_items().fn_once_output()
|
||||||
// args tuple will always be substs[1]
|
// args tuple will always be substs[1]
|
||||||
&& let ty::Tuple(args) = proj.projection_ty.substs.type_at(1).kind()
|
&& let ty::Tuple(args) = proj.projection_ty.substs.type_at(1).kind()
|
||||||
|
@ -208,7 +208,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
ty::Param(param) => {
|
ty::Param(param) => {
|
||||||
let def_id = self.tcx.generics_of(self.body_id.owner).type_param(¶m, self.tcx).def_id;
|
let def_id = self.tcx.generics_of(self.body_id.owner).type_param(¶m, self.tcx).def_id;
|
||||||
self.tcx.predicates_of(self.body_id.owner).predicates.iter().find_map(|(pred, _)| {
|
self.tcx.predicates_of(self.body_id.owner).predicates.iter().find_map(|(pred, _)| {
|
||||||
if let ty::PredicateKind::Projection(proj) = pred.kind().skip_binder()
|
if let ty::PredicateKind::Clause(ty::Clause::Projection(proj)) = pred.kind().skip_binder()
|
||||||
&& Some(proj.projection_ty.item_def_id) == self.tcx.lang_items().fn_once_output()
|
&& Some(proj.projection_ty.item_def_id) == self.tcx.lang_items().fn_once_output()
|
||||||
&& proj.projection_ty.self_ty() == found
|
&& proj.projection_ty.self_ty() == found
|
||||||
// args tuple will always be substs[1]
|
// args tuple will always be substs[1]
|
||||||
|
|
|
@ -566,7 +566,7 @@ fn check_must_not_suspend_ty<'tcx>(
|
||||||
let mut has_emitted = false;
|
let mut has_emitted = false;
|
||||||
for &(predicate, _) in fcx.tcx.explicit_item_bounds(def) {
|
for &(predicate, _) in fcx.tcx.explicit_item_bounds(def) {
|
||||||
// We only look at the `DefId`, so it is safe to skip the binder here.
|
// We only look at the `DefId`, so it is safe to skip the binder here.
|
||||||
if let ty::PredicateKind::Trait(ref poly_trait_predicate) =
|
if let ty::PredicateKind::Clause(ty::Clause::Trait(ref poly_trait_predicate)) =
|
||||||
predicate.kind().skip_binder()
|
predicate.kind().skip_binder()
|
||||||
{
|
{
|
||||||
let def_id = poly_trait_predicate.trait_ref.def_id;
|
let def_id = poly_trait_predicate.trait_ref.def_id;
|
||||||
|
|
|
@ -531,7 +531,9 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
|
||||||
traits::elaborate_predicates(self.tcx, predicates.predicates.iter().copied())
|
traits::elaborate_predicates(self.tcx, predicates.predicates.iter().copied())
|
||||||
// We don't care about regions here.
|
// We don't care about regions here.
|
||||||
.filter_map(|obligation| match obligation.predicate.kind().skip_binder() {
|
.filter_map(|obligation| match obligation.predicate.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(trait_pred) if trait_pred.def_id() == sized_def_id => {
|
ty::PredicateKind::Clause(ty::Clause::Trait(trait_pred))
|
||||||
|
if trait_pred.def_id() == sized_def_id =>
|
||||||
|
{
|
||||||
let span = iter::zip(&predicates.predicates, &predicates.spans)
|
let span = iter::zip(&predicates.predicates, &predicates.spans)
|
||||||
.find_map(
|
.find_map(
|
||||||
|(p, span)| {
|
|(p, span)| {
|
||||||
|
|
|
@ -785,7 +785,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
||||||
let bounds = self.param_env.caller_bounds().iter().filter_map(|predicate| {
|
let bounds = self.param_env.caller_bounds().iter().filter_map(|predicate| {
|
||||||
let bound_predicate = predicate.kind();
|
let bound_predicate = predicate.kind();
|
||||||
match bound_predicate.skip_binder() {
|
match bound_predicate.skip_binder() {
|
||||||
ty::PredicateKind::Trait(trait_predicate) => {
|
ty::PredicateKind::Clause(ty::Clause::Trait(trait_predicate)) => {
|
||||||
match *trait_predicate.trait_ref.self_ty().kind() {
|
match *trait_predicate.trait_ref.self_ty().kind() {
|
||||||
ty::Param(p) if p == param_ty => {
|
ty::Param(p) if p == param_ty => {
|
||||||
Some(bound_predicate.rebind(trait_predicate.trait_ref))
|
Some(bound_predicate.rebind(trait_predicate.trait_ref))
|
||||||
|
@ -795,12 +795,12 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Subtype(..)
|
ty::PredicateKind::Subtype(..)
|
||||||
| ty::PredicateKind::Coerce(..)
|
| ty::PredicateKind::Coerce(..)
|
||||||
| ty::PredicateKind::Projection(..)
|
| ty::PredicateKind::Clause(ty::Clause::Projection(..))
|
||||||
| ty::PredicateKind::RegionOutlives(..)
|
| ty::PredicateKind::Clause(ty::Clause::RegionOutlives(..))
|
||||||
| ty::PredicateKind::WellFormed(..)
|
| ty::PredicateKind::WellFormed(..)
|
||||||
| ty::PredicateKind::ObjectSafe(..)
|
| ty::PredicateKind::ObjectSafe(..)
|
||||||
| ty::PredicateKind::ClosureKind(..)
|
| ty::PredicateKind::ClosureKind(..)
|
||||||
| ty::PredicateKind::TypeOutlives(..)
|
| ty::PredicateKind::Clause(ty::Clause::TypeOutlives(..))
|
||||||
| ty::PredicateKind::ConstEvaluatable(..)
|
| ty::PredicateKind::ConstEvaluatable(..)
|
||||||
| ty::PredicateKind::ConstEquate(..)
|
| ty::PredicateKind::ConstEquate(..)
|
||||||
| ty::PredicateKind::Ambiguous
|
| ty::PredicateKind::Ambiguous
|
||||||
|
|
|
@ -442,7 +442,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
let mut unimplemented_traits = FxHashMap::default();
|
let mut unimplemented_traits = FxHashMap::default();
|
||||||
let mut unimplemented_traits_only = true;
|
let mut unimplemented_traits_only = true;
|
||||||
for (predicate, _parent_pred, cause) in &unsatisfied_predicates {
|
for (predicate, _parent_pred, cause) in &unsatisfied_predicates {
|
||||||
if let (ty::PredicateKind::Trait(p), Some(cause)) =
|
if let (ty::PredicateKind::Clause(ty::Clause::Trait(p)), Some(cause)) =
|
||||||
(predicate.kind().skip_binder(), cause.as_ref())
|
(predicate.kind().skip_binder(), cause.as_ref())
|
||||||
{
|
{
|
||||||
if p.trait_ref.self_ty() != rcvr_ty {
|
if p.trait_ref.self_ty() != rcvr_ty {
|
||||||
|
@ -469,7 +469,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
// because of some non-Clone item being iterated over.
|
// because of some non-Clone item being iterated over.
|
||||||
for (predicate, _parent_pred, _cause) in &unsatisfied_predicates {
|
for (predicate, _parent_pred, _cause) in &unsatisfied_predicates {
|
||||||
match predicate.kind().skip_binder() {
|
match predicate.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(p)
|
ty::PredicateKind::Clause(ty::Clause::Trait(p))
|
||||||
if unimplemented_traits.contains_key(&p.trait_ref.def_id) => {}
|
if unimplemented_traits.contains_key(&p.trait_ref.def_id) => {}
|
||||||
_ => {
|
_ => {
|
||||||
unimplemented_traits_only = false;
|
unimplemented_traits_only = false;
|
||||||
|
@ -481,7 +481,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
let mut collect_type_param_suggestions =
|
let mut collect_type_param_suggestions =
|
||||||
|self_ty: Ty<'tcx>, parent_pred: ty::Predicate<'tcx>, obligation: &str| {
|
|self_ty: Ty<'tcx>, parent_pred: ty::Predicate<'tcx>, obligation: &str| {
|
||||||
// We don't care about regions here, so it's fine to skip the binder here.
|
// We don't care about regions here, so it's fine to skip the binder here.
|
||||||
if let (ty::Param(_), ty::PredicateKind::Trait(p)) =
|
if let (ty::Param(_), ty::PredicateKind::Clause(ty::Clause::Trait(p))) =
|
||||||
(self_ty.kind(), parent_pred.kind().skip_binder())
|
(self_ty.kind(), parent_pred.kind().skip_binder())
|
||||||
{
|
{
|
||||||
let hir = self.tcx.hir();
|
let hir = self.tcx.hir();
|
||||||
|
@ -544,7 +544,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
let mut format_pred = |pred: ty::Predicate<'tcx>| {
|
let mut format_pred = |pred: ty::Predicate<'tcx>| {
|
||||||
let bound_predicate = pred.kind();
|
let bound_predicate = pred.kind();
|
||||||
match bound_predicate.skip_binder() {
|
match bound_predicate.skip_binder() {
|
||||||
ty::PredicateKind::Projection(pred) => {
|
ty::PredicateKind::Clause(ty::Clause::Projection(pred)) => {
|
||||||
let pred = bound_predicate.rebind(pred);
|
let pred = bound_predicate.rebind(pred);
|
||||||
// `<Foo as Iterator>::Item = String`.
|
// `<Foo as Iterator>::Item = String`.
|
||||||
let projection_ty = pred.skip_binder().projection_ty;
|
let projection_ty = pred.skip_binder().projection_ty;
|
||||||
|
@ -567,7 +567,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
bound_span_label(projection_ty.self_ty(), &obligation, &quiet);
|
bound_span_label(projection_ty.self_ty(), &obligation, &quiet);
|
||||||
Some((obligation, projection_ty.self_ty()))
|
Some((obligation, projection_ty.self_ty()))
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Trait(poly_trait_ref) => {
|
ty::PredicateKind::Clause(ty::Clause::Trait(poly_trait_ref)) => {
|
||||||
let p = poly_trait_ref.trait_ref;
|
let p = poly_trait_ref.trait_ref;
|
||||||
let self_ty = p.self_ty();
|
let self_ty = p.self_ty();
|
||||||
let path = p.print_only_trait_path();
|
let path = p.print_only_trait_path();
|
||||||
|
@ -637,7 +637,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
let sized_pred =
|
let sized_pred =
|
||||||
unsatisfied_predicates.iter().any(|(pred, _, _)| {
|
unsatisfied_predicates.iter().any(|(pred, _, _)| {
|
||||||
match pred.kind().skip_binder() {
|
match pred.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(pred) => {
|
ty::PredicateKind::Clause(ty::Clause::Trait(pred)) => {
|
||||||
Some(pred.def_id())
|
Some(pred.def_id())
|
||||||
== self.tcx.lang_items().sized_trait()
|
== self.tcx.lang_items().sized_trait()
|
||||||
&& pred.polarity == ty::ImplPolarity::Positive
|
&& pred.polarity == ty::ImplPolarity::Positive
|
||||||
|
@ -1722,7 +1722,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
) {
|
) {
|
||||||
let all_local_types_needing_impls =
|
let all_local_types_needing_impls =
|
||||||
errors.iter().all(|e| match e.obligation.predicate.kind().skip_binder() {
|
errors.iter().all(|e| match e.obligation.predicate.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(pred) => match pred.self_ty().kind() {
|
ty::PredicateKind::Clause(ty::Clause::Trait(pred)) => match pred.self_ty().kind() {
|
||||||
ty::Adt(def, _) => def.did().is_local(),
|
ty::Adt(def, _) => def.did().is_local(),
|
||||||
_ => false,
|
_ => false,
|
||||||
},
|
},
|
||||||
|
@ -1731,7 +1731,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
let mut preds: Vec<_> = errors
|
let mut preds: Vec<_> = errors
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|e| match e.obligation.predicate.kind().skip_binder() {
|
.filter_map(|e| match e.obligation.predicate.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(pred) => Some(pred),
|
ty::PredicateKind::Clause(ty::Clause::Trait(pred)) => Some(pred),
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
@ -1802,7 +1802,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
let mut derives = Vec::<(String, Span, Symbol)>::new();
|
let mut derives = Vec::<(String, Span, Symbol)>::new();
|
||||||
let mut traits = Vec::<Span>::new();
|
let mut traits = Vec::<Span>::new();
|
||||||
for (pred, _, _) in unsatisfied_predicates {
|
for (pred, _, _) in unsatisfied_predicates {
|
||||||
let ty::PredicateKind::Trait(trait_pred) = pred.kind().skip_binder() else { continue };
|
let ty::PredicateKind::Clause(ty::Clause::Trait(trait_pred)) = pred.kind().skip_binder() else { continue };
|
||||||
let adt = match trait_pred.self_ty().ty_adt_def() {
|
let adt = match trait_pred.self_ty().ty_adt_def() {
|
||||||
Some(adt) if adt.did().is_local() => adt,
|
Some(adt) if adt.did().is_local() => adt,
|
||||||
_ => continue,
|
_ => continue,
|
||||||
|
@ -2212,8 +2212,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
match p.kind().skip_binder() {
|
match p.kind().skip_binder() {
|
||||||
// Hide traits if they are present in predicates as they can be fixed without
|
// Hide traits if they are present in predicates as they can be fixed without
|
||||||
// having to implement them.
|
// having to implement them.
|
||||||
ty::PredicateKind::Trait(t) => t.def_id() == info.def_id,
|
ty::PredicateKind::Clause(ty::Clause::Trait(t)) => {
|
||||||
ty::PredicateKind::Projection(p) => {
|
t.def_id() == info.def_id
|
||||||
|
}
|
||||||
|
ty::PredicateKind::Clause(ty::Clause::Projection(p)) => {
|
||||||
p.projection_ty.item_def_id == info.def_id
|
p.projection_ty.item_def_id == info.def_id
|
||||||
}
|
}
|
||||||
_ => false,
|
_ => false,
|
||||||
|
|
|
@ -569,10 +569,10 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
|
|
||||||
let atom = match k1.unpack() {
|
let atom = match k1.unpack() {
|
||||||
GenericArgKind::Lifetime(r1) => {
|
GenericArgKind::Lifetime(r1) => {
|
||||||
ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(r1, r2))
|
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(ty::OutlivesPredicate(r1, r2)))
|
||||||
}
|
}
|
||||||
GenericArgKind::Type(t1) => {
|
GenericArgKind::Type(t1) => {
|
||||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(t1, r2))
|
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(ty::OutlivesPredicate(t1, r2)))
|
||||||
}
|
}
|
||||||
GenericArgKind::Const(..) => {
|
GenericArgKind::Const(..) => {
|
||||||
// Consts cannot outlive one another, so we don't expect to
|
// Consts cannot outlive one another, so we don't expect to
|
||||||
|
@ -720,8 +720,8 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for QueryTypeRelatingDelegate<'_, 'tcx> {
|
||||||
self.obligations.push(Obligation {
|
self.obligations.push(Obligation {
|
||||||
cause: self.cause.clone(),
|
cause: self.cause.clone(),
|
||||||
param_env: self.param_env,
|
param_env: self.param_env,
|
||||||
predicate: ty::Binder::dummy(ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(
|
predicate: ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::RegionOutlives(
|
||||||
sup, sub,
|
ty::OutlivesPredicate(sup, sub),
|
||||||
)))
|
)))
|
||||||
.to_predicate(self.infcx.tcx),
|
.to_predicate(self.infcx.tcx),
|
||||||
recursion_depth: 0,
|
recursion_depth: 0,
|
||||||
|
|
|
@ -351,7 +351,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
let output = predicate
|
let output = predicate
|
||||||
.kind()
|
.kind()
|
||||||
.map_bound(|kind| match kind {
|
.map_bound(|kind| match kind {
|
||||||
ty::PredicateKind::Projection(projection_predicate)
|
ty::PredicateKind::Clause(ty::Clause::Projection(projection_predicate))
|
||||||
if projection_predicate.projection_ty.item_def_id == item_def_id =>
|
if projection_predicate.projection_ty.item_def_id == item_def_id =>
|
||||||
{
|
{
|
||||||
projection_predicate.term.ty()
|
projection_predicate.term.ty()
|
||||||
|
|
|
@ -595,7 +595,9 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
ct_op: |ct| ct,
|
ct_op: |ct| ct,
|
||||||
});
|
});
|
||||||
|
|
||||||
if let ty::PredicateKind::Projection(projection) = predicate.kind().skip_binder() {
|
if let ty::PredicateKind::Clause(ty::Clause::Projection(projection)) =
|
||||||
|
predicate.kind().skip_binder()
|
||||||
|
{
|
||||||
if projection.term.references_error() {
|
if projection.term.references_error() {
|
||||||
// No point on adding these obligations since there's a type error involved.
|
// No point on adding these obligations since there's a type error involved.
|
||||||
return Ok(InferOk { value: (), obligations: vec![] });
|
return Ok(InferOk { value: (), obligations: vec![] });
|
||||||
|
|
|
@ -19,20 +19,21 @@ pub fn explicit_outlives_bounds<'tcx>(
|
||||||
.map(ty::Predicate::kind)
|
.map(ty::Predicate::kind)
|
||||||
.filter_map(ty::Binder::no_bound_vars)
|
.filter_map(ty::Binder::no_bound_vars)
|
||||||
.filter_map(move |kind| match kind {
|
.filter_map(move |kind| match kind {
|
||||||
ty::PredicateKind::Projection(..)
|
ty::PredicateKind::Clause(ty::Clause::Projection(..))
|
||||||
| ty::PredicateKind::Trait(..)
|
| ty::PredicateKind::Clause(ty::Clause::Trait(..))
|
||||||
| ty::PredicateKind::Coerce(..)
|
| ty::PredicateKind::Coerce(..)
|
||||||
| ty::PredicateKind::Subtype(..)
|
| ty::PredicateKind::Subtype(..)
|
||||||
| ty::PredicateKind::WellFormed(..)
|
| ty::PredicateKind::WellFormed(..)
|
||||||
| ty::PredicateKind::ObjectSafe(..)
|
| ty::PredicateKind::ObjectSafe(..)
|
||||||
| ty::PredicateKind::ClosureKind(..)
|
| ty::PredicateKind::ClosureKind(..)
|
||||||
| ty::PredicateKind::TypeOutlives(..)
|
| ty::PredicateKind::Clause(ty::Clause::TypeOutlives(..))
|
||||||
| ty::PredicateKind::ConstEvaluatable(..)
|
| ty::PredicateKind::ConstEvaluatable(..)
|
||||||
| ty::PredicateKind::ConstEquate(..)
|
| ty::PredicateKind::ConstEquate(..)
|
||||||
| ty::PredicateKind::Ambiguous
|
| ty::PredicateKind::Ambiguous
|
||||||
| ty::PredicateKind::TypeWellFormedFromEnv(..) => None,
|
| ty::PredicateKind::TypeWellFormedFromEnv(..) => None,
|
||||||
ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(r_a, r_b)) => {
|
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(ty::OutlivesPredicate(
|
||||||
Some(OutlivesBound::RegionSubRegion(r_b, r_a))
|
r_a,
|
||||||
}
|
r_b,
|
||||||
|
))) => Some(OutlivesBound::RegionSubRegion(r_b, r_a)),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,8 +70,8 @@ impl<'tcx> PredicateObligation<'tcx> {
|
||||||
|
|
||||||
pub fn without_const(mut self, tcx: TyCtxt<'tcx>) -> PredicateObligation<'tcx> {
|
pub fn without_const(mut self, tcx: TyCtxt<'tcx>) -> PredicateObligation<'tcx> {
|
||||||
self.param_env = self.param_env.without_const();
|
self.param_env = self.param_env.without_const();
|
||||||
if let ty::PredicateKind::Trait(trait_pred) = self.predicate.kind().skip_binder() && trait_pred.is_const_if_const() {
|
if let ty::PredicateKind::Clause(ty::Clause::Trait(trait_pred)) = self.predicate.kind().skip_binder() && trait_pred.is_const_if_const() {
|
||||||
self.predicate = tcx.mk_predicate(self.predicate.kind().map_bound(|_| ty::PredicateKind::Trait(trait_pred.without_const())));
|
self.predicate = tcx.mk_predicate(self.predicate.kind().map_bound(|_| ty::PredicateKind::Clause(ty::Clause::Trait(trait_pred.without_const()))));
|
||||||
}
|
}
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,7 +141,7 @@ impl<'tcx> Elaborator<'tcx> {
|
||||||
|
|
||||||
let bound_predicate = obligation.predicate.kind();
|
let bound_predicate = obligation.predicate.kind();
|
||||||
match bound_predicate.skip_binder() {
|
match bound_predicate.skip_binder() {
|
||||||
ty::PredicateKind::Trait(data) => {
|
ty::PredicateKind::Clause(ty::Clause::Trait(data)) => {
|
||||||
// Get predicates declared on the trait.
|
// Get predicates declared on the trait.
|
||||||
let predicates = tcx.super_predicates_of(data.def_id());
|
let predicates = tcx.super_predicates_of(data.def_id());
|
||||||
|
|
||||||
|
@ -184,7 +184,7 @@ impl<'tcx> Elaborator<'tcx> {
|
||||||
// Currently, we do not "elaborate" predicates like `X -> Y`,
|
// Currently, we do not "elaborate" predicates like `X -> Y`,
|
||||||
// though conceivably we might.
|
// though conceivably we might.
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Projection(..) => {
|
ty::PredicateKind::Clause(ty::Clause::Projection(..)) => {
|
||||||
// Nothing to elaborate in a projection predicate.
|
// Nothing to elaborate in a projection predicate.
|
||||||
}
|
}
|
||||||
ty::PredicateKind::ClosureKind(..) => {
|
ty::PredicateKind::ClosureKind(..) => {
|
||||||
|
@ -198,10 +198,13 @@ impl<'tcx> Elaborator<'tcx> {
|
||||||
// Currently, we do not elaborate const-equate
|
// Currently, we do not elaborate const-equate
|
||||||
// predicates.
|
// predicates.
|
||||||
}
|
}
|
||||||
ty::PredicateKind::RegionOutlives(..) => {
|
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(..)) => {
|
||||||
// Nothing to elaborate from `'a: 'b`.
|
// Nothing to elaborate from `'a: 'b`.
|
||||||
}
|
}
|
||||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty_max, r_min)) => {
|
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(ty::OutlivesPredicate(
|
||||||
|
ty_max,
|
||||||
|
r_min,
|
||||||
|
))) => {
|
||||||
// We know that `T: 'a` for some type `T`. We can
|
// We know that `T: 'a` for some type `T`. We can
|
||||||
// often elaborate this. For example, if we know that
|
// often elaborate this. For example, if we know that
|
||||||
// `[U]: 'a`, that implies that `U: 'a`. Similarly, if
|
// `[U]: 'a`, that implies that `U: 'a`. Similarly, if
|
||||||
|
@ -231,16 +234,16 @@ impl<'tcx> Elaborator<'tcx> {
|
||||||
if r.is_late_bound() {
|
if r.is_late_bound() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(
|
Some(ty::PredicateKind::Clause(ty::Clause::RegionOutlives(
|
||||||
r, r_min,
|
ty::OutlivesPredicate(r, r_min),
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component::Param(p) => {
|
Component::Param(p) => {
|
||||||
let ty = tcx.mk_ty_param(p.index, p.name);
|
let ty = tcx.mk_ty_param(p.index, p.name);
|
||||||
Some(ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(
|
Some(ty::PredicateKind::Clause(ty::Clause::TypeOutlives(
|
||||||
ty, r_min,
|
ty::OutlivesPredicate(ty, r_min),
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,8 +251,8 @@ impl<'tcx> Elaborator<'tcx> {
|
||||||
|
|
||||||
Component::Opaque(def_id, substs) => {
|
Component::Opaque(def_id, substs) => {
|
||||||
let ty = tcx.mk_opaque(def_id, substs);
|
let ty = tcx.mk_opaque(def_id, substs);
|
||||||
Some(ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(
|
Some(ty::PredicateKind::Clause(ty::Clause::TypeOutlives(
|
||||||
ty, r_min,
|
ty::OutlivesPredicate(ty, r_min),
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,8 +261,8 @@ impl<'tcx> Elaborator<'tcx> {
|
||||||
// With this, we can deduce that `<Bar as Baz>::Assoc: 'a`.
|
// With this, we can deduce that `<Bar as Baz>::Assoc: 'a`.
|
||||||
let ty =
|
let ty =
|
||||||
tcx.mk_projection(projection.item_def_id, projection.substs);
|
tcx.mk_projection(projection.item_def_id, projection.substs);
|
||||||
Some(ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(
|
Some(ty::PredicateKind::Clause(ty::Clause::TypeOutlives(
|
||||||
ty, r_min,
|
ty::OutlivesPredicate(ty, r_min),
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1638,19 +1638,20 @@ declare_lint_pass!(
|
||||||
impl<'tcx> LateLintPass<'tcx> for TrivialConstraints {
|
impl<'tcx> LateLintPass<'tcx> for TrivialConstraints {
|
||||||
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
|
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
|
||||||
use rustc_middle::ty::visit::TypeVisitable;
|
use rustc_middle::ty::visit::TypeVisitable;
|
||||||
|
use rustc_middle::ty::Clause;
|
||||||
use rustc_middle::ty::PredicateKind::*;
|
use rustc_middle::ty::PredicateKind::*;
|
||||||
|
|
||||||
if cx.tcx.features().trivial_bounds {
|
if cx.tcx.features().trivial_bounds {
|
||||||
let predicates = cx.tcx.predicates_of(item.owner_id);
|
let predicates = cx.tcx.predicates_of(item.owner_id);
|
||||||
for &(predicate, span) in predicates.predicates {
|
for &(predicate, span) in predicates.predicates {
|
||||||
let predicate_kind_name = match predicate.kind().skip_binder() {
|
let predicate_kind_name = match predicate.kind().skip_binder() {
|
||||||
Trait(..) => "trait",
|
Clause(Clause::Trait(..)) => "trait",
|
||||||
TypeOutlives(..) |
|
Clause(Clause::TypeOutlives(..)) |
|
||||||
RegionOutlives(..) => "lifetime",
|
Clause(Clause::RegionOutlives(..)) => "lifetime",
|
||||||
|
|
||||||
// Ignore projections, as they can only be global
|
// Ignore projections, as they can only be global
|
||||||
// if the trait bound is global
|
// if the trait bound is global
|
||||||
Projection(..) |
|
Clause(Clause::Projection(..)) |
|
||||||
// Ignore bounds that a user can't type
|
// Ignore bounds that a user can't type
|
||||||
WellFormed(..) |
|
WellFormed(..) |
|
||||||
ObjectSafe(..) |
|
ObjectSafe(..) |
|
||||||
|
@ -2051,7 +2052,10 @@ impl ExplicitOutlivesRequirements {
|
||||||
inferred_outlives
|
inferred_outlives
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|(pred, _)| match pred.kind().skip_binder() {
|
.filter_map(|(pred, _)| match pred.kind().skip_binder() {
|
||||||
ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(a, b)) => match *a {
|
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(ty::OutlivesPredicate(
|
||||||
|
a,
|
||||||
|
b,
|
||||||
|
))) => match *a {
|
||||||
ty::ReEarlyBound(ebr) if ebr.def_id == def_id => Some(b),
|
ty::ReEarlyBound(ebr) if ebr.def_id == def_id => Some(b),
|
||||||
_ => None,
|
_ => None,
|
||||||
},
|
},
|
||||||
|
@ -2067,9 +2071,10 @@ impl ExplicitOutlivesRequirements {
|
||||||
inferred_outlives
|
inferred_outlives
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|(pred, _)| match pred.kind().skip_binder() {
|
.filter_map(|(pred, _)| match pred.kind().skip_binder() {
|
||||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(a, b)) => {
|
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(ty::OutlivesPredicate(
|
||||||
a.is_param(index).then_some(b)
|
a,
|
||||||
}
|
b,
|
||||||
|
))) => a.is_param(index).then_some(b),
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
|
|
|
@ -74,7 +74,7 @@ impl<'tcx> LateLintPass<'tcx> for OpaqueHiddenInferredBound {
|
||||||
// Liberate bound regions in the predicate since we
|
// Liberate bound regions in the predicate since we
|
||||||
// don't actually care about lifetimes in this check.
|
// don't actually care about lifetimes in this check.
|
||||||
let predicate = cx.tcx.liberate_late_bound_regions(def_id, pred.kind());
|
let predicate = cx.tcx.liberate_late_bound_regions(def_id, pred.kind());
|
||||||
let ty::PredicateKind::Projection(proj) = predicate else {
|
let ty::PredicateKind::Clause(ty::Clause::Projection(proj)) = predicate else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
// Only check types, since those are the only things that may
|
// Only check types, since those are the only things that may
|
||||||
|
@ -116,12 +116,13 @@ impl<'tcx> LateLintPass<'tcx> for OpaqueHiddenInferredBound {
|
||||||
// If it's a trait bound and an opaque that doesn't satisfy it,
|
// If it's a trait bound and an opaque that doesn't satisfy it,
|
||||||
// then we can emit a suggestion to add the bound.
|
// then we can emit a suggestion to add the bound.
|
||||||
let add_bound = match (proj_term.kind(), assoc_pred.kind().skip_binder()) {
|
let add_bound = match (proj_term.kind(), assoc_pred.kind().skip_binder()) {
|
||||||
(ty::Opaque(def_id, _), ty::PredicateKind::Trait(trait_pred)) => {
|
(
|
||||||
Some(AddBound {
|
ty::Opaque(def_id, _),
|
||||||
suggest_span: cx.tcx.def_span(*def_id).shrink_to_hi(),
|
ty::PredicateKind::Clause(ty::Clause::Trait(trait_pred)),
|
||||||
trait_ref: trait_pred.print_modifiers_and_trait_path(),
|
) => Some(AddBound {
|
||||||
})
|
suggest_span: cx.tcx.def_span(*def_id).shrink_to_hi(),
|
||||||
}
|
trait_ref: trait_pred.print_modifiers_and_trait_path(),
|
||||||
|
}),
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
cx.emit_spanned_lint(
|
cx.emit_spanned_lint(
|
||||||
|
|
|
@ -87,11 +87,12 @@ declare_lint_pass!(
|
||||||
|
|
||||||
impl<'tcx> LateLintPass<'tcx> for DropTraitConstraints {
|
impl<'tcx> LateLintPass<'tcx> for DropTraitConstraints {
|
||||||
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
|
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
|
||||||
|
use rustc_middle::ty::Clause;
|
||||||
use rustc_middle::ty::PredicateKind::*;
|
use rustc_middle::ty::PredicateKind::*;
|
||||||
|
|
||||||
let predicates = cx.tcx.explicit_predicates_of(item.owner_id);
|
let predicates = cx.tcx.explicit_predicates_of(item.owner_id);
|
||||||
for &(predicate, span) in predicates.predicates {
|
for &(predicate, span) in predicates.predicates {
|
||||||
let Trait(trait_predicate) = predicate.kind().skip_binder() else {
|
let Clause(Clause::Trait(trait_predicate)) = predicate.kind().skip_binder() else {
|
||||||
continue
|
continue
|
||||||
};
|
};
|
||||||
let def_id = trait_predicate.trait_ref.def_id;
|
let def_id = trait_predicate.trait_ref.def_id;
|
||||||
|
|
|
@ -258,8 +258,9 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
|
||||||
)
|
)
|
||||||
.filter_map(|obligation| {
|
.filter_map(|obligation| {
|
||||||
// We only look at the `DefId`, so it is safe to skip the binder here.
|
// We only look at the `DefId`, so it is safe to skip the binder here.
|
||||||
if let ty::PredicateKind::Trait(ref poly_trait_predicate) =
|
if let ty::PredicateKind::Clause(ty::Clause::Trait(
|
||||||
obligation.predicate.kind().skip_binder()
|
ref poly_trait_predicate,
|
||||||
|
)) = obligation.predicate.kind().skip_binder()
|
||||||
{
|
{
|
||||||
let def_id = poly_trait_predicate.trait_ref.def_id;
|
let def_id = poly_trait_predicate.trait_ref.def_id;
|
||||||
|
|
||||||
|
|
|
@ -2296,7 +2296,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
let future_trait = self.require_lang_item(LangItem::Future, None);
|
let future_trait = self.require_lang_item(LangItem::Future, None);
|
||||||
|
|
||||||
self.explicit_item_bounds(def_id).iter().any(|(predicate, _)| {
|
self.explicit_item_bounds(def_id).iter().any(|(predicate, _)| {
|
||||||
let ty::PredicateKind::Trait(trait_predicate) = predicate.kind().skip_binder() else {
|
let ty::PredicateKind::Clause(ty::Clause::Trait(trait_predicate)) = predicate.kind().skip_binder() else {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
trait_predicate.trait_ref.def_id == future_trait
|
trait_predicate.trait_ref.def_id == future_trait
|
||||||
|
@ -2319,7 +2319,9 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
let generic_predicates = self.super_predicates_of(trait_did);
|
let generic_predicates = self.super_predicates_of(trait_did);
|
||||||
|
|
||||||
for (predicate, _) in generic_predicates.predicates {
|
for (predicate, _) in generic_predicates.predicates {
|
||||||
if let ty::PredicateKind::Trait(data) = predicate.kind().skip_binder() {
|
if let ty::PredicateKind::Clause(ty::Clause::Trait(data)) =
|
||||||
|
predicate.kind().skip_binder()
|
||||||
|
{
|
||||||
if set.insert(data.def_id()) {
|
if set.insert(data.def_id()) {
|
||||||
stack.push(data.def_id());
|
stack.push(data.def_id());
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,14 +216,17 @@ impl FlagComputation {
|
||||||
|
|
||||||
fn add_predicate_atom(&mut self, atom: ty::PredicateKind<'_>) {
|
fn add_predicate_atom(&mut self, atom: ty::PredicateKind<'_>) {
|
||||||
match atom {
|
match atom {
|
||||||
ty::PredicateKind::Trait(trait_pred) => {
|
ty::PredicateKind::Clause(ty::Clause::Trait(trait_pred)) => {
|
||||||
self.add_substs(trait_pred.trait_ref.substs);
|
self.add_substs(trait_pred.trait_ref.substs);
|
||||||
}
|
}
|
||||||
ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(a, b)) => {
|
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(ty::OutlivesPredicate(a, b))) => {
|
||||||
self.add_region(a);
|
self.add_region(a);
|
||||||
self.add_region(b);
|
self.add_region(b);
|
||||||
}
|
}
|
||||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty, region)) => {
|
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(ty::OutlivesPredicate(
|
||||||
|
ty,
|
||||||
|
region,
|
||||||
|
))) => {
|
||||||
self.add_ty(ty);
|
self.add_ty(ty);
|
||||||
self.add_region(region);
|
self.add_region(region);
|
||||||
}
|
}
|
||||||
|
@ -235,7 +238,10 @@ impl FlagComputation {
|
||||||
self.add_ty(a);
|
self.add_ty(a);
|
||||||
self.add_ty(b);
|
self.add_ty(b);
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Projection(ty::ProjectionPredicate { projection_ty, term }) => {
|
ty::PredicateKind::Clause(ty::Clause::Projection(ty::ProjectionPredicate {
|
||||||
|
projection_ty,
|
||||||
|
term,
|
||||||
|
})) => {
|
||||||
self.add_projection_ty(projection_ty);
|
self.add_projection_ty(projection_ty);
|
||||||
match term.unpack() {
|
match term.unpack() {
|
||||||
ty::TermKind::Ty(ty) => self.add_ty(ty),
|
ty::TermKind::Ty(ty) => self.add_ty(ty),
|
||||||
|
|
|
@ -574,13 +574,15 @@ impl<'tcx> Predicate<'tcx> {
|
||||||
let kind = self
|
let kind = self
|
||||||
.kind()
|
.kind()
|
||||||
.map_bound(|kind| match kind {
|
.map_bound(|kind| match kind {
|
||||||
PredicateKind::Trait(TraitPredicate { trait_ref, constness, polarity }) => {
|
PredicateKind::Clause(Clause::Trait(TraitPredicate {
|
||||||
Some(PredicateKind::Trait(TraitPredicate {
|
trait_ref,
|
||||||
trait_ref,
|
constness,
|
||||||
constness,
|
polarity,
|
||||||
polarity: polarity.flip()?,
|
})) => Some(PredicateKind::Clause(Clause::Trait(TraitPredicate {
|
||||||
}))
|
trait_ref,
|
||||||
}
|
constness,
|
||||||
|
polarity: polarity.flip()?,
|
||||||
|
}))),
|
||||||
|
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
|
@ -590,14 +592,14 @@ impl<'tcx> Predicate<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn without_const(mut self, tcx: TyCtxt<'tcx>) -> Self {
|
pub fn without_const(mut self, tcx: TyCtxt<'tcx>) -> Self {
|
||||||
if let PredicateKind::Trait(TraitPredicate { trait_ref, constness, polarity }) = self.kind().skip_binder()
|
if let PredicateKind::Clause(Clause::Trait(TraitPredicate { trait_ref, constness, polarity })) = self.kind().skip_binder()
|
||||||
&& constness != BoundConstness::NotConst
|
&& constness != BoundConstness::NotConst
|
||||||
{
|
{
|
||||||
self = tcx.mk_predicate(self.kind().rebind(PredicateKind::Trait(TraitPredicate {
|
self = tcx.mk_predicate(self.kind().rebind(PredicateKind::Clause(Clause::Trait(TraitPredicate {
|
||||||
trait_ref,
|
trait_ref,
|
||||||
constness: BoundConstness::NotConst,
|
constness: BoundConstness::NotConst,
|
||||||
polarity,
|
polarity,
|
||||||
})));
|
}))));
|
||||||
}
|
}
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -611,10 +613,10 @@ impl<'tcx> Predicate<'tcx> {
|
||||||
pub fn allow_normalization(self) -> bool {
|
pub fn allow_normalization(self) -> bool {
|
||||||
match self.kind().skip_binder() {
|
match self.kind().skip_binder() {
|
||||||
PredicateKind::WellFormed(_) => false,
|
PredicateKind::WellFormed(_) => false,
|
||||||
PredicateKind::Trait(_)
|
PredicateKind::Clause(Clause::Trait(_))
|
||||||
| PredicateKind::RegionOutlives(_)
|
| PredicateKind::Clause(Clause::RegionOutlives(_))
|
||||||
| PredicateKind::TypeOutlives(_)
|
| PredicateKind::Clause(Clause::TypeOutlives(_))
|
||||||
| PredicateKind::Projection(_)
|
| PredicateKind::Clause(Clause::Projection(_))
|
||||||
| PredicateKind::ObjectSafe(_)
|
| PredicateKind::ObjectSafe(_)
|
||||||
| PredicateKind::ClosureKind(_, _, _)
|
| PredicateKind::ClosureKind(_, _, _)
|
||||||
| PredicateKind::Subtype(_)
|
| PredicateKind::Subtype(_)
|
||||||
|
@ -650,7 +652,9 @@ impl rustc_errors::IntoDiagnosticArg for Predicate<'_> {
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, TyEncodable, TyDecodable)]
|
#[derive(Clone, Copy, PartialEq, Eq, Hash, TyEncodable, TyDecodable)]
|
||||||
#[derive(HashStable, TypeFoldable, TypeVisitable, Lift)]
|
#[derive(HashStable, TypeFoldable, TypeVisitable, Lift)]
|
||||||
pub enum PredicateKind<'tcx> {
|
/// A clause is something that can appear in where bounds or be inferred
|
||||||
|
/// by implied bounds.
|
||||||
|
pub enum Clause<'tcx> {
|
||||||
/// Corresponds to `where Foo: Bar<A, B, C>`. `Foo` here would be
|
/// Corresponds to `where Foo: Bar<A, B, C>`. `Foo` here would be
|
||||||
/// the `Self` type of the trait reference and `A`, `B`, and `C`
|
/// the `Self` type of the trait reference and `A`, `B`, and `C`
|
||||||
/// would be the type parameters.
|
/// would be the type parameters.
|
||||||
|
@ -665,6 +669,13 @@ pub enum PredicateKind<'tcx> {
|
||||||
/// `where <T as TraitRef>::Name == X`, approximately.
|
/// `where <T as TraitRef>::Name == X`, approximately.
|
||||||
/// See the `ProjectionPredicate` struct for details.
|
/// See the `ProjectionPredicate` struct for details.
|
||||||
Projection(ProjectionPredicate<'tcx>),
|
Projection(ProjectionPredicate<'tcx>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, PartialEq, Eq, Hash, TyEncodable, TyDecodable)]
|
||||||
|
#[derive(HashStable, TypeFoldable, TypeVisitable, Lift)]
|
||||||
|
pub enum PredicateKind<'tcx> {
|
||||||
|
/// Prove a clause
|
||||||
|
Clause(Clause<'tcx>),
|
||||||
|
|
||||||
/// No syntax: `T` well-formed.
|
/// No syntax: `T` well-formed.
|
||||||
WellFormed(GenericArg<'tcx>),
|
WellFormed(GenericArg<'tcx>),
|
||||||
|
@ -1174,25 +1185,25 @@ impl<'tcx> ToPredicate<'tcx, PolyTraitPredicate<'tcx>> for Binder<'tcx, TraitRef
|
||||||
|
|
||||||
impl<'tcx> ToPredicate<'tcx, Predicate<'tcx>> for PolyTraitPredicate<'tcx> {
|
impl<'tcx> ToPredicate<'tcx, Predicate<'tcx>> for PolyTraitPredicate<'tcx> {
|
||||||
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||||
self.map_bound(PredicateKind::Trait).to_predicate(tcx)
|
self.map_bound(|p| PredicateKind::Clause(Clause::Trait(p))).to_predicate(tcx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> ToPredicate<'tcx, Predicate<'tcx>> for PolyRegionOutlivesPredicate<'tcx> {
|
impl<'tcx> ToPredicate<'tcx, Predicate<'tcx>> for PolyRegionOutlivesPredicate<'tcx> {
|
||||||
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||||
self.map_bound(PredicateKind::RegionOutlives).to_predicate(tcx)
|
self.map_bound(|p| PredicateKind::Clause(Clause::RegionOutlives(p))).to_predicate(tcx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> ToPredicate<'tcx, Predicate<'tcx>> for PolyTypeOutlivesPredicate<'tcx> {
|
impl<'tcx> ToPredicate<'tcx, Predicate<'tcx>> for PolyTypeOutlivesPredicate<'tcx> {
|
||||||
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||||
self.map_bound(PredicateKind::TypeOutlives).to_predicate(tcx)
|
self.map_bound(|p| PredicateKind::Clause(Clause::TypeOutlives(p))).to_predicate(tcx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> ToPredicate<'tcx, Predicate<'tcx>> for PolyProjectionPredicate<'tcx> {
|
impl<'tcx> ToPredicate<'tcx, Predicate<'tcx>> for PolyProjectionPredicate<'tcx> {
|
||||||
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||||
self.map_bound(PredicateKind::Projection).to_predicate(tcx)
|
self.map_bound(|p| PredicateKind::Clause(Clause::Projection(p))).to_predicate(tcx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1200,15 +1211,15 @@ impl<'tcx> Predicate<'tcx> {
|
||||||
pub fn to_opt_poly_trait_pred(self) -> Option<PolyTraitPredicate<'tcx>> {
|
pub fn to_opt_poly_trait_pred(self) -> Option<PolyTraitPredicate<'tcx>> {
|
||||||
let predicate = self.kind();
|
let predicate = self.kind();
|
||||||
match predicate.skip_binder() {
|
match predicate.skip_binder() {
|
||||||
PredicateKind::Trait(t) => Some(predicate.rebind(t)),
|
PredicateKind::Clause(Clause::Trait(t)) => Some(predicate.rebind(t)),
|
||||||
PredicateKind::Projection(..)
|
PredicateKind::Clause(Clause::Projection(..))
|
||||||
| PredicateKind::Subtype(..)
|
| PredicateKind::Subtype(..)
|
||||||
| PredicateKind::Coerce(..)
|
| PredicateKind::Coerce(..)
|
||||||
| PredicateKind::RegionOutlives(..)
|
| PredicateKind::Clause(Clause::RegionOutlives(..))
|
||||||
| PredicateKind::WellFormed(..)
|
| PredicateKind::WellFormed(..)
|
||||||
| PredicateKind::ObjectSafe(..)
|
| PredicateKind::ObjectSafe(..)
|
||||||
| PredicateKind::ClosureKind(..)
|
| PredicateKind::ClosureKind(..)
|
||||||
| PredicateKind::TypeOutlives(..)
|
| PredicateKind::Clause(Clause::TypeOutlives(..))
|
||||||
| PredicateKind::ConstEvaluatable(..)
|
| PredicateKind::ConstEvaluatable(..)
|
||||||
| PredicateKind::ConstEquate(..)
|
| PredicateKind::ConstEquate(..)
|
||||||
| PredicateKind::Ambiguous
|
| PredicateKind::Ambiguous
|
||||||
|
@ -1219,15 +1230,15 @@ impl<'tcx> Predicate<'tcx> {
|
||||||
pub fn to_opt_poly_projection_pred(self) -> Option<PolyProjectionPredicate<'tcx>> {
|
pub fn to_opt_poly_projection_pred(self) -> Option<PolyProjectionPredicate<'tcx>> {
|
||||||
let predicate = self.kind();
|
let predicate = self.kind();
|
||||||
match predicate.skip_binder() {
|
match predicate.skip_binder() {
|
||||||
PredicateKind::Projection(t) => Some(predicate.rebind(t)),
|
PredicateKind::Clause(Clause::Projection(t)) => Some(predicate.rebind(t)),
|
||||||
PredicateKind::Trait(..)
|
PredicateKind::Clause(Clause::Trait(..))
|
||||||
| PredicateKind::Subtype(..)
|
| PredicateKind::Subtype(..)
|
||||||
| PredicateKind::Coerce(..)
|
| PredicateKind::Coerce(..)
|
||||||
| PredicateKind::RegionOutlives(..)
|
| PredicateKind::Clause(Clause::RegionOutlives(..))
|
||||||
| PredicateKind::WellFormed(..)
|
| PredicateKind::WellFormed(..)
|
||||||
| PredicateKind::ObjectSafe(..)
|
| PredicateKind::ObjectSafe(..)
|
||||||
| PredicateKind::ClosureKind(..)
|
| PredicateKind::ClosureKind(..)
|
||||||
| PredicateKind::TypeOutlives(..)
|
| PredicateKind::Clause(Clause::TypeOutlives(..))
|
||||||
| PredicateKind::ConstEvaluatable(..)
|
| PredicateKind::ConstEvaluatable(..)
|
||||||
| PredicateKind::ConstEquate(..)
|
| PredicateKind::ConstEquate(..)
|
||||||
| PredicateKind::Ambiguous
|
| PredicateKind::Ambiguous
|
||||||
|
@ -1238,12 +1249,12 @@ impl<'tcx> Predicate<'tcx> {
|
||||||
pub fn to_opt_type_outlives(self) -> Option<PolyTypeOutlivesPredicate<'tcx>> {
|
pub fn to_opt_type_outlives(self) -> Option<PolyTypeOutlivesPredicate<'tcx>> {
|
||||||
let predicate = self.kind();
|
let predicate = self.kind();
|
||||||
match predicate.skip_binder() {
|
match predicate.skip_binder() {
|
||||||
PredicateKind::TypeOutlives(data) => Some(predicate.rebind(data)),
|
PredicateKind::Clause(Clause::TypeOutlives(data)) => Some(predicate.rebind(data)),
|
||||||
PredicateKind::Trait(..)
|
PredicateKind::Clause(Clause::Trait(..))
|
||||||
| PredicateKind::Projection(..)
|
| PredicateKind::Clause(Clause::Projection(..))
|
||||||
| PredicateKind::Subtype(..)
|
| PredicateKind::Subtype(..)
|
||||||
| PredicateKind::Coerce(..)
|
| PredicateKind::Coerce(..)
|
||||||
| PredicateKind::RegionOutlives(..)
|
| PredicateKind::Clause(Clause::RegionOutlives(..))
|
||||||
| PredicateKind::WellFormed(..)
|
| PredicateKind::WellFormed(..)
|
||||||
| PredicateKind::ObjectSafe(..)
|
| PredicateKind::ObjectSafe(..)
|
||||||
| PredicateKind::ClosureKind(..)
|
| PredicateKind::ClosureKind(..)
|
||||||
|
|
|
@ -814,7 +814,7 @@ pub trait PrettyPrinter<'tcx>:
|
||||||
let bound_predicate = predicate.kind();
|
let bound_predicate = predicate.kind();
|
||||||
|
|
||||||
match bound_predicate.skip_binder() {
|
match bound_predicate.skip_binder() {
|
||||||
ty::PredicateKind::Trait(pred) => {
|
ty::PredicateKind::Clause(ty::Clause::Trait(pred)) => {
|
||||||
let trait_ref = bound_predicate.rebind(pred.trait_ref);
|
let trait_ref = bound_predicate.rebind(pred.trait_ref);
|
||||||
|
|
||||||
// Don't print + Sized, but rather + ?Sized if absent.
|
// Don't print + Sized, but rather + ?Sized if absent.
|
||||||
|
@ -825,7 +825,7 @@ pub trait PrettyPrinter<'tcx>:
|
||||||
|
|
||||||
self.insert_trait_and_projection(trait_ref, None, &mut traits, &mut fn_traits);
|
self.insert_trait_and_projection(trait_ref, None, &mut traits, &mut fn_traits);
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Projection(pred) => {
|
ty::PredicateKind::Clause(ty::Clause::Projection(pred)) => {
|
||||||
let proj_ref = bound_predicate.rebind(pred);
|
let proj_ref = bound_predicate.rebind(pred);
|
||||||
let trait_ref = proj_ref.required_poly_trait_ref(tcx);
|
let trait_ref = proj_ref.required_poly_trait_ref(tcx);
|
||||||
|
|
||||||
|
@ -839,7 +839,7 @@ pub trait PrettyPrinter<'tcx>:
|
||||||
&mut fn_traits,
|
&mut fn_traits,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
ty::PredicateKind::TypeOutlives(outlives) => {
|
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(outlives)) => {
|
||||||
lifetimes.push(outlives.1);
|
lifetimes.push(outlives.1);
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
@ -2689,14 +2689,14 @@ define_print_and_forward_display! {
|
||||||
|
|
||||||
ty::PredicateKind<'tcx> {
|
ty::PredicateKind<'tcx> {
|
||||||
match *self {
|
match *self {
|
||||||
ty::PredicateKind::Trait(ref data) => {
|
ty::PredicateKind::Clause(ty::Clause::Trait(ref data)) => {
|
||||||
p!(print(data))
|
p!(print(data))
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Subtype(predicate) => p!(print(predicate)),
|
ty::PredicateKind::Subtype(predicate) => p!(print(predicate)),
|
||||||
ty::PredicateKind::Coerce(predicate) => p!(print(predicate)),
|
ty::PredicateKind::Coerce(predicate) => p!(print(predicate)),
|
||||||
ty::PredicateKind::RegionOutlives(predicate) => p!(print(predicate)),
|
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(predicate)) => p!(print(predicate)),
|
||||||
ty::PredicateKind::TypeOutlives(predicate) => p!(print(predicate)),
|
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(predicate)) => p!(print(predicate)),
|
||||||
ty::PredicateKind::Projection(predicate) => p!(print(predicate)),
|
ty::PredicateKind::Clause(ty::Clause::Projection(predicate)) => p!(print(predicate)),
|
||||||
ty::PredicateKind::WellFormed(arg) => p!(print(arg), " well-formed"),
|
ty::PredicateKind::WellFormed(arg) => p!(print(arg), " well-formed"),
|
||||||
ty::PredicateKind::ObjectSafe(trait_def_id) => {
|
ty::PredicateKind::ObjectSafe(trait_def_id) => {
|
||||||
p!("the trait `", print_def_path(trait_def_id, &[]), "` is object-safe")
|
p!("the trait `", print_def_path(trait_def_id, &[]), "` is object-safe")
|
||||||
|
|
|
@ -150,15 +150,23 @@ impl<'tcx> fmt::Debug for ty::Predicate<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'tcx> fmt::Debug for ty::Clause<'tcx> {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
match *self {
|
||||||
|
ty::Clause::Trait(ref a) => a.fmt(f),
|
||||||
|
ty::Clause::RegionOutlives(ref pair) => pair.fmt(f),
|
||||||
|
ty::Clause::TypeOutlives(ref pair) => pair.fmt(f),
|
||||||
|
ty::Clause::Projection(ref pair) => pair.fmt(f),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'tcx> fmt::Debug for ty::PredicateKind<'tcx> {
|
impl<'tcx> fmt::Debug for ty::PredicateKind<'tcx> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match *self {
|
match *self {
|
||||||
ty::PredicateKind::Trait(ref a) => a.fmt(f),
|
ty::PredicateKind::Clause(ref a) => a.fmt(f),
|
||||||
ty::PredicateKind::Subtype(ref pair) => pair.fmt(f),
|
ty::PredicateKind::Subtype(ref pair) => pair.fmt(f),
|
||||||
ty::PredicateKind::Coerce(ref pair) => pair.fmt(f),
|
ty::PredicateKind::Coerce(ref pair) => pair.fmt(f),
|
||||||
ty::PredicateKind::RegionOutlives(ref pair) => pair.fmt(f),
|
|
||||||
ty::PredicateKind::TypeOutlives(ref pair) => pair.fmt(f),
|
|
||||||
ty::PredicateKind::Projection(ref pair) => pair.fmt(f),
|
|
||||||
ty::PredicateKind::WellFormed(data) => write!(f, "WellFormed({:?})", data),
|
ty::PredicateKind::WellFormed(data) => write!(f, "WellFormed({:?})", data),
|
||||||
ty::PredicateKind::ObjectSafe(trait_def_id) => {
|
ty::PredicateKind::ObjectSafe(trait_def_id) => {
|
||||||
write!(f, "ObjectSafe({:?})", trait_def_id)
|
write!(f, "ObjectSafe({:?})", trait_def_id)
|
||||||
|
|
|
@ -110,7 +110,7 @@ impl<'tcx> FunctionItemRefChecker<'_, 'tcx> {
|
||||||
|
|
||||||
/// If the given predicate is the trait `fmt::Pointer`, returns the bound parameter type.
|
/// If the given predicate is the trait `fmt::Pointer`, returns the bound parameter type.
|
||||||
fn is_pointer_trait(&self, bound: &PredicateKind<'tcx>) -> Option<Ty<'tcx>> {
|
fn is_pointer_trait(&self, bound: &PredicateKind<'tcx>) -> Option<Ty<'tcx>> {
|
||||||
if let ty::PredicateKind::Trait(predicate) = bound {
|
if let ty::PredicateKind::Clause(ty::Clause::Trait(predicate)) = bound {
|
||||||
if self.tcx.is_diagnostic_item(sym::Pointer, predicate.def_id()) {
|
if self.tcx.is_diagnostic_item(sym::Pointer, predicate.def_id()) {
|
||||||
Some(predicate.trait_ref.self_ty())
|
Some(predicate.trait_ref.self_ty())
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -146,19 +146,23 @@ where
|
||||||
|
|
||||||
fn visit_predicate(&mut self, predicate: ty::Predicate<'tcx>) -> ControlFlow<V::BreakTy> {
|
fn visit_predicate(&mut self, predicate: ty::Predicate<'tcx>) -> ControlFlow<V::BreakTy> {
|
||||||
match predicate.kind().skip_binder() {
|
match predicate.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(ty::TraitPredicate {
|
ty::PredicateKind::Clause(ty::Clause::Trait(ty::TraitPredicate {
|
||||||
trait_ref,
|
trait_ref,
|
||||||
constness: _,
|
constness: _,
|
||||||
polarity: _,
|
polarity: _,
|
||||||
}) => self.visit_trait(trait_ref),
|
})) => self.visit_trait(trait_ref),
|
||||||
ty::PredicateKind::Projection(ty::ProjectionPredicate { projection_ty, term }) => {
|
ty::PredicateKind::Clause(ty::Clause::Projection(ty::ProjectionPredicate {
|
||||||
|
projection_ty,
|
||||||
|
term,
|
||||||
|
})) => {
|
||||||
term.visit_with(self)?;
|
term.visit_with(self)?;
|
||||||
self.visit_projection_ty(projection_ty)
|
self.visit_projection_ty(projection_ty)
|
||||||
}
|
}
|
||||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty, _region)) => {
|
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(ty::OutlivesPredicate(
|
||||||
ty.visit_with(self)
|
ty,
|
||||||
}
|
_region,
|
||||||
ty::PredicateKind::RegionOutlives(..) => ControlFlow::CONTINUE,
|
))) => ty.visit_with(self),
|
||||||
|
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(..)) => ControlFlow::CONTINUE,
|
||||||
ty::PredicateKind::ConstEvaluatable(ct) => ct.visit_with(self),
|
ty::PredicateKind::ConstEvaluatable(ct) => ct.visit_with(self),
|
||||||
ty::PredicateKind::WellFormed(arg) => arg.visit_with(self),
|
ty::PredicateKind::WellFormed(arg) => arg.visit_with(self),
|
||||||
_ => bug!("unexpected predicate: {:?}", predicate),
|
_ => bug!("unexpected predicate: {:?}", predicate),
|
||||||
|
|
|
@ -403,8 +403,10 @@ impl<'tcx> AutoTraitFinder<'tcx> {
|
||||||
) {
|
) {
|
||||||
let mut should_add_new = true;
|
let mut should_add_new = true;
|
||||||
user_computed_preds.retain(|&old_pred| {
|
user_computed_preds.retain(|&old_pred| {
|
||||||
if let (ty::PredicateKind::Trait(new_trait), ty::PredicateKind::Trait(old_trait)) =
|
if let (
|
||||||
(new_pred.kind().skip_binder(), old_pred.kind().skip_binder())
|
ty::PredicateKind::Clause(ty::Clause::Trait(new_trait)),
|
||||||
|
ty::PredicateKind::Clause(ty::Clause::Trait(old_trait)),
|
||||||
|
) = (new_pred.kind().skip_binder(), old_pred.kind().skip_binder())
|
||||||
{
|
{
|
||||||
if new_trait.def_id() == old_trait.def_id() {
|
if new_trait.def_id() == old_trait.def_id() {
|
||||||
let new_substs = new_trait.trait_ref.substs;
|
let new_substs = new_trait.trait_ref.substs;
|
||||||
|
@ -624,14 +626,14 @@ impl<'tcx> AutoTraitFinder<'tcx> {
|
||||||
|
|
||||||
let bound_predicate = predicate.kind();
|
let bound_predicate = predicate.kind();
|
||||||
match bound_predicate.skip_binder() {
|
match bound_predicate.skip_binder() {
|
||||||
ty::PredicateKind::Trait(p) => {
|
ty::PredicateKind::Clause(ty::Clause::Trait(p)) => {
|
||||||
// Add this to `predicates` so that we end up calling `select`
|
// Add this to `predicates` so that we end up calling `select`
|
||||||
// with it. If this predicate ends up being unimplemented,
|
// with it. If this predicate ends up being unimplemented,
|
||||||
// then `evaluate_predicates` will handle adding it the `ParamEnv`
|
// then `evaluate_predicates` will handle adding it the `ParamEnv`
|
||||||
// if possible.
|
// if possible.
|
||||||
predicates.push_back(bound_predicate.rebind(p));
|
predicates.push_back(bound_predicate.rebind(p));
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Projection(p) => {
|
ty::PredicateKind::Clause(ty::Clause::Projection(p)) => {
|
||||||
let p = bound_predicate.rebind(p);
|
let p = bound_predicate.rebind(p);
|
||||||
debug!(
|
debug!(
|
||||||
"evaluate_nested_obligations: examining projection predicate {:?}",
|
"evaluate_nested_obligations: examining projection predicate {:?}",
|
||||||
|
@ -764,11 +766,11 @@ impl<'tcx> AutoTraitFinder<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ty::PredicateKind::RegionOutlives(binder) => {
|
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(binder)) => {
|
||||||
let binder = bound_predicate.rebind(binder);
|
let binder = bound_predicate.rebind(binder);
|
||||||
select.infcx().region_outlives_predicate(&dummy_cause, binder)
|
select.infcx().region_outlives_predicate(&dummy_cause, binder)
|
||||||
}
|
}
|
||||||
ty::PredicateKind::TypeOutlives(binder) => {
|
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(binder)) => {
|
||||||
let binder = bound_predicate.rebind(binder);
|
let binder = bound_predicate.rebind(binder);
|
||||||
match (
|
match (
|
||||||
binder.no_bound_vars(),
|
binder.no_bound_vars(),
|
||||||
|
|
|
@ -587,7 +587,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||||
|
|
||||||
let bound_predicate = obligation.predicate.kind();
|
let bound_predicate = obligation.predicate.kind();
|
||||||
match bound_predicate.skip_binder() {
|
match bound_predicate.skip_binder() {
|
||||||
ty::PredicateKind::Trait(trait_predicate) => {
|
ty::PredicateKind::Clause(ty::Clause::Trait(trait_predicate)) => {
|
||||||
let trait_predicate = bound_predicate.rebind(trait_predicate);
|
let trait_predicate = bound_predicate.rebind(trait_predicate);
|
||||||
let mut trait_predicate = self.resolve_vars_if_possible(trait_predicate);
|
let mut trait_predicate = self.resolve_vars_if_possible(trait_predicate);
|
||||||
|
|
||||||
|
@ -1051,9 +1051,9 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||||
span_bug!(span, "coerce requirement gave wrong error: `{:?}`", predicate)
|
span_bug!(span, "coerce requirement gave wrong error: `{:?}`", predicate)
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::PredicateKind::RegionOutlives(..)
|
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(..))
|
||||||
| ty::PredicateKind::Projection(..)
|
| ty::PredicateKind::Clause(ty::Clause::Projection(..))
|
||||||
| ty::PredicateKind::TypeOutlives(..) => {
|
| ty::PredicateKind::Clause(ty::Clause::TypeOutlives(..)) => {
|
||||||
let predicate = self.resolve_vars_if_possible(obligation.predicate);
|
let predicate = self.resolve_vars_if_possible(obligation.predicate);
|
||||||
struct_span_err!(
|
struct_span_err!(
|
||||||
self.tcx.sess,
|
self.tcx.sess,
|
||||||
|
@ -1473,9 +1473,10 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||||
// FIXME: It should be possible to deal with `ForAll` in a cleaner way.
|
// FIXME: It should be possible to deal with `ForAll` in a cleaner way.
|
||||||
let bound_error = error.kind();
|
let bound_error = error.kind();
|
||||||
let (cond, error) = match (cond.kind().skip_binder(), bound_error.skip_binder()) {
|
let (cond, error) = match (cond.kind().skip_binder(), bound_error.skip_binder()) {
|
||||||
(ty::PredicateKind::Trait(..), ty::PredicateKind::Trait(error)) => {
|
(
|
||||||
(cond, bound_error.rebind(error))
|
ty::PredicateKind::Clause(ty::Clause::Trait(..)),
|
||||||
}
|
ty::PredicateKind::Clause(ty::Clause::Trait(error)),
|
||||||
|
) => (cond, bound_error.rebind(error)),
|
||||||
_ => {
|
_ => {
|
||||||
// FIXME: make this work in other cases too.
|
// FIXME: make this work in other cases too.
|
||||||
return false;
|
return false;
|
||||||
|
@ -1484,7 +1485,9 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||||
|
|
||||||
for obligation in super::elaborate_predicates(self.tcx, std::iter::once(cond)) {
|
for obligation in super::elaborate_predicates(self.tcx, std::iter::once(cond)) {
|
||||||
let bound_predicate = obligation.predicate.kind();
|
let bound_predicate = obligation.predicate.kind();
|
||||||
if let ty::PredicateKind::Trait(implication) = bound_predicate.skip_binder() {
|
if let ty::PredicateKind::Clause(ty::Clause::Trait(implication)) =
|
||||||
|
bound_predicate.skip_binder()
|
||||||
|
{
|
||||||
let error = error.to_poly_trait_ref();
|
let error = error.to_poly_trait_ref();
|
||||||
let implication = bound_predicate.rebind(implication.trait_ref);
|
let implication = bound_predicate.rebind(implication.trait_ref);
|
||||||
// FIXME: I'm just not taking associated types at all here.
|
// FIXME: I'm just not taking associated types at all here.
|
||||||
|
@ -1581,7 +1584,9 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||||
// this can fail if the problem was higher-ranked, in which
|
// this can fail if the problem was higher-ranked, in which
|
||||||
// cause I have no idea for a good error message.
|
// cause I have no idea for a good error message.
|
||||||
let bound_predicate = predicate.kind();
|
let bound_predicate = predicate.kind();
|
||||||
if let ty::PredicateKind::Projection(data) = bound_predicate.skip_binder() {
|
if let ty::PredicateKind::Clause(ty::Clause::Projection(data)) =
|
||||||
|
bound_predicate.skip_binder()
|
||||||
|
{
|
||||||
let mut selcx = SelectionContext::new(self);
|
let mut selcx = SelectionContext::new(self);
|
||||||
let data = self.replace_bound_vars_with_fresh_vars(
|
let data = self.replace_bound_vars_with_fresh_vars(
|
||||||
obligation.cause.span,
|
obligation.cause.span,
|
||||||
|
@ -1629,7 +1634,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||||
let mut diag = struct_span_err!(self.tcx.sess, obligation.cause.span, E0271, "{msg}");
|
let mut diag = struct_span_err!(self.tcx.sess, obligation.cause.span, E0271, "{msg}");
|
||||||
|
|
||||||
let secondary_span = match predicate.kind().skip_binder() {
|
let secondary_span = match predicate.kind().skip_binder() {
|
||||||
ty::PredicateKind::Projection(proj) => self
|
ty::PredicateKind::Clause(ty::Clause::Projection(proj)) => self
|
||||||
.tcx
|
.tcx
|
||||||
.opt_associated_item(proj.projection_ty.item_def_id)
|
.opt_associated_item(proj.projection_ty.item_def_id)
|
||||||
.and_then(|trait_assoc_item| {
|
.and_then(|trait_assoc_item| {
|
||||||
|
@ -2047,7 +2052,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||||
|
|
||||||
let bound_predicate = predicate.kind();
|
let bound_predicate = predicate.kind();
|
||||||
let mut err = match bound_predicate.skip_binder() {
|
let mut err = match bound_predicate.skip_binder() {
|
||||||
ty::PredicateKind::Trait(data) => {
|
ty::PredicateKind::Clause(ty::Clause::Trait(data)) => {
|
||||||
let trait_ref = bound_predicate.rebind(data.trait_ref);
|
let trait_ref = bound_predicate.rebind(data.trait_ref);
|
||||||
debug!(?trait_ref);
|
debug!(?trait_ref);
|
||||||
|
|
||||||
|
@ -2324,7 +2329,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||||
assert!(a.is_ty_var() && b.is_ty_var());
|
assert!(a.is_ty_var() && b.is_ty_var());
|
||||||
self.emit_inference_failure_err(body_id, span, a.into(), ErrorCode::E0282, true)
|
self.emit_inference_failure_err(body_id, span, a.into(), ErrorCode::E0282, true)
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Projection(data) => {
|
ty::PredicateKind::Clause(ty::Clause::Projection(data)) => {
|
||||||
if predicate.references_error() || self.tainted_by_errors().is_some() {
|
if predicate.references_error() || self.tainted_by_errors().is_some() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2570,7 +2575,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||||
err: &mut Diagnostic,
|
err: &mut Diagnostic,
|
||||||
obligation: &PredicateObligation<'tcx>,
|
obligation: &PredicateObligation<'tcx>,
|
||||||
) {
|
) {
|
||||||
let ty::PredicateKind::Trait(pred) = obligation.predicate.kind().skip_binder() else { return; };
|
let ty::PredicateKind::Clause(ty::Clause::Trait(pred)) = obligation.predicate.kind().skip_binder() else { return; };
|
||||||
let (ObligationCauseCode::BindingObligation(item_def_id, span)
|
let (ObligationCauseCode::BindingObligation(item_def_id, span)
|
||||||
| ObligationCauseCode::ExprBindingObligation(item_def_id, span, ..))
|
| ObligationCauseCode::ExprBindingObligation(item_def_id, span, ..))
|
||||||
= *obligation.cause.code().peel_derives() else { return; };
|
= *obligation.cause.code().peel_derives() else { return; };
|
||||||
|
|
|
@ -810,7 +810,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||||
err: &mut Diagnostic,
|
err: &mut Diagnostic,
|
||||||
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
if let ty::PredicateKind::Trait(trait_pred) = obligation.predicate.kind().skip_binder()
|
if let ty::PredicateKind::Clause(ty::Clause::Trait(trait_pred)) = obligation.predicate.kind().skip_binder()
|
||||||
&& Some(trait_pred.def_id()) == self.tcx.lang_items().sized_trait()
|
&& Some(trait_pred.def_id()) == self.tcx.lang_items().sized_trait()
|
||||||
{
|
{
|
||||||
// Don't suggest calling to turn an unsized type into a sized type
|
// Don't suggest calling to turn an unsized type into a sized type
|
||||||
|
@ -839,7 +839,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
ty::Opaque(def_id, substs) => {
|
ty::Opaque(def_id, substs) => {
|
||||||
self.tcx.bound_item_bounds(def_id).subst(self.tcx, substs).iter().find_map(|pred| {
|
self.tcx.bound_item_bounds(def_id).subst(self.tcx, substs).iter().find_map(|pred| {
|
||||||
if let ty::PredicateKind::Projection(proj) = pred.kind().skip_binder()
|
if let ty::PredicateKind::Clause(ty::Clause::Projection(proj)) = pred.kind().skip_binder()
|
||||||
&& Some(proj.projection_ty.item_def_id) == self.tcx.lang_items().fn_once_output()
|
&& Some(proj.projection_ty.item_def_id) == self.tcx.lang_items().fn_once_output()
|
||||||
// args tuple will always be substs[1]
|
// args tuple will always be substs[1]
|
||||||
&& let ty::Tuple(args) = proj.projection_ty.substs.type_at(1).kind()
|
&& let ty::Tuple(args) = proj.projection_ty.substs.type_at(1).kind()
|
||||||
|
@ -873,7 +873,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
ty::Param(_) => {
|
ty::Param(_) => {
|
||||||
obligation.param_env.caller_bounds().iter().find_map(|pred| {
|
obligation.param_env.caller_bounds().iter().find_map(|pred| {
|
||||||
if let ty::PredicateKind::Projection(proj) = pred.kind().skip_binder()
|
if let ty::PredicateKind::Clause(ty::Clause::Projection(proj)) = pred.kind().skip_binder()
|
||||||
&& Some(proj.projection_ty.item_def_id) == self.tcx.lang_items().fn_once_output()
|
&& Some(proj.projection_ty.item_def_id) == self.tcx.lang_items().fn_once_output()
|
||||||
&& proj.projection_ty.self_ty() == found
|
&& proj.projection_ty.self_ty() == found
|
||||||
// args tuple will always be substs[1]
|
// args tuple will always be substs[1]
|
||||||
|
@ -1256,7 +1256,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||||
);
|
);
|
||||||
// FIXME: account for associated `async fn`s.
|
// FIXME: account for associated `async fn`s.
|
||||||
if let hir::Expr { span, kind: hir::ExprKind::Call(base, _), .. } = expr {
|
if let hir::Expr { span, kind: hir::ExprKind::Call(base, _), .. } = expr {
|
||||||
if let ty::PredicateKind::Trait(pred) =
|
if let ty::PredicateKind::Clause(ty::Clause::Trait(pred)) =
|
||||||
obligation.predicate.kind().skip_binder()
|
obligation.predicate.kind().skip_binder()
|
||||||
{
|
{
|
||||||
err.span_label(
|
err.span_label(
|
||||||
|
@ -1755,7 +1755,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||||
if let ObligationCauseCode::ExprBindingObligation(def_id, _, _, idx) = cause
|
if let ObligationCauseCode::ExprBindingObligation(def_id, _, _, idx) = cause
|
||||||
&& let predicates = self.tcx.predicates_of(def_id).instantiate_identity(self.tcx)
|
&& let predicates = self.tcx.predicates_of(def_id).instantiate_identity(self.tcx)
|
||||||
&& let Some(pred) = predicates.predicates.get(*idx)
|
&& let Some(pred) = predicates.predicates.get(*idx)
|
||||||
&& let ty::PredicateKind::Trait(trait_pred) = pred.kind().skip_binder()
|
&& let ty::PredicateKind::Clause(ty::Clause::Trait(trait_pred)) = pred.kind().skip_binder()
|
||||||
&& ty::ClosureKind::from_def_id(self.tcx, trait_pred.def_id()).is_some()
|
&& ty::ClosureKind::from_def_id(self.tcx, trait_pred.def_id()).is_some()
|
||||||
{
|
{
|
||||||
let expected_self =
|
let expected_self =
|
||||||
|
@ -1769,7 +1769,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||||
let other_pred = std::iter::zip(&predicates.predicates, &predicates.spans)
|
let other_pred = std::iter::zip(&predicates.predicates, &predicates.spans)
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.find(|(other_idx, (pred, _))| match pred.kind().skip_binder() {
|
.find(|(other_idx, (pred, _))| match pred.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(trait_pred)
|
ty::PredicateKind::Clause(ty::Clause::Trait(trait_pred))
|
||||||
if ty::ClosureKind::from_def_id(self.tcx, trait_pred.def_id())
|
if ty::ClosureKind::from_def_id(self.tcx, trait_pred.def_id())
|
||||||
.is_some()
|
.is_some()
|
||||||
&& other_idx != idx
|
&& other_idx != idx
|
||||||
|
@ -1896,7 +1896,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||||
// bound was introduced. At least one generator should be present for this diagnostic to be
|
// bound was introduced. At least one generator should be present for this diagnostic to be
|
||||||
// modified.
|
// modified.
|
||||||
let (mut trait_ref, mut target_ty) = match obligation.predicate.kind().skip_binder() {
|
let (mut trait_ref, mut target_ty) = match obligation.predicate.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(p) => (Some(p), Some(p.self_ty())),
|
ty::PredicateKind::Clause(ty::Clause::Trait(p)) => (Some(p), Some(p.self_ty())),
|
||||||
_ => (None, None),
|
_ => (None, None),
|
||||||
};
|
};
|
||||||
let mut generator = None;
|
let mut generator = None;
|
||||||
|
|
|
@ -269,7 +269,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
|
||||||
// Evaluation will discard candidates using the leak check.
|
// Evaluation will discard candidates using the leak check.
|
||||||
// This means we need to pass it the bound version of our
|
// This means we need to pass it the bound version of our
|
||||||
// predicate.
|
// predicate.
|
||||||
ty::PredicateKind::Trait(trait_ref) => {
|
ty::PredicateKind::Clause(ty::Clause::Trait(trait_ref)) => {
|
||||||
let trait_obligation = obligation.with(infcx.tcx, binder.rebind(trait_ref));
|
let trait_obligation = obligation.with(infcx.tcx, binder.rebind(trait_ref));
|
||||||
|
|
||||||
self.process_trait_obligation(
|
self.process_trait_obligation(
|
||||||
|
@ -278,7 +278,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
|
||||||
&mut pending_obligation.stalled_on,
|
&mut pending_obligation.stalled_on,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Projection(data) => {
|
ty::PredicateKind::Clause(ty::Clause::Projection(data)) => {
|
||||||
let project_obligation = obligation.with(infcx.tcx, binder.rebind(data));
|
let project_obligation = obligation.with(infcx.tcx, binder.rebind(data));
|
||||||
|
|
||||||
self.process_projection_obligation(
|
self.process_projection_obligation(
|
||||||
|
@ -287,8 +287,8 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
|
||||||
&mut pending_obligation.stalled_on,
|
&mut pending_obligation.stalled_on,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
ty::PredicateKind::RegionOutlives(_)
|
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(_))
|
||||||
| ty::PredicateKind::TypeOutlives(_)
|
| ty::PredicateKind::Clause(ty::Clause::TypeOutlives(_))
|
||||||
| ty::PredicateKind::WellFormed(_)
|
| ty::PredicateKind::WellFormed(_)
|
||||||
| ty::PredicateKind::ObjectSafe(_)
|
| ty::PredicateKind::ObjectSafe(_)
|
||||||
| ty::PredicateKind::ClosureKind(..)
|
| ty::PredicateKind::ClosureKind(..)
|
||||||
|
@ -306,7 +306,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Some(pred) => match pred {
|
Some(pred) => match pred {
|
||||||
ty::PredicateKind::Trait(data) => {
|
ty::PredicateKind::Clause(ty::Clause::Trait(data)) => {
|
||||||
let trait_obligation = obligation.with(infcx.tcx, Binder::dummy(data));
|
let trait_obligation = obligation.with(infcx.tcx, Binder::dummy(data));
|
||||||
|
|
||||||
self.process_trait_obligation(
|
self.process_trait_obligation(
|
||||||
|
@ -316,7 +316,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::PredicateKind::RegionOutlives(data) => {
|
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(data)) => {
|
||||||
if infcx.considering_regions {
|
if infcx.considering_regions {
|
||||||
infcx.region_outlives_predicate(&obligation.cause, Binder::dummy(data));
|
infcx.region_outlives_predicate(&obligation.cause, Binder::dummy(data));
|
||||||
}
|
}
|
||||||
|
@ -324,14 +324,17 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
|
||||||
ProcessResult::Changed(vec![])
|
ProcessResult::Changed(vec![])
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(t_a, r_b)) => {
|
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(ty::OutlivesPredicate(
|
||||||
|
t_a,
|
||||||
|
r_b,
|
||||||
|
))) => {
|
||||||
if infcx.considering_regions {
|
if infcx.considering_regions {
|
||||||
infcx.register_region_obligation_with_cause(t_a, r_b, &obligation.cause);
|
infcx.register_region_obligation_with_cause(t_a, r_b, &obligation.cause);
|
||||||
}
|
}
|
||||||
ProcessResult::Changed(vec![])
|
ProcessResult::Changed(vec![])
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::PredicateKind::Projection(ref data) => {
|
ty::PredicateKind::Clause(ty::Clause::Projection(ref data)) => {
|
||||||
let project_obligation = obligation.with(infcx.tcx, Binder::dummy(*data));
|
let project_obligation = obligation.with(infcx.tcx, Binder::dummy(*data));
|
||||||
|
|
||||||
self.process_projection_obligation(
|
self.process_projection_obligation(
|
||||||
|
|
|
@ -317,7 +317,10 @@ pub fn normalize_param_env_or_error<'tcx>(
|
||||||
// TypeOutlives predicates - these are normally used by regionck.
|
// TypeOutlives predicates - these are normally used by regionck.
|
||||||
let outlives_predicates: Vec<_> = predicates
|
let outlives_predicates: Vec<_> = predicates
|
||||||
.drain_filter(|predicate| {
|
.drain_filter(|predicate| {
|
||||||
matches!(predicate.kind().skip_binder(), ty::PredicateKind::TypeOutlives(..))
|
matches!(
|
||||||
|
predicate.kind().skip_binder(),
|
||||||
|
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(..))
|
||||||
|
)
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
|
|
@ -288,11 +288,11 @@ fn predicate_references_self<'tcx>(
|
||||||
let self_ty = tcx.types.self_param;
|
let self_ty = tcx.types.self_param;
|
||||||
let has_self_ty = |arg: &GenericArg<'tcx>| arg.walk().any(|arg| arg == self_ty.into());
|
let has_self_ty = |arg: &GenericArg<'tcx>| arg.walk().any(|arg| arg == self_ty.into());
|
||||||
match predicate.kind().skip_binder() {
|
match predicate.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(ref data) => {
|
ty::PredicateKind::Clause(ty::Clause::Trait(ref data)) => {
|
||||||
// In the case of a trait predicate, we can skip the "self" type.
|
// In the case of a trait predicate, we can skip the "self" type.
|
||||||
if data.trait_ref.substs[1..].iter().any(has_self_ty) { Some(sp) } else { None }
|
if data.trait_ref.substs[1..].iter().any(has_self_ty) { Some(sp) } else { None }
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Projection(ref data) => {
|
ty::PredicateKind::Clause(ty::Clause::Projection(ref data)) => {
|
||||||
// And similarly for projections. This should be redundant with
|
// And similarly for projections. This should be redundant with
|
||||||
// the previous check because any projection should have a
|
// the previous check because any projection should have a
|
||||||
// matching `Trait` predicate with the same inputs, but we do
|
// matching `Trait` predicate with the same inputs, but we do
|
||||||
|
@ -312,8 +312,8 @@ fn predicate_references_self<'tcx>(
|
||||||
}
|
}
|
||||||
ty::PredicateKind::WellFormed(..)
|
ty::PredicateKind::WellFormed(..)
|
||||||
| ty::PredicateKind::ObjectSafe(..)
|
| ty::PredicateKind::ObjectSafe(..)
|
||||||
| ty::PredicateKind::TypeOutlives(..)
|
| ty::PredicateKind::Clause(ty::Clause::TypeOutlives(..))
|
||||||
| ty::PredicateKind::RegionOutlives(..)
|
| ty::PredicateKind::Clause(ty::Clause::RegionOutlives(..))
|
||||||
| ty::PredicateKind::ClosureKind(..)
|
| ty::PredicateKind::ClosureKind(..)
|
||||||
| ty::PredicateKind::Subtype(..)
|
| ty::PredicateKind::Subtype(..)
|
||||||
| ty::PredicateKind::Coerce(..)
|
| ty::PredicateKind::Coerce(..)
|
||||||
|
@ -338,17 +338,17 @@ fn generics_require_sized_self(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
|
||||||
let predicates = predicates.instantiate_identity(tcx).predicates;
|
let predicates = predicates.instantiate_identity(tcx).predicates;
|
||||||
elaborate_predicates(tcx, predicates.into_iter()).any(|obligation| {
|
elaborate_predicates(tcx, predicates.into_iter()).any(|obligation| {
|
||||||
match obligation.predicate.kind().skip_binder() {
|
match obligation.predicate.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(ref trait_pred) => {
|
ty::PredicateKind::Clause(ty::Clause::Trait(ref trait_pred)) => {
|
||||||
trait_pred.def_id() == sized_def_id && trait_pred.self_ty().is_param(0)
|
trait_pred.def_id() == sized_def_id && trait_pred.self_ty().is_param(0)
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Projection(..)
|
ty::PredicateKind::Clause(ty::Clause::Projection(..))
|
||||||
| ty::PredicateKind::Subtype(..)
|
| ty::PredicateKind::Subtype(..)
|
||||||
| ty::PredicateKind::Coerce(..)
|
| ty::PredicateKind::Coerce(..)
|
||||||
| ty::PredicateKind::RegionOutlives(..)
|
| ty::PredicateKind::Clause(ty::Clause::RegionOutlives(..))
|
||||||
| ty::PredicateKind::WellFormed(..)
|
| ty::PredicateKind::WellFormed(..)
|
||||||
| ty::PredicateKind::ObjectSafe(..)
|
| ty::PredicateKind::ObjectSafe(..)
|
||||||
| ty::PredicateKind::ClosureKind(..)
|
| ty::PredicateKind::ClosureKind(..)
|
||||||
| ty::PredicateKind::TypeOutlives(..)
|
| ty::PredicateKind::Clause(ty::Clause::TypeOutlives(..))
|
||||||
| ty::PredicateKind::ConstEvaluatable(..)
|
| ty::PredicateKind::ConstEvaluatable(..)
|
||||||
| ty::PredicateKind::ConstEquate(..)
|
| ty::PredicateKind::ConstEquate(..)
|
||||||
| ty::PredicateKind::Ambiguous
|
| ty::PredicateKind::Ambiguous
|
||||||
|
|
|
@ -1476,7 +1476,9 @@ fn assemble_candidates_from_predicates<'cx, 'tcx>(
|
||||||
let infcx = selcx.infcx();
|
let infcx = selcx.infcx();
|
||||||
for predicate in env_predicates {
|
for predicate in env_predicates {
|
||||||
let bound_predicate = predicate.kind();
|
let bound_predicate = predicate.kind();
|
||||||
if let ty::PredicateKind::Projection(data) = predicate.kind().skip_binder() {
|
if let ty::PredicateKind::Clause(ty::Clause::Projection(data)) =
|
||||||
|
predicate.kind().skip_binder()
|
||||||
|
{
|
||||||
let data = bound_predicate.rebind(data);
|
let data = bound_predicate.rebind(data);
|
||||||
if data.projection_def_id() != obligation.predicate.item_def_id {
|
if data.projection_def_id() != obligation.predicate.item_def_id {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -66,7 +66,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
|
||||||
let mut _orig_values = OriginalQueryValues::default();
|
let mut _orig_values = OriginalQueryValues::default();
|
||||||
|
|
||||||
let param_env = match obligation.predicate.kind().skip_binder() {
|
let param_env = match obligation.predicate.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(pred) => {
|
ty::PredicateKind::Clause(ty::Clause::Trait(pred)) => {
|
||||||
// we ignore the value set to it.
|
// we ignore the value set to it.
|
||||||
let mut _constness = pred.constness;
|
let mut _constness = pred.constness;
|
||||||
obligation
|
obligation
|
||||||
|
|
|
@ -15,7 +15,9 @@ impl<'tcx> super::QueryTypeOp<'tcx> for ProvePredicate<'tcx> {
|
||||||
// `&T`, accounts for about 60% percentage of the predicates
|
// `&T`, accounts for about 60% percentage of the predicates
|
||||||
// we have to prove. No need to canonicalize and all that for
|
// we have to prove. No need to canonicalize and all that for
|
||||||
// such cases.
|
// such cases.
|
||||||
if let ty::PredicateKind::Trait(trait_ref) = key.value.predicate.kind().skip_binder() {
|
if let ty::PredicateKind::Clause(ty::Clause::Trait(trait_ref)) =
|
||||||
|
key.value.predicate.kind().skip_binder()
|
||||||
|
{
|
||||||
if let Some(sized_def_id) = tcx.lang_items().sized_trait() {
|
if let Some(sized_def_id) = tcx.lang_items().sized_trait() {
|
||||||
if trait_ref.def_id() == sized_def_id {
|
if trait_ref.def_id() == sized_def_id {
|
||||||
if trait_ref.self_ty().is_trivially_sized(tcx) {
|
if trait_ref.self_ty().is_trivially_sized(tcx) {
|
||||||
|
@ -33,7 +35,7 @@ impl<'tcx> super::QueryTypeOp<'tcx> for ProvePredicate<'tcx> {
|
||||||
mut canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Self>>,
|
mut canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Self>>,
|
||||||
) -> Fallible<CanonicalizedQueryResponse<'tcx, ()>> {
|
) -> Fallible<CanonicalizedQueryResponse<'tcx, ()>> {
|
||||||
match canonicalized.value.value.predicate.kind().skip_binder() {
|
match canonicalized.value.value.predicate.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(pred) => {
|
ty::PredicateKind::Clause(ty::Clause::Trait(pred)) => {
|
||||||
canonicalized.value.param_env.remap_constness_with(pred.constness);
|
canonicalized.value.param_env.remap_constness_with(pred.constness);
|
||||||
}
|
}
|
||||||
_ => canonicalized.value.param_env = canonicalized.value.param_env.without_const(),
|
_ => canonicalized.value.param_env = canonicalized.value.param_env.without_const(),
|
||||||
|
|
|
@ -12,7 +12,7 @@ pub(crate) fn update<'tcx, T>(
|
||||||
T: TraitEngine<'tcx>,
|
T: TraitEngine<'tcx>,
|
||||||
{
|
{
|
||||||
// (*) binder skipped
|
// (*) binder skipped
|
||||||
if let ty::PredicateKind::Trait(tpred) = obligation.predicate.kind().skip_binder()
|
if let ty::PredicateKind::Clause(ty::Clause::Trait(tpred)) = obligation.predicate.kind().skip_binder()
|
||||||
&& let Some(ty) = infcx.shallow_resolve(tpred.self_ty()).ty_vid().map(|t| infcx.root_var(t))
|
&& let Some(ty) = infcx.shallow_resolve(tpred.self_ty()).ty_vid().map(|t| infcx.root_var(t))
|
||||||
&& infcx.tcx.lang_items().sized_trait().map_or(false, |st| st != tpred.trait_ref.def_id)
|
&& infcx.tcx.lang_items().sized_trait().map_or(false, |st| st != tpred.trait_ref.def_id)
|
||||||
{
|
{
|
||||||
|
@ -26,7 +26,7 @@ pub(crate) fn update<'tcx, T>(
|
||||||
.kind()
|
.kind()
|
||||||
.rebind(
|
.rebind(
|
||||||
// (*) binder moved here
|
// (*) binder moved here
|
||||||
ty::PredicateKind::Trait(tpred.with_self_type(infcx.tcx, new_self_ty))
|
ty::PredicateKind::Clause(ty::Clause::Trait(tpred.with_self_type(infcx.tcx, new_self_ty)))
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
// Don't report overflow errors. Otherwise equivalent to may_hold.
|
// Don't report overflow errors. Otherwise equivalent to may_hold.
|
||||||
|
@ -35,7 +35,9 @@ pub(crate) fn update<'tcx, T>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let ty::PredicateKind::Projection(predicate) = obligation.predicate.kind().skip_binder() {
|
if let ty::PredicateKind::Clause(ty::Clause::Projection(predicate)) =
|
||||||
|
obligation.predicate.kind().skip_binder()
|
||||||
|
{
|
||||||
// If the projection predicate (Foo::Bar == X) has X as a non-TyVid,
|
// If the projection predicate (Foo::Bar == X) has X as a non-TyVid,
|
||||||
// we need to make it into one.
|
// we need to make it into one.
|
||||||
if let Some(vid) = predicate.term.ty().and_then(|ty| ty.ty_vid()) {
|
if let Some(vid) = predicate.term.ty().and_then(|ty| ty.ty_vid()) {
|
||||||
|
|
|
@ -419,7 +419,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
ensure_sufficient_stack(|| {
|
ensure_sufficient_stack(|| {
|
||||||
let bound_predicate = obligation.predicate.kind();
|
let bound_predicate = obligation.predicate.kind();
|
||||||
match bound_predicate.skip_binder() {
|
match bound_predicate.skip_binder() {
|
||||||
ty::PredicateKind::Trait(t) => {
|
ty::PredicateKind::Clause(ty::Clause::Trait(t)) => {
|
||||||
let t = bound_predicate.rebind(t);
|
let t = bound_predicate.rebind(t);
|
||||||
debug_assert!(!t.has_escaping_bound_vars());
|
debug_assert!(!t.has_escaping_bound_vars());
|
||||||
let obligation = obligation.with(self.tcx(), t);
|
let obligation = obligation.with(self.tcx(), t);
|
||||||
|
@ -546,7 +546,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::PredicateKind::TypeOutlives(pred) => {
|
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(pred)) => {
|
||||||
// A global type with no late-bound regions can only
|
// A global type with no late-bound regions can only
|
||||||
// contain the "'static" lifetime (any other lifetime
|
// contain the "'static" lifetime (any other lifetime
|
||||||
// would either be late-bound or local), so it is guaranteed
|
// would either be late-bound or local), so it is guaranteed
|
||||||
|
@ -558,7 +558,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::PredicateKind::RegionOutlives(..) => {
|
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(..)) => {
|
||||||
// We do not consider region relationships when evaluating trait matches.
|
// We do not consider region relationships when evaluating trait matches.
|
||||||
Ok(EvaluatedToOkModuloRegions)
|
Ok(EvaluatedToOkModuloRegions)
|
||||||
}
|
}
|
||||||
|
@ -571,7 +571,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::PredicateKind::Projection(data) => {
|
ty::PredicateKind::Clause(ty::Clause::Projection(data)) => {
|
||||||
let data = bound_predicate.rebind(data);
|
let data = bound_predicate.rebind(data);
|
||||||
let project_obligation = obligation.with(self.tcx(), data);
|
let project_obligation = obligation.with(self.tcx(), data);
|
||||||
match project::poly_project_and_unify_type(self, &project_obligation) {
|
match project::poly_project_and_unify_type(self, &project_obligation) {
|
||||||
|
@ -931,7 +931,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
|
|
||||||
fn coinductive_predicate(&self, predicate: ty::Predicate<'tcx>) -> bool {
|
fn coinductive_predicate(&self, predicate: ty::Predicate<'tcx>) -> bool {
|
||||||
let result = match predicate.kind().skip_binder() {
|
let result = match predicate.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(ref data) => self.tcx().trait_is_coinductive(data.def_id()),
|
ty::PredicateKind::Clause(ty::Clause::Trait(ref data)) => {
|
||||||
|
self.tcx().trait_is_coinductive(data.def_id())
|
||||||
|
}
|
||||||
ty::PredicateKind::WellFormed(_) => true,
|
ty::PredicateKind::WellFormed(_) => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
};
|
};
|
||||||
|
@ -1377,7 +1379,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.filter_map(|(idx, bound)| {
|
.filter_map(|(idx, bound)| {
|
||||||
let bound_predicate = bound.kind();
|
let bound_predicate = bound.kind();
|
||||||
if let ty::PredicateKind::Trait(pred) = bound_predicate.skip_binder() {
|
if let ty::PredicateKind::Clause(ty::Clause::Trait(pred)) =
|
||||||
|
bound_predicate.skip_binder()
|
||||||
|
{
|
||||||
let bound = bound_predicate.rebind(pred.trait_ref);
|
let bound = bound_predicate.rebind(pred.trait_ref);
|
||||||
if self.infcx.probe(|_| {
|
if self.infcx.probe(|_| {
|
||||||
match self.match_normalize_trait_ref(
|
match self.match_normalize_trait_ref(
|
||||||
|
|
|
@ -476,7 +476,9 @@ pub(crate) fn to_pretty_impl_header(tcx: TyCtxt<'_>, impl_def_id: DefId) -> Opti
|
||||||
trait_pred
|
trait_pred
|
||||||
});
|
});
|
||||||
|
|
||||||
p = tcx.mk_predicate(new_trait_pred.map_bound(ty::PredicateKind::Trait))
|
p = tcx.mk_predicate(
|
||||||
|
new_trait_pred.map_bound(|p| ty::PredicateKind::Clause(ty::Clause::Trait(p))),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pretty_predicates.push(p.to_string());
|
pretty_predicates.push(p.to_string());
|
||||||
|
|
|
@ -121,14 +121,14 @@ pub fn predicate_obligations<'tcx>(
|
||||||
|
|
||||||
// It's ok to skip the binder here because wf code is prepared for it
|
// It's ok to skip the binder here because wf code is prepared for it
|
||||||
match predicate.kind().skip_binder() {
|
match predicate.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(t) => {
|
ty::PredicateKind::Clause(ty::Clause::Trait(t)) => {
|
||||||
wf.compute_trait_pred(&t, Elaborate::None);
|
wf.compute_trait_pred(&t, Elaborate::None);
|
||||||
}
|
}
|
||||||
ty::PredicateKind::RegionOutlives(..) => {}
|
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(..)) => {}
|
||||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty, _reg)) => {
|
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(ty::OutlivesPredicate(ty, _reg))) => {
|
||||||
wf.compute(ty.into());
|
wf.compute(ty.into());
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Projection(t) => {
|
ty::PredicateKind::Clause(ty::Clause::Projection(t)) => {
|
||||||
wf.compute_projection(t.projection_ty);
|
wf.compute_projection(t.projection_ty);
|
||||||
wf.compute(match t.term.unpack() {
|
wf.compute(match t.term.unpack() {
|
||||||
ty::TermKind::Ty(ty) => ty.into(),
|
ty::TermKind::Ty(ty) => ty.into(),
|
||||||
|
@ -228,7 +228,7 @@ fn extend_cause_with_original_assoc_item_obligation<'tcx>(
|
||||||
|
|
||||||
// It is fine to skip the binder as we don't care about regions here.
|
// It is fine to skip the binder as we don't care about regions here.
|
||||||
match pred.kind().skip_binder() {
|
match pred.kind().skip_binder() {
|
||||||
ty::PredicateKind::Projection(proj) => {
|
ty::PredicateKind::Clause(ty::Clause::Projection(proj)) => {
|
||||||
// The obligation comes not from the current `impl` nor the `trait` being implemented,
|
// The obligation comes not from the current `impl` nor the `trait` being implemented,
|
||||||
// but rather from a "second order" obligation, where an associated type has a
|
// but rather from a "second order" obligation, where an associated type has a
|
||||||
// projection coming from another associated type. See
|
// projection coming from another associated type. See
|
||||||
|
@ -245,7 +245,7 @@ fn extend_cause_with_original_assoc_item_obligation<'tcx>(
|
||||||
cause.span = impl_item_span;
|
cause.span = impl_item_span;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Trait(pred) => {
|
ty::PredicateKind::Clause(ty::Clause::Trait(pred)) => {
|
||||||
// An associated item obligation born out of the `trait` failed to be met. An example
|
// An associated item obligation born out of the `trait` failed to be met. An example
|
||||||
// can be seen in `ui/associated-types/point-at-type-on-obligation-failure-2.rs`.
|
// can be seen in `ui/associated-types/point-at-type-on-obligation-failure-2.rs`.
|
||||||
debug!("extended_cause_with_original_assoc_item_obligation trait proj {:?}", pred);
|
debug!("extended_cause_with_original_assoc_item_obligation trait proj {:?}", pred);
|
||||||
|
@ -561,9 +561,9 @@ impl<'tcx> WfPredicates<'tcx> {
|
||||||
cause,
|
cause,
|
||||||
depth,
|
depth,
|
||||||
param_env,
|
param_env,
|
||||||
ty::Binder::dummy(ty::PredicateKind::TypeOutlives(
|
ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::TypeOutlives(
|
||||||
ty::OutlivesPredicate(rty, r),
|
ty::OutlivesPredicate(rty, r),
|
||||||
)),
|
))),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -866,19 +866,22 @@ pub(crate) fn required_region_bounds<'tcx>(
|
||||||
.filter_map(|obligation| {
|
.filter_map(|obligation| {
|
||||||
debug!(?obligation);
|
debug!(?obligation);
|
||||||
match obligation.predicate.kind().skip_binder() {
|
match obligation.predicate.kind().skip_binder() {
|
||||||
ty::PredicateKind::Projection(..)
|
ty::PredicateKind::Clause(ty::Clause::Projection(..))
|
||||||
| ty::PredicateKind::Trait(..)
|
| ty::PredicateKind::Clause(ty::Clause::Trait(..))
|
||||||
| ty::PredicateKind::Subtype(..)
|
| ty::PredicateKind::Subtype(..)
|
||||||
| ty::PredicateKind::Coerce(..)
|
| ty::PredicateKind::Coerce(..)
|
||||||
| ty::PredicateKind::WellFormed(..)
|
| ty::PredicateKind::WellFormed(..)
|
||||||
| ty::PredicateKind::ObjectSafe(..)
|
| ty::PredicateKind::ObjectSafe(..)
|
||||||
| ty::PredicateKind::ClosureKind(..)
|
| ty::PredicateKind::ClosureKind(..)
|
||||||
| ty::PredicateKind::RegionOutlives(..)
|
| ty::PredicateKind::Clause(ty::Clause::RegionOutlives(..))
|
||||||
| ty::PredicateKind::ConstEvaluatable(..)
|
| ty::PredicateKind::ConstEvaluatable(..)
|
||||||
| ty::PredicateKind::ConstEquate(..)
|
| ty::PredicateKind::ConstEquate(..)
|
||||||
| ty::PredicateKind::Ambiguous
|
| ty::PredicateKind::Ambiguous
|
||||||
| ty::PredicateKind::TypeWellFormedFromEnv(..) => None,
|
| ty::PredicateKind::TypeWellFormedFromEnv(..) => None,
|
||||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ref t, ref r)) => {
|
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(ty::OutlivesPredicate(
|
||||||
|
ref t,
|
||||||
|
ref r,
|
||||||
|
))) => {
|
||||||
// Search for a bound of the form `erased_self_ty
|
// Search for a bound of the form `erased_self_ty
|
||||||
// : 'a`, but be wary of something like `for<'a>
|
// : 'a`, but be wary of something like `for<'a>
|
||||||
// erased_self_ty : 'a` (we interpret a
|
// erased_self_ty : 'a` (we interpret a
|
||||||
|
|
|
@ -89,24 +89,32 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::InEnvironment<chalk_ir::Goal<RustInterner<'
|
||||||
ty::PredicateKind::TypeWellFormedFromEnv(ty) => {
|
ty::PredicateKind::TypeWellFormedFromEnv(ty) => {
|
||||||
chalk_ir::DomainGoal::FromEnv(chalk_ir::FromEnv::Ty(ty.lower_into(interner)))
|
chalk_ir::DomainGoal::FromEnv(chalk_ir::FromEnv::Ty(ty.lower_into(interner)))
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Trait(predicate) => chalk_ir::DomainGoal::FromEnv(
|
ty::PredicateKind::Clause(ty::Clause::Trait(predicate)) => {
|
||||||
chalk_ir::FromEnv::Trait(predicate.trait_ref.lower_into(interner)),
|
chalk_ir::DomainGoal::FromEnv(chalk_ir::FromEnv::Trait(
|
||||||
),
|
predicate.trait_ref.lower_into(interner),
|
||||||
ty::PredicateKind::RegionOutlives(predicate) => chalk_ir::DomainGoal::Holds(
|
))
|
||||||
chalk_ir::WhereClause::LifetimeOutlives(chalk_ir::LifetimeOutlives {
|
}
|
||||||
a: predicate.0.lower_into(interner),
|
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(predicate)) => {
|
||||||
b: predicate.1.lower_into(interner),
|
chalk_ir::DomainGoal::Holds(chalk_ir::WhereClause::LifetimeOutlives(
|
||||||
}),
|
chalk_ir::LifetimeOutlives {
|
||||||
),
|
a: predicate.0.lower_into(interner),
|
||||||
ty::PredicateKind::TypeOutlives(predicate) => chalk_ir::DomainGoal::Holds(
|
b: predicate.1.lower_into(interner),
|
||||||
chalk_ir::WhereClause::TypeOutlives(chalk_ir::TypeOutlives {
|
},
|
||||||
ty: predicate.0.lower_into(interner),
|
))
|
||||||
lifetime: predicate.1.lower_into(interner),
|
}
|
||||||
}),
|
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(predicate)) => {
|
||||||
),
|
chalk_ir::DomainGoal::Holds(chalk_ir::WhereClause::TypeOutlives(
|
||||||
ty::PredicateKind::Projection(predicate) => chalk_ir::DomainGoal::Holds(
|
chalk_ir::TypeOutlives {
|
||||||
chalk_ir::WhereClause::AliasEq(predicate.lower_into(interner)),
|
ty: predicate.0.lower_into(interner),
|
||||||
),
|
lifetime: predicate.1.lower_into(interner),
|
||||||
|
},
|
||||||
|
))
|
||||||
|
}
|
||||||
|
ty::PredicateKind::Clause(ty::Clause::Projection(predicate)) => {
|
||||||
|
chalk_ir::DomainGoal::Holds(chalk_ir::WhereClause::AliasEq(
|
||||||
|
predicate.lower_into(interner),
|
||||||
|
))
|
||||||
|
}
|
||||||
ty::PredicateKind::WellFormed(arg) => match arg.unpack() {
|
ty::PredicateKind::WellFormed(arg) => match arg.unpack() {
|
||||||
ty::GenericArgKind::Type(ty) => chalk_ir::DomainGoal::WellFormed(
|
ty::GenericArgKind::Type(ty) => chalk_ir::DomainGoal::WellFormed(
|
||||||
chalk_ir::WellFormed::Ty(ty.lower_into(interner)),
|
chalk_ir::WellFormed::Ty(ty.lower_into(interner)),
|
||||||
|
@ -149,12 +157,12 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData<RustInterner<'tcx>>> for ty::Predi
|
||||||
collect_bound_vars(interner, interner.tcx, self.kind());
|
collect_bound_vars(interner, interner.tcx, self.kind());
|
||||||
|
|
||||||
let value = match predicate {
|
let value = match predicate {
|
||||||
ty::PredicateKind::Trait(predicate) => {
|
ty::PredicateKind::Clause(ty::Clause::Trait(predicate)) => {
|
||||||
chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::Holds(
|
chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::Holds(
|
||||||
chalk_ir::WhereClause::Implemented(predicate.trait_ref.lower_into(interner)),
|
chalk_ir::WhereClause::Implemented(predicate.trait_ref.lower_into(interner)),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
ty::PredicateKind::RegionOutlives(predicate) => {
|
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(predicate)) => {
|
||||||
chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::Holds(
|
chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::Holds(
|
||||||
chalk_ir::WhereClause::LifetimeOutlives(chalk_ir::LifetimeOutlives {
|
chalk_ir::WhereClause::LifetimeOutlives(chalk_ir::LifetimeOutlives {
|
||||||
a: predicate.0.lower_into(interner),
|
a: predicate.0.lower_into(interner),
|
||||||
|
@ -162,7 +170,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData<RustInterner<'tcx>>> for ty::Predi
|
||||||
}),
|
}),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
ty::PredicateKind::TypeOutlives(predicate) => {
|
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(predicate)) => {
|
||||||
chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::Holds(
|
chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::Holds(
|
||||||
chalk_ir::WhereClause::TypeOutlives(chalk_ir::TypeOutlives {
|
chalk_ir::WhereClause::TypeOutlives(chalk_ir::TypeOutlives {
|
||||||
ty: predicate.0.lower_into(interner),
|
ty: predicate.0.lower_into(interner),
|
||||||
|
@ -170,7 +178,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData<RustInterner<'tcx>>> for ty::Predi
|
||||||
}),
|
}),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Projection(predicate) => {
|
ty::PredicateKind::Clause(ty::Clause::Projection(predicate)) => {
|
||||||
chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::Holds(
|
chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::Holds(
|
||||||
chalk_ir::WhereClause::AliasEq(predicate.lower_into(interner)),
|
chalk_ir::WhereClause::AliasEq(predicate.lower_into(interner)),
|
||||||
))
|
))
|
||||||
|
@ -605,22 +613,22 @@ impl<'tcx> LowerInto<'tcx, Option<chalk_ir::QuantifiedWhereClause<RustInterner<'
|
||||||
let (predicate, binders, _named_regions) =
|
let (predicate, binders, _named_regions) =
|
||||||
collect_bound_vars(interner, interner.tcx, self.kind());
|
collect_bound_vars(interner, interner.tcx, self.kind());
|
||||||
let value = match predicate {
|
let value = match predicate {
|
||||||
ty::PredicateKind::Trait(predicate) => {
|
ty::PredicateKind::Clause(ty::Clause::Trait(predicate)) => {
|
||||||
Some(chalk_ir::WhereClause::Implemented(predicate.trait_ref.lower_into(interner)))
|
Some(chalk_ir::WhereClause::Implemented(predicate.trait_ref.lower_into(interner)))
|
||||||
}
|
}
|
||||||
ty::PredicateKind::RegionOutlives(predicate) => {
|
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(predicate)) => {
|
||||||
Some(chalk_ir::WhereClause::LifetimeOutlives(chalk_ir::LifetimeOutlives {
|
Some(chalk_ir::WhereClause::LifetimeOutlives(chalk_ir::LifetimeOutlives {
|
||||||
a: predicate.0.lower_into(interner),
|
a: predicate.0.lower_into(interner),
|
||||||
b: predicate.1.lower_into(interner),
|
b: predicate.1.lower_into(interner),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
ty::PredicateKind::TypeOutlives(predicate) => {
|
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(predicate)) => {
|
||||||
Some(chalk_ir::WhereClause::TypeOutlives(chalk_ir::TypeOutlives {
|
Some(chalk_ir::WhereClause::TypeOutlives(chalk_ir::TypeOutlives {
|
||||||
ty: predicate.0.lower_into(interner),
|
ty: predicate.0.lower_into(interner),
|
||||||
lifetime: predicate.1.lower_into(interner),
|
lifetime: predicate.1.lower_into(interner),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Projection(predicate) => {
|
ty::PredicateKind::Clause(ty::Clause::Projection(predicate)) => {
|
||||||
Some(chalk_ir::WhereClause::AliasEq(predicate.lower_into(interner)))
|
Some(chalk_ir::WhereClause::AliasEq(predicate.lower_into(interner)))
|
||||||
}
|
}
|
||||||
ty::PredicateKind::WellFormed(_ty) => None,
|
ty::PredicateKind::WellFormed(_ty) => None,
|
||||||
|
@ -741,20 +749,24 @@ impl<'tcx> LowerInto<'tcx, Option<chalk_solve::rust_ir::QuantifiedInlineBound<Ru
|
||||||
let (predicate, binders, _named_regions) =
|
let (predicate, binders, _named_regions) =
|
||||||
collect_bound_vars(interner, interner.tcx, self.kind());
|
collect_bound_vars(interner, interner.tcx, self.kind());
|
||||||
match predicate {
|
match predicate {
|
||||||
ty::PredicateKind::Trait(predicate) => Some(chalk_ir::Binders::new(
|
ty::PredicateKind::Clause(ty::Clause::Trait(predicate)) => {
|
||||||
binders,
|
Some(chalk_ir::Binders::new(
|
||||||
chalk_solve::rust_ir::InlineBound::TraitBound(
|
binders,
|
||||||
predicate.trait_ref.lower_into(interner),
|
chalk_solve::rust_ir::InlineBound::TraitBound(
|
||||||
),
|
predicate.trait_ref.lower_into(interner),
|
||||||
)),
|
),
|
||||||
ty::PredicateKind::Projection(predicate) => Some(chalk_ir::Binders::new(
|
))
|
||||||
binders,
|
}
|
||||||
chalk_solve::rust_ir::InlineBound::AliasEqBound(predicate.lower_into(interner)),
|
ty::PredicateKind::Clause(ty::Clause::Projection(predicate)) => {
|
||||||
)),
|
Some(chalk_ir::Binders::new(
|
||||||
ty::PredicateKind::TypeOutlives(_predicate) => None,
|
binders,
|
||||||
|
chalk_solve::rust_ir::InlineBound::AliasEqBound(predicate.lower_into(interner)),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(_predicate)) => None,
|
||||||
ty::PredicateKind::WellFormed(_ty) => None,
|
ty::PredicateKind::WellFormed(_ty) => None,
|
||||||
|
|
||||||
ty::PredicateKind::RegionOutlives(..)
|
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(..))
|
||||||
| ty::PredicateKind::ObjectSafe(..)
|
| ty::PredicateKind::ObjectSafe(..)
|
||||||
| ty::PredicateKind::ClosureKind(..)
|
| ty::PredicateKind::ClosureKind(..)
|
||||||
| ty::PredicateKind::Subtype(..)
|
| ty::PredicateKind::Subtype(..)
|
||||||
|
|
|
@ -86,10 +86,10 @@ fn compute_implied_outlives_bounds<'tcx>(
|
||||||
match obligation.predicate.kind().no_bound_vars() {
|
match obligation.predicate.kind().no_bound_vars() {
|
||||||
None => None,
|
None => None,
|
||||||
Some(pred) => match pred {
|
Some(pred) => match pred {
|
||||||
ty::PredicateKind::Trait(..)
|
ty::PredicateKind::Clause(ty::Clause::Trait(..))
|
||||||
| ty::PredicateKind::Subtype(..)
|
| ty::PredicateKind::Subtype(..)
|
||||||
| ty::PredicateKind::Coerce(..)
|
| ty::PredicateKind::Coerce(..)
|
||||||
| ty::PredicateKind::Projection(..)
|
| ty::PredicateKind::Clause(ty::Clause::Projection(..))
|
||||||
| ty::PredicateKind::ClosureKind(..)
|
| ty::PredicateKind::ClosureKind(..)
|
||||||
| ty::PredicateKind::ObjectSafe(..)
|
| ty::PredicateKind::ObjectSafe(..)
|
||||||
| ty::PredicateKind::ConstEvaluatable(..)
|
| ty::PredicateKind::ConstEvaluatable(..)
|
||||||
|
@ -101,13 +101,14 @@ fn compute_implied_outlives_bounds<'tcx>(
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(r_a, r_b)) => {
|
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(
|
||||||
Some(ty::OutlivesPredicate(r_a.into(), r_b))
|
ty::OutlivesPredicate(r_a, r_b),
|
||||||
}
|
)) => Some(ty::OutlivesPredicate(r_a.into(), r_b)),
|
||||||
|
|
||||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty_a, r_b)) => {
|
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(ty::OutlivesPredicate(
|
||||||
Some(ty::OutlivesPredicate(ty_a.into(), r_b))
|
ty_a,
|
||||||
}
|
r_b,
|
||||||
|
))) => Some(ty::OutlivesPredicate(ty_a.into(), r_b)),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -56,9 +56,10 @@ fn try_normalize_after_erasing_regions<'tcx, T: TypeFoldable<'tcx> + PartialEq +
|
||||||
|
|
||||||
fn not_outlives_predicate<'tcx>(p: ty::Predicate<'tcx>) -> bool {
|
fn not_outlives_predicate<'tcx>(p: ty::Predicate<'tcx>) -> bool {
|
||||||
match p.kind().skip_binder() {
|
match p.kind().skip_binder() {
|
||||||
ty::PredicateKind::RegionOutlives(..) | ty::PredicateKind::TypeOutlives(..) => false,
|
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(..))
|
||||||
ty::PredicateKind::Trait(..)
|
| ty::PredicateKind::Clause(ty::Clause::TypeOutlives(..)) => false,
|
||||||
| ty::PredicateKind::Projection(..)
|
ty::PredicateKind::Clause(ty::Clause::Trait(..))
|
||||||
|
| ty::PredicateKind::Clause(ty::Clause::Projection(..))
|
||||||
| ty::PredicateKind::WellFormed(..)
|
| ty::PredicateKind::WellFormed(..)
|
||||||
| ty::PredicateKind::ObjectSafe(..)
|
| ty::PredicateKind::ObjectSafe(..)
|
||||||
| ty::PredicateKind::ClosureKind(..)
|
| ty::PredicateKind::ClosureKind(..)
|
||||||
|
|
|
@ -321,10 +321,10 @@ where
|
||||||
let bound_predicate = pred.kind();
|
let bound_predicate = pred.kind();
|
||||||
let tcx = self.cx.tcx;
|
let tcx = self.cx.tcx;
|
||||||
let regions = match bound_predicate.skip_binder() {
|
let regions = match bound_predicate.skip_binder() {
|
||||||
ty::PredicateKind::Trait(poly_trait_pred) => {
|
ty::PredicateKind::Clause(ty::Clause::Trait(poly_trait_pred)) => {
|
||||||
tcx.collect_referenced_late_bound_regions(&bound_predicate.rebind(poly_trait_pred))
|
tcx.collect_referenced_late_bound_regions(&bound_predicate.rebind(poly_trait_pred))
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Projection(poly_proj_pred) => {
|
ty::PredicateKind::Clause(ty::Clause::Projection(poly_proj_pred)) => {
|
||||||
tcx.collect_referenced_late_bound_regions(&bound_predicate.rebind(poly_proj_pred))
|
tcx.collect_referenced_late_bound_regions(&bound_predicate.rebind(poly_proj_pred))
|
||||||
}
|
}
|
||||||
_ => return FxHashSet::default(),
|
_ => return FxHashSet::default(),
|
||||||
|
@ -451,7 +451,9 @@ where
|
||||||
.filter(|p| {
|
.filter(|p| {
|
||||||
!orig_bounds.contains(p)
|
!orig_bounds.contains(p)
|
||||||
|| match p.kind().skip_binder() {
|
|| match p.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(pred) => pred.def_id() == sized_trait,
|
ty::PredicateKind::Clause(ty::Clause::Trait(pred)) => {
|
||||||
|
pred.def_id() == sized_trait
|
||||||
|
}
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -302,12 +302,16 @@ pub(crate) fn clean_predicate<'tcx>(
|
||||||
) -> Option<WherePredicate> {
|
) -> Option<WherePredicate> {
|
||||||
let bound_predicate = predicate.kind();
|
let bound_predicate = predicate.kind();
|
||||||
match bound_predicate.skip_binder() {
|
match bound_predicate.skip_binder() {
|
||||||
ty::PredicateKind::Trait(pred) => {
|
ty::PredicateKind::Clause(ty::Clause::Trait(pred)) => {
|
||||||
clean_poly_trait_predicate(bound_predicate.rebind(pred), cx)
|
clean_poly_trait_predicate(bound_predicate.rebind(pred), cx)
|
||||||
}
|
}
|
||||||
ty::PredicateKind::RegionOutlives(pred) => clean_region_outlives_predicate(pred),
|
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(pred)) => {
|
||||||
ty::PredicateKind::TypeOutlives(pred) => clean_type_outlives_predicate(pred, cx),
|
clean_region_outlives_predicate(pred)
|
||||||
ty::PredicateKind::Projection(pred) => {
|
}
|
||||||
|
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(pred)) => {
|
||||||
|
clean_type_outlives_predicate(pred, cx)
|
||||||
|
}
|
||||||
|
ty::PredicateKind::Clause(ty::Clause::Projection(pred)) => {
|
||||||
Some(clean_projection_predicate(bound_predicate.rebind(pred), cx))
|
Some(clean_projection_predicate(bound_predicate.rebind(pred), cx))
|
||||||
}
|
}
|
||||||
ty::PredicateKind::ConstEvaluatable(..) => None,
|
ty::PredicateKind::ConstEvaluatable(..) => None,
|
||||||
|
@ -689,17 +693,20 @@ fn clean_ty_generics<'tcx>(
|
||||||
let param_idx = (|| {
|
let param_idx = (|| {
|
||||||
let bound_p = p.kind();
|
let bound_p = p.kind();
|
||||||
match bound_p.skip_binder() {
|
match bound_p.skip_binder() {
|
||||||
ty::PredicateKind::Trait(pred) => {
|
ty::PredicateKind::Clause(ty::Clause::Trait(pred)) => {
|
||||||
if let ty::Param(param) = pred.self_ty().kind() {
|
if let ty::Param(param) = pred.self_ty().kind() {
|
||||||
return Some(param.index);
|
return Some(param.index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty, _reg)) => {
|
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(ty::OutlivesPredicate(
|
||||||
|
ty,
|
||||||
|
_reg,
|
||||||
|
))) => {
|
||||||
if let ty::Param(param) = ty.kind() {
|
if let ty::Param(param) = ty.kind() {
|
||||||
return Some(param.index);
|
return Some(param.index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Projection(p) => {
|
ty::PredicateKind::Clause(ty::Clause::Projection(p)) => {
|
||||||
if let ty::Param(param) = p.projection_ty.self_ty().kind() {
|
if let ty::Param(param) = p.projection_ty.self_ty().kind() {
|
||||||
projection = Some(bound_p.rebind(p));
|
projection = Some(bound_p.rebind(p));
|
||||||
return Some(param.index);
|
return Some(param.index);
|
||||||
|
@ -1772,8 +1779,13 @@ fn clean_middle_opaque_bounds<'tcx>(
|
||||||
.filter_map(|bound| {
|
.filter_map(|bound| {
|
||||||
let bound_predicate = bound.kind();
|
let bound_predicate = bound.kind();
|
||||||
let trait_ref = match bound_predicate.skip_binder() {
|
let trait_ref = match bound_predicate.skip_binder() {
|
||||||
ty::PredicateKind::Trait(tr) => bound_predicate.rebind(tr.trait_ref),
|
ty::PredicateKind::Clause(ty::Clause::Trait(tr)) => {
|
||||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(_ty, reg)) => {
|
bound_predicate.rebind(tr.trait_ref)
|
||||||
|
}
|
||||||
|
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(ty::OutlivesPredicate(
|
||||||
|
_ty,
|
||||||
|
reg,
|
||||||
|
))) => {
|
||||||
if let Some(r) = clean_middle_region(reg) {
|
if let Some(r) = clean_middle_region(reg) {
|
||||||
regions.push(GenericBound::Outlives(r));
|
regions.push(GenericBound::Outlives(r));
|
||||||
}
|
}
|
||||||
|
@ -1792,7 +1804,9 @@ fn clean_middle_opaque_bounds<'tcx>(
|
||||||
let bindings: ThinVec<_> = bounds
|
let bindings: ThinVec<_> = bounds
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|bound| {
|
.filter_map(|bound| {
|
||||||
if let ty::PredicateKind::Projection(proj) = bound.kind().skip_binder() {
|
if let ty::PredicateKind::Clause(ty::Clause::Projection(proj)) =
|
||||||
|
bound.kind().skip_binder()
|
||||||
|
{
|
||||||
if proj.projection_ty.trait_ref(cx.tcx) == trait_ref.skip_binder() {
|
if proj.projection_ty.trait_ref(cx.tcx) == trait_ref.skip_binder() {
|
||||||
Some(TypeBinding {
|
Some(TypeBinding {
|
||||||
assoc: projection_to_path_segment(proj.projection_ty, cx),
|
assoc: projection_to_path_segment(proj.projection_ty, cx),
|
||||||
|
|
|
@ -132,7 +132,7 @@ fn trait_is_same_or_supertrait(cx: &DocContext<'_>, child: DefId, trait_: DefId)
|
||||||
.predicates
|
.predicates
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|(pred, _)| {
|
.filter_map(|(pred, _)| {
|
||||||
if let ty::PredicateKind::Trait(pred) = pred.kind().skip_binder() {
|
if let ty::PredicateKind::Clause(ty::Clause::Trait(pred)) = pred.kind().skip_binder() {
|
||||||
if pred.trait_ref.self_ty() == self_ty { Some(pred.def_id()) } else { None }
|
if pred.trait_ref.self_ty() == self_ty { Some(pred.def_id()) } else { None }
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
|
@ -25,7 +25,7 @@ use rustc_lint::{LateContext, LateLintPass};
|
||||||
use rustc_middle::mir::{Rvalue, StatementKind};
|
use rustc_middle::mir::{Rvalue, StatementKind};
|
||||||
use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow, AutoBorrowMutability};
|
use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow, AutoBorrowMutability};
|
||||||
use rustc_middle::ty::{
|
use rustc_middle::ty::{
|
||||||
self, Binder, BoundVariableKind, EarlyBinder, FnSig, GenericArgKind, List, ParamTy, PredicateKind,
|
self, Binder, BoundVariableKind, Clause, EarlyBinder, FnSig, GenericArgKind, List, ParamTy, PredicateKind,
|
||||||
ProjectionPredicate, Ty, TyCtxt, TypeVisitable, TypeckResults,
|
ProjectionPredicate, Ty, TyCtxt, TypeVisitable, TypeckResults,
|
||||||
};
|
};
|
||||||
use rustc_semver::RustcVersion;
|
use rustc_semver::RustcVersion;
|
||||||
|
@ -1097,7 +1097,7 @@ fn needless_borrow_impl_arg_position<'tcx>(
|
||||||
let projection_predicates = predicates
|
let projection_predicates = predicates
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|predicate| {
|
.filter_map(|predicate| {
|
||||||
if let PredicateKind::Projection(projection_predicate) = predicate.kind().skip_binder() {
|
if let PredicateKind::Clause(Clause::Projection(projection_predicate)) = predicate.kind().skip_binder() {
|
||||||
Some(projection_predicate)
|
Some(projection_predicate)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -1111,7 +1111,7 @@ fn needless_borrow_impl_arg_position<'tcx>(
|
||||||
if predicates
|
if predicates
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|predicate| {
|
.filter_map(|predicate| {
|
||||||
if let PredicateKind::Trait(trait_predicate) = predicate.kind().skip_binder()
|
if let PredicateKind::Clause(Clause::Trait(trait_predicate)) = predicate.kind().skip_binder()
|
||||||
&& trait_predicate.trait_ref.self_ty() == param_ty.to_ty(cx.tcx)
|
&& trait_predicate.trait_ref.self_ty() == param_ty.to_ty(cx.tcx)
|
||||||
{
|
{
|
||||||
Some(trait_predicate.trait_ref.def_id)
|
Some(trait_predicate.trait_ref.def_id)
|
||||||
|
@ -1173,7 +1173,7 @@ fn needless_borrow_impl_arg_position<'tcx>(
|
||||||
}
|
}
|
||||||
|
|
||||||
predicates.iter().all(|predicate| {
|
predicates.iter().all(|predicate| {
|
||||||
if let PredicateKind::Trait(trait_predicate) = predicate.kind().skip_binder()
|
if let PredicateKind::Clause(Clause::Trait(trait_predicate)) = predicate.kind().skip_binder()
|
||||||
&& cx.tcx.is_diagnostic_item(sym::IntoIterator, trait_predicate.trait_ref.def_id)
|
&& cx.tcx.is_diagnostic_item(sym::IntoIterator, trait_predicate.trait_ref.def_id)
|
||||||
&& let ty::Param(param_ty) = trait_predicate.self_ty().kind()
|
&& let ty::Param(param_ty) = trait_predicate.self_ty().kind()
|
||||||
&& let GenericArgKind::Type(ty) = substs_with_referent_ty[param_ty.index as usize].unpack()
|
&& let GenericArgKind::Type(ty) = substs_with_referent_ty[param_ty.index as usize].unpack()
|
||||||
|
|
|
@ -14,7 +14,7 @@ use rustc_lint::{LateContext, LateLintPass};
|
||||||
use rustc_middle::hir::nested_filter;
|
use rustc_middle::hir::nested_filter;
|
||||||
use rustc_middle::traits::Reveal;
|
use rustc_middle::traits::Reveal;
|
||||||
use rustc_middle::ty::{
|
use rustc_middle::ty::{
|
||||||
self, Binder, BoundConstness, GenericParamDefKind, ImplPolarity, ParamEnv, PredicateKind, TraitPredicate, TraitRef,
|
self, Binder, BoundConstness, Clause, GenericParamDefKind, ImplPolarity, ParamEnv, PredicateKind, TraitPredicate, TraitRef,
|
||||||
Ty, TyCtxt,
|
Ty, TyCtxt,
|
||||||
};
|
};
|
||||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||||
|
@ -499,7 +499,7 @@ fn param_env_for_derived_eq(tcx: TyCtxt<'_>, did: DefId, eq_trait_id: DefId) ->
|
||||||
|
|
||||||
let ty_predicates = tcx.predicates_of(did).predicates;
|
let ty_predicates = tcx.predicates_of(did).predicates;
|
||||||
for (p, _) in ty_predicates {
|
for (p, _) in ty_predicates {
|
||||||
if let PredicateKind::Trait(p) = p.kind().skip_binder()
|
if let PredicateKind::Clause(Clause::Trait(p)) = p.kind().skip_binder()
|
||||||
&& p.trait_ref.def_id == eq_trait_id
|
&& p.trait_ref.def_id == eq_trait_id
|
||||||
&& let ty::Param(self_ty) = p.trait_ref.self_ty().kind()
|
&& let ty::Param(self_ty) = p.trait_ref.self_ty().kind()
|
||||||
&& p.constness == BoundConstness::NotConst
|
&& p.constness == BoundConstness::NotConst
|
||||||
|
@ -512,14 +512,14 @@ fn param_env_for_derived_eq(tcx: TyCtxt<'_>, did: DefId, eq_trait_id: DefId) ->
|
||||||
ParamEnv::new(
|
ParamEnv::new(
|
||||||
tcx.mk_predicates(ty_predicates.iter().map(|&(p, _)| p).chain(
|
tcx.mk_predicates(ty_predicates.iter().map(|&(p, _)| p).chain(
|
||||||
params.iter().filter(|&&(_, needs_eq)| needs_eq).map(|&(param, _)| {
|
params.iter().filter(|&&(_, needs_eq)| needs_eq).map(|&(param, _)| {
|
||||||
tcx.mk_predicate(Binder::dummy(PredicateKind::Trait(TraitPredicate {
|
tcx.mk_predicate(Binder::dummy(PredicateKind::Clause(Clause::Trait(TraitPredicate {
|
||||||
trait_ref: TraitRef::new(
|
trait_ref: TraitRef::new(
|
||||||
eq_trait_id,
|
eq_trait_id,
|
||||||
tcx.mk_substs(std::iter::once(tcx.mk_param_from_def(param))),
|
tcx.mk_substs(std::iter::once(tcx.mk_param_from_def(param))),
|
||||||
),
|
),
|
||||||
constness: BoundConstness::NotConst,
|
constness: BoundConstness::NotConst,
|
||||||
polarity: ImplPolarity::Positive,
|
polarity: ImplPolarity::Positive,
|
||||||
})))
|
}))))
|
||||||
}),
|
}),
|
||||||
)),
|
)),
|
||||||
Reveal::UserFacing,
|
Reveal::UserFacing,
|
||||||
|
|
|
@ -4,7 +4,7 @@ use rustc_hir::intravisit::FnKind;
|
||||||
use rustc_hir::{Body, FnDecl, HirId};
|
use rustc_hir::{Body, FnDecl, HirId};
|
||||||
use rustc_infer::infer::TyCtxtInferExt;
|
use rustc_infer::infer::TyCtxtInferExt;
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
use rustc_middle::ty::{EarlyBinder, Opaque, PredicateKind::Trait};
|
use rustc_middle::ty::{Clause, EarlyBinder, Opaque, PredicateKind};
|
||||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||||
use rustc_span::{sym, Span};
|
use rustc_span::{sym, Span};
|
||||||
use rustc_trait_selection::traits::error_reporting::suggestions::TypeErrCtxtExt;
|
use rustc_trait_selection::traits::error_reporting::suggestions::TypeErrCtxtExt;
|
||||||
|
@ -91,7 +91,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
|
||||||
infcx
|
infcx
|
||||||
.err_ctxt()
|
.err_ctxt()
|
||||||
.maybe_note_obligation_cause_for_async_await(db, &obligation);
|
.maybe_note_obligation_cause_for_async_await(db, &obligation);
|
||||||
if let Trait(trait_pred) = obligation.predicate.kind().skip_binder() {
|
if let PredicateKind::Clause(Clause::Trait(trait_pred)) = obligation.predicate.kind().skip_binder() {
|
||||||
db.note(&format!(
|
db.note(&format!(
|
||||||
"`{}` doesn't implement `{}`",
|
"`{}` doesn't implement `{}`",
|
||||||
trait_pred.self_ty(),
|
trait_pred.self_ty(),
|
||||||
|
|
|
@ -17,7 +17,7 @@ use rustc_middle::mir::Mutability;
|
||||||
use rustc_middle::ty::adjustment::{Adjust, Adjustment, OverloadedDeref};
|
use rustc_middle::ty::adjustment::{Adjust, Adjustment, OverloadedDeref};
|
||||||
use rustc_middle::ty::subst::{GenericArg, GenericArgKind, SubstsRef};
|
use rustc_middle::ty::subst::{GenericArg, GenericArgKind, SubstsRef};
|
||||||
use rustc_middle::ty::EarlyBinder;
|
use rustc_middle::ty::EarlyBinder;
|
||||||
use rustc_middle::ty::{self, ParamTy, PredicateKind, ProjectionPredicate, TraitPredicate, Ty};
|
use rustc_middle::ty::{self, Clause, ParamTy, PredicateKind, ProjectionPredicate, TraitPredicate, Ty};
|
||||||
use rustc_semver::RustcVersion;
|
use rustc_semver::RustcVersion;
|
||||||
use rustc_span::{sym, Symbol};
|
use rustc_span::{sym, Symbol};
|
||||||
use rustc_trait_selection::traits::{
|
use rustc_trait_selection::traits::{
|
||||||
|
@ -341,12 +341,12 @@ fn get_input_traits_and_projections<'tcx>(
|
||||||
let mut projection_predicates = Vec::new();
|
let mut projection_predicates = Vec::new();
|
||||||
for predicate in cx.tcx.param_env(callee_def_id).caller_bounds() {
|
for predicate in cx.tcx.param_env(callee_def_id).caller_bounds() {
|
||||||
match predicate.kind().skip_binder() {
|
match predicate.kind().skip_binder() {
|
||||||
PredicateKind::Trait(trait_predicate) => {
|
PredicateKind::Clause(Clause::Trait(trait_predicate)) => {
|
||||||
if trait_predicate.trait_ref.self_ty() == input {
|
if trait_predicate.trait_ref.self_ty() == input {
|
||||||
trait_predicates.push(trait_predicate);
|
trait_predicates.push(trait_predicate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PredicateKind::Projection(projection_predicate) => {
|
PredicateKind::Clause(Clause::Projection(projection_predicate)) => {
|
||||||
if projection_predicate.projection_ty.self_ty() == input {
|
if projection_predicate.projection_ty.self_ty() == input {
|
||||||
projection_predicates.push(projection_predicate);
|
projection_predicates.push(projection_predicate);
|
||||||
}
|
}
|
||||||
|
@ -403,7 +403,7 @@ fn can_change_type<'a>(cx: &LateContext<'a>, mut expr: &'a Expr<'a>, mut ty: Ty<
|
||||||
|
|
||||||
let mut trait_predicates = cx.tcx.param_env(callee_def_id)
|
let mut trait_predicates = cx.tcx.param_env(callee_def_id)
|
||||||
.caller_bounds().iter().filter(|predicate| {
|
.caller_bounds().iter().filter(|predicate| {
|
||||||
if let PredicateKind::Trait(trait_predicate) = predicate.kind().skip_binder()
|
if let PredicateKind::Clause(Clause::Trait(trait_predicate)) = predicate.kind().skip_binder()
|
||||||
&& trait_predicate.trait_ref.self_ty() == *param_ty {
|
&& trait_predicate.trait_ref.self_ty() == *param_ty {
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -124,7 +124,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
|
||||||
.filter_map(|obligation| {
|
.filter_map(|obligation| {
|
||||||
// Note that we do not want to deal with qualified predicates here.
|
// Note that we do not want to deal with qualified predicates here.
|
||||||
match obligation.predicate.kind().no_bound_vars() {
|
match obligation.predicate.kind().no_bound_vars() {
|
||||||
Some(ty::PredicateKind::Trait(pred)) if pred.def_id() != sized_trait => Some(pred),
|
Some(ty::PredicateKind::Clause(ty::Clause::Trait(pred))) if pred.def_id() != sized_trait => Some(pred),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -19,7 +19,7 @@ use rustc_infer::infer::TyCtxtInferExt;
|
||||||
use rustc_infer::traits::{Obligation, ObligationCause};
|
use rustc_infer::traits::{Obligation, ObligationCause};
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
use rustc_middle::hir::nested_filter;
|
use rustc_middle::hir::nested_filter;
|
||||||
use rustc_middle::ty::{self, Binder, ExistentialPredicate, List, PredicateKind, Ty};
|
use rustc_middle::ty::{self, Binder, Clause, ExistentialPredicate, List, PredicateKind, Ty};
|
||||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::source_map::Span;
|
||||||
use rustc_span::sym;
|
use rustc_span::sym;
|
||||||
|
@ -699,7 +699,7 @@ fn matches_preds<'tcx>(
|
||||||
ObligationCause::dummy(),
|
ObligationCause::dummy(),
|
||||||
cx.param_env,
|
cx.param_env,
|
||||||
cx.tcx.mk_predicate(Binder::dummy(
|
cx.tcx.mk_predicate(Binder::dummy(
|
||||||
PredicateKind::Projection(p.with_self_ty(cx.tcx, ty)),
|
PredicateKind::Clause(Clause::Projection(p.with_self_ty(cx.tcx, ty))),
|
||||||
)),
|
)),
|
||||||
)),
|
)),
|
||||||
ExistentialPredicate::AutoTrait(p) => infcx
|
ExistentialPredicate::AutoTrait(p) => infcx
|
||||||
|
|
|
@ -4,7 +4,7 @@ use rustc_hir::def_id::DefId;
|
||||||
use rustc_hir::{Closure, Expr, ExprKind, StmtKind};
|
use rustc_hir::{Closure, Expr, ExprKind, StmtKind};
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
use rustc_middle::ty;
|
use rustc_middle::ty;
|
||||||
use rustc_middle::ty::{GenericPredicates, PredicateKind, ProjectionPredicate, TraitPredicate};
|
use rustc_middle::ty::{Clause, GenericPredicates, PredicateKind, ProjectionPredicate, TraitPredicate};
|
||||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||||
use rustc_span::{sym, BytePos, Span};
|
use rustc_span::{sym, BytePos, Span};
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ fn get_trait_predicates_for_trait_id<'tcx>(
|
||||||
let mut preds = Vec::new();
|
let mut preds = Vec::new();
|
||||||
for (pred, _) in generics.predicates {
|
for (pred, _) in generics.predicates {
|
||||||
if_chain! {
|
if_chain! {
|
||||||
if let PredicateKind::Trait(poly_trait_pred) = pred.kind().skip_binder();
|
if let PredicateKind::Clause(Clause::Trait(poly_trait_pred)) = pred.kind().skip_binder();
|
||||||
let trait_pred = cx.tcx.erase_late_bound_regions(pred.kind().rebind(poly_trait_pred));
|
let trait_pred = cx.tcx.erase_late_bound_regions(pred.kind().rebind(poly_trait_pred));
|
||||||
if let Some(trait_def_id) = trait_id;
|
if let Some(trait_def_id) = trait_id;
|
||||||
if trait_def_id == trait_pred.trait_ref.def_id;
|
if trait_def_id == trait_pred.trait_ref.def_id;
|
||||||
|
@ -63,7 +63,7 @@ fn get_projection_pred<'tcx>(
|
||||||
trait_pred: TraitPredicate<'tcx>,
|
trait_pred: TraitPredicate<'tcx>,
|
||||||
) -> Option<ProjectionPredicate<'tcx>> {
|
) -> Option<ProjectionPredicate<'tcx>> {
|
||||||
generics.predicates.iter().find_map(|(proj_pred, _)| {
|
generics.predicates.iter().find_map(|(proj_pred, _)| {
|
||||||
if let ty::PredicateKind::Projection(pred) = proj_pred.kind().skip_binder() {
|
if let ty::PredicateKind::Clause(Clause::Projection(pred)) = proj_pred.kind().skip_binder() {
|
||||||
let projection_pred = cx.tcx.erase_late_bound_regions(proj_pred.kind().rebind(pred));
|
let projection_pred = cx.tcx.erase_late_bound_regions(proj_pred.kind().rebind(pred));
|
||||||
if projection_pred.projection_ty.substs == trait_pred.trait_ref.substs {
|
if projection_pred.projection_ty.substs == trait_pred.trait_ref.substs {
|
||||||
return Some(projection_pred);
|
return Some(projection_pred);
|
||||||
|
|
|
@ -73,7 +73,7 @@ fn fn_eagerness(cx: &LateContext<'_>, fn_id: DefId, name: Symbol, have_one_arg:
|
||||||
.flat_map(|v| v.fields.iter())
|
.flat_map(|v| v.fields.iter())
|
||||||
.any(|x| matches!(cx.tcx.type_of(x.did).peel_refs().kind(), ty::Param(_)))
|
.any(|x| matches!(cx.tcx.type_of(x.did).peel_refs().kind(), ty::Param(_)))
|
||||||
&& all_predicates_of(cx.tcx, fn_id).all(|(pred, _)| match pred.kind().skip_binder() {
|
&& all_predicates_of(cx.tcx, fn_id).all(|(pred, _)| match pred.kind().skip_binder() {
|
||||||
PredicateKind::Trait(pred) => cx.tcx.trait_def(pred.trait_ref.def_id).is_marker,
|
PredicateKind::Clause(ty::Clause::Trait(pred)) => cx.tcx.trait_def(pred.trait_ref.def_id).is_marker,
|
||||||
_ => true,
|
_ => true,
|
||||||
})
|
})
|
||||||
&& subs.types().all(|x| matches!(x.peel_refs().kind(), ty::Param(_)))
|
&& subs.types().all(|x| matches!(x.peel_refs().kind(), ty::Param(_)))
|
||||||
|
|
|
@ -25,13 +25,13 @@ pub fn is_min_const_fn<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>, msrv: Option<
|
||||||
let predicates = tcx.predicates_of(current);
|
let predicates = tcx.predicates_of(current);
|
||||||
for (predicate, _) in predicates.predicates {
|
for (predicate, _) in predicates.predicates {
|
||||||
match predicate.kind().skip_binder() {
|
match predicate.kind().skip_binder() {
|
||||||
ty::PredicateKind::RegionOutlives(_)
|
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(_))
|
||||||
| ty::PredicateKind::TypeOutlives(_)
|
| ty::PredicateKind::Clause(ty::Clause::TypeOutlives(_))
|
||||||
| ty::PredicateKind::WellFormed(_)
|
| ty::PredicateKind::WellFormed(_)
|
||||||
| ty::PredicateKind::Projection(_)
|
| ty::PredicateKind::Clause(ty::Clause::Projection(_))
|
||||||
| ty::PredicateKind::ConstEvaluatable(..)
|
| ty::PredicateKind::ConstEvaluatable(..)
|
||||||
| ty::PredicateKind::ConstEquate(..)
|
| ty::PredicateKind::ConstEquate(..)
|
||||||
| ty::PredicateKind::Trait(..)
|
| ty::PredicateKind::Clause(ty::Clause::Trait(..))
|
||||||
| ty::PredicateKind::TypeWellFormedFromEnv(..) => continue,
|
| ty::PredicateKind::TypeWellFormedFromEnv(..) => continue,
|
||||||
ty::PredicateKind::ObjectSafe(_) => panic!("object safe predicate on function: {predicate:#?}"),
|
ty::PredicateKind::ObjectSafe(_) => panic!("object safe predicate on function: {predicate:#?}"),
|
||||||
ty::PredicateKind::ClosureKind(..) => panic!("closure kind predicate on function: {predicate:#?}"),
|
ty::PredicateKind::ClosureKind(..) => panic!("closure kind predicate on function: {predicate:#?}"),
|
||||||
|
|
|
@ -81,7 +81,7 @@ pub fn contains_ty_adt_constructor_opaque<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'
|
||||||
match predicate.kind().skip_binder() {
|
match predicate.kind().skip_binder() {
|
||||||
// For `impl Trait<U>`, it will register a predicate of `T: Trait<U>`, so we go through
|
// For `impl Trait<U>`, it will register a predicate of `T: Trait<U>`, so we go through
|
||||||
// and check substituions to find `U`.
|
// and check substituions to find `U`.
|
||||||
ty::PredicateKind::Trait(trait_predicate) => {
|
ty::PredicateKind::Clause(ty::Clause::Trait(trait_predicate)) => {
|
||||||
if trait_predicate
|
if trait_predicate
|
||||||
.trait_ref
|
.trait_ref
|
||||||
.substs
|
.substs
|
||||||
|
@ -94,7 +94,7 @@ pub fn contains_ty_adt_constructor_opaque<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'
|
||||||
},
|
},
|
||||||
// For `impl Trait<Assoc=U>`, it will register a predicate of `<T as Trait>::Assoc = U`,
|
// For `impl Trait<Assoc=U>`, it will register a predicate of `<T as Trait>::Assoc = U`,
|
||||||
// so we check the term for `U`.
|
// so we check the term for `U`.
|
||||||
ty::PredicateKind::Projection(projection_predicate) => {
|
ty::PredicateKind::Clause(ty::Clause::Projection(projection_predicate)) => {
|
||||||
if let ty::TermKind::Ty(ty) = projection_predicate.term.unpack() {
|
if let ty::TermKind::Ty(ty) = projection_predicate.term.unpack() {
|
||||||
if contains_ty_adt_constructor_opaque(cx, ty, needle) {
|
if contains_ty_adt_constructor_opaque(cx, ty, needle) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -239,7 +239,7 @@ pub fn is_must_use_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
|
||||||
ty::Tuple(substs) => substs.iter().any(|ty| is_must_use_ty(cx, ty)),
|
ty::Tuple(substs) => substs.iter().any(|ty| is_must_use_ty(cx, ty)),
|
||||||
ty::Opaque(def_id, _) => {
|
ty::Opaque(def_id, _) => {
|
||||||
for (predicate, _) in cx.tcx.explicit_item_bounds(*def_id) {
|
for (predicate, _) in cx.tcx.explicit_item_bounds(*def_id) {
|
||||||
if let ty::PredicateKind::Trait(trait_predicate) = predicate.kind().skip_binder() {
|
if let ty::PredicateKind::Clause(ty::Clause::Trait(trait_predicate)) = predicate.kind().skip_binder() {
|
||||||
if cx.tcx.has_attr(trait_predicate.trait_ref.def_id, sym::must_use) {
|
if cx.tcx.has_attr(trait_predicate.trait_ref.def_id, sym::must_use) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -658,7 +658,7 @@ fn sig_from_bounds<'tcx>(
|
||||||
|
|
||||||
for pred in predicates {
|
for pred in predicates {
|
||||||
match pred.kind().skip_binder() {
|
match pred.kind().skip_binder() {
|
||||||
PredicateKind::Trait(p)
|
PredicateKind::Clause(ty::Clause::Trait(p))
|
||||||
if (lang_items.fn_trait() == Some(p.def_id())
|
if (lang_items.fn_trait() == Some(p.def_id())
|
||||||
|| lang_items.fn_mut_trait() == Some(p.def_id())
|
|| lang_items.fn_mut_trait() == Some(p.def_id())
|
||||||
|| lang_items.fn_once_trait() == Some(p.def_id()))
|
|| lang_items.fn_once_trait() == Some(p.def_id()))
|
||||||
|
@ -671,7 +671,7 @@ fn sig_from_bounds<'tcx>(
|
||||||
}
|
}
|
||||||
inputs = Some(i);
|
inputs = Some(i);
|
||||||
},
|
},
|
||||||
PredicateKind::Projection(p)
|
PredicateKind::Clause(ty::Clause::Projection(p))
|
||||||
if Some(p.projection_ty.item_def_id) == lang_items.fn_once_output()
|
if Some(p.projection_ty.item_def_id) == lang_items.fn_once_output()
|
||||||
&& p.projection_ty.self_ty() == ty =>
|
&& p.projection_ty.self_ty() == ty =>
|
||||||
{
|
{
|
||||||
|
@ -699,7 +699,7 @@ fn sig_for_projection<'tcx>(cx: &LateContext<'tcx>, ty: ProjectionTy<'tcx>) -> O
|
||||||
.subst_iter_copied(cx.tcx, ty.substs)
|
.subst_iter_copied(cx.tcx, ty.substs)
|
||||||
{
|
{
|
||||||
match pred.kind().skip_binder() {
|
match pred.kind().skip_binder() {
|
||||||
PredicateKind::Trait(p)
|
PredicateKind::Clause(ty::Clause::Trait(p))
|
||||||
if (lang_items.fn_trait() == Some(p.def_id())
|
if (lang_items.fn_trait() == Some(p.def_id())
|
||||||
|| lang_items.fn_mut_trait() == Some(p.def_id())
|
|| lang_items.fn_mut_trait() == Some(p.def_id())
|
||||||
|| lang_items.fn_once_trait() == Some(p.def_id())) =>
|
|| lang_items.fn_once_trait() == Some(p.def_id())) =>
|
||||||
|
@ -712,7 +712,7 @@ fn sig_for_projection<'tcx>(cx: &LateContext<'tcx>, ty: ProjectionTy<'tcx>) -> O
|
||||||
}
|
}
|
||||||
inputs = Some(i);
|
inputs = Some(i);
|
||||||
},
|
},
|
||||||
PredicateKind::Projection(p) if Some(p.projection_ty.item_def_id) == lang_items.fn_once_output() => {
|
PredicateKind::Clause(ty::Clause::Projection(p)) if Some(p.projection_ty.item_def_id) == lang_items.fn_once_output() => {
|
||||||
if output.is_some() {
|
if output.is_some() {
|
||||||
// Multiple different fn trait impls. Is this even allowed?
|
// Multiple different fn trait impls. Is this even allowed?
|
||||||
return None;
|
return None;
|
||||||
|
@ -887,7 +887,7 @@ pub fn ty_is_fn_once_param<'tcx>(tcx: TyCtxt<'_>, ty: Ty<'tcx>, predicates: &'tc
|
||||||
predicates
|
predicates
|
||||||
.iter()
|
.iter()
|
||||||
.try_fold(false, |found, p| {
|
.try_fold(false, |found, p| {
|
||||||
if let PredicateKind::Trait(p) = p.kind().skip_binder()
|
if let PredicateKind::Clause(ty::Clause::Trait(p)) = p.kind().skip_binder()
|
||||||
&& let ty::Param(self_ty) = p.trait_ref.self_ty().kind()
|
&& let ty::Param(self_ty) = p.trait_ref.self_ty().kind()
|
||||||
&& ty.index == self_ty.index
|
&& ty.index == self_ty.index
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue