Don't allow adjustments for manual_map

This commit is contained in:
Jason Newcomb 2021-04-15 10:37:42 -04:00
parent b1c675f3fc
commit 779d98f6cc
No known key found for this signature in database
GPG key ID: DA59E8643A37ED06
3 changed files with 20 additions and 0 deletions

View file

@ -104,12 +104,18 @@ impl LateLintPass<'_> for ManualMap {
None => return,
};
// These two lints will go back and forth with each other.
if cx.typeck_results().expr_ty(some_expr) == cx.tcx.types.unit
&& !is_allowed(cx, OPTION_MAP_UNIT_FN, expr.hir_id)
{
return;
}
// `map` won't perform any adjustments.
if !cx.typeck_results().expr_adjustments(some_expr).is_empty() {
return;
}
if !can_move_expr_to_closure(cx, some_expr) {
return;
}