@@ -7,7 +7,7 @@ use rustc_hir::def::{CtorKind, DefKind, Res};
77use rustc_hir:: def_id:: DefId ;
88use rustc_hir:: { Expr , ExprKind , QPath } ;
99use rustc_lint:: { LateContext , LateLintPass } ;
10- use rustc_middle:: ty:: { self , List , ParamTy , Ty , TyCtxt } ;
10+ use rustc_middle:: ty:: { self , GenericPredicates , List , ParamTy , Ty , TyCtxt } ;
1111use rustc_session:: impl_lint_pass;
1212use rustc_span:: sym;
1313use std:: iter;
@@ -114,6 +114,8 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPathNew<'tcx> {
114114
115115 let implements_asref_path = |arg| implements_trait ( cx, arg, asref_def_id, & [ path_ty. into ( ) ] ) ;
116116
117+ let has_required_preds = |_param_ty : & ParamTy , _preds : GenericPredicates < ' _ > | -> bool { true } ;
118+
117119 // as far as I understand, `ExprKind::MethodCall` doesn't include the receiver in `args`,
118120 // but does in `sig.inputs()` -- so we iterate over both in `rev`erse in order to line
119121 // them up starting from the _end_
@@ -135,7 +137,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPathNew<'tcx> {
135137 . enumerate ( )
136138 . filter_map ( |( i, input) | ( i != arg_idx) . then_some ( * input) ) ,
137139 )
138- && implements_asref_path ( * arg_ty )
140+ && has_required_preds ( arg_param_ty , cx . tcx . predicates_of ( fn_did ) )
139141 {
140142 span_lint_and_sugg (
141143 cx,
0 commit comments