Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use BinOp::Cmp for iNN::signum #137835

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

scottmcm
Copy link
Member

@scottmcm scottmcm commented Mar 1, 2025

This way it can use the nice new LLVM intrinsic in LLVM20.

@rustbot
Copy link
Collaborator

rustbot commented Mar 1, 2025

r? @ibraheemdev

rustbot has assigned @ibraheemdev.
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

@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 Mar 1, 2025
@rustbot
Copy link
Collaborator

rustbot commented Mar 1, 2025

Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter
gets adapted for the changes, if necessary.

cc @rust-lang/miri, @rust-lang/wg-const-eval

@@ -3242,6 +3242,8 @@ pub const fn bitreverse<T: Copy>(_x: T) -> T {
/// large and difficult to optimize.
///
/// The stabilized version of this intrinsic is [`Ord::cmp`].
#[rustc_intrinsic_const_stable_indirect]
Copy link
Member Author

Choose a reason for hiding this comment

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

@RalfJung, can you remind me which teams need to sign off on using this in const?

Copy link
Member

Choose a reason for hiding this comment

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

Usually lang.

Copy link
Member

Choose a reason for hiding this comment

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

In the interpreter, this operator is implemented for integers and characters. That matches what the validator does. Seems worth mentioning in the doc comment that char is supported.

Other than that, the implementation looks good and doesn't do anything odd, so seems fine to stabilize. Cc @rust-lang/wg-const-eval

Copy link

@rvolgers rvolgers left a comment

Choose a reason for hiding this comment

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

(drive by suggestion, not a reviewer)

This way it can use the nice new LLVM intrinsic in LLVM20.
@scottmcm scottmcm added T-lang Relevant to the language 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 Mar 1, 2025
@scottmcm
Copy link
Member Author

scottmcm commented Mar 1, 2025

Hello lang! I propose that we stabilize the indirect use of the three_way_compare intrinsic in const. This is the one already used in Ord::cmp for iN, uN, and char, but this would be the first stable use of it in const fn, since the trait impls are not yet const themselves.

This doesn't expose anything fundamentally new, since the comparison operators are const-stable on these types and thus open-coding this was already possible. Ralf says that it "seems fine" (#137835 (comment)).

(The PR uses it in the implementation of the stable iNN::signum method, which would be the first accessible use from stable. The intrinsic itself will, of course, remain unstable.)

@rfcbot fcp merge

@rfcbot
Copy link

rfcbot commented Mar 1, 2025

Team member @scottmcm 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!

cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns.
See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Mar 1, 2025
@traviscross
Copy link
Contributor

traviscross commented Mar 1, 2025

@rfcbot reviewed

Looks good to me.

@ibraheemdev ibraheemdev added S-waiting-on-fcp Status: PR is in FCP and is awaiting for FCP to complete. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 4, 2025
@scottmcm scottmcm added the I-lang-easy-decision Issue: The decision needed by the team is conjectured to be easy; this does not imply nomination label Mar 5, 2025
@tmandry
Copy link
Member

tmandry commented Mar 19, 2025

@rfcbot reviewed

Seems like there's no interesting surface area being stabilized.

@rfcbot rfcbot added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels Mar 19, 2025
@rfcbot
Copy link

rfcbot commented Mar 19, 2025

🔔 This is now entering its final comment period, as per the review above. 🔔

@scottmcm scottmcm removed the I-lang-easy-decision Issue: The decision needed by the team is conjectured to be easy; this does not imply nomination label Mar 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. S-waiting-on-fcp Status: PR is in FCP and is awaiting for FCP to complete. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants