diff options
| author | Jason Newcomb <jsnewcomb@pm.me> | 2021-04-02 19:04:45 -0400 |
|---|---|---|
| committer | Jason Newcomb <jsnewcomb@pm.me> | 2021-04-15 20:37:20 -0400 |
| commit | c02baba1dcd9847d07762f42412d10eed7cff3e9 (patch) | |
| tree | 67f1dcfdb65d9cf3d14f575bbf408feca3d194e7 | |
| parent | b6581636bd9cfb16337a9ffcecd1b38e68a6abce (diff) | |
| download | rust-c02baba1dcd9847d07762f42412d10eed7cff3e9.tar.gz rust-c02baba1dcd9847d07762f42412d10eed7cff3e9.zip | |
`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 ebc64690d
# Last commands done (6 commands done):
# pick 25d211ad8 Code cleanup and additional std types checked
# r 0c71ce56f `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
#
| -rw-r--r-- | clippy_lints/src/matches.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/clippy_lints/src/matches.rs b/clippy_lints/src/matches.rs index dc5232085ed..ddfc27e8460 100644 --- a/clippy_lints/src/matches.rs +++ b/clippy_lints/src/matches.rs @@ -1733,15 +1733,17 @@ mod redundant_pattern_match { } } - // Check if the drop order for a type matters + /// Checks if the drop order for a type matters. Some std types implement drop solely to + /// deallocate memory. For these types, and composites containing them, changing the drop order + /// won't result in any observable side effects. fn type_needs_ordered_drop(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool { if !ty.needs_drop(cx.tcx, cx.param_env) { false - } else if cx + } else if !cx .tcx .lang_items() .drop_trait() - .map_or(false, |id| !implements_trait(cx, ty, id, &[])) + .map_or(false, |id| implements_trait(cx, ty, id, &[])) { // This type doesn't implement drop, so no side effects here. // Check if any component type has any. |
