reasoning
This commit is contained in:
parent
22f57ff584
commit
a356785065
1 changed files with 2 additions and 1 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue