We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
map_unit_fn
1 parent ddd7d10 commit a87443aCopy full SHA for a87443a
compiler/rustc_lint/src/map_unit_fn.rs
@@ -72,6 +72,22 @@ impl<'tcx> LateLintPass<'tcx> for MapUnitFn {
72
},
73
)
74
}
75
+ } else if let ty::Closure(id, subs) = arg_ty.kind() {
76
+ let cl_ty = subs.as_closure().sig();
77
+ let ret_ty = cl_ty.output().skip_binder();
78
+ if is_unit_type(ret_ty) {
79
+ cx.emit_spanned_lint(
80
+ MAP_UNIT_FN,
81
+ span,
82
+ MappingToUnit {
83
+ function_label: cx.tcx.span_of_impl(*id).unwrap(),
84
+ argument_label: args[0].span,
85
+ map_label: arg_ty.default_span(cx.tcx),
86
+ suggestion: path.ident.span,
87
+ replace: "for_each".to_string(),
88
+ },
89
+ )
90
+ }
91
92
93
0 commit comments