Skip to content

Commit a356785

Browse files
committed
reasoning
1 parent 22f57ff commit a356785

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

clippy_lints/src/needless_for_each.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessForEach {
6868
// e.g. `v.iter().for_each(f)` is simpler and clearer than using `for` loop.
6969
&& let ExprKind::Closure(&Closure { body, .. }) = for_each_arg.kind
7070
&& let body = cx.tcx.hir().body(body)
71-
// Skip the lint if the body is not safe.
71+
// Skip the lint if the body is not safe, so as not to suggest `for … in … unsafe {}`
72+
// and suggesting `for … in … { unsafe { } }` is a little ugly.
7273
&& let ExprKind::Block(Block { rules: BlockCheckMode::DefaultBlock, .. }, ..) = body.value.kind
7374
{
7475
let mut ret_collector = RetCollector::default();

0 commit comments

Comments
 (0)