Skip to content

wrapping_rem methods should document panic-on-zero #116063

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
yoshuawuyts opened this issue Sep 22, 2023 · 2 comments
Closed

wrapping_rem methods should document panic-on-zero #116063

yoshuawuyts opened this issue Sep 22, 2023 · 2 comments
Assignees
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools Libs-Small Libs issues that are considered "small" or self-contained T-libs Relevant to the library team, which will review and decide on the PR/issue.

Comments

@yoshuawuyts
Copy link
Member

yoshuawuyts commented Sep 22, 2023

Location

All wrapping_rem methods.

Summary

As reported in yoshuawuyts/futures-concurrency#156, when calling the wrapping_rem functions with a value of 0, a panic is triggered. The documentation of the wrapping_rem method should include a # panic section making note of this.

Example

playground

100usize.wrapping_rem(0);
thread 'main' panicked at 'attempt to calculate the remainder with a divisor of zero',
@yoshuawuyts yoshuawuyts added the A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools label Sep 22, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 22, 2023
@saethlin saethlin added T-libs Relevant to the library team, which will review and decide on the PR/issue. Libs-Small Libs issues that are considered "small" or self-contained and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Sep 22, 2023
@Colonial-Dev
Copy link
Contributor

Colonial-Dev commented Sep 22, 2023

It seems that this is correctly documented for the signed integer types, but not the unsigned ones. So a quick copy-paste should be sufficient.

@Colonial-Dev
Copy link
Contributor

@rustbot claim

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Sep 23, 2023
…ark-Simulacrum

Document panics on unsigned wrapping_div/rem calls (rust-lang#116063)

Add missing `# Panics` sections to the `uint_impl!` macro, documenting that the `wrapping_rem/div` calls will panic if passed zero.
bors added a commit to rust-lang-ci/rust that referenced this issue Sep 24, 2023
…iaskrgr

Rollup of 5 pull requests

Successful merges:

 - rust-lang#115794 (Do not create a DerefLen place for `Box<[T]>`.)
 - rust-lang#116069 (Fix debug printing of tuple)
 - rust-lang#116075 (Document panics on unsigned wrapping_div/rem calls (rust-lang#116063))
 - rust-lang#116076 (Add Zba, Zbb, and Zbs as target features for riscv64-linux-android)
 - rust-lang#116078 (Add assembly test to make sure that inlining works as expected when closures inherit target features)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this issue Sep 24, 2023
…k-Simulacrum

Document panics on unsigned wrapping_div/rem calls (rust-lang#116063)

Add missing `# Panics` sections to the `uint_impl!` macro, documenting that the `wrapping_rem/div` calls will panic if passed zero.
@bors bors closed this as completed in 1170b7b Sep 24, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools Libs-Small Libs issues that are considered "small" or self-contained T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants