diff options
| author | bendn <bend.n@outlook.com> | 2024-03-21 05:48:16 +0700 |
|---|---|---|
| committer | bendn <bend.n@outlook.com> | 2024-03-21 05:48:16 +0700 |
| commit | a356785065cd31d1501f533393f4b2bdbd04075e (patch) | |
| tree | c0c8b34ba7ccdcf1616c736db8f587b678b73cb8 | |
| parent | 22f57ff5842fde8acf78ea59528c149b0046b5fb (diff) | |
| download | rust-a356785065cd31d1501f533393f4b2bdbd04075e.tar.gz rust-a356785065cd31d1501f533393f4b2bdbd04075e.zip | |
reasoning
| -rw-r--r-- | clippy_lints/src/needless_for_each.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/clippy_lints/src/needless_for_each.rs b/clippy_lints/src/needless_for_each.rs index fda15f469f4..3fe3d50197d 100644 --- a/clippy_lints/src/needless_for_each.rs +++ b/clippy_lints/src/needless_for_each.rs @@ -68,7 +68,8 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessForEach { // e.g. `v.iter().for_each(f)` is simpler and clearer than using `for` loop. && let ExprKind::Closure(&Closure { body, .. }) = for_each_arg.kind && let body = cx.tcx.hir().body(body) - // Skip the lint if the body is not safe. + // Skip the lint if the body is not safe, so as not to suggest `for … in … unsafe {}` + // and suggesting `for … in … { unsafe { } }` is a little ugly. && let ExprKind::Block(Block { rules: BlockCheckMode::DefaultBlock, .. }, ..) = body.value.kind { let mut ret_collector = RetCollector::default(); |
