Skip to content

Commit 040c342

Browse files
committed
Cleanup: Simplify expression checking has side effects in it's drop impl
Remove Option<_> from the list of type being checked as it doesn't implement Drop Fix: Wrong default value if generic type can't be resolved in the aforementioned expression
1 parent f17cca6 commit 040c342

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

clippy_lints/src/matches.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,16 +1755,15 @@ mod redundant_pattern_match {
17551755
}
17561756

17571757
// Check for std types which implement drop, but only for memory allocation.
1758-
!((is_type_diagnostic_item(cx, ty, sym::vec_type)
1759-
&& !try_get_generic_ty(ty, 0).map_or(false, |ty| type_needs_ordered_drop(cx, ty)))
1760-
|| (is_type_lang_item(cx, ty, LangItem::OwnedBox)
1761-
&& !try_get_generic_ty(ty, 0).map_or(false, |ty| type_needs_ordered_drop(cx, ty)))
1762-
|| (is_type_diagnostic_item(cx, ty, sym::option_type)
1763-
&& !try_get_generic_ty(ty, 0).map_or(false, |ty| type_needs_ordered_drop(cx, ty)))
1764-
|| (is_type_diagnostic_item(cx, ty, sym::Rc)
1765-
&& !try_get_generic_ty(ty, 0).map_or(false, |ty| type_needs_ordered_drop(cx, ty)))
1766-
|| (is_type_diagnostic_item(cx, ty, sym::Arc)
1767-
&& !try_get_generic_ty(ty, 0).map_or(false, |ty| type_needs_ordered_drop(cx, ty))))
1758+
if is_type_diagnostic_item(cx, ty, sym::vec_type)
1759+
|| is_type_lang_item(cx, ty, LangItem::OwnedBox)
1760+
|| is_type_diagnostic_item(cx, ty, sym::Rc)
1761+
|| is_type_diagnostic_item(cx, ty, sym::Arc)
1762+
{
1763+
try_get_generic_ty(ty, 0).map_or(true, |ty| type_needs_ordered_drop(cx, ty))
1764+
} else {
1765+
true
1766+
}
17681767
}
17691768

17701769
// Extract the generic arguments out of a type

0 commit comments

Comments
 (0)