Skip to content

Commit ec5b5f2

Browse files
committed
fix path.ident.name does not point to the name of the function applied
1 parent 0e7fef7 commit ec5b5f2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

clippy_lints/src/unnecessary_map_on_constructor.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,13 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryMapOnConstructor {
7373
}
7474

7575
if let Some(map_arg) = args.get(0)
76-
&& let hir::ExprKind::Path(_) = map_arg.kind
76+
&& let hir::ExprKind::Path(fun) = map_arg.kind
7777
{
7878
if map_arg.span.from_expansion() {
7979
return;
8080
}
8181
let mut applicability = Applicability::MachineApplicable;
82+
let fun_snippet = snippet_with_applicability(cx, fun.span(), "_", &mut applicability);
8283
let constructor_snippet =
8384
snippet_with_applicability(cx, constructor_path.span(), "_", &mut applicability);
8485
let constructor_arg_snippet =
@@ -87,9 +88,9 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryMapOnConstructor {
8788
cx,
8889
UNNECESSARY_MAP_ON_CONSTRUCTOR,
8990
expr.span,
90-
&format!("unnecessary {} on contstuctor {constructor_snippet}(_)", path.ident.name),
91+
&format!("unnecessary {fun_snippet} on contstuctor {constructor_snippet}(_)"),
9192
"try",
92-
format!("{constructor_snippet}({}({constructor_arg_snippet}))", path.ident.name),
93+
format!("{constructor_snippet}({fun_snippet}({constructor_arg_snippet}))"),
9394
applicability,
9495
);
9596
}

0 commit comments

Comments
 (0)