about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src/interpret/operand.rs
diff options
context:
space:
mode:
authorScott McMurray <scottmcm@users.noreply.github.com>2023-03-05 20:19:41 -0800
committerScott McMurray <scottmcm@users.noreply.github.com>2024-03-23 23:23:41 -0700
commit3da115a93b782796e3d267266b4241e5258f1fef (patch)
treed96ec402b98579b285d21945727fcb35eb51a6f8 /compiler/rustc_const_eval/src/interpret/operand.rs
parent744c664ba2e6440024457d5ec0d3600b3e0c0144 (diff)
downloadrust-3da115a93b782796e3d267266b4241e5258f1fef.tar.gz
rust-3da115a93b782796e3d267266b4241e5258f1fef.zip
Add+Use `mir::BinOp::Cmp`
Diffstat (limited to 'compiler/rustc_const_eval/src/interpret/operand.rs')
-rw-r--r--compiler/rustc_const_eval/src/interpret/operand.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/operand.rs b/compiler/rustc_const_eval/src/interpret/operand.rs
index dbc6a317640..831787a92c8 100644
--- a/compiler/rustc_const_eval/src/interpret/operand.rs
+++ b/compiler/rustc_const_eval/src/interpret/operand.rs
@@ -236,6 +236,13 @@ impl<'tcx, Prov: Provenance> ImmTy<'tcx, Prov> {
     }
 
     #[inline]
+    pub fn from_ordering(c: std::cmp::Ordering, tcx: TyCtxt<'tcx>) -> Self {
+        let ty = tcx.ty_ordering_enum(None);
+        let layout = tcx.layout_of(ty::ParamEnv::reveal_all().and(ty)).unwrap();
+        Self::from_scalar(Scalar::from_i8(c as i8), layout)
+    }
+
+    #[inline]
     pub fn to_const_int(self) -> ConstInt {
         assert!(self.layout.ty.is_integral());
         let int = self.to_scalar().assert_int();