about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYusuke Tanaka <yusuktan@maguro.dev>2021-02-11 01:41:52 +0900
committerflip1995 <philipp.krones@embecosm.com>2021-03-02 10:40:25 +0100
commit8a8f7b4cf5c7642e72b0c0e40586a9310b1ca48b (patch)
tree4a20c78a64627328642ff7fe9121d4bf1ff0fe5b
parent89ef26a68131d846b07e339e277232ff8737be3e (diff)
downloadrust-8a8f7b4cf5c7642e72b0c0e40586a9310b1ca48b.tar.gz
rust-8a8f7b4cf5c7642e72b0c0e40586a9310b1ca48b.zip
Refactor calls to lint check functions
-rw-r--r--clippy_lints/src/transmute/mod.rs61
1 files changed, 16 insertions, 45 deletions
diff --git a/clippy_lints/src/transmute/mod.rs b/clippy_lints/src/transmute/mod.rs
index e16dfa87229..c1870f5208b 100644
--- a/clippy_lints/src/transmute/mod.rs
+++ b/clippy_lints/src/transmute/mod.rs
@@ -338,53 +338,24 @@ impl<'tcx> LateLintPass<'tcx> for Transmute {
                 let from_ty = cx.typeck_results().expr_ty(&args[0]);
                 let to_ty = cx.typeck_results().expr_ty(e);
 
-                let triggered = useless_transmute::check(cx, e, from_ty, to_ty, args);
-                if triggered {
+                // If useless_transmute is triggered, the other lints can be skipped.
+                if useless_transmute::check(cx, e, from_ty, to_ty, args) {
                     return;
                 }
-                let triggered = wrong_transmute::check(cx, e, from_ty, to_ty);
-                if triggered {
-                    return;
-                }
-                let triggered = crosspointer_transmute::check(cx, e, from_ty, to_ty);
-                if triggered {
-                    return;
-                }
-                let triggered = transmute_ptr_to_ref::check(cx, e, from_ty, to_ty, args, qpath);
-                if triggered {
-                    return;
-                }
-                let triggered = transmute_int_to_char::check(cx, e, from_ty, to_ty, args);
-                if triggered {
-                    return;
-                }
-                let triggered = transmute_ref_to_ref::check(cx, e, from_ty, to_ty, args, const_context);
-                if triggered {
-                    return;
-                }
-                let triggered = transmute_ptr_to_ptr::check(cx, e, from_ty, to_ty, args);
-                if triggered {
-                    return;
-                }
-                let triggered = transmute_int_to_bool::check(cx, e, from_ty, to_ty, args);
-                if triggered {
-                    return;
-                }
-                let triggered = transmute_int_to_float::check(cx, e, from_ty, to_ty, args, const_context);
-                if triggered {
-                    return;
-                }
-                let triggered = transmute_float_to_int::check(cx, e, from_ty, to_ty, args, const_context);
-                if triggered {
-                    return;
-                }
-                let triggered = unsound_collection_transmute::check(cx, e, from_ty, to_ty);
-                if triggered {
-                    return;
-                }
-                let triggered = transmutes_expressible_as_ptr_casts::check(cx, e, from_ty, to_ty, args);
-                if triggered {
-                    return;
+
+                let mut linted = wrong_transmute::check(cx, e, from_ty, to_ty);
+                linted |= crosspointer_transmute::check(cx, e, from_ty, to_ty);
+                linted |= transmute_ptr_to_ref::check(cx, e, from_ty, to_ty, args, qpath);
+                linted |= transmute_int_to_char::check(cx, e, from_ty, to_ty, args);
+                linted |= transmute_ref_to_ref::check(cx, e, from_ty, to_ty, args, const_context);
+                linted |= transmute_ptr_to_ptr::check(cx, e, from_ty, to_ty, args);
+                linted |= transmute_int_to_bool::check(cx, e, from_ty, to_ty, args);
+                linted |= transmute_int_to_float::check(cx, e, from_ty, to_ty, args, const_context);
+                linted |= transmute_float_to_int::check(cx, e, from_ty, to_ty, args, const_context);
+                linted |= unsound_collection_transmute::check(cx, e, from_ty, to_ty);
+
+                if !linted {
+                    transmutes_expressible_as_ptr_casts::check(cx, e, from_ty, to_ty, args);
                 }
             }
         }