Skip to content

Commit 95682e5

Browse files
committed
core: Rename funnel shift rhs parameter to right
`rhs` is confusing since for the `Shl` and `Shr` traits, that is the name used for the value to shift by (i.e. `self >> rhs`).
1 parent bcf3d36 commit 95682e5

2 files changed

Lines changed: 17 additions & 17 deletions

File tree

library/core/src/intrinsics/fallback.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,11 @@ impl_disjoint_bitor! {
151151
pub const trait FunnelShift: Copy + 'static {
152152
/// See [`super::unchecked_funnel_shl`]; we just need the trait indirection to handle
153153
/// different types since calling intrinsics with generics doesn't work.
154-
unsafe fn unchecked_funnel_shl(self, rhs: Self, shift: u32) -> Self;
154+
unsafe fn unchecked_funnel_shl(self, right: Self, shift: u32) -> Self;
155155

156156
/// See [`super::unchecked_funnel_shr`]; we just need the trait indirection to handle
157157
/// different types since calling intrinsics with generics doesn't work.
158-
unsafe fn unchecked_funnel_shr(self, rhs: Self, shift: u32) -> Self;
158+
unsafe fn unchecked_funnel_shr(self, right: Self, shift: u32) -> Self;
159159
}
160160

161161
macro_rules! impl_funnel_shifts {
@@ -164,7 +164,7 @@ macro_rules! impl_funnel_shifts {
164164
impl const FunnelShift for $type {
165165
#[cfg_attr(miri, track_caller)]
166166
#[inline]
167-
unsafe fn unchecked_funnel_shl(self, rhs: Self, shift: u32) -> Self {
167+
unsafe fn unchecked_funnel_shl(self, right: Self, shift: u32) -> Self {
168168
// This implementation is also used by Miri so we have to check the precondition.
169169
// SAFETY: this is guaranteed by the caller
170170
unsafe { super::assume(shift < $type::BITS) };
@@ -181,20 +181,20 @@ macro_rules! impl_funnel_shifts {
181181
unsafe {
182182
super::disjoint_bitor(
183183
super::unchecked_shl(self, shift),
184-
super::unchecked_shr(rhs, $type::BITS - shift),
184+
super::unchecked_shr(right, $type::BITS - shift),
185185
)
186186
}
187187
}
188188
}
189189

190190
#[cfg_attr(miri, track_caller)]
191191
#[inline]
192-
unsafe fn unchecked_funnel_shr(self, rhs: Self, shift: u32) -> Self {
192+
unsafe fn unchecked_funnel_shr(self, right: Self, shift: u32) -> Self {
193193
// This implementation is also used by Miri so we have to check the precondition.
194194
// SAFETY: this is guaranteed by the caller
195195
unsafe { super::assume(shift < $type::BITS) };
196196
if shift == 0 {
197-
rhs
197+
right
198198
} else {
199199
// SAFETY:
200200
// - `shift < T::BITS`, which satisfies `unchecked_shr`
@@ -206,7 +206,7 @@ macro_rules! impl_funnel_shifts {
206206
unsafe {
207207
super::disjoint_bitor(
208208
super::unchecked_shl(self, $type::BITS - shift),
209-
super::unchecked_shr(rhs, shift),
209+
super::unchecked_shr(right, shift),
210210
)
211211
}
212212
}

library/core/src/num/uint_macros.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -415,9 +415,9 @@ macro_rules! uint_impl {
415415
return intrinsics::rotate_right(self, n);
416416
}
417417

418-
/// Performs a left funnel shift (concatenates `self` with `rhs`, with `self`
419-
/// making up the most significant half, then shifts the combined value left
420-
/// by `n`, and most significant half is extracted to produce the result).
418+
/// Performs a left funnel shift (concatenates `self` with `low`, with `self`
419+
/// making up the high half, then shifts the combined value left
420+
/// by `n`, and the high half is extracted to produce the result).
421421
///
422422
/// Please note this isn't the same operation as the `<<` shifting operator or
423423
/// [`rotate_left`](Self::rotate_left), although `a.funnel_shl(a, n)` is *equivalent*
@@ -444,15 +444,15 @@ macro_rules! uint_impl {
444444
#[must_use = "this returns the result of the operation, \
445445
without modifying the original"]
446446
#[inline(always)]
447-
pub const fn funnel_shl(self, rhs: Self, n: u32) -> Self {
447+
pub const fn funnel_shl(self, right: Self, n: u32) -> Self {
448448
assert!(n < Self::BITS, "attempt to funnel shift left with overflow");
449449
// SAFETY: just checked that `shift` is in-range
450-
unsafe { intrinsics::unchecked_funnel_shl(self, rhs, n) }
450+
unsafe { intrinsics::unchecked_funnel_shl(self, right, n) }
451451
}
452452

453-
/// Performs a right funnel shift (concatenates `self` and `rhs`, with `self`
454-
/// making up the most significant half, then shifts the combined value right
455-
/// by `n`, and least significant half is extracted to produce the result).
453+
/// Performs a right funnel shift (concatenates `self` and `right`, with `self`
454+
/// making up the high half, then shifts the combined value right
455+
/// by `n`, and the low half is extracted to produce the result).
456456
///
457457
/// Please note this isn't the same operation as the `>>` shifting operator or
458458
/// [`rotate_right`](Self::rotate_right), although `a.funnel_shr(a, n)` is *equivalent*
@@ -479,10 +479,10 @@ macro_rules! uint_impl {
479479
#[must_use = "this returns the result of the operation, \
480480
without modifying the original"]
481481
#[inline(always)]
482-
pub const fn funnel_shr(self, rhs: Self, n: u32) -> Self {
482+
pub const fn funnel_shr(self, right: Self, n: u32) -> Self {
483483
assert!(n < Self::BITS, "attempt to funnel shift right with overflow");
484484
// SAFETY: just checked that `shift` is in-range
485-
unsafe { intrinsics::unchecked_funnel_shr(self, rhs, n) }
485+
unsafe { intrinsics::unchecked_funnel_shr(self, right, n) }
486486
}
487487

488488
/// Performs a carry-less multiplication, returning the lower bits.

0 commit comments

Comments
 (0)