diff options
| author | ThibsG <thibsg@pm.me> | 2021-11-27 20:32:23 +0100 |
|---|---|---|
| committer | ThibsG <thibsg@pm.me> | 2021-11-27 20:32:50 +0100 |
| commit | 917fdb11e45c5b2d0b43566d3736fc34ad917294 (patch) | |
| tree | 117d56c09834e8c5323db36f7d5e84374a5f654f | |
| parent | c5ce7ff6d94000bab267324db2aa11341265291e (diff) | |
Rewrite comment when handling special case for `ProjectionKind::Deref`
| -rw-r--r-- | clippy_utils/src/sugg.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/clippy_utils/src/sugg.rs b/clippy_utils/src/sugg.rs index 5dd49c1d26b..e1d0920590b 100644 --- a/clippy_utils/src/sugg.rs +++ b/clippy_utils/src/sugg.rs @@ -937,10 +937,11 @@ impl<'tcx> Delegate<'tcx> for DerefDelegate<'_, 'tcx> { // note: unable to trigger `Subslice` kind in tests ProjectionKind::Subslice => (), ProjectionKind::Deref => { - // explicit deref for arrays should be avoided in the suggestion - // i.e.: `|sub| *sub[1..4].len() == 3` is not expected + // Explicit derefs are typically handled later on, but + // some items do not need explicit deref, such as array accesses, + // so we mark them as already processed + // i.e.: don't suggest `*sub[1..4].len()` for `|sub| sub[1..4].len() == 3` if let ty::Ref(_, inner, _) = cmt.place.ty_before_projection(i).kind() { - // dereferencing an array (i.e.: `|sub| sub[1..4].len() == 3`) if matches!(inner.kind(), ty::Ref(_, innermost, _) if innermost.is_array()) { projections_handled = true; } |
