Skip to content

Commit 7ebdbc5

Browse files
authored
Rollup merge of #107389 - zvavybir:master, r=estebank
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.
2 parents 9e23690 + a859159 commit 7ebdbc5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

core/src/ops/arith.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ div_impl_float! { f32 f64 }
545545
#[lang = "rem"]
546546
#[stable(feature = "rust1", since = "1.0.0")]
547547
#[rustc_on_unimplemented(
548-
message = "cannot mod `{Self}` by `{Rhs}`",
548+
message = "cannot calculate the remainder of `{Self}` divided by `{Rhs}`",
549549
label = "no implementation for `{Self} % {Rhs}`"
550550
)]
551551
#[doc(alias = "%")]
@@ -981,7 +981,7 @@ div_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
981981
#[lang = "rem_assign"]
982982
#[stable(feature = "op_assign_traits", since = "1.8.0")]
983983
#[rustc_on_unimplemented(
984-
message = "cannot mod-assign `{Self}` by `{Rhs}``",
984+
message = "cannot calculate and assign the remainder of `{Self}` divided by `{Rhs}`",
985985
label = "no implementation for `{Self} %= {Rhs}`"
986986
)]
987987
#[doc(alias = "%")]

0 commit comments

Comments
 (0)