Skip to content
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

Simplify std::num::Primitive trait definition #11622

Closed

Conversation

brendanzab
Copy link
Member

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 BYTESstatics 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 Implement compile time function evaluation (CTFE) #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 Ability to specify self parameter in static method call #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.
@brson
Copy link
Contributor

brson commented Jan 17, 2014

Does Primitive serve any useful purpose now? It's pretty similar to Pod.

@brendanzab
Copy link
Member Author

Not sure. We could remove it yes.

bors added a commit that referenced this pull request Jan 18, 2014
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.
@bors bors closed this Jan 18, 2014
@brendanzab brendanzab deleted the simplify-primitive-trait branch January 18, 2014 15:21
flip1995 pushed a commit to flip1995/rust that referenced this pull request Oct 21, 2023
…ut-regression-test-11610, r=blyxyas

Add regression test for rust-lang#11610 about mutable usage of argument in async function for the `needless_pass_by_ref_mut` lint

Fixes rust-lang/rust-clippy#11610.

This was already fixed. I simply added a regression test.

changelog: Add regression test for rust-lang#11610 about mutable usage of argument in async function for the `needless_pass_by_ref_mut` lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants