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

Remove floating point modulus as a built-in operation; relegate it to the libraries #12278

Closed
brson opened this issue Feb 14, 2014 · 5 comments
Closed
Milestone

Comments

@brson
Copy link
Contributor

brson commented Feb 14, 2014

Floating point modulus is rarely used, doesn't exist in C, and is always lowered to an fmod library call. LLVM is considering removing support entirely. Nominating.

@thestinger
Copy link
Contributor

I don't think it should be removed if it can be well-defined and is sometimes useful. The modulus operator can be overloaded in a library anyway, so whether or not it's built-in to the compiler only changes constant evaluation since CTFE isn't part of Rust.

@pcwalton
Copy link
Contributor

I highly doubt anyone will notice it gone. I don't think we should be making design decisions to keep obscure features based on CTFE concerns. For example, sqrt is far more useful than fmod; do we want to build sqrt into the language too so that constants can use it?

@thestinger
Copy link
Contributor

I don't care whether or not it's built-in to the language. I just don't want it completely removed as the bessel functions were. It's absolutely trivial to support it and the API design is very clear cut.

@huonw
Copy link
Member

huonw commented Feb 14, 2014

I'd like to at least have the operator overloaded by the traits even if it's not directly in the compiler, e.g. Python offers it

>>> 1.5 % 0.4
0.29999999999999993

@pnkfelix
Copy link
Member

Accepted for P-backcompat-lang, 1.0.

@pnkfelix pnkfelix added this to the 1.0 milestone Feb 27, 2014
bors added a commit that referenced this issue Apr 20, 2014
This commit removes the compiler support for floating point modulus operations,
as well as from the language. An implementation for this operator is now
required to be provided by libraries.

Floating point modulus is rarely used, doesn't exist in C, and is always lowered
to an fmod library call by LLVM, and LLVM is considering removing support
entirely.

Closes #12278
flip1995 pushed a commit to flip1995/rust that referenced this issue Feb 26, 2024
[`mem_replace_with_default`] No longer triggers on unused expression

changelog:[`mem_replace_with_default`]: No longer triggers on unused expression

Change [`mem_replace_with_default`] to not trigger on unused expression because the lint from `#[must_use]` handle this case better.

fixes: rust-lang#5586
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 a pull request may close this issue.

5 participants