Emit map_unit_fn
lint in closure case
This commit is contained in:
parent
ddd7d10879
commit
a87443a859
@ -72,6 +72,22 @@ impl<'tcx> LateLintPass<'tcx> for MapUnitFn {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
} else if let ty::Closure(id, subs) = arg_ty.kind() {
|
||||||
|
let cl_ty = subs.as_closure().sig();
|
||||||
|
let ret_ty = cl_ty.output().skip_binder();
|
||||||
|
if is_unit_type(ret_ty) {
|
||||||
|
cx.emit_spanned_lint(
|
||||||
|
MAP_UNIT_FN,
|
||||||
|
span,
|
||||||
|
MappingToUnit {
|
||||||
|
function_label: cx.tcx.span_of_impl(*id).unwrap(),
|
||||||
|
argument_label: args[0].span,
|
||||||
|
map_label: arg_ty.default_span(cx.tcx),
|
||||||
|
suggestion: path.ident.span,
|
||||||
|
replace: "for_each".to_string(),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user