Skip to content

Commit eb6a20d

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 a53ade0 commit eb6a20d

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
@@ -1608,16 +1608,15 @@ mod redundant_pattern_match {
16081608
}
16091609

16101610
// Check for std types which implement drop, but only for memory allocation.
1611-
!((is_type_diagnostic_item(cx, ty, sym::vec_type)
1612-
&& !try_get_generic_ty(ty, 0).map_or(false, |ty| type_needs_ordered_drop(cx, ty)))
1613-
|| (is_type_lang_item(cx, ty, LangItem::OwnedBox)
1614-
&& !try_get_generic_ty(ty, 0).map_or(false, |ty| type_needs_ordered_drop(cx, ty)))
1615-
|| (is_type_diagnostic_item(cx, ty, sym::option_type)
1616-
&& !try_get_generic_ty(ty, 0).map_or(false, |ty| type_needs_ordered_drop(cx, ty)))
1617-
|| (is_type_diagnostic_item(cx, ty, sym::Rc)
1618-
&& !try_get_generic_ty(ty, 0).map_or(false, |ty| type_needs_ordered_drop(cx, ty)))
1619-
|| (is_type_diagnostic_item(cx, ty, sym::Arc)
1620-
&& !try_get_generic_ty(ty, 0).map_or(false, |ty| type_needs_ordered_drop(cx, ty))))
1611+
if is_type_diagnostic_item(cx, ty, sym::vec_type)
1612+
|| is_type_lang_item(cx, ty, LangItem::OwnedBox)
1613+
|| is_type_diagnostic_item(cx, ty, sym::Rc)
1614+
|| is_type_diagnostic_item(cx, ty, sym::Arc)
1615+
{
1616+
try_get_generic_ty(ty, 0).map_or(true, |ty| type_needs_ordered_drop(cx, ty))
1617+
} else {
1618+
true
1619+
}
16211620
}
16221621

16231622
// Extract the generic arguments out of a type

0 commit comments

Comments
 (0)