close
Skip to content

Add extra unchecked_disjoint_bitor implementations.#147368

Open
bjoernager wants to merge 1 commit into
rust-lang:mainfrom
bjoernager:disjoint-bitor
Open

Add extra unchecked_disjoint_bitor implementations.#147368
bjoernager wants to merge 1 commit into
rust-lang:mainfrom
bjoernager:disjoint-bitor

Conversation

@bjoernager
Copy link
Copy Markdown
Contributor

@bjoernager bjoernager commented Oct 5, 2025

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
Copy link
Copy Markdown
Collaborator

rustbot commented Oct 5, 2025

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 Relevant to the library API team, which will review and decide on the PR/issue. 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
Copy link
Copy Markdown
Collaborator

rustbot commented May 20, 2026

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.

@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.

Copy link
Copy Markdown
Contributor

@tgross35 tgross35 left a comment

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 Outdated
Comment thread library/core/src/num/uint_macros.rs Outdated
}

/// Same value as `self | other`, but UB if any bit position is set in both inputs.
/// Disjoint, bitwise or. Computes `self | rhs`, assuming no one bits in common.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"assuming no one bits in common" -> "assuming there are no one bits in common."

Or something like "Computes self | rhs given the precondition that no set bits of the inputs overlap."

/// `((a as u32) << 16) | (b as u32)`, that's fine, as the backend will
/// know those sides of the `|` are disjoint without needing help.
/// Practically, this requires that `self | rhs`, `self ^ rhs`, and `self + rhs` all
/// yield the same result, allowing for any of the three to be emitted in code gen
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: "code gen" -> either "codegen" or "code generation"

Copy link
Copy Markdown
Contributor Author

@bjoernager bjoernager May 28, 2026

Choose a reason for hiding this comment

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

What is wrong with "code gen" ? It's already used in the repo: https://github.com/search?q=repo%3Arust-lang%2Frust%20%22code%20gen%22&type=code.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Most of those hits are part of "code generation" https://github.com/search?q=repo%3Arust-lang%2Frust+%2Fcode+gen%5Cb%2F&type=code. Loosely I think "gen" is considered an abbreviation rather than a word that can stand on its own, but we do consider "codegen" to be one.

Also we have codegen-units, codegen-backend etc. rather than code-gen-units and code-gen-backend.

@rustbot rustbot added the I-libs-api-nominated Nominated for discussion during a libs-api team meeting. label May 27, 2026
…'i64', 'i128', and 'isize'; Update existing 'unchecked_disjoint_bitor' docs; Add 'must_use' to 'unchecked_disjoint_bitor';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

I-libs-api-nominated Nominated for discussion during a libs-api team meeting. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants