Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upconst fn tracking issue (RFC 911) #24111
Comments
steveklabnik
added
B-RFC
B-RFC-approved
and removed
B-RFC
labels
Apr 6, 2015
This comment has been minimized.
This comment has been minimized.
|
Is this closed by #25609? |
This comment has been minimized.
This comment has been minimized.
|
@Munksgaard That just adds support to the compiler AFAIK. There's a lot of functions in the stdlib that need to be changed to |
bluss
referenced this issue
Jul 28, 2015
Closed
rustdoc: `const fn` not displayed for reexported docs #27362
This comment has been minimized.
This comment has been minimized.
|
I'm hoping this to be implemented on |
alexcrichton
added
the
T-lang
label
Aug 11, 2015
This comment was marked as off-topic.
This comment was marked as off-topic.
rohel01
commented
Aug 14, 2015
|
EDIT: Removed since it was out of subject |
This comment has been minimized.
This comment has been minimized.
|
To be clear, the question here is not primarily about the usefulness of the feature but rather regarding the best way to formulate it (or the best framework to formulate it in). See the RFC discussion. |
Manishearth
referenced this issue
Sep 19, 2015
Merged
Don't recommend const fns on a stable build without a note about nightlies #28507
added a commit
to Manishearth/rust
that referenced
this issue
Sep 20, 2015
aturon
added
B-unstable
and removed
B-RFC-approved
labels
Nov 5, 2015
This comment has been minimized.
This comment has been minimized.
|
This is now the tracking issue for eventual stabilization. |
This comment has been minimized.
This comment has been minimized.
briansmith
commented
Jan 12, 2016
|
#29107 has been closed. I disagree that "Integration with patterns", or any changes to the standard library should block this. This is very useful even without those changes, and those changes can be done later. In particular, I would like to start using Accordingly, could the stabilization status of this be re-evaluated? |
This comment has been minimized.
This comment has been minimized.
|
I don't doubt that (Given that the semantics of safe Rust code should be fully definable, it seems likely that eventually at least every function which doesn't (transitively) depend on |
This comment has been minimized.
This comment has been minimized.
What I would personally like, even more than that, is that we have a fairly clear view on how we're going to implement it, and what portion of the language we are going to cover. That said, this is very closely related to support for associated constants or generics over integers in my mind. @eddyb and I did some sketching recently on a scheme which could enable constant evaluation of a very broad swath of code. Basically lowering all constants to MIR and intrepreting it (in some cases, However, while it seems like it would be fairly easy to support a very large fraction of the "builtin language", real code in practice hits up against the need to do memory allocation very quickly. In other words, you want to use That said, @glaebhoerl, I'd also love to hear you articulate your preferred alternative endgame. I think you sketched out some such thoughts in the |
This comment has been minimized.
This comment has been minimized.
|
The problem with allocation is having it escape into run-time. Alternatively, we could generate runtime code to allocate and fill in the values every time that barrier has to be passed, although I'm not sure what kind of usecases that has. Keep in mind that even with full-fledged |
This comment has been minimized.
This comment has been minimized.
|
@nikomatsakis If I had one I would have mentioned it. :) I mainly just see known unknowns. The whole thing with Of the main use cases for the Rust language, the ones that primarily need low-level control, like kernels, seem reasonably well-served already, but another area where Rust could have lots of potential is things that primarily need high performance, and in that space powerful support (in some form) for staged computation (which As for what would be inspiring and good enough... I haven't seen it yet, and I'm not familiar enough with the whole space to know, precisely, where to look. Of course, per the above, we might want to at least glance at Julia and Terra, even if they seem like quite different languages from Rust in many ways. I know Oleg Kiselyov has done a lot of interesting work in this area. Tiark Rompf's work on Lancet and Lightweight Modular Staging for Scala seems definitely worth looking at. I recall seeing a presentation by @kmcallister at some point about what a dependently typed Rust might look like (which might at least be more general than sticking (This was just a braindump and I've almost surely imperfectly characterized many things.) |
This comment has been minimized.
This comment has been minimized.
briansmith
commented
Jan 16, 2016
I disagree with that characterization of "real code in practice". I think there is big interest in Rust because it helps reduce the need for heap memory allocation. My code, in particular, makes a concrete effort to avoid heap allocation whenever possible. Being able to do more than that would be nice but being able to construct static instances of non-trivial types with compiler-enforced invariants is essential. The C++ |
This comment has been minimized.
This comment has been minimized.
|
@briansmith FWIW another approach which has a chance of solving the same use cases would be if macros had privacy hygiene, which I believe (hope) we're planning to make them have. |
This comment has been minimized.
This comment has been minimized.
briansmith
commented
Jan 16, 2016
I guess if you use the procedural macros then you can evaluate |
This comment has been minimized.
This comment has been minimized.
|
@glaebhoerl I wouldn't hold my breath for strict hygiene, it's quite possible we're going to have an escape mechanism (just like real LISPs), so you may not want it for any kind of safety purposes. |
This comment has been minimized.
This comment has been minimized.
|
@glaebhoerl there is also https://anydsl.github.io/, which even uses On Sat, Jan 16, 2016 at 6:29 PM, Eduard-Mihai Burtescu <
|
This comment has been minimized.
This comment has been minimized.
|
#29525 should be fixed before stabilization |
This comment has been minimized.
This comment has been minimized.
Just a thought: if we ever formally define Rust's memory model, then even I'm not sure where that leaves us with respect to So you'd still have |
This comment has been minimized.
This comment has been minimized.
@glaebhoerl Well, that is pretty much the model I described and which @tsion's miri is implementing. I think the FFI distinction is very important because of purity, which is required for coherence. I don't like the Just like |
This comment has been minimized.
This comment has been minimized.
aledomu
commented
Dec 31, 2018
|
@remexre There's another middle point that I haven't seen discussed about and it's the possibility to introduce an opposite of this marker and some sort of "function purity inference" when it's not explicitly set. Then the docs would show the actual marker but with some sort of warning about not guaranteeing the stability of that marker if it's a |
This comment has been minimized.
This comment has been minimized.
SoniEx2
commented
Dec 31, 2018
|
should a const fn be able to produce output? why should |
This comment has been minimized.
This comment has been minimized.
|
@aledomu My comment was directed at @AGaussman; I'm talking about the case where a library author exposes a function that's not "meant to be" const (in that the const-ness is not intended to be part of the API); if const were to be inferred, it would be a breaking change to make said function non-const. |
This comment has been minimized.
This comment has been minimized.
aledomu
commented
Dec 31, 2018
|
@SoniEx2 `const fn` is a function that can be evaluated at compile time, which happens to be the case only of any pure function.
@remexre If it's not meant to be a stable part of the API, just don't mark it.
For the inference bit I commented, that's why I mentioned the need for some warning on the crate docs.
|
This comment has been minimized.
This comment has been minimized.
SoniEx2
commented
Dec 31, 2018
•
|
what's the difference? absolutely none! const fn add_1(x: &mut i32) { x += 1; }
let mut x = 0;
add_1(&mut x);
assert_eq!(x, 1);
x = 0;
add_1(&mut x);
assert_eq!(x, 1);
const fn added_1(x: i32) -> i32 { x + 1 }
let mut x = 0;
x = added_1(x);
assert_eq!(x, 1);
x = 0;
x = added_1(x);
assert_eq!(x, 1); |
This comment has been minimized.
This comment has been minimized.
|
I've filed targeted issues for: The following targeted issues already exist:
If there are other areas, not already tracked by other issues, that need to be discussed wrt. const eval and This concludes the usefulness of this issue, which is hereby closed. |
Centril
closed this
Dec 31, 2018
Centril
added
A-const-fn
A-const-eval
labels
Dec 31, 2018
This comment has been minimized.
This comment has been minimized.
|
I don’t have all the specifics in mind, but isn’t there a lot more that’s suppported by miri but not enabled yet in |
This comment has been minimized.
This comment has been minimized.
|
@SimonSapin Yeah, good catch. There are some more existing issues for that. I've updated the comment + issue description. If there's something not covered that you happen upon, make new issues please. |
This comment has been minimized.
This comment has been minimized.
|
I think it’s not appropriate to close a meta tracking issue when it’s not at all clear that what it covers is exhaustively covered by more specific issues. When I remove
(These However, neither traits nor function pointer types are mentioned in this issue’s description. I don’t mean we should have just two more specific issues for the above. I mean we should reopen this one until we somehow ensure that everything behind the |
This comment has been minimized.
This comment has been minimized.
This issue has the flavor of #34511 which is one of the biggest messes there are as far as tracking issues go. This issue has also been a free-for-all for some time so it doesn't act as a meta-issue right now. For such free-for-alls, please use http://internals.rust-lang.org/ instead.
That's exactly what I think should be done. From a T-Lang triage perspective, it is favorable to have targeted and actionable issues.
It's not even clear to me what |
This comment has been minimized.
This comment has been minimized.
That’s exactly why we shouldn’t close it until we figure that out, IMO.
Is it really everything, though? |
This comment has been minimized.
This comment has been minimized.
|
Related: #57261 |
This comment has been minimized.
This comment has been minimized.
|
Does someone know what happened to the |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
The issue should be open then. It's just insulting as a user to be pointed
to a closed issue.
…On Wed, Jan 9, 2019, 04:05 Mazdak Farrokhzad ***@***.*** wrote:
@phansch <https://github.com/phansch> That's because all
rustc_const_unstable point here.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#24111 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAC3n7JhzsZZpizmWlp0Nww5bcfIqH2Vks5vBbC8gaJpZM4D66IA>
.
|
This comment has been minimized.
This comment has been minimized.
ErichDonGubler
commented
Jan 9, 2019
|
@durka: There's always going to be a possible window where something is closed in nightly and the resolution still hasn't landed in stable. How is that insulting? |
This comment has been minimized.
This comment has been minimized.
nixpulvis
commented
Jan 9, 2019
•
|
I've been resisting commenting here, and maybe we should move this conversation to a thread on internals (is there one already?) but... The decision to close this makes no sense to me. It's a tracking issue, because it shows up in error messages from the compiler, and it's not alone, see this post for some more examples: https://internals.rust-lang.org/t/psa-tracking-for-gated-language-features/2887. Closing this issue to me implies stability, which is obviously not yet the case. I frankly can't see an argument for closing this... I'm glad more targeted issue now exist, so implementation can move forward, with hopefully new discussion and focus, but I don't see a clear way to associate the compiler messages with those. Again, if this needs (or already has) a thread on internals maybe let's move this conversation there? EDIT: Or is the issue just that the book is outdated? Trying the example from the RFC (it's missing a couple
If we want to have them linked to the specific issues that would be an improvement possibly. |
This comment has been minimized.
This comment has been minimized.
nixpulvis
commented
Jan 9, 2019
|
Ok, so here should be some strong evidence for this issue remaining open. As far as I can tell this: rust/src/libsyntax/feature_gate.rs Line 194 in 6ecad33 is the only In an ideal world I believe these kinda of discussions should really be automated, since as we've discovered, people have varying opinions and ideas about how things should work. But that's really not a conversation for this thread... |
This comment has been minimized.
This comment has been minimized.
Yes, this is the correct solution, and what @Centril already suggested. The initial comment has also been edited to redirect people to the specific issues who arrive here in the "window" that @ErichDonGubler mentions. |
This comment has been minimized.
This comment has been minimized.
|
#57563 has now been opened to track the remaining unstable const features. |
varkor
referenced this issue
Jan 13, 2019
Merged
Update the const fn tracking issue to the new metabug #57564
added a commit
to Centril/rust
that referenced
this issue
Jan 13, 2019
This comment has been minimized.
This comment has been minimized.
|
Someone could edit the issue body here to prominently link to #57563 then? |
This comment has been minimized.
This comment has been minimized.
|
@glaebhoerl done :) |
nikomatsakis commentedApr 6, 2015
•
edited by Centril
#57563 | new meta tracking issue
Old content
Tracking issue for rust-lang/rfcs#911.
This issue has been closed in favor of more targeted issues:
Locals, assignments, destructuring: #48821usizecasts: #51910&mut Treferences and borrows: #57349Things to be done before stabilizing:
const unsafe fndeclaration order #29107CTFE = https://en.wikipedia.org/wiki/Compile_time_function_execution