-
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
Individualize feature gates for const fn invocation #43017
Conversation
r? @eddyb (rust_highfive has picked a reviewer for you, use r? to override) |
cc @rust-lang/lang |
WRT deprecations, we prefer to do those a release or two after. |
|
Fixed botched rebase. |
358d2d2
to
d0fc8fc
Compare
@rfcbot fcp merge |
Do we have a mechanism yet to make something deprecated in some future version? (In this case 1.22+, I think.) It’s bothersome if Nightly warns and says to use instead something that is not available in the Stable channel yet. |
#42859 adds |
Team member @withoutboats has proposed to merge this. The next step is review by the rest of the tagged teams: Concerns:
Once these reviewers reach consensus, 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! See this document for info about what commands tagged team members can give me. |
No, please don't deprecate during the same release as the replacement. Give it a while. |
This is a bit of a tangent, but I'd assume this applies to |
@rfcbot concern constness In discussion in the @rust-lang/lang meeting, the question was raised whether we want to have the ability to control whether to stabilize the "constness" of individual functions. So, for example, one might imagine making |
@rust-lang/lang was generally in favor of making this change, and stabilizing There was also some discussion about whether this automatically makes the constness of all const functions in the library immediately stable, which might not have been anticipated. There was discussion elsewhere about whether there might be future extensions of some such functions/traits that may be non-const. |
@joshtriplett |
As written, yes, it stabilizes the constness of const fns in core/std. It
seems rather useless to stabilize uses of const fn, but not declarations,
and then not declare any const fns :)
If we have to be hyper-conservative and start with just size_of/align_of, I
guess that's OK, but I'm also excited to get rid of tons of lazy_statics
which only exist in order to call Cell::new etc!
I'm not 100% sure how we would implement stabilizable-constness. One
approach that comes to mind is a build script for core and std that checks
which train we are compiling, and sets a cfg flag. But then for a user if
you *are* on nightly, there's no opt-in, you just get a const.
…On Thu, Jul 6, 2017 at 3:45 PM, Eduard-Mihai Burtescu < ***@***.***> wrote:
@joshtriplett <https://github.com/joshtriplett> std::mem is a mere
reexport of core::mem so yes, they are the same functions.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#43017 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAC3n9jAY5Oj_QqARZHnm7R08DiCciqWks5sLTllgaJpZM4OLrkp>
.
|
We could also just un-constify the rest of that list, breaking nightly users until we figure out which library functions can be const. Are there any specific concerns, though? |
I have no problem being more aggressive than such a minimal starting set, but it seems like it'd be useful to have the ability to add things later that we don't stabilize immediately. |
That said, perhaps un-constifying is indeed a viable alternative. |
All I can think of is adding a magic function attribute |
📌 Commit 332c38c has been approved by |
Individualize feature gates for const fn invocation This PR changes the meaning of `#![feature(const_fn)]` so it is only required to declare a const fn but not to call one. Based on discussion at #24111. I was hoping we could have an FCP here in order to move that conversation forward. This sets the stage for future stabilization of the constness of several functions in the standard library (listed below), so could someone please tag the lang team for review. - `std::cell` - `Cell::new` - `RefCell::new` - `UnsafeCell::new` - `std::mem` - `size_of` - `align_of` - `std::ptr` - `null` - `null_mut` - `std::sync` - `atomic` - `Atomic{Bool,Ptr,Isize,Usize}::new` - `once` - `Once::new` - primitives - `{integer}::min_value` - `{integer}::max_value` Some other functions are const but they are also unstable or hidden, e.g. `Unique::new` so they don't have to be considered at this time. After this stabilization, the following `*_INIT` constants in the standard library can be deprecated. I wasn't sure whether to include those deprecations in the current PR. - `std::sync` - `atomic` - `ATOMIC_{BOOL,ISIZE,USIZE}_INIT` - `once` - `ONCE_INIT`
☀️ Test successful - status-appveyor, status-travis |
Thanks for bearing with me @kennytm and @eddyb (and @bors). Next up,
figuring out which of these are actually uncontroversial to stabilize!
…On Sep 16, 2017 15:55, "bors" ***@***.***> wrote:
Merged #43017 <#43017>.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#43017 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAC3n6lgClFDCPpVSyAxgnNjIfGr1ev1ks5sjCepgaJpZM4OLrkp>
.
|
Upgrade to rustc 1.22.0-nightly (277476c4f 2017-09-16) rust-lang/rust#43017 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18541) <!-- Reviewable:end -->
Upgrade to rustc 1.22.0-nightly (277476c4f 2017-09-16) rust-lang/rust#43017 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18541) <!-- Reviewable:end -->
This seems to be required now, due to rust-lang/rust#43017
…-09-16) (from servo:rustup); r=SimonSapin rust-lang/rust#43017 Source-Repo: https://github.com/servo/servo Source-Revision: c28cf7490f2def7335c7c12e70e12e343eb1ec05 --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : 1e2b6d8c2339a47ed373f4a00dcea43348c04a99
…-09-16) (from servo:rustup); r=SimonSapin rust-lang/rust#43017 Source-Repo: https://github.com/servo/servo Source-Revision: c28cf7490f2def7335c7c12e70e12e343eb1ec05
…-09-16) (from servo:rustup); r=SimonSapin rust-lang/rust#43017 Source-Repo: https://github.com/servo/servo Source-Revision: c28cf7490f2def7335c7c12e70e12e343eb1ec05
@durka Did you ever open a bug to try to stabilize the uncontroversial const functions? It seemed from reading this that size_of and align_of, for example, are not controversial, yet I couldn't find a bug tracking their stabilization. |
I'll try to get that process started. I guess #24111 is still tracking all the const fns -- maybe that's too confusing. |
…-09-16) (from servo:rustup); r=SimonSapin rust-lang/rust#43017 Source-Repo: https://github.com/servo/servo Source-Revision: c28cf7490f2def7335c7c12e70e12e343eb1ec05 UltraBlame original commit: 14d7326af64d60a6be900427b468f94c7a2d2fda
…-09-16) (from servo:rustup); r=SimonSapin rust-lang/rust#43017 Source-Repo: https://github.com/servo/servo Source-Revision: c28cf7490f2def7335c7c12e70e12e343eb1ec05 UltraBlame original commit: 14d7326af64d60a6be900427b468f94c7a2d2fda
…-09-16) (from servo:rustup); r=SimonSapin rust-lang/rust#43017 Source-Repo: https://github.com/servo/servo Source-Revision: c28cf7490f2def7335c7c12e70e12e343eb1ec05 UltraBlame original commit: 14d7326af64d60a6be900427b468f94c7a2d2fda
This PR changes the meaning of
#![feature(const_fn)]
so it is only required to declare a const fn but not to call one. Based on discussion at #24111. I was hoping we could have an FCP here in order to move that conversation forward.This sets the stage for future stabilization of the constness of several functions in the standard library (listed below), so could someone please tag the lang team for review.
std::cell
Cell::new
RefCell::new
UnsafeCell::new
std::mem
size_of
align_of
std::ptr
null
null_mut
std::sync
atomic
Atomic{Bool,Ptr,Isize,Usize}::new
once
Once::new
{integer}::min_value
{integer}::max_value
Some other functions are const but they are also unstable or hidden, e.g.
Unique::new
so they don't have to be considered at this time.After this stabilization, the following
*_INIT
constants in the standard library can be deprecated. I wasn't sure whether to include those deprecations in the current PR.std::sync
atomic
ATOMIC_{BOOL,ISIZE,USIZE}_INIT
once
ONCE_INIT