Skip to content

Commit 8d7b092

Browse files
author
Matthias Kaak
committed
Improved wording of error messages of missing remainder implementations
1 parent e02517d commit 8d7b092

File tree

7 files changed

+8
-8
lines changed

7 files changed

+8
-8
lines changed

compiler/rustc_hir_typeck/src/op.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
335335
format!("cannot divide `{lhs_ty}` by `{rhs_ty}`")
336336
}
337337
hir::BinOpKind::Rem => {
338-
format!("cannot rem `{lhs_ty}` by `{rhs_ty}`")
338+
format!("cannot calculate the remainder of `{lhs_ty}` divided by `{rhs_ty}`")
339339
}
340340
hir::BinOpKind::BitAnd => {
341341
format!("no implementation for `{lhs_ty} & {rhs_ty}`")

library/core/src/ops/arith.rs

+2-2
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 rem `{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 rem-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 = "%")]

tests/ui/binop/binary-op-on-double-ref.fixed

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ fn main() {
33
let v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9];
44
let vr = v.iter().filter(|x| {
55
*x % 2 == 0
6-
//~^ ERROR cannot rem `&&{integer}` by `{integer}`
6+
//~^ ERROR cannot calculate the remainder of `&&{integer}` divided by `{integer}`
77
});
88
println!("{:?}", vr);
99
}

tests/ui/binop/binary-op-on-double-ref.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ fn main() {
33
let v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9];
44
let vr = v.iter().filter(|x| {
55
x % 2 == 0
6-
//~^ ERROR cannot rem `&&{integer}` by `{integer}`
6+
//~^ ERROR cannot calculate the remainder of `&&{integer}` divided by `{integer}`
77
});
88
println!("{:?}", vr);
99
}

tests/ui/binop/binary-op-on-double-ref.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0369]: cannot rem `&&{integer}` by `{integer}`
1+
error[E0369]: cannot calculate the remainder of `&&{integer}` divided by `{integer}`
22
--> $DIR/binary-op-on-double-ref.rs:5:11
33
|
44
LL | x % 2 == 0

tests/ui/binop/issue-28837.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ fn main() {
1111

1212
a / a; //~ ERROR cannot divide `A` by `A`
1313

14-
a % a; //~ ERROR cannot rem `A` by `A`
14+
a % a; //~ ERROR cannot calculate the remainder of `A` divided by `A`
1515

1616
a & a; //~ ERROR no implementation for `A & A`
1717

tests/ui/binop/issue-28837.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ LL | struct A;
6262
note: the trait `Div` must be implemented
6363
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
6464

65-
error[E0369]: cannot rem `A` by `A`
65+
error[E0369]: cannot calculate the remainder of `A` divided by `A`
6666
--> $DIR/issue-28837.rs:14:7
6767
|
6868
LL | a % a;

0 commit comments

Comments
 (0)