-
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
Move numeric consts to associated consts #67913
Move numeric consts to associated consts #67913
Conversation
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
pub const MIN: f32 = -3.40282347e+38_f32; | ||
/// Smallest positive normal `f32` value. | ||
#[stable(feature = "assoc_int_consts", since = "1.42.0")] | ||
pub const MIN_POSITIVE: f32 = 1.17549435e-38_f32; |
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 non-associated constants should use the definition from the associated ones to have one source of truth.
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.
Done
4f0cc1f
to
0db6468
Compare
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
☔ The latest upstream changes (presumably #67917) made this pull request unmergeable. Please resolve the merge conflicts. |
Co-Authored-By: lzutao <[email protected]>
Co-Authored-By: lzutao <[email protected]>
Co-Authored-By: lzutao <[email protected]>
405f01f
to
ab389e5
Compare
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
☔ The latest upstream changes (presumably #67886) made this pull request unmergeable. Please resolve the merge conflicts. |
Ping from triage: |
@JohnCSimon I was under the impression that we did not want to merge all the deprecation and everything in one go. But rather first introduce the new constants only and deprecate them later. See discussion in rust-lang/rfcs#2700 and heavily reduced PR at #68325. That PR has a lot less risk of experiencing bit rot, since it does not touch so much of the standard library/compiler. |
…-step1, r=LukasKalbertodt Move numeric consts to associated consts step1 A subset of #67913. Implements the first step of RFC rust-lang/rfcs#2700 This PR adds the new constants as unstable constants and defines the old ones in terms of the new ones. Then fix a tiny bit of code that started having naming collisions because of the new assoc consts. Removed a test that did not seem relevant any longer. Since doing just `u8::MIN` should now indeed be valid.
@faern since you are splitting this PR into multiple ones, is it fine if we close this? Thanks |
My intention was to use this PR to update the entire repo to use the new constants (a subset of what this PR currently does) after they have been stabilized (hopefully soon). But if you prefer me to open a new PR for that instead of keeping this one open you are free to close it. |
I think it is better idea to close it. Thanks |
Use associated numeric consts in documentation Now when the associated constants on int/float types are stabilized and the recommended way of accessing said constants (rust-lang#68952). We can start using it in this repository, and recommend it via documentation example code. This PR is the reincarnation of rust-lang#67913 minus the actual adding + stabilization of said constants. (EDIT: Now it's only changing the documentation. So users will see the new consts, but we don't yet update the internal code) Because of how fast bit rot happens to PRs that touch this many files, it does not try to replace 100% of the old usage of the constants in the entire repo, but a good chunk of them.
Use associated numeric consts in documentation Now when the associated constants on int/float types are stabilized and the recommended way of accessing said constants (rust-lang#68952). We can start using it in this repository, and recommend it via documentation example code. This PR is the reincarnation of rust-lang#67913 minus the actual adding + stabilization of said constants. (EDIT: Now it's only changing the documentation. So users will see the new consts, but we don't yet update the internal code) Because of how fast bit rot happens to PRs that touch this many files, it does not try to replace 100% of the old usage of the constants in the entire repo, but a good chunk of them.
Implements RFC rust-lang/rfcs#2700 (which at the time of writing this is not yet merged).
Since the RFC has
disposition-merge
and the discussion does not voice any opinions against it, I don't have any reason to believe it won't be merged. And I felt that showing the code needed to do this would give the RFC a push again.One thing that is not yet implemented is where the compiler prints
std::i8::MIN
and similar in error/help messages. These now need to bei8::MIN
instead, but I don't know where the compiler get this name from.It still also does not do the required changes to the
src/stdarch
submodule. I did not want to get in too deep before this has been discussed/accepted.