about summary refs log tree commit diff
diff options
context:
space:
mode:
authortabokie <xy.tao@outlook.com>2022-08-02 11:37:44 +0800
committertabokie <xy.tao@outlook.com>2022-08-02 17:56:20 +0800
commit9ab6146afea0119afb1a06afef5fbed5a3efe422 (patch)
treed50e7723dd56ad579c901dbd81e706f797b319c6
parenta5a6c95da813ce81d9d4c83d2632379284e0fc06 (diff)
downloadrust-9ab6146afea0119afb1a06afef5fbed5a3efe422.tar.gz
rust-9ab6146afea0119afb1a06afef5fbed5a3efe422.zip
simplify unit type check
Signed-off-by: tabokie <xy.tao@outlook.com>
-rw-r--r--clippy_lints/src/map_unit_fn.rs6
1 files changed, 1 insertions, 5 deletions
diff --git a/clippy_lints/src/map_unit_fn.rs b/clippy_lints/src/map_unit_fn.rs
index af9d948af00..6db852c3ffe 100644
--- a/clippy_lints/src/map_unit_fn.rs
+++ b/clippy_lints/src/map_unit_fn.rs
@@ -97,11 +97,7 @@ declare_clippy_lint! {
 declare_lint_pass!(MapUnit => [OPTION_MAP_UNIT_FN, RESULT_MAP_UNIT_FN]);
 
 fn is_unit_type(ty: Ty<'_>) -> bool {
-    match ty.kind() {
-        ty::Tuple(slice) => slice.is_empty(),
-        ty::Never => true,
-        _ => false,
-    }
+    ty.is_unit() || ty.is_never()
 }
 
 fn is_unit_function(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> bool {