-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Implement compile time function evaluation (CTFE) #11621
Comments
This removes the `Primitive::{bits, bytes, is_signed}` methods and removes the operator trait constraints, for the reasons outlined below: - The `Primitive::{bits, bytes}` associated functions were originally added to reflect the existing `BITS` and `BYTES` statics included in the numeric modules. These statics are only exist as a workaround for Rust's lack of CTFE, and should probably be deprecated in the future in favor of using the `std::mem::size_of` function (see rust-lang#11621). - `Primitive::is_signed` seems to be of little utility and does not seem to be used anywhere in the Rust compiler or libraries. It is also rather ugly to call due to the `Option<Self>` workaround for rust-lang#8888. - The operator trait constraints are already covered by the `Num` trait.
As part of #10387, this removes the `Primitive::{bits, bytes, is_signed}` methods and removes the trait's operator trait constraints for the reasons outlined below: - The `Primitive::{bits, bytes}` associated functions were originally added to reflect the existing `BITS` and `BYTES`statics included in the numeric modules. These statics are only exist as a workaround for Rust's lack of CTFE, and should be deprecated in the future in favor of using the `std::mem::size_of` function (see #11621). - `Primitive::is_signed` seems to be of little utility and does not seem to be used anywhere in the Rust compiler or libraries. It is also rather ugly to call due to the `Option<Self>` workaround for #8888. - The operator trait constraints are already covered by the `Num` trait.
This removes the `Primitive::{bits, bytes, is_signed}` methods and removes the operator trait constraints, for the reasons outlined below: - The `Primitive::{bits, bytes}` associated functions were originally added to reflect the existing `BITS` and `BYTES` statics included in the numeric modules. These statics are only exist as a workaround for Rust's lack of CTFE, and should probably be deprecated in the future in favor of using the `std::mem::size_of` function (see rust-lang#11621). - `Primitive::is_signed` seems to be of little utility and does not seem to be used anywhere in the Rust compiler or libraries. It is also rather ugly to call due to the `Option<Self>` workaround for rust-lang#8888. - The operator trait constraints are already covered by the `Num` trait.
Nominating. The "P-backcompat-lang" should be removed. CTFE is a post-1.0, backwards-compatible feature. |
Re-assigning as P-low Also, as something that really would require an RFC, we may want to move it to an issue on that repo, depending on what policy we decide on there. Cc @brson |
@nick29581 Should this be moved to rust-lang/rfcs? (There is already rust-lang/rfcs#322 though.) |
Closing in favour of rust-lang/rfcs#322 |
…ut-closure-non-async-fn, r=blyxyas Needless pass by ref mut closure non async fn Fixes rust-lang/rust-clippy#11620. Fixes rust-lang/rust-clippy#11561. changelog: [`needless_pass_by_ref_mut`]: Correctly handle arguments moved into closure in non-async functions. r? `@Centri3`
This is a big gap in Rust's current support of zero cost abstractions, and something that puts us behind languages such as D or C++. This would for example allow us to deprecate the
std::uint::{bits, bytes}
statics in favor of using thestd::mem::size_of
function. It would also allow for the use of overloaded operators in constexprs, which would in turn allow us implement the base numeric arithmetic operators within the standard library, as opposed to relying on compiler magic (see #11526).The text was updated successfully, but these errors were encountered: