Skip to content

Commit 595ae83

Browse files
committed
Stop passing the self-type as a separate argument.
1 parent f60e43e commit 595ae83

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

clippy_lints/src/dereference.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -842,14 +842,10 @@ fn walk_parents<'tcx>(
842842
} else if let Some(trait_id) = cx.tcx.trait_of_item(id)
843843
&& let arg_ty = cx.tcx.erase_regions(cx.typeck_results().expr_ty_adjusted(e))
844844
&& let ty::Ref(_, sub_ty, _) = *arg_ty.kind()
845-
&& let subs = match cx
845+
&& let subs = cx
846846
.typeck_results()
847-
.node_substs_opt(parent.hir_id)
848-
.and_then(|subs| subs.get(1..))
849-
{
850-
Some(subs) => cx.tcx.mk_substs(subs.iter().copied()),
851-
None => cx.tcx.mk_substs(std::iter::empty::<ty::subst::GenericArg<'_>>()),
852-
} && let impl_ty = if cx.tcx.fn_sig(id).skip_binder().inputs()[0].is_ref() {
847+
.node_substs_opt(parent.hir_id).map(|subs| &subs[1..]).unwrap_or_default()
848+
&& let impl_ty = if cx.tcx.fn_sig(id).skip_binder().inputs()[0].is_ref() {
853849
// Trait methods taking `&self`
854850
sub_ty
855851
} else {
@@ -858,7 +854,7 @@ fn walk_parents<'tcx>(
858854
} && impl_ty.is_ref()
859855
&& let infcx = cx.tcx.infer_ctxt().build()
860856
&& infcx
861-
.type_implements_trait(trait_id, impl_ty, subs, cx.param_env)
857+
.type_implements_trait(trait_id, [impl_ty.into()].into_iter().chain(subs.iter().copied()), cx.param_env)
862858
.must_apply_modulo_regions()
863859
{
864860
return Some(Position::MethodReceiverRefImpl)

clippy_lints/src/ptr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ fn matches_preds<'tcx>(
692692
let infcx = cx.tcx.infer_ctxt().build();
693693
preds.iter().all(|&p| match cx.tcx.erase_late_bound_regions(p) {
694694
ExistentialPredicate::Trait(p) => infcx
695-
.type_implements_trait(p.def_id, ty, p.substs, cx.param_env)
695+
.type_implements_trait(p.def_id, [ty.into()].into_iter().chain(p.substs.iter()), cx.param_env)
696696
.must_apply_modulo_regions(),
697697
ExistentialPredicate::Projection(p) => infcx.predicate_must_hold_modulo_regions(&Obligation::new(
698698
cx.tcx,
@@ -704,7 +704,7 @@ fn matches_preds<'tcx>(
704704
)),
705705
)),
706706
ExistentialPredicate::AutoTrait(p) => infcx
707-
.type_implements_trait(p, ty, List::empty(), cx.param_env)
707+
.type_implements_trait(p, [ty], cx.param_env)
708708
.must_apply_modulo_regions(),
709709
})
710710
}

clippy_utils/src/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ pub fn implements_trait_with_env<'tcx>(
178178
};
179179
let ty_params = tcx.mk_substs(ty_params.into_iter().map(|arg| arg.unwrap_or_else(|| infcx.next_ty_var(orig).into())));
180180
infcx
181-
.type_implements_trait(trait_id, ty, ty_params, param_env)
181+
.type_implements_trait(trait_id, [ty.into()].into_iter().chain(ty_params), param_env)
182182
.must_apply_modulo_regions()
183183
}
184184

0 commit comments

Comments
 (0)