Skip to content

Commit b8a1e85

Browse files
committed
WIP: has_required_preds
1 parent ae9c2a4 commit b8a1e85

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
};
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_
@@ -127,7 +129,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPathNew<'tcx> {
127129
&& is_path_new(path_new)
128130
&& let ty::Param(arg_param_ty) = arg_ty.kind()
129131
&& !is_used_anywhere_else(arg_param_ty, sig.inputs())
130-
&& implements_asref_path(*arg_ty)
132+
&& has_required_preds(arg_param_ty /* , cx.tcx.predicates_of(arg_ty) */)
131133
{
132134
span_lint_and_sugg(
133135
cx,

0 commit comments

Comments
 (0)