-
Notifications
You must be signed in to change notification settings - Fork 146
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
Rust: const fn
support
#1955
Comments
The PR has been merged, and the fiat-crypto emitted code should be valid under I guess for now I can just do find/replace on the generated code, but first-class support would be great. |
Rust 1.83.0-beta.1 has been released with stabilized support for |
If I understand correctly, simply replacing fiat-crypto/src/Stringification/Rust.v Line 395 in 58481a8
will do the trick. I'm a bit short on time, but if you prepare a PR, updating both this line and the generated files (either by find/replace, or by downloading the artifacts that the CI generates), I'd be happy to merge it. Do we need to update any Rust version constraints anywhere? |
Great, thanks! If you do accept this change, the generated code will only work under Rust 1.83, which is quite a jump. If there's some way to make it optional, it might make sense for the immediate future, so older Rust versions can still be supported. I can also do find/replace to make use of it in const contexts for the time being. |
Is there any way to make the generated code condition on Rust version, a la C/C++ preprocessor macros? If not, the crates package will still need to pick a single version to be compatible with, and I imagine most of the users of the Rust codegen use it via the crate. Users of older Rusts can still (I presume?) get the older versions of the crates package, and users who want the older codegen can still download previous releases. Fiat Crypto development itself is not moving particularly quickly, so I imagine the use case of "old Rust version, new Fiat Crypto features" will be quite niche. Still, if you (or anyone else) is interested in putting in the work to make it optional, I'd accept a PR adding threading through a Line 387 in 58481a8
(and perhaps then inline and static and const should be merged into a "function declaration options" type class a la fiat-crypto/src/Stringification/Language.v Line 156 in 58481a8
If you want to do this and any of the control flow is unclear, let me know and I can clarify. |
Not really for this particular case. Every function definition would have to be duplicated to make that work, and at that point, a toggle seems in order.
Sounds good! |
Note that since the code is autogenerated, this should actually be pretty easy to implement. fiat-crypto/src/Stringification/Rust.v Lines 390 to 397 in 58481a8
is responsible for emitting the entire function (except for docstring, which is added at fiat-crypto/src/Stringification/Rust.v Lines 425 to 434 in 58481a8
|
This is a (perhaps a bit early) request to at least optionally generate Rust source code use
const fn
instead offn
.Though current stable Rust doesn't support the use of mutable references in
const fn
, that's about to change with this stabilization PR: rust-lang/rust#129195Once that PR lands, the existing emitted Rust code should be valid under
const fn
.The text was updated successfully, but these errors were encountered: