@@ -3,7 +3,7 @@ use clippy_utils::mir::{enclosing_mir, expr_local, local_assignments, used_exact
33use clippy_utils:: msrvs:: { self , Msrv } ;
44use clippy_utils:: source:: { snippet_with_applicability, snippet_with_context} ;
55use clippy_utils:: sugg:: has_enclosing_paren;
6- use clippy_utils:: ty:: { is_copy, peel_mid_ty_refs} ;
6+ use clippy_utils:: ty:: { implements_trait , is_copy, peel_mid_ty_refs} ;
77use clippy_utils:: {
88 expr_use_ctxt, get_parent_expr, get_parent_node, is_lint_allowed, path_to_local, DefinedTy , ExprUseNode ,
99} ;
@@ -33,7 +33,6 @@ use rustc_middle::ty::{
3333use rustc_session:: { declare_tool_lint, impl_lint_pass} ;
3434use rustc_span:: symbol:: sym;
3535use rustc_span:: { Span , Symbol } ;
36- use rustc_trait_selection:: infer:: InferCtxtExt as _;
3736use rustc_trait_selection:: traits:: query:: evaluate_obligation:: InferCtxtExt as _;
3837use rustc_trait_selection:: traits:: { Obligation , ObligationCause } ;
3938use std:: collections:: VecDeque ;
@@ -452,13 +451,12 @@ impl<'tcx> LateLintPass<'tcx> for Dereferencing<'tcx> {
452451 // Trait methods taking `self`
453452 arg_ty
454453 } && impl_ty. is_ref ( )
455- && cx. tcx . infer_ctxt ( ) . build ( )
456- . type_implements_trait (
457- trait_id,
458- [ impl_ty. into ( ) ] . into_iter ( ) . chain ( args. iter ( ) . copied ( ) ) ,
459- cx. param_env ,
460- )
461- . must_apply_modulo_regions ( )
454+ && implements_trait (
455+ cx,
456+ impl_ty,
457+ trait_id,
458+ & args[ ..cx. tcx . generics_of ( trait_id) . params . len ( ) - 1 ] ,
459+ )
462460 {
463461 false
464462 } else {
0 commit comments