Skip to content

Commit 5ab943c

Browse files
committed
prevent items from macro expansions triggering lint
1 parent 36bf6ba commit 5ab943c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

clippy_lints/src/unnecessary_map_on_constructor.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryMapOnConstructor {
4848
&& let hir::ExprKind::Path(constructor_path) = constructor.kind
4949
&& let Some(arg) = constructor_args.get(0)
5050
{
51+
if constructor.span.from_expansion() || arg.span.from_expansion() {
52+
return;
53+
}
5154
(constructor_path, arg)
5255
} else {
5356
return;
@@ -69,9 +72,12 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryMapOnConstructor {
6972
_ => return,
7073
}
7174

72-
if let Some(arg) = args.get(0)
73-
&& let hir::ExprKind::Path(fun) = arg.kind
75+
if let Some(map_arg) = args.get(0)
76+
&& let hir::ExprKind::Path(fun) = map_arg.kind
7477
{
78+
if map_arg.span.from_expansion() {
79+
return;
80+
}
7581
let mut applicability = Applicability::MachineApplicable;
7682
let constructor_snippet =
7783
snippet_with_applicability(cx, constructor_path.span(), "_", &mut applicability);

0 commit comments

Comments
 (0)