From 3da115a93b782796e3d267266b4241e5258f1fef Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Sun, 5 Mar 2023 20:19:41 -0800 Subject: Add+Use `mir::BinOp::Cmp` --- compiler/rustc_const_eval/src/interpret/operand.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'compiler/rustc_const_eval/src/interpret/operand.rs') 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 @@ -235,6 +235,13 @@ impl<'tcx, Prov: Provenance> ImmTy<'tcx, Prov> { Self::from_scalar(Scalar::from_bool(b), layout) } + #[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()); -- cgit 1.4.1-3-g733a5