-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Make most std::ops traits const on numeric types #89876
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @m-ou-se (or someone else) soon. Please see the contribution instructions for more information. |
☔ The latest upstream changes (presumably #90067) made this pull request unmergeable. Please resolve the merge conflicts. |
Looks like someone's PR beat me to it (#90009). |
r? @oli-obk |
As discussed in the libs-api meeting today, @rust-lang/wg-const-eval may now approve unstably adding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The impl looks good! We can go ahead with all of these. Just needs those tests you talked about.
Starting tests now, are the files |
Yes.
We should not approve |
Ah yea, that is next on my list anyway, might have a PR up today |
☔ The latest upstream changes (presumably #90119) made this pull request unmergeable. Please resolve the merge conflicts. |
# Conflicts: # library/core/src/lib.rs
@bors r+ rollup |
📌 Commit 361c978 has been approved by |
I haven't completed the tests yet (mostly for a lack of time), are you sure it's OK to be merged without them? |
Make most std::ops traits const on numeric types This PR makes existing implementations of `std::ops` traits (`Add`, `Sub`, etc) [`impl const`](rust-lang#67792) where possible. This affects: - All numeric primitives (`u*`, `i*`, `f*`) - `NonZero*` - `Wrapping` This is under the `rustc_const_unstable` feature `const_ops`. I will write tests once I know what can and can't be kept for the final version of this PR. Since this is my first PR to rustc (and hopefully one of many), please give me feedback on how to better handle the PR process wherever possible. Thanks [Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Const.20std.3A.3Aops.20traits.20PR)
…askrgr Rollup of 8 pull requests Successful merges: - rust-lang#89876 (Make most std::ops traits const on numeric types) - rust-lang#90371 (Fix incorrect doc link) - rust-lang#90374 (Unify titles in rustdoc book doc attributes chapter) - rust-lang#90377 (Make `core::slice::from_raw_parts[_mut]` const) - rust-lang#90395 (Restrict liveness of mutable borrow of inner infcx in ConstInferUnifier::consts) - rust-lang#90396 (Prevent type flags assertions being thrown in default_anon_const_substs if errors occurred) - rust-lang#90402 (Add a few query descriptions) - rust-lang#90412 (Remove unnecessary `macro_use`s in rustdoc) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Could you open an issue to track adding those tests, maybe leaving some notes for what kinds of tests you think would be good to have? |
I'll put it on the tracking issue, I'm busy with exams right now but I should be able to set aside some time to implement the tests in a week or two. |
This seems to add |
Does this work? |
Ahh, I see the problem. I was using |
This PR makes existing implementations of
std::ops
traits (Add
,Sub
, etc)impl const
where possible.This affects:
u*
,i*
,f*
)NonZero*
Wrapping
This is under the
rustc_const_unstable
featureconst_ops
.I will write tests once I know what can and can't be kept for the final version of this PR.
Since this is my first PR to rustc (and hopefully one of many), please give me feedback on how to better handle the PR process wherever possible. Thanks
Zulip discussion