-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Tracking issue for RFC 2700: numeric constants as associated consts #68490
Comments
This comment has been minimized.
This comment has been minimized.
I have implemented the stabilization and documentation changes needed to show people which constant is the preferred one now. I will submit this as a PR in a few days when the unstable version has been out for a bit over a week. You can find the code here: https://github.com/rust-lang/rust/compare/master...faern:stabilize-assoc-int-consts?expand=1 What parts of it I don't think will be controversial at all:
Other changes that possibly might create some discussion:
I opted for doing what //! **this module is soft-deprecated.**
//!
//! Although using these constants won’t cause compilation warnings,
//! new code should use the associated constants directly on
//! the [`i128` primitive type](../../std/primitive.i128.html) instead. I added soft deprecation notices to:
|
The code/docs were changed a bit after I wrote that last comment just above. But the stabilization PR is live now. |
Stabilize assoc_int_consts associated int/float constants The next step in RFC rust-lang/rfcs#2700 (tracking issue #68490). Stabilizing the associated constants that were added in #68325. * Stabilize all constants under the `assoc_int_consts` feature flag. * Update documentation on old constants to say they are soft-deprecated and the new ones should be preferred. * Update documentation examples to use new constants. * Remove `uint_macro` and use `int_macro` for all integer types since the macros were identical anyway. r? @LukasKalbertodt
One thing that remains is to improve the compiler error that mentions the fn main() {
match 5i32 {
5 => (),
}
} It gives the following error:
Now when the associated constants are the preferred ones the error should be
|
…, r=dtolnay Migrate to numeric associated consts The deprecation PR is rust-lang#72885 cc rust-lang#68490 cc rust-lang/rfcs#2700
…, r=dtolnay Migrate to numeric associated consts The deprecation PR is rust-lang#72885 cc rust-lang#68490 cc rust-lang/rfcs#2700
…, r=dtolnay Migrate to numeric associated consts The deprecation PR is rust-lang#72885 cc rust-lang#68490 cc rust-lang/rfcs#2700
Prefer the associated constants for pattern matching error Resolved this comment: rust-lang#68490 (comment)
…, r=dtolnay Migrate to numeric associated consts The deprecation PR is rust-lang#72885 cc rust-lang#68490 cc rust-lang/rfcs#2700
As the original author of RFC 2700, I propose the following resolution to the two currently-listed unresolved questions:
|
if I can't just write |
Unsure if that was meant to be sarcasm, but if you take the time to read the original RFC you will see that the point of all this is that |
I was not being sarcastic at all. If floating types don't get the same design fixes applied them, then that's dumb for all the reasons that |
You're preaching to the choir; as mentioned in the accepted RFC, the original RFC text had proposed this treatment for all the float constants. I'd be happy if the libs team decided to deprecate the float shadow modules as well, but in the absence of that decision there's no need to put off deprecating the integral shadow modules any longer. This RFC has gone on for quite long already. |
(It's also worth noting that your specific example of |
In my deprecation PR I ran into some obstacles and have updated the issue here with references to new issues and PRs. I'll hold off on proposing deprecation until those are addressed. |
Part of rust-lang#68490. Care has been taken to leave the old consts where appropriate, for testing backcompat regressions, module shadowing, etc. The intrinsics docs were accidentally referring to some methods on f64 as std::f64, which I changed due to being contrary with how we normally disambiguate the shadow module from the primitive. In one other place I changed std::u8 to std::ops since it was just testing path handling in macros. For places which have legitimate uses of the old consts, deprecated attributes have been optimistically inserted. Although currently unnecessary, they exist to emphasize to any future deprecation effort the necessity of these specific symbols and prevent them from being accidentally removed.
… r=jyn514 Update tests to remove old numeric constants Part of rust-lang#68490. Care has been taken to leave the old consts where appropriate, for testing backcompat regressions, module shadowing, etc. The intrinsics docs were accidentally referring to some methods on f64 as std::f64, which I changed due to being contrary with how we normally disambiguate the shadow module from the primitive. In one other place I changed std::u8 to std::ops since it was just testing path handling in macros. For places which have legitimate uses of the old consts, deprecated attributes have been optimistically inserted. Although currently unnecessary, they exist to emphasize to any future deprecation effort the necessity of these specific symbols and prevent them from being accidentally removed.
Part of rust-lang#68490. Care has been taken to leave the old consts where appropriate, for testing backcompat regressions, module shadowing, etc. The intrinsics docs were accidentally referring to some methods on f64 as std::f64, which I changed due to being contrary with how we normally disambiguate the shadow module from the primitive. In one other place I changed std::u8 to std::ops since it was just testing path handling in macros. For places which have legitimate uses of the old consts, deprecated attributes have been optimistically inserted. Although currently unnecessary, they exist to emphasize to any future deprecation effort the necessity of these specific symbols and prevent them from being accidentally removed.
…=jyn514 Update tests to remove old numeric constants Part of rust-lang#68490. Care has been taken to leave the old consts where appropriate, for testing backcompat regressions, module shadowing, etc. The intrinsics docs were accidentally referring to some methods on f64 as std::f64, which I changed due to being contrary with how we normally disambiguate the shadow module from the primitive. In one other place I changed std::u8 to std::ops since it was just testing path handling in macros. For places which have legitimate uses of the old consts, deprecated attributes have been optimistically inserted. Although currently unnecessary, they exist to emphasize to any future deprecation effort the necessity of these specific symbols and prevent them from being accidentally removed.
Part of rust-lang#68490. Care has been taken to leave the old consts where appropriate, for testing backcompat regressions, module shadowing, etc. The intrinsics docs were accidentally referring to some methods on f64 as std::f64, which I changed due to being contrary with how we normally disambiguate the shadow module from the primitive. In one other place I changed std::u8 to std::ops since it was just testing path handling in macros. For places which have legitimate uses of the old consts, deprecated attributes have been optimistically inserted. Although currently unnecessary, they exist to emphasize to any future deprecation effort the necessity of these specific symbols and prevent them from being accidentally removed.
We discussed the open questions in the library meeting last week. Our conclusions were:
Yes.
No. At least not as part of this tracking issue/RFC. That could be a separate proposal, with a separate discussion. |
Checking off "adjust the documentation" (found no uses of the old consts in the reference, the book, or Rust By Example, which I presume faern fixed when originally adjusting the stdlib docs). In addition #79877 has landed, which finishes checking off all the new issues that were filed after the closing of the prior deprecation effort (#78335). Once #79877 rides the train into beta later this month I'll file a new deprecation PR. And once that's all done I'll write up a new RFC to discuss the fate of the floating-point |
Deprecate-in-future the constants superceded by RFC 2700 Successor to rust-lang#78335, re-opened after addressing the issues tracked in rust-lang#68490. This PR makes use of the new ability to explicitly annotate an item as triggering the deprecated-in-future lint (via `rustc_deprecated(since="TBD"`, see rust-lang#78381). We might call this *soft deprecation*; unlike with deprecation, users will *not* receive warnings when compiling code that uses these items *unless* they opt-in via `#[warn(deprecated_in_future)]`. Like deprecation, soft deprecation causes documentation to formally acknowledge that an item is marked for eventual deprecation (at a non-specific point in the future). With this new ability, we can sidestep all debate about when or on what timeframe something ought to be deprecated; as long as we can agree that something ought to be deprecated, we can receive much of the benefits of deprecation with none of the drawbacks. For these items specifically, the libs team has already agreed that they should be deprecated (see rust-lang#68490 (comment)).
Deprecate-in-future the constants superceded by RFC 2700 Successor to rust-lang#78335, re-opened after addressing the issues tracked in rust-lang#68490. This PR makes use of the new ability to explicitly annotate an item as triggering the deprecated-in-future lint (via `rustc_deprecated(since="TBD"`, see rust-lang#78381). We might call this *soft deprecation*; unlike with deprecation, users will *not* receive warnings when compiling code that uses these items *unless* they opt-in via `#[warn(deprecated_in_future)]`. Like deprecation, soft deprecation causes documentation to formally acknowledge that an item is marked for eventual deprecation (at a non-specific point in the future). With this new ability, we can sidestep all debate about when or on what timeframe something ought to be deprecated; as long as we can agree that something ought to be deprecated, we can receive much of the benefits of deprecation with none of the drawbacks. For these items specifically, the libs team has already agreed that they should be deprecated (see rust-lang#68490 (comment)).
Deprecate-in-future the constants superceded by RFC 2700 Successor to rust-lang#78335, re-opened after addressing the issues tracked in rust-lang#68490. This PR makes use of the new ability to explicitly annotate an item as triggering the deprecated-in-future lint (via `rustc_deprecated(since="TBD"`, see rust-lang#78381). We might call this *soft deprecation*; unlike with deprecation, users will *not* receive warnings when compiling code that uses these items *unless* they opt-in via `#[warn(deprecated_in_future)]`. Like deprecation, soft deprecation causes documentation to formally acknowledge that an item is marked for eventual deprecation (at a non-specific point in the future). With this new ability, we can sidestep all debate about when or on what timeframe something ought to be deprecated; as long as we can agree that something ought to be deprecated, we can receive much of the benefits of deprecation with none of the drawbacks. For these items specifically, the libs team has already agreed that they should be deprecated (see rust-lang#68490 (comment)).
With the merge of #80958 , I'm happy with where this is at. I will leave this issue open until such time as the old items are marked as fully deprecated rather than just deprecated-in-future, but making that change is not a priority of mine at this moment. |
RE from #107587
Can we move them into a module like
Then we could fully deprecate |
Putting it here because I haven't see much discussion elsewhere. small previous discussion It appears that the |
I don't think creating yet another copy of the constants is the right direction. Since the old ones can't be removed, only deprecated, the API surface will inevitably grow. I'm all for moving constants to better places when the new place is actually better. Here it feels like they are equally bad/good but just duplicated for the sake of deprecation. Personally I always wanted to move the float constants onto the actual float types as well. But I know this was controversial back in RFC 2700. I know there was some talk about being able to put modules in types, so one could have
I'm all for deprecating that as well, but not in this RFC/issue. This issue seems to be controversial as is and moves way too slowly. Anything that can just have this be merged asap would be great. Then further similar work can happen in other RFCs. If we let RFCs scope creep it will greatly slow down their progress. |
You can kind of emulate a module in this case by using |
This is a tracking issue for the RFC 2700 (rust-lang/rfcs#2700): "Deprecate stdlib modules dedicated to numeric constants and move those constants to associated consts".
Steps:
deprecated_in_future
lint to specify an indeterminate future deprecation date #78381)Unresolved questions:
std::{f32, f64}::consts
also be made associated consts? From the alternative question of the RFC:The text was updated successfully, but these errors were encountered: