Skip to content

Add extra unchecked_disjoint_bitor implementations. - #147368

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
bjoernager:disjoint-bitor
Oct 24, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
bjoernager:disjoint-bitor

Conversation

@bjoernager

@bjoernager bjoernager commented Oct 5, 2025 •

Copy link
Copy Markdown
Contributor

View all comments

Tracking issue: #135758.

This PR implements the unchecked_disjoint_bitor method for additional types:

impl bool {
    pub const unsafe fn unchecked_disjoint_bitor(self, rhs: Self) -> Self;
}

impl i8 {
    pub const unsafe fn unchecked_disjoint_bitor(self, rhs: Self) -> Self;
}

impl i16 {
    pub const unsafe fn unchecked_disjoint_bitor(self, rhs: Self) -> Self;
}

impl i32 {
    pub const unsafe fn unchecked_disjoint_bitor(self, rhs: Self) -> Self;
}

impl i64 {
    pub const unsafe fn unchecked_disjoint_bitor(self, rhs: Self) -> Self;
}

impl i128 {
    pub const unsafe fn unchecked_disjoint_bitor(self, rhs: Self) -> Self;
}

impl isize {
    pub const unsafe fn unchecked_disjoint_bitor(self, rhs: Self) -> Self;
}

Our disjoint_bitor intrinsic is already implemented for these types. This method specifically is also already present on unsigned, integral types.

Additionally, this PR rewrites the existing docs for unchecked_disjoint_bitor and adds the must_use attribute to the method.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Oct 5, 2025
@rustbot

rustbot commented Oct 5, 2025

Copy link
Copy Markdown
Collaborator

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@bjoernager

Copy link
Copy Markdown
Contributor Author

@rustbot label +T-libs-api -T-libs

r? libs-api

@rustbot rustbot added T-libs-api [DEPRECATED; DO NOT USE] and removed T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Oct 5, 2025
@rustbot rustbot assigned BurntSushi and unassigned Mark-Simulacrum Oct 5, 2025
@rust-log-analyzer

This comment has been minimized.

@bjoernager

This comment was marked as outdated.

@bjoernager

Copy link
Copy Markdown
Contributor Author

r? libs-api

@rustbot rustbot assigned the8472 and unassigned BurntSushi Jan 5, 2026
@rust-bors

This comment has been minimized.

@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@tgross35 tgross35 left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable to me but should get a @rust-lang/libs-api okay.

@rustbot label +I-libs-api-nominated

r? tgross35

View changes since this review

Comment thread library/core/src/bool.rs Resolved
Comment thread library/core/src/num/uint_macros.rs Resolved
Comment thread library/core/src/num/uint_macros.rs Resolved
Comment thread library/core/src/num/uint_macros.rs Resolved
@rustbot rustbot added the I-libs-api-nominated [DEPRECATED; DO NOT USE] label May 27, 2026
@nia-e

nia-e commented Jun 2, 2026

Copy link
Copy Markdown
Member

We discussed this in today's libs-api meeting; we're happy to add these functions. Thanks!

@tgross35

tgross35 commented Jun 8, 2026

Copy link
Copy Markdown
Member

Just a couple of small remaining review comments

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 8, 2026
@rustbot

rustbot commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@clarfonthey clarfonthey removed the I-libs-api-nominated [DEPRECATED; DO NOT USE] label Jun 9, 2026
@rust-bors

This comment has been minimized.

@clarfonthey clarfonthey added T-libs Relevant to the library team, which will review and decide on the PR/issue. and removed T-libs-api [DEPRECATED; DO NOT USE] labels Aug 12, 2026
@tgross35

Copy link
Copy Markdown
Member

@bjoernager gentle ping since this is pretty close, just needs the few small things addressed

@rustbot

rustbot commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

…'i64', 'i128', and 'isize'; Update existing 'unchecked_disjoint_bitor' docs; Add 'must_use' to 'unchecked_disjoint_bitor';
@bjoernager

bjoernager commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor Author

@rustbot ready
:)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 23, 2026

@tgross35 tgross35 left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rust-bors

rust-bors Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

📌 Commit d42b8ca has been approved by tgross35

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 23, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 24, 2026
…uwer

Rollup of 5 pull requests

Successful merges:

 - #163766 (Outline constant messages from panicking macros)
 - #147368 (Add extra `unchecked_disjoint_bitor` implementations.)
 - #164748 (Use 64-bit futex syscalls on RV32 Linux)
 - #164520 (powerpc: implement c-variadic correctly for softfloat targets)
 - #164671 (add maintainers for tier 2 riscv64 targets (baremetal only))
@rust-bors
rust-bors Bot merged commit 8368dde into rust-lang:main Oct 24, 2026
14 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Oct 24, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 24, 2026
Rollup merge of #147368 - bjoernager:disjoint-bitor, r=tgross35

Add extra `unchecked_disjoint_bitor` implementations.

Tracking issue: #135758.

This PR implements the `unchecked_disjoint_bitor` method for additional types:

```rust
impl bool {
    pub const unsafe fn unchecked_disjoint_bitor(self, rhs: Self) -> Self;
}

impl i8 {
    pub const unsafe fn unchecked_disjoint_bitor(self, rhs: Self) -> Self;
}

impl i16 {
    pub const unsafe fn unchecked_disjoint_bitor(self, rhs: Self) -> Self;
}

impl i32 {
    pub const unsafe fn unchecked_disjoint_bitor(self, rhs: Self) -> Self;
}

impl i64 {
    pub const unsafe fn unchecked_disjoint_bitor(self, rhs: Self) -> Self;
}

impl i128 {
    pub const unsafe fn unchecked_disjoint_bitor(self, rhs: Self) -> Self;
}

impl isize {
    pub const unsafe fn unchecked_disjoint_bitor(self, rhs: Self) -> Self;
}
```

Our `disjoint_bitor` intrinsic is already implemented for these types. This method specifically is also already present on unsigned, integral types.

Additionally, this PR rewrites the existing docs for `unchecked_disjoint_bitor` and adds the `must_use` attribute to the method.
mehmettoplu-rs pushed a commit to mehmettoplu-rs/miri that referenced this pull request Oct 24, 2026
…uwer

Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#163766 (Outline constant messages from panicking macros)
 - rust-lang/rust#147368 (Add extra `unchecked_disjoint_bitor` implementations.)
 - rust-lang/rust#164748 (Use 64-bit futex syscalls on RV32 Linux)
 - rust-lang/rust#164520 (powerpc: implement c-variadic correctly for softfloat targets)
 - rust-lang/rust#164671 (add maintainers for tier 2 riscv64 targets (baremetal only))
Comment on lines -1742 to -1749
/// This is a situational micro-optimization for places where you'd rather
/// use addition on some platforms and bitwise or on other platforms, based
/// on exactly which instructions combine better with whatever else you're
/// doing. Note that there's no reason to bother using this for places
/// where it's clear from the operations involved that they can't overlap.
/// For example, if you're combining `u16`s into a `u32` with
/// `((a as u32) << 16) | (b as u32)`, that's fine, as the backend will
/// know those sides of the `|` are disjoint without needing help.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you delete this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.