Skip to content

Commit 45d7fd2

Browse files
committed
Just use as in Ordering::as_raw
Now that it doesn't bloat the MIR
1 parent 93981be commit 45d7fd2

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

library/core/src/cmp.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ impl Ordering {
400400
#[inline]
401401
const fn as_raw(self) -> i8 {
402402
// FIXME(const-hack): just use `PartialOrd` against `Equal` once that's const
403-
crate::intrinsics::discriminant_value(&self)
403+
self as i8
404404
}
405405

406406
/// Returns `true` if the ordering is the `Equal` variant.

tests/mir-opt/pre-codegen/derived_ord.demo_le.PreCodegen.after.mir

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ fn demo_le(_1: &MultiField, _2: &MultiField) -> bool {
7979
bb3: {
8080
_12 = move ((_11 as Some).0: std::cmp::Ordering);
8181
StorageLive(_13);
82-
_13 = discriminant(_12);
82+
_13 = copy _12 as i8 (Transmute);
8383
_0 = Le(move _13, const 0_i8);
8484
StorageDead(_13);
8585
StorageDead(_11);

tests/mir-opt/pre-codegen/derived_ord.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub fn demo_le(a: &MultiField, b: &MultiField) -> bool {
2424
// CHECK: [[B1:_[0-9]+]] = copy ((*_2).1: i16);
2525
// CHECK: Cmp(move [[A1]], move [[B1]]);
2626

27-
// CHECK: [[D1:_[0-9]+]] = discriminant({{.+}});
27+
// CHECK: [[D1:_[0-9]+]] = copy {{.+}} as i8 (Transmute);
2828
// CHECK: _0 = Le(move [[D1]], const 0_i8);
2929
*a <= *b
3030
}

0 commit comments

Comments
 (0)