File tree 2 files changed +7
-8
lines changed
2 files changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -2528,13 +2528,15 @@ pub const fn bswap<T: Copy>(_x: T) -> T;
2528
2528
#[ rustc_intrinsic]
2529
2529
pub const fn bitreverse < T : Copy > ( _x : T ) -> T ;
2530
2530
2531
- /// Does a three-way comparison between the two integer arguments.
2531
+ /// Does a three-way comparison between the two arguments,
2532
+ /// which must be of character or integer (signed or unsigned) type.
2532
2533
///
2533
- /// This is included as an intrinsic as it's useful to let it be one thing
2534
- /// in MIR, rather than the multiple checks and switches that make its IR
2535
- /// large and difficult to optimize.
2534
+ /// This was originally added because it greatly simplified the MIR in `cmp`
2535
+ /// implementations, and then LLVM 20 added a backend intrinsic for it too.
2536
2536
///
2537
2537
/// The stabilized version of this intrinsic is [`Ord::cmp`].
2538
+ #[ rustc_intrinsic_const_stable_indirect]
2539
+ #[ rustc_nounwind]
2538
2540
#[ rustc_intrinsic]
2539
2541
pub const fn three_way_compare < T : Copy > ( _lhs : T , _rhss : T ) -> crate :: cmp:: Ordering ;
2540
2542
Original file line number Diff line number Diff line change @@ -3571,10 +3571,7 @@ macro_rules! int_impl {
3571
3571
// so delegate it to `Ord` which is already producing -1/0/+1
3572
3572
// exactly like we need and can be the place to deal with the complexity.
3573
3573
3574
- // FIXME(const-hack): replace with cmp
3575
- if self < 0 { -1 }
3576
- else if self == 0 { 0 }
3577
- else { 1 }
3574
+ crate :: intrinsics:: three_way_compare( self , 0 ) as Self
3578
3575
}
3579
3576
3580
3577
/// Returns `true` if `self` is positive and `false` if the number is zero or
You can’t perform that action at this time.
0 commit comments