Skip to content

Commit c02baba

Browse files
committed
redundant_pattern_matching fix inverted boolean when missing Drop trait # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # Date: Fri Apr 2 19:04:45 2021 -0400 # # On branch redundant_pattern_matching # Your branch is ahead of 'origin/redundant_pattern_matching' by 1 commit. # (use "git push" to publish your local commits) # # Changes to be committed: # modified: clippy_lints/src/matches.rs # # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # Date: Fri Apr 2 19:04:45 2021 -0400 # # interactive rebase in progress; onto ebc6469 # Last commands done (6 commands done): # pick 25d211a Code cleanup and additional std types checked # r 0c71ce5 redundant_pattern_matching fix inverted boolean when missing Drop trait # No commands remaining. # You are currently editing a commit while rebasing branch 'redundant_pattern_matching' on 'ebc64690d'. # # Changes to be committed: # modified: clippy_lints/src/matches.rs #
1 parent b658163 commit c02baba

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

clippy_lints/src/matches.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1733,15 +1733,17 @@ mod redundant_pattern_match {
17331733
}
17341734
}
17351735

1736-
// Check if the drop order for a type matters
1736+
/// Checks if the drop order for a type matters. Some std types implement drop solely to
1737+
/// deallocate memory. For these types, and composites containing them, changing the drop order
1738+
/// won't result in any observable side effects.
17371739
fn type_needs_ordered_drop(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
17381740
if !ty.needs_drop(cx.tcx, cx.param_env) {
17391741
false
1740-
} else if cx
1742+
} else if !cx
17411743
.tcx
17421744
.lang_items()
17431745
.drop_trait()
1744-
.map_or(false, |id| !implements_trait(cx, ty, id, &[]))
1746+
.map_or(false, |id| implements_trait(cx, ty, id, &[]))
17451747
{
17461748
// This type doesn't implement drop, so no side effects here.
17471749
// Check if any component type has any.

0 commit comments

Comments
 (0)