Open
Description
Feature gate: #![feature(unbounded_shifts)]
This is a tracking issue for ACP 428.
This adds shifts functions to the integer types that ignore type bounds when shifting, with out of range values for the rhs
yielding the result of shifting the entire value out (0
for left shifts, and unsigned right shifts, and either 0
or -1
for signed right shifts).
Public API
impl uN{
pub const fn unbounded_shl(self, rhs: u32) -> Self;
pub const fn unbounded_shr(self, rhs: u32) -> Self;
}
impl iN{
pub const fn unbounded_shl(self, rhs: u32) -> Self;
pub const fn unbounded_shr(self, rhs: u32) -> Self;
}
Steps / History
- Implementation: Add implementations for
unbounded_shl
/unbounded_shr
#129377Final comment period (FCP)1Stabilization PR Stabilizeunbounded_shifts
#137393
Unresolved Questions
- None yet.
Footnotes
Metadata
Metadata
Assignees
Labels
Category: An issue tracking the progress of sth. like the implementation of an RFCRelevant to the library API team, which will review and decide on the PR/issue.This issue / PR is in PFCP or FCP with a disposition to merge it.The final comment period is finished for this PR / Issue.Announce this issue on triage meeting
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
unbounded_shl
/unbounded_shr
#129377Rollup merge of rust-lang#129377 - chorman0773:unbounded-shifts-impl,…
Unrolled build for rust-lang#129377
joshtriplett commentedon Nov 12, 2024
This seems ready to stabilize.
@rfcbot merge
rfcbot commentedon Nov 12, 2024
Team member @joshtriplett has proposed to merge this. The next step is review by the rest of the tagged team members:
No concerns currently listed.
Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!
See this document for info about what commands tagged team members can give me.
chorman0773 commentedon Nov 12, 2024
I was going to do a stabilization report.
Just to be clear, my intention was to stabilize it both as a function and as a
const fn
in one shot, so team should keep that in mind during the pFCP.chorman0773 commentedon Dec 5, 2024
Stabilization Report
(Retroactive to pFCP)
Implementation History
unbounded_shl
/unbounded_shr
#129377Api Summary
unbounded_shl
andunbounded_shr
shiftsself
left or right byrhs
as though with unbounded range. Ifrhs
exceeds the bounds of the type, the result is:unbounded_shl
,0
alwaysunbounded_shr
,0
for unsigned integers and either0
or-1
(depending on the sign bit)Experience Report
The Clever-ISA Project Emulator uses the nightly version of these functions to implement same-named functions in a primitive type wrapper. The wrapper functions (particularily
unbounded_shr
) are then used throughout the emulator to compute a number of different bitmasks.scottmcm commentedon Jan 7, 2025
Big fan of stabilizing a canonical way to write "shift that actually works" 👍
(These are the only shifts where shifting by one N times is the same as shifting by N one time.)
rfcbot commentedon Feb 11, 2025
🔔 This is now entering its final comment period, as per the review above. 🔔
13 remaining items