From 3ab6ef19386c8df6d43bd474f356d2bc38942350 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 9 Jun 2022 09:38:30 +1000 Subject: [PATCH] Remove `from_bool` closure. The code is clearer and simpler without it. Note that the `a == b` early return at the top of the function means the `a == b` test at the end of the function could never succeed. --- compiler/rustc_mir_build/src/thir/pattern/mod.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_mir_build/src/thir/pattern/mod.rs b/compiler/rustc_mir_build/src/thir/pattern/mod.rs index 30c86355c88..3e5e12d2286 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/mod.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/mod.rs @@ -757,10 +757,8 @@ pub(crate) fn compare_const_vals<'tcx>( assert_eq!(a.ty(), b.ty()); assert_eq!(a.ty(), ty); - let from_bool = |v: bool| v.then_some(Ordering::Equal); - if a == b { - return from_bool(true); + return Some(Ordering::Equal); } let a_bits = a.try_eval_bits(tcx, param_env, ty); @@ -790,5 +788,5 @@ pub(crate) fn compare_const_vals<'tcx>( }; } - from_bool(a == b) + None }