Skip to content

Commit

Permalink
Rewrite comment when handling special case for ProjectionKind::Deref
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibsG committed Nov 27, 2021
1 parent c5ce7ff commit 917fdb1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions clippy_utils/src/sugg.rs
Expand Up @@ -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;
}
Expand Down

0 comments on commit 917fdb1

Please sign in to comment.