Skip to content

Commit 2ed4049

Browse files
Introduce subst_iter and subst_iter_copied on EarlyBinder
1 parent 46cf1ea commit 2ed4049

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

clippy_utils/src/ty.rs

+5-11
Original file line numberDiff line numberDiff line change
@@ -657,21 +657,18 @@ fn sig_for_projection<'tcx>(cx: &LateContext<'tcx>, ty: ProjectionTy<'tcx>) -> O
657657
let mut output = None;
658658
let lang_items = cx.tcx.lang_items();
659659

660-
for pred in cx
660+
for (pred, _) in cx
661661
.tcx
662662
.bound_explicit_item_bounds(ty.item_def_id)
663-
.transpose_iter()
664-
.map(|x| x.map_bound(|(p, _)| p))
663+
.subst_iter_copied(cx.tcx, ty.substs)
665664
{
666-
match pred.0.kind().skip_binder() {
665+
match pred.kind().skip_binder() {
667666
PredicateKind::Trait(p)
668667
if (lang_items.fn_trait() == Some(p.def_id())
669668
|| lang_items.fn_mut_trait() == Some(p.def_id())
670669
|| lang_items.fn_once_trait() == Some(p.def_id())) =>
671670
{
672-
let i = pred
673-
.map_bound(|pred| pred.kind().rebind(p.trait_ref.substs.type_at(1)))
674-
.subst(cx.tcx, ty.substs);
671+
let i = pred.kind().rebind(p.trait_ref.substs.type_at(1));
675672

676673
if inputs.map_or(false, |inputs| inputs != i) {
677674
// Multiple different fn trait impls. Is this even allowed?
@@ -684,10 +681,7 @@ fn sig_for_projection<'tcx>(cx: &LateContext<'tcx>, ty: ProjectionTy<'tcx>) -> O
684681
// Multiple different fn trait impls. Is this even allowed?
685682
return None;
686683
}
687-
output = Some(
688-
pred.map_bound(|pred| pred.kind().rebind(p.term.ty().unwrap()))
689-
.subst(cx.tcx, ty.substs),
690-
);
684+
output = pred.kind().rebind(p.term.ty()).transpose();
691685
},
692686
_ => (),
693687
}

0 commit comments

Comments
 (0)