Some rounding methods in float types (namely trunc
, floor
, ceil
, round
, and round_ties_even
) could probably be made const
, but they currently aren't.
I read Tracking issue for `#![feature(const_fn_floating_point_arithmetic)]` · Issue #57241 · rust-lang/rust · GitHub and many of the issues linked in it, but I did not find a reason for those methods not to be const
. For example, abs
, min
and max
became const
in Make some float methods unstable `const fn` · rust-lang/rust@c09ed3e · GitHub.
If the answer is simply "because no one took the time to implement that", then I'd like to volunteer.
(I'm sorry if this is the wrong forum to post this - could you please point me to the right place?)
3 Likes
Indeed, that's what it is.
In fact they are all already implemented in Miri:
So that would mostly just have to be moved over to compiler/rustc_const_eval/src/interpret/intrinsics.rs
in the compiler.
Definitely feel free to give it a shot. 
2 Likes
Thank you very much for the pointer here! I'm very happy to have opened my first PR contributing code to the Rust project: feat: add `const` support for float rounding methods by ruancomelli · Pull Request #141521 · rust-lang/rust · GitHub 
2 Likes