mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 22:41:50 +00:00
Fixed confusement between mod and remainder
This commit is contained in:
parent
7919ef0ec5
commit
e02517d753
@ -335,7 +335,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
format!("cannot divide `{lhs_ty}` by `{rhs_ty}`")
|
format!("cannot divide `{lhs_ty}` by `{rhs_ty}`")
|
||||||
}
|
}
|
||||||
hir::BinOpKind::Rem => {
|
hir::BinOpKind::Rem => {
|
||||||
format!("cannot mod `{lhs_ty}` by `{rhs_ty}`")
|
format!("cannot rem `{lhs_ty}` by `{rhs_ty}`")
|
||||||
}
|
}
|
||||||
hir::BinOpKind::BitAnd => {
|
hir::BinOpKind::BitAnd => {
|
||||||
format!("no implementation for `{lhs_ty} & {rhs_ty}`")
|
format!("no implementation for `{lhs_ty} & {rhs_ty}`")
|
||||||
|
@ -545,7 +545,7 @@ div_impl_float! { f32 f64 }
|
|||||||
#[lang = "rem"]
|
#[lang = "rem"]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[rustc_on_unimplemented(
|
#[rustc_on_unimplemented(
|
||||||
message = "cannot mod `{Self}` by `{Rhs}`",
|
message = "cannot rem `{Self}` by `{Rhs}`",
|
||||||
label = "no implementation for `{Self} % {Rhs}`"
|
label = "no implementation for `{Self} % {Rhs}`"
|
||||||
)]
|
)]
|
||||||
#[doc(alias = "%")]
|
#[doc(alias = "%")]
|
||||||
@ -981,7 +981,7 @@ div_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
|
|||||||
#[lang = "rem_assign"]
|
#[lang = "rem_assign"]
|
||||||
#[stable(feature = "op_assign_traits", since = "1.8.0")]
|
#[stable(feature = "op_assign_traits", since = "1.8.0")]
|
||||||
#[rustc_on_unimplemented(
|
#[rustc_on_unimplemented(
|
||||||
message = "cannot mod-assign `{Self}` by `{Rhs}``",
|
message = "cannot rem-assign `{Self}` by `{Rhs}``",
|
||||||
label = "no implementation for `{Self} %= {Rhs}`"
|
label = "no implementation for `{Self} %= {Rhs}`"
|
||||||
)]
|
)]
|
||||||
#[doc(alias = "%")]
|
#[doc(alias = "%")]
|
||||||
|
@ -3,7 +3,7 @@ fn main() {
|
|||||||
let v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9];
|
let v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||||
let vr = v.iter().filter(|x| {
|
let vr = v.iter().filter(|x| {
|
||||||
*x % 2 == 0
|
*x % 2 == 0
|
||||||
//~^ ERROR cannot mod `&&{integer}` by `{integer}`
|
//~^ ERROR cannot rem `&&{integer}` by `{integer}`
|
||||||
});
|
});
|
||||||
println!("{:?}", vr);
|
println!("{:?}", vr);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ fn main() {
|
|||||||
let v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9];
|
let v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||||
let vr = v.iter().filter(|x| {
|
let vr = v.iter().filter(|x| {
|
||||||
x % 2 == 0
|
x % 2 == 0
|
||||||
//~^ ERROR cannot mod `&&{integer}` by `{integer}`
|
//~^ ERROR cannot rem `&&{integer}` by `{integer}`
|
||||||
});
|
});
|
||||||
println!("{:?}", vr);
|
println!("{:?}", vr);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
error[E0369]: cannot mod `&&{integer}` by `{integer}`
|
error[E0369]: cannot rem `&&{integer}` by `{integer}`
|
||||||
--> $DIR/binary-op-on-double-ref.rs:5:11
|
--> $DIR/binary-op-on-double-ref.rs:5:11
|
||||||
|
|
|
|
||||||
LL | x % 2 == 0
|
LL | x % 2 == 0
|
||||||
|
@ -11,7 +11,7 @@ fn main() {
|
|||||||
|
|
||||||
a / a; //~ ERROR cannot divide `A` by `A`
|
a / a; //~ ERROR cannot divide `A` by `A`
|
||||||
|
|
||||||
a % a; //~ ERROR cannot mod `A` by `A`
|
a % a; //~ ERROR cannot rem `A` by `A`
|
||||||
|
|
||||||
a & a; //~ ERROR no implementation for `A & A`
|
a & a; //~ ERROR no implementation for `A & A`
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ LL | struct A;
|
|||||||
note: the trait `Div` must be implemented
|
note: the trait `Div` must be implemented
|
||||||
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
|
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
|
||||||
|
|
||||||
error[E0369]: cannot mod `A` by `A`
|
error[E0369]: cannot rem `A` by `A`
|
||||||
--> $DIR/issue-28837.rs:14:7
|
--> $DIR/issue-28837.rs:14:7
|
||||||
|
|
|
|
||||||
LL | a % a;
|
LL | a % a;
|
||||||
|
Loading…
Reference in New Issue
Block a user