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

Move numeric consts to associated consts #67913

Closed

Conversation

faern
Copy link
Contributor

@faern faern commented Jan 6, 2020

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 be i8::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.

@rust-highfive
Copy link
Collaborator

The job mingw-check of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2020-01-06T02:03:24.4607448Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-01-06T02:03:24.4622791Z ##[command]git config gc.auto 0
2020-01-06T02:03:24.4626152Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-01-06T02:03:24.4630145Z ##[command]git config --get-all http.proxy
2020-01-06T02:03:24.4634281Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/67913/merge:refs/remotes/pull/67913/merge
---
2020-01-06T02:08:48.6928914Z     Checking panic_abort v0.0.0 (/checkout/src/libpanic_abort)
2020-01-06T02:08:48.8669309Z     Checking backtrace v0.3.40
2020-01-06T02:08:50.5482540Z     Checking rustc-std-workspace-alloc v1.99.0 (/checkout/src/tools/rustc-std-workspace-alloc)
2020-01-06T02:08:50.5491731Z     Checking panic_unwind v0.0.0 (/checkout/src/libpanic_unwind)
2020-01-06T02:08:53.5541214Z error: use of item 'core::num::<impl u64>::max_value' that will be deprecated in future version 1.42.0: replaced by associated constant MAX
2020-01-06T02:08:53.5542380Z   --> src/libstd/../stdarch/crates/std_detect/src/detect/cache.rs:84:30
2020-01-06T02:08:53.5542826Z    |
2020-01-06T02:08:53.5543306Z 84 |         Cache(AtomicU64::new(u64::max_value()))
2020-01-06T02:08:53.5544139Z    |
2020-01-06T02:08:53.5544605Z    = note: `-D deprecated-in-future` implied by `-D warnings`
2020-01-06T02:08:53.5545371Z 
2020-01-06T02:08:53.5545371Z 
2020-01-06T02:08:53.5554291Z error: use of item 'core::num::<impl u64>::max_value' that will be deprecated in future version 1.42.0: replaced by associated constant MAX
2020-01-06T02:08:53.5554680Z   --> src/libstd/../stdarch/crates/std_detect/src/detect/cache.rs:89:43
2020-01-06T02:08:53.5554911Z    |
2020-01-06T02:08:53.5555228Z 89 |         self.0.load(Ordering::Relaxed) == u64::max_value()
2020-01-06T02:08:53.5555596Z 
2020-01-06T02:08:53.9143896Z error: aborting due to 2 previous errors
2020-01-06T02:08:53.9144057Z 
2020-01-06T02:08:53.9295575Z error: could not compile `std`.
---
2020-01-06T02:08:53.9404136Z   local time: Mon Jan  6 02:08:53 UTC 2020
2020-01-06T02:08:54.2062867Z   network time: Mon, 06 Jan 2020 02:08:54 GMT
2020-01-06T02:08:54.2068846Z == end clock drift check ==
2020-01-06T02:09:02.6859683Z 
2020-01-06T02:09:02.6971067Z ##[error]Bash exited with code '1'.
2020-01-06T02:09:02.7112246Z ##[section]Starting: Checkout
2020-01-06T02:09:02.7114445Z ==============================================================================
2020-01-06T02:09:02.7114519Z Task         : Get sources
2020-01-06T02:09:02.7114883Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

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 @TimNN. (Feature Requests)

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;
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@faern faern force-pushed the move-numeric-consts-to-associated-consts branch from 4f0cc1f to 0db6468 Compare January 6, 2020 03:23
@rust-highfive
Copy link
Collaborator

The job mingw-check of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2020-01-06T03:24:03.1667517Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-01-06T03:24:03.1875482Z ##[command]git config gc.auto 0
2020-01-06T03:24:03.1943480Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-01-06T03:24:03.8139997Z ##[command]git config --get-all http.proxy
2020-01-06T03:24:03.8146279Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/67913/merge:refs/remotes/pull/67913/merge
---
2020-01-06T03:28:54.1628439Z Checking rustdoc artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-01-06T03:28:54.1651572Z Checking std artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-01-06T03:28:54.5665318Z    Compiling cc v1.0.47
2020-01-06T03:28:54.5665798Z     Checking core v0.0.0 (/checkout/src/libcore)
2020-01-06T03:28:58.4819600Z error: use of item 'f64::MIN_POSITIVE' that will be deprecated in future version 1.42.0: replaced by associated constant
2020-01-06T03:28:58.4820390Z   --> src/libcore/num/f64.rs:46:31
2020-01-06T03:28:58.4821693Z 46 | pub const MIN_POSITIVE: f64 = MIN_POSITIVE;
2020-01-06T03:28:58.4822016Z    |                               ^^^^^^^^^^^^
2020-01-06T03:28:58.4822299Z    |
2020-01-06T03:28:58.4822589Z    = note: `-D deprecated-in-future` implied by `-D warnings`
---
2020-01-06T03:29:06.1926803Z   local time: Mon Jan  6 03:29:06 UTC 2020
2020-01-06T03:29:06.4759611Z   network time: Mon, 06 Jan 2020 03:29:06 GMT
2020-01-06T03:29:06.4789330Z == end clock drift check ==
2020-01-06T03:29:22.3255543Z 
2020-01-06T03:29:22.3373155Z ##[error]Bash exited with code '1'.
2020-01-06T03:29:22.3403560Z ##[section]Starting: Checkout
2020-01-06T03:29:22.3405711Z ==============================================================================
2020-01-06T03:29:22.3405788Z Task         : Get sources
2020-01-06T03:29:22.3405838Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

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 @TimNN. (Feature Requests)

