Skip to content

Commit 533a819

Browse files
Migrate item_bounds to ty::Clause
1 parent a2b99d8 commit 533a819

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

clippy_lints/src/future_not_send.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
6767
let preds = cx.tcx.explicit_item_bounds(def_id);
6868
let mut is_future = false;
6969
for (p, _span) in preds.subst_iter_copied(cx.tcx, substs) {
70-
if let Some(trait_pred) = p.to_opt_poly_trait_pred() {
70+
if let Some(trait_pred) = p.as_trait_clause() {
7171
if Some(trait_pred.skip_binder().trait_ref.def_id) == cx.tcx.lang_items().future_trait() {
7272
is_future = true;
7373
break;

clippy_utils/src/ty.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ pub fn contains_ty_adt_constructor_opaque<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'
9494
match predicate.kind().skip_binder() {
9595
// For `impl Trait<U>`, it will register a predicate of `T: Trait<U>`, so we go through
9696
// and check substitutions to find `U`.
97-
ty::PredicateKind::Clause(ty::ClauseKind::Trait(trait_predicate)) => {
97+
ty::ClauseKind::Trait(trait_predicate) => {
9898
if trait_predicate
9999
.trait_ref
100100
.substs
@@ -107,7 +107,7 @@ pub fn contains_ty_adt_constructor_opaque<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'
107107
},
108108
// For `impl Trait<Assoc=U>`, it will register a predicate of `<T as Trait>::Assoc = U`,
109109
// so we check the term for `U`.
110-
ty::PredicateKind::Clause(ty::ClauseKind::Projection(projection_predicate)) => {
110+
ty::ClauseKind::Projection(projection_predicate) => {
111111
if let ty::TermKind::Ty(ty) = projection_predicate.term.unpack() {
112112
if contains_ty_adt_constructor_opaque_inner(cx, ty, needle, seen) {
113113
return true;
@@ -268,7 +268,7 @@ pub fn is_must_use_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
268268
ty::Tuple(substs) => substs.iter().any(|ty| is_must_use_ty(cx, ty)),
269269
ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) => {
270270
for (predicate, _) in cx.tcx.explicit_item_bounds(def_id).skip_binder() {
271-
if let ty::PredicateKind::Clause(ty::ClauseKind::Trait(trait_predicate)) = predicate.kind().skip_binder() {
271+
if let ty::ClauseKind::Trait(trait_predicate) = predicate.kind().skip_binder() {
272272
if cx.tcx.has_attr(trait_predicate.trait_ref.def_id, sym::must_use) {
273273
return true;
274274
}
@@ -665,7 +665,7 @@ pub fn ty_sig<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<ExprFnSig<'t
665665
ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => sig_from_bounds(
666666
cx,
667667
ty,
668-
cx.tcx.item_bounds(def_id).subst(cx.tcx, substs),
668+
cx.tcx.item_bounds(def_id).subst_iter(cx.tcx, substs).map(|c| c.as_predicate()),
669669
cx.tcx.opt_parent(def_id),
670670
),
671671
ty::FnPtr(sig) => Some(ExprFnSig::Sig(sig, None)),
@@ -698,7 +698,7 @@ pub fn ty_sig<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<ExprFnSig<'t
698698
fn sig_from_bounds<'tcx>(
699699
cx: &LateContext<'tcx>,
700700
ty: Ty<'tcx>,
701-
predicates: &'tcx [Predicate<'tcx>],
701+
predicates: impl IntoIterator<Item = Predicate<'tcx>>,
702702
predicates_id: Option<DefId>,
703703
) -> Option<ExprFnSig<'tcx>> {
704704
let mut inputs = None;
@@ -747,7 +747,7 @@ fn sig_for_projection<'tcx>(cx: &LateContext<'tcx>, ty: AliasTy<'tcx>) -> Option
747747
.subst_iter_copied(cx.tcx, ty.substs)
748748
{
749749
match pred.kind().skip_binder() {
750-
PredicateKind::Clause(ty::ClauseKind::Trait(p))
750+
ty::ClauseKind::Trait(p)
751751
if (lang_items.fn_trait() == Some(p.def_id())
752752
|| lang_items.fn_mut_trait() == Some(p.def_id())
753753
|| lang_items.fn_once_trait() == Some(p.def_id())) =>
@@ -760,7 +760,7 @@ fn sig_for_projection<'tcx>(cx: &LateContext<'tcx>, ty: AliasTy<'tcx>) -> Option
760760
}
761761
inputs = Some(i);
762762
},
763-
PredicateKind::Clause(ty::ClauseKind::Projection(p))
763+
ty::ClauseKind::Projection(p)
764764
if Some(p.projection_ty.def_id) == lang_items.fn_once_output() =>
765765
{
766766
if output.is_some() {

0 commit comments

Comments
 (0)