Skip to content

Commit 917fdb1

Browse files
committed
Rewrite comment when handling special case for ProjectionKind::Deref
1 parent c5ce7ff commit 917fdb1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

clippy_utils/src/sugg.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -937,10 +937,11 @@ impl<'tcx> Delegate<'tcx> for DerefDelegate<'_, 'tcx> {
937937
// note: unable to trigger `Subslice` kind in tests
938938
ProjectionKind::Subslice => (),
939939
ProjectionKind::Deref => {
940-
// explicit deref for arrays should be avoided in the suggestion
941-
// i.e.: `|sub| *sub[1..4].len() == 3` is not expected
940+
// Explicit derefs are typically handled later on, but
941+
// some items do not need explicit deref, such as array accesses,
942+
// so we mark them as already processed
943+
// i.e.: don't suggest `*sub[1..4].len()` for `|sub| sub[1..4].len() == 3`
942944
if let ty::Ref(_, inner, _) = cmt.place.ty_before_projection(i).kind() {
943-
// dereferencing an array (i.e.: `|sub| sub[1..4].len() == 3`)
944945
if matches!(inner.kind(), ty::Ref(_, innermost, _) if innermost.is_array()) {
945946
projections_handled = true;
946947
}

0 commit comments

Comments
 (0)