add track_caller for arith ops
This commit is contained in:
parent
91f7f266ce
commit
fc87d6e23d
@ -31,6 +31,7 @@ macro_rules! forward_ref_binop {
|
||||
type Output = <$t as $imp<$u>>::Output;
|
||||
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
fn $method(self, other: $u) -> <$t as $imp<$u>>::Output {
|
||||
$imp::$method(*self, other)
|
||||
}
|
||||
@ -41,6 +42,7 @@ macro_rules! forward_ref_binop {
|
||||
type Output = <$t as $imp<$u>>::Output;
|
||||
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
fn $method(self, other: &$u) -> <$t as $imp<$u>>::Output {
|
||||
$imp::$method(self, *other)
|
||||
}
|
||||
@ -51,6 +53,7 @@ macro_rules! forward_ref_binop {
|
||||
type Output = <$t as $imp<$u>>::Output;
|
||||
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
fn $method(self, other: &$u) -> <$t as $imp<$u>>::Output {
|
||||
$imp::$method(*self, *other)
|
||||
}
|
||||
@ -69,6 +72,7 @@ macro_rules! forward_ref_op_assign {
|
||||
#[$attr]
|
||||
impl $imp<&$u> for $t {
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
fn $method(&mut self, other: &$u) {
|
||||
$imp::$method(self, *other);
|
||||
}
|
||||
|
@ -98,6 +98,7 @@ macro_rules! add_impl {
|
||||
type Output = $t;
|
||||
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
#[rustc_inherit_overflow_checks]
|
||||
fn add(self, other: $t) -> $t { self + other }
|
||||
}
|
||||
@ -206,6 +207,7 @@ macro_rules! sub_impl {
|
||||
type Output = $t;
|
||||
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
#[rustc_inherit_overflow_checks]
|
||||
fn sub(self, other: $t) -> $t { self - other }
|
||||
}
|
||||
@ -335,6 +337,7 @@ macro_rules! mul_impl {
|
||||
type Output = $t;
|
||||
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
#[rustc_inherit_overflow_checks]
|
||||
fn mul(self, other: $t) -> $t { self * other }
|
||||
}
|
||||
@ -474,6 +477,7 @@ macro_rules! div_impl_integer {
|
||||
type Output = $t;
|
||||
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
fn div(self, other: $t) -> $t { self / other }
|
||||
}
|
||||
|
||||
@ -575,6 +579,7 @@ macro_rules! rem_impl_integer {
|
||||
type Output = $t;
|
||||
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
fn rem(self, other: $t) -> $t { self % other }
|
||||
}
|
||||
|
||||
@ -749,6 +754,7 @@ macro_rules! add_assign_impl {
|
||||
#[stable(feature = "op_assign_traits", since = "1.8.0")]
|
||||
impl AddAssign for $t {
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
#[rustc_inherit_overflow_checks]
|
||||
fn add_assign(&mut self, other: $t) { *self += other }
|
||||
}
|
||||
@ -815,6 +821,7 @@ macro_rules! sub_assign_impl {
|
||||
#[stable(feature = "op_assign_traits", since = "1.8.0")]
|
||||
impl SubAssign for $t {
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
#[rustc_inherit_overflow_checks]
|
||||
fn sub_assign(&mut self, other: $t) { *self -= other }
|
||||
}
|
||||
@ -872,6 +879,7 @@ macro_rules! mul_assign_impl {
|
||||
#[stable(feature = "op_assign_traits", since = "1.8.0")]
|
||||
impl MulAssign for $t {
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
#[rustc_inherit_overflow_checks]
|
||||
fn mul_assign(&mut self, other: $t) { *self *= other }
|
||||
}
|
||||
@ -929,6 +937,7 @@ macro_rules! div_assign_impl {
|
||||
#[stable(feature = "op_assign_traits", since = "1.8.0")]
|
||||
impl DivAssign for $t {
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
fn div_assign(&mut self, other: $t) { *self /= other }
|
||||
}
|
||||
|
||||
@ -989,6 +998,7 @@ macro_rules! rem_assign_impl {
|
||||
#[stable(feature = "op_assign_traits", since = "1.8.0")]
|
||||
impl RemAssign for $t {
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
fn rem_assign(&mut self, other: $t) { *self %= other }
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
let mut _3: u8;
|
||||
scope 1 {
|
||||
}
|
||||
scope 2 (inlined <u8 as Add>::add) {
|
||||
scope 2 (inlined #[track_caller] <u8 as Add>::add) {
|
||||
debug self => _2;
|
||||
debug other => _3;
|
||||
let mut _4: (u8, bool);
|
||||
|
@ -8,7 +8,7 @@
|
||||
let mut _3: u8;
|
||||
scope 1 {
|
||||
}
|
||||
scope 2 (inlined <u8 as Add>::add) {
|
||||
scope 2 (inlined #[track_caller] <u8 as Add>::add) {
|
||||
debug self => _2;
|
||||
debug other => _3;
|
||||
let mut _4: (u8, bool);
|
||||
|
@ -8,7 +8,7 @@
|
||||
let mut _3: u8;
|
||||
scope 1 {
|
||||
}
|
||||
scope 2 (inlined <u8 as Add>::add) {
|
||||
scope 2 (inlined #[track_caller] <u8 as Add>::add) {
|
||||
debug self => _2;
|
||||
debug other => _3;
|
||||
let mut _4: (u8, bool);
|
||||
|
@ -8,7 +8,7 @@
|
||||
let mut _3: u8;
|
||||
scope 1 {
|
||||
}
|
||||
scope 2 (inlined <u8 as Add>::add) {
|
||||
scope 2 (inlined #[track_caller] <u8 as Add>::add) {
|
||||
debug self => _2;
|
||||
debug other => _3;
|
||||
let mut _4: (u8, bool);
|
||||
|
@ -0,0 +1,8 @@
|
||||
// run-fail
|
||||
// ignore-wasm32
|
||||
// error-pattern:location-add-assign-overflow.rs
|
||||
|
||||
fn main() {
|
||||
let mut a: u8 = 255;
|
||||
a += &1;
|
||||
}
|
7
tests/ui/numbers-arithmetic/location-add-overflow.rs
Normal file
7
tests/ui/numbers-arithmetic/location-add-overflow.rs
Normal file
@ -0,0 +1,7 @@
|
||||
// run-fail
|
||||
// ignore-wasm32
|
||||
// error-pattern:location-add-overflow.rs
|
||||
|
||||
fn main() {
|
||||
let _: u8 = 255 + &1;
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
// run-fail
|
||||
// ignore-wasm32
|
||||
// error-pattern:location-divide-assign-by-zero.rs
|
||||
|
||||
fn main() {
|
||||
let mut a = 1;
|
||||
a /= &0;
|
||||
}
|
9
tests/ui/numbers-arithmetic/location-divide-by-zero.rs
Normal file
9
tests/ui/numbers-arithmetic/location-divide-by-zero.rs
Normal file
@ -0,0 +1,9 @@
|
||||
// run-fail
|
||||
// ignore-wasm32
|
||||
// error-pattern:location-divide-by-zero.rs
|
||||
|
||||
// https://github.com/rust-lang/rust/issues/114814
|
||||
|
||||
fn main() {
|
||||
let _ = 1 / &0;
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
// run-fail
|
||||
// ignore-wasm32
|
||||
// error-pattern:location-mod-assign-by-zero.rs
|
||||
|
||||
fn main() {
|
||||
let mut a = 1;
|
||||
a %= &0;
|
||||
}
|
7
tests/ui/numbers-arithmetic/location-mod-by-zero.rs
Normal file
7
tests/ui/numbers-arithmetic/location-mod-by-zero.rs
Normal file
@ -0,0 +1,7 @@
|
||||
// run-fail
|
||||
// ignore-wasm32
|
||||
// error-pattern:location-mod-by-zero.rs
|
||||
|
||||
fn main() {
|
||||
let _ = 1 % &0;
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
// run-fail
|
||||
// ignore-wasm32
|
||||
// error-pattern:location-mul-assign-overflow.rs
|
||||
|
||||
fn main() {
|
||||
let mut a: u8 = 255;
|
||||
a *= &2;
|
||||
}
|
7
tests/ui/numbers-arithmetic/location-mul-overflow.rs
Normal file
7
tests/ui/numbers-arithmetic/location-mul-overflow.rs
Normal file
@ -0,0 +1,7 @@
|
||||
// run-fail
|
||||
// ignore-wasm32
|
||||
// error-pattern:location-mul-overflow.rs
|
||||
|
||||
fn main() {
|
||||
let _: u8 = 255 * &2;
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
// run-fail
|
||||
// ignore-wasm32
|
||||
// error-pattern:location-sub-assign-overflow.rs
|
||||
|
||||
fn main() {
|
||||
let mut a: u8 = 0;
|
||||
a -= &1;
|
||||
}
|
7
tests/ui/numbers-arithmetic/location-sub-overflow.rs
Normal file
7
tests/ui/numbers-arithmetic/location-sub-overflow.rs
Normal file
@ -0,0 +1,7 @@
|
||||
// run-fail
|
||||
// ignore-wasm32
|
||||
// error-pattern:location-sub-overflow.rs
|
||||
|
||||
fn main() {
|
||||
let _: u8 = 0 - &1;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user