about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2022-06-09 09:38:30 +1000
committerNicholas Nethercote <n.nethercote@gmail.com>2022-06-16 10:52:58 +1000
commit3ab6ef19386c8df6d43bd474f356d2bc38942350 (patch)
tree994eec61e2df77d97fdd91673452e4cb48c04d62
parentfab85ddbebcd99867344f05b610dc74709abbe6d (diff)
downloadrust-3ab6ef19386c8df6d43bd474f356d2bc38942350.tar.gz
rust-3ab6ef19386c8df6d43bd474f356d2bc38942350.zip
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.
-rw-r--r--compiler/rustc_mir_build/src/thir/pattern/mod.rs6
1 files 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
 }