Skip to content

Commit 30e8710

Browse files
committed
WIP: has_required_preds
1 parent eab74aa commit 30e8710

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

clippy_lints/src/needless_path_new.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_hir::def::{CtorKind, DefKind, Res};
77
use rustc_hir::def_id::DefId;
88
use rustc_hir::{Expr, ExprKind, QPath};
99
use 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};
1111
use rustc_session::impl_lint_pass;
1212
use rustc_span::sym;
1313
use 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

Comments
 (0)