-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Fixing confusion between mod and remainder #107389
Conversation
r? @estebank (rustbot has picked a reviewer for you, use r? to override) |
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
compiler/rustc_hir_typeck/src/op.rs
Outdated
@@ -335,7 +335,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { | |||
format!("cannot divide `{lhs_ty}` by `{rhs_ty}`") | |||
} | |||
hir::BinOpKind::Rem => { | |||
format!("cannot mod `{lhs_ty}` by `{rhs_ty}`") | |||
format!("cannot rem `{lhs_ty}` by `{rhs_ty}`") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, let's expand the wording here to make it even clearer (feel free to change the wording further), here and elsewhere
format!("cannot rem `{lhs_ty}` by `{rhs_ty}`") | |
format!("cannot calculate the remainder of `{lhs_ty}` divided by `{rhs_ty}`") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, fixed it.
@bors r+ |
Fixing confusion between mod and remainder Like many programming languages, rust too confuses remainder and modulus. The `%` operator and the associated `Rem` trait is (as the trait name suggests) the remainder, but since most people are linguistically more familiar with the modulus the documentation sometimes claims otherwise. This PR tries to fix this problem in rustc.
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#107389 (Fixing confusion between mod and remainder) - rust-lang#107442 (improve panic message for slice windows and chunks) - rust-lang#107470 (Small bootstrap improvements) - rust-lang#107487 (Make the "extra if in let...else block" hint a suggestion) - rust-lang#107499 (Do not depend on Generator trait when deducing closure signature) - rust-lang#107533 (Extend `-Z print-type-sizes` to distinguish generator upvars+locals from "normal" fields.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Like many programming languages, rust too confuses remainder and modulus. The
%
operator and the associatedRem
trait is (as the trait name suggests) the remainder, but since most people are linguistically more familiar with the modulus the documentation sometimes claims otherwise. This PR tries to fix this problem in rustc.