Skip to content

Commit e4782f7

Browse files
committed
expect there to be a single arg
1 parent cdbcdd1 commit e4782f7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

clippy_lints/src/needless_path_new.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,10 @@ fn check_arguments<'tcx>(
9292
dbg!(bounds);
9393

9494
for (argument, parameter) in iter::zip(arguments, parameters) {
95-
if let ExprKind::Call(func, args) = argument.kind
95+
// we want `argument` to be `Path::new(x)`, which has one arg, x
96+
if let ExprKind::Call(func, [arg]) = argument.kind
9697
&& is_path_new(func)
97-
&& implements_asref_path(cx.typeck_results().expr_ty(&args[0]))
98+
&& implements_asref_path(cx.typeck_results().expr_ty(arg))
9899
&& implements_asref_path(*parameter)
99100
{
100101
span_lint_and_sugg(
@@ -103,7 +104,7 @@ fn check_arguments<'tcx>(
103104
argument.span,
104105
"the expression enclosed in `Path::new` implements `AsRef<Path>`",
105106
"remove the enclosing `Path::new`",
106-
format!("{}", snippet(cx, args[0].span, "..")),
107+
format!("{}", snippet(cx, arg.span, "..")),
107108
Applicability::MachineApplicable,
108109
);
109110
}

0 commit comments

Comments
 (0)