src/libstd/collections/hash/map.rs Outdated Show resolved Hide resolved
src/libstd/io/cursor.rs Outdated Show resolved Hide resolved
src/libstd/sys/unix/condvar.rs Outdated Show resolved Hide resolved
src/libstd/sys/vxworks/condvar.rs Outdated Show resolved Hide resolved
@bors
Copy link
Contributor

bors commented Jan 6, 2020

☔ The latest upstream changes (presumably #67917) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jan 6, 2020
@faern faern force-pushed the move-numeric-consts-to-associated-consts branch from 405f01f to ab389e5 Compare January 6, 2020 15:37
@rust-highfive
Copy link
Collaborator

The job mingw-check of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2020-01-06T15:38:12.6757910Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-01-06T15:38:12.6778529Z ##[command]git config gc.auto 0
2020-01-06T15:38:12.6783351Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-01-06T15:38:12.6785657Z ##[command]git config --get-all http.proxy
2020-01-06T15:38:12.6789806Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/67913/merge:refs/remotes/pull/67913/merge
---
2020-01-06T15:43:46.5096968Z     Checking panic_abort v0.0.0 (/checkout/src/libpanic_abort)
2020-01-06T15:43:46.6337466Z     Checking backtrace v0.3.40
2020-01-06T15:43:46.6786652Z     Checking rustc-std-workspace-alloc v1.99.0 (/checkout/src/tools/rustc-std-workspace-alloc)
2020-01-06T15:43:46.8492944Z     Checking panic_unwind v0.0.0 (/checkout/src/libpanic_unwind)
2020-01-06T15:43:49.8299530Z error: use of item 'core::num::<impl u64>::max_value' that will be deprecated in future version 1.42.0: replaced by associated constant MAX
2020-01-06T15:43:49.8300732Z   --> src/libstd/../stdarch/crates/std_detect/src/detect/cache.rs:84:30
2020-01-06T15:43:49.8301207Z    |
2020-01-06T15:43:49.8301729Z 84 |         Cache(AtomicU64::new(u64::max_value()))
2020-01-06T15:43:49.8302678Z    |
2020-01-06T15:43:49.8303218Z    = note: `-D deprecated-in-future` implied by `-D warnings`
2020-01-06T15:43:49.8303394Z 
2020-01-06T15:43:49.8303394Z 
2020-01-06T15:43:49.8309394Z error: use of item 'core::num::<impl u64>::max_value' that will be deprecated in future version 1.42.0: replaced by associated constant MAX
2020-01-06T15:43:49.8310013Z   --> src/libstd/../stdarch/crates/std_detect/src/detect/cache.rs:89:43
2020-01-06T15:43:49.8310440Z    |
2020-01-06T15:43:49.8310947Z 89 |         self.0.load(Ordering::Relaxed) == u64::max_value()
2020-01-06T15:43:49.8311620Z 
2020-01-06T15:43:50.1726861Z error: aborting due to 2 previous errors
2020-01-06T15:43:50.1726966Z 
2020-01-06T15:43:50.1850676Z error: could not compile `std`.
---
2020-01-06T15:43:50.1949876Z   local time: Mon Jan  6 15:43:50 UTC 2020
2020-01-06T15:43:50.4906769Z   network time: Mon, 06 Jan 2020 15:43:50 GMT
2020-01-06T15:43:50.4911299Z == end clock drift check ==
2020-01-06T15:43:58.7314620Z 
2020-01-06T15:43:58.7378907Z ##[error]Bash exited with code '1'.
2020-01-06T15:43:58.7406498Z ##[section]Starting: Checkout
2020-01-06T15:43:58.7408565Z ==============================================================================
2020-01-06T15:43:58.7408654Z Task         : Get sources
2020-01-06T15:43:58.7408701Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

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 @TimNN. (Feature Requests)

@bors
Copy link
Contributor

bors commented Jan 6, 2020

☔ The latest upstream changes (presumably #67886) made this pull request unmergeable. Please resolve the merge conflicts.

@JohnCSimon
Copy link
Member

Ping from triage:
@faern - Can you please address the merge conflicts and build failures? Thanks.

@faern
Copy link
Contributor Author

faern commented Jan 19, 2020

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

bors added a commit that referenced this pull request Jan 30, 2020
…-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.
@Dylan-DPC-zz
Copy link

@faern since you are splitting this PR into multiple ones, is it fine if we close this? Thanks

@faern
Copy link
Contributor Author

faern commented Feb 10, 2020

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

@Dylan-DPC-zz
Copy link

I think it is better idea to close it. Thanks

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Apr 3, 2020
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.
Centril added a commit to Centril/rust that referenced this pull request Apr 3, 2020
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants