diff options
| author | bors <bors@rust-lang.org> | 2021-04-16 03:05:52 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-04-16 03:05:52 +0000 |
| commit | faa97568a0ed3804339bec3becc2dda54ccdcafc (patch) | |
| tree | bb593f00da40c4fc612d13eefa068ec2376357f3 /clippy_lints/src | |
| parent | 586a99348c6a6f5309e82b340193067b7d76e37c (diff) | |
| parent | 779d98f6ccbd76807e811a134bb00a4e0d92c6db (diff) | |
| download | rust-faa97568a0ed3804339bec3becc2dda54ccdcafc.tar.gz rust-faa97568a0ed3804339bec3becc2dda54ccdcafc.zip | |
Auto merge of #7085 - Jarcho:manual_map_autoderef, r=giraffate
Don't allow adjustments for `manual_map` fixes: #7077 The other option here would be to add the return type to the closure. It would be fine for simple types, but longer types can be rather unwieldy. Could also implement the adjustment manually. changelog: Don't lint `manual_map` when type adjustments are added. e.g. autoderef
Diffstat (limited to 'clippy_lints/src')
| -rw-r--r-- | clippy_lints/src/manual_map.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/clippy_lints/src/manual_map.rs b/clippy_lints/src/manual_map.rs index 29be0739977..f16ed4104fe 100644 --- a/clippy_lints/src/manual_map.rs +++ b/clippy_lints/src/manual_map.rs @@ -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; } |
